@vendure-io/ui 2.0.0-beta.9 → 2.0.0-rc.0

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 (75) hide show
  1. package/LICENSE.md +34 -0
  2. package/package.json +8 -6
  3. package/src/components/atoms/alert-dialog.tsx +1 -1
  4. package/src/components/atoms/alert.tsx +1 -1
  5. package/src/components/atoms/badge.tsx +1 -1
  6. package/src/components/atoms/button.tsx +2 -2
  7. package/src/components/atoms/card.tsx +39 -4
  8. package/src/components/atoms/checkbox.tsx +1 -1
  9. package/src/components/atoms/combobox.tsx +24 -5
  10. package/src/components/atoms/command.tsx +16 -5
  11. package/src/components/atoms/context-menu.tsx +1 -1
  12. package/src/components/atoms/dialog.tsx +1 -1
  13. package/src/components/atoms/drawer.tsx +134 -35
  14. package/src/components/atoms/dropdown-menu.tsx +1 -1
  15. package/src/components/atoms/field.tsx +2 -2
  16. package/src/components/atoms/input.tsx +1 -1
  17. package/src/components/atoms/item.tsx +4 -1
  18. package/src/components/atoms/menubar.tsx +1 -1
  19. package/src/components/atoms/native-select.tsx +1 -1
  20. package/src/components/atoms/navigation-menu.tsx +8 -2
  21. package/src/components/atoms/progress.tsx +1 -1
  22. package/src/components/atoms/radio-group.tsx +1 -1
  23. package/src/components/atoms/scroll-area.tsx +1 -2
  24. package/src/components/atoms/select.tsx +1 -1
  25. package/src/components/atoms/sheet.tsx +1 -1
  26. package/src/components/atoms/sidebar.tsx +6 -4
  27. package/src/components/atoms/slider.tsx +2 -2
  28. package/src/components/atoms/switch.tsx +1 -1
  29. package/src/components/atoms/table.tsx +34 -2
  30. package/src/components/atoms/tabs.tsx +64 -1
  31. package/src/components/atoms/textarea.tsx +1 -1
  32. package/src/components/atoms/toggle-group.tsx +1 -1
  33. package/src/components/atoms/toggle.tsx +5 -2
  34. package/src/components/molecules/chip.tsx +7 -2
  35. package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
  36. package/src/components/molecules/code-block/process-code.ts +60 -0
  37. package/src/components/molecules/code-block/transform-command.tsx +177 -0
  38. package/src/components/molecules/code-block.tsx +25 -443
  39. package/src/components/molecules/combobox-free-text.tsx +23 -2
  40. package/src/components/molecules/copyable-text.tsx +14 -1
  41. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +12 -13
  42. package/src/components/molecules/data-table/data-table-types.tsx +50 -2
  43. package/src/components/molecules/data-table/data-table-view-options.tsx +2 -1
  44. package/src/components/molecules/data-table/data-table.tsx +188 -96
  45. package/src/components/molecules/date-picker.tsx +3 -1
  46. package/src/components/molecules/date-range-picker.tsx +3 -1
  47. package/src/components/molecules/date-time-picker.tsx +3 -1
  48. package/src/components/molecules/file-dropzone.tsx +15 -5
  49. package/src/components/molecules/illustrations/empty-database.tsx +8 -5
  50. package/src/components/molecules/illustrations/error.tsx +19 -17
  51. package/src/components/molecules/illustrations/expired.tsx +55 -0
  52. package/src/components/molecules/illustrations/first-run.tsx +3 -1
  53. package/src/components/molecules/illustrations/no-activity.tsx +35 -14
  54. package/src/components/molecules/illustrations/no-customers.tsx +66 -0
  55. package/src/components/molecules/illustrations/no-documents.tsx +4 -3
  56. package/src/components/molecules/illustrations/no-invoices.tsx +45 -0
  57. package/src/components/molecules/illustrations/no-notifications.tsx +7 -8
  58. package/src/components/molecules/illustrations/no-orders.tsx +25 -17
  59. package/src/components/molecules/illustrations/no-plugins.tsx +21 -31
  60. package/src/components/molecules/illustrations/no-products.tsx +53 -0
  61. package/src/components/molecules/illustrations/no-projects.tsx +54 -0
  62. package/src/components/molecules/illustrations/no-promotions.tsx +49 -0
  63. package/src/components/molecules/illustrations/no-subscription.tsx +72 -0
  64. package/src/components/molecules/illustrations/not-found.tsx +17 -15
  65. package/src/components/molecules/illustrations/offline.tsx +12 -10
  66. package/src/components/molecules/illustrations/payment-failed.tsx +53 -0
  67. package/src/components/molecules/illustrations/success.tsx +43 -0
  68. package/src/components/molecules/inline-code.tsx +26 -0
  69. package/src/components/molecules/page-header.tsx +7 -3
  70. package/src/components/molecules/stat-card.tsx +13 -12
  71. package/src/components/molecules/state-views/empty-state.tsx +12 -1
  72. package/src/components/molecules/state-views/loading-state.tsx +7 -3
  73. package/src/lib/highlight.ts +37 -1
  74. package/src/lib/state-dictionary.ts +18 -5
  75. package/src/lib/utils.ts +0 -19
@@ -85,6 +85,10 @@ interface CopyableTextProps {
85
85
  onCopied?: () => void;
86
86
  /** Called when the clipboard write fails. Falls back to `CopyFeedbackProvider`. */
87
87
  onCopyError?: (error: Error) => void;
88
+ /** Accessible label before copying, forwarded to the inner `CopyButton`. @default "Copy" */
89
+ copyLabel?: string;
90
+ /** Accessible label shown while the copied state is active, forwarded to the inner `CopyButton`. @default "Copied" */
91
+ copiedLabel?: string;
88
92
  }
89
93
 
90
94
  /**
@@ -99,11 +103,20 @@ function CopyableText({
99
103
  timeout,
100
104
  onCopied,
101
105
  onCopyError,
106
+ copyLabel,
107
+ copiedLabel,
102
108
  }: CopyableTextProps) {
103
109
  return (
104
110
  <span data-slot="copyable-text" className={cn('inline-flex items-center gap-1.5', className)}>
105
111
  {children ?? value}
106
- <CopyButton value={value} timeout={timeout} onCopied={onCopied} onCopyError={onCopyError} />
112
+ <CopyButton
113
+ value={value}
114
+ timeout={timeout}
115
+ onCopied={onCopied}
116
+ onCopyError={onCopyError}
117
+ copyLabel={copyLabel}
118
+ copiedLabel={copiedLabel}
119
+ />
107
120
  </span>
108
121
  );
109
122
  }
@@ -1,19 +1,18 @@
1
1
  'use client';
2
2
 
3
3
  import type { Table } from '@tanstack/react-table';
4
- import {
5
- getSelectedOriginals,
6
- getSelectedRowIds,
7
- } from '@vendure-io/ui/components/molecules/data-table/data-table-helpers';
8
4
  import type { DataTableBulkActionContext } from '@vendure-io/ui/components/molecules/data-table/data-table-types';
9
5
  import { cn } from '@vendure-io/ui/lib/utils';
10
6
  import * as React from 'react';
7
+ // Relative: `data-table-helpers` is closed in the package exports.
8
+ import { getSelectedOriginals, getSelectedRowIds } from './data-table-helpers.tsx';
11
9
 
12
- // The selection overlay that replaces the controls row while rows are selected.
13
- // The cross-page selection cache lives here (donor parity): `rows` only ever
14
- // holds the current page, so we accumulate `row.original` by id as pages are
15
- // seen, letting `bulkActions` receive every selected original — not just the
16
- // ones still on screen.
10
+ // The selection bar that replaces the controls row inside the header band
11
+ // while rows are selected (returns null with an empty selection; the core
12
+ // decides where it renders). The cross-page selection cache lives here (donor
13
+ // parity): `rows` only ever holds the current page, so we accumulate
14
+ // `row.original` by id as pages are seen, letting `bulkActions` receive every
15
+ // selected original — not just the ones still on screen.
17
16
 
18
17
  /**
19
18
  * Accumulate `row.original` keyed by row id across page changes. Populated during
@@ -53,12 +52,12 @@ function DataTableBulkActions<TData>({
53
52
  };
54
53
 
55
54
  return (
55
+ // A plain band row, not a box: it takes the controls row's place inside
56
+ // the header band, so it carries no chrome of its own. min-h-9 matches
57
+ // the controls row's h-9 inputs so the swap holds the band height steady.
56
58
  <div
57
59
  data-slot="data-table-bulk-actions"
58
- className={cn(
59
- 'bg-muted/50 flex flex-wrap items-center gap-2 rounded-md border px-3 py-2',
60
- className,
61
- )}
60
+ className={cn('flex min-h-9 flex-wrap items-center gap-2', className)}
62
61
  {...props}
63
62
  >
64
63
  {render(ctx)}
@@ -182,7 +182,11 @@ export interface DataTableProps<TData> {
182
182
  header?: React.ReactNode;
183
183
  /** Controls row (search, faceted filters, custom buttons). Render-prop gets the live table. */
184
184
  toolbar?: React.ReactNode | ((table: Table<TData>) => React.ReactNode);
185
- /** Overlay content when selection is non-empty. Only meaningful with `rowSelection` wired. */
185
+ /**
186
+ * Replaces the controls row inside the header band while selection is
187
+ * non-empty (title and applied-filter chips stay). Only meaningful with
188
+ * `rowSelection` wired.
189
+ */
186
190
  bulkActions?: (ctx: DataTableBulkActionContext<TData>) => React.ReactNode;
187
191
  /**
188
192
  * Per-row actions → appends an actions column. First arg is `row.original`
@@ -225,8 +229,52 @@ export interface DataTableProps<TData> {
225
229
  */
226
230
  setTableOptions?: (options: TableOptions<TData>) => TableOptions<TData>;
227
231
 
232
+ /**
233
+ * Receives the core's TanStack {@link Table} instance so consumers (saved-view
234
+ * controls, external toolbars) can drive it without rendering a slot to
235
+ * capture it — the supported alternative to reading `table` off the `toolbar`
236
+ * render-prop purely for its side effect.
237
+ *
238
+ * Fires from an effect after the first commit — never during render or SSR —
239
+ * so it is safe to call setState from here. `useReactTable` returns a
240
+ * referentially stable instance for the component's lifetime, so this fires
241
+ * once per mount (twice under React StrictMode in development, like any
242
+ * effect — keep the callback idempotent): never on a plain rerender, and not
243
+ * again when the callback prop's identity changes. Treat it as a "ready"
244
+ * capture, not a subscription — the latest callback as of that single fire is
245
+ * used (an inline function is fine), but a callback swapped in after mount is
246
+ * never invoked. TanStack mutates the instance in place as state changes, so
247
+ * the reference you capture here stays current — read live state through it
248
+ * (e.g. inside an event handler) rather than expecting a fresh object on each
249
+ * change.
250
+ */
251
+ onTableReady?: (table: Table<TData>) => void;
252
+
253
+ /**
254
+ * The table's frame. `'card'` (default) renders the band anatomy on a real
255
+ * `Card`: a `CardHeader` (border-b) hosting the header/controls/chips zones,
256
+ * `CardTable` hosting the table flush to the card edges, and a `CardFooter`
257
+ * (border-t) hosting pagination when it is wired — no footer means the last
258
+ * row sits flush against the card's bottom edge. `'plain'` renders the same
259
+ * band structure without any card chrome, for a table embedded in an
260
+ * existing card (e.g. a dashboard widget): it MUST sit inside a `Card`,
261
+ * whose spacing variables (`--card-px`/`--card-gap`) drive the bands and
262
+ * edge-cell alignment — the host card is the frame.
263
+ */
264
+ frame?: 'card' | 'plain';
265
+ /**
266
+ * Extra `<TableRow>`s appended inside `TableBody` after the data rows — e.g.
267
+ * an order table's subtotal/shipping/total rows. Rendered only alongside
268
+ * real rows, never with the skeleton or empty states, and has no interaction
269
+ * with selection, sorting, or pagination. Use the function form to receive
270
+ * `columnCount` for `colSpan`s — display columns (select, actions) are
271
+ * injected around your columns, so a hard-coded count desyncs. Rows are
272
+ * presentational: give them `hover:bg-transparent`.
273
+ */
274
+ footerRows?: React.ReactNode | ((ctx: { columnCount: number }) => React.ReactNode);
275
+
228
276
  labels?: DataTableLabels;
229
- className?: string; // outer div[data-slot="data-table"]
277
+ className?: string; // the frame root (data-slot="data-table")
230
278
  }
231
279
 
232
280
  /**
@@ -11,8 +11,9 @@ import {
11
11
  DropdownMenuSeparator,
12
12
  DropdownMenuTrigger,
13
13
  } from '@vendure-io/ui/components/atoms/dropdown-menu';
14
- import { getHideableLeafColumns } from '@vendure-io/ui/components/molecules/data-table/data-table-helpers';
15
14
  import { SlidersHorizontalIcon } from 'lucide-react';
15
+ // Relative: `data-table-helpers` is closed in the package exports.
16
+ import { getHideableLeafColumns } from './data-table-helpers.tsx';
16
17
 
17
18
  // The column-visibility gear. Lists only hideable columns (`getCanHide()`), so
18
19
  // the always-on `select`/`actions` display columns never appear here. Labels
@@ -19,6 +19,7 @@ import {
19
19
  useReactTable,
20
20
  type VisibilityState,
21
21
  } from '@tanstack/react-table';
22
+ import { Card, CardFooter, CardHeader, CardTable } from '@vendure-io/ui/components/atoms/card';
22
23
  import { Checkbox } from '@vendure-io/ui/components/atoms/checkbox';
23
24
  import {
24
25
  ContextMenu,
@@ -43,10 +44,6 @@ import {
43
44
  DataTableAddFilter,
44
45
  DataTableAppliedFilters,
45
46
  } from '@vendure-io/ui/components/molecules/data-table/data-table-filters';
46
- import {
47
- buildDisplayColumns,
48
- resolveSlot,
49
- } from '@vendure-io/ui/components/molecules/data-table/data-table-helpers';
50
47
  import type {
51
48
  ControlledState,
52
49
  DataTableProps,
@@ -59,13 +56,19 @@ import {
59
56
  } from '@vendure-io/ui/components/molecules/data-table/list-header';
60
57
  import { TablePagination } from '@vendure-io/ui/components/molecules/data-table/table-pagination';
61
58
  import { cn } from '@vendure-io/ui/lib/utils';
59
+ import { AnimatePresence, motion } from 'motion/react';
62
60
  import * as React from 'react';
61
+ // Relative: `data-table-helpers` is closed in the package exports.
62
+ import { buildDisplayColumns, getSelectedRowIds, resolveSlot } from './data-table-helpers.tsx';
63
63
 
64
64
  // The composition root. Owns the single `useReactTable` instance and the
65
- // controlled/uncontrolled bridge, then lays out header → controls → chips →
66
- // bulk overlay → Table → footer. Every capability follows the Phase-1 rule
67
- // verbatim: a feature renders only if its config is wired — no feature flags, no
68
- // disabled placeholders. Only this folder imports TanStack; the composed
65
+ // controlled/uncontrolled bridge, then lays out the card-framed table anatomy:
66
+ // a CardHeader band (header → controls → chips → bulk overlay), a CardTable
67
+ // hosting the Table flush to the card edges, and a CardFooter band for
68
+ // pagination. `frame="plain"` keeps the band structure without the card
69
+ // chrome. Every capability follows the Phase-1 rule verbatim: a feature
70
+ // renders only if its config is wired — no feature flags, no disabled
71
+ // placeholders. Only this folder imports TanStack; the composed
69
72
  // ListHeader/TablePagination/Chip primitives stay TanStack-free.
70
73
 
71
74
  /**
@@ -98,6 +101,16 @@ function headerLabelText<TData>(column: Column<TData, unknown>): string {
98
101
  return typeof header === 'string' ? header : column.id;
99
102
  }
100
103
 
104
+ // The controls/bulk replace-on-select swap: the outgoing row drifts slightly
105
+ // up as it fades, the incoming row rises in from below — a subtle vertical
106
+ // hand-off (4px) rather than a plain crossfade.
107
+ const bandRowFade = {
108
+ initial: { opacity: 0, y: 4 },
109
+ animate: { opacity: 1, y: 0 },
110
+ exit: { opacity: 0, y: -4 },
111
+ transition: { duration: 0.1, ease: 'easeOut' },
112
+ } as const;
113
+
101
114
  function ariaSort<TData>(
102
115
  hasSorting: boolean,
103
116
  column: Column<TData, unknown>,
@@ -126,6 +139,9 @@ function DataTable<TData>({
126
139
  emptyState,
127
140
  renderRow,
128
141
  setTableOptions,
142
+ onTableReady,
143
+ frame = 'card',
144
+ footerRows,
129
145
  labels,
130
146
  className,
131
147
  }: DataTableProps<TData>) {
@@ -293,6 +309,16 @@ function DataTable<TData>({
293
309
 
294
310
  const table = useReactTable(setTableOptions ? setTableOptions(baseOptions) : baseOptions);
295
311
 
312
+ // Hand the table instance to the consumer once it exists. A ref holds the
313
+ // latest callback so the effect can key on `table` alone — do NOT add
314
+ // `onTableReady` to the deps: that would re-fire the "ready" notification
315
+ // whenever an inline callback gets a new identity on rerender.
316
+ const onTableReadyRef = React.useRef(onTableReady);
317
+ onTableReadyRef.current = onTableReady;
318
+ React.useEffect(() => {
319
+ onTableReadyRef.current?.(table);
320
+ }, [table]);
321
+
296
322
  const selectionCache = useSelectionCache(table);
297
323
 
298
324
  const bodyRows = table.getRowModel().rows;
@@ -307,7 +333,11 @@ function DataTable<TData>({
307
333
  ? table.getVisibleLeafColumns().find((column) => column.id !== selectColumnId)?.id
308
334
  : undefined;
309
335
  const columnClass = (id: string): string | undefined => {
310
- if (id === selectColumnId) return 'relative w-0 p-0';
336
+ // `pl-0!`: the select cell is the first child, so CardTable's edge-cell
337
+ // padding would otherwise widen the zero-width cell and push the whole
338
+ // gutter arrangement out; important because CardTable's descendant rule
339
+ // out-specifies a plain utility on the cell.
340
+ if (id === selectColumnId) return 'relative w-0 p-0 pl-0!';
311
341
  if (id === leadingColumnId) return 'pl-8';
312
342
  // Actions cells drop vertical padding so a row-action button (taller than a
313
343
  // text line) sits inside the natural row height rather than inflating every
@@ -327,47 +357,76 @@ function DataTable<TData>({
327
357
  filters.showAppliedFilters !== false &&
328
358
  table.getState().columnFilters.length > 0;
329
359
  const showHeader = header != null || showControls || showChips;
330
- const showBulk = rowSelection != null && bulkActions != null;
360
+ // Unlike the other zones, the bulk bar exists only while rows are selected,
361
+ // so it opens the header band on its own only then — a controls-less
362
+ // selectable table must not render an empty band. (Deliberate trade-off:
363
+ // for a table with no header content at all, the band pops in on first
364
+ // selection rather than reserving empty space.)
365
+ const showBulk =
366
+ rowSelection != null &&
367
+ bulkActions != null &&
368
+ getSelectedRowIds(table.getState().rowSelection).length > 0;
331
369
 
332
- return (
333
- <div data-slot="data-table" className={cn('flex flex-col gap-4', className)}>
334
- {showHeader && (
335
- <ListHeader>
336
- {header}
337
- {showControls && (
338
- <ListHeaderControls>
339
- {toolbarNode}
340
- {hasFilterMenu && filters?.columns && (
341
- <DataTableAddFilter table={table} columns={filters.columns} label={l.addFilter} />
342
- )}
343
- {showViewOptions && (
344
- <DataTableViewOptions
370
+ const bands = (
371
+ <>
372
+ {(showHeader || showBulk) && (
373
+ <CardHeader className="border-b">
374
+ <ListHeader>
375
+ {header}
376
+ {/* Replace-on-select: while rows are selected the bulk bar takes
377
+ the controls row's place (title and applied-filter chips stay).
378
+ The swap fades out then in — one --transition-duration-fast
379
+ (100ms) per phase; mode="wait" keeps the rows sequential so
380
+ they never stack. */}
381
+ {(showControls || (rowSelection != null && bulkActions != null)) && (
382
+ <AnimatePresence initial={false} mode="wait">
383
+ {showBulk && bulkActions ? (
384
+ <motion.div key="bulk-actions" {...bandRowFade}>
385
+ <DataTableBulkActions
386
+ table={table}
387
+ cache={selectionCache}
388
+ render={bulkActions}
389
+ />
390
+ </motion.div>
391
+ ) : showControls ? (
392
+ <motion.div key="controls" {...bandRowFade}>
393
+ <ListHeaderControls>
394
+ {toolbarNode}
395
+ {hasFilterMenu && filters?.columns && (
396
+ <DataTableAddFilter
397
+ table={table}
398
+ columns={filters.columns}
399
+ label={l.addFilter}
400
+ />
401
+ )}
402
+ {showViewOptions && (
403
+ <DataTableViewOptions
404
+ table={table}
405
+ triggerLabel={l.columnsTrigger}
406
+ heading={l.columnsHeading}
407
+ />
408
+ )}
409
+ </ListHeaderControls>
410
+ </motion.div>
411
+ ) : null}
412
+ </AnimatePresence>
413
+ )}
414
+ {showChips && (
415
+ <ListHeaderChips>
416
+ <DataTableAppliedFilters
345
417
  table={table}
346
- triggerLabel={l.columnsTrigger}
347
- heading={l.columnsHeading}
418
+ columns={filters?.columns}
419
+ inlineChipLimit={filters?.inlineChipLimit}
420
+ removeLabel={l.removeFilter}
421
+ collapsedLabel={l.filtersCollapsed}
348
422
  />
349
- )}
350
- </ListHeaderControls>
351
- )}
352
- {showChips && (
353
- <ListHeaderChips>
354
- <DataTableAppliedFilters
355
- table={table}
356
- columns={filters?.columns}
357
- inlineChipLimit={filters?.inlineChipLimit}
358
- removeLabel={l.removeFilter}
359
- collapsedLabel={l.filtersCollapsed}
360
- />
361
- </ListHeaderChips>
362
- )}
363
- </ListHeader>
364
- )}
365
-
366
- {showBulk && bulkActions && (
367
- <DataTableBulkActions table={table} cache={selectionCache} render={bulkActions} />
423
+ </ListHeaderChips>
424
+ )}
425
+ </ListHeader>
426
+ </CardHeader>
368
427
  )}
369
428
 
370
- <div className="bg-card overflow-hidden rounded-xl border border-border/60">
429
+ <CardTable>
371
430
  <Table>
372
431
  <TableHeader>
373
432
  {table.getHeaderGroups().map((headerGroup) => (
@@ -419,63 +478,94 @@ function DataTable<TData>({
419
478
  </TableCell>
420
479
  </TableRow>
421
480
  ) : (
422
- bodyRows.map((row) => {
423
- const rowNode = (
424
- <TableRow
425
- className="group/row"
426
- data-state={row.getIsSelected() ? 'selected' : undefined}
427
- >
428
- {row.getVisibleCells().map((cell) => (
429
- <TableCell key={cell.id} className={columnClass(cell.column.id)}>
430
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
431
- </TableCell>
432
- ))}
433
- </TableRow>
434
- );
435
- // Right-click accelerator: the row itself is the context-menu
436
- // trigger, so the consumer supplies only the items and the core
437
- // owns the menu chrome.
438
- const defaultRow = contextActions ? (
439
- <ContextMenu>
440
- <ContextMenuTrigger render={rowNode} />
441
- <ContextMenuContent>
442
- {contextActions(row.original, { row, table })}
443
- </ContextMenuContent>
444
- </ContextMenu>
445
- ) : (
446
- rowNode
447
- );
448
- // Row-render seam: consumers can swap the default row for a
449
- // full-width utility row or a per-row wrapper the cell grid can't
450
- // express. Returning `defaultRow` keeps the built-in rendering.
451
- return (
452
- <React.Fragment key={row.id}>
453
- {renderRow ? renderRow(row, { table, columnCount, defaultRow }) : defaultRow}
454
- </React.Fragment>
455
- );
456
- })
481
+ <>
482
+ {bodyRows.map((row) => {
483
+ const rowNode = (
484
+ <TableRow
485
+ className="group/row"
486
+ data-state={row.getIsSelected() ? 'selected' : undefined}
487
+ >
488
+ {row.getVisibleCells().map((cell) => (
489
+ <TableCell key={cell.id} className={columnClass(cell.column.id)}>
490
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
491
+ </TableCell>
492
+ ))}
493
+ </TableRow>
494
+ );
495
+ // Right-click accelerator: the row itself is the context-menu
496
+ // trigger, so the consumer supplies only the items and the core
497
+ // owns the menu chrome.
498
+ const defaultRow = contextActions ? (
499
+ <ContextMenu>
500
+ <ContextMenuTrigger render={rowNode} />
501
+ <ContextMenuContent>
502
+ {contextActions(row.original, { row, table })}
503
+ </ContextMenuContent>
504
+ </ContextMenu>
505
+ ) : (
506
+ rowNode
507
+ );
508
+ // Row-render seam: consumers can swap the default row for a
509
+ // full-width utility row or a per-row wrapper the cell grid can't
510
+ // express. Returning `defaultRow` keeps the built-in rendering.
511
+ return (
512
+ <React.Fragment key={row.id}>
513
+ {renderRow ? renderRow(row, { table, columnCount, defaultRow }) : defaultRow}
514
+ </React.Fragment>
515
+ );
516
+ })}
517
+ {typeof footerRows === 'function' ? footerRows({ columnCount }) : footerRows}
518
+ </>
457
519
  )}
458
520
  </TableBody>
459
521
  </Table>
460
- </div>
522
+ </CardTable>
461
523
 
462
524
  {pagination && (
463
- <TablePagination
464
- page={pagination.page}
465
- pageSize={pagination.pageSize}
466
- totalItems={pagination.totalItems ?? table.getPrePaginationRowModel().rows.length}
467
- onPageChange={pagination.onPageChange}
468
- onPageSizeChange={pagination.onPageSizeChange}
469
- pageSizeOptions={pagination.pageSizeOptions}
470
- getPageHref={pagination.getPageHref}
471
- formatRange={pagination.formatRange}
472
- navLabel={l.pagination?.navLabel}
473
- previousLabel={l.pagination?.previousLabel}
474
- nextLabel={l.pagination?.nextLabel}
475
- pageSizeLabel={l.pagination?.pageSizeLabel}
476
- />
525
+ <CardFooter className="border-t">
526
+ <TablePagination
527
+ className="w-full"
528
+ page={pagination.page}
529
+ pageSize={pagination.pageSize}
530
+ totalItems={pagination.totalItems ?? table.getPrePaginationRowModel().rows.length}
531
+ onPageChange={pagination.onPageChange}
532
+ onPageSizeChange={pagination.onPageSizeChange}
533
+ pageSizeOptions={pagination.pageSizeOptions}
534
+ getPageHref={pagination.getPageHref}
535
+ formatRange={pagination.formatRange}
536
+ navLabel={l.pagination?.navLabel}
537
+ previousLabel={l.pagination?.previousLabel}
538
+ nextLabel={l.pagination?.nextLabel}
539
+ pageSizeLabel={l.pagination?.pageSizeLabel}
540
+ />
541
+ </CardFooter>
477
542
  )}
543
+ </>
544
+ );
545
+
546
+ // `plain` renders a chrome-less stack instead of a Card so the bands and
547
+ // CardTable consume the HOST card's spacing variables (--card-px /
548
+ // --card-gap): edge cells align with the host's padding regardless of its
549
+ // size, and a trailing CardTable's negative margin reaches through the
550
+ // host's bottom padding so the last row sits flush against the host's edge.
551
+ // With no header band the leading CardTable's negative margin would eat the
552
+ // host's flex gap too and press the rows against the preceding content, so
553
+ // the stack restores that one gap as padding.
554
+ return frame === 'plain' ? (
555
+ <div
556
+ data-slot="data-table"
557
+ className={cn(
558
+ 'flex flex-col gap-(--card-gap)',
559
+ !(showHeader || showBulk) && 'pt-(--card-gap)',
560
+ className,
561
+ )}
562
+ >
563
+ {bands}
478
564
  </div>
565
+ ) : (
566
+ <Card data-slot="data-table" className={className}>
567
+ {bands}
568
+ </Card>
479
569
  );
480
570
  }
481
571
 
@@ -493,7 +583,9 @@ export type {
493
583
  Row,
494
584
  RowSelectionState,
495
585
  SortingState,
496
- Table,
586
+ // Not `Table`: that name is the Table atom. This is the TanStack instance
587
+ // type, as `onTableReady` hands it over.
588
+ Table as TableInstance,
497
589
  TableOptions,
498
590
  VisibilityState,
499
591
  } from '@tanstack/react-table';
@@ -75,7 +75,9 @@ function DatePicker({
75
75
  variant="outline"
76
76
  disabled={disabled}
77
77
  aria-invalid={invalid || undefined}
78
- className="min-w-0 flex-1 justify-start font-normal"
78
+ // Pickers sit in forms next to Inputs, so mirror the Input/Select
79
+ // trigger look (transparent bg) instead of the outline button fill.
80
+ className="min-w-0 flex-1 justify-start border-input bg-transparent font-normal hover:bg-transparent aria-expanded:bg-transparent"
79
81
  />
80
82
  }
81
83
  >
@@ -92,7 +92,9 @@ function DateRangePicker({
92
92
  variant="outline"
93
93
  disabled={disabled}
94
94
  aria-invalid={invalid || undefined}
95
- className="min-w-0 flex-1 justify-start font-normal"
95
+ // Pickers sit in forms next to Inputs, so mirror the Input/Select
96
+ // trigger look (transparent bg) instead of the outline button fill.
97
+ className="min-w-0 flex-1 justify-start border-input bg-transparent font-normal hover:bg-transparent aria-expanded:bg-transparent"
96
98
  />
97
99
  }
98
100
  >
@@ -84,7 +84,9 @@ function DateTimePicker({
84
84
  variant="outline"
85
85
  disabled={disabled}
86
86
  aria-invalid={invalid || undefined}
87
- className="min-w-0 flex-1 justify-start font-normal"
87
+ // Pickers sit in forms next to Inputs, so mirror the Input/Select
88
+ // trigger look (transparent bg) instead of the outline button fill.
89
+ className="min-w-0 flex-1 justify-start border-input bg-transparent font-normal hover:bg-transparent aria-expanded:bg-transparent"
88
90
  />
89
91
  }
90
92
  >
@@ -91,9 +91,13 @@ function FileDropzone({
91
91
  const [validating, setValidating] = React.useState(false);
92
92
  const [rejections, setRejections] = React.useState<FileRejection[]>([]);
93
93
  const dragDepth = React.useRef(0);
94
+ // Synchronous mirror of `validating`: a drop while an async validateFile is
95
+ // in flight would otherwise start a second addFiles against a stale `value`.
96
+ const busy = React.useRef(false);
94
97
 
95
98
  async function addFiles(incoming: readonly File[]) {
96
- if (disabled || incoming.length === 0) return;
99
+ if (disabled || busy.current || incoming.length === 0) return;
100
+ busy.current = true;
97
101
  setValidating(true);
98
102
  const accepted: File[] = [];
99
103
  const rejected: FileRejection[] = [];
@@ -118,11 +122,15 @@ function FileDropzone({
118
122
 
119
123
  if (incoming.length > remaining) {
120
124
  for (const file of incoming.slice(remaining)) {
121
- rejected.push({ file, messages: [`You can select up to ${maxFiles} files.`] });
125
+ rejected.push({
126
+ file,
127
+ messages: [`You can select up to ${maxFiles} ${maxFiles === 1 ? 'file' : 'files'}.`],
128
+ });
122
129
  }
123
130
  }
124
131
 
125
132
  setRejections(rejected);
133
+ busy.current = false;
126
134
  setValidating(false);
127
135
  if (rejected.length > 0) onRejected?.(rejected);
128
136
  if (accepted.length > 0) {
@@ -211,7 +219,9 @@ function FileDropzone({
211
219
  {value.length > 0 ? (
212
220
  <ul data-slot="file-dropzone-files" className="flex flex-col gap-2">
213
221
  {value.map((file, index) => (
214
- <li key={`${file.name}-${file.size}-${file.lastModified}`}>
222
+ // Metadata alone can collide (two distinct files with identical
223
+ // name, size and mtime), so the index disambiguates the key.
224
+ <li key={`${file.name}-${file.size}-${file.lastModified}-${index}`}>
215
225
  {renderFile ? (
216
226
  renderFile(file, () => removeFile(index))
217
227
  ) : (
@@ -240,8 +250,8 @@ function FileDropzone({
240
250
 
241
251
  {rejections.length > 0 ? (
242
252
  <div id={errorId} role="alert" className="text-destructive text-sm">
243
- {rejections.map(({ file, messages }) => (
244
- <p key={`${file.name}-${file.size}`}>
253
+ {rejections.map(({ file, messages }, index) => (
254
+ <p key={`${file.name}-${file.size}-${index}`}>
245
255
  <span className="font-medium">{file.name}:</span> {messages.join(' ')}
246
256
  </p>
247
257
  ))}
@@ -3,9 +3,9 @@ import { cn } from '@vendure-io/ui/lib/utils';
3
3
 
4
4
  /**
5
5
  * A database cylinder with a solid rim but dashed walls and dividing bands —
6
- * a shell with nothing provisioned inside. For no database provisioned yet,
7
- * or no backups exist. Not for a generic empty list (use
8
- * `EmptyCollectionIllustration`).
6
+ * a shell with nothing provisioned inside, and a "+" badge for the first one
7
+ * to create. For no database provisioned yet, or no backups exist. Not for a
8
+ * generic empty list (use `EmptyCollectionIllustration`).
9
9
  */
10
10
  function EmptyDatabaseIllustration({ className, size = 160 }: IllustrationProps) {
11
11
  return (
@@ -35,8 +35,11 @@ function EmptyDatabaseIllustration({ className, size = 160 }: IllustrationProps)
35
35
  <path d="M56,66 A24,8 0 0,0 104,66" className="stroke-border" strokeDasharray="3 4" />
36
36
  <path d="M56,82 A24,8 0 0,0 104,82" className="stroke-border" strokeDasharray="3 4" />
37
37
 
38
- {/* status dot — the one brand accent */}
39
- <circle cx="100" cy="28" r="4" className="fill-brand" />
38
+ {/* provision badge — the one brand accent */}
39
+ <polygon
40
+ points="110,18 114,18 114,22 118,22 118,26 114,26 114,30 110,30 110,26 106,26 106,22 110,22"
41
+ className="fill-brand"
42
+ />
40
43
  </svg>
41
44
  );
42
45
  }