@vendure-io/ui 3.0.0-next.3 → 3.0.0-next.5

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 (86) hide show
  1. package/package.json +12 -10
  2. package/src/components/atoms/alert-dialog.tsx +1 -4
  3. package/src/components/atoms/alert.tsx +59 -35
  4. package/src/components/atoms/badge.tsx +2 -2
  5. package/src/components/atoms/breadcrumb.tsx +124 -49
  6. package/src/components/atoms/button-group.tsx +1 -1
  7. package/src/components/atoms/button.tsx +4 -3
  8. package/src/components/atoms/calendar.tsx +2 -2
  9. package/src/components/atoms/card.tsx +15 -2
  10. package/src/components/atoms/chart.tsx +3 -3
  11. package/src/components/atoms/checkbox.tsx +1 -1
  12. package/src/components/atoms/combobox.tsx +37 -26
  13. package/src/components/atoms/command.tsx +3 -3
  14. package/src/components/atoms/context-menu.tsx +5 -5
  15. package/src/components/atoms/dialog.tsx +30 -14
  16. package/src/components/atoms/dropdown-menu.tsx +1 -1
  17. package/src/components/atoms/hover-card.tsx +1 -1
  18. package/src/components/atoms/input-group.tsx +30 -12
  19. package/src/components/atoms/input-otp.tsx +2 -2
  20. package/src/components/atoms/input.tsx +13 -3
  21. package/src/components/atoms/menubar.tsx +2 -2
  22. package/src/components/atoms/native-select.tsx +1 -1
  23. package/src/components/atoms/navigation-menu.tsx +3 -3
  24. package/src/components/atoms/pagination.tsx +9 -3
  25. package/src/components/atoms/popover.tsx +1 -1
  26. package/src/components/atoms/select.tsx +3 -3
  27. package/src/components/atoms/sheet.tsx +35 -15
  28. package/src/components/atoms/sidebar.tsx +200 -31
  29. package/src/components/atoms/skeleton.tsx +6 -3
  30. package/src/components/atoms/switch.tsx +1 -1
  31. package/src/components/atoms/tabs.tsx +6 -2
  32. package/src/components/atoms/textarea.tsx +1 -1
  33. package/src/components/atoms/toggle.tsx +1 -1
  34. package/src/components/molecules/action-needed.tsx +483 -0
  35. package/src/components/molecules/anonymized-token.tsx +52 -8
  36. package/src/components/molecules/chip.tsx +37 -18
  37. package/src/components/molecules/choice-card.tsx +114 -9
  38. package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
  39. package/src/components/molecules/code-block/process-code.ts +1 -1
  40. package/src/components/molecules/code-block.tsx +58 -47
  41. package/src/components/molecules/combobox-free-text.tsx +75 -20
  42. package/src/components/molecules/confirm-dialog.tsx +11 -1
  43. package/src/components/molecules/copyable-text.tsx +10 -8
  44. package/src/components/molecules/data-table/data-table-filters.tsx +14 -2
  45. package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
  46. package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
  47. package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
  48. package/src/components/molecules/data-table/data-table-types.tsx +123 -13
  49. package/src/components/molecules/data-table/data-table.tsx +112 -55
  50. package/src/components/molecules/data-table/table-pagination.tsx +96 -14
  51. package/src/components/molecules/date-picker.tsx +55 -24
  52. package/src/components/molecules/date-range-picker.tsx +54 -23
  53. package/src/components/molecules/date-time-picker.tsx +60 -24
  54. package/src/components/molecules/date-time.tsx +38 -3
  55. package/src/components/molecules/elapsed-time.tsx +61 -12
  56. package/src/components/molecules/file-dropzone.tsx +139 -39
  57. package/src/components/molecules/format-provider.tsx +14 -4
  58. package/src/components/molecules/id-chip-chrome.tsx +114 -0
  59. package/src/components/molecules/id-chip.tsx +3 -107
  60. package/src/components/molecules/issued-secret.tsx +1 -1
  61. package/src/components/molecules/live-indicator.tsx +1 -1
  62. package/src/components/molecules/money.tsx +46 -4
  63. package/src/components/molecules/multi-select.tsx +58 -15
  64. package/src/components/molecules/page-header.tsx +6 -2
  65. package/src/components/molecules/password-input.tsx +11 -10
  66. package/src/components/molecules/relative-time.tsx +88 -16
  67. package/src/components/molecules/search-trigger.tsx +5 -3
  68. package/src/components/molecules/secret-value.tsx +10 -2
  69. package/src/components/molecules/stat-card.tsx +143 -33
  70. package/src/components/molecules/state-views/empty-state.tsx +16 -12
  71. package/src/components/molecules/state-views/error-state.tsx +19 -15
  72. package/src/components/molecules/state-views/loading-state.tsx +16 -6
  73. package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
  74. package/src/components/molecules/status-badge.tsx +11 -35
  75. package/src/components/molecules/time-tooltip.tsx +55 -1
  76. package/src/hooks/use-copy.ts +3 -1
  77. package/src/lib/deprecated.ts +71 -0
  78. package/src/lib/env.ts +9 -0
  79. package/src/lib/field-surface.ts +7 -7
  80. package/src/lib/format-messages.ts +192 -0
  81. package/src/lib/highlight.ts +1 -1
  82. package/src/lib/menu-item.tsx +1 -1
  83. package/src/lib/state-dictionary.ts +2 -3
  84. package/src/lib/tint-recipes.ts +10 -5
  85. package/src/lib/utils.ts +19 -1
  86. package/src/lib/dialog-padding.ts +0 -48
@@ -7,7 +7,16 @@ import { cva, type VariantProps } from "class-variance-authority"
7
7
 
8
8
  import { useIsMobile } from "@vendure-io/ui/hooks/use-mobile"
9
9
  import { cn } from "@vendure-io/ui/lib/utils"
10
+ import { useMessages } from "../../lib/format-messages.ts"
11
+ import { menuItem } from "../../lib/menu-item.tsx"
12
+ import { logicalSide, type PhysicalSide, warnDeprecated } from "../../lib/deprecated.ts"
13
+ import { usePopupDir } from "../../lib/popup-direction.ts"
10
14
  import { Button } from "@vendure-io/ui/components/atoms/button"
15
+ import {
16
+ HoverCard,
17
+ HoverCardContent,
18
+ HoverCardTrigger,
19
+ } from "@vendure-io/ui/components/atoms/hover-card"
11
20
  import { Input } from "@vendure-io/ui/components/atoms/input"
12
21
  import { Separator } from "@vendure-io/ui/components/atoms/separator"
13
22
  import {
@@ -150,19 +159,38 @@ function SidebarProvider({
150
159
  }
151
160
 
152
161
  function Sidebar({
153
- side = "left",
162
+ side: sideProp = "start",
154
163
  variant = "sidebar",
155
164
  collapsible = "offcanvas",
156
165
  className,
157
166
  children,
158
167
  dir,
168
+ mobileLabels,
159
169
  ...props
160
170
  }: React.ComponentProps<"div"> & {
161
- side?: "left" | "right"
171
+ /**
172
+ * The edge the sidebar sits on. `start` and `end` follow the reading
173
+ * direction. `left` and `right` are deprecated: use `start` or `end`.
174
+ * They are removed in 4.0.
175
+ */
176
+ side?: "start" | "end" | PhysicalSide
162
177
  variant?: "sidebar" | "floating" | "inset"
163
178
  collapsible?: "offcanvas" | "icon" | "none"
179
+ /**
180
+ * The screen-reader title and description of the sheet the sidebar opens
181
+ * in on a small screen. Default to `messages.sidebar` (`mobileTitle`,
182
+ * `mobileDescription`) from `FormatProvider`, then "Sidebar" and
183
+ * "Displays the mobile sidebar.".
184
+ */
185
+ mobileLabels?: { title?: string; description?: string }
164
186
  }) {
165
187
  const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
188
+ const providedDir = usePopupDir()
189
+ const side = logicalSide("Sidebar", sideProp, dir ?? providedDir)
190
+ const t = useMessages("sidebar", {
191
+ mobileTitle: mobileLabels?.title,
192
+ mobileDescription: mobileLabels?.description,
193
+ })
166
194
 
167
195
  if (collapsible === "none") {
168
196
  return (
@@ -196,8 +224,8 @@ function Sidebar({
196
224
  side={side}
197
225
  >
198
226
  <SheetHeader className="sr-only">
199
- <SheetTitle>Sidebar</SheetTitle>
200
- <SheetDescription>Displays the mobile sidebar.</SheetDescription>
227
+ <SheetTitle>{t.mobileTitle}</SheetTitle>
228
+ <SheetDescription>{t.mobileDescription}</SheetDescription>
201
229
  </SheetHeader>
202
230
  <div className="flex h-full w-full flex-col">{children}</div>
203
231
  </SheetContent>
@@ -205,13 +233,13 @@ function Sidebar({
205
233
  )
206
234
  }
207
235
 
208
- // The sidebar's flex order follows its physical side, not its place in the
209
- // markup, so the gap that keeps its width sits on the same side as the
210
- // fixed container: at the start of the line for the start side, at the end
211
- // for the end side, in either direction.
236
+ // The sidebar's flex order follows its side, not its place in the markup,
237
+ // so the gap that keeps its width sits on the same side as the fixed
238
+ // container: at the start of the line for the start side, at the end for
239
+ // the end side, in either direction.
212
240
  return (
213
241
  <div
214
- className="group peer text-sidebar-foreground hidden md:block data-[side=left]:order-first data-[side=left]:rtl:order-last data-[side=right]:order-last data-[side=right]:rtl:order-first"
242
+ className="group peer text-sidebar-foreground hidden md:block data-[side=start]:order-first data-[side=end]:order-last"
215
243
  data-state={state}
216
244
  data-collapsible={state === "collapsed" ? collapsible : ""}
217
245
  data-variant={variant}
@@ -224,7 +252,7 @@ function Sidebar({
224
252
  className={cn(
225
253
  "relative w-(--sidebar-width) bg-transparent transition-[width] duration-slow ease-drawer motion-reduce:transition-none",
226
254
  "group-data-[collapsible=offcanvas]:w-0",
227
- "group-data-[side=right]:rotate-180",
255
+ "group-data-[side=end]:rotate-180",
228
256
  variant === "floating" || variant === "inset"
229
257
  ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
230
258
  : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
@@ -234,11 +262,11 @@ function Sidebar({
234
262
  data-slot="sidebar-container"
235
263
  data-side={side}
236
264
  className={cn(
237
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-slow ease-drawer motion-reduce:transition-none data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
265
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[inset-inline-start,inset-inline-end,width] duration-slow ease-drawer motion-reduce:transition-none data-[side=start]:start-0 data-[side=start]:group-data-[collapsible=offcanvas]:start-[calc(var(--sidebar-width)*-1)] data-[side=end]:end-0 data-[side=end]:group-data-[collapsible=offcanvas]:end-[calc(var(--sidebar-width)*-1)] md:flex",
238
266
  // Adjust the padding for floating and inset variants.
239
267
  variant === "floating" || variant === "inset"
240
268
  ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
241
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
269
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=start]:border-e group-data-[side=end]:border-s",
242
270
  className
243
271
  )}
244
272
  {...props}
@@ -246,7 +274,7 @@ function Sidebar({
246
274
  <div
247
275
  data-sidebar="sidebar"
248
276
  data-slot="sidebar-inner"
249
- className="bg-sidebar group-data-[variant=floating]:ring-sidebar-border flex size-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1"
277
+ className="bg-sidebar group-data-[variant=floating]:ring-sidebar-border flex size-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-control group-data-[variant=floating]:ring-1"
250
278
  >
251
279
  {children}
252
280
  </div>
@@ -293,12 +321,12 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
293
321
  onClick={toggleSidebar}
294
322
  title="Toggle Sidebar"
295
323
  className={cn(
296
- "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 transition-[left,right,translate,background-color] ease-drawer group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
297
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
298
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
299
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
300
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
301
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
324
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 transition-[inset-inline-start,inset-inline-end,translate,background-color] ease-drawer group-data-[side=start]:-end-4 group-data-[side=end]:start-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:translate-x-1/2",
325
+ "in-data-[side=start]:ltr:cursor-w-resize in-data-[side=start]:rtl:cursor-e-resize in-data-[side=end]:ltr:cursor-e-resize in-data-[side=end]:rtl:cursor-w-resize",
326
+ "[[data-side=start][data-state=collapsed]_&]:ltr:cursor-e-resize [[data-side=start][data-state=collapsed]_&]:rtl:cursor-w-resize [[data-side=end][data-state=collapsed]_&]:ltr:cursor-w-resize [[data-side=end][data-state=collapsed]_&]:rtl:cursor-e-resize",
327
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:start-full",
328
+ "[[data-side=start][data-collapsible=offcanvas]_&]:-end-2",
329
+ "[[data-side=end][data-collapsible=offcanvas]_&]:-start-2",
302
330
  className
303
331
  )}
304
332
  {...props}
@@ -316,14 +344,14 @@ function SidebarInset({
316
344
  // recedes and cards (--surface-raised) lift off the pane. A border carries the
317
345
  // tier in light mode where the ramp collapses to white; flat by design, no drop
318
346
  // shadow (see AGENTS.md "flat look"). The default variant stays flush on canvas.
319
- // The pane drops its margin on the sidebar's side. `side` is physical, as
320
- // for Sheet: it does not mirror in right-to-left.
347
+ // The pane drops its margin on the sidebar's side. `side` is logical, as
348
+ // for Sheet: in right-to-left the start side is the right edge.
321
349
  return useRender({
322
350
  defaultTagName: "main",
323
351
  props: mergeProps<"main">(
324
352
  {
325
353
  className: cn(
326
- "bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:peer-data-[side=left]:ml-0 md:peer-data-[variant=inset]:peer-data-[side=right]:mr-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60",
354
+ "bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:peer-data-[side=start]:ms-0 md:peer-data-[variant=inset]:peer-data-[side=end]:me-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60",
327
355
  className
328
356
  ),
329
357
  },
@@ -621,7 +649,7 @@ const sidebarMenuButtonVariants = cva(
621
649
  variant: {
622
650
  default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
623
651
  outline:
624
- "bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_var(--sidebar-border)] hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
652
+ "bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ring ring-sidebar-border hover:ring-sidebar-accent",
625
653
  },
626
654
  size: {
627
655
  default: "h-8 text-sm",
@@ -638,7 +666,8 @@ const sidebarMenuButtonVariants = cva(
638
666
 
639
667
  function SidebarMenuButton({
640
668
  render,
641
- isActive = false,
669
+ active: activeProp,
670
+ isActive,
642
671
  hasActiveChild = false,
643
672
  variant = "default",
644
673
  size = "default",
@@ -647,6 +676,8 @@ function SidebarMenuButton({
647
676
  ...props
648
677
  }: useRender.ComponentProps<"button"> &
649
678
  React.ComponentProps<"button"> & {
679
+ active?: boolean
680
+ /** @deprecated Use `active`. Removed in 4.0. */
650
681
  isActive?: boolean
651
682
  /**
652
683
  * Set it on the button of every group that holds the current page, whether
@@ -660,6 +691,8 @@ function SidebarMenuButton({
660
691
  hasActiveChild?: boolean
661
692
  tooltip?: string | React.ComponentProps<typeof TooltipContent>
662
693
  } & VariantProps<typeof sidebarMenuButtonVariants>) {
694
+ if (isActive !== undefined) warnDeprecated("SidebarMenuButton", "isActive", "active")
695
+ const active = activeProp ?? isActive ?? false
663
696
  const { isMobile, state } = useSidebar()
664
697
  const comp = useRender({
665
698
  defaultTagName: "button",
@@ -674,7 +707,7 @@ function SidebarMenuButton({
674
707
  slot: "sidebar-menu-button",
675
708
  sidebar: "menu-button",
676
709
  size,
677
- active: isActive,
710
+ active,
678
711
  "has-active-child": hasActiveChild,
679
712
  },
680
713
  })
@@ -693,7 +726,7 @@ function SidebarMenuButton({
693
726
  <Tooltip>
694
727
  {comp}
695
728
  <TooltipContent
696
- side="right"
729
+ side="inline-end"
697
730
  align="center"
698
731
  // Clears the rail: the button ends one group padding (8px) short of
699
732
  // the rail edge, and the label sits 8px beyond that edge.
@@ -890,21 +923,29 @@ function SidebarMenuSubItem({
890
923
 
891
924
  function SidebarMenuSubButton({
892
925
  render,
893
- size = "md",
894
- isActive = false,
926
+ size: sizeProp = "default",
927
+ active: activeProp,
928
+ isActive,
895
929
  className,
896
930
  ...props
897
931
  }: useRender.ComponentProps<"a"> &
898
932
  React.ComponentProps<"a"> & {
899
- size?: "sm" | "md"
933
+ /** `md` is deprecated: use `default`. It is removed in 4.0. */
934
+ size?: "sm" | "default" | "md"
935
+ active?: boolean
936
+ /** @deprecated Use `active`. Removed in 4.0. */
900
937
  isActive?: boolean
901
938
  }) {
939
+ if (isActive !== undefined) warnDeprecated("SidebarMenuSubButton", "isActive", "active")
940
+ if (sizeProp === "md") warnDeprecated("SidebarMenuSubButton", 'size="md"', 'size="default"')
941
+ const active = activeProp ?? isActive ?? false
942
+ const size = sizeProp === "md" ? "default" : sizeProp
902
943
  return useRender({
903
944
  defaultTagName: "a",
904
945
  props: mergeProps<"a">(
905
946
  {
906
947
  className: cn(
907
- "relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sidebar-ring [&>svg]:opacity-55 [&>svg]:transition-opacity [&>svg]:duration-normal hover:[&>svg]:opacity-85 data-active:[&>svg]:opacity-100 data-active:[&>svg]:text-brand-indicator data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px rtl:translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
948
+ "relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sidebar-ring [&>svg]:opacity-55 [&>svg]:transition-opacity [&>svg]:duration-normal hover:[&>svg]:opacity-85 data-active:[&>svg]:opacity-100 data-active:[&>svg]:text-brand-indicator data-[size=default]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px rtl:translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
908
949
  className
909
950
  ),
910
951
  },
@@ -915,7 +956,131 @@ function SidebarMenuSubButton({
915
956
  slot: "sidebar-menu-sub-button",
916
957
  sidebar: "menu-sub-button",
917
958
  size,
918
- active: isActive,
959
+ active,
960
+ },
961
+ })
962
+ }
963
+
964
+ // The icon rail's flyout: hover or focus a group's icon and a card beside the
965
+ // rail shows the group's title, a separator and its items. Use it for a group
966
+ // whose items the rail hides. The card's title row is centred on the trigger,
967
+ // so the title reads as the icon's label, and the card still flips to the other
968
+ // side or shifts along the rail when it would leave the viewport.
969
+ //
970
+ // <SidebarMenuFlyout>
971
+ // <SidebarMenuFlyoutTrigger hasActiveChild><CartIcon /><span>Sales</span></SidebarMenuFlyoutTrigger>
972
+ // <SidebarMenuFlyoutContent label="Sales">
973
+ // <SidebarMenuFlyoutItem render={<Link to="/orders" />} active>Orders</SidebarMenuFlyoutItem>
974
+ // </SidebarMenuFlyoutContent>
975
+ // </SidebarMenuFlyout>
976
+
977
+ // The card's padding and its title row's height. The title row is centred on
978
+ // the trigger from these, whatever the trigger's height.
979
+ const FLYOUT_PADDING = 5
980
+ const FLYOUT_LABEL_HEIGHT = 34
981
+
982
+ function SidebarMenuFlyout(props: React.ComponentProps<typeof HoverCard>) {
983
+ return <HoverCard {...props} />
984
+ }
985
+
986
+ /**
987
+ * A SidebarMenuButton that opens the flyout. It takes the button's props, plus
988
+ * the hover delays of the card. The flyout opens only in the icon rail, like
989
+ * the rail's tooltips: on the expanded sidebar and on mobile it is a plain
990
+ * button.
991
+ */
992
+ function SidebarMenuFlyoutTrigger({
993
+ delay,
994
+ closeDelay,
995
+ ...props
996
+ }: Omit<React.ComponentProps<typeof SidebarMenuButton>, "tooltip"> &
997
+ Pick<React.ComponentProps<typeof HoverCardTrigger>, "delay" | "closeDelay">) {
998
+ const { isMobile, state } = useSidebar()
999
+ if (state !== "collapsed" || isMobile) {
1000
+ return <SidebarMenuButton {...props} />
1001
+ }
1002
+ return (
1003
+ <HoverCardTrigger
1004
+ delay={delay}
1005
+ closeDelay={closeDelay}
1006
+ render={<SidebarMenuButton {...props} />}
1007
+ />
1008
+ )
1009
+ }
1010
+
1011
+ /**
1012
+ * The card. `label` is the group's title: it sits on the trigger's centre
1013
+ * line, above a separator and the items.
1014
+ */
1015
+ function SidebarMenuFlyoutContent({
1016
+ label,
1017
+ className,
1018
+ children,
1019
+ ...props
1020
+ }: Omit<
1021
+ React.ComponentProps<typeof HoverCardContent>,
1022
+ "side" | "align" | "alignOffset" | "sideOffset"
1023
+ > & { label: React.ReactNode }) {
1024
+ return (
1025
+ <HoverCardContent
1026
+ side="inline-end"
1027
+ align="start"
1028
+ // Moves the card up by its padding plus half the height difference
1029
+ // between the title row and the trigger.
1030
+ alignOffset={({ anchor }) =>
1031
+ (anchor.height - FLYOUT_LABEL_HEIGHT) / 2 - FLYOUT_PADDING
1032
+ }
1033
+ // Clears the rail by the same 8px as the rail's tooltips.
1034
+ sideOffset={16}
1035
+ className={cn("flex w-auto min-w-40 flex-col rounded-2xl p-1.25", className)}
1036
+ {...props}
1037
+ >
1038
+ <div
1039
+ data-slot="sidebar-menu-flyout-label"
1040
+ className="text-foreground flex h-8.5 shrink-0 items-center px-2 text-sm font-medium"
1041
+ >
1042
+ {label}
1043
+ </div>
1044
+ <div
1045
+ data-slot="sidebar-menu-flyout-separator"
1046
+ role="presentation"
1047
+ className="bg-border -mx-1.25 my-1.25 h-px shrink-0"
1048
+ />
1049
+ {children}
1050
+ </HoverCardContent>
1051
+ )
1052
+ }
1053
+
1054
+ /**
1055
+ * One item of the flyout, a link by default. Compose a router link with
1056
+ * `render`. `active` sets aria-current="page"; a router link that sets it
1057
+ * itself does not need `active`.
1058
+ */
1059
+ function SidebarMenuFlyoutItem({
1060
+ render,
1061
+ active,
1062
+ className,
1063
+ ...props
1064
+ }: useRender.ComponentProps<"a"> & { active?: boolean }) {
1065
+ return useRender({
1066
+ defaultTagName: "a",
1067
+ render,
1068
+ props: mergeProps<"a">(
1069
+ {
1070
+ ...(active !== undefined && {
1071
+ "aria-current": active ? ("page" as const) : undefined,
1072
+ }),
1073
+ className: cn(
1074
+ menuItem,
1075
+ "hover:bg-muted hover:text-accent-foreground aria-[current=page]:text-foreground aria-[current=page]:font-medium [&>span:last-child]:min-w-0 [&>span:last-child]:truncate",
1076
+ className
1077
+ ),
1078
+ },
1079
+ props
1080
+ ),
1081
+ state: {
1082
+ slot: "sidebar-menu-flyout-item",
1083
+ sidebar: "menu-flyout-item",
919
1084
  },
920
1085
  })
921
1086
  }
@@ -1109,6 +1274,10 @@ export {
1109
1274
  SidebarMenuAction,
1110
1275
  SidebarMenuBadge,
1111
1276
  SidebarMenuButton,
1277
+ SidebarMenuFlyout,
1278
+ SidebarMenuFlyoutContent,
1279
+ SidebarMenuFlyoutItem,
1280
+ SidebarMenuFlyoutTrigger,
1112
1281
  SidebarMenuItem,
1113
1282
  SidebarMenuSkeleton,
1114
1283
  SidebarMenuSub,
@@ -1,11 +1,14 @@
1
1
  import { cn } from "@vendure-io/ui/lib/utils"
2
2
 
3
- function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
3
+ // A <span> with `block`, not a <div>: a skeleton stands in for a value, and a
4
+ // value often sits in a <p> or a <span>, where a <div> is invalid HTML. A
5
+ // caller's display class (`inline-block`, `flex`) replaces `block`.
6
+ function Skeleton({ className, ...props }: React.ComponentProps<"span">) {
4
7
  return (
5
- <div
8
+ <span
6
9
  data-slot="skeleton"
7
10
  className={cn(
8
- "animate-shimmer motion-reduce:animate-none motion-reduce:bg-none motion-reduce:bg-muted rounded-md bg-[length:200%_100%] bg-[linear-gradient(90deg,var(--muted)_25%,var(--accent)_50%,var(--muted)_75%)]",
11
+ "animate-shimmer motion-reduce:animate-none motion-reduce:bg-none motion-reduce:bg-muted block rounded-md bg-[length:200%_100%] bg-[linear-gradient(90deg,var(--muted)_25%,var(--accent)_50%,var(--muted)_75%)]",
9
12
  className
10
13
  )}
11
14
  {...props}
@@ -3,7 +3,7 @@
3
3
  import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
4
4
 
5
5
  import { cn } from "@vendure-io/ui/lib/utils"
6
- import { useUserToggleMotion } from "../../hooks/use-user-toggle-motion"
6
+ import { useUserToggleMotion } from "../../hooks/use-user-toggle-motion.ts"
7
7
  import {
8
8
  useFieldControlProps,
9
9
  useFieldLabelCheckedClass,
@@ -60,13 +60,17 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
60
60
  <TabsPrimitive.Tab
61
61
  data-slot="tabs-trigger"
62
62
  className={cn(
63
- "focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
63
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-[calc(var(--radius-lg)-3px)] border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]",
64
64
  "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent",
65
65
  // ADR 0001: the active trigger lifts to surface-raised out of the inset
66
66
  // track in both themes. Dark keeps a hairline — lightness alone can't
67
67
  // separate a 0.21 thumb near the black end of the ramp.
68
68
  "data-active:bg-surface-raised dark:data-active:border-input dark:data-active:text-foreground data-active:text-foreground",
69
- "after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-end-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
69
+ // The underline must not stick out below the list: a parent that
70
+ // scrolls sideways also scrolls vertically, and 1px of overflow gives
71
+ // it a vertical scrollbar. The default variant has no underline, and
72
+ // the line variant's ends on the list's bottom edge.
73
+ "after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[variant=default]/tabs-list:after:hidden group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-4.5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-end-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
70
74
  className
71
75
  )}
72
76
  {...props}
@@ -3,7 +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
+ import { fieldSurface } from "../../lib/field-surface.ts"
7
7
  import { useFieldControlProps } from "@vendure-io/ui/components/atoms/field"
8
8
 
9
9
  function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
@@ -4,7 +4,7 @@ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
5
 
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
- import { outlineEdge, outlineEdgeHover } from "@vendure-io/ui/lib/outline-edge"
7
+ import { outlineEdge, outlineEdgeHover } from "../../lib/outline-edge.ts"
8
8
 
9
9
  const toggleVariants = cva(
10
10
  // Pressed is the accent tint with foreground text, as in the v3 look. Hover