@redsift/table 12.3.0-muiv7 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_internal/BaseComponents.js +1 -1
- package/_internal/BaseIconButton.js +125 -0
- package/_internal/BaseIconButton.js.map +1 -0
- package/_internal/DataGrid2.js +49 -34
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/{ControlledPagination.js → ServerSideControlledPagination.js} +7584 -760
- package/_internal/ServerSideControlledPagination.js.map +1 -0
- package/_internal/StatefulDataGrid2.js +126 -67
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/Toolbar2.js +1 -1
- package/_internal/Toolbar2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +1 -1
- package/_internal/useControlledDatagridState.js +73 -119
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +342 -121
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/package.json +7 -8
- 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,14 @@
|
|
|
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
|
-
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef,
|
|
6
|
+
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef, DataGridPremium, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-premium';
|
|
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, p as memoTheme, q as createSimplePaletteValueFilter, r as useDefaultProps, t as useFormControl, v as formControlState, w as capitalize, x as composeClasses, y as rootShouldForwardProp, z as isAdornedStart, A as isFilled, F as FormControlContext, B as useId, D as useSlot, G as Select, H as refType, I as Input, J as FilledInput, O as OutlinedInput, n as normalizeRowSelectionModel, o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination, g as getSelectionCount } from './ServerSideControlledPagination.js';
|
|
10
10
|
import { j as jsxRuntimeExports } from './jsx-runtime.js';
|
|
11
|
-
import {
|
|
12
|
-
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
|
-
import { T as ToolbarWrapper } from './ToolbarWrapper2.js';
|
|
11
|
+
import { B as BaseButton, a as BaseCheckbox, c as BaseIconButton, b as BaseIcon } from './BaseIconButton.js';
|
|
15
12
|
|
|
16
13
|
const splitProps = props => {
|
|
17
14
|
const result = {
|
|
@@ -93,7 +90,7 @@ function createBox(options = {}) {
|
|
|
93
90
|
|
|
94
91
|
function isMuiElement(element, muiNames) {
|
|
95
92
|
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(
|
|
96
|
-
// For server components `muiName` is
|
|
93
|
+
// For server components `muiName` is available in element.type._payload.value.muiName
|
|
97
94
|
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
|
|
98
95
|
// eslint-disable-next-line no-underscore-dangle
|
|
99
96
|
element.type.muiName ?? element.type?._payload?.value?.muiName) !== -1;
|
|
@@ -192,8 +189,7 @@ const FormLabelRoot = styled$1('label', {
|
|
|
192
189
|
})));
|
|
193
190
|
const AsteriskComponent = styled$1('span', {
|
|
194
191
|
name: 'MuiFormLabel',
|
|
195
|
-
slot: 'Asterisk'
|
|
196
|
-
overridesResolver: (props, styles) => styles.asterisk
|
|
192
|
+
slot: 'Asterisk'
|
|
197
193
|
})(memoTheme(({
|
|
198
194
|
theme
|
|
199
195
|
}) => ({
|
|
@@ -320,7 +316,7 @@ const useUtilityClasses$3 = ownerState => {
|
|
|
320
316
|
required
|
|
321
317
|
} = ownerState;
|
|
322
318
|
const slots = {
|
|
323
|
-
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== '
|
|
319
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== 'medium' && `size${capitalize(size)}`, variant],
|
|
324
320
|
asterisk: [required && 'asterisk']
|
|
325
321
|
};
|
|
326
322
|
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
@@ -563,9 +559,9 @@ process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes
|
|
|
563
559
|
shrink: PropTypes.bool,
|
|
564
560
|
/**
|
|
565
561
|
* The size of the component.
|
|
566
|
-
* @default '
|
|
562
|
+
* @default 'medium'
|
|
567
563
|
*/
|
|
568
|
-
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['
|
|
564
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
569
565
|
/**
|
|
570
566
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
571
567
|
*/
|
|
@@ -1074,8 +1070,7 @@ const useUtilityClasses = ownerState => {
|
|
|
1074
1070
|
};
|
|
1075
1071
|
const TextFieldRoot = styled$1(FormControl$1, {
|
|
1076
1072
|
name: 'MuiTextField',
|
|
1077
|
-
slot: 'Root'
|
|
1078
|
-
overridesResolver: (props, styles) => styles.root
|
|
1073
|
+
slot: 'Root'
|
|
1079
1074
|
})({});
|
|
1080
1075
|
|
|
1081
1076
|
/**
|
|
@@ -1343,7 +1338,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1343
1338
|
error: PropTypes.bool,
|
|
1344
1339
|
/**
|
|
1345
1340
|
* 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
|
|
1341
|
+
* @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
1342
|
*/
|
|
1348
1343
|
FormHelperTextProps: PropTypes.object,
|
|
1349
1344
|
/**
|
|
@@ -1363,12 +1358,12 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1363
1358
|
/**
|
|
1364
1359
|
* Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
|
|
1365
1360
|
* 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
|
|
1361
|
+
* @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
1362
|
*/
|
|
1368
1363
|
InputLabelProps: PropTypes.object,
|
|
1369
1364
|
/**
|
|
1370
|
-
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
1371
|
-
* @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in
|
|
1365
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
|
|
1366
|
+
* @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
1367
|
*/
|
|
1373
1368
|
inputProps: PropTypes.object,
|
|
1374
1369
|
/**
|
|
@@ -1376,7 +1371,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1376
1371
|
* It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
|
|
1377
1372
|
* [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
|
|
1378
1373
|
* component depending on the `variant` prop value.
|
|
1379
|
-
* @deprecated Use `slotProps.input` instead. This prop will be removed in
|
|
1374
|
+
* @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
1375
|
*/
|
|
1381
1376
|
InputProps: PropTypes.object,
|
|
1382
1377
|
/**
|
|
@@ -1445,7 +1440,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1445
1440
|
select: PropTypes.bool,
|
|
1446
1441
|
/**
|
|
1447
1442
|
* 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
|
|
1443
|
+
* @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
1444
|
*/
|
|
1450
1445
|
SelectProps: PropTypes.object,
|
|
1451
1446
|
/**
|
|
@@ -1481,9 +1476,9 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
1481
1476
|
*/
|
|
1482
1477
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1483
1478
|
/**
|
|
1484
|
-
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
1479
|
+
* 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
1480
|
*/
|
|
1486
|
-
type: PropTypes
|
|
1481
|
+
type: PropTypes.string,
|
|
1487
1482
|
/**
|
|
1488
1483
|
* The value of the `input` element, required for a controlled component.
|
|
1489
1484
|
*/
|
|
@@ -2831,6 +2826,23 @@ const useTableStates = (id, version) => {
|
|
|
2831
2826
|
};
|
|
2832
2827
|
};
|
|
2833
2828
|
|
|
2829
|
+
/**
|
|
2830
|
+
* Deep-equal comparison for plain objects / arrays.
|
|
2831
|
+
* Used to stabilise parsed model references so that MUI v8 does not
|
|
2832
|
+
* reset pagination on every render.
|
|
2833
|
+
*/
|
|
2834
|
+
function isDeepEqual(a, b) {
|
|
2835
|
+
if (a === b) return true;
|
|
2836
|
+
if (a == null || b == null) return false;
|
|
2837
|
+
if (typeof a !== typeof b) return false;
|
|
2838
|
+
if (typeof a !== 'object') return false;
|
|
2839
|
+
const aObj = a;
|
|
2840
|
+
const bObj = b;
|
|
2841
|
+
const aKeys = Object.keys(aObj);
|
|
2842
|
+
const bKeys = Object.keys(bObj);
|
|
2843
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
2844
|
+
return aKeys.every(key => isDeepEqual(aObj[key], bObj[key]));
|
|
2845
|
+
}
|
|
2834
2846
|
const useStatefulTable = props => {
|
|
2835
2847
|
const {
|
|
2836
2848
|
// density = 'standard',
|
|
@@ -2899,6 +2911,29 @@ const useStatefulTable = props => {
|
|
|
2899
2911
|
localStoragePinnedColumns: pinnedColumns,
|
|
2900
2912
|
setLocalStoragePinnedColumns: setPinnedColumns
|
|
2901
2913
|
});
|
|
2914
|
+
|
|
2915
|
+
// Stabilise parsed model references to prevent MUI v8 from resetting
|
|
2916
|
+
// pagination on every render due to new object identity.
|
|
2917
|
+
const filterParsedRef = useRef(filterParsed);
|
|
2918
|
+
if (!isDeepEqual(filterParsedRef.current, filterParsed)) {
|
|
2919
|
+
filterParsedRef.current = filterParsed;
|
|
2920
|
+
}
|
|
2921
|
+
const sortModelParsedRef = useRef(sortModelParsed);
|
|
2922
|
+
if (!isDeepEqual(sortModelParsedRef.current, sortModelParsed)) {
|
|
2923
|
+
sortModelParsedRef.current = sortModelParsed;
|
|
2924
|
+
}
|
|
2925
|
+
const paginationModelParsedRef = useRef(paginationModelParsed);
|
|
2926
|
+
if (!isDeepEqual(paginationModelParsedRef.current, paginationModelParsed)) {
|
|
2927
|
+
paginationModelParsedRef.current = paginationModelParsed;
|
|
2928
|
+
}
|
|
2929
|
+
const visibilityModelRef = useRef(visibilityModel);
|
|
2930
|
+
if (!isDeepEqual(visibilityModelRef.current, visibilityModel)) {
|
|
2931
|
+
visibilityModelRef.current = visibilityModel;
|
|
2932
|
+
}
|
|
2933
|
+
const pinnedColumnsModelRef = useRef(pinnedColumnsModel);
|
|
2934
|
+
if (!isDeepEqual(pinnedColumnsModelRef.current, pinnedColumnsModel)) {
|
|
2935
|
+
pinnedColumnsModelRef.current = pinnedColumnsModel;
|
|
2936
|
+
}
|
|
2902
2937
|
const columns = useMemo(() => propsColumns.map(column => {
|
|
2903
2938
|
column.width = dimensionModel[column.field] || column.width || 100;
|
|
2904
2939
|
return column;
|
|
@@ -2906,70 +2941,75 @@ const useStatefulTable = props => {
|
|
|
2906
2941
|
if (apiRef.current) {
|
|
2907
2942
|
/** Add resetPage method to apiRef. */
|
|
2908
2943
|
apiRef.current.resetPage = () => {
|
|
2909
|
-
|
|
2944
|
+
var _apiRef$current;
|
|
2945
|
+
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPage(0);
|
|
2910
2946
|
};
|
|
2911
2947
|
}
|
|
2912
2948
|
return {
|
|
2913
2949
|
apiRef,
|
|
2914
2950
|
columns,
|
|
2915
2951
|
onFilterModelChange: (model, details) => {
|
|
2952
|
+
var _apiRef$current$state, _apiRef$current3;
|
|
2916
2953
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2917
2954
|
items: model.items.map(item => {
|
|
2918
|
-
|
|
2919
|
-
|
|
2955
|
+
var _apiRef$current2;
|
|
2956
|
+
const column = (_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.getColumn(item.field);
|
|
2957
|
+
item.type = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
2920
2958
|
return item;
|
|
2921
2959
|
}),
|
|
2922
2960
|
quickFilterValues: model.quickFilterValues || []
|
|
2923
2961
|
});
|
|
2924
|
-
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
2925
2962
|
updateUrl({
|
|
2926
2963
|
filterModel: filterModel,
|
|
2927
2964
|
sortModel: sortModelParsed,
|
|
2928
2965
|
paginationModel: paginationModelParsed,
|
|
2929
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
2966
|
+
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 : {},
|
|
2930
2967
|
pinnedColumnsModel: pinnedColumnsModel
|
|
2931
2968
|
}, search, localStorageVersion, historyReplace, columns);
|
|
2969
|
+
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
2932
2970
|
},
|
|
2933
|
-
filterModel:
|
|
2971
|
+
filterModel: filterParsedRef.current,
|
|
2934
2972
|
onSortModelChange: (model, details) => {
|
|
2935
|
-
|
|
2973
|
+
var _apiRef$current$state2, _apiRef$current4;
|
|
2936
2974
|
updateUrl({
|
|
2937
2975
|
filterModel: filterParsed,
|
|
2938
2976
|
sortModel: model,
|
|
2939
2977
|
paginationModel: paginationModelParsed,
|
|
2940
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
2978
|
+
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 : {},
|
|
2941
2979
|
pinnedColumnsModel: pinnedColumnsModel
|
|
2942
2980
|
}, search, localStorageVersion, historyReplace, columns);
|
|
2981
|
+
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
2943
2982
|
},
|
|
2944
|
-
sortModel:
|
|
2983
|
+
sortModel: sortModelParsedRef.current,
|
|
2945
2984
|
onPinnedColumnsChange: (pinnedColumns, details) => {
|
|
2946
|
-
|
|
2985
|
+
var _apiRef$current$state3, _apiRef$current5;
|
|
2947
2986
|
updateUrl({
|
|
2948
2987
|
filterModel: filterParsed,
|
|
2949
2988
|
sortModel: sortModelParsed,
|
|
2950
2989
|
paginationModel: paginationModelParsed,
|
|
2951
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
2990
|
+
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 : {},
|
|
2952
2991
|
pinnedColumnsModel: pinnedColumns
|
|
2953
2992
|
}, search, localStorageVersion, historyReplace, columns);
|
|
2993
|
+
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
2954
2994
|
},
|
|
2955
|
-
pinnedColumns:
|
|
2956
|
-
paginationModel:
|
|
2995
|
+
pinnedColumns: pinnedColumnsModelRef.current,
|
|
2996
|
+
paginationModel: paginationModelParsedRef.current,
|
|
2957
2997
|
onPaginationModelChange: (model, details) => {
|
|
2998
|
+
var _apiRef$current$state4, _apiRef$current6;
|
|
2958
2999
|
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2959
3000
|
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
2960
3001
|
});
|
|
2961
|
-
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
2962
3002
|
updateUrl({
|
|
2963
3003
|
filterModel: filterParsed,
|
|
2964
3004
|
sortModel: sortModelParsed,
|
|
2965
3005
|
paginationModel: paginationModel,
|
|
2966
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
3006
|
+
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 : {},
|
|
2967
3007
|
pinnedColumnsModel: pinnedColumnsModel
|
|
2968
3008
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3009
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
2969
3010
|
},
|
|
2970
|
-
columnVisibilityModel:
|
|
3011
|
+
columnVisibilityModel: visibilityModelRef.current,
|
|
2971
3012
|
onColumnVisibilityModelChange: (columnsVisibilityModel, details) => {
|
|
2972
|
-
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
2973
3013
|
updateUrl({
|
|
2974
3014
|
filterModel: filterParsed,
|
|
2975
3015
|
sortModel: sortModelParsed,
|
|
@@ -2977,6 +3017,7 @@ const useStatefulTable = props => {
|
|
|
2977
3017
|
columnsModel: columnsVisibilityModel,
|
|
2978
3018
|
pinnedColumnsModel: pinnedColumnsModel
|
|
2979
3019
|
}, search, localStorageVersion, historyReplace, columns);
|
|
3020
|
+
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
2980
3021
|
},
|
|
2981
3022
|
onColumnWidthChange: (params, event, details) => {
|
|
2982
3023
|
propsOnColumnWidthChange === null || propsOnColumnWidthChange === void 0 ? void 0 : propsOnColumnWidthChange(params, event, details);
|
|
@@ -3044,6 +3085,7 @@ const CLASSNAME = 'redsift-datagrid';
|
|
|
3044
3085
|
*/
|
|
3045
3086
|
|
|
3046
3087
|
const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
3088
|
+
var _initialState$density, _forwardedProps$densi;
|
|
3047
3089
|
const datagridRef = ref || useRef();
|
|
3048
3090
|
const {
|
|
3049
3091
|
apiRef: propsApiRef,
|
|
@@ -3087,7 +3129,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3087
3129
|
const theme = useTheme$1(propsTheme);
|
|
3088
3130
|
const _apiRef = useGridApiRef();
|
|
3089
3131
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
3090
|
-
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar;
|
|
3091
3132
|
LicenseInfo.setLicenseKey(license);
|
|
3092
3133
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
3093
3134
|
const {
|
|
@@ -3136,9 +3177,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3136
3177
|
localStorageVersion,
|
|
3137
3178
|
previousLocalStorageVersions
|
|
3138
3179
|
});
|
|
3139
|
-
const [rowSelectionModel, setRowSelectionModel] = useState(
|
|
3180
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(() => normalizeRowSelectionModel(propsRowSelectionModel));
|
|
3140
3181
|
useEffect(() => {
|
|
3141
|
-
setRowSelectionModel(propsRowSelectionModel
|
|
3182
|
+
setRowSelectionModel(normalizeRowSelectionModel(propsRowSelectionModel));
|
|
3142
3183
|
}, [propsRowSelectionModel]);
|
|
3143
3184
|
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
3144
3185
|
if (propsOnRowSelectionModelChange) {
|
|
@@ -3162,11 +3203,21 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3162
3203
|
// for server-side pagination it produces inconsistent behavior when selecting all rows in pages 2 and beyond
|
|
3163
3204
|
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(paginationMode != 'server');
|
|
3164
3205
|
|
|
3206
|
+
// Track when the grid API is ready to ensure top pagination renders correctly
|
|
3207
|
+
const [gridReady, setGridReady] = useState(false);
|
|
3208
|
+
|
|
3209
|
+
// Force re-render when the grid API becomes ready (for top pagination)
|
|
3210
|
+
useEffect(() => {
|
|
3211
|
+
if (apiRef.current && !gridReady) {
|
|
3212
|
+
setGridReady(true);
|
|
3213
|
+
}
|
|
3214
|
+
});
|
|
3215
|
+
|
|
3165
3216
|
// in server-side pagination we want to update the selection status
|
|
3166
3217
|
// every time we navigate between pages, resize our page or select something
|
|
3167
3218
|
useEffect(() => {
|
|
3168
3219
|
if (paginationMode == 'server') {
|
|
3169
|
-
onServerSideSelectionStatusChange(
|
|
3220
|
+
onServerSideSelectionStatusChange(rowSelectionModel, apiRef, selectionStatus, forceSelectionUpdate, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
3170
3221
|
}
|
|
3171
3222
|
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize]);
|
|
3172
3223
|
if (!Array.isArray(rows)) {
|
|
@@ -3194,7 +3245,28 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3194
3245
|
ref: datagridRef,
|
|
3195
3246
|
className: classNames(StatefulDataGrid.className, className),
|
|
3196
3247
|
$height: height
|
|
3197
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
3248
|
+
}, pagination && ['top', 'both'].includes(paginationPlacement) && gridReady ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, {
|
|
3249
|
+
displaySelection: true,
|
|
3250
|
+
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3251
|
+
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3252
|
+
selectionStatus: selectionStatus.current,
|
|
3253
|
+
paginationModel: paginationModel,
|
|
3254
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3255
|
+
pageSizeOptions: pageSizeOptions,
|
|
3256
|
+
paginationProps: paginationProps,
|
|
3257
|
+
rowCount: rowCount
|
|
3258
|
+
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
3259
|
+
displaySelection: true,
|
|
3260
|
+
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3261
|
+
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3262
|
+
selectionStatus: selectionStatus.current,
|
|
3263
|
+
apiRef: apiRef,
|
|
3264
|
+
isRowSelectable: isRowSelectable,
|
|
3265
|
+
paginationModel: paginationModel,
|
|
3266
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3267
|
+
pageSizeOptions: pageSizeOptions,
|
|
3268
|
+
paginationProps: paginationProps
|
|
3269
|
+
}) : null, /*#__PURE__*/React__default.createElement(DataGridPremium, _extends({}, forwardedProps, {
|
|
3198
3270
|
apiRef: apiRef,
|
|
3199
3271
|
columns: columns,
|
|
3200
3272
|
columnVisibilityModel: columnVisibilityModel,
|
|
@@ -3209,7 +3281,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3209
3281
|
sortModel: sortModel,
|
|
3210
3282
|
pageSizeOptions: pageSizeOptions,
|
|
3211
3283
|
onColumnWidthChange: onColumnWidthChange,
|
|
3212
|
-
initialState: initialState,
|
|
3284
|
+
initialState: _objectSpread2(_objectSpread2({}, initialState), {}, {
|
|
3285
|
+
density: (_initialState$density = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _initialState$density !== void 0 ? _initialState$density : 'standard'
|
|
3286
|
+
}),
|
|
3213
3287
|
isRowSelectable: isRowSelectable,
|
|
3214
3288
|
pagination: pagination,
|
|
3215
3289
|
paginationMode: paginationMode,
|
|
@@ -3218,11 +3292,12 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3218
3292
|
rowCount: rowCount,
|
|
3219
3293
|
autoHeight: autoHeight,
|
|
3220
3294
|
checkboxSelectionVisibleOnly: checkboxSelectionVisibleOnly,
|
|
3295
|
+
showToolbar: !hideToolbar,
|
|
3296
|
+
density: (_forwardedProps$densi = forwardedProps.density) !== null && _forwardedProps$densi !== void 0 ? _forwardedProps$densi : 'standard',
|
|
3221
3297
|
slots: _objectSpread2(_objectSpread2({
|
|
3222
3298
|
baseButton: BaseButton,
|
|
3223
3299
|
baseCheckbox: BaseCheckbox,
|
|
3224
|
-
|
|
3225
|
-
basePopper: BasePopper,
|
|
3300
|
+
baseIconButton: BaseIconButton,
|
|
3226
3301
|
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3227
3302
|
displayName: "columnFilteredIcon"
|
|
3228
3303
|
})),
|
|
@@ -3257,23 +3332,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3257
3332
|
displayName: "openFilterButtonIcon"
|
|
3258
3333
|
}))
|
|
3259
3334
|
}, slots), {}, {
|
|
3260
|
-
toolbar: props => /*#__PURE__*/React__default.createElement(ToolbarWrapper, _extends({}, props, {
|
|
3261
|
-
hideToolbar: hideToolbar,
|
|
3262
|
-
RenderedToolbar: RenderedToolbar,
|
|
3263
|
-
filterModel: filterModel,
|
|
3264
|
-
onFilterModelChange: onFilterModelChange,
|
|
3265
|
-
pagination: pagination,
|
|
3266
|
-
paginationPlacement: paginationPlacement,
|
|
3267
|
-
selectionStatus: selectionStatus,
|
|
3268
|
-
apiRef: apiRef,
|
|
3269
|
-
isRowSelectable: isRowSelectable,
|
|
3270
|
-
paginationModel: paginationModel,
|
|
3271
|
-
onPaginationModelChange: onPaginationModelChange,
|
|
3272
|
-
pageSizeOptions: pageSizeOptions,
|
|
3273
|
-
paginationProps: paginationProps,
|
|
3274
|
-
paginationMode: paginationMode,
|
|
3275
|
-
rowCount: rowCount
|
|
3276
|
-
})),
|
|
3277
3335
|
pagination: props => {
|
|
3278
3336
|
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends({}, props, {
|
|
3279
3337
|
displaySelection: false,
|
|
@@ -3331,10 +3389,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3331
3389
|
return id;
|
|
3332
3390
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3333
3391
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3334
|
-
const numberOfSelectedRows = newSelectionModel
|
|
3392
|
+
const numberOfSelectedRows = getSelectionCount(newSelectionModel);
|
|
3335
3393
|
if (selectionStatus.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable - numberOfSelectableRowsInPage || selectionStatus.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable || selectionStatus.current.type === 'page' && numberOfSelectedRows === numberOfSelectableRowsInPage) {
|
|
3336
3394
|
setTimeout(() => {
|
|
3337
|
-
|
|
3395
|
+
var _apiRef$current;
|
|
3396
|
+
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.selectRows([], true, true);
|
|
3338
3397
|
}, 0);
|
|
3339
3398
|
}
|
|
3340
3399
|
if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|