@terraware/web-components 5.2.8 → 5.2.9-rc.1

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 (53) hide show
  1. package/components/EditableTable/index.d.ts +2 -3
  2. package/components/EditableTable/index.d.ts.map +1 -1
  3. package/components/EditableTable/tableSettings.d.ts +11 -5
  4. package/components/EditableTable/tableSettings.d.ts.map +1 -1
  5. package/components/EditableTable/tableSettings.js +41 -8
  6. package/components/EditableTableV2/ColumnDragging.d.ts +23 -0
  7. package/components/EditableTableV2/ColumnDragging.d.ts.map +1 -0
  8. package/components/EditableTableV2/ColumnDragging.js +263 -0
  9. package/components/EditableTableV2/EditableCellV2.d.ts +10 -0
  10. package/components/EditableTableV2/EditableCellV2.d.ts.map +1 -0
  11. package/components/EditableTableV2/EditableCellV2.js +81 -0
  12. package/components/EditableTableV2/ToolbarButtons.d.ts +29 -0
  13. package/components/EditableTableV2/ToolbarButtons.d.ts.map +1 -0
  14. package/components/EditableTableV2/ToolbarButtons.js +84 -0
  15. package/components/EditableTableV2/filterTooltip.d.ts +4 -0
  16. package/components/EditableTableV2/filterTooltip.d.ts.map +1 -0
  17. package/components/EditableTableV2/filterTooltip.js +35 -0
  18. package/components/EditableTableV2/functions.d.ts +33 -0
  19. package/components/EditableTableV2/functions.d.ts.map +1 -0
  20. package/components/EditableTableV2/functions.js +55 -0
  21. package/components/EditableTableV2/highlightValue.d.ts +3 -0
  22. package/components/EditableTableV2/highlightValue.d.ts.map +1 -0
  23. package/components/EditableTableV2/highlightValue.js +42 -0
  24. package/components/EditableTableV2/index.d.ts +63 -0
  25. package/components/EditableTableV2/index.d.ts.map +1 -0
  26. package/components/EditableTableV2/index.js +1027 -0
  27. package/components/EditableTableV2/pinning.d.ts +8 -0
  28. package/components/EditableTableV2/pinning.d.ts.map +1 -0
  29. package/components/EditableTableV2/pinning.js +16 -0
  30. package/components/EditableTableV2/types.d.ts +92 -0
  31. package/components/EditableTableV2/types.d.ts.map +1 -0
  32. package/components/EditableTableV2/types.js +18 -0
  33. package/components/table/density.d.ts +1 -1
  34. package/index.d.ts +7 -3
  35. package/index.d.ts.map +1 -1
  36. package/index.js +4 -1
  37. package/license-report.html +1 -1
  38. package/package.json +4 -1
  39. package/strings/csv/en.csv +57 -0
  40. package/strings/csv/es.csv +57 -0
  41. package/strings/csv/fr.csv +57 -0
  42. package/strings/strings-en.d.ts +57 -0
  43. package/strings/strings-en.d.ts.map +1 -1
  44. package/strings/strings-en.js +58 -1
  45. package/strings/strings-es.d.ts +57 -0
  46. package/strings/strings-es.d.ts.map +1 -1
  47. package/strings/strings-es.js +58 -1
  48. package/strings/strings-fr.d.ts +57 -0
  49. package/strings/strings-fr.d.ts.map +1 -1
  50. package/strings/strings-fr.js +58 -1
  51. package/strings/strings-gx.d.ts +57 -0
  52. package/strings/strings-gx.d.ts.map +1 -1
  53. package/strings/strings-gx.js +58 -1
@@ -0,0 +1,1027 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { createElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { arrayMove } from "@dnd-kit/sortable";
4
+ import { ArrowDownward, ArrowUpward, ClearAll, Close, FilterAlt, FilterList, FilterListOff, MoreVert, PushPin, Search, Sort, SyncAlt, ViewColumn, VisibilityOff } from "@mui/icons-material";
5
+ import { Box, Button, Divider, FormControlLabel, IconButton, InputAdornment, ListItemIcon, MenuItem, Paper, Switch, Table, TableBody, TableCell, TableHead, TablePagination, TableRow, TableSortLabel, TextField, Toolbar, Tooltip } from "@mui/material";
6
+ import { alpha, darken, lighten, useTheme } from "@mui/material/styles";
7
+ import { functionalUpdate, useTable } from "@tanstack/react-table";
8
+ import { getLocale, useStrings } from "../../strings/index.js";
9
+ import Button_Button from "../Button/Button.js";
10
+ import { ColumnDragBodyCell, ColumnDragHandle, ColumnDragMenu, ColumnDragTableContainer, DraggableColumnHeader, DraggableColumnItem } from "./ColumnDragging.js";
11
+ import EditableCellV2 from "./EditableCellV2.js";
12
+ import { EditableTableShowHideColumnsButtonV2, EditableTableToggleDensePaddingButtonV2, EditableTableToggleFiltersButtonV2, EditableTableToggleFullScreenButtonV2, EditableTableToggleGlobalFilterButtonV2, EditableTableToolbarRoot } from "./ToolbarButtons.js";
13
+ import { filterTooltip } from "./filterTooltip.js";
14
+ import { namedFilterFns, namedSortFns } from "./functions.js";
15
+ import { highlightValue } from "./highlightValue.js";
16
+ import { toInternalPinning, toPublicPinning } from "./pinning.js";
17
+ import { editableTableFeatures } from "./types.js";
18
+ const isActiveFilter = (filter)=>{
19
+ const values = Array.isArray(filter.value) ? filter.value : [
20
+ filter.value
21
+ ];
22
+ return values.some((value)=>null != value && '' !== value);
23
+ };
24
+ const readFilters = (storageKey)=>{
25
+ try {
26
+ const saved = storageKey ? JSON.parse(localStorage.getItem(`${storageKey}_columnFilters`) ?? 'null') : null;
27
+ if (Array.isArray(saved) && saved.every((filter)=>'object' == typeof filter && null !== filter && 'id' in filter && 'string' == typeof filter.id && 'value' in filter)) return saved.filter(isActiveFilter);
28
+ } catch {
29
+ return;
30
+ }
31
+ };
32
+ const pinnedStyles = (column, theme, offsets)=>{
33
+ const position = column.getIsPinned();
34
+ const background = theme.palette.background.default;
35
+ const baseBackground = 'dark' === theme.palette.mode ? lighten(background, 0.05) : background;
36
+ return {
37
+ width: column.getSize(),
38
+ minWidth: column.getSize(),
39
+ ...position && {
40
+ position: 'sticky',
41
+ zIndex: 1,
42
+ opacity: 0.97,
43
+ '&::before': {
44
+ content: '""',
45
+ position: 'absolute',
46
+ inset: 0,
47
+ zIndex: -1,
48
+ backgroundColor: alpha(darken(baseBackground, 'dark' === theme.palette.mode ? 0.05 : 0.01), 0.97),
49
+ boxShadow: 'start' === position && column.getIsLastColumn('start') ? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` : 'end' === position && column.getIsFirstColumn('end') ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset` : void 0
50
+ },
51
+ ...'start' === position ? {
52
+ insetInlineStart: offsets[column.id] ?? column.getStart('start')
53
+ } : {
54
+ insetInlineEnd: offsets[column.id] ?? column.getAfter('end')
55
+ }
56
+ }
57
+ };
58
+ };
59
+ const UnsortedIcon = (props)=>/*#__PURE__*/ jsx(SyncAlt, {
60
+ ...props,
61
+ style: {
62
+ ...props.style,
63
+ transform: 'rotate(-90deg) scaleX(0.9) translateX(-1px)'
64
+ }
65
+ });
66
+ const ColumnActionMenuItemV2 = ({ icon, children, ...props })=>/*#__PURE__*/ jsx(MenuItem, {
67
+ sx: {
68
+ minWidth: '120px',
69
+ my: 0,
70
+ py: '6px'
71
+ },
72
+ ...props,
73
+ children: /*#__PURE__*/ jsxs(Box, {
74
+ display: "flex",
75
+ alignItems: "center",
76
+ children: [
77
+ /*#__PURE__*/ jsx(ListItemIcon, {
78
+ children: icon
79
+ }),
80
+ children
81
+ ]
82
+ })
83
+ });
84
+ const ColumnFilter = ({ column, definition })=>{
85
+ const strings = useStrings();
86
+ const label = `${strings.TABLE_FILTER}: ${definition.header}`;
87
+ const placeholder = strings.TABLE_FILTER_BY.replace('{column}', definition.header);
88
+ const value = column.getFilterValue();
89
+ if ('range' === definition.filterVariant || 'date-range' === definition.filterVariant) {
90
+ const range = Array.isArray(value) ? value : [
91
+ '',
92
+ ''
93
+ ];
94
+ return /*#__PURE__*/ jsx(Box, {
95
+ display: "flex",
96
+ gap: 1,
97
+ children: [
98
+ 0,
99
+ 1
100
+ ].map((index)=>/*#__PURE__*/ jsx(TextField, {
101
+ size: "small",
102
+ variant: "standard",
103
+ placeholder: 0 === index ? strings.TABLE_MIN : strings.TABLE_MAX,
104
+ type: 'date-range' === definition.filterVariant ? 'date' : 'number',
105
+ value: range[index] ?? '',
106
+ slotProps: {
107
+ htmlInput: {
108
+ 'aria-label': `${label} ${0 === index ? strings.TABLE_MIN : strings.TABLE_MAX}`
109
+ }
110
+ },
111
+ onChange: (event)=>{
112
+ const next = [
113
+ ...range
114
+ ];
115
+ next[index] = event.target.value;
116
+ column.setFilterValue(next.some((entry)=>'' !== entry) ? next : void 0);
117
+ }
118
+ }, index))
119
+ });
120
+ }
121
+ const multiple = 'multi-select' === definition.filterVariant;
122
+ const select = multiple || 'select' === definition.filterVariant;
123
+ return /*#__PURE__*/ jsxs(TextField, {
124
+ fullWidth: true,
125
+ variant: "standard",
126
+ placeholder: placeholder,
127
+ sx: {
128
+ minWidth: 120,
129
+ mx: '-2px',
130
+ p: 0,
131
+ width: 'calc(100% + 4px)'
132
+ },
133
+ select: select,
134
+ value: value ?? (multiple ? [] : ''),
135
+ onChange: (event)=>{
136
+ const next = event.target.value;
137
+ column.setFilterValue(Array.isArray(next) && !next.length ? void 0 : next || void 0);
138
+ },
139
+ slotProps: {
140
+ htmlInput: {
141
+ 'aria-label': label
142
+ },
143
+ input: {
144
+ endAdornment: /*#__PURE__*/ jsx(InputAdornment, {
145
+ position: "end",
146
+ sx: {
147
+ mr: select ? '20px' : void 0,
148
+ visibility: isActiveFilter({
149
+ value
150
+ }) ? 'visible' : 'hidden'
151
+ },
152
+ children: /*#__PURE__*/ jsx(IconButton, {
153
+ size: "small",
154
+ "aria-label": `${strings.TABLE_CLEAR_FILTER}: ${definition.header}`,
155
+ disabled: !isActiveFilter({
156
+ value
157
+ }),
158
+ onClick: ()=>column.setFilterValue(void 0),
159
+ sx: {
160
+ height: '2rem',
161
+ width: '2rem',
162
+ transform: 'scale(0.9)'
163
+ },
164
+ children: /*#__PURE__*/ jsx(Close, {})
165
+ })
166
+ })
167
+ },
168
+ select: {
169
+ multiple,
170
+ displayEmpty: true,
171
+ 'aria-label': label,
172
+ renderValue: (selected)=>(Array.isArray(selected) ? selected.join(', ') : String(selected ?? '')) || /*#__PURE__*/ jsx(Box, {
173
+ sx: {
174
+ opacity: 0.5
175
+ },
176
+ children: placeholder
177
+ })
178
+ }
179
+ },
180
+ children: [
181
+ select && !multiple && /*#__PURE__*/ jsx(MenuItem, {
182
+ value: "",
183
+ children: strings.TABLE_ALL
184
+ }),
185
+ select && definition.filterSelectOptions?.map((option)=>/*#__PURE__*/ jsx(MenuItem, {
186
+ value: option,
187
+ children: option
188
+ }, option))
189
+ ]
190
+ });
191
+ };
192
+ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFilters = true, enableEditing = false, enableColumnOrdering = false, enableColumnDragging = false, enableColumnActions = true, enableShowAllColumnsMenuItem = true, showColumnsButton = false, showGlobalFilterButton = false, showColumnFiltersButton = false, showDensityButton = false, showFullScreenButton = false, enableColumnPinning = false, enableHiding = true, enableSorting = true, enableGlobalFilter = false, positionGlobalFilter = 'left', enableFilterMatchHighlighting = true, enableColumnFilters = false, stickyFilters = false, storageKey, enablePagination = true, enableBottomToolbar = true, enableTopToolbar = true, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, renderTopToolbarCustomActions, muiTableHeadCellProps, muiTableBodyCellProps, tableOptions, containerProps, sx })=>{
193
+ const strings = useStrings();
194
+ const theme = useTheme();
195
+ const [editingCell, setEditingCell] = useState(null);
196
+ const [globalFilterVisible, setGlobalFilterVisible] = useState(true);
197
+ const [columnFiltersVisible, setColumnFiltersVisible] = useState(false);
198
+ const [density, setDensity] = useState();
199
+ const [fullScreen, setFullScreen] = useState(false);
200
+ const [menuColumnId, setMenuColumnId] = useState(null);
201
+ const [menuAnchor, setMenuAnchor] = useState(null);
202
+ const [columnsButtonCount, setColumnsButtonCount] = useState(0);
203
+ const registerColumnsButton = useCallback(()=>{
204
+ setColumnsButtonCount((count)=>count + 1);
205
+ return ()=>setColumnsButtonCount((count)=>count - 1);
206
+ }, []);
207
+ const [initialColumnFilters] = useState(()=>tableOptions?.initialState?.columnFilters ?? []);
208
+ const [columnFilters, setColumnFilters] = useState(()=>readFilters(stickyFilters ? storageKey : void 0) ?? initialColumnFilters);
209
+ useEffect(()=>{
210
+ setColumnFilters(readFilters(stickyFilters ? storageKey : void 0) ?? initialColumnFilters);
211
+ }, [
212
+ stickyFilters,
213
+ storageKey,
214
+ initialColumnFilters
215
+ ]);
216
+ const tableColumns = useMemo(()=>columns.map((column)=>({
217
+ id: column.id,
218
+ header: column.header,
219
+ meta: {
220
+ filterVariant: column.filterVariant,
221
+ filterSelectOptions: column.filterSelectOptions
222
+ },
223
+ accessorFn: column.accessorFn ?? ((row)=>void 0 !== column.accessorKey ? row[column.accessorKey] : void 0),
224
+ enableHiding: column.enableHiding ?? true,
225
+ ...void 0 !== column.size ? {
226
+ size: column.size
227
+ } : {},
228
+ ...void 0 !== column.enableGlobalFilter ? {
229
+ enableGlobalFilter: column.enableGlobalFilter
230
+ } : {},
231
+ enableColumnFilter: !!column.filterVariant,
232
+ ...void 0 !== column.enableSorting ? {
233
+ enableSorting: column.enableSorting
234
+ } : column.accessorFn || void 0 !== column.accessorKey || column.sortFn || 'sortingFn' in column && column.sortingFn ? {} : {
235
+ enableSorting: false
236
+ },
237
+ ...column.sortFn || column.sortingFn ? {
238
+ sortFn: column.sortFn ?? ('function' == typeof column.sortingFn ? column.sortingFn : column.sortingFn && 'auto' !== column.sortingFn ? namedSortFns[column.sortingFn] : 'auto')
239
+ } : {},
240
+ filterFn: Object.assign((row, id, filterValue, addMeta)=>{
241
+ if ('function' == typeof column.filterFn) return column.filterFn(row.original, id, filterValue);
242
+ if (column.filterFn) {
243
+ const filter = namedFilterFns[column.filterFn];
244
+ const resolvedValue = filter.resolveFilterValue?.(filterValue) ?? filterValue;
245
+ return filter(row, id, resolvedValue, addMeta);
246
+ }
247
+ const value = row.getValue(id);
248
+ if ('select' === column.filterVariant) return String(value ?? '') === String(filterValue);
249
+ if ('multi-select' === column.filterVariant) return !Array.isArray(filterValue) || !filterValue.length || filterValue.some((selected)=>Array.isArray(value) ? value.includes(selected) : String(value ?? '') === String(selected));
250
+ if ('range' === column.filterVariant || 'date-range' === column.filterVariant) {
251
+ const [min, max] = Array.isArray(filterValue) ? filterValue : [];
252
+ const normalize = (entry)=>'date-range' === column.filterVariant ? Date.parse(String(entry)) : Number(entry);
253
+ const numeric = normalize(value);
254
+ return null != value && '' !== value && Number.isFinite(numeric) && ('' === min || null == min || numeric >= normalize(min)) && ('' === max || null == max || ('date-range' === column.filterVariant && 'string' == typeof max && /^\d{4}-\d{2}-\d{2}$/.test(max) ? numeric < normalize(max) + 86400000 : numeric <= normalize(max)));
255
+ }
256
+ return String(value ?? '').toLocaleLowerCase().includes(String(filterValue).toLocaleLowerCase());
257
+ }, {
258
+ autoRemove: 'string' == typeof column.filterFn ? namedFilterFns[column.filterFn].autoRemove : void 0
259
+ })
260
+ })), [
261
+ columns,
262
+ tableOptions?.defaultColumn
263
+ ]);
264
+ const persistFilters = stickyFilters && !!storageKey && tableOptions?.state?.columnFilters === void 0;
265
+ const { state, initialState, onColumnPinningChange, ...options } = tableOptions ?? {};
266
+ const { columnPinning: controlledPinning, ...controlledState } = state ?? {};
267
+ const { columnPinning: initialPinning, ...initialTableState } = initialState ?? {};
268
+ const table = useTable({
269
+ features: editableTableFeatures,
270
+ columns: tableColumns,
271
+ data,
272
+ enableSorting,
273
+ sortDescFirst: false,
274
+ enableColumnPinning,
275
+ enableHiding,
276
+ enableColumnFilters,
277
+ enableGlobalFilter,
278
+ manualPagination: !enablePagination,
279
+ ...options,
280
+ initialState: {
281
+ sorting: initialSorting ?? [],
282
+ ...initialTableState,
283
+ ...initialPinning && {
284
+ columnPinning: toInternalPinning(initialPinning)
285
+ }
286
+ },
287
+ state: {
288
+ ...controlledState,
289
+ ...controlledPinning && {
290
+ columnPinning: toInternalPinning(controlledPinning)
291
+ },
292
+ ...persistFilters && {
293
+ columnFilters
294
+ }
295
+ },
296
+ ...onColumnPinningChange && {
297
+ onColumnPinningChange: (updater)=>onColumnPinningChange((previous)=>{
298
+ const next = functionalUpdate(updater, toInternalPinning(previous));
299
+ return toPublicPinning(next);
300
+ })
301
+ },
302
+ ...persistFilters && {
303
+ onColumnFiltersChange: (updater)=>{
304
+ setColumnFilters((previous)=>{
305
+ const next = 'function' == typeof updater ? updater(previous) : updater;
306
+ try {
307
+ localStorage.setItem(`${storageKey}_columnFilters`, JSON.stringify(next.filter(isActiveFilter)));
308
+ } catch {}
309
+ return next;
310
+ });
311
+ }
312
+ }
313
+ });
314
+ const hasFilters = table.state.columnFilters.some(isActiveFilter) || !!table.state.globalFilter;
315
+ const clearFilters = ()=>{
316
+ table.setColumnFilters([]);
317
+ table.setGlobalFilter('');
318
+ onClearAllFilters?.();
319
+ };
320
+ const definitions = new Map(columns.map((column)=>[
321
+ column.id,
322
+ column
323
+ ]));
324
+ const visibleColumns = table.getVisibleLeafColumns();
325
+ const allColumns = [
326
+ ...table.getStartLeafColumns(),
327
+ ...table.getCenterLeafColumns(),
328
+ ...table.getEndLeafColumns()
329
+ ];
330
+ const orderedColumns = [
331
+ ...table.getStartVisibleLeafColumns(),
332
+ ...table.getCenterVisibleLeafColumns(),
333
+ ...table.getEndVisibleLeafColumns()
334
+ ];
335
+ const rows = table.getRowModel().rows;
336
+ const pageCountWithoutRowCount = table.options.manualPagination && void 0 !== table.options.pageCount && table.options.pageCount >= 0 && void 0 === table.options.rowCount;
337
+ const nextPageButton = {
338
+ disabled: !table.getCanNextPage()
339
+ };
340
+ const lastPageButton = {
341
+ disabled: !table.getCanNextPage(),
342
+ onClick: ()=>table.setPageIndex(Math.max(0, table.getPageCount() - 1))
343
+ };
344
+ const tableRef = useRef(null);
345
+ const [renderedWidths, setRenderedWidths] = useState({});
346
+ const visibleColumnIds = JSON.stringify(orderedColumns.map((column)=>column.id));
347
+ const hasPinnedColumns = orderedColumns.some((column)=>column.getIsPinned());
348
+ useLayoutEffect(()=>{
349
+ if (!tableRef.current || !hasPinnedColumns) return;
350
+ const headers = Array.from(tableRef.current.querySelectorAll('thead th[data-column-id]'));
351
+ const measure = ()=>{
352
+ const next = {};
353
+ headers.forEach((header)=>{
354
+ const width = header.getBoundingClientRect().width;
355
+ if (header.dataset.columnId && width > 0) next[header.dataset.columnId] = width;
356
+ });
357
+ setRenderedWidths((current)=>Object.keys(current).length === Object.keys(next).length && Object.keys(next).every((id)=>current[id] === next[id]) ? current : next);
358
+ };
359
+ measure();
360
+ if ("u" < typeof ResizeObserver) return;
361
+ const observer = new ResizeObserver(measure);
362
+ headers.forEach((header)=>observer.observe(header));
363
+ return ()=>observer.disconnect();
364
+ }, [
365
+ visibleColumnIds,
366
+ hasPinnedColumns
367
+ ]);
368
+ const pinnedOffsets = {};
369
+ for (const group of [
370
+ table.getStartVisibleLeafColumns(),
371
+ [
372
+ ...table.getEndVisibleLeafColumns()
373
+ ].reverse()
374
+ ]){
375
+ let offset = 0;
376
+ for (const column of group){
377
+ pinnedOffsets[column.id] = offset;
378
+ offset += renderedWidths[column.id] ?? column.getSize();
379
+ }
380
+ }
381
+ const controlsEnabled = enableHiding || enableColumnOrdering || enableColumnPinning;
382
+ const columnManagerReachable = columnsButtonCount > 0;
383
+ const hideableColumns = table.getAllLeafColumns().filter((column)=>column.getCanHide());
384
+ const filtersVisible = enableColumnFilters && columnFiltersVisible;
385
+ useEffect(()=>{
386
+ if (!fullScreen) return;
387
+ const onKeyDown = (event)=>{
388
+ if ('Escape' === event.key) setFullScreen(false);
389
+ };
390
+ const overflow = document.body.style.overflow;
391
+ document.body.style.overflow = 'hidden';
392
+ document.addEventListener('keydown', onKeyDown);
393
+ return ()=>{
394
+ document.body.style.overflow = overflow;
395
+ document.removeEventListener('keydown', onKeyDown);
396
+ };
397
+ }, [
398
+ fullScreen
399
+ ]);
400
+ const moveColumn = (id, offset)=>{
401
+ const index = allColumns.findIndex((column)=>column.id === id);
402
+ const column = allColumns[index];
403
+ const target = allColumns[index + offset];
404
+ if (!column || !target || column.getIsPinned() !== target.getIsPinned()) return;
405
+ const swap = (order)=>{
406
+ const from = order.indexOf(id);
407
+ const to = order.indexOf(target.id);
408
+ if (from < 0 || to < 0) return order;
409
+ const next = [
410
+ ...order
411
+ ];
412
+ [next[from], next[to]] = [
413
+ next[to],
414
+ next[from]
415
+ ];
416
+ return next;
417
+ };
418
+ const pinned = column.getIsPinned();
419
+ if (pinned) table.setColumnPinning((current)=>({
420
+ ...current,
421
+ [pinned]: swap(current[pinned])
422
+ }));
423
+ else table.setColumnOrder(swap(table.getAllLeafColumns().map((column)=>column.id)));
424
+ };
425
+ const reorderColumns = ({ active, over })=>{
426
+ if (!over || active.id === over.id) return;
427
+ const source = table.getAllLeafColumns().find((column)=>column.id === active.id);
428
+ const target = table.getAllLeafColumns().find((column)=>column.id === over.id);
429
+ if (!source || !target || source.getIsPinned() !== target.getIsPinned()) return;
430
+ const pin = source.getIsPinned();
431
+ const order = table.getAllLeafColumns().map((column)=>column.id);
432
+ table.setColumnOrder(arrayMove(order, order.indexOf(source.id), order.indexOf(target.id)));
433
+ if (pin) table.setColumnPinning((previous)=>{
434
+ const group = previous[pin] ?? [];
435
+ return {
436
+ ...previous,
437
+ [pin]: arrayMove(group, group.indexOf(source.id), group.indexOf(target.id))
438
+ };
439
+ });
440
+ };
441
+ const searchField = enableGlobalFilter && globalFilterVisible && /*#__PURE__*/ jsx(TextField, {
442
+ placeholder: strings.TABLE_SEARCH,
443
+ size: "small",
444
+ slotProps: {
445
+ htmlInput: {
446
+ 'aria-label': strings.TABLE_SEARCH
447
+ },
448
+ input: {
449
+ startAdornment: /*#__PURE__*/ jsx(Search, {
450
+ sx: {
451
+ mr: '4px'
452
+ }
453
+ }),
454
+ endAdornment: /*#__PURE__*/ jsx(InputAdornment, {
455
+ position: "end",
456
+ children: /*#__PURE__*/ jsx(IconButton, {
457
+ size: "small",
458
+ "aria-label": strings.TABLE_CLEAR_SEARCH,
459
+ disabled: !table.state.globalFilter,
460
+ onClick: ()=>table.setGlobalFilter(''),
461
+ children: /*#__PURE__*/ jsx(Close, {})
462
+ })
463
+ })
464
+ }
465
+ },
466
+ value: table.state.globalFilter ?? '',
467
+ onChange: (event)=>table.setGlobalFilter(event.target.value)
468
+ });
469
+ return /*#__PURE__*/ jsx(EditableTableToolbarRoot, {
470
+ value: {
471
+ table,
472
+ globalFilterVisible,
473
+ columnFiltersVisible,
474
+ density: density ?? 1,
475
+ fullScreen,
476
+ registerColumnsButton,
477
+ toggleGlobalFilter: ()=>setGlobalFilterVisible((visible)=>!visible),
478
+ toggleColumnFilters: ()=>setColumnFiltersVisible((visible)=>!visible),
479
+ toggleDensity: ()=>setDensity((value)=>((value ?? 1) + 2) % 3),
480
+ toggleFullScreen: ()=>setFullScreen((value)=>!value),
481
+ openColumns: (anchor)=>{
482
+ setMenuColumnId(null);
483
+ setMenuAnchor(anchor);
484
+ }
485
+ },
486
+ minHeight: "160px",
487
+ padding: 2,
488
+ sx: [
489
+ ...Array.isArray(sx) ? sx : [
490
+ sx
491
+ ],
492
+ ...showDensityButton || void 0 !== density ? [
493
+ {
494
+ '& td': {
495
+ py: 0 === density ? '4px' : 2 === density ? '24px' : '16px'
496
+ }
497
+ }
498
+ ] : [],
499
+ ...fullScreen ? [
500
+ {
501
+ position: 'fixed',
502
+ inset: 0,
503
+ m: 0,
504
+ p: 0,
505
+ zIndex: 1200,
506
+ bgcolor: 'background.paper',
507
+ overflow: 'auto'
508
+ }
509
+ ] : []
510
+ ],
511
+ children: /*#__PURE__*/ jsxs(Paper, {
512
+ elevation: 0,
513
+ children: [
514
+ enableTopToolbar && /*#__PURE__*/ jsxs(Toolbar, {
515
+ disableGutters: true,
516
+ sx: {
517
+ gap: 1,
518
+ flexWrap: 'wrap',
519
+ alignItems: 'flex-start',
520
+ p: 1,
521
+ minHeight: '56px !important',
522
+ boxSizing: 'border-box'
523
+ },
524
+ children: [
525
+ 'left' === positionGlobalFilter && searchField,
526
+ renderTopToolbarCustomActions?.({
527
+ table
528
+ }),
529
+ /*#__PURE__*/ jsx(Box, {
530
+ flexGrow: 1
531
+ }),
532
+ 'right' === positionGlobalFilter && searchField,
533
+ enableClearAllFilters && hasFilters && /*#__PURE__*/ jsx(Button_Button, {
534
+ label: clearAllFiltersLabel,
535
+ priority: "ghost",
536
+ size: "small",
537
+ onClick: clearFilters
538
+ }),
539
+ /*#__PURE__*/ jsx(Box, {
540
+ display: "flex",
541
+ alignItems: "center",
542
+ children: renderToolbarInternalActions ? renderToolbarInternalActions({
543
+ table
544
+ }) : /*#__PURE__*/ jsxs(Fragment, {
545
+ children: [
546
+ showGlobalFilterButton && enableGlobalFilter && /*#__PURE__*/ jsx(EditableTableToggleGlobalFilterButtonV2, {
547
+ table: table
548
+ }),
549
+ showColumnFiltersButton && enableColumnFilters && /*#__PURE__*/ jsx(EditableTableToggleFiltersButtonV2, {
550
+ table: table
551
+ }),
552
+ showColumnsButton && controlsEnabled && /*#__PURE__*/ jsx(EditableTableShowHideColumnsButtonV2, {
553
+ table: table
554
+ }),
555
+ showDensityButton && /*#__PURE__*/ jsx(EditableTableToggleDensePaddingButtonV2, {
556
+ table: table
557
+ }),
558
+ showFullScreenButton && /*#__PURE__*/ jsx(EditableTableToggleFullScreenButtonV2, {
559
+ table: table
560
+ })
561
+ ]
562
+ })
563
+ })
564
+ ]
565
+ }),
566
+ /*#__PURE__*/ jsxs(ColumnDragMenu, {
567
+ ids: allColumns.map((column)=>column.id),
568
+ onDragEnd: reorderColumns,
569
+ anchorEl: menuAnchor,
570
+ open: !!menuAnchor,
571
+ onClose: ()=>setMenuAnchor(null),
572
+ children: [
573
+ menuColumnId && table.getColumn(menuColumnId)?.getCanSort() && [
574
+ {
575
+ label: strings.TABLE_CLEAR_SORTING,
576
+ icon: /*#__PURE__*/ jsx(ClearAll, {}),
577
+ disabled: !table.getColumn(menuColumnId)?.getIsSorted(),
578
+ action: ()=>table.getColumn(menuColumnId)?.clearSorting()
579
+ },
580
+ {
581
+ label: strings.TABLE_SORT_ASCENDING.replace('{column}', definitions.get(menuColumnId).header),
582
+ icon: /*#__PURE__*/ jsx(Sort, {
583
+ sx: {
584
+ transform: 'rotate(180deg) scaleX(-1)'
585
+ }
586
+ }),
587
+ disabled: table.getColumn(menuColumnId)?.getIsSorted() === 'asc',
588
+ action: ()=>table.getColumn(menuColumnId)?.toggleSorting(false)
589
+ },
590
+ {
591
+ label: strings.TABLE_SORT_DESCENDING.replace('{column}', definitions.get(menuColumnId).header),
592
+ icon: /*#__PURE__*/ jsx(Sort, {}),
593
+ disabled: table.getColumn(menuColumnId)?.getIsSorted() === 'desc',
594
+ divider: table.getColumn(menuColumnId)?.getCanFilter() || enableHiding || enableColumnPinning,
595
+ action: ()=>table.getColumn(menuColumnId)?.toggleSorting(true)
596
+ }
597
+ ].map(({ label, icon, disabled, divider, action })=>/*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
598
+ icon: icon,
599
+ disabled: disabled,
600
+ divider: divider,
601
+ onClick: ()=>{
602
+ action();
603
+ setMenuAnchor(null);
604
+ },
605
+ children: label
606
+ }, label)),
607
+ menuColumnId && table.getColumn(menuColumnId)?.getCanFilter() && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
608
+ icon: /*#__PURE__*/ jsx(FilterListOff, {}),
609
+ disabled: !table.getColumn(menuColumnId)?.getIsFiltered(),
610
+ onClick: ()=>{
611
+ table.getColumn(menuColumnId)?.setFilterValue(void 0);
612
+ setMenuAnchor(null);
613
+ },
614
+ children: strings.TABLE_CLEAR_FILTER
615
+ }),
616
+ menuColumnId && table.getColumn(menuColumnId)?.getCanFilter() && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
617
+ icon: /*#__PURE__*/ jsx(FilterList, {}),
618
+ disabled: true,
619
+ divider: enableHiding || enableColumnPinning,
620
+ children: strings.TABLE_FILTER_BY.replace('{column}', definitions.get(menuColumnId).header)
621
+ }),
622
+ menuColumnId && enableColumnPinning && [
623
+ {
624
+ label: strings.TABLE_PIN_LEFT,
625
+ direction: 'start',
626
+ rotation: '90deg'
627
+ },
628
+ {
629
+ label: strings.TABLE_PIN_RIGHT,
630
+ direction: 'end',
631
+ rotation: '-90deg'
632
+ },
633
+ {
634
+ label: strings.TABLE_UNPIN,
635
+ direction: false,
636
+ rotation: '0deg'
637
+ }
638
+ ].map(({ label, direction, rotation })=>/*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
639
+ icon: /*#__PURE__*/ jsx(PushPin, {
640
+ sx: {
641
+ transform: `rotate(${rotation})`
642
+ }
643
+ }),
644
+ disabled: !table.getColumn(menuColumnId)?.getCanPin() || table.getColumn(menuColumnId)?.getIsPinned() === direction,
645
+ divider: false === direction && enableHiding,
646
+ onClick: ()=>{
647
+ table.getColumn(menuColumnId)?.pin(direction);
648
+ setMenuAnchor(null);
649
+ },
650
+ children: label
651
+ }, label)),
652
+ menuColumnId && enableHiding && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
653
+ icon: /*#__PURE__*/ jsx(VisibilityOff, {}),
654
+ disabled: !table.getColumn(menuColumnId)?.getCanHide() || !columnManagerReachable && 1 === orderedColumns.length,
655
+ onClick: ()=>{
656
+ table.getColumn(menuColumnId)?.toggleVisibility(false);
657
+ setMenuAnchor(null);
658
+ },
659
+ children: strings.TABLE_HIDE_COLUMN.replace('{column}', definitions.get(menuColumnId).header)
660
+ }),
661
+ menuColumnId && enableHiding && enableShowAllColumnsMenuItem && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
662
+ icon: /*#__PURE__*/ jsx(ViewColumn, {}),
663
+ disabled: table.getAllLeafColumns().every((column)=>column.getIsVisible() || !column.getCanHide()),
664
+ onClick: ()=>{
665
+ table.getAllLeafColumns().filter((column)=>column.getCanHide()).forEach((column)=>column.toggleVisibility(true));
666
+ setMenuAnchor(null);
667
+ },
668
+ children: strings.TABLE_SHOW_ALL_COLUMNS
669
+ }),
670
+ !menuColumnId && enableHiding && /*#__PURE__*/ jsxs(Box, {
671
+ display: "flex",
672
+ justifyContent: "space-between",
673
+ px: 1,
674
+ pb: 1,
675
+ children: [
676
+ /*#__PURE__*/ jsx(Button, {
677
+ disabled: !hideableColumns.some((column)=>column.getIsVisible()) || !columnManagerReachable && orderedColumns.every((column)=>column.getCanHide()),
678
+ onClick: ()=>hideableColumns.forEach((column)=>column.toggleVisibility(false)),
679
+ children: strings.TABLE_HIDE_ALL
680
+ }),
681
+ /*#__PURE__*/ jsx(Button, {
682
+ disabled: hideableColumns.every((column)=>column.getIsVisible()),
683
+ onClick: ()=>hideableColumns.forEach((column)=>column.toggleVisibility(true)),
684
+ children: strings.TABLE_SHOW_ALL
685
+ })
686
+ ]
687
+ }),
688
+ !menuColumnId && controlsEnabled && /*#__PURE__*/ jsx(Divider, {}),
689
+ allColumns.map((column, index)=>!menuColumnId && controlsEnabled && /*#__PURE__*/ jsxs(DraggableColumnItem, {
690
+ id: column.id,
691
+ label: definitions.get(column.id).header,
692
+ enabled: enableColumnOrdering,
693
+ disableRipple: true,
694
+ sx: {
695
+ my: 0,
696
+ py: '6px',
697
+ pl: '16px'
698
+ },
699
+ children: [
700
+ /*#__PURE__*/ jsx(ColumnDragHandle, {}),
701
+ /*#__PURE__*/ jsx(FormControlLabel, {
702
+ label: definitions.get(column.id)?.header,
703
+ slotProps: {
704
+ typography: {
705
+ sx: {
706
+ mb: 0
707
+ }
708
+ }
709
+ },
710
+ control: /*#__PURE__*/ jsx(Switch, {
711
+ checked: column.getIsVisible(),
712
+ disabled: !enableHiding || !column.getCanHide() || !columnManagerReachable && column.getIsVisible() && 1 === orderedColumns.length,
713
+ onChange: column.getToggleVisibilityHandler()
714
+ })
715
+ }),
716
+ enableColumnOrdering && /*#__PURE__*/ jsxs(Fragment, {
717
+ children: [
718
+ /*#__PURE__*/ jsx(IconButton, {
719
+ "aria-label": `${strings.TABLE_MOVE_BACK}: ${definitions.get(column.id)?.header}`,
720
+ disabled: allColumns[index - 1]?.getIsPinned() !== column.getIsPinned(),
721
+ onClick: ()=>moveColumn(column.id, -1),
722
+ children: /*#__PURE__*/ jsx(ArrowUpward, {})
723
+ }),
724
+ /*#__PURE__*/ jsx(IconButton, {
725
+ "aria-label": `${strings.TABLE_MOVE_FORWARD}: ${definitions.get(column.id)?.header}`,
726
+ disabled: allColumns[index + 1]?.getIsPinned() !== column.getIsPinned(),
727
+ onClick: ()=>moveColumn(column.id, 1),
728
+ children: /*#__PURE__*/ jsx(ArrowDownward, {})
729
+ })
730
+ ]
731
+ }),
732
+ enableColumnPinning && /*#__PURE__*/ jsxs(TextField, {
733
+ select: true,
734
+ size: "small",
735
+ label: strings.TABLE_PIN,
736
+ disabled: !column.getCanPin(),
737
+ value: 'start' === column.getIsPinned() ? 'left' : 'end' === column.getIsPinned() ? 'right' : '',
738
+ onChange: (event)=>column.pin('left' === event.target.value ? 'start' : 'right' === event.target.value ? 'end' : false),
739
+ children: [
740
+ /*#__PURE__*/ jsx(MenuItem, {
741
+ value: "",
742
+ children: strings.TABLE_UNPIN
743
+ }),
744
+ /*#__PURE__*/ jsx(MenuItem, {
745
+ value: "left",
746
+ children: strings.TABLE_PIN_LEFT
747
+ }),
748
+ /*#__PURE__*/ jsx(MenuItem, {
749
+ value: "right",
750
+ children: strings.TABLE_PIN_RIGHT
751
+ })
752
+ ]
753
+ })
754
+ ]
755
+ }, column.id))
756
+ ]
757
+ }),
758
+ /*#__PURE__*/ jsx(ColumnDragTableContainer, {
759
+ ...containerProps,
760
+ ids: orderedColumns.map((column)=>column.id),
761
+ onDragEnd: reorderColumns,
762
+ children: /*#__PURE__*/ jsxs(Table, {
763
+ ref: tableRef,
764
+ sx: {
765
+ minWidth: table.getTotalSize()
766
+ },
767
+ children: [
768
+ /*#__PURE__*/ jsx(TableHead, {
769
+ children: /*#__PURE__*/ jsx(TableRow, {
770
+ children: orderedColumns.map((column)=>{
771
+ const headCellProps = 'function' == typeof muiTableHeadCellProps ? muiTableHeadCellProps({
772
+ column,
773
+ table
774
+ }) : muiTableHeadCellProps;
775
+ const header = /*#__PURE__*/ jsxs(Fragment, {
776
+ children: [
777
+ /*#__PURE__*/ jsx("span", {
778
+ className: "Mui-TableHeadCell-Content-Wrapper",
779
+ children: definitions.get(column.id)?.header
780
+ }),
781
+ column.getIsFiltered() && /*#__PURE__*/ jsx(Tooltip, {
782
+ placement: "top",
783
+ title: filterTooltip(definitions.get(column.id), column.getFilterValue(), strings),
784
+ children: /*#__PURE__*/ jsx(FilterAlt, {
785
+ sx: {
786
+ color: 'action.active',
787
+ ml: '4px',
788
+ width: '18px',
789
+ height: '18px'
790
+ },
791
+ role: "img",
792
+ "aria-label": `${strings.TABLE_FILTERED}: ${definitions.get(column.id)?.header}`,
793
+ onClick: (event)=>event.stopPropagation()
794
+ })
795
+ })
796
+ ]
797
+ });
798
+ return /*#__PURE__*/ createElement(DraggableColumnHeader, {
799
+ ...headCellProps,
800
+ key: column.id,
801
+ "data-column-id": column.id,
802
+ "data-pinned": column.getIsPinned() ? 'true' : void 0,
803
+ id: column.id,
804
+ label: definitions.get(column.id).header,
805
+ enabled: enableColumnDragging || enableColumnOrdering,
806
+ sortDirection: column.getIsSorted() || false,
807
+ sx: [
808
+ (theme)=>({
809
+ ...pinnedStyles(column, theme, pinnedOffsets),
810
+ bgcolor: 'background.paper',
811
+ fontWeight: 'bold',
812
+ p: 2,
813
+ pt: '12px',
814
+ pb: filtersVisible ? '6.4px' : '9.6px',
815
+ verticalAlign: 'top',
816
+ '&:hover .MuiIconButton-root': {
817
+ opacity: 1
818
+ }
819
+ }),
820
+ ...Array.isArray(headCellProps?.sx) ? headCellProps.sx : [
821
+ headCellProps?.sx
822
+ ]
823
+ ],
824
+ children: [
825
+ /*#__PURE__*/ jsxs(Box, {
826
+ display: "flex",
827
+ alignItems: "center",
828
+ sx: {
829
+ minHeight: '24px'
830
+ },
831
+ children: [
832
+ column.getCanSort() ? /*#__PURE__*/ jsx(TableSortLabel, {
833
+ active: !!column.getIsSorted(),
834
+ direction: column.getIsSorted() || 'asc',
835
+ IconComponent: column.getIsSorted() ? ArrowDownward : UnsortedIcon,
836
+ sx: (theme)=>({
837
+ fontWeight: 'inherit',
838
+ whiteSpace: definitions.get(column.id).header.length < 20 ? 'nowrap' : 'normal',
839
+ '& .MuiTableSortLabel-icon': {
840
+ color: `${'dark' === theme.palette.mode ? theme.palette.text.primary : theme.palette.text.secondary} !important`,
841
+ opacity: column.getIsSorted() ? 1 : 0.3,
842
+ width: '3ch',
843
+ m: 0
844
+ }
845
+ }),
846
+ onClick: column.getToggleSortingHandler(),
847
+ children: header
848
+ }) : header,
849
+ /*#__PURE__*/ jsx(ColumnDragHandle, {}),
850
+ enableColumnActions && (column.getCanSort() || column.getCanFilter() || controlsEnabled) && /*#__PURE__*/ jsx(IconButton, {
851
+ size: "small",
852
+ sx: {
853
+ height: '2rem',
854
+ width: '2rem',
855
+ m: '-8px -4px',
856
+ opacity: 0.3,
857
+ transition: 'all 150ms'
858
+ },
859
+ "aria-label": `${strings.TABLE_COLUMN_ACTIONS}: ${definitions.get(column.id)?.header}`,
860
+ "aria-haspopup": "menu",
861
+ "aria-expanded": !!menuAnchor && menuColumnId === column.id,
862
+ onClick: (event)=>{
863
+ setMenuColumnId(column.id);
864
+ setMenuAnchor(event.currentTarget);
865
+ },
866
+ children: /*#__PURE__*/ jsx(MoreVert, {
867
+ sx: {
868
+ transform: 'scale(0.9)'
869
+ }
870
+ })
871
+ })
872
+ ]
873
+ }, "content"),
874
+ filtersVisible && column.getCanFilter() && /*#__PURE__*/ jsx(ColumnFilter, {
875
+ column: column,
876
+ definition: definitions.get(column.id)
877
+ }, "filter")
878
+ ]
879
+ });
880
+ })
881
+ })
882
+ }),
883
+ /*#__PURE__*/ jsxs(TableBody, {
884
+ children: [
885
+ rows.map((row, rowIndex)=>/*#__PURE__*/ jsx(TableRow, {
886
+ onClick: onRowClick ? ()=>onRowClick(row.original) : void 0,
887
+ sx: (theme)=>{
888
+ const background = theme.palette.background.default;
889
+ const hoverColor = alpha('dark' === theme.palette.mode ? lighten(background, 0.3) : darken(background, 0.3), 0.3);
890
+ return {
891
+ cursor: onRowClick ? 'pointer' : 'default',
892
+ '&:hover > td': {
893
+ backgroundImage: `linear-gradient(${hoverColor}, ${hoverColor})`
894
+ }
895
+ };
896
+ },
897
+ children: [
898
+ ...row.getStartVisibleCells(),
899
+ ...row.getCenterVisibleCells(),
900
+ ...row.getEndVisibleCells()
901
+ ].map((cell)=>{
902
+ const column = cell.column;
903
+ const definition = definitions.get(column.id);
904
+ const editConfig = definition.editConfig;
905
+ const canEdit = ('function' == typeof definition.enableEditing ? definition.enableEditing(row) : definition.enableEditing ?? enableEditing) && enableEditing && (!!editConfig?.onSave || editConfig?.editVariant === 'custom' && !!editConfig.customEditComponent);
906
+ const value = cell.getValue();
907
+ const bodyCellProps = 'function' == typeof muiTableBodyCellProps ? muiTableBodyCellProps({
908
+ cell,
909
+ column,
910
+ row,
911
+ table
912
+ }) : muiTableBodyCellProps;
913
+ const columnFilter = column.getFilterValue();
914
+ const highlightColumnFilter = columnFilter && (!definition.filterVariant || 'text' === definition.filterVariant);
915
+ const renderedCellValue = highlightValue(value, enableFilterMatchHighlighting && false !== definition.enableFilterMatchHighlighting ? highlightColumnFilter ? columnFilter : column.getCanGlobalFilter() ? table.state.globalFilter : void 0 : void 0, highlightColumnFilter ? 'fuzzy' !== definition.filterFn : true);
916
+ return /*#__PURE__*/ createElement(ColumnDragBodyCell, {
917
+ ...bodyCellProps,
918
+ key: cell.id,
919
+ columnId: column.id,
920
+ lastRow: rowIndex === rows.length - 1,
921
+ "data-pinned": column.getIsPinned() ? 'true' : void 0,
922
+ tabIndex: bodyCellProps?.tabIndex ?? (canEdit ? 0 : void 0),
923
+ onClick: (event)=>{
924
+ if (canEdit) event.stopPropagation();
925
+ bodyCellProps?.onClick?.(event);
926
+ },
927
+ onDoubleClick: (event)=>{
928
+ if (canEdit) setEditingCell({
929
+ id: cell.id
930
+ });
931
+ bodyCellProps?.onDoubleClick?.(event);
932
+ },
933
+ onKeyDown: (event)=>{
934
+ if (canEdit && event.target === event.currentTarget) {
935
+ if ('Enter' === event.key || 'F2' === event.key) {
936
+ event.preventDefault();
937
+ setEditingCell({
938
+ id: cell.id
939
+ });
940
+ }
941
+ }
942
+ bodyCellProps?.onKeyDown?.(event);
943
+ },
944
+ sx: [
945
+ (theme)=>({
946
+ ...pinnedStyles(column, theme, pinnedOffsets),
947
+ borderBottom: 'none',
948
+ bgcolor: rowIndex % 2 === 0 ? 'TwClrBaseGray025' : 'background.paper',
949
+ cursor: canEdit ? 'pointer' : 'inherit',
950
+ outlineOffset: '-1px',
951
+ '&:hover': {
952
+ outline: canEdit ? '1px solid' : void 0,
953
+ outlineColor: 'grey.500'
954
+ }
955
+ }),
956
+ ...Array.isArray(bodyCellProps?.sx) ? bodyCellProps.sx : [
957
+ bodyCellProps?.sx
958
+ ]
959
+ ]
960
+ }, editingCell?.id === cell.id ? /*#__PURE__*/ jsx(EditableCellV2, {
961
+ cell: cell,
962
+ column: definition,
963
+ onClose: ()=>setEditingCell((current)=>current === editingCell ? null : current)
964
+ }, cell.id) : definition.Cell ? /*#__PURE__*/ jsx(definition.Cell, {
965
+ ...cell.getContext(),
966
+ renderedCellValue: renderedCellValue
967
+ }) : renderedCellValue);
968
+ })
969
+ }, row.id)),
970
+ !rows.length && /*#__PURE__*/ jsx(TableRow, {
971
+ children: /*#__PURE__*/ jsx(TableCell, {
972
+ colSpan: Math.max(1, visibleColumns.length),
973
+ children: strings.TABLE_NO_ROWS
974
+ })
975
+ })
976
+ ]
977
+ })
978
+ ]
979
+ })
980
+ }),
981
+ enablePagination && enableBottomToolbar && /*#__PURE__*/ jsx(TablePagination, {
982
+ component: "div",
983
+ sx: (theme)=>({
984
+ boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} inset`,
985
+ '& .MuiTablePagination-displayedRows': {
986
+ ...theme.typography.body2,
987
+ color: 'text.primary'
988
+ }
989
+ }),
990
+ showFirstButton: true,
991
+ showLastButton: true,
992
+ count: pageCountWithoutRowCount ? -1 : table.getRowCount(),
993
+ slotProps: pageCountWithoutRowCount ? {
994
+ actions: 'rtl' === theme.direction ? {
995
+ previousButton: nextPageButton,
996
+ firstButton: lastPageButton
997
+ } : {
998
+ nextButton: nextPageButton,
999
+ lastButton: lastPageButton
1000
+ }
1001
+ } : void 0,
1002
+ page: table.state.pagination.pageIndex,
1003
+ rowsPerPage: table.state.pagination.pageSize,
1004
+ rowsPerPageOptions: Array.from(new Set([
1005
+ table.state.pagination.pageSize,
1006
+ 10,
1007
+ 25,
1008
+ 50,
1009
+ 100
1010
+ ])).sort((a, b)=>a - b),
1011
+ labelRowsPerPage: strings.TABLE_ROWS_PER_PAGE,
1012
+ labelDisplayedRows: ({ from, to, count })=>pageCountWithoutRowCount ? `${rows.length ? from : 0}–${rows.length ? from + rows.length - 1 : 0}` : `${from.toLocaleString(getLocale())}-${to.toLocaleString(getLocale())} ${strings.TABLE_OF} ${count.toLocaleString(getLocale())}`,
1013
+ getItemAriaLabel: (type)=>({
1014
+ first: strings.TABLE_FIRST_PAGE,
1015
+ last: strings.TABLE_LAST_PAGE,
1016
+ next: strings.TABLE_NEXT_PAGE,
1017
+ previous: strings.TABLE_PREVIOUS_PAGE
1018
+ })[type],
1019
+ onPageChange: (_, page)=>table.setPageIndex(page),
1020
+ onRowsPerPageChange: (event)=>table.setPageSize(Number(event.target.value))
1021
+ })
1022
+ ]
1023
+ })
1024
+ });
1025
+ };
1026
+ const components_EditableTableV2 = EditableTableV2;
1027
+ export default components_EditableTableV2;