@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
@@ -5,12 +5,8 @@ import { DirectionProvider } from '@vendure-io/ui/components/atoms/direction';
5
5
  import { ScrollArea, ScrollBar } from '@vendure-io/ui/components/atoms/scroll-area';
6
6
  import { Tooltip, TooltipContent, TooltipTrigger } from '@vendure-io/ui/components/atoms/tooltip';
7
7
  import { useCopyFeedback } from '@vendure-io/ui/components/molecules/copy-feedback-provider';
8
+ import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
8
9
  import { useCopy } from '@vendure-io/ui/hooks/use-copy';
9
- import {
10
- highlightCode,
11
- normalizeLanguage,
12
- type SupportedLanguage,
13
- } from '@vendure-io/ui/lib/highlight';
14
10
  import { cn } from '@vendure-io/ui/lib/utils';
15
11
  import {
16
12
  CheckIcon,
@@ -25,7 +21,14 @@ import { motion, useReducedMotion } from 'motion/react';
25
21
  import { type ComponentProps, type ReactNode, useEffect, useId, useMemo, useState } from 'react';
26
22
  // Relative imports: `code-block/*` is closed in the package exports, so a
27
23
  // `@vendure-io/ui/...` self-reference to these modules fails in consumers.
24
+ import { useMessages } from '../../lib/format-messages.ts';
25
+ import { highlightCode, normalizeLanguage, type SupportedLanguage } from '../../lib/highlight.ts';
28
26
  import { FileTypeIcon, matchFileTypeIcon } from './code-block/file-type-icons.tsx';
27
+ import {
28
+ getStoredPackageManager,
29
+ STORAGE_EVENT,
30
+ setStoredPackageManager,
31
+ } from './code-block/package-manager-storage.ts';
29
32
  import { processCode } from './code-block/process-code.ts';
30
33
  import {
31
34
  isPackageManagerCommand,
@@ -34,6 +37,31 @@ import {
34
37
  transformCommand,
35
38
  } from './code-block/transform-command.tsx';
36
39
 
40
+ /**
41
+ * The texts of a CodeBlock. Each one falls back to `FormatProvider`'s
42
+ * `messages.codeBlock`, then to English.
43
+ */
44
+ interface CodeBlockLabels {
45
+ /** Label of the copy button. @default `messages.codeBlock.copyCode`, "Copy code" */
46
+ copyCode?: string;
47
+ /** Label of the copy button after a copy. @default `messages.codeBlock.copied`, "Copied!" */
48
+ copied?: string;
49
+ /** Header of a shell block with no filename and no package-manager tabs. @default `messages.codeBlock.terminal`, "Terminal" */
50
+ terminal?: string;
51
+ /** Header of a block with no filename and no language. @default `messages.codeBlock.code`, "Code" */
52
+ code?: string;
53
+ /** Label of the button that collapses a long block. @default `messages.codeBlock.showLess`, "Show less" */
54
+ showLess?: string;
55
+ /**
56
+ * Label of the button that expands a long block. `{count}` is replaced by the
57
+ * number of hidden lines, formatted with `FormatProvider`'s `locale`.
58
+ * @default `messages.codeBlock.showMore`, "Show {count} more lines"
59
+ */
60
+ showMore?: string;
61
+ }
62
+
63
+ type CodeBlockTexts = Required<CodeBlockLabels>;
64
+
37
65
  type CodeBlockProps = Omit<ComponentProps<'div'>, 'children'> & {
38
66
  /**
39
67
  * The code to render, as a plain string. Anything else (elements, numbers)
@@ -63,6 +91,8 @@ type CodeBlockProps = Omit<ComponentProps<'div'>, 'children'> & {
63
91
  onCopied?: () => void;
64
92
  /** Called when the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
65
93
  onCopyError?: (error: Error) => void;
94
+ /** Translate the texts of the header, the copy button and the expander. Each text also reads `FormatProvider`'s `messages.codeBlock`. */
95
+ labels?: CodeBlockLabels;
66
96
  };
67
97
 
68
98
  interface CodeBlockActionProps {
@@ -72,42 +102,9 @@ interface CodeBlockActionProps {
72
102
  disabled?: boolean;
73
103
  }
74
104
 
75
- const STORAGE_KEY = 'vendure-ui-package-manager';
76
- const STORAGE_EVENT = 'vendure-ui-package-manager-change';
77
-
78
105
  const COLLAPSE_THRESHOLD = 40; // Lines needed to trigger collapse
79
106
  const COLLAPSED_HEIGHT = 300; // px height when collapsed (roughly 15-20 lines)
80
107
 
81
- /**
82
- * Get the stored package manager preference from localStorage
83
- */
84
- function getStoredPackageManager(): PackageManager {
85
- if (typeof window === 'undefined') return 'npm';
86
- try {
87
- const stored = localStorage.getItem(STORAGE_KEY);
88
- if (stored && PACKAGE_MANAGERS.includes(stored as PackageManager)) {
89
- return stored as PackageManager;
90
- }
91
- } catch {
92
- // localStorage might not be available
93
- }
94
- return 'npm';
95
- }
96
-
97
- /**
98
- * Store the package manager preference in localStorage
99
- */
100
- function setStoredPackageManager(pm: PackageManager): void {
101
- if (typeof window === 'undefined') return;
102
- try {
103
- localStorage.setItem(STORAGE_KEY, pm);
104
- // Dispatch a custom event so other CodeBlock instances can update
105
- window.dispatchEvent(new CustomEvent(STORAGE_EVENT, { detail: pm }));
106
- } catch {
107
- // localStorage might not be available
108
- }
109
- }
110
-
111
108
  /**
112
109
  * Custom hook to manage package manager state with localStorage persistence
113
110
  */
@@ -220,9 +217,10 @@ interface CodeBlockToolbarProps {
220
217
  onCopy: () => void;
221
218
  isCopied: boolean;
222
219
  actions?: ReactNode;
220
+ texts: CodeBlockTexts;
223
221
  }
224
222
 
225
- function CodeBlockToolbar({ onCopy, isCopied, actions }: CodeBlockToolbarProps) {
223
+ function CodeBlockToolbar({ onCopy, isCopied, actions, texts }: CodeBlockToolbarProps) {
226
224
  return (
227
225
  <div className="flex items-center gap-0.5">
228
226
  {actions}
@@ -230,7 +228,7 @@ function CodeBlockToolbar({ onCopy, isCopied, actions }: CodeBlockToolbarProps)
230
228
  icon={
231
229
  isCopied ? <CheckIcon className="size-4 text-success" /> : <CopyIcon className="size-4" />
232
230
  }
233
- label={isCopied ? 'Copied!' : 'Copy code'}
231
+ label={isCopied ? texts.copied : texts.copyCode}
234
232
  onClick={onCopy}
235
233
  />
236
234
  </div>
@@ -299,6 +297,7 @@ interface CodeBlockHeaderProps {
299
297
  onSelectManager?: (pm: PackageManager) => void;
300
298
  toolbar: ReactNode;
301
299
  id: string;
300
+ texts: CodeBlockTexts;
302
301
  }
303
302
 
304
303
  function CodeBlockHeader({
@@ -310,6 +309,7 @@ function CodeBlockHeader({
310
309
  onSelectManager,
311
310
  toolbar,
312
311
  id,
312
+ texts,
313
313
  }: CodeBlockHeaderProps) {
314
314
  const getLabel = () => {
315
315
  if (filename) {
@@ -332,7 +332,7 @@ function CodeBlockHeader({
332
332
  return (
333
333
  <div className="text-muted-foreground flex items-center gap-1.5 text-sm">
334
334
  <TerminalIcon className="size-3.5" />
335
- <span>Terminal</span>
335
+ <span>{texts.terminal}</span>
336
336
  </div>
337
337
  );
338
338
  }
@@ -340,7 +340,7 @@ function CodeBlockHeader({
340
340
  return (
341
341
  <div className="text-muted-foreground flex items-center gap-1.5 text-sm">
342
342
  <CodeIcon className="size-3.5" />
343
- <span>{language ? language.charAt(0).toUpperCase() + language.slice(1) : 'Code'}</span>
343
+ <span>{language ? language.charAt(0).toUpperCase() + language.slice(1) : texts.code}</span>
344
344
  </div>
345
345
  );
346
346
  };
@@ -373,9 +373,11 @@ interface ExpandButtonProps {
373
373
  isExpanded: boolean;
374
374
  hiddenLineCount: number;
375
375
  onToggle: () => void;
376
+ texts: CodeBlockTexts;
376
377
  }
377
378
 
378
- function ExpandButton({ isExpanded, hiddenLineCount, onToggle }: ExpandButtonProps) {
379
+ function ExpandButton({ isExpanded, hiddenLineCount, onToggle, texts }: ExpandButtonProps) {
380
+ const { locale } = useFormatSettings();
379
381
  return (
380
382
  <div className="border-border bg-muted/30 flex items-center justify-center border-t py-2">
381
383
  <Button
@@ -387,12 +389,15 @@ function ExpandButton({ isExpanded, hiddenLineCount, onToggle }: ExpandButtonPro
387
389
  {isExpanded ? (
388
390
  <>
389
391
  <ChevronUpIcon className="size-3.5" />
390
- Show less
392
+ {texts.showLess}
391
393
  </>
392
394
  ) : (
393
395
  <>
394
396
  <ChevronDownIcon className="size-3.5" />
395
- Show {hiddenLineCount} more lines
397
+ {texts.showMore.replace(
398
+ '{count}',
399
+ new Intl.NumberFormat(locale).format(hiddenLineCount),
400
+ )}
396
401
  </>
397
402
  )}
398
403
  </Button>
@@ -473,8 +478,10 @@ export function CodeBlock({
473
478
  actions,
474
479
  onCopied,
475
480
  onCopyError,
481
+ labels,
476
482
  ...props
477
483
  }: CodeBlockProps) {
484
+ const texts = useMessages('codeBlock', labels);
478
485
  const { copied, copy } = useCopy();
479
486
  const copyFeedback = useCopyFeedback();
480
487
  const [activePackageManager, setActivePackageManager] = usePackageManager();
@@ -516,7 +523,9 @@ export function CodeBlock({
516
523
  else (onCopyError ?? copyFeedback.onCopyError)?.(new Error('Failed to copy to the clipboard'));
517
524
  };
518
525
 
519
- const toolbar = <CodeBlockToolbar onCopy={handleCopy} isCopied={copied} actions={actions} />;
526
+ const toolbar = (
527
+ <CodeBlockToolbar onCopy={handleCopy} isCopied={copied} actions={actions} texts={texts} />
528
+ );
520
529
 
521
530
  const showCollapsed = isCollapsible && !isExpanded;
522
531
 
@@ -539,6 +548,7 @@ export function CodeBlock({
539
548
  onSelectManager={setActivePackageManager}
540
549
  toolbar={toolbar}
541
550
  id={instanceId}
551
+ texts={texts}
542
552
  />
543
553
  )}
544
554
 
@@ -591,6 +601,7 @@ export function CodeBlock({
591
601
  isExpanded={isExpanded}
592
602
  hiddenLineCount={hiddenLineCount}
593
603
  onToggle={() => setIsExpanded(!isExpanded)}
604
+ texts={texts}
594
605
  />
595
606
  )}
596
607
  </div>
@@ -598,4 +609,4 @@ export function CodeBlock({
598
609
  }
599
610
 
600
611
  export { CodeBlockAction };
601
- export type { CodeBlockProps, CodeBlockActionProps, PackageManager };
612
+ export type { CodeBlockProps, CodeBlockActionProps, CodeBlockLabels, PackageManager };
@@ -11,9 +11,11 @@ import {
11
11
  InputGroupAddon,
12
12
  InputGroupInput,
13
13
  } from '@vendure-io/ui/components/atoms/input-group';
14
- import { Spinner } from '@vendure-io/ui/components/atoms/spinner';
15
14
  import { cn } from '@vendure-io/ui/lib/utils';
15
+ import { Loader2Icon } from 'lucide-react';
16
16
  import * as React from 'react';
17
+ import { warnDeprecated } from '../../lib/deprecated.ts';
18
+ import { useMessages } from '../../lib/format-messages.ts';
17
19
 
18
20
  export interface ComboboxFreeTextItem {
19
21
  /**
@@ -49,16 +51,34 @@ export interface ComboboxFreeTextProps<T extends ComboboxFreeTextItem = Combobox
49
51
  * debounced against `value` — and they are assumed to be already filtered
50
52
  * (the component does no client-side filtering). Items may carry extra fields
51
53
  * beyond `value`/`label`/`description`; those flow through to `onSelectItem`.
54
+ *
55
+ * `undefined` means the first fetch has not returned yet: the field shows
56
+ * its spinner and the open list shows a loading row, one suggestion tall.
57
+ * `[]` means there are no suggestions: the list stays closed.
58
+ */
59
+ items: readonly T[] | undefined;
60
+ /**
61
+ * A refetch is running and the current `items` stay on screen. Shows the
62
+ * trailing spinner. For the first load, pass `items={undefined}` instead.
52
63
  */
53
- items: readonly T[];
54
- /** Async state of the suggestion source. Shows a trailing spinner while true. */
55
64
  isLoading?: boolean;
56
- /** @deprecated Use `isLoading`. Kept as an alias until the next major. */
65
+ /** @deprecated Use `isLoading`. Removed in 4.0. */
57
66
  loading?: boolean;
67
+ /**
68
+ * Announced by the spinner while the suggestions load.
69
+ * @default `messages.comboboxFreeText.loading`, "Loading…"
70
+ */
71
+ loadingLabel?: string;
58
72
  /** Render a suggestion row. Defaults to `label` over `description`. */
59
73
  renderItem?: (item: T) => React.ReactNode;
60
74
  /** id forwarded to the input. */
61
75
  id?: string;
76
+ /** Form field name of the input. */
77
+ name?: string;
78
+ /** Accessible name of the input, when no visible label points at it. */
79
+ 'aria-label'?: string;
80
+ /** Id of the element that names the input. */
81
+ 'aria-labelledby'?: string;
62
82
  placeholder?: string;
63
83
  /** Render the error state (sets `aria-invalid` on the input). */
64
84
  invalid?: boolean;
@@ -94,20 +114,33 @@ function ComboboxFreeText<T extends ComboboxFreeTextItem = ComboboxFreeTextItem>
94
114
  onValueChange,
95
115
  onSelectItem,
96
116
  items,
97
- isLoading,
117
+ isLoading: isLoadingProp,
98
118
  loading,
119
+ loadingLabel,
99
120
  renderItem = defaultRenderItem,
100
121
  id,
122
+ name,
123
+ 'aria-label': ariaLabel,
124
+ 'aria-labelledby': ariaLabelledBy,
101
125
  placeholder,
102
126
  invalid,
103
127
  disabled,
104
128
  className,
105
129
  }: ComboboxFreeTextProps<T>) {
130
+ if (loading !== undefined) warnDeprecated('ComboboxFreeText', 'loading', 'isLoading');
131
+ const isLoading = isLoadingProp ?? loading;
106
132
  // Base UI opens the popup on every keystroke; we only want it open when there
107
133
  // is something pickable, so a no-match closes it silently instead of flashing
108
134
  // an empty box. `open` tracks the user's intent (typing, Escape, blur,
109
135
  // select) and we AND it with "items present" to derive the rendered state.
136
+ // While the first fetch runs (`items` undefined) the list opens on its
137
+ // loading row, so the field shows that suggestions are coming.
110
138
  const [open, setOpen] = React.useState(false);
139
+ const t = useMessages('comboboxFreeText', { loading: loadingLabel });
140
+ const firstLoad = items === undefined;
141
+ // The list lines up with the whole field, as a Combobox list does. Anchored
142
+ // to the input, it would widen when the trailing spinner goes away.
143
+ const fieldRef = React.useRef<HTMLDivElement>(null);
111
144
 
112
145
  return (
113
146
  <Autocomplete.Root
@@ -123,28 +156,31 @@ function ComboboxFreeText<T extends ComboboxFreeTextItem = ComboboxFreeTextItem>
123
156
  // The literal is checked against Base UI's public `reason` union, so a
124
157
  // future rename surfaces as a type error rather than silent breakage.
125
158
  if (onSelectItem && details.reason === 'item-press') {
126
- const picked = items.find((i) => i.value === next);
159
+ const picked = items?.find((i) => i.value === next);
127
160
  if (picked) {
128
161
  onSelectItem(picked);
129
162
  }
130
163
  }
131
164
  }}
132
- open={open && items.length > 0}
165
+ open={open && (firstLoad || items.length > 0)}
133
166
  onOpenChange={setOpen}
134
167
  disabled={disabled}
135
168
  >
136
- <InputGroup className={cn('w-full', className)}>
169
+ <InputGroup ref={fieldRef} className={cn('w-full', className)}>
137
170
  <Autocomplete.Input
138
171
  render={<InputGroupInput />}
139
172
  id={id}
173
+ name={name}
174
+ aria-label={ariaLabel}
175
+ aria-labelledby={ariaLabelledBy}
140
176
  placeholder={placeholder}
141
177
  disabled={disabled}
142
178
  aria-invalid={invalid || undefined}
143
179
  // Base UI only requests open on a keystroke; for pick-or-create
144
180
  // fields the suggestions should also show on focus/click so a small
145
- // known option set is discoverable without typing. The
146
- // `items.length > 0` gate on `open` keeps an empty popup from
147
- // flashing when there is nothing to pick.
181
+ // known option set is discoverable without typing. The gate on
182
+ // `open` keeps an empty popup from flashing when there is nothing
183
+ // to pick.
148
184
  onFocus={() => setOpen(true)}
149
185
  onClick={() => setOpen(true)}
150
186
  // Enter has a local meaning here — commit the highlighted suggestion
@@ -159,19 +195,38 @@ function ComboboxFreeText<T extends ComboboxFreeTextItem = ComboboxFreeTextItem>
159
195
  }
160
196
  }}
161
197
  />
162
- {(isLoading ?? loading) ? (
198
+ {isLoading || firstLoad ? (
163
199
  <InputGroupAddon align="inline-end">
164
- <Spinner />
200
+ {/* Decorative: the status below announces the load. */}
201
+ <Loader2Icon aria-hidden className="size-4 animate-spin motion-reduce:animate-none" />
165
202
  </InputGroupAddon>
166
203
  ) : null}
167
204
  </InputGroup>
168
- <ComboboxContent>
169
- <ComboboxList>
170
- {items.map((item) => (
171
- <ComboboxItem key={item.value} value={item.value}>
172
- {renderItem(item)}
173
- </ComboboxItem>
174
- ))}
205
+ {/* Stays mounted, so screen readers announce the change: a status
206
+ that mounts with its text is not reliably read. */}
207
+ <Autocomplete.Status data-slot="combobox-free-text-status" className="sr-only">
208
+ {isLoading || firstLoad ? t.loading : null}
209
+ </Autocomplete.Status>
210
+ <ComboboxContent anchor={fieldRef}>
211
+ <ComboboxList aria-busy={isLoading || firstLoad || undefined}>
212
+ {firstLoad ? (
213
+ // Decorative: the status announces the load. One
214
+ // suggestion row tall (the ComboboxItem height), so a single
215
+ // one-line suggestion takes its place without a jump.
216
+ <div
217
+ data-slot="combobox-free-text-loading"
218
+ aria-hidden="true"
219
+ className="text-muted-foreground flex min-h-8.5 items-center justify-center"
220
+ >
221
+ <Loader2Icon className="size-4 motion-safe:animate-spin" />
222
+ </div>
223
+ ) : (
224
+ items.map((item) => (
225
+ <ComboboxItem key={item.value} value={item.value}>
226
+ {renderItem(item)}
227
+ </ComboboxItem>
228
+ ))
229
+ )}
175
230
  </ComboboxList>
176
231
  </ComboboxContent>
177
232
  </Autocomplete.Root>
@@ -21,6 +21,7 @@ import {
21
21
  useRef,
22
22
  useState,
23
23
  } from 'react';
24
+ import { useMessages } from '../../lib/format-messages.ts';
24
25
 
25
26
  // The dialog's buttons show the ring on any focus, not only keyboard focus:
26
27
  // the dialog moves focus itself when it opens, and after a mouse click some
@@ -65,8 +66,15 @@ interface ConfirmDialogProps {
65
66
  * A rejection leaves the dialog open so the user can retry.
66
67
  */
67
68
  onConfirm: () => void | Promise<void>;
69
+ /** @default `messages.confirmDialog.confirm`, "Confirm" */
68
70
  confirmLabel?: ReactNode;
71
+ /** @default `messages.confirmDialog.cancel`, "Cancel" */
69
72
  cancelLabel?: ReactNode;
73
+ /**
74
+ * Screen-reader text of the spinner while `onConfirm` runs.
75
+ * @default `messages.confirmDialog.loading`, "Loading"
76
+ */
77
+ loadingLabel?: string;
70
78
  /**
71
79
  * `default`: Confirm is the filled primary and takes the focus.
72
80
  * `caution`: a costly action that is not destructive ("Deploy anyway" after
@@ -112,8 +120,9 @@ function ConfirmDialog({
112
120
  description,
113
121
  body,
114
122
  onConfirm,
115
- confirmLabel = 'Confirm',
116
- cancelLabel = 'Cancel',
123
+ confirmLabel,
124
+ cancelLabel,
125
+ loadingLabel,
117
126
  variant = 'default',
118
127
  confirmDisabled = false,
119
128
  confirmDisabledReason,
@@ -123,6 +132,7 @@ function ConfirmDialog({
123
132
  open,
124
133
  onOpenChange,
125
134
  }: ConfirmDialogProps) {
135
+ const t = useMessages('confirmDialog', { loading: loadingLabel });
126
136
  const isControlled = open !== undefined;
127
137
  const [internalOpen, setInternalOpen] = useState(false);
128
138
  const [pending, setPending] = useState(false);
@@ -214,7 +224,7 @@ function ConfirmDialog({
214
224
  </p>
215
225
  ) : null}
216
226
  <AlertDialogCancel ref={cancelRef} disabled={pending} className={focusRing}>
217
- {cancelLabel}
227
+ {cancelLabel !== undefined ? cancelLabel : t.cancel}
218
228
  </AlertDialogCancel>
219
229
  {/* AlertDialogAction is a plain Button (not a Close), so closing stays
220
230
  under our control — the promise decides when the dialog leaves. */}
@@ -230,9 +240,11 @@ function ConfirmDialog({
230
240
  className={cn('relative', focusRing)}
231
241
  >
232
242
  <span data-slot="confirm-dialog-label" className={cn(pending && 'opacity-0')}>
233
- {confirmLabel}
243
+ {confirmLabel !== undefined ? confirmLabel : t.confirm}
234
244
  </span>
235
- {pending ? <Spinner className="absolute inset-0 m-auto" /> : null}
245
+ {pending ? (
246
+ <Spinner aria-label={t.loading} className="absolute inset-0 m-auto" />
247
+ ) : null}
236
248
  </AlertDialogAction>
237
249
  </AlertDialogFooter>
238
250
  </AlertDialogContent>
@@ -3,10 +3,11 @@
3
3
  import { Button } from '@vendure-io/ui/components/atoms/button';
4
4
  import { useCopyFeedback } from '@vendure-io/ui/components/molecules/copy-feedback-provider';
5
5
  import { useCopy } from '@vendure-io/ui/hooks/use-copy';
6
- import type { ClipboardSource } from '@vendure-io/ui/lib/clipboard';
7
6
  import { cn } from '@vendure-io/ui/lib/utils';
8
7
  import { CheckIcon, CopyIcon } from 'lucide-react';
9
8
  import type * as React from 'react';
9
+ import type { ClipboardSource } from '../../lib/clipboard.ts';
10
+ import { useMessages } from '../../lib/format-messages.ts';
10
11
 
11
12
  interface UseCopyActionOptions {
12
13
  /** How long `copied` stays true after a successful copy, in ms. @default 2000 */
@@ -88,9 +89,9 @@ interface CopyButtonProps extends Omit<React.ComponentProps<typeof Button>, 'val
88
89
  * Falls back to `CopyFeedbackProvider` when omitted.
89
90
  */
90
91
  onCopyError?: (error: Error) => void;
91
- /** Accessible label before copying. @default "Copy" */
92
+ /** Accessible label before copying. @default `messages.copyButton.copy`, "Copy" */
92
93
  copyLabel?: string;
93
- /** Accessible label shown while the copied state is active. @default "Copied" */
94
+ /** Accessible label shown while the copied state is active. @default `messages.copyButton.copied`, "Copied" */
94
95
  copiedLabel?: string;
95
96
  /**
96
97
  * A shared copy state from `useCopyAction`. When set, the button uses it
@@ -109,8 +110,8 @@ function CopyButton({
109
110
  timeout,
110
111
  onCopied,
111
112
  onCopyError,
112
- copyLabel = 'Copy',
113
- copiedLabel = 'Copied',
113
+ copyLabel,
114
+ copiedLabel,
114
115
  variant = 'ghost',
115
116
  size = 'icon-xs',
116
117
  className,
@@ -120,6 +121,7 @@ function CopyButton({
120
121
  }: CopyButtonProps) {
121
122
  const ownAction = useCopyAction({ timeout, onCopied, onCopyError });
122
123
  const { copied, copy } = copyAction ?? ownAction;
124
+ const t = useMessages('copyButton', { copy: copyLabel, copied: copiedLabel });
123
125
 
124
126
  return (
125
127
  <Button
@@ -127,7 +129,7 @@ function CopyButton({
127
129
  data-slot="copy-button"
128
130
  variant={variant}
129
131
  size={size}
130
- aria-label={copied ? copiedLabel : copyLabel}
132
+ aria-label={copied ? t.copied : t.copy}
131
133
  className={cn('text-muted-foreground hover:text-foreground', className)}
132
134
  onClick={async (event) => {
133
135
  onClick?.(event);
@@ -153,9 +155,9 @@ interface CopyableTextProps {
153
155
  onCopied?: () => void;
154
156
  /** Called when the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
155
157
  onCopyError?: (error: Error) => void;
156
- /** Accessible label before copying, forwarded to the inner `CopyButton`. @default "Copy" */
158
+ /** Accessible label before copying, forwarded to the inner `CopyButton`. @default `messages.copyButton.copy`, "Copy" */
157
159
  copyLabel?: string;
158
- /** Accessible label shown while the copied state is active, forwarded to the inner `CopyButton`. @default "Copied" */
160
+ /** Accessible label shown while the copied state is active, forwarded to the inner `CopyButton`. @default `messages.copyButton.copied`, "Copied" */
159
161
  copiedLabel?: string;
160
162
  }
161
163
 
@@ -12,6 +12,7 @@ import type {
12
12
  import { cn } from '@vendure-io/ui/lib/utils';
13
13
  import { ChevronLeftIcon, ListFilterIcon } from 'lucide-react';
14
14
  import * as React from 'react';
15
+ import { fillMessage, useMessages } from '../../../lib/format-messages.ts';
15
16
 
16
17
  // The two filter surfaces. `DataTableAddFilter` is the core-owned column picker
17
18
  // + value editor (rendered only when `filters.columns` is declared).
@@ -25,10 +26,12 @@ function DefaultFilterInput<TData>({
25
26
  column,
26
27
  value,
27
28
  onChange,
29
+ label,
28
30
  }: {
29
31
  column: DataTableFilterColumn<TData>;
30
32
  value: DataTableFilterValue | undefined;
31
33
  onChange: (next: DataTableFilterValue | undefined) => void;
34
+ label: string;
32
35
  }) {
33
36
  const operator = column.operators?.[0] ?? 'contains';
34
37
  const current = value?.[operator];
@@ -37,7 +40,8 @@ function DefaultFilterInput<TData>({
37
40
  <Input
38
41
  autoFocus
39
42
  value={typeof current === 'string' ? current : ''}
40
- placeholder="Value"
43
+ placeholder={label}
44
+ aria-label={label}
41
45
  onChange={(event) => {
42
46
  const next = event.target.value;
43
47
  onChange(next ? { [operator]: next } : undefined);
@@ -49,14 +53,25 @@ function DefaultFilterInput<TData>({
49
53
  interface DataTableAddFilterProps<TData> {
50
54
  table: Table<TData>;
51
55
  columns: DataTableFilterColumn<TData>[];
56
+ /**
57
+ * The trigger's text.
58
+ * @default `messages.dataTable.addFilter`, "Add filter"
59
+ */
52
60
  label?: string;
61
+ /**
62
+ * Placeholder and accessible name of the default value input.
63
+ * @default `messages.dataTable.filterValue`, "Value"
64
+ */
65
+ valueLabel?: string;
53
66
  }
54
67
 
55
68
  function DataTableAddFilter<TData>({
56
69
  table,
57
70
  columns,
58
- label = 'Add filter',
71
+ label,
72
+ valueLabel,
59
73
  }: DataTableAddFilterProps<TData>) {
74
+ const t = useMessages('dataTable', { filterValue: valueLabel, addFilter: label });
60
75
  const [open, setOpen] = React.useState(false);
61
76
  const [activeId, setActiveId] = React.useState<string | null>(null);
62
77
  const active = columns.find((column) => column.id === activeId) ?? null;
@@ -75,11 +90,11 @@ function DataTableAddFilter<TData>({
75
90
  render={
76
91
  <Button variant="outline">
77
92
  <ListFilterIcon />
78
- {label}
93
+ {t.addFilter}
79
94
  </Button>
80
95
  }
81
96
  />
82
- <PopoverContent align="start" className="w-64 gap-2 p-2">
97
+ <PopoverContent align="start" className="w-64 gap-2 p-2" aria-label={t.addFilter}>
83
98
  {active ? (
84
99
  <div className="flex flex-col gap-2">
85
100
  <button
@@ -101,6 +116,7 @@ function DataTableAddFilter<TData>({
101
116
  column={active}
102
117
  value={tableColumn?.getFilterValue() as DataTableFilterValue | undefined}
103
118
  onChange={(next) => tableColumn?.setFilterValue(next)}
119
+ label={t.filterValue}
104
120
  />
105
121
  )}
106
122
  </div>
@@ -184,7 +200,15 @@ interface DataTableAppliedFiltersProps<TData> {
184
200
  table: Table<TData>;
185
201
  columns?: DataTableFilterColumn<TData>[];
186
202
  inlineChipLimit?: number;
203
+ /**
204
+ * Accessible name of a chip's remove button.
205
+ * @default `messages.dataTable.removeFilter`, "Remove {column} filter"
206
+ */
187
207
  removeLabel?: (columnLabel: string) => string;
208
+ /**
209
+ * The chip that holds the filters past `inlineChipLimit`.
210
+ * @default `messages.dataTable.filtersCollapsed`, "{count} filters"
211
+ */
188
212
  collapsedLabel?: (count: number) => string;
189
213
  }
190
214
 
@@ -192,9 +216,15 @@ function DataTableAppliedFilters<TData>({
192
216
  table,
193
217
  columns,
194
218
  inlineChipLimit = Number.POSITIVE_INFINITY,
195
- removeLabel = (columnLabel) => `Remove ${columnLabel} filter`,
196
- collapsedLabel = (count) => `${count} filters`,
219
+ removeLabel: removeLabelProp,
220
+ collapsedLabel: collapsedLabelProp,
197
221
  }: DataTableAppliedFiltersProps<TData>) {
222
+ const t = useMessages('dataTable');
223
+ const removeLabel =
224
+ removeLabelProp ??
225
+ ((columnLabel: string) => fillMessage(t.removeFilter, { column: columnLabel }));
226
+ const collapsedLabel =
227
+ collapsedLabelProp ?? ((count: number) => fillMessage(t.filtersCollapsed, { count }));
198
228
  const applied = table.getState().columnFilters;
199
229
  if (applied.length === 0) return null;
200
230