@meith/ui 0.23.2 → 0.24.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meith/ui",
3
- "version": "0.23.2",
3
+ "version": "0.24.0",
4
4
  "description": "Meith's shared UI primitives: buttons, menus and the class utilities themes build with.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,7 @@
14
14
  "exports": {
15
15
  ".": "./src/index.ts",
16
16
  "./button": "./src/button.tsx",
17
+ "./input-otp": "./src/input-otp.tsx",
17
18
  "./menu": "./src/menu.tsx",
18
19
  "./popover": "./src/popover.tsx",
19
20
  "./tabs": "./src/tabs.tsx",
@@ -32,6 +33,7 @@
32
33
  "@base-ui/react": "^1.7.0",
33
34
  "class-variance-authority": "^0.7.1",
34
35
  "clsx": "^2.1.1",
36
+ "input-otp": "^1.5.0",
35
37
  "tailwind-merge": "^3.4.1"
36
38
  },
37
39
  "peerDependencies": {
package/src/alert.tsx CHANGED
@@ -8,7 +8,8 @@ const alertVariants = cva(
8
8
  variants: {
9
9
  tone: {
10
10
  info: 'border-border border-l-muted-foreground bg-card text-card-foreground',
11
- success: 'border-border border-l-moderation-approved bg-card text-card-foreground',
11
+ success:
12
+ 'border-moderation-approved/30 border-l-moderation-approved bg-moderation-approved/5 text-card-foreground',
12
13
  warning: 'border-border border-l-moderation-pending bg-card text-card-foreground',
13
14
  error: 'border-destructive/30 border-l-destructive bg-destructive/5 text-card-foreground',
14
15
  },
@@ -0,0 +1,92 @@
1
+ 'use client'
2
+
3
+ import { OTPInput, OTPInputContext, REGEXP_ONLY_DIGITS } from 'input-otp'
4
+ import { type ComponentProps, useContext } from 'react'
5
+
6
+ import { cn } from './utils'
7
+
8
+ function InputOTP({
9
+ className,
10
+ containerClassName,
11
+ ...props
12
+ }: ComponentProps<typeof OTPInput> & {
13
+ containerClassName?: string
14
+ }) {
15
+ return (
16
+ <OTPInput
17
+ data-slot="input-otp"
18
+ containerClassName={cn(
19
+ 'flex items-center gap-2 has-[:disabled]:opacity-60',
20
+ containerClassName,
21
+ )}
22
+ className={cn('disabled:cursor-not-allowed', className)}
23
+ {...props}
24
+ />
25
+ )
26
+ }
27
+
28
+ function InputOTPGroup({ className, ...props }: ComponentProps<'div'>) {
29
+ return (
30
+ <div data-slot="input-otp-group" className={cn('flex items-center', className)} {...props} />
31
+ )
32
+ }
33
+
34
+ function InputOTPSlot({
35
+ index,
36
+ className,
37
+ ...props
38
+ }: ComponentProps<'div'> & {
39
+ index: number
40
+ }) {
41
+ const context = useContext(OTPInputContext)
42
+ const { char, hasFakeCaret, isActive } = context.slots[index] ?? {}
43
+
44
+ return (
45
+ <div
46
+ data-slot="input-otp-slot"
47
+ data-active={isActive ? '' : undefined}
48
+ className={cn(
49
+ 'relative flex h-9 w-9 items-center justify-center border-y border-r border-input bg-card text-sm',
50
+ 'transition duration-100 outline-none',
51
+ 'first:rounded-l-md first:border-l last:rounded-r-md',
52
+ 'aria-invalid:border-destructive',
53
+ 'data-[active]:z-10 data-[active]:border-ring data-[active]:ring-[3px] data-[active]:ring-ring/50',
54
+ 'data-[active]:aria-invalid:border-destructive data-[active]:aria-invalid:ring-destructive/20',
55
+ className,
56
+ )}
57
+ {...props}
58
+ >
59
+ {char}
60
+ {hasFakeCaret && (
61
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
62
+ <div className="h-4 w-px animate-pulse bg-foreground" />
63
+ </div>
64
+ )}
65
+ </div>
66
+ )
67
+ }
68
+
69
+ function InputOTPSeparator({ className, ...props }: ComponentProps<'div'>) {
70
+ return (
71
+ <div
72
+ data-slot="input-otp-separator"
73
+ aria-hidden="true"
74
+ className={cn('flex items-center text-muted-foreground', className)}
75
+ {...props}
76
+ >
77
+ <svg
78
+ aria-hidden="true"
79
+ viewBox="0 0 12 12"
80
+ className="size-3"
81
+ fill="none"
82
+ stroke="currentColor"
83
+ strokeWidth="1.5"
84
+ strokeLinecap="round"
85
+ >
86
+ <path d="M2.5 6h7" />
87
+ </svg>
88
+ </div>
89
+ )
90
+ }
91
+
92
+ export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, REGEXP_ONLY_DIGITS }