@vendure-io/ui 3.0.0-next.0 → 3.0.0-next.2

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 (38) hide show
  1. package/package.json +2 -2
  2. package/src/components/atoms/alert.tsx +13 -6
  3. package/src/components/atoms/avatar.tsx +11 -3
  4. package/src/components/atoms/breadcrumb.tsx +467 -53
  5. package/src/components/atoms/button.tsx +1 -1
  6. package/src/components/atoms/calendar.tsx +11 -2
  7. package/src/components/atoms/combobox.tsx +220 -17
  8. package/src/components/atoms/command.tsx +51 -130
  9. package/src/components/atoms/dialog.tsx +23 -1
  10. package/src/components/atoms/empty.tsx +1 -1
  11. package/src/components/atoms/field.tsx +4 -1
  12. package/src/components/atoms/input-group.tsx +2 -2
  13. package/src/components/atoms/label-swap.tsx +59 -3
  14. package/src/components/atoms/popover.tsx +6 -1
  15. package/src/components/atoms/sheet.tsx +18 -1
  16. package/src/components/atoms/sidebar.tsx +73 -1
  17. package/src/components/atoms/sonner.tsx +1 -1
  18. package/src/components/atoms/table.tsx +133 -10
  19. package/src/components/atoms/tooltip.tsx +3 -3
  20. package/src/components/molecules/chip.tsx +43 -4
  21. package/src/components/molecules/confirm-dialog.tsx +9 -0
  22. package/src/components/molecules/count-badge.tsx +115 -0
  23. package/src/components/molecules/data-table/data-table-filters.tsx +61 -21
  24. package/src/components/molecules/data-table/data-table-helpers.tsx +26 -1
  25. package/src/components/molecules/data-table/data-table-types.tsx +66 -2
  26. package/src/components/molecules/data-table/data-table.tsx +190 -35
  27. package/src/components/molecules/direction-link.tsx +1 -1
  28. package/src/components/molecules/format-provider.tsx +12 -2
  29. package/src/components/molecules/page-header.tsx +1 -1
  30. package/src/components/molecules/search-trigger.tsx +2 -18
  31. package/src/components/molecules/secret-value.tsx +6 -3
  32. package/src/components/molecules/state-views/loading-state.tsx +37 -7
  33. package/src/components/molecules/state-views/skeleton-parts.tsx +245 -0
  34. package/src/components/molecules/status-badge.tsx +2 -2
  35. package/src/components/molecules/timeline.tsx +1 -1
  36. package/src/hooks/use-active-label-size.ts +39 -5
  37. package/src/hooks/use-apple-platform.ts +26 -0
  38. package/src/lib/utils.ts +0 -7
@@ -23,6 +23,7 @@ import {
23
23
  useReactTable,
24
24
  type VisibilityState,
25
25
  } from '@tanstack/react-table';
26
+ import { Button } from '@vendure-io/ui/components/atoms/button';
26
27
  import { Card, CardFooter, CardHeader, CardTable } from '@vendure-io/ui/components/atoms/card';
27
28
  import { Checkbox } from '@vendure-io/ui/components/atoms/checkbox';
28
29
  import {
@@ -64,16 +65,19 @@ import {
64
65
  } from '@vendure-io/ui/components/molecules/data-table/list-header';
65
66
  import { TablePagination } from '@vendure-io/ui/components/molecules/data-table/table-pagination';
66
67
  import { ListRowChevron } from '@vendure-io/ui/components/molecules/list-row';
68
+ import { SkeletonLine } from '@vendure-io/ui/components/molecules/state-views/skeleton-parts';
67
69
  import { cn } from '@vendure-io/ui/lib/utils';
68
70
  import { ChevronRight } from 'lucide-react';
69
71
  import { AnimatePresence, MotionConfig, motion, useReducedMotion } from 'motion/react';
70
72
  import * as React from 'react';
73
+ import { createPortal } from 'react-dom';
71
74
  // Relative: `data-table-helpers` is closed in the package exports.
72
75
  import {
73
76
  buildDisplayColumns,
74
77
  columnAlign,
75
78
  getSelectedRowIds,
76
79
  measureColumnIndents,
80
+ resolveClearFilters,
77
81
  resolveSlot,
78
82
  sameIndents,
79
83
  } from './data-table-helpers.tsx';
@@ -84,25 +88,6 @@ import { useSelectionStorage } from './data-table-selection-storage.tsx';
84
88
  // for the actions cell.
85
89
  const ACTIONS_COLUMN_ID = 'actions';
86
90
 
87
- /**
88
- * One text line of loading placeholder: a box exactly one line box tall (`1lh`
89
- * of the inherited font) with a bar centred in it, so a skeleton line is as tall
90
- * as the text line it stands in for. Size the line with a text utility
91
- * (`text-xs` for a muted sub-line) and its width with `w-*`. DataTable uses it as
92
- * the default loading cell; stack several for multi-line `skeletonCells`.
93
- */
94
- function DataTableSkeletonLine({ className, ...props }: React.ComponentProps<'div'>) {
95
- return (
96
- <div
97
- data-slot="data-table-skeleton-line"
98
- className={cn('flex h-[1lh] w-full items-center', className)}
99
- {...props}
100
- >
101
- <Skeleton className="h-[0.8lh] w-full" />
102
- </div>
103
- );
104
- }
105
-
106
91
  // The row link is a stretched link, like ListRowLink: one real link per row,
107
92
  // whose ::after covers the row (the row is `relative`), so a click on any point
108
93
  // of the row opens it, while keyboard and screen reader users get one tab stop
@@ -128,11 +113,15 @@ const LINKED_ROW_CLASS = cn(
128
113
  // before the click (useSelectAllRipple): the cursor is inherited, so its
129
114
  // change restyles every cell of every row.
130
115
  '[&[data-selecting-cursor]_tr]:cursor-default!',
131
- '[&_tr:has([data-slot=data-table-row-link])_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]):not([data-slot=data-table-row-link],[data-slot=checkbox],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:relative',
132
- '[&_tr:has([data-slot=data-table-row-link])_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]):not([data-slot=data-table-row-link],[data-slot=checkbox],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:z-10',
116
+ '[&_tr:has([data-slot=data-table-row-link])_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]):not([data-slot=data-table-row-link],[data-slot=data-table-row-link-overlay],[data-slot=checkbox],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:relative',
117
+ '[&_tr:has([data-slot=data-table-row-link])_:is(a,button,input,select,textarea,[role=button],[tabindex],[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]):not([data-slot=data-table-row-link],[data-slot=data-table-row-link-overlay],[data-slot=checkbox],[data-slot=id-chip]_*,[data-slot=anonymized-token]_*,[data-slot=copyable-text]_*)]:z-10',
133
118
  // Only the first row link of a row stretches. A later one (a variant's
134
119
  // Product, rendered by the same link component) is a plain link above it,
135
120
  // underlined on hover, without a chevron.
121
+ // Pinned (`pinFirstColumn`): while the row link holds keyboard focus, the
122
+ // pinned cells draw their part of the row's focus ring (inline-start side,
123
+ // top and bottom): they stack above the ring the link draws over the row.
124
+ '[&_tr:not([data-click-selects]):has([data-slot=data-table-row-link]:focus-visible)]:[--table-pin-ring-x:inset_2px_0_0_var(--ring)] rtl:[&_tr:not([data-click-selects]):has([data-slot=data-table-row-link]:focus-visible)]:[--table-pin-ring-x:inset_-2px_0_0_var(--ring)] [&_tr:not([data-click-selects]):has([data-slot=data-table-row-link]:focus-visible)]:[--table-pin-ring-top:inset_0_2px_0_var(--ring)] [&_tr:not([data-click-selects]):has([data-slot=data-table-row-link]:focus-visible)]:[--table-pin-ring-bottom:inset_0_-2px_0_var(--ring)]',
136
125
  '[&_td:has([data-slot=data-table-row-link])~td_[data-slot=data-table-row-link]]:relative [&_td:has([data-slot=data-table-row-link])~td_[data-slot=data-table-row-link]]:z-10 [&_td:has([data-slot=data-table-row-link])~td_[data-slot=data-table-row-link]]:underline-offset-4 [&_td:has([data-slot=data-table-row-link])~td_[data-slot=data-table-row-link]]:hover:underline [&_td:has([data-slot=data-table-row-link])~td_[data-slot=data-table-row-chevron]]:hidden',
137
126
  );
138
127
 
@@ -144,6 +133,38 @@ const LINKED_ROW_CLASS = cn(
144
133
  const ROW_CHEVRON_SLOT_CLASS =
145
134
  '[&:has([data-slot=data-table-row-link])_tr>*:last-child]:pe-[calc(var(--card-px)+--spacing(7))]!';
146
135
 
136
+ // Pinned (`pinFirstColumn`): a pinned cell is positioned, so it becomes the
137
+ // containing block of the link's stretched ::after. A link in the pinned cell
138
+ // then covers only that cell, and a link in a scrolling cell covers every cell
139
+ // but the pinned ones, which stack above it. The cells on the other side of
140
+ // the pinned edge open the item through an overlay: a second anchor with the
141
+ // same href, hidden from assistive technology and from the tab order, so the
142
+ // row keeps one link and one tab stop. Cmd+click, middle-click and the hover
143
+ // URL work on it as on the link. It renders (in a portal) into a host the
144
+ // DataTable puts in the other side: in the last cell when the link is pinned,
145
+ // so the row is its containing block, else in the pinned cell. It sits under
146
+ // the row controls, as the ::after does.
147
+ const PINNED_CELL_SELECTOR = ':first-child, [data-pinned]';
148
+ const OVERLAY_HOST_SELECTOR = ':scope > * > [data-slot=data-table-row-link-overlay-host]';
149
+
150
+ interface RowLinkOverlay {
151
+ host: Element;
152
+ pinnedLink: boolean;
153
+ }
154
+
155
+ function rowLinkOverlay(link: HTMLElement): RowLinkOverlay | null {
156
+ const cell = link.closest('td, th');
157
+ const row = cell?.parentElement;
158
+ if (!cell || !row || row.tagName !== 'TR' || !row.closest('[data-pin-first-column]')) return null;
159
+ // Only the first row link of a row stretches.
160
+ if (row.querySelector('[data-slot=data-table-row-link]') !== link) return null;
161
+ const pinnedLink = cell.matches(PINNED_CELL_SELECTOR);
162
+ const host = Array.from(row.querySelectorAll(OVERLAY_HOST_SELECTOR)).find(
163
+ (candidate) => candidate.parentElement?.matches(PINNED_CELL_SELECTOR) !== pinnedLink,
164
+ );
165
+ return host ? { host, pinnedLink } : null;
166
+ }
167
+
147
168
  /**
148
169
  * Opens the row's item from any point of the row. Render it in the cell that
149
170
  * names the item, around the name: its children are the accessible name of
@@ -176,6 +197,11 @@ const ROW_CHEVRON_SLOT_CLASS =
176
197
  * the end of the row, the full row height, the chevron stays on row hover and
177
198
  * turns blue on the target's hover or focus, and the focus ring goes around
178
199
  * the slot. A click anywhere else on the row selects it.
200
+ *
201
+ * In a table with `pinFirstColumn`, the cells on the other side of the pinned
202
+ * edge open the item through an overlay anchor with the same href (see
203
+ * rowLinkOverlay). It is hidden from assistive technology and from the tab
204
+ * order, so the row still has one link and one tab stop.
179
205
  */
180
206
  function DataTableRowLink({
181
207
  className,
@@ -188,16 +214,62 @@ function DataTableRowLink({
188
214
  // target is the row-end chevron instead.
189
215
  const linkRef = React.useRef<HTMLAnchorElement>(null);
190
216
  const [nameless, setNameless] = React.useState(false);
217
+ const [overlay, setOverlay] = React.useState<RowLinkOverlay | null>(null);
191
218
  React.useLayoutEffect(() => {
192
219
  const link = linkRef.current;
193
- if (link) setNameless(link.getBoundingClientRect().width < 1);
220
+ if (!link) return;
221
+ setNameless(link.getBoundingClientRect().width < 1);
222
+ const next = rowLinkOverlay(link);
223
+ setOverlay((current) =>
224
+ current?.host === next?.host && current?.pinnedLink === next?.pinnedLink ? current : next,
225
+ );
194
226
  });
195
- return useRender({
227
+ // In a pinned cell the link's ::after covers only that cell, and its
228
+ // chevron would sit at the cell's end: the overlay draws both for the row.
229
+ const pinnedLink = overlay?.pinnedLink === true;
230
+ // The overlay goes to the same place as the link, with the link's own props
231
+ // (a router link's `render` included), but no id and no styling of its own.
232
+ const { id: _id, style: _style, ...overlayLinkProps } = props;
233
+ const overlayNode = useRender({
234
+ defaultTagName: 'a',
235
+ render,
236
+ enabled: overlay != null,
237
+ props: mergeProps<'a'>(overlayLinkProps, {
238
+ 'aria-hidden': true,
239
+ tabIndex: -1,
240
+ className: cn(
241
+ 'group/row-link-overlay absolute inset-0 z-1 cursor-pointer outline-none',
242
+ // While rows are selected a click on the row selects it.
243
+ 'in-data-click-selects:hidden',
244
+ pinnedLink && [
245
+ // The row's focus ring while the link holds keyboard focus; the
246
+ // pinned cells draw their part of it (LINKED_ROW_CLASS).
247
+ 'in-[tr:has([data-slot=data-table-row-link]:focus-visible)]:outline-2 in-[tr:has([data-slot=data-table-row-link]:focus-visible)]:-outline-offset-2 in-[tr:has([data-slot=data-table-row-link]:focus-visible)]:outline-ring in-[tr:has([data-slot=data-table-row-link]:focus-visible)]:outline-solid',
248
+ // A link without a visible name: while rows are selected the
249
+ // overlay is its target over the row-end chevron slot.
250
+ 'in-data-click-selects:data-nameless:block in-data-click-selects:data-nameless:start-auto in-data-click-selects:data-nameless:w-[calc(var(--card-px)+--spacing(7))] in-data-click-selects:data-nameless:rounded-md',
251
+ ],
252
+ ),
253
+ children: pinnedLink ? (
254
+ <ListRowChevron
255
+ data-slot="data-table-row-link-overlay-chevron"
256
+ className={cn(
257
+ 'pointer-events-none absolute end-(--card-px) top-1/2 -translate-y-1/2 in-data-selecting:hidden',
258
+ 'in-data-click-selects:group-data-nameless/row-link-overlay:block in-data-click-selects:group-data-nameless/row-link-overlay:transition-[opacity,translate,color]',
259
+ 'in-data-click-selects:group-data-nameless/row-link-overlay:group-hover/row-link-overlay:text-brand-text in-data-click-selects:group-data-nameless/row-link-overlay:in-[tr:has([data-slot=data-table-row-link]:focus-visible)]:text-brand-text',
260
+ )}
261
+ />
262
+ ) : null,
263
+ }),
264
+ state: { slot: 'data-table-row-link-overlay', nameless },
265
+ });
266
+ const linkNode = useRender({
196
267
  defaultTagName: 'a',
197
268
  render,
198
269
  ref: linkRef,
199
270
  props: mergeProps<'a'>(
200
271
  {
272
+ ...(pinnedLink ? { 'data-pinned-link': '' } : {}),
201
273
  className: cn(
202
274
  'group/row-link cursor-pointer font-medium text-foreground outline-none',
203
275
  'after:absolute after:inset-0 after:z-1 focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-ring focus-visible:after:outline-solid',
@@ -210,6 +282,8 @@ function DataTableRowLink({
210
282
  // is drawn around that slot.
211
283
  'in-data-click-selects:data-nameless:after:block in-data-click-selects:data-nameless:after:start-auto in-data-click-selects:data-nameless:after:w-[calc(var(--card-px)+--spacing(7))] in-data-click-selects:data-nameless:after:rounded-md',
212
284
  'in-data-click-selects:data-nameless:focus-visible:outline-none',
285
+ // In a pinned cell the overlay draws the ring and the row-end target.
286
+ 'data-pinned-link:focus-visible:after:outline-none in-data-click-selects:data-nameless:data-pinned-link:after:hidden',
213
287
  className,
214
288
  ),
215
289
  children: (
@@ -232,7 +306,7 @@ function DataTableRowLink({
232
306
  <ListRowChevron
233
307
  data-slot="data-table-row-chevron"
234
308
  className={cn(
235
- 'pointer-events-none absolute end-(--card-px) top-1/2 -translate-y-1/2 in-data-selecting:hidden',
309
+ 'pointer-events-none absolute end-(--card-px) top-1/2 -translate-y-1/2 in-data-selecting:hidden group-data-pinned-link/row-link:hidden!',
236
310
  // The target of a link without a visible name while rows are
237
311
  // selected: shown on row hover, blue on its own hover or focus.
238
312
  'in-data-click-selects:group-data-nameless/row-link:block in-data-click-selects:group-data-nameless/row-link:transition-[opacity,translate,color]',
@@ -247,6 +321,12 @@ function DataTableRowLink({
247
321
  // `nameless` renders as `data-nameless` while true.
248
322
  state: { slot: 'data-table-row-link', nameless },
249
323
  });
324
+ return (
325
+ <>
326
+ {linkNode}
327
+ {overlay != null && overlayNode != null && createPortal(overlayNode, overlay.host)}
328
+ </>
329
+ );
250
330
  }
251
331
 
252
332
  // The composition root. Owns the single `useReactTable` instance and the
@@ -336,17 +416,25 @@ const HEADER_LABEL_UNDER_BULK_CLASS =
336
416
  // control inside the row counts: an ancestor of the table that matches (an app
337
417
  // shell's `<main tabindex="-1">`, the skip link target) is not a row control.
338
418
  const ROW_CONTROL_SELECTOR =
339
- '[data-slot=data-table-select-area],a:not([data-slot=data-table-row-link]),button,input,select,textarea,[role=button],[role=checkbox],[role=menuitem],[tabindex]:not([data-slot=data-table-row-link]),[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]';
419
+ '[data-slot=data-table-select-area],a:not([data-slot=data-table-row-link],[data-slot=data-table-row-link-overlay]),button,input,select,textarea,[role=button],[role=checkbox],[role=menuitem],[tabindex]:not([data-slot=data-table-row-link],[data-slot=data-table-row-link-overlay]),[data-tooltip-trigger],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=copyable-text],[data-table-row-control]';
340
420
 
421
+ // The select gutter is `--spacing(10)`, 40px: the checkbox (8px in, 16px wide,
422
+ // ending at 24px), a 5px gap, then the 11px `--content-inset` of a sortable
423
+ // header (DataTableColumnHeader pulls its pill back by that much so its label
424
+ // starts with the cell text). A narrower gutter puts the hovered or sorted
425
+ // header pill over the select-all checkbox. Every rule that uses the gutter
426
+ // (the select area, the leading cell, the bulk bar over the header) writes
427
+ // `--spacing(10)`; change them together.
428
+ //
341
429
  // The click area of a select checkbox is its whole cell: the full height of
342
430
  // the row, from the table's start edge to where the leading cell's content
343
- // starts (its gutter, `--spacing(8)` plus its indent). The select cell is
431
+ // starts (its gutter plus its indent). The select cell is
344
432
  // zero-width, so the area is floated over that gutter, under the checkbox and
345
433
  // above the row link's stretched ::after. It is not focusable: keyboard focus
346
434
  // and the focus ring stay on the checkbox. The checkbox's own enlarged hit
347
435
  // area is turned off here, since it reached past the gutter into the content.
348
436
  const SELECT_AREA_CLASS =
349
- 'absolute inset-y-0 start-0 z-10 w-[calc(var(--spacing)*8+var(--column-indent,0px))]';
437
+ 'absolute inset-y-0 start-0 z-10 w-[calc(var(--spacing)*10+var(--column-indent,0px))]';
350
438
  const SELECT_CHECKBOX_HIT_CLASS = 'after:hidden';
351
439
 
352
440
  // Select all and clear all from the header checkbox ripple down the page: the
@@ -389,6 +477,16 @@ const SELECT_RIPPLE_ROW_CLASS = cn(
389
477
  'in-data-[select-ripple=select]:not-data-[state=selected]:before:[transition:none]! in-data-[select-ripple=select]:not-data-[state=selected]:after:[transition:none]!',
390
478
  'in-data-[select-ripple=clear]:not-data-[state=selected]:before:[clip-path:inset(100%_0_0_0)]! in-data-[select-ripple=clear]:not-data-[state=selected]:after:[clip-path:inset(100%_0_0_0)]!',
391
479
  );
480
+ // Pinned (`pinFirstColumn`), the first cell draws the selected-row bar (see
481
+ // Table), so the select cell takes the row's ripple on its own bar: the same
482
+ // rules, reading the row's state and delay.
483
+ const SELECT_RIPPLE_PINNED_BAR_CLASS = cn(
484
+ 'in-data-[select-ripple=select]:before:[transition:clip-path_var(--row-ripple-span)_linear_var(--row-ripple-delay),opacity_var(--transition-duration-moderate)_var(--ease-soft)_var(--row-ripple-delay),scale_var(--transition-duration-moderate)_var(--ease-out)_var(--row-ripple-delay)]! in-data-[select-ripple=select]:after:[transition:clip-path_var(--row-ripple-span)_linear_var(--row-ripple-delay),opacity_var(--transition-duration-moderate)_var(--ease-soft)_var(--row-ripple-delay),scale_var(--transition-duration-moderate)_var(--ease-out)_var(--row-ripple-delay)]!',
485
+ 'in-data-[select-ripple=clear]:before:[transition:clip-path_var(--row-ripple-span)_linear_var(--row-ripple-delay),opacity_var(--transition-duration-fast)_var(--ease-soft)_var(--row-ripple-delay),scale_var(--transition-duration-fast)_var(--ease-soft)_var(--row-ripple-delay)]! in-data-[select-ripple=clear]:after:[transition:clip-path_var(--row-ripple-span)_linear_var(--row-ripple-delay),opacity_var(--transition-duration-fast)_var(--ease-soft)_var(--row-ripple-delay),scale_var(--transition-duration-fast)_var(--ease-soft)_var(--row-ripple-delay)]!',
486
+ 'in-data-[select-ripple=select]:[tr:not([data-state=selected])>&]:before:[clip-path:inset(0_0_100%_0)]! in-data-[select-ripple=select]:[tr:not([data-state=selected])>&]:after:[clip-path:inset(0_0_100%_0)]!',
487
+ 'in-data-[select-ripple=select]:[tr:not([data-state=selected])>&]:before:[transition:none]! in-data-[select-ripple=select]:[tr:not([data-state=selected])>&]:after:[transition:none]!',
488
+ 'in-data-[select-ripple=clear]:[tr:not([data-state=selected])>&]:before:[clip-path:inset(100%_0_0_0)]! in-data-[select-ripple=clear]:[tr:not([data-state=selected])>&]:after:[clip-path:inset(100%_0_0_0)]!',
489
+ );
392
490
  // The row checkbox keeps its own transitions (the fill, the mark revealed with
393
491
  // it, the fade in) and only takes the row's delay. Row checkboxes are never
394
492
  // indeterminate, so their mark never swaps and needs no delay.
@@ -640,6 +738,7 @@ function DataTable<TData>({
640
738
  setTableOptions,
641
739
  onTableReady,
642
740
  frame = 'card',
741
+ pinFirstColumn = false,
643
742
  footerRows,
644
743
  labels,
645
744
  className,
@@ -672,6 +771,7 @@ function DataTable<TData>({
672
771
  columnsTrigger: labels?.columnsTrigger ?? 'Columns',
673
772
  columnsHeading: labels?.columnsHeading ?? 'Toggle columns',
674
773
  addFilter: labels?.addFilter ?? 'Add filter',
774
+ clearFilters: labels?.clearFilters ?? 'Clear filters',
675
775
  removeFilter:
676
776
  labels?.removeFilter ?? ((columnLabel: string) => `Remove ${columnLabel} filter`),
677
777
  sortLabel: labels?.sortLabel ?? ((columnLabel: string) => `Sort by ${columnLabel}`),
@@ -914,6 +1014,14 @@ function DataTable<TData>({
914
1014
  if (rowActions != null && id === ACTIONS_COLUMN_ID) return 'actions';
915
1015
  return undefined;
916
1016
  };
1017
+ // Pinned (`pinFirstColumn`): the first data column. With row selection the
1018
+ // zero-width select cell is the first cell and the checkbox floats over this
1019
+ // column's gutter, so its cells carry `data-pinned` and Table pins them
1020
+ // with the select cell, at the same inline-start edge.
1021
+ const pinnedColumnId = pinFirstColumn
1022
+ ? table.getVisibleLeafColumns().find((column) => generatedColumn(column.id) !== 'select')?.id
1023
+ : undefined;
1024
+ const pinnedMark = (id: string): '' | undefined => (id === pinnedColumnId ? '' : undefined);
917
1025
  // Columns whose `meta.align` is `'end'`: their header, sort control and
918
1026
  // cells line up on the end side, so the digits of a number column line up.
919
1027
  const endColumnIds = new Set(
@@ -934,7 +1042,7 @@ function DataTable<TData>({
934
1042
  // Every other cell adds its column's indent (`--column-indent`, see
935
1043
  // `columnIndents`) to its start padding. CardTable's edge-cell padding
936
1044
  // adds it too.
937
- if (id === leadingColumnId) return 'ps-[calc(var(--spacing)*8+var(--column-indent,0px))]';
1045
+ if (id === leadingColumnId) return 'ps-[calc(var(--spacing)*10+var(--column-indent,0px))]';
938
1046
  // Actions cells drop vertical padding so a row-action button (taller than a
939
1047
  // text line) sits inside the natural row height rather than inflating every
940
1048
  // row; `align-middle` on the cell keeps it centred.
@@ -991,14 +1099,29 @@ function DataTable<TData>({
991
1099
  const bodyCellProps = (columnId: string): DataTableRowCellProps => ({
992
1100
  'data-column-id': columnId,
993
1101
  'data-content-inset-cell': '',
1102
+ 'data-pinned': pinnedMark(columnId),
994
1103
  className: cn(
995
1104
  columnClass(columnId),
996
1105
  bodyCellClass,
997
1106
  endColumnIds.has(columnId) ? endPullClass : startPullClass,
1107
+ pinFirstColumn && generatedColumn(columnId) === 'select' && SELECT_RIPPLE_PINNED_BAR_CLASS,
998
1108
  ),
999
1109
  style: columnIndentStyle(columnId),
1000
1110
  });
1001
1111
 
1112
+ // Pinned: where a DataTableRowLink renders its overlay (see rowLinkOverlay),
1113
+ // one host on each side of the pinned edge: in the pinned cell, and in the
1114
+ // last cell when that one scrolls. A host has no box of its own. Handed to
1115
+ // `renderRow` as `ctx.rowLinkHost`, so a row a consumer renders itself gets
1116
+ // the same hosts.
1117
+ const lastColumnId = table.getVisibleLeafColumns().at(-1)?.id;
1118
+ const rowLinkHost = (columnId: string): React.ReactNode =>
1119
+ pinFirstColumn &&
1120
+ pinnedColumnId != null &&
1121
+ (columnId === pinnedColumnId || columnId === lastColumnId) ? (
1122
+ <span data-slot="data-table-row-link-overlay-host" className="contents" />
1123
+ ) : null;
1124
+
1002
1125
  // Loading cells follow the real column layout (same ids, same cell classes),
1003
1126
  // so a consumer's `skeletonCells` entry can match its loaded cell's height.
1004
1127
  const skeletonCell = (id: string): React.ReactNode => {
@@ -1010,7 +1133,7 @@ function DataTable<TData>({
1010
1133
  const custom = skeletonCells?.[id];
1011
1134
  if (custom !== undefined) return custom;
1012
1135
  if (generated === 'actions') return <Skeleton className="size-8" />;
1013
- return <DataTableSkeletonLine />;
1136
+ return <SkeletonLine data-slot="data-table-skeleton-line" />;
1014
1137
  };
1015
1138
 
1016
1139
  const warnedUnknownSkeletonCells = React.useRef(false);
@@ -1047,6 +1170,13 @@ function DataTable<TData>({
1047
1170
  filters.showAppliedFilters !== false &&
1048
1171
  table.getState().columnFilters.length > 0;
1049
1172
  const showHeader = header != null || showControls || showChips;
1173
+ // "Clear filters" after the chips. With no rows (and not loading) the empty
1174
+ // state has the only one.
1175
+ const clearFilters = resolveClearFilters(
1176
+ filters?.clearFilters,
1177
+ table,
1178
+ !(isLoading && rows.length === 0) && bodyRows.length === 0,
1179
+ );
1050
1180
  // The bulk bar exists only while rows are selected. It takes the controls
1051
1181
  // row's place, or, with no controls row, covers the column header row (see
1052
1182
  // `bulkBarFade`): it never opens a band of its own, so the table never
@@ -1089,8 +1219,13 @@ function DataTable<TData>({
1089
1219
  if (!event.currentTarget.contains(target) || isRowControl(target, event.currentTarget)) return;
1090
1220
  // The name: the row link does not stretch while rows are selected, so a
1091
1221
  // click that lands in it was on the name, and opens the item. Shift+click
1092
- // on it still extends the selection.
1093
- if (!event.shiftKey && target.closest('[data-slot=data-table-row-link]')) return;
1222
+ // on it still extends the selection. In a pinned table the link's overlay
1223
+ // then shows only as the row-end target of a link without a visible name.
1224
+ if (
1225
+ !event.shiftKey &&
1226
+ target.closest('[data-slot=data-table-row-link],[data-slot=data-table-row-link-overlay]')
1227
+ )
1228
+ return;
1094
1229
  event.preventDefault();
1095
1230
  event.stopPropagation();
1096
1231
  selectAllRipple.end();
@@ -1185,7 +1320,10 @@ function DataTable<TData>({
1185
1320
  </MotionConfig>
1186
1321
  )}
1187
1322
  {showChips && (
1188
- <ListHeaderChips>
1323
+ // With "Clear filters" on, the line keeps the button's height
1324
+ // (Button sm, h-7; a Chip is h-6), so the table does not move
1325
+ // when the button shows or hides.
1326
+ <ListHeaderChips className={clearFilters ? 'min-h-7' : undefined}>
1189
1327
  <DataTableAppliedFilters
1190
1328
  table={table}
1191
1329
  columns={filters?.columns}
@@ -1193,6 +1331,16 @@ function DataTable<TData>({
1193
1331
  removeLabel={l.removeFilter}
1194
1332
  collapsedLabel={l.filtersCollapsed}
1195
1333
  />
1334
+ {clearFilters && !clearFilters.hidden && (
1335
+ <Button
1336
+ data-slot="data-table-clear-filters"
1337
+ variant="ghost"
1338
+ size="sm"
1339
+ onClick={clearFilters.onClear}
1340
+ >
1341
+ {l.clearFilters}
1342
+ </Button>
1343
+ )}
1196
1344
  </ListHeaderChips>
1197
1345
  )}
1198
1346
  </ListHeader>
@@ -1211,7 +1359,7 @@ function DataTable<TData>({
1211
1359
  <motion.div
1212
1360
  key="bulk-over-header"
1213
1361
  {...bulkBarFade}
1214
- className="pointer-events-none absolute inset-x-0 top-0 z-20 flex h-10 items-center ps-8 pe-(--card-px)"
1362
+ className="pointer-events-none absolute inset-x-0 top-0 z-20 flex h-10 items-center ps-10 pe-(--card-px)"
1215
1363
  >
1216
1364
  <DataTableBulkActions
1217
1365
  table={table}
@@ -1226,6 +1374,7 @@ function DataTable<TData>({
1226
1374
  )}
1227
1375
  <Table
1228
1376
  ref={tableRef}
1377
+ pinFirstColumn={pinFirstColumn}
1229
1378
  className={cn(LINKED_ROW_CLASS, ROW_CHEVRON_SLOT_CLASS, SELECT_RIPPLE_TABLE_CLASS)}
1230
1379
  data-selecting={selecting ? '' : undefined}
1231
1380
  data-bulk-over-header={bulkOverHeader && showBulk ? '' : undefined}
@@ -1242,6 +1391,7 @@ function DataTable<TData>({
1242
1391
  key={headerCell.id}
1243
1392
  aria-sort={ariaSort(sorting != null, headerCell.column)}
1244
1393
  data-column-id={headerCell.column.id}
1394
+ data-pinned={pinnedMark(headerCell.column.id)}
1245
1395
  className={cn(
1246
1396
  columnClass(headerCell.column.id),
1247
1397
  generatedColumn(headerCell.column.id) !== 'select' &&
@@ -1272,13 +1422,14 @@ function DataTable<TData>({
1272
1422
  <TableRow key={`skeleton-${rowIndex}`}>
1273
1423
  {columnCount === 0 ? (
1274
1424
  <TableCell>
1275
- <DataTableSkeletonLine />
1425
+ <SkeletonLine data-slot="data-table-skeleton-line" />
1276
1426
  </TableCell>
1277
1427
  ) : (
1278
1428
  table.getVisibleLeafColumns().map((column) => (
1279
1429
  <TableCell
1280
1430
  key={column.id}
1281
1431
  data-column-id={column.id}
1432
+ data-pinned={pinnedMark(column.id)}
1282
1433
  className={columnClass(column.id)}
1283
1434
  style={columnIndentStyle(column.id)}
1284
1435
  >
@@ -1315,6 +1466,7 @@ function DataTable<TData>({
1315
1466
  {row.getVisibleCells().map((cell) => (
1316
1467
  <TableCell key={cell.id} {...bodyCellProps(cell.column.id)}>
1317
1468
  {flexRender(cell.column.columnDef.cell, cell.getContext())}
1469
+ {rowLinkHost(cell.column.id)}
1318
1470
  </TableCell>
1319
1471
  ))}
1320
1472
  </TableRow>
@@ -1344,6 +1496,7 @@ function DataTable<TData>({
1344
1496
  defaultRow,
1345
1497
  ripple,
1346
1498
  cellProps: bodyCellProps,
1499
+ rowLinkHost,
1347
1500
  selectProps,
1348
1501
  })
1349
1502
  : defaultRow}
@@ -1401,7 +1554,9 @@ function DataTable<TData>({
1401
1554
  );
1402
1555
  }
1403
1556
 
1404
- export { DataTable, DataTableRowLink, DataTableSkeletonLine };
1557
+ // `DataTableSkeletonLine` is the shared SkeletonLine under its old name, kept for
1558
+ // consumers that stack it in `skeletonCells`.
1559
+ export { DataTable, DataTableRowLink, SkeletonLine as DataTableSkeletonLine };
1405
1560
 
1406
1561
  // Re-export the consumer-facing TanStack types so columns can be authored from
1407
1562
  // the same import as `DataTable` — no direct `@tanstack/react-table` dependency
@@ -8,7 +8,7 @@ import type * as React from 'react';
8
8
  // this, and PageHeaderFactLink renders ExternalArrow. The package exports map
9
9
  // this file to null.
10
10
  //
11
- // The v3 look: 13px medium text, and a 15px chevron at 45%: trailing forward,
11
+ // The v3 look: 14px medium text, and a 15px chevron at 45%: trailing forward,
12
12
  // leading back. A straight direction takes a chevron; an arrow is for a
13
13
  // diagonal only, such as a link that leaves the app. On hover or keyboard
14
14
  // focus the text reaches full foreground and the chevron full strength, and
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { createContext, type ReactNode, useContext, useMemo } from 'react';
4
+ import type { Locale } from 'react-day-picker';
4
5
 
5
6
  // The design system cannot depend on any app's i18n. Formatters resolve their
6
7
  // locale/currency in a fixed order — explicit prop → this context → `undefined`
@@ -21,6 +22,14 @@ interface FormatContextValue {
21
22
  * digits (2 for USD, 0 for JPY, 3 for BHD).
22
23
  */
23
24
  currencyPrecision?: number;
25
+ /**
26
+ * Language of every `Calendar`, including the date pickers' popups: month
27
+ * caption, weekday names, first day of the week and screen-reader labels.
28
+ * Import only the active language, e.g. `react-day-picker/locale/fr`, never
29
+ * the `react-day-picker/locale` barrel (every language, about 1.6 MB).
30
+ * `undefined` → US English. A `Calendar`'s own `locale` prop wins.
31
+ */
32
+ calendarLocale?: Locale;
24
33
  }
25
34
 
26
35
  const FormatContext = createContext<FormatContextValue>({});
@@ -31,10 +40,11 @@ function FormatProvider({
31
40
  timeZone,
32
41
  currency,
33
42
  currencyPrecision,
43
+ calendarLocale,
34
44
  }: FormatContextValue & { children: ReactNode }) {
35
45
  const value = useMemo(
36
- () => ({ locale, timeZone, currency, currencyPrecision }),
37
- [locale, timeZone, currency, currencyPrecision],
46
+ () => ({ locale, timeZone, currency, currencyPrecision, calendarLocale }),
47
+ [locale, timeZone, currency, currencyPrecision, calendarLocale],
38
48
  );
39
49
  return <FormatContext.Provider value={value}>{children}</FormatContext.Provider>;
40
50
  }
@@ -67,7 +67,7 @@ function PageHeaderActions({ className, ...props }: React.ComponentProps<'div'>)
67
67
  }
68
68
 
69
69
  /**
70
- * The facts under the title: branch, region, host, owner. 13px text in
70
+ * The facts under the title: branch, region, host, owner. 14px text in
71
71
  * `foreground-secondary`, 18px between facts and 6px between rows when they
72
72
  * wrap. Put it in PageHeaderContent, below the title.
73
73
  */
@@ -1,31 +1,15 @@
1
1
  'use client';
2
2
 
3
3
  import { Kbd } from '@vendure-io/ui/components/atoms/kbd';
4
+ import { useIsApplePlatform } from '@vendure-io/ui/hooks/use-apple-platform';
4
5
  import { cn } from '@vendure-io/ui/lib/utils';
5
6
  import { SearchIcon } from 'lucide-react';
6
7
  import type * as React from 'react';
7
- import { useSyncExternalStore } from 'react';
8
8
 
9
9
  type SearchTriggerCollapse = 'md' | 'never' | 'always';
10
10
 
11
- const subscribe = () => () => {};
12
-
13
- // Apple platforms show ⌘, the rest show Ctrl. The server and the first
14
- // hydration render have no platform, so they show Ctrl; React swaps in the
15
- // client value right after hydration without a mismatch error.
16
- function isApplePlatform() {
17
- if (typeof navigator === 'undefined') return false;
18
- const nav = navigator as Navigator & { userAgentData?: { platform?: string } };
19
- const platform = nav.userAgentData?.platform || nav.platform || nav.userAgent;
20
- return /mac|iphone|ipad|ipod/i.test(platform);
21
- }
22
-
23
- function useIsApplePlatform() {
24
- return useSyncExternalStore(subscribe, isApplePlatform, () => false);
25
- }
26
-
27
11
  // The v3 look: a button that looks like a field. 28px high, 220px wide, on
28
- // the muted fill with a 1px inset hairline and the lg radius. The 13px text
12
+ // the muted fill with a 1px inset hairline and the lg radius. The 14px text
29
13
  // is `foreground-secondary`: muted text on the muted fill is under 4.5:1.
30
14
  // The icon is 14px and quieter than the text (55%). Hover steps the fill up
31
15
  // to `accent` in 120ms. No press scale: it is a field, not a button, to
@@ -45,10 +45,11 @@ const MASK = '••••••••';
45
45
 
46
46
  // The trailing buttons have the IdChip button look (`chipIconButtonClass`).
47
47
  // Each one is its own control (the chip has two), so its icon brightens on
48
- // its own hover, and its ::after widens the target to 21px.
48
+ // its own hover. Its ::after is a 24px target centred on the 13px icon
49
+ // (WCAG 2.5.8).
49
50
  const CHIP_BUTTON_CLASS = cn(
50
51
  chipIconButtonClass,
51
- 'relative after:absolute after:-inset-1 hover:text-foreground',
52
+ 'relative after:absolute after:top-1/2 after:left-1/2 after:size-6 after:-translate-1/2 hover:text-foreground',
52
53
  'hover:[&>svg:not([role=status])]:opacity-100',
53
54
  'hover:[&_[data-slot=copy-state-icon]:not([data-copied])>svg:first-child]:opacity-100',
54
55
  );
@@ -180,7 +181,9 @@ function SecretValue({
180
181
  onCopyError={onCopyError}
181
182
  copyLabel={copyLabel}
182
183
  copiedLabel={copiedLabel}
183
- className={CHIP_BUTTON_CLASS}
184
+ // 6px more than the chip gap puts the icon centres 25px apart, so
185
+ // the two 24px targets do not overlap.
186
+ className={cn(CHIP_BUTTON_CLASS, 'ms-1.5')}
184
187
  />
185
188
  ) : null}
186
189
  {state.status === 'error' ? (