@appdirect/design-system 0.0.17 → 0.0.18

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 (85) hide show
  1. package/bin/ad-sync-design-md.mjs +0 -0
  2. package/dist/ComplexComponents/DataTable/CellHoverReveal/CellHoverReveal.module.css +25 -0
  3. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.js +24 -0
  4. package/dist/ComplexComponents/DataTable/CellHoverReveal/index.tsx +44 -0
  5. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +7 -0
  6. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +25 -77
  7. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +101 -157
  8. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +14 -7
  9. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +13 -7
  10. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +4 -0
  11. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +8 -20
  12. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +40 -58
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  14. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +3 -0
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +50 -154
  16. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +59 -205
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.js +48 -0
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.ts +51 -0
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +5 -25
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +7 -28
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.js +16 -0
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.tsx +26 -0
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +26 -28
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +38 -38
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +8 -18
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.module.css +3 -0
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +25 -37
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +67 -378
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +170 -711
  30. package/dist/ComplexComponents/DataTable/DataTable.js +74 -393
  31. package/dist/ComplexComponents/DataTable/DataTable.tsx +229 -546
  32. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +85 -0
  33. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +46 -0
  34. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +143 -0
  35. package/dist/ComplexComponents/DataTable/DataTableShell/DataTableShell.module.css +38 -0
  36. package/dist/ComplexComponents/DataTable/DataTableShell/index.js +9 -0
  37. package/dist/ComplexComponents/DataTable/DataTableShell/index.tsx +47 -0
  38. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +6 -6
  39. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +53 -24
  40. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.js +33 -0
  41. package/dist/ComplexComponents/DataTable/SelectCheckbox/index.tsx +63 -0
  42. package/dist/ComplexComponents/DataTable/SortableHeaderCell/SortableHeaderCell.module.css +3 -0
  43. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +43 -21
  44. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +62 -38
  45. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.js +18 -0
  46. package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.tsx +47 -0
  47. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.js +19 -0
  48. package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.tsx +59 -0
  49. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +15 -0
  50. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.js +8 -0
  51. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.tsx +20 -0
  52. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.js +27 -0
  53. package/dist/ComplexComponents/DataTable/hooks/useClickOutside.ts +39 -0
  54. package/dist/ComplexComponents/DataTable/index.js +5 -1
  55. package/dist/ComplexComponents/DataTable/index.ts +13 -2
  56. package/dist/ComplexComponents/DataTable/table.module.css +9 -0
  57. package/dist/ComplexComponents/DataTable/tableFeatures.js +6 -0
  58. package/dist/ComplexComponents/DataTable/tableFeatures.ts +7 -0
  59. package/dist/ComplexComponents/DataTable/translations/en.js +16 -4
  60. package/dist/ComplexComponents/DataTable/translations/en.ts +16 -4
  61. package/dist/ComplexComponents/DataTable/translations/index.js +5 -0
  62. package/dist/ComplexComponents/DataTable/translations/index.ts +11 -1
  63. package/dist/ComplexComponents/DataTable/types.js +5 -0
  64. package/dist/ComplexComponents/DataTable/types.ts +17 -0
  65. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.js +3 -0
  66. package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.ts +4 -0
  67. package/dist/DESIGN.md +9 -10
  68. package/dist/contracts/DataTable.json +83 -6
  69. package/dist/contracts/index.json +1 -1
  70. package/dist/css/foundations.css +4 -0
  71. package/dist/css/mantine.css +1 -1
  72. package/dist/css/tokens.css +3145 -0
  73. package/dist/index.js +3 -0
  74. package/dist/index.ts +14 -1
  75. package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +216 -458
  76. package/dist/stories/index.json +13 -15
  77. package/package.json +5 -3
  78. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +0 -31
  79. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +0 -76
  80. package/dist/hooks/useTableHandlers.js +0 -136
  81. package/dist/hooks/useTableHandlers.ts +0 -179
  82. package/dist/hooks/useTableRenderFunctions.js +0 -164
  83. package/dist/hooks/useTableRenderFunctions.tsx +0 -283
  84. package/dist/hooks/useTableState.js +0 -70
  85. package/dist/hooks/useTableState.ts +0 -81
@@ -1,405 +1,86 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { useMemo } from 'react';
4
- import { useMantineReactTable, MantineReactTable, } from 'mantine-react-table-open';
5
- import { useTableState } from '../../hooks/useTableState.js';
6
- import { useTableHandlers } from '../../hooks/useTableHandlers.js';
7
- import { useTableRenderFunctions } from '../../hooks/useTableRenderFunctions.js';
8
- // ========================== CONSTANTS ==========================
9
- /**
10
- * Default values for various table configuration options
11
- * Centralized to ensure consistency and easy modification
12
- */
13
- const DEFAULT_VALUES = {
14
- /** Default number of rows per page */
15
- PAGE_SIZE: 10,
16
- /** Default table density (row height) - 'xs' is most compact */
17
- DENSITY: 'xs',
18
- /** Default locale for internationalization */
19
- LOCALE: 'en',
20
- /** Default total count when not provided */
21
- TOTAL_COUNT: 0,
22
- /** Default result count (deprecated) */
23
- RESULT_COUNT: 0,
24
- };
25
- /**
26
- * Feature flags that control which table features are enabled by default
27
- * Can be overridden by props but provide sensible defaults
28
- */
29
- const FEATURE_FLAGS = {
30
- /** Enable filters panel by default */
31
- SHOW_FILTERS: true,
32
- /** Enable global search by default */
33
- SHOW_SEARCH: true,
34
- /** Enable density toggle by default */
35
- SHOW_DENSITY_TOGGLE: true,
36
- /** Enable fullscreen toggle by default */
37
- SHOW_FULL_SCREEN_TOGGLE: true,
38
- };
39
- // ========================== CUSTOM HOOKS ==========================
40
3
  /**
41
- * DataTable Component
42
- *
43
- * A powerful, feature-rich data table component built on top of Mantine React Table.
44
- * Supports pagination, sorting, filtering, row selection, density controls, and more.
45
- * Perfect for displaying large datasets with complex interaction requirements.
46
- *
47
- * @example
48
- * // Basic usage with minimal configuration
49
- * const userData = [
50
- * { id: '1', name: 'John Doe', email: 'john@example.com', status: 'Active' },
51
- * { id: '2', name: 'Jane Smith', email: 'jane@example.com', status: 'Inactive' },
52
- * ];
53
- *
54
- * const columns = [
55
- * { accessorKey: 'name', header: 'Name' },
56
- * { accessorKey: 'email', header: 'Email' },
57
- * { accessorKey: 'status', header: 'Status' },
58
- * ];
59
- *
60
- * <DataTable
61
- * data={userData}
62
- * columns={columns}
63
- * />
64
- *
65
- * @example
66
- * // Advanced usage with pagination and filtering
67
- * const [tableData, setTableData] = useState([]);
68
- * const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
69
- * const [filters, setFilters] = useState({});
70
- * const [isLoading, setIsLoading] = useState(false);
71
- *
72
- * // Fetch data when pagination or filters change
73
- * useEffect(() => {
74
- * fetchData(pagination, filters);
75
- * }, [pagination, filters]);
76
- *
77
- * <DataTable
78
- * data={tableData}
79
- * columns={columns}
80
- * isLoading={isLoading}
81
- * totalCount={1000}
82
- * defaultPageSize={20}
83
- * filtersState={filters}
84
- * onPaginationChange={setPagination}
85
- * onFiltersChange={setFilters}
86
- * pageInfo={{
87
- * hasNextPage: true,
88
- * hasPreviousPage: false,
89
- * startCursor: 'cursor-start',
90
- * endCursor: 'cursor-end'
91
- * }}
92
- * />
93
- *
94
- * @example
95
- * // With row selection and custom actions
96
- * const [selectedRows, setSelectedRows] = useState({});
97
- *
98
- * const handleRowSelection = (rowSelection) => {
99
- * setSelectedRows(rowSelection);
100
- * console.log('Selected rows:', Object.keys(rowSelection));
101
- * };
102
- *
103
- * const handleBulkAction = () => {
104
- * const selectedIds = Object.keys(selectedRows);
105
- * // Perform bulk action on selected rows
106
- * };
107
- *
108
- * <DataTable
109
- * data={tableData}
110
- * columns={columns}
111
- * onRowSelectionChange={handleRowSelection}
112
- * // Custom toolbar actions will appear when rows are selected
113
- * />
114
- *
115
- * @example
116
- * // Error handling and retry functionality
117
- * const [error, setError] = useState(null);
118
- * const [isError, setIsError] = useState(false);
4
+ * DataTable: controlled composition of the micro-ui-ts table pieces.
119
5
  *
120
- * const handleRetry = () => {
121
- * setError(null);
122
- * setIsError(false);
123
- * // Retry data fetching logic
124
- * fetchData();
125
- * };
6
+ * Source of truth for the pieces is `micro-ui-ts/src/components/Table`. This file is the one
7
+ * DS-only layer: it assembles the same pieces the micro-ui-ts `Table` page assembles, but takes
8
+ * all state as props (controlled, stateless). A prototype using `<DataTable>` therefore has the
9
+ * same shape as production: swap the mock data source for the real query and keep the rest.
126
10
  *
127
- * <DataTable
128
- * data={tableData}
129
- * columns={columns}
130
- * isError={isError}
131
- * error={error}
132
- * onRetry={handleRetry}
133
- * />
134
- *
135
- * @example
136
- * // Customized table features and styling
137
- * <DataTable
138
- * data={tableData}
139
- * columns={columns}
140
- * defaultDensity="md"
141
- * showFilters={true}
142
- * showSearch={true}
143
- * showDensityToggle={true}
144
- * showFullScreenToggle={false}
145
- * locale="en-US"
146
- * mantineTableContainerProps={{
147
- * style: { maxHeight: '600px' }
148
- * }}
149
- * mantinePaperProps={{
150
- * shadow: 'md',
151
- * radius: 'md'
152
- * }}
153
- * />
154
- *
155
- * @example
156
- * // Dynamic columns with conditional rendering
157
- * const columns = useMemo(() => [
158
- * { accessorKey: 'name', header: 'Name', enableSorting: true },
159
- * { accessorKey: 'email', header: 'Email', enableColumnFilter: true },
160
- * {
161
- * accessorKey: 'status',
162
- * header: () => <Text fw="bold">Status</Text>,
163
- * size: 120,
164
- * enableSorting: false
165
- * },
166
- * {
167
- * accessorKey: 'actions',
168
- * header: 'Actions',
169
- * enableSorting: false,
170
- * enableColumnFilter: false,
171
- * Cell: ({ row }) => (
172
- * <Inline>
173
- * <Button size="xs" onClick={() => handleEdit(row.original)}>
174
- * Edit
175
- * </Button>
176
- * <Button size="xs" color="red" onClick={() => handleDelete(row.original)}>
177
- * Delete
178
- * </Button>
179
- * </Inline>
180
- * )
181
- * }
182
- * ], []);
183
- *
184
- * <DataTable
185
- * data={tableData}
186
- * columns={columns}
187
- * onSortChange={(field, direction) => {
188
- * console.log(`Sorting ${field} in ${direction} order`);
189
- * }}
190
- * />
11
+ * Rules for this file:
12
+ * - No state, no data fetching, no behaviour that is not a visible composition of the exported pieces.
13
+ * - Prop and type names follow micro-ui-ts (`PaginationState`, `RowSelectionState`, `DensityState`).
191
14
  */
192
- export function DataTable({
193
- // ==================== DATA PROPS ====================
194
- data, columns, totalCount = DEFAULT_VALUES.TOTAL_COUNT,
195
- // ==================== LOADING AND ERROR STATES ====================
196
- isLoading = false, isError = false, error, onRetry,
197
- // ==================== PAGINATION PROPS ====================
198
- pageInfo, onPaginationChange, defaultPageSize = DEFAULT_VALUES.PAGE_SIZE,
199
- // ==================== SELECTION PROPS ====================
200
- onRowSelectionChange,
201
- // ==================== UI STATE PROPS ====================
202
- onDensityChange, defaultDensity = DEFAULT_VALUES.DENSITY,
203
- // ==================== SORTING PROPS ====================
204
- onSortChange,
205
- // ==================== FILTER PROPS ====================
206
- filtersState = {}, onFiltersChange = () => { }, locale = DEFAULT_VALUES.LOCALE,
207
- // ==================== FEATURE TOGGLES ====================
208
- showFilters = FEATURE_FLAGS.SHOW_FILTERS, showSearch = FEATURE_FLAGS.SHOW_SEARCH, showDensityToggle = FEATURE_FLAGS.SHOW_DENSITY_TOGGLE, showFullScreenToggle = FEATURE_FLAGS.SHOW_FULL_SCREEN_TOGGLE,
209
- // ==================== STYLE CUSTOMIZATION ====================
210
- mantineTableContainerProps = {}, mantinePaperProps = {},
211
- // ==================== DEPRECATED/UNUSED PROPS ====================
212
- resultCount = DEFAULT_VALUES.RESULT_COUNT, }) {
213
- // ==================== HOOK INITIALIZATION ====================
214
- /** Initialize table state management */
215
- const tableState = useTableState(defaultPageSize, defaultDensity);
216
- /** Initialize event handlers with proper memoization */
217
- const handlers = useTableHandlers(tableState, {
218
- onPaginationChange,
219
- onRowSelectionChange,
220
- onDensityChange,
221
- onSortChange,
222
- });
223
- /** Initialize render functions with all required dependencies */
224
- const renderFunctions = useTableRenderFunctions({
225
- filtersState,
226
- locale,
227
- onFiltersChange,
228
- data,
229
- showFilters,
230
- isLoading,
231
- totalCount,
232
- pageInfo,
233
- error,
234
- onRetry,
235
- }, { numberOfSelectedRows: tableState.numberOfSelectedRows }, { handleClearSelection: handlers.handleClearSelection });
236
- // ==================== TABLE CONFIGURATION ====================
237
- /**
238
- * Memoized table configuration object
239
- * Contains all options, state, and handlers for Mantine React Table
240
- */
241
- const tableConfig = useMemo(() => ({
242
- // ==================== CORE DATA AND COLUMNS ====================
243
- columns,
15
+ import React, { useMemo } from 'react';
16
+ import { createColumnHelper, useTable } from '@tanstack/react-table';
17
+ import { RiDeleteBin5Line, RiSearchLine } from '@remixicon/react';
18
+ import { translate } from './translations/index.js';
19
+ import { dataTableFeatures } from './tableFeatures.js';
20
+ import CustomTopToolbar from './CustomTopToolbar/index.js';
21
+ import CustomBottomToolbar from './CustomBottomToolbar/index.js';
22
+ import CustomToolbarAlertBannerContent from './CustomToolbarAlertBannerContent/index.js';
23
+ import ToolbarAlertBanner from './ToolbarAlertBanner/index.js';
24
+ import ToggleDensityButton from './ToggleDensityButton/index.js';
25
+ import ToggleFullScreenButton from './ToggleFullScreenButton/index.js';
26
+ import ErrorOverlay from './ErrorOverlay/index.js';
27
+ import DataTableGrid from './DataTableGrid/index.js';
28
+ import DataTableShell from './DataTableShell/index.js';
29
+ import { getSelectColumnDef, RowSelectionContext } from './SelectCheckbox/index.js';
30
+ /** Same helper `micro-ui-ts` uses: `createColumnHelper<typeof dataTableFeatures, TData>()`. */
31
+ export const createDataTableColumnHelper = () => createColumnHelper();
32
+ const getNumberOfSelectedRowsText = (rowSelection) => {
33
+ const count = Object.keys(rowSelection).filter(key => rowSelection[key]).length;
34
+ return count > 0 ? translate('table.row.selected.count', { count }) : undefined;
35
+ };
36
+ const defaultGetRowId = (row) => String(row?.id);
37
+ export function DataTable({ data, columns, totalCount, getRowId = defaultGetRowId, isLoading = false, isFetching = false, isError = false, onRetry, pagination, pageInfo, onPreviousPage, onNextPage, onPageSizeChange, rowSelection, onRowSelectionChange, selectionActions = [], density, onDensityChange, isFullScreen, onFullScreenChange, filters, onFiltersChange, onResetFilters, showFilters, onFilterToggleChange, locale, emptyFallback, }) {
38
+ 'use no memo';
39
+ const columnHelper = createDataTableColumnHelper();
40
+ const tableColumns = useMemo(() => columnHelper.columns([getSelectColumnDef(columnHelper), ...columns]),
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ [columns]);
43
+ const table = useTable({
44
+ features: dataTableFeatures,
45
+ columns: tableColumns,
244
46
  data,
245
- /** Use the 'id' field from each row for unique identification (enables proper selection tracking) */
246
- getRowId: (row) => row.id,
247
- // ==================== FEATURE ENABLEMENT ====================
248
- /** Enable row selection with checkboxes */
249
- enableRowSelection: true,
250
- /** Allow multiple rows to be selected simultaneously */
251
- enableMultiRowSelection: true,
252
- /** Show select all checkbox in header */
253
- enableSelectAll: true,
254
- /** Enable column-specific filtering */
255
- enableColumnFilters: true,
256
- /** Enable column sorting */
257
- enableSorting: true,
258
- /** Allow users to resize columns */
259
- enableColumnResizing: true,
260
- /** Keep header visible when scrolling */
261
- enableStickyHeader: true,
262
- /** Show density toggle button */
263
- enableDensityToggle: showDensityToggle,
264
- /** Show fullscreen toggle button */
265
- enableFullScreenToggle: showFullScreenToggle,
266
- /** Enable pagination controls */
267
- enablePagination: true,
268
- /** Disable built-in row actions (we handle them manually) */
269
- enableRowActions: false,
270
- /** Disable individual column actions - we'll use a custom column visibility button */
271
- enableColumnActions: false,
272
- /** Enable column hiding feature */
273
- enableHiding: true,
274
- /** Use manual pagination (parent handles data slicing) */
275
- manualPagination: true,
276
- // ==================== DATA AND STATE ====================
277
- /** Total number of rows across all pages */
278
- rowCount: totalCount,
279
- /** Initial state with pinned actions column */
280
- initialState: {
281
- columnPinning: {
282
- right: ['actions'],
283
- },
47
+ defaultColumn: {
48
+ size: 180,
49
+ minSize: 40,
50
+ maxSize: 1000,
284
51
  },
285
- /** Current state object passed to Mantine React Table */
52
+ enableRowSelection: true,
53
+ getRowId: originalRow => getRowId(originalRow),
286
54
  state: {
287
- pagination: tableState.pagination,
288
- rowSelection: tableState.rowSelection,
289
- density: tableState.density,
290
- isLoading,
291
- showAlertBanner: tableState.showAlertBanner,
292
- },
293
- // ==================== LAYOUT CONFIGURATION ====================
294
- /** Use grid layout for better column control */
295
- layoutMode: 'grid',
296
- /** Configure display columns (selection, etc.) */
297
- displayColumnDefOptions: {
298
- 'mrt-row-select': {
299
- size: 40, // Minimal width for checkbox
300
- grow: false, // Don't grow this column
301
- },
55
+ rowSelection,
302
56
  },
303
- /** Enable column pinning to keep actions column fixed */
304
- enablePinning: true,
305
- // ==================== EVENT HANDLERS ====================
306
- /** Handle pagination changes (page navigation, page size changes) */
307
- onPaginationChange: handlers.handlePaginationChange,
308
- /** Handle row selection changes */
309
- onRowSelectionChange: handlers.handleRowSelectionChange,
310
- /** Handle density changes */
311
- onDensityChange: handlers.handleDensityChange,
312
- /** Handle sorting changes */
313
- onSortingChange: handlers.handleSortingChange,
314
- // ==================== RENDER FUNCTIONS ====================
315
- /** Custom top toolbar with filters and actions */
316
- renderTopToolbar: renderFunctions.renderTopToolbar,
317
- /** Custom bottom toolbar with pagination */
318
- renderBottomToolbar: renderFunctions.renderBottomToolbar,
319
- /** Custom alert banner for selection state */
320
- renderToolbarAlertBannerContent: renderFunctions.renderToolbarAlertBannerContent,
321
- /** Custom empty state with error handling */
322
- renderEmptyRowsFallback: renderFunctions.renderEmptyRowsFallback,
323
- /** Custom header cell renderer */
324
- mantineTableHeadCellProps: renderFunctions.renderTableHeadCell,
325
- // ==================== ACCESSIBILITY AND STYLING ====================
326
- /** Accessibility props for select all checkbox */
327
- mantineSelectAllCheckboxProps: {
328
- 'aria-label': 'Select all rows on this page',
57
+ onRowSelectionChange: updater => {
58
+ onRowSelectionChange(typeof updater === 'function' ? updater(rowSelection) : updater);
329
59
  },
330
- /** Accessibility props for individual row checkboxes */
331
- mantineSelectCheckboxProps: {
332
- 'aria-label': 'Select row',
333
- },
334
- /** Table styling options */
335
- mantineTableProps: {
336
- striped: true, // Alternating row colors
337
- highlightOnHover: true, // Highlight rows on hover
338
- withColumnBorders: false, // No vertical borders between columns
339
- },
340
- /** Header row styling */
341
- mantineTableHeadRowProps: {
342
- style: {
343
- borderBottom: '2px solid var(--ad-color-border-subtle)',
344
- },
345
- },
346
- /** Body cell styling */
347
- mantineTableBodyCellProps: {
348
- style: {
349
- padding: 'var(--mantine-spacing-xs)',
350
- },
351
- },
352
- /** Alert banner styling */
353
- mantineToolbarAlertBannerProps: {
354
- color: 'blue',
355
- },
356
- /** Table container styling */
357
- mantineTableContainerProps: {
358
- style: {
359
- backgroundColor: 'var(--ad-color-bg-default)',
360
- },
361
- ...mantineTableContainerProps, // Allow prop overrides
362
- },
363
- /** Paper wrapper styling */
364
- mantinePaperProps: {
365
- style: {
366
- backgroundColor: 'var(--ad-color-bg-default)',
367
- },
368
- ...mantinePaperProps, // Allow prop overrides
369
- },
370
- }), [
371
- // ==================== MEMOIZATION DEPENDENCIES ====================
372
- // Core data dependencies
373
- columns,
374
- data,
375
- showDensityToggle,
376
- showFullScreenToggle,
377
- totalCount,
378
- isLoading,
379
- // State dependencies
380
- tableState.pagination,
381
- tableState.rowSelection,
382
- tableState.density,
383
- tableState.showAlertBanner,
384
- // Handler dependencies
385
- handlers.handlePaginationChange,
386
- handlers.handleRowSelectionChange,
387
- handlers.handleDensityChange,
388
- handlers.handleSortingChange,
389
- // Render function dependencies
390
- renderFunctions.renderTopToolbar,
391
- renderFunctions.renderBottomToolbar,
392
- renderFunctions.renderToolbarAlertBannerContent,
393
- renderFunctions.renderEmptyRowsFallback,
394
- renderFunctions.renderTableHeadCell,
395
- // Style customization dependencies
396
- mantineTableContainerProps,
397
- mantinePaperProps,
398
- ]);
399
- // ==================== COMPONENT INITIALIZATION ====================
400
- /** Initialize the Mantine React Table instance with our configuration */
401
- const table = useMantineReactTable(tableConfig);
402
- // ==================== RENDER ====================
403
- /** Render the table component */
404
- return _jsx(MantineReactTable, { table: table });
60
+ });
61
+ const selectedCount = Object.values(rowSelection).filter(Boolean).length;
62
+ const isTableLoading = isFetching || isLoading;
63
+ const selectedRowsText = getNumberOfSelectedRowsText(rowSelection);
64
+ const fallback = emptyFallback ?? (_jsx(ErrorOverlay, { title: isError
65
+ ? translate('table.overlay.error.state.title')
66
+ : translate('table.overlay.empty.state.title'), description: isError
67
+ ? translate('table.overlay.error.state.description')
68
+ : translate('table.overlay.empty.state.description'), SVGIcon: isError ? undefined : _jsx(RiSearchLine, {}), my: "xl",
69
+ // Without onRetry there is nothing that can recover a load failure, so show no action rather than one that only clears filters.
70
+ actions: isError && !onRetry
71
+ ? undefined
72
+ : [
73
+ {
74
+ label: isError
75
+ ? translate('table.overlay.error.state.button')
76
+ : translate('table.overlay.empty.state.button'),
77
+ onClick: isError ? onRetry : onResetFilters,
78
+ variant: 'default',
79
+ },
80
+ ] }));
81
+ return (_jsx(DataTableShell, { isFullScreen: isFullScreen, isLoading: isTableLoading, topToolbar: _jsx(CustomTopToolbar, { resultCount: totalCount, filtersState: filters, locale: locale, onChange: (partial) => onFiltersChange({ ...filters, ...partial }), isLoading: isTableLoading, showFilters: showFilters, onFilterToggleChange: onFilterToggleChange, fullscreenControl: _jsx(ToggleFullScreenButton, { isFullScreen: isFullScreen, onChange: onFullScreenChange }), densityControl: _jsx(ToggleDensityButton, { density: density, onChange: onDensityChange }), alertBanner: _jsx(ToolbarAlertBanner, { selectedCount: selectedCount, children: _jsx(CustomToolbarAlertBannerContent, { resetRowSelection: () => onRowSelectionChange({}), numberOfSelectedRowsText: selectedRowsText, actions: selectionActions.map(action => ({
82
+ label: action.label,
83
+ onClick: action.onClick,
84
+ SVGIcon: action.SVGIcon ?? _jsx(RiDeleteBin5Line, { size: 14 }),
85
+ })) }) }) }), bottomToolbar: _jsx(CustomBottomToolbar, { isDisabled: isError, paginationState: pagination, hasPreviousPage: pageInfo?.hasPreviousPage, hasNextPage: pageInfo?.hasNextPage, totalNumOfRows: totalCount, onNextPage: onNextPage, onPreviousPage: onPreviousPage, onPageSizeChange: onPageSizeChange, isFetching: isFetching, numberOfSelectedRowsText: selectedRowsText }), children: _jsx(RowSelectionContext.Provider, { value: rowSelection, children: _jsx(DataTableGrid, { table: table, density: density, rowSelection: rowSelection, isLoading: isTableLoading, pageSize: pagination.pageSize, emptyFallback: fallback }) }) }));
405
86
  }