@dooherceg/material-react-table 4.1.7 → 4.1.9
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/README.md +0 -1
- package/dist/index.d.ts +36 -3
- package/dist/index.esm.js +1263 -1108
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1267 -1105
- package/dist/index.js.map +1 -1
- package/locales/de/index.esm.js +1 -0
- package/locales/de/index.js +1 -0
- package/locales/en/index.esm.js +1 -0
- package/locales/en/index.js +1 -0
- package/locales/fr/index.esm.js +1 -0
- package/locales/fr/index.js +1 -0
- package/locales/hr/index.esm.js +1 -0
- package/locales/hr/index.js +1 -0
- package/locales/nl/index.esm.js +1 -0
- package/locales/nl/index.js +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useMemo, useState, createElement, useRef, useId, useCallback, useEffect, createContext, useContext, forwardRef, Fragment as Fragment$1, useLayoutEffect, memo, useReducer, Suspense, lazy, useImperativeHandle } from 'react';
|
|
2
|
+
import { c } from 'react/compiler-runtime';
|
|
3
|
+
import IconButton from '@mui/material/IconButton';
|
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
5
|
+
import { useSelector, useCreateAtom } from '@tanstack/react-store';
|
|
6
|
+
import Menu from '@mui/material/Menu';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
import { keyframes, darken, lighten, alpha, useTheme } from '@mui/material/styles';
|
|
9
|
+
import { Subscribe, sortFns, flexRender as flexRender$1, constructRow, aggregationFns, makeStateUpdater, setStateSlice, tableFeatures, rowSortingFeature, columnGroupingFeature, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowPinningFeature, columnPinningFeature, columnVisibilityFeature, columnOrderingFeature, columnSizingFeature, columnResizingFeature, createSortedRowModel, createPaginatedRowModel, createExpandedRowModel, createGroupedRowModel, useTable, functionalUpdate } from '@tanstack/react-table';
|
|
10
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
11
|
+
import Radio from '@mui/material/Radio';
|
|
3
12
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
4
13
|
import Button from '@mui/material/Button';
|
|
5
14
|
import Dialog from '@mui/material/Dialog';
|
|
6
15
|
import DialogActions from '@mui/material/DialogActions';
|
|
7
16
|
import DialogContent from '@mui/material/DialogContent';
|
|
8
17
|
import DialogTitle from '@mui/material/DialogTitle';
|
|
9
|
-
import IconButton from '@mui/material/IconButton';
|
|
10
18
|
import Stack from '@mui/material/Stack';
|
|
11
|
-
import { c } from 'react/compiler-runtime';
|
|
12
19
|
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
13
|
-
import Tooltip from '@mui/material/Tooltip';
|
|
14
|
-
import { keyframes, darken, lighten, alpha, useTheme } from '@mui/material/styles';
|
|
15
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
20
|
import EditNoteIcon from '@mui/icons-material/EditNote';
|
|
17
21
|
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
18
22
|
import PrintIcon from '@mui/icons-material/Print';
|
|
19
|
-
import Checkbox from '@mui/material/Checkbox';
|
|
20
23
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
21
24
|
import Divider from '@mui/material/Divider';
|
|
22
25
|
import FormControl from '@mui/material/FormControl';
|
|
23
26
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
24
|
-
import Menu from '@mui/material/Menu';
|
|
25
27
|
import MenuItem from '@mui/material/MenuItem';
|
|
26
|
-
import Radio from '@mui/material/Radio';
|
|
27
28
|
import RadioGroup from '@mui/material/RadioGroup';
|
|
28
29
|
import Typography from '@mui/material/Typography';
|
|
29
30
|
import printJS from 'print-js';
|
|
30
31
|
import { enqueueSnackbar, closeSnackbar, useSnackbar, SnackbarProvider } from 'notistack';
|
|
31
|
-
import { useSelector, useCreateAtom } from '@tanstack/react-store';
|
|
32
32
|
import SubdirectoryArrowLeftIcon from '@mui/icons-material/SubdirectoryArrowLeft';
|
|
33
33
|
import VerticalAlignTopIcon from '@mui/icons-material/VerticalAlignTop';
|
|
34
34
|
import Box from '@mui/material/Box';
|
|
@@ -126,163 +126,133 @@ import AccordionSummary from '@mui/material/AccordionSummary';
|
|
|
126
126
|
import Modal from '@mui/material/Modal';
|
|
127
127
|
import AlertTitle from '@mui/material/AlertTitle';
|
|
128
128
|
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const getLeafColumns = cols => {
|
|
137
|
-
cols.forEach(col => {
|
|
138
|
-
if (col.columns) {
|
|
139
|
-
getLeafColumns(col.columns);
|
|
140
|
-
} else {
|
|
141
|
-
allLeafColumnDefs.push(col);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
getLeafColumns(columns);
|
|
146
|
-
return allLeafColumnDefs;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// Must run on the raw, user-authored column array — by the time TanStack
|
|
150
|
-
// resolves column.columnDef.size (via constructColumn's `{...defaultColumn,
|
|
151
|
-
// ...columnDef}` merge), a column the consumer never gave a size backfills
|
|
152
|
-
// MRT_DefaultColumn.size (180) directly into columnDef.size, indistinguishable
|
|
153
|
-
// from a column that explicitly asked for 180. Checking `size === undefined`
|
|
154
|
-
// here, before that merge happens, is the only point where the distinction
|
|
155
|
-
// still exists.
|
|
156
|
-
const getAutoSizeCandidateColumnIds = columnDefs => new Set(getAllLeafColumnDefs(columnDefs).filter(columnDef => columnDef.size === undefined).map(columnDef => getColumnId(columnDef)));
|
|
157
|
-
const prepareColumns = ({
|
|
158
|
-
columnDefs,
|
|
159
|
-
tableOptions
|
|
129
|
+
const MRT_RowActionMenu = ({
|
|
130
|
+
anchorEl,
|
|
131
|
+
row,
|
|
132
|
+
setAnchorEl,
|
|
133
|
+
staticRowIndex,
|
|
134
|
+
table,
|
|
135
|
+
...rest
|
|
160
136
|
}) => {
|
|
161
137
|
const {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//assign columnDefType
|
|
168
|
-
if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
|
|
169
|
-
if (columnDef.columns?.length) {
|
|
170
|
-
columnDef.columnDefType = 'group';
|
|
171
|
-
//recursively prepare columns if this is a group column
|
|
172
|
-
columnDef.columns = prepareColumns({
|
|
173
|
-
columnDefs: columnDef.columns,
|
|
174
|
-
tableOptions
|
|
175
|
-
});
|
|
176
|
-
} else if (columnDef.columnDefType === 'data') {
|
|
177
|
-
// Multi-aggregation arrays (e.g. aggregationFn: ['count', 'mean']) are
|
|
178
|
-
// handled natively by v9's rowAggregationFeature — it resolves each
|
|
179
|
-
// registered name and returns a keyed result object, so no manual
|
|
180
|
-
// mapping is needed here anymore (v8 required it).
|
|
181
|
-
|
|
182
|
-
//assign sortFns
|
|
183
|
-
if (Object.keys(MRT_SortingFns).includes(columnDef.sortFn)) {
|
|
184
|
-
// @ts-expect-error - resolving the registered string name to its function
|
|
185
|
-
columnDef.sortFn = MRT_SortingFns[columnDef.sortFn];
|
|
186
|
-
}
|
|
187
|
-
} else if (columnDef.columnDefType === 'display') {
|
|
188
|
-
columnDef = {
|
|
189
|
-
...defaultDisplayColumn,
|
|
190
|
-
...columnDef,
|
|
191
|
-
onClickIconTypeColumn: undefined
|
|
192
|
-
};
|
|
138
|
+
options: {
|
|
139
|
+
mrtTheme: {
|
|
140
|
+
menuBackgroundColor
|
|
141
|
+
},
|
|
142
|
+
renderRowActionMenuItems
|
|
193
143
|
}
|
|
194
|
-
|
|
144
|
+
} = table;
|
|
145
|
+
const density = useSelector(table.store, state => state.density);
|
|
146
|
+
const menuItems = useMemo(() => {
|
|
147
|
+
const items = [];
|
|
148
|
+
const rowActionMenuItems = renderRowActionMenuItems?.({
|
|
149
|
+
closeMenu: () => setAnchorEl(null),
|
|
150
|
+
row,
|
|
151
|
+
staticRowIndex,
|
|
152
|
+
table
|
|
153
|
+
});
|
|
154
|
+
if (rowActionMenuItems?.length) items.push(...rowActionMenuItems);
|
|
155
|
+
return items;
|
|
156
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
157
|
+
if (!menuItems.length) return null;
|
|
158
|
+
return /*#__PURE__*/jsx(Menu, {
|
|
159
|
+
MenuListProps: {
|
|
160
|
+
dense: density === 'compact',
|
|
161
|
+
sx: {
|
|
162
|
+
backgroundColor: menuBackgroundColor
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
anchorEl: anchorEl,
|
|
166
|
+
disableScrollLock: true,
|
|
167
|
+
onClick: event => event.stopPropagation(),
|
|
168
|
+
onClose: () => setAnchorEl(null),
|
|
169
|
+
open: !!anchorEl,
|
|
170
|
+
...rest,
|
|
171
|
+
children: menuItems
|
|
195
172
|
});
|
|
196
173
|
};
|
|
197
|
-
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
198
|
-
if (draggedColumn.getCanPin()) {
|
|
199
|
-
draggedColumn.pin(targetColumn.getIsPinned());
|
|
200
|
-
}
|
|
201
|
-
const newColumnOrder = [...columnOrder];
|
|
202
|
-
newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
203
|
-
return newColumnOrder;
|
|
204
|
-
};
|
|
205
174
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const {
|
|
214
|
-
defaultDisplayColumn,
|
|
215
|
-
displayColumnDefOptions,
|
|
216
|
-
localization
|
|
217
|
-
} = tableOptions;
|
|
175
|
+
/** Resolved column limits shared by measurement, resizing, and cell layout. */
|
|
176
|
+
const getColumnSizeBounds = ({
|
|
177
|
+
minSize = 40,
|
|
178
|
+
maxSize = 1000
|
|
179
|
+
}) => {
|
|
180
|
+
const min = Number.isFinite(minSize) ? Math.max(0, minSize) : 40;
|
|
181
|
+
const max = Number.isNaN(maxSize) ? 1000 : Math.max(min, maxSize);
|
|
218
182
|
return {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
size,
|
|
222
|
-
...columnSpecificDefaults,
|
|
223
|
-
...displayColumnDefOptions?.[id],
|
|
224
|
-
id
|
|
183
|
+
minSize: min,
|
|
184
|
+
maxSize: max
|
|
225
185
|
};
|
|
226
|
-
}
|
|
227
|
-
const showRowPinningColumn = tableOptions => {
|
|
228
|
-
const {
|
|
229
|
-
enableRowPinning,
|
|
230
|
-
rowPinningDisplayMode
|
|
231
|
-
} = tableOptions;
|
|
232
|
-
return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
|
|
233
|
-
};
|
|
234
|
-
const showRowExpandColumn = tableOptions => {
|
|
235
|
-
const {
|
|
236
|
-
enableExpanding,
|
|
237
|
-
enableGrouping,
|
|
238
|
-
renderDetailPanel,
|
|
239
|
-
state: {
|
|
240
|
-
grouping
|
|
241
|
-
}
|
|
242
|
-
} = tableOptions;
|
|
243
|
-
return !!(enableExpanding || enableGrouping && grouping?.length || renderDetailPanel);
|
|
244
186
|
};
|
|
245
|
-
|
|
187
|
+
|
|
188
|
+
// `el` normally has an explicit width/min-width/flex-basis (driven by the
|
|
189
|
+
// column's size CSS var), so nothing overflows and `getBoundingClientRect`
|
|
190
|
+
// just reports that forced size back — and `min-width` alone would otherwise
|
|
191
|
+
// stop it from ever shrinking below the current (large) column size.
|
|
192
|
+
// Temporarily switching to `max-content` with min-width/grow/shrink zeroed
|
|
193
|
+
// out lets the browser lay it out at its natural content size instead — then
|
|
194
|
+
// the inline style is restored before this task yields, so there's no
|
|
195
|
+
// visible flash.
|
|
196
|
+
const measureIntrinsicWidth = el => {
|
|
246
197
|
const {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
198
|
+
width,
|
|
199
|
+
minWidth,
|
|
200
|
+
maxWidth,
|
|
201
|
+
flexBasis,
|
|
202
|
+
flexGrow,
|
|
203
|
+
flexShrink
|
|
204
|
+
} = el.style;
|
|
205
|
+
el.style.width = 'max-content';
|
|
206
|
+
el.style.minWidth = '0';
|
|
207
|
+
el.style.maxWidth = 'none';
|
|
208
|
+
el.style.flexBasis = 'auto';
|
|
209
|
+
el.style.flexGrow = '0';
|
|
210
|
+
el.style.flexShrink = '0';
|
|
211
|
+
const measured = Math.ceil(el.getBoundingClientRect().width);
|
|
212
|
+
el.style.width = width;
|
|
213
|
+
el.style.minWidth = minWidth;
|
|
214
|
+
el.style.maxWidth = maxWidth;
|
|
215
|
+
el.style.flexBasis = flexBasis;
|
|
216
|
+
el.style.flexGrow = flexGrow;
|
|
217
|
+
el.style.flexShrink = flexShrink;
|
|
218
|
+
return measured;
|
|
251
219
|
};
|
|
252
|
-
const showRowSelectionColumn = tableOptions => !!tableOptions.enableRowSelection;
|
|
253
|
-
const showRowNumbersColumn = tableOptions => !!tableOptions.enableRowNumbers;
|
|
254
|
-
const showRowSpacerColumn = tableOptions => tableOptions.layoutMode === 'grid-no-grow';
|
|
255
|
-
const getLeadingDisplayColumnIds = tableOptions => [showRowPinningColumn(tableOptions) && 'mrt-row-pin', tableOptions.positionActionsColumn === 'first' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'first' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSelectionColumn(tableOptions) && '__check__', showRowNumbersColumn(tableOptions) && 'mrt-row-numbers'].filter(Boolean);
|
|
256
|
-
const getTrailingDisplayColumnIds = tableOptions => [tableOptions.positionActionsColumn === 'last' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'last' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSpacerColumn(tableOptions) && 'mrt-row-spacer'].filter(Boolean);
|
|
257
|
-
|
|
258
|
-
/** The internal ID used by TanStack Table for the row-selection checkbox column */
|
|
259
|
-
const CHECKBOX_DISPLAY_COLUMN_ID = '__check__';
|
|
260
220
|
|
|
261
221
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
222
|
+
* The single measurement this library uses anywhere it decides "what's the
|
|
223
|
+
* right width for this column's current content" — shared by the resize
|
|
224
|
+
* handle's double-click autosize and the initial autosize effect
|
|
225
|
+
* (MRT_AutoSizeColumnsEffect), so both agree on the exact same answer.
|
|
226
|
+
*
|
|
227
|
+
* Driven purely by body cell content: the header title never contributes,
|
|
228
|
+
* so a long header simply ellipsizes when its values are narrower.
|
|
229
|
+
*
|
|
230
|
+
* Only the currently rendered (visible, due to row virtualization) body
|
|
231
|
+
* cells can be measured — a full-dataset autosize would require rendering
|
|
232
|
+
* every row off-screen, which defeats the point of virtualization.
|
|
265
233
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
234
|
+
// Absorbs the sub-pixel rounding gap between measurement time (forced
|
|
235
|
+
// `max-content`, read via `Math.ceil`) and final render time (the actual
|
|
236
|
+
// `calc(var(--col-x-size) * 1px)` width) — without it, a column can land
|
|
237
|
+
// exactly 1px short of its own measured content and still clip/ellipsize.
|
|
238
|
+
const MEASUREMENT_SAFETY_MARGIN_PX = 2;
|
|
239
|
+
const computeAutoSizedColumnWidth = ({
|
|
240
|
+
bodyCellEls,
|
|
241
|
+
maxSize,
|
|
242
|
+
minSize
|
|
243
|
+
}) => {
|
|
244
|
+
let contentWidth = 0;
|
|
245
|
+
for (const cellEl of bodyCellEls ?? []) {
|
|
246
|
+
contentWidth = Math.max(contentWidth, measureIntrinsicWidth(cellEl));
|
|
269
247
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
} = tableOptions;
|
|
280
|
-
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
|
281
|
-
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
|
282
|
-
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map(columnDef => getColumnId(columnDef));
|
|
283
|
-
let allLeafColumnDefIds = reset ? defaultColumnDefIds : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
|
284
|
-
allLeafColumnDefIds = allLeafColumnDefIds.filter(colId => !leadingDisplayColIds.includes(colId) && !trailingDisplayColIds.includes(colId));
|
|
285
|
-
return [...leadingDisplayColIds, ...allLeafColumnDefIds, ...trailingDisplayColIds];
|
|
248
|
+
if (contentWidth > 0) {
|
|
249
|
+
contentWidth = Math.ceil(contentWidth) + MEASUREMENT_SAFETY_MARGIN_PX;
|
|
250
|
+
}
|
|
251
|
+
const bounds = getColumnSizeBounds({
|
|
252
|
+
minSize,
|
|
253
|
+
maxSize
|
|
254
|
+
});
|
|
255
|
+
return Math.min(Math.max(contentWidth, bounds.minSize), bounds.maxSize);
|
|
286
256
|
};
|
|
287
257
|
|
|
288
258
|
const parseFromValuesOrFunc = (fn, arg) => fn instanceof Function ? fn(arg) : fn;
|
|
@@ -304,116 +274,401 @@ const getValueAndLabel = option => {
|
|
|
304
274
|
};
|
|
305
275
|
};
|
|
306
276
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
277
|
+
// Loading indicators fade in after a short delay
|
|
278
|
+
// (`animation: ${mrtDelayedFadeIn}`), so fast responses don't flash them.
|
|
279
|
+
const mrtDelayedFadeIn = `${keyframes`
|
|
280
|
+
from { opacity: 0; }
|
|
281
|
+
to { opacity: 1; }
|
|
282
|
+
`} 150ms ease-out 200ms both`;
|
|
283
|
+
const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
284
|
+
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
285
|
+
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
286
|
+
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
287
|
+
return {
|
|
288
|
+
baseBackgroundColor,
|
|
289
|
+
cellNavigationOutlineColor: muiTheme.palette.primary.main,
|
|
290
|
+
draggingBorderColor: muiTheme.palette.primary.main,
|
|
291
|
+
matchHighlightColor: muiTheme.palette.mode === 'dark' ? darken(muiTheme.palette.warning.dark, 0.25) : lighten(muiTheme.palette.warning.light, 0.5),
|
|
292
|
+
menuBackgroundColor: lighten(baseBackgroundColor, 0.07),
|
|
293
|
+
pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1),
|
|
294
|
+
selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2),
|
|
295
|
+
...mrtThemeOverrides
|
|
296
|
+
};
|
|
325
297
|
};
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
298
|
+
const commonCellBeforeAfterStyles = {
|
|
299
|
+
content: '""',
|
|
300
|
+
height: '100%',
|
|
301
|
+
left: 0,
|
|
302
|
+
position: 'absolute',
|
|
303
|
+
top: 0,
|
|
304
|
+
width: '100%',
|
|
305
|
+
zIndex: -1
|
|
306
|
+
};
|
|
307
|
+
const getCommonPinnedCellStyles = ({
|
|
308
|
+
column,
|
|
309
|
+
table,
|
|
310
|
+
theme
|
|
329
311
|
}) => {
|
|
330
312
|
const {
|
|
331
|
-
|
|
332
|
-
|
|
313
|
+
baseBackgroundColor
|
|
314
|
+
} = table.options.mrtTheme;
|
|
315
|
+
return {
|
|
316
|
+
'&[data-pinned="true"]': {
|
|
317
|
+
'&:before': {
|
|
318
|
+
backgroundColor: baseBackgroundColor,
|
|
319
|
+
// Draw only the edge facing the center region, including when other
|
|
320
|
+
// pinned columns are hidden. Logical borders also handle RTL layouts.
|
|
321
|
+
borderInlineEnd: column?.getIsPinned() === 'start' && column.getIsLastColumn('start') ? `1px solid ${theme.palette.divider}` : undefined,
|
|
322
|
+
borderInlineStart: column?.getIsPinned() === 'end' && column.getIsFirstColumn('end') ? `1px solid ${theme.palette.divider}` : undefined,
|
|
323
|
+
boxSizing: 'border-box',
|
|
324
|
+
...commonCellBeforeAfterStyles
|
|
325
|
+
}
|
|
333
326
|
}
|
|
334
|
-
}
|
|
335
|
-
return row.getIsSelected() || parseFromValuesOrFunc(enableRowSelection, row) && row.getCanSelectSubRows() && row.getIsAllSubRowsSelected();
|
|
327
|
+
};
|
|
336
328
|
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
329
|
+
|
|
330
|
+
// Shared by cell styles and the imperative sizing subscription: resizing must
|
|
331
|
+
// update growth even when memoized cells do not render again.
|
|
332
|
+
const getColumnGrowWeight = (column, table) => {
|
|
333
|
+
const {
|
|
334
|
+
columnDef
|
|
335
|
+
} = column;
|
|
336
|
+
const sizing = table.getState().columnSizing[column.id];
|
|
337
|
+
const hasUserSize = sizing !== undefined && sizing !== table.refs.autoSizedColumnWidthsRef.current[column.id];
|
|
338
|
+
if (column.getIsPinned() || !table.refs.autoSizeColumnIdsRef.current.has(column.id) || hasUserSize) return 0;
|
|
339
|
+
if (typeof columnDef.grow === 'number') return Math.max(0, columnDef.grow);
|
|
340
|
+
return columnDef.grow === false ? 0 : 1;
|
|
341
|
+
};
|
|
342
|
+
const getCommonMRTCellStyles = ({
|
|
343
|
+
column,
|
|
344
|
+
header,
|
|
345
|
+
isDraggingColumn,
|
|
346
|
+
isHoveredColumn,
|
|
347
|
+
table,
|
|
348
|
+
tableCellProps,
|
|
349
|
+
theme
|
|
350
|
+
}) => {
|
|
342
351
|
const {
|
|
343
|
-
getState,
|
|
344
352
|
options: {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
enableRowPinning,
|
|
348
|
-
manualPagination,
|
|
349
|
-
rowPinningDisplayMode
|
|
350
|
-
},
|
|
351
|
-
refs: {
|
|
352
|
-
allSelectableRowIdsRef,
|
|
353
|
-
lastSelectedRowId
|
|
353
|
+
enableColumnVirtualization,
|
|
354
|
+
layoutMode
|
|
354
355
|
}
|
|
355
356
|
} = table;
|
|
356
357
|
const {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
} =
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
lastSelectedRowId.current = row.id;
|
|
381
|
-
return;
|
|
358
|
+
columnDef
|
|
359
|
+
} = column;
|
|
360
|
+
const {
|
|
361
|
+
columnDefType
|
|
362
|
+
} = columnDef;
|
|
363
|
+
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
364
|
+
const {
|
|
365
|
+
minSize,
|
|
366
|
+
maxSize
|
|
367
|
+
} = getColumnSizeBounds(columnDef);
|
|
368
|
+
const sizeVar = `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`;
|
|
369
|
+
const boundedSize = Number.isFinite(maxSize) ? `clamp(${minSize}px, ${sizeVar}, ${maxSize}px)` : `max(${minSize}px, ${sizeVar})`;
|
|
370
|
+
const widthStyles = {
|
|
371
|
+
// Group headers span already-bounded child columns; the default leaf
|
|
372
|
+
// maximum must not truncate the sum of their widths.
|
|
373
|
+
maxWidth: columnDefType === 'group' ? sizeVar : Number.isFinite(maxSize) ? `${maxSize}px` : 'none',
|
|
374
|
+
minWidth: columnDefType === 'group' ? sizeVar : boundedSize,
|
|
375
|
+
width: columnDefType === 'group' ? sizeVar : boundedSize
|
|
376
|
+
};
|
|
377
|
+
if (layoutMode === 'grid' || layoutMode === 'grid-no-grow') {
|
|
378
|
+
const weight = getColumnGrowWeight(column, table);
|
|
379
|
+
const growVar = `var(--col-${parseCSSVarId(column.id)}-grow, ${weight})`;
|
|
380
|
+
widthStyles.flex = `${growVar} 0 auto`;
|
|
382
381
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
382
|
+
const pinnedStyles = isColumnPinned ? {
|
|
383
|
+
...getCommonPinnedCellStyles({
|
|
384
|
+
column,
|
|
385
|
+
table,
|
|
386
|
+
theme
|
|
387
|
+
}),
|
|
388
|
+
// Logical CSS insets (not left/right) so pinning stays correct in RTL
|
|
389
|
+
// without branching on theme.direction here.
|
|
390
|
+
insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
|
|
391
|
+
position: 'sticky',
|
|
392
|
+
insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
|
|
393
|
+
} : {};
|
|
394
|
+
return {
|
|
395
|
+
backgroundColor: 'inherit',
|
|
396
|
+
backgroundImage: 'inherit',
|
|
397
|
+
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
|
398
|
+
justifyContent: columnDefType === 'group' ? 'center' : layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
|
|
399
|
+
opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1,
|
|
400
|
+
position: 'relative',
|
|
401
|
+
transition: enableColumnVirtualization ? 'none' : `padding 150ms ease-in-out`,
|
|
402
|
+
zIndex: column.getIsResizing() || isDraggingColumn ? 2 : columnDefType !== 'group' && isColumnPinned ? 1 : 0,
|
|
403
|
+
'&:focus-visible': {
|
|
404
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
405
|
+
outlineOffset: '-2px'
|
|
406
|
+
},
|
|
407
|
+
...pinnedStyles,
|
|
408
|
+
...widthStyles,
|
|
409
|
+
...parseFromValuesOrFunc(tableCellProps?.sx, theme)
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
const getCommonToolbarStyles = ({
|
|
413
|
+
table
|
|
414
|
+
}) => ({
|
|
415
|
+
alignItems: 'flex-start',
|
|
416
|
+
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
417
|
+
display: 'grid',
|
|
418
|
+
flexWrap: 'wrap-reverse',
|
|
419
|
+
position: 'relative',
|
|
420
|
+
transition: 'all 150ms ease-in-out',
|
|
421
|
+
zIndex: 1
|
|
422
|
+
});
|
|
423
|
+
const flipIconStyles = theme => theme.direction === 'rtl' ? {
|
|
424
|
+
style: {
|
|
425
|
+
transform: 'scaleX(-1)'
|
|
409
426
|
}
|
|
427
|
+
} : undefined;
|
|
428
|
+
const getCommonTooltipProps = placement => ({
|
|
429
|
+
disableInteractive: true,
|
|
430
|
+
enterDelay: 1000,
|
|
431
|
+
enterNextDelay: 1000,
|
|
432
|
+
placement
|
|
433
|
+
});
|
|
410
434
|
|
|
411
|
-
|
|
412
|
-
|
|
435
|
+
// Stable, row-scoped hook for e2e/unit tests to target a specific default
|
|
436
|
+
// row action (e.g. edit, delete) without relying on DOM order or icon markup.
|
|
437
|
+
const getRowActionTestId = (rowId, actionName) => `mrt-row-${rowId}-${actionName}-action`;
|
|
413
438
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
439
|
+
const commonIconButtonStyles = {
|
|
440
|
+
'&:hover': {
|
|
441
|
+
opacity: 1
|
|
442
|
+
},
|
|
443
|
+
height: '2rem',
|
|
444
|
+
ml: '10px',
|
|
445
|
+
opacity: 0.5,
|
|
446
|
+
transition: 'opacity 150ms',
|
|
447
|
+
width: '2rem'
|
|
448
|
+
};
|
|
449
|
+
const MRT_ToggleRowActionMenuButton = t0 => {
|
|
450
|
+
const $ = c(20);
|
|
451
|
+
let cell;
|
|
452
|
+
let rest;
|
|
453
|
+
let row;
|
|
454
|
+
let staticRowIndex;
|
|
455
|
+
let table;
|
|
456
|
+
if ($[0] !== t0) {
|
|
457
|
+
({
|
|
458
|
+
cell,
|
|
459
|
+
row,
|
|
460
|
+
staticRowIndex,
|
|
461
|
+
table,
|
|
462
|
+
...rest
|
|
463
|
+
} = t0);
|
|
464
|
+
$[0] = t0;
|
|
465
|
+
$[1] = cell;
|
|
466
|
+
$[2] = rest;
|
|
467
|
+
$[3] = row;
|
|
468
|
+
$[4] = staticRowIndex;
|
|
469
|
+
$[5] = table;
|
|
470
|
+
} else {
|
|
471
|
+
cell = $[1];
|
|
472
|
+
rest = $[2];
|
|
473
|
+
row = $[3];
|
|
474
|
+
staticRowIndex = $[4];
|
|
475
|
+
table = $[5];
|
|
476
|
+
}
|
|
477
|
+
const {
|
|
478
|
+
options: t1
|
|
479
|
+
} = table;
|
|
480
|
+
const {
|
|
481
|
+
icons: t2,
|
|
482
|
+
localization,
|
|
483
|
+
renderRowActionMenuItems,
|
|
484
|
+
renderRowActions
|
|
485
|
+
} = t1;
|
|
486
|
+
const {
|
|
487
|
+
MoreHorizIcon
|
|
488
|
+
} = t2;
|
|
489
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
490
|
+
let t3;
|
|
491
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
492
|
+
t3 = event => {
|
|
493
|
+
event.stopPropagation();
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
setAnchorEl(event.currentTarget);
|
|
496
|
+
};
|
|
497
|
+
$[6] = t3;
|
|
498
|
+
} else {
|
|
499
|
+
t3 = $[6];
|
|
500
|
+
}
|
|
501
|
+
const handleOpenRowActionMenu = t3;
|
|
502
|
+
let t4;
|
|
503
|
+
if ($[7] !== MoreHorizIcon || $[8] !== anchorEl || $[9] !== cell || $[10] !== localization || $[11] !== renderRowActionMenuItems || $[12] !== renderRowActions || $[13] !== rest || $[14] !== row || $[15] !== staticRowIndex || $[16] !== table) {
|
|
504
|
+
t4 = renderRowActions ? renderRowActions({
|
|
505
|
+
cell,
|
|
506
|
+
row,
|
|
507
|
+
staticRowIndex,
|
|
508
|
+
table
|
|
509
|
+
}) : renderRowActionMenuItems?.({
|
|
510
|
+
closeMenu: _temp$B,
|
|
511
|
+
row,
|
|
512
|
+
staticRowIndex,
|
|
513
|
+
table
|
|
514
|
+
})?.length ? /*#__PURE__*/jsxs(Fragment, {
|
|
515
|
+
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
516
|
+
...getCommonTooltipProps(),
|
|
517
|
+
title: localization.rowActions,
|
|
518
|
+
children: /*#__PURE__*/jsx(IconButton, {
|
|
519
|
+
"aria-label": localization.rowActions,
|
|
520
|
+
onClick: handleOpenRowActionMenu,
|
|
521
|
+
size: "small",
|
|
522
|
+
sx: commonIconButtonStyles,
|
|
523
|
+
...rest,
|
|
524
|
+
children: /*#__PURE__*/jsx(MoreHorizIcon, {})
|
|
525
|
+
})
|
|
526
|
+
}), /*#__PURE__*/jsx(MRT_RowActionMenu, {
|
|
527
|
+
anchorEl: anchorEl,
|
|
528
|
+
row: row,
|
|
529
|
+
setAnchorEl: setAnchorEl,
|
|
530
|
+
staticRowIndex: staticRowIndex,
|
|
531
|
+
table: table
|
|
532
|
+
})]
|
|
533
|
+
}) : null;
|
|
534
|
+
$[7] = MoreHorizIcon;
|
|
535
|
+
$[8] = anchorEl;
|
|
536
|
+
$[9] = cell;
|
|
537
|
+
$[10] = localization;
|
|
538
|
+
$[11] = renderRowActionMenuItems;
|
|
539
|
+
$[12] = renderRowActions;
|
|
540
|
+
$[13] = rest;
|
|
541
|
+
$[14] = row;
|
|
542
|
+
$[15] = staticRowIndex;
|
|
543
|
+
$[16] = table;
|
|
544
|
+
$[17] = t4;
|
|
545
|
+
} else {
|
|
546
|
+
t4 = $[17];
|
|
547
|
+
}
|
|
548
|
+
let t5;
|
|
549
|
+
if ($[18] !== t4) {
|
|
550
|
+
t5 = /*#__PURE__*/jsx(Fragment, {
|
|
551
|
+
children: t4
|
|
552
|
+
});
|
|
553
|
+
$[18] = t4;
|
|
554
|
+
$[19] = t5;
|
|
555
|
+
} else {
|
|
556
|
+
t5 = $[19];
|
|
557
|
+
}
|
|
558
|
+
return t5;
|
|
559
|
+
};
|
|
560
|
+
function _temp$B() {}
|
|
561
|
+
|
|
562
|
+
const getMRT_Rows = (table, all) => {
|
|
563
|
+
const {
|
|
564
|
+
getCenterRows,
|
|
565
|
+
getPrePaginatedRowModel,
|
|
566
|
+
getRowModel,
|
|
567
|
+
getTopRows,
|
|
568
|
+
options: {
|
|
569
|
+
enableRowPinning,
|
|
570
|
+
rowPinningDisplayMode
|
|
571
|
+
}
|
|
572
|
+
} = table;
|
|
573
|
+
let rows = !enableRowPinning || rowPinningDisplayMode?.includes('sticky') ? all ? getPrePaginatedRowModel().rows : getRowModel().rows : getCenterRows();
|
|
574
|
+
// row pinning adjustments
|
|
575
|
+
if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
|
|
576
|
+
const centerPinnedRowIds = rows.filter(row => row.getIsPinned()).map(r => r.id);
|
|
577
|
+
rows = [...getTopRows().filter(row => !centerPinnedRowIds.includes(row.id)), ...rows];
|
|
578
|
+
}
|
|
579
|
+
return rows;
|
|
580
|
+
};
|
|
581
|
+
const getIsRowSelected = ({
|
|
582
|
+
row,
|
|
583
|
+
table
|
|
584
|
+
}) => {
|
|
585
|
+
const {
|
|
586
|
+
options: {
|
|
587
|
+
enableRowSelection
|
|
588
|
+
}
|
|
589
|
+
} = table;
|
|
590
|
+
return row.getIsSelected() || parseFromValuesOrFunc(enableRowSelection, row) && row.getCanSelectSubRows() && row.getIsAllSubRowsSelected();
|
|
591
|
+
};
|
|
592
|
+
const getMRT_RowSelectionHandler = ({
|
|
593
|
+
row,
|
|
594
|
+
staticRowIndex = 0,
|
|
595
|
+
table
|
|
596
|
+
}) => (event, value) => {
|
|
597
|
+
const {
|
|
598
|
+
getState,
|
|
599
|
+
options: {
|
|
600
|
+
enableBatchRowSelection,
|
|
601
|
+
enableMultiRowSelection,
|
|
602
|
+
enableRowPinning,
|
|
603
|
+
manualPagination,
|
|
604
|
+
rowPinningDisplayMode
|
|
605
|
+
},
|
|
606
|
+
refs: {
|
|
607
|
+
allSelectableRowIdsRef,
|
|
608
|
+
lastSelectedRowId
|
|
609
|
+
}
|
|
610
|
+
} = table;
|
|
611
|
+
const {
|
|
612
|
+
pagination: {
|
|
613
|
+
pageIndex,
|
|
614
|
+
pageSize
|
|
615
|
+
}
|
|
616
|
+
} = getState();
|
|
617
|
+
const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
|
|
618
|
+
const wasCurrentRowChecked = getIsRowSelected({
|
|
619
|
+
row,
|
|
620
|
+
table
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// ── Special case: deselecting a row while "select all pages" is active ────
|
|
624
|
+
// Per spec: deselecting any single row while in global-select-all mode must
|
|
625
|
+
// reset the selection to only the current page rows, minus the clicked row.
|
|
626
|
+
if (allSelectableRowIdsRef.current.length > 0 && wasCurrentRowChecked) {
|
|
627
|
+
allSelectableRowIdsRef.current = [];
|
|
628
|
+
const newSelection = {};
|
|
629
|
+
table.getPaginatedRowModel().rows.forEach(pageRow => {
|
|
630
|
+
if (pageRow.id !== row.id && pageRow.getCanSelect()) {
|
|
631
|
+
newSelection[pageRow.id] = true;
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
table.setRowSelection(newSelection);
|
|
635
|
+
lastSelectedRowId.current = row.id;
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// toggle selection of this row (normal path)
|
|
640
|
+
row.toggleSelected(value ?? !wasCurrentRowChecked);
|
|
641
|
+
const changedRowIds = new Set([row.id]);
|
|
642
|
+
|
|
643
|
+
// if shift key is pressed, select all rows between last selected and this one
|
|
644
|
+
if (enableBatchRowSelection && enableMultiRowSelection && event.nativeEvent.shiftKey && lastSelectedRowId.current !== null) {
|
|
645
|
+
const rows = getMRT_Rows(table, true);
|
|
646
|
+
const lastIndex = rows.findIndex(r => r.id === lastSelectedRowId.current);
|
|
647
|
+
if (lastIndex !== -1) {
|
|
648
|
+
const isLastIndexChecked = getIsRowSelected({
|
|
649
|
+
row: rows?.[lastIndex],
|
|
650
|
+
table
|
|
651
|
+
});
|
|
652
|
+
const currentIndex = staticRowIndex + paginationOffset;
|
|
653
|
+
const [start, end] = lastIndex < currentIndex ? [lastIndex, currentIndex] : [currentIndex, lastIndex];
|
|
654
|
+
|
|
655
|
+
// toggle selection of all rows between last selected and this one
|
|
656
|
+
// but only if the last selected row is not the same as the current one
|
|
657
|
+
if (wasCurrentRowChecked !== isLastIndexChecked) {
|
|
658
|
+
for (let i = start; i <= end; i++) {
|
|
659
|
+
rows[i].toggleSelected(!wasCurrentRowChecked);
|
|
660
|
+
changedRowIds.add(rows[i].id);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// record the last selected row id
|
|
667
|
+
lastSelectedRowId.current = row.id;
|
|
668
|
+
|
|
669
|
+
// if all sub rows were selected, unselect them
|
|
670
|
+
if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
|
|
671
|
+
row.subRows?.forEach(r => r.toggleSelected(false));
|
|
417
672
|
}
|
|
418
673
|
if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
|
|
419
674
|
changedRowIds.forEach(rowId => {
|
|
@@ -468,265 +723,465 @@ const getIsAllPagesSelectionActive = (table, rowSelection) => {
|
|
|
468
723
|
return table.getIsAllRowsSelected();
|
|
469
724
|
};
|
|
470
725
|
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
maxSize: max
|
|
496
|
-
};
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
// `el` normally has an explicit width/min-width/flex-basis (driven by the
|
|
500
|
-
// column's size CSS var), so nothing overflows and `getBoundingClientRect`
|
|
501
|
-
// just reports that forced size back — and `min-width` alone would otherwise
|
|
502
|
-
// stop it from ever shrinking below the current (large) column size.
|
|
503
|
-
// Temporarily switching to `max-content` with min-width/grow/shrink zeroed
|
|
504
|
-
// out lets the browser lay it out at its natural content size instead — then
|
|
505
|
-
// the inline style is restored before this task yields, so there's no
|
|
506
|
-
// visible flash.
|
|
507
|
-
const measureIntrinsicWidth = el => {
|
|
726
|
+
const MRT_SelectCheckbox = t0 => {
|
|
727
|
+
const $ = c(32);
|
|
728
|
+
let rest;
|
|
729
|
+
let row;
|
|
730
|
+
let staticRowIndex;
|
|
731
|
+
let table;
|
|
732
|
+
if ($[0] !== t0) {
|
|
733
|
+
({
|
|
734
|
+
row,
|
|
735
|
+
staticRowIndex,
|
|
736
|
+
table,
|
|
737
|
+
...rest
|
|
738
|
+
} = t0);
|
|
739
|
+
$[0] = t0;
|
|
740
|
+
$[1] = rest;
|
|
741
|
+
$[2] = row;
|
|
742
|
+
$[3] = staticRowIndex;
|
|
743
|
+
$[4] = table;
|
|
744
|
+
} else {
|
|
745
|
+
rest = $[1];
|
|
746
|
+
row = $[2];
|
|
747
|
+
staticRowIndex = $[3];
|
|
748
|
+
table = $[4];
|
|
749
|
+
}
|
|
508
750
|
const {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
el.style.flexBasis = flexBasis;
|
|
527
|
-
el.style.flexGrow = flexGrow;
|
|
528
|
-
el.style.flexShrink = flexShrink;
|
|
529
|
-
return measured;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* The single measurement this library uses anywhere it decides "what's the
|
|
534
|
-
* right width for this column's current content" — shared by the resize
|
|
535
|
-
* handle's double-click autosize and the initial autosize effect
|
|
536
|
-
* (MRT_AutoSizeColumnsEffect), so both agree on the exact same answer.
|
|
537
|
-
*
|
|
538
|
-
* Driven purely by body cell content: the header title never contributes,
|
|
539
|
-
* so a long header simply ellipsizes when its values are narrower.
|
|
540
|
-
*
|
|
541
|
-
* Only the currently rendered (visible, due to row virtualization) body
|
|
542
|
-
* cells can be measured — a full-dataset autosize would require rendering
|
|
543
|
-
* every row off-screen, which defeats the point of virtualization.
|
|
544
|
-
*/
|
|
545
|
-
// Absorbs the sub-pixel rounding gap between measurement time (forced
|
|
546
|
-
// `max-content`, read via `Math.ceil`) and final render time (the actual
|
|
547
|
-
// `calc(var(--col-x-size) * 1px)` width) — without it, a column can land
|
|
548
|
-
// exactly 1px short of its own measured content and still clip/ellipsize.
|
|
549
|
-
const MEASUREMENT_SAFETY_MARGIN_PX = 2;
|
|
550
|
-
const computeAutoSizedColumnWidth = ({
|
|
551
|
-
bodyCellEls,
|
|
552
|
-
maxSize,
|
|
553
|
-
minSize
|
|
554
|
-
}) => {
|
|
555
|
-
let contentWidth = 0;
|
|
556
|
-
for (const cellEl of bodyCellEls ?? []) {
|
|
557
|
-
contentWidth = Math.max(contentWidth, measureIntrinsicWidth(cellEl));
|
|
751
|
+
getState,
|
|
752
|
+
options: t1
|
|
753
|
+
} = table;
|
|
754
|
+
const {
|
|
755
|
+
enableMultiRowSelection,
|
|
756
|
+
localization,
|
|
757
|
+
muiSelectAllCheckboxProps,
|
|
758
|
+
muiSelectCheckboxProps,
|
|
759
|
+
selectAllMode
|
|
760
|
+
} = t1;
|
|
761
|
+
let t2;
|
|
762
|
+
if ($[5] !== getState) {
|
|
763
|
+
t2 = getState();
|
|
764
|
+
$[5] = getState;
|
|
765
|
+
$[6] = t2;
|
|
766
|
+
} else {
|
|
767
|
+
t2 = $[6];
|
|
558
768
|
}
|
|
559
|
-
|
|
560
|
-
|
|
769
|
+
const {
|
|
770
|
+
isLoading
|
|
771
|
+
} = t2;
|
|
772
|
+
const density = useSelector(table.store, _temp$A);
|
|
773
|
+
const selectAll = !row;
|
|
774
|
+
let t3;
|
|
775
|
+
if ($[7] !== row || $[8] !== staticRowIndex || $[9] !== table) {
|
|
776
|
+
t3 = row ? getMRT_RowSelectionHandler({
|
|
777
|
+
row,
|
|
778
|
+
staticRowIndex,
|
|
779
|
+
table
|
|
780
|
+
}) : undefined;
|
|
781
|
+
$[7] = row;
|
|
782
|
+
$[8] = staticRowIndex;
|
|
783
|
+
$[9] = table;
|
|
784
|
+
$[10] = t3;
|
|
785
|
+
} else {
|
|
786
|
+
t3 = $[10];
|
|
561
787
|
}
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
788
|
+
const onSelectionChange = t3;
|
|
789
|
+
let t4;
|
|
790
|
+
if ($[11] !== table) {
|
|
791
|
+
t4 = getMRT_SelectAllHandler({
|
|
792
|
+
table
|
|
793
|
+
});
|
|
794
|
+
$[11] = table;
|
|
795
|
+
$[12] = t4;
|
|
796
|
+
} else {
|
|
797
|
+
t4 = $[12];
|
|
798
|
+
}
|
|
799
|
+
const onSelectAllChange = t4;
|
|
800
|
+
let t5;
|
|
801
|
+
if ($[13] !== density || $[14] !== enableMultiRowSelection || $[15] !== isLoading || $[16] !== localization.toggleSelectAll || $[17] !== localization.toggleSelectRow || $[18] !== muiSelectAllCheckboxProps || $[19] !== muiSelectCheckboxProps || $[20] !== onSelectAllChange || $[21] !== onSelectionChange || $[22] !== rest || $[23] !== row || $[24] !== selectAll || $[25] !== selectAllMode || $[26] !== staticRowIndex || $[27] !== table) {
|
|
802
|
+
t5 = () => {
|
|
803
|
+
const allRowsSelected = selectAll ? selectAllMode === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected() : undefined;
|
|
804
|
+
const isChecked = selectAll ? allRowsSelected : getIsRowSelected({
|
|
805
|
+
row,
|
|
806
|
+
table
|
|
807
|
+
});
|
|
808
|
+
const checkboxProps = {
|
|
809
|
+
...(selectAll ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, {
|
|
810
|
+
table
|
|
811
|
+
}) : parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
812
|
+
row,
|
|
813
|
+
staticRowIndex,
|
|
814
|
+
table
|
|
815
|
+
})),
|
|
816
|
+
...rest
|
|
817
|
+
};
|
|
818
|
+
const commonProps = {
|
|
819
|
+
"aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow,
|
|
820
|
+
checked: isChecked,
|
|
821
|
+
disabled: isLoading || row && !row.getCanSelect() || row?.id === "mrt-row-create",
|
|
822
|
+
inputProps: {
|
|
823
|
+
"aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
|
824
|
+
},
|
|
825
|
+
onChange: event => {
|
|
826
|
+
event.stopPropagation();
|
|
827
|
+
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
828
|
+
},
|
|
829
|
+
size: density === "compact" ? "small" : "medium",
|
|
830
|
+
...checkboxProps,
|
|
831
|
+
onClick: e => {
|
|
832
|
+
e.stopPropagation();
|
|
833
|
+
checkboxProps?.onClick?.(e);
|
|
834
|
+
},
|
|
835
|
+
sx: theme => ({
|
|
836
|
+
height: density === "compact" ? "1.75rem" : "2.5rem",
|
|
837
|
+
m: density !== "compact" ? "-0.4rem" : undefined,
|
|
838
|
+
width: density === "compact" ? "1.75rem" : "2.5rem",
|
|
839
|
+
zIndex: 0,
|
|
840
|
+
...parseFromValuesOrFunc(checkboxProps?.sx, theme)
|
|
841
|
+
}),
|
|
842
|
+
title: undefined
|
|
843
|
+
};
|
|
844
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
845
|
+
...getCommonTooltipProps(),
|
|
846
|
+
title: checkboxProps?.title ?? (selectAll ? localization.toggleSelectAll : localization.toggleSelectRow),
|
|
847
|
+
children: enableMultiRowSelection === false ? /*#__PURE__*/jsx(Radio, {
|
|
848
|
+
...commonProps
|
|
849
|
+
}) : /*#__PURE__*/jsx(Checkbox, {
|
|
850
|
+
disableRipple: true,
|
|
851
|
+
indeterminate: !isChecked && selectAll ? table.getIsSomeRowsSelected() : row?.getIsSomeSelected() && row.getCanSelectSubRows(),
|
|
852
|
+
...commonProps
|
|
853
|
+
})
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
$[13] = density;
|
|
857
|
+
$[14] = enableMultiRowSelection;
|
|
858
|
+
$[15] = isLoading;
|
|
859
|
+
$[16] = localization.toggleSelectAll;
|
|
860
|
+
$[17] = localization.toggleSelectRow;
|
|
861
|
+
$[18] = muiSelectAllCheckboxProps;
|
|
862
|
+
$[19] = muiSelectCheckboxProps;
|
|
863
|
+
$[20] = onSelectAllChange;
|
|
864
|
+
$[21] = onSelectionChange;
|
|
865
|
+
$[22] = rest;
|
|
866
|
+
$[23] = row;
|
|
867
|
+
$[24] = selectAll;
|
|
868
|
+
$[25] = selectAllMode;
|
|
869
|
+
$[26] = staticRowIndex;
|
|
870
|
+
$[27] = table;
|
|
871
|
+
$[28] = t5;
|
|
872
|
+
} else {
|
|
873
|
+
t5 = $[28];
|
|
874
|
+
}
|
|
875
|
+
let t6;
|
|
876
|
+
if ($[29] !== t5 || $[30] !== table.store) {
|
|
877
|
+
t6 = /*#__PURE__*/jsx(Subscribe, {
|
|
878
|
+
selector: _temp2$d,
|
|
879
|
+
source: table.store,
|
|
880
|
+
children: t5
|
|
881
|
+
});
|
|
882
|
+
$[29] = t5;
|
|
883
|
+
$[30] = table.store;
|
|
884
|
+
$[31] = t6;
|
|
885
|
+
} else {
|
|
886
|
+
t6 = $[31];
|
|
887
|
+
}
|
|
888
|
+
return t6;
|
|
567
889
|
};
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
from { opacity: 0; }
|
|
573
|
-
to { opacity: 1; }
|
|
574
|
-
`} 150ms ease-out 200ms both`;
|
|
575
|
-
const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
576
|
-
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
577
|
-
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
578
|
-
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
890
|
+
function _temp$A(state) {
|
|
891
|
+
return state.density;
|
|
892
|
+
}
|
|
893
|
+
function _temp2$d(state_0) {
|
|
579
894
|
return {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
draggingBorderColor: muiTheme.palette.primary.main,
|
|
583
|
-
matchHighlightColor: muiTheme.palette.mode === 'dark' ? darken(muiTheme.palette.warning.dark, 0.25) : lighten(muiTheme.palette.warning.light, 0.5),
|
|
584
|
-
menuBackgroundColor: lighten(baseBackgroundColor, 0.07),
|
|
585
|
-
pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1),
|
|
586
|
-
selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2),
|
|
587
|
-
...mrtThemeOverrides
|
|
895
|
+
pagination: state_0.pagination,
|
|
896
|
+
rowSelection: state_0.rowSelection
|
|
588
897
|
};
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
};
|
|
599
|
-
const getCommonPinnedCellStyles = ({
|
|
600
|
-
column,
|
|
601
|
-
table,
|
|
602
|
-
theme
|
|
603
|
-
}) => {
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function defaultDisplayColumnProps({
|
|
901
|
+
columnSpecificDefaults,
|
|
902
|
+
header,
|
|
903
|
+
id,
|
|
904
|
+
size,
|
|
905
|
+
tableOptions
|
|
906
|
+
}) {
|
|
604
907
|
const {
|
|
605
|
-
|
|
606
|
-
|
|
908
|
+
defaultDisplayColumn,
|
|
909
|
+
displayColumnDefOptions,
|
|
910
|
+
localization
|
|
911
|
+
} = tableOptions;
|
|
607
912
|
return {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
borderInlineStart: column?.getIsPinned() === 'end' && column.getIsFirstColumn('end') ? `1px solid ${theme.palette.divider}` : undefined,
|
|
615
|
-
boxSizing: 'border-box',
|
|
616
|
-
...commonCellBeforeAfterStyles
|
|
617
|
-
}
|
|
618
|
-
}
|
|
913
|
+
...defaultDisplayColumn,
|
|
914
|
+
header: header ? localization[header] : '',
|
|
915
|
+
size,
|
|
916
|
+
...columnSpecificDefaults,
|
|
917
|
+
...displayColumnDefOptions?.[id],
|
|
918
|
+
id
|
|
619
919
|
};
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// Shared by cell styles and the imperative sizing subscription: resizing must
|
|
623
|
-
// update growth even when memoized cells do not render again.
|
|
624
|
-
const getColumnGrowWeight = (column, table) => {
|
|
920
|
+
}
|
|
921
|
+
const showRowPinningColumn = tableOptions => {
|
|
625
922
|
const {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
if (column.getIsPinned() || !table.refs.autoSizeColumnIdsRef.current.has(column.id) || hasUserSize) return 0;
|
|
631
|
-
if (typeof columnDef.grow === 'number') return Math.max(0, columnDef.grow);
|
|
632
|
-
return columnDef.grow === false ? 0 : 1;
|
|
923
|
+
enableRowPinning,
|
|
924
|
+
rowPinningDisplayMode
|
|
925
|
+
} = tableOptions;
|
|
926
|
+
return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
|
|
633
927
|
};
|
|
634
|
-
const
|
|
635
|
-
column,
|
|
636
|
-
header,
|
|
637
|
-
isDraggingColumn,
|
|
638
|
-
isHoveredColumn,
|
|
639
|
-
table,
|
|
640
|
-
tableCellProps,
|
|
641
|
-
theme
|
|
642
|
-
}) => {
|
|
928
|
+
const showRowExpandColumn = tableOptions => {
|
|
643
929
|
const {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
930
|
+
enableExpanding,
|
|
931
|
+
enableGrouping,
|
|
932
|
+
renderDetailPanel,
|
|
933
|
+
state: {
|
|
934
|
+
grouping
|
|
647
935
|
}
|
|
648
|
-
} =
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
936
|
+
} = tableOptions;
|
|
937
|
+
return !!(enableExpanding || enableGrouping && grouping?.length || renderDetailPanel);
|
|
938
|
+
};
|
|
939
|
+
const showRowActionsColumn = tableOptions => {
|
|
652
940
|
const {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
941
|
+
enableEditing,
|
|
942
|
+
enableRowActions
|
|
943
|
+
} = tableOptions;
|
|
944
|
+
return !!(enableRowActions || enableEditing) && !columnsIncludeRowActions(tableOptions.columns);
|
|
945
|
+
};
|
|
946
|
+
const showRowNumbersColumn = tableOptions => !!tableOptions.enableRowNumbers;
|
|
947
|
+
const showRowSpacerColumn = tableOptions => tableOptions.layoutMode === 'grid-no-grow';
|
|
948
|
+
const getLeadingDisplayColumnIds = tableOptions => [showRowPinningColumn(tableOptions) && 'mrt-row-pin', tableOptions.positionActionsColumn === 'first' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'first' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', columnsIncludeCheckboxSelection(tableOptions.columns) && '__check__', showRowNumbersColumn(tableOptions) && 'mrt-row-numbers'].filter(Boolean);
|
|
949
|
+
const getTrailingDisplayColumnIds = tableOptions => [tableOptions.positionActionsColumn === 'last' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'last' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSpacerColumn(tableOptions) && 'mrt-row-spacer'].filter(Boolean);
|
|
950
|
+
|
|
951
|
+
/** The internal ID used by TanStack Table for the row-selection checkbox column */
|
|
952
|
+
const CHECKBOX_DISPLAY_COLUMN_ID = '__check__';
|
|
953
|
+
const getColumnMenuLabel = (column, localization) => column.id === CHECKBOX_DISPLAY_COLUMN_ID ? localization.selection : column.columnDef.header;
|
|
954
|
+
const ACTIONS_DISPLAY_COLUMN_ID = 'actions';
|
|
955
|
+
const getRowActionsCell = () => ({
|
|
956
|
+
Cell: ({
|
|
957
|
+
cell,
|
|
958
|
+
row,
|
|
959
|
+
staticRowIndex,
|
|
960
|
+
table
|
|
961
|
+
}) => /*#__PURE__*/createElement(MRT_ToggleRowActionMenuButton, {
|
|
962
|
+
cell,
|
|
963
|
+
row,
|
|
964
|
+
staticRowIndex,
|
|
965
|
+
table
|
|
966
|
+
})
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
/** Render row actions in the supplied column, preserving its layout and metadata. */
|
|
970
|
+
const decorateRowActionsColumn = (columnDef, tableOptions) => ({
|
|
971
|
+
...columnDef,
|
|
972
|
+
enableColumnDragging: columnDef.enableColumnDragging ?? true,
|
|
973
|
+
enableColumnOrdering: columnDef.enableColumnOrdering ?? true,
|
|
974
|
+
enableColumnActions: columnDef.enableColumnActions ?? true,
|
|
975
|
+
enablePinning: columnDef.enablePinning ?? true,
|
|
976
|
+
enableResizing: columnDef.enableResizing ?? true,
|
|
977
|
+
id: ACTIONS_DISPLAY_COLUMN_ID,
|
|
978
|
+
columnDefType: 'display',
|
|
979
|
+
onClickIconTypeColumn: undefined,
|
|
980
|
+
...getRowActionsCell(),
|
|
981
|
+
...tableOptions.displayColumnDefOptions?.[ACTIONS_DISPLAY_COLUMN_ID]
|
|
982
|
+
});
|
|
983
|
+
const columnsIncludeRowActions = columnDefs => getAllLeafColumnDefs(columnDefs).some(columnDef => getColumnId(columnDef) === ACTIONS_DISPLAY_COLUMN_ID);
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* The Cell/Header pair every `__check__` column renders — shared by the
|
|
987
|
+
* auto-injected row-select column (getMRT_RowSelectColumnDef) and any column
|
|
988
|
+
* a consumer supplies directly under this reserved id (see
|
|
989
|
+
* decorateCheckboxSelectionColumn below), so both stay visually and
|
|
990
|
+
* behaviorally identical.
|
|
991
|
+
*/
|
|
992
|
+
const getCheckboxSelectionCellAndHeader = tableOptions => {
|
|
656
993
|
const {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
} =
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
994
|
+
enableMultiRowSelection,
|
|
995
|
+
enableSelectAll
|
|
996
|
+
} = tableOptions;
|
|
997
|
+
return {
|
|
998
|
+
Cell: ({
|
|
999
|
+
row,
|
|
1000
|
+
staticRowIndex,
|
|
1001
|
+
table
|
|
1002
|
+
}) => /*#__PURE__*/createElement(MRT_SelectCheckbox, {
|
|
1003
|
+
row,
|
|
1004
|
+
staticRowIndex,
|
|
1005
|
+
table
|
|
1006
|
+
}),
|
|
1007
|
+
Header: enableSelectAll && enableMultiRowSelection ? ({
|
|
1008
|
+
table
|
|
1009
|
+
}) => /*#__PURE__*/createElement(MRT_SelectCheckbox, {
|
|
1010
|
+
table
|
|
1011
|
+
}) : undefined
|
|
668
1012
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* `__check__` is reserved: MRT always knows how to render a column by this
|
|
1017
|
+
* id as the row-selection checkbox — supplied directly in the consumer's
|
|
1018
|
+
* own columns array, e.g. a column converted 1:1, size/minSize/sortable and
|
|
1019
|
+
* all, from an external data source that happens to use this id for its own
|
|
1020
|
+
* selection column. `enableColumnActions`/`enablePinning` default to true
|
|
1021
|
+
* (matching every other display column's own baseline) unless the
|
|
1022
|
+
* consumer's own column def says otherwise; Cell/Header/columnDefType are
|
|
1023
|
+
* always forced, to route through the same display-column render path.
|
|
1024
|
+
* `displayColumnDefOptions['__check__']`, same as every other display
|
|
1025
|
+
* column, always has the final say, able to override any of it.
|
|
1026
|
+
*/
|
|
1027
|
+
const decorateCheckboxSelectionColumn = (columnDef, tableOptions) => ({
|
|
1028
|
+
...columnDef,
|
|
1029
|
+
enableColumnActions: columnDef.enableColumnActions ?? true,
|
|
1030
|
+
enablePinning: columnDef.enablePinning ?? true,
|
|
1031
|
+
enableResizing: columnDef.enableResizing ?? true,
|
|
1032
|
+
// Breathing room between the select-all checkbox/column-actions button
|
|
1033
|
+
// and whatever sits to their right (next column's border, or the
|
|
1034
|
+
// resize handle) — logical property so it's the correct side in RTL too.
|
|
1035
|
+
muiTableHeadCellProps: columnDef.muiTableHeadCellProps ?? {
|
|
1036
|
+
sx: {
|
|
1037
|
+
paddingInlineEnd: '1rem'
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
id: CHECKBOX_DISPLAY_COLUMN_ID,
|
|
1041
|
+
accessorKey: CHECKBOX_DISPLAY_COLUMN_ID,
|
|
1042
|
+
columnDefType: 'display',
|
|
1043
|
+
// Matches prepareColumns' own display-column merge below — without this,
|
|
1044
|
+
// the spread above leaves TS unable to tell this apart from the
|
|
1045
|
+
// icon-column variant of MRT_ColumnDef (which requires this field).
|
|
1046
|
+
onClickIconTypeColumn: undefined,
|
|
1047
|
+
...getCheckboxSelectionCellAndHeader(tableOptions),
|
|
1048
|
+
...tableOptions.displayColumnDefOptions?.[CHECKBOX_DISPLAY_COLUMN_ID]
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Whether the consumer's own columns already include a `__check__` column —
|
|
1053
|
+
* when true, MRT must not also auto-inject its own (enableRowSelection would
|
|
1054
|
+
* otherwise create a second column under the same reserved id).
|
|
1055
|
+
*/
|
|
1056
|
+
const columnsIncludeCheckboxSelection = columnDefs => getAllLeafColumnDefs(columnDefs).some(columnDef => getColumnId(columnDef) === CHECKBOX_DISPLAY_COLUMN_ID);
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Forces mrt-row-expand to a fixed slot in columnOrder: right after the
|
|
1060
|
+
* checkbox column when row selection is enabled, otherwise the very first
|
|
1061
|
+
* column. This slot is independent of column pinning.
|
|
1062
|
+
*/
|
|
1063
|
+
const normalizeRowExpandColumnOrder = (tableOptions, columnOrder) => {
|
|
1064
|
+
if (!showRowExpandColumn(tableOptions)) {
|
|
1065
|
+
return columnOrder;
|
|
673
1066
|
}
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
1067
|
+
const withoutExpand = columnOrder.filter(id => id !== 'mrt-row-expand');
|
|
1068
|
+
const expandIndex = columnsIncludeCheckboxSelection(tableOptions.columns) ? 1 : 0;
|
|
1069
|
+
return [...withoutExpand.slice(0, expandIndex), 'mrt-row-expand', ...withoutExpand.slice(expandIndex)];
|
|
1070
|
+
};
|
|
1071
|
+
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
|
1072
|
+
const {
|
|
1073
|
+
state: {
|
|
1074
|
+
columnOrder: currentColumnOrderIds = []
|
|
1075
|
+
}
|
|
1076
|
+
} = tableOptions;
|
|
1077
|
+
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
|
1078
|
+
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
|
1079
|
+
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map(columnDef => getColumnId(columnDef));
|
|
1080
|
+
let allLeafColumnDefIds = reset ? defaultColumnDefIds : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
|
1081
|
+
allLeafColumnDefIds = allLeafColumnDefIds.filter(colId => !leadingDisplayColIds.includes(colId) && !trailingDisplayColIds.includes(colId));
|
|
1082
|
+
return [...leadingDisplayColIds, ...allLeafColumnDefIds, ...trailingDisplayColIds];
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
const MRT_SortingFns = {
|
|
1086
|
+
...sortFns
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
const getColumnId = columnDef => columnDef.id ?? columnDef.accessorKey?.toString?.() ?? columnDef.header;
|
|
1090
|
+
const getAllLeafColumnDefs = columns => {
|
|
1091
|
+
const allLeafColumnDefs = [];
|
|
1092
|
+
const getLeafColumns = cols => {
|
|
1093
|
+
cols.forEach(col => {
|
|
1094
|
+
if (col.columns) {
|
|
1095
|
+
getLeafColumns(col.columns);
|
|
1096
|
+
} else {
|
|
1097
|
+
allLeafColumnDefs.push(col);
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
702
1100
|
};
|
|
1101
|
+
getLeafColumns(columns);
|
|
1102
|
+
return allLeafColumnDefs;
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
// Must run on the raw, user-authored column array — by the time TanStack
|
|
1106
|
+
// resolves column.columnDef.size (via constructColumn's `{...defaultColumn,
|
|
1107
|
+
// ...columnDef}` merge), a column the consumer never gave a size backfills
|
|
1108
|
+
// MRT_DefaultColumn.size (180) directly into columnDef.size, indistinguishable
|
|
1109
|
+
// from a column that explicitly asked for 180. Checking `size === undefined`
|
|
1110
|
+
// here, before that merge happens, is the only point where the distinction
|
|
1111
|
+
// still exists.
|
|
1112
|
+
const getAutoSizeCandidateColumnIds = columnDefs => new Set(getAllLeafColumnDefs(columnDefs).filter(columnDef => columnDef.size === undefined).map(columnDef => getColumnId(columnDef)));
|
|
1113
|
+
const prepareColumns = ({
|
|
1114
|
+
columnDefs,
|
|
1115
|
+
tableOptions
|
|
1116
|
+
}) => {
|
|
1117
|
+
const {
|
|
1118
|
+
defaultDisplayColumn
|
|
1119
|
+
} = tableOptions;
|
|
1120
|
+
return columnDefs.map(columnDef => {
|
|
1121
|
+
//assign columnId
|
|
1122
|
+
if (!columnDef.id) columnDef.id = getColumnId(columnDef);
|
|
1123
|
+
// __check__ is reserved: MRT always knows how to render a column by this
|
|
1124
|
+
// id as the row-selection checkbox, whether it was auto-injected or
|
|
1125
|
+
// supplied directly in the consumer's own columns array — see
|
|
1126
|
+
// decorateCheckboxSelectionColumn.
|
|
1127
|
+
if (columnDef.id === CHECKBOX_DISPLAY_COLUMN_ID) {
|
|
1128
|
+
columnDef = decorateCheckboxSelectionColumn(columnDef, tableOptions);
|
|
1129
|
+
} else if (columnDef.id === ACTIONS_DISPLAY_COLUMN_ID) {
|
|
1130
|
+
columnDef = decorateRowActionsColumn(columnDef, tableOptions);
|
|
1131
|
+
}
|
|
1132
|
+
//assign columnDefType
|
|
1133
|
+
if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
|
|
1134
|
+
if (columnDef.columns?.length) {
|
|
1135
|
+
columnDef.columnDefType = 'group';
|
|
1136
|
+
//recursively prepare columns if this is a group column
|
|
1137
|
+
columnDef.columns = prepareColumns({
|
|
1138
|
+
columnDefs: columnDef.columns,
|
|
1139
|
+
tableOptions
|
|
1140
|
+
});
|
|
1141
|
+
} else if (columnDef.columnDefType === 'data') {
|
|
1142
|
+
// Multi-aggregation arrays (e.g. aggregationFn: ['count', 'mean']) are
|
|
1143
|
+
// handled natively by v9's rowAggregationFeature — it resolves each
|
|
1144
|
+
// registered name and returns a keyed result object, so no manual
|
|
1145
|
+
// mapping is needed here anymore (v8 required it).
|
|
1146
|
+
|
|
1147
|
+
//assign sortFns
|
|
1148
|
+
if (Object.keys(MRT_SortingFns).includes(columnDef.sortFn)) {
|
|
1149
|
+
// @ts-expect-error - resolving the registered string name to its function
|
|
1150
|
+
columnDef.sortFn = MRT_SortingFns[columnDef.sortFn];
|
|
1151
|
+
}
|
|
1152
|
+
} else if (columnDef.columnDefType === 'display') {
|
|
1153
|
+
columnDef = {
|
|
1154
|
+
...defaultDisplayColumn,
|
|
1155
|
+
...columnDef,
|
|
1156
|
+
onClickIconTypeColumn: undefined
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
return columnDef;
|
|
1160
|
+
});
|
|
703
1161
|
};
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
alignItems: 'flex-start',
|
|
708
|
-
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
709
|
-
display: 'grid',
|
|
710
|
-
flexWrap: 'wrap-reverse',
|
|
711
|
-
position: 'relative',
|
|
712
|
-
transition: 'all 150ms ease-in-out',
|
|
713
|
-
zIndex: 1
|
|
714
|
-
});
|
|
715
|
-
const flipIconStyles = theme => theme.direction === 'rtl' ? {
|
|
716
|
-
style: {
|
|
717
|
-
transform: 'scaleX(-1)'
|
|
1162
|
+
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
1163
|
+
if (draggedColumn.getCanPin()) {
|
|
1164
|
+
draggedColumn.pin(targetColumn.getIsPinned());
|
|
718
1165
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
enterNextDelay: 1000,
|
|
724
|
-
placement
|
|
725
|
-
});
|
|
1166
|
+
const newColumnOrder = [...columnOrder];
|
|
1167
|
+
newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
1168
|
+
return newColumnOrder;
|
|
1169
|
+
};
|
|
726
1170
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
1171
|
+
const flexRender = flexRender$1;
|
|
1172
|
+
function createMRTColumnHelper() {
|
|
1173
|
+
return {
|
|
1174
|
+
accessor: (accessor, column) => ({
|
|
1175
|
+
...column,
|
|
1176
|
+
accessorKey: accessor
|
|
1177
|
+
}),
|
|
1178
|
+
display: column => column,
|
|
1179
|
+
group: column => column
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => constructRow(table, 'mrt-row-create', originalRow ?? Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map(col => ({
|
|
1183
|
+
[getColumnId(col)]: ''
|
|
1184
|
+
}))), rowIndex, depth, subRows, parentId);
|
|
730
1185
|
|
|
731
1186
|
function MRT_DeleteRowButton(t0) {
|
|
732
1187
|
const $ = c(14);
|
|
@@ -2004,199 +2459,20 @@ const createExportAction = ({
|
|
|
2004
2459
|
});
|
|
2005
2460
|
};
|
|
2006
2461
|
return {
|
|
2007
|
-
name: 'export',
|
|
2008
|
-
renderRow: renderRowAction,
|
|
2009
|
-
renderToolbar: renderToolbarAction,
|
|
2010
|
-
...rest
|
|
2011
|
-
};
|
|
2012
|
-
};
|
|
2013
|
-
|
|
2014
|
-
const MRT_AggregationFns = {
|
|
2015
|
-
...aggregationFns
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
const MRT_RowActionMenu = ({
|
|
2019
|
-
anchorEl,
|
|
2020
|
-
row,
|
|
2021
|
-
setAnchorEl,
|
|
2022
|
-
staticRowIndex,
|
|
2023
|
-
table,
|
|
2024
|
-
...rest
|
|
2025
|
-
}) => {
|
|
2026
|
-
const {
|
|
2027
|
-
options: {
|
|
2028
|
-
mrtTheme: {
|
|
2029
|
-
menuBackgroundColor
|
|
2030
|
-
},
|
|
2031
|
-
renderRowActionMenuItems
|
|
2032
|
-
}
|
|
2033
|
-
} = table;
|
|
2034
|
-
const density = useSelector(table.store, state => state.density);
|
|
2035
|
-
const menuItems = useMemo(() => {
|
|
2036
|
-
const items = [];
|
|
2037
|
-
const rowActionMenuItems = renderRowActionMenuItems?.({
|
|
2038
|
-
closeMenu: () => setAnchorEl(null),
|
|
2039
|
-
row,
|
|
2040
|
-
staticRowIndex,
|
|
2041
|
-
table
|
|
2042
|
-
});
|
|
2043
|
-
if (rowActionMenuItems?.length) items.push(...rowActionMenuItems);
|
|
2044
|
-
return items;
|
|
2045
|
-
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
2046
|
-
if (!menuItems.length) return null;
|
|
2047
|
-
return /*#__PURE__*/jsx(Menu, {
|
|
2048
|
-
MenuListProps: {
|
|
2049
|
-
dense: density === 'compact',
|
|
2050
|
-
sx: {
|
|
2051
|
-
backgroundColor: menuBackgroundColor
|
|
2052
|
-
}
|
|
2053
|
-
},
|
|
2054
|
-
anchorEl: anchorEl,
|
|
2055
|
-
disableScrollLock: true,
|
|
2056
|
-
onClick: event => event.stopPropagation(),
|
|
2057
|
-
onClose: () => setAnchorEl(null),
|
|
2058
|
-
open: !!anchorEl,
|
|
2059
|
-
...rest,
|
|
2060
|
-
children: menuItems
|
|
2061
|
-
});
|
|
2062
|
-
};
|
|
2063
|
-
|
|
2064
|
-
const commonIconButtonStyles = {
|
|
2065
|
-
'&:hover': {
|
|
2066
|
-
opacity: 1
|
|
2067
|
-
},
|
|
2068
|
-
height: '2rem',
|
|
2069
|
-
ml: '10px',
|
|
2070
|
-
opacity: 0.5,
|
|
2071
|
-
transition: 'opacity 150ms',
|
|
2072
|
-
width: '2rem'
|
|
2073
|
-
};
|
|
2074
|
-
const MRT_ToggleRowActionMenuButton = t0 => {
|
|
2075
|
-
const $ = c(20);
|
|
2076
|
-
let cell;
|
|
2077
|
-
let rest;
|
|
2078
|
-
let row;
|
|
2079
|
-
let staticRowIndex;
|
|
2080
|
-
let table;
|
|
2081
|
-
if ($[0] !== t0) {
|
|
2082
|
-
({
|
|
2083
|
-
cell,
|
|
2084
|
-
row,
|
|
2085
|
-
staticRowIndex,
|
|
2086
|
-
table,
|
|
2087
|
-
...rest
|
|
2088
|
-
} = t0);
|
|
2089
|
-
$[0] = t0;
|
|
2090
|
-
$[1] = cell;
|
|
2091
|
-
$[2] = rest;
|
|
2092
|
-
$[3] = row;
|
|
2093
|
-
$[4] = staticRowIndex;
|
|
2094
|
-
$[5] = table;
|
|
2095
|
-
} else {
|
|
2096
|
-
cell = $[1];
|
|
2097
|
-
rest = $[2];
|
|
2098
|
-
row = $[3];
|
|
2099
|
-
staticRowIndex = $[4];
|
|
2100
|
-
table = $[5];
|
|
2101
|
-
}
|
|
2102
|
-
const {
|
|
2103
|
-
options: t1
|
|
2104
|
-
} = table;
|
|
2105
|
-
const {
|
|
2106
|
-
icons: t2,
|
|
2107
|
-
localization,
|
|
2108
|
-
renderRowActionMenuItems,
|
|
2109
|
-
renderRowActions
|
|
2110
|
-
} = t1;
|
|
2111
|
-
const {
|
|
2112
|
-
MoreHorizIcon
|
|
2113
|
-
} = t2;
|
|
2114
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
2115
|
-
let t3;
|
|
2116
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2117
|
-
t3 = event => {
|
|
2118
|
-
event.stopPropagation();
|
|
2119
|
-
event.preventDefault();
|
|
2120
|
-
setAnchorEl(event.currentTarget);
|
|
2121
|
-
};
|
|
2122
|
-
$[6] = t3;
|
|
2123
|
-
} else {
|
|
2124
|
-
t3 = $[6];
|
|
2125
|
-
}
|
|
2126
|
-
const handleOpenRowActionMenu = t3;
|
|
2127
|
-
let t4;
|
|
2128
|
-
if ($[7] !== MoreHorizIcon || $[8] !== anchorEl || $[9] !== cell || $[10] !== localization || $[11] !== renderRowActionMenuItems || $[12] !== renderRowActions || $[13] !== rest || $[14] !== row || $[15] !== staticRowIndex || $[16] !== table) {
|
|
2129
|
-
t4 = renderRowActions ? renderRowActions({
|
|
2130
|
-
cell,
|
|
2131
|
-
row,
|
|
2132
|
-
staticRowIndex,
|
|
2133
|
-
table
|
|
2134
|
-
}) : renderRowActionMenuItems?.({
|
|
2135
|
-
closeMenu: _temp$B,
|
|
2136
|
-
row,
|
|
2137
|
-
staticRowIndex,
|
|
2138
|
-
table
|
|
2139
|
-
})?.length ? /*#__PURE__*/jsxs(Fragment, {
|
|
2140
|
-
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
2141
|
-
...getCommonTooltipProps(),
|
|
2142
|
-
title: localization.rowActions,
|
|
2143
|
-
children: /*#__PURE__*/jsx(IconButton, {
|
|
2144
|
-
"aria-label": localization.rowActions,
|
|
2145
|
-
onClick: handleOpenRowActionMenu,
|
|
2146
|
-
size: "small",
|
|
2147
|
-
sx: commonIconButtonStyles,
|
|
2148
|
-
...rest,
|
|
2149
|
-
children: /*#__PURE__*/jsx(MoreHorizIcon, {})
|
|
2150
|
-
})
|
|
2151
|
-
}), /*#__PURE__*/jsx(MRT_RowActionMenu, {
|
|
2152
|
-
anchorEl: anchorEl,
|
|
2153
|
-
row: row,
|
|
2154
|
-
setAnchorEl: setAnchorEl,
|
|
2155
|
-
staticRowIndex: staticRowIndex,
|
|
2156
|
-
table: table
|
|
2157
|
-
})]
|
|
2158
|
-
}) : null;
|
|
2159
|
-
$[7] = MoreHorizIcon;
|
|
2160
|
-
$[8] = anchorEl;
|
|
2161
|
-
$[9] = cell;
|
|
2162
|
-
$[10] = localization;
|
|
2163
|
-
$[11] = renderRowActionMenuItems;
|
|
2164
|
-
$[12] = renderRowActions;
|
|
2165
|
-
$[13] = rest;
|
|
2166
|
-
$[14] = row;
|
|
2167
|
-
$[15] = staticRowIndex;
|
|
2168
|
-
$[16] = table;
|
|
2169
|
-
$[17] = t4;
|
|
2170
|
-
} else {
|
|
2171
|
-
t4 = $[17];
|
|
2172
|
-
}
|
|
2173
|
-
let t5;
|
|
2174
|
-
if ($[18] !== t4) {
|
|
2175
|
-
t5 = /*#__PURE__*/jsx(Fragment, {
|
|
2176
|
-
children: t4
|
|
2177
|
-
});
|
|
2178
|
-
$[18] = t4;
|
|
2179
|
-
$[19] = t5;
|
|
2180
|
-
} else {
|
|
2181
|
-
t5 = $[19];
|
|
2182
|
-
}
|
|
2183
|
-
return t5;
|
|
2462
|
+
name: 'export',
|
|
2463
|
+
renderRow: renderRowAction,
|
|
2464
|
+
renderToolbar: renderToolbarAction,
|
|
2465
|
+
...rest
|
|
2466
|
+
};
|
|
2467
|
+
};
|
|
2468
|
+
|
|
2469
|
+
const MRT_AggregationFns = {
|
|
2470
|
+
...aggregationFns
|
|
2184
2471
|
};
|
|
2185
|
-
function _temp$B() {}
|
|
2186
2472
|
|
|
2187
2473
|
const getMRT_RowActionsColumnDef = tableOptions => {
|
|
2188
2474
|
return {
|
|
2189
|
-
|
|
2190
|
-
cell,
|
|
2191
|
-
row,
|
|
2192
|
-
staticRowIndex,
|
|
2193
|
-
table
|
|
2194
|
-
}) => /*#__PURE__*/jsx(MRT_ToggleRowActionMenuButton, {
|
|
2195
|
-
cell: cell,
|
|
2196
|
-
row: row,
|
|
2197
|
-
staticRowIndex: staticRowIndex,
|
|
2198
|
-
table: table
|
|
2199
|
-
}),
|
|
2475
|
+
...getRowActionsCell(),
|
|
2200
2476
|
...(tableOptions.positionActionsColumn === 'last' && {
|
|
2201
2477
|
grow: true
|
|
2202
2478
|
}),
|
|
@@ -2261,7 +2537,7 @@ const MRT_ExpandAllButton = t0 => {
|
|
|
2261
2537
|
const {
|
|
2262
2538
|
isLoading
|
|
2263
2539
|
} = t3;
|
|
2264
|
-
const density = useSelector(table.store, _temp$
|
|
2540
|
+
const density = useSelector(table.store, _temp$z);
|
|
2265
2541
|
let t4;
|
|
2266
2542
|
if ($[5] !== muiExpandAllButtonProps || $[6] !== table) {
|
|
2267
2543
|
t4 = parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
|
@@ -2350,7 +2626,7 @@ const MRT_ExpandAllButton = t0 => {
|
|
|
2350
2626
|
}
|
|
2351
2627
|
return t7;
|
|
2352
2628
|
};
|
|
2353
|
-
function _temp$
|
|
2629
|
+
function _temp$z(state) {
|
|
2354
2630
|
return state.density;
|
|
2355
2631
|
}
|
|
2356
2632
|
|
|
@@ -2565,11 +2841,11 @@ const MRT_ReorderRowCheckbox = t0 => {
|
|
|
2565
2841
|
onChange,
|
|
2566
2842
|
isSelected
|
|
2567
2843
|
} = t0;
|
|
2568
|
-
const handleClick = _temp$
|
|
2844
|
+
const handleClick = _temp$y;
|
|
2569
2845
|
let t1;
|
|
2570
2846
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2571
2847
|
t1 = {
|
|
2572
|
-
color: _temp2$
|
|
2848
|
+
color: _temp2$c,
|
|
2573
2849
|
height: "1.75rem",
|
|
2574
2850
|
m: "-0.4rem",
|
|
2575
2851
|
width: "1.75rem",
|
|
@@ -2600,10 +2876,10 @@ const MRT_ReorderRowCheckbox = t0 => {
|
|
|
2600
2876
|
}
|
|
2601
2877
|
return t2;
|
|
2602
2878
|
};
|
|
2603
|
-
function _temp$
|
|
2879
|
+
function _temp$y(event) {
|
|
2604
2880
|
event.stopPropagation();
|
|
2605
2881
|
}
|
|
2606
|
-
function _temp2$
|
|
2882
|
+
function _temp2$c(theme) {
|
|
2607
2883
|
return theme.palette.warning.main;
|
|
2608
2884
|
}
|
|
2609
2885
|
function _temp3$5(theme_0) {
|
|
@@ -2925,14 +3201,14 @@ const useTreeRowReorderingHeader = t0 => {
|
|
|
2925
3201
|
enableRowReordering,
|
|
2926
3202
|
onTreeRowReorder
|
|
2927
3203
|
} = t0;
|
|
2928
|
-
const rowReorderingSelection = useSelector(table.store, _temp$
|
|
3204
|
+
const rowReorderingSelection = useSelector(table.store, _temp$x);
|
|
2929
3205
|
let selectedReorderRowIds;
|
|
2930
3206
|
let selectedRowsForReorder;
|
|
2931
3207
|
let t1;
|
|
2932
3208
|
if ($[0] !== enableRowReordering || $[1] !== rowReorderingSelection || $[2] !== table) {
|
|
2933
3209
|
selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
|
|
2934
3210
|
selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
2935
|
-
t1 = !!enableRowReordering && selectedRowsForReorder.length > 0 && selectedRowsForReorder.some(_temp2$
|
|
3211
|
+
t1 = !!enableRowReordering && selectedRowsForReorder.length > 0 && selectedRowsForReorder.some(_temp2$b);
|
|
2936
3212
|
$[0] = enableRowReordering;
|
|
2937
3213
|
$[1] = rowReorderingSelection;
|
|
2938
3214
|
$[2] = table;
|
|
@@ -2988,10 +3264,10 @@ const useTreeRowReorderingHeader = t0 => {
|
|
|
2988
3264
|
}
|
|
2989
3265
|
return t3;
|
|
2990
3266
|
};
|
|
2991
|
-
function _temp$
|
|
3267
|
+
function _temp$x(state) {
|
|
2992
3268
|
return state.rowReorderingSelection;
|
|
2993
3269
|
}
|
|
2994
|
-
function _temp2$
|
|
3270
|
+
function _temp2$b(selectedRow) {
|
|
2995
3271
|
return selectedRow.depth > 0;
|
|
2996
3272
|
}
|
|
2997
3273
|
|
|
@@ -3330,314 +3606,106 @@ const MRT_TableBodyRowPinButton = t0 => {
|
|
|
3330
3606
|
const {
|
|
3331
3607
|
enableRowPinning,
|
|
3332
3608
|
rowPinningDisplayMode
|
|
3333
|
-
} = t1;
|
|
3334
|
-
const density = useSelector(table.store, _temp$
|
|
3335
|
-
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
|
3336
|
-
if (!canPin) {
|
|
3337
|
-
return null;
|
|
3338
|
-
}
|
|
3339
|
-
let t2;
|
|
3340
|
-
if ($[4] !== rest || $[5] !== row || $[6] !== table) {
|
|
3341
|
-
t2 = {
|
|
3342
|
-
row,
|
|
3343
|
-
table,
|
|
3344
|
-
...rest
|
|
3345
|
-
};
|
|
3346
|
-
$[4] = rest;
|
|
3347
|
-
$[5] = row;
|
|
3348
|
-
$[6] = table;
|
|
3349
|
-
$[7] = t2;
|
|
3350
|
-
} else {
|
|
3351
|
-
t2 = $[7];
|
|
3352
|
-
}
|
|
3353
|
-
const rowPinButtonProps = t2;
|
|
3354
|
-
if (rowPinningDisplayMode === "top-and-bottom" && !row.getIsPinned()) {
|
|
3355
|
-
const t3 = density === "compact" ? "row" : "column";
|
|
3356
|
-
let t4;
|
|
3357
|
-
if ($[8] !== t3) {
|
|
3358
|
-
t4 = {
|
|
3359
|
-
display: "flex",
|
|
3360
|
-
flexDirection: t3
|
|
3361
|
-
};
|
|
3362
|
-
$[8] = t3;
|
|
3363
|
-
$[9] = t4;
|
|
3364
|
-
} else {
|
|
3365
|
-
t4 = $[9];
|
|
3366
|
-
}
|
|
3367
|
-
let t5;
|
|
3368
|
-
let t6;
|
|
3369
|
-
if ($[10] !== rowPinButtonProps) {
|
|
3370
|
-
t5 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3371
|
-
pinningPosition: "top",
|
|
3372
|
-
...rowPinButtonProps
|
|
3373
|
-
});
|
|
3374
|
-
t6 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3375
|
-
pinningPosition: "bottom",
|
|
3376
|
-
...rowPinButtonProps
|
|
3377
|
-
});
|
|
3378
|
-
$[10] = rowPinButtonProps;
|
|
3379
|
-
$[11] = t5;
|
|
3380
|
-
$[12] = t6;
|
|
3381
|
-
} else {
|
|
3382
|
-
t5 = $[11];
|
|
3383
|
-
t6 = $[12];
|
|
3384
|
-
}
|
|
3385
|
-
let t7;
|
|
3386
|
-
if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
|
|
3387
|
-
t7 = /*#__PURE__*/jsxs(Box, {
|
|
3388
|
-
sx: t4,
|
|
3389
|
-
children: [t5, t6]
|
|
3390
|
-
});
|
|
3391
|
-
$[13] = t4;
|
|
3392
|
-
$[14] = t5;
|
|
3393
|
-
$[15] = t6;
|
|
3394
|
-
$[16] = t7;
|
|
3395
|
-
} else {
|
|
3396
|
-
t7 = $[16];
|
|
3397
|
-
}
|
|
3398
|
-
return t7;
|
|
3399
|
-
}
|
|
3400
|
-
const t3 = rowPinningDisplayMode === "bottom" ? "bottom" : "top";
|
|
3401
|
-
let t4;
|
|
3402
|
-
if ($[17] !== rowPinButtonProps || $[18] !== t3) {
|
|
3403
|
-
t4 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3404
|
-
pinningPosition: t3,
|
|
3405
|
-
...rowPinButtonProps
|
|
3406
|
-
});
|
|
3407
|
-
$[17] = rowPinButtonProps;
|
|
3408
|
-
$[18] = t3;
|
|
3409
|
-
$[19] = t4;
|
|
3410
|
-
} else {
|
|
3411
|
-
t4 = $[19];
|
|
3412
|
-
}
|
|
3413
|
-
return t4;
|
|
3414
|
-
};
|
|
3415
|
-
function _temp$x(state) {
|
|
3416
|
-
return state.density;
|
|
3417
|
-
}
|
|
3418
|
-
|
|
3419
|
-
const getMRT_RowPinningColumnDef = tableOptions => {
|
|
3420
|
-
return {
|
|
3421
|
-
Cell: ({
|
|
3422
|
-
row,
|
|
3423
|
-
table
|
|
3424
|
-
}) => /*#__PURE__*/jsx(MRT_TableBodyRowPinButton, {
|
|
3425
|
-
row: row,
|
|
3426
|
-
table: table
|
|
3427
|
-
}),
|
|
3428
|
-
grow: false,
|
|
3429
|
-
...defaultDisplayColumnProps({
|
|
3430
|
-
header: 'pin',
|
|
3431
|
-
id: 'mrt-row-pin',
|
|
3432
|
-
size: 60,
|
|
3433
|
-
tableOptions
|
|
3434
|
-
})
|
|
3435
|
-
};
|
|
3436
|
-
};
|
|
3437
|
-
|
|
3438
|
-
const MRT_SelectCheckbox = t0 => {
|
|
3439
|
-
const $ = c(32);
|
|
3440
|
-
let rest;
|
|
3441
|
-
let row;
|
|
3442
|
-
let staticRowIndex;
|
|
3443
|
-
let table;
|
|
3444
|
-
if ($[0] !== t0) {
|
|
3445
|
-
({
|
|
3446
|
-
row,
|
|
3447
|
-
staticRowIndex,
|
|
3448
|
-
table,
|
|
3449
|
-
...rest
|
|
3450
|
-
} = t0);
|
|
3451
|
-
$[0] = t0;
|
|
3452
|
-
$[1] = rest;
|
|
3453
|
-
$[2] = row;
|
|
3454
|
-
$[3] = staticRowIndex;
|
|
3455
|
-
$[4] = table;
|
|
3456
|
-
} else {
|
|
3457
|
-
rest = $[1];
|
|
3458
|
-
row = $[2];
|
|
3459
|
-
staticRowIndex = $[3];
|
|
3460
|
-
table = $[4];
|
|
3461
|
-
}
|
|
3462
|
-
const {
|
|
3463
|
-
getState,
|
|
3464
|
-
options: t1
|
|
3465
|
-
} = table;
|
|
3466
|
-
const {
|
|
3467
|
-
enableMultiRowSelection,
|
|
3468
|
-
localization,
|
|
3469
|
-
muiSelectAllCheckboxProps,
|
|
3470
|
-
muiSelectCheckboxProps,
|
|
3471
|
-
selectAllMode
|
|
3472
|
-
} = t1;
|
|
3473
|
-
let t2;
|
|
3474
|
-
if ($[5] !== getState) {
|
|
3475
|
-
t2 = getState();
|
|
3476
|
-
$[5] = getState;
|
|
3477
|
-
$[6] = t2;
|
|
3478
|
-
} else {
|
|
3479
|
-
t2 = $[6];
|
|
3480
|
-
}
|
|
3481
|
-
const {
|
|
3482
|
-
isLoading
|
|
3483
|
-
} = t2;
|
|
3484
|
-
const density = useSelector(table.store, _temp$w);
|
|
3485
|
-
const selectAll = !row;
|
|
3486
|
-
let t3;
|
|
3487
|
-
if ($[7] !== row || $[8] !== staticRowIndex || $[9] !== table) {
|
|
3488
|
-
t3 = row ? getMRT_RowSelectionHandler({
|
|
3489
|
-
row,
|
|
3490
|
-
staticRowIndex,
|
|
3491
|
-
table
|
|
3492
|
-
}) : undefined;
|
|
3493
|
-
$[7] = row;
|
|
3494
|
-
$[8] = staticRowIndex;
|
|
3495
|
-
$[9] = table;
|
|
3496
|
-
$[10] = t3;
|
|
3497
|
-
} else {
|
|
3498
|
-
t3 = $[10];
|
|
3499
|
-
}
|
|
3500
|
-
const onSelectionChange = t3;
|
|
3501
|
-
let t4;
|
|
3502
|
-
if ($[11] !== table) {
|
|
3503
|
-
t4 = getMRT_SelectAllHandler({
|
|
3504
|
-
table
|
|
3505
|
-
});
|
|
3506
|
-
$[11] = table;
|
|
3507
|
-
$[12] = t4;
|
|
3508
|
-
} else {
|
|
3509
|
-
t4 = $[12];
|
|
3510
|
-
}
|
|
3511
|
-
const onSelectAllChange = t4;
|
|
3512
|
-
let t5;
|
|
3513
|
-
if ($[13] !== density || $[14] !== enableMultiRowSelection || $[15] !== isLoading || $[16] !== localization.toggleSelectAll || $[17] !== localization.toggleSelectRow || $[18] !== muiSelectAllCheckboxProps || $[19] !== muiSelectCheckboxProps || $[20] !== onSelectAllChange || $[21] !== onSelectionChange || $[22] !== rest || $[23] !== row || $[24] !== selectAll || $[25] !== selectAllMode || $[26] !== staticRowIndex || $[27] !== table) {
|
|
3514
|
-
t5 = () => {
|
|
3515
|
-
const allRowsSelected = selectAll ? selectAllMode === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected() : undefined;
|
|
3516
|
-
const isChecked = selectAll ? allRowsSelected : getIsRowSelected({
|
|
3517
|
-
row,
|
|
3518
|
-
table
|
|
3519
|
-
});
|
|
3520
|
-
const checkboxProps = {
|
|
3521
|
-
...(selectAll ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, {
|
|
3522
|
-
table
|
|
3523
|
-
}) : parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
3524
|
-
row,
|
|
3525
|
-
staticRowIndex,
|
|
3526
|
-
table
|
|
3527
|
-
})),
|
|
3528
|
-
...rest
|
|
3529
|
-
};
|
|
3530
|
-
const commonProps = {
|
|
3531
|
-
"aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow,
|
|
3532
|
-
checked: isChecked,
|
|
3533
|
-
disabled: isLoading || row && !row.getCanSelect() || row?.id === "mrt-row-create",
|
|
3534
|
-
inputProps: {
|
|
3535
|
-
"aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
|
3536
|
-
},
|
|
3537
|
-
onChange: event => {
|
|
3538
|
-
event.stopPropagation();
|
|
3539
|
-
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
3540
|
-
},
|
|
3541
|
-
size: density === "compact" ? "small" : "medium",
|
|
3542
|
-
...checkboxProps,
|
|
3543
|
-
onClick: e => {
|
|
3544
|
-
e.stopPropagation();
|
|
3545
|
-
checkboxProps?.onClick?.(e);
|
|
3546
|
-
},
|
|
3547
|
-
sx: theme => ({
|
|
3548
|
-
height: density === "compact" ? "1.75rem" : "2.5rem",
|
|
3549
|
-
m: density !== "compact" ? "-0.4rem" : undefined,
|
|
3550
|
-
width: density === "compact" ? "1.75rem" : "2.5rem",
|
|
3551
|
-
zIndex: 0,
|
|
3552
|
-
...parseFromValuesOrFunc(checkboxProps?.sx, theme)
|
|
3553
|
-
}),
|
|
3554
|
-
title: undefined
|
|
3555
|
-
};
|
|
3556
|
-
return /*#__PURE__*/jsx(Tooltip, {
|
|
3557
|
-
...getCommonTooltipProps(),
|
|
3558
|
-
title: checkboxProps?.title ?? (selectAll ? localization.toggleSelectAll : localization.toggleSelectRow),
|
|
3559
|
-
children: enableMultiRowSelection === false ? /*#__PURE__*/jsx(Radio, {
|
|
3560
|
-
...commonProps
|
|
3561
|
-
}) : /*#__PURE__*/jsx(Checkbox, {
|
|
3562
|
-
disableRipple: true,
|
|
3563
|
-
indeterminate: !isChecked && selectAll ? table.getIsSomeRowsSelected() : row?.getIsSomeSelected() && row.getCanSelectSubRows(),
|
|
3564
|
-
...commonProps
|
|
3565
|
-
})
|
|
3566
|
-
});
|
|
3609
|
+
} = t1;
|
|
3610
|
+
const density = useSelector(table.store, _temp$w);
|
|
3611
|
+
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
|
3612
|
+
if (!canPin) {
|
|
3613
|
+
return null;
|
|
3614
|
+
}
|
|
3615
|
+
let t2;
|
|
3616
|
+
if ($[4] !== rest || $[5] !== row || $[6] !== table) {
|
|
3617
|
+
t2 = {
|
|
3618
|
+
row,
|
|
3619
|
+
table,
|
|
3620
|
+
...rest
|
|
3567
3621
|
};
|
|
3568
|
-
$[
|
|
3569
|
-
$[
|
|
3570
|
-
$[
|
|
3571
|
-
$[
|
|
3572
|
-
$[17] = localization.toggleSelectRow;
|
|
3573
|
-
$[18] = muiSelectAllCheckboxProps;
|
|
3574
|
-
$[19] = muiSelectCheckboxProps;
|
|
3575
|
-
$[20] = onSelectAllChange;
|
|
3576
|
-
$[21] = onSelectionChange;
|
|
3577
|
-
$[22] = rest;
|
|
3578
|
-
$[23] = row;
|
|
3579
|
-
$[24] = selectAll;
|
|
3580
|
-
$[25] = selectAllMode;
|
|
3581
|
-
$[26] = staticRowIndex;
|
|
3582
|
-
$[27] = table;
|
|
3583
|
-
$[28] = t5;
|
|
3622
|
+
$[4] = rest;
|
|
3623
|
+
$[5] = row;
|
|
3624
|
+
$[6] = table;
|
|
3625
|
+
$[7] = t2;
|
|
3584
3626
|
} else {
|
|
3585
|
-
|
|
3627
|
+
t2 = $[7];
|
|
3586
3628
|
}
|
|
3587
|
-
|
|
3588
|
-
if (
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3629
|
+
const rowPinButtonProps = t2;
|
|
3630
|
+
if (rowPinningDisplayMode === "top-and-bottom" && !row.getIsPinned()) {
|
|
3631
|
+
const t3 = density === "compact" ? "row" : "column";
|
|
3632
|
+
let t4;
|
|
3633
|
+
if ($[8] !== t3) {
|
|
3634
|
+
t4 = {
|
|
3635
|
+
display: "flex",
|
|
3636
|
+
flexDirection: t3
|
|
3637
|
+
};
|
|
3638
|
+
$[8] = t3;
|
|
3639
|
+
$[9] = t4;
|
|
3640
|
+
} else {
|
|
3641
|
+
t4 = $[9];
|
|
3642
|
+
}
|
|
3643
|
+
let t5;
|
|
3644
|
+
let t6;
|
|
3645
|
+
if ($[10] !== rowPinButtonProps) {
|
|
3646
|
+
t5 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3647
|
+
pinningPosition: "top",
|
|
3648
|
+
...rowPinButtonProps
|
|
3649
|
+
});
|
|
3650
|
+
t6 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3651
|
+
pinningPosition: "bottom",
|
|
3652
|
+
...rowPinButtonProps
|
|
3653
|
+
});
|
|
3654
|
+
$[10] = rowPinButtonProps;
|
|
3655
|
+
$[11] = t5;
|
|
3656
|
+
$[12] = t6;
|
|
3657
|
+
} else {
|
|
3658
|
+
t5 = $[11];
|
|
3659
|
+
t6 = $[12];
|
|
3660
|
+
}
|
|
3661
|
+
let t7;
|
|
3662
|
+
if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
|
|
3663
|
+
t7 = /*#__PURE__*/jsxs(Box, {
|
|
3664
|
+
sx: t4,
|
|
3665
|
+
children: [t5, t6]
|
|
3666
|
+
});
|
|
3667
|
+
$[13] = t4;
|
|
3668
|
+
$[14] = t5;
|
|
3669
|
+
$[15] = t6;
|
|
3670
|
+
$[16] = t7;
|
|
3671
|
+
} else {
|
|
3672
|
+
t7 = $[16];
|
|
3673
|
+
}
|
|
3674
|
+
return t7;
|
|
3675
|
+
}
|
|
3676
|
+
const t3 = rowPinningDisplayMode === "bottom" ? "bottom" : "top";
|
|
3677
|
+
let t4;
|
|
3678
|
+
if ($[17] !== rowPinButtonProps || $[18] !== t3) {
|
|
3679
|
+
t4 = /*#__PURE__*/jsx(MRT_RowPinButton, {
|
|
3680
|
+
pinningPosition: t3,
|
|
3681
|
+
...rowPinButtonProps
|
|
3593
3682
|
});
|
|
3594
|
-
$[
|
|
3595
|
-
$[
|
|
3596
|
-
$[
|
|
3683
|
+
$[17] = rowPinButtonProps;
|
|
3684
|
+
$[18] = t3;
|
|
3685
|
+
$[19] = t4;
|
|
3597
3686
|
} else {
|
|
3598
|
-
|
|
3687
|
+
t4 = $[19];
|
|
3599
3688
|
}
|
|
3600
|
-
return
|
|
3689
|
+
return t4;
|
|
3601
3690
|
};
|
|
3602
3691
|
function _temp$w(state) {
|
|
3603
3692
|
return state.density;
|
|
3604
3693
|
}
|
|
3605
|
-
function _temp2$b(state_0) {
|
|
3606
|
-
return {
|
|
3607
|
-
pagination: state_0.pagination,
|
|
3608
|
-
rowSelection: state_0.rowSelection
|
|
3609
|
-
};
|
|
3610
|
-
}
|
|
3611
3694
|
|
|
3612
|
-
const
|
|
3613
|
-
const {
|
|
3614
|
-
enableMultiRowSelection,
|
|
3615
|
-
enableSelectAll
|
|
3616
|
-
} = tableOptions;
|
|
3695
|
+
const getMRT_RowPinningColumnDef = tableOptions => {
|
|
3617
3696
|
return {
|
|
3618
3697
|
Cell: ({
|
|
3619
3698
|
row,
|
|
3620
|
-
staticRowIndex,
|
|
3621
3699
|
table
|
|
3622
|
-
}) => /*#__PURE__*/jsx(
|
|
3700
|
+
}) => /*#__PURE__*/jsx(MRT_TableBodyRowPinButton, {
|
|
3623
3701
|
row: row,
|
|
3624
|
-
staticRowIndex: staticRowIndex,
|
|
3625
3702
|
table: table
|
|
3626
3703
|
}),
|
|
3627
|
-
Header: enableSelectAll && enableMultiRowSelection ? ({
|
|
3628
|
-
table
|
|
3629
|
-
}) => /*#__PURE__*/jsx(MRT_SelectCheckbox, {
|
|
3630
|
-
table: table
|
|
3631
|
-
}) : undefined,
|
|
3632
3704
|
grow: false,
|
|
3633
3705
|
...defaultDisplayColumnProps({
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
},
|
|
3638
|
-
header: 'select',
|
|
3639
|
-
id: '__check__',
|
|
3640
|
-
size: 56,
|
|
3706
|
+
header: 'pin',
|
|
3707
|
+
id: 'mrt-row-pin',
|
|
3708
|
+
size: 60,
|
|
3641
3709
|
tableOptions
|
|
3642
3710
|
})
|
|
3643
3711
|
};
|
|
@@ -3815,6 +3883,7 @@ const MRT_Localization_EN = {
|
|
|
3815
3883
|
search: 'Search',
|
|
3816
3884
|
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
3817
3885
|
select: 'Select',
|
|
3886
|
+
selection: 'Selection',
|
|
3818
3887
|
selectAllOnAllPages: 'Select all on all pages',
|
|
3819
3888
|
selectAllOnCurrentPage: 'Select all on current page',
|
|
3820
3889
|
showAll: 'Show all',
|
|
@@ -4482,10 +4551,31 @@ const useMRT_TableInstance = definedTableOptions => {
|
|
|
4482
4551
|
const {
|
|
4483
4552
|
grouping: stateGrouping
|
|
4484
4553
|
} = statefulTableOptions.state;
|
|
4485
|
-
statefulTableOptions.columns = useMemo(() =>
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4554
|
+
statefulTableOptions.columns = useMemo(() => {
|
|
4555
|
+
const displayColumnDefsBefore = [showRowPinningColumn(statefulTableOptions) && getMRT_RowPinningColumnDef(statefulTableOptions), showRowActionsColumn(statefulTableOptions) && getMRT_RowActionsColumnDef(statefulTableOptions), showRowExpandColumn(statefulTableOptions) && getMRT_RowExpandColumnDef(statefulTableOptions), showRowNumbersColumn(statefulTableOptions) && getMRT_RowNumbersColumnDef(statefulTableOptions)].filter(Boolean);
|
|
4556
|
+
|
|
4557
|
+
// Display columns ship with a fixed fallback `size` — a reasonable guess
|
|
4558
|
+
// for before any real content exists (e.g. a checkbox or chevron
|
|
4559
|
+
// button) — but unlike a user-authored column's explicit `size`, that
|
|
4560
|
+
// fallback was never meant to be final. They're autosize candidates the
|
|
4561
|
+
// same as any other column with no explicit size, unless the consumer
|
|
4562
|
+
// pinned one down themselves via `displayColumnDefOptions`. This runs
|
|
4563
|
+
// before `prepareColumns` below for the same reason `rawColumns` is
|
|
4564
|
+
// snapshotted above: once sizes are backfilled, "no explicit size" can
|
|
4565
|
+
// no longer be told apart from "explicitly sized". `mrt-row-spacer` is
|
|
4566
|
+
// structural (tree-depth indentation), never content, so it's excluded
|
|
4567
|
+
// by simply never being added here.
|
|
4568
|
+
displayColumnDefsBefore.forEach(columnDef => {
|
|
4569
|
+
const id = columnDef.id;
|
|
4570
|
+
if (id && displayColumnDefOptions?.[id]?.size === undefined) {
|
|
4571
|
+
autoSizeColumnIdsRef.current.add(id);
|
|
4572
|
+
}
|
|
4573
|
+
});
|
|
4574
|
+
return prepareColumns({
|
|
4575
|
+
columnDefs: [...displayColumnDefsBefore, ...rawColumns, ...[showRowSpacerColumn(statefulTableOptions) && getMRT_RowSpacerColumnDef(statefulTableOptions)].filter(Boolean)],
|
|
4576
|
+
tableOptions: statefulTableOptions
|
|
4577
|
+
});
|
|
4578
|
+
}, [rawColumns, defaultDisplayColumn, displayColumnDefOptions, enableEditing, enableExpanding, enableGrouping, enableRowActions, enableRowNumbers, enableRowPinning, enableRowSelection, layoutMode, localization, renderDetailPanel, rowNumberDisplayMode, rowPinningDisplayMode, stateGrouping]);
|
|
4489
4579
|
|
|
4490
4580
|
//if loading, generate blank rows to show skeleton loaders
|
|
4491
4581
|
// pagination.pageSize is deliberately read here without being a dependency:
|
|
@@ -7350,7 +7440,7 @@ const MRT_IconStatusDot = /*#__PURE__*/forwardRef((t0, ref) => {
|
|
|
7350
7440
|
MRT_IconStatusDot.displayName = 'MRT_IconStatusDot';
|
|
7351
7441
|
|
|
7352
7442
|
const Iconify = /*#__PURE__*/forwardRef((t0, ref) => {
|
|
7353
|
-
const $ = c(
|
|
7443
|
+
const $ = c(16);
|
|
7354
7444
|
let icon;
|
|
7355
7445
|
let other;
|
|
7356
7446
|
let sx;
|
|
@@ -7374,38 +7464,55 @@ const Iconify = /*#__PURE__*/forwardRef((t0, ref) => {
|
|
|
7374
7464
|
t1 = $[4];
|
|
7375
7465
|
}
|
|
7376
7466
|
const width = t1 === undefined ? 20 : t1;
|
|
7467
|
+
const fallbackSize = typeof width === "number" || typeof width === "string" ? width : 20;
|
|
7377
7468
|
let t2;
|
|
7378
|
-
if ($[5] !==
|
|
7379
|
-
t2 = {
|
|
7469
|
+
if ($[5] !== fallbackSize) {
|
|
7470
|
+
t2 = /*#__PURE__*/jsx("span", {
|
|
7471
|
+
style: {
|
|
7472
|
+
display: "inline-block",
|
|
7473
|
+
width: fallbackSize,
|
|
7474
|
+
height: fallbackSize
|
|
7475
|
+
}
|
|
7476
|
+
});
|
|
7477
|
+
$[5] = fallbackSize;
|
|
7478
|
+
$[6] = t2;
|
|
7479
|
+
} else {
|
|
7480
|
+
t2 = $[6];
|
|
7481
|
+
}
|
|
7482
|
+
let t3;
|
|
7483
|
+
if ($[7] !== sx || $[8] !== width) {
|
|
7484
|
+
t3 = {
|
|
7380
7485
|
width,
|
|
7381
7486
|
height: width,
|
|
7382
7487
|
...sx
|
|
7383
7488
|
};
|
|
7384
|
-
$[
|
|
7385
|
-
$[
|
|
7386
|
-
$[
|
|
7489
|
+
$[7] = sx;
|
|
7490
|
+
$[8] = width;
|
|
7491
|
+
$[9] = t3;
|
|
7387
7492
|
} else {
|
|
7388
|
-
|
|
7493
|
+
t3 = $[9];
|
|
7389
7494
|
}
|
|
7390
|
-
let
|
|
7391
|
-
if ($[
|
|
7392
|
-
|
|
7495
|
+
let t4;
|
|
7496
|
+
if ($[10] !== icon || $[11] !== other || $[12] !== ref || $[13] !== t2 || $[14] !== t3) {
|
|
7497
|
+
t4 = /*#__PURE__*/jsx(Box, {
|
|
7393
7498
|
ref: ref,
|
|
7394
7499
|
component: Icon,
|
|
7395
7500
|
className: "component-iconify",
|
|
7396
7501
|
icon: icon,
|
|
7397
|
-
|
|
7502
|
+
fallback: t2,
|
|
7503
|
+
sx: t3,
|
|
7398
7504
|
...other
|
|
7399
7505
|
});
|
|
7400
|
-
$[
|
|
7401
|
-
$[
|
|
7402
|
-
$[
|
|
7403
|
-
$[
|
|
7404
|
-
$[
|
|
7506
|
+
$[10] = icon;
|
|
7507
|
+
$[11] = other;
|
|
7508
|
+
$[12] = ref;
|
|
7509
|
+
$[13] = t2;
|
|
7510
|
+
$[14] = t3;
|
|
7511
|
+
$[15] = t4;
|
|
7405
7512
|
} else {
|
|
7406
|
-
|
|
7513
|
+
t4 = $[15];
|
|
7407
7514
|
}
|
|
7408
|
-
return
|
|
7515
|
+
return t4;
|
|
7409
7516
|
});
|
|
7410
7517
|
var Iconify$1 = Iconify;
|
|
7411
7518
|
|
|
@@ -10192,6 +10299,7 @@ const MRT_Localization_HR = {
|
|
|
10192
10299
|
search: 'Pretraži',
|
|
10193
10300
|
selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
|
|
10194
10301
|
select: 'Odaberi',
|
|
10302
|
+
selection: 'Odabir',
|
|
10195
10303
|
selectAllOnAllPages: 'Odaberi sve na svim stranicama',
|
|
10196
10304
|
selectAllOnCurrentPage: 'Odaberi sve na trenutnoj stranici',
|
|
10197
10305
|
showAll: 'Prikaži sve',
|
|
@@ -12554,7 +12662,7 @@ const MRT_NewEntryButton = t0 => {
|
|
|
12554
12662
|
};
|
|
12555
12663
|
|
|
12556
12664
|
const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
12557
|
-
const $ = c(
|
|
12665
|
+
const $ = c(50);
|
|
12558
12666
|
let allColumns;
|
|
12559
12667
|
let column;
|
|
12560
12668
|
let hoveredColumn;
|
|
@@ -12607,8 +12715,18 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12607
12715
|
columnDefType
|
|
12608
12716
|
} = columnDef;
|
|
12609
12717
|
let t3;
|
|
12610
|
-
if ($[8] !==
|
|
12611
|
-
t3 = (
|
|
12718
|
+
if ($[8] !== column || $[9] !== localization) {
|
|
12719
|
+
t3 = getColumnMenuLabel(column, localization);
|
|
12720
|
+
$[8] = column;
|
|
12721
|
+
$[9] = localization;
|
|
12722
|
+
$[10] = t3;
|
|
12723
|
+
} else {
|
|
12724
|
+
t3 = $[10];
|
|
12725
|
+
}
|
|
12726
|
+
const label = t3;
|
|
12727
|
+
let t4;
|
|
12728
|
+
if ($[11] !== columnDefType) {
|
|
12729
|
+
t4 = (column_0, isCurrentlyVisible) => {
|
|
12612
12730
|
if (columnDefType === "group") {
|
|
12613
12731
|
column_0?.columns?.forEach?.(childColumn => {
|
|
12614
12732
|
childColumn.toggleVisibility(!isCurrentlyVisible);
|
|
@@ -12617,34 +12735,34 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12617
12735
|
column_0.toggleVisibility();
|
|
12618
12736
|
}
|
|
12619
12737
|
};
|
|
12620
|
-
$[
|
|
12621
|
-
$[
|
|
12738
|
+
$[11] = columnDefType;
|
|
12739
|
+
$[12] = t4;
|
|
12622
12740
|
} else {
|
|
12623
|
-
|
|
12741
|
+
t4 = $[12];
|
|
12624
12742
|
}
|
|
12625
|
-
const handleToggleColumnHidden =
|
|
12626
|
-
if (!
|
|
12743
|
+
const handleToggleColumnHidden = t4;
|
|
12744
|
+
if (!label || columnDef.visibleInShowHideMenu === false) {
|
|
12627
12745
|
return null;
|
|
12628
12746
|
}
|
|
12629
|
-
let
|
|
12630
|
-
if ($[
|
|
12631
|
-
|
|
12747
|
+
let t5;
|
|
12748
|
+
if ($[13] !== column || $[14] !== enableHiding || $[15] !== handleToggleColumnHidden || $[16] !== rest) {
|
|
12749
|
+
t5 = event => {
|
|
12632
12750
|
rest?.onClick?.(event);
|
|
12633
12751
|
if (enableHiding && column.getCanHide()) {
|
|
12634
12752
|
handleToggleColumnHidden(column, column.getIsVisible());
|
|
12635
12753
|
}
|
|
12636
12754
|
};
|
|
12637
|
-
$[
|
|
12638
|
-
$[
|
|
12639
|
-
$[
|
|
12640
|
-
$[
|
|
12641
|
-
$[
|
|
12755
|
+
$[13] = column;
|
|
12756
|
+
$[14] = enableHiding;
|
|
12757
|
+
$[15] = handleToggleColumnHidden;
|
|
12758
|
+
$[16] = rest;
|
|
12759
|
+
$[17] = t5;
|
|
12642
12760
|
} else {
|
|
12643
|
-
|
|
12761
|
+
t5 = $[17];
|
|
12644
12762
|
}
|
|
12645
|
-
let
|
|
12646
|
-
if ($[
|
|
12647
|
-
|
|
12763
|
+
let t6;
|
|
12764
|
+
if ($[18] !== column.depth || $[19] !== column.id || $[20] !== draggingBorderColor || $[21] !== hoveredColumn?.id || $[22] !== rest?.sx) {
|
|
12765
|
+
t6 = theme => ({
|
|
12648
12766
|
alignItems: "center",
|
|
12649
12767
|
justifyContent: "flex-start",
|
|
12650
12768
|
my: 0,
|
|
@@ -12654,31 +12772,31 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12654
12772
|
py: "6px",
|
|
12655
12773
|
...parseFromValuesOrFunc(rest?.sx, theme)
|
|
12656
12774
|
});
|
|
12657
|
-
$[
|
|
12658
|
-
$[
|
|
12659
|
-
$[
|
|
12660
|
-
$[
|
|
12661
|
-
$[
|
|
12662
|
-
$[
|
|
12775
|
+
$[18] = column.depth;
|
|
12776
|
+
$[19] = column.id;
|
|
12777
|
+
$[20] = draggingBorderColor;
|
|
12778
|
+
$[21] = hoveredColumn?.id;
|
|
12779
|
+
$[22] = rest?.sx;
|
|
12780
|
+
$[23] = t6;
|
|
12663
12781
|
} else {
|
|
12664
|
-
|
|
12782
|
+
t6 = $[23];
|
|
12665
12783
|
}
|
|
12666
|
-
const
|
|
12667
|
-
let
|
|
12668
|
-
if ($[
|
|
12669
|
-
|
|
12784
|
+
const t7 = `column-show-hide-row-${column.id}`;
|
|
12785
|
+
let t8;
|
|
12786
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
12787
|
+
t8 = {
|
|
12670
12788
|
display: "flex",
|
|
12671
12789
|
flexWrap: "nowrap",
|
|
12672
12790
|
gap: "8px",
|
|
12673
12791
|
width: "100%"
|
|
12674
12792
|
};
|
|
12675
|
-
$[
|
|
12793
|
+
$[24] = t8;
|
|
12676
12794
|
} else {
|
|
12677
|
-
|
|
12795
|
+
t8 = $[24];
|
|
12678
12796
|
}
|
|
12679
|
-
let
|
|
12680
|
-
if ($[
|
|
12681
|
-
|
|
12797
|
+
let t9;
|
|
12798
|
+
if ($[25] !== column || $[26] !== columnDefType || $[27] !== enableHiding || $[28] !== label || $[29] !== localization || $[30] !== table.atoms) {
|
|
12799
|
+
t9 = enableHiding ? /*#__PURE__*/jsx(Subscribe, {
|
|
12682
12800
|
source: table.atoms.columnVisibility,
|
|
12683
12801
|
children: () => {
|
|
12684
12802
|
const switchChecked = column.getIsVisible();
|
|
@@ -12700,7 +12818,7 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12700
12818
|
})
|
|
12701
12819
|
}),
|
|
12702
12820
|
disabled: !column.getCanHide(),
|
|
12703
|
-
label:
|
|
12821
|
+
label: label,
|
|
12704
12822
|
onChange: _temp$g
|
|
12705
12823
|
});
|
|
12706
12824
|
}
|
|
@@ -12708,51 +12826,51 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12708
12826
|
sx: {
|
|
12709
12827
|
alignSelf: "center"
|
|
12710
12828
|
},
|
|
12711
|
-
children:
|
|
12712
|
-
});
|
|
12713
|
-
$[22] = column;
|
|
12714
|
-
$[23] = columnDef.header;
|
|
12715
|
-
$[24] = columnDefType;
|
|
12716
|
-
$[25] = enableHiding;
|
|
12717
|
-
$[26] = localization;
|
|
12718
|
-
$[27] = table.atoms;
|
|
12719
|
-
$[28] = t8;
|
|
12720
|
-
} else {
|
|
12721
|
-
t8 = $[28];
|
|
12722
|
-
}
|
|
12723
|
-
let t9;
|
|
12724
|
-
if ($[29] !== t6 || $[30] !== t8) {
|
|
12725
|
-
t9 = /*#__PURE__*/jsx(Box, {
|
|
12726
|
-
"data-testid": t6,
|
|
12727
|
-
sx: t7,
|
|
12728
|
-
children: t8
|
|
12829
|
+
children: label
|
|
12729
12830
|
});
|
|
12730
|
-
$[
|
|
12731
|
-
$[
|
|
12831
|
+
$[25] = column;
|
|
12832
|
+
$[26] = columnDefType;
|
|
12833
|
+
$[27] = enableHiding;
|
|
12834
|
+
$[28] = label;
|
|
12835
|
+
$[29] = localization;
|
|
12836
|
+
$[30] = table.atoms;
|
|
12732
12837
|
$[31] = t9;
|
|
12733
12838
|
} else {
|
|
12734
12839
|
t9 = $[31];
|
|
12735
12840
|
}
|
|
12736
12841
|
let t10;
|
|
12737
|
-
if ($[32] !==
|
|
12738
|
-
t10 = /*#__PURE__*/jsx(
|
|
12842
|
+
if ($[32] !== t7 || $[33] !== t9) {
|
|
12843
|
+
t10 = /*#__PURE__*/jsx(Box, {
|
|
12844
|
+
"data-testid": t7,
|
|
12845
|
+
sx: t8,
|
|
12846
|
+
children: t9
|
|
12847
|
+
});
|
|
12848
|
+
$[32] = t7;
|
|
12849
|
+
$[33] = t9;
|
|
12850
|
+
$[34] = t10;
|
|
12851
|
+
} else {
|
|
12852
|
+
t10 = $[34];
|
|
12853
|
+
}
|
|
12854
|
+
let t11;
|
|
12855
|
+
if ($[35] !== rest || $[36] !== t10 || $[37] !== t5 || $[38] !== t6) {
|
|
12856
|
+
t11 = /*#__PURE__*/jsx(MenuItem, {
|
|
12739
12857
|
disableRipple: true,
|
|
12740
12858
|
...rest,
|
|
12741
|
-
onClick:
|
|
12742
|
-
sx:
|
|
12743
|
-
children:
|
|
12859
|
+
onClick: t5,
|
|
12860
|
+
sx: t6,
|
|
12861
|
+
children: t10
|
|
12744
12862
|
});
|
|
12745
|
-
$[
|
|
12746
|
-
$[33] = t4;
|
|
12747
|
-
$[34] = t5;
|
|
12748
|
-
$[35] = t9;
|
|
12863
|
+
$[35] = rest;
|
|
12749
12864
|
$[36] = t10;
|
|
12865
|
+
$[37] = t5;
|
|
12866
|
+
$[38] = t6;
|
|
12867
|
+
$[39] = t11;
|
|
12750
12868
|
} else {
|
|
12751
|
-
|
|
12869
|
+
t11 = $[39];
|
|
12752
12870
|
}
|
|
12753
|
-
let
|
|
12754
|
-
if ($[
|
|
12755
|
-
|
|
12871
|
+
let t12;
|
|
12872
|
+
if ($[40] !== allColumns || $[41] !== column.columns || $[42] !== hoveredColumn || $[43] !== isNestedColumns || $[44] !== setHoveredColumn || $[45] !== table) {
|
|
12873
|
+
t12 = column.columns?.map((c, i) => /*#__PURE__*/jsx(MRT_ShowHideColumnsMenuItems, {
|
|
12756
12874
|
allColumns: allColumns,
|
|
12757
12875
|
column: c,
|
|
12758
12876
|
hoveredColumn: hoveredColumn,
|
|
@@ -12760,40 +12878,37 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
|
|
|
12760
12878
|
setHoveredColumn: setHoveredColumn,
|
|
12761
12879
|
table: table
|
|
12762
12880
|
}, `${i}-${c.id}`));
|
|
12763
|
-
$[
|
|
12764
|
-
$[
|
|
12765
|
-
$[
|
|
12766
|
-
$[
|
|
12767
|
-
$[
|
|
12768
|
-
$[
|
|
12769
|
-
$[
|
|
12881
|
+
$[40] = allColumns;
|
|
12882
|
+
$[41] = column.columns;
|
|
12883
|
+
$[42] = hoveredColumn;
|
|
12884
|
+
$[43] = isNestedColumns;
|
|
12885
|
+
$[44] = setHoveredColumn;
|
|
12886
|
+
$[45] = table;
|
|
12887
|
+
$[46] = t12;
|
|
12770
12888
|
} else {
|
|
12771
|
-
|
|
12889
|
+
t12 = $[46];
|
|
12772
12890
|
}
|
|
12773
|
-
let
|
|
12774
|
-
if ($[
|
|
12775
|
-
|
|
12776
|
-
children: [
|
|
12891
|
+
let t13;
|
|
12892
|
+
if ($[47] !== t11 || $[48] !== t12) {
|
|
12893
|
+
t13 = /*#__PURE__*/jsxs(Fragment, {
|
|
12894
|
+
children: [t11, t12]
|
|
12777
12895
|
});
|
|
12778
|
-
$[
|
|
12779
|
-
$[
|
|
12780
|
-
$[
|
|
12896
|
+
$[47] = t11;
|
|
12897
|
+
$[48] = t12;
|
|
12898
|
+
$[49] = t13;
|
|
12781
12899
|
} else {
|
|
12782
|
-
|
|
12900
|
+
t13 = $[49];
|
|
12783
12901
|
}
|
|
12784
|
-
return
|
|
12902
|
+
return t13;
|
|
12785
12903
|
};
|
|
12786
12904
|
function _temp$g() {}
|
|
12787
12905
|
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
// children rather than filtering within the group, so the tree stays intact.
|
|
12791
|
-
const columnMatchesSearch = (column, term) => {
|
|
12792
|
-
const header = column.columnDef.header;
|
|
12906
|
+
const columnMatchesSearch = (column, term, localization) => {
|
|
12907
|
+
const header = getColumnMenuLabel(column, localization);
|
|
12793
12908
|
if (typeof header === 'string' && header.toLowerCase().includes(term)) {
|
|
12794
12909
|
return true;
|
|
12795
12910
|
}
|
|
12796
|
-
return !!column.columns?.some(child => columnMatchesSearch(child, term));
|
|
12911
|
+
return !!column.columns?.some(child => columnMatchesSearch(child, term, localization));
|
|
12797
12912
|
};
|
|
12798
12913
|
const MRT_ShowHideColumnsMenu = ({
|
|
12799
12914
|
anchorEl,
|
|
@@ -12850,8 +12965,8 @@ const MRT_ShowHideColumnsMenu = ({
|
|
|
12850
12965
|
const trimmedSearchText = searchText.trim().toLowerCase();
|
|
12851
12966
|
const filteredColumns = useMemo(() => {
|
|
12852
12967
|
if (!trimmedSearchText) return allColumns;
|
|
12853
|
-
return allColumns.filter(column_1 => columnMatchesSearch(column_1, trimmedSearchText));
|
|
12854
|
-
}, [allColumns, trimmedSearchText]);
|
|
12968
|
+
return allColumns.filter(column_1 => columnMatchesSearch(column_1, trimmedSearchText, localization));
|
|
12969
|
+
}, [allColumns, trimmedSearchText, localization]);
|
|
12855
12970
|
const handleSearchChange = event => {
|
|
12856
12971
|
setSearchText(event.target.value);
|
|
12857
12972
|
};
|
|
@@ -13811,7 +13926,7 @@ const BODY_CELL_SELECTOR = '[data-column-id]';
|
|
|
13811
13926
|
* the container. Once every candidate is settled it is an early return.
|
|
13812
13927
|
*/
|
|
13813
13928
|
const MRT_AutoSizeColumnsEffect = t0 => {
|
|
13814
|
-
const $ = c(
|
|
13929
|
+
const $ = c(10);
|
|
13815
13930
|
const {
|
|
13816
13931
|
table
|
|
13817
13932
|
} = t0;
|
|
@@ -13836,7 +13951,7 @@ const MRT_AutoSizeColumnsEffect = t0 => {
|
|
|
13836
13951
|
}
|
|
13837
13952
|
const settledIdsRef = useRef(t2);
|
|
13838
13953
|
let t3;
|
|
13839
|
-
if ($[1] !== autoSizeColumnIdsRef || $[2] !== autoSizedColumnWidthsRef || $[3] !== getColumn || $[4] !== getRowModel || $[5] !== getState || $[6] !== setColumnSizing || $[7] !== tableRef) {
|
|
13954
|
+
if ($[1] !== autoSizeColumnIdsRef || $[2] !== autoSizedColumnWidthsRef || $[3] !== getColumn || $[4] !== getRowModel || $[5] !== getState || $[6] !== setColumnSizing || $[7] !== table || $[8] !== tableRef) {
|
|
13840
13955
|
t3 = () => {
|
|
13841
13956
|
const candidateIds = autoSizeColumnIdsRef.current;
|
|
13842
13957
|
const settledIds = settledIdsRef.current;
|
|
@@ -13879,6 +13994,31 @@ const MRT_AutoSizeColumnsEffect = t0 => {
|
|
|
13879
13994
|
});
|
|
13880
13995
|
});
|
|
13881
13996
|
if (Object.keys(updates).length) {
|
|
13997
|
+
for (const header of table.getFlatHeaders()) {
|
|
13998
|
+
const width = updates[header.column.id];
|
|
13999
|
+
if (width === undefined) {
|
|
14000
|
+
continue;
|
|
14001
|
+
}
|
|
14002
|
+
tableEl.style.setProperty(`--header-${parseCSSVarId(header.id)}-size`, `${width}`);
|
|
14003
|
+
tableEl.style.setProperty(`--col-${parseCSSVarId(header.column.id)}-size`, `${width}`);
|
|
14004
|
+
tableEl.style.setProperty(`--col-${parseCSSVarId(header.column.id)}-grow`, `${getColumnGrowWeight(header.column, table)}`);
|
|
14005
|
+
}
|
|
14006
|
+
if (table.options.layoutMode?.startsWith("grid")) {
|
|
14007
|
+
for (const columnId_0 of Object.keys(updates)) {
|
|
14008
|
+
const column_0 = getColumn(columnId_0);
|
|
14009
|
+
if (!getColumnGrowWeight(column_0, table)) {
|
|
14010
|
+
continue;
|
|
14011
|
+
}
|
|
14012
|
+
const cell = tableEl.querySelector(`[data-column-id="${CSS.escape(columnId_0)}"]`) ?? table.refs.tableHeadCellRefs.current?.[columnId_0];
|
|
14013
|
+
const renderedWidth = cell?.getBoundingClientRect().width ?? 0;
|
|
14014
|
+
const {
|
|
14015
|
+
maxSize
|
|
14016
|
+
} = getColumnSizeBounds(column_0.columnDef);
|
|
14017
|
+
if (renderedWidth > updates[columnId_0]) {
|
|
14018
|
+
updates[columnId_0] = Math.min(renderedWidth, maxSize);
|
|
14019
|
+
}
|
|
14020
|
+
}
|
|
14021
|
+
}
|
|
13882
14022
|
Object.assign(autoSizedColumnWidthsRef.current, updates);
|
|
13883
14023
|
setColumnSizing(old => ({
|
|
13884
14024
|
...old,
|
|
@@ -13892,10 +14032,11 @@ const MRT_AutoSizeColumnsEffect = t0 => {
|
|
|
13892
14032
|
$[4] = getRowModel;
|
|
13893
14033
|
$[5] = getState;
|
|
13894
14034
|
$[6] = setColumnSizing;
|
|
13895
|
-
$[7] =
|
|
13896
|
-
$[8] =
|
|
14035
|
+
$[7] = table;
|
|
14036
|
+
$[8] = tableRef;
|
|
14037
|
+
$[9] = t3;
|
|
13897
14038
|
} else {
|
|
13898
|
-
t3 = $[
|
|
14039
|
+
t3 = $[9];
|
|
13899
14040
|
}
|
|
13900
14041
|
useLayoutEffect(t3);
|
|
13901
14042
|
return null;
|
|
@@ -14401,10 +14542,17 @@ const MRT_TableBodyCell = ({
|
|
|
14401
14542
|
const size = column.getSize();
|
|
14402
14543
|
setSkeletonWidth(columnDefType === 'display' ? size / 2 : Math.round(Math.random() * (size - size / 3) + size / 3));
|
|
14403
14544
|
}, [isLoading, showSkeletons]);
|
|
14545
|
+
|
|
14546
|
+
// Asserted with `!important` so this always wins over a consumer's own
|
|
14547
|
+
// `MuiTableCell`/`MuiTableRow` theme overrides (e.g. the common MUI docs
|
|
14548
|
+
// pattern of stripping the last row's border via `&:last-child td`) —
|
|
14549
|
+
// the last row keeping its bottom border is part of MRT's own visual
|
|
14550
|
+
// contract, not something a host app's table theme should be able to undo.
|
|
14551
|
+
const isLastRow = !!numRows && staticRowIndex === numRows - 1;
|
|
14552
|
+
const lastRowBorderBottom = isLastRow ? `1px solid ${theme.palette.divider} !important` : undefined;
|
|
14404
14553
|
const draggingBorders = useMemo(() => {
|
|
14405
14554
|
const isFirstColumn = column.getIsFirstColumn();
|
|
14406
14555
|
const isLastColumn = column.getIsLastColumn();
|
|
14407
|
-
const isLastRow = numRows && staticRowIndex === numRows - 1;
|
|
14408
14556
|
const isResizingColumn = isResizingThisColumn;
|
|
14409
14557
|
const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
|
|
14410
14558
|
const borderStyle = showResizeBorder ? `2px solid ${draggingBorderColor} !important` : isDraggingColumn || isDraggingRow ? `1px dashed ${theme.palette.grey[500]} !important` : isHoveredColumn || isHoveredRow || isResizingColumn ? `2px dashed ${draggingBorderColor} !important` : undefined;
|
|
@@ -14416,12 +14564,12 @@ const MRT_TableBodyCell = ({
|
|
|
14416
14564
|
};
|
|
14417
14565
|
}
|
|
14418
14566
|
return borderStyle ? {
|
|
14419
|
-
borderBottom: isDraggingRow || isHoveredRow || isLastRow && !isResizingColumn ? borderStyle :
|
|
14567
|
+
borderBottom: isDraggingRow || isHoveredRow || isLastRow && !isResizingColumn ? borderStyle : lastRowBorderBottom,
|
|
14420
14568
|
borderLeft: isDraggingColumn || isHoveredColumn || (isDraggingRow || isHoveredRow) && isFirstColumn ? borderStyle : undefined,
|
|
14421
14569
|
borderRight: isDraggingColumn || isHoveredColumn || (isDraggingRow || isHoveredRow) && isLastColumn ? borderStyle : undefined,
|
|
14422
14570
|
borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined
|
|
14423
14571
|
} : undefined;
|
|
14424
|
-
}, [isResizingThisColumn, isDraggingColumn, isDraggingRow, isHoveredColumn, isHoveredRow,
|
|
14572
|
+
}, [isResizingThisColumn, isDraggingColumn, isDraggingRow, isHoveredColumn, isHoveredRow, isLastRow, lastRowBorderBottom]);
|
|
14425
14573
|
const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
14426
14574
|
const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
|
|
14427
14575
|
const cellValueProps = {
|
|
@@ -14468,6 +14616,7 @@ const MRT_TableBodyCell = ({
|
|
|
14468
14616
|
textOverflow: 'clip'
|
|
14469
14617
|
},
|
|
14470
14618
|
alignItems: layoutMode?.startsWith('grid') ? 'center' : undefined,
|
|
14619
|
+
borderBottom: lastRowBorderBottom,
|
|
14471
14620
|
cursor: isRightClickable ? 'context-menu' : 'inherit',
|
|
14472
14621
|
outline: isActionCell ? `1px solid ${theme_0.palette.grey[500]}` : undefined,
|
|
14473
14622
|
outlineOffset: '-1px',
|
|
@@ -16707,8 +16856,9 @@ const MRT_TableHeadCellResizeHandle = ({
|
|
|
16707
16856
|
const {
|
|
16708
16857
|
column
|
|
16709
16858
|
} = header;
|
|
16710
|
-
const
|
|
16711
|
-
const
|
|
16859
|
+
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
16860
|
+
const mx = isCheckboxColumn ? '0' : density === 'compact' ? '-2px' : density === 'comfortable' ? '-16px' : '-24px';
|
|
16861
|
+
const lr = !isCheckboxColumn && column.columnDef.columnDefType === 'display' ? '4px' : '0';
|
|
16712
16862
|
|
|
16713
16863
|
// Drives the resize purely through refs/DOM writes (CSS vars + the indicator line) so
|
|
16714
16864
|
// dragging causes zero React renders; the only state write is the commit on release.
|
|
@@ -16893,7 +17043,9 @@ const MRT_TableHeadCellResizeHandle = ({
|
|
|
16893
17043
|
mr: columnResizeDirection === 'ltr' ? mx : undefined,
|
|
16894
17044
|
position: 'absolute',
|
|
16895
17045
|
px: '4px',
|
|
16896
|
-
right: columnResizeDirection === 'ltr' ? lr : undefined
|
|
17046
|
+
right: columnResizeDirection === 'ltr' ? lr : undefined,
|
|
17047
|
+
top: isCheckboxColumn ? '50%' : undefined,
|
|
17048
|
+
transform: isCheckboxColumn ? 'translateY(-50%)' : undefined
|
|
16897
17049
|
}),
|
|
16898
17050
|
children: /*#__PURE__*/jsx(Divider, {
|
|
16899
17051
|
className: "Mui-TableHeadCell-ResizeHandle-Divider",
|
|
@@ -16904,7 +17056,7 @@ const MRT_TableHeadCellResizeHandle = ({
|
|
|
16904
17056
|
borderWidth: '1px',
|
|
16905
17057
|
height: '24px',
|
|
16906
17058
|
touchAction: 'none',
|
|
16907
|
-
transform: 'translateX(4px)',
|
|
17059
|
+
transform: isCheckboxColumn && columnResizeDirection === 'rtl' ? 'translateX(-4px)' : 'translateX(4px)',
|
|
16908
17060
|
transition: column.getIsResizing() ? undefined : 'all 150ms ease-in-out',
|
|
16909
17061
|
userSelect: 'none',
|
|
16910
17062
|
zIndex: 4,
|
|
@@ -17162,7 +17314,7 @@ const MRT_TableHeadCell = ({
|
|
|
17162
17314
|
header,
|
|
17163
17315
|
table
|
|
17164
17316
|
}) ?? columnDef.header;
|
|
17165
|
-
return /*#__PURE__*/
|
|
17317
|
+
return /*#__PURE__*/jsxs(TableCell, {
|
|
17166
17318
|
align: columnDefType === 'group' ? 'center' : theme.direction === 'rtl' ? 'right' : 'left',
|
|
17167
17319
|
"aria-sort": column.getIsSorted() ? column.getIsSorted() === 'asc' ? 'ascending' : 'descending' : 'none',
|
|
17168
17320
|
colSpan: header.colSpan,
|
|
@@ -17201,7 +17353,7 @@ const MRT_TableHeadCell = ({
|
|
|
17201
17353
|
}),
|
|
17202
17354
|
...draggingBorders
|
|
17203
17355
|
}),
|
|
17204
|
-
children: header.isPlaceholder ? null : tableCellProps.children ?? /*#__PURE__*/jsxs(Box, {
|
|
17356
|
+
children: [header.isPlaceholder ? null : tableCellProps.children ?? /*#__PURE__*/jsxs(Box, {
|
|
17205
17357
|
className: "Mui-TableHeadCell-Content",
|
|
17206
17358
|
sx: {
|
|
17207
17359
|
alignItems: 'center',
|
|
@@ -17273,11 +17425,14 @@ const MRT_TableHeadCell = ({
|
|
|
17273
17425
|
current: tableHeadCellRefs.current?.[column.id]
|
|
17274
17426
|
}
|
|
17275
17427
|
})]
|
|
17276
|
-
}), column.getCanResize() && /*#__PURE__*/jsx(MRT_TableHeadCellResizeHandle, {
|
|
17428
|
+
}), column.getCanResize() && !isCheckboxColumn && /*#__PURE__*/jsx(MRT_TableHeadCellResizeHandle, {
|
|
17277
17429
|
header: header,
|
|
17278
17430
|
table: table
|
|
17279
17431
|
})]
|
|
17280
|
-
})
|
|
17432
|
+
}), column.getCanResize() && isCheckboxColumn && !header.isPlaceholder && /*#__PURE__*/jsx(MRT_TableHeadCellResizeHandle, {
|
|
17433
|
+
header: header,
|
|
17434
|
+
table: table
|
|
17435
|
+
})]
|
|
17281
17436
|
});
|
|
17282
17437
|
};
|
|
17283
17438
|
|
|
@@ -20844,5 +20999,5 @@ function _temp2(state_0) {
|
|
|
20844
20999
|
};
|
|
20845
21000
|
}
|
|
20846
21001
|
|
|
20847
|
-
export { CHECKBOX_DISPLAY_COLUMN_ID, MRT_ActionMenuItem, MRT_AdvancedFilters, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_ExpandAllButton, MRT_ExpandButton, MRT_ExportsToolbar, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_NewEntryForm, MRT_NewEntryFormActions, MRT_NewEntryFormActionsContext, MRT_NewEntryFormProvider, MRT_NewEntryModal, MRT_PaginationBoundsEffect, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectAllMenuItems, MRT_SelectCheckbox, MRT_SelectionCountBadge, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactServerTable, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, RHF_FormProvider, buildDefaultValues, createDeleteAction, createEditAction, createExportAction, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getAutoSizeCandidateColumnIds, getColumnId, getDefaultColumnOrderIds, getIsAllPagesSelectionActive, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, groupFieldsBySection, normalizeRowExpandColumnOrder, prepareColumns, reorderColumn, resolveFormFields, showRowActionsColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn,
|
|
21002
|
+
export { ACTIONS_DISPLAY_COLUMN_ID, CHECKBOX_DISPLAY_COLUMN_ID, MRT_ActionMenuItem, MRT_AdvancedFilters, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_ExpandAllButton, MRT_ExpandButton, MRT_ExportsToolbar, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_NewEntryForm, MRT_NewEntryFormActions, MRT_NewEntryFormActionsContext, MRT_NewEntryFormProvider, MRT_NewEntryModal, MRT_PaginationBoundsEffect, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectAllMenuItems, MRT_SelectCheckbox, MRT_SelectionCountBadge, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactServerTable, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, RHF_FormProvider, buildDefaultValues, columnsIncludeCheckboxSelection, columnsIncludeRowActions, createDeleteAction, createEditAction, createExportAction, createMRTColumnHelper, createRow, decorateCheckboxSelectionColumn, decorateRowActionsColumn, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getAutoSizeCandidateColumnIds, getCheckboxSelectionCellAndHeader, getColumnId, getColumnMenuLabel, getDefaultColumnOrderIds, getIsAllPagesSelectionActive, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getRowActionsCell, getTrailingDisplayColumnIds, groupFieldsBySection, normalizeRowExpandColumnOrder, prepareColumns, reorderColumn, resolveFormFields, showRowActionsColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSpacerColumn, sortByOrder, toAdditionalRenderEntries, toColumnRenderEntries, useMRT_ColumnVirtualizer, useMRT_NewEntryFormActions, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
20848
21003
|
//# sourceMappingURL=index.esm.js.map
|