better-auth-ui 3.2.6 → 3.2.12
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 +30 -3
- package/dist/index.cjs +653 -661
- package/dist/index.d.cts +19 -15
- package/dist/index.d.ts +19 -15
- package/dist/index.js +665 -673
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +161 -156
- package/src/components/organization/organization-cell-view.tsx +2 -2
- package/src/components/organization/organization-invitations-card.tsx +3 -1
- package/src/components/organization/organization-view.tsx +6 -6
- package/src/components/organization/organizations-card.tsx +3 -1
- package/src/components/organization/user-invitations-card.tsx +3 -1
- package/src/components/ui/alert.tsx +37 -44
- package/src/components/ui/avatar.tsx +39 -44
- package/src/components/ui/button.tsx +28 -30
- package/src/components/ui/card.tsx +66 -82
- package/src/components/ui/checkbox.tsx +20 -24
- package/src/components/ui/dialog.tsx +92 -113
- package/src/components/ui/drawer.tsx +82 -101
- package/src/components/ui/dropdown-menu.tsx +183 -224
- package/src/components/ui/form.tsx +50 -39
- package/src/components/ui/input-otp.tsx +43 -51
- package/src/components/ui/input.tsx +16 -15
- package/src/components/ui/label.tsx +17 -17
- package/src/components/ui/select.tsx +130 -156
- package/src/components/ui/separator.tsx +13 -12
- package/src/components/ui/skeleton.tsx +5 -3
- package/src/components/ui/tabs.tsx +43 -54
- package/src/components/ui/textarea.tsx +8 -4
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Controller,
|
|
8
8
|
FormProvider,
|
|
9
9
|
useFormContext,
|
|
10
|
-
useFormState,
|
|
11
10
|
type ControllerProps,
|
|
12
11
|
type FieldPath,
|
|
13
12
|
type FieldValues,
|
|
@@ -20,18 +19,16 @@ const Form = FormProvider
|
|
|
20
19
|
|
|
21
20
|
type FormFieldContextValue<
|
|
22
21
|
TFieldValues extends FieldValues = FieldValues,
|
|
23
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues
|
|
22
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
24
23
|
> = {
|
|
25
24
|
name: TName
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
29
|
-
{} as FormFieldContextValue
|
|
30
|
-
)
|
|
27
|
+
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null)
|
|
31
28
|
|
|
32
29
|
const FormField = <
|
|
33
30
|
TFieldValues extends FieldValues = FieldValues,
|
|
34
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues
|
|
31
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
35
32
|
>({
|
|
36
33
|
...props
|
|
37
34
|
}: ControllerProps<TFieldValues, TName>) => {
|
|
@@ -45,14 +42,18 @@ const FormField = <
|
|
|
45
42
|
const useFormField = () => {
|
|
46
43
|
const fieldContext = React.useContext(FormFieldContext)
|
|
47
44
|
const itemContext = React.useContext(FormItemContext)
|
|
48
|
-
const { getFieldState } = useFormContext()
|
|
49
|
-
const formState = useFormState({ name: fieldContext.name })
|
|
50
|
-
const fieldState = getFieldState(fieldContext.name, formState)
|
|
45
|
+
const { getFieldState, formState } = useFormContext()
|
|
51
46
|
|
|
52
47
|
if (!fieldContext) {
|
|
53
48
|
throw new Error("useFormField should be used within <FormField>")
|
|
54
49
|
}
|
|
55
50
|
|
|
51
|
+
if (!itemContext) {
|
|
52
|
+
throw new Error("useFormField should be used within <FormItem>")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const fieldState = getFieldState(fieldContext.name, formState)
|
|
56
|
+
|
|
56
57
|
const { id } = itemContext
|
|
57
58
|
|
|
58
59
|
return {
|
|
@@ -69,47 +70,48 @@ type FormItemContextValue = {
|
|
|
69
70
|
id: string
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
73
|
-
{} as FormItemContextValue
|
|
74
|
-
)
|
|
73
|
+
const FormItemContext = React.createContext<FormItemContextValue | null>(null)
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
const FormItem = React.forwardRef<
|
|
76
|
+
HTMLDivElement,
|
|
77
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
78
|
+
>(({ className, ...props }, ref) => {
|
|
77
79
|
const id = React.useId()
|
|
78
80
|
|
|
79
81
|
return (
|
|
80
82
|
<FormItemContext.Provider value={{ id }}>
|
|
81
|
-
<div
|
|
82
|
-
data-slot="form-item"
|
|
83
|
-
className={cn("grid gap-2", className)}
|
|
84
|
-
{...props}
|
|
85
|
-
/>
|
|
83
|
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
|
86
84
|
</FormItemContext.Provider>
|
|
87
85
|
)
|
|
88
|
-
}
|
|
86
|
+
})
|
|
87
|
+
FormItem.displayName = "FormItem"
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
89
|
+
const FormLabel = React.forwardRef<
|
|
90
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
91
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
92
|
+
>(({ className, ...props }, ref) => {
|
|
94
93
|
const { error, formItemId } = useFormField()
|
|
95
94
|
|
|
96
95
|
return (
|
|
97
96
|
<Label
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
className={cn("data-[error=true]:text-destructive", className)}
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={cn(error && "text-destructive", className)}
|
|
101
99
|
htmlFor={formItemId}
|
|
102
100
|
{...props}
|
|
103
101
|
/>
|
|
104
102
|
)
|
|
105
|
-
}
|
|
103
|
+
})
|
|
104
|
+
FormLabel.displayName = "FormLabel"
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
const FormControl = React.forwardRef<
|
|
107
|
+
React.ElementRef<typeof Slot>,
|
|
108
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
|
109
|
+
>(({ ...props }, ref) => {
|
|
108
110
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
|
109
111
|
|
|
110
112
|
return (
|
|
111
113
|
<Slot
|
|
112
|
-
|
|
114
|
+
ref={ref}
|
|
113
115
|
id={formItemId}
|
|
114
116
|
aria-describedby={
|
|
115
117
|
!error
|
|
@@ -120,24 +122,32 @@ function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
|
|
120
122
|
{...props}
|
|
121
123
|
/>
|
|
122
124
|
)
|
|
123
|
-
}
|
|
125
|
+
})
|
|
126
|
+
FormControl.displayName = "FormControl"
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
const FormDescription = React.forwardRef<
|
|
129
|
+
HTMLParagraphElement,
|
|
130
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
131
|
+
>(({ className, ...props }, ref) => {
|
|
126
132
|
const { formDescriptionId } = useFormField()
|
|
127
133
|
|
|
128
134
|
return (
|
|
129
135
|
<p
|
|
130
|
-
|
|
136
|
+
ref={ref}
|
|
131
137
|
id={formDescriptionId}
|
|
132
|
-
className={cn("text-muted-foreground
|
|
138
|
+
className={cn("text-[0.8rem] text-muted-foreground", className)}
|
|
133
139
|
{...props}
|
|
134
140
|
/>
|
|
135
141
|
)
|
|
136
|
-
}
|
|
142
|
+
})
|
|
143
|
+
FormDescription.displayName = "FormDescription"
|
|
137
144
|
|
|
138
|
-
|
|
145
|
+
const FormMessage = React.forwardRef<
|
|
146
|
+
HTMLParagraphElement,
|
|
147
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
148
|
+
>(({ className, children, ...props }, ref) => {
|
|
139
149
|
const { error, formMessageId } = useFormField()
|
|
140
|
-
const body = error ? String(error?.message ?? "") :
|
|
150
|
+
const body = error ? String(error?.message ?? "") : children
|
|
141
151
|
|
|
142
152
|
if (!body) {
|
|
143
153
|
return null
|
|
@@ -145,15 +155,16 @@ function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
145
155
|
|
|
146
156
|
return (
|
|
147
157
|
<p
|
|
148
|
-
|
|
158
|
+
ref={ref}
|
|
149
159
|
id={formMessageId}
|
|
150
|
-
className={cn("text-
|
|
160
|
+
className={cn("text-[0.8rem] font-medium text-destructive", className)}
|
|
151
161
|
{...props}
|
|
152
162
|
>
|
|
153
163
|
{body}
|
|
154
164
|
</p>
|
|
155
165
|
)
|
|
156
|
-
}
|
|
166
|
+
})
|
|
167
|
+
FormMessage.displayName = "FormMessage"
|
|
157
168
|
|
|
158
169
|
export {
|
|
159
170
|
useFormField,
|
|
@@ -1,57 +1,46 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
1
|
import * as React from "react"
|
|
4
2
|
import { OTPInput, OTPInputContext } from "input-otp"
|
|
5
|
-
import {
|
|
3
|
+
import { Minus } from "lucide-react"
|
|
6
4
|
|
|
7
5
|
import { cn } from "../../lib/utils"
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
7
|
+
const InputOTP = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof OTPInput>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof OTPInput>
|
|
10
|
+
>(({ className, containerClassName, ...props }, ref) => (
|
|
11
|
+
<OTPInput
|
|
12
|
+
ref={ref}
|
|
13
|
+
containerClassName={cn(
|
|
14
|
+
"flex items-center gap-2 has-[:disabled]:opacity-50",
|
|
15
|
+
containerClassName
|
|
16
|
+
)}
|
|
17
|
+
className={cn("disabled:cursor-not-allowed", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
))
|
|
21
|
+
InputOTP.displayName = "InputOTP"
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
}
|
|
23
|
+
const InputOTPGroup = React.forwardRef<
|
|
24
|
+
React.ElementRef<"div">,
|
|
25
|
+
React.ComponentPropsWithoutRef<"div">
|
|
26
|
+
>(({ className, ...props }, ref) => (
|
|
27
|
+
<div ref={ref} className={cn("flex items-center", className)} {...props} />
|
|
28
|
+
))
|
|
29
|
+
InputOTPGroup.displayName = "InputOTPGroup"
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}: React.ComponentProps<"div"> & {
|
|
44
|
-
index: number
|
|
45
|
-
}) {
|
|
31
|
+
const InputOTPSlot = React.forwardRef<
|
|
32
|
+
React.ElementRef<"div">,
|
|
33
|
+
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
|
34
|
+
>(({ index, className, ...props }, ref) => {
|
|
46
35
|
const inputOTPContext = React.useContext(OTPInputContext)
|
|
47
|
-
const { char, hasFakeCaret, isActive } = inputOTPContext
|
|
36
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
|
|
48
37
|
|
|
49
38
|
return (
|
|
50
39
|
<div
|
|
51
|
-
|
|
52
|
-
data-active={isActive}
|
|
40
|
+
ref={ref}
|
|
53
41
|
className={cn(
|
|
54
|
-
"
|
|
42
|
+
"relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
|
|
43
|
+
isActive && "z-10 ring-1 ring-ring",
|
|
55
44
|
className
|
|
56
45
|
)}
|
|
57
46
|
{...props}
|
|
@@ -59,19 +48,22 @@ function InputOTPSlot({
|
|
|
59
48
|
{char}
|
|
60
49
|
{hasFakeCaret && (
|
|
61
50
|
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
62
|
-
<div className="animate-caret-blink bg-foreground
|
|
51
|
+
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
|
|
63
52
|
</div>
|
|
64
53
|
)}
|
|
65
54
|
</div>
|
|
66
55
|
)
|
|
67
|
-
}
|
|
56
|
+
})
|
|
57
|
+
InputOTPSlot.displayName = "InputOTPSlot"
|
|
68
58
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
const InputOTPSeparator = React.forwardRef<
|
|
60
|
+
React.ElementRef<"div">,
|
|
61
|
+
React.ComponentPropsWithoutRef<"div">
|
|
62
|
+
>(({ ...props }, ref) => (
|
|
63
|
+
<div ref={ref} role="separator" {...props}>
|
|
64
|
+
<Minus />
|
|
65
|
+
</div>
|
|
66
|
+
))
|
|
67
|
+
InputOTPSeparator.displayName = "InputOTPSeparator"
|
|
76
68
|
|
|
77
69
|
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
|
@@ -2,20 +2,21 @@ import * as React from "react"
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
|
6
|
+
({ className, type, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<input
|
|
9
|
+
type={type}
|
|
10
|
+
className={cn(
|
|
11
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
ref={ref}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
Input.displayName = "Input"
|
|
20
21
|
|
|
21
22
|
export { Input }
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
1
|
import * as React from "react"
|
|
4
2
|
import * as LabelPrimitive from "@radix-ui/react-label"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
4
|
|
|
6
5
|
import { cn } from "../../lib/utils"
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
const Label = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof labelVariants>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<LabelPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(labelVariants(), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
))
|
|
22
|
+
Label.displayName = LabelPrimitive.Root.displayName
|
|
23
23
|
|
|
24
24
|
export { Label }
|