@vendure-io/ui 2.2.0 → 3.0.0-next.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/package.json +19 -5
- package/src/components/atoms/accordion.tsx +21 -6
- package/src/components/atoms/alert-dialog.tsx +31 -6
- package/src/components/atoms/alert.tsx +59 -12
- package/src/components/atoms/avatar.tsx +1 -1
- package/src/components/atoms/badge.tsx +7 -2
- package/src/components/atoms/breadcrumb.tsx +137 -4
- package/src/components/atoms/button-group.tsx +30 -6
- package/src/components/atoms/button.tsx +128 -18
- package/src/components/atoms/calendar.tsx +6 -6
- package/src/components/atoms/card.tsx +130 -16
- package/src/components/atoms/carousel.tsx +16 -9
- package/src/components/atoms/chart.tsx +87 -1
- package/src/components/atoms/checkbox.tsx +85 -7
- package/src/components/atoms/collapsible.tsx +2 -1
- package/src/components/atoms/combobox.tsx +147 -21
- package/src/components/atoms/command.tsx +414 -12
- package/src/components/atoms/context-menu.tsx +28 -23
- package/src/components/atoms/dialog.tsx +151 -29
- package/src/components/atoms/direction.tsx +23 -2
- package/src/components/atoms/drawer.tsx +15 -10
- package/src/components/atoms/dropdown-menu.tsx +43 -28
- package/src/components/atoms/empty.tsx +4 -0
- package/src/components/atoms/field.tsx +41 -15
- package/src/components/atoms/hover-card.tsx +61 -8
- package/src/components/atoms/input-group.tsx +17 -9
- package/src/components/atoms/input-otp.tsx +6 -6
- package/src/components/atoms/input.tsx +7 -1
- package/src/components/atoms/item.tsx +3 -3
- package/src/components/atoms/kbd.tsx +32 -3
- package/src/components/atoms/label-swap.tsx +82 -0
- package/src/components/atoms/label.tsx +1 -1
- package/src/components/atoms/menubar.tsx +28 -26
- package/src/components/atoms/native-select.tsx +3 -2
- package/src/components/atoms/navigation-menu.tsx +13 -8
- package/src/components/atoms/pagination.tsx +2 -2
- package/src/components/atoms/popover.tsx +23 -5
- package/src/components/atoms/progress.tsx +46 -33
- package/src/components/atoms/radio-group.tsx +9 -4
- package/src/components/atoms/resizable.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +2 -2
- package/src/components/atoms/select.tsx +258 -19
- package/src/components/atoms/sheet.tsx +59 -23
- package/src/components/atoms/sidebar.tsx +333 -23
- package/src/components/atoms/skeleton.tsx +1 -1
- package/src/components/atoms/slider.tsx +1 -1
- package/src/components/atoms/sonner.tsx +128 -38
- package/src/components/atoms/spinner.tsx +1 -1
- package/src/components/atoms/switch.tsx +10 -5
- package/src/components/atoms/table.tsx +147 -7
- package/src/components/atoms/tabs.tsx +3 -3
- package/src/components/atoms/textarea.tsx +3 -1
- package/src/components/atoms/toggle-group.tsx +4 -2
- package/src/components/atoms/toggle.tsx +28 -6
- package/src/components/atoms/tooltip.tsx +85 -15
- package/src/components/molecules/anonymized-token.tsx +24 -8
- package/src/components/molecules/app-shell.tsx +53 -20
- package/src/components/molecules/arrow-link.tsx +40 -0
- package/src/components/molecules/chip.tsx +2 -2
- package/src/components/molecules/code-block.tsx +54 -31
- package/src/components/molecules/collapsible-section.tsx +129 -0
- package/src/components/molecules/confirm-dialog.tsx +113 -9
- package/src/components/molecules/copyable-text.tsx +75 -11
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
- package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
- package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
- package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
- package/src/components/molecules/data-table/data-table-types.tsx +121 -4
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
- package/src/components/molecules/data-table/data-table.tsx +837 -80
- package/src/components/molecules/data-table/table-pagination.tsx +2 -2
- package/src/components/molecules/date-picker.tsx +13 -7
- package/src/components/molecules/date-range-picker.tsx +13 -6
- package/src/components/molecules/date-time-picker.tsx +13 -7
- package/src/components/molecules/date-time.tsx +8 -1
- package/src/components/molecules/direction-link.tsx +130 -0
- package/src/components/molecules/elapsed-time.tsx +223 -0
- package/src/components/molecules/file-dropzone.tsx +2 -2
- package/src/components/molecules/id-chip.tsx +169 -32
- package/src/components/molecules/inline-code.tsx +4 -0
- package/src/components/molecules/issued-secret.tsx +318 -0
- package/src/components/molecules/list-row.tsx +349 -0
- package/src/components/molecules/live-indicator.tsx +83 -0
- package/src/components/molecules/page-header.tsx +117 -5
- package/src/components/molecules/password-input.tsx +2 -2
- package/src/components/molecules/relative-time.tsx +85 -56
- package/src/components/molecules/search-trigger.tsx +127 -0
- package/src/components/molecules/secret-value.tsx +26 -9
- package/src/components/molecules/skip-link.tsx +1 -1
- package/src/components/molecules/stat-card.tsx +4 -4
- package/src/components/molecules/state-views/empty-state.tsx +35 -17
- package/src/components/molecules/state-views/error-state.tsx +32 -14
- package/src/components/molecules/status-badge.tsx +415 -49
- package/src/components/molecules/time-tooltip.tsx +140 -0
- package/src/components/molecules/timeline.tsx +246 -0
- package/src/components/molecules/visibility-icon.tsx +89 -0
- package/src/hooks/use-active-label-size.ts +32 -0
- package/src/hooks/use-pinned-height.ts +55 -0
- package/src/hooks/use-scrolled.ts +27 -0
- package/src/lib/content-inset.ts +17 -0
- package/src/lib/control-name.ts +55 -0
- package/src/lib/dialog-padding.ts +48 -0
- package/src/lib/field-surface.ts +31 -0
- package/src/lib/format-elapsed.ts +67 -0
- package/src/lib/format-relative.ts +29 -1
- package/src/lib/highlight.ts +3 -3
- package/src/lib/menu-item.tsx +72 -0
- package/src/lib/outline-edge.ts +21 -0
- package/src/lib/popup-align.ts +67 -0
- package/src/lib/popup-direction.ts +22 -0
- package/src/lib/popup-motion.ts +19 -0
- package/src/lib/state-dictionary.ts +42 -6
- package/src/lib/syntax-colors.ts +8 -0
- package/src/lib/tint-recipes.ts +68 -0
- package/src/lib/tone-icons.ts +24 -0
- package/src/lib/trigger-slot.ts +16 -0
- package/src/lib/utils.ts +104 -1
|
@@ -2,52 +2,142 @@
|
|
|
2
2
|
|
|
3
3
|
import { useTheme } from "next-themes"
|
|
4
4
|
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
|
5
|
-
import {
|
|
5
|
+
import { buttonVariants } from "@vendure-io/ui/components/atoms/button"
|
|
6
|
+
import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
|
|
7
|
+
import { cn } from "@vendure-io/ui/lib/utils"
|
|
8
|
+
|
|
9
|
+
// A toast shows the same icon as a StatusBadge of its tone: error is
|
|
10
|
+
// `critical`, loading is `progress`.
|
|
11
|
+
const SuccessIcon = toneIcons.success
|
|
12
|
+
const InfoIcon = toneIcons.info
|
|
13
|
+
const WarningIcon = toneIcons.warning
|
|
14
|
+
const ErrorIcon = toneIcons.critical
|
|
15
|
+
const LoadingIcon = toneIcons.progress
|
|
16
|
+
|
|
17
|
+
// What an extra-small Button sets that Sonner's own button rule overrides.
|
|
18
|
+
const toastButton = cn(
|
|
19
|
+
"h-6! rounded-lg! px-2! text-xs! font-medium!",
|
|
20
|
+
"focus-visible:outline-solid! focus-visible:outline-2! focus-visible:outline-ring! focus-visible:shadow-none!",
|
|
21
|
+
"[transition:background-color_var(--transition-duration-quick)_var(--ease-default),color_var(--transition-duration-quick)_var(--ease-default),scale_var(--transition-duration-moderate)_var(--ease-press)]!",
|
|
22
|
+
)
|
|
6
23
|
|
|
7
24
|
const Toaster = ({ ...props }: ToasterProps) => {
|
|
8
|
-
const { theme = "system" } = useTheme()
|
|
25
|
+
const { theme = "system", forcedTheme } = useTheme()
|
|
9
26
|
|
|
10
27
|
return (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<CircleCheckIcon className="size-4" />
|
|
18
|
-
),
|
|
19
|
-
info: (
|
|
20
|
-
<InfoIcon className="size-4" />
|
|
21
|
-
),
|
|
22
|
-
warning: (
|
|
23
|
-
<TriangleAlertIcon className="size-4" />
|
|
24
|
-
),
|
|
25
|
-
error: (
|
|
26
|
-
<OctagonXIcon className="size-4" />
|
|
27
|
-
),
|
|
28
|
-
loading: (
|
|
29
|
-
<Loader2Icon className="size-4 animate-spin" />
|
|
30
|
-
),
|
|
31
|
-
}}
|
|
28
|
+
// Sonner declares its own --success-text, --warning-text and --info-text
|
|
29
|
+
// on the toaster, and they shadow the tokens of the same name. This
|
|
30
|
+
// wrapper reads the tokens outside the toaster; the toaster's style
|
|
31
|
+
// points Sonner's names back at them.
|
|
32
|
+
<div
|
|
33
|
+
className="contents"
|
|
32
34
|
style={
|
|
33
35
|
{
|
|
34
|
-
"--
|
|
35
|
-
"--
|
|
36
|
-
"--
|
|
37
|
-
"--border-radius": "var(--radius)",
|
|
36
|
+
"--toaster-success-text": "var(--success-text)",
|
|
37
|
+
"--toaster-warning-text": "var(--warning-text)",
|
|
38
|
+
"--toaster-info-text": "var(--info-text)",
|
|
38
39
|
} as React.CSSProperties
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
>
|
|
42
|
+
<Sonner
|
|
43
|
+
theme={(forcedTheme ?? theme) as ToasterProps["theme"]}
|
|
44
|
+
position="bottom-right"
|
|
45
|
+
className="toaster group"
|
|
46
|
+
// The v3 look keeps the stack open: the newest toast at the bottom and
|
|
47
|
+
// each older one 52px higher (a 44px toast and an 8px gap), 3% smaller
|
|
48
|
+
// and 20% fainter. Pass expand={false} for Sonner's collapsed stack.
|
|
49
|
+
expand
|
|
50
|
+
gap={8}
|
|
51
|
+
// 20px from the corner of the viewport.
|
|
52
|
+
offset={20}
|
|
53
|
+
// Each icon carries its tone: the toast surface stays neutral. Info
|
|
54
|
+
// draws the info icon in the brand colour, not the info tone colour.
|
|
55
|
+
icons={{
|
|
56
|
+
success: (
|
|
57
|
+
<SuccessIcon className="text-success-text size-4 stroke-2" />
|
|
58
|
+
),
|
|
59
|
+
info: (
|
|
60
|
+
<InfoIcon className="text-brand-indicator size-4 stroke-2" />
|
|
61
|
+
),
|
|
62
|
+
warning: (
|
|
63
|
+
<WarningIcon className="text-warning-text size-4 stroke-2" />
|
|
64
|
+
),
|
|
65
|
+
error: (
|
|
66
|
+
<ErrorIcon className="text-destructive-text size-4 stroke-2" />
|
|
67
|
+
),
|
|
68
|
+
loading: (
|
|
69
|
+
<LoadingIcon className="text-muted-foreground size-4 animate-spin stroke-2 motion-reduce:animate-none" />
|
|
70
|
+
),
|
|
71
|
+
}}
|
|
72
|
+
style={
|
|
73
|
+
{
|
|
74
|
+
// A toast sits on the raised surface, not the overlay tier.
|
|
75
|
+
"--normal-bg": "var(--card)",
|
|
76
|
+
"--normal-text": "var(--card-foreground)",
|
|
77
|
+
"--success-text": "var(--toaster-success-text)",
|
|
78
|
+
"--warning-text": "var(--toaster-warning-text)",
|
|
79
|
+
"--info-text": "var(--toaster-info-text)",
|
|
80
|
+
"--border-radius": "var(--radius-2xl)",
|
|
81
|
+
"--width": "320px",
|
|
82
|
+
// Sonner pulls the icon 3px out and adds 4px after it. The toast's
|
|
83
|
+
// own 10px gap is the only space between the icon and the text.
|
|
84
|
+
"--toast-icon-margin-start": "0px",
|
|
85
|
+
"--toast-icon-margin-end": "0px",
|
|
86
|
+
"--toast-svg-margin-start": "0px",
|
|
87
|
+
"--toast-svg-margin-end": "0px",
|
|
88
|
+
} as React.CSSProperties
|
|
89
|
+
}
|
|
90
|
+
toastOptions={{
|
|
91
|
+
classNames: {
|
|
92
|
+
// Sonner's own stylesheet is unlayered, so the overlay shadow and
|
|
93
|
+
// the type need ! to win over it.
|
|
94
|
+
// 44px high, 10px 14px padding, 13px medium text, a 10px gap. The
|
|
95
|
+
// overlay shadow gives the edge. The toast has no
|
|
96
|
+
// border and no inset hairline: either would sit next to the
|
|
97
|
+
// shadow's 1px edge and read as a second line. A new toast fades in from 12px
|
|
98
|
+
// below; a leaving one drops 6px at 0.97. The entry has no scale:
|
|
99
|
+
// Sonner measures the toast's height on mount, and a scaled toast
|
|
100
|
+
// would shorten every step of the stack. Positions move in toast-move (320ms)
|
|
101
|
+
// on ease-drawer and heights on ease-height, opacity in toast-fade
|
|
102
|
+
// (220ms) on ease-soft. Reduced
|
|
103
|
+
// motion keeps the fades only.
|
|
104
|
+
toast: cn(
|
|
105
|
+
"cn-toast font-sans! min-h-11! gap-2.5! px-3.5! py-2.5! text-sm! font-medium!",
|
|
106
|
+
"border-0! shadow-overlay!",
|
|
107
|
+
"[transition:transform_var(--transition-duration-toast-move)_var(--ease-drawer),opacity_var(--transition-duration-toast-fade)_var(--ease-soft),height_var(--transition-duration-toast-move)_var(--ease-height)]!",
|
|
108
|
+
"data-[mounted=false]:[--y:translateY(calc(var(--lift)*-12px))]!",
|
|
109
|
+
"data-[mounted=true]:data-[expanded=true]:[--y:translateY(calc(var(--lift)*var(--offset)))_scale(calc(1-var(--index)*0.03))]!",
|
|
110
|
+
"data-[mounted=true]:data-[visible=true]:data-[removed=false]:opacity-[calc(1-var(--index)*0.2)]!",
|
|
111
|
+
"data-[removed=true]:data-[swipe-out=false]:[--y:translateY(calc(var(--lift)*var(--offset)-var(--lift)*6px))_scale(0.97)]!",
|
|
112
|
+
"data-[removed=true]:[transition:transform_var(--transition-duration-toast-exit-move)_var(--ease-soft),opacity_var(--transition-duration-toast-exit-fade)_var(--ease-soft)]!",
|
|
113
|
+
"motion-reduce:[transition:opacity_var(--transition-duration-toast-fade)_var(--ease-soft)]!",
|
|
114
|
+
),
|
|
115
|
+
// Override Sonner's hardcoded #3f3f3f description colour
|
|
116
|
+
// with our semantic muted-foreground token for consistent contrast.
|
|
117
|
+
// See: https://github.com/vendurehq/design/issues/5
|
|
118
|
+
description: "!text-muted-foreground",
|
|
119
|
+
// An icon passed to a plain toast is the foreground at 60%. The
|
|
120
|
+
// tone icons above set their own colour.
|
|
121
|
+
icon: "text-foreground/60",
|
|
122
|
+
// The action and cancel buttons are extra-small Buttons: the
|
|
123
|
+
// action the default variant, the cancel ghost. Sonner styles its
|
|
124
|
+
// buttons unlayered (radius, size, colours, outline, transition),
|
|
125
|
+
// so each of those properties needs ! to win.
|
|
126
|
+
actionButton: cn(
|
|
127
|
+
buttonVariants({ size: "xs" }),
|
|
128
|
+
toastButton,
|
|
129
|
+
"bg-primary! text-primary-foreground! hover:bg-(--primary-hover)!",
|
|
130
|
+
),
|
|
131
|
+
cancelButton: cn(
|
|
132
|
+
buttonVariants({ variant: "ghost", size: "xs" }),
|
|
133
|
+
toastButton,
|
|
134
|
+
"bg-transparent! text-foreground-secondary! hover:bg-muted! hover:text-foreground!",
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
}}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
51
141
|
)
|
|
52
142
|
}
|
|
53
143
|
|
|
@@ -3,7 +3,7 @@ import { Loader2Icon } from "lucide-react"
|
|
|
3
3
|
|
|
4
4
|
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
5
5
|
return (
|
|
6
|
-
<Loader2Icon role="status" aria-label="Loading" className={cn("size-4 animate-spin", className)} {...props} />
|
|
6
|
+
<Loader2Icon role="status" aria-label="Loading" className={cn("size-4 animate-spin motion-reduce:animate-none", className)} {...props} />
|
|
7
7
|
)
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useFieldControlProps,
|
|
8
|
+
useFieldLabelCheckedClass,
|
|
9
|
+
} from "@vendure-io/ui/components/atoms/field"
|
|
7
10
|
|
|
8
11
|
function Switch({
|
|
9
12
|
className,
|
|
@@ -12,19 +15,21 @@ function Switch({
|
|
|
12
15
|
}: SwitchPrimitive.Root.Props & {
|
|
13
16
|
size?: "sm" | "default"
|
|
14
17
|
}) {
|
|
18
|
+
const fieldLabelChecked = useFieldLabelCheckedClass()
|
|
15
19
|
return (
|
|
16
20
|
<SwitchPrimitive.Root
|
|
17
21
|
data-slot="switch"
|
|
18
22
|
data-size={size}
|
|
19
|
-
className={cn(
|
|
20
|
-
"data-checked:bg-primary data-unchecked:bg-control-border focus-visible:
|
|
21
|
-
|
|
23
|
+
className={(state) => cn(
|
|
24
|
+
"data-checked:bg-primary data-unchecked:bg-control-border focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:focus-visible:outline-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-[background-color,border-color,box-shadow,opacity] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 aria-invalid:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]",
|
|
25
|
+
fieldLabelChecked(state.checked),
|
|
26
|
+
typeof className === "function" ? className(state) : className
|
|
22
27
|
)}
|
|
23
28
|
{...useFieldControlProps(props)}
|
|
24
29
|
>
|
|
25
30
|
<SwitchPrimitive.Thumb
|
|
26
31
|
data-slot="switch-thumb"
|
|
27
|
-
className="bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0"
|
|
32
|
+
className="bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform motion-reduce:transition-none group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0"
|
|
28
33
|
/>
|
|
29
34
|
</SwitchPrimitive.Root>
|
|
30
35
|
)
|
|
@@ -37,7 +37,7 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
|
37
37
|
ref={containerRef}
|
|
38
38
|
data-slot="table-container"
|
|
39
39
|
tabIndex={scrollable ? 0 : undefined}
|
|
40
|
-
className="focus-visible:
|
|
40
|
+
className="focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring relative w-full overflow-x-auto rounded-[inherit] outline-none"
|
|
41
41
|
>
|
|
42
42
|
<table
|
|
43
43
|
data-slot="table"
|
|
@@ -58,9 +58,77 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// Marks each row whose next row is selected with `data-next-selected`, for the
|
|
62
|
+
// selected-row bar (see selectedBar). The marks are synced in a layout effect
|
|
63
|
+
// on every commit, so they change in the same task as the selection (a style
|
|
64
|
+
// read before a microtask would see stale marks and start the bar from the
|
|
65
|
+
// wrong place). A MutationObserver covers a row that changes `data-state`
|
|
66
|
+
// without this body re-rendering.
|
|
67
|
+
function syncNextSelectedMarks(body: HTMLTableSectionElement) {
|
|
68
|
+
for (let row = body.firstElementChild; row; row = row.nextElementSibling) {
|
|
69
|
+
const mark =
|
|
70
|
+
row.nextElementSibling?.getAttribute("data-state") === "selected"
|
|
71
|
+
if (row.hasAttribute("data-next-selected") !== mark) {
|
|
72
|
+
row.toggleAttribute("data-next-selected", mark)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function useNextSelectedMarks(
|
|
78
|
+
body: React.RefObject<HTMLTableSectionElement | null>
|
|
79
|
+
) {
|
|
80
|
+
React.useLayoutEffect(() => {
|
|
81
|
+
if (body.current) {
|
|
82
|
+
syncNextSelectedMarks(body.current)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
React.useLayoutEffect(() => {
|
|
86
|
+
const element = body.current
|
|
87
|
+
if (!element || typeof MutationObserver === "undefined") {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
const observer = new MutationObserver((records) => {
|
|
91
|
+
if (
|
|
92
|
+
records.some(
|
|
93
|
+
(record) =>
|
|
94
|
+
record.target === element ||
|
|
95
|
+
record.target.parentElement === element
|
|
96
|
+
)
|
|
97
|
+
) {
|
|
98
|
+
syncNextSelectedMarks(element)
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
observer.observe(element, {
|
|
102
|
+
childList: true,
|
|
103
|
+
subtree: true,
|
|
104
|
+
attributeFilter: ["data-state"],
|
|
105
|
+
})
|
|
106
|
+
return () => observer.disconnect()
|
|
107
|
+
}, [body])
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function TableBody({
|
|
111
|
+
className,
|
|
112
|
+
ref,
|
|
113
|
+
...props
|
|
114
|
+
}: React.ComponentProps<"tbody">) {
|
|
115
|
+
const bodyRef = React.useRef<HTMLTableSectionElement>(null)
|
|
116
|
+
useNextSelectedMarks(bodyRef)
|
|
117
|
+
const setRef = React.useCallback(
|
|
118
|
+
(node: HTMLTableSectionElement | null) => {
|
|
119
|
+
bodyRef.current = node
|
|
120
|
+
if (typeof ref === "function") {
|
|
121
|
+
return ref(node)
|
|
122
|
+
}
|
|
123
|
+
if (ref) {
|
|
124
|
+
ref.current = node
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
[ref]
|
|
128
|
+
)
|
|
62
129
|
return (
|
|
63
130
|
<tbody
|
|
131
|
+
ref={setRef}
|
|
64
132
|
data-slot="table-body"
|
|
65
133
|
className={cn("[&_tr:last-child]:border-0", className)}
|
|
66
134
|
{...props}
|
|
@@ -82,14 +150,75 @@ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
|
82
150
|
}
|
|
83
151
|
|
|
84
152
|
// data-state="selected" is the DataTable (TanStack) row-selection marker, not a
|
|
85
|
-
// Radix attribute, so the selector is live. Selected rows use the
|
|
86
|
-
// plus a
|
|
153
|
+
// Radix attribute, so the selector is live. Selected rows use the muted fill,
|
|
154
|
+
// as in the v3 look, plus a brand-colour bar on the inline-start edge, so they
|
|
155
|
+
// stay distinct from the lighter muted/50 hover.
|
|
156
|
+
//
|
|
157
|
+
// The bar draws itself and knows its neighbours. It is two pseudo-elements of
|
|
158
|
+
// the row, both full height and absolute (so neither becomes a table cell):
|
|
159
|
+
// ::before shows the top half and ::after the bottom half, each through a
|
|
160
|
+
// clip-path inset. A selected row shows both halves. An unselected row
|
|
161
|
+
// collapses each half to the point the bar grows from, so selecting animates
|
|
162
|
+
// the clip from there (`moderate`, `ease-out`) and deselecting plays it back:
|
|
163
|
+
// - no selected neighbour: both halves from the middle, so it grows outward;
|
|
164
|
+
// - a selected row above: both from the top, so it extends that row's bar down;
|
|
165
|
+
// - a selected row below: both from the bottom, so it grows up from it;
|
|
166
|
+
// - selected rows on both sides: the top half from the top and the bottom half
|
|
167
|
+
// from the bottom, so they meet in the middle.
|
|
168
|
+
// The selected clips are `!important` to beat the neighbour rules, whose
|
|
169
|
+
// sibling selectors are more specific. A range selection grows all its bars
|
|
170
|
+
// at once. The DataTable's select all and clear all ripple instead: they
|
|
171
|
+
// delay each row and start every bar from its top (SELECT_RIPPLE_ROW_CLASS). The selected halves overlap by 1px (each runs 0.5px past the middle):
|
|
172
|
+
// on a row of an odd height the middle falls on a half pixel, and two edges
|
|
173
|
+
// that each cover half of a pixel row blend to a lighter 1px notch. With the
|
|
174
|
+
// overlap one half fully covers every pixel row, whatever the height.
|
|
175
|
+
// A bar that grows on its own (no selected neighbour) also fades in and
|
|
176
|
+
// widens from 1px to 2px against the table edge (`scale` 0.5 on x, origin
|
|
177
|
+
// inline-start), so it arrives softly: `moderate`, opacity on `ease-soft` and
|
|
178
|
+
// scale on `ease-out`, as the checkbox fill. Clearing plays it back in
|
|
179
|
+
// `fast`, both on `ease-soft`, as the checkbox clears; its clip waits for that
|
|
180
|
+
// and then jumps, since a collapsing clip would hide the bar in a few frames.
|
|
181
|
+
// A bar that extends a selected neighbour stays opaque and full width, so the
|
|
182
|
+
// line has no lighter or thinner join, and clears by shrinking toward the
|
|
183
|
+
// neighbour (`--bar-clip-duration`, `--bar-clip-delay`, set on the
|
|
184
|
+
// pseudo-elements: on the row they would be inherited by every cell, and a
|
|
185
|
+
// change would restyle the whole row). The row below is read from
|
|
186
|
+
// `data-next-selected`, which TableBody keeps up to date, not with
|
|
187
|
+
// `:has(+[data-state=selected])`: in Chromium any such rule makes a change of
|
|
188
|
+
// `data-state` restyle every row with all its cells, and select all on a long
|
|
189
|
+
// table then drops frames. At rest
|
|
190
|
+
// the bar is the same as without the motion: opacity 1, no scale. Under
|
|
191
|
+
// reduced motion the bar is whole and only fades: the clip jumps on select and
|
|
192
|
+
// waits for the fade on deselect.
|
|
193
|
+
const selectedBar = [
|
|
194
|
+
"before:pointer-events-none before:absolute before:inset-y-0 before:start-0 before:w-0.5 before:bg-brand-indicator",
|
|
195
|
+
"after:pointer-events-none after:absolute after:inset-y-0 after:start-0 after:w-0.5 after:bg-brand-indicator",
|
|
196
|
+
"before:[clip-path:inset(50%_0_50%_0)] after:[clip-path:inset(50%_0_50%_0)]",
|
|
197
|
+
"[[data-state=selected]+&]:before:[clip-path:inset(0_0_100%_0)] [[data-state=selected]+&]:after:[clip-path:inset(0_0_100%_0)]",
|
|
198
|
+
"data-next-selected:before:[clip-path:inset(100%_0_0_0)] data-next-selected:after:[clip-path:inset(100%_0_0_0)]",
|
|
199
|
+
"[[data-state=selected]+&[data-next-selected]]:before:[clip-path:inset(0_0_100%_0)] [[data-state=selected]+&[data-next-selected]]:after:[clip-path:inset(100%_0_0_0)]",
|
|
200
|
+
"data-[state=selected]:before:[clip-path:inset(0_0_calc(50%_-_0.5px)_0)]! data-[state=selected]:after:[clip-path:inset(calc(50%_-_0.5px)_0_0_0)]!",
|
|
201
|
+
"before:origin-left after:origin-left rtl:before:origin-right rtl:after:origin-right",
|
|
202
|
+
"motion-safe:before:opacity-0 motion-safe:after:opacity-0 motion-safe:before:[scale:0.5_1] motion-safe:after:[scale:0.5_1]",
|
|
203
|
+
"motion-safe:[[data-state=selected]+&]:before:opacity-100 motion-safe:[[data-state=selected]+&]:after:opacity-100 motion-safe:[[data-state=selected]+&]:before:[scale:none] motion-safe:[[data-state=selected]+&]:after:[scale:none]",
|
|
204
|
+
"motion-safe:data-next-selected:before:opacity-100 motion-safe:data-next-selected:after:opacity-100 motion-safe:data-next-selected:before:[scale:none] motion-safe:data-next-selected:after:[scale:none]",
|
|
205
|
+
"motion-safe:data-[state=selected]:before:opacity-100 motion-safe:data-[state=selected]:after:opacity-100 motion-safe:data-[state=selected]:before:[scale:none] motion-safe:data-[state=selected]:after:[scale:none]",
|
|
206
|
+
"before:[--bar-clip-duration:0s] after:[--bar-clip-duration:0s] before:[--bar-clip-delay:var(--transition-duration-fast)] after:[--bar-clip-delay:var(--transition-duration-fast)]",
|
|
207
|
+
"[[data-state=selected]+&]:before:[--bar-clip-duration:var(--transition-duration-moderate)] [[data-state=selected]+&]:after:[--bar-clip-duration:var(--transition-duration-moderate)] [[data-state=selected]+&]:before:[--bar-clip-delay:0s] [[data-state=selected]+&]:after:[--bar-clip-delay:0s] data-next-selected:before:[--bar-clip-duration:var(--transition-duration-moderate)] data-next-selected:after:[--bar-clip-duration:var(--transition-duration-moderate)] data-next-selected:before:[--bar-clip-delay:0s] data-next-selected:after:[--bar-clip-delay:0s]",
|
|
208
|
+
"before:[transition:clip-path_var(--bar-clip-duration)_var(--ease-out)_var(--bar-clip-delay),opacity_var(--transition-duration-fast)_var(--ease-soft),scale_var(--transition-duration-fast)_var(--ease-soft)] after:[transition:clip-path_var(--bar-clip-duration)_var(--ease-out)_var(--bar-clip-delay),opacity_var(--transition-duration-fast)_var(--ease-soft),scale_var(--transition-duration-fast)_var(--ease-soft)]",
|
|
209
|
+
"motion-safe:data-[state=selected]:before:[transition:clip-path_var(--transition-duration-moderate)_var(--ease-out),opacity_var(--transition-duration-moderate)_var(--ease-soft),scale_var(--transition-duration-moderate)_var(--ease-out)] motion-safe:data-[state=selected]:after:[transition:clip-path_var(--transition-duration-moderate)_var(--ease-out),opacity_var(--transition-duration-moderate)_var(--ease-soft),scale_var(--transition-duration-moderate)_var(--ease-out)]",
|
|
210
|
+
"motion-reduce:before:opacity-0 motion-reduce:after:opacity-0 motion-reduce:data-[state=selected]:before:opacity-100 motion-reduce:data-[state=selected]:after:opacity-100",
|
|
211
|
+
"motion-reduce:before:[transition:opacity_var(--transition-duration-fast)_var(--ease-soft),clip-path_0s_linear_var(--transition-duration-fast)] motion-reduce:after:[transition:opacity_var(--transition-duration-fast)_var(--ease-soft),clip-path_0s_linear_var(--transition-duration-fast)]",
|
|
212
|
+
"motion-reduce:data-[state=selected]:before:[transition:opacity_var(--transition-duration-moderate)_var(--ease-soft)] motion-reduce:data-[state=selected]:after:[transition:opacity_var(--transition-duration-moderate)_var(--ease-soft)]",
|
|
213
|
+
].join(" ")
|
|
214
|
+
|
|
87
215
|
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
88
216
|
return (
|
|
89
217
|
<tr
|
|
90
218
|
data-slot="table-row"
|
|
91
219
|
className={cn(
|
|
92
|
-
"hover:bg-muted/50 data-[state=selected]:bg-
|
|
220
|
+
"hover:bg-muted/50 data-[state=selected]:bg-muted relative border-b border-border/50 transition-colors",
|
|
221
|
+
selectedBar,
|
|
93
222
|
className
|
|
94
223
|
)}
|
|
95
224
|
{...props}
|
|
@@ -97,12 +226,15 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
|
97
226
|
)
|
|
98
227
|
}
|
|
99
228
|
|
|
229
|
+
// Every header label has the same size, weight and colour: 12px, medium,
|
|
230
|
+
// muted, the small label of the v3 look. A sortable header (a ghost Button)
|
|
231
|
+
// inherits the colour, so only its sort icon says it sorts.
|
|
100
232
|
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
101
233
|
return (
|
|
102
234
|
<th
|
|
103
235
|
data-slot="table-head"
|
|
104
236
|
className={cn(
|
|
105
|
-
"text-foreground h-10 px-2 text-
|
|
237
|
+
"text-muted-foreground h-10 px-2 text-start align-middle text-xs font-medium whitespace-nowrap [&:has([role=checkbox])]:pe-0",
|
|
106
238
|
className
|
|
107
239
|
)}
|
|
108
240
|
{...props}
|
|
@@ -110,12 +242,20 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
|
110
242
|
)
|
|
111
243
|
}
|
|
112
244
|
|
|
245
|
+
// A body row is at least 48px (`h-12`), the same as a ListRow and a CardRow.
|
|
246
|
+
// On a table cell `height` is a minimum (`min-height` does nothing there), so
|
|
247
|
+
// taller content (a thumbnail, two lines) still grows the row. The column
|
|
248
|
+
// header row stays 40px (TableHead). The row's 1px divider counts in the
|
|
249
|
+
// 48px. The table collapses its borders, so each row box holds half of the
|
|
250
|
+
// divider above and half of its own. The cell pads 7.5px on both sides, so
|
|
251
|
+
// 32px content (a thumbnail, a button) fills the row at 48px, and it and
|
|
252
|
+
// one-line text sit as far from the divider above as from the one below.
|
|
113
253
|
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
114
254
|
return (
|
|
115
255
|
<td
|
|
116
256
|
data-slot="table-cell"
|
|
117
257
|
className={cn(
|
|
118
|
-
"
|
|
258
|
+
"h-12 px-2 py-[7.5px] align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0",
|
|
119
259
|
className
|
|
120
260
|
)}
|
|
121
261
|
{...props}
|
|
@@ -60,13 +60,13 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
|
|
60
60
|
<TabsPrimitive.Tab
|
|
61
61
|
data-slot="tabs-trigger"
|
|
62
62
|
className={cn(
|
|
63
|
-
"focus-visible:
|
|
63
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
|
|
64
64
|
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent",
|
|
65
65
|
// ADR 0001: the active trigger lifts to surface-raised out of the inset
|
|
66
66
|
// track in both themes. Dark keeps a hairline — lightness alone can't
|
|
67
67
|
// separate a 0.21 thumb near the black end of the ramp.
|
|
68
68
|
"data-active:bg-surface-raised dark:data-active:border-input dark:data-active:text-foreground data-active:text-foreground",
|
|
69
|
-
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-
|
|
69
|
+
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-end-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
70
70
|
className
|
|
71
71
|
)}
|
|
72
72
|
{...props}
|
|
@@ -122,7 +122,7 @@ function TabsLink({
|
|
|
122
122
|
"aria-current": active ? ("page" as const) : undefined,
|
|
123
123
|
}),
|
|
124
124
|
className: cn(
|
|
125
|
-
"focus-visible:
|
|
125
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-full shrink-0 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,opacity] aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
|
|
126
126
|
"aria-[current=page]:text-foreground dark:aria-[current=page]:text-foreground",
|
|
127
127
|
// The underline sits on the bottom edge of the nav, like the line variant.
|
|
128
128
|
"after:bg-foreground after:absolute after:inset-x-0 after:bottom-[-4px] after:h-0.5 after:opacity-0 after:transition-opacity aria-[current=page]:after:opacity-100",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from "react"
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
|
+
import { fieldSurface } from "@vendure-io/ui/lib/field-surface"
|
|
6
7
|
import { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
|
|
7
8
|
|
|
8
9
|
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
@@ -10,7 +11,8 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
|
10
11
|
<textarea
|
|
11
12
|
data-slot="textarea"
|
|
12
13
|
className={cn(
|
|
13
|
-
|
|
14
|
+
fieldSurface,
|
|
15
|
+
"placeholder:text-faint-foreground flex field-sizing-content min-h-16 w-full px-2.5 py-2 text-base disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
14
16
|
className
|
|
15
17
|
)}
|
|
16
18
|
{...useFieldControlProps(props)}
|
|
@@ -42,7 +42,9 @@ function ToggleGroup({
|
|
|
42
42
|
data-orientation={orientation}
|
|
43
43
|
style={{ "--gap": spacing } as React.CSSProperties}
|
|
44
44
|
className={cn(
|
|
45
|
-
|
|
45
|
+
// A joined outline group sits on the card fill with shadow-control, like
|
|
46
|
+
// a ButtonGroup; its items drop their own shadow.
|
|
47
|
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-xl data-vertical:flex-col data-vertical:items-stretch data-[variant=outline]:data-[spacing=0]:bg-card data-[variant=outline]:data-[spacing=0]:shadow-control",
|
|
46
48
|
className
|
|
47
49
|
)}
|
|
48
50
|
{...props}
|
|
@@ -73,7 +75,7 @@ function ToggleGroupItem({
|
|
|
73
75
|
data-spacing={context.spacing}
|
|
74
76
|
className={cn(
|
|
75
77
|
// Base UI's Toggle emits data-pressed, never Radix's data-[state=on] — the pressed style comes from toggleVariants via its aria-pressed and data-pressed rules
|
|
76
|
-
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-
|
|
78
|
+
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-s-xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-e-xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-xl group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-s-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-s group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
|
77
79
|
toggleVariants({
|
|
78
80
|
variant: context.variant || variant,
|
|
79
81
|
size: context.size || size,
|
|
@@ -4,21 +4,43 @@ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
|
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
+
import { outlineEdge, outlineEdgeHover } from "@vendure-io/ui/lib/outline-edge"
|
|
7
8
|
|
|
8
9
|
const toggleVariants = cva(
|
|
9
|
-
// Pressed
|
|
10
|
-
//
|
|
10
|
+
// Pressed is the accent tint with foreground text, as in the v3 look. Hover
|
|
11
|
+
// is the muted fill, so a hovered item never reads as pressed; a pressed item
|
|
12
|
+
// keeps its tint on hover. The outline border keeps its colour when pressed,
|
|
13
|
+
// so a pressed item stays part of its group.
|
|
11
14
|
// Base UI sets both aria-pressed and data-pressed; both are styled.
|
|
12
|
-
|
|
15
|
+
// A disabled toggle that keeps its tab stop and tooltip carries
|
|
16
|
+
// aria-disabled="true" (Base UI's Toggle has no focusableWhenDisabled). It
|
|
17
|
+
// looks like a disabled toggle: half opacity and a not-allowed cursor. Its
|
|
18
|
+
// hover is undone by `aria-disabled:hover:` resets to the rest look, pressed
|
|
19
|
+
// or not, so a consumer's own `hover:` class keeps working on an enabled
|
|
20
|
+
// toggle. Ignoring the press is the consumer's job: cancel it in
|
|
21
|
+
// `onPressedChange`.
|
|
22
|
+
// Sizes and corners match Button, so a toggle sits level with the buttons,
|
|
23
|
+
// ButtonGroup and fields next to it: 34px default and 28px sm (12px text),
|
|
24
|
+
// the xl radius.
|
|
25
|
+
// The icon follows Button's icon recipe, as in the v3 look: quieter than
|
|
26
|
+
// the text at 55%, 85% under the pointer, a 1.75 stroke; 14px in the small
|
|
27
|
+
// size. Pressed keeps 55%, as the v3 look's pressed toggle does: the accent
|
|
28
|
+
// tint marks the press. An icon with its own opacity class keeps it.
|
|
29
|
+
"[&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 [&>svg]:[transition:opacity_var(--transition-duration-moderate)_var(--ease-default)] hover:text-foreground aria-pressed:bg-accent aria-pressed:text-foreground aria-pressed:hover:bg-accent data-pressed:bg-accent data-pressed:text-foreground data-pressed:hover:bg-accent focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:focus-visible:outline-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive gap-1 rounded-xl text-sm font-medium transition-[background-color,border-color,color,box-shadow] duration-quick ease-default [&_svg:not([class*='size-'])]:size-4 group/toggle hover:bg-muted inline-flex items-center justify-center whitespace-nowrap outline-none disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:hover:bg-transparent aria-disabled:hover:text-current aria-disabled:aria-pressed:hover:bg-accent aria-disabled:aria-pressed:hover:text-foreground aria-disabled:data-pressed:hover:bg-accent aria-disabled:data-pressed:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
13
30
|
{
|
|
14
31
|
variants: {
|
|
15
32
|
variant: {
|
|
16
33
|
default: "bg-transparent",
|
|
17
|
-
outline
|
|
34
|
+
// The outline toggle takes the outline Button's surface: the card fill
|
|
35
|
+
// and shadow-control, as the v3 look draws a pressed toggle beside
|
|
36
|
+
// buttons. Its hover is the outline Button's too: 4% foreground mixed
|
|
37
|
+
// into the card, and the edge steps up to `input`. Pressed is still
|
|
38
|
+
// the accent tint on top, under the pointer as well.
|
|
39
|
+
outline: [outlineEdge, outlineEdgeHover, "hover:bg-[color-mix(in_oklab,var(--card),var(--foreground)_4%)] aria-disabled:hover:bg-card border bg-card shadow-control"],
|
|
18
40
|
},
|
|
19
41
|
size: {
|
|
20
|
-
default: "h-
|
|
21
|
-
sm: "h-
|
|
42
|
+
default: "h-8.5 min-w-8.5 px-2",
|
|
43
|
+
sm: "h-7 min-w-7 px-1.5 text-xs [&_svg:not([class*='size-'])]:size-3.5",
|
|
22
44
|
lg: "h-10 min-w-10 px-2.5",
|
|
23
45
|
},
|
|
24
46
|
},
|