@vendure-io/ui 2.1.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.
Files changed (118) hide show
  1. package/package.json +19 -5
  2. package/src/components/atoms/accordion.tsx +21 -6
  3. package/src/components/atoms/alert-dialog.tsx +31 -6
  4. package/src/components/atoms/alert.tsx +73 -13
  5. package/src/components/atoms/avatar.tsx +1 -1
  6. package/src/components/atoms/badge.tsx +7 -2
  7. package/src/components/atoms/breadcrumb.tsx +137 -4
  8. package/src/components/atoms/button-group.tsx +30 -6
  9. package/src/components/atoms/button.tsx +128 -18
  10. package/src/components/atoms/calendar.tsx +6 -6
  11. package/src/components/atoms/card.tsx +130 -16
  12. package/src/components/atoms/carousel.tsx +16 -9
  13. package/src/components/atoms/chart.tsx +87 -1
  14. package/src/components/atoms/checkbox.tsx +85 -7
  15. package/src/components/atoms/collapsible.tsx +2 -1
  16. package/src/components/atoms/combobox.tsx +147 -21
  17. package/src/components/atoms/command.tsx +414 -12
  18. package/src/components/atoms/context-menu.tsx +28 -23
  19. package/src/components/atoms/dialog.tsx +151 -29
  20. package/src/components/atoms/direction.tsx +23 -2
  21. package/src/components/atoms/drawer.tsx +15 -10
  22. package/src/components/atoms/dropdown-menu.tsx +43 -28
  23. package/src/components/atoms/empty.tsx +4 -0
  24. package/src/components/atoms/field.tsx +41 -15
  25. package/src/components/atoms/hover-card.tsx +61 -8
  26. package/src/components/atoms/input-group.tsx +17 -9
  27. package/src/components/atoms/input-otp.tsx +6 -6
  28. package/src/components/atoms/input.tsx +7 -1
  29. package/src/components/atoms/item.tsx +3 -3
  30. package/src/components/atoms/kbd.tsx +32 -3
  31. package/src/components/atoms/label-swap.tsx +82 -0
  32. package/src/components/atoms/label.tsx +1 -1
  33. package/src/components/atoms/menubar.tsx +28 -26
  34. package/src/components/atoms/native-select.tsx +3 -2
  35. package/src/components/atoms/navigation-menu.tsx +13 -8
  36. package/src/components/atoms/pagination.tsx +2 -2
  37. package/src/components/atoms/popover.tsx +23 -5
  38. package/src/components/atoms/progress.tsx +46 -33
  39. package/src/components/atoms/radio-group.tsx +9 -4
  40. package/src/components/atoms/resizable.tsx +1 -1
  41. package/src/components/atoms/scroll-area.tsx +2 -2
  42. package/src/components/atoms/select.tsx +258 -19
  43. package/src/components/atoms/sheet.tsx +59 -23
  44. package/src/components/atoms/sidebar.tsx +333 -23
  45. package/src/components/atoms/skeleton.tsx +1 -1
  46. package/src/components/atoms/slider.tsx +1 -1
  47. package/src/components/atoms/sonner.tsx +128 -38
  48. package/src/components/atoms/spinner.tsx +1 -1
  49. package/src/components/atoms/switch.tsx +10 -5
  50. package/src/components/atoms/table.tsx +147 -7
  51. package/src/components/atoms/tabs.tsx +3 -3
  52. package/src/components/atoms/textarea.tsx +3 -1
  53. package/src/components/atoms/toggle-group.tsx +4 -2
  54. package/src/components/atoms/toggle.tsx +28 -6
  55. package/src/components/atoms/tooltip.tsx +85 -15
  56. package/src/components/molecules/anonymized-token.tsx +24 -8
  57. package/src/components/molecules/app-shell.tsx +53 -20
  58. package/src/components/molecules/arrow-link.tsx +40 -0
  59. package/src/components/molecules/chip.tsx +2 -2
  60. package/src/components/molecules/code-block.tsx +54 -31
  61. package/src/components/molecules/collapsible-section.tsx +129 -0
  62. package/src/components/molecules/confirm-dialog.tsx +113 -9
  63. package/src/components/molecules/copyable-text.tsx +75 -11
  64. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
  65. package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
  66. package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
  67. package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
  68. package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
  69. package/src/components/molecules/data-table/data-table-types.tsx +138 -4
  70. package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
  71. package/src/components/molecules/data-table/data-table.tsx +916 -84
  72. package/src/components/molecules/data-table/table-pagination.tsx +2 -2
  73. package/src/components/molecules/date-picker.tsx +13 -7
  74. package/src/components/molecules/date-range-picker.tsx +13 -6
  75. package/src/components/molecules/date-time-picker.tsx +13 -7
  76. package/src/components/molecules/date-time.tsx +8 -1
  77. package/src/components/molecules/direction-link.tsx +130 -0
  78. package/src/components/molecules/elapsed-time.tsx +223 -0
  79. package/src/components/molecules/file-dropzone.tsx +2 -2
  80. package/src/components/molecules/id-chip.tsx +169 -32
  81. package/src/components/molecules/inline-code.tsx +4 -0
  82. package/src/components/molecules/issued-secret.tsx +318 -0
  83. package/src/components/molecules/list-row.tsx +349 -0
  84. package/src/components/molecules/live-indicator.tsx +83 -0
  85. package/src/components/molecules/page-header.tsx +117 -5
  86. package/src/components/molecules/password-input.tsx +2 -2
  87. package/src/components/molecules/relative-time.tsx +85 -56
  88. package/src/components/molecules/search-trigger.tsx +127 -0
  89. package/src/components/molecules/secret-value.tsx +26 -9
  90. package/src/components/molecules/skip-link.tsx +1 -1
  91. package/src/components/molecules/stat-card.tsx +4 -4
  92. package/src/components/molecules/state-views/empty-state.tsx +35 -17
  93. package/src/components/molecules/state-views/error-state.tsx +32 -14
  94. package/src/components/molecules/status-badge.tsx +415 -49
  95. package/src/components/molecules/time-tooltip.tsx +140 -0
  96. package/src/components/molecules/timeline.tsx +246 -0
  97. package/src/components/molecules/visibility-icon.tsx +89 -0
  98. package/src/hooks/use-active-label-size.ts +32 -0
  99. package/src/hooks/use-pinned-height.ts +55 -0
  100. package/src/hooks/use-scrolled.ts +27 -0
  101. package/src/lib/content-inset.ts +17 -0
  102. package/src/lib/control-name.ts +55 -0
  103. package/src/lib/dialog-padding.ts +48 -0
  104. package/src/lib/field-surface.ts +31 -0
  105. package/src/lib/format-elapsed.ts +67 -0
  106. package/src/lib/format-relative.ts +29 -1
  107. package/src/lib/highlight.ts +3 -3
  108. package/src/lib/menu-item.tsx +72 -0
  109. package/src/lib/outline-edge.ts +21 -0
  110. package/src/lib/popup-align.ts +67 -0
  111. package/src/lib/popup-direction.ts +22 -0
  112. package/src/lib/popup-motion.ts +19 -0
  113. package/src/lib/state-dictionary.ts +42 -6
  114. package/src/lib/syntax-colors.ts +8 -0
  115. package/src/lib/tint-recipes.ts +68 -0
  116. package/src/lib/tone-icons.ts +24 -0
  117. package/src/lib/trigger-slot.ts +16 -0
  118. package/src/lib/utils.ts +104 -1
@@ -20,7 +20,7 @@ import {
20
20
  DropdownMenuSubTrigger,
21
21
  DropdownMenuTrigger,
22
22
  } from "@vendure-io/ui/components/atoms/dropdown-menu"
23
- import { CheckIcon } from "lucide-react"
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 = "start",
73
- alignOffset = -4,
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("bg-popover text-popover-foreground data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 min-w-36 rounded-md p-1 shadow-md ring-1 motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in)", className )}
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
- "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive-subtle-foreground data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive-subtle-foreground data-[variant=destructive]:*:[svg]:text-destructive-subtle-foreground! not-data-[variant=destructive]:focus:**:text-accent-foreground group/menubar-item gap-2 rounded-sm px-2 py-1.5 text-sm data-disabled:opacity-50 data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
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
- "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",
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 left-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
130
- <MenuPrimitive.CheckboxItemIndicator>
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
- "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
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 left-2 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
165
- <MenuPrimitive.RadioItemIndicator>
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:pl-8",
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={cn("bg-border -mx-1 my-1 h-px", 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 ml-auto text-xs tracking-widest",
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={cn(
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
- "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-32 rounded-md p-1 shadow-lg ring-1 motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in)",
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="border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive h-9 w-full min-w-0 appearance-none rounded-md border bg-transparent py-1 pr-8 pl-2.5 text-sm transition-[color,box-shadow] outline-none select-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:ring-3 data-[size=sm]:h-8"
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 right-2.5 size-4 -translate-y-1/2 select-none" aria-hidden="true" data-slot="native-select-icon" />
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:ring-ring data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted rounded-md px-4 py-2 text-sm font-medium transition-all focus-visible:ring-2 disabled:opacity-50 group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center disabled:pointer-events-none outline-none"
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 ml-1 size-3 transition duration-300 group-data-open/navigation-menu-trigger:rotate-180 group-data-popup-open/navigation-menu-trigger:rotate-180" aria-hidden="true" />
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
- "data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-open:animate-in group-data-[viewport=false]/navigation-menu:data-closed:animate-out group-data-[viewport=false]/navigation-menu:data-closed:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-open:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-open:fade-in-0 group-data-[viewport=false]/navigation-menu:data-closed:fade-out-0 group-data-[viewport=false]/navigation-menu:ring-foreground/10 data-ending-style:data-activation-direction=left:translate-x-[50%] data-ending-style:data-activation-direction=right:translate-x-[-50%] data-starting-style:data-activation-direction=left:translate-x-[-50%] data-starting-style:data-activation-direction=right:translate-x-[50%] h-full w-auto p-2 pr-2.5 transition-[opacity,transform,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:animate-none motion-reduce:transition-none group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:ring-1 group-data-[viewport=false]/navigation-menu:data-open:duration-(--transition-duration-normal) group-data-[viewport=false]/navigation-menu:data-open:ease-(--ease-out) group-data-[viewport=false]/navigation-menu:data-closed:duration-(--transition-duration-fast) group-data-[viewport=false]/navigation-menu:data-closed:ease-(--ease-in) data-ending-style:opacity-0 data-starting-style:opacity-0 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none",
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-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] 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",
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
- <NavigationMenuPrimitive.Popup className="bg-popover text-popover-foreground ring-foreground/10 data-[ending-style]:easing-[ease] xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) origin-(--transform-origin) rounded-lg shadow ring-1 transition-[opacity,transform,width,height,scale,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] outline-none motion-reduce:transition-none data-ending-style:scale-90 data-ending-style:opacity-0 data-ending-style:duration-(--transition-duration-fast) data-ending-style:ease-(--ease-in) data-starting-style:scale-90 data-starting-style:opacity-0">
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:ring-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-2 [&_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",
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 instead of an exit animation
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
- "data-popup-open:animate-in data-popup-open:fade-in not-data-popup-open:opacity-0 motion-reduce:animate-none top-full z-1 flex h-1.5 items-end justify-center overflow-hidden",
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("pl-2!", className)}
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("pr-2!", className)}
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,48 @@ function PopoverPortal({ ...props }: PopoverPrimitive.Portal.Props) {
14
18
  }
15
19
 
16
20
  function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
17
- return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
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
+ */
20
32
  function PopoverContent({
21
33
  className,
22
- align = "center",
34
+ align,
35
+ ref,
23
36
  alignOffset = 0,
24
37
  side = "bottom",
25
- sideOffset = 4,
38
+ sideOffset = 6,
26
39
  ...props
27
40
  }: PopoverPrimitive.Popup.Props &
28
41
  Pick<
29
42
  PopoverPrimitive.Positioner.Props,
30
43
  "align" | "alignOffset" | "side" | "sideOffset"
31
44
  >) {
45
+ const dir = usePopupDir()
46
+ const { popupRef, align: positionAlign } = usePopupAlign(align, side, ref)
32
47
  return (
33
48
  <PopoverPrimitive.Portal>
34
49
  <PopoverPrimitive.Positioner
35
- align={align}
50
+ dir={dir}
51
+ align={positionAlign}
36
52
  alignOffset={alignOffset}
37
53
  side={side}
38
54
  sideOffset={sideOffset}
39
55
  className="isolate z-50"
40
56
  >
41
57
  <PopoverPrimitive.Popup
58
+ ref={popupRef}
42
59
  data-slot="popover-content"
43
60
  className={cn(
44
- "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md p-4 text-sm shadow-md ring-1 outline-hidden motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in)",
61
+ "bg-popover text-popover-foreground shadow-overlay z-50 flex w-72 flex-col gap-4 rounded-xl p-4 text-sm outline-hidden",
62
+ popupMotion,
45
63
  className
46
64
  )}
47
65
  {...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, type VariantProps } from "class-variance-authority"
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
- // Tone names follow the state dictionary; `critical` renders with the
9
- // `destructive` slots. A toned bar sits on the tone's subtle track. The solid
10
- // tone slots are too close to the neutral track in luminance (down to 1.1:1),
11
- // so the fill uses a fixed ramp step in light mode (600: at least 3.97:1 on the
12
- // track and 4.35:1 on the page) and the subtle foreground in dark mode (at
13
- // least 8.58:1 on the track), meeting 3:1 non-text contrast in both.
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.5 w-full items-center overflow-x-hidden rounded-full",
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: "bg-control-border",
20
- success: "bg-success-subtle",
21
- warning: "bg-warning-subtle",
22
- critical: "bg-destructive-subtle",
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
- const progressIndicatorVariants = cva("h-full transition-all", {
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 tone={tone}>
69
- <ProgressIndicator tone={tone} />
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({ tone }), className)}
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 ml-auto text-sm tabular-nums",
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 { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
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:border-ring focus-visible:ring-ring/50 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 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3",
25
- className
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:ring-ring ring-offset-background 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 focus-visible:ring-1 focus-visible:outline-hidden 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",
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:ring-ring size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-2"
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-l data-vertical:border-l-transparent",
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}