@zentauri-ui/zentauri-components 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/cli/registry.json +2 -0
- package/dist/chunk-KEKMMNL5.mjs +600 -0
- package/dist/chunk-KEKMMNL5.mjs.map +1 -0
- package/dist/chunk-NZDHSIIC.js +616 -0
- package/dist/chunk-NZDHSIIC.js.map +1 -0
- package/dist/design-system/command.d.ts +41 -0
- package/dist/design-system/command.d.ts.map +1 -0
- package/dist/design-system/index.d.ts +2 -0
- package/dist/design-system/index.d.ts.map +1 -1
- package/dist/design-system/otp-input.d.ts +27 -0
- package/dist/design-system/otp-input.d.ts.map +1 -0
- package/dist/ui/command/animated/animations.d.ts +3 -0
- package/dist/ui/command/animated/animations.d.ts.map +1 -0
- package/dist/ui/command/animated/command-content-animated.d.ts +6 -0
- package/dist/ui/command/animated/command-content-animated.d.ts.map +1 -0
- package/dist/ui/command/animated/index.d.ts +4 -0
- package/dist/ui/command/animated/index.d.ts.map +1 -0
- package/dist/ui/command/animated/types.d.ts +9 -0
- package/dist/ui/command/animated/types.d.ts.map +1 -0
- package/dist/ui/command/animated.js +92 -0
- package/dist/ui/command/animated.js.map +1 -0
- package/dist/ui/command/animated.mjs +89 -0
- package/dist/ui/command/animated.mjs.map +1 -0
- package/dist/ui/command/command-base.d.ts +53 -0
- package/dist/ui/command/command-base.d.ts.map +1 -0
- package/dist/ui/command/command.d.ts +6 -0
- package/dist/ui/command/command.d.ts.map +1 -0
- package/dist/ui/command/index.d.ts +5 -0
- package/dist/ui/command/index.d.ts.map +1 -0
- package/dist/ui/command/types.d.ts +111 -0
- package/dist/ui/command/types.d.ts.map +1 -0
- package/dist/ui/command/variants.d.ts +15 -0
- package/dist/ui/command/variants.d.ts.map +1 -0
- package/dist/ui/command.js +69 -0
- package/dist/ui/command.js.map +1 -0
- package/dist/ui/command.mjs +16 -0
- package/dist/ui/command.mjs.map +1 -0
- package/dist/ui/otp-input/index.d.ts +4 -0
- package/dist/ui/otp-input/index.d.ts.map +1 -0
- package/dist/ui/otp-input/otp-input.d.ts +6 -0
- package/dist/ui/otp-input/otp-input.d.ts.map +1 -0
- package/dist/ui/otp-input/types.d.ts +23 -0
- package/dist/ui/otp-input/types.d.ts.map +1 -0
- package/dist/ui/otp-input/variants.d.ts +5 -0
- package/dist/ui/otp-input/variants.d.ts.map +1 -0
- package/dist/ui/otp-input.js +302 -0
- package/dist/ui/otp-input.js.map +1 -0
- package/dist/ui/otp-input.mjs +299 -0
- package/dist/ui/otp-input.mjs.map +1 -0
- package/package.json +1 -1
- package/src/design-system/command.ts +80 -0
- package/src/design-system/index.ts +2 -0
- package/src/design-system/otp-input.ts +50 -0
- package/src/ui/command/animated/animations.ts +29 -0
- package/src/ui/command/animated/command-content-animated.tsx +58 -0
- package/src/ui/command/animated/index.ts +10 -0
- package/src/ui/command/animated/types.ts +23 -0
- package/src/ui/command/command-base.tsx +660 -0
- package/src/ui/command/command.test.tsx +130 -0
- package/src/ui/command/command.tsx +8 -0
- package/src/ui/command/index.ts +34 -0
- package/src/ui/command/types.ts +129 -0
- package/src/ui/command/variants.ts +41 -0
- package/src/ui/otp-input/index.ts +9 -0
- package/src/ui/otp-input/otp-input.test.tsx +99 -0
- package/src/ui/otp-input/otp-input.tsx +327 -0
- package/src/ui/otp-input/types.ts +32 -0
- package/src/ui/otp-input/variants.ts +18 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { CSSProperties, ReactNode, Ref, RefObject } from "react";
|
|
3
|
+
import type { commandContentVariants } from "./variants";
|
|
4
|
+
export type CommandContentVariantProps = VariantProps<typeof commandContentVariants>;
|
|
5
|
+
export type CommandProps = {
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/**
|
|
10
|
+
* When set, binds a global shortcut that toggles the palette: this key plus
|
|
11
|
+
* meta (⌘) or ctrl. Defaults to "k" when `hotkey` is `true`.
|
|
12
|
+
*/
|
|
13
|
+
hotkey?: string | boolean;
|
|
14
|
+
/** Accessible label for the dialog. */
|
|
15
|
+
label?: string;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
export type CommandTriggerProps = {
|
|
19
|
+
className?: string;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
ref?: Ref<HTMLButtonElement>;
|
|
22
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
23
|
+
};
|
|
24
|
+
export type CommandContentProps = CommandContentVariantProps & {
|
|
25
|
+
className?: string;
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
ref?: Ref<HTMLDivElement>;
|
|
28
|
+
id?: string;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
};
|
|
31
|
+
export type CommandInputProps = {
|
|
32
|
+
className?: string;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
ref?: Ref<HTMLInputElement>;
|
|
35
|
+
};
|
|
36
|
+
export type CommandListProps = {
|
|
37
|
+
className?: string;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
};
|
|
40
|
+
export type CommandGroupProps = {
|
|
41
|
+
className?: string;
|
|
42
|
+
heading?: ReactNode;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
};
|
|
45
|
+
export type CommandItemProps = {
|
|
46
|
+
className?: string;
|
|
47
|
+
/** Stable identifier used for filtering, keyboard nav, and onSelect. */
|
|
48
|
+
value: string;
|
|
49
|
+
/** Extra terms used by the filter in addition to the rendered text. */
|
|
50
|
+
keywords?: string[];
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
onSelect?: (value: string) => void;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
};
|
|
55
|
+
export type CommandSectionProps = {
|
|
56
|
+
className?: string;
|
|
57
|
+
children?: ReactNode;
|
|
58
|
+
};
|
|
59
|
+
export type ItemMeta = {
|
|
60
|
+
keywords?: string[];
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
onSelect?: (value: string) => void;
|
|
63
|
+
searchText?: string;
|
|
64
|
+
};
|
|
65
|
+
export type RegisteredItem = {
|
|
66
|
+
value: string;
|
|
67
|
+
metaRef: RefObject<ItemMeta>;
|
|
68
|
+
};
|
|
69
|
+
export type CommandCtx = {
|
|
70
|
+
open: boolean;
|
|
71
|
+
setOpen: (next: boolean) => void;
|
|
72
|
+
labelId: string;
|
|
73
|
+
listId: string;
|
|
74
|
+
query: string;
|
|
75
|
+
setQuery: (next: string) => void;
|
|
76
|
+
activeValue: string | null;
|
|
77
|
+
setActiveValue: (next: string | null) => void;
|
|
78
|
+
visibleValues: string[];
|
|
79
|
+
isVisible: (value: string) => boolean;
|
|
80
|
+
registerItem: (item: RegisteredItem) => () => void;
|
|
81
|
+
invalidateRegistry: () => void;
|
|
82
|
+
selectValue: (value: string) => boolean;
|
|
83
|
+
contentRef: RefObject<HTMLDivElement | null>;
|
|
84
|
+
triggerRef: RefObject<HTMLElement | null>;
|
|
85
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
86
|
+
};
|
|
87
|
+
export type CommandContentOverlayRenderProps = {
|
|
88
|
+
role: "presentation";
|
|
89
|
+
"data-slot": "command-overlay";
|
|
90
|
+
className: string;
|
|
91
|
+
onClick: () => void;
|
|
92
|
+
};
|
|
93
|
+
export type CommandContentPanelRenderProps = {
|
|
94
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
95
|
+
role: "dialog";
|
|
96
|
+
"aria-modal": true;
|
|
97
|
+
"aria-labelledby": string;
|
|
98
|
+
"data-slot": "command-content";
|
|
99
|
+
tabIndex: -1;
|
|
100
|
+
className: string;
|
|
101
|
+
id?: string;
|
|
102
|
+
style?: CommandContentProps["style"];
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
};
|
|
105
|
+
export type CommandContentLayerProps = CommandContentProps & {
|
|
106
|
+
componentName: string;
|
|
107
|
+
renderPresence?: (children: ReactNode) => ReactNode;
|
|
108
|
+
renderOverlay?: (props: CommandContentOverlayRenderProps) => ReactNode;
|
|
109
|
+
renderPanel?: (props: CommandContentPanelRenderProps) => ReactNode;
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ui/command/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const commandOverlayVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const commandTriggerVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const commandContentVariants: (props?: ({
|
|
4
|
+
size?: "md" | "sm" | "lg" | null | undefined;
|
|
5
|
+
appearance?: "default" | "glass" | "sky" | "emerald" | "violet" | "amber" | "rose" | "gray" | "indigo" | "orange" | "pink" | "purple" | "teal" | "yellow" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export declare const commandInputRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
8
|
+
export declare const commandInputVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
9
|
+
export declare const commandListVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
10
|
+
export declare const commandGroupHeadingVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
11
|
+
export declare const commandItemVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
12
|
+
export declare const commandSeparatorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
13
|
+
export declare const commandEmptyVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
14
|
+
export declare const commandFooterVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
15
|
+
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/ui/command/variants.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,sBAAsB,oFAA6B,CAAC;AAEjE,eAAO,MAAM,sBAAsB,oFAA6B,CAAC;AAEjE,eAAO,MAAM,sBAAsB;;;8EASjC,CAAC;AAEH,eAAO,MAAM,uBAAuB,oFAA8B,CAAC;AACnE,eAAO,MAAM,oBAAoB,oFAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,oFAA0B,CAAC;AAC3D,eAAO,MAAM,2BAA2B,oFAAkC,CAAC;AAC3E,eAAO,MAAM,mBAAmB,oFAA0B,CAAC;AAC3D,eAAO,MAAM,wBAAwB,oFAA+B,CAAC;AACrE,eAAO,MAAM,oBAAoB,oFAA2B,CAAC;AAC7D,eAAO,MAAM,qBAAqB,oFAA4B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkNZDHSIIC_js = require('../chunk-NZDHSIIC.js');
|
|
5
|
+
require('../chunk-GBWGVNDA.js');
|
|
6
|
+
require('../chunk-UIYFEP3I.js');
|
|
7
|
+
require('../chunk-ZS5756ZC.js');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
var Command2 = (props) => {
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkNZDHSIIC_js.Command, { ...props });
|
|
12
|
+
};
|
|
13
|
+
Command2.displayName = "Command";
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(exports, "CommandContent", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkNZDHSIIC_js.CommandContent; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "CommandEmpty", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkNZDHSIIC_js.CommandEmpty; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "CommandFooter", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkNZDHSIIC_js.CommandFooter; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "CommandGroup", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkNZDHSIIC_js.CommandGroup; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "CommandInput", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkNZDHSIIC_js.CommandInput; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "CommandItem", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkNZDHSIIC_js.CommandItem; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "CommandList", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkNZDHSIIC_js.CommandList; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "CommandSeparator", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkNZDHSIIC_js.CommandSeparator; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "CommandTrigger", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunkNZDHSIIC_js.CommandTrigger; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "commandContentVariants", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return chunkNZDHSIIC_js.commandContentVariants; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "commandItemVariants", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return chunkNZDHSIIC_js.commandItemVariants; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "commandOverlayVariants", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return chunkNZDHSIIC_js.commandOverlayVariants; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "useCommandContext", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunkNZDHSIIC_js.useCommandContext; }
|
|
66
|
+
});
|
|
67
|
+
exports.Command = Command2;
|
|
68
|
+
//# sourceMappingURL=command.js.map
|
|
69
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/command/command.tsx"],"names":["Command","jsx"],"mappings":";;;;;;;;AAGO,IAAMA,QAAAA,GAAU,CAAC,KAAA,KAAwB;AAC9C,EAAA,uBAAOC,cAAA,CAACD,wBAAA,EAAA,EAAa,GAAG,KAAA,EAAO,CAAA;AACjC;AAEAA,QAAAA,CAAQ,WAAA,GAAc,SAAA","file":"command.js","sourcesContent":["import { Command as CommandBase } from \"./command-base\";\nimport type { CommandProps } from \"./types\";\n\nexport const Command = (props: CommandProps) => {\n return <CommandBase {...props} />;\n};\n\nCommand.displayName = \"Command\";\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Command } from '../chunk-KEKMMNL5.mjs';
|
|
3
|
+
export { CommandContent, CommandEmpty, CommandFooter, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandTrigger, commandContentVariants, commandItemVariants, commandOverlayVariants, useCommandContext } from '../chunk-KEKMMNL5.mjs';
|
|
4
|
+
import '../chunk-K6YI4FJO.mjs';
|
|
5
|
+
import '../chunk-PMAF6FBF.mjs';
|
|
6
|
+
import '../chunk-4D54YOL6.mjs';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var Command2 = (props) => {
|
|
10
|
+
return /* @__PURE__ */ jsx(Command, { ...props });
|
|
11
|
+
};
|
|
12
|
+
Command2.displayName = "Command";
|
|
13
|
+
|
|
14
|
+
export { Command2 as Command };
|
|
15
|
+
//# sourceMappingURL=command.mjs.map
|
|
16
|
+
//# sourceMappingURL=command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/command/command.tsx"],"names":["Command"],"mappings":";;;;;;;AAGO,IAAMA,QAAAA,GAAU,CAAC,KAAA,KAAwB;AAC9C,EAAA,uBAAO,GAAA,CAAC,OAAA,EAAA,EAAa,GAAG,KAAA,EAAO,CAAA;AACjC;AAEAA,QAAAA,CAAQ,WAAA,GAAc,SAAA","file":"command.mjs","sourcesContent":["import { Command as CommandBase } from \"./command-base\";\nimport type { CommandProps } from \"./types\";\n\nexport const Command = (props: CommandProps) => {\n return <CommandBase {...props} />;\n};\n\nCommand.displayName = \"Command\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/otp-input/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-input.d.ts","sourceRoot":"","sources":["../../../src/ui/otp-input/otp-input.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAA6B,aAAa,EAAE,MAAM,SAAS,CAAC;AA2BxE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAmR5C;yBAnRe,QAAQ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
import type { otpInputCellVariants } from "./variants";
|
|
4
|
+
export type OTPInputAllowedCharacters = "numeric" | "alphanumeric";
|
|
5
|
+
export type OTPInputCellVariantProps = VariantProps<typeof otpInputCellVariants>;
|
|
6
|
+
export type OTPInputProps = OTPInputCellVariantProps & Omit<ComponentPropsWithRef<"div">, "defaultValue" | "dir" | "onChange" | "children"> & {
|
|
7
|
+
allowedCharacters?: OTPInputAllowedCharacters;
|
|
8
|
+
autoFocus?: boolean;
|
|
9
|
+
cellClassName?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
errorMessage?: ReactNode;
|
|
13
|
+
hint?: ReactNode;
|
|
14
|
+
label?: ReactNode;
|
|
15
|
+
length?: number;
|
|
16
|
+
mask?: boolean;
|
|
17
|
+
name?: string;
|
|
18
|
+
onComplete?: (value: string) => void;
|
|
19
|
+
onValueChange?: (value: string) => void;
|
|
20
|
+
separatorEvery?: number;
|
|
21
|
+
value?: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ui/otp-input/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,cAAc,CAAC;AAEnE,MAAM,MAAM,wBAAwB,GAAG,YAAY,CACjD,OAAO,oBAAoB,CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,wBAAwB,GAClD,IAAI,CACF,qBAAqB,CAAC,KAAK,CAAC,EAC5B,cAAc,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,CACjD,GAAG;IACF,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const otpInputCellVariants: (props?: ({
|
|
2
|
+
appearance?: "default" | "outline" | "glass" | "violet" | "amber" | "indigo" | "orange" | "pink" | "error" | "success" | "warning" | "info" | null | undefined;
|
|
3
|
+
size?: "md" | "sm" | "lg" | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/ui/otp-input/variants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,oBAAoB;;;8EAS/B,CAAC"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkZS5756ZC_js = require('../chunk-ZS5756ZC.js');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/design-system/otp-input.ts
|
|
10
|
+
var zuiOtpRootBase = "grid w-fit gap-2 text-[color:var(--zui-otp-label-fg,oklch(20.8%_0.042_265.755))] dark:text-[color:var(--zui-otp-label-fg-dark,oklch(98.4%_0.003_247.858))] data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50";
|
|
11
|
+
var zuiOtpLabelBase = "text-sm font-medium leading-6 text-[color:var(--zui-otp-label-fg,oklch(20.8%_0.042_265.755))] dark:text-[color:var(--zui-otp-label-fg-dark,oklch(98.4%_0.003_247.858))]";
|
|
12
|
+
var zuiOtpHintBase = "max-w-sm text-xs leading-5 text-[color:var(--zui-otp-hint-fg,oklch(55.4%_0.046_257.417))] dark:text-[color:var(--zui-otp-hint-fg-dark,oklch(70.4%_0.04_256.788))]";
|
|
13
|
+
var zuiOtpCellsBase = "flex flex-wrap items-center gap-2";
|
|
14
|
+
var zuiOtpCellBase = "grid place-items-center rounded-xl border bg-[var(--zui-otp-bg,#ffffff)] text-center font-semibold tabular-nums text-[color:var(--zui-otp-fg,oklch(20.8%_0.042_265.755))] shadow-sm shadow-black/5 outline-none transition-[background-color,border-color,box-shadow,color,transform] placeholder:text-transparent focus-visible:-translate-y-0.5 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--zui-otp-ring-offset-focus,#ffffff)] disabled:cursor-not-allowed dark:bg-[var(--zui-otp-bg-dark,oklch(12.9%_0.042_264.695))] dark:text-[color:var(--zui-otp-fg-dark,oklch(98.4%_0.003_247.858))] dark:shadow-black/20 dark:focus-visible:ring-offset-[var(--zui-otp-ring-offset-focus-dark,oklch(12.9%_0.042_264.695))]";
|
|
15
|
+
var zuiOtpSeparatorBase = "h-px w-3 shrink-0 bg-[color:var(--zui-otp-separator,#94a3b8)] opacity-70 dark:bg-[color:var(--zui-otp-separator-dark,#64748b)]";
|
|
16
|
+
var zuiOtpErrorBase = "text-sm leading-6 text-[color:var(--zui-otp-error-fg,oklch(58.6%_0.253_17.585))] dark:text-[color:var(--zui-otp-error-fg-dark,oklch(71.2%_0.194_13.428))]";
|
|
17
|
+
var zuiOtpSizes = {
|
|
18
|
+
sm: "size-7 md:size-9 rounded-lg text-sm",
|
|
19
|
+
md: "size-9 md:size-11 text-base",
|
|
20
|
+
lg: "size-11 md:size-13 rounded-2xl text-lg"
|
|
21
|
+
};
|
|
22
|
+
var zuiOtpAppearances = {
|
|
23
|
+
default: "border-[color:var(--zui-otp-default-border,#cbd5e1)] focus-visible:border-[color:var(--zui-otp-default-border-focus,oklch(44.6%_0.043_257.281))] focus-visible:ring-[var(--zui-otp-default-ring-focus,oklch(44.6%_0.043_257.281_/_0.25))] dark:border-[color:var(--zui-otp-default-border-dark,#475569)] dark:focus-visible:border-[color:var(--zui-otp-default-border-focus-dark,oklch(86.9%_0.022_252.894))] dark:focus-visible:ring-[var(--zui-otp-default-ring-focus-dark,oklch(86.9%_0.022_252.894_/_0.25))]",
|
|
24
|
+
outline: "border-[color:var(--zui-otp-outline-border,#64748b)] bg-transparent focus-visible:border-[color:var(--zui-otp-outline-border-focus,oklch(54.6%_0.245_262.881))] focus-visible:ring-[var(--zui-otp-outline-ring-focus,oklch(54.6%_0.245_262.881_/_0.28))] dark:border-[color:var(--zui-otp-outline-border-dark,#94a3b8)] dark:bg-transparent dark:focus-visible:border-[color:var(--zui-otp-outline-border-focus-dark,oklch(70.7%_0.165_254.624))] dark:focus-visible:ring-[var(--zui-otp-outline-ring-focus-dark,oklch(70.7%_0.165_254.624_/_0.28))]",
|
|
25
|
+
glass: "border-[color:var(--zui-otp-glass-border,#ffffff66)] bg-[var(--zui-otp-glass-bg,#ffffffcc)] backdrop-blur-md focus-visible:border-[color:var(--zui-otp-glass-border-focus,oklch(70.7%_0.165_254.624))] focus-visible:ring-[var(--zui-otp-glass-ring-focus,oklch(70.7%_0.165_254.624_/_0.32))] dark:border-[color:var(--zui-otp-glass-border-dark,#ffffff26)] dark:bg-[var(--zui-otp-glass-bg-dark,#0f172acc)] dark:focus-visible:border-[color:var(--zui-otp-glass-border-focus-dark,oklch(78.9%_0.154_211.53))] dark:focus-visible:ring-[var(--zui-otp-glass-ring-focus-dark,oklch(78.9%_0.154_211.53_/_0.32))]",
|
|
26
|
+
success: "border-[color:var(--zui-otp-success-border,oklch(69.6%_0.17_162.48_/_0.6))] focus-visible:border-[color:var(--zui-otp-success-border-focus,oklch(59.6%_0.145_163.225))] focus-visible:ring-[var(--zui-otp-success-ring-focus,oklch(59.6%_0.145_163.225_/_0.28))] dark:border-[color:var(--zui-otp-success-border-dark,oklch(69.6%_0.17_162.48_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-success-border-focus-dark,oklch(77.7%_0.152_181.912))] dark:focus-visible:ring-[var(--zui-otp-success-ring-focus-dark,oklch(77.7%_0.152_181.912_/_0.28))]",
|
|
27
|
+
error: "border-[color:var(--zui-otp-error-border,oklch(58.6%_0.253_17.585_/_0.7))] focus-visible:border-[color:var(--zui-otp-error-border-focus,oklch(58.6%_0.253_17.585))] focus-visible:ring-[var(--zui-otp-error-ring-focus,oklch(58.6%_0.253_17.585_/_0.28))] dark:border-[color:var(--zui-otp-error-border-dark,oklch(71.2%_0.194_13.428_/_0.65))] dark:focus-visible:border-[color:var(--zui-otp-error-border-focus-dark,oklch(71.2%_0.194_13.428))] dark:focus-visible:ring-[var(--zui-otp-error-ring-focus-dark,oklch(71.2%_0.194_13.428_/_0.28))]",
|
|
28
|
+
warning: "border-[color:var(--zui-otp-warning-border,oklch(79.5%_0.184_86.047_/_0.7))] focus-visible:border-[color:var(--zui-otp-warning-border-focus,oklch(68.1%_0.162_75.834))] focus-visible:ring-[var(--zui-otp-warning-ring-focus,oklch(68.1%_0.162_75.834_/_0.28))] dark:border-[color:var(--zui-otp-warning-border-dark,oklch(79.5%_0.184_86.047_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-warning-border-focus-dark,oklch(85.2%_0.199_91.936))] dark:focus-visible:ring-[var(--zui-otp-warning-ring-focus-dark,oklch(85.2%_0.199_91.936_/_0.28))]",
|
|
29
|
+
info: "border-[color:var(--zui-otp-info-border,oklch(62.3%_0.214_259.815_/_0.7))] focus-visible:border-[color:var(--zui-otp-info-border-focus,oklch(54.6%_0.245_262.881))] focus-visible:ring-[var(--zui-otp-info-ring-focus,oklch(54.6%_0.245_262.881_/_0.28))] dark:border-[color:var(--zui-otp-info-border-dark,oklch(62.3%_0.214_259.815_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-info-border-focus-dark,oklch(70.7%_0.165_254.624))] dark:focus-visible:ring-[var(--zui-otp-info-ring-focus-dark,oklch(70.7%_0.165_254.624_/_0.28))]",
|
|
30
|
+
violet: "border-[color:var(--zui-otp-violet-border,oklch(60.6%_0.25_292.717_/_0.7))] focus-visible:border-[color:var(--zui-otp-violet-border-focus,oklch(54.1%_0.281_293.009))] focus-visible:ring-[var(--zui-otp-violet-ring-focus,oklch(54.1%_0.281_293.009_/_0.28))] dark:border-[color:var(--zui-otp-violet-border-dark,oklch(60.6%_0.25_292.717_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-violet-border-focus-dark,oklch(70.2%_0.183_293.541))] dark:focus-visible:ring-[var(--zui-otp-violet-ring-focus-dark,oklch(70.2%_0.183_293.541_/_0.28))]",
|
|
31
|
+
amber: "border-[color:var(--zui-otp-amber-border,oklch(76.9%_0.188_70.08_/_0.7))] focus-visible:border-[color:var(--zui-otp-amber-border-focus,oklch(66.6%_0.179_58.318))] focus-visible:ring-[var(--zui-otp-amber-ring-focus,oklch(66.6%_0.179_58.318_/_0.28))] dark:border-[color:var(--zui-otp-amber-border-dark,oklch(76.9%_0.188_70.08_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-amber-border-focus-dark,oklch(82.8%_0.189_84.429))] dark:focus-visible:ring-[var(--zui-otp-amber-ring-focus-dark,oklch(82.8%_0.189_84.429_/_0.28))]",
|
|
32
|
+
pink: "border-[color:var(--zui-otp-pink-border,oklch(65.6%_0.241_354.308_/_0.7))] focus-visible:border-[color:var(--zui-otp-pink-border-focus,oklch(59.2%_0.249_0.584))] focus-visible:ring-[var(--zui-otp-pink-ring-focus,oklch(59.2%_0.249_0.584_/_0.28))] dark:border-[color:var(--zui-otp-pink-border-dark,oklch(65.6%_0.241_354.308_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-pink-border-focus-dark,oklch(71.8%_0.202_349.761))] dark:focus-visible:ring-[var(--zui-otp-pink-ring-focus-dark,oklch(71.8%_0.202_349.761_/_0.28))]",
|
|
33
|
+
indigo: "border-[color:var(--zui-otp-indigo-border,oklch(58.5%_0.233_277.117_/_0.7))] focus-visible:border-[color:var(--zui-otp-indigo-border-focus,oklch(51.1%_0.262_276.966))] focus-visible:ring-[var(--zui-otp-indigo-ring-focus,oklch(51.1%_0.262_276.966_/_0.28))] dark:border-[color:var(--zui-otp-indigo-border-dark,oklch(58.5%_0.233_277.117_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-indigo-border-focus-dark,oklch(67.3%_0.182_276.935))] dark:focus-visible:ring-[var(--zui-otp-indigo-ring-focus-dark,oklch(67.3%_0.182_276.935_/_0.28))]",
|
|
34
|
+
orange: "border-[color:var(--zui-otp-orange-border,oklch(70.5%_0.213_47.604_/_0.7))] focus-visible:border-[color:var(--zui-otp-orange-border-focus,oklch(64.6%_0.222_41.116))] focus-visible:ring-[var(--zui-otp-orange-ring-focus,oklch(64.6%_0.222_41.116_/_0.28))] dark:border-[color:var(--zui-otp-orange-border-dark,oklch(70.5%_0.213_47.604_/_0.5))] dark:focus-visible:border-[color:var(--zui-otp-orange-border-focus-dark,oklch(75%_0.183_55.934))] dark:focus-visible:ring-[var(--zui-otp-orange-ring-focus-dark,oklch(75%_0.183_55.934_/_0.28))]"
|
|
35
|
+
};
|
|
36
|
+
var otpInputCellVariants = classVarianceAuthority.cva(zuiOtpCellBase, {
|
|
37
|
+
variants: {
|
|
38
|
+
appearance: zuiOtpAppearances,
|
|
39
|
+
size: zuiOtpSizes
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
appearance: "default",
|
|
43
|
+
size: "md"
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
function clampLength(length) {
|
|
47
|
+
return Number.isFinite(length) ? Math.max(1, Math.min(12, length)) : 6;
|
|
48
|
+
}
|
|
49
|
+
function sanitizeValue(value, allowedCharacters, maxLength) {
|
|
50
|
+
const pattern = allowedCharacters === "numeric" ? /[0-9]/g : /[a-zA-Z0-9]/g;
|
|
51
|
+
return (value.match(pattern) ?? []).join("").slice(0, maxLength);
|
|
52
|
+
}
|
|
53
|
+
function valueToCells(value, length) {
|
|
54
|
+
return Array.from({ length }, (_, index) => {
|
|
55
|
+
const c = value[index] ?? "\0";
|
|
56
|
+
return c === "\0" ? "" : c;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function cellsToInternal(cells, length) {
|
|
60
|
+
return Array.from({ length }, (_, i) => cells[i] || "\0").join("");
|
|
61
|
+
}
|
|
62
|
+
function OTPInput(props) {
|
|
63
|
+
const {
|
|
64
|
+
allowedCharacters = "numeric",
|
|
65
|
+
appearance,
|
|
66
|
+
autoFocus,
|
|
67
|
+
cellClassName,
|
|
68
|
+
className,
|
|
69
|
+
defaultValue = "",
|
|
70
|
+
disabled,
|
|
71
|
+
errorMessage,
|
|
72
|
+
hint,
|
|
73
|
+
id,
|
|
74
|
+
label,
|
|
75
|
+
length = 6,
|
|
76
|
+
mask,
|
|
77
|
+
name,
|
|
78
|
+
onComplete,
|
|
79
|
+
onValueChange,
|
|
80
|
+
ref,
|
|
81
|
+
separatorEvery,
|
|
82
|
+
size,
|
|
83
|
+
value,
|
|
84
|
+
...rest
|
|
85
|
+
} = props;
|
|
86
|
+
const generatedId = react.useId();
|
|
87
|
+
const rootId = id ?? generatedId;
|
|
88
|
+
const resolvedLength = clampLength(length);
|
|
89
|
+
const isControlled = value !== void 0;
|
|
90
|
+
const [uncontrolledValue, setUncontrolledValue] = react.useState(() => {
|
|
91
|
+
const clean = sanitizeValue(
|
|
92
|
+
defaultValue,
|
|
93
|
+
allowedCharacters,
|
|
94
|
+
resolvedLength
|
|
95
|
+
);
|
|
96
|
+
return clean.padEnd(resolvedLength, "\0");
|
|
97
|
+
});
|
|
98
|
+
const inputRefs = react.useRef([]);
|
|
99
|
+
const cells = react.useMemo(
|
|
100
|
+
() => isControlled ? valueToCells(
|
|
101
|
+
sanitizeValue(
|
|
102
|
+
value ?? "",
|
|
103
|
+
allowedCharacters,
|
|
104
|
+
resolvedLength
|
|
105
|
+
).padEnd(resolvedLength, "\0"),
|
|
106
|
+
resolvedLength
|
|
107
|
+
) : Array.from({ length: resolvedLength }, (_, index) => {
|
|
108
|
+
const c = uncontrolledValue[index] ?? "\0";
|
|
109
|
+
return c === "\0" ? "" : sanitizeValue(c, allowedCharacters, 1);
|
|
110
|
+
}),
|
|
111
|
+
[allowedCharacters, isControlled, resolvedLength, uncontrolledValue, value]
|
|
112
|
+
);
|
|
113
|
+
const sanitizedValue = cells.filter(Boolean).join("");
|
|
114
|
+
const labelId = `${rootId}-label`;
|
|
115
|
+
const hintId = `${rootId}-hint`;
|
|
116
|
+
const errorId = `${rootId}-error`;
|
|
117
|
+
const describedBy = [
|
|
118
|
+
hint !== void 0 ? hintId : void 0,
|
|
119
|
+
errorMessage !== void 0 ? errorId : void 0
|
|
120
|
+
].filter(Boolean).join(" ");
|
|
121
|
+
const commitValue = react.useCallback(
|
|
122
|
+
(nextCells) => {
|
|
123
|
+
if (!isControlled) {
|
|
124
|
+
setUncontrolledValue(cellsToInternal(nextCells, resolvedLength));
|
|
125
|
+
}
|
|
126
|
+
const next = nextCells.filter(Boolean).join("").slice(0, resolvedLength);
|
|
127
|
+
onValueChange?.(next);
|
|
128
|
+
if (next.length === resolvedLength) {
|
|
129
|
+
onComplete?.(next);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
[isControlled, onComplete, onValueChange, resolvedLength]
|
|
133
|
+
);
|
|
134
|
+
const focusCell = react.useCallback(
|
|
135
|
+
(index) => {
|
|
136
|
+
const target = inputRefs.current[Math.max(0, Math.min(index, resolvedLength - 1))];
|
|
137
|
+
target?.focus();
|
|
138
|
+
target?.select();
|
|
139
|
+
},
|
|
140
|
+
[resolvedLength]
|
|
141
|
+
);
|
|
142
|
+
const updateAtIndex = react.useCallback(
|
|
143
|
+
(index, nextChars, isPaste = false) => {
|
|
144
|
+
let chars = sanitizeValue(
|
|
145
|
+
nextChars,
|
|
146
|
+
allowedCharacters,
|
|
147
|
+
resolvedLength
|
|
148
|
+
);
|
|
149
|
+
if (!isPaste && chars && chars.length === 2 && chars[0] === (cells[index] ?? "")) {
|
|
150
|
+
chars = chars[1];
|
|
151
|
+
}
|
|
152
|
+
if (!chars?.length || !isPaste && chars === cells[index]) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const nextCells = [...cells];
|
|
156
|
+
chars.split("").forEach((char, offset) => {
|
|
157
|
+
const targetIndex = index + offset;
|
|
158
|
+
if (targetIndex < resolvedLength) {
|
|
159
|
+
nextCells[targetIndex] = char;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
commitValue(nextCells);
|
|
163
|
+
focusCell(
|
|
164
|
+
Math.min(index + Math.max(chars.length, 1), resolvedLength - 1)
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
[allowedCharacters, cells, commitValue, focusCell, resolvedLength]
|
|
168
|
+
);
|
|
169
|
+
const clearAtIndex = react.useCallback(
|
|
170
|
+
(index) => {
|
|
171
|
+
const nextCells = [...cells];
|
|
172
|
+
nextCells[index] = "";
|
|
173
|
+
commitValue(nextCells);
|
|
174
|
+
},
|
|
175
|
+
[cells, commitValue]
|
|
176
|
+
);
|
|
177
|
+
const handlePaste = react.useCallback(
|
|
178
|
+
(event, index) => {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
updateAtIndex(index, event.clipboardData.getData("text"), true);
|
|
181
|
+
},
|
|
182
|
+
[updateAtIndex]
|
|
183
|
+
);
|
|
184
|
+
const handleKeyDown = react.useCallback(
|
|
185
|
+
(event, index) => {
|
|
186
|
+
if (event.key === "Backspace") {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
if (cells[index]) {
|
|
189
|
+
clearAtIndex(index);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
clearAtIndex(Math.max(index - 1, 0));
|
|
193
|
+
focusCell(index - 1);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (event.key === "Delete") {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
clearAtIndex(index);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (event.key === "ArrowLeft") {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
focusCell(index - 1);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (event.key === "ArrowRight") {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
focusCell(index + 1);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (event.key === "Home") {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
focusCell(0);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (event.key === "End") {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
focusCell(resolvedLength - 1);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
[cells, clearAtIndex, focusCell, resolvedLength]
|
|
222
|
+
);
|
|
223
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
ref,
|
|
227
|
+
id: rootId,
|
|
228
|
+
role: "group",
|
|
229
|
+
"aria-labelledby": label !== void 0 ? labelId : void 0,
|
|
230
|
+
"aria-describedby": describedBy || void 0,
|
|
231
|
+
"aria-invalid": errorMessage !== void 0 ? true : void 0,
|
|
232
|
+
className: chunkZS5756ZC_js.cn(zuiOtpRootBase, className),
|
|
233
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
234
|
+
"data-slot": "otp-input",
|
|
235
|
+
...rest,
|
|
236
|
+
children: [
|
|
237
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { id: labelId, className: zuiOtpLabelBase, children: label }),
|
|
238
|
+
hint !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { id: hintId, className: zuiOtpHintBase, children: hint }),
|
|
239
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: zuiOtpCellsBase, "data-slot": "otp-input-cells", children: cells.map((char, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
240
|
+
"span",
|
|
241
|
+
{
|
|
242
|
+
className: "contents",
|
|
243
|
+
"data-slot": "otp-input-cell-wrapper",
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
246
|
+
"input",
|
|
247
|
+
{
|
|
248
|
+
ref: (node) => {
|
|
249
|
+
inputRefs.current[index] = node;
|
|
250
|
+
},
|
|
251
|
+
"aria-label": `Digit ${index + 1} of ${resolvedLength}`,
|
|
252
|
+
autoComplete: index === 0 ? "one-time-code" : "off",
|
|
253
|
+
autoFocus: autoFocus && index === 0,
|
|
254
|
+
className: chunkZS5756ZC_js.cn(
|
|
255
|
+
otpInputCellVariants({ appearance, size }),
|
|
256
|
+
cellClassName
|
|
257
|
+
),
|
|
258
|
+
"data-slot": "otp-input-cell",
|
|
259
|
+
disabled,
|
|
260
|
+
inputMode: allowedCharacters === "numeric" ? "numeric" : "text",
|
|
261
|
+
maxLength: resolvedLength,
|
|
262
|
+
onChange: (event) => updateAtIndex(index, event.currentTarget.value, false),
|
|
263
|
+
onFocus: (event) => event.currentTarget.select(),
|
|
264
|
+
onKeyDown: (event) => handleKeyDown(event, index),
|
|
265
|
+
onPaste: (event) => handlePaste(event, index),
|
|
266
|
+
pattern: allowedCharacters === "numeric" ? "[0-9]*" : "[A-Za-z0-9]*",
|
|
267
|
+
type: mask ? "password" : "text",
|
|
268
|
+
value: char
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
separatorEvery && separatorEvery > 0 && index < resolvedLength - 1 && (index + 1) % separatorEvery === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
272
|
+
"span",
|
|
273
|
+
{
|
|
274
|
+
"aria-hidden": "true",
|
|
275
|
+
className: zuiOtpSeparatorBase,
|
|
276
|
+
"data-slot": "otp-input-separator"
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
`${rootId}-${index}`
|
|
282
|
+
)) }),
|
|
283
|
+
name !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
284
|
+
"input",
|
|
285
|
+
{
|
|
286
|
+
type: "hidden",
|
|
287
|
+
name,
|
|
288
|
+
value: sanitizedValue,
|
|
289
|
+
disabled
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
errorMessage !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: zuiOtpErrorBase, children: errorMessage })
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
OTPInput.displayName = "OTPInput";
|
|
298
|
+
|
|
299
|
+
exports.OTPInput = OTPInput;
|
|
300
|
+
exports.otpInputCellVariants = otpInputCellVariants;
|
|
301
|
+
//# sourceMappingURL=otp-input.js.map
|
|
302
|
+
//# sourceMappingURL=otp-input.js.map
|