@terraware/web-components 5.2.5 → 5.2.6-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.
- package/components/EditableTable/index.d.ts +2 -3
- package/components/EditableTable/index.d.ts.map +1 -1
- package/components/EditableTableV2/EditableCellV2.d.ts +10 -0
- package/components/EditableTableV2/EditableCellV2.d.ts.map +1 -0
- package/components/EditableTableV2/EditableCellV2.js +80 -0
- package/components/EditableTableV2/index.d.ts +43 -0
- package/components/EditableTableV2/index.d.ts.map +1 -0
- package/components/EditableTableV2/index.js +824 -0
- package/components/EditableTableV2/types.d.ts +78 -0
- package/components/EditableTableV2/types.d.ts.map +1 -0
- package/components/EditableTableV2/types.js +17 -0
- package/components/table/density.d.ts +1 -1
- package/index.d.ts +3 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/license-report.html +1 -1
- package/package.json +2 -1
- package/strings/csv/en.csv +35 -0
- package/strings/csv/es.csv +35 -0
- package/strings/csv/fr.csv +35 -0
- package/strings/strings-en.d.ts +35 -0
- package/strings/strings-en.d.ts.map +1 -1
- package/strings/strings-en.js +36 -1
- package/strings/strings-es.d.ts +35 -0
- package/strings/strings-es.d.ts.map +1 -1
- package/strings/strings-es.js +36 -1
- package/strings/strings-fr.d.ts +35 -0
- package/strings/strings-fr.d.ts.map +1 -1
- package/strings/strings-fr.js +36 -1
- package/strings/strings-gx.d.ts +35 -0
- package/strings/strings-gx.d.ts.map +1 -1
- package/strings/strings-gx.js +36 -1
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { ArrowDownward, ArrowUpward, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, FilterAlt, FilterList, FilterListOff, Fullscreen, FullscreenExit, MoreVert, PushPin, Search, SearchOff, Sort, SyncAlt, ViewColumn, VisibilityOff } from "@mui/icons-material";
|
|
4
|
+
import { Box, Button, Divider, FormControlLabel, IconButton, InputAdornment, ListItemIcon, Menu, MenuItem, Paper, Switch, Table, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, TextField, Toolbar, Tooltip } from "@mui/material";
|
|
5
|
+
import { alpha, darken, lighten } from "@mui/material/styles";
|
|
6
|
+
import { useTable } from "@tanstack/react-table";
|
|
7
|
+
import { useStrings } from "../../strings/index.js";
|
|
8
|
+
import Button_Button from "../Button/Button.js";
|
|
9
|
+
import EditableCellV2 from "./EditableCellV2.js";
|
|
10
|
+
import { editableTableFeatures } from "./types.js";
|
|
11
|
+
const isActiveFilter = (filter)=>{
|
|
12
|
+
const values = Array.isArray(filter.value) ? filter.value : [
|
|
13
|
+
filter.value
|
|
14
|
+
];
|
|
15
|
+
return values.some((value)=>null != value && '' !== value);
|
|
16
|
+
};
|
|
17
|
+
const readFilters = (storageKey)=>{
|
|
18
|
+
try {
|
|
19
|
+
const saved = storageKey ? JSON.parse(localStorage.getItem(`${storageKey}_columnFilters`) ?? '[]') : [];
|
|
20
|
+
return Array.isArray(saved) ? saved.filter((filter)=>filter && 'string' == typeof filter.id && isActiveFilter(filter)) : [];
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const pinnedStyles = (column, theme)=>{
|
|
26
|
+
const position = column.getIsPinned();
|
|
27
|
+
const background = theme.palette.background.default;
|
|
28
|
+
const baseBackground = 'dark' === theme.palette.mode ? lighten(background, 0.05) : background;
|
|
29
|
+
return {
|
|
30
|
+
width: column.getSize(),
|
|
31
|
+
minWidth: column.getSize(),
|
|
32
|
+
...position && {
|
|
33
|
+
position: 'sticky',
|
|
34
|
+
zIndex: 1,
|
|
35
|
+
opacity: 0.97,
|
|
36
|
+
'&::before': {
|
|
37
|
+
content: '""',
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
inset: 0,
|
|
40
|
+
zIndex: -1,
|
|
41
|
+
backgroundColor: alpha(darken(baseBackground, 'dark' === theme.palette.mode ? 0.05 : 0.01), 0.97),
|
|
42
|
+
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
|
|
43
|
+
},
|
|
44
|
+
...'start' === position ? {
|
|
45
|
+
insetInlineStart: column.getStart('start')
|
|
46
|
+
} : {
|
|
47
|
+
insetInlineEnd: column.getAfter('end')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const UnsortedIcon = (props)=>/*#__PURE__*/ jsx(SyncAlt, {
|
|
53
|
+
...props,
|
|
54
|
+
style: {
|
|
55
|
+
...props.style,
|
|
56
|
+
transform: 'rotate(-90deg) scaleX(0.9) translateX(-1px)'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const ColumnActionMenuItemV2 = ({ icon, children, ...props })=>/*#__PURE__*/ jsx(MenuItem, {
|
|
60
|
+
sx: {
|
|
61
|
+
minWidth: '120px',
|
|
62
|
+
my: 0,
|
|
63
|
+
py: '6px'
|
|
64
|
+
},
|
|
65
|
+
...props,
|
|
66
|
+
children: /*#__PURE__*/ jsxs(Box, {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ jsx(ListItemIcon, {
|
|
71
|
+
children: icon
|
|
72
|
+
}),
|
|
73
|
+
children
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
const ColumnFilter = ({ column, definition })=>{
|
|
78
|
+
const strings = useStrings();
|
|
79
|
+
const label = `${strings.TABLE_FILTER}: ${definition.header}`;
|
|
80
|
+
const placeholder = strings.TABLE_FILTER_BY.replace('{column}', definition.header);
|
|
81
|
+
const value = column.getFilterValue();
|
|
82
|
+
if ('range' === definition.filterVariant || 'date-range' === definition.filterVariant) {
|
|
83
|
+
const range = Array.isArray(value) ? value : [
|
|
84
|
+
'',
|
|
85
|
+
''
|
|
86
|
+
];
|
|
87
|
+
return /*#__PURE__*/ jsx(Box, {
|
|
88
|
+
display: "flex",
|
|
89
|
+
gap: 1,
|
|
90
|
+
children: [
|
|
91
|
+
0,
|
|
92
|
+
1
|
|
93
|
+
].map((index)=>/*#__PURE__*/ jsx(TextField, {
|
|
94
|
+
size: "small",
|
|
95
|
+
variant: "standard",
|
|
96
|
+
placeholder: 0 === index ? strings.TABLE_MIN : strings.TABLE_MAX,
|
|
97
|
+
type: 'date-range' === definition.filterVariant ? 'date' : 'number',
|
|
98
|
+
value: range[index] ?? '',
|
|
99
|
+
slotProps: {
|
|
100
|
+
htmlInput: {
|
|
101
|
+
'aria-label': `${label} ${0 === index ? strings.TABLE_MIN : strings.TABLE_MAX}`
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
onChange: (event)=>{
|
|
105
|
+
const next = [
|
|
106
|
+
...range
|
|
107
|
+
];
|
|
108
|
+
next[index] = event.target.value;
|
|
109
|
+
column.setFilterValue(next.some((entry)=>'' !== entry) ? next : void 0);
|
|
110
|
+
}
|
|
111
|
+
}, index))
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const multiple = 'multi-select' === definition.filterVariant;
|
|
115
|
+
const select = multiple || 'select' === definition.filterVariant;
|
|
116
|
+
return /*#__PURE__*/ jsxs(TextField, {
|
|
117
|
+
fullWidth: true,
|
|
118
|
+
variant: "standard",
|
|
119
|
+
placeholder: placeholder,
|
|
120
|
+
sx: {
|
|
121
|
+
minWidth: 120,
|
|
122
|
+
mx: '-2px',
|
|
123
|
+
p: 0,
|
|
124
|
+
width: 'calc(100% + 4px)'
|
|
125
|
+
},
|
|
126
|
+
select: select,
|
|
127
|
+
value: value ?? (multiple ? [] : ''),
|
|
128
|
+
onChange: (event)=>column.setFilterValue(event.target.value || void 0),
|
|
129
|
+
slotProps: {
|
|
130
|
+
htmlInput: {
|
|
131
|
+
'aria-label': label
|
|
132
|
+
},
|
|
133
|
+
input: {
|
|
134
|
+
endAdornment: /*#__PURE__*/ jsx(InputAdornment, {
|
|
135
|
+
position: "end",
|
|
136
|
+
sx: {
|
|
137
|
+
mr: select ? '20px' : void 0,
|
|
138
|
+
visibility: isActiveFilter({
|
|
139
|
+
value
|
|
140
|
+
}) ? 'visible' : 'hidden'
|
|
141
|
+
},
|
|
142
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
143
|
+
size: "small",
|
|
144
|
+
"aria-label": `${strings.TABLE_CLEAR_FILTER}: ${definition.header}`,
|
|
145
|
+
disabled: !isActiveFilter({
|
|
146
|
+
value
|
|
147
|
+
}),
|
|
148
|
+
onClick: ()=>column.setFilterValue(void 0),
|
|
149
|
+
sx: {
|
|
150
|
+
height: '2rem',
|
|
151
|
+
width: '2rem',
|
|
152
|
+
transform: 'scale(0.9)'
|
|
153
|
+
},
|
|
154
|
+
children: /*#__PURE__*/ jsx(Close, {})
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
},
|
|
158
|
+
select: {
|
|
159
|
+
multiple,
|
|
160
|
+
displayEmpty: true,
|
|
161
|
+
'aria-label': label,
|
|
162
|
+
renderValue: (selected)=>(Array.isArray(selected) ? selected.join(', ') : String(selected ?? '')) || /*#__PURE__*/ jsx(Box, {
|
|
163
|
+
sx: {
|
|
164
|
+
opacity: 0.5
|
|
165
|
+
},
|
|
166
|
+
children: placeholder
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
children: [
|
|
171
|
+
select && !multiple && /*#__PURE__*/ jsx(MenuItem, {
|
|
172
|
+
value: "",
|
|
173
|
+
children: strings.TABLE_ALL
|
|
174
|
+
}),
|
|
175
|
+
select && definition.filterSelectOptions?.map((option)=>/*#__PURE__*/ jsx(MenuItem, {
|
|
176
|
+
value: option,
|
|
177
|
+
children: option
|
|
178
|
+
}, option))
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFilters = true, enableEditing = false, enableColumnOrdering = false, enableColumnActions = true, showColumnsButton = false, showGlobalFilterButton = false, showColumnFiltersButton = false, showDensityButton = false, showFullScreenButton = false, enableColumnPinning = false, enableHiding = true, enableSorting = true, enableGlobalFilter = false, enableColumnFilters = false, stickyFilters = false, storageKey, enablePagination = true, enableBottomToolbar = true, enableTopToolbar = true, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, tableOptions, containerProps, sx })=>{
|
|
183
|
+
const strings = useStrings();
|
|
184
|
+
const [editingCell, setEditingCell] = useState(null);
|
|
185
|
+
const [globalFilterVisible, setGlobalFilterVisible] = useState(true);
|
|
186
|
+
const [columnFiltersVisible, setColumnFiltersVisible] = useState(!showColumnFiltersButton);
|
|
187
|
+
const [density, setDensity] = useState(1);
|
|
188
|
+
const [fullScreen, setFullScreen] = useState(false);
|
|
189
|
+
const [menuColumnId, setMenuColumnId] = useState(null);
|
|
190
|
+
const [menuAnchor, setMenuAnchor] = useState(null);
|
|
191
|
+
const [columnFilters, setColumnFilters] = useState(()=>readFilters(stickyFilters ? storageKey : void 0));
|
|
192
|
+
useEffect(()=>{
|
|
193
|
+
setColumnFilters(readFilters(stickyFilters ? storageKey : void 0));
|
|
194
|
+
}, [
|
|
195
|
+
stickyFilters,
|
|
196
|
+
storageKey
|
|
197
|
+
]);
|
|
198
|
+
const tableColumns = useMemo(()=>columns.map((column)=>({
|
|
199
|
+
id: column.id,
|
|
200
|
+
header: column.header,
|
|
201
|
+
accessorFn: column.accessorFn ?? ((row)=>void 0 !== column.accessorKey ? row[column.accessorKey] : void 0),
|
|
202
|
+
size: column.size,
|
|
203
|
+
enableHiding: column.enableHiding ?? true,
|
|
204
|
+
enableColumnFilter: !!column.filterVariant,
|
|
205
|
+
...column.sortFn ? {
|
|
206
|
+
sortFn: column.sortFn
|
|
207
|
+
} : {},
|
|
208
|
+
filterFn: (row, id, filterValue)=>{
|
|
209
|
+
if (column.filterFn) return column.filterFn(row.original, id, filterValue);
|
|
210
|
+
const value = row.getValue(id);
|
|
211
|
+
if ('select' === column.filterVariant) return String(value ?? '') === String(filterValue);
|
|
212
|
+
if ('multi-select' === column.filterVariant) return !Array.isArray(filterValue) || !filterValue.length || filterValue.some((selected)=>Array.isArray(value) ? value.includes(selected) : String(value ?? '') === String(selected));
|
|
213
|
+
if ('range' === column.filterVariant || 'date-range' === column.filterVariant) {
|
|
214
|
+
const [min, max] = Array.isArray(filterValue) ? filterValue : [];
|
|
215
|
+
const normalize = (entry)=>'date-range' === column.filterVariant ? Date.parse(String(entry)) : Number(entry);
|
|
216
|
+
const numeric = normalize(value);
|
|
217
|
+
return null != value && '' !== value && Number.isFinite(numeric) && ('' === min || void 0 === min || numeric >= normalize(min)) && ('' === max || void 0 === max || numeric <= normalize(max));
|
|
218
|
+
}
|
|
219
|
+
return String(value ?? '').toLocaleLowerCase().includes(String(filterValue).toLocaleLowerCase());
|
|
220
|
+
}
|
|
221
|
+
})), [
|
|
222
|
+
columns
|
|
223
|
+
]);
|
|
224
|
+
const persistFilters = stickyFilters && !!storageKey && tableOptions?.state?.columnFilters === void 0;
|
|
225
|
+
const table = useTable({
|
|
226
|
+
features: editableTableFeatures,
|
|
227
|
+
columns: tableColumns,
|
|
228
|
+
data,
|
|
229
|
+
enableSorting,
|
|
230
|
+
sortDescFirst: false,
|
|
231
|
+
enableColumnPinning,
|
|
232
|
+
enableHiding,
|
|
233
|
+
enableColumnFilters,
|
|
234
|
+
enableGlobalFilter,
|
|
235
|
+
manualPagination: !enablePagination,
|
|
236
|
+
...tableOptions,
|
|
237
|
+
initialState: {
|
|
238
|
+
sorting: initialSorting ?? [],
|
|
239
|
+
...tableOptions?.initialState
|
|
240
|
+
},
|
|
241
|
+
...persistFilters && {
|
|
242
|
+
state: {
|
|
243
|
+
...tableOptions?.state,
|
|
244
|
+
columnFilters
|
|
245
|
+
},
|
|
246
|
+
onColumnFiltersChange: (updater)=>{
|
|
247
|
+
setColumnFilters((previous)=>{
|
|
248
|
+
const next = 'function' == typeof updater ? updater(previous) : updater;
|
|
249
|
+
try {
|
|
250
|
+
if (next.some(isActiveFilter)) localStorage.setItem(`${storageKey}_columnFilters`, JSON.stringify(next.filter(isActiveFilter)));
|
|
251
|
+
else localStorage.removeItem(`${storageKey}_columnFilters`);
|
|
252
|
+
} catch {}
|
|
253
|
+
return next;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const hasFilters = table.state.columnFilters.some(isActiveFilter) || !!table.state.globalFilter;
|
|
259
|
+
const clearFilters = ()=>{
|
|
260
|
+
table.setColumnFilters([]);
|
|
261
|
+
table.setGlobalFilter('');
|
|
262
|
+
onClearAllFilters?.();
|
|
263
|
+
};
|
|
264
|
+
const definitions = new Map(columns.map((column)=>[
|
|
265
|
+
column.id,
|
|
266
|
+
column
|
|
267
|
+
]));
|
|
268
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
269
|
+
const orderedColumns = [
|
|
270
|
+
...table.getStartVisibleLeafColumns(),
|
|
271
|
+
...table.getCenterVisibleLeafColumns(),
|
|
272
|
+
...table.getEndVisibleLeafColumns()
|
|
273
|
+
];
|
|
274
|
+
const rows = table.getRowModel().rows;
|
|
275
|
+
const controlsEnabled = enableHiding || enableColumnOrdering || enableColumnPinning;
|
|
276
|
+
const hideableColumns = table.getAllLeafColumns().filter((column)=>column.getCanHide());
|
|
277
|
+
const filtersVisible = enableColumnFilters && columnFiltersVisible;
|
|
278
|
+
useEffect(()=>{
|
|
279
|
+
if (!fullScreen) return;
|
|
280
|
+
const onKeyDown = (event)=>{
|
|
281
|
+
if ('Escape' === event.key) setFullScreen(false);
|
|
282
|
+
};
|
|
283
|
+
const overflow = document.body.style.overflow;
|
|
284
|
+
document.body.style.overflow = 'hidden';
|
|
285
|
+
document.addEventListener('keydown', onKeyDown);
|
|
286
|
+
return ()=>{
|
|
287
|
+
document.body.style.overflow = overflow;
|
|
288
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
289
|
+
};
|
|
290
|
+
}, [
|
|
291
|
+
fullScreen
|
|
292
|
+
]);
|
|
293
|
+
const moveColumn = (id, offset)=>{
|
|
294
|
+
const order = table.getAllLeafColumns().map((column)=>column.id);
|
|
295
|
+
const index = order.indexOf(id);
|
|
296
|
+
const target = index + offset;
|
|
297
|
+
if (target >= 0 && target < order.length) {
|
|
298
|
+
[order[index], order[target]] = [
|
|
299
|
+
order[target],
|
|
300
|
+
order[index]
|
|
301
|
+
];
|
|
302
|
+
table.setColumnOrder(order);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
return /*#__PURE__*/ jsx(Box, {
|
|
306
|
+
minHeight: "160px",
|
|
307
|
+
padding: 2,
|
|
308
|
+
sx: [
|
|
309
|
+
...Array.isArray(sx) ? sx : [
|
|
310
|
+
sx
|
|
311
|
+
],
|
|
312
|
+
...showDensityButton ? [
|
|
313
|
+
{
|
|
314
|
+
'& td': {
|
|
315
|
+
py: 0 === density ? '4px' : 1 === density ? '16px' : '24px'
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
] : [],
|
|
319
|
+
...fullScreen ? [
|
|
320
|
+
{
|
|
321
|
+
position: 'fixed',
|
|
322
|
+
inset: 0,
|
|
323
|
+
m: 0,
|
|
324
|
+
p: 0,
|
|
325
|
+
zIndex: 1200,
|
|
326
|
+
bgcolor: 'background.paper',
|
|
327
|
+
overflow: 'auto'
|
|
328
|
+
}
|
|
329
|
+
] : []
|
|
330
|
+
],
|
|
331
|
+
children: /*#__PURE__*/ jsxs(Paper, {
|
|
332
|
+
elevation: 0,
|
|
333
|
+
children: [
|
|
334
|
+
enableTopToolbar && /*#__PURE__*/ jsxs(Toolbar, {
|
|
335
|
+
disableGutters: true,
|
|
336
|
+
sx: {
|
|
337
|
+
gap: 1,
|
|
338
|
+
flexWrap: 'wrap',
|
|
339
|
+
alignItems: 'flex-start',
|
|
340
|
+
p: 1,
|
|
341
|
+
minHeight: '56px !important',
|
|
342
|
+
boxSizing: 'border-box'
|
|
343
|
+
},
|
|
344
|
+
children: [
|
|
345
|
+
enableGlobalFilter && globalFilterVisible && /*#__PURE__*/ jsx(TextField, {
|
|
346
|
+
placeholder: strings.TABLE_SEARCH,
|
|
347
|
+
size: "small",
|
|
348
|
+
slotProps: {
|
|
349
|
+
htmlInput: {
|
|
350
|
+
'aria-label': strings.TABLE_SEARCH
|
|
351
|
+
},
|
|
352
|
+
input: {
|
|
353
|
+
startAdornment: /*#__PURE__*/ jsx(Search, {
|
|
354
|
+
sx: {
|
|
355
|
+
mr: '4px'
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
endAdornment: /*#__PURE__*/ jsx(InputAdornment, {
|
|
359
|
+
position: "end",
|
|
360
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
361
|
+
size: "small",
|
|
362
|
+
"aria-label": strings.TABLE_CLEAR_SEARCH,
|
|
363
|
+
disabled: !table.state.globalFilter,
|
|
364
|
+
onClick: ()=>table.setGlobalFilter(''),
|
|
365
|
+
children: /*#__PURE__*/ jsx(Close, {})
|
|
366
|
+
})
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
value: table.state.globalFilter ?? '',
|
|
371
|
+
onChange: (event)=>table.setGlobalFilter(event.target.value)
|
|
372
|
+
}),
|
|
373
|
+
/*#__PURE__*/ jsx(Box, {
|
|
374
|
+
flexGrow: 1
|
|
375
|
+
}),
|
|
376
|
+
enableClearAllFilters && hasFilters && /*#__PURE__*/ jsx(Button_Button, {
|
|
377
|
+
label: clearAllFiltersLabel,
|
|
378
|
+
priority: "ghost",
|
|
379
|
+
size: "small",
|
|
380
|
+
onClick: clearFilters
|
|
381
|
+
}),
|
|
382
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
383
|
+
display: "flex",
|
|
384
|
+
alignItems: "center",
|
|
385
|
+
children: [
|
|
386
|
+
renderToolbarInternalActions?.({
|
|
387
|
+
table
|
|
388
|
+
}),
|
|
389
|
+
showGlobalFilterButton && enableGlobalFilter && /*#__PURE__*/ jsx(Tooltip, {
|
|
390
|
+
title: strings.TABLE_TOGGLE_SEARCH,
|
|
391
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
392
|
+
"aria-label": strings.TABLE_TOGGLE_SEARCH,
|
|
393
|
+
"aria-pressed": globalFilterVisible,
|
|
394
|
+
onClick: ()=>setGlobalFilterVisible((visible)=>!visible),
|
|
395
|
+
children: globalFilterVisible ? /*#__PURE__*/ jsx(SearchOff, {}) : /*#__PURE__*/ jsx(Search, {})
|
|
396
|
+
})
|
|
397
|
+
}),
|
|
398
|
+
showColumnFiltersButton && enableColumnFilters && /*#__PURE__*/ jsx(Tooltip, {
|
|
399
|
+
title: strings.TABLE_TOGGLE_FILTERS,
|
|
400
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
401
|
+
"aria-label": strings.TABLE_TOGGLE_FILTERS,
|
|
402
|
+
"aria-pressed": columnFiltersVisible,
|
|
403
|
+
onClick: ()=>setColumnFiltersVisible((visible)=>!visible),
|
|
404
|
+
children: columnFiltersVisible ? /*#__PURE__*/ jsx(FilterListOff, {}) : /*#__PURE__*/ jsx(FilterList, {})
|
|
405
|
+
})
|
|
406
|
+
}),
|
|
407
|
+
showColumnsButton && controlsEnabled && /*#__PURE__*/ jsx(IconButton, {
|
|
408
|
+
"aria-label": strings.TABLE_COLUMNS,
|
|
409
|
+
onClick: (event)=>{
|
|
410
|
+
setMenuColumnId(null);
|
|
411
|
+
setMenuAnchor(event.currentTarget);
|
|
412
|
+
},
|
|
413
|
+
children: /*#__PURE__*/ jsx(ViewColumn, {})
|
|
414
|
+
}),
|
|
415
|
+
showDensityButton && /*#__PURE__*/ jsx(Tooltip, {
|
|
416
|
+
title: strings.TABLE_TOGGLE_DENSITY,
|
|
417
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
418
|
+
"aria-label": strings.TABLE_TOGGLE_DENSITY,
|
|
419
|
+
onClick: ()=>setDensity((value)=>(value + 2) % 3),
|
|
420
|
+
children: 0 === density ? /*#__PURE__*/ jsx(DensitySmall, {}) : 1 === density ? /*#__PURE__*/ jsx(DensityMedium, {}) : /*#__PURE__*/ jsx(DensityLarge, {})
|
|
421
|
+
})
|
|
422
|
+
}),
|
|
423
|
+
showFullScreenButton && /*#__PURE__*/ jsx(Tooltip, {
|
|
424
|
+
title: strings.TABLE_TOGGLE_FULLSCREEN,
|
|
425
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
426
|
+
"aria-label": strings.TABLE_TOGGLE_FULLSCREEN,
|
|
427
|
+
"aria-pressed": fullScreen,
|
|
428
|
+
onClick: ()=>setFullScreen((value)=>!value),
|
|
429
|
+
children: fullScreen ? /*#__PURE__*/ jsx(FullscreenExit, {}) : /*#__PURE__*/ jsx(Fullscreen, {})
|
|
430
|
+
})
|
|
431
|
+
})
|
|
432
|
+
]
|
|
433
|
+
})
|
|
434
|
+
]
|
|
435
|
+
}),
|
|
436
|
+
/*#__PURE__*/ jsxs(Menu, {
|
|
437
|
+
anchorEl: menuAnchor,
|
|
438
|
+
open: !!menuAnchor,
|
|
439
|
+
onClose: ()=>setMenuAnchor(null),
|
|
440
|
+
children: [
|
|
441
|
+
menuColumnId && table.getColumn(menuColumnId)?.getCanSort() && [
|
|
442
|
+
{
|
|
443
|
+
label: strings.TABLE_CLEAR_SORTING,
|
|
444
|
+
icon: /*#__PURE__*/ jsx(ClearAll, {}),
|
|
445
|
+
disabled: !table.getColumn(menuColumnId)?.getIsSorted(),
|
|
446
|
+
action: ()=>table.getColumn(menuColumnId)?.clearSorting()
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
label: strings.TABLE_SORT_ASCENDING.replace('{column}', definitions.get(menuColumnId).header),
|
|
450
|
+
icon: /*#__PURE__*/ jsx(Sort, {
|
|
451
|
+
sx: {
|
|
452
|
+
transform: 'rotate(180deg) scaleX(-1)'
|
|
453
|
+
}
|
|
454
|
+
}),
|
|
455
|
+
disabled: table.getColumn(menuColumnId)?.getIsSorted() === 'asc',
|
|
456
|
+
action: ()=>table.getColumn(menuColumnId)?.toggleSorting(false)
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
label: strings.TABLE_SORT_DESCENDING.replace('{column}', definitions.get(menuColumnId).header),
|
|
460
|
+
icon: /*#__PURE__*/ jsx(Sort, {}),
|
|
461
|
+
disabled: table.getColumn(menuColumnId)?.getIsSorted() === 'desc',
|
|
462
|
+
divider: enableColumnFilters || controlsEnabled,
|
|
463
|
+
action: ()=>table.getColumn(menuColumnId)?.toggleSorting(true)
|
|
464
|
+
}
|
|
465
|
+
].map(({ label, icon, disabled, divider, action })=>/*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
466
|
+
icon: icon,
|
|
467
|
+
disabled: disabled,
|
|
468
|
+
divider: divider,
|
|
469
|
+
onClick: ()=>{
|
|
470
|
+
action();
|
|
471
|
+
setMenuAnchor(null);
|
|
472
|
+
},
|
|
473
|
+
children: label
|
|
474
|
+
}, label)),
|
|
475
|
+
menuColumnId && table.getColumn(menuColumnId)?.getCanFilter() && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
476
|
+
icon: /*#__PURE__*/ jsx(FilterListOff, {}),
|
|
477
|
+
disabled: !table.getColumn(menuColumnId)?.getIsFiltered(),
|
|
478
|
+
onClick: ()=>{
|
|
479
|
+
table.getColumn(menuColumnId)?.setFilterValue(void 0);
|
|
480
|
+
setMenuAnchor(null);
|
|
481
|
+
},
|
|
482
|
+
children: strings.TABLE_CLEAR_FILTER
|
|
483
|
+
}),
|
|
484
|
+
menuColumnId && table.getColumn(menuColumnId)?.getCanFilter() && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
485
|
+
icon: /*#__PURE__*/ jsx(FilterList, {}),
|
|
486
|
+
disabled: true,
|
|
487
|
+
divider: controlsEnabled,
|
|
488
|
+
children: strings.TABLE_FILTER_BY.replace('{column}', definitions.get(menuColumnId).header)
|
|
489
|
+
}),
|
|
490
|
+
menuColumnId && enableColumnPinning && [
|
|
491
|
+
{
|
|
492
|
+
label: strings.TABLE_PIN_START,
|
|
493
|
+
direction: 'start',
|
|
494
|
+
rotation: '90deg'
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
label: strings.TABLE_PIN_END,
|
|
498
|
+
direction: 'end',
|
|
499
|
+
rotation: '-90deg'
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
label: strings.TABLE_UNPIN,
|
|
503
|
+
direction: false,
|
|
504
|
+
rotation: '0deg'
|
|
505
|
+
}
|
|
506
|
+
].map(({ label, direction, rotation })=>/*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
507
|
+
icon: /*#__PURE__*/ jsx(PushPin, {
|
|
508
|
+
sx: {
|
|
509
|
+
transform: `rotate(${rotation})`
|
|
510
|
+
}
|
|
511
|
+
}),
|
|
512
|
+
disabled: !table.getColumn(menuColumnId)?.getCanPin() || table.getColumn(menuColumnId)?.getIsPinned() === direction,
|
|
513
|
+
divider: false === direction && enableHiding,
|
|
514
|
+
onClick: ()=>{
|
|
515
|
+
table.getColumn(menuColumnId)?.pin(direction);
|
|
516
|
+
setMenuAnchor(null);
|
|
517
|
+
},
|
|
518
|
+
children: label
|
|
519
|
+
}, label)),
|
|
520
|
+
menuColumnId && enableHiding && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
521
|
+
icon: /*#__PURE__*/ jsx(VisibilityOff, {}),
|
|
522
|
+
disabled: !table.getColumn(menuColumnId)?.getCanHide() || !(enableTopToolbar && showColumnsButton) && 1 === orderedColumns.length,
|
|
523
|
+
onClick: ()=>{
|
|
524
|
+
table.getColumn(menuColumnId)?.toggleVisibility(false);
|
|
525
|
+
setMenuAnchor(null);
|
|
526
|
+
},
|
|
527
|
+
children: strings.TABLE_HIDE_COLUMN.replace('{column}', definitions.get(menuColumnId).header)
|
|
528
|
+
}),
|
|
529
|
+
menuColumnId && enableHiding && /*#__PURE__*/ jsx(ColumnActionMenuItemV2, {
|
|
530
|
+
icon: /*#__PURE__*/ jsx(ViewColumn, {}),
|
|
531
|
+
disabled: table.getAllLeafColumns().every((column)=>column.getIsVisible() || !column.getCanHide()),
|
|
532
|
+
onClick: ()=>{
|
|
533
|
+
table.getAllLeafColumns().filter((column)=>column.getCanHide()).forEach((column)=>column.toggleVisibility(true));
|
|
534
|
+
setMenuAnchor(null);
|
|
535
|
+
},
|
|
536
|
+
children: strings.TABLE_SHOW_ALL_COLUMNS
|
|
537
|
+
}),
|
|
538
|
+
!menuColumnId && enableHiding && /*#__PURE__*/ jsxs(Box, {
|
|
539
|
+
display: "flex",
|
|
540
|
+
justifyContent: "space-between",
|
|
541
|
+
px: 1,
|
|
542
|
+
pb: 1,
|
|
543
|
+
children: [
|
|
544
|
+
/*#__PURE__*/ jsx(Button, {
|
|
545
|
+
disabled: !hideableColumns.some((column)=>column.getIsVisible()),
|
|
546
|
+
onClick: ()=>hideableColumns.forEach((column)=>column.toggleVisibility(false)),
|
|
547
|
+
children: strings.TABLE_HIDE_ALL
|
|
548
|
+
}),
|
|
549
|
+
/*#__PURE__*/ jsx(Button, {
|
|
550
|
+
disabled: hideableColumns.every((column)=>column.getIsVisible()),
|
|
551
|
+
onClick: ()=>hideableColumns.forEach((column)=>column.toggleVisibility(true)),
|
|
552
|
+
children: strings.TABLE_SHOW_ALL
|
|
553
|
+
})
|
|
554
|
+
]
|
|
555
|
+
}),
|
|
556
|
+
!menuColumnId && controlsEnabled && /*#__PURE__*/ jsx(Divider, {}),
|
|
557
|
+
table.getAllLeafColumns().map((column, index, allColumns)=>!menuColumnId && controlsEnabled && /*#__PURE__*/ jsxs(MenuItem, {
|
|
558
|
+
disableRipple: true,
|
|
559
|
+
sx: {
|
|
560
|
+
my: 0,
|
|
561
|
+
py: '6px',
|
|
562
|
+
pl: '16px'
|
|
563
|
+
},
|
|
564
|
+
children: [
|
|
565
|
+
/*#__PURE__*/ jsx(FormControlLabel, {
|
|
566
|
+
label: definitions.get(column.id)?.header,
|
|
567
|
+
slotProps: {
|
|
568
|
+
typography: {
|
|
569
|
+
sx: {
|
|
570
|
+
mb: 0
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
control: /*#__PURE__*/ jsx(Switch, {
|
|
575
|
+
checked: column.getIsVisible(),
|
|
576
|
+
disabled: !enableHiding || !column.getCanHide() || !(enableTopToolbar && showColumnsButton) && column.getIsVisible() && 1 === orderedColumns.length,
|
|
577
|
+
onChange: column.getToggleVisibilityHandler()
|
|
578
|
+
})
|
|
579
|
+
}),
|
|
580
|
+
enableColumnOrdering && /*#__PURE__*/ jsxs(Fragment, {
|
|
581
|
+
children: [
|
|
582
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
583
|
+
"aria-label": `${strings.TABLE_MOVE_BACK}: ${definitions.get(column.id)?.header}`,
|
|
584
|
+
disabled: 0 === index,
|
|
585
|
+
onClick: ()=>moveColumn(column.id, -1),
|
|
586
|
+
children: /*#__PURE__*/ jsx(ArrowUpward, {})
|
|
587
|
+
}),
|
|
588
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
589
|
+
"aria-label": `${strings.TABLE_MOVE_FORWARD}: ${definitions.get(column.id)?.header}`,
|
|
590
|
+
disabled: index === allColumns.length - 1,
|
|
591
|
+
onClick: ()=>moveColumn(column.id, 1),
|
|
592
|
+
children: /*#__PURE__*/ jsx(ArrowDownward, {})
|
|
593
|
+
})
|
|
594
|
+
]
|
|
595
|
+
}),
|
|
596
|
+
enableColumnPinning && /*#__PURE__*/ jsxs(TextField, {
|
|
597
|
+
select: true,
|
|
598
|
+
size: "small",
|
|
599
|
+
label: strings.TABLE_PIN,
|
|
600
|
+
value: column.getIsPinned() || '',
|
|
601
|
+
onChange: (event)=>column.pin('start' === event.target.value ? 'start' : 'end' === event.target.value ? 'end' : false),
|
|
602
|
+
children: [
|
|
603
|
+
/*#__PURE__*/ jsx(MenuItem, {
|
|
604
|
+
value: "",
|
|
605
|
+
children: strings.TABLE_UNPIN
|
|
606
|
+
}),
|
|
607
|
+
/*#__PURE__*/ jsx(MenuItem, {
|
|
608
|
+
value: "start",
|
|
609
|
+
children: strings.TABLE_PIN_START
|
|
610
|
+
}),
|
|
611
|
+
/*#__PURE__*/ jsx(MenuItem, {
|
|
612
|
+
value: "end",
|
|
613
|
+
children: strings.TABLE_PIN_END
|
|
614
|
+
})
|
|
615
|
+
]
|
|
616
|
+
})
|
|
617
|
+
]
|
|
618
|
+
}, column.id))
|
|
619
|
+
]
|
|
620
|
+
}),
|
|
621
|
+
/*#__PURE__*/ jsx(TableContainer, {
|
|
622
|
+
...containerProps,
|
|
623
|
+
children: /*#__PURE__*/ jsxs(Table, {
|
|
624
|
+
sx: {
|
|
625
|
+
minWidth: table.getTotalSize()
|
|
626
|
+
},
|
|
627
|
+
children: [
|
|
628
|
+
/*#__PURE__*/ jsx(TableHead, {
|
|
629
|
+
children: /*#__PURE__*/ jsx(TableRow, {
|
|
630
|
+
children: orderedColumns.map((column)=>{
|
|
631
|
+
const header = /*#__PURE__*/ jsxs(Fragment, {
|
|
632
|
+
children: [
|
|
633
|
+
definitions.get(column.id)?.header,
|
|
634
|
+
column.getIsFiltered() && /*#__PURE__*/ jsx(Tooltip, {
|
|
635
|
+
title: `${strings.TABLE_FILTERED}: ${definitions.get(column.id)?.header}`,
|
|
636
|
+
children: /*#__PURE__*/ jsx(FilterAlt, {
|
|
637
|
+
sx: {
|
|
638
|
+
color: 'action.active',
|
|
639
|
+
ml: '4px',
|
|
640
|
+
width: '18px',
|
|
641
|
+
height: '18px'
|
|
642
|
+
},
|
|
643
|
+
role: "img",
|
|
644
|
+
"aria-label": `${strings.TABLE_FILTERED}: ${definitions.get(column.id)?.header}`,
|
|
645
|
+
onClick: (event)=>event.stopPropagation()
|
|
646
|
+
})
|
|
647
|
+
})
|
|
648
|
+
]
|
|
649
|
+
});
|
|
650
|
+
return /*#__PURE__*/ jsxs(TableCell, {
|
|
651
|
+
sortDirection: column.getIsSorted() || false,
|
|
652
|
+
sx: (theme)=>({
|
|
653
|
+
...pinnedStyles(column, theme),
|
|
654
|
+
bgcolor: 'background.paper',
|
|
655
|
+
fontWeight: 'bold',
|
|
656
|
+
p: 2,
|
|
657
|
+
pt: '12px',
|
|
658
|
+
pb: filtersVisible ? '6.4px' : '9.6px',
|
|
659
|
+
verticalAlign: 'top',
|
|
660
|
+
'&:hover .MuiIconButton-root': {
|
|
661
|
+
opacity: 1
|
|
662
|
+
}
|
|
663
|
+
}),
|
|
664
|
+
children: [
|
|
665
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
666
|
+
display: "flex",
|
|
667
|
+
alignItems: "center",
|
|
668
|
+
sx: {
|
|
669
|
+
minHeight: '24px'
|
|
670
|
+
},
|
|
671
|
+
children: [
|
|
672
|
+
column.getCanSort() ? /*#__PURE__*/ jsx(TableSortLabel, {
|
|
673
|
+
active: !!column.getIsSorted(),
|
|
674
|
+
direction: column.getIsSorted() || 'asc',
|
|
675
|
+
IconComponent: column.getIsSorted() ? ArrowDownward : UnsortedIcon,
|
|
676
|
+
sx: (theme)=>({
|
|
677
|
+
fontWeight: 'inherit',
|
|
678
|
+
whiteSpace: definitions.get(column.id).header.length < 20 ? 'nowrap' : 'normal',
|
|
679
|
+
'& .MuiTableSortLabel-icon': {
|
|
680
|
+
color: `${'dark' === theme.palette.mode ? theme.palette.text.primary : theme.palette.text.secondary} !important`,
|
|
681
|
+
opacity: column.getIsSorted() ? 1 : 0.3,
|
|
682
|
+
width: '3ch',
|
|
683
|
+
m: 0
|
|
684
|
+
}
|
|
685
|
+
}),
|
|
686
|
+
onClick: column.getToggleSortingHandler(),
|
|
687
|
+
children: header
|
|
688
|
+
}) : header,
|
|
689
|
+
enableColumnActions && (column.getCanSort() || column.getCanFilter() || controlsEnabled) && /*#__PURE__*/ jsx(IconButton, {
|
|
690
|
+
size: "small",
|
|
691
|
+
sx: {
|
|
692
|
+
height: '2rem',
|
|
693
|
+
width: '2rem',
|
|
694
|
+
m: '-8px -4px',
|
|
695
|
+
opacity: 0.3,
|
|
696
|
+
transition: 'all 150ms'
|
|
697
|
+
},
|
|
698
|
+
"aria-label": `${strings.TABLE_COLUMN_ACTIONS}: ${definitions.get(column.id)?.header}`,
|
|
699
|
+
"aria-haspopup": "menu",
|
|
700
|
+
"aria-expanded": !!menuAnchor && menuColumnId === column.id,
|
|
701
|
+
onClick: (event)=>{
|
|
702
|
+
setMenuColumnId(column.id);
|
|
703
|
+
setMenuAnchor(event.currentTarget);
|
|
704
|
+
},
|
|
705
|
+
children: /*#__PURE__*/ jsx(MoreVert, {
|
|
706
|
+
sx: {
|
|
707
|
+
transform: 'scale(0.9)'
|
|
708
|
+
}
|
|
709
|
+
})
|
|
710
|
+
})
|
|
711
|
+
]
|
|
712
|
+
}),
|
|
713
|
+
filtersVisible && column.getCanFilter() && /*#__PURE__*/ jsx(ColumnFilter, {
|
|
714
|
+
column: column,
|
|
715
|
+
definition: definitions.get(column.id)
|
|
716
|
+
})
|
|
717
|
+
]
|
|
718
|
+
}, column.id);
|
|
719
|
+
})
|
|
720
|
+
})
|
|
721
|
+
}),
|
|
722
|
+
/*#__PURE__*/ jsxs(TableBody, {
|
|
723
|
+
children: [
|
|
724
|
+
rows.map((row, rowIndex)=>/*#__PURE__*/ jsx(TableRow, {
|
|
725
|
+
onClick: onRowClick ? ()=>onRowClick(row.original) : void 0,
|
|
726
|
+
sx: (theme)=>{
|
|
727
|
+
const background = theme.palette.background.default;
|
|
728
|
+
const hoverColor = alpha('dark' === theme.palette.mode ? lighten(background, 0.3) : darken(background, 0.3), 0.3);
|
|
729
|
+
return {
|
|
730
|
+
cursor: onRowClick ? 'pointer' : 'default',
|
|
731
|
+
'&:hover > td': {
|
|
732
|
+
backgroundImage: `linear-gradient(${hoverColor}, ${hoverColor})`
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
children: [
|
|
737
|
+
...row.getStartVisibleCells(),
|
|
738
|
+
...row.getCenterVisibleCells(),
|
|
739
|
+
...row.getEndVisibleCells()
|
|
740
|
+
].map((cell)=>{
|
|
741
|
+
const column = cell.column;
|
|
742
|
+
const definition = definitions.get(column.id);
|
|
743
|
+
const canEdit = ('function' == typeof definition.enableEditing ? definition.enableEditing(row) : definition.enableEditing ?? enableEditing) && enableEditing;
|
|
744
|
+
const value = cell.getValue();
|
|
745
|
+
return /*#__PURE__*/ jsx(TableCell, {
|
|
746
|
+
tabIndex: canEdit ? 0 : void 0,
|
|
747
|
+
onClick: canEdit ? (event)=>event.stopPropagation() : void 0,
|
|
748
|
+
onDoubleClick: canEdit ? ()=>setEditingCell({
|
|
749
|
+
id: cell.id
|
|
750
|
+
}) : void 0,
|
|
751
|
+
onKeyDown: canEdit ? (event)=>{
|
|
752
|
+
if ('Enter' === event.key || 'F2' === event.key) {
|
|
753
|
+
event.preventDefault();
|
|
754
|
+
setEditingCell({
|
|
755
|
+
id: cell.id
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
} : void 0,
|
|
759
|
+
sx: (theme)=>({
|
|
760
|
+
...pinnedStyles(column, theme),
|
|
761
|
+
borderBottom: 'none',
|
|
762
|
+
bgcolor: rowIndex % 2 === 0 ? 'TwClrBaseGray025' : 'background.paper',
|
|
763
|
+
cursor: canEdit ? 'pointer' : 'inherit',
|
|
764
|
+
outlineOffset: '-1px',
|
|
765
|
+
'&:hover': {
|
|
766
|
+
outline: canEdit ? '1px solid' : void 0,
|
|
767
|
+
outlineColor: 'grey.500'
|
|
768
|
+
}
|
|
769
|
+
}),
|
|
770
|
+
children: editingCell?.id === cell.id ? /*#__PURE__*/ jsx(EditableCellV2, {
|
|
771
|
+
cell: cell,
|
|
772
|
+
column: definition,
|
|
773
|
+
onClose: ()=>setEditingCell((current)=>current === editingCell ? null : current)
|
|
774
|
+
}, cell.id) : definition.Cell ? /*#__PURE__*/ jsx(definition.Cell, {
|
|
775
|
+
...cell.getContext()
|
|
776
|
+
}) : String(value ?? '')
|
|
777
|
+
}, cell.id);
|
|
778
|
+
})
|
|
779
|
+
}, row.id)),
|
|
780
|
+
!rows.length && /*#__PURE__*/ jsx(TableRow, {
|
|
781
|
+
children: /*#__PURE__*/ jsx(TableCell, {
|
|
782
|
+
colSpan: Math.max(1, visibleColumns.length),
|
|
783
|
+
children: strings.TABLE_NO_ROWS
|
|
784
|
+
})
|
|
785
|
+
})
|
|
786
|
+
]
|
|
787
|
+
})
|
|
788
|
+
]
|
|
789
|
+
})
|
|
790
|
+
}),
|
|
791
|
+
enablePagination && enableBottomToolbar && /*#__PURE__*/ jsx(TablePagination, {
|
|
792
|
+
component: "div",
|
|
793
|
+
sx: (theme)=>({
|
|
794
|
+
boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} inset`
|
|
795
|
+
}),
|
|
796
|
+
showFirstButton: true,
|
|
797
|
+
showLastButton: true,
|
|
798
|
+
count: table.getRowCount(),
|
|
799
|
+
page: table.state.pagination.pageIndex,
|
|
800
|
+
rowsPerPage: table.state.pagination.pageSize,
|
|
801
|
+
rowsPerPageOptions: Array.from(new Set([
|
|
802
|
+
table.state.pagination.pageSize,
|
|
803
|
+
10,
|
|
804
|
+
25,
|
|
805
|
+
50,
|
|
806
|
+
100
|
|
807
|
+
])).sort((a, b)=>a - b),
|
|
808
|
+
labelRowsPerPage: strings.TABLE_ROWS_PER_PAGE,
|
|
809
|
+
labelDisplayedRows: ({ from, to, count })=>`${from}–${to} / ${count}`,
|
|
810
|
+
getItemAriaLabel: (type)=>({
|
|
811
|
+
first: strings.TABLE_FIRST_PAGE,
|
|
812
|
+
last: strings.TABLE_LAST_PAGE,
|
|
813
|
+
next: strings.TABLE_NEXT_PAGE,
|
|
814
|
+
previous: strings.TABLE_PREVIOUS_PAGE
|
|
815
|
+
})[type],
|
|
816
|
+
onPageChange: (_, page)=>table.setPageIndex(page),
|
|
817
|
+
onRowsPerPageChange: (event)=>table.setPageSize(Number(event.target.value))
|
|
818
|
+
})
|
|
819
|
+
]
|
|
820
|
+
})
|
|
821
|
+
});
|
|
822
|
+
};
|
|
823
|
+
const components_EditableTableV2 = EditableTableV2;
|
|
824
|
+
export default components_EditableTableV2;
|