@sytechui/input-otp 2.1.32
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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/chunk-IJHHP6DJ.mjs +46 -0
- package/dist/chunk-R2XKH6IK.mjs +13 -0
- package/dist/chunk-VZ7MKXTH.mjs +250 -0
- package/dist/chunk-ZVXVMEIW.mjs +72 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +391 -0
- package/dist/index.mjs +19 -0
- package/dist/input-otp-context.d.mts +499 -0
- package/dist/input-otp-context.d.ts +499 -0
- package/dist/input-otp-context.js +37 -0
- package/dist/input-otp-context.mjs +9 -0
- package/dist/input-otp-segment.d.mts +9 -0
- package/dist/input-otp-segment.d.ts +9 -0
- package/dist/input-otp-segment.js +75 -0
- package/dist/input-otp-segment.mjs +8 -0
- package/dist/input-otp.d.mts +14 -0
- package/dist/input-otp.d.ts +14 -0
- package/dist/input-otp.js +374 -0
- package/dist/input-otp.mjs +10 -0
- package/dist/use-input-otp.d.mts +315 -0
- package/dist/use-input-otp.d.ts +315 -0
- package/dist/use-input-otp.js +273 -0
- package/dist/use-input-otp.mjs +7 -0
- package/package.json +63 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
4
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
|
|
5
|
+
import { SlotsToClasses, InputOtpSlots, InputOtpVariantProps, InputOtpReturnType } from '@sytechui/theme';
|
|
6
|
+
import { ReactRef } from '@sytechui/react-utils';
|
|
7
|
+
import { AriaTextFieldProps } from '@react-types/textfield';
|
|
8
|
+
import { OTPInputProps } from 'input-otp';
|
|
9
|
+
|
|
10
|
+
interface Props extends HTMLHeroUIProps<"div"> {
|
|
11
|
+
/**
|
|
12
|
+
* Ref to the DOM node.
|
|
13
|
+
*/
|
|
14
|
+
ref?: ReactRef<HTMLInputElement | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the container DOM node.
|
|
17
|
+
*/
|
|
18
|
+
baseRef?: ReactRef<HTMLDivElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Length required for the otp.
|
|
21
|
+
*/
|
|
22
|
+
length: number;
|
|
23
|
+
/**
|
|
24
|
+
* Regex string for the allowed keys.
|
|
25
|
+
*/
|
|
26
|
+
allowedKeys?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Callback that will be fired when the value has length equal to otp length
|
|
29
|
+
*/
|
|
30
|
+
onComplete?: (v?: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Boolean to disable the input-otp component.
|
|
33
|
+
*/
|
|
34
|
+
isDisabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Boolean to disable the animation in input-otp component.
|
|
37
|
+
*/
|
|
38
|
+
disableAnimation?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Classname or List of classes to change the classNames of the element.
|
|
41
|
+
* if `className` is passed, it will be added to the base slot.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* <InputOtp classNames={{
|
|
46
|
+
* base:"base-classes",
|
|
47
|
+
* inputWrapper:"input-wrapper-classes",
|
|
48
|
+
* input: "input-classes",
|
|
49
|
+
* segmentWrapper: "segment-wrapper-classes",
|
|
50
|
+
* segment: "segment-classes",
|
|
51
|
+
* helperWrapper: "helper-wrapper-classes",
|
|
52
|
+
* description: "description-classes",
|
|
53
|
+
* errorMessage: "error-message-classes",
|
|
54
|
+
* }} />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
classNames?: SlotsToClasses<InputOtpSlots>;
|
|
58
|
+
/**
|
|
59
|
+
* React aria onChange event.
|
|
60
|
+
*/
|
|
61
|
+
onValueChange?: (value: string) => void;
|
|
62
|
+
}
|
|
63
|
+
type ValueTypes = {
|
|
64
|
+
slots: InputOtpReturnType;
|
|
65
|
+
classNames: SlotsToClasses<InputOtpSlots>;
|
|
66
|
+
};
|
|
67
|
+
type UseInputOtpProps = Props & InputOtpVariantProps & Omit<AriaTextFieldProps, "onChange"> & Omit<Partial<OTPInputProps>, "render" | "children" | "value" | "onChange" | keyof InputOtpVariantProps>;
|
|
68
|
+
declare function useInputOtp(originalProps: UseInputOtpProps): {
|
|
69
|
+
Component: _sytechui_system.As<any>;
|
|
70
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
|
71
|
+
length: number;
|
|
72
|
+
value: string;
|
|
73
|
+
type: string | undefined;
|
|
74
|
+
slots: {
|
|
75
|
+
base: (slotProps?: ({
|
|
76
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
77
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
78
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
79
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
80
|
+
isInvalid?: boolean | undefined;
|
|
81
|
+
disableAnimation?: boolean | undefined;
|
|
82
|
+
isDisabled?: boolean | undefined;
|
|
83
|
+
isReadOnly?: boolean | undefined;
|
|
84
|
+
fullWidth?: boolean | undefined;
|
|
85
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
86
|
+
wrapper: (slotProps?: ({
|
|
87
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
88
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
89
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
90
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
91
|
+
isInvalid?: boolean | undefined;
|
|
92
|
+
disableAnimation?: boolean | undefined;
|
|
93
|
+
isDisabled?: boolean | undefined;
|
|
94
|
+
isReadOnly?: boolean | undefined;
|
|
95
|
+
fullWidth?: boolean | undefined;
|
|
96
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
97
|
+
input: (slotProps?: ({
|
|
98
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
99
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
100
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
101
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
102
|
+
isInvalid?: boolean | undefined;
|
|
103
|
+
disableAnimation?: boolean | undefined;
|
|
104
|
+
isDisabled?: boolean | undefined;
|
|
105
|
+
isReadOnly?: boolean | undefined;
|
|
106
|
+
fullWidth?: boolean | undefined;
|
|
107
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
108
|
+
segmentWrapper: (slotProps?: ({
|
|
109
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
110
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
111
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
112
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
113
|
+
isInvalid?: boolean | undefined;
|
|
114
|
+
disableAnimation?: boolean | undefined;
|
|
115
|
+
isDisabled?: boolean | undefined;
|
|
116
|
+
isReadOnly?: boolean | undefined;
|
|
117
|
+
fullWidth?: boolean | undefined;
|
|
118
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
119
|
+
segment: (slotProps?: ({
|
|
120
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
121
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
122
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
123
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
124
|
+
isInvalid?: boolean | undefined;
|
|
125
|
+
disableAnimation?: boolean | undefined;
|
|
126
|
+
isDisabled?: boolean | undefined;
|
|
127
|
+
isReadOnly?: boolean | undefined;
|
|
128
|
+
fullWidth?: boolean | undefined;
|
|
129
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
130
|
+
passwordChar: (slotProps?: ({
|
|
131
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
132
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
133
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
134
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
135
|
+
isInvalid?: boolean | undefined;
|
|
136
|
+
disableAnimation?: boolean | undefined;
|
|
137
|
+
isDisabled?: boolean | undefined;
|
|
138
|
+
isReadOnly?: boolean | undefined;
|
|
139
|
+
fullWidth?: boolean | undefined;
|
|
140
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
141
|
+
caret: (slotProps?: ({
|
|
142
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
143
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
144
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
145
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
146
|
+
isInvalid?: boolean | undefined;
|
|
147
|
+
disableAnimation?: boolean | undefined;
|
|
148
|
+
isDisabled?: boolean | undefined;
|
|
149
|
+
isReadOnly?: boolean | undefined;
|
|
150
|
+
fullWidth?: boolean | undefined;
|
|
151
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
152
|
+
helperWrapper: (slotProps?: ({
|
|
153
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
154
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
155
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
156
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
157
|
+
isInvalid?: boolean | undefined;
|
|
158
|
+
disableAnimation?: boolean | undefined;
|
|
159
|
+
isDisabled?: boolean | undefined;
|
|
160
|
+
isReadOnly?: boolean | undefined;
|
|
161
|
+
fullWidth?: boolean | undefined;
|
|
162
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
163
|
+
errorMessage: (slotProps?: ({
|
|
164
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
165
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
166
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
167
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
168
|
+
isInvalid?: boolean | undefined;
|
|
169
|
+
disableAnimation?: boolean | undefined;
|
|
170
|
+
isDisabled?: boolean | undefined;
|
|
171
|
+
isReadOnly?: boolean | undefined;
|
|
172
|
+
fullWidth?: boolean | undefined;
|
|
173
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
174
|
+
description: (slotProps?: ({
|
|
175
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
176
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
177
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
178
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
179
|
+
isInvalid?: boolean | undefined;
|
|
180
|
+
disableAnimation?: boolean | undefined;
|
|
181
|
+
isDisabled?: boolean | undefined;
|
|
182
|
+
isReadOnly?: boolean | undefined;
|
|
183
|
+
fullWidth?: boolean | undefined;
|
|
184
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
185
|
+
} & {
|
|
186
|
+
base: (slotProps?: ({
|
|
187
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
188
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
189
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
190
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
191
|
+
isInvalid?: boolean | undefined;
|
|
192
|
+
disableAnimation?: boolean | undefined;
|
|
193
|
+
isDisabled?: boolean | undefined;
|
|
194
|
+
isReadOnly?: boolean | undefined;
|
|
195
|
+
fullWidth?: boolean | undefined;
|
|
196
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
197
|
+
wrapper: (slotProps?: ({
|
|
198
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
199
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
200
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
201
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
202
|
+
isInvalid?: boolean | undefined;
|
|
203
|
+
disableAnimation?: boolean | undefined;
|
|
204
|
+
isDisabled?: boolean | undefined;
|
|
205
|
+
isReadOnly?: boolean | undefined;
|
|
206
|
+
fullWidth?: boolean | undefined;
|
|
207
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
208
|
+
input: (slotProps?: ({
|
|
209
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
210
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
211
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
212
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
213
|
+
isInvalid?: boolean | undefined;
|
|
214
|
+
disableAnimation?: boolean | undefined;
|
|
215
|
+
isDisabled?: boolean | undefined;
|
|
216
|
+
isReadOnly?: boolean | undefined;
|
|
217
|
+
fullWidth?: boolean | undefined;
|
|
218
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
219
|
+
segmentWrapper: (slotProps?: ({
|
|
220
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
221
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
222
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
223
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
224
|
+
isInvalid?: boolean | undefined;
|
|
225
|
+
disableAnimation?: boolean | undefined;
|
|
226
|
+
isDisabled?: boolean | undefined;
|
|
227
|
+
isReadOnly?: boolean | undefined;
|
|
228
|
+
fullWidth?: boolean | undefined;
|
|
229
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
230
|
+
segment: (slotProps?: ({
|
|
231
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
232
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
233
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
234
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
235
|
+
isInvalid?: boolean | undefined;
|
|
236
|
+
disableAnimation?: boolean | undefined;
|
|
237
|
+
isDisabled?: boolean | undefined;
|
|
238
|
+
isReadOnly?: boolean | undefined;
|
|
239
|
+
fullWidth?: boolean | undefined;
|
|
240
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
241
|
+
passwordChar: (slotProps?: ({
|
|
242
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
243
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
244
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
245
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
246
|
+
isInvalid?: boolean | undefined;
|
|
247
|
+
disableAnimation?: boolean | undefined;
|
|
248
|
+
isDisabled?: boolean | undefined;
|
|
249
|
+
isReadOnly?: boolean | undefined;
|
|
250
|
+
fullWidth?: boolean | undefined;
|
|
251
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
252
|
+
caret: (slotProps?: ({
|
|
253
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
254
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
255
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
256
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
257
|
+
isInvalid?: boolean | undefined;
|
|
258
|
+
disableAnimation?: boolean | undefined;
|
|
259
|
+
isDisabled?: boolean | undefined;
|
|
260
|
+
isReadOnly?: boolean | undefined;
|
|
261
|
+
fullWidth?: boolean | undefined;
|
|
262
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
263
|
+
helperWrapper: (slotProps?: ({
|
|
264
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
265
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
266
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
267
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
268
|
+
isInvalid?: boolean | undefined;
|
|
269
|
+
disableAnimation?: boolean | undefined;
|
|
270
|
+
isDisabled?: boolean | undefined;
|
|
271
|
+
isReadOnly?: boolean | undefined;
|
|
272
|
+
fullWidth?: boolean | undefined;
|
|
273
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
274
|
+
errorMessage: (slotProps?: ({
|
|
275
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
276
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
277
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
278
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
279
|
+
isInvalid?: boolean | undefined;
|
|
280
|
+
disableAnimation?: boolean | undefined;
|
|
281
|
+
isDisabled?: boolean | undefined;
|
|
282
|
+
isReadOnly?: boolean | undefined;
|
|
283
|
+
fullWidth?: boolean | undefined;
|
|
284
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
285
|
+
description: (slotProps?: ({
|
|
286
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
287
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
288
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
289
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
290
|
+
isInvalid?: boolean | undefined;
|
|
291
|
+
disableAnimation?: boolean | undefined;
|
|
292
|
+
isDisabled?: boolean | undefined;
|
|
293
|
+
isReadOnly?: boolean | undefined;
|
|
294
|
+
fullWidth?: boolean | undefined;
|
|
295
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
296
|
+
} & {};
|
|
297
|
+
hasHelper: boolean;
|
|
298
|
+
classNames: SlotsToClasses<"base" | "wrapper" | "input" | "segmentWrapper" | "segment" | "passwordChar" | "caret" | "helperWrapper" | "errorMessage" | "description"> | undefined;
|
|
299
|
+
isInvalid: boolean;
|
|
300
|
+
description: react.ReactNode;
|
|
301
|
+
errorMessage: react.ReactNode;
|
|
302
|
+
isFocusVisible: boolean;
|
|
303
|
+
isFocused: boolean;
|
|
304
|
+
getBaseProps: PropGetter;
|
|
305
|
+
getInputOtpProps: (props?: Partial<OTPInputProps>) => Omit<OTPInputProps, "children" | "render"> & {
|
|
306
|
+
ref?: ReactRef<HTMLInputElement>;
|
|
307
|
+
};
|
|
308
|
+
getSegmentWrapperProps: PropGetter;
|
|
309
|
+
getHelperWrapperProps: PropGetter;
|
|
310
|
+
getErrorMessageProps: PropGetter;
|
|
311
|
+
getDescriptionProps: PropGetter;
|
|
312
|
+
};
|
|
313
|
+
type UseInputOtpReturn = ReturnType<typeof useInputOtp>;
|
|
314
|
+
|
|
315
|
+
export { type UseInputOtpProps, type UseInputOtpReturn, type ValueTypes, useInputOtp };
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
4
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
|
|
5
|
+
import { SlotsToClasses, InputOtpSlots, InputOtpVariantProps, InputOtpReturnType } from '@sytechui/theme';
|
|
6
|
+
import { ReactRef } from '@sytechui/react-utils';
|
|
7
|
+
import { AriaTextFieldProps } from '@react-types/textfield';
|
|
8
|
+
import { OTPInputProps } from 'input-otp';
|
|
9
|
+
|
|
10
|
+
interface Props extends HTMLHeroUIProps<"div"> {
|
|
11
|
+
/**
|
|
12
|
+
* Ref to the DOM node.
|
|
13
|
+
*/
|
|
14
|
+
ref?: ReactRef<HTMLInputElement | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the container DOM node.
|
|
17
|
+
*/
|
|
18
|
+
baseRef?: ReactRef<HTMLDivElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Length required for the otp.
|
|
21
|
+
*/
|
|
22
|
+
length: number;
|
|
23
|
+
/**
|
|
24
|
+
* Regex string for the allowed keys.
|
|
25
|
+
*/
|
|
26
|
+
allowedKeys?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Callback that will be fired when the value has length equal to otp length
|
|
29
|
+
*/
|
|
30
|
+
onComplete?: (v?: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Boolean to disable the input-otp component.
|
|
33
|
+
*/
|
|
34
|
+
isDisabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Boolean to disable the animation in input-otp component.
|
|
37
|
+
*/
|
|
38
|
+
disableAnimation?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Classname or List of classes to change the classNames of the element.
|
|
41
|
+
* if `className` is passed, it will be added to the base slot.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* <InputOtp classNames={{
|
|
46
|
+
* base:"base-classes",
|
|
47
|
+
* inputWrapper:"input-wrapper-classes",
|
|
48
|
+
* input: "input-classes",
|
|
49
|
+
* segmentWrapper: "segment-wrapper-classes",
|
|
50
|
+
* segment: "segment-classes",
|
|
51
|
+
* helperWrapper: "helper-wrapper-classes",
|
|
52
|
+
* description: "description-classes",
|
|
53
|
+
* errorMessage: "error-message-classes",
|
|
54
|
+
* }} />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
classNames?: SlotsToClasses<InputOtpSlots>;
|
|
58
|
+
/**
|
|
59
|
+
* React aria onChange event.
|
|
60
|
+
*/
|
|
61
|
+
onValueChange?: (value: string) => void;
|
|
62
|
+
}
|
|
63
|
+
type ValueTypes = {
|
|
64
|
+
slots: InputOtpReturnType;
|
|
65
|
+
classNames: SlotsToClasses<InputOtpSlots>;
|
|
66
|
+
};
|
|
67
|
+
type UseInputOtpProps = Props & InputOtpVariantProps & Omit<AriaTextFieldProps, "onChange"> & Omit<Partial<OTPInputProps>, "render" | "children" | "value" | "onChange" | keyof InputOtpVariantProps>;
|
|
68
|
+
declare function useInputOtp(originalProps: UseInputOtpProps): {
|
|
69
|
+
Component: _sytechui_system.As<any>;
|
|
70
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
|
71
|
+
length: number;
|
|
72
|
+
value: string;
|
|
73
|
+
type: string | undefined;
|
|
74
|
+
slots: {
|
|
75
|
+
base: (slotProps?: ({
|
|
76
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
77
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
78
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
79
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
80
|
+
isInvalid?: boolean | undefined;
|
|
81
|
+
disableAnimation?: boolean | undefined;
|
|
82
|
+
isDisabled?: boolean | undefined;
|
|
83
|
+
isReadOnly?: boolean | undefined;
|
|
84
|
+
fullWidth?: boolean | undefined;
|
|
85
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
86
|
+
wrapper: (slotProps?: ({
|
|
87
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
88
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
89
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
90
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
91
|
+
isInvalid?: boolean | undefined;
|
|
92
|
+
disableAnimation?: boolean | undefined;
|
|
93
|
+
isDisabled?: boolean | undefined;
|
|
94
|
+
isReadOnly?: boolean | undefined;
|
|
95
|
+
fullWidth?: boolean | undefined;
|
|
96
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
97
|
+
input: (slotProps?: ({
|
|
98
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
99
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
100
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
101
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
102
|
+
isInvalid?: boolean | undefined;
|
|
103
|
+
disableAnimation?: boolean | undefined;
|
|
104
|
+
isDisabled?: boolean | undefined;
|
|
105
|
+
isReadOnly?: boolean | undefined;
|
|
106
|
+
fullWidth?: boolean | undefined;
|
|
107
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
108
|
+
segmentWrapper: (slotProps?: ({
|
|
109
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
110
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
111
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
112
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
113
|
+
isInvalid?: boolean | undefined;
|
|
114
|
+
disableAnimation?: boolean | undefined;
|
|
115
|
+
isDisabled?: boolean | undefined;
|
|
116
|
+
isReadOnly?: boolean | undefined;
|
|
117
|
+
fullWidth?: boolean | undefined;
|
|
118
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
119
|
+
segment: (slotProps?: ({
|
|
120
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
121
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
122
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
123
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
124
|
+
isInvalid?: boolean | undefined;
|
|
125
|
+
disableAnimation?: boolean | undefined;
|
|
126
|
+
isDisabled?: boolean | undefined;
|
|
127
|
+
isReadOnly?: boolean | undefined;
|
|
128
|
+
fullWidth?: boolean | undefined;
|
|
129
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
130
|
+
passwordChar: (slotProps?: ({
|
|
131
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
132
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
133
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
134
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
135
|
+
isInvalid?: boolean | undefined;
|
|
136
|
+
disableAnimation?: boolean | undefined;
|
|
137
|
+
isDisabled?: boolean | undefined;
|
|
138
|
+
isReadOnly?: boolean | undefined;
|
|
139
|
+
fullWidth?: boolean | undefined;
|
|
140
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
141
|
+
caret: (slotProps?: ({
|
|
142
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
143
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
144
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
145
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
146
|
+
isInvalid?: boolean | undefined;
|
|
147
|
+
disableAnimation?: boolean | undefined;
|
|
148
|
+
isDisabled?: boolean | undefined;
|
|
149
|
+
isReadOnly?: boolean | undefined;
|
|
150
|
+
fullWidth?: boolean | undefined;
|
|
151
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
152
|
+
helperWrapper: (slotProps?: ({
|
|
153
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
154
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
155
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
156
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
157
|
+
isInvalid?: boolean | undefined;
|
|
158
|
+
disableAnimation?: boolean | undefined;
|
|
159
|
+
isDisabled?: boolean | undefined;
|
|
160
|
+
isReadOnly?: boolean | undefined;
|
|
161
|
+
fullWidth?: boolean | undefined;
|
|
162
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
163
|
+
errorMessage: (slotProps?: ({
|
|
164
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
165
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
166
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
167
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
168
|
+
isInvalid?: boolean | undefined;
|
|
169
|
+
disableAnimation?: boolean | undefined;
|
|
170
|
+
isDisabled?: boolean | undefined;
|
|
171
|
+
isReadOnly?: boolean | undefined;
|
|
172
|
+
fullWidth?: boolean | undefined;
|
|
173
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
174
|
+
description: (slotProps?: ({
|
|
175
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
176
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
177
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
178
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
179
|
+
isInvalid?: boolean | undefined;
|
|
180
|
+
disableAnimation?: boolean | undefined;
|
|
181
|
+
isDisabled?: boolean | undefined;
|
|
182
|
+
isReadOnly?: boolean | undefined;
|
|
183
|
+
fullWidth?: boolean | undefined;
|
|
184
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
185
|
+
} & {
|
|
186
|
+
base: (slotProps?: ({
|
|
187
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
188
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
189
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
190
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
191
|
+
isInvalid?: boolean | undefined;
|
|
192
|
+
disableAnimation?: boolean | undefined;
|
|
193
|
+
isDisabled?: boolean | undefined;
|
|
194
|
+
isReadOnly?: boolean | undefined;
|
|
195
|
+
fullWidth?: boolean | undefined;
|
|
196
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
197
|
+
wrapper: (slotProps?: ({
|
|
198
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
199
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
200
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
201
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
202
|
+
isInvalid?: boolean | undefined;
|
|
203
|
+
disableAnimation?: boolean | undefined;
|
|
204
|
+
isDisabled?: boolean | undefined;
|
|
205
|
+
isReadOnly?: boolean | undefined;
|
|
206
|
+
fullWidth?: boolean | undefined;
|
|
207
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
208
|
+
input: (slotProps?: ({
|
|
209
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
210
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
211
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
212
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
213
|
+
isInvalid?: boolean | undefined;
|
|
214
|
+
disableAnimation?: boolean | undefined;
|
|
215
|
+
isDisabled?: boolean | undefined;
|
|
216
|
+
isReadOnly?: boolean | undefined;
|
|
217
|
+
fullWidth?: boolean | undefined;
|
|
218
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
219
|
+
segmentWrapper: (slotProps?: ({
|
|
220
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
221
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
222
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
223
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
224
|
+
isInvalid?: boolean | undefined;
|
|
225
|
+
disableAnimation?: boolean | undefined;
|
|
226
|
+
isDisabled?: boolean | undefined;
|
|
227
|
+
isReadOnly?: boolean | undefined;
|
|
228
|
+
fullWidth?: boolean | undefined;
|
|
229
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
230
|
+
segment: (slotProps?: ({
|
|
231
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
232
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
233
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
234
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
235
|
+
isInvalid?: boolean | undefined;
|
|
236
|
+
disableAnimation?: boolean | undefined;
|
|
237
|
+
isDisabled?: boolean | undefined;
|
|
238
|
+
isReadOnly?: boolean | undefined;
|
|
239
|
+
fullWidth?: boolean | undefined;
|
|
240
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
241
|
+
passwordChar: (slotProps?: ({
|
|
242
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
243
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
244
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
245
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
246
|
+
isInvalid?: boolean | undefined;
|
|
247
|
+
disableAnimation?: boolean | undefined;
|
|
248
|
+
isDisabled?: boolean | undefined;
|
|
249
|
+
isReadOnly?: boolean | undefined;
|
|
250
|
+
fullWidth?: boolean | undefined;
|
|
251
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
252
|
+
caret: (slotProps?: ({
|
|
253
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
254
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
255
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
256
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
257
|
+
isInvalid?: boolean | undefined;
|
|
258
|
+
disableAnimation?: boolean | undefined;
|
|
259
|
+
isDisabled?: boolean | undefined;
|
|
260
|
+
isReadOnly?: boolean | undefined;
|
|
261
|
+
fullWidth?: boolean | undefined;
|
|
262
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
263
|
+
helperWrapper: (slotProps?: ({
|
|
264
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
265
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
266
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
267
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
268
|
+
isInvalid?: boolean | undefined;
|
|
269
|
+
disableAnimation?: boolean | undefined;
|
|
270
|
+
isDisabled?: boolean | undefined;
|
|
271
|
+
isReadOnly?: boolean | undefined;
|
|
272
|
+
fullWidth?: boolean | undefined;
|
|
273
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
274
|
+
errorMessage: (slotProps?: ({
|
|
275
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
276
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
277
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
278
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
279
|
+
isInvalid?: boolean | undefined;
|
|
280
|
+
disableAnimation?: boolean | undefined;
|
|
281
|
+
isDisabled?: boolean | undefined;
|
|
282
|
+
isReadOnly?: boolean | undefined;
|
|
283
|
+
fullWidth?: boolean | undefined;
|
|
284
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
285
|
+
description: (slotProps?: ({
|
|
286
|
+
variant?: "flat" | "faded" | "bordered" | "underlined" | undefined;
|
|
287
|
+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined;
|
|
288
|
+
radius?: "md" | "none" | "sm" | "lg" | "full" | undefined;
|
|
289
|
+
size?: "md" | "sm" | "lg" | undefined;
|
|
290
|
+
isInvalid?: boolean | undefined;
|
|
291
|
+
disableAnimation?: boolean | undefined;
|
|
292
|
+
isDisabled?: boolean | undefined;
|
|
293
|
+
isReadOnly?: boolean | undefined;
|
|
294
|
+
fullWidth?: boolean | undefined;
|
|
295
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
296
|
+
} & {};
|
|
297
|
+
hasHelper: boolean;
|
|
298
|
+
classNames: SlotsToClasses<"base" | "wrapper" | "input" | "segmentWrapper" | "segment" | "passwordChar" | "caret" | "helperWrapper" | "errorMessage" | "description"> | undefined;
|
|
299
|
+
isInvalid: boolean;
|
|
300
|
+
description: react.ReactNode;
|
|
301
|
+
errorMessage: react.ReactNode;
|
|
302
|
+
isFocusVisible: boolean;
|
|
303
|
+
isFocused: boolean;
|
|
304
|
+
getBaseProps: PropGetter;
|
|
305
|
+
getInputOtpProps: (props?: Partial<OTPInputProps>) => Omit<OTPInputProps, "children" | "render"> & {
|
|
306
|
+
ref?: ReactRef<HTMLInputElement>;
|
|
307
|
+
};
|
|
308
|
+
getSegmentWrapperProps: PropGetter;
|
|
309
|
+
getHelperWrapperProps: PropGetter;
|
|
310
|
+
getErrorMessageProps: PropGetter;
|
|
311
|
+
getDescriptionProps: PropGetter;
|
|
312
|
+
};
|
|
313
|
+
type UseInputOtpReturn = ReturnType<typeof useInputOtp>;
|
|
314
|
+
|
|
315
|
+
export { type UseInputOtpProps, type UseInputOtpReturn, type ValueTypes, useInputOtp };
|