Files
dotter/resources/js/components/ui/input-otp/context.ts
T
salam e687b4437b
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s
first commit
2026-10-06 18:53:03 +02:00

19 lines
475 B
TypeScript

import { getContext, setContext } from 'svelte';
export const INPUT_OTP_CONTEXT = Symbol('input-otp');
export type InputOTPContext = {
value: () => string;
activeIndex: () => number;
isFocused: () => boolean;
focus: () => void;
};
export function setInputOTPContext(ctx: InputOTPContext): void {
setContext(INPUT_OTP_CONTEXT, ctx);
}
export function getInputOTPContext(): InputOTPContext {
return getContext<InputOTPContext>(INPUT_OTP_CONTEXT);
}