@redsift/table 11.11.0-muiv7 → 11.11.0-muiv8-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_internal/BaseComponents.js +1 -1
- package/_internal/BaseIconButton.js +117 -0
- package/_internal/BaseIconButton.js.map +1 -0
- package/_internal/DataGrid2.js +48 -32
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/{ControlledPagination.js → ServerSideControlledPagination.js} +7533 -740
- package/_internal/ServerSideControlledPagination.js.map +1 -0
- package/_internal/StatefulDataGrid2.js +103 -47
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +1 -1
- package/_internal/useControlledDatagridState.js +76 -115
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +284 -80
- package/index.js +2 -2
- package/package.json +7 -7
- package/_internal/BasePopper.js +0 -2452
- package/_internal/BasePopper.js.map +0 -1
- package/_internal/ControlledPagination.js.map +0 -1
- package/_internal/Portal.js +0 -6563
- package/_internal/Portal.js.map +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { useCallback, useEffect, useMemo, forwardRef,
|
|
3
|
+
import React__default, { useCallback, useEffect, useRef, useMemo, forwardRef, useState } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { Icon, useTheme as useTheme$1, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite, ThemeProvider } from '@redsift/design-system';
|
|
6
6
|
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef, DataGridPro, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
|
|
7
7
|
import { L as LicenseInfo, u as useControlledDatagridState, T as ThemeProvider$1, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
8
8
|
import { mdiSync } from '@redsift/icons';
|
|
9
|
-
import { d as defaultSxConfig,
|
|
9
|
+
import { d as defaultSxConfig, b as isPlainObject, s as styled, e as styleFunctionSx, u as useTheme, f as clsx, h as generateUtilityClasses, j as createTheme, T as THEME_ID, k as ClassNameGenerator, P as PropTypes, l as generateUtilityClass, m as styled$1, n as memoTheme, p as createSimplePaletteValueFilter, q as useDefaultProps, r as useFormControl, t as formControlState, v as capitalize, w as composeClasses, x as rootShouldForwardProp, y as isAdornedStart, z as isFilled, F as FormControlContext, A as useId, B as useSlot, D as Select, G as refType, I as Input, H as FilledInput, O as OutlinedInput, E as EMPTY_ROW_SELECTION_MODEL, o as onServerSideSelectionStatusChange, g as getSelectionCount, S as ServerSideControlledPagination, C as ControlledPagination } from './ServerSideControlledPagination.js';
|
|
10
10
|
import { j as jsxRuntimeExports } from './jsx-runtime.js';
|
|
11
|
-
import { u as useTheme, m as memoTheme, c as createSimplePaletteValueFilter, a as useFormControl, f as formControlState, b as capitalize, i as isAdornedStart, d as isFilled, F as FormControlContext, e as useId, g as useSlot, h as Select, I as Input, j as FilledInput, O as OutlinedInput, o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination } from './ControlledPagination.js';
|
|
12
11
|
import { T as Toolbar } from './Toolbar2.js';
|
|
13
|
-
import { B as BaseButton, a as BaseCheckbox, c as BasePopper, b as BaseIcon } from './BasePopper.js';
|
|
14
12
|
import { T as ToolbarWrapper } from './ToolbarWrapper2.js';
|
|
13
|
+
import { B as BaseButton, c as BaseIconButton, a as BaseCheckbox, b as BaseIcon } from './BaseIconButton.js';
|
|
15
14
|
|
|
16
15
|
const splitProps = props => {
|
|
17
16
|
const result = {
|
|
@@ -93,7 +92,7 @@ function createBox(options = {}) {
|
|
|
93
92
|
|
|
94
93
|
function isMuiElement(element, muiNames) {
|
|
95
94
|
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(
|
|
96
|
-
// For server components `muiName` is
|
|
95
|
+
// For server components `muiName` is available in element.type._payload.value.muiName
|
|
97
96
|
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
|
|
98
97
|
// eslint-disable-next-line no-underscore-dangle
|
|
99
98
|
element.type.muiName ?? element.type?._payload?.value?.muiName) !== -1;
|
|
@@ -192,8 +191,7 @@ const FormLabelRoot = styled$1('label', {
|
|
|
192
191
|
})));
|
|
193
192
|
const AsteriskComponent = styled$1('span', {
|
|
194
193
|
name: 'MuiFormLabel',
|
|
195
|
-
slot: 'Asterisk'
|
|
196
|
-
overridesResolver: (props, styles) => styles.asterisk
|
|
194
|
+
slot: 'Asterisk'
|
|
197
195
|
})(memoTheme(({
|
|
198
196
|
theme
|
|
199
197
|
}) => ({
|
|
@@ -320,7 +318,7 @@ const useUtilityClasses$3 = ownerState => {
|
|
|
320
318
|
required
|
|
321
319
|
} = ownerState;
|
|
322
320
|
const slots = {
|
|
323
|
-
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== '
|
|
321
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== 'medium' && `size${capitalize(size)}`, variant],
|
|
324
322
|
asterisk: [required && 'asterisk']
|
|
325
323
|
};
|
|
326
324
|
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
@@ -563,9 +561,9 @@ process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes
|
|
|
563
561
|
shrink: PropTypes.bool,
|
|
564
562
|
/**
|
|
565
563
|
* The size of the component.
|
|
566
|
-
* @default '
|
|
564
|
+
* @default 'medium'
|
|
567
565
|
*/
|
|
568
|
-
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['
|
|
566
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
569
567
|
/**
|
|
570
568
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
571
569
|
*/
|
|
@@ -1074,8 +1072,7 @@ const useUtilityClasses = ownerState => {
|
|
|
1074
1072
|
};
|
|
1075
1073
|
const TextFieldRoot = styled$1(FormControl$1, {
|
|
1076
1074
|
name: 'MuiTextField',
|
|
1077
|
-
slot: 'Root'
|
|
1078
|
-
overridesResolver: (props, styles) => styles.root
|
|
1075
|
+
slot: 'Root'
|
|
1079
1076
|
})({});
|
|
1080
1077
|
|
|
1081
1078
|
/**
|
|
@@ -1343,7 +1340,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1343
1340
|
error: PropTypes.bool,
|
|
1344
1341
|
/**
|
|
1345
1342
|
* Props applied to the [`FormHelperText`](https://mui.com/material-ui/api/form-helper-text/) element.
|
|
1346
|
-
* @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in
|
|
1343
|
+
* @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1347
1344
|
*/
|
|
1348
1345
|
FormHelperTextProps: PropTypes.object,
|
|
1349
1346
|
/**
|
|
@@ -1363,12 +1360,12 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1363
1360
|
/**
|
|
1364
1361
|
* Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
|
|
1365
1362
|
* Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
|
|
1366
|
-
* @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in
|
|
1363
|
+
* @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1367
1364
|
*/
|
|
1368
1365
|
InputLabelProps: PropTypes.object,
|
|
1369
1366
|
/**
|
|
1370
|
-
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
1371
|
-
* @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in
|
|
1367
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
|
|
1368
|
+
* @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1372
1369
|
*/
|
|
1373
1370
|
inputProps: PropTypes.object,
|
|
1374
1371
|
/**
|
|
@@ -1376,7 +1373,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1376
1373
|
* It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
|
|
1377
1374
|
* [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
|
|
1378
1375
|
* component depending on the `variant` prop value.
|
|
1379
|
-
* @deprecated Use `slotProps.input` instead. This prop will be removed in
|
|
1376
|
+
* @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1380
1377
|
*/
|
|
1381
1378
|
InputProps: PropTypes.object,
|
|
1382
1379
|
/**
|
|
@@ -1445,7 +1442,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1445
1442
|
select: PropTypes.bool,
|
|
1446
1443
|
/**
|
|
1447
1444
|
* Props applied to the [`Select`](https://mui.com/material-ui/api/select/) element.
|
|
1448
|
-
* @deprecated Use `slotProps.select` instead. This prop will be removed in
|
|
1445
|
+
* @deprecated Use `slotProps.select` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1449
1446
|
*/
|
|
1450
1447
|
SelectProps: PropTypes.object,
|
|
1451
1448
|
/**
|
|
@@ -1481,9 +1478,9 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1481
1478
|
*/
|
|
1482
1479
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1483
1480
|
/**
|
|
1484
|
-
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
1481
|
+
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types).
|
|
1485
1482
|
*/
|
|
1486
|
-
type: PropTypes
|
|
1483
|
+
type: PropTypes.string,
|
|
1487
1484
|
/**
|
|
1488
1485
|
* The value of the `input` element, required for a controlled component.
|
|
1489
1486
|
*/
|
|
@@ -3132,6 +3129,25 @@ const useTableStates = (id, version) => {
|
|
|
3132
3129
|
};
|
|
3133
3130
|
};
|
|
3134
3131
|
|
|
3132
|
+
/**
|
|
3133
|
+
* Deep comparison for objects to maintain stable references.
|
|
3134
|
+
* MUI DataGrid v8 resets pagination when it detects filter/sort model changes.
|
|
3135
|
+
* We need to ensure stable references when values are the same.
|
|
3136
|
+
*/
|
|
3137
|
+
const isDeepEqual = (a, b) => {
|
|
3138
|
+
if (a === b) return true;
|
|
3139
|
+
if (a == null || b == null) return a === b;
|
|
3140
|
+
if (typeof a !== 'object' || typeof b !== 'object') return a === b;
|
|
3141
|
+
const aKeys = Object.keys(a);
|
|
3142
|
+
const bKeys = Object.keys(b);
|
|
3143
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
3144
|
+
for (const key of aKeys) {
|
|
3145
|
+
if (!isDeepEqual(a[key], b[key])) {
|
|
3146
|
+
return false;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
return true;
|
|
3150
|
+
};
|
|
3135
3151
|
const useStatefulTable = props => {
|
|
3136
3152
|
const {
|
|
3137
3153
|
// density = 'standard',
|
|
@@ -3182,13 +3198,7 @@ const useStatefulTable = props => {
|
|
|
3182
3198
|
[field]: newWidth
|
|
3183
3199
|
}));
|
|
3184
3200
|
}, [dimensionModel, setDimensionModel]);
|
|
3185
|
-
const {
|
|
3186
|
-
filterModel: filterParsed,
|
|
3187
|
-
sortModel: sortModelParsed,
|
|
3188
|
-
paginationModel: paginationModelParsed,
|
|
3189
|
-
columnVisibilityModel: visibilityModel,
|
|
3190
|
-
pinnedColumnsModel
|
|
3191
|
-
} = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, historyReplace, initialState, {
|
|
3201
|
+
const parsedModels = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, historyReplace, initialState, {
|
|
3192
3202
|
localStorageFilters,
|
|
3193
3203
|
setLocalStorageFilters,
|
|
3194
3204
|
localStorageSorting: sortModel,
|
|
@@ -3200,6 +3210,39 @@ const useStatefulTable = props => {
|
|
|
3200
3210
|
localStoragePinnedColumns: pinnedColumns,
|
|
3201
3211
|
setLocalStoragePinnedColumns: setPinnedColumns
|
|
3202
3212
|
});
|
|
3213
|
+
|
|
3214
|
+
// MUI DataGrid v8 auto-resets pagination when filter/sort models change.
|
|
3215
|
+
// We use refs with deep comparison to maintain stable references when values are equal.
|
|
3216
|
+
// This prevents false "change" detections that would reset pagination.
|
|
3217
|
+
const filterModelRef = useRef(parsedModels.filterModel);
|
|
3218
|
+
const sortModelRef = useRef(parsedModels.sortModel);
|
|
3219
|
+
const paginationModelRef = useRef(parsedModels.paginationModel);
|
|
3220
|
+
const columnVisibilityModelRef = useRef(parsedModels.columnVisibilityModel);
|
|
3221
|
+
const pinnedColumnsModelRef = useRef(parsedModels.pinnedColumnsModel);
|
|
3222
|
+
|
|
3223
|
+
// Only update refs if values actually changed (deep comparison)
|
|
3224
|
+
if (!isDeepEqual(filterModelRef.current, parsedModels.filterModel)) {
|
|
3225
|
+
filterModelRef.current = parsedModels.filterModel;
|
|
3226
|
+
}
|
|
3227
|
+
if (!isDeepEqual(sortModelRef.current, parsedModels.sortModel)) {
|
|
3228
|
+
sortModelRef.current = parsedModels.sortModel;
|
|
3229
|
+
}
|
|
3230
|
+
if (!isDeepEqual(paginationModelRef.current, parsedModels.paginationModel)) {
|
|
3231
|
+
paginationModelRef.current = parsedModels.paginationModel;
|
|
3232
|
+
}
|
|
3233
|
+
if (!isDeepEqual(columnVisibilityModelRef.current, parsedModels.columnVisibilityModel)) {
|
|
3234
|
+
columnVisibilityModelRef.current = parsedModels.columnVisibilityModel;
|
|
3235
|
+
}
|
|
3236
|
+
if (!isDeepEqual(pinnedColumnsModelRef.current, parsedModels.pinnedColumnsModel)) {
|
|
3237
|
+
pinnedColumnsModelRef.current = parsedModels.pinnedColumnsModel;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// Use the stable references
|
|
3241
|
+
const filterParsed = filterModelRef.current;
|
|
3242
|
+
const sortModelParsed = sortModelRef.current;
|
|
3243
|
+
const paginationModelParsed = paginationModelRef.current;
|
|
3244
|
+
const visibilityModel = columnVisibilityModelRef.current;
|
|
3245
|
+
const pinnedColumnsModel = pinnedColumnsModelRef.current;
|
|
3203
3246
|
const columns = useMemo(() => propsColumns.map(column => {
|
|
3204
3247
|
column.width = dimensionModel[column.field] || column.width || 100;
|
|
3205
3248
|
return column;
|
|
@@ -3207,70 +3250,81 @@ const useStatefulTable = props => {
|
|
|
3207
3250
|
if (apiRef.current) {
|
|
3208
3251
|
/** Add resetPage method to apiRef. */
|
|
3209
3252
|
apiRef.current.resetPage = () => {
|
|
3210
|
-
|
|
3253
|
+
var _apiRef$current;
|
|
3254
|
+
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPage(0);
|
|
3211
3255
|
};
|
|
3212
3256
|
}
|
|
3213
3257
|
return {
|
|
3214
3258
|
apiRef,
|
|
3215
3259
|
columns,
|
|
3216
3260
|
onFilterModelChange: (model, details) => {
|
|
3261
|
+
var _apiRef$current$state, _apiRef$current3;
|
|
3217
3262
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
3218
3263
|
items: model.items.map(item => {
|
|
3219
|
-
|
|
3220
|
-
|
|
3264
|
+
var _apiRef$current2;
|
|
3265
|
+
const column = (_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.getColumn(item.field);
|
|
3266
|
+
item.type = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
3221
3267
|
return item;
|
|
3222
3268
|
}),
|
|
3223
3269
|
quickFilterValues: model.quickFilterValues || []
|
|
3224
3270
|
});
|
|
3225
|
-
|
|
3271
|
+
// Update URL first to ensure the search string is updated before any re-render
|
|
3226
3272
|
updateUrl({
|
|
3227
3273
|
filterModel: filterModel,
|
|
3228
3274
|
sortModel: sortModelParsed,
|
|
3229
3275
|
paginationModel: paginationModelParsed,
|
|
3230
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
3276
|
+
columnsModel: (_apiRef$current$state = (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 ? void 0 : _apiRef$current3.state.columns.columnVisibilityModel) !== null && _apiRef$current$state !== void 0 ? _apiRef$current$state : {},
|
|
3231
3277
|
pinnedColumnsModel: pinnedColumnsModel
|
|
3232
3278
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3279
|
+
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
3233
3280
|
},
|
|
3234
3281
|
filterModel: filterParsed,
|
|
3235
3282
|
onSortModelChange: (model, details) => {
|
|
3236
|
-
|
|
3283
|
+
var _apiRef$current$state2, _apiRef$current4;
|
|
3284
|
+
// Update URL first to ensure the search string is updated before any re-render
|
|
3237
3285
|
updateUrl({
|
|
3238
3286
|
filterModel: filterParsed,
|
|
3239
3287
|
sortModel: model,
|
|
3240
3288
|
paginationModel: paginationModelParsed,
|
|
3241
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
3289
|
+
columnsModel: (_apiRef$current$state2 = (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.state.columns.columnVisibilityModel) !== null && _apiRef$current$state2 !== void 0 ? _apiRef$current$state2 : {},
|
|
3242
3290
|
pinnedColumnsModel: pinnedColumnsModel
|
|
3243
3291
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3292
|
+
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
3244
3293
|
},
|
|
3245
3294
|
sortModel: sortModelParsed,
|
|
3246
3295
|
onPinnedColumnsChange: (pinnedColumns, details) => {
|
|
3247
|
-
|
|
3296
|
+
var _apiRef$current$state3, _apiRef$current5;
|
|
3297
|
+
// Update URL first to ensure the search string is updated before any re-render
|
|
3248
3298
|
updateUrl({
|
|
3249
3299
|
filterModel: filterParsed,
|
|
3250
3300
|
sortModel: sortModelParsed,
|
|
3251
3301
|
paginationModel: paginationModelParsed,
|
|
3252
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
3302
|
+
columnsModel: (_apiRef$current$state3 = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.state.columns.columnVisibilityModel) !== null && _apiRef$current$state3 !== void 0 ? _apiRef$current$state3 : {},
|
|
3253
3303
|
pinnedColumnsModel: pinnedColumns
|
|
3254
3304
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3305
|
+
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
3255
3306
|
},
|
|
3256
3307
|
pinnedColumns: pinnedColumnsModel,
|
|
3257
3308
|
paginationModel: paginationModelParsed,
|
|
3258
3309
|
onPaginationModelChange: (model, details) => {
|
|
3310
|
+
var _apiRef$current$state4, _apiRef$current6;
|
|
3259
3311
|
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
3260
3312
|
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
3261
3313
|
});
|
|
3262
|
-
|
|
3314
|
+
// Update URL first to ensure the search string is updated before any re-render
|
|
3315
|
+
// This prevents MUI DataGrid v8 from resetting pagination on re-render
|
|
3263
3316
|
updateUrl({
|
|
3264
3317
|
filterModel: filterParsed,
|
|
3265
3318
|
sortModel: sortModelParsed,
|
|
3266
3319
|
paginationModel: paginationModel,
|
|
3267
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
3320
|
+
columnsModel: (_apiRef$current$state4 = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.state.columns.columnVisibilityModel) !== null && _apiRef$current$state4 !== void 0 ? _apiRef$current$state4 : {},
|
|
3268
3321
|
pinnedColumnsModel: pinnedColumnsModel
|
|
3269
3322
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3323
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
3270
3324
|
},
|
|
3271
3325
|
columnVisibilityModel: visibilityModel,
|
|
3272
3326
|
onColumnVisibilityModelChange: (columnsVisibilityModel, details) => {
|
|
3273
|
-
|
|
3327
|
+
// Update URL first to ensure the search string is updated before any re-render
|
|
3274
3328
|
updateUrl({
|
|
3275
3329
|
filterModel: filterParsed,
|
|
3276
3330
|
sortModel: sortModelParsed,
|
|
@@ -3278,6 +3332,7 @@ const useStatefulTable = props => {
|
|
|
3278
3332
|
columnsModel: columnsVisibilityModel,
|
|
3279
3333
|
pinnedColumnsModel: pinnedColumnsModel
|
|
3280
3334
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3335
|
+
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
3281
3336
|
},
|
|
3282
3337
|
onColumnWidthChange: (params, event, details) => {
|
|
3283
3338
|
propsOnColumnWidthChange === null || propsOnColumnWidthChange === void 0 ? void 0 : propsOnColumnWidthChange(params, event, details);
|
|
@@ -3325,7 +3380,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3325
3380
|
paginationPlacement = 'both',
|
|
3326
3381
|
paginationProps,
|
|
3327
3382
|
rows,
|
|
3328
|
-
pageSizeOptions,
|
|
3383
|
+
pageSizeOptions = [5, 10, 25, 50],
|
|
3329
3384
|
sx,
|
|
3330
3385
|
theme: propsTheme,
|
|
3331
3386
|
useRouter,
|
|
@@ -3385,9 +3440,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3385
3440
|
localStorageVersion,
|
|
3386
3441
|
previousLocalStorageVersions
|
|
3387
3442
|
});
|
|
3388
|
-
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel :
|
|
3443
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : EMPTY_ROW_SELECTION_MODEL);
|
|
3389
3444
|
useEffect(() => {
|
|
3390
|
-
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel :
|
|
3445
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : EMPTY_ROW_SELECTION_MODEL);
|
|
3391
3446
|
}, [propsRowSelectionModel]);
|
|
3392
3447
|
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
3393
3448
|
if (propsOnRowSelectionModelChange) {
|
|
@@ -3415,7 +3470,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3415
3470
|
// every time we navigate between pages, resize our page or select something
|
|
3416
3471
|
useEffect(() => {
|
|
3417
3472
|
if (paginationMode == 'server') {
|
|
3418
|
-
onServerSideSelectionStatusChange(
|
|
3473
|
+
onServerSideSelectionStatusChange(rowSelectionModel, apiRef, selectionStatus, forceSelectionUpdate, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
3419
3474
|
}
|
|
3420
3475
|
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize]);
|
|
3421
3476
|
if (!Array.isArray(rows)) {
|
|
@@ -3467,11 +3522,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3467
3522
|
rowCount: rowCount,
|
|
3468
3523
|
autoHeight: autoHeight,
|
|
3469
3524
|
checkboxSelectionVisibleOnly: checkboxSelectionVisibleOnly,
|
|
3525
|
+
showToolbar: !hideToolbar,
|
|
3470
3526
|
slots: _objectSpread2(_objectSpread2({
|
|
3471
3527
|
baseButton: BaseButton,
|
|
3528
|
+
baseIconButton: BaseIconButton,
|
|
3472
3529
|
baseCheckbox: BaseCheckbox,
|
|
3473
|
-
// baseTextField,
|
|
3474
|
-
basePopper: BasePopper,
|
|
3475
3530
|
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3476
3531
|
displayName: "columnFilteredIcon"
|
|
3477
3532
|
})),
|
|
@@ -3580,10 +3635,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3580
3635
|
return id;
|
|
3581
3636
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3582
3637
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3583
|
-
const numberOfSelectedRows = newSelectionModel
|
|
3638
|
+
const numberOfSelectedRows = getSelectionCount(newSelectionModel);
|
|
3584
3639
|
if (selectionStatus.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable - numberOfSelectableRowsInPage || selectionStatus.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable || selectionStatus.current.type === 'page' && numberOfSelectedRows === numberOfSelectableRowsInPage) {
|
|
3585
3640
|
setTimeout(() => {
|
|
3586
|
-
|
|
3641
|
+
var _apiRef$current;
|
|
3642
|
+
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.selectRows([], true, true);
|
|
3587
3643
|
}, 0);
|
|
3588
3644
|
}
|
|
3589
3645
|
if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|