@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.
Files changed (120) 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 +72 -18
  5. package/src/components/atoms/avatar.tsx +12 -4
  6. package/src/components/atoms/badge.tsx +7 -2
  7. package/src/components/atoms/breadcrumb.tsx +493 -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 +358 -29
  17. package/src/components/atoms/command.tsx +336 -13
  18. package/src/components/atoms/context-menu.tsx +28 -23
  19. package/src/components/atoms/dialog.tsx +173 -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 +5 -1
  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 +19 -11
  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 +113 -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 +29 -6
  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 +76 -23
  44. package/src/components/atoms/sidebar.tsx +405 -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 +43 -4
  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 +122 -9
  63. package/src/components/molecules/copyable-text.tsx +75 -11
  64. package/src/components/molecules/count-badge.tsx +115 -0
  65. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
  66. package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
  67. package/src/components/molecules/data-table/data-table-filters.tsx +62 -22
  68. package/src/components/molecules/data-table/data-table-helpers.tsx +88 -1
  69. package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
  70. package/src/components/molecules/data-table/data-table-types.tsx +160 -4
  71. package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
  72. package/src/components/molecules/data-table/data-table.tsx +869 -81
  73. package/src/components/molecules/data-table/table-pagination.tsx +2 -2
  74. package/src/components/molecules/date-picker.tsx +13 -7
  75. package/src/components/molecules/date-range-picker.tsx +13 -6
  76. package/src/components/molecules/date-time-picker.tsx +13 -7
  77. package/src/components/molecules/date-time.tsx +8 -1
  78. package/src/components/molecules/direction-link.tsx +130 -0
  79. package/src/components/molecules/elapsed-time.tsx +223 -0
  80. package/src/components/molecules/file-dropzone.tsx +2 -2
  81. package/src/components/molecules/id-chip.tsx +169 -32
  82. package/src/components/molecules/inline-code.tsx +4 -0
  83. package/src/components/molecules/issued-secret.tsx +318 -0
  84. package/src/components/molecules/list-row.tsx +349 -0
  85. package/src/components/molecules/live-indicator.tsx +83 -0
  86. package/src/components/molecules/page-header.tsx +117 -5
  87. package/src/components/molecules/password-input.tsx +2 -2
  88. package/src/components/molecules/relative-time.tsx +85 -56
  89. package/src/components/molecules/search-trigger.tsx +111 -0
  90. package/src/components/molecules/secret-value.tsx +29 -9
  91. package/src/components/molecules/skip-link.tsx +1 -1
  92. package/src/components/molecules/stat-card.tsx +4 -4
  93. package/src/components/molecules/state-views/empty-state.tsx +35 -17
  94. package/src/components/molecules/state-views/error-state.tsx +32 -14
  95. package/src/components/molecules/status-badge.tsx +415 -49
  96. package/src/components/molecules/time-tooltip.tsx +140 -0
  97. package/src/components/molecules/timeline.tsx +246 -0
  98. package/src/components/molecules/visibility-icon.tsx +89 -0
  99. package/src/hooks/use-active-label-size.ts +66 -0
  100. package/src/hooks/use-apple-platform.ts +26 -0
  101. package/src/hooks/use-pinned-height.ts +55 -0
  102. package/src/hooks/use-scrolled.ts +27 -0
  103. package/src/lib/content-inset.ts +17 -0
  104. package/src/lib/control-name.ts +55 -0
  105. package/src/lib/dialog-padding.ts +48 -0
  106. package/src/lib/field-surface.ts +31 -0
  107. package/src/lib/format-elapsed.ts +67 -0
  108. package/src/lib/format-relative.ts +29 -1
  109. package/src/lib/highlight.ts +3 -3
  110. package/src/lib/menu-item.tsx +72 -0
  111. package/src/lib/outline-edge.ts +21 -0
  112. package/src/lib/popup-align.ts +67 -0
  113. package/src/lib/popup-direction.ts +22 -0
  114. package/src/lib/popup-motion.ts +19 -0
  115. package/src/lib/state-dictionary.ts +42 -6
  116. package/src/lib/syntax-colors.ts +8 -0
  117. package/src/lib/tint-recipes.ts +68 -0
  118. package/src/lib/tone-icons.ts +24 -0
  119. package/src/lib/trigger-slot.ts +16 -0
  120. package/src/lib/utils.ts +97 -1
@@ -3,23 +3,38 @@
3
3
  import * as React from "react"
4
4
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
5
5
 
6
+ import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
6
7
  import { cn } from "@vendure-io/ui/lib/utils"
7
8
  import { Button } from "@vendure-io/ui/components/atoms/button"
8
9
  import { XIcon } from "lucide-react"
10
+ import { usePopupDir } from "../../lib/popup-direction.ts"
11
+ import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
12
+ import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
13
+ import { triggerSlot } from "../../lib/trigger-slot.ts"
9
14
 
10
15
  function Dialog({ ...props }: DialogPrimitive.Root.Props) {
11
16
  return <DialogPrimitive.Root data-slot="dialog" {...props} />
12
17
  }
13
18
 
14
19
  function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
15
- return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
20
+ return <DialogPrimitive.Trigger {...triggerSlot("dialog-trigger", props.render)} {...props} />
16
21
  }
17
22
 
18
23
  function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
19
24
  return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
20
25
  }
21
26
 
27
+ // DialogClose and DialogFooter tell the content they are there, so a dialog
28
+ // without either shows the ✕ (DialogContent `showCloseButton`).
29
+ const DialogCloseControlContext = React.createContext<(() => () => void) | null>(null)
30
+
31
+ function useRegisterCloseControl() {
32
+ const register = React.useContext(DialogCloseControlContext)
33
+ React.useLayoutEffect(() => register?.(), [register])
34
+ }
35
+
22
36
  function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
37
+ useRegisterCloseControl()
23
38
  return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
24
39
  }
25
40
 
@@ -31,7 +46,7 @@ function DialogOverlay({
31
46
  <DialogPrimitive.Backdrop
32
47
  data-slot="dialog-overlay"
33
48
  className={cn(
34
- "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 isolate z-50 bg-scrim 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) supports-backdrop-filter:backdrop-blur-xs",
49
+ "fixed inset-0 isolate z-50 bg-scrim transition-opacity duration-dialog-scrim ease-soft data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-dialog-exit supports-backdrop-filter:backdrop-blur-[2px]",
35
50
  className
36
51
  )}
37
52
  {...props}
@@ -39,54 +54,138 @@ function DialogOverlay({
39
54
  )
40
55
  }
41
56
 
57
+ // Tells DialogHeader to host the close button, so the ✕ stays pinned with the
58
+ // header while the body scrolls.
59
+ const DialogCloseButtonContext = React.createContext(false)
60
+
61
+ function DialogCloseButton({ className }: { className?: string }) {
62
+ return (
63
+ <DialogPrimitive.Close
64
+ data-slot="dialog-close"
65
+ // top-4.5 centres the 28px button on the 24px first line of the title.
66
+ render={
67
+ <Button
68
+ variant="ghost"
69
+ className={cn("absolute top-4.5 end-3.5", className)}
70
+ size="icon-sm"
71
+ />
72
+ }
73
+ >
74
+ <XIcon
75
+ />
76
+ <span className="sr-only">Close</span>
77
+ </DialogPrimitive.Close>
78
+ )
79
+ }
80
+
81
+ // The width per size, as whole class strings so Tailwind finds them in this
82
+ // source. They sit before `className` in `cn`, so a consumer's `sm:max-w-*`
83
+ // still replaces them. Below the breakpoint a dialog is the viewport less 1rem
84
+ // on each side: `xl` waits for `lg`, where 800px fits with that margin.
85
+ const dialogSizes = {
86
+ default: "sm:max-w-110",
87
+ lg: "sm:max-w-140",
88
+ xl: "lg:max-w-200",
89
+ full: "",
90
+ } as const
91
+
42
92
  function DialogContent({
43
93
  className,
44
94
  children,
45
- showCloseButton = true,
95
+ size = "default",
96
+ showCloseButton,
97
+ overlayClassName,
98
+ style,
46
99
  ...props
47
100
  }: DialogPrimitive.Popup.Props & {
101
+ /**
102
+ * The width, by the dialog's job. `default` (440px): a confirmation or a
103
+ * form of a few fields. `lg` (560px): a form with longer fields or a short
104
+ * list. `xl` (800px): a wide form, a table or a tree. `full`: the viewport
105
+ * less 1rem on each side, for a picker or a preview. Every size shrinks to
106
+ * the viewport less that margin on a small screen.
107
+ */
108
+ size?: keyof typeof dialogSizes
109
+ /**
110
+ * Shows a ✕ in the top-right corner. Left out, the dialog shows it only
111
+ * when it holds no `DialogFooter` and no `DialogClose`: a dialog with a
112
+ * footer closes with its Cancel, Escape or a click on the backdrop, and a
113
+ * dialog without one still has a visible way to close. `true` or `false`
114
+ * wins over that.
115
+ */
48
116
  showCloseButton?: boolean
117
+ /** Classes for the backdrop behind the dialog, e.g. `bg-scrim-subtle`. */
118
+ overlayClassName?: string
49
119
  }) {
120
+ const dir = usePopupDir()
121
+ const [closeControls, setCloseControls] = React.useState(0)
122
+ const registerCloseControl = React.useCallback(() => {
123
+ setCloseControls((count) => count + 1)
124
+ return () => setCloseControls((count) => count - 1)
125
+ }, [])
126
+ const showClose = showCloseButton ?? closeControls === 0
50
127
  return (
51
128
  <DialogPortal>
52
- <DialogOverlay />
129
+ <DialogOverlay className={overlayClassName} />
130
+ {/* Enters from 4px below at 96%: opacity 200ms, scale and translate 240ms on the strong ease-out. Leaves to 98% (opacity 120ms on `ease`, scale 140ms on the strong ease-out). The scrim fades in 180ms and out in 140ms. Reduced motion keeps the fades. */}
131
+ {/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; DialogHeader and DialogFooter stick to its top and bottom edges. */}
132
+ {/* The padding is `--dialog-padding` (20px), and the pinned header and footer reach over it. Change the variable; a `p-*` or `px-*` class also sets it (dialogPaddingStyle). */}
133
+ {/* One column as wide as the space inside the padding: content wider than that shrinks or wraps inside it instead of widening the dialog past its padding. */}
134
+ {/* The scroll padding is the pinned header's and footer's measured heights plus 4px for a focus ring: a focused field scrolls clear of both. */}
53
135
  <DialogPrimitive.Popup
136
+ dir={dir}
54
137
  data-slot="dialog-content"
138
+ data-size={size}
55
139
  className={cn(
56
- "bg-overlay 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 ring-foreground/10 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm 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) outline-none sm:max-w-md",
140
+ "group/dialog-content bg-overlay shadow-overlay fixed top-1/2 left-1/2 z-50 grid grid-cols-[minmax(0,1fr)] max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-5 overflow-y-auto overscroll-contain rounded-2xl [--dialog-padding:--spacing(5)] p-(--dialog-padding) [scroll-padding-block:calc(var(--pinned-header-height,0px)+--spacing(1))_calc(var(--pinned-footer-height,0px)+--spacing(1))] text-sm transition-[opacity,scale,translate] duration-[var(--transition-duration-normal),var(--transition-duration-dialog-enter),var(--transition-duration-dialog-enter)] ease-out data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-[var(--transition-duration-quick),var(--transition-duration-dialog-exit),var(--transition-duration-dialog-exit)] data-ending-style:ease-[var(--ease-soft),var(--ease-out),var(--ease-out)] motion-safe:data-starting-style:scale-96 motion-safe:data-starting-style:translate-y-[calc(-50%+4px)] motion-safe:data-ending-style:scale-98 outline-none",
141
+ dialogSizes[size],
57
142
  className
58
143
  )}
144
+ style={dialogPaddingStyle(className, style)}
59
145
  {...props}
60
146
  >
61
- {children}
62
- {showCloseButton && (
63
- <DialogPrimitive.Close
64
- data-slot="dialog-close"
65
- render={
66
- <Button
67
- variant="ghost"
68
- className="absolute top-4 right-4"
69
- size="icon-sm"
70
- />
71
- }
72
- >
73
- <XIcon
74
- />
75
- <span className="sr-only">Close</span>
76
- </DialogPrimitive.Close>
147
+ <DialogCloseControlContext.Provider value={registerCloseControl}>
148
+ <DialogCloseButtonContext.Provider value={showClose}>
149
+ {children}
150
+ </DialogCloseButtonContext.Provider>
151
+ </DialogCloseControlContext.Provider>
152
+ {/* A dialog without a DialogHeader keeps the ✕ here, in the corner. */}
153
+ {showClose && (
154
+ <DialogCloseButton className="group-has-data-[slot=dialog-header]/dialog-content:hidden" />
77
155
  )}
78
156
  </DialogPrimitive.Popup>
79
157
  </DialogPortal>
80
158
  )
81
159
  }
82
160
 
83
- function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
161
+ // The header and the footer reach over the dialog's padding (`--dialog-padding`)
162
+ // and 16px of the 20px gap beside them, with the dialog's surface behind, so a
163
+ // scrolled body passes under them and stays clear of their text. The 4px left
164
+ // of the gap keeps a field's focus ring visible. The margins cancel the
165
+ // paddings: a short dialog keeps its layout. The sticky offsets are negative
166
+ // because a sticky box sticks inside the scroll container's padding. Each
167
+ // measures its height for the content's scroll padding (usePinnedHeight).
168
+ const pinned = "sticky z-10 -mx-(--dialog-padding) bg-overlay px-(--dialog-padding)"
169
+
170
+ function DialogHeader({ className, children, ref, ...props }: React.ComponentProps<"div">) {
171
+ const showCloseButton = React.useContext(DialogCloseButtonContext)
172
+ const pinnedRef = usePinnedHeight("--pinned-header-height", "dialog-content", ref)
84
173
  return (
85
174
  <div
175
+ ref={pinnedRef}
86
176
  data-slot="dialog-header"
87
- className={cn("flex flex-col gap-2", className)}
177
+ className={cn(
178
+ pinned,
179
+ "-top-(--dialog-padding) -mt-(--dialog-padding) -mb-4 flex flex-col gap-2.5 pt-(--dialog-padding) pb-4",
180
+ // The text stops before the close button, so a long title wraps instead of running under it.
181
+ showCloseButton && "pe-14",
182
+ className
183
+ )}
88
184
  {...props}
89
- />
185
+ >
186
+ {children}
187
+ {showCloseButton && <DialogCloseButton />}
188
+ </div>
90
189
  )
91
190
  }
92
191
 
@@ -94,15 +193,20 @@ function DialogFooter({
94
193
  className,
95
194
  showCloseButton = false,
96
195
  children,
196
+ ref,
97
197
  ...props
98
198
  }: React.ComponentProps<"div"> & {
99
199
  showCloseButton?: boolean
100
200
  }) {
201
+ useRegisterCloseControl()
202
+ const pinnedRef = usePinnedHeight("--pinned-footer-height", "dialog-content", ref)
101
203
  return (
102
204
  <div
205
+ ref={pinnedRef}
103
206
  data-slot="dialog-footer"
104
207
  className={cn(
105
- "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
208
+ pinned,
209
+ "-bottom-(--dialog-padding) -mt-4 -mb-(--dialog-padding) flex flex-col-reverse gap-2 pt-4 pb-(--dialog-padding) sm:flex-row sm:justify-end",
106
210
  className
107
211
  )}
108
212
  {...props}
@@ -117,13 +221,53 @@ function DialogFooter({
117
221
  )
118
222
  }
119
223
 
120
- function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
224
+ // The colour of the title icon per tone. Neutral is the foreground at 60%;
225
+ // info is the brand mark, as on the toast.
226
+ const titleIconTone: Record<Tone, string> = {
227
+ neutral: "text-foreground/60",
228
+ progress: "text-foreground/60",
229
+ info: "text-brand-indicator",
230
+ success: "text-success-text",
231
+ warning: "text-warning-text",
232
+ critical: "text-destructive-text",
233
+ }
234
+
235
+ function DialogTitle({
236
+ className,
237
+ icon,
238
+ tone = "neutral",
239
+ children,
240
+ ...props
241
+ }: DialogPrimitive.Title.Props & {
242
+ /** An 18px icon before the title, e.g. `<RocketIcon />`. */
243
+ icon?: React.ReactNode
244
+ /** The colour of `icon`. Neutral by default; use a tone for a state. */
245
+ tone?: Tone
246
+ }) {
121
247
  return (
122
248
  <DialogPrimitive.Title
123
249
  data-slot="dialog-title"
124
- className={cn("text-style-section-title", className)}
250
+ className={cn(
251
+ "text-style-dialog-title",
252
+ icon != null && "flex items-center gap-2.5",
253
+ className
254
+ )}
125
255
  {...props}
126
- />
256
+ >
257
+ {icon != null && (
258
+ <span
259
+ data-slot="dialog-title-icon"
260
+ aria-hidden="true"
261
+ className={cn(
262
+ "flex shrink-0 [&_svg:not([class*='size-'])]:size-4.5 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
263
+ titleIconTone[tone]
264
+ )}
265
+ >
266
+ {icon}
267
+ </span>
268
+ )}
269
+ {children}
270
+ </DialogPrimitive.Title>
127
271
  )
128
272
  }
129
273
 
@@ -135,7 +279,7 @@ function DialogDescription({
135
279
  <DialogPrimitive.Description
136
280
  data-slot="dialog-description"
137
281
  className={cn(
138
- "text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3",
282
+ "text-foreground-secondary *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3",
139
283
  className
140
284
  )}
141
285
  {...props}
@@ -1,6 +1,27 @@
1
1
  "use client"
2
2
 
3
- export {
4
- DirectionProvider,
3
+ import {
4
+ DirectionProvider as DirectionProviderPrimitive,
5
5
  useDirection,
6
6
  } from "@base-ui/react/direction-provider"
7
+
8
+ import { ProvidedDirection } from "../../lib/popup-direction.ts"
9
+
10
+ /**
11
+ * Sets the direction for Base UI behaviour (keyboard navigation, sides and
12
+ * alignment) and for every popup inside it, which renders in a portal. It does
13
+ * not set `dir` on any element: set it on `<html>`, or on the element that
14
+ * wraps the right-to-left region, so the page's own layout follows too.
15
+ */
16
+ function DirectionProvider({
17
+ direction = "ltr",
18
+ ...props
19
+ }: DirectionProviderPrimitive.Props) {
20
+ return (
21
+ <ProvidedDirection.Provider value={direction}>
22
+ <DirectionProviderPrimitive direction={direction} {...props} />
23
+ </ProvidedDirection.Provider>
24
+ )
25
+ }
26
+
27
+ export { DirectionProvider, useDirection }
@@ -4,11 +4,14 @@ import * as React from "react"
4
4
  import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
+ import { usePopupDir } from "../../lib/popup-direction.ts"
8
+ import { triggerSlot } from "../../lib/trigger-slot.ts"
7
9
 
8
10
  // Follows the shadcn base-vega Base UI drawer (upstream replaced vaul, which
9
11
  // depends on Radix). Divergences: the scrim and surface use the scrim and
10
- // overlay slots, the title uses our type style, and reduced motion turns the
11
- // transitions off.
12
+ // overlay slots, the title uses our type style, the slide uses the drawer
13
+ // easing, and reduced motion turns the slide off: the scrim and the panel fade
14
+ // in place.
12
15
 
13
16
  type DrawerContextProps = {
14
17
  hasSnapPoints: boolean
@@ -58,7 +61,7 @@ function Drawer({
58
61
  }
59
62
 
60
63
  function DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {
61
- return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
64
+ return <DrawerPrimitive.Trigger {...triggerSlot("drawer-trigger", props.render)} {...props} />
62
65
  }
63
66
 
64
67
  function DrawerPortal({ ...props }: DrawerPrimitive.Portal.Props) {
@@ -77,7 +80,7 @@ function DrawerOverlay({
77
80
  <DrawerPrimitive.Backdrop
78
81
  data-slot="drawer-overlay"
79
82
  className={cn(
80
- "fixed inset-0 z-50 min-h-dvh bg-scrim opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] transition-opacity duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] select-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-snap-points:[--drawer-overlay-min-opacity:0.5] data-starting-style:opacity-0 data-swiping:duration-0 supports-backdrop-filter:backdrop-blur-xs supports-[-webkit-touch-callout:none]:absolute motion-reduce:transition-none",
83
+ "fixed inset-0 z-50 min-h-dvh bg-scrim opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] transition-opacity duration-drawer-slide ease-drawer select-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*var(--transition-duration-drawer-swipe))] data-snap-points:[--drawer-overlay-min-opacity:0.5] data-starting-style:opacity-0 data-swiping:duration-instant supports-backdrop-filter:backdrop-blur-xs supports-[-webkit-touch-callout:none]:absolute",
81
84
  className
82
85
  )}
83
86
  {...props}
@@ -94,7 +97,7 @@ function DrawerSwipeHandle({
94
97
  data-slot="drawer-swipe-handle"
95
98
  aria-hidden="true"
96
99
  className={cn(
97
- "relative z-10 flex shrink-0 cursor-grab transition-opacity duration-200 group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-[swipe-axis=x]/drawer-popup:h-full group-data-[swipe-axis=x]/drawer-popup:w-3 group-data-[swipe-axis=x]/drawer-popup:items-center group-data-[swipe-axis=y]/drawer-popup:h-3 group-data-[swipe-axis=y]/drawer-popup:w-full group-data-[swipe-axis=y]/drawer-popup:justify-center group-data-[swipe-direction=down]/drawer-popup:items-end group-data-[swipe-direction=left]/drawer-popup:order-last group-data-[swipe-direction=left]/drawer-popup:justify-start group-data-[swipe-direction=right]/drawer-popup:justify-end group-data-[swipe-direction=up]/drawer-popup:order-last group-data-[swipe-direction=up]/drawer-popup:items-start after:block after:shrink-0 after:rounded-full after:bg-muted group-data-[swipe-axis=x]/drawer-popup:after:h-[100px] group-data-[swipe-axis=x]/drawer-popup:after:w-1.5 group-data-[swipe-axis=y]/drawer-popup:after:h-1.5 group-data-[swipe-axis=y]/drawer-popup:after:w-[100px] active:cursor-grabbing",
100
+ "relative z-10 flex shrink-0 cursor-grab transition-opacity duration-normal group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-[swipe-axis=x]/drawer-popup:h-full group-data-[swipe-axis=x]/drawer-popup:w-3 group-data-[swipe-axis=x]/drawer-popup:items-center group-data-[swipe-axis=y]/drawer-popup:h-3 group-data-[swipe-axis=y]/drawer-popup:w-full group-data-[swipe-axis=y]/drawer-popup:justify-center group-data-[swipe-direction=down]/drawer-popup:items-end group-data-[swipe-direction=left]/drawer-popup:order-last group-data-[swipe-direction=left]/drawer-popup:justify-start group-data-[swipe-direction=right]/drawer-popup:justify-end group-data-[swipe-direction=up]/drawer-popup:order-last group-data-[swipe-direction=up]/drawer-popup:items-start after:block after:shrink-0 after:rounded-full after:bg-muted group-data-[swipe-axis=x]/drawer-popup:after:h-[100px] group-data-[swipe-axis=x]/drawer-popup:after:w-1.5 group-data-[swipe-axis=y]/drawer-popup:after:h-1.5 group-data-[swipe-axis=y]/drawer-popup:after:w-[100px] active:cursor-grabbing",
98
101
  className
99
102
  )}
100
103
  {...props}
@@ -110,6 +113,7 @@ function DrawerContent({
110
113
  const { hasSnapPoints, modal, showSwipeHandle, swipeDirection } = useDrawer()
111
114
  const swipeAxis =
112
115
  swipeDirection === "down" || swipeDirection === "up" ? "y" : "x"
116
+ const dir = usePopupDir()
113
117
 
114
118
  return (
115
119
  <DrawerPortal data-slot="drawer-portal">
@@ -122,22 +126,23 @@ function DrawerContent({
122
126
  className="pointer-events-none fixed inset-0 z-50 select-none data-[modal=true]:pointer-events-auto"
123
127
  >
124
128
  <DrawerPrimitive.Popup
129
+ dir={dir}
125
130
  data-slot="drawer-popup"
126
131
  data-swipe-axis={swipeAxis}
127
132
  data-snap-points={hasSnapPoints ? "" : undefined}
128
133
  className={cn(
129
134
  // Base.
130
- "group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col bg-overlay text-sm text-popover-foreground transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [interpolate-size:allow-keywords] data-[swipe-direction=down]:rounded-t-xl data-[swipe-direction=down]:border-t data-[swipe-direction=left]:rounded-r-xl data-[swipe-direction=left]:border-r data-[swipe-direction=right]:rounded-l-xl data-[swipe-direction=right]:border-l data-[swipe-direction=up]:rounded-b-xl data-[swipe-direction=up]:border-b motion-reduce:transition-none",
135
+ "group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col bg-overlay text-sm text-popover-foreground transition-[transform,height,opacity,filter] duration-drawer-slide ease-drawer will-change-transform outline-none select-none [interpolate-size:allow-keywords] data-[swipe-direction=down]:rounded-t-xl data-[swipe-direction=down]:border-t data-[swipe-direction=left]:rounded-r-xl data-[swipe-direction=left]:border-r data-[swipe-direction=right]:rounded-l-xl data-[swipe-direction=right]:border-l data-[swipe-direction=up]:rounded-b-xl data-[swipe-direction=up]:border-b motion-reduce:transition-opacity motion-reduce:data-starting-style:opacity-0 motion-reduce:data-ending-style:opacity-0",
131
136
  // Nested.
132
137
  "data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95",
133
138
  // Bleed.
134
- "after:pointer-events-none after:absolute after:bg-(--drawer-bleed-background,var(--color-overlay)) data-[swipe-axis=x]:after:inset-y-0 data-[swipe-axis=x]:after:w-(--bleed) data-[swipe-axis=y]:after:inset-x-0 data-[swipe-axis=y]:after:h-(--bleed) data-[swipe-direction=down]:after:top-full data-[swipe-direction=left]:after:right-full data-[swipe-direction=right]:after:left-full data-[swipe-direction=up]:after:bottom-full",
139
+ "after:pointer-events-none after:absolute after:bg-(--drawer-bleed-background,var(--overlay)) data-[swipe-axis=x]:after:inset-y-0 data-[swipe-axis=x]:after:w-(--bleed) data-[swipe-axis=y]:after:inset-x-0 data-[swipe-axis=y]:after:h-(--bleed) data-[swipe-direction=down]:after:top-full data-[swipe-direction=left]:after:right-full data-[swipe-direction=right]:after:left-full data-[swipe-direction=up]:after:bottom-full",
135
140
  // Sizing.
136
141
  "[--drawer-content-height:var(--drawer-height,auto)] data-[swipe-axis=x]:[--drawer-content-width:75%] data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)] data-[swipe-axis=y]:data-snap-points:[--drawer-content-height:100dvh] data-[swipe-axis=x]:sm:[--drawer-content-width:24rem]",
137
142
  // Stack.
138
143
  "[--bleed:3rem] [--peek:1rem] [--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] [--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--peek)))] [--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] [--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] [--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] [--stack-shrink:calc(1-var(--stack-scale))] [--stack-step:0.05]",
139
144
  // Transitions.
140
- "data-ending-style:transform-(--closed-transform) data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-nested-drawer-swiping:duration-0 data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:transform-(--closed-transform) data-swiping:duration-0 data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]",
145
+ "motion-safe:data-ending-style:transform-(--closed-transform) motion-safe:data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*var(--transition-duration-drawer-swipe))] data-nested-drawer-swiping:duration-instant data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*var(--transition-duration-drawer-swipe))] motion-safe:data-starting-style:transform-(--closed-transform) data-swiping:duration-instant data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*var(--transition-duration-drawer-swipe))]",
141
146
  // Axis: y.
142
147
  "data-[swipe-axis=y]:inset-x-0 data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)",
143
148
  // Axis: x.
@@ -158,7 +163,7 @@ function DrawerContent({
158
163
  <DrawerPrimitive.Content
159
164
  data-slot="drawer-content"
160
165
  className={cn(
161
- "flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-300 ease-[cubic-bezier(0.45,1.005,0,1.005)] select-text group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none"
166
+ "flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-slow ease-drawer-content select-text group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none"
162
167
  )}
163
168
  >
164
169
  {children}
@@ -174,7 +179,7 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
174
179
  <div
175
180
  data-slot="drawer-header"
176
181
  className={cn(
177
- "flex shrink-0 flex-col gap-0.5 p-4 pb-0 group-data-[swipe-axis=y]/drawer-popup:text-center md:gap-1.5 md:text-left",
182
+ "flex shrink-0 flex-col gap-0.5 p-4 pb-0 group-data-[swipe-axis=y]/drawer-popup:text-center md:gap-1.5 md:text-start",
178
183
  className
179
184
  )}
180
185
  {...props}
@@ -4,7 +4,12 @@ import * as React from "react"
4
4
  import { Menu as MenuPrimitive } from "@base-ui/react/menu"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
- import { ChevronRightIcon, CheckIcon } from "lucide-react"
7
+ import { popupMotion } from "../../lib/popup-motion.ts"
8
+ import { ChevronRightIcon } from "lucide-react"
9
+ import { usePopupDir } from "../../lib/popup-direction.ts"
10
+ import { usePopupAlign } from "../../lib/popup-align.ts"
11
+ import { triggerSlot } from "../../lib/trigger-slot.ts"
12
+ import { menuCheckItem, menuItem, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
8
13
 
9
14
  function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
10
15
  return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
@@ -15,34 +20,49 @@ function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
15
20
  }
16
21
 
17
22
  function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
18
- return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
23
+ return <MenuPrimitive.Trigger {...triggerSlot("dropdown-menu-trigger", props.render)} {...props} />
19
24
  }
20
25
 
26
+ /**
27
+ * Without an `align`, the menu opens toward the centre of the viewport: a
28
+ * trigger in the right half lines the menu up with its right edge, so the menu
29
+ * grows to the left and stays on screen, and a trigger in the left half lines
30
+ * it up with its left edge. The side is picked each time the menu opens. A
31
+ * menu that opens to the left or right of its trigger keeps "start". An
32
+ * explicit `align` always wins.
33
+ */
21
34
  function DropdownMenuContent({
22
- align = "start",
35
+ align,
23
36
  alignOffset = 0,
24
37
  side = "bottom",
25
- sideOffset = 4,
38
+ sideOffset = 6,
26
39
  className,
40
+ ref,
27
41
  ...props
28
42
  }: MenuPrimitive.Popup.Props &
29
43
  Pick<
30
44
  MenuPrimitive.Positioner.Props,
31
45
  "align" | "alignOffset" | "side" | "sideOffset"
32
46
  >) {
47
+ // Without an align, the popup opens toward the centre of the screen.
48
+ const { popupRef, align: positionAlign } = usePopupAlign(align, side, ref)
49
+ const dir = usePopupDir()
33
50
  return (
34
51
  <MenuPrimitive.Portal>
35
52
  <MenuPrimitive.Positioner
53
+ dir={dir}
36
54
  className="isolate z-50 outline-none"
37
- align={align}
55
+ align={positionAlign}
38
56
  alignOffset={alignOffset}
39
57
  side={side}
40
58
  sideOffset={sideOffset}
41
59
  >
42
- {/* No w-(--anchor-width) here: pinning the popup to the trigger width makes wide items wrap — the popup sizes to its content, min-w-32 keeps the floor */}
60
+ {/* Opens with popupMotion, the motion every popup shares. */}
61
+ {/* No w-(--anchor-width) here: pinning the popup to the trigger width makes wide items wrap — the popup sizes to its content, min-w-60 keeps the 240px floor of the v3 look */}
43
62
  <MenuPrimitive.Popup
63
+ ref={popupRef}
44
64
  data-slot="dropdown-menu-content"
45
- className={cn("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 bg-popover text-popover-foreground data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md p-1 shadow-md ring-1 outline-none 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) data-closed:overflow-hidden", className )}
65
+ className={cn("bg-popover text-popover-foreground shadow-overlay rounded-xl p-1.25 z-50 max-h-(--available-height) min-w-60 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", popupMotion, className )}
46
66
  {...props}
47
67
  />
48
68
  </MenuPrimitive.Positioner>
@@ -66,7 +86,7 @@ function DropdownMenuLabel({
66
86
  data-slot="dropdown-menu-label"
67
87
  data-inset={inset}
68
88
  className={cn(
69
- "text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:pl-8",
89
+ "text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:ps-8",
70
90
  className
71
91
  )}
72
92
  {...props}
@@ -89,7 +109,7 @@ function DropdownMenuItem({
89
109
  data-inset={inset}
90
110
  data-variant={variant}
91
111
  className={cn(
92
- "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/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 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",
112
+ menuItem, "data-[variant=destructive]:text-destructive-text data-[variant=destructive]:not-data-disabled:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive-text data-[variant=destructive]:*:[svg]:text-destructive-text data-[variant=destructive]:[&>svg:not([class*='opacity-'])]:opacity-100 not-data-[variant=destructive]:not-data-disabled:focus:**:not-data-[slot=dropdown-menu-shortcut]:text-accent-foreground group/dropdown-menu-item",
93
113
  className
94
114
  )}
95
115
  {...props}
@@ -114,21 +134,22 @@ function DropdownMenuSubTrigger({
114
134
  data-slot="dropdown-menu-sub-trigger"
115
135
  data-inset={inset}
116
136
  className={cn(
117
- "focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
137
+ menuItem, "not-data-[variant=destructive]:not-data-disabled:focus:**:not-data-[slot=dropdown-menu-shortcut]:text-accent-foreground data-popup-open:bg-muted data-popup-open:text-accent-foreground",
118
138
  className
119
139
  )}
120
140
  {...props}
121
141
  >
122
142
  {children}
123
- <ChevronRightIcon className="ml-auto" />
143
+ <ChevronRightIcon className="ms-auto rtl:rotate-180" />
124
144
  </MenuPrimitive.SubmenuTrigger>
125
145
  )
126
146
  }
127
147
 
128
148
  function DropdownMenuSubContent({
129
149
  align = "start",
130
- alignOffset = -3,
131
- side = "right",
150
+ alignOffset = -5,
151
+ // Logical: the sub-menu opens to the left in a right-to-left layout.
152
+ side = "inline-end",
132
153
  sideOffset = 0,
133
154
  className,
134
155
  ...props
@@ -137,7 +158,7 @@ function DropdownMenuSubContent({
137
158
  <DropdownMenuContent
138
159
  data-slot="dropdown-menu-sub-content"
139
160
  className={cn(
140
- "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 bg-popover text-popover-foreground w-auto min-w-[96px] 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)",
161
+ "w-auto min-w-[96px]",
141
162
  className
142
163
  )}
143
164
  align={align}
@@ -163,20 +184,17 @@ function DropdownMenuCheckboxItem({
163
184
  data-slot="dropdown-menu-checkbox-item"
164
185
  data-inset={inset}
165
186
  className={cn(
166
- "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 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",
187
+ menuItem, menuCheckItem, "not-data-disabled:focus:**:text-accent-foreground pe-8",
167
188
  className
168
189
  )}
169
190
  checked={checked}
170
191
  {...props}
171
192
  >
172
193
  <span
173
- className="pointer-events-none absolute right-2 flex items-center justify-center"
194
+ className="pointer-events-none absolute end-2 flex items-center justify-center"
174
195
  data-slot="dropdown-menu-checkbox-item-indicator"
175
196
  >
176
- <MenuPrimitive.CheckboxItemIndicator>
177
- <CheckIcon
178
- />
179
- </MenuPrimitive.CheckboxItemIndicator>
197
+ <MenuCheck />
180
198
  </span>
181
199
  {children}
182
200
  </MenuPrimitive.CheckboxItem>
@@ -205,19 +223,16 @@ function DropdownMenuRadioItem({
205
223
  data-slot="dropdown-menu-radio-item"
206
224
  data-inset={inset}
207
225
  className={cn(
208
- "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 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",
226
+ menuItem, menuRadioItem, "not-data-disabled:focus:**:text-accent-foreground pe-8",
209
227
  className
210
228
  )}
211
229
  {...props}
212
230
  >
213
231
  <span
214
- className="pointer-events-none absolute right-2 flex items-center justify-center"
232
+ className="pointer-events-none absolute end-2 flex items-center justify-center"
215
233
  data-slot="dropdown-menu-radio-item-indicator"
216
234
  >
217
- <MenuPrimitive.RadioItemIndicator>
218
- <CheckIcon
219
- />
220
- </MenuPrimitive.RadioItemIndicator>
235
+ <MenuCheck />
221
236
  </span>
222
237
  {children}
223
238
  </MenuPrimitive.RadioItem>
@@ -231,7 +246,7 @@ function DropdownMenuSeparator({
231
246
  return (
232
247
  <MenuPrimitive.Separator
233
248
  data-slot="dropdown-menu-separator"
234
- className={cn("bg-border -mx-1 my-1 h-px", className)}
249
+ className={cn("bg-border -mx-1.25 my-1.25 h-px", className)}
235
250
  {...props}
236
251
  />
237
252
  )
@@ -245,7 +260,7 @@ function DropdownMenuShortcut({
245
260
  <span
246
261
  data-slot="dropdown-menu-shortcut"
247
262
  className={cn(
248
- "text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",
263
+ "text-muted-foreground ms-auto ps-4 text-xs",
249
264
  className
250
265
  )}
251
266
  {...props}
@@ -32,6 +32,10 @@ const emptyMediaVariants = cva(
32
32
  variant: {
33
33
  default: "bg-transparent",
34
34
  icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6",
35
+ // A bare icon with no chip, the icon of every state view (EmptyState,
36
+ // ErrorState): 28px, a light stroke and 40% opacity, so it marks the
37
+ // region without drawing focus.
38
+ bare: "text-foreground opacity-40 [&_svg]:stroke-[1.5] [&_svg:not([class*='size-'])]:size-7",
35
39
  },
36
40
  },
37
41
  defaultVariants: {
@@ -59,7 +63,7 @@ function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
59
63
  return (
60
64
  <div
61
65
  data-slot="empty-title"
62
- className={cn("text-style-section-title", className)}
66
+ className={cn("text-style-section-title text-foreground", className)}
63
67
  {...props}
64
68
  />
65
69
  )