@terraware/web-components 5.2.12 → 5.3.0

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