@robomous/ui-core 0.1.0 → 0.2.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/README.md +19 -7
- package/dist/{primitives → components}/alert.js +1 -1
- package/dist/{primitives → components}/badge.js +1 -1
- package/dist/{primitives → components}/button.d.ts +1 -1
- package/dist/{primitives → components}/button.js +4 -1
- package/dist/{primitives → components}/card.d.ts +1 -1
- package/dist/{primitives → components}/card.js +2 -2
- package/dist/{primitives → components}/combobox.js +4 -4
- package/dist/{primitives → components}/dialog.js +1 -1
- package/dist/{primitives → components}/dropdown-menu.js +12 -7
- package/dist/{primitives → components}/field.js +2 -4
- package/dist/{primitives → components}/input-group.js +1 -1
- package/dist/{primitives → components}/input.js +1 -1
- package/dist/{primitives → components}/label.js +1 -1
- package/dist/components/progress.js +7 -0
- package/dist/{primitives → components}/select.d.ts +3 -1
- package/dist/{primitives → components}/select.js +7 -4
- package/dist/{primitives → components}/separator.js +1 -1
- package/dist/{primitives → components}/sheet.js +1 -1
- package/dist/{primitives → components}/skeleton.js +1 -1
- package/dist/{primitives → components}/sonner.js +17 -12
- package/dist/{primitives → components}/table.d.ts +1 -1
- package/dist/{primitives → components}/table.js +3 -3
- package/dist/{primitives → components}/tabs.js +1 -1
- package/dist/{primitives → components}/textarea.js +1 -1
- package/dist/{primitives → components}/tooltip.js +1 -1
- package/dist/gates/index.d.ts +28 -0
- package/dist/gates/index.js +142 -0
- package/dist/index.d.ts +31 -32
- package/dist/index.js +32 -33
- package/dist/{tokens.d.ts → theme/tokens.d.ts} +5 -5
- package/dist/{tokens.js → theme/tokens.js} +12 -12
- package/package.json +23 -12
- package/{shadcn → src/components}/alert.tsx +14 -21
- package/src/{primitives → components}/badge.tsx +15 -21
- package/src/{primitives → components}/button.tsx +13 -10
- package/{shadcn → src/components}/card.tsx +16 -31
- package/src/{primitives → components}/combobox.test.tsx +15 -2
- package/src/{primitives → components}/combobox.tsx +45 -74
- package/src/{primitives/primitives.test.tsx → components/components.test.tsx} +106 -69
- package/src/{primitives → components}/dialog.tsx +31 -54
- package/src/{primitives → components}/dropdown-menu.tsx +51 -65
- package/src/{primitives → components}/field.tsx +48 -62
- package/src/{primitives → components}/input-group.tsx +37 -49
- package/{shadcn → src/components}/input.tsx +5 -5
- package/{shadcn → src/components}/label.tsx +7 -10
- package/src/{primitives → components}/progress.tsx +7 -6
- package/{shadcn → src/components}/select.tsx +40 -40
- package/{shadcn → src/components}/separator.tsx +7 -7
- package/src/{primitives → components}/sheet.tsx +27 -44
- package/{shadcn → src/components}/skeleton.tsx +3 -3
- package/src/{primitives → components}/sonner.test.tsx +12 -4
- package/src/components/sonner.tsx +67 -0
- package/{shadcn → src/components}/table.tsx +17 -44
- package/{shadcn → src/components}/tabs.tsx +16 -26
- package/{shadcn → src/components}/textarea.tsx +5 -5
- package/{shadcn → src/components}/tooltip.tsx +12 -16
- package/src/gates/design.test.ts +188 -0
- package/src/gates/index.test.ts +11 -0
- package/src/gates/index.ts +165 -0
- package/src/gates/tokens.test.ts +215 -0
- package/src/harness.test.tsx +1 -1
- package/src/index.ts +63 -33
- package/src/theme/imports.test.ts +160 -0
- package/src/{statusTone.test.ts → theme/statusTone.test.ts} +5 -1
- package/src/{styles.css → theme/styles.css} +45 -31
- package/src/theme/tailwind.css +646 -0
- package/src/{tokens.test.ts → theme/tokens.test.ts} +30 -23
- package/src/{tokens.ts → theme/tokens.ts} +12 -12
- package/components.json +0 -13
- package/dist/lib/button.d.ts +0 -1
- package/dist/lib/button.js +0 -4
- package/dist/lib/cn.d.ts +0 -18
- package/dist/lib/cn.js +0 -21
- package/dist/lib/menu.d.ts +0 -1
- package/dist/lib/menu.js +0 -16
- package/dist/lib/progress.d.ts +0 -3
- package/dist/lib/progress.js +0 -6
- package/dist/lib/select.d.ts +0 -1
- package/dist/lib/select.js +0 -3
- package/dist/primitives/progress.js +0 -7
- package/gates/canonical.test.mjs +0 -71
- package/gates/extensions.test.mjs +0 -373
- package/gates/index.d.mts +0 -51
- package/gates/index.mjs +0 -514
- package/gates/tokens.test.mjs +0 -276
- package/shadcn/README.md +0 -13
- package/shadcn/badge.tsx +0 -49
- package/shadcn/button.tsx +0 -67
- package/shadcn/combobox.tsx +0 -299
- package/shadcn/dialog.tsx +0 -166
- package/shadcn/dropdown-menu.tsx +0 -267
- package/shadcn/field.tsx +0 -236
- package/shadcn/input-group.tsx +0 -154
- package/shadcn/progress.tsx +0 -29
- package/shadcn/sheet.tsx +0 -145
- package/shadcn/sonner.tsx +0 -49
- package/src/lib/button.ts +0 -4
- package/src/lib/cn.test.ts +0 -33
- package/src/lib/cn.ts +0 -23
- package/src/lib/menu.ts +0 -16
- package/src/lib/progress.ts +0 -6
- package/src/lib/select.ts +0 -4
- package/src/primitives/alert.tsx +0 -76
- package/src/primitives/card.tsx +0 -103
- package/src/primitives/input.tsx +0 -19
- package/src/primitives/label.tsx +0 -22
- package/src/primitives/select.tsx +0 -190
- package/src/primitives/separator.tsx +0 -28
- package/src/primitives/skeleton.tsx +0 -13
- package/src/primitives/sonner.tsx +0 -65
- package/src/primitives/table.tsx +0 -114
- package/src/primitives/tabs.tsx +0 -88
- package/src/primitives/textarea.tsx +0 -18
- package/src/primitives/tooltip.tsx +0 -57
- /package/dist/{primitives → components}/alert.d.ts +0 -0
- /package/dist/{primitives → components}/badge.d.ts +0 -0
- /package/dist/{primitives → components}/combobox.d.ts +0 -0
- /package/dist/{primitives → components}/dialog.d.ts +0 -0
- /package/dist/{primitives → components}/dropdown-menu.d.ts +0 -0
- /package/dist/{primitives → components}/field.d.ts +0 -0
- /package/dist/{primitives → components}/input-group.d.ts +0 -0
- /package/dist/{primitives → components}/input.d.ts +0 -0
- /package/dist/{primitives → components}/label.d.ts +0 -0
- /package/dist/{primitives → components}/progress.d.ts +0 -0
- /package/dist/{primitives → components}/separator.d.ts +0 -0
- /package/dist/{primitives → components}/sheet.d.ts +0 -0
- /package/dist/{primitives → components}/skeleton.d.ts +0 -0
- /package/dist/{primitives → components}/sonner.d.ts +0 -0
- /package/dist/{primitives → components}/tabs.d.ts +0 -0
- /package/dist/{primitives → components}/textarea.d.ts +0 -0
- /package/dist/{primitives → components}/tooltip.d.ts +0 -0
- /package/dist/{statusTone.d.ts → theme/statusTone.d.ts} +0 -0
- /package/dist/{statusTone.js → theme/statusTone.js} +0 -0
- /package/src/{statusTone.ts → theme/statusTone.ts} +0 -0
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
3
3
|
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { CheckIcon, ChevronRightIcon } from "lucide-react"
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { CheckIcon, ChevronRightIcon } from "lucide-react";
|
|
6
6
|
|
|
7
|
-
function DropdownMenu({
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
10
|
-
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
7
|
+
function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
8
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
function DropdownMenuPortal({
|
|
14
12
|
...props
|
|
15
13
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
16
|
-
return
|
|
17
|
-
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
18
|
-
)
|
|
14
|
+
return <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
function DropdownMenuTrigger({
|
|
22
18
|
...props
|
|
23
19
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
24
|
-
return
|
|
25
|
-
<DropdownMenuPrimitive.Trigger
|
|
26
|
-
data-slot="dropdown-menu-trigger"
|
|
27
|
-
{...props}
|
|
28
|
-
/>
|
|
29
|
-
)
|
|
20
|
+
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
30
21
|
}
|
|
31
22
|
|
|
23
|
+
// A menu sizes to its items, not to its trigger — behind an icon-sized button
|
|
24
|
+
// the trigger width is a 128px ceiling that wraps every longer item; min-w-32
|
|
25
|
+
// survives as the floor it was meant to be. And it leaves on the frame it is
|
|
26
|
+
// dismissed: while an exit animation runs, the dismissable layer stays mounted
|
|
27
|
+
// and swallows the press that should open the next menu.
|
|
32
28
|
function DropdownMenuContent({
|
|
33
29
|
className,
|
|
34
30
|
align = "start",
|
|
@@ -41,19 +37,18 @@ function DropdownMenuContent({
|
|
|
41
37
|
data-slot="dropdown-menu-content"
|
|
42
38
|
sideOffset={sideOffset}
|
|
43
39
|
align={align}
|
|
44
|
-
className={cn(
|
|
40
|
+
className={cn(
|
|
41
|
+
"z-50 max-h-(--radix-dropdown-menu-content-available-height) w-auto min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
45
44
|
{...props}
|
|
46
45
|
/>
|
|
47
46
|
</DropdownMenuPrimitive.Portal>
|
|
48
|
-
)
|
|
47
|
+
);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
function DropdownMenuGroup({
|
|
52
|
-
...props
|
|
53
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
54
|
-
return (
|
|
55
|
-
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
56
|
-
)
|
|
50
|
+
function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
51
|
+
return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
function DropdownMenuItem({
|
|
@@ -62,8 +57,8 @@ function DropdownMenuItem({
|
|
|
62
57
|
variant = "default",
|
|
63
58
|
...props
|
|
64
59
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
65
|
-
inset?: boolean
|
|
66
|
-
variant?: "default" | "destructive"
|
|
60
|
+
inset?: boolean;
|
|
61
|
+
variant?: "default" | "destructive";
|
|
67
62
|
}) {
|
|
68
63
|
return (
|
|
69
64
|
<DropdownMenuPrimitive.Item
|
|
@@ -72,11 +67,11 @@ function DropdownMenuItem({
|
|
|
72
67
|
data-variant={variant}
|
|
73
68
|
className={cn(
|
|
74
69
|
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
75
|
-
className
|
|
70
|
+
className,
|
|
76
71
|
)}
|
|
77
72
|
{...props}
|
|
78
73
|
/>
|
|
79
|
-
)
|
|
74
|
+
);
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
function DropdownMenuCheckboxItem({
|
|
@@ -86,7 +81,7 @@ function DropdownMenuCheckboxItem({
|
|
|
86
81
|
inset,
|
|
87
82
|
...props
|
|
88
83
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
|
|
89
|
-
inset?: boolean
|
|
84
|
+
inset?: boolean;
|
|
90
85
|
}) {
|
|
91
86
|
return (
|
|
92
87
|
<DropdownMenuPrimitive.CheckboxItem
|
|
@@ -94,7 +89,7 @@ function DropdownMenuCheckboxItem({
|
|
|
94
89
|
data-inset={inset}
|
|
95
90
|
className={cn(
|
|
96
91
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
97
|
-
className
|
|
92
|
+
className,
|
|
98
93
|
)}
|
|
99
94
|
checked={checked}
|
|
100
95
|
{...props}
|
|
@@ -104,24 +99,18 @@ function DropdownMenuCheckboxItem({
|
|
|
104
99
|
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
105
100
|
>
|
|
106
101
|
<DropdownMenuPrimitive.ItemIndicator>
|
|
107
|
-
<CheckIcon
|
|
108
|
-
/>
|
|
102
|
+
<CheckIcon />
|
|
109
103
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
110
104
|
</span>
|
|
111
105
|
{children}
|
|
112
106
|
</DropdownMenuPrimitive.CheckboxItem>
|
|
113
|
-
)
|
|
107
|
+
);
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
function DropdownMenuRadioGroup({
|
|
117
111
|
...props
|
|
118
112
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
119
|
-
return
|
|
120
|
-
<DropdownMenuPrimitive.RadioGroup
|
|
121
|
-
data-slot="dropdown-menu-radio-group"
|
|
122
|
-
{...props}
|
|
123
|
-
/>
|
|
124
|
-
)
|
|
113
|
+
return <DropdownMenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />;
|
|
125
114
|
}
|
|
126
115
|
|
|
127
116
|
function DropdownMenuRadioItem({
|
|
@@ -130,7 +119,7 @@ function DropdownMenuRadioItem({
|
|
|
130
119
|
inset,
|
|
131
120
|
...props
|
|
132
121
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
|
|
133
|
-
inset?: boolean
|
|
122
|
+
inset?: boolean;
|
|
134
123
|
}) {
|
|
135
124
|
return (
|
|
136
125
|
<DropdownMenuPrimitive.RadioItem
|
|
@@ -138,7 +127,7 @@ function DropdownMenuRadioItem({
|
|
|
138
127
|
data-inset={inset}
|
|
139
128
|
className={cn(
|
|
140
129
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
141
|
-
className
|
|
130
|
+
className,
|
|
142
131
|
)}
|
|
143
132
|
{...props}
|
|
144
133
|
>
|
|
@@ -147,13 +136,12 @@ function DropdownMenuRadioItem({
|
|
|
147
136
|
data-slot="dropdown-menu-radio-item-indicator"
|
|
148
137
|
>
|
|
149
138
|
<DropdownMenuPrimitive.ItemIndicator>
|
|
150
|
-
<CheckIcon
|
|
151
|
-
/>
|
|
139
|
+
<CheckIcon />
|
|
152
140
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
153
141
|
</span>
|
|
154
142
|
{children}
|
|
155
143
|
</DropdownMenuPrimitive.RadioItem>
|
|
156
|
-
)
|
|
144
|
+
);
|
|
157
145
|
}
|
|
158
146
|
|
|
159
147
|
function DropdownMenuLabel({
|
|
@@ -161,7 +149,7 @@ function DropdownMenuLabel({
|
|
|
161
149
|
inset,
|
|
162
150
|
...props
|
|
163
151
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
164
|
-
inset?: boolean
|
|
152
|
+
inset?: boolean;
|
|
165
153
|
}) {
|
|
166
154
|
return (
|
|
167
155
|
<DropdownMenuPrimitive.Label
|
|
@@ -169,11 +157,11 @@ function DropdownMenuLabel({
|
|
|
169
157
|
data-inset={inset}
|
|
170
158
|
className={cn(
|
|
171
159
|
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
|
172
|
-
className
|
|
160
|
+
className,
|
|
173
161
|
)}
|
|
174
162
|
{...props}
|
|
175
163
|
/>
|
|
176
|
-
)
|
|
164
|
+
);
|
|
177
165
|
}
|
|
178
166
|
|
|
179
167
|
function DropdownMenuSeparator({
|
|
@@ -186,29 +174,24 @@ function DropdownMenuSeparator({
|
|
|
186
174
|
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
187
175
|
{...props}
|
|
188
176
|
/>
|
|
189
|
-
)
|
|
177
|
+
);
|
|
190
178
|
}
|
|
191
179
|
|
|
192
|
-
function DropdownMenuShortcut({
|
|
193
|
-
className,
|
|
194
|
-
...props
|
|
195
|
-
}: React.ComponentProps<"span">) {
|
|
180
|
+
function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
196
181
|
return (
|
|
197
182
|
<span
|
|
198
183
|
data-slot="dropdown-menu-shortcut"
|
|
199
184
|
className={cn(
|
|
200
185
|
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
|
201
|
-
className
|
|
186
|
+
className,
|
|
202
187
|
)}
|
|
203
188
|
{...props}
|
|
204
189
|
/>
|
|
205
|
-
)
|
|
190
|
+
);
|
|
206
191
|
}
|
|
207
192
|
|
|
208
|
-
function DropdownMenuSub({
|
|
209
|
-
...props
|
|
210
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
211
|
-
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
|
193
|
+
function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
194
|
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
|
|
212
195
|
}
|
|
213
196
|
|
|
214
197
|
function DropdownMenuSubTrigger({
|
|
@@ -217,7 +200,7 @@ function DropdownMenuSubTrigger({
|
|
|
217
200
|
children,
|
|
218
201
|
...props
|
|
219
202
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
220
|
-
inset?: boolean
|
|
203
|
+
inset?: boolean;
|
|
221
204
|
}) {
|
|
222
205
|
return (
|
|
223
206
|
<DropdownMenuPrimitive.SubTrigger
|
|
@@ -225,14 +208,14 @@ function DropdownMenuSubTrigger({
|
|
|
225
208
|
data-inset={inset}
|
|
226
209
|
className={cn(
|
|
227
210
|
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
228
|
-
className
|
|
211
|
+
className,
|
|
229
212
|
)}
|
|
230
213
|
{...props}
|
|
231
214
|
>
|
|
232
215
|
{children}
|
|
233
216
|
<ChevronRightIcon className="ml-auto" />
|
|
234
217
|
</DropdownMenuPrimitive.SubTrigger>
|
|
235
|
-
)
|
|
218
|
+
);
|
|
236
219
|
}
|
|
237
220
|
|
|
238
221
|
function DropdownMenuSubContent({
|
|
@@ -242,10 +225,13 @@ function DropdownMenuSubContent({
|
|
|
242
225
|
return (
|
|
243
226
|
<DropdownMenuPrimitive.SubContent
|
|
244
227
|
data-slot="dropdown-menu-sub-content"
|
|
245
|
-
className={cn(
|
|
228
|
+
className={cn(
|
|
229
|
+
"z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
230
|
+
className,
|
|
231
|
+
)}
|
|
246
232
|
{...props}
|
|
247
233
|
/>
|
|
248
|
-
)
|
|
234
|
+
);
|
|
249
235
|
}
|
|
250
236
|
|
|
251
237
|
export {
|
|
@@ -264,4 +250,4 @@ export {
|
|
|
264
250
|
DropdownMenuSub,
|
|
265
251
|
DropdownMenuSubTrigger,
|
|
266
252
|
DropdownMenuSubContent,
|
|
267
|
-
}
|
|
253
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useMemo } from "react"
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
3
|
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { Label } from "./label.js"
|
|
6
|
-
import { Separator } from "./separator.js"
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { Label } from "./label.js";
|
|
6
|
+
import { Separator } from "./separator.js";
|
|
7
7
|
|
|
8
8
|
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
9
9
|
return (
|
|
@@ -11,11 +11,11 @@ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
|
11
11
|
data-slot="field-set"
|
|
12
12
|
className={cn(
|
|
13
13
|
"flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
14
|
-
className
|
|
14
|
+
className,
|
|
15
15
|
)}
|
|
16
16
|
{...props}
|
|
17
17
|
/>
|
|
18
|
-
)
|
|
18
|
+
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function FieldLegend({
|
|
@@ -29,11 +29,11 @@ function FieldLegend({
|
|
|
29
29
|
data-variant={variant}
|
|
30
30
|
className={cn(
|
|
31
31
|
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
|
|
32
|
-
className
|
|
32
|
+
className,
|
|
33
33
|
)}
|
|
34
34
|
{...props}
|
|
35
35
|
/>
|
|
36
|
-
)
|
|
36
|
+
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -42,30 +42,27 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
42
42
|
data-slot="field-group"
|
|
43
43
|
className={cn(
|
|
44
44
|
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
|
|
45
|
-
className
|
|
45
|
+
className,
|
|
46
46
|
)}
|
|
47
47
|
{...props}
|
|
48
48
|
/>
|
|
49
|
-
)
|
|
49
|
+
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const fieldVariants = cva(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
responsive:
|
|
61
|
-
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
62
|
-
},
|
|
52
|
+
const fieldVariants = cva("group/field flex w-full gap-2 data-[invalid=true]:text-destructive", {
|
|
53
|
+
variants: {
|
|
54
|
+
orientation: {
|
|
55
|
+
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
|
56
|
+
horizontal:
|
|
57
|
+
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
58
|
+
responsive:
|
|
59
|
+
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
63
60
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
)
|
|
61
|
+
},
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
orientation: "vertical",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
69
66
|
|
|
70
67
|
function Field({
|
|
71
68
|
className,
|
|
@@ -80,37 +77,31 @@ function Field({
|
|
|
80
77
|
className={cn(fieldVariants({ orientation }), className)}
|
|
81
78
|
{...props}
|
|
82
79
|
/>
|
|
83
|
-
)
|
|
80
|
+
);
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
87
84
|
return (
|
|
88
85
|
<div
|
|
89
86
|
data-slot="field-content"
|
|
90
|
-
className={cn(
|
|
91
|
-
"group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
|
|
92
|
-
className
|
|
93
|
-
)}
|
|
87
|
+
className={cn("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", className)}
|
|
94
88
|
{...props}
|
|
95
89
|
/>
|
|
96
|
-
)
|
|
90
|
+
);
|
|
97
91
|
}
|
|
98
92
|
|
|
99
|
-
function FieldLabel({
|
|
100
|
-
className,
|
|
101
|
-
...props
|
|
102
|
-
}: React.ComponentProps<typeof Label>) {
|
|
93
|
+
function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
|
|
103
94
|
return (
|
|
104
95
|
<Label
|
|
105
96
|
data-slot="field-label"
|
|
106
97
|
className={cn(
|
|
107
98
|
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
|
|
108
99
|
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
|
109
|
-
className
|
|
100
|
+
className,
|
|
110
101
|
)}
|
|
111
102
|
{...props}
|
|
112
103
|
/>
|
|
113
|
-
)
|
|
104
|
+
);
|
|
114
105
|
}
|
|
115
106
|
|
|
116
107
|
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -119,11 +110,11 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
119
110
|
data-slot="field-label"
|
|
120
111
|
className={cn(
|
|
121
112
|
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
|
|
122
|
-
className
|
|
113
|
+
className,
|
|
123
114
|
)}
|
|
124
115
|
{...props}
|
|
125
116
|
/>
|
|
126
|
-
)
|
|
117
|
+
);
|
|
127
118
|
}
|
|
128
119
|
|
|
129
120
|
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
@@ -134,11 +125,11 @@ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
134
125
|
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
|
|
135
126
|
"last:mt-0 nth-last-2:-mt-1",
|
|
136
127
|
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
|
137
|
-
className
|
|
128
|
+
className,
|
|
138
129
|
)}
|
|
139
130
|
{...props}
|
|
140
131
|
/>
|
|
141
|
-
)
|
|
132
|
+
);
|
|
142
133
|
}
|
|
143
134
|
|
|
144
135
|
function FieldSeparator({
|
|
@@ -146,7 +137,7 @@ function FieldSeparator({
|
|
|
146
137
|
className,
|
|
147
138
|
...props
|
|
148
139
|
}: React.ComponentProps<"div"> & {
|
|
149
|
-
children?: React.ReactNode
|
|
140
|
+
children?: React.ReactNode;
|
|
150
141
|
}) {
|
|
151
142
|
return (
|
|
152
143
|
<div
|
|
@@ -154,7 +145,7 @@ function FieldSeparator({
|
|
|
154
145
|
data-content={!!children}
|
|
155
146
|
className={cn(
|
|
156
147
|
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
|
157
|
-
className
|
|
148
|
+
className,
|
|
158
149
|
)}
|
|
159
150
|
{...props}
|
|
160
151
|
>
|
|
@@ -168,7 +159,7 @@ function FieldSeparator({
|
|
|
168
159
|
</span>
|
|
169
160
|
)}
|
|
170
161
|
</div>
|
|
171
|
-
)
|
|
162
|
+
);
|
|
172
163
|
}
|
|
173
164
|
|
|
174
165
|
function FieldError({
|
|
@@ -177,37 +168,32 @@ function FieldError({
|
|
|
177
168
|
errors,
|
|
178
169
|
...props
|
|
179
170
|
}: React.ComponentProps<"div"> & {
|
|
180
|
-
errors?: Array<{ message?: string } | undefined
|
|
171
|
+
errors?: Array<{ message?: string } | undefined>;
|
|
181
172
|
}) {
|
|
182
173
|
const content = useMemo(() => {
|
|
183
174
|
if (children) {
|
|
184
|
-
return children
|
|
175
|
+
return children;
|
|
185
176
|
}
|
|
186
177
|
|
|
187
178
|
if (!errors?.length) {
|
|
188
|
-
return null
|
|
179
|
+
return null;
|
|
189
180
|
}
|
|
190
181
|
|
|
191
|
-
const uniqueErrors = [
|
|
192
|
-
...new Map(errors.map((error) => [error?.message, error])).values(),
|
|
193
|
-
]
|
|
182
|
+
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
|
|
194
183
|
|
|
195
184
|
if (uniqueErrors?.length == 1) {
|
|
196
|
-
return uniqueErrors[0]?.message
|
|
185
|
+
return uniqueErrors[0]?.message;
|
|
197
186
|
}
|
|
198
187
|
|
|
199
188
|
return (
|
|
200
189
|
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
201
|
-
{uniqueErrors.map(
|
|
202
|
-
(error, index) =>
|
|
203
|
-
error?.message && <li key={index}>{error.message}</li>
|
|
204
|
-
)}
|
|
190
|
+
{uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
|
|
205
191
|
</ul>
|
|
206
|
-
)
|
|
207
|
-
}, [children, errors])
|
|
192
|
+
);
|
|
193
|
+
}, [children, errors]);
|
|
208
194
|
|
|
209
195
|
if (!content) {
|
|
210
|
-
return null
|
|
196
|
+
return null;
|
|
211
197
|
}
|
|
212
198
|
|
|
213
199
|
return (
|
|
@@ -219,7 +205,7 @@ function FieldError({
|
|
|
219
205
|
>
|
|
220
206
|
{content}
|
|
221
207
|
</div>
|
|
222
|
-
)
|
|
208
|
+
);
|
|
223
209
|
}
|
|
224
210
|
|
|
225
211
|
export {
|
|
@@ -233,4 +219,4 @@ export {
|
|
|
233
219
|
FieldSet,
|
|
234
220
|
FieldContent,
|
|
235
221
|
FieldTitle,
|
|
236
|
-
}
|
|
222
|
+
};
|