@saena-io/create 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/dist/index.js +9 -9
- package/package.json +1 -1
- package/template/base/package.json +44 -2
- package/template/base/scripts/ui-update.ts +83 -0
- package/template/base/src/components/ui/accordion.tsx +75 -0
- package/template/base/src/components/ui/alert-dialog.tsx +162 -0
- package/template/base/src/components/ui/alert.tsx +73 -0
- package/template/base/src/components/ui/app-sidebar.tsx +183 -0
- package/template/base/src/components/ui/aspect-ratio.tsx +22 -0
- package/template/base/src/components/ui/asset-input.tsx +211 -0
- package/template/base/src/components/ui/avatar.tsx +91 -0
- package/template/base/src/components/ui/badge.tsx +50 -0
- package/template/base/src/components/ui/breadcrumb.tsx +104 -0
- package/template/base/src/components/ui/button-group.tsx +78 -0
- package/template/base/src/components/ui/button.tsx +56 -0
- package/template/base/src/components/ui/calendar.tsx +205 -0
- package/template/base/src/components/ui/card.tsx +85 -0
- package/template/base/src/components/ui/carousel.tsx +232 -0
- package/template/base/src/components/ui/chart.tsx +337 -0
- package/template/base/src/components/ui/checkbox.tsx +29 -0
- package/template/base/src/components/ui/collapsible.tsx +15 -0
- package/template/base/src/components/ui/combobox.tsx +276 -0
- package/template/base/src/components/ui/command.tsx +190 -0
- package/template/base/src/components/ui/context-menu.tsx +243 -0
- package/template/base/src/components/ui/dialog.tsx +134 -0
- package/template/base/src/components/ui/direction.tsx +4 -0
- package/template/base/src/components/ui/drawer.tsx +120 -0
- package/template/base/src/components/ui/dropdown-menu.tsx +254 -0
- package/template/base/src/components/ui/empty.tsx +94 -0
- package/template/base/src/components/ui/field.tsx +222 -0
- package/template/base/src/components/ui/focal-point-picker.tsx +175 -0
- package/template/base/src/components/ui/hover-card.tsx +46 -0
- package/template/base/src/components/ui/input-group.tsx +149 -0
- package/template/base/src/components/ui/input-otp.tsx +85 -0
- package/template/base/src/components/ui/input.tsx +20 -0
- package/template/base/src/components/ui/item.tsx +188 -0
- package/template/base/src/components/ui/kbd.tsx +26 -0
- package/template/base/src/components/ui/label.tsx +20 -0
- package/template/base/src/components/ui/menubar.tsx +268 -0
- package/template/base/src/components/ui/native-select.tsx +58 -0
- package/template/base/src/components/ui/nav-main.tsx +70 -0
- package/template/base/src/components/ui/nav-projects.tsx +97 -0
- package/template/base/src/components/ui/nav-secondary.tsx +37 -0
- package/template/base/src/components/ui/nav-user.tsx +108 -0
- package/template/base/src/components/ui/navigation-menu.tsx +164 -0
- package/template/base/src/components/ui/pagination.tsx +123 -0
- package/template/base/src/components/ui/popover.tsx +80 -0
- package/template/base/src/components/ui/progress.tsx +66 -0
- package/template/base/src/components/ui/radio-group.tsx +36 -0
- package/template/base/src/components/ui/resizable.tsx +42 -0
- package/template/base/src/components/ui/rich-text/ai-chat-editor.tsx +20 -0
- package/template/base/src/components/ui/rich-text/ai-command.tsx +90 -0
- package/template/base/src/components/ui/rich-text/ai-copilot.tsx +67 -0
- package/template/base/src/components/ui/rich-text/ai-menu.tsx +456 -0
- package/template/base/src/components/ui/rich-text/ai-node.tsx +42 -0
- package/template/base/src/components/ui/rich-text/ai-toolbar-button.tsx +29 -0
- package/template/base/src/components/ui/rich-text/block-draggable.tsx +187 -0
- package/template/base/src/components/ui/rich-text/block-selection.tsx +17 -0
- package/template/base/src/components/ui/rich-text/code-block-node.tsx +204 -0
- package/template/base/src/components/ui/rich-text/codec.ts +63 -0
- package/template/base/src/components/ui/rich-text/extension.ts +53 -0
- package/template/base/src/components/ui/rich-text/ghost-text.tsx +23 -0
- package/template/base/src/components/ui/rich-text/import-export-toolbar.tsx +103 -0
- package/template/base/src/components/ui/rich-text/link.tsx +18 -0
- package/template/base/src/components/ui/rich-text/list-node.tsx +65 -0
- package/template/base/src/components/ui/rich-text/nodes.tsx +44 -0
- package/template/base/src/components/ui/rich-text/plugins.ts +233 -0
- package/template/base/src/components/ui/rich-text/rich-text-editor.tsx +82 -0
- package/template/base/src/components/ui/rich-text/static.tsx +117 -0
- package/template/base/src/components/ui/rich-text/table-node.tsx +934 -0
- package/template/base/src/components/ui/rich-text/table-toolbar.tsx +232 -0
- package/template/base/src/components/ui/rich-text/toggle-node.tsx +36 -0
- package/template/base/src/components/ui/rich-text/toolbar-slots.ts +41 -0
- package/template/base/src/components/ui/rich-text/toolbar.tsx +668 -0
- package/template/base/src/components/ui/rich-text/use-ai-chat.ts +35 -0
- package/template/base/src/components/ui/rich-text/variable-type.ts +4 -0
- package/template/base/src/components/ui/rich-text/variable.tsx +97 -0
- package/template/base/src/components/ui/scroll-area.tsx +49 -0
- package/template/base/src/components/ui/select.tsx +202 -0
- package/template/base/src/components/ui/separator.tsx +19 -0
- package/template/base/src/components/ui/sheet.tsx +126 -0
- package/template/base/src/components/ui/sidebar.tsx +695 -0
- package/template/base/src/components/ui/skeleton.tsx +13 -0
- package/template/base/src/components/ui/slider.tsx +52 -0
- package/template/base/src/components/ui/sonner.tsx +50 -0
- package/template/base/src/components/ui/spinner.tsx +18 -0
- package/template/base/src/components/ui/switch.tsx +30 -0
- package/template/base/src/components/ui/table.tsx +89 -0
- package/template/base/src/components/ui/tabs.tsx +73 -0
- package/template/base/src/components/ui/textarea.tsx +18 -0
- package/template/base/src/components/ui/toggle-group.tsx +85 -0
- package/template/base/src/components/ui/toggle.tsx +45 -0
- package/template/base/src/components/ui/toolbar.tsx +451 -0
- package/template/base/src/components/ui/tooltip.tsx +52 -0
- package/template/base/src/hooks/use-mobile.ts +19 -0
- package/template/base/src/lib/utils.ts +6 -0
- package/template/base/src/routes/__root.tsx +1 -1
- package/template/base/src/server/auth.ts +2 -2
- package/template/base/src/styles/globals.css +230 -0
- package/template/base/vite.config.ts +15 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { ArrowRight01Icon, Tick02Icon } from '@hugeicons/core-free-icons';
|
|
5
|
+
import { HugeiconsIcon } from '@hugeicons/react';
|
|
6
|
+
import { cn } from '@saena-io/ui/lib/utils';
|
|
7
|
+
|
|
8
|
+
function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
|
|
9
|
+
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
|
|
13
|
+
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
|
|
17
|
+
return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DropdownMenuContent({
|
|
21
|
+
align = 'start',
|
|
22
|
+
alignOffset = 0,
|
|
23
|
+
side = 'bottom',
|
|
24
|
+
sideOffset = 4,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: MenuPrimitive.Popup.Props &
|
|
28
|
+
Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
|
|
29
|
+
return (
|
|
30
|
+
<MenuPrimitive.Portal>
|
|
31
|
+
<MenuPrimitive.Positioner
|
|
32
|
+
className="isolate z-50 outline-none"
|
|
33
|
+
align={align}
|
|
34
|
+
alignOffset={alignOffset}
|
|
35
|
+
side={side}
|
|
36
|
+
sideOffset={sideOffset}
|
|
37
|
+
>
|
|
38
|
+
<MenuPrimitive.Popup
|
|
39
|
+
data-slot="dropdown-menu-content"
|
|
40
|
+
className={cn(
|
|
41
|
+
'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--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 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
</MenuPrimitive.Positioner>
|
|
47
|
+
</MenuPrimitive.Portal>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {
|
|
52
|
+
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function DropdownMenuLabel({
|
|
56
|
+
className,
|
|
57
|
+
inset,
|
|
58
|
+
...props
|
|
59
|
+
}: MenuPrimitive.GroupLabel.Props & {
|
|
60
|
+
inset?: boolean;
|
|
61
|
+
}) {
|
|
62
|
+
return (
|
|
63
|
+
<MenuPrimitive.GroupLabel
|
|
64
|
+
data-slot="dropdown-menu-label"
|
|
65
|
+
data-inset={inset}
|
|
66
|
+
className={cn('px-2 py-1.5 text-xs text-muted-foreground data-inset:pl-7.5', className)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function DropdownMenuItem({
|
|
73
|
+
className,
|
|
74
|
+
inset,
|
|
75
|
+
variant = 'default',
|
|
76
|
+
...props
|
|
77
|
+
}: MenuPrimitive.Item.Props & {
|
|
78
|
+
inset?: boolean;
|
|
79
|
+
variant?: 'default' | 'destructive';
|
|
80
|
+
}) {
|
|
81
|
+
return (
|
|
82
|
+
<MenuPrimitive.Item
|
|
83
|
+
data-slot="dropdown-menu-item"
|
|
84
|
+
data-inset={inset}
|
|
85
|
+
data-variant={variant}
|
|
86
|
+
className={cn(
|
|
87
|
+
"group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 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-3.5 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
|
|
96
|
+
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function DropdownMenuSubTrigger({
|
|
100
|
+
className,
|
|
101
|
+
inset,
|
|
102
|
+
children,
|
|
103
|
+
...props
|
|
104
|
+
}: MenuPrimitive.SubmenuTrigger.Props & {
|
|
105
|
+
inset?: boolean;
|
|
106
|
+
}) {
|
|
107
|
+
return (
|
|
108
|
+
<MenuPrimitive.SubmenuTrigger
|
|
109
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
110
|
+
data-inset={inset}
|
|
111
|
+
className={cn(
|
|
112
|
+
"flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
{...props}
|
|
116
|
+
>
|
|
117
|
+
{children}
|
|
118
|
+
<HugeiconsIcon icon={ArrowRight01Icon} strokeWidth={2} className="ml-auto" />
|
|
119
|
+
</MenuPrimitive.SubmenuTrigger>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function DropdownMenuSubContent({
|
|
124
|
+
align = 'start',
|
|
125
|
+
alignOffset = -3,
|
|
126
|
+
side = 'right',
|
|
127
|
+
sideOffset = 0,
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}: React.ComponentProps<typeof DropdownMenuContent>) {
|
|
131
|
+
return (
|
|
132
|
+
<DropdownMenuContent
|
|
133
|
+
data-slot="dropdown-menu-sub-content"
|
|
134
|
+
className={cn(
|
|
135
|
+
'w-auto min-w-32 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-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',
|
|
136
|
+
className,
|
|
137
|
+
)}
|
|
138
|
+
align={align}
|
|
139
|
+
alignOffset={alignOffset}
|
|
140
|
+
side={side}
|
|
141
|
+
sideOffset={sideOffset}
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function DropdownMenuCheckboxItem({
|
|
148
|
+
className,
|
|
149
|
+
children,
|
|
150
|
+
checked,
|
|
151
|
+
inset,
|
|
152
|
+
...props
|
|
153
|
+
}: MenuPrimitive.CheckboxItem.Props & {
|
|
154
|
+
inset?: boolean;
|
|
155
|
+
}) {
|
|
156
|
+
return (
|
|
157
|
+
<MenuPrimitive.CheckboxItem
|
|
158
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
159
|
+
data-inset={inset}
|
|
160
|
+
className={cn(
|
|
161
|
+
"relative flex min-h-7 cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7.5 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
162
|
+
className,
|
|
163
|
+
)}
|
|
164
|
+
checked={checked}
|
|
165
|
+
{...props}
|
|
166
|
+
>
|
|
167
|
+
<span
|
|
168
|
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
169
|
+
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
170
|
+
>
|
|
171
|
+
<MenuPrimitive.CheckboxItemIndicator>
|
|
172
|
+
<HugeiconsIcon icon={Tick02Icon} strokeWidth={2} />
|
|
173
|
+
</MenuPrimitive.CheckboxItemIndicator>
|
|
174
|
+
</span>
|
|
175
|
+
{children}
|
|
176
|
+
</MenuPrimitive.CheckboxItem>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
|
|
181
|
+
return <MenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function DropdownMenuRadioItem({
|
|
185
|
+
className,
|
|
186
|
+
children,
|
|
187
|
+
inset,
|
|
188
|
+
...props
|
|
189
|
+
}: MenuPrimitive.RadioItem.Props & {
|
|
190
|
+
inset?: boolean;
|
|
191
|
+
}) {
|
|
192
|
+
return (
|
|
193
|
+
<MenuPrimitive.RadioItem
|
|
194
|
+
data-slot="dropdown-menu-radio-item"
|
|
195
|
+
data-inset={inset}
|
|
196
|
+
className={cn(
|
|
197
|
+
"relative flex min-h-7 cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7.5 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
198
|
+
className,
|
|
199
|
+
)}
|
|
200
|
+
{...props}
|
|
201
|
+
>
|
|
202
|
+
<span
|
|
203
|
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
204
|
+
data-slot="dropdown-menu-radio-item-indicator"
|
|
205
|
+
>
|
|
206
|
+
<MenuPrimitive.RadioItemIndicator>
|
|
207
|
+
<HugeiconsIcon icon={Tick02Icon} strokeWidth={2} />
|
|
208
|
+
</MenuPrimitive.RadioItemIndicator>
|
|
209
|
+
</span>
|
|
210
|
+
{children}
|
|
211
|
+
</MenuPrimitive.RadioItem>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {
|
|
216
|
+
return (
|
|
217
|
+
<MenuPrimitive.Separator
|
|
218
|
+
data-slot="dropdown-menu-separator"
|
|
219
|
+
className={cn('-mx-1 my-1 h-px bg-border/50', className)}
|
|
220
|
+
{...props}
|
|
221
|
+
/>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>) {
|
|
226
|
+
return (
|
|
227
|
+
<span
|
|
228
|
+
data-slot="dropdown-menu-shortcut"
|
|
229
|
+
className={cn(
|
|
230
|
+
'ml-auto text-[0.625rem] tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground',
|
|
231
|
+
className,
|
|
232
|
+
)}
|
|
233
|
+
{...props}
|
|
234
|
+
/>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export {
|
|
239
|
+
DropdownMenu,
|
|
240
|
+
DropdownMenuPortal,
|
|
241
|
+
DropdownMenuTrigger,
|
|
242
|
+
DropdownMenuContent,
|
|
243
|
+
DropdownMenuGroup,
|
|
244
|
+
DropdownMenuLabel,
|
|
245
|
+
DropdownMenuItem,
|
|
246
|
+
DropdownMenuCheckboxItem,
|
|
247
|
+
DropdownMenuRadioGroup,
|
|
248
|
+
DropdownMenuRadioItem,
|
|
249
|
+
DropdownMenuSeparator,
|
|
250
|
+
DropdownMenuShortcut,
|
|
251
|
+
DropdownMenuSub,
|
|
252
|
+
DropdownMenuSubTrigger,
|
|
253
|
+
DropdownMenuSubContent,
|
|
254
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type VariantProps, cva } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@saena-io/ui/lib/utils';
|
|
4
|
+
|
|
5
|
+
function Empty({ className, ...props }: React.ComponentProps<'div'>) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="empty"
|
|
9
|
+
className={cn(
|
|
10
|
+
'flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance',
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="empty-header"
|
|
22
|
+
className={cn('flex max-w-sm flex-col items-center gap-1', className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const emptyMediaVariants = cva(
|
|
29
|
+
'mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
default: 'bg-transparent',
|
|
34
|
+
icon: "flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
variant: 'default',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function EmptyMedia({
|
|
44
|
+
className,
|
|
45
|
+
variant = 'default',
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>) {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
data-slot="empty-icon"
|
|
51
|
+
data-variant={variant}
|
|
52
|
+
className={cn(emptyMediaVariants({ variant, className }))}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function EmptyTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-slot="empty-title"
|
|
62
|
+
className={cn('font-heading text-sm font-medium tracking-tight', className)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function EmptyDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
data-slot="empty-description"
|
|
72
|
+
className={cn(
|
|
73
|
+
'text-xs/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
|
|
74
|
+
className,
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function EmptyContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
data-slot="empty-content"
|
|
85
|
+
className={cn(
|
|
86
|
+
'flex w-full max-w-sm min-w-0 flex-col items-center gap-2 text-xs/relaxed text-balance',
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { type VariantProps, cva } from 'class-variance-authority';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Label } from '@saena-io/ui/components/label';
|
|
5
|
+
import { Separator } from '@saena-io/ui/components/separator';
|
|
6
|
+
import { cn } from '@saena-io/ui/lib/utils';
|
|
7
|
+
|
|
8
|
+
function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
|
|
9
|
+
return (
|
|
10
|
+
<fieldset
|
|
11
|
+
data-slot="field-set"
|
|
12
|
+
className={cn(
|
|
13
|
+
'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function FieldLegend({
|
|
22
|
+
className,
|
|
23
|
+
variant = 'legend',
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
|
|
26
|
+
return (
|
|
27
|
+
<legend
|
|
28
|
+
data-slot="field-legend"
|
|
29
|
+
data-variant={variant}
|
|
30
|
+
className={cn(
|
|
31
|
+
'mb-2 font-medium data-[variant=label]:text-xs/relaxed data-[variant=legend]:text-sm',
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
data-slot="field-group"
|
|
43
|
+
className={cn(
|
|
44
|
+
'group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
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',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
orientation: 'vertical',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function Field({
|
|
68
|
+
className,
|
|
69
|
+
orientation = 'vertical',
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
role="group"
|
|
75
|
+
data-slot="field"
|
|
76
|
+
data-orientation={orientation}
|
|
77
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="field-content"
|
|
87
|
+
className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
|
|
94
|
+
return (
|
|
95
|
+
<Label
|
|
96
|
+
data-slot="field-label"
|
|
97
|
+
className={cn(
|
|
98
|
+
'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10',
|
|
99
|
+
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
|
|
100
|
+
className,
|
|
101
|
+
)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
data-slot="field-label"
|
|
111
|
+
className={cn(
|
|
112
|
+
'flex w-fit items-center gap-2 text-xs/relaxed font-medium group-data-[disabled=true]/field:opacity-50',
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
121
|
+
return (
|
|
122
|
+
<p
|
|
123
|
+
data-slot="field-description"
|
|
124
|
+
className={cn(
|
|
125
|
+
'text-left text-xs/relaxed leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5',
|
|
126
|
+
'last:mt-0 nth-last-2:-mt-1',
|
|
127
|
+
'[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
|
|
128
|
+
className,
|
|
129
|
+
)}
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function FieldSeparator({
|
|
136
|
+
children,
|
|
137
|
+
className,
|
|
138
|
+
...props
|
|
139
|
+
}: React.ComponentProps<'div'> & {
|
|
140
|
+
children?: React.ReactNode;
|
|
141
|
+
}) {
|
|
142
|
+
return (
|
|
143
|
+
<div
|
|
144
|
+
data-slot="field-separator"
|
|
145
|
+
data-content={!!children}
|
|
146
|
+
className={cn(
|
|
147
|
+
'relative -my-2 h-5 text-xs/relaxed group-data-[variant=outline]/field-group:-mb-2',
|
|
148
|
+
className,
|
|
149
|
+
)}
|
|
150
|
+
{...props}
|
|
151
|
+
>
|
|
152
|
+
<Separator className="absolute inset-0 top-1/2" />
|
|
153
|
+
{children && (
|
|
154
|
+
<span
|
|
155
|
+
className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
|
|
156
|
+
data-slot="field-separator-content"
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
</span>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function FieldError({
|
|
166
|
+
className,
|
|
167
|
+
children,
|
|
168
|
+
errors,
|
|
169
|
+
...props
|
|
170
|
+
}: React.ComponentProps<'div'> & {
|
|
171
|
+
errors?: Array<{ message?: string } | undefined>;
|
|
172
|
+
}) {
|
|
173
|
+
const content = useMemo(() => {
|
|
174
|
+
if (children) {
|
|
175
|
+
return children;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!errors?.length) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
|
|
183
|
+
|
|
184
|
+
if (uniqueErrors?.length == 1) {
|
|
185
|
+
return uniqueErrors[0]?.message;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
190
|
+
{uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
|
|
191
|
+
</ul>
|
|
192
|
+
);
|
|
193
|
+
}, [children, errors]);
|
|
194
|
+
|
|
195
|
+
if (!content) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div
|
|
201
|
+
role="alert"
|
|
202
|
+
data-slot="field-error"
|
|
203
|
+
className={cn('text-xs/relaxed font-normal text-destructive', className)}
|
|
204
|
+
{...props}
|
|
205
|
+
>
|
|
206
|
+
{content}
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export {
|
|
212
|
+
Field,
|
|
213
|
+
FieldLabel,
|
|
214
|
+
FieldDescription,
|
|
215
|
+
FieldError,
|
|
216
|
+
FieldGroup,
|
|
217
|
+
FieldLegend,
|
|
218
|
+
FieldSeparator,
|
|
219
|
+
FieldSet,
|
|
220
|
+
FieldContent,
|
|
221
|
+
FieldTitle,
|
|
222
|
+
};
|