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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/package.json +12 -11
  2. package/src/components/atoms/alert-dialog.tsx +1 -4
  3. package/src/components/atoms/alert.tsx +59 -35
  4. package/src/components/atoms/badge.tsx +2 -2
  5. package/src/components/atoms/breadcrumb.tsx +154 -59
  6. package/src/components/atoms/button-group.tsx +1 -1
  7. package/src/components/atoms/button.tsx +2 -2
  8. package/src/components/atoms/calendar.tsx +2 -2
  9. package/src/components/atoms/card.tsx +15 -2
  10. package/src/components/atoms/carousel.tsx +33 -7
  11. package/src/components/atoms/chart.tsx +3 -3
  12. package/src/components/atoms/checkbox.tsx +1 -1
  13. package/src/components/atoms/combobox.tsx +60 -36
  14. package/src/components/atoms/command.tsx +17 -7
  15. package/src/components/atoms/context-menu.tsx +5 -5
  16. package/src/components/atoms/dialog.tsx +30 -14
  17. package/src/components/atoms/dropdown-menu.tsx +1 -1
  18. package/src/components/atoms/hover-card.tsx +1 -1
  19. package/src/components/atoms/input-group.tsx +30 -12
  20. package/src/components/atoms/input-otp.tsx +2 -2
  21. package/src/components/atoms/input.tsx +13 -3
  22. package/src/components/atoms/menubar.tsx +2 -2
  23. package/src/components/atoms/native-select.tsx +1 -1
  24. package/src/components/atoms/navigation-menu.tsx +3 -3
  25. package/src/components/atoms/pagination.tsx +52 -15
  26. package/src/components/atoms/popover.tsx +1 -1
  27. package/src/components/atoms/select.tsx +3 -3
  28. package/src/components/atoms/sheet.tsx +35 -15
  29. package/src/components/atoms/sidebar.tsx +224 -36
  30. package/src/components/atoms/skeleton.tsx +6 -3
  31. package/src/components/atoms/spinner.tsx +7 -2
  32. package/src/components/atoms/tabs.tsx +6 -2
  33. package/src/components/atoms/textarea.tsx +1 -1
  34. package/src/components/atoms/toggle.tsx +1 -1
  35. package/src/components/molecules/action-needed.tsx +483 -0
  36. package/src/components/molecules/anonymized-token.tsx +70 -25
  37. package/src/components/molecules/app-shell.tsx +14 -5
  38. package/src/components/molecules/checklist/checklist.tsx +47 -17
  39. package/src/components/molecules/chip.tsx +37 -19
  40. package/src/components/molecules/choice-card.tsx +117 -9
  41. package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
  42. package/src/components/molecules/code-block/process-code.ts +1 -1
  43. package/src/components/molecules/code-block.tsx +58 -47
  44. package/src/components/molecules/combobox-free-text.tsx +75 -20
  45. package/src/components/molecules/confirm-dialog.tsx +17 -5
  46. package/src/components/molecules/copyable-text.tsx +10 -8
  47. package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
  48. package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
  49. package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
  50. package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
  51. package/src/components/molecules/data-table/data-table-types.tsx +156 -29
  52. package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
  53. package/src/components/molecules/data-table/data-table.tsx +156 -75
  54. package/src/components/molecules/data-table/table-pagination.tsx +142 -38
  55. package/src/components/molecules/date-picker.tsx +58 -25
  56. package/src/components/molecules/date-range-picker.tsx +59 -24
  57. package/src/components/molecules/date-time-picker.tsx +63 -25
  58. package/src/components/molecules/date-time.tsx +38 -3
  59. package/src/components/molecules/elapsed-time.tsx +61 -12
  60. package/src/components/molecules/file-dropzone.tsx +151 -40
  61. package/src/components/molecules/format-provider.tsx +14 -4
  62. package/src/components/molecules/id-chip-chrome.tsx +114 -0
  63. package/src/components/molecules/id-chip.tsx +13 -115
  64. package/src/components/molecules/issued-secret.tsx +35 -25
  65. package/src/components/molecules/live-indicator.tsx +1 -1
  66. package/src/components/molecules/money.tsx +44 -3
  67. package/src/components/molecules/multi-select.tsx +62 -16
  68. package/src/components/molecules/page-header.tsx +6 -2
  69. package/src/components/molecules/password-input.tsx +11 -10
  70. package/src/components/molecules/relative-time.tsx +88 -16
  71. package/src/components/molecules/search-trigger.tsx +5 -3
  72. package/src/components/molecules/secret-value.tsx +35 -19
  73. package/src/components/molecules/skip-link.tsx +11 -9
  74. package/src/components/molecules/stat-card.tsx +145 -33
  75. package/src/components/molecules/state-views/empty-state.tsx +16 -12
  76. package/src/components/molecules/state-views/error-state.tsx +36 -20
  77. package/src/components/molecules/state-views/loading-state.tsx +18 -6
  78. package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
  79. package/src/components/molecules/status-badge.tsx +11 -35
  80. package/src/components/molecules/time-tooltip.tsx +55 -1
  81. package/src/hooks/use-copy.ts +3 -1
  82. package/src/lib/deprecated.ts +71 -0
  83. package/src/lib/field-surface.ts +7 -7
  84. package/src/lib/format-messages.ts +368 -0
  85. package/src/lib/highlight.ts +1 -1
  86. package/src/lib/menu-item.tsx +1 -1
  87. package/src/lib/tint-recipes.ts +10 -5
  88. package/src/lib/utils.ts +19 -1
  89. package/src/lib/dialog-padding.ts +0 -48
@@ -41,23 +41,17 @@ import {
41
41
  TableRow,
42
42
  } from '@vendure-io/ui/components/atoms/table';
43
43
  import { Tooltip, TooltipContent, TooltipTrigger } from '@vendure-io/ui/components/atoms/tooltip';
44
- import {
45
- DataTableBulkActions,
46
- useSelectionCache,
47
- } from '@vendure-io/ui/components/molecules/data-table/data-table-bulk-actions';
48
44
  import { DataTableColumnHeader } from '@vendure-io/ui/components/molecules/data-table/data-table-column-header';
49
45
  import {
50
46
  DataTableAddFilter,
51
47
  DataTableAppliedFilters,
52
48
  } from '@vendure-io/ui/components/molecules/data-table/data-table-filters';
53
49
  import type {
54
- ControlledState,
55
50
  DataTableProps,
56
51
  DataTableRowCellProps,
57
52
  DataTableRowRipple,
58
53
  DataTableRowSelectProps,
59
54
  } from '@vendure-io/ui/components/molecules/data-table/data-table-types';
60
- import { DataTableViewOptions } from '@vendure-io/ui/components/molecules/data-table/data-table-view-options';
61
55
  import {
62
56
  ListHeader,
63
57
  ListHeaderChips,
@@ -72,22 +66,39 @@ import { AnimatePresence, MotionConfig, motion, useReducedMotion } from 'motion/
72
66
  import * as React from 'react';
73
67
  import { createPortal } from 'react-dom';
74
68
  import { isDevelopment } from '../../../lib/env.ts';
69
+ import { fillMessage, useMessages } from '../../../lib/format-messages.ts';
70
+ import { DataTableBulkActions, useSelectionCache } from './data-table-bulk-actions.tsx';
75
71
  // Relative: `data-table-helpers` is closed in the package exports.
76
72
  import {
77
73
  buildDisplayColumns,
78
74
  columnAlign,
75
+ columnContentIndent,
76
+ columnMinWidth,
77
+ columnWidth,
79
78
  getSelectedRowIds,
80
79
  measureColumnIndents,
80
+ PENDING_CLASS,
81
81
  resolveClearFilters,
82
82
  resolveSlot,
83
83
  sameIndents,
84
+ useControlledTableState,
85
+ warnOnChange,
84
86
  } from './data-table-helpers.tsx';
87
+ // Relative: `data-table-row-count-storage` is closed in the package exports.
88
+ import { skeletonRowCountFor, useRememberedListTotal } from './data-table-row-count-storage.tsx';
85
89
  // Relative: `data-table-selection-storage` is closed in the package exports.
86
90
  import { useSelectionStorage } from './data-table-selection-storage.tsx';
91
+ import { DataTableViewOptions } from './data-table-view-options.tsx';
87
92
 
88
93
  // Id of the generated row-actions column. Public: it is the `skeletonCells` key
89
94
  // for the actions cell.
90
95
  const ACTIONS_COLUMN_ID = 'actions';
96
+ // The table's data before the first load. One array, so TanStack's row model
97
+ // does not rebuild on every render.
98
+ const NO_ROWS: never[] = [];
99
+
100
+ // The built-in empty-state cell.
101
+ const EMPTY_CELL_CLASS = 'text-muted-foreground h-24 text-center';
91
102
 
92
103
  // The row link is a stretched link, like ListRowLink: one real link per row,
93
104
  // whose ::after covers the row (the row is `relative`), so a click on any point
@@ -130,9 +141,11 @@ const LINKED_ROW_CLASS = cn(
130
141
  // cell of every row, header included, so the chevron never covers a cell and
131
142
  // a row without a link lines up with the others. The chevron is 15px and sits
132
143
  // one 12px gap after the last cell, like ListRowChevron. Important: CardTable
133
- // sets the edge padding with a descendant rule.
144
+ // sets the edge padding with a descendant rule. `rowLinks` (`data-row-links`)
145
+ // keeps the slot in every state, also while skeleton or empty rows have no
146
+ // link to find, so the columns do not move when the linked rows arrive.
134
147
  const ROW_CHEVRON_SLOT_CLASS =
135
- '[&:has([data-slot=data-table-row-link])_tr>*:last-child]:pe-[calc(var(--card-px)+--spacing(7))]!';
148
+ '[&:has([data-slot=data-table-row-link])_tr>*:last-child]:pe-[calc(var(--card-px)+--spacing(7))]! [&[data-row-links]_tr>*:last-child]:pe-[calc(var(--card-px)+--spacing(7))]!';
136
149
 
137
150
  // Pinned (`pinFirstColumn`): a pinned cell is positioned, so it becomes the
138
151
  // containing block of the link's stretched ::after. A link in the pinned cell
@@ -340,30 +353,6 @@ function DataTableRowLink({
340
353
  // placeholders. Only this folder imports TanStack; the composed
341
354
  // ListHeader/TablePagination/Chip primitives stay TanStack-free.
342
355
 
343
- /**
344
- * Bridge a capability config to a `[value, onChange]` pair TanStack can consume
345
- * as fully controlled. Controlled configs (`value`) are the source of truth every
346
- * render; uncontrolled configs (`defaultValue` or nothing) get internal state the
347
- * core owns, with any `onChange` observing. This fixes the donor's seed-then-emit
348
- * bug: the prop, not a one-time seed, drives every render.
349
- */
350
- function useControlledTableState<T>(
351
- config: ControlledState<T> | undefined,
352
- fallback: T,
353
- ): readonly [T, OnChangeFn<T>] {
354
- const controlled = config?.value !== undefined;
355
- const [internal, setInternal] = React.useState<T>(config?.defaultValue ?? fallback);
356
- const value = controlled ? (config?.value as T) : internal;
357
- const onChange = React.useCallback<OnChangeFn<T>>(
358
- (updater) => {
359
- if (!controlled) setInternal((old) => functionalUpdate(updater, old));
360
- config?.onChange?.(updater);
361
- },
362
- [controlled, config],
363
- );
364
- return [value, onChange] as const;
365
- }
366
-
367
356
  /** A string label for a column, from a string `header`, else the column id. */
368
357
  function headerLabelText<TData>(column: Column<TData, unknown>): string {
369
358
  const header = column.columnDef.header;
@@ -723,6 +712,7 @@ function DataTable<TData>({
723
712
  isLoading,
724
713
  skeletonRowCount = 10,
725
714
  skeletonCells,
715
+ expectedTotal,
726
716
  pagination,
727
717
  sorting,
728
718
  filters,
@@ -740,6 +730,7 @@ function DataTable<TData>({
740
730
  onTableReady,
741
731
  frame = 'card',
742
732
  pinFirstColumn = false,
733
+ rowLinks = false,
743
734
  footerRows,
744
735
  labels,
745
736
  className,
@@ -760,28 +751,78 @@ function DataTable<TData>({
760
751
  );
761
752
  }
762
753
 
763
- // Resolve labels once per `labels` identity.
754
+ // Before the first load (`rows` undefined) the body shows skeleton rows. A
755
+ // load with rows loaded (a page, sort or filter change, or a refetch of an
756
+ // empty list) is pending instead: the rows or the empty state stay and dim
757
+ // after a short delay.
758
+ const firstLoad = rows === undefined;
759
+ const pending = Boolean(isLoading) && !firstLoad;
760
+ const serverTotal =
761
+ pagination != null && pagination.mode !== 'client' ? pagination.totalItems : undefined;
762
+ const serverTotalUnknown =
763
+ pagination != null && pagination.mode !== 'client' && serverTotal == null;
764
+
765
+ const warnedUnknownTotal = React.useRef(false);
766
+ if (
767
+ isDevelopment &&
768
+ serverTotalUnknown &&
769
+ !firstLoad &&
770
+ !isLoading &&
771
+ !warnedUnknownTotal.current
772
+ ) {
773
+ warnedUnknownTotal.current = true;
774
+ console.warn(
775
+ '[DataTable] The rows have loaded but pagination.totalItems is not known (null or undefined). ' +
776
+ 'Pass the total with the rows: the footer range stays a skeleton until then.',
777
+ );
778
+ }
779
+
780
+ // The texts DataTable draws itself: the `labels` entry, then
781
+ // `messages.dataTable`, then English. The texts of the toolbar parts
782
+ // (DataTableAddFilter, DataTableViewOptions, DataTableAppliedFilters,
783
+ // TablePagination) get the raw `labels` entry and resolve it there, so each
784
+ // text has one resolution point.
785
+ const t = useMessages('dataTable', {
786
+ empty: labels?.empty,
787
+ selectAllRows: labels?.selectAllRows,
788
+ selectAllOnPage: labels?.selectAllOnPage,
789
+ clearPageSelection: labels?.clearPageSelection,
790
+ rowActions: labels?.rowActions,
791
+ clearFilters: labels?.clearFilters,
792
+ });
793
+ // Resolve labels once per `labels` identity and messages.
764
794
  const l = React.useMemo(
765
795
  () => ({
766
- empty: labels?.empty ?? 'No results',
767
- selectAllRows: labels?.selectAllRows ?? 'Select all rows',
768
- selectAllOnPage: labels?.selectAllOnPage ?? 'Select all on this page',
769
- clearPageSelection: labels?.clearPageSelection ?? 'Clear selection on this page',
770
- selectRow: labels?.selectRow ?? ((index: number) => `Select row ${index + 1}`),
771
- rowActions: labels?.rowActions ?? 'Open row actions',
772
- columnsTrigger: labels?.columnsTrigger ?? 'Columns',
773
- columnsHeading: labels?.columnsHeading ?? 'Toggle columns',
774
- addFilter: labels?.addFilter ?? 'Add filter',
775
- clearFilters: labels?.clearFilters ?? 'Clear filters',
776
- removeFilter:
777
- labels?.removeFilter ?? ((columnLabel: string) => `Remove ${columnLabel} filter`),
778
- sortLabel: labels?.sortLabel ?? ((columnLabel: string) => `Sort by ${columnLabel}`),
779
- filtersCollapsed: labels?.filtersCollapsed ?? ((count: number) => `${count} filters`),
780
- pagination: labels?.pagination,
796
+ empty: t.empty,
797
+ selectAllRows: t.selectAllRows,
798
+ selectAllOnPage: t.selectAllOnPage,
799
+ clearPageSelection: t.clearPageSelection,
800
+ selectRow:
801
+ labels?.selectRow ?? ((index: number) => fillMessage(t.selectRow, { row: index + 1 })),
802
+ rowActions: t.rowActions,
803
+ clearFilters: t.clearFilters,
804
+ sortLabel:
805
+ labels?.sortLabel ??
806
+ ((columnLabel: string) => fillMessage(t.sortLabel, { column: columnLabel })),
781
807
  }),
782
- [labels],
808
+ [
809
+ labels?.selectRow,
810
+ labels?.sortLabel,
811
+ t.empty,
812
+ t.selectAllRows,
813
+ t.selectAllOnPage,
814
+ t.clearPageSelection,
815
+ t.selectRow,
816
+ t.rowActions,
817
+ t.clearFilters,
818
+ t.sortLabel,
819
+ ],
783
820
  );
784
821
 
822
+ warnOnChange(sorting, 'sorting');
823
+ warnOnChange(filters, 'filters');
824
+ warnOnChange(columnVisibility, 'columnVisibility');
825
+ warnOnChange(rowSelection, 'rowSelection');
785
826
  const [sortingState, onSortingChange] = useControlledTableState<SortingState>(sorting, []);
786
827
  const [filtersState, onColumnFiltersChange] = useControlledTableState<ColumnFiltersState>(
787
828
  filters,
@@ -951,7 +992,7 @@ function DataTable<TData>({
951
992
  };
952
993
 
953
994
  const baseOptions: TableOptions<TData> = {
954
- data: rows,
995
+ data: rows ?? NO_ROWS,
955
996
  columns: displayColumns,
956
997
  state,
957
998
  getRowId,
@@ -962,7 +1003,7 @@ function DataTable<TData>({
962
1003
  manualSorting: sorting ? sorting.mode !== 'client' : undefined,
963
1004
  manualFiltering: filters ? filters.mode !== 'client' : undefined,
964
1005
  manualPagination: pagination ? pagination.mode !== 'client' : undefined,
965
- rowCount: pagination && pagination.mode !== 'client' ? pagination.totalItems : undefined,
1006
+ rowCount: serverTotal ?? undefined,
966
1007
  };
967
1008
 
968
1009
  if (sorting) {
@@ -999,6 +1040,8 @@ function DataTable<TData>({
999
1040
 
1000
1041
  const bodyRows = table.getRowModel().rows;
1001
1042
  const columnCount = table.getVisibleLeafColumns().length;
1043
+ // The first load draws as many skeleton rows as the current page will have.
1044
+ const skeletonRows = skeletonRowCountFor(expectedTotal ?? null, pagination, skeletonRowCount);
1002
1045
 
1003
1046
  // The select checkbox is floated absolutely over a zero-width cell, so the
1004
1047
  // gutter it needs is folded into the leading data column as left padding —
@@ -1089,9 +1132,22 @@ function DataTable<TData>({
1089
1132
  generatedColumn(columnId) === 'select' && leadingColumnId != null
1090
1133
  ? leadingColumnId
1091
1134
  : columnId;
1092
- return columnIndents[id]
1093
- ? ({ '--column-indent': `${columnIndents[id]}px` } as React.CSSProperties)
1094
- : undefined;
1135
+ // A declared inset (`meta.contentInset`) indents the column the same in
1136
+ // every state; the measured indent is the fallback.
1137
+ const declared = columnContentIndent(table.getColumn(id)?.columnDef.meta);
1138
+ const indent = declared ?? (columnIndents[id] ? `${columnIndents[id]}px` : undefined);
1139
+ return indent ? ({ '--column-indent': indent } as React.CSSProperties) : undefined;
1140
+ };
1141
+
1142
+ // A column's `meta.width` is set on its header cell, so the column has that
1143
+ // width while the skeleton shows and once the rows arrive (the table keeps
1144
+ // its automatic layout: wider content still widens it).
1145
+ // biome-ignore lint/suspicious/noExplicitAny: matches TanStack's ColumnDef value-type convention
1146
+ const headerCellStyle = (column: Column<TData, any>): React.CSSProperties | undefined => {
1147
+ const indent = columnIndentStyle(column.id);
1148
+ const width = columnWidth(column.columnDef.meta);
1149
+ const minWidth = columnMinWidth(column.columnDef.meta);
1150
+ return width == null && minWidth == null ? indent : { ...indent, width, minWidth };
1095
1151
  };
1096
1152
 
1097
1153
  // What a built-in body cell of this column carries. Handed to `renderRow` as
@@ -1172,7 +1228,7 @@ function DataTable<TData>({
1172
1228
  const clearFilters = resolveClearFilters(
1173
1229
  filters?.clearFilters,
1174
1230
  table,
1175
- !(isLoading && rows.length === 0) && bodyRows.length === 0,
1231
+ !firstLoad && bodyRows.length === 0,
1176
1232
  );
1177
1233
  // The bulk bar exists only while rows are selected. It takes the controls
1178
1234
  // row's place, or, with no controls row, covers the column header row (see
@@ -1285,14 +1341,15 @@ function DataTable<TData>({
1285
1341
  <DataTableAddFilter
1286
1342
  table={table}
1287
1343
  columns={filters.columns}
1288
- label={l.addFilter}
1344
+ label={labels?.addFilter}
1345
+ valueLabel={labels?.filterValue}
1289
1346
  />
1290
1347
  )}
1291
1348
  {showViewOptions && (
1292
1349
  <DataTableViewOptions
1293
1350
  table={table}
1294
- triggerLabel={l.columnsTrigger}
1295
- heading={l.columnsHeading}
1351
+ triggerLabel={labels?.columnsTrigger}
1352
+ heading={labels?.columnsHeading}
1296
1353
  />
1297
1354
  )}
1298
1355
  </ListHeaderControls>
@@ -1325,8 +1382,8 @@ function DataTable<TData>({
1325
1382
  table={table}
1326
1383
  columns={filters?.columns}
1327
1384
  inlineChipLimit={filters?.inlineChipLimit}
1328
- removeLabel={l.removeFilter}
1329
- collapsedLabel={l.filtersCollapsed}
1385
+ removeLabel={labels?.removeFilter}
1386
+ collapsedLabel={labels?.filtersCollapsed}
1330
1387
  />
1331
1388
  {clearFilters && !clearFilters.hidden && (
1332
1389
  <Button
@@ -1374,6 +1431,7 @@ function DataTable<TData>({
1374
1431
  pinFirstColumn={pinFirstColumn}
1375
1432
  className={cn(LINKED_ROW_CLASS, ROW_CHEVRON_SLOT_CLASS, SELECT_RIPPLE_TABLE_CLASS)}
1376
1433
  data-selecting={selecting ? '' : undefined}
1434
+ data-row-links={rowLinks ? '' : undefined}
1377
1435
  data-bulk-over-header={bulkOverHeader && showBulk ? '' : undefined}
1378
1436
  >
1379
1437
  <TableHeader>
@@ -1394,7 +1452,7 @@ function DataTable<TData>({
1394
1452
  generatedColumn(headerCell.column.id) !== 'select' &&
1395
1453
  HEADER_LABEL_UNDER_BULK_CLASS,
1396
1454
  )}
1397
- style={columnIndentStyle(headerCell.column.id)}
1455
+ style={headerCellStyle(headerCell.column)}
1398
1456
  >
1399
1457
  {sorting != null && !headerCell.isPlaceholder ? (
1400
1458
  <DataTableColumnHeader
@@ -1413,9 +1471,13 @@ function DataTable<TData>({
1413
1471
  </TableRow>
1414
1472
  ))}
1415
1473
  </TableHeader>
1416
- <TableBody>
1417
- {isLoading && rows.length === 0 ? (
1418
- Array.from({ length: skeletonRowCount }).map((_, rowIndex) => (
1474
+ <TableBody
1475
+ aria-busy={isLoading || firstLoad ? true : undefined}
1476
+ data-pending={pending ? '' : undefined}
1477
+ className={PENDING_CLASS}
1478
+ >
1479
+ {firstLoad && skeletonRows > 0 ? (
1480
+ Array.from({ length: skeletonRows }).map((_, rowIndex) => (
1419
1481
  <TableRow key={`skeleton-${rowIndex}`}>
1420
1482
  {columnCount === 0 ? (
1421
1483
  <TableCell>
@@ -1437,11 +1499,17 @@ function DataTable<TData>({
1437
1499
  </TableRow>
1438
1500
  ))
1439
1501
  ) : bodyRows.length === 0 ? (
1440
- <TableRow className="hover:bg-transparent">
1441
- <TableCell
1442
- colSpan={Math.max(columnCount, 1)}
1443
- className="text-muted-foreground h-24 text-center"
1444
- >
1502
+ // The empty state. Before the first load of a page that will be
1503
+ // empty (by the remembered total), it is already here but hidden
1504
+ // and inert, so the body has its exact height and the empty
1505
+ // result shows in place.
1506
+ <TableRow
1507
+ data-slot={firstLoad ? 'data-table-empty-placeholder' : undefined}
1508
+ aria-hidden={firstLoad ? true : undefined}
1509
+ inert={firstLoad ? true : undefined}
1510
+ className={cn('hover:bg-transparent', firstLoad && 'invisible')}
1511
+ >
1512
+ <TableCell colSpan={Math.max(columnCount, 1)} className={EMPTY_CELL_CLASS}>
1445
1513
  {emptyState ?? l.empty}
1446
1514
  </TableCell>
1447
1515
  </TableRow>
@@ -1513,16 +1581,24 @@ function DataTable<TData>({
1513
1581
  className="w-full"
1514
1582
  page={pagination.page}
1515
1583
  pageSize={pagination.pageSize}
1516
- totalItems={pagination.totalItems ?? table.getPrePaginationRowModel().rows.length}
1584
+ // Unknown (null or undefined, or client rows not loaded): a skeleton, not "0 of 0".
1585
+ totalItems={
1586
+ pagination.mode === 'client'
1587
+ ? firstLoad
1588
+ ? undefined
1589
+ : table.getPrePaginationRowModel().rows.length
1590
+ : pagination.totalItems
1591
+ }
1592
+ isLoading={pending}
1517
1593
  onPageChange={pagination.onPageChange}
1518
1594
  onPageSizeChange={pagination.onPageSizeChange}
1519
1595
  pageSizeOptions={pagination.pageSizeOptions}
1520
1596
  getPageHref={pagination.getPageHref}
1521
1597
  formatRange={pagination.formatRange}
1522
- navLabel={l.pagination?.navLabel}
1523
- previousLabel={l.pagination?.previousLabel}
1524
- nextLabel={l.pagination?.nextLabel}
1525
- pageSizeLabel={l.pagination?.pageSizeLabel}
1598
+ navLabel={labels?.pagination?.navLabel}
1599
+ previousLabel={labels?.pagination?.previousLabel}
1600
+ nextLabel={labels?.pagination?.nextLabel}
1601
+ pageSizeLabel={labels?.pagination?.pageSizeLabel}
1526
1602
  />
1527
1603
  </CardFooter>
1528
1604
  )}
@@ -1553,7 +1629,12 @@ function DataTable<TData>({
1553
1629
 
1554
1630
  // `DataTableSkeletonLine` is the shared SkeletonLine under its old name, kept for
1555
1631
  // consumers that stack it in `skeletonCells`.
1556
- export { DataTable, DataTableRowLink, SkeletonLine as DataTableSkeletonLine };
1632
+ export {
1633
+ DataTable,
1634
+ DataTableRowLink,
1635
+ SkeletonLine as DataTableSkeletonLine,
1636
+ useRememberedListTotal,
1637
+ };
1557
1638
 
1558
1639
  // Re-export the consumer-facing TanStack types so columns can be authored from
1559
1640
  // the same import as `DataTable` — no direct `@tanstack/react-table` dependency