@vendure-io/ui 2.2.0 → 3.0.0-next.1
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 +72 -18
- package/src/components/atoms/avatar.tsx +12 -4
- package/src/components/atoms/badge.tsx +7 -2
- package/src/components/atoms/breadcrumb.tsx +493 -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 +358 -29
- package/src/components/atoms/command.tsx +336 -13
- package/src/components/atoms/context-menu.tsx +28 -23
- package/src/components/atoms/dialog.tsx +173 -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 +5 -1
- package/src/components/atoms/field.tsx +41 -15
- package/src/components/atoms/hover-card.tsx +61 -8
- package/src/components/atoms/input-group.tsx +19 -11
- 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 +113 -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 +29 -6
- 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 +76 -23
- package/src/components/atoms/sidebar.tsx +405 -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 +43 -4
- 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 +122 -9
- package/src/components/molecules/copyable-text.tsx +75 -11
- package/src/components/molecules/count-badge.tsx +115 -0
- 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 +62 -22
- package/src/components/molecules/data-table/data-table-helpers.tsx +88 -1
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
- package/src/components/molecules/data-table/data-table-types.tsx +160 -4
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
- package/src/components/molecules/data-table/data-table.tsx +869 -81
- 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 +111 -0
- package/src/components/molecules/secret-value.tsx +29 -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 +66 -0
- package/src/hooks/use-apple-platform.ts +26 -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 +97 -1
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
DropdownMenuSubTrigger,
|
|
21
21
|
DropdownMenuTrigger,
|
|
22
22
|
} from "@vendure-io/ui/components/atoms/dropdown-menu"
|
|
23
|
-
import {
|
|
23
|
+
import { menuCheckItem, menuItemDisabled, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
|
|
24
24
|
|
|
25
25
|
function Menubar({ className, ...props }: MenubarPrimitive.Props) {
|
|
26
26
|
return (
|
|
@@ -59,7 +59,7 @@ function MenubarTrigger({
|
|
|
59
59
|
<DropdownMenuTrigger
|
|
60
60
|
data-slot="menubar-trigger"
|
|
61
61
|
className={cn(
|
|
62
|
-
"hover:bg-muted aria-expanded:bg-muted flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none",
|
|
62
|
+
"hover:bg-muted aria-expanded:bg-muted flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
|
|
63
63
|
className
|
|
64
64
|
)}
|
|
65
65
|
{...props}
|
|
@@ -67,10 +67,17 @@ function MenubarTrigger({
|
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Without an `align`, the menu opens toward the centre of the screen, as a
|
|
72
|
+
* DropdownMenu does: a trigger in the right half lines the menu up with its
|
|
73
|
+
* right edge, one in the left half with its left edge. The -5px offset moves
|
|
74
|
+
* the menu outward on either side, so its items line up with the trigger's
|
|
75
|
+
* text. An explicit `align` always wins.
|
|
76
|
+
*/
|
|
70
77
|
function MenubarContent({
|
|
71
78
|
className,
|
|
72
|
-
align
|
|
73
|
-
alignOffset = -
|
|
79
|
+
align,
|
|
80
|
+
alignOffset = -5,
|
|
74
81
|
sideOffset = 8,
|
|
75
82
|
...props
|
|
76
83
|
}: React.ComponentProps<typeof DropdownMenuContent>) {
|
|
@@ -80,7 +87,7 @@ function MenubarContent({
|
|
|
80
87
|
align={align}
|
|
81
88
|
alignOffset={alignOffset}
|
|
82
89
|
sideOffset={sideOffset}
|
|
83
|
-
className={cn("
|
|
90
|
+
className={cn("min-w-36", className)}
|
|
84
91
|
{...props}
|
|
85
92
|
/>
|
|
86
93
|
)
|
|
@@ -98,7 +105,7 @@ function MenubarItem({
|
|
|
98
105
|
data-inset={inset}
|
|
99
106
|
data-variant={variant}
|
|
100
107
|
className={cn(
|
|
101
|
-
"
|
|
108
|
+
"group/menubar-item",
|
|
102
109
|
className
|
|
103
110
|
)}
|
|
104
111
|
{...props}
|
|
@@ -120,17 +127,16 @@ function MenubarCheckboxItem({
|
|
|
120
127
|
data-slot="menubar-checkbox-item"
|
|
121
128
|
data-inset={inset}
|
|
122
129
|
className={cn(
|
|
123
|
-
|
|
130
|
+
menuItemDisabled,
|
|
131
|
+
menuCheckItem,
|
|
132
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
124
133
|
className
|
|
125
134
|
)}
|
|
126
135
|
checked={checked}
|
|
127
136
|
{...props}
|
|
128
137
|
>
|
|
129
|
-
<span className="pointer-events-none absolute
|
|
130
|
-
<
|
|
131
|
-
<CheckIcon
|
|
132
|
-
/>
|
|
133
|
-
</MenuPrimitive.CheckboxItemIndicator>
|
|
138
|
+
<span className="pointer-events-none absolute start-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
|
|
139
|
+
<MenuCheck />
|
|
134
140
|
</span>
|
|
135
141
|
{children}
|
|
136
142
|
</MenuPrimitive.CheckboxItem>
|
|
@@ -156,16 +162,15 @@ function MenubarRadioItem({
|
|
|
156
162
|
data-slot="menubar-radio-item"
|
|
157
163
|
data-inset={inset}
|
|
158
164
|
className={cn(
|
|
159
|
-
|
|
165
|
+
menuItemDisabled,
|
|
166
|
+
menuRadioItem,
|
|
167
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground not-data-disabled:focus:**:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg pe-2 ps-8 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
160
168
|
className
|
|
161
169
|
)}
|
|
162
170
|
{...props}
|
|
163
171
|
>
|
|
164
|
-
<span className="pointer-events-none absolute
|
|
165
|
-
<
|
|
166
|
-
<CheckIcon
|
|
167
|
-
/>
|
|
168
|
-
</MenuPrimitive.RadioItemIndicator>
|
|
172
|
+
<span className="pointer-events-none absolute start-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
|
|
173
|
+
<MenuCheck />
|
|
169
174
|
</span>
|
|
170
175
|
{children}
|
|
171
176
|
</MenuPrimitive.RadioItem>
|
|
@@ -184,7 +189,7 @@ function MenubarLabel({
|
|
|
184
189
|
data-slot="menubar-label"
|
|
185
190
|
data-inset={inset}
|
|
186
191
|
className={cn(
|
|
187
|
-
"px-2 py-1.5 text-sm font-medium data-inset:
|
|
192
|
+
"px-2 py-1.5 text-sm font-medium data-inset:ps-8",
|
|
188
193
|
className
|
|
189
194
|
)}
|
|
190
195
|
{...props}
|
|
@@ -199,7 +204,7 @@ function MenubarSeparator({
|
|
|
199
204
|
return (
|
|
200
205
|
<DropdownMenuSeparator
|
|
201
206
|
data-slot="menubar-separator"
|
|
202
|
-
className={
|
|
207
|
+
className={className}
|
|
203
208
|
{...props}
|
|
204
209
|
/>
|
|
205
210
|
)
|
|
@@ -213,7 +218,7 @@ function MenubarShortcut({
|
|
|
213
218
|
<DropdownMenuShortcut
|
|
214
219
|
data-slot="menubar-shortcut"
|
|
215
220
|
className={cn(
|
|
216
|
-
"text-muted-foreground group-focus/menubar-item:text-accent-foreground
|
|
221
|
+
"text-muted-foreground group-focus/menubar-item:text-accent-foreground ms-auto text-xs tracking-widest",
|
|
217
222
|
className
|
|
218
223
|
)}
|
|
219
224
|
{...props}
|
|
@@ -238,10 +243,7 @@ function MenubarSubTrigger({
|
|
|
238
243
|
<DropdownMenuSubTrigger
|
|
239
244
|
data-slot="menubar-sub-trigger"
|
|
240
245
|
data-inset={inset}
|
|
241
|
-
className={
|
|
242
|
-
"focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground gap-2 rounded-sm px-2 py-1.5 text-sm data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
|
|
243
|
-
className
|
|
244
|
-
)}
|
|
246
|
+
className={className}
|
|
245
247
|
{...props}
|
|
246
248
|
/>
|
|
247
249
|
)
|
|
@@ -255,7 +257,7 @@ function MenubarSubContent({
|
|
|
255
257
|
<DropdownMenuSubContent
|
|
256
258
|
data-slot="menubar-sub-content"
|
|
257
259
|
className={cn(
|
|
258
|
-
"
|
|
260
|
+
"min-w-32",
|
|
259
261
|
className
|
|
260
262
|
)}
|
|
261
263
|
{...props}
|
|
@@ -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
|
import { ChevronDownIcon } from "lucide-react"
|
|
8
9
|
|
|
@@ -27,10 +28,10 @@ function NativeSelect({
|
|
|
27
28
|
<select
|
|
28
29
|
data-slot="native-select"
|
|
29
30
|
data-size={size}
|
|
30
|
-
className="
|
|
31
|
+
className={cn(fieldSurface, "selection:bg-primary selection:text-primary-foreground h-8.5 w-full min-w-0 appearance-none py-1 pe-8 ps-2.5 text-sm select-none disabled:pointer-events-none disabled:cursor-not-allowed data-[size=sm]:h-7")}
|
|
31
32
|
{...useFieldControlProps(props)}
|
|
32
33
|
/>
|
|
33
|
-
<ChevronDownIcon className="text-muted-foreground pointer-events-none absolute top-1/2
|
|
34
|
+
<ChevronDownIcon className="text-muted-foreground pointer-events-none absolute top-1/2 end-2.5 size-4 -translate-y-1/2 select-none" aria-hidden="true" data-slot="native-select-icon" />
|
|
34
35
|
</div>
|
|
35
36
|
)
|
|
36
37
|
}
|
|
@@ -2,7 +2,9 @@ import { NavigationMenu as NavigationMenuPrimitive } from "@base-ui/react/naviga
|
|
|
2
2
|
import { cva } from "class-variance-authority"
|
|
3
3
|
|
|
4
4
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
5
|
+
import { popupMotion } from "../../lib/popup-motion.ts"
|
|
5
6
|
import { ChevronDownIcon } from "lucide-react"
|
|
7
|
+
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
6
8
|
|
|
7
9
|
function NavigationMenu({
|
|
8
10
|
align = "start",
|
|
@@ -56,7 +58,7 @@ function NavigationMenuItem({
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
const navigationMenuTriggerStyle = cva(
|
|
59
|
-
"bg-transparent hover:bg-muted focus:bg-muted data-open:hover:bg-muted data-open:focus:bg-muted data-open:bg-muted/50 focus-visible:
|
|
61
|
+
"bg-transparent hover:bg-muted focus:bg-muted data-open:hover:bg-muted data-open:focus:bg-muted data-open:bg-muted/50 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted rounded-md px-4 py-2 text-sm font-medium transition-[background-color,opacity] disabled:opacity-50 group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center disabled:pointer-events-none outline-none"
|
|
60
62
|
)
|
|
61
63
|
|
|
62
64
|
function NavigationMenuTrigger({
|
|
@@ -71,7 +73,7 @@ function NavigationMenuTrigger({
|
|
|
71
73
|
{...props}
|
|
72
74
|
>
|
|
73
75
|
{children}{" "}
|
|
74
|
-
<ChevronDownIcon className="relative top-px
|
|
76
|
+
<ChevronDownIcon className="relative top-px ms-1 size-3 transition duration-slow group-data-popup-open/navigation-menu-trigger:rotate-180" aria-hidden="true" />
|
|
75
77
|
</NavigationMenuPrimitive.Trigger>
|
|
76
78
|
)
|
|
77
79
|
}
|
|
@@ -84,7 +86,7 @@ function NavigationMenuContent({
|
|
|
84
86
|
<NavigationMenuPrimitive.Content
|
|
85
87
|
data-slot="navigation-menu-content"
|
|
86
88
|
className={cn(
|
|
87
|
-
"
|
|
89
|
+
"motion-safe:data-ending-style:data-activation-direction=left:translate-x-[50%] motion-safe:data-ending-style:data-activation-direction=right:translate-x-[-50%] motion-safe:data-starting-style:data-activation-direction=left:translate-x-[-50%] motion-safe:data-starting-style:data-activation-direction=right:translate-x-[50%] h-full w-auto p-2 pe-2.5 transition-[opacity,transform,translate] duration-popup-resize ease-out motion-reduce:transition-opacity data-ending-style:opacity-0 data-starting-style:opacity-0",
|
|
88
90
|
className
|
|
89
91
|
)}
|
|
90
92
|
{...props}
|
|
@@ -100,20 +102,23 @@ function NavigationMenuPositioner({
|
|
|
100
102
|
alignOffset = 0,
|
|
101
103
|
...props
|
|
102
104
|
}: NavigationMenuPrimitive.Positioner.Props) {
|
|
105
|
+
const dir = usePopupDir()
|
|
103
106
|
return (
|
|
104
107
|
<NavigationMenuPrimitive.Portal>
|
|
105
108
|
<NavigationMenuPrimitive.Positioner
|
|
109
|
+
dir={dir}
|
|
106
110
|
side={side}
|
|
107
111
|
sideOffset={sideOffset}
|
|
108
112
|
align={align}
|
|
109
113
|
alignOffset={alignOffset}
|
|
110
114
|
className={cn(
|
|
111
|
-
"isolate z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom] duration-
|
|
115
|
+
"isolate z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom] duration-popup-resize ease-out data-instant:transition-none motion-reduce:transition-none data-[side=bottom]:before:top-[-10px] data-[side=bottom]:before:right-0 data-[side=bottom]:before:left-0",
|
|
112
116
|
className
|
|
113
117
|
)}
|
|
114
118
|
{...props}
|
|
115
119
|
>
|
|
116
|
-
|
|
120
|
+
{/* Opens with popupMotion. While open, it resizes to the next item's content in `popup-resize` (350ms). */}
|
|
121
|
+
<NavigationMenuPrimitive.Popup className={cn("bg-popover text-popover-foreground shadow-overlay xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) rounded-xl outline-none", popupMotion, "transition-[opacity,scale,translate,width,height] [transition-duration:var(--transition-duration-popup-fade),var(--transition-duration-normal),var(--transition-duration-normal),var(--transition-duration-popup-resize),var(--transition-duration-popup-resize)] motion-reduce:transition-opacity")}>
|
|
117
122
|
<NavigationMenuPrimitive.Viewport className="relative size-full overflow-hidden" />
|
|
118
123
|
</NavigationMenuPrimitive.Popup>
|
|
119
124
|
</NavigationMenuPrimitive.Positioner>
|
|
@@ -132,7 +137,7 @@ function NavigationMenuLink({
|
|
|
132
137
|
<NavigationMenuPrimitive.Link
|
|
133
138
|
data-slot="navigation-menu-link"
|
|
134
139
|
className={cn(
|
|
135
|
-
"data-active:text-foreground data-active:font-medium focus-visible:
|
|
140
|
+
"data-active:text-foreground data-active:font-medium focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-sm p-2 text-sm transition-[color,background-color] outline-none [&_svg:not([class*='size-'])]:size-4 after:bg-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:opacity-0 after:transition-opacity data-active:after:opacity-100",
|
|
136
141
|
className
|
|
137
142
|
)}
|
|
138
143
|
{...props}
|
|
@@ -146,12 +151,12 @@ function NavigationMenuIndicator({
|
|
|
146
151
|
}: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.Icon>) {
|
|
147
152
|
// Base UI's Icon emits data-popup-open while its item's popup is open (never Radix-style
|
|
148
153
|
// data-[state=...]) and stays mounted when closed with no closed/ending attribute, so the
|
|
149
|
-
// closed state is hidden via opacity
|
|
154
|
+
// closed state is hidden via opacity, faded in step with the popup
|
|
150
155
|
return (
|
|
151
156
|
<NavigationMenuPrimitive.Icon
|
|
152
157
|
data-slot="navigation-menu-indicator"
|
|
153
158
|
className={cn(
|
|
154
|
-
"
|
|
159
|
+
"transition-opacity duration-popup-fade ease-out not-data-popup-open:opacity-0 top-full z-1 flex h-1.5 items-end justify-center overflow-hidden",
|
|
155
160
|
className
|
|
156
161
|
)}
|
|
157
162
|
{...props}
|
|
@@ -71,7 +71,7 @@ function PaginationPrevious({
|
|
|
71
71
|
<PaginationLink
|
|
72
72
|
aria-label="Go to previous page"
|
|
73
73
|
size="default"
|
|
74
|
-
className={cn("
|
|
74
|
+
className={cn("ps-2!", className)}
|
|
75
75
|
{...props}
|
|
76
76
|
>
|
|
77
77
|
<ChevronLeftIcon data-icon="inline-start" />
|
|
@@ -89,7 +89,7 @@ function PaginationNext({
|
|
|
89
89
|
<PaginationLink
|
|
90
90
|
aria-label="Go to next page"
|
|
91
91
|
size="default"
|
|
92
|
-
className={cn("
|
|
92
|
+
className={cn("pe-2!", className)}
|
|
93
93
|
{...props}
|
|
94
94
|
>
|
|
95
95
|
<span className="hidden sm:block">{text}</span>
|
|
@@ -4,6 +4,10 @@ import * as React from "react"
|
|
|
4
4
|
import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
+
import { popupMotion } from "../../lib/popup-motion.ts"
|
|
8
|
+
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
9
|
+
import { usePopupAlign } from "../../lib/popup-align.ts"
|
|
10
|
+
import { triggerSlot } from "../../lib/trigger-slot.ts"
|
|
7
11
|
|
|
8
12
|
function Popover({ ...props }: PopoverPrimitive.Root.Props) {
|
|
9
13
|
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
|
@@ -14,34 +18,53 @@ function PopoverPortal({ ...props }: PopoverPrimitive.Portal.Props) {
|
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
|
|
17
|
-
return <PopoverPrimitive.Trigger
|
|
21
|
+
return <PopoverPrimitive.Trigger {...triggerSlot("popover-trigger", props.render)} {...props} />
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Without an `align`, the popover opens toward the centre of the screen: a
|
|
26
|
+
* trigger in the right half lines the popover up with its right edge, so it
|
|
27
|
+
* grows to the left and stays on screen, and a trigger in the left half lines
|
|
28
|
+
* it up with its left edge. The side is picked each time it opens. A popover
|
|
29
|
+
* that opens to the left or right of its trigger keeps "start". An explicit
|
|
30
|
+
* `align` always wins. Do not set `align` unless there is a reason.
|
|
31
|
+
*
|
|
32
|
+
* `anchor` positions a popover that has no trigger against another element,
|
|
33
|
+
* e.g. an editor opened from an applied-filter chip.
|
|
34
|
+
*/
|
|
20
35
|
function PopoverContent({
|
|
21
36
|
className,
|
|
22
|
-
align
|
|
37
|
+
align,
|
|
38
|
+
ref,
|
|
23
39
|
alignOffset = 0,
|
|
24
40
|
side = "bottom",
|
|
25
|
-
sideOffset =
|
|
41
|
+
sideOffset = 6,
|
|
42
|
+
anchor,
|
|
26
43
|
...props
|
|
27
44
|
}: PopoverPrimitive.Popup.Props &
|
|
28
45
|
Pick<
|
|
29
46
|
PopoverPrimitive.Positioner.Props,
|
|
30
|
-
"align" | "alignOffset" | "side" | "sideOffset"
|
|
47
|
+
"align" | "alignOffset" | "side" | "sideOffset" | "anchor"
|
|
31
48
|
>) {
|
|
49
|
+
const dir = usePopupDir()
|
|
50
|
+
const { popupRef, align: positionAlign } = usePopupAlign(align, side, ref)
|
|
32
51
|
return (
|
|
33
52
|
<PopoverPrimitive.Portal>
|
|
34
53
|
<PopoverPrimitive.Positioner
|
|
35
|
-
|
|
54
|
+
dir={dir}
|
|
55
|
+
align={positionAlign}
|
|
36
56
|
alignOffset={alignOffset}
|
|
37
57
|
side={side}
|
|
38
58
|
sideOffset={sideOffset}
|
|
59
|
+
anchor={anchor}
|
|
39
60
|
className="isolate z-50"
|
|
40
61
|
>
|
|
41
62
|
<PopoverPrimitive.Popup
|
|
63
|
+
ref={popupRef}
|
|
42
64
|
data-slot="popover-content"
|
|
43
65
|
className={cn(
|
|
44
|
-
"bg-popover text-popover-foreground
|
|
66
|
+
"bg-popover text-popover-foreground shadow-overlay z-50 flex w-72 flex-col gap-4 rounded-xl p-4 text-sm outline-hidden",
|
|
67
|
+
popupMotion,
|
|
45
68
|
className
|
|
46
69
|
)}
|
|
47
70
|
{...props}
|
|
@@ -1,25 +1,44 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import type * as React from "react"
|
|
3
4
|
import { Progress as ProgressPrimitive } from "@base-ui/react/progress"
|
|
4
|
-
import { cva
|
|
5
|
+
import { cva } from "class-variance-authority"
|
|
5
6
|
|
|
7
|
+
import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
|
|
6
8
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
9
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// tone
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
10
|
+
// Progress takes the glossary tones (`Tone`) plus `default`, the primary fill
|
|
11
|
+
// of a task bar. Every tone sits on one 4px track in the `accent` tint and
|
|
12
|
+
// fills with the tone's text slot, so a done step reads green and a failed one
|
|
13
|
+
// red. As everywhere, `critical` renders with the `destructive` slots and
|
|
14
|
+
// `progress`, the running step, with the `info` slots. `neutral` is a stopped
|
|
15
|
+
// step that needs nothing from the user: a muted fill at 55% opacity. Each
|
|
16
|
+
// tone sets the fill as --progress-fill, so the solid bar and the
|
|
17
|
+
// indeterminate band share one colour.
|
|
14
18
|
const progressTrackVariants = cva(
|
|
15
|
-
"relative flex h-1
|
|
19
|
+
"relative flex h-1 w-full items-center overflow-hidden rounded-full bg-accent"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// A known value is a full-width fill scaled to the value (--progress-scale,
|
|
23
|
+
// set by Progress), so the bar grows with a transform: from 0 when it first
|
|
24
|
+
// shows, and to each new value. With `value={null}` the bar is indeterminate:
|
|
25
|
+
// a 40% fill with a band that sweeps across at a constant speed. Both run from
|
|
26
|
+
// the start side: in a right-to-left layout the fill grows from the right and
|
|
27
|
+
// the band plays its sweep in reverse. The reverse class repeats the sweep's
|
|
28
|
+
// variants so it sorts after the `animation` shorthand that would reset it.
|
|
29
|
+
// Under reduced motion the fill shows at once and the band is gone.
|
|
30
|
+
const progressIndicatorVariants = cva(
|
|
31
|
+
"relative h-full origin-left rtl:origin-right overflow-hidden bg-(--progress-fill) scale-x-(--progress-scale,1) motion-safe:transition-[scale] motion-safe:duration-progress-fill motion-safe:ease-out motion-safe:not-data-indeterminate:starting:scale-x-0 data-indeterminate:w-full data-indeterminate:bg-(--progress-fill)/40 motion-safe:data-indeterminate:after:absolute motion-safe:data-indeterminate:after:inset-y-0 motion-safe:data-indeterminate:after:left-0 motion-safe:data-indeterminate:after:w-2/5 motion-safe:data-indeterminate:after:bg-linear-to-r motion-safe:data-indeterminate:after:from-transparent motion-safe:data-indeterminate:after:via-(--progress-fill) motion-safe:data-indeterminate:after:to-transparent motion-safe:data-indeterminate:after:animate-progress-sweep motion-safe:data-indeterminate:rtl:after:[animation-direction:reverse]",
|
|
16
32
|
{
|
|
17
33
|
variants: {
|
|
18
34
|
tone: {
|
|
19
|
-
default: "
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
default: "[--progress-fill:var(--primary)]",
|
|
36
|
+
info: "[--progress-fill:var(--info-text)]",
|
|
37
|
+
progress: "[--progress-fill:var(--info-text)]",
|
|
38
|
+
success: "[--progress-fill:var(--success-text)]",
|
|
39
|
+
warning: "[--progress-fill:var(--warning-text)]",
|
|
40
|
+
critical: "[--progress-fill:var(--destructive-text)]",
|
|
41
|
+
neutral: "opacity-55 [--progress-fill:var(--muted-foreground)]",
|
|
23
42
|
},
|
|
24
43
|
},
|
|
25
44
|
defaultVariants: {
|
|
@@ -28,45 +47,38 @@ const progressTrackVariants = cva(
|
|
|
28
47
|
}
|
|
29
48
|
)
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
variants: {
|
|
33
|
-
tone: {
|
|
34
|
-
default: "bg-primary",
|
|
35
|
-
success: "bg-success-600 dark:bg-success-subtle-foreground",
|
|
36
|
-
warning: "bg-warning-600 dark:bg-warning-subtle-foreground",
|
|
37
|
-
critical: "bg-destructive-600 dark:bg-destructive-subtle-foreground",
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
defaultVariants: {
|
|
41
|
-
tone: "default",
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
type ProgressTone = NonNullable<
|
|
46
|
-
VariantProps<typeof progressIndicatorVariants>["tone"]
|
|
47
|
-
>
|
|
50
|
+
type ProgressTone = Tone | "default"
|
|
48
51
|
|
|
49
52
|
function Progress({
|
|
50
53
|
className,
|
|
51
54
|
children,
|
|
52
55
|
value,
|
|
56
|
+
min = 0,
|
|
57
|
+
max = 100,
|
|
53
58
|
tone = "default",
|
|
54
59
|
...props
|
|
55
60
|
}: ProgressPrimitive.Root.Props & {
|
|
56
61
|
/** Indicator tone. Follows consequence: see the Progress guidance. */
|
|
57
62
|
tone?: ProgressTone
|
|
58
63
|
}) {
|
|
64
|
+
const scale =
|
|
65
|
+
value == null ? 1 : Math.min(1, Math.max(0, (value - min) / (max - min || 1)))
|
|
59
66
|
return (
|
|
60
67
|
<ProgressPrimitive.Root
|
|
61
68
|
value={value}
|
|
69
|
+
min={min}
|
|
70
|
+
max={max}
|
|
62
71
|
data-slot="progress"
|
|
63
72
|
data-tone={tone}
|
|
64
73
|
className={cn("flex flex-wrap gap-3", className)}
|
|
65
74
|
{...props}
|
|
66
75
|
>
|
|
67
76
|
{children}
|
|
68
|
-
<ProgressTrack
|
|
69
|
-
|
|
77
|
+
<ProgressTrack
|
|
78
|
+
tone={tone}
|
|
79
|
+
style={{ "--progress-scale": scale } as React.CSSProperties}
|
|
80
|
+
>
|
|
81
|
+
<ProgressIndicator tone={tone} className="w-full!" />
|
|
70
82
|
</ProgressTrack>
|
|
71
83
|
</ProgressPrimitive.Root>
|
|
72
84
|
)
|
|
@@ -79,8 +91,9 @@ function ProgressTrack({
|
|
|
79
91
|
}: ProgressPrimitive.Track.Props & { tone?: ProgressTone }) {
|
|
80
92
|
return (
|
|
81
93
|
<ProgressPrimitive.Track
|
|
82
|
-
className={cn(progressTrackVariants(
|
|
94
|
+
className={cn(progressTrackVariants(), className)}
|
|
83
95
|
data-slot="progress-track"
|
|
96
|
+
data-tone={tone}
|
|
84
97
|
{...props}
|
|
85
98
|
/>
|
|
86
99
|
)
|
|
@@ -114,7 +127,7 @@ function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {
|
|
|
114
127
|
return (
|
|
115
128
|
<ProgressPrimitive.Value
|
|
116
129
|
className={cn(
|
|
117
|
-
"text-muted-foreground
|
|
130
|
+
"text-muted-foreground ms-auto text-sm tabular-nums",
|
|
118
131
|
className
|
|
119
132
|
)}
|
|
120
133
|
data-slot="progress-value"
|
|
@@ -4,7 +4,10 @@ import { Radio as RadioPrimitive } from "@base-ui/react/radio"
|
|
|
4
4
|
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useFieldControlProps,
|
|
9
|
+
useFieldLabelCheckedClass,
|
|
10
|
+
} from "@vendure-io/ui/components/atoms/field"
|
|
8
11
|
|
|
9
12
|
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
|
|
10
13
|
return (
|
|
@@ -17,12 +20,14 @@ function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
|
|
23
|
+
const fieldLabelChecked = useFieldLabelCheckedClass()
|
|
20
24
|
return (
|
|
21
25
|
<RadioPrimitive.Root
|
|
22
26
|
data-slot="radio-group-item"
|
|
23
|
-
className={cn(
|
|
24
|
-
"border-control-border dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:
|
|
25
|
-
|
|
27
|
+
className={(state) => cn(
|
|
28
|
+
"border-control-border dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive 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 group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:ring-3",
|
|
29
|
+
fieldLabelChecked(state.checked),
|
|
30
|
+
typeof className === "function" ? className(state) : className
|
|
26
31
|
)}
|
|
27
32
|
{...props}
|
|
28
33
|
>
|
|
@@ -35,7 +35,7 @@ function ResizableHandle({
|
|
|
35
35
|
<ResizablePrimitive.Separator
|
|
36
36
|
data-slot="resizable-handle"
|
|
37
37
|
className={cn(
|
|
38
|
-
"bg-border focus-visible:
|
|
38
|
+
"bg-border focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",
|
|
39
39
|
className
|
|
40
40
|
)}
|
|
41
41
|
{...props}
|
|
@@ -17,7 +17,7 @@ function ScrollArea({
|
|
|
17
17
|
>
|
|
18
18
|
<ScrollAreaPrimitive.Viewport
|
|
19
19
|
data-slot="scroll-area-viewport"
|
|
20
|
-
className="focus-visible:
|
|
20
|
+
className="focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring size-full rounded-[inherit] outline-none"
|
|
21
21
|
>
|
|
22
22
|
{children}
|
|
23
23
|
</ScrollAreaPrimitive.Viewport>
|
|
@@ -41,7 +41,7 @@ function ScrollBar({
|
|
|
41
41
|
// Overlay scrollbars: invisible at rest, fade in while the pointer is over
|
|
42
42
|
// the scroll area (data-hovering) or during active scrolling (data-scrolling).
|
|
43
43
|
// Base UI omits data-scrolling on programmatic scrolls, so route changes don't flash.
|
|
44
|
-
"flex touch-none p-px select-none opacity-0 transition-opacity data-hovering:opacity-100 data-scrolling:opacity-100 data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-
|
|
44
|
+
"flex touch-none p-px select-none opacity-0 transition-opacity data-hovering:opacity-100 data-scrolling:opacity-100 data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-s data-vertical:border-s-transparent",
|
|
45
45
|
className
|
|
46
46
|
)}
|
|
47
47
|
{...props}
|