better-auth-ui 3.2.6 → 3.2.11
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 -41
- 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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
1
|
import * as React from "react"
|
|
4
2
|
import * as LabelPrimitive from "@radix-ui/react-label"
|
|
5
3
|
import { Slot } from "@radix-ui/react-slot"
|
|
@@ -7,7 +5,6 @@ import {
|
|
|
7
5
|
Controller,
|
|
8
6
|
FormProvider,
|
|
9
7
|
useFormContext,
|
|
10
|
-
useFormState,
|
|
11
8
|
type ControllerProps,
|
|
12
9
|
type FieldPath,
|
|
13
10
|
type FieldValues,
|
|
@@ -20,18 +17,16 @@ const Form = FormProvider
|
|
|
20
17
|
|
|
21
18
|
type FormFieldContextValue<
|
|
22
19
|
TFieldValues extends FieldValues = FieldValues,
|
|
23
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues
|
|
20
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
24
21
|
> = {
|
|
25
22
|
name: TName
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
29
|
-
{} as FormFieldContextValue
|
|
30
|
-
)
|
|
25
|
+
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null)
|
|
31
26
|
|
|
32
27
|
const FormField = <
|
|
33
28
|
TFieldValues extends FieldValues = FieldValues,
|
|
34
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues
|
|
29
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
35
30
|
>({
|
|
36
31
|
...props
|
|
37
32
|
}: ControllerProps<TFieldValues, TName>) => {
|
|
@@ -45,14 +40,18 @@ const FormField = <
|
|
|
45
40
|
const useFormField = () => {
|
|
46
41
|
const fieldContext = React.useContext(FormFieldContext)
|
|
47
42
|
const itemContext = React.useContext(FormItemContext)
|
|
48
|
-
const { getFieldState } = useFormContext()
|
|
49
|
-
const formState = useFormState({ name: fieldContext.name })
|
|
50
|
-
const fieldState = getFieldState(fieldContext.name, formState)
|
|
43
|
+
const { getFieldState, formState } = useFormContext()
|
|
51
44
|
|
|
52
45
|
if (!fieldContext) {
|
|
53
46
|
throw new Error("useFormField should be used within <FormField>")
|
|
54
47
|
}
|
|
55
48
|
|
|
49
|
+
if (!itemContext) {
|
|
50
|
+
throw new Error("useFormField should be used within <FormItem>")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const fieldState = getFieldState(fieldContext.name, formState)
|
|
54
|
+
|
|
56
55
|
const { id } = itemContext
|
|
57
56
|
|
|
58
57
|
return {
|
|
@@ -69,47 +68,48 @@ type FormItemContextValue = {
|
|
|
69
68
|
id: string
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
73
|
-
{} as FormItemContextValue
|
|
74
|
-
)
|
|
71
|
+
const FormItemContext = React.createContext<FormItemContextValue | null>(null)
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
const FormItem = React.forwardRef<
|
|
74
|
+
HTMLDivElement,
|
|
75
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
76
|
+
>(({ className, ...props }, ref) => {
|
|
77
77
|
const id = React.useId()
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
80
|
<FormItemContext.Provider value={{ id }}>
|
|
81
|
-
<div
|
|
82
|
-
data-slot="form-item"
|
|
83
|
-
className={cn("grid gap-2", className)}
|
|
84
|
-
{...props}
|
|
85
|
-
/>
|
|
81
|
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
|
86
82
|
</FormItemContext.Provider>
|
|
87
83
|
)
|
|
88
|
-
}
|
|
84
|
+
})
|
|
85
|
+
FormItem.displayName = "FormItem"
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
87
|
+
const FormLabel = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
90
|
+
>(({ className, ...props }, ref) => {
|
|
94
91
|
const { error, formItemId } = useFormField()
|
|
95
92
|
|
|
96
93
|
return (
|
|
97
94
|
<Label
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
className={cn("data-[error=true]:text-destructive", className)}
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(error && "text-destructive", className)}
|
|
101
97
|
htmlFor={formItemId}
|
|
102
98
|
{...props}
|
|
103
99
|
/>
|
|
104
100
|
)
|
|
105
|
-
}
|
|
101
|
+
})
|
|
102
|
+
FormLabel.displayName = "FormLabel"
|
|
106
103
|
|
|
107
|
-
|
|
104
|
+
const FormControl = React.forwardRef<
|
|
105
|
+
React.ElementRef<typeof Slot>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
|
107
|
+
>(({ ...props }, ref) => {
|
|
108
108
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
|
109
109
|
|
|
110
110
|
return (
|
|
111
111
|
<Slot
|
|
112
|
-
|
|
112
|
+
ref={ref}
|
|
113
113
|
id={formItemId}
|
|
114
114
|
aria-describedby={
|
|
115
115
|
!error
|
|
@@ -120,24 +120,32 @@ function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
|
|
120
120
|
{...props}
|
|
121
121
|
/>
|
|
122
122
|
)
|
|
123
|
-
}
|
|
123
|
+
})
|
|
124
|
+
FormControl.displayName = "FormControl"
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
const FormDescription = React.forwardRef<
|
|
127
|
+
HTMLParagraphElement,
|
|
128
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
129
|
+
>(({ className, ...props }, ref) => {
|
|
126
130
|
const { formDescriptionId } = useFormField()
|
|
127
131
|
|
|
128
132
|
return (
|
|
129
133
|
<p
|
|
130
|
-
|
|
134
|
+
ref={ref}
|
|
131
135
|
id={formDescriptionId}
|
|
132
|
-
className={cn("text-muted-foreground
|
|
136
|
+
className={cn("text-[0.8rem] text-muted-foreground", className)}
|
|
133
137
|
{...props}
|
|
134
138
|
/>
|
|
135
139
|
)
|
|
136
|
-
}
|
|
140
|
+
})
|
|
141
|
+
FormDescription.displayName = "FormDescription"
|
|
137
142
|
|
|
138
|
-
|
|
143
|
+
const FormMessage = React.forwardRef<
|
|
144
|
+
HTMLParagraphElement,
|
|
145
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
146
|
+
>(({ className, children, ...props }, ref) => {
|
|
139
147
|
const { error, formMessageId } = useFormField()
|
|
140
|
-
const body = error ? String(error?.message ?? "") :
|
|
148
|
+
const body = error ? String(error?.message ?? "") : children
|
|
141
149
|
|
|
142
150
|
if (!body) {
|
|
143
151
|
return null
|
|
@@ -145,15 +153,16 @@ function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
145
153
|
|
|
146
154
|
return (
|
|
147
155
|
<p
|
|
148
|
-
|
|
156
|
+
ref={ref}
|
|
149
157
|
id={formMessageId}
|
|
150
|
-
className={cn("text-
|
|
158
|
+
className={cn("text-[0.8rem] font-medium text-destructive", className)}
|
|
151
159
|
{...props}
|
|
152
160
|
>
|
|
153
161
|
{body}
|
|
154
162
|
</p>
|
|
155
163
|
)
|
|
156
|
-
}
|
|
164
|
+
})
|
|
165
|
+
FormMessage.displayName = "FormMessage"
|
|
157
166
|
|
|
158
167
|
export {
|
|
159
168
|
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 }
|