@oaiz/app-kit 0.0.0-stage → 0.1.4128
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/LICENSE +21 -0
- package/README.md +143 -2
- package/THIRD_PARTY_NOTICES.md +76 -0
- package/package.json +139 -4
- package/registry.json +1847 -0
- package/src/components/activity-timeline.tsx +227 -0
- package/src/components/app-shell.tsx +622 -0
- package/src/components/bar-list.tsx +47 -0
- package/src/components/board.tsx +700 -0
- package/src/components/calendar-view.tsx +1388 -0
- package/src/components/card-grid.tsx +462 -0
- package/src/components/charts.tsx +701 -0
- package/src/components/chat-markdown.tsx +230 -0
- package/src/components/chat-panel.tsx +760 -0
- package/src/components/code-editor.tsx +276 -0
- package/src/components/collection-controls.tsx +226 -0
- package/src/components/command-palette.tsx +403 -0
- package/src/components/confirm-action.tsx +123 -0
- package/src/components/data-table.tsx +821 -0
- package/src/components/date-input.tsx +429 -0
- package/src/components/empty-state.tsx +31 -0
- package/src/components/error-state.tsx +37 -0
- package/src/components/file-upload.tsx +595 -0
- package/src/components/filter-bar.tsx +415 -0
- package/src/components/grouped-picker.tsx +250 -0
- package/src/components/line-items.tsx +601 -0
- package/src/components/list-view.tsx +491 -0
- package/src/components/metrics.tsx +53 -0
- package/src/components/page-header.tsx +33 -0
- package/src/components/property-picker.tsx +546 -0
- package/src/components/record-detail.tsx +416 -0
- package/src/components/record-form.tsx +295 -0
- package/src/components/record-name.tsx +85 -0
- package/src/components/save-bar.tsx +142 -0
- package/src/components/sign-in.tsx +179 -0
- package/src/components/split-view.tsx +128 -0
- package/src/components/status-dot.tsx +56 -0
- package/src/components/stepper.tsx +153 -0
- package/src/components/text-diff-model.ts +111 -0
- package/src/components/text-diff.tsx +98 -0
- package/src/components/time-zone-picker.tsx +69 -0
- package/src/components/ui/accordion.tsx +138 -0
- package/src/components/ui/alert-dialog.tsx +67 -0
- package/src/components/ui/alert.tsx +65 -0
- package/src/components/ui/avatar-group.tsx +119 -0
- package/src/components/ui/avatar.tsx +55 -0
- package/src/components/ui/badge.tsx +59 -0
- package/src/components/ui/bottom-navigation.tsx +102 -0
- package/src/components/ui/breadcrumb.tsx +117 -0
- package/src/components/ui/button.tsx +71 -0
- package/src/components/ui/card.tsx +95 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/collapsible.tsx +27 -0
- package/src/components/ui/context-menu.tsx +270 -0
- package/src/components/ui/count-up.tsx +136 -0
- package/src/components/ui/detail-disclosure-section.tsx +109 -0
- package/src/components/ui/dialog.tsx +157 -0
- package/src/components/ui/dropdown-menu.tsx +273 -0
- package/src/components/ui/form-field.tsx +155 -0
- package/src/components/ui/heading.tsx +126 -0
- package/src/components/ui/hover-card.tsx +45 -0
- package/src/components/ui/input.tsx +50 -0
- package/src/components/ui/label.tsx +30 -0
- package/src/components/ui/orb-spinner.tsx +238 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/progress-ring.tsx +125 -0
- package/src/components/ui/progress.tsx +38 -0
- package/src/components/ui/radio-group.tsx +124 -0
- package/src/components/ui/resizable.tsx +48 -0
- package/src/components/ui/scroll-fade.tsx +98 -0
- package/src/components/ui/segmented-control.tsx +70 -0
- package/src/components/ui/select.tsx +230 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +170 -0
- package/src/components/ui/shimmer-text.tsx +87 -0
- package/src/components/ui/shortcut.tsx +39 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/slider.tsx +48 -0
- package/src/components/ui/switch.tsx +44 -0
- package/src/components/ui/table.tsx +119 -0
- package/src/components/ui/tabs.tsx +80 -0
- package/src/components/ui/text.tsx +93 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/toast.tsx +141 -0
- package/src/components/ui/toaster.tsx +40 -0
- package/src/components/ui/tooltip.tsx +38 -0
- package/src/components/ui/top-banner.tsx +108 -0
- package/src/components/ui/tree-view.tsx +215 -0
- package/src/components/ui/use-toast.tsx +184 -0
- package/src/components/ui/voice-orb.tsx +252 -0
- package/src/hooks/oaiz-chat.tsx +530 -0
- package/src/hooks/oaiz-data.tsx +617 -0
- package/src/hooks/oaiz-session.tsx +63 -0
- package/src/hooks/use-arrivals.ts +19 -0
- package/src/hooks/use-breakpoint.ts +100 -0
- package/src/hooks/use-media-query.ts +36 -0
- package/src/hooks/use-theme.ts +67 -0
- package/src/hooks/use-url-state.ts +77 -0
- package/src/lib/breakpoints.ts +81 -0
- package/src/lib/csp-nonce.ts +15 -0
- package/src/lib/format.ts +291 -0
- package/src/lib/speech-level.ts +118 -0
- package/src/lib/utils.ts +109 -0
- package/src/styles/oaiz/app.css +21 -0
- package/src/styles/oaiz/scrollbars.css +20 -0
- package/src/styles/oaiz/tokens.css +952 -0
- package/src/styles/oaiz/voice-orb.css +39 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn, usePointerCloseFocus } from '../../lib/utils';
|
|
6
|
+
import { Text } from './text';
|
|
7
|
+
|
|
8
|
+
const ModalMenuOpenContext = React.createContext(false);
|
|
9
|
+
|
|
10
|
+
const DropdownMenu = ({
|
|
11
|
+
open: controlledOpen,
|
|
12
|
+
defaultOpen = false,
|
|
13
|
+
modal = true,
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) => {
|
|
16
|
+
const [uncontrolledOpen, setOpen] = React.useState(defaultOpen);
|
|
17
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
18
|
+
return (
|
|
19
|
+
<ModalMenuOpenContext.Provider value={modal && open}>
|
|
20
|
+
<DropdownMenuPrimitive.Root
|
|
21
|
+
{...props}
|
|
22
|
+
modal={modal}
|
|
23
|
+
open={open}
|
|
24
|
+
onOpenChange={(nextOpen) => {
|
|
25
|
+
if (controlledOpen === undefined) setOpen(nextOpen);
|
|
26
|
+
props.onOpenChange?.(nextOpen);
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
</ModalMenuOpenContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DropdownMenuTrigger = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Trigger>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Trigger>
|
|
36
|
+
>(({ tabIndex, ...props }, ref) => {
|
|
37
|
+
const modalOpen = React.useContext(ModalMenuOpenContext);
|
|
38
|
+
return (
|
|
39
|
+
<DropdownMenuPrimitive.Trigger
|
|
40
|
+
{...props}
|
|
41
|
+
ref={ref}
|
|
42
|
+
// Radix hides the trigger from AT while its modal menu traps focus.
|
|
43
|
+
// Keep the sequential tab order consistent with that hidden state.
|
|
44
|
+
tabIndex={modalOpen ? -1 : tabIndex}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
DropdownMenuTrigger.displayName = DropdownMenuPrimitive.Trigger.displayName;
|
|
49
|
+
|
|
50
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
51
|
+
|
|
52
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
53
|
+
|
|
54
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
55
|
+
|
|
56
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
57
|
+
|
|
58
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
59
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
60
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
61
|
+
inset?: boolean;
|
|
62
|
+
}
|
|
63
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
64
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn(
|
|
67
|
+
'flex cursor-default gap-inline select-none items-center rounded-sm px-inline py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
68
|
+
inset && 'pl-section',
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
<ChevronRight className="ml-auto" />
|
|
75
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
76
|
+
));
|
|
77
|
+
DropdownMenuSubTrigger.displayName =
|
|
78
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
79
|
+
|
|
80
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
81
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
82
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
83
|
+
>(({ className, ...props }, ref) => (
|
|
84
|
+
<DropdownMenuPrimitive.SubContent
|
|
85
|
+
ref={ref}
|
|
86
|
+
className={cn(
|
|
87
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg outline-none duration-fast ease-enter data-[state=closed]:ease-exit 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',
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
DropdownMenuSubContent.displayName =
|
|
94
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
95
|
+
|
|
96
|
+
const DropdownMenuContent = React.forwardRef<
|
|
97
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
98
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
|
|
99
|
+
onOpenAutoFocus?: (event: Event) => void;
|
|
100
|
+
}
|
|
101
|
+
>(
|
|
102
|
+
(
|
|
103
|
+
{
|
|
104
|
+
className,
|
|
105
|
+
sideOffset = 4,
|
|
106
|
+
onOpenAutoFocus,
|
|
107
|
+
onPointerDownCapture,
|
|
108
|
+
onClickCapture,
|
|
109
|
+
onKeyDownCapture,
|
|
110
|
+
onEscapeKeyDown,
|
|
111
|
+
onPointerDownOutside,
|
|
112
|
+
onCloseAutoFocus,
|
|
113
|
+
...props
|
|
114
|
+
},
|
|
115
|
+
ref,
|
|
116
|
+
) => {
|
|
117
|
+
const pointerCloseFocus = usePointerCloseFocus({
|
|
118
|
+
onPointerDownCapture,
|
|
119
|
+
onClickCapture,
|
|
120
|
+
onKeyDownCapture,
|
|
121
|
+
onEscapeKeyDown,
|
|
122
|
+
onPointerDownOutside,
|
|
123
|
+
onCloseAutoFocus,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<DropdownMenuPrimitive.Portal>
|
|
128
|
+
<DropdownMenuPrimitive.Content
|
|
129
|
+
ref={ref}
|
|
130
|
+
sideOffset={sideOffset}
|
|
131
|
+
className={cn(
|
|
132
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none duration-fast ease-enter data-[state=closed]:ease-exit 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',
|
|
133
|
+
className,
|
|
134
|
+
)}
|
|
135
|
+
{...pointerCloseFocus}
|
|
136
|
+
{...props}
|
|
137
|
+
{...(onOpenAutoFocus ? { onOpenAutoFocus } : {})}
|
|
138
|
+
/>
|
|
139
|
+
</DropdownMenuPrimitive.Portal>
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
144
|
+
|
|
145
|
+
const DropdownMenuItem = React.forwardRef<
|
|
146
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
147
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
148
|
+
inset?: boolean;
|
|
149
|
+
unstyled?: boolean;
|
|
150
|
+
}
|
|
151
|
+
>(({ className, inset, unstyled = false, ...props }, ref) => (
|
|
152
|
+
<DropdownMenuPrimitive.Item
|
|
153
|
+
ref={ref}
|
|
154
|
+
className={cn(
|
|
155
|
+
unstyled
|
|
156
|
+
? 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'
|
|
157
|
+
: 'relative flex cursor-default select-none items-center gap-inline rounded-sm px-inline py-1.5 text-sm text-sidebar-foreground outline-none transition-colors duration-fast ease-move focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
158
|
+
!unstyled && inset && 'pl-section',
|
|
159
|
+
className,
|
|
160
|
+
)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
));
|
|
164
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
165
|
+
|
|
166
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
167
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
168
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
169
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
170
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
171
|
+
ref={ref}
|
|
172
|
+
className={cn(
|
|
173
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-section pr-inline text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
174
|
+
className,
|
|
175
|
+
)}
|
|
176
|
+
checked={checked}
|
|
177
|
+
{...props}
|
|
178
|
+
>
|
|
179
|
+
<span className="absolute left-inline flex h-3.5 w-3.5 items-center justify-center rounded-sm border border-input bg-background text-current">
|
|
180
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
181
|
+
<Check className="h-3 w-3" />
|
|
182
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
183
|
+
</span>
|
|
184
|
+
{children}
|
|
185
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
186
|
+
));
|
|
187
|
+
DropdownMenuCheckboxItem.displayName =
|
|
188
|
+
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
189
|
+
|
|
190
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
191
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
192
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
193
|
+
>(({ className, children, ...props }, ref) => (
|
|
194
|
+
<DropdownMenuPrimitive.RadioItem
|
|
195
|
+
ref={ref}
|
|
196
|
+
className={cn(
|
|
197
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-section pr-inline text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
198
|
+
className,
|
|
199
|
+
)}
|
|
200
|
+
{...props}
|
|
201
|
+
>
|
|
202
|
+
<span className="absolute left-inline flex h-3.5 w-3.5 items-center justify-center">
|
|
203
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
204
|
+
<Circle className="h-2 w-2 fill-current" />
|
|
205
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
206
|
+
</span>
|
|
207
|
+
{children}
|
|
208
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
209
|
+
));
|
|
210
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
211
|
+
|
|
212
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
213
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
214
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
215
|
+
inset?: boolean;
|
|
216
|
+
}
|
|
217
|
+
>(({ className, inset, ...props }, ref) => (
|
|
218
|
+
<Text
|
|
219
|
+
asChild
|
|
220
|
+
size="sm"
|
|
221
|
+
weight="semibold"
|
|
222
|
+
className={cn('px-inline py-1.5', inset && 'pl-section', className)}
|
|
223
|
+
>
|
|
224
|
+
<DropdownMenuPrimitive.Label ref={ref} {...props} />
|
|
225
|
+
</Text>
|
|
226
|
+
));
|
|
227
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
228
|
+
|
|
229
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
230
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
231
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
232
|
+
>(({ className, ...props }, ref) => (
|
|
233
|
+
<DropdownMenuPrimitive.Separator
|
|
234
|
+
ref={ref}
|
|
235
|
+
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
|
236
|
+
{...props}
|
|
237
|
+
/>
|
|
238
|
+
));
|
|
239
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
240
|
+
|
|
241
|
+
const DropdownMenuShortcut = ({
|
|
242
|
+
className,
|
|
243
|
+
...props
|
|
244
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
245
|
+
return (
|
|
246
|
+
<Text
|
|
247
|
+
as="span"
|
|
248
|
+
size="xs"
|
|
249
|
+
variant="muted"
|
|
250
|
+
className={cn('ml-auto tracking-widest', className)}
|
|
251
|
+
{...props}
|
|
252
|
+
/>
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
256
|
+
|
|
257
|
+
export {
|
|
258
|
+
DropdownMenu,
|
|
259
|
+
DropdownMenuTrigger,
|
|
260
|
+
DropdownMenuContent,
|
|
261
|
+
DropdownMenuItem,
|
|
262
|
+
DropdownMenuCheckboxItem,
|
|
263
|
+
DropdownMenuRadioItem,
|
|
264
|
+
DropdownMenuLabel,
|
|
265
|
+
DropdownMenuSeparator,
|
|
266
|
+
DropdownMenuShortcut,
|
|
267
|
+
DropdownMenuGroup,
|
|
268
|
+
DropdownMenuPortal,
|
|
269
|
+
DropdownMenuSub,
|
|
270
|
+
DropdownMenuSubContent,
|
|
271
|
+
DropdownMenuSubTrigger,
|
|
272
|
+
DropdownMenuRadioGroup,
|
|
273
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useId, type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import { Label } from './label';
|
|
4
|
+
import { Text } from './text';
|
|
5
|
+
|
|
6
|
+
export interface FieldControlProps {
|
|
7
|
+
id: string;
|
|
8
|
+
required: boolean;
|
|
9
|
+
'aria-required': boolean;
|
|
10
|
+
'aria-invalid'?: true;
|
|
11
|
+
'aria-describedby'?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FormFieldProps {
|
|
15
|
+
id?: string;
|
|
16
|
+
label: ReactNode;
|
|
17
|
+
hint?: ReactNode;
|
|
18
|
+
error?: ReactNode;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
requiredLabel?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
children: (control: FieldControlProps) => ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The render prop associates a native input or a custom control with its visible feedback. */
|
|
26
|
+
export function FormField({
|
|
27
|
+
id: suppliedId,
|
|
28
|
+
label,
|
|
29
|
+
hint,
|
|
30
|
+
error,
|
|
31
|
+
required = false,
|
|
32
|
+
requiredLabel = 'required',
|
|
33
|
+
className,
|
|
34
|
+
children,
|
|
35
|
+
}: FormFieldProps) {
|
|
36
|
+
const generatedId = useId();
|
|
37
|
+
const id = suppliedId ?? generatedId;
|
|
38
|
+
const descriptions = [
|
|
39
|
+
hint ? `${id}-hint` : undefined,
|
|
40
|
+
error ? `${id}-error` : undefined,
|
|
41
|
+
]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join(' ');
|
|
44
|
+
return (
|
|
45
|
+
<div className={cn('flex min-w-0 flex-col gap-inline', className)}>
|
|
46
|
+
<div className="flex items-baseline gap-1">
|
|
47
|
+
<Label id={`${id}-label`} htmlFor={id}>
|
|
48
|
+
{label}
|
|
49
|
+
</Label>
|
|
50
|
+
{required && (
|
|
51
|
+
<span className="text-xs text-muted-foreground">
|
|
52
|
+
({requiredLabel})
|
|
53
|
+
</span>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
{hint && (
|
|
57
|
+
<Text id={`${id}-hint`} size="sm" variant="muted">
|
|
58
|
+
{hint}
|
|
59
|
+
</Text>
|
|
60
|
+
)}
|
|
61
|
+
{children({
|
|
62
|
+
id,
|
|
63
|
+
required,
|
|
64
|
+
'aria-required': required,
|
|
65
|
+
'aria-invalid': error ? true : undefined,
|
|
66
|
+
'aria-describedby': descriptions || undefined,
|
|
67
|
+
})}
|
|
68
|
+
{error && (
|
|
69
|
+
<Text id={`${id}-error`} size="sm" variant="destructive">
|
|
70
|
+
{error}
|
|
71
|
+
</Text>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface FieldGroupProps extends ComponentProps<'fieldset'> {
|
|
78
|
+
legend: ReactNode;
|
|
79
|
+
description?: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function FieldGroup({
|
|
83
|
+
legend,
|
|
84
|
+
description,
|
|
85
|
+
className,
|
|
86
|
+
children,
|
|
87
|
+
...props
|
|
88
|
+
}: FieldGroupProps) {
|
|
89
|
+
const id = useId();
|
|
90
|
+
return (
|
|
91
|
+
<fieldset
|
|
92
|
+
className={cn('flex min-w-0 flex-col gap-stack', className)}
|
|
93
|
+
aria-describedby={description ? id : undefined}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
<legend className="mb-inline text-sm font-medium">{legend}</legend>
|
|
97
|
+
{description && (
|
|
98
|
+
<Text id={id} size="sm" variant="muted">
|
|
99
|
+
{description}
|
|
100
|
+
</Text>
|
|
101
|
+
)}
|
|
102
|
+
{children}
|
|
103
|
+
</fieldset>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ErrorSummaryProps extends Omit<
|
|
108
|
+
ComponentProps<'div'>,
|
|
109
|
+
'title'
|
|
110
|
+
> {
|
|
111
|
+
title?: ReactNode;
|
|
112
|
+
errors: readonly { id: string; label: ReactNode; message: ReactNode }[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Focus this summary after a failed submit; each link takes focus to its field. */
|
|
116
|
+
export function ErrorSummary({
|
|
117
|
+
title = 'Check the following fields',
|
|
118
|
+
errors,
|
|
119
|
+
className,
|
|
120
|
+
...props
|
|
121
|
+
}: ErrorSummaryProps) {
|
|
122
|
+
const titleId = useId();
|
|
123
|
+
if (errors.length === 0) return null;
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
|
+
tabIndex={-1}
|
|
127
|
+
aria-labelledby={titleId}
|
|
128
|
+
className={cn(
|
|
129
|
+
'rounded-md border border-destructive-text p-inset focus:outline-none focus:ring-2 focus:ring-ring',
|
|
130
|
+
className,
|
|
131
|
+
)}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
<p id={titleId} className="font-medium">
|
|
135
|
+
{title}
|
|
136
|
+
</p>
|
|
137
|
+
<ul className="mt-inline list-inside list-disc space-y-1">
|
|
138
|
+
{errors.map((error) => (
|
|
139
|
+
<li key={error.id}>
|
|
140
|
+
<a
|
|
141
|
+
href={`#${error.id}`}
|
|
142
|
+
className="text-sm underline underline-offset-2"
|
|
143
|
+
onClick={(event) => {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
document.getElementById(error.id)?.focus();
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{error.label}: {error.message}
|
|
149
|
+
</a>
|
|
150
|
+
</li>
|
|
151
|
+
))}
|
|
152
|
+
</ul>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
9
|
+
export type HeadingTag =
|
|
10
|
+
| 'h1'
|
|
11
|
+
| 'h2'
|
|
12
|
+
| 'h3'
|
|
13
|
+
| 'h4'
|
|
14
|
+
| 'h5'
|
|
15
|
+
| 'h6'
|
|
16
|
+
| 'span'
|
|
17
|
+
| 'div';
|
|
18
|
+
|
|
19
|
+
const LEVEL_DEFAULT_TAG: Record<HeadingLevel, HeadingTag> = {
|
|
20
|
+
1: 'h1',
|
|
21
|
+
2: 'h2',
|
|
22
|
+
3: 'h3',
|
|
23
|
+
4: 'h4',
|
|
24
|
+
5: 'h5',
|
|
25
|
+
6: 'h6',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const headingVariants = cva('font-sans text-foreground', {
|
|
29
|
+
variants: {
|
|
30
|
+
size: {
|
|
31
|
+
'5xl': 'text-4xl tracking-tight half:text-5xl',
|
|
32
|
+
'3xl': 'text-3xl tracking-tight',
|
|
33
|
+
'2xl': 'text-2xl tracking-tight',
|
|
34
|
+
lg: 'text-lg tracking-normal',
|
|
35
|
+
md: 'text-base',
|
|
36
|
+
sm: 'text-sm',
|
|
37
|
+
xs: 'text-xs tracking-wider',
|
|
38
|
+
},
|
|
39
|
+
weight: {
|
|
40
|
+
normal: 'font-normal',
|
|
41
|
+
medium: 'font-medium',
|
|
42
|
+
semibold: 'font-semibold',
|
|
43
|
+
bold: 'font-bold',
|
|
44
|
+
},
|
|
45
|
+
variant: {
|
|
46
|
+
default: 'text-foreground',
|
|
47
|
+
inherit: 'text-inherit',
|
|
48
|
+
muted: 'text-muted-foreground',
|
|
49
|
+
destructive: 'text-destructive-text',
|
|
50
|
+
primary: 'text-primary',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
size: '2xl',
|
|
55
|
+
weight: 'semibold',
|
|
56
|
+
variant: 'default',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const LEVEL_DEFAULT_SIZE: Record<
|
|
61
|
+
HeadingLevel,
|
|
62
|
+
NonNullable<VariantProps<typeof headingVariants>['size']>
|
|
63
|
+
> = {
|
|
64
|
+
1: '3xl',
|
|
65
|
+
2: '2xl',
|
|
66
|
+
3: 'lg',
|
|
67
|
+
4: 'md',
|
|
68
|
+
5: 'sm',
|
|
69
|
+
6: 'xs',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const LEVEL_DEFAULT_WEIGHT: Record<
|
|
73
|
+
HeadingLevel,
|
|
74
|
+
NonNullable<VariantProps<typeof headingVariants>['weight']>
|
|
75
|
+
> = {
|
|
76
|
+
1: 'normal',
|
|
77
|
+
2: 'semibold',
|
|
78
|
+
3: 'semibold',
|
|
79
|
+
4: 'semibold',
|
|
80
|
+
5: 'semibold',
|
|
81
|
+
6: 'semibold',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export interface HeadingProps
|
|
85
|
+
extends
|
|
86
|
+
React.HTMLAttributes<HTMLHeadingElement>,
|
|
87
|
+
VariantProps<typeof headingVariants> {
|
|
88
|
+
asChild?: boolean;
|
|
89
|
+
as?: HeadingTag;
|
|
90
|
+
level?: HeadingLevel;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
|
|
94
|
+
(
|
|
95
|
+
{ className, size, weight, variant, asChild = false, as, level, ...props },
|
|
96
|
+
ref,
|
|
97
|
+
) => {
|
|
98
|
+
const resolvedLevel =
|
|
99
|
+
level ??
|
|
100
|
+
(as && /^h[1-6]$/.test(as) ? (Number(as.slice(1)) as HeadingLevel) : 2);
|
|
101
|
+
|
|
102
|
+
const resolvedTag = as ?? LEVEL_DEFAULT_TAG[resolvedLevel];
|
|
103
|
+
const resolvedSize = size ?? LEVEL_DEFAULT_SIZE[resolvedLevel];
|
|
104
|
+
const resolvedWeight = weight ?? LEVEL_DEFAULT_WEIGHT[resolvedLevel];
|
|
105
|
+
|
|
106
|
+
const Comp = (asChild ? Slot : resolvedTag) as React.ElementType;
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Comp
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
headingVariants({
|
|
113
|
+
size: resolvedSize,
|
|
114
|
+
weight: resolvedWeight,
|
|
115
|
+
variant,
|
|
116
|
+
}),
|
|
117
|
+
className,
|
|
118
|
+
)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
Heading.displayName = 'Heading';
|
|
125
|
+
|
|
126
|
+
export { Heading, headingVariants };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
8
|
+
|
|
9
|
+
const HoverCardContent = React.forwardRef<
|
|
10
|
+
React.ComponentRef<typeof HoverCardPrimitive.Content>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content> & {
|
|
12
|
+
container?: React.ComponentPropsWithoutRef<
|
|
13
|
+
typeof HoverCardPrimitive.Portal
|
|
14
|
+
>['container'];
|
|
15
|
+
}
|
|
16
|
+
>(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
className,
|
|
20
|
+
align = 'center',
|
|
21
|
+
sideOffset = 4,
|
|
22
|
+
collisionPadding = 8,
|
|
23
|
+
container,
|
|
24
|
+
...props
|
|
25
|
+
},
|
|
26
|
+
ref,
|
|
27
|
+
) => (
|
|
28
|
+
<HoverCardPrimitive.Portal container={container}>
|
|
29
|
+
<HoverCardPrimitive.Content
|
|
30
|
+
ref={ref}
|
|
31
|
+
align={align}
|
|
32
|
+
sideOffset={sideOffset}
|
|
33
|
+
collisionPadding={collisionPadding}
|
|
34
|
+
className={cn(
|
|
35
|
+
'pointer-events-auto z-50 w-64 max-w-[calc(100vw-var(--spacing-section))] max-h-[var(--radix-hover-card-content-available-height)] overflow-y-auto rounded-md border bg-popover p-inset text-popover-foreground shadow-md outline-none duration-fast ease-enter data-[state=closed]:ease-exit 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',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
</HoverCardPrimitive.Portal>
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
44
|
+
|
|
45
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const inputVariants = cva(
|
|
8
|
+
'flex h-10 w-full rounded-md px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 half:text-sm transition-colors duration-fast ease-move aria-invalid:border-destructive-text aria-invalid:focus-visible:ring-destructive-text',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
'border border-input bg-background focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1',
|
|
14
|
+
filled:
|
|
15
|
+
'border border-transparent bg-input-fill text-foreground hover:bg-input-fill-hover focus-visible:border-input focus-visible:bg-background focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:hover:bg-input-fill aria-invalid:border-destructive-text aria-invalid:focus-visible:border-destructive-text',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
variant: 'default',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export interface InputProps
|
|
25
|
+
extends React.ComponentProps<'input'>, VariantProps<typeof inputVariants> {
|
|
26
|
+
error?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
30
|
+
(
|
|
31
|
+
{ className, variant, type, error, 'aria-invalid': ariaInvalid, ...props },
|
|
32
|
+
ref,
|
|
33
|
+
) => {
|
|
34
|
+
const isInvalid =
|
|
35
|
+
error === true || ariaInvalid === true || ariaInvalid === 'true';
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<input
|
|
39
|
+
type={type}
|
|
40
|
+
aria-invalid={isInvalid ? true : ariaInvalid}
|
|
41
|
+
className={cn(inputVariants({ variant, className }))}
|
|
42
|
+
ref={ref}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
Input.displayName = 'Input';
|
|
49
|
+
|
|
50
|
+
export { Input, inputVariants };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { Text } from './text';
|
|
7
|
+
|
|
8
|
+
const labelVariants = cva(
|
|
9
|
+
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const Label = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
15
|
+
VariantProps<typeof labelVariants>
|
|
16
|
+
>(({ className, ...props }, ref) => (
|
|
17
|
+
<Text
|
|
18
|
+
asChild
|
|
19
|
+
as="label"
|
|
20
|
+
size="sm"
|
|
21
|
+
weight="medium"
|
|
22
|
+
leading="none"
|
|
23
|
+
className={cn(labelVariants(), className)}
|
|
24
|
+
>
|
|
25
|
+
<LabelPrimitive.Root ref={ref} {...props} />
|
|
26
|
+
</Text>
|
|
27
|
+
));
|
|
28
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
29
|
+
|
|
30
|
+
export { Label };
|