@vendure-io/ui 3.0.0-next.4 → 3.0.0-next.6

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 (89) hide show
  1. package/package.json +12 -11
  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 +154 -59
  6. package/src/components/atoms/button-group.tsx +1 -1
  7. package/src/components/atoms/button.tsx +2 -2
  8. package/src/components/atoms/calendar.tsx +2 -2
  9. package/src/components/atoms/card.tsx +15 -2
  10. package/src/components/atoms/carousel.tsx +33 -7
  11. package/src/components/atoms/chart.tsx +3 -3
  12. package/src/components/atoms/checkbox.tsx +1 -1
  13. package/src/components/atoms/combobox.tsx +60 -36
  14. package/src/components/atoms/command.tsx +17 -7
  15. package/src/components/atoms/context-menu.tsx +5 -5
  16. package/src/components/atoms/dialog.tsx +30 -14
  17. package/src/components/atoms/dropdown-menu.tsx +1 -1
  18. package/src/components/atoms/hover-card.tsx +1 -1
  19. package/src/components/atoms/input-group.tsx +30 -12
  20. package/src/components/atoms/input-otp.tsx +2 -2
  21. package/src/components/atoms/input.tsx +13 -3
  22. package/src/components/atoms/menubar.tsx +2 -2
  23. package/src/components/atoms/native-select.tsx +1 -1
  24. package/src/components/atoms/navigation-menu.tsx +3 -3
  25. package/src/components/atoms/pagination.tsx +52 -15
  26. package/src/components/atoms/popover.tsx +1 -1
  27. package/src/components/atoms/select.tsx +3 -3
  28. package/src/components/atoms/sheet.tsx +35 -15
  29. package/src/components/atoms/sidebar.tsx +224 -36
  30. package/src/components/atoms/skeleton.tsx +6 -3
  31. package/src/components/atoms/spinner.tsx +7 -2
  32. package/src/components/atoms/tabs.tsx +6 -2
  33. package/src/components/atoms/textarea.tsx +1 -1
  34. package/src/components/atoms/toggle.tsx +1 -1
  35. package/src/components/molecules/action-needed.tsx +483 -0
  36. package/src/components/molecules/anonymized-token.tsx +70 -25
  37. package/src/components/molecules/app-shell.tsx +14 -5
  38. package/src/components/molecules/checklist/checklist.tsx +47 -17
  39. package/src/components/molecules/chip.tsx +37 -19
  40. package/src/components/molecules/choice-card.tsx +117 -9
  41. package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
  42. package/src/components/molecules/code-block/process-code.ts +1 -1
  43. package/src/components/molecules/code-block.tsx +58 -47
  44. package/src/components/molecules/combobox-free-text.tsx +75 -20
  45. package/src/components/molecules/confirm-dialog.tsx +17 -5
  46. package/src/components/molecules/copyable-text.tsx +10 -8
  47. package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
  48. package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
  49. package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
  50. package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
  51. package/src/components/molecules/data-table/data-table-types.tsx +156 -29
  52. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  53. package/src/components/molecules/data-table/data-table.tsx +156 -75
  54. package/src/components/molecules/data-table/table-pagination.tsx +142 -38
  55. package/src/components/molecules/date-picker.tsx +58 -25
  56. package/src/components/molecules/date-range-picker.tsx +59 -24
  57. package/src/components/molecules/date-time-picker.tsx +63 -25
  58. package/src/components/molecules/date-time.tsx +38 -3
  59. package/src/components/molecules/elapsed-time.tsx +61 -12
  60. package/src/components/molecules/file-dropzone.tsx +151 -40
  61. package/src/components/molecules/format-provider.tsx +14 -4
  62. package/src/components/molecules/id-chip-chrome.tsx +114 -0
  63. package/src/components/molecules/id-chip.tsx +13 -115
  64. package/src/components/molecules/issued-secret.tsx +35 -25
  65. package/src/components/molecules/live-indicator.tsx +1 -1
  66. package/src/components/molecules/money.tsx +44 -3
  67. package/src/components/molecules/multi-select.tsx +62 -16
  68. package/src/components/molecules/page-header.tsx +6 -2
  69. package/src/components/molecules/password-input.tsx +11 -10
  70. package/src/components/molecules/relative-time.tsx +88 -16
  71. package/src/components/molecules/search-trigger.tsx +5 -3
  72. package/src/components/molecules/secret-value.tsx +35 -19
  73. package/src/components/molecules/skip-link.tsx +11 -9
  74. package/src/components/molecules/stat-card.tsx +145 -33
  75. package/src/components/molecules/state-views/empty-state.tsx +16 -12
  76. package/src/components/molecules/state-views/error-state.tsx +36 -20
  77. package/src/components/molecules/state-views/loading-state.tsx +18 -6
  78. package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
  79. package/src/components/molecules/status-badge.tsx +11 -35
  80. package/src/components/molecules/time-tooltip.tsx +55 -1
  81. package/src/hooks/use-copy.ts +3 -1
  82. package/src/lib/deprecated.ts +71 -0
  83. package/src/lib/field-surface.ts +7 -7
  84. package/src/lib/format-messages.ts +368 -0
  85. package/src/lib/highlight.ts +1 -1
  86. package/src/lib/menu-item.tsx +1 -1
  87. package/src/lib/tint-recipes.ts +10 -5
  88. package/src/lib/utils.ts +19 -1
  89. package/src/lib/dialog-padding.ts +0 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/ui",
3
- "version": "3.0.0-next.4",
3
+ "version": "3.0.0-next.6",
4
4
  "description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
@@ -16,19 +16,20 @@
16
16
  "./components/atoms/label-swap": null,
17
17
  "./components/molecules/*": "./src/components/molecules/*.tsx",
18
18
  "./components/molecules/code-block/*": null,
19
+ "./components/molecules/data-table/data-table-bulk-actions": null,
19
20
  "./components/molecules/data-table/data-table-helpers": null,
21
+ "./components/molecules/data-table/data-table-row-count-storage": null,
20
22
  "./components/molecules/data-table/data-table-selection-storage": null,
23
+ "./components/molecules/data-table/data-table-view-options": null,
21
24
  "./components/molecules/direction-link": null,
25
+ "./components/molecules/id-chip-chrome": null,
22
26
  "./components/molecules/time-tooltip": null,
23
- "./lib/*": "./src/lib/*.ts",
24
- "./lib/control-name": null,
25
- "./lib/dialog-padding": null,
26
- "./lib/env": null,
27
- "./lib/menu-item": null,
28
- "./lib/popup-align": null,
29
- "./lib/popup-direction": null,
30
- "./lib/popup-motion": null,
31
- "./lib/trigger-slot": null,
27
+ "./lib/base-ui": "./src/lib/base-ui.ts",
28
+ "./lib/date-value": "./src/lib/date-value.ts",
29
+ "./lib/format-relative": "./src/lib/format-relative.ts",
30
+ "./lib/state-dictionary": "./src/lib/state-dictionary.ts",
31
+ "./lib/tone-icons": "./src/lib/tone-icons.ts",
32
+ "./lib/utils": "./src/lib/utils.ts",
32
33
  "./hooks/*": "./src/hooks/*.ts",
33
34
  "./hooks/use-active-label-size": null,
34
35
  "./hooks/use-pinned-height": null,
@@ -50,7 +51,7 @@
50
51
  "pack:check": "bun pm pack --dry-run"
51
52
  },
52
53
  "peerDependencies": {
53
- "@vendure-io/design-tokens": "^3.0.0-next.2",
54
+ "@vendure-io/design-tokens": "^3.0.0-next.3",
54
55
  "react": ">=19",
55
56
  "react-dom": ">=19",
56
57
  "next": ">=14",
@@ -6,7 +6,6 @@ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
7
  import { Button } from "@vendure-io/ui/components/atoms/button"
8
8
  import { usePopupDir } from "../../lib/popup-direction.ts"
9
- import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
10
9
  import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
11
10
  import { triggerSlot } from "../../lib/trigger-slot.ts"
12
11
 
@@ -45,7 +44,6 @@ function AlertDialogOverlay({
45
44
  function AlertDialogContent({
46
45
  className,
47
46
  size = "default",
48
- style,
49
47
  ...props
50
48
  }: AlertDialogPrimitive.Popup.Props & {
51
49
  size?: "default" | "sm"
@@ -54,7 +52,7 @@ function AlertDialogContent({
54
52
  return (
55
53
  <AlertDialogPortal>
56
54
  <AlertDialogOverlay />
57
- {/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; the header and the footer stick to its edges, as in DialogContent. The padding is `--dialog-padding`, which a `p-*` or `px-*` class also sets (dialogPaddingStyle), and the scroll padding keeps a focused field clear of the header and the footer. */}
55
+ {/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; the header and the footer stick to its edges, as in DialogContent. The padding is `--dialog-padding`; change the variable, not the padding, and the scroll padding keeps a focused field clear of the header and the footer. */}
58
56
  <AlertDialogPrimitive.Popup
59
57
  dir={dir}
60
58
  data-slot="alert-dialog-content"
@@ -63,7 +61,6 @@ function AlertDialogContent({
63
61
  "bg-overlay shadow-overlay group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid grid-cols-[minmax(0,1fr)] max-h-[calc(100dvh-2rem)] w-full -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))] 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 data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-110",
64
62
  className
65
63
  )}
66
- style={dialogPaddingStyle(className, style)}
67
64
  {...props}
68
65
  />
69
66
  </AlertDialogPortal>
@@ -1,9 +1,11 @@
1
1
  import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
2
+ import { cva } from "class-variance-authority"
3
3
 
4
4
  import { cn } from "@vendure-io/ui/lib/utils"
5
- import { alertTint, alertToneVars } from "@vendure-io/ui/lib/tint-recipes"
5
+ import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
6
+ import { alertTint, alertToneVars } from "../../lib/tint-recipes.ts"
6
7
  import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
8
+ import { warnDeprecated } from "../../lib/deprecated.ts"
7
9
 
8
10
  // Alert is an inline-size container so AlertAction can move under the text when
9
11
  // the alert is narrow. A container cannot size to its content: an Alert inside a
@@ -16,9 +18,11 @@ import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
16
18
  // mixed into the cool surface it reads grey. The modes switch the
17
19
  // --alert-fill and --alert-border properties, not the utilities, so a
18
20
  // consumer's bg-* or border-* class wins in both modes. The icon takes the
19
- // tone's text slot. Warning tints with the brighter warning-indicator, as an
21
+ // tone's text slot. The tones are the state dictionary's, with the StatusBadge
22
+ // recipe: critical tints with destructive-text, progress with info-text and a
23
+ // spinner. Warning tints with the brighter warning-indicator, as an
20
24
  // amber text colour mixes to brown. The title stays foreground and the
21
- // description foreground-secondary in every variant, because a muted grey on
25
+ // description foreground-secondary in every tone, because a muted grey on
22
26
  // a tinted fill falls below text contrast.
23
27
  // The recipe lives in lib/tint-recipes.ts, which the contrast test in
24
28
  // @vendure-io/design-tokens reads.
@@ -28,60 +32,80 @@ const tonedAlert = alertTint
28
32
  // place, 240ms ease-out (@starting-style: nothing runs after it). Reduced motion
29
33
  // keeps the fade. Content padding is 12px inline, 10px block.
30
34
  const alertVariants = cva(
31
- "@container/alert grid grid-cols-[minmax(0,1fr)] rounded-xl border px-3 py-2.5 text-start text-sm has-[>svg]:grid-cols-[auto_minmax(0,1fr)] has-[>[data-slot=alert-action]]:grid-cols-[minmax(0,1fr)_auto] has-[>svg]:has-[>[data-slot=alert-action]]:grid-cols-[auto_minmax(0,1fr)_auto] *:[svg]:row-span-2 *:[svg]:me-3 *:[svg]:translate-y-0.5 *:[svg:not([class*='size-'])]:size-4 *:[svg:not([class*='stroke-'])]:stroke-[1.75] [&:has(>svg:not([data-slot=alert-icon]))>[data-slot=alert-icon]]:hidden w-full relative group/alert transition-[opacity,translate] duration-alert-enter ease-out starting:opacity-0 motion-safe:starting:-translate-y-1",
35
+ "@container/alert grid grid-cols-[minmax(0,1fr)] rounded-xl border px-3 py-2.5 text-start text-sm has-[>svg]:grid-cols-[auto_minmax(0,1fr)] has-[>[data-slot=alert-action]]:grid-cols-[minmax(0,1fr)_auto] has-[>svg]:has-[>[data-slot=alert-action]]:grid-cols-[auto_minmax(0,1fr)_auto] *:[svg]:row-span-2 *:[svg]:me-3 *:[svg]:translate-y-0.5 *:[svg:not([class*='size-'])]:size-4 *:[svg:not([class*='stroke-'])]:stroke-[1.75] w-full relative group/alert transition-[opacity,translate] duration-alert-enter ease-out starting:opacity-0 motion-safe:starting:-translate-y-1",
32
36
  {
33
37
  variants: {
34
- variant: {
35
- default: "bg-card text-card-foreground *:[svg]:text-current",
36
- destructive: [
37
- tonedAlert,
38
- alertToneVars.destructive,
39
- ],
40
- warning: [
41
- tonedAlert,
42
- alertToneVars.warning,
43
- ],
38
+ tone: {
39
+ none: "bg-card text-card-foreground *:[svg]:text-current",
40
+ neutral: [tonedAlert, alertToneVars.neutral],
44
41
  info: [tonedAlert, alertToneVars.info],
45
- },
42
+ success: [tonedAlert, alertToneVars.success],
43
+ warning: [tonedAlert, alertToneVars.warning],
44
+ critical: [tonedAlert, alertToneVars.critical],
45
+ progress: [tonedAlert, alertToneVars.progress],
46
+ } satisfies Record<Tone | "none", unknown>,
46
47
  },
47
48
  defaultVariants: {
48
- variant: "default",
49
+ tone: "none",
49
50
  },
50
51
  }
51
52
  )
52
53
 
53
- // A toned variant shows the icon of its tone, the same shape a StatusBadge of
54
- // that tone shows. The default variant has no tone and no icon of its own.
55
- const variantIcons = {
56
- destructive: toneIcons.critical,
57
- warning: toneIcons.warning,
58
- info: toneIcons.info,
59
- } as const
54
+ // The progress spinner turns once per 1.6s, as in StatusBadge, and stands
55
+ // still under reduced motion; the loader shape still says "in motion".
56
+ const spinnerClass = "animate-spin-slow motion-reduce:animate-none"
60
57
 
61
58
  /**
62
- * A toned Alert shows its tone icon unless the caller passes one. An `icon`
63
- * prop replaces it, and so does an svg child (the older way): the tone icon is
64
- * then hidden. `icon={false}` shows no icon.
59
+ * A toned Alert is a faint tint of its tone and shows the tone's icon, the
60
+ * same shape a StatusBadge of that tone shows (`progress` spins it). Without a
61
+ * tone it sits on the card with no icon. `icon` replaces the tone icon, and
62
+ * `icon={false}` shows no icon. Pass the icon here, not as a child.
65
63
  */
64
+ // The 2.x variant names and the tone each one maps to. Remove in 4.0.
65
+ const variantTones = {
66
+ default: undefined,
67
+ destructive: "critical",
68
+ warning: "warning",
69
+ info: "info",
70
+ } as const satisfies Record<string, Tone | undefined>
71
+
66
72
  function Alert({
67
73
  className,
74
+ tone: toneProp,
68
75
  variant,
69
76
  icon,
70
77
  children,
71
78
  ...props
72
- }: React.ComponentProps<"div"> &
73
- VariantProps<typeof alertVariants> & {
74
- /** Replaces the tone icon. `false` or `null` shows no icon. */
75
- icon?: React.ReactNode
76
- }) {
77
- const ToneIcon = variant && variant !== "default" ? variantIcons[variant] : undefined
79
+ }: React.ComponentProps<"div"> & {
80
+ /** The tone from the state dictionary. Leave it out for a plain notice on the card. */
81
+ tone?: Tone
82
+ /**
83
+ * @deprecated Use `tone`: `destructive` is `critical`, `warning` and `info`
84
+ * keep their names, and `default` is no tone. Removed in 4.0.
85
+ */
86
+ variant?: keyof typeof variantTones
87
+ /** Replaces the tone icon. `false` or `null` shows no icon. */
88
+ icon?: React.ReactNode
89
+ }) {
90
+ if (variant !== undefined) warnDeprecated("Alert", "variant", "tone")
91
+ const tone = toneProp ?? (variant === undefined ? undefined : variantTones[variant])
92
+ const ToneIcon = tone ? toneIcons[tone] : undefined
78
93
  const shownIcon =
79
- icon !== undefined ? icon || null : ToneIcon ? <ToneIcon aria-hidden data-slot="alert-icon" /> : null
94
+ icon !== undefined ? (
95
+ icon || null
96
+ ) : ToneIcon ? (
97
+ <ToneIcon
98
+ aria-hidden
99
+ data-slot="alert-icon"
100
+ className={tone === "progress" ? spinnerClass : undefined}
101
+ />
102
+ ) : null
80
103
  return (
81
104
  <div
82
105
  data-slot="alert"
106
+ data-tone={tone}
83
107
  role="alert"
84
- className={cn(alertVariants({ variant }), className)}
108
+ className={cn(alertVariants({ tone: tone ?? "none" }), className)}
85
109
  {...props}
86
110
  >
87
111
  {shownIcon}
@@ -2,7 +2,7 @@ import { mergeProps } from "@base-ui/react/merge-props"
2
2
  import { useRender } from "@base-ui/react/use-render"
3
3
  import { cva, type VariantProps } from "class-variance-authority"
4
4
 
5
- import { contentInsetPull } from "@vendure-io/ui/lib/content-inset"
5
+ import { contentInsetPull } from "../../lib/content-inset.ts"
6
6
  import { cn } from "@vendure-io/ui/lib/utils"
7
7
 
8
8
  // `--content-inset` is the distance from the box to the first letter: the
@@ -10,7 +10,7 @@ import { cn } from "@vendure-io/ui/lib/utils"
10
10
  // and the gap. A DataTable cell pulls the badge back by it, so the text lines
11
11
  // up with the column header.
12
12
  const badgeVariants = cva(
13
- [contentInsetPull, "[--content-inset:calc(var(--spacing)*2+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*5.5+1px)] h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-[color,background-color,border-color] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive overflow-hidden group/badge"],
13
+ [contentInsetPull, "[--content-inset:calc(var(--spacing)*2+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*5.5+1px)] h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-xs font-medium transition-[color,background-color,border-color] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive overflow-hidden group/badge"],
14
14
  {
15
15
  variants: {
16
16
  variant: {
@@ -37,11 +37,15 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.tsx"
37
37
  // Relative: `label-swap` is closed in the package exports.
38
38
  import { LabelSwap } from "./label-swap.tsx"
39
39
  import { menuItem, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
40
+ import { useMessages } from "../../lib/format-messages.ts"
41
+ import { warnDeprecated } from "../../lib/deprecated.ts"
40
42
 
41
- function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
43
+ // `aria-label` defaults to `messages.breadcrumb.nav`, "breadcrumb".
44
+ function Breadcrumb({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"nav">) {
45
+ const t = useMessages("breadcrumb", { nav: ariaLabel })
42
46
  return (
43
47
  <nav
44
- aria-label="breadcrumb"
48
+ aria-label={t.nav}
45
49
  data-slot="breadcrumb"
46
50
  className={cn(className)}
47
51
  {...props}
@@ -130,8 +134,16 @@ function BreadcrumbSeparator({
130
134
 
131
135
  function BreadcrumbEllipsis({
132
136
  className,
137
+ label,
133
138
  ...props
134
- }: React.ComponentProps<"span">) {
139
+ }: React.ComponentProps<"span"> & {
140
+ /**
141
+ * Screen-reader text of the ellipsis.
142
+ * @default `messages.breadcrumb.more`, "More"
143
+ */
144
+ label?: string
145
+ }) {
146
+ const t = useMessages("breadcrumb", { more: label })
135
147
  return (
136
148
  <span
137
149
  data-slot="breadcrumb-ellipsis"
@@ -145,7 +157,7 @@ function BreadcrumbEllipsis({
145
157
  >
146
158
  <MoreHorizontalIcon
147
159
  />
148
- <span className="sr-only">More</span>
160
+ <span className="sr-only">{t.more}</span>
149
161
  </span>
150
162
  )
151
163
  }
@@ -189,7 +201,12 @@ type BreadcrumbSearchMenuOption = Omit<BreadcrumbMenuOption, "render" | "href">
189
201
 
190
202
  /** The props both crumb menus share. */
191
203
  type BreadcrumbMenuBaseProps = {
192
- options: readonly BreadcrumbSearchMenuOption[]
204
+ /**
205
+ * The items to switch to. `undefined` means they are still loading: the
206
+ * open menu shows a loading row, one item tall, in their place. `[]` means
207
+ * there are none.
208
+ */
209
+ options: readonly BreadcrumbSearchMenuOption[] | undefined
193
210
  value: string
194
211
  onValueChange?: (value: string) => void
195
212
  /** Names the list: it heads the menu and starts the crumb's accessible name. */
@@ -215,6 +232,12 @@ type BreadcrumbMenuBaseProps = {
215
232
  * `placeholder` undefined and the skeleton shows.
216
233
  */
217
234
  pending?: boolean
235
+ /**
236
+ * Read while the options load, and after the list label in the pending
237
+ * crumb ("Project: Loading…").
238
+ * @default `messages.breadcrumb.loading`, "Loading…"
239
+ */
240
+ loadingLabel?: string
218
241
  open?: boolean
219
242
  onOpenChange?: (open: boolean) => void
220
243
  defaultOpen?: boolean
@@ -261,7 +284,15 @@ const crumbTriggerClassName =
261
284
  * is known. The skeleton is hidden from screen readers, which hear the
262
285
  * status text instead. A `div`, as the skeleton is one.
263
286
  */
264
- function PendingCrumb({ label, className }: { label: string; className?: string }) {
287
+ function PendingCrumb({
288
+ label,
289
+ loadingLabel,
290
+ className,
291
+ }: {
292
+ label: string
293
+ loadingLabel: string
294
+ className?: string
295
+ }) {
265
296
  return (
266
297
  <div
267
298
  role="status"
@@ -271,7 +302,7 @@ function PendingCrumb({ label, className }: { label: string; className?: string
271
302
  className
272
303
  )}
273
304
  >
274
- <span className="sr-only">{`${label}: Loading…`}</span>
305
+ <span className="sr-only">{`${label}: ${loadingLabel}`}</span>
275
306
  <Skeleton aria-hidden className="h-[0.8lh] w-24 min-w-0 shrink" />
276
307
  </div>
277
308
  )
@@ -290,7 +321,8 @@ function useCrumbTrigger({
290
321
  label,
291
322
  placeholder,
292
323
  open,
293
- }: Pick<BreadcrumbMenuBaseProps, "options" | "value" | "label" | "placeholder"> & {
324
+ }: Pick<BreadcrumbMenuBaseProps, "value" | "label" | "placeholder"> & {
325
+ options: readonly BreadcrumbSearchMenuOption[]
294
326
  open: boolean
295
327
  }) {
296
328
  const found = options.findIndex((option) => option.value === value)
@@ -427,6 +459,7 @@ function BreadcrumbMenu({
427
459
  label,
428
460
  placeholder,
429
461
  pending = false,
462
+ loadingLabel,
430
463
  open: openProp,
431
464
  onOpenChange,
432
465
  defaultOpen = false,
@@ -434,14 +467,21 @@ function BreadcrumbMenu({
434
467
  className,
435
468
  contentClassName,
436
469
  }: Omit<BreadcrumbMenuBaseProps, "options"> & {
437
- options: readonly BreadcrumbMenuOption[]
470
+ /**
471
+ * The items to switch to. `undefined` means they are still loading: the
472
+ * open menu shows a loading row, one item tall, in their place. `[]` means
473
+ * there are none.
474
+ */
475
+ options: readonly BreadcrumbMenuOption[] | undefined
438
476
  children?: React.ReactNode
439
477
  }) {
440
478
  const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
441
- const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
479
+ const crumb = useCrumbTrigger({ options: options ?? [], value, label, placeholder, open })
480
+ const t = useMessages("breadcrumb", { loading: loadingLabel })
442
481
  // Without a name, a skeleton. The trigger mounts with the first name, so
443
482
  // it shows without a swap.
444
- if (pending && !crumb.named) return <PendingCrumb label={label} className={className} />
483
+ if (pending && !crumb.named)
484
+ return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
445
485
  return (
446
486
  <DropdownMenu open={open} onOpenChange={setOpen}>
447
487
  <Tooltip>
@@ -466,34 +506,51 @@ function BreadcrumbMenu({
466
506
  </Tooltip>
467
507
  <DropdownMenuContent
468
508
  {...popupEventProps}
509
+ aria-busy={options === undefined || undefined}
469
510
  className={cn("w-max min-w-72 max-w-90", contentClassName)}
470
511
  >
471
512
  <DropdownMenuGroup>
472
513
  <DropdownMenuLabel>{label}</DropdownMenuLabel>
473
- <MenuPrimitive.RadioGroup
474
- value={value}
475
- onValueChange={(next: string, details) => {
476
- // A modifier or middle click opens a link row elsewhere: the
477
- // current item stays.
478
- if (isNewTabClick(details.event)) return
479
- onValueChange?.(next)
480
- }}
481
- >
482
- {options.map((option) => (
483
- <MenuPrimitive.RadioItem
484
- key={option.value}
485
- value={option.value}
486
- disabled={option.disabled}
487
- closeOnClick={false}
488
- data-slot="breadcrumb-menu-item"
489
- render={option.disabled ? undefined : (option.render ?? (option.href !== undefined ? <a href={option.href} /> : undefined))}
490
- className={cn(menuItem, menuRadioItem)}
491
- >
492
- <OptionRow option={option} />
493
- <MenuCheck />
494
- </MenuPrimitive.RadioItem>
495
- ))}
496
- </MenuPrimitive.RadioGroup>
514
+ {options === undefined ? (
515
+ // A disabled item: a menu takes only items, groups and
516
+ // separators, so a screen reader reads "Loading…" as a dimmed
517
+ // item. One item tall, so the items take its place without a jump.
518
+ <MenuPrimitive.Item
519
+ disabled
520
+ data-slot="breadcrumb-menu-loading"
521
+ // The shared item look: the arrow keys stop on it, so it
522
+ // keeps the focus ring.
523
+ className={cn(menuItem, "text-muted-foreground")}
524
+ >
525
+ <Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
526
+ {t.loading}
527
+ </MenuPrimitive.Item>
528
+ ) : (
529
+ <MenuPrimitive.RadioGroup
530
+ value={value}
531
+ onValueChange={(next: string, details) => {
532
+ // A modifier or middle click opens a link row elsewhere: the
533
+ // current item stays.
534
+ if (isNewTabClick(details.event)) return
535
+ onValueChange?.(next)
536
+ }}
537
+ >
538
+ {options.map((option) => (
539
+ <MenuPrimitive.RadioItem
540
+ key={option.value}
541
+ value={option.value}
542
+ disabled={option.disabled}
543
+ closeOnClick={false}
544
+ data-slot="breadcrumb-menu-item"
545
+ render={option.disabled ? undefined : (option.render ?? (option.href !== undefined ? <a href={option.href} /> : undefined))}
546
+ className={cn(menuItem, menuRadioItem)}
547
+ >
548
+ <OptionRow option={option} />
549
+ <MenuCheck />
550
+ </MenuPrimitive.RadioItem>
551
+ ))}
552
+ </MenuPrimitive.RadioGroup>
553
+ )}
497
554
  </DropdownMenuGroup>
498
555
  {children}
499
556
  </DropdownMenuContent>
@@ -518,17 +575,19 @@ function searchFilter(_value: string, search: string, keywords?: string[]) {
518
575
  * project". The search matches the option labels and `keywords`.
519
576
  *
520
577
  * Picking an option calls `onValueChange` and closes the popup, so the crumb's
521
- * label is seen swapping. `loading` shows a loading row in place of the
522
- * options. `error` shows its text as a row that cannot be picked and, with
523
- * `onRetry`, a Retry row. A search that matches nothing shows `emptyText`.
578
+ * label is seen swapping. `options={undefined}` shows a loading row in place
579
+ * of the options. `error` shows its text as a row that cannot be picked and,
580
+ * with `onRetry`, a Retry row; it wins over the loading row. A search that
581
+ * matches nothing shows `emptyText`.
524
582
  * Footer items are `CommandItem`s with `forceMount`, so a search does not
525
583
  * hide them, and close the popup themselves through `onOpenChange`. *
526
- * `loading` is about the list in the open popup. `pending` is about the
584
+ * `options={undefined}` is about the list in the open popup. `pending` is about the
527
585
  * crumb: while the current item loads, it shows the last known name, or a
528
586
  * text skeleton in place of a placeholder word when no name is known.
529
587
  */
530
588
  function BreadcrumbSearchMenu({
531
- options,
589
+ options: optionsProp,
590
+ loading: loadingProp,
532
591
  value,
533
592
  onValueChange,
534
593
  label,
@@ -537,34 +596,63 @@ function BreadcrumbSearchMenu({
537
596
  open: openProp,
538
597
  onOpenChange,
539
598
  defaultOpen = false,
540
- searchPlaceholder = `Find ${label.toLowerCase()}…`,
541
- emptyText = "No results.",
542
- loading = false,
599
+ searchPlaceholder,
600
+ emptyText,
543
601
  error,
544
602
  onRetry,
603
+ loadingLabel,
604
+ retryLabel,
545
605
  children,
546
606
  className,
547
607
  contentClassName,
548
608
  }: BreadcrumbMenuBaseProps & {
549
- /** The search field's placeholder. Default: "Find <label>…". */
609
+ /**
610
+ * The search field's placeholder.
611
+ * @default `messages.breadcrumb.search`, "Find {label}…", with `{label}` the menu's `label` in lower case
612
+ */
550
613
  searchPlaceholder?: string
551
- /** Shows when the search matches no option. */
614
+ /**
615
+ * Shows when the search matches no option.
616
+ * @default `messages.breadcrumb.empty`, "No results."
617
+ */
552
618
  emptyText?: React.ReactNode
553
- /** The options are on their way: a loading row shows in their place. */
554
- loading?: boolean
555
619
  /** The options could not be read: this text shows as a row. */
556
620
  error?: React.ReactNode
557
621
  /** With `error`, a Retry row calls it. */
558
622
  onRetry?: () => void
623
+ /**
624
+ * The text of the Retry row.
625
+ * @default `messages.breadcrumb.retry`, "Retry"
626
+ */
627
+ retryLabel?: string
628
+ /**
629
+ * @deprecated Pass `options={undefined}` while the options load. Removed
630
+ * in 4.0.
631
+ */
632
+ loading?: boolean
559
633
  /** Footer items: `CommandItem`s with `forceMount`. */
560
634
  children?: React.ReactNode
561
635
  }) {
636
+ if (loadingProp !== undefined) {
637
+ warnDeprecated("BreadcrumbSearchMenu", "loading", "options={undefined}")
638
+ }
639
+ // The 2.x `loading` flag stands for `options={undefined}` in the list. The
640
+ // crumb still names the current option from the options it has.
641
+ const options = loadingProp ? undefined : optionsProp
562
642
  const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
563
- const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
643
+ const crumb = useCrumbTrigger({ options: optionsProp ?? [], value, label, placeholder, open })
644
+ const t = useMessages("breadcrumb", {
645
+ loading: loadingLabel,
646
+ retry: retryLabel,
647
+ search: searchPlaceholder,
648
+ })
564
649
  const failed = error != null && error !== false
650
+ // The error wins: a failed first read has no options either.
651
+ const loading = options === undefined && !failed
565
652
  // Without a name, a skeleton. The trigger mounts with the first name, so
566
653
  // it shows without a swap.
567
- if (pending && !crumb.named) return <PendingCrumb label={label} className={className} />
654
+ if (pending && !crumb.named)
655
+ return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
568
656
  return (
569
657
  <Popover open={open} onOpenChange={setOpen}>
570
658
  <Tooltip>
@@ -597,31 +685,38 @@ function BreadcrumbSearchMenu({
597
685
  selected after it unmounts, and the field then points at a row
598
686
  that is gone (aria-activedescendant). */}
599
687
  <Command key={failed ? "failed" : "read"} label={label} filter={searchFilter}>
600
- <CommandInput autoFocus placeholder={searchPlaceholder} />
601
- {/* Outside the list: a listbox takes only options and groups. */}
688
+ <CommandInput autoFocus placeholder={t.search.replaceAll("{label}", label.toLowerCase())} />
689
+ {/* Outside the list: a listbox takes only options and groups. As
690
+ tall as one option row with its group's padding, so one
691
+ option takes its place without a jump. */}
692
+ {/* Stays mounted, so screen readers announce the change: a status
693
+ that mounts with its text is not reliably read. */}
694
+ <div role="status" data-slot="breadcrumb-search-menu-status" className="sr-only">
695
+ {loading ? t.loading : null}
696
+ </div>
602
697
  {loading && (
603
698
  <div
604
- role="status"
699
+ aria-hidden
605
700
  data-slot="breadcrumb-search-menu-loading"
606
- className="text-muted-foreground flex min-h-8.5 items-center gap-2.5 px-4 pt-2.5 pb-1 text-sm"
701
+ className="text-muted-foreground flex min-h-10 items-center gap-2.5 px-4 pt-2 text-sm"
607
702
  >
608
703
  <Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
609
- Loading…
704
+ {t.loading}
610
705
  </div>
611
706
  )}
612
- <CommandList>
613
- {!loading && !failed && <CommandEmpty>{emptyText}</CommandEmpty>}
614
- {failed && !loading && (
707
+ <CommandList aria-busy={loading || undefined}>
708
+ {!loading && !failed && <CommandEmpty>{emptyText !== undefined ? emptyText : t.empty}</CommandEmpty>}
709
+ {failed && (
615
710
  <CommandGroup forceMount heading={error}>
616
711
  {onRetry && (
617
712
  <CommandItem forceMount value="__retry" onSelect={onRetry}>
618
713
  <RefreshCwIcon />
619
- <span className="min-w-0 truncate">Retry</span>
714
+ <span className="min-w-0 truncate">{t.retry}</span>
620
715
  </CommandItem>
621
716
  )}
622
717
  </CommandGroup>
623
718
  )}
624
- {!loading && options.length > 0 && (
719
+ {options !== undefined && options.length > 0 && (
625
720
  <CommandGroup>
626
721
  {options.map((option) => (
627
722
  <CommandItem
@@ -3,7 +3,7 @@ import { useRender } from "@base-ui/react/use-render"
3
3
  import { cva, type VariantProps } from "class-variance-authority"
4
4
 
5
5
  import { cn } from "@vendure-io/ui/lib/utils"
6
- import { outlineEdgeRing } from "@vendure-io/ui/lib/outline-edge"
6
+ import { outlineEdgeRing } from "../../lib/outline-edge.ts"
7
7
  import { Separator } from "@vendure-io/ui/components/atoms/separator"
8
8
 
9
9
  // The v3 look: the group draws one outer edge and its children draw none.
@@ -8,9 +8,9 @@ import { cva, type VariantProps } from "class-variance-authority"
8
8
 
9
9
  // Relative: `label-swap` is closed in the package exports.
10
10
  import { LabelSwap } from "./label-swap.tsx"
11
- import { contentInsetPull } from "@vendure-io/ui/lib/content-inset"
11
+ import { contentInsetPull } from "../../lib/content-inset.ts"
12
12
  import { cn } from "@vendure-io/ui/lib/utils"
13
- import { outlineEdge, outlineEdgeHover } from "@vendure-io/ui/lib/outline-edge"
13
+ import { outlineEdge, outlineEdgeHover } from "../../lib/outline-edge.ts"
14
14
  import { isDevelopment } from "../../lib/env.ts"
15
15
 
16
16
  // The v3 look: 34px default and 28px sm, the xl radius, 14px medium text.
@@ -99,7 +99,7 @@ function Calendar({
99
99
  table: "w-full border-collapse",
100
100
  weekdays: cn("flex", defaultClassNames.weekdays),
101
101
  weekday: cn(
102
- "text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-[0.8rem] select-none",
102
+ "text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-xs select-none",
103
103
  defaultClassNames.weekday
104
104
  ),
105
105
  week: cn("flex w-full mt-2", defaultClassNames.week),
@@ -108,7 +108,7 @@ function Calendar({
108
108
  defaultClassNames.week_number_header
109
109
  ),
110
110
  week_number: cn(
111
- "text-[0.8rem] select-none text-muted-foreground",
111
+ "text-xs select-none text-muted-foreground",
112
112
  defaultClassNames.week_number
113
113
  ),
114
114
  day: cn(