@leitware/composables 2.0.0 → 3.1.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 +16 -0
- package/dist/presets/brutalist.css +16 -17
- package/dist/presets/default.css +11 -13
- package/dist/presets/editorial-grid.css +12 -13
- package/dist/presets/kumo.css +14 -20
- package/dist/presets/signal-pop.css +14 -26
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +20 -0
- package/package.json +13 -12
- package/rules/composables.md +24 -21
- package/skills/use-composables/references/public-api.md +2 -2
- package/skills/use-composables/references/semantic-utilities.md +5 -0
- package/src/_internal/accordion.tsx +10 -10
- package/src/_internal/ai-elements/reasoning.tsx +2 -0
- package/src/_internal/alert-dialog.tsx +3 -3
- package/src/_internal/alert.tsx +9 -7
- package/src/_internal/avatar.tsx +25 -14
- package/src/_internal/badge.tsx +2 -1
- package/src/_internal/bubble.tsx +2 -2
- package/src/_internal/button.tsx +16 -8
- package/src/_internal/calendar.tsx +3 -3
- package/src/_internal/card.tsx +53 -17
- package/src/_internal/checkbox.tsx +2 -2
- package/src/_internal/combobox.tsx +2 -2
- package/src/_internal/dialog.tsx +29 -9
- package/src/_internal/divider.tsx +14 -16
- package/src/_internal/dropdown-menu.tsx +4 -4
- package/src/_internal/empty.tsx +6 -3
- package/src/_internal/field.tsx +11 -7
- package/src/_internal/hover-card.tsx +1 -1
- package/src/_internal/input-group.tsx +17 -12
- package/src/_internal/input.tsx +33 -4
- package/src/_internal/item.tsx +2 -2
- package/src/_internal/label.tsx +1 -1
- package/src/_internal/message.tsx +1 -1
- package/src/_internal/native-select.tsx +1 -1
- package/src/_internal/popover.tsx +9 -3
- package/src/_internal/progress.tsx +37 -7
- package/src/_internal/radio-group.tsx +39 -4
- package/src/_internal/select.tsx +2 -2
- package/src/_internal/separator.tsx +1 -1
- package/src/_internal/sheet.tsx +9 -3
- package/src/_internal/sidebar.tsx +0 -35
- package/src/_internal/skeleton.tsx +26 -3
- package/src/_internal/slider.tsx +9 -7
- package/src/_internal/sonner.tsx +4 -4
- package/src/_internal/spinner.tsx +43 -3
- package/src/_internal/switch.tsx +2 -2
- package/src/_internal/table.tsx +20 -5
- package/src/_internal/tabs.tsx +4 -1
- package/src/_internal/textarea.tsx +1 -1
- package/src/_internal/toggle.tsx +1 -1
- package/src/_internal/tooltip.tsx +53 -8
- package/src/_internal/typography.tsx +4 -2
- package/src/index.ts +25 -1
- package/src/lib/utils.ts +2 -2
- package/src/opinionated/alert.tsx +8 -10
- package/src/opinionated/avatar.tsx +2 -2
- package/src/opinionated/button.tsx +13 -3
- package/src/opinionated/command.tsx +23 -0
- package/src/opinionated/data-grid.tsx +125 -0
- package/src/opinionated/dialog.tsx +10 -1
- package/src/opinionated/form-calendar-popover.tsx +5 -10
- package/src/opinionated/form-checkbox.tsx +2 -2
- package/src/opinionated/form-date-of-birth.tsx +12 -8
- package/src/opinionated/form-input-group.tsx +1 -1
- package/src/opinionated/form-radiogroup.tsx +24 -7
- package/src/opinionated/form-switch.tsx +7 -6
- package/src/opinionated/progress.tsx +7 -2
- package/src/opinionated/select.tsx +4 -1
- package/src/opinionated/sidebar.tsx +0 -1
- package/src/opinionated/skeleton.tsx +3 -13
- package/src/opinionated/spinner.tsx +2 -0
- package/src/opinionated/token-config-panel/spacing-editor.tsx +21 -3
- package/src/opinionated/tooltip.tsx +20 -2
- package/src/styles/presets/brutalist.css +16 -17
- package/src/styles/presets/default.css +11 -13
- package/src/styles/presets/editorial-grid.css +12 -13
- package/src/styles/presets/kumo.css +14 -20
- package/src/styles/presets/signal-pop.css +14 -26
- package/src/styles/presets-data/brutalist.ts +16 -19
- package/src/styles/presets-data/default.ts +11 -15
- package/src/styles/presets-data/editorial-grid.ts +12 -6
- package/src/styles/presets-data/kumo.ts +12 -6
- package/src/styles/presets-data/signal-pop.ts +14 -30
- package/src/styles/tokens/components.css +64 -20
- package/src/styles/tokens/registry.ts +33 -0
- package/src/styles/tokens/semantic-utilities.css +20 -0
- package/src/styles/tokens/semantic.css +10 -0
- package/src/styles/tokens/tailwind-color-adapter.css +3 -0
- package/src/styles/tokens/tailwind-public-utilities.css +20 -0
package/src/_internal/switch.tsx
CHANGED
|
@@ -16,14 +16,14 @@ function Switch({
|
|
|
16
16
|
className={cn(
|
|
17
17
|
FOCUS_RING,
|
|
18
18
|
HOVER_RING,
|
|
19
|
-
'data-checked:bg-
|
|
19
|
+
'data-checked:bg-(--switch-on-color) data-unchecked:bg-surface-field dark:data-unchecked:bg-surface-field/80 shrink-0 rounded-[var(--radius)] p-0.5 data-[size=default]:h-(--switch-height) data-[size=default]:w-[calc(var(--switch-height)*2_-_var(--spacing))] data-[size=sm]:h-3.5 data-[size=sm]:w-6 peer group/switch relative inline-flex items-center transition-[opacity,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-disabled',
|
|
20
20
|
className,
|
|
21
21
|
)}
|
|
22
22
|
{...props}
|
|
23
23
|
>
|
|
24
24
|
<SwitchPrimitive.Thumb
|
|
25
25
|
data-slot="switch-thumb"
|
|
26
|
-
className="bg-page dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-[var(--radius)] group-data-[size=default]/switch:size-
|
|
26
|
+
className="bg-page dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-[var(--radius)] group-data-[size=default]/switch:size-[calc(var(--switch-height)_-_var(--spacing))] group-data-[size=sm]/switch:size-2.5 group-data-[size=default]/switch:data-checked:translate-x-[calc(var(--switch-height)_-_var(--spacing))] group-data-[size=sm]/switch:data-checked:translate-x-2.5 data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"
|
|
27
27
|
/>
|
|
28
28
|
</SwitchPrimitive.Root>
|
|
29
29
|
)
|
package/src/_internal/table.tsx
CHANGED
|
@@ -7,7 +7,10 @@ function Table({ className, ...props }: React.ComponentProps<'table'>) {
|
|
|
7
7
|
<div data-slot="table-container" className="relative w-full overflow-x-auto">
|
|
8
8
|
<table
|
|
9
9
|
data-slot="table"
|
|
10
|
-
className={cn(
|
|
10
|
+
className={cn(
|
|
11
|
+
'w-full caption-bottom text-(length:--body-font-size) leading-(--body-line-height)',
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
11
14
|
{...props}
|
|
12
15
|
/>
|
|
13
16
|
</div>
|
|
@@ -15,7 +18,13 @@ function Table({ className, ...props }: React.ComponentProps<'table'>) {
|
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
|
|
18
|
-
return
|
|
21
|
+
return (
|
|
22
|
+
<thead
|
|
23
|
+
data-slot="table-header"
|
|
24
|
+
className={cn('[&_tr]:border-b-(length:--rule-width)', className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
|
|
@@ -32,7 +41,10 @@ function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
|
|
|
32
41
|
return (
|
|
33
42
|
<tfoot
|
|
34
43
|
data-slot="table-footer"
|
|
35
|
-
className={cn(
|
|
44
|
+
className={cn(
|
|
45
|
+
'bg-muted/50 border-t-(length:--rule-width) font-medium [&>tr]:last:border-b-0',
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
36
48
|
{...props}
|
|
37
49
|
/>
|
|
38
50
|
)
|
|
@@ -42,7 +54,10 @@ function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
|
|
|
42
54
|
return (
|
|
43
55
|
<tr
|
|
44
56
|
data-slot="table-row"
|
|
45
|
-
className={cn(
|
|
57
|
+
className={cn(
|
|
58
|
+
'hover:bg-muted/50 data-[state=selected]:bg-muted border-b-(length:--rule-width)',
|
|
59
|
+
className,
|
|
60
|
+
)}
|
|
46
61
|
{...props}
|
|
47
62
|
/>
|
|
48
63
|
)
|
|
@@ -53,7 +68,7 @@ function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
|
|
|
53
68
|
<th
|
|
54
69
|
data-slot="table-head"
|
|
55
70
|
className={cn(
|
|
56
|
-
'text-
|
|
71
|
+
'text-(color:--label-color) text-(length:--label-font-size) leading-(--text-xs--line-height) [text-transform:var(--label-text-transform)] h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0',
|
|
57
72
|
className,
|
|
58
73
|
)}
|
|
59
74
|
{...props}
|
package/src/_internal/tabs.tsx
CHANGED
|
@@ -85,7 +85,10 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
|
85
85
|
return (
|
|
86
86
|
<TabsPrimitive.Panel
|
|
87
87
|
data-slot="tabs-content"
|
|
88
|
-
className={cn(
|
|
88
|
+
className={cn(
|
|
89
|
+
'text-(length:--body-font-size) leading-relaxed flex-1 outline-none',
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
89
92
|
{...props}
|
|
90
93
|
/>
|
|
91
94
|
)
|
|
@@ -9,7 +9,7 @@ function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
|
9
9
|
className={cn(
|
|
10
10
|
FOCUS_RING,
|
|
11
11
|
HOVER_RING,
|
|
12
|
-
'border-field bg-surface-
|
|
12
|
+
'border-field bg-surface-input resize-none rounded-(--input-radius) border px-2 py-2 text-(length:--control-font-size) max-md:text-[length:max(var(--control-font-size),var(--text-sm))] leading-relaxed placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full min-w-(--control-min-width) outline-none disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
13
13
|
className,
|
|
14
14
|
)}
|
|
15
15
|
{...props}
|
package/src/_internal/toggle.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from 'class-variance-authority'
|
|
|
4
4
|
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
5
5
|
|
|
6
6
|
const toggleVariants = cva(
|
|
7
|
-
`${FOCUS_RING} ${HOVER_RING} hover:text-foreground aria-pressed:bg-muted data-[state=on]:bg-muted gap-1 rounded-md text-xs font-medium transition-[opacity,box-shadow] [&_svg:not([class*='size-'])]:size-3.5 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none disabled:pointer-events-none disabled:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
7
|
+
`${FOCUS_RING} ${HOVER_RING} hover:text-foreground aria-pressed:bg-muted data-[state=on]:bg-muted gap-1 rounded-md text-(length:--control-font-size) leading-(--text-xs--line-height) font-medium transition-[opacity,box-shadow] [&_svg:not([class*='size-'])]:size-3.5 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none disabled:pointer-events-none disabled:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
8
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip'
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
3
|
|
|
3
4
|
import { cn } from '../lib/utils'
|
|
4
5
|
|
|
@@ -14,20 +15,59 @@ function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
|
|
|
14
15
|
)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const tooltipTriggerVariants = cva('', {
|
|
19
|
+
variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
default: '',
|
|
22
|
+
// Marks inline text that reveals more on hover.
|
|
23
|
+
underline:
|
|
24
|
+
'cursor-help underline decoration-dashed decoration-(color:--bg-fill-primary) underline-offset-4',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: { variant: 'default' },
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
function TooltipTrigger({
|
|
31
|
+
className,
|
|
32
|
+
variant = 'default',
|
|
33
|
+
...props
|
|
34
|
+
}: TooltipPrimitive.Trigger.Props & VariantProps<typeof tooltipTriggerVariants>) {
|
|
35
|
+
return (
|
|
36
|
+
<TooltipPrimitive.Trigger
|
|
37
|
+
data-slot="tooltip-trigger"
|
|
38
|
+
className={cn(tooltipTriggerVariants({ variant }), className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
const tooltipContentVariants = cva(
|
|
45
|
+
'data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-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 rounded-md px-3 py-1.5 text-(length:--body-font-size) leading-(--body-line-height) **:data-[slot=kbd]:rounded-md z-tooltip w-fit max-w-xs origin-(--transform-origin)',
|
|
46
|
+
{
|
|
47
|
+
variants: {
|
|
48
|
+
variant: {
|
|
49
|
+
// The preset's tooltip colours (--tooltip-bg / --tooltip-fg).
|
|
50
|
+
default: 'bg-(--tooltip-bg) text-(color:--tooltip-fg)',
|
|
51
|
+
inverse: 'bg-(--bg-inverse) text-(color:--text-inverse)',
|
|
52
|
+
brand: 'bg-surface-brand text-foreground',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: { variant: 'default' },
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
21
59
|
function TooltipContent({
|
|
22
60
|
className,
|
|
23
61
|
side = 'top',
|
|
24
62
|
sideOffset = 4,
|
|
25
63
|
align = 'center',
|
|
26
64
|
alignOffset = 0,
|
|
65
|
+
variant = 'default',
|
|
27
66
|
children,
|
|
28
67
|
...props
|
|
29
68
|
}: TooltipPrimitive.Popup.Props &
|
|
30
|
-
Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>
|
|
69
|
+
Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> &
|
|
70
|
+
VariantProps<typeof tooltipContentVariants>) {
|
|
31
71
|
return (
|
|
32
72
|
<TooltipPrimitive.Portal>
|
|
33
73
|
<TooltipPrimitive.Positioner
|
|
@@ -39,10 +79,8 @@ function TooltipContent({
|
|
|
39
79
|
>
|
|
40
80
|
<TooltipPrimitive.Popup
|
|
41
81
|
data-slot="tooltip-content"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
className,
|
|
45
|
-
)}
|
|
82
|
+
data-variant={variant}
|
|
83
|
+
className={cn(tooltipContentVariants({ variant }), className)}
|
|
46
84
|
{...props}
|
|
47
85
|
>
|
|
48
86
|
{children}
|
|
@@ -52,4 +90,11 @@ function TooltipContent({
|
|
|
52
90
|
)
|
|
53
91
|
}
|
|
54
92
|
|
|
55
|
-
export {
|
|
93
|
+
export {
|
|
94
|
+
Tooltip,
|
|
95
|
+
TooltipContent,
|
|
96
|
+
TooltipProvider,
|
|
97
|
+
TooltipTrigger,
|
|
98
|
+
tooltipContentVariants,
|
|
99
|
+
tooltipTriggerVariants,
|
|
100
|
+
}
|
|
@@ -50,8 +50,10 @@ const typographyVariants = cva('', {
|
|
|
50
50
|
'caption-100': 'font-sans font-normal text-xs tracking-normal text-muted-foreground',
|
|
51
51
|
|
|
52
52
|
// Link variants - sans font, 500, underline
|
|
53
|
-
'link-100':
|
|
54
|
-
|
|
53
|
+
'link-100':
|
|
54
|
+
'font-sans font-medium text-sm tracking-normal underline hover:text-(--text-secondary)',
|
|
55
|
+
'link-200':
|
|
56
|
+
'font-sans font-medium text-base tracking-normal underline hover:text-(--text-secondary)',
|
|
55
57
|
},
|
|
56
58
|
},
|
|
57
59
|
defaultVariants: {
|
package/src/index.ts
CHANGED
|
@@ -135,6 +135,18 @@ export {
|
|
|
135
135
|
type ComboboxProps,
|
|
136
136
|
} from './opinionated/combobox'
|
|
137
137
|
|
|
138
|
+
export {
|
|
139
|
+
Command,
|
|
140
|
+
CommandDialog,
|
|
141
|
+
CommandEmpty,
|
|
142
|
+
CommandGroup,
|
|
143
|
+
CommandInput,
|
|
144
|
+
CommandItem,
|
|
145
|
+
CommandList,
|
|
146
|
+
CommandSeparator,
|
|
147
|
+
CommandShortcut,
|
|
148
|
+
} from './opinionated/command'
|
|
149
|
+
|
|
138
150
|
export { Container, type ContainerProps } from './opinionated/container'
|
|
139
151
|
|
|
140
152
|
export {
|
|
@@ -149,6 +161,17 @@ export {
|
|
|
149
161
|
type DialogProps,
|
|
150
162
|
} from './opinionated/dialog'
|
|
151
163
|
|
|
164
|
+
export {
|
|
165
|
+
DataGrid,
|
|
166
|
+
DataLabel,
|
|
167
|
+
DataRow,
|
|
168
|
+
DataValue,
|
|
169
|
+
type DataGridProps,
|
|
170
|
+
type DataLabelProps,
|
|
171
|
+
type DataRowProps,
|
|
172
|
+
type DataValueProps,
|
|
173
|
+
} from './opinionated/data-grid'
|
|
174
|
+
|
|
152
175
|
export { Divider, type DividerProps } from './opinionated/divider'
|
|
153
176
|
|
|
154
177
|
export {
|
|
@@ -369,6 +392,7 @@ export {
|
|
|
369
392
|
SelectGroup,
|
|
370
393
|
SelectItem,
|
|
371
394
|
SelectLabel,
|
|
395
|
+
SelectRoot,
|
|
372
396
|
SelectTrigger,
|
|
373
397
|
SelectValue,
|
|
374
398
|
type SelectOption,
|
|
@@ -405,7 +429,6 @@ export {
|
|
|
405
429
|
SidebarMenuBadge,
|
|
406
430
|
SidebarMenuButton,
|
|
407
431
|
SidebarMenuItem,
|
|
408
|
-
SidebarMenuSkeleton,
|
|
409
432
|
SidebarMenuSub,
|
|
410
433
|
SidebarMenuSubButton,
|
|
411
434
|
SidebarMenuSubItem,
|
|
@@ -430,6 +453,7 @@ export {
|
|
|
430
453
|
export { Slider } from './opinionated/slider'
|
|
431
454
|
export { Toaster } from './opinionated/sonner'
|
|
432
455
|
export { Spacer, type SpacerProps } from './opinionated/spacer'
|
|
456
|
+
export { Spinner, spinnerVariants } from './opinionated/spinner'
|
|
433
457
|
export { Stack, type StackProps } from './opinionated/stack'
|
|
434
458
|
export { Switch } from './opinionated/switch'
|
|
435
459
|
|
package/src/lib/utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
10
10
|
* Change this once to update focus behaviour across every component.
|
|
11
11
|
*/
|
|
12
12
|
export const FOCUS_RING =
|
|
13
|
-
'focus-visible:border-[var(--focus-ring-color)] focus-visible:ring-[color:var(--focus-ring-color)]
|
|
13
|
+
'focus-visible:border-[var(--focus-ring-color)] focus-visible:ring-[color:color-mix(in_oklab,var(--focus-ring-color)_var(--focus-ring-opacity),transparent)] focus-visible:ring-[length:var(--focus-ring-width)] focus-visible:ring-offset-[length:var(--focus-ring-offset)] focus-visible:ring-offset-(--background) aria-invalid:ring-fill-critical/20 dark:aria-invalid:ring-fill-critical/40 aria-invalid:border-fill-critical dark:aria-invalid:border-fill-critical/50 aria-invalid:ring-[length:var(--focus-ring-width)]'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Centralised hover ring style for all interactive elements.
|
|
@@ -25,7 +25,7 @@ export const HOVER_RING =
|
|
|
25
25
|
* inside a wrapper, such as InputGroup and chip inputs.
|
|
26
26
|
*/
|
|
27
27
|
export const GROUP_FOCUS_RING =
|
|
28
|
-
'has-[:focus-visible]:border-[var(--focus-ring-color)] has-[:focus-visible]:ring-[color:var(--focus-ring-color)]
|
|
28
|
+
'has-[:focus-visible]:border-[var(--focus-ring-color)] has-[:focus-visible]:ring-[color:color-mix(in_oklab,var(--focus-ring-color)_var(--focus-ring-opacity),transparent)] has-[:focus-visible]:ring-[length:var(--focus-ring-width)] has-[:focus-visible]:ring-offset-[length:var(--focus-ring-offset)] has-[:focus-visible]:ring-offset-(--background) has-aria-invalid:ring-fill-critical/20 dark:has-aria-invalid:ring-fill-critical/40 has-aria-invalid:border-fill-critical dark:has-aria-invalid:border-fill-critical/50 has-aria-invalid:ring-[length:var(--focus-ring-width)]'
|
|
29
29
|
|
|
30
30
|
/** Destructive-variant focus override layered on top of FOCUS_RING. */
|
|
31
31
|
export const FOCUS_RING_DESTRUCTIVE =
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon } from 'lucide-react'
|
|
2
2
|
import type { VariantProps } from 'class-variance-authority'
|
|
3
3
|
import type * as React from 'react'
|
|
4
4
|
|
|
@@ -39,7 +39,7 @@ export interface AlertProps extends Omit<React.ComponentProps<typeof AlertPrimit
|
|
|
39
39
|
* - `notice` - info icon (ℹ), neutral styling
|
|
40
40
|
* - `positive` - check icon, green styling
|
|
41
41
|
* - `warning` - triangle icon, amber styling
|
|
42
|
-
* - `negative` - alert
|
|
42
|
+
* - `negative` - alert circle icon, red/destructive styling
|
|
43
43
|
* @default 'default'
|
|
44
44
|
*/
|
|
45
45
|
type?: AlertType
|
|
@@ -80,13 +80,13 @@ function Alert({
|
|
|
80
80
|
const getIcon = () => {
|
|
81
81
|
switch (type) {
|
|
82
82
|
case 'negative':
|
|
83
|
-
return <
|
|
83
|
+
return <CircleAlertIcon />
|
|
84
84
|
case 'positive':
|
|
85
|
-
return <CircleCheckIcon
|
|
85
|
+
return <CircleCheckIcon />
|
|
86
86
|
case 'notice':
|
|
87
|
-
return <InfoIcon
|
|
87
|
+
return <InfoIcon />
|
|
88
88
|
case 'warning':
|
|
89
|
-
return <TriangleAlertIcon
|
|
89
|
+
return <TriangleAlertIcon />
|
|
90
90
|
default:
|
|
91
91
|
return null
|
|
92
92
|
}
|
|
@@ -98,10 +98,8 @@ function Alert({
|
|
|
98
98
|
return (
|
|
99
99
|
<AlertPrimitive variant={resolvedVariant} className={className} {...alertProps}>
|
|
100
100
|
{icon}
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
{content && <AlertDescription>{content}</AlertDescription>}
|
|
104
|
-
</div>
|
|
101
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
102
|
+
{content && <AlertDescription>{content}</AlertDescription>}
|
|
105
103
|
{action && <AlertAction>{action}</AlertAction>}
|
|
106
104
|
</AlertPrimitive>
|
|
107
105
|
)
|
|
@@ -43,11 +43,11 @@ export interface AvatarProps extends VariantProps<typeof avatarVariants> {
|
|
|
43
43
|
* <Avatar src="/user.png" fallback="?" />
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
function Avatar({ src, alt, name, fallback, size, className }: AvatarProps) {
|
|
46
|
+
function Avatar({ src, alt, name, fallback, size, variant, className }: AvatarProps) {
|
|
47
47
|
const displayFallback = fallback ?? (name ? getInitials(name) : '?')
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<AvatarPrimitive size={size} className={className}>
|
|
50
|
+
<AvatarPrimitive size={size} variant={variant} className={className}>
|
|
51
51
|
{src && <AvatarImage src={src} alt={alt ?? name ?? 'Avatar'} />}
|
|
52
52
|
<AvatarFallback>{displayFallback}</AvatarFallback>
|
|
53
53
|
</AvatarPrimitive>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { VariantProps } from 'class-variance-authority'
|
|
2
|
-
import { Loader2Icon } from 'lucide-react'
|
|
3
2
|
import type * as React from 'react'
|
|
4
3
|
|
|
5
4
|
import { Button as ButtonPrimitive, type buttonVariants } from '../_internal/button'
|
|
5
|
+
import { Spinner } from '../_internal/spinner'
|
|
6
|
+
import { cn } from '../lib/utils'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Props for the opinionated Button component.
|
|
@@ -52,12 +53,21 @@ function Button({
|
|
|
52
53
|
variant={variant}
|
|
53
54
|
size={size}
|
|
54
55
|
shape={shape}
|
|
55
|
-
className={className}
|
|
56
|
+
className={cn(loading && 'relative', className)}
|
|
56
57
|
disabled={isDisabled}
|
|
58
|
+
aria-busy={loading || undefined}
|
|
57
59
|
type={type}
|
|
58
60
|
{...buttonProps}
|
|
59
61
|
>
|
|
60
|
-
{loading ?
|
|
62
|
+
{loading ? (
|
|
63
|
+
<>
|
|
64
|
+
{/* Keep the label in flow so the button holds its width. */}
|
|
65
|
+
<span className="invisible inline-flex items-center gap-1">{children}</span>
|
|
66
|
+
<Spinner className="absolute inset-0 m-auto" />
|
|
67
|
+
</>
|
|
68
|
+
) : (
|
|
69
|
+
children
|
|
70
|
+
)}
|
|
61
71
|
</ButtonPrimitive>
|
|
62
72
|
)
|
|
63
73
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
CommandDialog,
|
|
4
|
+
CommandEmpty,
|
|
5
|
+
CommandGroup,
|
|
6
|
+
CommandInput,
|
|
7
|
+
CommandItem,
|
|
8
|
+
CommandList,
|
|
9
|
+
CommandSeparator,
|
|
10
|
+
CommandShortcut,
|
|
11
|
+
} from '../_internal/command'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
Command,
|
|
15
|
+
CommandDialog,
|
|
16
|
+
CommandEmpty,
|
|
17
|
+
CommandGroup,
|
|
18
|
+
CommandInput,
|
|
19
|
+
CommandItem,
|
|
20
|
+
CommandList,
|
|
21
|
+
CommandSeparator,
|
|
22
|
+
CommandShortcut,
|
|
23
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
import { Typography } from './typography'
|
|
3
|
+
import { cn } from '../lib/utils'
|
|
4
|
+
|
|
5
|
+
export interface DataGridProps extends React.ComponentProps<'dl'> {
|
|
6
|
+
/**
|
|
7
|
+
* Children data rows
|
|
8
|
+
*/
|
|
9
|
+
children: React.ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Container for data rows. Displays rows in a vertical stack.
|
|
14
|
+
* Uses semantic HTML (`<dl>`) for better accessibility.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <DataGrid>
|
|
19
|
+
* <DataRow>
|
|
20
|
+
* <DataLabel>Name</DataLabel>
|
|
21
|
+
* <DataValue>John Doe</DataValue>
|
|
22
|
+
* </DataRow>
|
|
23
|
+
* </DataGrid>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function DataGrid({ children, className, ...props }: DataGridProps) {
|
|
27
|
+
return (
|
|
28
|
+
<dl className={cn('flex flex-col gap-1.5', className)} {...props}>
|
|
29
|
+
{children}
|
|
30
|
+
</dl>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DataRowProps extends React.ComponentProps<'div'> {
|
|
35
|
+
/**
|
|
36
|
+
* Children should be DataLabel and DataValue components
|
|
37
|
+
*/
|
|
38
|
+
children: React.ReactNode
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A single row containing a label and value pair.
|
|
43
|
+
* Displays in a responsive layout: stacked on mobile, 2-column grid on desktop.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <DataRow>
|
|
48
|
+
* <DataLabel>Email</DataLabel>
|
|
49
|
+
* <DataValue>user@example.com</DataValue>
|
|
50
|
+
* </DataRow>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function DataRow({ children, className, ...props }: DataRowProps) {
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
className={cn(
|
|
57
|
+
'flex flex-col gap-1 md:grid md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] md:gap-2 items-start min-w-0',
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DataLabelProps extends React.ComponentProps<'dt'> {
|
|
68
|
+
/**
|
|
69
|
+
* Label text
|
|
70
|
+
*/
|
|
71
|
+
children: React.ReactNode
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Label component for data rows. Displays muted text.
|
|
76
|
+
* Uses semantic HTML (`<dt>`) for better accessibility.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <DataLabel>Email address</DataLabel>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function DataLabel({ children, className, ...props }: DataLabelProps) {
|
|
84
|
+
return (
|
|
85
|
+
<dt className={cn('break-words min-w-0', className)} {...props}>
|
|
86
|
+
<Typography variant="body-100" className="font-normal text-muted-foreground">
|
|
87
|
+
{children}
|
|
88
|
+
</Typography>
|
|
89
|
+
</dt>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface DataValueProps extends React.ComponentProps<'dd'> {
|
|
94
|
+
/**
|
|
95
|
+
* Value content. Can contain multiple children for complex values.
|
|
96
|
+
* Renders empty string if children are null or undefined.
|
|
97
|
+
*/
|
|
98
|
+
children: React.ReactNode
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Value component for data rows. Displays small text and supports multiple children.
|
|
103
|
+
* Uses semantic HTML (`<dd>`) for better accessibility.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* // Simple value
|
|
108
|
+
* <DataValue>John Doe</DataValue>
|
|
109
|
+
*
|
|
110
|
+
* // Complex value with multiple children
|
|
111
|
+
* <DataValue>
|
|
112
|
+
* <span>£1,000</span>
|
|
113
|
+
* <span className="text-muted">(Calculated)</span>
|
|
114
|
+
* </DataValue>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function DataValue({ children, className, ...props }: DataValueProps) {
|
|
118
|
+
return (
|
|
119
|
+
<dd className={cn('break-words min-w-0', className)} {...props}>
|
|
120
|
+
<Typography variant="body-100" className="font-normal">
|
|
121
|
+
{children}
|
|
122
|
+
</Typography>
|
|
123
|
+
</dd>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dialog as DialogPrimitiveBase } from '@base-ui/react/dialog'
|
|
2
|
+
import type { VariantProps } from 'class-variance-authority'
|
|
2
3
|
import type * as React from 'react'
|
|
3
4
|
|
|
4
5
|
import {
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
Dialog as DialogPrimitive,
|
|
13
14
|
DialogTitle,
|
|
14
15
|
DialogTrigger,
|
|
16
|
+
type dialogContentVariants,
|
|
15
17
|
} from '../_internal/dialog'
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -52,6 +54,8 @@ export interface DialogProps extends Omit<DialogPrimitiveBase.Root.Props, 'child
|
|
|
52
54
|
footer?: React.ReactNode
|
|
53
55
|
/** Whether to show the built-in close (×) button. @default true */
|
|
54
56
|
showCloseButton?: boolean
|
|
57
|
+
/** `responsive` docks the dialog to the bottom of the screen on small viewports. @default 'center' */
|
|
58
|
+
placement?: VariantProps<typeof dialogContentVariants>['placement']
|
|
55
59
|
className?: string
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -62,6 +66,7 @@ function Dialog({
|
|
|
62
66
|
children,
|
|
63
67
|
footer,
|
|
64
68
|
showCloseButton = true,
|
|
69
|
+
placement,
|
|
65
70
|
className,
|
|
66
71
|
open,
|
|
67
72
|
onOpenChange,
|
|
@@ -77,7 +82,11 @@ function Dialog({
|
|
|
77
82
|
return (
|
|
78
83
|
<DialogPrimitive open={open} onOpenChange={onOpenChange} {...dialogProps}>
|
|
79
84
|
{trigger && <DialogTrigger>{trigger}</DialogTrigger>}
|
|
80
|
-
<DialogContent
|
|
85
|
+
<DialogContent
|
|
86
|
+
className={className}
|
|
87
|
+
placement={placement}
|
|
88
|
+
showCloseButton={showCloseButton}
|
|
89
|
+
>
|
|
81
90
|
{(title || description) && (
|
|
82
91
|
<DialogHeader>
|
|
83
92
|
{title && <DialogTitle>{title}</DialogTitle>}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { VariantProps } from 'class-variance-authority'
|
|
2
2
|
import { ChevronDownIcon } from 'lucide-react'
|
|
3
3
|
import * as React from 'react'
|
|
4
|
-
import { Button as ButtonPrimitive } from '../_internal/button'
|
|
5
4
|
import { Calendar } from '../_internal/calendar'
|
|
6
5
|
import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '../_internal/field'
|
|
6
|
+
import { FieldTrigger } from '../_internal/input'
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger } from '../_internal/popover'
|
|
8
|
-
import { cn } from '../lib/utils'
|
|
9
8
|
|
|
10
9
|
export interface FormCalendarPopoverProps {
|
|
11
10
|
label?: string
|
|
@@ -96,25 +95,21 @@ function FormCalendarPopover({
|
|
|
96
95
|
<Popover open={open} onOpenChange={setOpen}>
|
|
97
96
|
<PopoverTrigger
|
|
98
97
|
render={
|
|
99
|
-
<
|
|
98
|
+
<FieldTrigger
|
|
100
99
|
id={inputId}
|
|
101
100
|
name={name}
|
|
102
|
-
variant="outline"
|
|
103
101
|
disabled={disabled}
|
|
104
102
|
aria-invalid={hasError}
|
|
105
103
|
aria-required={required}
|
|
106
104
|
aria-label={ariaLabel}
|
|
107
105
|
aria-labelledby={ariaLabelledBy || (label ? inputId : undefined)}
|
|
108
106
|
onBlur={handleBlur}
|
|
109
|
-
|
|
110
|
-
'w-full justify-between font-normal',
|
|
111
|
-
!value && 'text-muted-foreground',
|
|
112
|
-
)}
|
|
107
|
+
data-placeholder={value ? undefined : ''}
|
|
113
108
|
{...props}
|
|
114
109
|
>
|
|
115
110
|
{value ? value.toLocaleDateString() : placeholder}
|
|
116
|
-
<ChevronDownIcon className="
|
|
117
|
-
</
|
|
111
|
+
<ChevronDownIcon className="text-muted-foreground size-[1.25em] shrink-0" />
|
|
112
|
+
</FieldTrigger>
|
|
118
113
|
}
|
|
119
114
|
/>
|
|
120
115
|
<PopoverContent className="w-auto p-0" align="start">
|
|
@@ -28,7 +28,7 @@ export interface FormCheckboxProps extends Omit<
|
|
|
28
28
|
description?: string
|
|
29
29
|
/** Error message(s). Accepts a string, array, or react-hook-form error array. */
|
|
30
30
|
error?: string | string[] | Array<{ message?: string } | undefined>
|
|
31
|
-
/** Controlled checked state.
|
|
31
|
+
/** Controlled checked state. Omit (or use `defaultChecked`) for uncontrolled. */
|
|
32
32
|
checked?: boolean
|
|
33
33
|
/** Called when the user toggles the checkbox. */
|
|
34
34
|
onCheckedChange?: (checked: boolean) => void
|
|
@@ -49,7 +49,7 @@ function FormCheckbox({
|
|
|
49
49
|
label,
|
|
50
50
|
description,
|
|
51
51
|
error,
|
|
52
|
-
checked
|
|
52
|
+
checked,
|
|
53
53
|
onCheckedChange,
|
|
54
54
|
disabled = false,
|
|
55
55
|
required = false,
|