@catalystsoftware/ui 1.0.5 → 1.0.7

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.
Files changed (155) hide show
  1. package/dist/data/data.tsx +29 -29
  2. package/dist/data/tailwind.config.js +3821 -261
  3. package/dist/data.tsx +29 -29
  4. package/package.json +4 -3
  5. package/components/catalyst-ui/buttons/burger.tsx +0 -207
  6. package/components/catalyst-ui/core/data-display/timeline.tsx +0 -210
  7. package/components/catalyst-ui/core/feedback/alert.tsx +0 -491
  8. package/components/catalyst-ui/core/feedback/spinner-1.tsx +0 -65
  9. package/components/catalyst-ui/core/feedback/toast.tsx +0 -1857
  10. package/components/catalyst-ui/core/navigation/menu.tsx +0 -164
  11. package/components/catalyst-ui/forms/toggle-class.tsx +0 -176
  12. package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +0 -419
  13. package/components/catalyst-ui/hooks/use-counter.tsx +0 -13
  14. package/components/catalyst-ui/hooks/use-event-listener.tsx +0 -23
  15. package/components/catalyst-ui/hooks/use-export-markdown.tsx +0 -47
  16. package/components/catalyst-ui/hooks/use-focus.tsx +0 -17
  17. package/components/catalyst-ui/hooks/use-interval.tsx +0 -23
  18. package/components/catalyst-ui/hooks/use-is-client.tsx +0 -16
  19. package/components/catalyst-ui/hooks/use-media-query.tsx +0 -19
  20. package/components/catalyst-ui/hooks/use-mobile.tsx +0 -19
  21. package/components/catalyst-ui/hooks/use-resize-observer.tsx +0 -81
  22. package/components/catalyst-ui/hooks/use-timeout.tsx +0 -21
  23. package/components/catalyst-ui/hooks/use-timer.tsx +0 -209
  24. package/components/catalyst-ui/hooks/use-toggle.tsx +0 -12
  25. package/components/catalyst-ui/media/image.tsx +0 -13
  26. package/components/catalyst-ui/overlays/dual-sidebar.tsx +0 -4142
  27. package/components/catalyst-ui/overlays/sidebar-original.tsx +0 -726
  28. package/components/catalyst-ui/primitives/accordion.tsx +0 -250
  29. package/components/catalyst-ui/primitives/alert-dialog.tsx +0 -126
  30. package/components/catalyst-ui/primitives/aspect-ratio.tsx +0 -9
  31. package/components/catalyst-ui/primitives/avatar.tsx +0 -296
  32. package/components/catalyst-ui/primitives/badge.tsx +0 -57
  33. package/components/catalyst-ui/primitives/breadcrumb.tsx +0 -101
  34. package/components/catalyst-ui/primitives/button.tsx +0 -265
  35. package/components/catalyst-ui/primitives/calendar-v4.tsx +0 -208
  36. package/components/catalyst-ui/primitives/calendar.tsx +0 -295
  37. package/components/catalyst-ui/primitives/card.tsx +0 -618
  38. package/components/catalyst-ui/primitives/carousel.tsx +0 -238
  39. package/components/catalyst-ui/primitives/chart.tsx +0 -347
  40. package/components/catalyst-ui/primitives/checkbox.tsx +0 -225
  41. package/components/catalyst-ui/primitives/collapsible.tsx +0 -212
  42. package/components/catalyst-ui/primitives/command.tsx +0 -393
  43. package/components/catalyst-ui/primitives/context-menu.tsx +0 -236
  44. package/components/catalyst-ui/primitives/dialog.tsx +0 -471
  45. package/components/catalyst-ui/primitives/drawer.tsx +0 -761
  46. package/components/catalyst-ui/primitives/dropdown-menu.tsx +0 -290
  47. package/components/catalyst-ui/primitives/empty.tsx +0 -104
  48. package/components/catalyst-ui/primitives/field.tsx +0 -244
  49. package/components/catalyst-ui/primitives/hover-card.tsx +0 -124
  50. package/components/catalyst-ui/primitives/input-otp.tsx +0 -76
  51. package/components/catalyst-ui/primitives/input.tsx +0 -64
  52. package/components/catalyst-ui/primitives/item.tsx +0 -196
  53. package/components/catalyst-ui/primitives/kbd.tsx +0 -75
  54. package/components/catalyst-ui/primitives/label.tsx +0 -24
  55. package/components/catalyst-ui/primitives/navigation-menu.tsx +0 -150
  56. package/components/catalyst-ui/primitives/pagination.tsx +0 -198
  57. package/components/catalyst-ui/primitives/popover.tsx +0 -232
  58. package/components/catalyst-ui/primitives/progress.tsx +0 -34
  59. package/components/catalyst-ui/primitives/radio-group.tsx +0 -43
  60. package/components/catalyst-ui/primitives/resizable.tsx +0 -56
  61. package/components/catalyst-ui/primitives/select.tsx +0 -155
  62. package/components/catalyst-ui/primitives/separator.tsx +0 -74
  63. package/components/catalyst-ui/primitives/sheet.tsx +0 -126
  64. package/components/catalyst-ui/primitives/skeleton.tsx +0 -15
  65. package/components/catalyst-ui/primitives/slider.tsx +0 -27
  66. package/components/catalyst-ui/primitives/switch.tsx +0 -187
  67. package/components/catalyst-ui/primitives/tabs.tsx +0 -335
  68. package/components/catalyst-ui/primitives/textarea.tsx +0 -24
  69. package/components/catalyst-ui/primitives/toggle-group.tsx +0 -55
  70. package/components/catalyst-ui/primitives/toggle.tsx +0 -42
  71. package/components/catalyst-ui/primitives/tooltip.tsx +0 -116
  72. package/components/catalyst-ui/utils/basic-auth.tsx +0 -40
  73. package/components/catalyst-ui/utils/context-storage.tsx +0 -19
  74. package/components/catalyst-ui/utils/cors-middleware.tsx +0 -71
  75. package/components/catalyst-ui/utils/deferred-content.tsx +0 -595
  76. package/components/catalyst-ui/utils/honeypot-middleware.tsx +0 -38
  77. package/components/catalyst-ui/utils/incId.tsx +0 -75
  78. package/components/catalyst-ui/utils/jwk-auth.tsx +0 -36
  79. package/components/catalyst-ui/utils/request-id.tsx +0 -14
  80. package/components/catalyst-ui/utils/secure-headers.tsx +0 -37
  81. package/components/catalyst-ui/utils/server-timing.tsx +0 -23
  82. package/components/catalyst-ui/utils/utils.ts +0 -43
  83. package/components/catalyst-ui/utils/with-cookie.tsx +0 -43
  84. package/components/catalyst-ui/x/accordian-x.tsx +0 -428
  85. package/components/catalyst-ui/x/alert-x.tsx +0 -413
  86. package/components/catalyst-ui/x/animated-text-x.tsx +0 -2242
  87. package/components/catalyst-ui/x/avatar-x.tsx +0 -515
  88. package/components/catalyst-ui/x/badge-x.tsx +0 -670
  89. package/components/catalyst-ui/x/button-X.tsx +0 -2857
  90. package/components/catalyst-ui/x/button-group-x.tsx +0 -847
  91. package/components/catalyst-ui/x/calendar-x.tsx +0 -1910
  92. package/components/catalyst-ui/x/card-x.tsx +0 -2597
  93. package/components/catalyst-ui/x/checkbox-x.tsx +0 -656
  94. package/components/catalyst-ui/x/collapsible-x.tsx +0 -1360
  95. package/components/catalyst-ui/x/combobox-x.tsx +0 -911
  96. package/components/catalyst-ui/x/data-table-x.tsx +0 -1753
  97. package/components/catalyst-ui/x/date-picker-x.tsx +0 -648
  98. package/components/catalyst-ui/x/dialog-x.tsx +0 -659
  99. package/components/catalyst-ui/x/dropdown-menu-x.tsx +0 -612
  100. package/components/catalyst-ui/x/hover-card-x.tsx +0 -375
  101. package/components/catalyst-ui/x/icon-x.tsx +0 -840
  102. package/components/catalyst-ui/x/input-mask-x.tsx +0 -981
  103. package/components/catalyst-ui/x/input-otp-x.tsx +0 -659
  104. package/components/catalyst-ui/x/loader-x.tsx +0 -1757
  105. package/components/catalyst-ui/x/pagination-x.tsx +0 -622
  106. package/components/catalyst-ui/x/popover-x.tsx +0 -744
  107. package/components/catalyst-ui/x/radio-group-x.tsx +0 -499
  108. package/components/catalyst-ui/x/select-x.tsx +0 -1127
  109. package/components/catalyst-ui/x/sheet-x.tsx +0 -668
  110. package/components/catalyst-ui/x/switch-x.tsx +0 -681
  111. package/components/catalyst-ui/x/table-x.tsx +0 -574
  112. package/components/catalyst-ui/x/tabs-x.tsx +0 -839
  113. package/components/catalyst-ui/x/textarea-x.tsx +0 -1263
  114. package/components/catalyst-ui/x/tooltip-x.tsx +0 -396
  115. package/components/catalyst-ui/x/tracker-x.tsx +0 -560
  116. package/data/bg-data.tsx +0 -901
  117. package/data/buttons-data.tsx +0 -2327
  118. package/data/charts-data.tsx +0 -102
  119. package/data/chat-data.tsx +0 -83
  120. package/data/code-data.tsx +0 -1040
  121. package/data/comboboxes-data.tsx +0 -1843
  122. package/data/command-data.tsx +0 -1381
  123. package/data/core-data.tsx +0 -15953
  124. package/data/crm-data.tsx +0 -47
  125. package/data/data.tsx +0 -159
  126. package/data/date-and-time-data.tsx +0 -554
  127. package/data/dependencies.tsx +0 -7
  128. package/data/ecommerce-data.tsx +0 -1387
  129. package/data/forms-data.tsx +0 -7890
  130. package/data/hooks-data.tsx +0 -5487
  131. package/data/index.ts +0 -34
  132. package/data/inputs-data.tsx +0 -557
  133. package/data/interactive-data.tsx +0 -5394
  134. package/data/lofi-data.tsx +0 -18295
  135. package/data/marketing-data.tsx +0 -2546
  136. package/data/media-data.tsx +0 -1510
  137. package/data/motion-data.tsx +0 -5801
  138. package/data/overlay-data.tsx +0 -4136
  139. package/data/pdf-data.tsx +0 -124
  140. package/data/pos-data.tsx +0 -213
  141. package/data/postcss.config.js +0 -6
  142. package/data/primitive-data.tsx +0 -5170
  143. package/data/prompt-data.tsx +0 -1226
  144. package/data/requiredLibs.ts +0 -4
  145. package/data/sandbox-data.tsx +0 -1
  146. package/data/sidebars-data.tsx +0 -5421
  147. package/data/stacks-data.tsx +0 -32
  148. package/data/table-data.tsx +0 -706
  149. package/data/tailwind.config.js +0 -270
  150. package/data/tailwind.config.ngin.js +0 -3830
  151. package/data/tailwind.css +0 -431
  152. package/data/tools-data.tsx +0 -6910
  153. package/data/typography-data.tsx +0 -2050
  154. package/data/utils-data.tsx +0 -6500
  155. package/data/x-data.tsx +0 -1171
@@ -1,659 +0,0 @@
1
- 'use client'
2
-
3
- import React, { useId, useState, useEffect } from 'react'
4
- import { REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from 'input-otp'
5
- import { Dot } from 'lucide-react'
6
- import { cva } from 'class-variance-authority'
7
- import { cn } from '~/components/catalyst-ui'
8
- import { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from '~/components/catalyst-ui'
9
- import { Field, FieldLabel, FieldDescription, FieldError } from '~/components/catalyst-ui'
10
-
11
- // #region CVA VARIANTS
12
- export const inputOtpVariants = cva(
13
- 'flex items-center gap-2 has-[:disabled]:opacity-50',
14
- {
15
- variants: {
16
- variant: {
17
- default: '',
18
- outlined: 'gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border',
19
- filled: '*:data-[slot=input-otp-slot]:bg-muted gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border *:data-[slot=input-otp-slot]:border-transparent *:data-[slot=input-otp-slot]:shadow-none',
20
- minimal: 'gap-2 *:data-[active=true]:ring-0 *:data-[slot=input-otp-slot]:rounded-none *:data-[slot=input-otp-slot]:border-0 *:data-[slot=input-otp-slot]:border-b-2 *:data-[slot=input-otp-slot]:shadow-none *:dark:data-[slot=input-otp-slot]:bg-transparent',
21
- },
22
- size: {
23
- sm: '*:data-[slot=input-otp-slot]:h-8 *:data-[slot=input-otp-slot]:w-8 *:data-[slot=input-otp-slot]:text-xs',
24
- default: '*:data-[slot=input-otp-slot]:h-10 *:data-[slot=input-otp-slot]:w-10',
25
- lg: '*:data-[slot=input-otp-slot]:h-12 *:data-[slot=input-otp-slot]:w-12 *:data-[slot=input-otp-slot]:text-base',
26
- },
27
- },
28
- defaultVariants: {
29
- variant: 'default',
30
- size: 'default',
31
- },
32
- }
33
- )
34
- // #endregion
35
-
36
- // #region PARENT FUNCTION
37
- export function InputOtpX({ inputOtp = 'default', ...props }: any) {
38
- switch (inputOtp) {
39
- case 'Number':
40
- return <Number {...props} />
41
- case 'Alphanumeric':
42
- return <Alphanumeric {...props} />
43
- case 'WithResend':
44
- return <WithResend {...props} />
45
- case 'WithResendTimer':
46
- return <WithResendTimer {...props} />
47
- case 'Outlined':
48
- return <Outlined {...props} />
49
- case 'Filled':
50
- return <Filled {...props} />
51
- case 'Minimal':
52
- return <Minimal {...props} />
53
- case 'Grouped':
54
- return <Grouped {...props} />
55
- case 'OutlinedGrouped':
56
- return <OutlinedGrouped {...props} />
57
- case 'CustomSeparator':
58
- return <CustomSeparator {...props} />
59
- default:
60
- return <DefaultInputOtp {...props} />
61
- }
62
- }
63
- // #endregion
64
-
65
- // #region SUPPORTING FUNCTIONS
66
- const DefaultInputOtp = ({ label, description, error, variant, size, className, maxLength = 4, ...props }: any) => {
67
- const id = useId()
68
- return (
69
- <Field className='space-y-3'>
70
- {label && <FieldLabel htmlFor={id}>{label}</FieldLabel>}
71
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
72
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
73
- {Array.from({ length: maxLength }).map((_, index) => (
74
- <InputOTPSlot key={index} index={index} />
75
- ))}
76
- </InputOTPGroup>
77
- </InputOTP>
78
- {description && <FieldDescription>{description}</FieldDescription>}
79
- {error && <FieldError>{error}</FieldError>}
80
- </Field>
81
- )
82
- }
83
-
84
- const Number = ({ label = 'Input OTP number', description, error, variant, size, className, maxLength = 4, ...props }: any) => {
85
- const id = useId()
86
- return (
87
- <Field className='space-y-3'>
88
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
89
- <InputOTP id={id} maxLength={maxLength} pattern={REGEXP_ONLY_DIGITS} className={className} {...props}>
90
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
91
- {Array.from({ length: maxLength }).map((_, index) => (
92
- <InputOTPSlot key={index} index={index} />
93
- ))}
94
- </InputOTPGroup>
95
- </InputOTP>
96
- {description && <FieldDescription>{description}</FieldDescription>}
97
- {error && <FieldError>{error}</FieldError>}
98
- </Field>
99
- )
100
- }
101
-
102
- const Alphanumeric = ({ label = 'Input OTP Alphanumeric', description, error, variant, size, className, maxLength = 4, ...props }: any) => {
103
- const id = useId()
104
- return (
105
- <Field className='space-y-3'>
106
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
107
- <InputOTP id={id} maxLength={maxLength} pattern={REGEXP_ONLY_DIGITS_AND_CHARS} className={className} {...props}>
108
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
109
- {Array.from({ length: maxLength }).map((_, index) => (
110
- <InputOTPSlot key={index} index={index} />
111
- ))}
112
- </InputOTPGroup>
113
- </InputOTP>
114
- {description && <FieldDescription>{description}</FieldDescription>}
115
- {error && <FieldError>{error}</FieldError>}
116
- </Field>
117
- )
118
- }
119
-
120
- const WithResend = ({ label = 'Input OTP with resend', description, error, variant, size, className, maxLength = 4, ...props }: any) => {
121
- const id = useId()
122
- return (
123
- <Field className='space-y-3'>
124
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
125
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
126
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
127
- {Array.from({ length: maxLength }).map((_, index) => (
128
- <InputOTPSlot key={index} index={index} />
129
- ))}
130
- </InputOTPGroup>
131
- </InputOTP>
132
- <p className='text-muted-foreground text-xs'>
133
- Didn&apos;t get the code?{' '}
134
- <a href='#' className='text-primary hover:underline'>
135
- Resend code
136
- </a>
137
- </p>
138
- {description && <FieldDescription>{description}</FieldDescription>}
139
- {error && <FieldError>{error}</FieldError>}
140
- </Field>
141
- )
142
- }
143
-
144
- const WithResendTimer = ({ label = 'Input OTP with resend timer', description, error, variant, size, className, maxLength = 4, initialTimer = 30, ...props }: any) => {
145
- const [timeLeft, setTimeLeft] = useState(initialTimer)
146
- const id = useId()
147
-
148
- useEffect(() => {
149
- if (timeLeft > 0) {
150
- const timer = setTimeout(() => {
151
- setTimeLeft(prev => prev - 1)
152
- }, 1000)
153
-
154
- return () => clearTimeout(timer)
155
- }
156
- }, [timeLeft])
157
-
158
- const formatTime = (seconds: number) => {
159
- const mins = Math.floor(seconds / 60)
160
- const secs = seconds % 60
161
-
162
- return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
163
- }
164
-
165
- const handleResend = () => {
166
- setTimeLeft(60)
167
- }
168
-
169
- return (
170
- <Field className='space-y-3'>
171
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
172
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
173
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
174
- {Array.from({ length: maxLength }).map((_, index) => (
175
- <InputOTPSlot key={index} index={index} />
176
- ))}
177
- </InputOTPGroup>
178
- </InputOTP>
179
- <p className='text-muted-foreground text-xs'>
180
- {timeLeft > 0 ? (
181
- `Resend available in ${formatTime(timeLeft)}`
182
- ) : (
183
- <a
184
- href='#'
185
- onClick={e => {
186
- e.preventDefault()
187
- handleResend()
188
- }}
189
- className='hover:text-primary underline'
190
- >
191
- Resend code
192
- </a>
193
- )}
194
- </p>
195
- {description && <FieldDescription>{description}</FieldDescription>}
196
- {error && <FieldError>{error}</FieldError>}
197
- </Field>
198
- )
199
- }
200
-
201
- const Outlined = ({ label = 'Input OTP outlined', description, error, size, className, maxLength = 4, ...props }: any) => {
202
- const id = useId()
203
- return (
204
- <Field className='space-y-3'>
205
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
206
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
207
- <InputOTPGroup className={cn(inputOtpVariants({ variant: 'outlined', size }))}>
208
- {Array.from({ length: maxLength }).map((_, index) => (
209
- <InputOTPSlot key={index} index={index} />
210
- ))}
211
- </InputOTPGroup>
212
- </InputOTP>
213
- {description && <FieldDescription>{description}</FieldDescription>}
214
- {error && <FieldError>{error}</FieldError>}
215
- </Field>
216
- )
217
- }
218
-
219
- const Filled = ({ label = 'Input OTP filled', description, error, size, className, maxLength = 4, ...props }: any) => {
220
- const id = useId()
221
- return (
222
- <Field className='space-y-3'>
223
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
224
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
225
- <InputOTPGroup className={cn(inputOtpVariants({ variant: 'filled', size }))}>
226
- {Array.from({ length: maxLength }).map((_, index) => (
227
- <InputOTPSlot key={index} index={index} />
228
- ))}
229
- </InputOTPGroup>
230
- </InputOTP>
231
- {description && <FieldDescription>{description}</FieldDescription>}
232
- {error && <FieldError>{error}</FieldError>}
233
- </Field>
234
- )
235
- }
236
-
237
- const Minimal = ({ label = 'Input OTP minimal', description, error, size, className, maxLength = 4, ...props }: any) => {
238
- const id = useId()
239
- return (
240
- <Field className='space-y-3'>
241
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
242
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
243
- <InputOTPGroup className={cn(inputOtpVariants({ variant: 'minimal', size }))}>
244
- {Array.from({ length: maxLength }).map((_, index) => (
245
- <InputOTPSlot key={index} index={index} />
246
- ))}
247
- </InputOTPGroup>
248
- </InputOTP>
249
- {description && <FieldDescription>{description}</FieldDescription>}
250
- {error && <FieldError>{error}</FieldError>}
251
- </Field>
252
- )
253
- }
254
-
255
- const Grouped = ({ label = 'Input OTP Grouped', description, error, variant, size, className, maxLength = 6, ...props }: any) => {
256
- const id = useId()
257
- const halfLength = Math.floor(maxLength / 2)
258
-
259
- return (
260
- <Field className='space-y-3'>
261
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
262
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
263
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
264
- {Array.from({ length: halfLength }).map((_, index) => (
265
- <InputOTPSlot key={index} index={index} />
266
- ))}
267
- </InputOTPGroup>
268
- <InputOTPSeparator />
269
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
270
- {Array.from({ length: maxLength - halfLength }).map((_, index) => (
271
- <InputOTPSlot key={index + halfLength} index={index + halfLength} />
272
- ))}
273
- </InputOTPGroup>
274
- </InputOTP>
275
- {description && <FieldDescription>{description}</FieldDescription>}
276
- {error && <FieldError>{error}</FieldError>}
277
- </Field>
278
- )
279
- }
280
-
281
- const OutlinedGrouped = ({ label = 'Input OTP Outline Grouped', description, error, size, className, maxLength = 6, ...props }: any) => {
282
- const id = useId()
283
- const halfLength = Math.floor(maxLength / 2)
284
-
285
- return (
286
- <Field className='space-y-3'>
287
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
288
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
289
- <InputOTPGroup className={cn(inputOtpVariants({ variant: 'outlined', size }))}>
290
- {Array.from({ length: halfLength }).map((_, index) => (
291
- <InputOTPSlot key={index} index={index} />
292
- ))}
293
- </InputOTPGroup>
294
- <InputOTPSeparator />
295
- <InputOTPGroup className={cn(inputOtpVariants({ variant: 'outlined', size }))}>
296
- {Array.from({ length: maxLength - halfLength }).map((_, index) => (
297
- <InputOTPSlot key={index + halfLength} index={index + halfLength} />
298
- ))}
299
- </InputOTPGroup>
300
- </InputOTP>
301
- {description && <FieldDescription>{description}</FieldDescription>}
302
- {error && <FieldError>{error}</FieldError>}
303
- </Field>
304
- )
305
- }
306
-
307
- const CustomSeparator = ({ label = 'Input OTP Custom Separator', description, error, variant, size, className, maxLength = 6, ...props }: any) => {
308
- const id = useId()
309
- const halfLength = Math.floor(maxLength / 2)
310
-
311
- return (
312
- <Field className='space-y-3'>
313
- <FieldLabel htmlFor={id}>{label}</FieldLabel>
314
- <InputOTP id={id} maxLength={maxLength} className={className} {...props}>
315
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
316
- {Array.from({ length: halfLength }).map((_, index) => (
317
- <InputOTPSlot key={index} index={index} />
318
- ))}
319
- </InputOTPGroup>
320
- <div role='separator' className='text-muted-foreground'>
321
- <Dot />
322
- </div>
323
- <InputOTPGroup className={cn(inputOtpVariants({ variant, size }))}>
324
- {Array.from({ length: maxLength - halfLength }).map((_, index) => (
325
- <InputOTPSlot key={index + halfLength} index={index + halfLength} />
326
- ))}
327
- </InputOTPGroup>
328
- </InputOTP>
329
- {description && <FieldDescription>{description}</FieldDescription>}
330
- {error && <FieldError>{error}</FieldError>}
331
- </Field>
332
- )
333
- }
334
- // #endregion
335
-
336
- // #region DEMO
337
- export function InputOtpXDemo() {
338
- return (
339
- <div className='space-y-12 p-6 max-w-3xl mx-auto'>
340
- <div>
341
- <h3 className='text-lg font-semibold mb-4'>Default</h3>
342
- <InputOtpX label='Default OTP' />
343
- </div>
344
-
345
- <div>
346
- <h3 className='text-lg font-semibold mb-4'>Number Only</h3>
347
- <InputOtpX inputOtp='Number' />
348
- </div>
349
-
350
- <div>
351
- <h3 className='text-lg font-semibold mb-4'>Alphanumeric</h3>
352
- <InputOtpX inputOtp='Alphanumeric' />
353
- </div>
354
-
355
- <div>
356
- <h3 className='text-lg font-semibold mb-4'>With Resend</h3>
357
- <InputOtpX inputOtp='WithResend' />
358
- </div>
359
-
360
- <div>
361
- <h3 className='text-lg font-semibold mb-4'>With Resend Timer</h3>
362
- <InputOtpX inputOtp='WithResendTimer' />
363
- </div>
364
-
365
- <div>
366
- <h3 className='text-lg font-semibold mb-4'>Outlined</h3>
367
- <InputOtpX inputOtp='Outlined' />
368
- </div>
369
-
370
- <div>
371
- <h3 className='text-lg font-semibold mb-4'>Filled</h3>
372
- <InputOtpX inputOtp='Filled' />
373
- </div>
374
-
375
- <div>
376
- <h3 className='text-lg font-semibold mb-4'>Minimal</h3>
377
- <InputOtpX inputOtp='Minimal' />
378
- </div>
379
-
380
- <div>
381
- <h3 className='text-lg font-semibold mb-4'>Grouped</h3>
382
- <InputOtpX inputOtp='Grouped' />
383
- </div>
384
-
385
- <div>
386
- <h3 className='text-lg font-semibold mb-4'>Outlined Grouped</h3>
387
- <InputOtpX inputOtp='OutlinedGrouped' />
388
- </div>
389
-
390
- <div>
391
- <h3 className='text-lg font-semibold mb-4'>Custom Separator</h3>
392
- <InputOtpX inputOtp='CustomSeparator' />
393
- </div>
394
- </div>
395
- )
396
- }
397
- // #endregion
398
-
399
-
400
-
401
- /**
402
-
403
-
404
-
405
-
406
-
407
-
408
- export function InputOtpX({ inputOtp = 'default', children, ...props }: any) {
409
- switch (inputOtp) {
410
- case 'Closable':
411
- break
412
- default:
413
- break;
414
- }
415
- }
416
-
417
- const InputOTPNumberDemo = () => {
418
- const id = useId()
419
-
420
- return (
421
- <div className='space-y-3'>
422
- <Label htmlFor={id}>Input OTP number</Label>
423
- <InputOTP id={id} maxLength={4} pattern={REGEXP_ONLY_DIGITS}>
424
- <InputOTPGroup>
425
- <InputOTPSlot index={0} />
426
- <InputOTPSlot index={1} />
427
- <InputOTPSlot index={2} />
428
- <InputOTPSlot index={3} />
429
- </InputOTPGroup>
430
- </InputOTP>
431
- </div>
432
- )
433
- }
434
-
435
- const InputOTPAlphanumericDemo = () => {
436
- const id = useId()
437
-
438
- return (
439
- <div className='space-y-3'>
440
- <Label htmlFor={id}>Input OTP Alphanumeric</Label>
441
- <InputOTP id={id} maxLength={4} pattern={REGEXP_ONLY_DIGITS_AND_CHARS}>
442
- <InputOTPGroup>
443
- <InputOTPSlot index={0} />
444
- <InputOTPSlot index={1} />
445
- <InputOTPSlot index={2} />
446
- <InputOTPSlot index={3} />
447
- </InputOTPGroup>
448
- </InputOTP>
449
- </div>
450
- )
451
- }
452
-
453
- const InputOTPWithResendDemo = () => {
454
- const id = useId()
455
-
456
- return (
457
- <div className='space-y-3'>
458
- <Label htmlFor={id}>Input OTP with resend</Label>
459
- <InputOTP id={id} maxLength={4}>
460
- <InputOTPGroup>
461
- <InputOTPSlot index={0} />
462
- <InputOTPSlot index={1} />
463
- <InputOTPSlot index={2} />
464
- <InputOTPSlot index={3} />
465
- </InputOTPGroup>
466
- </InputOTP>
467
- <p className='text-muted-foreground text-xs'>
468
- Didn&apos;t get the code?{' '}
469
- <a href='#' className='text-primary hover:underline'>
470
- Resend code
471
- </a>
472
- </p>
473
- </div>
474
- )
475
- }
476
-
477
- const InputOTPWithResendTimerDemo = () => {
478
- const [timeLeft, setTimeLeft] = useState(30)
479
- const id = useId()
480
-
481
- useEffect(() => {
482
- if (timeLeft > 0) {
483
- const timer = setTimeout(() => {
484
- setTimeLeft(prev => prev - 1)
485
- }, 1000)
486
-
487
- return () => clearTimeout(timer)
488
- }
489
- }, [timeLeft])
490
-
491
- const formatTime = (seconds: number) => {
492
- const mins = Math.floor(seconds / 60)
493
- const secs = seconds % 60
494
-
495
- return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
496
- }
497
-
498
- const handleResend = () => {
499
- setTimeLeft(60)
500
- }
501
-
502
- return (
503
- <div className='space-y-3'>
504
- <Label htmlFor={id}>Input OTP with resend timer</Label>
505
- <InputOTP id={id} maxLength={4}>
506
- <InputOTPGroup>
507
- <InputOTPSlot index={0} />
508
- <InputOTPSlot index={1} />
509
- <InputOTPSlot index={2} />
510
- <InputOTPSlot index={3} />
511
- </InputOTPGroup>
512
- </InputOTP>
513
- <p className='text-muted-foreground text-xs'>
514
- {timeLeft > 0 ? (
515
- `Resend available in ${formatTime(timeLeft)}`
516
- ) : (
517
- <a
518
- href='#'
519
- onClick={e => {
520
- e.preventDefault()
521
- handleResend()
522
- }}
523
- className='hover:text-primary underline'
524
- >
525
- Resend code
526
- </a>
527
- )}
528
- </p>
529
- </div>
530
- )
531
- }
532
-
533
- const InputOTPOutlinedDemo = () => {
534
- const id = useId()
535
-
536
- return (
537
- <div className='space-y-3'>
538
- <Label htmlFor={id}>Input OTP outlined</Label>
539
- <InputOTP id={id} maxLength={4}>
540
- <InputOTPGroup className='gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border'>
541
- <InputOTPSlot index={0} />
542
- <InputOTPSlot index={1} />
543
- <InputOTPSlot index={2} />
544
- <InputOTPSlot index={3} />
545
- </InputOTPGroup>
546
- </InputOTP>
547
- </div>
548
- )
549
- }
550
-
551
- const InputOTPFilledDemo = () => {
552
- const id = useId()
553
-
554
- return (
555
- <div className='space-y-3'>
556
- <Label htmlFor={id}>Input OTP filled</Label>
557
- <InputOTP id={id} maxLength={4}>
558
- <InputOTPGroup className='*:data-[slot=input-otp-slot]:bg-muted gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border *:data-[slot=input-otp-slot]:border-transparent *:data-[slot=input-otp-slot]:shadow-none'>
559
- <InputOTPSlot index={0} />
560
- <InputOTPSlot index={1} />
561
- <InputOTPSlot index={2} />
562
- <InputOTPSlot index={3} />
563
- </InputOTPGroup>
564
- </InputOTP>
565
- </div>
566
- )
567
- }
568
-
569
- const InputOTPMinimalDemo = () => {
570
- const id = useId()
571
-
572
- return (
573
- <div className='space-y-3'>
574
- <Label htmlFor={id}>Input OTP minimal</Label>
575
- <InputOTP id={id} maxLength={4}>
576
- <InputOTPGroup className='gap-2 *:data-[active=true]:ring-0 *:data-[slot=input-otp-slot]:rounded-none *:data-[slot=input-otp-slot]:border-0 *:data-[slot=input-otp-slot]:border-b-2 *:data-[slot=input-otp-slot]:shadow-none *:dark:data-[slot=input-otp-slot]:bg-transparent'>
577
- <InputOTPSlot index={0} />
578
- <InputOTPSlot index={1} />
579
- <InputOTPSlot index={2} />
580
- <InputOTPSlot index={3} />
581
- </InputOTPGroup>
582
- </InputOTP>
583
- </div>
584
- )
585
- }
586
-
587
- const InputOTPGroupedDemo = () => {
588
- const id = useId()
589
-
590
- return (
591
- <div className='space-y-3'>
592
- <Label htmlFor={id}>Input OTP Grouped</Label>
593
- <InputOTP id={id} maxLength={6}>
594
- <InputOTPGroup>
595
- <InputOTPSlot index={0} />
596
- <InputOTPSlot index={1} />
597
- <InputOTPSlot index={2} />
598
- </InputOTPGroup>
599
- <InputOTPSeparator />
600
- <InputOTPGroup>
601
- <InputOTPSlot index={3} />
602
- <InputOTPSlot index={4} />
603
- <InputOTPSlot index={5} />
604
- </InputOTPGroup>
605
- </InputOTP>
606
- </div>
607
- )
608
- }
609
-
610
- const InputOTPOutlinedGroupedDemo = () => {
611
- const id = useId()
612
-
613
- return (
614
- <div className='space-y-3'>
615
- <Label htmlFor={id}>Input OTP Outline Grouped</Label>
616
- <InputOTP id={id} maxLength={6}>
617
- <InputOTPGroup className='gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border'>
618
- <InputOTPSlot index={0} />
619
- <InputOTPSlot index={1} />
620
- <InputOTPSlot index={2} />
621
- </InputOTPGroup>
622
- <InputOTPSeparator />
623
- <InputOTPGroup className='gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border'>
624
- <InputOTPSlot index={3} />
625
- <InputOTPSlot index={4} />
626
- <InputOTPSlot index={5} />
627
- </InputOTPGroup>
628
- </InputOTP>
629
- </div>
630
- )
631
- }
632
-
633
- const InputOTPCustomSeparatorDemo = () => {
634
- const id = useId()
635
-
636
- return (
637
- <div className='space-y-3'>
638
- <Label htmlFor={id}>Input OTP Custom Separator</Label>
639
- <InputOTP id={id} maxLength={6}>
640
- <InputOTPGroup>
641
- <InputOTPSlot index={0} />
642
- <InputOTPSlot index={1} />
643
- <InputOTPSlot index={2} />
644
- </InputOTPGroup>
645
- <div role='separator' className='text-muted-foreground'>
646
- <DotIcon />
647
- </div>
648
- <InputOTPGroup>
649
- <InputOTPSlot index={3} />
650
- <InputOTPSlot index={4} />
651
- <InputOTPSlot index={5} />
652
- </InputOTPGroup>
653
- </InputOTP>
654
- </div>
655
- )
656
- } */
657
-
658
-
659
-