@arolariu/components 0.2.0 → 0.3.1
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/changelog.md +15 -0
- package/dist/components/ui/accordion.d.ts +4 -4
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +19 -27
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +17 -11
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +38 -61
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts +4 -5
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +17 -20
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +1 -2
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -8
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/avatar.d.ts +3 -3
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +16 -19
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +3 -3
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +7 -10
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts +16 -8
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +28 -35
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/button-group.d.ts +13 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +47 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +3 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +15 -14
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +20 -20
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts +7 -8
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +31 -44
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.d.ts +5 -6
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +29 -20
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts +35 -27
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +28 -26
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +10 -12
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/collapsible.d.ts +2 -4
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible.js +31 -20
- package/dist/components/ui/collapsible.js.map +1 -1
- package/dist/components/ui/command.d.ts +78 -16
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +47 -72
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts +21 -19
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +57 -101
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +16 -12
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +36 -64
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts +19 -10
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +32 -57
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +21 -19
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +64 -108
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdrawer.d.ts +1 -1
- package/dist/components/ui/dropdrawer.d.ts.map +1 -1
- package/dist/components/ui/dropdrawer.js +2 -5
- package/dist/components/ui/dropdrawer.js.map +1 -1
- package/dist/components/ui/empty.d.ts +13 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +65 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +26 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +135 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/form.d.ts +5 -6
- package/dist/components/ui/form.d.ts.map +1 -1
- package/dist/components/ui/form.js +29 -28
- package/dist/components/ui/form.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts +3 -3
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +11 -25
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +91 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +30 -7
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +22 -25
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +6 -7
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +122 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +5 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +21 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +2 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +8 -7
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/menubar.d.ts +18 -16
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/menubar.js +73 -93
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +8 -10
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +36 -55
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.d.ts +24 -9
- package/dist/components/ui/pagination.d.ts.map +1 -1
- package/dist/components/ui/pagination.js +33 -45
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts +4 -4
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +9 -25
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +5 -7
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts +2 -2
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +16 -19
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts +20 -4
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +8 -19
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts +2 -2
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +12 -16
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts +10 -12
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +54 -77
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +6 -7
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.d.ts +23 -11
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +54 -66
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +34 -38
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +116 -124
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/skeleton.js +1 -2
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +11 -30
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/sonner.d.ts +4 -2
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +7 -4
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +16 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +7 -9
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts +8 -8
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +36 -45
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +4 -4
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +17 -26
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +6 -7
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toggle-group.d.ts +8 -3
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.js +11 -15
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +4 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +7 -8
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts +4 -4
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +13 -38
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components/ui/typewriter.d.ts.map +1 -1
- package/dist/components/ui/typewriter.js +2 -6
- package/dist/components/ui/typewriter.js.map +1 -1
- package/dist/index.css +839 -1126
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/package.json +37 -2
- package/src/components/ui/accordion.tsx +43 -44
- package/src/components/ui/alert-dialog.tsx +88 -99
- package/src/components/ui/alert.tsx +24 -25
- package/src/components/ui/aspect-ratio.tsx +1 -9
- package/src/components/ui/avatar.tsx +33 -27
- package/src/components/ui/badge.tsx +8 -16
- package/src/components/ui/breadcrumb.tsx +70 -73
- package/src/components/ui/button-group.tsx +69 -0
- package/src/components/ui/button.tsx +18 -24
- package/src/components/ui/calendar.tsx +20 -20
- package/src/components/ui/card.tsx +52 -71
- package/src/components/ui/carousel.tsx +145 -133
- package/src/components/ui/chart.tsx +174 -182
- package/src/components/ui/checkbox.tsx +18 -18
- package/src/components/ui/collapsible.tsx +2 -26
- package/src/components/ui/command.tsx +101 -99
- package/src/components/ui/context-menu.tsx +150 -193
- package/src/components/ui/dialog.tsx +75 -110
- package/src/components/ui/drawer.tsx +74 -102
- package/src/components/ui/dropdown-menu.tsx +153 -200
- package/src/components/ui/dropdrawer.tsx +0 -5
- package/src/components/ui/empty.tsx +86 -0
- package/src/components/ui/field.tsx +199 -0
- package/src/components/ui/form.tsx +49 -50
- package/src/components/ui/hover-card.tsx +18 -37
- package/src/components/ui/input-group.tsx +145 -0
- package/src/components/ui/input-otp.tsx +49 -59
- package/src/components/ui/input.tsx +5 -6
- package/src/components/ui/item.tsx +163 -0
- package/src/components/ui/kbd.tsx +31 -0
- package/src/components/ui/label.tsx +14 -12
- package/src/components/ui/menubar.tsx +178 -201
- package/src/components/ui/navigation-menu.tsx +84 -100
- package/src/components/ui/pagination.tsx +75 -85
- package/src/components/ui/popover.tsx +19 -38
- package/src/components/ui/progress.tsx +15 -14
- package/src/components/ui/radio-group.tsx +19 -13
- package/src/components/ui/resizable.tsx +23 -36
- package/src/components/ui/scroll-area.tsx +32 -35
- package/src/components/ui/select.tsx +112 -127
- package/src/components/ui/separator.tsx +17 -19
- package/src/components/ui/sheet.tsx +87 -108
- package/src/components/ui/sidebar.tsx +276 -279
- package/src/components/ui/skeleton.tsx +2 -3
- package/src/components/ui/slider.tsx +15 -40
- package/src/components/ui/sonner.tsx +15 -9
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/switch.tsx +18 -17
- package/src/components/ui/table.tsx +66 -71
- package/src/components/ui/tabs.tsx +36 -36
- package/src/components/ui/textarea.tsx +5 -4
- package/src/components/ui/toggle-group.tsx +21 -34
- package/src/components/ui/toggle.tsx +14 -16
- package/src/components/ui/tooltip.tsx +19 -43
- package/src/components/ui/typewriter.tsx +3 -4
- package/src/index.css +6 -6
- package/src/index.ts +43 -4
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {cva, type VariantProps} from "class-variance-authority";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import {Label} from "@/components/ui/label";
|
|
7
|
+
import {Separator} from "@/components/ui/separator";
|
|
8
|
+
import {cn} from "@/lib/utilities";
|
|
9
|
+
|
|
10
|
+
function FieldSet({className, ...props}: React.ComponentProps<"fieldset">) {
|
|
11
|
+
return (
|
|
12
|
+
<fieldset
|
|
13
|
+
data-slot='field-set'
|
|
14
|
+
className={cn("flex flex-col gap-6", "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function FieldLegend({className, variant = "legend", ...props}: React.ComponentProps<"legend"> & {variant?: "legend" | "label"}) {
|
|
21
|
+
return (
|
|
22
|
+
<legend
|
|
23
|
+
data-slot='field-legend'
|
|
24
|
+
data-variant={variant}
|
|
25
|
+
className={cn("mb-3 font-medium", "data-[variant=legend]:text-base", "data-[variant=label]:text-sm", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function FieldGroup({className, ...props}: React.ComponentProps<"div">) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot='field-group'
|
|
35
|
+
className={cn(
|
|
36
|
+
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const fieldVariants = cva("group/field data-[invalid=true]:text-red-500 flex w-full gap-3 dark:data-[invalid=true]:text-red-900", {
|
|
45
|
+
variants: {
|
|
46
|
+
orientation: {
|
|
47
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
48
|
+
horizontal: [
|
|
49
|
+
"flex-row items-center",
|
|
50
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
51
|
+
"has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px has-[>[data-slot=field-content]]:items-start",
|
|
52
|
+
],
|
|
53
|
+
responsive: [
|
|
54
|
+
"@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto flex-col [&>*]:w-full [&>.sr-only]:w-auto",
|
|
55
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
56
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
orientation: "vertical",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
function Field({className, orientation = "vertical", ...props}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
role='group'
|
|
69
|
+
data-slot='field'
|
|
70
|
+
data-orientation={orientation}
|
|
71
|
+
className={cn(fieldVariants({orientation}), className)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function FieldContent({className, ...props}: React.ComponentProps<"div">) {
|
|
78
|
+
return (
|
|
79
|
+
<div
|
|
80
|
+
data-slot='field-content'
|
|
81
|
+
className={cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function FieldLabel({className, ...props}: React.ComponentProps<typeof Label>) {
|
|
88
|
+
return (
|
|
89
|
+
<Label
|
|
90
|
+
data-slot='field-label'
|
|
91
|
+
className={cn(
|
|
92
|
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
93
|
+
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>[data-slot=field]]:p-4",
|
|
94
|
+
"has-data-[state=checked]:border-neutral-900 has-data-[state=checked]:bg-neutral-900/5 dark:has-data-[state=checked]:border-neutral-50 dark:dark:has-data-[state=checked]:bg-neutral-50/10 dark:has-data-[state=checked]:bg-neutral-50/5 dark:has-data-[state=checked]:bg-neutral-900/10",
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function FieldTitle({className, ...props}: React.ComponentProps<"div">) {
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
data-slot='field-label'
|
|
106
|
+
className={cn(
|
|
107
|
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
|
|
108
|
+
className,
|
|
109
|
+
)}
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function FieldDescription({className, ...props}: React.ComponentProps<"p">) {
|
|
116
|
+
return (
|
|
117
|
+
<p
|
|
118
|
+
data-slot='field-description'
|
|
119
|
+
className={cn(
|
|
120
|
+
"text-sm leading-normal font-normal text-neutral-500 group-has-[[data-orientation=horizontal]]/field:text-balance dark:text-neutral-400",
|
|
121
|
+
"last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
|
|
122
|
+
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-neutral-900 dark:[&>a:hover]:text-neutral-50",
|
|
123
|
+
className,
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function FieldSeparator({
|
|
131
|
+
children,
|
|
132
|
+
className,
|
|
133
|
+
...props
|
|
134
|
+
}: React.ComponentProps<"div"> & {
|
|
135
|
+
children?: React.ReactNode;
|
|
136
|
+
}) {
|
|
137
|
+
return (
|
|
138
|
+
<div
|
|
139
|
+
data-slot='field-separator'
|
|
140
|
+
data-content={Boolean(children) || undefined}
|
|
141
|
+
className={cn("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2", className)}
|
|
142
|
+
{...props}>
|
|
143
|
+
<Separator className='absolute inset-0 top-1/2' />
|
|
144
|
+
{children && (
|
|
145
|
+
<span
|
|
146
|
+
className='relative mx-auto block w-fit bg-white px-2 text-neutral-500 dark:bg-neutral-950 dark:text-neutral-400'
|
|
147
|
+
data-slot='field-separator-content'>
|
|
148
|
+
{children}
|
|
149
|
+
</span>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function FieldError({
|
|
156
|
+
className,
|
|
157
|
+
children,
|
|
158
|
+
errors,
|
|
159
|
+
...props
|
|
160
|
+
}: React.ComponentProps<"div"> & {
|
|
161
|
+
errors?: Array<{message?: string} | undefined>;
|
|
162
|
+
}) {
|
|
163
|
+
// eslint-disable-next-line sonarjs/function-return-type -- expected different return type.
|
|
164
|
+
const content = React.useMemo(() => {
|
|
165
|
+
if (children) {
|
|
166
|
+
return children;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!errors) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (errors?.length === 1 && errors[0]?.message) {
|
|
174
|
+
return errors[0].message;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<ul className='ml-4 flex list-disc flex-col gap-1'>
|
|
179
|
+
{errors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
|
|
180
|
+
</ul>
|
|
181
|
+
);
|
|
182
|
+
}, [children, errors]);
|
|
183
|
+
|
|
184
|
+
if (!content) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<div
|
|
190
|
+
role='alert'
|
|
191
|
+
data-slot='field-error'
|
|
192
|
+
className={cn("text-sm font-normal text-red-500 dark:text-red-900", className)}
|
|
193
|
+
{...props}>
|
|
194
|
+
{content}
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export {Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle};
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
|
|
5
3
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
6
4
|
import {Slot} from "@radix-ui/react-slot";
|
|
7
5
|
import * as React from "react";
|
|
8
|
-
import {
|
|
9
|
-
Controller,
|
|
10
|
-
FormProvider,
|
|
11
|
-
useFormContext,
|
|
12
|
-
useFormState,
|
|
13
|
-
type ControllerProps,
|
|
14
|
-
type FieldPath,
|
|
15
|
-
type FieldValues,
|
|
16
|
-
} from "react-hook-form";
|
|
6
|
+
import {Controller, FormProvider, useFormContext, type ControllerProps, type FieldPath, type FieldValues} from "react-hook-form";
|
|
17
7
|
|
|
18
8
|
import {Label} from "@/components/ui/label";
|
|
19
9
|
import {cn} from "@/lib/utilities";
|
|
@@ -42,8 +32,8 @@ const FormField = <TFieldValues extends FieldValues = FieldValues, TName extends
|
|
|
42
32
|
const useFormField = () => {
|
|
43
33
|
const fieldContext = React.useContext(FormFieldContext);
|
|
44
34
|
const itemContext = React.useContext(FormItemContext);
|
|
45
|
-
const {getFieldState} = useFormContext();
|
|
46
|
-
|
|
35
|
+
const {getFieldState, formState} = useFormContext();
|
|
36
|
+
|
|
47
37
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
48
38
|
|
|
49
39
|
if (!fieldContext) {
|
|
@@ -68,78 +58,87 @@ type FormItemContextValue = {
|
|
|
68
58
|
|
|
69
59
|
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
|
|
70
60
|
|
|
71
|
-
|
|
61
|
+
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({className, ...props}, ref) => {
|
|
72
62
|
const id = React.useId();
|
|
73
63
|
|
|
74
64
|
return (
|
|
75
65
|
<FormItemContext.Provider value={{id}}>
|
|
76
66
|
<div
|
|
77
|
-
|
|
78
|
-
className={cn("
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cn("space-y-2", className)}
|
|
79
69
|
{...props}
|
|
80
70
|
/>
|
|
81
71
|
</FormItemContext.Provider>
|
|
82
72
|
);
|
|
83
|
-
}
|
|
73
|
+
});
|
|
74
|
+
FormItem.displayName = "FormItem";
|
|
84
75
|
|
|
85
|
-
|
|
76
|
+
const FormLabel = React.forwardRef<
|
|
77
|
+
React.ComponentRef<typeof LabelPrimitive.Root>,
|
|
78
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
79
|
+
>(({className, ...props}, ref) => {
|
|
86
80
|
const {error, formItemId} = useFormField();
|
|
87
81
|
|
|
88
82
|
return (
|
|
89
83
|
<Label
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
className={cn("data-[error=true]:text-red-500 dark:data-[error=true]:text-red-900", className)}
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(error && "text-red-500 dark:text-red-900", className)}
|
|
93
86
|
htmlFor={formItemId}
|
|
94
87
|
{...props}
|
|
95
88
|
/>
|
|
96
89
|
);
|
|
97
|
-
}
|
|
90
|
+
});
|
|
91
|
+
FormLabel.displayName = "FormLabel";
|
|
98
92
|
|
|
99
|
-
|
|
93
|
+
const FormControl = React.forwardRef<React.ComponentRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(({...props}, ref) => {
|
|
100
94
|
const {error, formItemId, formDescriptionId, formMessageId} = useFormField();
|
|
101
95
|
|
|
102
96
|
return (
|
|
103
97
|
<Slot
|
|
104
|
-
|
|
98
|
+
ref={ref}
|
|
105
99
|
id={formItemId}
|
|
106
|
-
aria-describedby={
|
|
107
|
-
aria-invalid={
|
|
100
|
+
aria-describedby={error ? `${formDescriptionId} ${formMessageId}` : `${formDescriptionId}`}
|
|
101
|
+
aria-invalid={Boolean(error)}
|
|
108
102
|
{...props}
|
|
109
103
|
/>
|
|
110
104
|
);
|
|
111
|
-
}
|
|
105
|
+
});
|
|
106
|
+
FormControl.displayName = "FormControl";
|
|
112
107
|
|
|
113
|
-
|
|
108
|
+
const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({className, ...props}, ref) => {
|
|
114
109
|
const {formDescriptionId} = useFormField();
|
|
115
110
|
|
|
116
111
|
return (
|
|
117
112
|
<p
|
|
118
|
-
|
|
113
|
+
ref={ref}
|
|
119
114
|
id={formDescriptionId}
|
|
120
|
-
className={cn("text-
|
|
115
|
+
className={cn("text-[0.8rem] text-neutral-500 dark:text-neutral-400", className)}
|
|
121
116
|
{...props}
|
|
122
117
|
/>
|
|
123
118
|
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
119
|
+
});
|
|
120
|
+
FormDescription.displayName = "FormDescription";
|
|
121
|
+
|
|
122
|
+
const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
123
|
+
({className, children, ...props}, ref) => {
|
|
124
|
+
const {error, formMessageId} = useFormField();
|
|
125
|
+
const body = error ? String(error?.message ?? "") : children;
|
|
126
|
+
|
|
127
|
+
if (!body) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<p
|
|
133
|
+
ref={ref}
|
|
134
|
+
id={formMessageId}
|
|
135
|
+
className={cn("text-[0.8rem] font-medium text-red-500 dark:text-red-900", className)}
|
|
136
|
+
{...props}>
|
|
137
|
+
{body}
|
|
138
|
+
</p>
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
FormMessage.displayName = "FormMessage";
|
|
144
143
|
|
|
145
144
|
export {Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField};
|
|
@@ -5,44 +5,25 @@ import * as React from "react";
|
|
|
5
5
|
|
|
6
6
|
import {cn} from "@/lib/utilities";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<HoverCardPrimitive.Root
|
|
11
|
-
data-slot='hover-card'
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
8
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<HoverCardPrimitive.Trigger
|
|
20
|
-
data-slot='hover-card-trigger'
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
10
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
25
11
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
</HoverCardPrimitive.Portal>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
12
|
+
const HoverCardContent = React.forwardRef<
|
|
13
|
+
React.ComponentRef<typeof HoverCardPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
15
|
+
>(({className, align = "center", sideOffset = 4, ...props}, ref) => (
|
|
16
|
+
<HoverCardPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
align={align}
|
|
19
|
+
sideOffset={sideOffset}
|
|
20
|
+
className={cn(
|
|
21
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-[--radix-hover-card-content-transform-origin] rounded-md border border-neutral-200 bg-white p-4 text-neutral-950 shadow-md outline-none dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",
|
|
22
|
+
className,
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
47
28
|
|
|
48
29
|
export {HoverCard, HoverCardContent, HoverCardTrigger};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {cva, type VariantProps} from "class-variance-authority";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import {Button} from "@/components/ui/button";
|
|
7
|
+
import {Input} from "@/components/ui/input";
|
|
8
|
+
import {Textarea} from "@/components/ui/textarea";
|
|
9
|
+
import {cn} from "@/lib/utilities";
|
|
10
|
+
|
|
11
|
+
function InputGroup({className, ...props}: React.ComponentProps<"div">) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
data-slot='input-group'
|
|
15
|
+
role='group'
|
|
16
|
+
className={cn(
|
|
17
|
+
"group/input-group relative flex w-full items-center rounded-md border border-neutral-200 shadow-xs transition-[color,box-shadow] outline-none dark:border-neutral-800 dark:bg-neutral-200/30 dark:dark:bg-neutral-800/30",
|
|
18
|
+
"h-9 has-[>textarea]:h-auto",
|
|
19
|
+
|
|
20
|
+
// Variants based on alignment.
|
|
21
|
+
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
22
|
+
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
23
|
+
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
24
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
25
|
+
|
|
26
|
+
// Focus state.
|
|
27
|
+
"has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-neutral-950 dark:has-[[data-slot=input-group-control]:focus-visible]:ring-neutral-300",
|
|
28
|
+
|
|
29
|
+
// Error state.
|
|
30
|
+
"has-[[data-slot][aria-invalid=true]]:border-red-500 has-[[data-slot][aria-invalid=true]]:ring-red-500/20 dark:has-[[data-slot][aria-invalid=true]]:border-red-900 dark:dark:has-[[data-slot][aria-invalid=true]]:ring-red-900/40 dark:has-[[data-slot][aria-invalid=true]]:ring-red-500/40 dark:has-[[data-slot][aria-invalid=true]]:ring-red-900/20",
|
|
31
|
+
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const inputGroupAddonVariants = cva(
|
|
40
|
+
"text-neutral-500 flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 dark:text-neutral-400",
|
|
41
|
+
{
|
|
42
|
+
variants: {
|
|
43
|
+
align: {
|
|
44
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
45
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]",
|
|
46
|
+
"block-start": "[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
|
|
47
|
+
"block-end": "[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
align: "inline-start",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
function InputGroupAddon({
|
|
57
|
+
className,
|
|
58
|
+
align = "inline-start",
|
|
59
|
+
...props
|
|
60
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
role='group'
|
|
64
|
+
data-slot='input-group-addon'
|
|
65
|
+
data-align={align}
|
|
66
|
+
className={cn(inputGroupAddonVariants({align}), className)}
|
|
67
|
+
onClick={(e) => {
|
|
68
|
+
if ((e.target as HTMLElement).closest("button")) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
72
|
+
}}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const inputGroupButtonVariants = cva("flex items-center gap-2 text-sm shadow-none", {
|
|
79
|
+
variants: {
|
|
80
|
+
size: {
|
|
81
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
82
|
+
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
83
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
84
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
defaultVariants: {
|
|
88
|
+
size: "xs",
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
function InputGroupButton({
|
|
93
|
+
className,
|
|
94
|
+
type = "button",
|
|
95
|
+
variant = "ghost",
|
|
96
|
+
size = "xs",
|
|
97
|
+
...props
|
|
98
|
+
}: Omit<React.ComponentProps<typeof Button>, "size"> & VariantProps<typeof inputGroupButtonVariants>) {
|
|
99
|
+
return (
|
|
100
|
+
<Button
|
|
101
|
+
type={type}
|
|
102
|
+
data-size={size}
|
|
103
|
+
variant={variant}
|
|
104
|
+
className={cn(inputGroupButtonVariants({size}), className)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function InputGroupText({className, ...props}: React.ComponentProps<"span">) {
|
|
111
|
+
return (
|
|
112
|
+
<span
|
|
113
|
+
className={cn(
|
|
114
|
+
"flex items-center gap-2 text-sm text-neutral-500 dark:text-neutral-400 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function InputGroupInput({className, ...props}: React.ComponentProps<"input">) {
|
|
123
|
+
return (
|
|
124
|
+
<Input
|
|
125
|
+
data-slot='input-group-control'
|
|
126
|
+
className={cn("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent", className)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function InputGroupTextarea({className, ...props}: React.ComponentProps<"textarea">) {
|
|
133
|
+
return (
|
|
134
|
+
<Textarea
|
|
135
|
+
data-slot='input-group-control'
|
|
136
|
+
className={cn(
|
|
137
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
138
|
+
className,
|
|
139
|
+
)}
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea};
|