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

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/components/atoms/breadcrumb.tsx +31 -11
  3. package/src/components/atoms/carousel.tsx +33 -7
  4. package/src/components/atoms/combobox.tsx +144 -17
  5. package/src/components/atoms/command.tsx +14 -4
  6. package/src/components/atoms/pagination.tsx +43 -12
  7. package/src/components/atoms/sidebar.tsx +24 -5
  8. package/src/components/atoms/spinner.tsx +7 -2
  9. package/src/components/molecules/action-needed.tsx +4 -4
  10. package/src/components/molecules/anonymized-token.tsx +19 -18
  11. package/src/components/molecules/app-shell.tsx +14 -5
  12. package/src/components/molecules/checklist/checklist.tsx +47 -17
  13. package/src/components/molecules/choice-card.tsx +3 -0
  14. package/src/components/molecules/confirm-dialog.tsx +6 -4
  15. package/src/components/molecules/data-table/data-table-filters.tsx +25 -7
  16. package/src/components/molecules/data-table/data-table-types.tsx +33 -16
  17. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  18. package/src/components/molecules/data-table/data-table.tsx +47 -26
  19. package/src/components/molecules/data-table/table-pagination.tsx +51 -29
  20. package/src/components/molecules/date-picker.tsx +4 -2
  21. package/src/components/molecules/date-range-picker.tsx +6 -2
  22. package/src/components/molecules/date-time-picker.tsx +4 -2
  23. package/src/components/molecules/file-dropzone.tsx +16 -5
  24. package/src/components/molecules/id-chip.tsx +10 -8
  25. package/src/components/molecules/issued-secret.tsx +34 -24
  26. package/src/components/molecules/multi-select.tsx +470 -107
  27. package/src/components/molecules/secret-value.tsx +26 -18
  28. package/src/components/molecules/skip-link.tsx +11 -9
  29. package/src/components/molecules/stat-card.tsx +2 -0
  30. package/src/components/molecules/state-views/error-state.tsx +18 -6
  31. package/src/components/molecules/state-views/loading-state.tsx +2 -0
  32. package/src/components/molecules/status-badge.tsx +5 -2
  33. package/src/lib/chip-fit.ts +62 -0
  34. package/src/lib/format-messages.ts +189 -0
  35. package/src/lib/multi-select-keys.ts +77 -0
@@ -286,9 +286,17 @@ function Sidebar({
286
286
  function SidebarTrigger({
287
287
  className,
288
288
  onClick,
289
+ label,
289
290
  ...props
290
- }: React.ComponentProps<typeof Button>) {
291
+ }: React.ComponentProps<typeof Button> & {
292
+ /**
293
+ * Screen-reader text of the button.
294
+ * @default `messages.sidebar.toggle`, "Toggle Sidebar"
295
+ */
296
+ label?: string
297
+ }) {
291
298
  const { toggleSidebar } = useSidebar()
299
+ const t = useMessages("sidebar", { toggle: label })
292
300
 
293
301
  return (
294
302
  <Button
@@ -304,22 +312,33 @@ function SidebarTrigger({
304
312
  {...props}
305
313
  >
306
314
  <PanelLeftIcon />
307
- <span className="sr-only">Toggle Sidebar</span>
315
+ <span className="sr-only">{t.toggle}</span>
308
316
  </Button>
309
317
  )
310
318
  }
311
319
 
312
- function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
320
+ function SidebarRail({
321
+ className,
322
+ label,
323
+ ...props
324
+ }: React.ComponentProps<"button"> & {
325
+ /**
326
+ * Accessible name and tooltip of the rail.
327
+ * @default `messages.sidebar.toggle`, "Toggle Sidebar"
328
+ */
329
+ label?: string
330
+ }) {
313
331
  const { toggleSidebar } = useSidebar()
332
+ const t = useMessages("sidebar", { toggle: label })
314
333
 
315
334
  return (
316
335
  <button
317
336
  data-sidebar="rail"
318
337
  data-slot="sidebar-rail"
319
- aria-label="Toggle Sidebar"
338
+ aria-label={t.toggle}
320
339
  tabIndex={-1}
321
340
  onClick={toggleSidebar}
322
- title="Toggle Sidebar"
341
+ title={t.toggle}
323
342
  className={cn(
324
343
  "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
344
  "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",
@@ -1,9 +1,14 @@
1
+ "use client"
2
+
1
3
  import { cn } from "@vendure-io/ui/lib/utils"
2
4
  import { Loader2Icon } from "lucide-react"
5
+ import { useMessages } from "../../lib/format-messages.ts"
3
6
 
4
- function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
7
+ // `aria-label` defaults to `messages.spinner.loading`, "Loading".
8
+ function Spinner({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"svg">) {
9
+ const t = useMessages("spinner", { loading: ariaLabel })
5
10
  return (
6
- <Loader2Icon role="status" aria-label="Loading" className={cn("size-4 animate-spin motion-reduce:animate-none", className)} {...props} />
11
+ <Loader2Icon role="status" aria-label={t.loading} className={cn("size-4 animate-spin motion-reduce:animate-none", className)} {...props} />
7
12
  )
8
13
  }
9
14
 
@@ -382,9 +382,9 @@ function ActionNeeded<T extends ActionNeededItem>({
382
382
  <span
383
383
  aria-hidden={open || undefined}
384
384
  data-slot="action-needed-counts"
385
- // The badges overlap the line's padding, so the title line keeps the text's
386
- // height and the space above the title equals the space under the last row.
387
- className="-my-1 flex min-w-0 flex-wrap items-center gap-1.5"
385
+ // The badges are bare, as high as the title text, so they sit inside the title
386
+ // line. The column gap is twice the icon-to-label gap, so two tones read apart.
387
+ className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1"
388
388
  >
389
389
  {actionNeededCounts(items).map(({ tone, count }, index) => (
390
390
  <span
@@ -394,7 +394,7 @@ function ActionNeeded<T extends ActionNeededItem>({
394
394
  className={badgeClass}
395
395
  style={{ '--i': index } as CSSProperties}
396
396
  >
397
- <StatusBadge className="tabular-nums" size="lg" tone={tone}>
397
+ <StatusBadge appearance="bare" className="tabular-nums" size="lg" tone={tone}>
398
398
  {countLabel(count, tone)}
399
399
  </StatusBadge>
400
400
  </span>
@@ -51,9 +51,9 @@ interface AnonymizedTokenProps extends Omit<React.ComponentProps<'span'>, 'child
51
51
  previewSuffixLength?: number;
52
52
  /** Text placed between visible preview segments. @default "..." */
53
53
  previewSeparator?: string;
54
- /** Accessible name while the preview is blurred. @default "Partially obscured token" */
54
+ /** Accessible name while the preview is blurred. @default `messages.anonymizedToken.obscured`, "Partially obscured token" */
55
55
  obscuredLabel?: string;
56
- /** Accessible name while the preview is sharp. @default "Partially visible token" */
56
+ /** Accessible name while the preview is sharp. @default `messages.anonymizedToken.preview`, "Partially visible token" */
57
57
  previewLabel?: string;
58
58
  /** Rendered when `value` is `null` or `''`. @default "—" */
59
59
  fallback?: React.ReactNode;
@@ -67,9 +67,9 @@ interface AnonymizedTokenProps extends Omit<React.ComponentProps<'span'>, 'child
67
67
  onCopied?: CopyButtonProps['onCopied'];
68
68
  /** Called when the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
69
69
  onCopyError?: CopyButtonProps['onCopyError'];
70
- /** Accessible label before copying. @default "Copy token" */
70
+ /** Accessible label before copying. @default `messages.anonymizedToken.copy`, "Copy token" */
71
71
  copyLabel?: CopyButtonProps['copyLabel'];
72
- /** Accessible label while the copied state is active. @default "Token copied" */
72
+ /** Accessible label while the copied state is active. @default `messages.anonymizedToken.copied`, "Token copied" */
73
73
  copiedLabel?: CopyButtonProps['copiedLabel'];
74
74
  }
75
75
 
@@ -86,16 +86,16 @@ function AnonymizedToken({
86
86
  previewPrefixLength = 8,
87
87
  previewSuffixLength = 4,
88
88
  previewSeparator = '...',
89
- obscuredLabel = 'Partially obscured token',
90
- previewLabel = 'Partially visible token',
89
+ obscuredLabel,
90
+ previewLabel,
91
91
  fallback = '—',
92
92
  loadingLabel,
93
93
  copyable = true,
94
94
  timeout,
95
95
  onCopied,
96
96
  onCopyError,
97
- copyLabel = 'Copy token',
98
- copiedLabel = 'Token copied',
97
+ copyLabel,
98
+ copiedLabel,
99
99
  className,
100
100
  onMouseEnter,
101
101
  onMouseLeave,
@@ -105,7 +105,13 @@ function AnonymizedToken({
105
105
  }: AnonymizedTokenProps) {
106
106
  const [previewRevealed, setPreviewRevealed] = useState(false);
107
107
  const action = useCopyAction({ timeout, onCopied, onCopyError });
108
- const t = useMessages('anonymizedToken', { loading: loadingLabel });
108
+ const t = useMessages('anonymizedToken', {
109
+ loading: loadingLabel,
110
+ obscured: obscuredLabel,
111
+ preview: previewLabel,
112
+ copy: copyLabel,
113
+ copied: copiedLabel,
114
+ });
109
115
 
110
116
  // The skeleton is the chip's own box: 24px tall, rounded like the chip and
111
117
  // as wide as the preview this token will show (prefix, separator and
@@ -200,13 +206,13 @@ function AnonymizedToken({
200
206
  >
201
207
  {preview}
202
208
  </code>
203
- <span className="sr-only">{showRevealed ? previewLabel : obscuredLabel}</span>
209
+ <span className="sr-only">{showRevealed ? t.preview : t.obscured}</span>
204
210
  {copyable ? (
205
211
  <CopyButton
206
212
  value={value}
207
213
  copyAction={action}
208
- copyLabel={copyLabel}
209
- copiedLabel={copiedLabel}
214
+ copyLabel={t.copy}
215
+ copiedLabel={t.copied}
210
216
  {...chipCopyButtonProps}
211
217
  />
212
218
  ) : null}
@@ -217,12 +223,7 @@ function AnonymizedToken({
217
223
 
218
224
  // The whole chip copies, like `IdChip`. The tooltip never shows the value.
219
225
  return (
220
- <ChipCopyTooltip
221
- chip={chip}
222
- copied={action.copied}
223
- copyLabel={copyLabel}
224
- copiedLabel={copiedLabel}
225
- />
226
+ <ChipCopyTooltip chip={chip} copied={action.copied} copyLabel={t.copy} copiedLabel={t.copied} />
226
227
  );
227
228
  }
228
229
 
@@ -68,6 +68,12 @@ function AppShellContent({ className, ...props }: React.ComponentProps<'div'>) {
68
68
  // centred in 52px), and 12px to the divider after it (the 6px gap plus a
69
69
  // 6px end margin). The header owns these margins, so a margin a consumer
70
70
  // puts on the toggle does not apply.
71
+ //
72
+ // The end padding (pe-4) is the page gutter, --app-shell-page-gutter in
73
+ // pageFrameClassName, so the last item in the header ends where the page
74
+ // content does. The header is outside the page frame and cannot read that
75
+ // variable: change both together. On a window wider than the frame, the
76
+ // centred page ends before the header.
71
77
  const headerToggleClassName =
72
78
  '[&_[data-slot=sidebar-trigger]]:ms-0 [&_[data-slot=sidebar-trigger]]:me-1.5';
73
79
 
@@ -76,7 +82,8 @@ function AppShellHeader({ className, ...props }: React.ComponentProps<'header'>)
76
82
  <header
77
83
  data-slot="app-shell-header"
78
84
  className={cn(
79
- 'bg-background md:in-[[data-variant=inset]~[data-slot=sidebar-inset]]:bg-surface sticky top-0 z-10 flex h-13 shrink-0 items-center gap-1.5 pe-5 ps-3 shadow-[inset_0_-1px_0_var(--border)] forced-colors:after:pointer-events-none forced-colors:after:absolute forced-colors:after:inset-x-0 forced-colors:after:bottom-0 forced-colors:after:border-b forced-colors:after:border-[CanvasText]',
85
+ // biome-ignore lint/plugin/no-raw-shadow: the header hairline is an inset shadow so it never adds height
86
+ 'bg-background md:in-[[data-variant=inset]~[data-slot=sidebar-inset]]:bg-surface sticky top-0 z-10 flex h-13 shrink-0 items-center gap-1.5 pe-4 ps-3 shadow-[inset_0_-1px_0_var(--border)] forced-colors:after:pointer-events-none forced-colors:after:absolute forced-colors:after:inset-x-0 forced-colors:after:bottom-0 forced-colors:after:border-b forced-colors:after:border-[CanvasText]',
80
87
  headerToggleClassName,
81
88
  className,
82
89
  )}
@@ -117,9 +124,11 @@ function AppShellMain({
117
124
  const pageEnterClassName = 'animate-page-enter motion-reduce:animate-page-fade';
118
125
 
119
126
  // The page frame: one frame for every app on AppShell. The page is centred in
120
- // AppShellMain, its content is at most 1180px wide, and a gutter of 32px (16px
121
- // below 768px) sits on every side, the top and bottom included. The gutter is
122
- // outside the 1180px, so the frame is at most 1180px plus two gutters wide.
127
+ // AppShellMain, its content is at most 1480px wide, and a 16px gutter sits on
128
+ // every side at every width, the top and bottom included. The gutter is outside
129
+ // the 1480px, so the frame is at most 1480px plus two gutters wide.
130
+ // The end padding of AppShellHeader (pe-4) is the same value as the gutter:
131
+ // change both together.
123
132
  //
124
133
  // The values are CSS variables on the frame, `--app-shell-page-width` and
125
134
  // `--app-shell-page-gutter`, so a descendant can read them (a full-bleed band
@@ -127,7 +136,7 @@ const pageEnterClassName = 'animate-page-enter motion-reduce:animate-page-fade';
127
136
  // A page that wants a narrower column, such as a settings form at `max-w-4xl`,
128
137
  // puts it inside the frame; it stays left-aligned there.
129
138
  const pageFrameClassName =
130
- '[--app-shell-page-width:1180px] [--app-shell-page-gutter:--spacing(4)] md:[--app-shell-page-gutter:--spacing(8)] mx-auto w-full min-w-0 max-w-[calc(var(--app-shell-page-width)+2*var(--app-shell-page-gutter))] p-(--app-shell-page-gutter)';
139
+ '[--app-shell-page-width:1480px] [--app-shell-page-gutter:--spacing(4)] mx-auto w-full min-w-0 max-w-[calc(var(--app-shell-page-width)+2*var(--app-shell-page-gutter))] p-(--app-shell-page-gutter)';
131
140
 
132
141
  // AppShellPage wraps the page inside AppShellMain. It is the page frame (see
133
142
  // pageFrameClassName), and it is the page enter: when it mounts, the page
@@ -10,6 +10,7 @@ import { cn } from '@vendure-io/ui/lib/utils';
10
10
  import { ChevronDown, X } from 'lucide-react';
11
11
  import { AnimatePresence, LayoutGroup, motion, useIsPresent, useReducedMotion } from 'motion/react';
12
12
  import * as React from 'react';
13
+ import { fillMessage, useMessages } from '../../../lib/format-messages.ts';
13
14
 
14
15
  // What was taken from Stealth UI's Checklist: the two lists (open steps, then
15
16
  // a "Completed" group) joined by a shared `layoutId`, so a finished step flies
@@ -166,22 +167,40 @@ type ChecklistProps = Omit<React.ComponentProps<'div'>, 'title' | 'children'> &
166
167
  * hide itself: remove it in this callback.
167
168
  */
168
169
  onDismiss?: () => void;
169
- /** Accessible name of the dismiss button. Default "Dismiss checklist". */
170
+ /**
171
+ * Accessible name of the dismiss button.
172
+ * @default `messages.checklist.dismiss`, "Dismiss checklist"
173
+ */
170
174
  dismissLabel?: string;
171
- /** Label of the group of finished steps. Default "Completed". */
175
+ /**
176
+ * Label of the group of finished steps.
177
+ * @default `messages.checklist.completed`, "Completed"
178
+ */
172
179
  completedLabel?: string;
173
180
  /** Whether the Completed group is open (controlled). */
174
181
  completedOpen?: boolean;
175
182
  /** Whether the Completed group starts open. Default `true`. */
176
183
  defaultCompletedOpen?: boolean;
177
184
  onCompletedOpenChange?: (open: boolean) => void;
178
- /** What a screen reader hears after a done step's label in system mode. Default "done". */
185
+ /**
186
+ * What a screen reader hears after a done step's label in system mode.
187
+ * @default `messages.checklist.stepDone`, "done"
188
+ */
179
189
  stepDoneLabel?: string;
180
- /** What a screen reader hears after an open step's label in system mode. Default "not done". */
190
+ /**
191
+ * What a screen reader hears after an open step's label in system mode.
192
+ * @default `messages.checklist.stepOpen`, "not done"
193
+ */
181
194
  stepOpenLabel?: string;
182
- /** The count beside the title. Default "2 of 6". */
195
+ /**
196
+ * The count beside the title.
197
+ * @default `messages.checklist.count`, "{done} of {total}"
198
+ */
183
199
  formatCount?: (done: number, total: number) => string;
184
- /** What a screen reader hears when the count changes. Default "2 of 6 steps done". */
200
+ /**
201
+ * What a screen reader hears when the count changes.
202
+ * @default `messages.checklist.announcement`, "{done} of {total} steps done"
203
+ */
185
204
  formatAnnouncement?: (done: number, total: number) => string;
186
205
  /** The steps: ChecklistStep elements, as direct children (fragments and arrays are fine). */
187
206
  children?: React.ReactNode;
@@ -219,19 +238,30 @@ function Checklist({
219
238
  mode = 'system',
220
239
  onStepCheckedChange,
221
240
  onDismiss,
222
- dismissLabel = 'Dismiss checklist',
223
- completedLabel = 'Completed',
224
- stepDoneLabel = 'done',
225
- stepOpenLabel = 'not done',
241
+ dismissLabel,
242
+ completedLabel,
243
+ stepDoneLabel,
244
+ stepOpenLabel,
226
245
  completedOpen: completedOpenProp,
227
246
  defaultCompletedOpen = true,
228
247
  onCompletedOpenChange,
229
- formatCount = (done, total) => `${done} of ${total}`,
230
- formatAnnouncement = (done, total) => `${done} of ${total} steps done`,
248
+ formatCount: formatCountProp,
249
+ formatAnnouncement: formatAnnouncementProp,
231
250
  className,
232
251
  children,
233
252
  ...props
234
253
  }: ChecklistProps) {
254
+ const t = useMessages('checklist', {
255
+ dismiss: dismissLabel,
256
+ completed: completedLabel,
257
+ stepDone: stepDoneLabel,
258
+ stepOpen: stepOpenLabel,
259
+ });
260
+ const formatCount =
261
+ formatCountProp ?? ((done: number, total: number) => fillMessage(t.count, { done, total }));
262
+ const formatAnnouncement =
263
+ formatAnnouncementProp ??
264
+ ((done: number, total: number) => fillMessage(t.announcement, { done, total }));
235
265
  const reduce = useReducedMotion() ?? false;
236
266
  const groupId = React.useId();
237
267
  const titleId = React.useId();
@@ -303,8 +333,8 @@ function Checklist({
303
333
  isDone: (id) => doneById.get(id) ?? false,
304
334
  isKnown: (id) => knownBefore.has(id),
305
335
  justDone: (id) => knownBefore.get(id) === false && doneById.get(id) === true,
306
- doneLabel: stepDoneLabel,
307
- openLabel: stepOpenLabel,
336
+ doneLabel: t.stepDone,
337
+ openLabel: t.stepOpen,
308
338
  toggle: (id, checked, input) => {
309
339
  const from = checklistSection(!checked, holdsRef.current[id]);
310
340
  setToggled((prev) => ({ ...prev, [id]: checked }));
@@ -405,7 +435,7 @@ function Checklist({
405
435
  data-slot="checklist-dismiss"
406
436
  variant="ghost"
407
437
  size="icon-sm"
408
- aria-label={dismissLabel}
438
+ aria-label={t.dismiss}
409
439
  onClick={onDismiss}
410
440
  className="-me-1.5"
411
441
  >
@@ -461,7 +491,7 @@ function Checklist({
461
491
  onClick={() => setCompletedOpen(!completedOpen)}
462
492
  className="group/checklist-completed text-foreground-secondary flex min-h-11 w-full cursor-pointer items-center gap-2 ps-(--card-ps) pe-(--card-px) text-start text-sm font-medium outline-none [transition:color_var(--transition-duration-fast)_var(--ease-default),background-color_var(--transition-duration-fast)_var(--ease-default),opacity_var(--transition-duration-moderate)_var(--ease-soft)] data-arrived:starting:opacity-0 hover:bg-muted focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
463
493
  >
464
- {completedLabel}
494
+ {t.completed}
465
495
  <CardCount className="ms-0">{finished.length}</CardCount>
466
496
  <ChevronDown
467
497
  aria-hidden="true"
@@ -476,7 +506,7 @@ function Checklist({
476
506
  <ul
477
507
  id={completedId}
478
508
  data-slot="checklist-completed-steps"
479
- aria-label={completedLabel}
509
+ aria-label={t.completed}
480
510
  className="relative flex flex-col"
481
511
  >
482
512
  <AnimatePresence initial={false} mode="popLayout">
@@ -164,7 +164,9 @@ function SelectedEdge({ edgeId, input }: { edgeId: string; input: ChoiceCardInpu
164
164
  data-slot="choice-card-edge"
165
165
  className="pointer-events-none absolute -inset-px z-10 rounded-[inherit]"
166
166
  style={{
167
+ // biome-ignore lint/plugin/no-raw-shadow: the moving edge draws the same inset ring as the checked card
167
168
  boxShadow: 'inset 0 0 0 2px var(--primary)',
169
+ // biome-ignore lint/plugin/no-raw-radius: motion measures the radius for the layout animation
168
170
  ...(radius !== undefined ? { borderRadius: radius } : null),
169
171
  }}
170
172
  initial={jump && input !== null ? { opacity: 0 } : false}
@@ -210,6 +212,7 @@ const choiceCardVariants = cva(
210
212
  // (inset-0) its corners would take the outer radius and leave a gap
211
213
  // between two strokes. So the card never clips its children: the media
212
214
  // variant rounds the image itself to the padding box instead.
215
+ // biome-ignore lint/plugin/no-raw-shadow: the checked ring is an inset shadow on the card edge
213
216
  'after:pointer-events-none after:absolute after:-inset-px after:z-10 after:rounded-[inherit] after:[transition:box-shadow_var(--transition-duration-fast)_var(--ease-soft)] data-[mode=multiple]:data-checked:border-primary data-[mode=multiple]:data-checked:hover:border-primary data-[mode=multiple]:data-checked:after:shadow-[inset_0_0_0_2px_var(--primary)]',
214
217
  ],
215
218
  {
@@ -66,7 +66,9 @@ interface ConfirmDialogProps {
66
66
  * A rejection leaves the dialog open so the user can retry.
67
67
  */
68
68
  onConfirm: () => void | Promise<void>;
69
+ /** @default `messages.confirmDialog.confirm`, "Confirm" */
69
70
  confirmLabel?: ReactNode;
71
+ /** @default `messages.confirmDialog.cancel`, "Cancel" */
70
72
  cancelLabel?: ReactNode;
71
73
  /**
72
74
  * Screen-reader text of the spinner while `onConfirm` runs.
@@ -118,8 +120,8 @@ function ConfirmDialog({
118
120
  description,
119
121
  body,
120
122
  onConfirm,
121
- confirmLabel = 'Confirm',
122
- cancelLabel = 'Cancel',
123
+ confirmLabel,
124
+ cancelLabel,
123
125
  loadingLabel,
124
126
  variant = 'default',
125
127
  confirmDisabled = false,
@@ -222,7 +224,7 @@ function ConfirmDialog({
222
224
  </p>
223
225
  ) : null}
224
226
  <AlertDialogCancel ref={cancelRef} disabled={pending} className={focusRing}>
225
- {cancelLabel}
227
+ {cancelLabel !== undefined ? cancelLabel : t.cancel}
226
228
  </AlertDialogCancel>
227
229
  {/* AlertDialogAction is a plain Button (not a Close), so closing stays
228
230
  under our control — the promise decides when the dialog leaves. */}
@@ -238,7 +240,7 @@ function ConfirmDialog({
238
240
  className={cn('relative', focusRing)}
239
241
  >
240
242
  <span data-slot="confirm-dialog-label" className={cn(pending && 'opacity-0')}>
241
- {confirmLabel}
243
+ {confirmLabel !== undefined ? confirmLabel : t.confirm}
242
244
  </span>
243
245
  {pending ? (
244
246
  <Spinner aria-label={t.loading} className="absolute inset-0 m-auto" />
@@ -12,7 +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 { useMessages } from '../../../lib/format-messages.ts';
15
+ import { fillMessage, useMessages } from '../../../lib/format-messages.ts';
16
16
 
17
17
  // The two filter surfaces. `DataTableAddFilter` is the core-owned column picker
18
18
  // + value editor (rendered only when `filters.columns` is declared).
@@ -53,6 +53,10 @@ function DefaultFilterInput<TData>({
53
53
  interface DataTableAddFilterProps<TData> {
54
54
  table: Table<TData>;
55
55
  columns: DataTableFilterColumn<TData>[];
56
+ /**
57
+ * The trigger's text.
58
+ * @default `messages.dataTable.addFilter`, "Add filter"
59
+ */
56
60
  label?: string;
57
61
  /**
58
62
  * Placeholder and accessible name of the default value input.
@@ -64,10 +68,10 @@ interface DataTableAddFilterProps<TData> {
64
68
  function DataTableAddFilter<TData>({
65
69
  table,
66
70
  columns,
67
- label = 'Add filter',
71
+ label,
68
72
  valueLabel,
69
73
  }: DataTableAddFilterProps<TData>) {
70
- const t = useMessages('dataTable', { filterValue: valueLabel });
74
+ const t = useMessages('dataTable', { filterValue: valueLabel, addFilter: label });
71
75
  const [open, setOpen] = React.useState(false);
72
76
  const [activeId, setActiveId] = React.useState<string | null>(null);
73
77
  const active = columns.find((column) => column.id === activeId) ?? null;
@@ -86,11 +90,11 @@ function DataTableAddFilter<TData>({
86
90
  render={
87
91
  <Button variant="outline">
88
92
  <ListFilterIcon />
89
- {label}
93
+ {t.addFilter}
90
94
  </Button>
91
95
  }
92
96
  />
93
- <PopoverContent align="start" className="w-64 gap-2 p-2" aria-label={label}>
97
+ <PopoverContent align="start" className="w-64 gap-2 p-2" aria-label={t.addFilter}>
94
98
  {active ? (
95
99
  <div className="flex flex-col gap-2">
96
100
  <button
@@ -196,7 +200,15 @@ interface DataTableAppliedFiltersProps<TData> {
196
200
  table: Table<TData>;
197
201
  columns?: DataTableFilterColumn<TData>[];
198
202
  inlineChipLimit?: number;
203
+ /**
204
+ * Accessible name of a chip's remove button.
205
+ * @default `messages.dataTable.removeFilter`, "Remove {column} filter"
206
+ */
199
207
  removeLabel?: (columnLabel: string) => string;
208
+ /**
209
+ * The chip that holds the filters past `inlineChipLimit`.
210
+ * @default `messages.dataTable.filtersCollapsed`, "{count} filters"
211
+ */
200
212
  collapsedLabel?: (count: number) => string;
201
213
  }
202
214
 
@@ -204,9 +216,15 @@ function DataTableAppliedFilters<TData>({
204
216
  table,
205
217
  columns,
206
218
  inlineChipLimit = Number.POSITIVE_INFINITY,
207
- removeLabel = (columnLabel) => `Remove ${columnLabel} filter`,
208
- collapsedLabel = (count) => `${count} filters`,
219
+ removeLabel: removeLabelProp,
220
+ collapsedLabel: collapsedLabelProp,
209
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 }));
210
228
  const applied = table.getState().columnFilters;
211
229
  if (applied.length === 0) return null;
212
230
 
@@ -315,28 +315,45 @@ export interface DataTableRowSelectProps {
315
315
  }
316
316
 
317
317
  export interface DataTableLabels {
318
- empty?: string; // 'No results'
319
- selectAllRows?: string; // 'Select all rows'
320
- /** Tooltip on the header checkbox while not every row on the page is selected. */
321
- selectAllOnPage?: string; // 'Select all on this page'
322
- /** Tooltip on the header checkbox while every row on the page is selected. */
323
- clearPageSelection?: string; // 'Clear selection on this page'
324
- selectRow?: (index: number) => string; // (i) => `Select row ${i + 1}`
325
- rowActions?: string; // 'Open row actions'
326
- columnsTrigger?: string; // 'Columns'
327
- columnsHeading?: string; // 'Toggle columns'
328
- addFilter?: string; // 'Add filter'
318
+ /** @default `messages.dataTable.empty`, "No results" */
319
+ empty?: string;
320
+ /** @default `messages.dataTable.selectAllRows`, "Select all rows" */
321
+ selectAllRows?: string;
322
+ /**
323
+ * Tooltip on the header checkbox while not every row on the page is selected.
324
+ * @default `messages.dataTable.selectAllOnPage`, "Select all on this page"
325
+ */
326
+ selectAllOnPage?: string;
327
+ /**
328
+ * Tooltip on the header checkbox while every row on the page is selected.
329
+ * @default `messages.dataTable.clearPageSelection`, "Clear selection on this page"
330
+ */
331
+ clearPageSelection?: string;
332
+ /** @default `messages.dataTable.selectRow`, "Select row {row}", with `{row}` the 1-based row number */
333
+ selectRow?: (index: number) => string;
334
+ /** @default `messages.dataTable.rowActions`, "Open row actions" */
335
+ rowActions?: string;
336
+ /** @default `messages.dataTable.columnsTrigger`, "Columns" */
337
+ columnsTrigger?: string;
338
+ /** @default `messages.dataTable.columnsHeading`, "Toggle columns" */
339
+ columnsHeading?: string;
340
+ /** @default `messages.dataTable.addFilter`, "Add filter" */
341
+ addFilter?: string;
329
342
  /**
330
343
  * Placeholder and accessible name of the filter editor's default value input.
331
344
  * @default `messages.dataTable.filterValue`, "Value"
332
345
  */
333
346
  filterValue?: string;
334
- clearFilters?: string; // 'Clear filters'
335
- removeFilter?: (columnLabel: string) => string; // (l) => `Remove ${l} filter`
336
- sortLabel?: (columnLabel: string) => string; // (c) => `Sort by ${c}`
337
- filtersCollapsed?: (count: number) => string; // (n) => `${n} filters`
347
+ /** @default `messages.dataTable.clearFilters`, "Clear filters" */
348
+ clearFilters?: string;
349
+ /** @default `messages.dataTable.removeFilter`, "Remove {column} filter" */
350
+ removeFilter?: (columnLabel: string) => string;
351
+ /** @default `messages.dataTable.sortLabel`, "Sort by {column}" */
352
+ sortLabel?: (columnLabel: string) => string;
353
+ /** @default `messages.dataTable.filtersCollapsed`, "{count} filters" */
354
+ filtersCollapsed?: (count: number) => string;
338
355
  pagination?: {
339
- // forwarded to TablePagination
356
+ // Forwarded to TablePagination, which resolves them against `messages.tablePagination`.
340
357
  navLabel?: string;
341
358
  previousLabel?: string;
342
359
  nextLabel?: string;
@@ -13,6 +13,7 @@ import {
13
13
  } from '@vendure-io/ui/components/atoms/dropdown-menu';
14
14
  import { SlidersHorizontalIcon } from 'lucide-react';
15
15
  // Relative: `data-table-helpers` is closed in the package exports.
16
+ import { useMessages } from '../../../lib/format-messages.ts';
16
17
  import { getHideableLeafColumns } from './data-table-helpers.tsx';
17
18
 
18
19
  // The column picker ("Columns" trigger). Lists only hideable columns (`getCanHide()`), so
@@ -22,7 +23,15 @@ import { getHideableLeafColumns } from './data-table-helpers.tsx';
22
23
 
23
24
  interface DataTableViewOptionsProps<TData> {
24
25
  table: Table<TData>;
26
+ /**
27
+ * The trigger's text.
28
+ * @default `messages.dataTable.columnsTrigger`, "Columns"
29
+ */
25
30
  triggerLabel?: string;
31
+ /**
32
+ * The menu's heading.
33
+ * @default `messages.dataTable.columnsHeading`, "Toggle columns"
34
+ */
26
35
  heading?: string;
27
36
  }
28
37
 
@@ -33,9 +42,10 @@ function columnLabel<TData>(column: Column<TData, unknown>): string {
33
42
 
34
43
  function DataTableViewOptions<TData>({
35
44
  table,
36
- triggerLabel = 'Columns',
37
- heading = 'Toggle columns',
45
+ triggerLabel,
46
+ heading,
38
47
  }: DataTableViewOptionsProps<TData>) {
48
+ const t = useMessages('dataTable', { columnsTrigger: triggerLabel, columnsHeading: heading });
39
49
  const hideableColumns = getHideableLeafColumns(table);
40
50
 
41
51
  return (
@@ -48,7 +58,7 @@ function DataTableViewOptions<TData>({
48
58
  render={
49
59
  <Button variant="outline">
50
60
  <SlidersHorizontalIcon />
51
- {triggerLabel}
61
+ {t.columnsTrigger}
52
62
  </Button>
53
63
  }
54
64
  />
@@ -56,7 +66,7 @@ function DataTableViewOptions<TData>({
56
66
  {/* Base UI ties `GroupLabel` to a `Group` via context: the heading names
57
67
  the toggle group and errors if rendered outside one. */}
58
68
  <DropdownMenuGroup>
59
- <DropdownMenuLabel>{heading}</DropdownMenuLabel>
69
+ <DropdownMenuLabel>{t.columnsHeading}</DropdownMenuLabel>
60
70
  <DropdownMenuSeparator />
61
71
  {hideableColumns.map((column) => (
62
72
  <DropdownMenuCheckboxItem