This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
@@ -0,0 +1,36 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { PinInputCellProps } from "../types.js";
import { PinInputCellState } from "../pin-input.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
cell,
child,
children,
...restProps
}: PinInputCellProps = $props();
const cellState = PinInputCellState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
cell: boxWith(() => cell),
});
const mergedProps = $derived(mergeProps(restProps, cellState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { PinInputCellProps } from "../types.js";
declare const PinInputCell: import("svelte").Component<PinInputCellProps, {}, "ref">;
type PinInputCell = ReturnType<typeof PinInputCell>;
export default PinInputCell;
+66
View File
@@ -0,0 +1,66 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { PinInputRootProps } from "../types.js";
import { PinInputRootState } from "../pin-input.svelte.js";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
id = createId(uid),
inputId = `${createId(uid)}-input`,
ref = $bindable(null),
maxlength = 6,
textalign = "left",
pattern,
inputmode = "numeric",
onComplete = noop,
pushPasswordManagerStrategy = "increase-width",
class: containerClass = "",
children,
autocomplete = "one-time-code",
disabled = false,
value = $bindable(""),
onValueChange = noop,
pasteTransformer,
...restProps
}: PinInputRootProps = $props();
const rootState = PinInputRootState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
inputId: boxWith(() => inputId),
autocomplete: boxWith(() => autocomplete),
maxLength: boxWith(() => maxlength),
textAlign: boxWith(() => textalign),
disabled: boxWith(() => disabled),
inputmode: boxWith(() => inputmode),
pattern: boxWith(() => pattern),
onComplete: boxWith(() => onComplete),
value: boxWith(
() => value,
(v) => {
value = v;
onValueChange(v);
}
),
pushPasswordManagerStrategy: boxWith(() => pushPasswordManagerStrategy),
pasteTransformer: boxWith(() => pasteTransformer),
});
const mergedInputProps = $derived(mergeProps(restProps, rootState.inputProps));
const mergedRootProps = $derived(mergeProps(rootState.rootProps, { class: containerClass }));
const mergedInputWrapperProps = $derived(mergeProps(rootState.inputWrapperProps, {}));
</script>
<div {...mergedRootProps}>
{@render children?.(rootState.snippetProps)}
<div {...mergedInputWrapperProps}>
<input {...mergedInputProps} />
</div>
</div>
@@ -0,0 +1,4 @@
import type { PinInputRootProps } from "../types.js";
declare const PinInput: import("svelte").Component<PinInputRootProps, {}, "value" | "ref">;
type PinInput = ReturnType<typeof PinInput>;
export default PinInput;