@hanzo/ui 1.0.14 → 1.0.15
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/package.json +2 -1
- package/primitives/index.ts +7 -0
- package/primitives/input-otp.tsx +65 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"class-variance-authority": "^0.7.0",
|
|
55
55
|
"clsx": "^2.1.0",
|
|
56
56
|
"cmdk": "^0.2.0",
|
|
57
|
+
"input-otp": "^1.0.1",
|
|
57
58
|
"lodash.castarray": "^4.4.0",
|
|
58
59
|
"lodash.isplainobject": "^4.0.6",
|
|
59
60
|
"lodash.merge": "^4.6.2",
|
package/primitives/index.ts
CHANGED
|
@@ -124,6 +124,13 @@ export {
|
|
|
124
124
|
AvatarFallback
|
|
125
125
|
} from './avatar'
|
|
126
126
|
|
|
127
|
+
export {
|
|
128
|
+
InputOTP,
|
|
129
|
+
InputOTPGroup,
|
|
130
|
+
InputOTPSeparator,
|
|
131
|
+
InputOTPSlot,
|
|
132
|
+
} from './input-otp'
|
|
133
|
+
|
|
127
134
|
export { Toggle, toggleVariants } from './toggle'
|
|
128
135
|
export { ToggleGroup, ToggleGroupItem } from './toggle-group'
|
|
129
136
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { OTPInput, type SlotProps } from 'input-otp'
|
|
5
|
+
import { Dot } from 'lucide-react'
|
|
6
|
+
|
|
7
|
+
import { cn } from '../util'
|
|
8
|
+
|
|
9
|
+
const InputOTP = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof OTPInput>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof OTPInput>
|
|
12
|
+
>(({ className, ...props }, ref) => (
|
|
13
|
+
<OTPInput
|
|
14
|
+
ref={ref}
|
|
15
|
+
containerClassName={cn('flex items-center gap-2', className)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
))
|
|
19
|
+
InputOTP.displayName = 'InputOTP'
|
|
20
|
+
|
|
21
|
+
const InputOTPGroup = React.forwardRef<
|
|
22
|
+
React.ElementRef<'div'>,
|
|
23
|
+
React.ComponentPropsWithoutRef<'div'>
|
|
24
|
+
>(({ className, ...props }, ref) => (
|
|
25
|
+
<div ref={ref} className={cn('flex items-center', className)} {...props} />
|
|
26
|
+
))
|
|
27
|
+
InputOTPGroup.displayName = 'InputOTPGroup'
|
|
28
|
+
|
|
29
|
+
const InputOTPSlot = React.forwardRef<
|
|
30
|
+
React.ElementRef<'div'>,
|
|
31
|
+
SlotProps & React.ComponentPropsWithoutRef<'div'>
|
|
32
|
+
>(({ char, hasFakeCaret, isActive, className, ...props }, ref) => {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(
|
|
37
|
+
'relative flex h-10 w-10 items-center justify-center border-y border-r border-muted-2 text-sm ',
|
|
38
|
+
'transition-all first:rounded-l-md first:border-l last:rounded-r-md',
|
|
39
|
+
isActive && 'z-10 ring-2 ring-muted', // TODO: couldn't find: 'ring-offset-background'
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{char}
|
|
45
|
+
{hasFakeCaret && (
|
|
46
|
+
<div className='pointer-events-none absolute inset-0 flex items-center justify-center'>
|
|
47
|
+
<div className='animate-caret-blink h-4 w-px bg-foreground duration-1000' />
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
InputOTPSlot.displayName = 'InputOTPSlot'
|
|
54
|
+
|
|
55
|
+
const InputOTPSeparator = React.forwardRef<
|
|
56
|
+
React.ElementRef<'div'>,
|
|
57
|
+
React.ComponentPropsWithoutRef<'div'>
|
|
58
|
+
>(({ ...props }, ref) => (
|
|
59
|
+
<div ref={ref} role='separator' {...props}>
|
|
60
|
+
<Dot />
|
|
61
|
+
</div>
|
|
62
|
+
))
|
|
63
|
+
InputOTPSeparator.displayName = 'InputOTPSeparator'
|
|
64
|
+
|
|
65
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|