@redsift/table 12.5.5-alpha.2 → 12.5.5-muiv6
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/BasePopper.js +2469 -0
- package/_internal/BasePopper.js.map +1 -0
- package/_internal/ControlledPagination.js +11004 -0
- package/_internal/ControlledPagination.js.map +1 -0
- package/_internal/DataGrid2.js +87 -116
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/GridToolbarFilterSemanticField2.js +3 -1340
- package/_internal/GridToolbarFilterSemanticField2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/Portal.js +6538 -0
- package/_internal/Portal.js.map +1 -0
- package/_internal/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +1683 -1063
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/Toolbar2.js +6 -23
- package/_internal/Toolbar2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +27 -11
- package/_internal/ToolbarWrapper2.js.map +1 -1
- package/_internal/jsx-runtime.js +1342 -0
- package/_internal/jsx-runtime.js.map +1 -0
- package/_internal/useControlledDatagridState.js +287 -13
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +464 -515
- package/index.js +40 -47
- package/index.js.map +1 -1
- package/package.json +10 -9
- package/_internal/BaseIconButton.js +0 -126
- package/_internal/BaseIconButton.js.map +0 -1
- package/_internal/ServerSideControlledPagination.js +0 -324
- package/_internal/ServerSideControlledPagination.js.map +0 -1
|
@@ -1,18 +1,1249 @@
|
|
|
1
|
-
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends } from './_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends$2 } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { useCallback, useEffect,
|
|
4
|
-
import { createTheme, ThemeProvider as ThemeProvider$1 } from '@mui/material/styles';
|
|
3
|
+
import React__default, { useCallback, useEffect, useMemo, useRef, forwardRef, useState } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { u as useControlledDatagridState, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
10
|
-
import Box from '@mui/material/Box';
|
|
11
|
-
import TextField from '@mui/material/TextField';
|
|
5
|
+
import { Icon, useTheme as useTheme$1, ThemeProvider, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite } from '@redsift/design-system';
|
|
6
|
+
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, DataGridPro } from '@mui/x-data-grid-pro';
|
|
7
|
+
import { L as LicenseInfo, u as useControlledDatagridState, T as ThemeProvider$1, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
12
8
|
import { mdiSync } from '@redsift/icons';
|
|
9
|
+
import { s as styled, a as styleFunctionSx, e as extendSxProp, _ as _objectWithoutPropertiesLoose, b as _extends, g as generateUtilityClasses, c as createTheme, T as THEME_ID, C as ClassNameGenerator, P as PropTypes, d as generateUtilityClass, f as styled$1, h as _extends$1, u as useDefaultProps, i as _objectWithoutPropertiesLoose$1, j as capitalize, k as composeClasses, r as rootShouldForwardProp, l as refType } from './Portal.js';
|
|
10
|
+
import { u as useTheme, a as useFormControl, b as formControlState, c as clsx$1, i as isAdornedStart, d as isFilled, F as FormControlContext, e as useId, h as Select, I as Input, j as FilledInput, O as OutlinedInput, o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination } from './ControlledPagination.js';
|
|
11
|
+
import { j as jsxRuntimeExports } from './jsx-runtime.js';
|
|
13
12
|
import { decompressFromEncodedURIComponent, compressToEncodedURIComponent } from 'lz-string';
|
|
14
|
-
import {
|
|
15
|
-
import { B as BaseButton, a as BaseCheckbox, c as
|
|
13
|
+
import { T as Toolbar } from './Toolbar2.js';
|
|
14
|
+
import { B as BaseButton, a as BaseCheckbox, c as BasePopper, b as BaseIcon } from './BasePopper.js';
|
|
15
|
+
import { T as ToolbarWrapper } from './ToolbarWrapper2.js';
|
|
16
|
+
|
|
17
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
18
|
+
|
|
19
|
+
const _excluded$6 = ["className", "component"];
|
|
20
|
+
function createBox(options = {}) {
|
|
21
|
+
const {
|
|
22
|
+
themeId,
|
|
23
|
+
defaultTheme,
|
|
24
|
+
defaultClassName = 'MuiBox-root',
|
|
25
|
+
generateClassName
|
|
26
|
+
} = options;
|
|
27
|
+
const BoxRoot = styled('div', {
|
|
28
|
+
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
|
29
|
+
})(styleFunctionSx);
|
|
30
|
+
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
31
|
+
const theme = useTheme(defaultTheme);
|
|
32
|
+
const _extendSxProp = extendSxProp(inProps),
|
|
33
|
+
{
|
|
34
|
+
className,
|
|
35
|
+
component = 'div'
|
|
36
|
+
} = _extendSxProp,
|
|
37
|
+
other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded$6);
|
|
38
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BoxRoot, _extends({
|
|
39
|
+
as: component,
|
|
40
|
+
ref: ref,
|
|
41
|
+
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
42
|
+
theme: themeId ? theme[themeId] || theme : theme
|
|
43
|
+
}, other));
|
|
44
|
+
});
|
|
45
|
+
return Box;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isMuiElement(element, muiNames) {
|
|
49
|
+
var _muiName, _element$type;
|
|
50
|
+
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf( // For server components `muiName` is avaialble in element.type._payload.value.muiName
|
|
51
|
+
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
|
|
52
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
53
|
+
(_muiName = element.type.muiName) != null ? _muiName : (_element$type = element.type) == null || (_element$type = _element$type._payload) == null || (_element$type = _element$type.value) == null ? void 0 : _element$type.muiName) !== -1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const boxClasses = generateUtilityClasses('MuiBox', ['root']);
|
|
57
|
+
var boxClasses$1 = boxClasses;
|
|
58
|
+
|
|
59
|
+
const defaultTheme = createTheme();
|
|
60
|
+
const Box = createBox({
|
|
61
|
+
themeId: THEME_ID,
|
|
62
|
+
defaultTheme,
|
|
63
|
+
defaultClassName: boxClasses$1.root,
|
|
64
|
+
generateClassName: ClassNameGenerator.generate
|
|
65
|
+
});
|
|
66
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
|
67
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
68
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
69
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
70
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
71
|
+
/**
|
|
72
|
+
* @ignore
|
|
73
|
+
*/
|
|
74
|
+
children: PropTypes.node,
|
|
75
|
+
/**
|
|
76
|
+
* The component used for the root node.
|
|
77
|
+
* Either a string to use a HTML element or a component.
|
|
78
|
+
*/
|
|
79
|
+
component: PropTypes.elementType,
|
|
80
|
+
/**
|
|
81
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
82
|
+
*/
|
|
83
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
84
|
+
} : void 0;
|
|
85
|
+
var Box$1 = Box;
|
|
86
|
+
|
|
87
|
+
function getFormLabelUtilityClasses(slot) {
|
|
88
|
+
return generateUtilityClass('MuiFormLabel', slot);
|
|
89
|
+
}
|
|
90
|
+
const formLabelClasses = generateUtilityClasses('MuiFormLabel', ['root', 'colorSecondary', 'focused', 'disabled', 'error', 'filled', 'required', 'asterisk']);
|
|
91
|
+
var formLabelClasses$1 = formLabelClasses;
|
|
92
|
+
|
|
93
|
+
const _excluded$5 = ["children", "className", "color", "component", "disabled", "error", "filled", "focused", "required"];
|
|
94
|
+
const useUtilityClasses$4 = ownerState => {
|
|
95
|
+
const {
|
|
96
|
+
classes,
|
|
97
|
+
color,
|
|
98
|
+
focused,
|
|
99
|
+
disabled,
|
|
100
|
+
error,
|
|
101
|
+
filled,
|
|
102
|
+
required
|
|
103
|
+
} = ownerState;
|
|
104
|
+
const slots = {
|
|
105
|
+
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', filled && 'filled', focused && 'focused', required && 'required'],
|
|
106
|
+
asterisk: ['asterisk', error && 'error']
|
|
107
|
+
};
|
|
108
|
+
return composeClasses(slots, getFormLabelUtilityClasses, classes);
|
|
109
|
+
};
|
|
110
|
+
const FormLabelRoot = styled$1('label', {
|
|
111
|
+
name: 'MuiFormLabel',
|
|
112
|
+
slot: 'Root',
|
|
113
|
+
overridesResolver: ({
|
|
114
|
+
ownerState
|
|
115
|
+
}, styles) => {
|
|
116
|
+
return _extends$1({}, styles.root, ownerState.color === 'secondary' && styles.colorSecondary, ownerState.filled && styles.filled);
|
|
117
|
+
}
|
|
118
|
+
})(({
|
|
119
|
+
theme,
|
|
120
|
+
ownerState
|
|
121
|
+
}) => _extends$1({
|
|
122
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
123
|
+
}, theme.typography.body1, {
|
|
124
|
+
lineHeight: '1.4375em',
|
|
125
|
+
padding: 0,
|
|
126
|
+
position: 'relative',
|
|
127
|
+
[`&.${formLabelClasses$1.focused}`]: {
|
|
128
|
+
color: (theme.vars || theme).palette[ownerState.color].main
|
|
129
|
+
},
|
|
130
|
+
[`&.${formLabelClasses$1.disabled}`]: {
|
|
131
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
132
|
+
},
|
|
133
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
134
|
+
color: (theme.vars || theme).palette.error.main
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
const AsteriskComponent = styled$1('span', {
|
|
138
|
+
name: 'MuiFormLabel',
|
|
139
|
+
slot: 'Asterisk',
|
|
140
|
+
overridesResolver: (props, styles) => styles.asterisk
|
|
141
|
+
})(({
|
|
142
|
+
theme
|
|
143
|
+
}) => ({
|
|
144
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
145
|
+
color: (theme.vars || theme).palette.error.main
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
const FormLabel = /*#__PURE__*/React.forwardRef(function FormLabel(inProps, ref) {
|
|
149
|
+
const props = useDefaultProps({
|
|
150
|
+
props: inProps,
|
|
151
|
+
name: 'MuiFormLabel'
|
|
152
|
+
});
|
|
153
|
+
const {
|
|
154
|
+
children,
|
|
155
|
+
className,
|
|
156
|
+
component = 'label'
|
|
157
|
+
} = props,
|
|
158
|
+
other = _objectWithoutPropertiesLoose$1(props, _excluded$5);
|
|
159
|
+
const muiFormControl = useFormControl();
|
|
160
|
+
const fcs = formControlState({
|
|
161
|
+
props,
|
|
162
|
+
muiFormControl,
|
|
163
|
+
states: ['color', 'required', 'focused', 'disabled', 'error', 'filled']
|
|
164
|
+
});
|
|
165
|
+
const ownerState = _extends$1({}, props, {
|
|
166
|
+
color: fcs.color || 'primary',
|
|
167
|
+
component,
|
|
168
|
+
disabled: fcs.disabled,
|
|
169
|
+
error: fcs.error,
|
|
170
|
+
filled: fcs.filled,
|
|
171
|
+
focused: fcs.focused,
|
|
172
|
+
required: fcs.required
|
|
173
|
+
});
|
|
174
|
+
const classes = useUtilityClasses$4(ownerState);
|
|
175
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(FormLabelRoot, _extends$1({
|
|
176
|
+
as: component,
|
|
177
|
+
ownerState: ownerState,
|
|
178
|
+
className: clsx$1(classes.root, className),
|
|
179
|
+
ref: ref
|
|
180
|
+
}, other, {
|
|
181
|
+
children: [children, fcs.required && /*#__PURE__*/jsxRuntimeExports.jsxs(AsteriskComponent, {
|
|
182
|
+
ownerState: ownerState,
|
|
183
|
+
"aria-hidden": true,
|
|
184
|
+
className: classes.asterisk,
|
|
185
|
+
children: ["\u2009", '*']
|
|
186
|
+
})]
|
|
187
|
+
}));
|
|
188
|
+
});
|
|
189
|
+
process.env.NODE_ENV !== "production" ? FormLabel.propTypes /* remove-proptypes */ = {
|
|
190
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
191
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
192
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
193
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
194
|
+
/**
|
|
195
|
+
* The content of the component.
|
|
196
|
+
*/
|
|
197
|
+
children: PropTypes.node,
|
|
198
|
+
/**
|
|
199
|
+
* Override or extend the styles applied to the component.
|
|
200
|
+
*/
|
|
201
|
+
classes: PropTypes.object,
|
|
202
|
+
/**
|
|
203
|
+
* @ignore
|
|
204
|
+
*/
|
|
205
|
+
className: PropTypes.string,
|
|
206
|
+
/**
|
|
207
|
+
* The color of the component.
|
|
208
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
209
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
210
|
+
*/
|
|
211
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
212
|
+
/**
|
|
213
|
+
* The component used for the root node.
|
|
214
|
+
* Either a string to use a HTML element or a component.
|
|
215
|
+
*/
|
|
216
|
+
component: PropTypes.elementType,
|
|
217
|
+
/**
|
|
218
|
+
* If `true`, the label should be displayed in a disabled state.
|
|
219
|
+
*/
|
|
220
|
+
disabled: PropTypes.bool,
|
|
221
|
+
/**
|
|
222
|
+
* If `true`, the label is displayed in an error state.
|
|
223
|
+
*/
|
|
224
|
+
error: PropTypes.bool,
|
|
225
|
+
/**
|
|
226
|
+
* If `true`, the label should use filled classes key.
|
|
227
|
+
*/
|
|
228
|
+
filled: PropTypes.bool,
|
|
229
|
+
/**
|
|
230
|
+
* If `true`, the input of this label is focused (used by `FormGroup` components).
|
|
231
|
+
*/
|
|
232
|
+
focused: PropTypes.bool,
|
|
233
|
+
/**
|
|
234
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
235
|
+
*/
|
|
236
|
+
required: PropTypes.bool,
|
|
237
|
+
/**
|
|
238
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
239
|
+
*/
|
|
240
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
241
|
+
} : void 0;
|
|
242
|
+
var FormLabel$1 = FormLabel;
|
|
243
|
+
|
|
244
|
+
function getInputLabelUtilityClasses(slot) {
|
|
245
|
+
return generateUtilityClass('MuiInputLabel', slot);
|
|
246
|
+
}
|
|
247
|
+
generateUtilityClasses('MuiInputLabel', ['root', 'focused', 'disabled', 'error', 'required', 'asterisk', 'formControl', 'sizeSmall', 'shrink', 'animated', 'standard', 'filled', 'outlined']);
|
|
248
|
+
|
|
249
|
+
const _excluded$4 = ["disableAnimation", "margin", "shrink", "variant", "className"];
|
|
250
|
+
const useUtilityClasses$3 = ownerState => {
|
|
251
|
+
const {
|
|
252
|
+
classes,
|
|
253
|
+
formControl,
|
|
254
|
+
size,
|
|
255
|
+
shrink,
|
|
256
|
+
disableAnimation,
|
|
257
|
+
variant,
|
|
258
|
+
required
|
|
259
|
+
} = ownerState;
|
|
260
|
+
const slots = {
|
|
261
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== 'normal' && `size${capitalize(size)}`, variant],
|
|
262
|
+
asterisk: [required && 'asterisk']
|
|
263
|
+
};
|
|
264
|
+
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
265
|
+
return _extends$1({}, classes, composedClasses);
|
|
266
|
+
};
|
|
267
|
+
const InputLabelRoot = styled$1(FormLabel$1, {
|
|
268
|
+
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
|
269
|
+
name: 'MuiInputLabel',
|
|
270
|
+
slot: 'Root',
|
|
271
|
+
overridesResolver: (props, styles) => {
|
|
272
|
+
const {
|
|
273
|
+
ownerState
|
|
274
|
+
} = props;
|
|
275
|
+
return [{
|
|
276
|
+
[`& .${formLabelClasses$1.asterisk}`]: styles.asterisk
|
|
277
|
+
}, styles.root, ownerState.formControl && styles.formControl, ownerState.size === 'small' && styles.sizeSmall, ownerState.shrink && styles.shrink, !ownerState.disableAnimation && styles.animated, ownerState.focused && styles.focused, styles[ownerState.variant]];
|
|
278
|
+
}
|
|
279
|
+
})(({
|
|
280
|
+
theme,
|
|
281
|
+
ownerState
|
|
282
|
+
}) => _extends$1({
|
|
283
|
+
display: 'block',
|
|
284
|
+
transformOrigin: 'top left',
|
|
285
|
+
whiteSpace: 'nowrap',
|
|
286
|
+
overflow: 'hidden',
|
|
287
|
+
textOverflow: 'ellipsis',
|
|
288
|
+
maxWidth: '100%'
|
|
289
|
+
}, ownerState.formControl && {
|
|
290
|
+
position: 'absolute',
|
|
291
|
+
left: 0,
|
|
292
|
+
top: 0,
|
|
293
|
+
// slight alteration to spec spacing to match visual spec result
|
|
294
|
+
transform: 'translate(0, 20px) scale(1)'
|
|
295
|
+
}, ownerState.size === 'small' && {
|
|
296
|
+
// Compensation for the `Input.inputSizeSmall` style.
|
|
297
|
+
transform: 'translate(0, 17px) scale(1)'
|
|
298
|
+
}, ownerState.shrink && {
|
|
299
|
+
transform: 'translate(0, -1.5px) scale(0.75)',
|
|
300
|
+
transformOrigin: 'top left',
|
|
301
|
+
maxWidth: '133%'
|
|
302
|
+
}, !ownerState.disableAnimation && {
|
|
303
|
+
transition: theme.transitions.create(['color', 'transform', 'max-width'], {
|
|
304
|
+
duration: theme.transitions.duration.shorter,
|
|
305
|
+
easing: theme.transitions.easing.easeOut
|
|
306
|
+
})
|
|
307
|
+
}, ownerState.variant === 'filled' && _extends$1({
|
|
308
|
+
// Chrome's autofill feature gives the input field a yellow background.
|
|
309
|
+
// Since the input field is behind the label in the HTML tree,
|
|
310
|
+
// the input field is drawn last and hides the label with an opaque background color.
|
|
311
|
+
// zIndex: 1 will raise the label above opaque background-colors of input.
|
|
312
|
+
zIndex: 1,
|
|
313
|
+
pointerEvents: 'none',
|
|
314
|
+
transform: 'translate(12px, 16px) scale(1)',
|
|
315
|
+
maxWidth: 'calc(100% - 24px)'
|
|
316
|
+
}, ownerState.size === 'small' && {
|
|
317
|
+
transform: 'translate(12px, 13px) scale(1)'
|
|
318
|
+
}, ownerState.shrink && _extends$1({
|
|
319
|
+
userSelect: 'none',
|
|
320
|
+
pointerEvents: 'auto',
|
|
321
|
+
transform: 'translate(12px, 7px) scale(0.75)',
|
|
322
|
+
maxWidth: 'calc(133% - 24px)'
|
|
323
|
+
}, ownerState.size === 'small' && {
|
|
324
|
+
transform: 'translate(12px, 4px) scale(0.75)'
|
|
325
|
+
})), ownerState.variant === 'outlined' && _extends$1({
|
|
326
|
+
// see comment above on filled.zIndex
|
|
327
|
+
zIndex: 1,
|
|
328
|
+
pointerEvents: 'none',
|
|
329
|
+
transform: 'translate(14px, 16px) scale(1)',
|
|
330
|
+
maxWidth: 'calc(100% - 24px)'
|
|
331
|
+
}, ownerState.size === 'small' && {
|
|
332
|
+
transform: 'translate(14px, 9px) scale(1)'
|
|
333
|
+
}, ownerState.shrink && {
|
|
334
|
+
userSelect: 'none',
|
|
335
|
+
pointerEvents: 'auto',
|
|
336
|
+
// Theoretically, we should have (8+5)*2/0.75 = 34px
|
|
337
|
+
// but it feels a better when it bleeds a bit on the left, so 32px.
|
|
338
|
+
maxWidth: 'calc(133% - 32px)',
|
|
339
|
+
transform: 'translate(14px, -9px) scale(0.75)'
|
|
340
|
+
})));
|
|
341
|
+
const InputLabel = /*#__PURE__*/React.forwardRef(function InputLabel(inProps, ref) {
|
|
342
|
+
const props = useDefaultProps({
|
|
343
|
+
name: 'MuiInputLabel',
|
|
344
|
+
props: inProps
|
|
345
|
+
});
|
|
346
|
+
const {
|
|
347
|
+
disableAnimation = false,
|
|
348
|
+
shrink: shrinkProp,
|
|
349
|
+
className
|
|
350
|
+
} = props,
|
|
351
|
+
other = _objectWithoutPropertiesLoose$1(props, _excluded$4);
|
|
352
|
+
const muiFormControl = useFormControl();
|
|
353
|
+
let shrink = shrinkProp;
|
|
354
|
+
if (typeof shrink === 'undefined' && muiFormControl) {
|
|
355
|
+
shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
|
356
|
+
}
|
|
357
|
+
const fcs = formControlState({
|
|
358
|
+
props,
|
|
359
|
+
muiFormControl,
|
|
360
|
+
states: ['size', 'variant', 'required', 'focused']
|
|
361
|
+
});
|
|
362
|
+
const ownerState = _extends$1({}, props, {
|
|
363
|
+
disableAnimation,
|
|
364
|
+
formControl: muiFormControl,
|
|
365
|
+
shrink,
|
|
366
|
+
size: fcs.size,
|
|
367
|
+
variant: fcs.variant,
|
|
368
|
+
required: fcs.required,
|
|
369
|
+
focused: fcs.focused
|
|
370
|
+
});
|
|
371
|
+
const classes = useUtilityClasses$3(ownerState);
|
|
372
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(InputLabelRoot, _extends$1({
|
|
373
|
+
"data-shrink": shrink,
|
|
374
|
+
ownerState: ownerState,
|
|
375
|
+
ref: ref,
|
|
376
|
+
className: clsx$1(classes.root, className)
|
|
377
|
+
}, other, {
|
|
378
|
+
classes: classes
|
|
379
|
+
}));
|
|
380
|
+
});
|
|
381
|
+
process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes */ = {
|
|
382
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
383
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
384
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
385
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
386
|
+
/**
|
|
387
|
+
* The content of the component.
|
|
388
|
+
*/
|
|
389
|
+
children: PropTypes.node,
|
|
390
|
+
/**
|
|
391
|
+
* Override or extend the styles applied to the component.
|
|
392
|
+
*/
|
|
393
|
+
classes: PropTypes.object,
|
|
394
|
+
/**
|
|
395
|
+
* @ignore
|
|
396
|
+
*/
|
|
397
|
+
className: PropTypes.string,
|
|
398
|
+
/**
|
|
399
|
+
* The color of the component.
|
|
400
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
401
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
402
|
+
*/
|
|
403
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
404
|
+
/**
|
|
405
|
+
* If `true`, the transition animation is disabled.
|
|
406
|
+
* @default false
|
|
407
|
+
*/
|
|
408
|
+
disableAnimation: PropTypes.bool,
|
|
409
|
+
/**
|
|
410
|
+
* If `true`, the component is disabled.
|
|
411
|
+
*/
|
|
412
|
+
disabled: PropTypes.bool,
|
|
413
|
+
/**
|
|
414
|
+
* If `true`, the label is displayed in an error state.
|
|
415
|
+
*/
|
|
416
|
+
error: PropTypes.bool,
|
|
417
|
+
/**
|
|
418
|
+
* If `true`, the `input` of this label is focused.
|
|
419
|
+
*/
|
|
420
|
+
focused: PropTypes.bool,
|
|
421
|
+
/**
|
|
422
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
423
|
+
* FormControl.
|
|
424
|
+
*/
|
|
425
|
+
margin: PropTypes.oneOf(['dense']),
|
|
426
|
+
/**
|
|
427
|
+
* if `true`, the label will indicate that the `input` is required.
|
|
428
|
+
*/
|
|
429
|
+
required: PropTypes.bool,
|
|
430
|
+
/**
|
|
431
|
+
* If `true`, the label is shrunk.
|
|
432
|
+
*/
|
|
433
|
+
shrink: PropTypes.bool,
|
|
434
|
+
/**
|
|
435
|
+
* The size of the component.
|
|
436
|
+
* @default 'normal'
|
|
437
|
+
*/
|
|
438
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['normal', 'small']), PropTypes.string]),
|
|
439
|
+
/**
|
|
440
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
441
|
+
*/
|
|
442
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
443
|
+
/**
|
|
444
|
+
* The variant to use.
|
|
445
|
+
*/
|
|
446
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
447
|
+
} : void 0;
|
|
448
|
+
var InputLabel$1 = InputLabel;
|
|
449
|
+
|
|
450
|
+
function getFormControlUtilityClasses(slot) {
|
|
451
|
+
return generateUtilityClass('MuiFormControl', slot);
|
|
452
|
+
}
|
|
453
|
+
generateUtilityClasses('MuiFormControl', ['root', 'marginNone', 'marginNormal', 'marginDense', 'fullWidth', 'disabled']);
|
|
454
|
+
|
|
455
|
+
const _excluded$3 = ["children", "className", "color", "component", "disabled", "error", "focused", "fullWidth", "hiddenLabel", "margin", "required", "size", "variant"];
|
|
456
|
+
const useUtilityClasses$2 = ownerState => {
|
|
457
|
+
const {
|
|
458
|
+
classes,
|
|
459
|
+
margin,
|
|
460
|
+
fullWidth
|
|
461
|
+
} = ownerState;
|
|
462
|
+
const slots = {
|
|
463
|
+
root: ['root', margin !== 'none' && `margin${capitalize(margin)}`, fullWidth && 'fullWidth']
|
|
464
|
+
};
|
|
465
|
+
return composeClasses(slots, getFormControlUtilityClasses, classes);
|
|
466
|
+
};
|
|
467
|
+
const FormControlRoot = styled$1('div', {
|
|
468
|
+
name: 'MuiFormControl',
|
|
469
|
+
slot: 'Root',
|
|
470
|
+
overridesResolver: ({
|
|
471
|
+
ownerState
|
|
472
|
+
}, styles) => {
|
|
473
|
+
return _extends$1({}, styles.root, styles[`margin${capitalize(ownerState.margin)}`], ownerState.fullWidth && styles.fullWidth);
|
|
474
|
+
}
|
|
475
|
+
})(({
|
|
476
|
+
ownerState
|
|
477
|
+
}) => _extends$1({
|
|
478
|
+
display: 'inline-flex',
|
|
479
|
+
flexDirection: 'column',
|
|
480
|
+
position: 'relative',
|
|
481
|
+
// Reset fieldset default style.
|
|
482
|
+
minWidth: 0,
|
|
483
|
+
padding: 0,
|
|
484
|
+
margin: 0,
|
|
485
|
+
border: 0,
|
|
486
|
+
verticalAlign: 'top'
|
|
487
|
+
}, ownerState.margin === 'normal' && {
|
|
488
|
+
marginTop: 16,
|
|
489
|
+
marginBottom: 8
|
|
490
|
+
}, ownerState.margin === 'dense' && {
|
|
491
|
+
marginTop: 8,
|
|
492
|
+
marginBottom: 4
|
|
493
|
+
}, ownerState.fullWidth && {
|
|
494
|
+
width: '100%'
|
|
495
|
+
}));
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Provides context such as filled/focused/error/required for form inputs.
|
|
499
|
+
* Relying on the context provides high flexibility and ensures that the state always stays
|
|
500
|
+
* consistent across the children of the `FormControl`.
|
|
501
|
+
* This context is used by the following components:
|
|
502
|
+
*
|
|
503
|
+
* - FormLabel
|
|
504
|
+
* - FormHelperText
|
|
505
|
+
* - Input
|
|
506
|
+
* - InputLabel
|
|
507
|
+
*
|
|
508
|
+
* You can find one composition example below and more going to [the demos](/material-ui/react-text-field/#components).
|
|
509
|
+
*
|
|
510
|
+
* ```jsx
|
|
511
|
+
* <FormControl>
|
|
512
|
+
* <InputLabel htmlFor="my-input">Email address</InputLabel>
|
|
513
|
+
* <Input id="my-input" aria-describedby="my-helper-text" />
|
|
514
|
+
* <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
|
515
|
+
* </FormControl>
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
518
|
+
* ⚠️ Only one `InputBase` can be used within a FormControl because it creates visual inconsistencies.
|
|
519
|
+
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
|
520
|
+
*/
|
|
521
|
+
const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps, ref) {
|
|
522
|
+
const props = useDefaultProps({
|
|
523
|
+
props: inProps,
|
|
524
|
+
name: 'MuiFormControl'
|
|
525
|
+
});
|
|
526
|
+
const {
|
|
527
|
+
children,
|
|
528
|
+
className,
|
|
529
|
+
color = 'primary',
|
|
530
|
+
component = 'div',
|
|
531
|
+
disabled = false,
|
|
532
|
+
error = false,
|
|
533
|
+
focused: visuallyFocused,
|
|
534
|
+
fullWidth = false,
|
|
535
|
+
hiddenLabel = false,
|
|
536
|
+
margin = 'none',
|
|
537
|
+
required = false,
|
|
538
|
+
size = 'medium',
|
|
539
|
+
variant = 'outlined'
|
|
540
|
+
} = props,
|
|
541
|
+
other = _objectWithoutPropertiesLoose$1(props, _excluded$3);
|
|
542
|
+
const ownerState = _extends$1({}, props, {
|
|
543
|
+
color,
|
|
544
|
+
component,
|
|
545
|
+
disabled,
|
|
546
|
+
error,
|
|
547
|
+
fullWidth,
|
|
548
|
+
hiddenLabel,
|
|
549
|
+
margin,
|
|
550
|
+
required,
|
|
551
|
+
size,
|
|
552
|
+
variant
|
|
553
|
+
});
|
|
554
|
+
const classes = useUtilityClasses$2(ownerState);
|
|
555
|
+
const [adornedStart, setAdornedStart] = React.useState(() => {
|
|
556
|
+
// We need to iterate through the children and find the Input in order
|
|
557
|
+
// to fully support server-side rendering.
|
|
558
|
+
let initialAdornedStart = false;
|
|
559
|
+
if (children) {
|
|
560
|
+
React.Children.forEach(children, child => {
|
|
561
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const input = isMuiElement(child, ['Select']) ? child.props.input : child;
|
|
565
|
+
if (input && isAdornedStart(input.props)) {
|
|
566
|
+
initialAdornedStart = true;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
return initialAdornedStart;
|
|
571
|
+
});
|
|
572
|
+
const [filled, setFilled] = React.useState(() => {
|
|
573
|
+
// We need to iterate through the children and find the Input in order
|
|
574
|
+
// to fully support server-side rendering.
|
|
575
|
+
let initialFilled = false;
|
|
576
|
+
if (children) {
|
|
577
|
+
React.Children.forEach(children, child => {
|
|
578
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
|
|
582
|
+
initialFilled = true;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
return initialFilled;
|
|
587
|
+
});
|
|
588
|
+
const [focusedState, setFocused] = React.useState(false);
|
|
589
|
+
if (disabled && focusedState) {
|
|
590
|
+
setFocused(false);
|
|
591
|
+
}
|
|
592
|
+
const focused = visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState;
|
|
593
|
+
let registerEffect;
|
|
594
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
595
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
596
|
+
const registeredInput = React.useRef(false);
|
|
597
|
+
registerEffect = () => {
|
|
598
|
+
if (registeredInput.current) {
|
|
599
|
+
console.error(['MUI: There are multiple `InputBase` components inside a FormControl.', 'This creates visual inconsistencies, only use one `InputBase`.'].join('\n'));
|
|
600
|
+
}
|
|
601
|
+
registeredInput.current = true;
|
|
602
|
+
return () => {
|
|
603
|
+
registeredInput.current = false;
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
const childContext = React.useMemo(() => {
|
|
608
|
+
return {
|
|
609
|
+
adornedStart,
|
|
610
|
+
setAdornedStart,
|
|
611
|
+
color,
|
|
612
|
+
disabled,
|
|
613
|
+
error,
|
|
614
|
+
filled,
|
|
615
|
+
focused,
|
|
616
|
+
fullWidth,
|
|
617
|
+
hiddenLabel,
|
|
618
|
+
size,
|
|
619
|
+
onBlur: () => {
|
|
620
|
+
setFocused(false);
|
|
621
|
+
},
|
|
622
|
+
onEmpty: () => {
|
|
623
|
+
setFilled(false);
|
|
624
|
+
},
|
|
625
|
+
onFilled: () => {
|
|
626
|
+
setFilled(true);
|
|
627
|
+
},
|
|
628
|
+
onFocus: () => {
|
|
629
|
+
setFocused(true);
|
|
630
|
+
},
|
|
631
|
+
registerEffect,
|
|
632
|
+
required,
|
|
633
|
+
variant
|
|
634
|
+
};
|
|
635
|
+
}, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, required, size, variant]);
|
|
636
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormControlContext.Provider, {
|
|
637
|
+
value: childContext,
|
|
638
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(FormControlRoot, _extends$1({
|
|
639
|
+
as: component,
|
|
640
|
+
ownerState: ownerState,
|
|
641
|
+
className: clsx$1(classes.root, className),
|
|
642
|
+
ref: ref
|
|
643
|
+
}, other, {
|
|
644
|
+
children: children
|
|
645
|
+
}))
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
process.env.NODE_ENV !== "production" ? FormControl.propTypes /* remove-proptypes */ = {
|
|
649
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
650
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
651
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
652
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
653
|
+
/**
|
|
654
|
+
* The content of the component.
|
|
655
|
+
*/
|
|
656
|
+
children: PropTypes.node,
|
|
657
|
+
/**
|
|
658
|
+
* Override or extend the styles applied to the component.
|
|
659
|
+
*/
|
|
660
|
+
classes: PropTypes.object,
|
|
661
|
+
/**
|
|
662
|
+
* @ignore
|
|
663
|
+
*/
|
|
664
|
+
className: PropTypes.string,
|
|
665
|
+
/**
|
|
666
|
+
* The color of the component.
|
|
667
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
668
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
669
|
+
* @default 'primary'
|
|
670
|
+
*/
|
|
671
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
672
|
+
/**
|
|
673
|
+
* The component used for the root node.
|
|
674
|
+
* Either a string to use a HTML element or a component.
|
|
675
|
+
*/
|
|
676
|
+
component: PropTypes.elementType,
|
|
677
|
+
/**
|
|
678
|
+
* If `true`, the label, input and helper text should be displayed in a disabled state.
|
|
679
|
+
* @default false
|
|
680
|
+
*/
|
|
681
|
+
disabled: PropTypes.bool,
|
|
682
|
+
/**
|
|
683
|
+
* If `true`, the label is displayed in an error state.
|
|
684
|
+
* @default false
|
|
685
|
+
*/
|
|
686
|
+
error: PropTypes.bool,
|
|
687
|
+
/**
|
|
688
|
+
* If `true`, the component is displayed in focused state.
|
|
689
|
+
*/
|
|
690
|
+
focused: PropTypes.bool,
|
|
691
|
+
/**
|
|
692
|
+
* If `true`, the component will take up the full width of its container.
|
|
693
|
+
* @default false
|
|
694
|
+
*/
|
|
695
|
+
fullWidth: PropTypes.bool,
|
|
696
|
+
/**
|
|
697
|
+
* If `true`, the label is hidden.
|
|
698
|
+
* This is used to increase density for a `FilledInput`.
|
|
699
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
700
|
+
* @default false
|
|
701
|
+
*/
|
|
702
|
+
hiddenLabel: PropTypes.bool,
|
|
703
|
+
/**
|
|
704
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
705
|
+
* @default 'none'
|
|
706
|
+
*/
|
|
707
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
708
|
+
/**
|
|
709
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
710
|
+
* @default false
|
|
711
|
+
*/
|
|
712
|
+
required: PropTypes.bool,
|
|
713
|
+
/**
|
|
714
|
+
* The size of the component.
|
|
715
|
+
* @default 'medium'
|
|
716
|
+
*/
|
|
717
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
718
|
+
/**
|
|
719
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
720
|
+
*/
|
|
721
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
722
|
+
/**
|
|
723
|
+
* The variant to use.
|
|
724
|
+
* @default 'outlined'
|
|
725
|
+
*/
|
|
726
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
727
|
+
} : void 0;
|
|
728
|
+
var FormControl$1 = FormControl;
|
|
729
|
+
|
|
730
|
+
function getFormHelperTextUtilityClasses(slot) {
|
|
731
|
+
return generateUtilityClass('MuiFormHelperText', slot);
|
|
732
|
+
}
|
|
733
|
+
const formHelperTextClasses = generateUtilityClasses('MuiFormHelperText', ['root', 'error', 'disabled', 'sizeSmall', 'sizeMedium', 'contained', 'focused', 'filled', 'required']);
|
|
734
|
+
var formHelperTextClasses$1 = formHelperTextClasses;
|
|
735
|
+
|
|
736
|
+
var _span;
|
|
737
|
+
const _excluded$2 = ["children", "className", "component", "disabled", "error", "filled", "focused", "margin", "required", "variant"];
|
|
738
|
+
const useUtilityClasses$1 = ownerState => {
|
|
739
|
+
const {
|
|
740
|
+
classes,
|
|
741
|
+
contained,
|
|
742
|
+
size,
|
|
743
|
+
disabled,
|
|
744
|
+
error,
|
|
745
|
+
filled,
|
|
746
|
+
focused,
|
|
747
|
+
required
|
|
748
|
+
} = ownerState;
|
|
749
|
+
const slots = {
|
|
750
|
+
root: ['root', disabled && 'disabled', error && 'error', size && `size${capitalize(size)}`, contained && 'contained', focused && 'focused', filled && 'filled', required && 'required']
|
|
751
|
+
};
|
|
752
|
+
return composeClasses(slots, getFormHelperTextUtilityClasses, classes);
|
|
753
|
+
};
|
|
754
|
+
const FormHelperTextRoot = styled$1('p', {
|
|
755
|
+
name: 'MuiFormHelperText',
|
|
756
|
+
slot: 'Root',
|
|
757
|
+
overridesResolver: (props, styles) => {
|
|
758
|
+
const {
|
|
759
|
+
ownerState
|
|
760
|
+
} = props;
|
|
761
|
+
return [styles.root, ownerState.size && styles[`size${capitalize(ownerState.size)}`], ownerState.contained && styles.contained, ownerState.filled && styles.filled];
|
|
762
|
+
}
|
|
763
|
+
})(({
|
|
764
|
+
theme,
|
|
765
|
+
ownerState
|
|
766
|
+
}) => _extends$1({
|
|
767
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
768
|
+
}, theme.typography.caption, {
|
|
769
|
+
textAlign: 'left',
|
|
770
|
+
marginTop: 3,
|
|
771
|
+
marginRight: 0,
|
|
772
|
+
marginBottom: 0,
|
|
773
|
+
marginLeft: 0,
|
|
774
|
+
[`&.${formHelperTextClasses$1.disabled}`]: {
|
|
775
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
776
|
+
},
|
|
777
|
+
[`&.${formHelperTextClasses$1.error}`]: {
|
|
778
|
+
color: (theme.vars || theme).palette.error.main
|
|
779
|
+
}
|
|
780
|
+
}, ownerState.size === 'small' && {
|
|
781
|
+
marginTop: 4
|
|
782
|
+
}, ownerState.contained && {
|
|
783
|
+
marginLeft: 14,
|
|
784
|
+
marginRight: 14
|
|
785
|
+
}));
|
|
786
|
+
const FormHelperText = /*#__PURE__*/React.forwardRef(function FormHelperText(inProps, ref) {
|
|
787
|
+
const props = useDefaultProps({
|
|
788
|
+
props: inProps,
|
|
789
|
+
name: 'MuiFormHelperText'
|
|
790
|
+
});
|
|
791
|
+
const {
|
|
792
|
+
children,
|
|
793
|
+
className,
|
|
794
|
+
component = 'p'
|
|
795
|
+
} = props,
|
|
796
|
+
other = _objectWithoutPropertiesLoose$1(props, _excluded$2);
|
|
797
|
+
const muiFormControl = useFormControl();
|
|
798
|
+
const fcs = formControlState({
|
|
799
|
+
props,
|
|
800
|
+
muiFormControl,
|
|
801
|
+
states: ['variant', 'size', 'disabled', 'error', 'filled', 'focused', 'required']
|
|
802
|
+
});
|
|
803
|
+
const ownerState = _extends$1({}, props, {
|
|
804
|
+
component,
|
|
805
|
+
contained: fcs.variant === 'filled' || fcs.variant === 'outlined',
|
|
806
|
+
variant: fcs.variant,
|
|
807
|
+
size: fcs.size,
|
|
808
|
+
disabled: fcs.disabled,
|
|
809
|
+
error: fcs.error,
|
|
810
|
+
filled: fcs.filled,
|
|
811
|
+
focused: fcs.focused,
|
|
812
|
+
required: fcs.required
|
|
813
|
+
});
|
|
814
|
+
const classes = useUtilityClasses$1(ownerState);
|
|
815
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperTextRoot, _extends$1({
|
|
816
|
+
as: component,
|
|
817
|
+
ownerState: ownerState,
|
|
818
|
+
className: clsx$1(classes.root, className),
|
|
819
|
+
ref: ref
|
|
820
|
+
}, other, {
|
|
821
|
+
children: children === ' ' ? // notranslate needed while Google Translate will not fix zero-width space issue
|
|
822
|
+
_span || (_span = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
823
|
+
className: "notranslate",
|
|
824
|
+
children: "\u200B"
|
|
825
|
+
})) : children
|
|
826
|
+
}));
|
|
827
|
+
});
|
|
828
|
+
process.env.NODE_ENV !== "production" ? FormHelperText.propTypes /* remove-proptypes */ = {
|
|
829
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
830
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
831
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
832
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
833
|
+
/**
|
|
834
|
+
* The content of the component.
|
|
835
|
+
*
|
|
836
|
+
* If `' '` is provided, the component reserves one line height for displaying a future message.
|
|
837
|
+
*/
|
|
838
|
+
children: PropTypes.node,
|
|
839
|
+
/**
|
|
840
|
+
* Override or extend the styles applied to the component.
|
|
841
|
+
*/
|
|
842
|
+
classes: PropTypes.object,
|
|
843
|
+
/**
|
|
844
|
+
* @ignore
|
|
845
|
+
*/
|
|
846
|
+
className: PropTypes.string,
|
|
847
|
+
/**
|
|
848
|
+
* The component used for the root node.
|
|
849
|
+
* Either a string to use a HTML element or a component.
|
|
850
|
+
*/
|
|
851
|
+
component: PropTypes.elementType,
|
|
852
|
+
/**
|
|
853
|
+
* If `true`, the helper text should be displayed in a disabled state.
|
|
854
|
+
*/
|
|
855
|
+
disabled: PropTypes.bool,
|
|
856
|
+
/**
|
|
857
|
+
* If `true`, helper text should be displayed in an error state.
|
|
858
|
+
*/
|
|
859
|
+
error: PropTypes.bool,
|
|
860
|
+
/**
|
|
861
|
+
* If `true`, the helper text should use filled classes key.
|
|
862
|
+
*/
|
|
863
|
+
filled: PropTypes.bool,
|
|
864
|
+
/**
|
|
865
|
+
* If `true`, the helper text should use focused classes key.
|
|
866
|
+
*/
|
|
867
|
+
focused: PropTypes.bool,
|
|
868
|
+
/**
|
|
869
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
870
|
+
* FormControl.
|
|
871
|
+
*/
|
|
872
|
+
margin: PropTypes.oneOf(['dense']),
|
|
873
|
+
/**
|
|
874
|
+
* If `true`, the helper text should use required classes key.
|
|
875
|
+
*/
|
|
876
|
+
required: PropTypes.bool,
|
|
877
|
+
/**
|
|
878
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
879
|
+
*/
|
|
880
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
881
|
+
/**
|
|
882
|
+
* The variant to use.
|
|
883
|
+
*/
|
|
884
|
+
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
|
885
|
+
} : void 0;
|
|
886
|
+
var FormHelperText$1 = FormHelperText;
|
|
887
|
+
|
|
888
|
+
function getTextFieldUtilityClass(slot) {
|
|
889
|
+
return generateUtilityClass('MuiTextField', slot);
|
|
890
|
+
}
|
|
891
|
+
generateUtilityClasses('MuiTextField', ['root']);
|
|
892
|
+
|
|
893
|
+
const _excluded$1 = ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"];
|
|
894
|
+
const variantComponent = {
|
|
895
|
+
standard: Input,
|
|
896
|
+
filled: FilledInput,
|
|
897
|
+
outlined: OutlinedInput
|
|
898
|
+
};
|
|
899
|
+
const useUtilityClasses = ownerState => {
|
|
900
|
+
const {
|
|
901
|
+
classes
|
|
902
|
+
} = ownerState;
|
|
903
|
+
const slots = {
|
|
904
|
+
root: ['root']
|
|
905
|
+
};
|
|
906
|
+
return composeClasses(slots, getTextFieldUtilityClass, classes);
|
|
907
|
+
};
|
|
908
|
+
const TextFieldRoot = styled$1(FormControl$1, {
|
|
909
|
+
name: 'MuiTextField',
|
|
910
|
+
slot: 'Root',
|
|
911
|
+
overridesResolver: (props, styles) => styles.root
|
|
912
|
+
})({});
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* The `TextField` is a convenience wrapper for the most common cases (80%).
|
|
916
|
+
* It cannot be all things to all people, otherwise the API would grow out of control.
|
|
917
|
+
*
|
|
918
|
+
* ## Advanced Configuration
|
|
919
|
+
*
|
|
920
|
+
* It's important to understand that the text field is a simple abstraction
|
|
921
|
+
* on top of the following components:
|
|
922
|
+
*
|
|
923
|
+
* - [FormControl](/material-ui/api/form-control/)
|
|
924
|
+
* - [InputLabel](/material-ui/api/input-label/)
|
|
925
|
+
* - [FilledInput](/material-ui/api/filled-input/)
|
|
926
|
+
* - [OutlinedInput](/material-ui/api/outlined-input/)
|
|
927
|
+
* - [Input](/material-ui/api/input/)
|
|
928
|
+
* - [FormHelperText](/material-ui/api/form-helper-text/)
|
|
929
|
+
*
|
|
930
|
+
* If you wish to alter the props applied to the `input` element, you can do so as follows:
|
|
931
|
+
*
|
|
932
|
+
* ```jsx
|
|
933
|
+
* const inputProps = {
|
|
934
|
+
* step: 300,
|
|
935
|
+
* };
|
|
936
|
+
*
|
|
937
|
+
* return <TextField id="time" type="time" inputProps={inputProps} />;
|
|
938
|
+
* ```
|
|
939
|
+
*
|
|
940
|
+
* For advanced cases, please look at the source of TextField by clicking on the
|
|
941
|
+
* "Edit this page" button above. Consider either:
|
|
942
|
+
*
|
|
943
|
+
* - using the upper case props for passing values directly to the components
|
|
944
|
+
* - using the underlying components directly as shown in the demos
|
|
945
|
+
*/
|
|
946
|
+
const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
|
|
947
|
+
const props = useDefaultProps({
|
|
948
|
+
props: inProps,
|
|
949
|
+
name: 'MuiTextField'
|
|
950
|
+
});
|
|
951
|
+
const {
|
|
952
|
+
autoComplete,
|
|
953
|
+
autoFocus = false,
|
|
954
|
+
children,
|
|
955
|
+
className,
|
|
956
|
+
color = 'primary',
|
|
957
|
+
defaultValue,
|
|
958
|
+
disabled = false,
|
|
959
|
+
error = false,
|
|
960
|
+
FormHelperTextProps,
|
|
961
|
+
fullWidth = false,
|
|
962
|
+
helperText,
|
|
963
|
+
id: idOverride,
|
|
964
|
+
InputLabelProps,
|
|
965
|
+
inputProps,
|
|
966
|
+
InputProps,
|
|
967
|
+
inputRef,
|
|
968
|
+
label,
|
|
969
|
+
maxRows,
|
|
970
|
+
minRows,
|
|
971
|
+
multiline = false,
|
|
972
|
+
name,
|
|
973
|
+
onBlur,
|
|
974
|
+
onChange,
|
|
975
|
+
onFocus,
|
|
976
|
+
placeholder,
|
|
977
|
+
required = false,
|
|
978
|
+
rows,
|
|
979
|
+
select = false,
|
|
980
|
+
SelectProps,
|
|
981
|
+
type,
|
|
982
|
+
value,
|
|
983
|
+
variant = 'outlined'
|
|
984
|
+
} = props,
|
|
985
|
+
other = _objectWithoutPropertiesLoose$1(props, _excluded$1);
|
|
986
|
+
const ownerState = _extends$1({}, props, {
|
|
987
|
+
autoFocus,
|
|
988
|
+
color,
|
|
989
|
+
disabled,
|
|
990
|
+
error,
|
|
991
|
+
fullWidth,
|
|
992
|
+
multiline,
|
|
993
|
+
required,
|
|
994
|
+
select,
|
|
995
|
+
variant
|
|
996
|
+
});
|
|
997
|
+
const classes = useUtilityClasses(ownerState);
|
|
998
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
999
|
+
if (select && !children) {
|
|
1000
|
+
console.error('MUI: `children` must be passed when using the `TextField` component with `select`.');
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
const InputMore = {};
|
|
1004
|
+
if (variant === 'outlined') {
|
|
1005
|
+
if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
|
|
1006
|
+
InputMore.notched = InputLabelProps.shrink;
|
|
1007
|
+
}
|
|
1008
|
+
InputMore.label = label;
|
|
1009
|
+
}
|
|
1010
|
+
if (select) {
|
|
1011
|
+
// unset defaults from textbox inputs
|
|
1012
|
+
if (!SelectProps || !SelectProps.native) {
|
|
1013
|
+
InputMore.id = undefined;
|
|
1014
|
+
}
|
|
1015
|
+
InputMore['aria-describedby'] = undefined;
|
|
1016
|
+
}
|
|
1017
|
+
const id = useId(idOverride);
|
|
1018
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
1019
|
+
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
1020
|
+
const InputComponent = variantComponent[variant];
|
|
1021
|
+
const InputElement = /*#__PURE__*/jsxRuntimeExports.jsx(InputComponent, _extends$1({
|
|
1022
|
+
"aria-describedby": helperTextId,
|
|
1023
|
+
autoComplete: autoComplete,
|
|
1024
|
+
autoFocus: autoFocus,
|
|
1025
|
+
defaultValue: defaultValue,
|
|
1026
|
+
fullWidth: fullWidth,
|
|
1027
|
+
multiline: multiline,
|
|
1028
|
+
name: name,
|
|
1029
|
+
rows: rows,
|
|
1030
|
+
maxRows: maxRows,
|
|
1031
|
+
minRows: minRows,
|
|
1032
|
+
type: type,
|
|
1033
|
+
value: value,
|
|
1034
|
+
id: id,
|
|
1035
|
+
inputRef: inputRef,
|
|
1036
|
+
onBlur: onBlur,
|
|
1037
|
+
onChange: onChange,
|
|
1038
|
+
onFocus: onFocus,
|
|
1039
|
+
placeholder: placeholder,
|
|
1040
|
+
inputProps: inputProps
|
|
1041
|
+
}, InputMore, InputProps));
|
|
1042
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(TextFieldRoot, _extends$1({
|
|
1043
|
+
className: clsx$1(classes.root, className),
|
|
1044
|
+
disabled: disabled,
|
|
1045
|
+
error: error,
|
|
1046
|
+
fullWidth: fullWidth,
|
|
1047
|
+
ref: ref,
|
|
1048
|
+
required: required,
|
|
1049
|
+
color: color,
|
|
1050
|
+
variant: variant,
|
|
1051
|
+
ownerState: ownerState
|
|
1052
|
+
}, other, {
|
|
1053
|
+
children: [label != null && label !== '' && /*#__PURE__*/jsxRuntimeExports.jsx(InputLabel$1, _extends$1({
|
|
1054
|
+
htmlFor: id,
|
|
1055
|
+
id: inputLabelId
|
|
1056
|
+
}, InputLabelProps, {
|
|
1057
|
+
children: label
|
|
1058
|
+
})), select ? /*#__PURE__*/jsxRuntimeExports.jsx(Select, _extends$1({
|
|
1059
|
+
"aria-describedby": helperTextId,
|
|
1060
|
+
id: id,
|
|
1061
|
+
labelId: inputLabelId,
|
|
1062
|
+
value: value,
|
|
1063
|
+
input: InputElement
|
|
1064
|
+
}, SelectProps, {
|
|
1065
|
+
children: children
|
|
1066
|
+
})) : InputElement, helperText && /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperText$1, _extends$1({
|
|
1067
|
+
id: helperTextId
|
|
1068
|
+
}, FormHelperTextProps, {
|
|
1069
|
+
children: helperText
|
|
1070
|
+
}))]
|
|
1071
|
+
}));
|
|
1072
|
+
});
|
|
1073
|
+
process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes */ = {
|
|
1074
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
1075
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
1076
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
1077
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
1078
|
+
/**
|
|
1079
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
1080
|
+
* The name can be confusing, as it's more like an autofill.
|
|
1081
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
1082
|
+
*/
|
|
1083
|
+
autoComplete: PropTypes.string,
|
|
1084
|
+
/**
|
|
1085
|
+
* If `true`, the `input` element is focused during the first mount.
|
|
1086
|
+
* @default false
|
|
1087
|
+
*/
|
|
1088
|
+
autoFocus: PropTypes.bool,
|
|
1089
|
+
/**
|
|
1090
|
+
* @ignore
|
|
1091
|
+
*/
|
|
1092
|
+
children: PropTypes.node,
|
|
1093
|
+
/**
|
|
1094
|
+
* Override or extend the styles applied to the component.
|
|
1095
|
+
*/
|
|
1096
|
+
classes: PropTypes.object,
|
|
1097
|
+
/**
|
|
1098
|
+
* @ignore
|
|
1099
|
+
*/
|
|
1100
|
+
className: PropTypes.string,
|
|
1101
|
+
/**
|
|
1102
|
+
* The color of the component.
|
|
1103
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
1104
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
1105
|
+
* @default 'primary'
|
|
1106
|
+
*/
|
|
1107
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
1108
|
+
/**
|
|
1109
|
+
* The default value. Use when the component is not controlled.
|
|
1110
|
+
*/
|
|
1111
|
+
defaultValue: PropTypes.any,
|
|
1112
|
+
/**
|
|
1113
|
+
* If `true`, the component is disabled.
|
|
1114
|
+
* @default false
|
|
1115
|
+
*/
|
|
1116
|
+
disabled: PropTypes.bool,
|
|
1117
|
+
/**
|
|
1118
|
+
* If `true`, the label is displayed in an error state.
|
|
1119
|
+
* @default false
|
|
1120
|
+
*/
|
|
1121
|
+
error: PropTypes.bool,
|
|
1122
|
+
/**
|
|
1123
|
+
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
1124
|
+
*/
|
|
1125
|
+
FormHelperTextProps: PropTypes.object,
|
|
1126
|
+
/**
|
|
1127
|
+
* If `true`, the input will take up the full width of its container.
|
|
1128
|
+
* @default false
|
|
1129
|
+
*/
|
|
1130
|
+
fullWidth: PropTypes.bool,
|
|
1131
|
+
/**
|
|
1132
|
+
* The helper text content.
|
|
1133
|
+
*/
|
|
1134
|
+
helperText: PropTypes.node,
|
|
1135
|
+
/**
|
|
1136
|
+
* The id of the `input` element.
|
|
1137
|
+
* Use this prop to make `label` and `helperText` accessible for screen readers.
|
|
1138
|
+
*/
|
|
1139
|
+
id: PropTypes.string,
|
|
1140
|
+
/**
|
|
1141
|
+
* Props applied to the [`InputLabel`](/material-ui/api/input-label/) element.
|
|
1142
|
+
* Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
|
|
1143
|
+
*/
|
|
1144
|
+
InputLabelProps: PropTypes.object,
|
|
1145
|
+
/**
|
|
1146
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
1147
|
+
*/
|
|
1148
|
+
inputProps: PropTypes.object,
|
|
1149
|
+
/**
|
|
1150
|
+
* Props applied to the Input element.
|
|
1151
|
+
* It will be a [`FilledInput`](/material-ui/api/filled-input/),
|
|
1152
|
+
* [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/)
|
|
1153
|
+
* component depending on the `variant` prop value.
|
|
1154
|
+
*/
|
|
1155
|
+
InputProps: PropTypes.object,
|
|
1156
|
+
/**
|
|
1157
|
+
* Pass a ref to the `input` element.
|
|
1158
|
+
*/
|
|
1159
|
+
inputRef: refType,
|
|
1160
|
+
/**
|
|
1161
|
+
* The label content.
|
|
1162
|
+
*/
|
|
1163
|
+
label: PropTypes.node,
|
|
1164
|
+
/**
|
|
1165
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
1166
|
+
* @default 'none'
|
|
1167
|
+
*/
|
|
1168
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
1169
|
+
/**
|
|
1170
|
+
* Maximum number of rows to display when multiline option is set to true.
|
|
1171
|
+
*/
|
|
1172
|
+
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1173
|
+
/**
|
|
1174
|
+
* Minimum number of rows to display when multiline option is set to true.
|
|
1175
|
+
*/
|
|
1176
|
+
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1177
|
+
/**
|
|
1178
|
+
* If `true`, a `textarea` element is rendered instead of an input.
|
|
1179
|
+
* @default false
|
|
1180
|
+
*/
|
|
1181
|
+
multiline: PropTypes.bool,
|
|
1182
|
+
/**
|
|
1183
|
+
* Name attribute of the `input` element.
|
|
1184
|
+
*/
|
|
1185
|
+
name: PropTypes.string,
|
|
1186
|
+
/**
|
|
1187
|
+
* @ignore
|
|
1188
|
+
*/
|
|
1189
|
+
onBlur: PropTypes.func,
|
|
1190
|
+
/**
|
|
1191
|
+
* Callback fired when the value is changed.
|
|
1192
|
+
*
|
|
1193
|
+
* @param {object} event The event source of the callback.
|
|
1194
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
1195
|
+
*/
|
|
1196
|
+
onChange: PropTypes.func,
|
|
1197
|
+
/**
|
|
1198
|
+
* @ignore
|
|
1199
|
+
*/
|
|
1200
|
+
onFocus: PropTypes.func,
|
|
1201
|
+
/**
|
|
1202
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
1203
|
+
*/
|
|
1204
|
+
placeholder: PropTypes.string,
|
|
1205
|
+
/**
|
|
1206
|
+
* If `true`, the label is displayed as required and the `input` element is required.
|
|
1207
|
+
* @default false
|
|
1208
|
+
*/
|
|
1209
|
+
required: PropTypes.bool,
|
|
1210
|
+
/**
|
|
1211
|
+
* Number of rows to display when multiline option is set to true.
|
|
1212
|
+
*/
|
|
1213
|
+
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1214
|
+
/**
|
|
1215
|
+
* Render a [`Select`](/material-ui/api/select/) element while passing the Input element to `Select` as `input` parameter.
|
|
1216
|
+
* If this option is set you must pass the options of the select as children.
|
|
1217
|
+
* @default false
|
|
1218
|
+
*/
|
|
1219
|
+
select: PropTypes.bool,
|
|
1220
|
+
/**
|
|
1221
|
+
* Props applied to the [`Select`](/material-ui/api/select/) element.
|
|
1222
|
+
*/
|
|
1223
|
+
SelectProps: PropTypes.object,
|
|
1224
|
+
/**
|
|
1225
|
+
* The size of the component.
|
|
1226
|
+
*/
|
|
1227
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
1228
|
+
/**
|
|
1229
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
1230
|
+
*/
|
|
1231
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1232
|
+
/**
|
|
1233
|
+
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
|
|
1234
|
+
*/
|
|
1235
|
+
type: PropTypes /* @typescript-to-proptypes-ignore */.string,
|
|
1236
|
+
/**
|
|
1237
|
+
* The value of the `input` element, required for a controlled component.
|
|
1238
|
+
*/
|
|
1239
|
+
value: PropTypes.any,
|
|
1240
|
+
/**
|
|
1241
|
+
* The variant to use.
|
|
1242
|
+
* @default 'outlined'
|
|
1243
|
+
*/
|
|
1244
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
1245
|
+
} : void 0;
|
|
1246
|
+
var TextField$1 = TextField;
|
|
16
1247
|
|
|
17
1248
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
18
1249
|
const InputNumberInterval = props => {
|
|
@@ -54,7 +1285,7 @@ const InputNumberInterval = props => {
|
|
|
54
1285
|
const newLowerBound = event.target.value;
|
|
55
1286
|
updateFilterValue(newLowerBound, filterValueState[1]);
|
|
56
1287
|
};
|
|
57
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
1288
|
+
return /*#__PURE__*/React.createElement(Box$1, {
|
|
58
1289
|
sx: {
|
|
59
1290
|
display: 'inline-flex',
|
|
60
1291
|
flexDirection: 'row',
|
|
@@ -62,7 +1293,7 @@ const InputNumberInterval = props => {
|
|
|
62
1293
|
height: 48,
|
|
63
1294
|
pl: '20px'
|
|
64
1295
|
}
|
|
65
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
1296
|
+
}, /*#__PURE__*/React.createElement(TextField$1, {
|
|
66
1297
|
name: "lower-bound-input",
|
|
67
1298
|
placeholder: "From",
|
|
68
1299
|
label: "From",
|
|
@@ -74,7 +1305,7 @@ const InputNumberInterval = props => {
|
|
|
74
1305
|
sx: {
|
|
75
1306
|
mr: 2
|
|
76
1307
|
}
|
|
77
|
-
}), /*#__PURE__*/React.createElement(TextField, {
|
|
1308
|
+
}), /*#__PURE__*/React.createElement(TextField$1, {
|
|
78
1309
|
name: "upper-bound-input",
|
|
79
1310
|
placeholder: "To",
|
|
80
1311
|
label: "To",
|
|
@@ -106,8 +1337,8 @@ const isBetweenOperator = {
|
|
|
106
1337
|
if (typeof filterItem.value[0] !== 'number' || typeof filterItem.value[1] !== 'number') {
|
|
107
1338
|
return null;
|
|
108
1339
|
}
|
|
109
|
-
return
|
|
110
|
-
return value !== null && value !== undefined && filterItem.value[0] <= value && value <= filterItem.value[1];
|
|
1340
|
+
return params => {
|
|
1341
|
+
return params.value !== null && params.value !== undefined && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
111
1342
|
};
|
|
112
1343
|
},
|
|
113
1344
|
InputComponent: InputNumberInterval
|
|
@@ -123,14 +1354,14 @@ const doesNotContain = {
|
|
|
123
1354
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
124
1355
|
return null;
|
|
125
1356
|
}
|
|
126
|
-
return
|
|
1357
|
+
return params => {
|
|
127
1358
|
if (filterItem.value.length === 0) {
|
|
128
1359
|
return true;
|
|
129
1360
|
}
|
|
130
|
-
if (value == null) {
|
|
1361
|
+
if (params.value == null) {
|
|
131
1362
|
return true;
|
|
132
1363
|
}
|
|
133
|
-
if (String(value).indexOf(filterItem.value) !== -1) {
|
|
1364
|
+
if (String(params.value).indexOf(filterItem.value) !== -1) {
|
|
134
1365
|
return false;
|
|
135
1366
|
}
|
|
136
1367
|
return true;
|
|
@@ -147,11 +1378,11 @@ const doesNotEndWithOperator = {
|
|
|
147
1378
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
148
1379
|
return null;
|
|
149
1380
|
}
|
|
150
|
-
return
|
|
151
|
-
if (value == null) {
|
|
1381
|
+
return params => {
|
|
1382
|
+
if (params.value == null) {
|
|
152
1383
|
return true;
|
|
153
1384
|
}
|
|
154
|
-
return !String(value).endsWith(filterItem.value);
|
|
1385
|
+
return !String(params.value).endsWith(filterItem.value);
|
|
155
1386
|
};
|
|
156
1387
|
},
|
|
157
1388
|
InputComponent: GridFilterInputValue
|
|
@@ -165,11 +1396,11 @@ const doesNotEqual = {
|
|
|
165
1396
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
166
1397
|
return null;
|
|
167
1398
|
}
|
|
168
|
-
return
|
|
169
|
-
if (value == null) {
|
|
1399
|
+
return params => {
|
|
1400
|
+
if (params.value == null) {
|
|
170
1401
|
return true;
|
|
171
1402
|
}
|
|
172
|
-
if (String(value) === filterItem.value) {
|
|
1403
|
+
if (String(params.value) === filterItem.value) {
|
|
173
1404
|
return false;
|
|
174
1405
|
}
|
|
175
1406
|
return true;
|
|
@@ -186,11 +1417,11 @@ const doesNotHaveOperator = {
|
|
|
186
1417
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
187
1418
|
return null;
|
|
188
1419
|
}
|
|
189
|
-
return
|
|
190
|
-
if (value == null) {
|
|
1420
|
+
return params => {
|
|
1421
|
+
if (params.value == null) {
|
|
191
1422
|
return true;
|
|
192
1423
|
}
|
|
193
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1424
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
194
1425
|
return !cellValues.map(value => String(value)).includes(filterItem.value);
|
|
195
1426
|
};
|
|
196
1427
|
},
|
|
@@ -208,11 +1439,11 @@ const doesNotStartWithOperator = {
|
|
|
208
1439
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
209
1440
|
return null;
|
|
210
1441
|
}
|
|
211
|
-
return
|
|
212
|
-
if (value == null) {
|
|
1442
|
+
return params => {
|
|
1443
|
+
if (params.value == null) {
|
|
213
1444
|
return true;
|
|
214
1445
|
}
|
|
215
|
-
return !String(value).startsWith(filterItem.value);
|
|
1446
|
+
return !String(params.value).startsWith(filterItem.value);
|
|
216
1447
|
};
|
|
217
1448
|
},
|
|
218
1449
|
InputComponent: GridFilterInputValue
|
|
@@ -226,11 +1457,11 @@ const hasOperator = {
|
|
|
226
1457
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
227
1458
|
return null;
|
|
228
1459
|
}
|
|
229
|
-
return
|
|
230
|
-
if (value == null) {
|
|
1460
|
+
return params => {
|
|
1461
|
+
if (params.value == null) {
|
|
231
1462
|
return false;
|
|
232
1463
|
}
|
|
233
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1464
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
234
1465
|
return cellValues.map(value => String(value)).includes(filterItem.value);
|
|
235
1466
|
};
|
|
236
1467
|
},
|
|
@@ -248,11 +1479,11 @@ const hasOnlyOperator = {
|
|
|
248
1479
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
249
1480
|
return null;
|
|
250
1481
|
}
|
|
251
|
-
return
|
|
252
|
-
if (value == null) {
|
|
1482
|
+
return params => {
|
|
1483
|
+
if (params.value == null) {
|
|
253
1484
|
return false;
|
|
254
1485
|
}
|
|
255
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1486
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
256
1487
|
return cellValues.length === 1 && String(cellValues[0]) === filterItem.value;
|
|
257
1488
|
};
|
|
258
1489
|
},
|
|
@@ -270,14 +1501,14 @@ const isOperator = {
|
|
|
270
1501
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
271
1502
|
return null;
|
|
272
1503
|
}
|
|
273
|
-
return
|
|
274
|
-
if (value == null) {
|
|
1504
|
+
return params => {
|
|
1505
|
+
if (params.value == null) {
|
|
275
1506
|
return false;
|
|
276
1507
|
}
|
|
277
|
-
if (Array.isArray(value)) {
|
|
1508
|
+
if (Array.isArray(params.value)) {
|
|
278
1509
|
return false;
|
|
279
1510
|
}
|
|
280
|
-
return String(value) === filterItem.value;
|
|
1511
|
+
return String(params.value) === filterItem.value;
|
|
281
1512
|
};
|
|
282
1513
|
},
|
|
283
1514
|
InputComponent: GridFilterInputValue
|
|
@@ -294,14 +1525,14 @@ const isNotOperator = {
|
|
|
294
1525
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
295
1526
|
return null;
|
|
296
1527
|
}
|
|
297
|
-
return
|
|
298
|
-
if (value == null) {
|
|
1528
|
+
return params => {
|
|
1529
|
+
if (params.value == null) {
|
|
299
1530
|
return true;
|
|
300
1531
|
}
|
|
301
|
-
if (Array.isArray(value)) {
|
|
1532
|
+
if (Array.isArray(params.value)) {
|
|
302
1533
|
return true;
|
|
303
1534
|
}
|
|
304
|
-
return String(value) !== filterItem.value;
|
|
1535
|
+
return String(params.value) !== filterItem.value;
|
|
305
1536
|
};
|
|
306
1537
|
},
|
|
307
1538
|
InputComponent: GridFilterInputValue
|
|
@@ -318,14 +1549,14 @@ const containsAnyOfOperator = {
|
|
|
318
1549
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
319
1550
|
return null;
|
|
320
1551
|
}
|
|
321
|
-
return
|
|
1552
|
+
return params => {
|
|
322
1553
|
if (filterItem.value.length === 0) {
|
|
323
1554
|
return true;
|
|
324
1555
|
}
|
|
325
|
-
if (value == null) {
|
|
1556
|
+
if (params.value == null) {
|
|
326
1557
|
return false;
|
|
327
1558
|
}
|
|
328
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1559
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
329
1560
|
let match = false;
|
|
330
1561
|
filterItem.value.forEach(filteredValue => {
|
|
331
1562
|
paramValues.forEach(paramValue => {
|
|
@@ -348,14 +1579,14 @@ const doesNotContainAnyOfOperator = {
|
|
|
348
1579
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
349
1580
|
return null;
|
|
350
1581
|
}
|
|
351
|
-
return
|
|
1582
|
+
return params => {
|
|
352
1583
|
if (filterItem.value.length === 0) {
|
|
353
1584
|
return true;
|
|
354
1585
|
}
|
|
355
|
-
if (value == null) {
|
|
1586
|
+
if (params.value == null) {
|
|
356
1587
|
return true;
|
|
357
1588
|
}
|
|
358
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1589
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
359
1590
|
for (const filteredValue of filterItem.value) {
|
|
360
1591
|
for (const paramValue of paramValues) {
|
|
361
1592
|
if (String(paramValue).indexOf(filteredValue) !== -1) {
|
|
@@ -377,14 +1608,14 @@ const doesNotEndWithAnyOfOperator = {
|
|
|
377
1608
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
378
1609
|
return null;
|
|
379
1610
|
}
|
|
380
|
-
return
|
|
1611
|
+
return params => {
|
|
381
1612
|
if (filterItem.value.length === 0) {
|
|
382
1613
|
return true;
|
|
383
1614
|
}
|
|
384
|
-
if (value == null) {
|
|
1615
|
+
if (params.value == null) {
|
|
385
1616
|
return true;
|
|
386
1617
|
}
|
|
387
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1618
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
388
1619
|
for (const filteredValue of filterItem.value) {
|
|
389
1620
|
for (const paramValue of paramValues) {
|
|
390
1621
|
if (String(paramValue).endsWith(filteredValue)) {
|
|
@@ -406,11 +1637,11 @@ const doesNotHaveAnyOf = {
|
|
|
406
1637
|
if (!filterItem.field || !filterItem.value || !Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
407
1638
|
return null;
|
|
408
1639
|
}
|
|
409
|
-
return
|
|
410
|
-
if (value == null) {
|
|
1640
|
+
return params => {
|
|
1641
|
+
if (params.value == null) {
|
|
411
1642
|
return true;
|
|
412
1643
|
}
|
|
413
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1644
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
414
1645
|
|
|
415
1646
|
// Return true only if none of the filter values are in the cell values
|
|
416
1647
|
return filterItem.value.every(filterVal => !cellValues.map(value => String(value)).includes(filterVal));
|
|
@@ -430,14 +1661,14 @@ const doesNotStartWithAnyOfOperator = {
|
|
|
430
1661
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
431
1662
|
return null;
|
|
432
1663
|
}
|
|
433
|
-
return
|
|
1664
|
+
return params => {
|
|
434
1665
|
if (filterItem.value.length === 0) {
|
|
435
1666
|
return true;
|
|
436
1667
|
}
|
|
437
|
-
if (value == null) {
|
|
1668
|
+
if (params.value == null) {
|
|
438
1669
|
return true;
|
|
439
1670
|
}
|
|
440
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1671
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
441
1672
|
for (const filteredValue of filterItem.value) {
|
|
442
1673
|
for (const paramValue of paramValues) {
|
|
443
1674
|
if (String(paramValue).startsWith(filteredValue)) {
|
|
@@ -459,14 +1690,14 @@ const endsWithAnyOfOperator = {
|
|
|
459
1690
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
460
1691
|
return null;
|
|
461
1692
|
}
|
|
462
|
-
return
|
|
1693
|
+
return params => {
|
|
463
1694
|
if (filterItem.value.length === 0) {
|
|
464
1695
|
return true;
|
|
465
1696
|
}
|
|
466
|
-
if (value == null) {
|
|
1697
|
+
if (params.value == null) {
|
|
467
1698
|
return false;
|
|
468
1699
|
}
|
|
469
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1700
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
470
1701
|
let match = false;
|
|
471
1702
|
filterItem.value.forEach(filteredValue => {
|
|
472
1703
|
paramValues.forEach(paramValue => {
|
|
@@ -489,14 +1720,14 @@ const hasAllOfOperator = {
|
|
|
489
1720
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
490
1721
|
return null;
|
|
491
1722
|
}
|
|
492
|
-
return
|
|
1723
|
+
return params => {
|
|
493
1724
|
if (filterItem.value.length === 0) {
|
|
494
1725
|
return true;
|
|
495
1726
|
}
|
|
496
|
-
if (value == null) {
|
|
1727
|
+
if (params.value == null) {
|
|
497
1728
|
return false;
|
|
498
1729
|
}
|
|
499
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1730
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
500
1731
|
const cellStrings = cellValues.map(value => String(value));
|
|
501
1732
|
const filterItemValues = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
502
1733
|
return filterItemValues.every(v => cellStrings.includes(v));
|
|
@@ -516,14 +1747,14 @@ const hasAnyOfOperator = {
|
|
|
516
1747
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
517
1748
|
return null;
|
|
518
1749
|
}
|
|
519
|
-
return
|
|
1750
|
+
return params => {
|
|
520
1751
|
if (filterItem.value.length === 0) {
|
|
521
1752
|
return true;
|
|
522
1753
|
}
|
|
523
|
-
if (value == null) {
|
|
1754
|
+
if (params.value == null) {
|
|
524
1755
|
return false;
|
|
525
1756
|
}
|
|
526
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1757
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
527
1758
|
const filterItemValues = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
528
1759
|
return filterItemValues.some(v => cellValues.map(value => String(value)).includes(v));
|
|
529
1760
|
};
|
|
@@ -542,14 +1773,14 @@ const isAnyOfOperator = {
|
|
|
542
1773
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
543
1774
|
return null;
|
|
544
1775
|
}
|
|
545
|
-
return
|
|
1776
|
+
return params => {
|
|
546
1777
|
if (filterItem.value.length === 0) {
|
|
547
1778
|
return true;
|
|
548
1779
|
}
|
|
549
|
-
if (value == null) {
|
|
1780
|
+
if (params.value == null) {
|
|
550
1781
|
return false;
|
|
551
1782
|
}
|
|
552
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1783
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
553
1784
|
for (const paramValue of paramValues) {
|
|
554
1785
|
if (filterItem.value.includes(String(paramValue))) {
|
|
555
1786
|
return true;
|
|
@@ -572,14 +1803,14 @@ const isNotAnyOfOperator = {
|
|
|
572
1803
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
573
1804
|
return null;
|
|
574
1805
|
}
|
|
575
|
-
return
|
|
1806
|
+
return params => {
|
|
576
1807
|
if (filterItem.value.length === 0) {
|
|
577
1808
|
return true;
|
|
578
1809
|
}
|
|
579
|
-
if (value == null) {
|
|
1810
|
+
if (params.value == null) {
|
|
580
1811
|
return true;
|
|
581
1812
|
}
|
|
582
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1813
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
583
1814
|
for (const paramValue of paramValues) {
|
|
584
1815
|
if (filterItem.value.includes(String(paramValue))) {
|
|
585
1816
|
return false;
|
|
@@ -602,14 +1833,14 @@ const startsWithAnyOfOperator = {
|
|
|
602
1833
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
603
1834
|
return null;
|
|
604
1835
|
}
|
|
605
|
-
return
|
|
1836
|
+
return params => {
|
|
606
1837
|
if (filterItem.value.length === 0) {
|
|
607
1838
|
return true;
|
|
608
1839
|
}
|
|
609
|
-
if (value == null) {
|
|
1840
|
+
if (params.value == null) {
|
|
610
1841
|
return false;
|
|
611
1842
|
}
|
|
612
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1843
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
613
1844
|
let match = false;
|
|
614
1845
|
filterItem.value.forEach(filteredValue => {
|
|
615
1846
|
paramValues.forEach(paramValue => {
|
|
@@ -636,15 +1867,15 @@ const isEmptyOperator = {
|
|
|
636
1867
|
value: 'isEmpty',
|
|
637
1868
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
638
1869
|
getApplyFilterFn: _filterItem => {
|
|
639
|
-
return
|
|
640
|
-
if (value == null) {
|
|
1870
|
+
return params => {
|
|
1871
|
+
if (params.value == null) {
|
|
641
1872
|
return true;
|
|
642
1873
|
}
|
|
643
|
-
if (Array.isArray(value)) {
|
|
644
|
-
return value.length === 0;
|
|
1874
|
+
if (Array.isArray(params.value)) {
|
|
1875
|
+
return params.value.length === 0;
|
|
645
1876
|
}
|
|
646
|
-
if (typeof value === 'string') {
|
|
647
|
-
return value.trim() === '';
|
|
1877
|
+
if (typeof params.value === 'string') {
|
|
1878
|
+
return params.value.trim() === '';
|
|
648
1879
|
}
|
|
649
1880
|
return false;
|
|
650
1881
|
};
|
|
@@ -656,15 +1887,15 @@ const isNotEmptyOperator = {
|
|
|
656
1887
|
value: 'isNotEmpty',
|
|
657
1888
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
658
1889
|
getApplyFilterFn: _filterItem => {
|
|
659
|
-
return
|
|
660
|
-
if (value == null) {
|
|
1890
|
+
return params => {
|
|
1891
|
+
if (params.value == null) {
|
|
661
1892
|
return false;
|
|
662
1893
|
}
|
|
663
|
-
if (Array.isArray(value)) {
|
|
664
|
-
return value.length > 0;
|
|
1894
|
+
if (Array.isArray(params.value)) {
|
|
1895
|
+
return params.value.length > 0;
|
|
665
1896
|
}
|
|
666
|
-
if (typeof value === 'string') {
|
|
667
|
-
return value.trim() !== '';
|
|
1897
|
+
if (typeof params.value === 'string') {
|
|
1898
|
+
return params.value.trim() !== '';
|
|
668
1899
|
}
|
|
669
1900
|
return true;
|
|
670
1901
|
};
|
|
@@ -703,20 +1934,14 @@ const DIMENSION_MODEL_KEY = 'dimension';
|
|
|
703
1934
|
const FILTER_SEARCH_KEY = 'searchModel';
|
|
704
1935
|
const DENSITY_MODEL_KEY = 'densityModel';
|
|
705
1936
|
const COLUMN_ORDER_MODEL_KEY = 'columnOrderModel';
|
|
706
|
-
const
|
|
707
|
-
const AGGREGATION_MODEL_KEY = 'aggregationModel';
|
|
708
|
-
/** Storage category key for the pivot column/row/value configuration. Consumer interop — use with `buildStorageKey`. */
|
|
709
|
-
const PIVOT_MODEL_KEY = 'pivotModel';
|
|
710
|
-
/** Storage category key for whether pivoting is active. Consumer interop — use with `buildStorageKey`. */
|
|
711
|
-
const PIVOT_ACTIVE_KEY = 'pivotActive';
|
|
712
|
-
const CATEGORIES = [PAGINATION_MODEL_KEY, FILTER_MODEL_KEY, SORT_MODEL_KEY, VISIBILITY_MODEL_KEY, DIMENSION_MODEL_KEY, FILTER_SEARCH_KEY, PINNED_COLUMNS, DENSITY_MODEL_KEY, COLUMN_ORDER_MODEL_KEY, ROW_GROUPING_MODEL_KEY, AGGREGATION_MODEL_KEY, PIVOT_MODEL_KEY, PIVOT_ACTIVE_KEY];
|
|
1937
|
+
const CATEGORIES = [PAGINATION_MODEL_KEY, FILTER_MODEL_KEY, SORT_MODEL_KEY, VISIBILITY_MODEL_KEY, DIMENSION_MODEL_KEY, FILTER_SEARCH_KEY, PINNED_COLUMNS, DENSITY_MODEL_KEY, COLUMN_ORDER_MODEL_KEY];
|
|
713
1938
|
/**
|
|
714
1939
|
* Build the localStorage key for a specific grid state category.
|
|
715
1940
|
* Consumers can use this to read or clear individual state entries directly.
|
|
716
1941
|
*
|
|
717
1942
|
* @example
|
|
718
1943
|
* ```ts
|
|
719
|
-
* const key = buildStorageKey({ id: pathname, version: 2, category:
|
|
1944
|
+
* const key = buildStorageKey({ id: pathname, version: 2, category: 'filterModel' });
|
|
720
1945
|
* localStorage.removeItem(key);
|
|
721
1946
|
* ```
|
|
722
1947
|
*/
|
|
@@ -766,22 +1991,6 @@ const clearPreviousVersionStorage = (id, previousLocalStorageVersions) => {
|
|
|
766
1991
|
id,
|
|
767
1992
|
version,
|
|
768
1993
|
category: COLUMN_ORDER_MODEL_KEY
|
|
769
|
-
}), buildStorageKey({
|
|
770
|
-
id,
|
|
771
|
-
version,
|
|
772
|
-
category: ROW_GROUPING_MODEL_KEY
|
|
773
|
-
}), buildStorageKey({
|
|
774
|
-
id,
|
|
775
|
-
version,
|
|
776
|
-
category: AGGREGATION_MODEL_KEY
|
|
777
|
-
}), buildStorageKey({
|
|
778
|
-
id,
|
|
779
|
-
version,
|
|
780
|
-
category: PIVOT_MODEL_KEY
|
|
781
|
-
}), buildStorageKey({
|
|
782
|
-
id,
|
|
783
|
-
version,
|
|
784
|
-
category: PIVOT_ACTIVE_KEY
|
|
785
1994
|
})];
|
|
786
1995
|
for (const keyToDelete of keysToDelete) {
|
|
787
1996
|
try {
|
|
@@ -808,6 +2017,19 @@ const clearAllVersionStorage = (id, maxVersion) => {
|
|
|
808
2017
|
* Fully reset a `StatefulDataGrid` — clear localStorage for the given versions
|
|
809
2018
|
* and strip all grid-owned URL params (`_*` and `v=`), preserving any non-grid params.
|
|
810
2019
|
*
|
|
2020
|
+
* The function reads `window.location.search` directly so the strip always
|
|
2021
|
+
* operates on the live URL. This matters because consumers typically call this
|
|
2022
|
+
* from a component whose captured `search` snapshot may be stale — for example
|
|
2023
|
+
* when the grid has just written its own keys to the URL via the router adapter
|
|
2024
|
+
* but the parent hasn't re-rendered yet. Falling back to the supplied `search`
|
|
2025
|
+
* is only used in non-browser environments (SSR, unit tests without jsdom).
|
|
2026
|
+
*
|
|
2027
|
+
* The write is performed via `historyReplace(newSearch, { authoritative: true })`.
|
|
2028
|
+
* Adapters with delta/coalescing logic (e.g. `createReactRouterV5Adapter`)
|
|
2029
|
+
* recognise the `authoritative` flag and bypass the delta computation, which
|
|
2030
|
+
* would otherwise drop keys that grew into the URL after the parent's last
|
|
2031
|
+
* captured snapshot. Adapters without delta logic simply ignore the flag.
|
|
2032
|
+
*
|
|
811
2033
|
* Call from within a component where the router values are available:
|
|
812
2034
|
* ```ts
|
|
813
2035
|
* const { search, historyReplace } = useMyRouter();
|
|
@@ -822,7 +2044,8 @@ const resetStatefulDataGridState = _ref2 => {
|
|
|
822
2044
|
historyReplace
|
|
823
2045
|
} = _ref2;
|
|
824
2046
|
clearPreviousVersionStorage(id, versions);
|
|
825
|
-
const
|
|
2047
|
+
const liveSearch = typeof window !== 'undefined' && window.location ? window.location.search : search;
|
|
2048
|
+
const params = new URLSearchParams(liveSearch);
|
|
826
2049
|
const keysToDelete = [];
|
|
827
2050
|
params.forEach((_value, key) => {
|
|
828
2051
|
if (key.startsWith('_') || key === 'v') {
|
|
@@ -832,7 +2055,59 @@ const resetStatefulDataGridState = _ref2 => {
|
|
|
832
2055
|
for (const key of keysToDelete) {
|
|
833
2056
|
params.delete(key);
|
|
834
2057
|
}
|
|
835
|
-
historyReplace(params.toString()
|
|
2058
|
+
historyReplace(params.toString(), {
|
|
2059
|
+
authoritative: true
|
|
2060
|
+
});
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Reset only the column-visibility state of a `StatefulDataGrid` back to its
|
|
2065
|
+
* default (all columns visible). Clears the persisted `visibilityModel`
|
|
2066
|
+
* localStorage entry for the given versions and strips the `_columnVisibility`
|
|
2067
|
+
* param from the live URL, leaving every other piece of grid state (filters,
|
|
2068
|
+
* sort, pagination, pinned columns, …) untouched.
|
|
2069
|
+
*
|
|
2070
|
+
* This is the visibility-scoped counterpart to `resetStatefulDataGridState`.
|
|
2071
|
+
* Reach for it at transition points where a stale visibility snapshot would
|
|
2072
|
+
* otherwise re-seed and keep base columns hidden. Because it leaves the other
|
|
2073
|
+
* params alone it will not clobber a filter the caller is writing in the same
|
|
2074
|
+
* transition.
|
|
2075
|
+
*
|
|
2076
|
+
* Like `resetStatefulDataGridState`, the URL strip reads `window.location.search`
|
|
2077
|
+
* directly so it operates on the live URL (the caller's captured snapshot may
|
|
2078
|
+
* be stale), and writes via `historyReplace(newSearch, { authoritative: true })`.
|
|
2079
|
+
*
|
|
2080
|
+
* This clears the *persisted* state only. The caller is responsible for
|
|
2081
|
+
* resetting the *live* grid in the same tick:
|
|
2082
|
+
* ```ts
|
|
2083
|
+
* resetColumnVisibility({ id: pathname, versions: [0, 1], search, historyReplace });
|
|
2084
|
+
* apiRef.current?.setColumnVisibilityModel?.({});
|
|
2085
|
+
* ```
|
|
2086
|
+
*/
|
|
2087
|
+
const resetColumnVisibility = _ref3 => {
|
|
2088
|
+
let {
|
|
2089
|
+
id,
|
|
2090
|
+
versions,
|
|
2091
|
+
search,
|
|
2092
|
+
historyReplace
|
|
2093
|
+
} = _ref3;
|
|
2094
|
+
for (const version of versions) {
|
|
2095
|
+
try {
|
|
2096
|
+
window.localStorage.removeItem(buildStorageKey({
|
|
2097
|
+
id,
|
|
2098
|
+
version,
|
|
2099
|
+
category: VISIBILITY_MODEL_KEY
|
|
2100
|
+
}));
|
|
2101
|
+
} catch (e) {
|
|
2102
|
+
// Ignore — storage may be unavailable (SSR, Safari private mode).
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
const liveSearch = typeof window !== 'undefined' && window.location ? window.location.search : search;
|
|
2106
|
+
const params = new URLSearchParams(liveSearch);
|
|
2107
|
+
params.delete('_columnVisibility');
|
|
2108
|
+
historyReplace(params.toString(), {
|
|
2109
|
+
authoritative: true
|
|
2110
|
+
});
|
|
836
2111
|
};
|
|
837
2112
|
|
|
838
2113
|
/** Maximum query string length (chars) before compression kicks in. */
|
|
@@ -846,7 +2121,7 @@ const COMPRESSED_PREFIX = '~';
|
|
|
846
2121
|
* Params listed first are compressed first (least valuable to read in the URL).
|
|
847
2122
|
* The filter aggregate step uses the special key `_filters_aggregate`.
|
|
848
2123
|
*/
|
|
849
|
-
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '
|
|
2124
|
+
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '_quickFilterValues'];
|
|
850
2125
|
|
|
851
2126
|
/** Params that are always short and should never be compressed. */
|
|
852
2127
|
const NEVER_COMPRESS = new Set(['_sortColumn', '_pagination', '_density', '_logicOperator', 'v', 'tab']);
|
|
@@ -1087,13 +2362,6 @@ const convertToDisplayFormat = search => {
|
|
|
1087
2362
|
const cleanSearch = search.startsWith('?') ? search.slice(1) : search;
|
|
1088
2363
|
const params = cleanSearch.split('&');
|
|
1089
2364
|
const converted = params.map(param => {
|
|
1090
|
-
const eqIndex = param.indexOf('=');
|
|
1091
|
-
if (eqIndex !== -1) {
|
|
1092
|
-
const value = param.slice(eqIndex + 1);
|
|
1093
|
-
// Skip conversion for compressed values — already URL-safe
|
|
1094
|
-
if (isCompressed(value)) return param;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
2365
|
// Handle _sortColumn=[field,direction]
|
|
1098
2366
|
if (param.startsWith('_sortColumn=')) {
|
|
1099
2367
|
const value = param.slice('_sortColumn='.length);
|
|
@@ -1134,7 +2402,8 @@ const convertToDisplayFormat = search => {
|
|
|
1134
2402
|
return param;
|
|
1135
2403
|
}
|
|
1136
2404
|
|
|
1137
|
-
// Handle _columnVisibility=[a,b,c
|
|
2405
|
+
// Handle _columnVisibility=[a,b,!c] → a,b,!c (single comma list; hidden fields
|
|
2406
|
+
// are `!`-prefixed. Only the brackets are structural; `!` and `,` are content.)
|
|
1138
2407
|
if (param.startsWith('_columnVisibility=')) {
|
|
1139
2408
|
const value = param.slice('_columnVisibility='.length);
|
|
1140
2409
|
if (value.startsWith('[') && value.endsWith(']')) {
|
|
@@ -1147,6 +2416,7 @@ const convertToDisplayFormat = search => {
|
|
|
1147
2416
|
// Handle _columnOrder=[a,b,c]
|
|
1148
2417
|
if (param.startsWith('_columnOrder=')) {
|
|
1149
2418
|
const value = param.slice('_columnOrder='.length);
|
|
2419
|
+
if (value.startsWith('~')) return param; // compressed — skip
|
|
1150
2420
|
if (value.startsWith('[') && value.endsWith(']')) {
|
|
1151
2421
|
const inner = value.slice(1, -1);
|
|
1152
2422
|
return `_columnOrder=${inner}`;
|
|
@@ -1154,21 +2424,6 @@ const convertToDisplayFormat = search => {
|
|
|
1154
2424
|
return param;
|
|
1155
2425
|
}
|
|
1156
2426
|
|
|
1157
|
-
// Handle _rowGrouping=[a,b,c]
|
|
1158
|
-
if (param.startsWith('_rowGrouping=')) {
|
|
1159
|
-
const value = param.slice('_rowGrouping='.length);
|
|
1160
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
1161
|
-
const inner = value.slice(1, -1);
|
|
1162
|
-
return `_rowGrouping=${inner}`;
|
|
1163
|
-
}
|
|
1164
|
-
return param;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
// _aggregation and _pivot do not use bracket notation — pass through
|
|
1168
|
-
if (param.startsWith('_aggregation=') || param.startsWith('_pivot=')) {
|
|
1169
|
-
return param;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
2427
|
// Handle _field[operator,type]=value or _field[operator,type]=list[a,b,c]
|
|
1173
2428
|
const bracketMatch = param.match(/^_([^[]+)\[([^\]]+)\]=(.*)$/);
|
|
1174
2429
|
if (bracketMatch) {
|
|
@@ -1208,13 +2463,6 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1208
2463
|
const cleanSearch = search.startsWith('?') ? search.slice(1) : search;
|
|
1209
2464
|
const params = cleanSearch.split('&');
|
|
1210
2465
|
const converted = params.map(param => {
|
|
1211
|
-
const eqIndex = param.indexOf('=');
|
|
1212
|
-
if (eqIndex !== -1) {
|
|
1213
|
-
const value = param.slice(eqIndex + 1);
|
|
1214
|
-
// Skip conversion for compressed values — already URL-safe
|
|
1215
|
-
if (isCompressed(value)) return param;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
2466
|
// Handle _sortColumn=field.direction or _sortColumn=
|
|
1219
2467
|
if (param.startsWith('_sortColumn=')) {
|
|
1220
2468
|
const value = param.slice('_sortColumn='.length);
|
|
@@ -1263,11 +2511,11 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1263
2511
|
return `${key}=[${value}]`;
|
|
1264
2512
|
}
|
|
1265
2513
|
|
|
1266
|
-
// Handle _columnVisibility
|
|
2514
|
+
// Handle _columnVisibility display `a,b,!c` → internal `[a,b,!c]`.
|
|
1267
2515
|
if (param.startsWith('_columnVisibility=')) {
|
|
1268
2516
|
const value = param.slice('_columnVisibility='.length);
|
|
1269
2517
|
// If it already has brackets, leave it alone
|
|
1270
|
-
if (value.startsWith('[')) {
|
|
2518
|
+
if (value.startsWith('[') || value.startsWith('~')) {
|
|
1271
2519
|
return param;
|
|
1272
2520
|
}
|
|
1273
2521
|
return `_columnVisibility=[${value}]`;
|
|
@@ -1276,26 +2524,13 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1276
2524
|
// Handle _columnOrder=a,b,c
|
|
1277
2525
|
if (param.startsWith('_columnOrder=')) {
|
|
1278
2526
|
const value = param.slice('_columnOrder='.length);
|
|
1279
|
-
|
|
2527
|
+
// If it already has brackets or is compressed, leave it alone
|
|
2528
|
+
if (value.startsWith('[') || value.startsWith('~')) {
|
|
1280
2529
|
return param;
|
|
1281
2530
|
}
|
|
1282
2531
|
return `_columnOrder=[${value}]`;
|
|
1283
2532
|
}
|
|
1284
2533
|
|
|
1285
|
-
// Handle _rowGrouping=a,b,c
|
|
1286
|
-
if (param.startsWith('_rowGrouping=')) {
|
|
1287
|
-
const value = param.slice('_rowGrouping='.length);
|
|
1288
|
-
if (value.startsWith('[')) {
|
|
1289
|
-
return param;
|
|
1290
|
-
}
|
|
1291
|
-
return `_rowGrouping=[${value}]`;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
// _aggregation, _pivot, _filters — pass through (no bracket conversion needed)
|
|
1295
|
-
if (param.startsWith('_aggregation=') || param.startsWith('_pivot=') || param.startsWith('_filters=')) {
|
|
1296
|
-
return param;
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
2534
|
// Handle field.operator=value (dot notation for filters)
|
|
1300
2535
|
const dotMatch = param.match(/^([^.]+)\.([a-zA-Z_]+)=(.*)$/);
|
|
1301
2536
|
if (dotMatch) {
|
|
@@ -1338,10 +2573,9 @@ const getDecodedSearchFromUrl = (search, columns) => {
|
|
|
1338
2573
|
const hasPaginationDotNotation = /_pagination=[^&[]+\.[^&]+/.test(searchWithoutLeadingQuestion);
|
|
1339
2574
|
const hasPinnedWithoutBrackets = /(_pinnedColumnsLeft|_pinnedColumnsRight)=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1340
2575
|
const hasVisibilityWithoutBrackets = /_columnVisibility=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1341
|
-
const hasColumnOrderWithoutBrackets = /_columnOrder=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1342
|
-
const hasRowGroupingWithoutBrackets = /_rowGrouping=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
2576
|
+
const hasColumnOrderWithoutBrackets = /_columnOrder=[^&[~]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1343
2577
|
const hasBracketNotation = /\[.*\]=/.test(searchWithoutLeadingQuestion);
|
|
1344
|
-
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets
|
|
2578
|
+
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets) && !hasBracketNotation;
|
|
1345
2579
|
if (isDisplayFormat) {
|
|
1346
2580
|
return '?' + convertFromDisplayFormat(searchWithoutLeadingQuestion, columns);
|
|
1347
2581
|
}
|
|
@@ -1502,7 +2736,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
1502
2736
|
let quickFilterValues = [];
|
|
1503
2737
|
const searchParams = new URLSearchParams();
|
|
1504
2738
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
1505
|
-
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '
|
|
2739
|
+
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '_density', '_filters'].includes(key)) {
|
|
1506
2740
|
searchParams.set(key, value);
|
|
1507
2741
|
}
|
|
1508
2742
|
if (key === '_logicOperator') {
|
|
@@ -1779,13 +3013,75 @@ const getColumnVisibilityFromString = (searchString, columns) => {
|
|
|
1779
3013
|
if (value === '' || value === null || value === '[]') {
|
|
1780
3014
|
return 'invalid';
|
|
1781
3015
|
}
|
|
1782
|
-
const parsedFields = value.slice(1, value.length - 1).split(',');
|
|
1783
3016
|
const fields = columns.map(column => column.field);
|
|
3017
|
+
|
|
3018
|
+
// Back-compat READ-ONLY: the short-lived `v:[<visible>];h:[<hidden>]` form written
|
|
3019
|
+
// by 12.5.5-muiv8-alpha.5/alpha.6 (replaced by the URL-safe `!` form below — see
|
|
3020
|
+
// getSearchParamsFromColumnVisibility). Still parsed so any localStorage entry
|
|
3021
|
+
// persisted by those alphas keeps working; never written anymore. The two sets are
|
|
3022
|
+
// split on the fixed `];h:[` separator, so a `[` or `]` inside a field name does
|
|
3023
|
+
// not break parsing.
|
|
3024
|
+
if (value.startsWith('v:[') && value.endsWith(']') && value.includes('];h:[')) {
|
|
3025
|
+
const inner = value.slice('v:['.length, -1);
|
|
3026
|
+
const separatorIndex = inner.indexOf('];h:[');
|
|
3027
|
+
const visibleRaw = inner.slice(0, separatorIndex);
|
|
3028
|
+
const hiddenRaw = inner.slice(separatorIndex + '];h:['.length);
|
|
3029
|
+
const visibleFields = visibleRaw ? visibleRaw.split(',') : [];
|
|
3030
|
+
const hiddenFields = hiddenRaw ? hiddenRaw.split(',') : [];
|
|
3031
|
+
const visibility = {};
|
|
3032
|
+
// Static columns default to visible; only those explicitly hidden are false.
|
|
3033
|
+
// (A column added after the URL was written is absent from both lists and
|
|
3034
|
+
// correctly defaults to visible, matching MUI's behaviour.)
|
|
3035
|
+
for (const field of fields) {
|
|
3036
|
+
visibility[field] = !hiddenFields.includes(field);
|
|
3037
|
+
}
|
|
3038
|
+
// Dynamic keys that are not part of the static `columns` prop — preserve verbatim.
|
|
3039
|
+
for (const field of visibleFields) {
|
|
3040
|
+
if (!fields.includes(field)) {
|
|
3041
|
+
visibility[field] = true;
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
for (const field of hiddenFields) {
|
|
3045
|
+
if (!fields.includes(field)) {
|
|
3046
|
+
visibility[field] = false;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
return visibility;
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// Bracketed token list: new `[a,b,!c]` (hidden fields `!`-prefixed) or legacy
|
|
3053
|
+
// `[a,b,c]` (visible-only). Split on the comma delimiter only, so `[`/`]` inside a
|
|
3054
|
+
// dynamic field name survive.
|
|
3055
|
+
const inner = value.slice(1, value.length - 1);
|
|
3056
|
+
const tokens = inner ? inner.split(',') : [];
|
|
3057
|
+
|
|
3058
|
+
// New form iff at least one `!`-prefixed (explicitly hidden) token is present.
|
|
3059
|
+
if (tokens.some(token => token.startsWith('!'))) {
|
|
3060
|
+
const hiddenFields = tokens.filter(token => token.startsWith('!')).map(token => token.slice(1));
|
|
3061
|
+
const visibility = {};
|
|
3062
|
+
// Static columns default to visible; only those explicitly hidden are false.
|
|
3063
|
+
for (const field of fields) {
|
|
3064
|
+
visibility[field] = !hiddenFields.includes(field);
|
|
3065
|
+
}
|
|
3066
|
+
// Dynamic keys not in the static `columns` prop — insert in TOKEN ORDER (do not
|
|
3067
|
+
// regroup visible/hidden) so the writer re-emits a byte-identical URL and the RR
|
|
3068
|
+
// v5 adapter's idempotency guard stops the URL-sync loop (ODM-3033).
|
|
3069
|
+
for (const token of tokens) {
|
|
3070
|
+
const hidden = token.startsWith('!');
|
|
3071
|
+
const field = hidden ? token.slice(1) : token;
|
|
3072
|
+
if (!fields.includes(field)) {
|
|
3073
|
+
visibility[field] = !hidden;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
return visibility;
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
// Legacy visible-only form: `[<visible>]` (hidden encoded implicitly by absence).
|
|
1784
3080
|
const visibility = {};
|
|
1785
3081
|
for (const field of fields) {
|
|
1786
3082
|
visibility[field] = false;
|
|
1787
3083
|
}
|
|
1788
|
-
for (const parsedField of
|
|
3084
|
+
for (const parsedField of tokens) {
|
|
1789
3085
|
if (fields.includes(parsedField)) {
|
|
1790
3086
|
visibility[parsedField] = true;
|
|
1791
3087
|
}
|
|
@@ -1812,8 +3108,24 @@ const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
|
1812
3108
|
[colName]: true
|
|
1813
3109
|
});
|
|
1814
3110
|
}, columnVisibility);
|
|
1815
|
-
|
|
1816
|
-
|
|
3111
|
+
|
|
3112
|
+
// Serialise a single comma list over the static columns plus any extra keys present
|
|
3113
|
+
// in the model (dynamically-generated fields, preserved in model order). Hidden
|
|
3114
|
+
// fields are prefixed `!`; visible fields are bare. This URL-safe form round-trips
|
|
3115
|
+
// idempotently through `URLSearchParams.toString()` percent-encoding — the earlier
|
|
3116
|
+
// `v:[..];h:[..]` form did NOT (its `:`/`;` were percent-encoded and mis-parsed on
|
|
3117
|
+
// read-back, driving an unbounded `history.replace` loop, ODM-3033). `!` (not `~`,
|
|
3118
|
+
// the compression sentinel — compression.ts COMPRESSED_PREFIX) is used so a leading
|
|
3119
|
+
// hidden field can't be mistaken for a compressed value. The hidden set is still
|
|
3120
|
+
// explicit, so deselected dynamic columns survive reloads.
|
|
3121
|
+
const allFields = [...fields];
|
|
3122
|
+
for (const field of Object.keys(finalColumnVisibility)) {
|
|
3123
|
+
if (!allFields.includes(field)) {
|
|
3124
|
+
allFields.push(field);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
const tokens = allFields.map(column => finalColumnVisibility[column] === false ? `!${column}` : column);
|
|
3128
|
+
searchParams.set('_columnVisibility', `[${tokens.join(',')}]`);
|
|
1817
3129
|
return searchParams;
|
|
1818
3130
|
};
|
|
1819
3131
|
|
|
@@ -1968,7 +3280,8 @@ const getSearchParamsFromDensity = density => {
|
|
|
1968
3280
|
return searchParams;
|
|
1969
3281
|
};
|
|
1970
3282
|
const getDensityModel = (search, localStorageDensity, setLocalStorageDensity, initialState, isNewVersion) => {
|
|
1971
|
-
//
|
|
3283
|
+
// MUI v6 GridInitialStatePro does not expose density on its type, but consumers
|
|
3284
|
+
// can still pass it through. Honour it when provided, otherwise fall back to 'compact'.
|
|
1972
3285
|
const initialDensity = initialState === null || initialState === void 0 ? void 0 : initialState.density;
|
|
1973
3286
|
const defaultValue = initialDensity && VALID_DENSITIES.includes(initialDensity) ? initialDensity : 'compact';
|
|
1974
3287
|
|
|
@@ -2021,6 +3334,29 @@ const getSearchParamsFromColumnOrder = columnOrder => {
|
|
|
2021
3334
|
}
|
|
2022
3335
|
return searchParams;
|
|
2023
3336
|
};
|
|
3337
|
+
|
|
3338
|
+
/**
|
|
3339
|
+
* Builds the `v=<version>` search param the grid uses to detect stale URLs.
|
|
3340
|
+
*
|
|
3341
|
+
* Use this when constructing a deep link or share URL outside the grid (e.g. via
|
|
3342
|
+
* `getSearchParamsFromFilterModel` + `buildQueryParamsString`). The grid itself
|
|
3343
|
+
* always includes `v` in URLs it writes via `getFinalSearch`, but external helpers
|
|
3344
|
+
* do not — include this when you want a stale `localStorageVersion` bump to invalidate
|
|
3345
|
+
* the link. Omitting `v` is also safe: a missing `v` is treated as "current version"
|
|
3346
|
+
* and the URL state is applied as-is.
|
|
3347
|
+
*
|
|
3348
|
+
* @example
|
|
3349
|
+
* const params = new URLSearchParams([
|
|
3350
|
+
* ...getSearchParamsFromFilterModel(filterModel),
|
|
3351
|
+
* ...getSearchParamsFromVersion(1),
|
|
3352
|
+
* ]);
|
|
3353
|
+
* const url = `/my-grid${buildQueryParamsString(urlSearchParamsToString(params))}`;
|
|
3354
|
+
*/
|
|
3355
|
+
const getSearchParamsFromVersion = version => {
|
|
3356
|
+
const searchParams = new URLSearchParams();
|
|
3357
|
+
searchParams.set('v', String(version));
|
|
3358
|
+
return searchParams;
|
|
3359
|
+
};
|
|
2024
3360
|
const getColumnOrder = (search, columns, localStorageColumnOrder, setLocalStorageColumnOrder, initialState, isNewVersion) => {
|
|
2025
3361
|
var _initialState$columns4, _initialState$columns5;
|
|
2026
3362
|
const defaultValue = (_initialState$columns4 = initialState === null || initialState === void 0 ? void 0 : (_initialState$columns5 = initialState.columns) === null || _initialState$columns5 === void 0 ? void 0 : _initialState$columns5.orderedFields) !== null && _initialState$columns4 !== void 0 ? _initialState$columns4 : columns.map(c => c.field);
|
|
@@ -2051,298 +3387,7 @@ const getColumnOrder = (search, columns, localStorageColumnOrder, setLocalStorag
|
|
|
2051
3387
|
persistDefault();
|
|
2052
3388
|
return defaultValue;
|
|
2053
3389
|
};
|
|
2054
|
-
|
|
2055
|
-
/** ROW GROUPING */
|
|
2056
|
-
|
|
2057
|
-
const getRowGroupingFromString = searchString => {
|
|
2058
|
-
if (!searchString) return 'invalid';
|
|
2059
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2060
|
-
const value = searchParams.get('_rowGrouping');
|
|
2061
|
-
if (value === '' || value === null || value === '[]') return 'invalid';
|
|
2062
|
-
const inner = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value;
|
|
2063
|
-
if (!inner) return 'invalid';
|
|
2064
|
-
return inner.split(',').filter(Boolean);
|
|
2065
|
-
};
|
|
2066
|
-
const getSearchParamsFromRowGrouping = rowGrouping => {
|
|
2067
|
-
const searchParams = new URLSearchParams();
|
|
2068
|
-
if (rowGrouping.length > 0) {
|
|
2069
|
-
searchParams.set('_rowGrouping', `[${rowGrouping.join(',')}]`);
|
|
2070
|
-
}
|
|
2071
|
-
return searchParams;
|
|
2072
|
-
};
|
|
2073
|
-
const getRowGroupingModel = (search, localStorageRowGrouping, setLocalStorageRowGrouping, initialState, isNewVersion) => {
|
|
2074
|
-
var _initialState$rowGrou, _initialState$rowGrou2;
|
|
2075
|
-
const defaultValue = (_initialState$rowGrou = initialState === null || initialState === void 0 ? void 0 : (_initialState$rowGrou2 = initialState.rowGrouping) === null || _initialState$rowGrou2 === void 0 ? void 0 : _initialState$rowGrou2.model) !== null && _initialState$rowGrou !== void 0 ? _initialState$rowGrou : [];
|
|
2076
|
-
const persistDefault = () => {
|
|
2077
|
-
const searchFromDefault = getSearchParamsFromRowGrouping(defaultValue);
|
|
2078
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2079
|
-
if (searchString !== localStorageRowGrouping) {
|
|
2080
|
-
setLocalStorageRowGrouping(searchString);
|
|
2081
|
-
}
|
|
2082
|
-
};
|
|
2083
|
-
if (isNewVersion) {
|
|
2084
|
-
persistDefault();
|
|
2085
|
-
return defaultValue;
|
|
2086
|
-
}
|
|
2087
|
-
const fromUrl = getRowGroupingFromString(search);
|
|
2088
|
-
if (fromUrl !== 'invalid') {
|
|
2089
|
-
const searchFromModel = getSearchParamsFromRowGrouping(fromUrl);
|
|
2090
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2091
|
-
if (searchString !== localStorageRowGrouping) {
|
|
2092
|
-
setLocalStorageRowGrouping(searchString);
|
|
2093
|
-
}
|
|
2094
|
-
return fromUrl;
|
|
2095
|
-
}
|
|
2096
|
-
const fromLocalStorage = getRowGroupingFromString(localStorageRowGrouping);
|
|
2097
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2098
|
-
return fromLocalStorage;
|
|
2099
|
-
}
|
|
2100
|
-
persistDefault();
|
|
2101
|
-
return defaultValue;
|
|
2102
|
-
};
|
|
2103
|
-
|
|
2104
|
-
/** AGGREGATION */
|
|
2105
|
-
|
|
2106
|
-
const getAggregationFromString = searchString => {
|
|
2107
|
-
if (!searchString) return 'invalid';
|
|
2108
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2109
|
-
const value = searchParams.get('_aggregation');
|
|
2110
|
-
if (value === '' || value === null) return 'invalid';
|
|
2111
|
-
|
|
2112
|
-
// Format: field1.sum,field2.avg or [field1.sum,field2.avg]
|
|
2113
|
-
const inner = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value;
|
|
2114
|
-
if (!inner) return 'invalid';
|
|
2115
|
-
const model = {};
|
|
2116
|
-
for (const entry of inner.split(',')) {
|
|
2117
|
-
const dotIndex = entry.lastIndexOf('.');
|
|
2118
|
-
if (dotIndex <= 0) return 'invalid';
|
|
2119
|
-
const field = entry.slice(0, dotIndex);
|
|
2120
|
-
const aggFunc = entry.slice(dotIndex + 1);
|
|
2121
|
-
if (!field || !aggFunc) return 'invalid';
|
|
2122
|
-
model[field] = aggFunc;
|
|
2123
|
-
}
|
|
2124
|
-
return Object.keys(model).length > 0 ? model : 'invalid';
|
|
2125
|
-
};
|
|
2126
|
-
const getSearchParamsFromAggregation = aggregation => {
|
|
2127
|
-
const searchParams = new URLSearchParams();
|
|
2128
|
-
const entries = Object.entries(aggregation);
|
|
2129
|
-
if (entries.length > 0) {
|
|
2130
|
-
const value = entries.map(_ref => {
|
|
2131
|
-
let [field, aggFunc] = _ref;
|
|
2132
|
-
return `${field}.${aggFunc}`;
|
|
2133
|
-
}).join(',');
|
|
2134
|
-
searchParams.set('_aggregation', value);
|
|
2135
|
-
}
|
|
2136
|
-
return searchParams;
|
|
2137
|
-
};
|
|
2138
|
-
const getAggregationModel = (search, localStorageAggregation, setLocalStorageAggregation, initialState, isNewVersion) => {
|
|
2139
|
-
var _initialState$aggrega, _initialState$aggrega2;
|
|
2140
|
-
const defaultValue = (_initialState$aggrega = initialState === null || initialState === void 0 ? void 0 : (_initialState$aggrega2 = initialState.aggregation) === null || _initialState$aggrega2 === void 0 ? void 0 : _initialState$aggrega2.model) !== null && _initialState$aggrega !== void 0 ? _initialState$aggrega : {};
|
|
2141
|
-
const persistDefault = () => {
|
|
2142
|
-
const searchFromDefault = getSearchParamsFromAggregation(defaultValue);
|
|
2143
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2144
|
-
if (searchString !== localStorageAggregation) {
|
|
2145
|
-
setLocalStorageAggregation(searchString);
|
|
2146
|
-
}
|
|
2147
|
-
};
|
|
2148
|
-
if (isNewVersion) {
|
|
2149
|
-
persistDefault();
|
|
2150
|
-
return defaultValue;
|
|
2151
|
-
}
|
|
2152
|
-
const fromUrl = getAggregationFromString(search);
|
|
2153
|
-
if (fromUrl !== 'invalid') {
|
|
2154
|
-
const searchFromModel = getSearchParamsFromAggregation(fromUrl);
|
|
2155
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2156
|
-
if (searchString !== localStorageAggregation) {
|
|
2157
|
-
setLocalStorageAggregation(searchString);
|
|
2158
|
-
}
|
|
2159
|
-
return fromUrl;
|
|
2160
|
-
}
|
|
2161
|
-
const fromLocalStorage = getAggregationFromString(localStorageAggregation);
|
|
2162
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2163
|
-
return fromLocalStorage;
|
|
2164
|
-
}
|
|
2165
|
-
persistDefault();
|
|
2166
|
-
return defaultValue;
|
|
2167
|
-
};
|
|
2168
|
-
|
|
2169
|
-
/** PIVOT */
|
|
2170
|
-
|
|
2171
|
-
/** Convert MUI's GridPivotModel → our simplified PivotModel */
|
|
2172
|
-
const fromGridPivotModel = model => ({
|
|
2173
|
-
columns: model.columns.map(c => c.field),
|
|
2174
|
-
rows: model.rows.map(r => r.field),
|
|
2175
|
-
values: model.values.map(_ref2 => {
|
|
2176
|
-
let {
|
|
2177
|
-
field,
|
|
2178
|
-
aggFunc
|
|
2179
|
-
} = _ref2;
|
|
2180
|
-
return {
|
|
2181
|
-
field,
|
|
2182
|
-
aggFunc
|
|
2183
|
-
};
|
|
2184
|
-
})
|
|
2185
|
-
});
|
|
2186
|
-
|
|
2187
|
-
/**
|
|
2188
|
-
* Pivot format: `cols:f1,f2;rows:f3;vals:f4.sum,f5.avg`
|
|
2189
|
-
*/
|
|
2190
|
-
const getPivotFromString = searchString => {
|
|
2191
|
-
if (!searchString) return 'invalid';
|
|
2192
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2193
|
-
const value = searchParams.get('_pivot');
|
|
2194
|
-
if (value === '' || value === null) return 'invalid';
|
|
2195
|
-
const model = {
|
|
2196
|
-
columns: [],
|
|
2197
|
-
rows: [],
|
|
2198
|
-
values: []
|
|
2199
|
-
};
|
|
2200
|
-
for (const segment of value.split(';')) {
|
|
2201
|
-
const colonIndex = segment.indexOf(':');
|
|
2202
|
-
if (colonIndex <= 0) return 'invalid';
|
|
2203
|
-
const key = segment.slice(0, colonIndex);
|
|
2204
|
-
const content = segment.slice(colonIndex + 1);
|
|
2205
|
-
if (key === 'cols') {
|
|
2206
|
-
model.columns = content ? content.split(',').filter(Boolean) : [];
|
|
2207
|
-
} else if (key === 'rows') {
|
|
2208
|
-
model.rows = content ? content.split(',').filter(Boolean) : [];
|
|
2209
|
-
} else if (key === 'vals') {
|
|
2210
|
-
if (!content) continue;
|
|
2211
|
-
for (const entry of content.split(',')) {
|
|
2212
|
-
const dotIndex = entry.lastIndexOf('.');
|
|
2213
|
-
if (dotIndex <= 0) return 'invalid';
|
|
2214
|
-
model.values.push({
|
|
2215
|
-
field: entry.slice(0, dotIndex),
|
|
2216
|
-
aggFunc: entry.slice(dotIndex + 1)
|
|
2217
|
-
});
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
// At least one section must have content
|
|
2223
|
-
if (model.columns.length === 0 && model.rows.length === 0 && model.values.length === 0) {
|
|
2224
|
-
return 'invalid';
|
|
2225
|
-
}
|
|
2226
|
-
return model;
|
|
2227
|
-
};
|
|
2228
|
-
const getSearchParamsFromPivot = pivot => {
|
|
2229
|
-
const searchParams = new URLSearchParams();
|
|
2230
|
-
const hasContent = pivot.columns.length > 0 || pivot.rows.length > 0 || pivot.values.length > 0;
|
|
2231
|
-
if (hasContent) {
|
|
2232
|
-
const parts = [];
|
|
2233
|
-
parts.push(`cols:${pivot.columns.join(',')}`);
|
|
2234
|
-
parts.push(`rows:${pivot.rows.join(',')}`);
|
|
2235
|
-
if (pivot.values.length > 0) {
|
|
2236
|
-
parts.push(`vals:${pivot.values.map(v => `${v.field}.${v.aggFunc}`).join(',')}`);
|
|
2237
|
-
}
|
|
2238
|
-
searchParams.set('_pivot', parts.join(';'));
|
|
2239
|
-
}
|
|
2240
|
-
return searchParams;
|
|
2241
|
-
};
|
|
2242
|
-
const getPivotModel = (search, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion) => {
|
|
2243
|
-
var _initialState$pivotin;
|
|
2244
|
-
const defaultValue = initialState !== null && initialState !== void 0 && (_initialState$pivotin = initialState.pivoting) !== null && _initialState$pivotin !== void 0 && _initialState$pivotin.model ? fromGridPivotModel(initialState.pivoting.model) : {
|
|
2245
|
-
columns: [],
|
|
2246
|
-
rows: [],
|
|
2247
|
-
values: []
|
|
2248
|
-
};
|
|
2249
|
-
const persistDefault = () => {
|
|
2250
|
-
const searchFromDefault = getSearchParamsFromPivot(defaultValue);
|
|
2251
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2252
|
-
if (searchString !== localStoragePivot) {
|
|
2253
|
-
setLocalStoragePivot(searchString);
|
|
2254
|
-
}
|
|
2255
|
-
};
|
|
2256
|
-
if (isNewVersion) {
|
|
2257
|
-
persistDefault();
|
|
2258
|
-
return defaultValue;
|
|
2259
|
-
}
|
|
2260
|
-
const fromUrl = getPivotFromString(search);
|
|
2261
|
-
if (fromUrl !== 'invalid') {
|
|
2262
|
-
const searchFromModel = getSearchParamsFromPivot(fromUrl);
|
|
2263
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2264
|
-
if (searchString !== localStoragePivot) {
|
|
2265
|
-
setLocalStoragePivot(searchString);
|
|
2266
|
-
}
|
|
2267
|
-
return fromUrl;
|
|
2268
|
-
}
|
|
2269
|
-
const fromLocalStorage = getPivotFromString(localStoragePivot);
|
|
2270
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2271
|
-
return fromLocalStorage;
|
|
2272
|
-
}
|
|
2273
|
-
persistDefault();
|
|
2274
|
-
return defaultValue;
|
|
2275
|
-
};
|
|
2276
|
-
|
|
2277
|
-
/** PIVOT ACTIVE */
|
|
2278
|
-
|
|
2279
|
-
const getPivotActiveFromString = searchString => {
|
|
2280
|
-
if (!searchString) return 'invalid';
|
|
2281
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2282
|
-
const value = searchParams.get('_pivotActive');
|
|
2283
|
-
if (value === 'true') return true;
|
|
2284
|
-
if (value === 'false') return false;
|
|
2285
|
-
return 'invalid';
|
|
2286
|
-
};
|
|
2287
|
-
const getSearchParamsFromPivotActive = active => {
|
|
2288
|
-
const searchParams = new URLSearchParams();
|
|
2289
|
-
searchParams.set('_pivotActive', String(active));
|
|
2290
|
-
return searchParams;
|
|
2291
|
-
};
|
|
2292
|
-
|
|
2293
|
-
/**
|
|
2294
|
-
* Builds the `v=<version>` search param the grid uses to detect stale URLs.
|
|
2295
|
-
*
|
|
2296
|
-
* Use this when constructing a deep link or share URL outside the grid (e.g. via
|
|
2297
|
-
* `getSearchParamsFromFilterModel` + `buildQueryParamsString`). The grid itself
|
|
2298
|
-
* always includes `v` in URLs it writes via `getFinalSearch`, but external helpers
|
|
2299
|
-
* do not — include this when you want a stale `localStorageVersion` bump to invalidate
|
|
2300
|
-
* the link. Omitting `v` is also safe: a missing `v` is treated as "current version"
|
|
2301
|
-
* and the URL state is applied as-is.
|
|
2302
|
-
*
|
|
2303
|
-
* @example
|
|
2304
|
-
* const params = new URLSearchParams([
|
|
2305
|
-
* ...getSearchParamsFromFilterModel(filterModel),
|
|
2306
|
-
* ...getSearchParamsFromVersion(1),
|
|
2307
|
-
* ]);
|
|
2308
|
-
* const url = `/my-grid${buildQueryParamsString(urlSearchParamsToString(params))}`;
|
|
2309
|
-
*/
|
|
2310
|
-
const getSearchParamsFromVersion = version => {
|
|
2311
|
-
const searchParams = new URLSearchParams();
|
|
2312
|
-
searchParams.set('v', String(version));
|
|
2313
|
-
return searchParams;
|
|
2314
|
-
};
|
|
2315
|
-
const getPivotActive = (search, localStoragePivotActive, setLocalStoragePivotActive, initialState, isNewVersion) => {
|
|
2316
|
-
var _initialState$pivotin2, _initialState$pivotin3;
|
|
2317
|
-
const defaultValue = (_initialState$pivotin2 = initialState === null || initialState === void 0 ? void 0 : (_initialState$pivotin3 = initialState.pivoting) === null || _initialState$pivotin3 === void 0 ? void 0 : _initialState$pivotin3.enabled) !== null && _initialState$pivotin2 !== void 0 ? _initialState$pivotin2 : false;
|
|
2318
|
-
const persistDefault = () => {
|
|
2319
|
-
const searchFromDefault = getSearchParamsFromPivotActive(defaultValue);
|
|
2320
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2321
|
-
if (searchString !== localStoragePivotActive) {
|
|
2322
|
-
setLocalStoragePivotActive(searchString);
|
|
2323
|
-
}
|
|
2324
|
-
};
|
|
2325
|
-
if (isNewVersion) {
|
|
2326
|
-
persistDefault();
|
|
2327
|
-
return defaultValue;
|
|
2328
|
-
}
|
|
2329
|
-
const fromUrl = getPivotActiveFromString(search);
|
|
2330
|
-
if (fromUrl !== 'invalid') {
|
|
2331
|
-
const searchFromModel = getSearchParamsFromPivotActive(fromUrl);
|
|
2332
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2333
|
-
if (searchString !== localStoragePivotActive) {
|
|
2334
|
-
setLocalStoragePivotActive(searchString);
|
|
2335
|
-
}
|
|
2336
|
-
return fromUrl;
|
|
2337
|
-
}
|
|
2338
|
-
const fromLocalStorage = getPivotActiveFromString(localStoragePivotActive);
|
|
2339
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2340
|
-
return fromLocalStorage;
|
|
2341
|
-
}
|
|
2342
|
-
persistDefault();
|
|
2343
|
-
return defaultValue;
|
|
2344
|
-
};
|
|
2345
|
-
const getFinalSearch = _ref3 => {
|
|
3390
|
+
const getFinalSearch = _ref => {
|
|
2346
3391
|
let {
|
|
2347
3392
|
search,
|
|
2348
3393
|
localStorageVersion,
|
|
@@ -2354,12 +3399,8 @@ const getFinalSearch = _ref3 => {
|
|
|
2354
3399
|
density,
|
|
2355
3400
|
columnOrderModel,
|
|
2356
3401
|
defaultColumnOrder,
|
|
2357
|
-
rowGroupingModel,
|
|
2358
|
-
aggregationModel,
|
|
2359
|
-
pivotModel,
|
|
2360
|
-
pivotActive,
|
|
2361
3402
|
columns
|
|
2362
|
-
} =
|
|
3403
|
+
} = _ref;
|
|
2363
3404
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
2364
3405
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
2365
3406
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -2368,10 +3409,6 @@ const getFinalSearch = _ref3 => {
|
|
|
2368
3409
|
const densitySearch = getSearchParamsFromDensity(density);
|
|
2369
3410
|
// Only include _columnOrder in URL when it differs from the default
|
|
2370
3411
|
const columnOrderSearch = columnOrderModel.length !== defaultColumnOrder.length || columnOrderModel.some((field, i) => field !== defaultColumnOrder[i]) ? getSearchParamsFromColumnOrder(columnOrderModel) : new URLSearchParams();
|
|
2371
|
-
const rowGroupingSearch = getSearchParamsFromRowGrouping(rowGroupingModel);
|
|
2372
|
-
const aggregationSearch = getSearchParamsFromAggregation(aggregationModel);
|
|
2373
|
-
const pivotSearch = getSearchParamsFromPivot(pivotModel);
|
|
2374
|
-
const pivotActiveSearch = getSearchParamsFromPivotActive(pivotActive);
|
|
2375
3412
|
const tabSearch = getSearchParamsFromTab(search);
|
|
2376
3413
|
const searchParams = new URLSearchParams();
|
|
2377
3414
|
for (const [key, value] of new URLSearchParams(search)) {
|
|
@@ -2386,7 +3423,7 @@ const getFinalSearch = _ref3 => {
|
|
|
2386
3423
|
// Encode array as JSON string to preserve all values in one param
|
|
2387
3424
|
searchParams.set('_quickFilterValues', encodeURIComponent(JSON.stringify(filterModel.quickFilterValues)));
|
|
2388
3425
|
}
|
|
2389
|
-
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch
|
|
3426
|
+
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch]);
|
|
2390
3427
|
};
|
|
2391
3428
|
/** Return the state of the table given the URL and the local storage state */
|
|
2392
3429
|
const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, columns, initialState, localStorage) => {
|
|
@@ -2426,15 +3463,7 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2426
3463
|
localStorageDensity,
|
|
2427
3464
|
setLocalStorageDensity,
|
|
2428
3465
|
localStorageColumnOrder,
|
|
2429
|
-
setLocalStorageColumnOrder
|
|
2430
|
-
localStorageRowGrouping,
|
|
2431
|
-
setLocalStorageRowGrouping,
|
|
2432
|
-
localStorageAggregation,
|
|
2433
|
-
setLocalStorageAggregation,
|
|
2434
|
-
localStoragePivot,
|
|
2435
|
-
setLocalStoragePivot,
|
|
2436
|
-
localStoragePivotActive,
|
|
2437
|
-
setLocalStoragePivotActive
|
|
3466
|
+
setLocalStorageColumnOrder
|
|
2438
3467
|
} = localStorage;
|
|
2439
3468
|
const filterModel = getFilterModel(decodedSearch, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion);
|
|
2440
3469
|
const sortModel = getSortModel(decodedSearch, columns, localStorageSorting, setLocalStorageSorting, initialState, isNewVersion);
|
|
@@ -2443,10 +3472,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2443
3472
|
const pinnedColumnsModel = getPinnedColumns(decodedSearch, columns, localStoragePinnedColumns, setLocalStoragePinnedColumns, initialState, isNewVersion);
|
|
2444
3473
|
const density = getDensityModel(decodedSearch, localStorageDensity, setLocalStorageDensity, initialState, isNewVersion);
|
|
2445
3474
|
const columnOrderModel = getColumnOrder(decodedSearch, columns, localStorageColumnOrder, setLocalStorageColumnOrder, initialState, isNewVersion);
|
|
2446
|
-
const rowGroupingModel = getRowGroupingModel(decodedSearch, localStorageRowGrouping, setLocalStorageRowGrouping, initialState, isNewVersion);
|
|
2447
|
-
const aggregationModel = getAggregationModel(decodedSearch, localStorageAggregation, setLocalStorageAggregation, initialState, isNewVersion);
|
|
2448
|
-
const pivotModel = getPivotModel(decodedSearch, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion);
|
|
2449
|
-
const pivotActive = getPivotActive(decodedSearch, localStoragePivotActive, setLocalStoragePivotActive, initialState, isNewVersion);
|
|
2450
3475
|
const defaultColumnOrder = (_initialState$columns6 = initialState === null || initialState === void 0 ? void 0 : (_initialState$columns7 = initialState.columns) === null || _initialState$columns7 === void 0 ? void 0 : _initialState$columns7.orderedFields) !== null && _initialState$columns6 !== void 0 ? _initialState$columns6 : columns.map(c => c.field);
|
|
2451
3476
|
const finalSearch = getFinalSearch({
|
|
2452
3477
|
localStorageVersion,
|
|
@@ -2459,10 +3484,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2459
3484
|
density,
|
|
2460
3485
|
columnOrderModel,
|
|
2461
3486
|
defaultColumnOrder,
|
|
2462
|
-
rowGroupingModel,
|
|
2463
|
-
aggregationModel,
|
|
2464
|
-
pivotModel,
|
|
2465
|
-
pivotActive,
|
|
2466
3487
|
columns
|
|
2467
3488
|
});
|
|
2468
3489
|
const internalSearchString = urlSearchParamsToString(finalSearch);
|
|
@@ -2483,14 +3504,10 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2483
3504
|
pinnedColumnsModel,
|
|
2484
3505
|
density,
|
|
2485
3506
|
columnOrderModel,
|
|
2486
|
-
rowGroupingModel,
|
|
2487
|
-
aggregationModel,
|
|
2488
|
-
pivotModel,
|
|
2489
|
-
pivotActive,
|
|
2490
3507
|
pendingSearch
|
|
2491
3508
|
};
|
|
2492
3509
|
};
|
|
2493
|
-
const updateUrl = (
|
|
3510
|
+
const updateUrl = (_ref2, search, localStorageVersion, historyReplace, columns) => {
|
|
2494
3511
|
let {
|
|
2495
3512
|
filterModel,
|
|
2496
3513
|
sortModel,
|
|
@@ -2499,12 +3516,8 @@ const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns)
|
|
|
2499
3516
|
pinnedColumnsModel,
|
|
2500
3517
|
density,
|
|
2501
3518
|
columnOrderModel,
|
|
2502
|
-
defaultColumnOrder
|
|
2503
|
-
|
|
2504
|
-
aggregationModel,
|
|
2505
|
-
pivotModel,
|
|
2506
|
-
pivotActive
|
|
2507
|
-
} = _ref4;
|
|
3519
|
+
defaultColumnOrder
|
|
3520
|
+
} = _ref2;
|
|
2508
3521
|
// Convert from display format to internal format if needed
|
|
2509
3522
|
const decodedSearch = getDecodedSearchFromUrl(search, columns);
|
|
2510
3523
|
const newSearch = getFinalSearch({
|
|
@@ -2518,10 +3531,6 @@ const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns)
|
|
|
2518
3531
|
density,
|
|
2519
3532
|
columnOrderModel,
|
|
2520
3533
|
defaultColumnOrder,
|
|
2521
|
-
rowGroupingModel,
|
|
2522
|
-
aggregationModel,
|
|
2523
|
-
pivotModel,
|
|
2524
|
-
pivotActive,
|
|
2525
3534
|
columns
|
|
2526
3535
|
});
|
|
2527
3536
|
const internalSearchString = urlSearchParamsToString(newSearch);
|
|
@@ -2709,26 +3718,6 @@ const useTableStates = (id, version) => {
|
|
|
2709
3718
|
version,
|
|
2710
3719
|
category: COLUMN_ORDER_MODEL_KEY
|
|
2711
3720
|
}));
|
|
2712
|
-
const [rowGroupingModel, setRowGroupingModel] = useFetchState('', buildStorageKey({
|
|
2713
|
-
id,
|
|
2714
|
-
version,
|
|
2715
|
-
category: ROW_GROUPING_MODEL_KEY
|
|
2716
|
-
}));
|
|
2717
|
-
const [aggregationModel, setAggregationModel] = useFetchState('', buildStorageKey({
|
|
2718
|
-
id,
|
|
2719
|
-
version,
|
|
2720
|
-
category: AGGREGATION_MODEL_KEY
|
|
2721
|
-
}));
|
|
2722
|
-
const [pivotModel, setPivotModel] = useFetchState('', buildStorageKey({
|
|
2723
|
-
id,
|
|
2724
|
-
version,
|
|
2725
|
-
category: PIVOT_MODEL_KEY
|
|
2726
|
-
}));
|
|
2727
|
-
const [pivotActive, setPivotActive] = useFetchState('', buildStorageKey({
|
|
2728
|
-
id,
|
|
2729
|
-
version,
|
|
2730
|
-
category: PIVOT_ACTIVE_KEY
|
|
2731
|
-
}));
|
|
2732
3721
|
return {
|
|
2733
3722
|
paginationModel,
|
|
2734
3723
|
setPaginationModel,
|
|
@@ -2745,55 +3734,10 @@ const useTableStates = (id, version) => {
|
|
|
2745
3734
|
densityModel,
|
|
2746
3735
|
setDensityModel,
|
|
2747
3736
|
columnOrderModel,
|
|
2748
|
-
setColumnOrderModel
|
|
2749
|
-
rowGroupingModel,
|
|
2750
|
-
setRowGroupingModel,
|
|
2751
|
-
aggregationModel,
|
|
2752
|
-
setAggregationModel,
|
|
2753
|
-
pivotModel,
|
|
2754
|
-
setPivotModel,
|
|
2755
|
-
pivotActive,
|
|
2756
|
-
setPivotActive
|
|
3737
|
+
setColumnOrderModel
|
|
2757
3738
|
};
|
|
2758
3739
|
};
|
|
2759
3740
|
|
|
2760
|
-
/** Convert our simplified PivotModel → MUI's GridPivotModel */
|
|
2761
|
-
const toGridPivotModel = model => ({
|
|
2762
|
-
columns: model.columns.map(field => ({
|
|
2763
|
-
field
|
|
2764
|
-
})),
|
|
2765
|
-
rows: model.rows.map(field => ({
|
|
2766
|
-
field
|
|
2767
|
-
})),
|
|
2768
|
-
values: model.values.map(_ref => {
|
|
2769
|
-
let {
|
|
2770
|
-
field,
|
|
2771
|
-
aggFunc
|
|
2772
|
-
} = _ref;
|
|
2773
|
-
return {
|
|
2774
|
-
field,
|
|
2775
|
-
aggFunc
|
|
2776
|
-
};
|
|
2777
|
-
})
|
|
2778
|
-
});
|
|
2779
|
-
|
|
2780
|
-
/**
|
|
2781
|
-
* Deep-equal comparison for plain objects / arrays.
|
|
2782
|
-
* Used to stabilise parsed model references so that MUI v8 does not
|
|
2783
|
-
* reset pagination on every render.
|
|
2784
|
-
*/
|
|
2785
|
-
function isDeepEqual(a, b) {
|
|
2786
|
-
if (a === b) return true;
|
|
2787
|
-
if (a == null || b == null) return false;
|
|
2788
|
-
if (typeof a !== typeof b) return false;
|
|
2789
|
-
if (typeof a !== 'object') return false;
|
|
2790
|
-
const aObj = a;
|
|
2791
|
-
const bObj = b;
|
|
2792
|
-
const aKeys = Object.keys(aObj);
|
|
2793
|
-
const bKeys = Object.keys(bObj);
|
|
2794
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
2795
|
-
return aKeys.every(key => isDeepEqual(aObj[key], bObj[key]));
|
|
2796
|
-
}
|
|
2797
3741
|
const useStatefulTable = props => {
|
|
2798
3742
|
var _initialState$columns, _initialState$columns2;
|
|
2799
3743
|
const {
|
|
@@ -2806,9 +3750,6 @@ const useStatefulTable = props => {
|
|
|
2806
3750
|
onPaginationModelChange: propsOnPaginationModelChange,
|
|
2807
3751
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
2808
3752
|
onSortModelChange: propsOnSortModelChange,
|
|
2809
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
2810
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
2811
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
2812
3753
|
useRouter,
|
|
2813
3754
|
localStorageVersion = 1,
|
|
2814
3755
|
previousLocalStorageVersions = []
|
|
@@ -2837,24 +3778,16 @@ const useStatefulTable = props => {
|
|
|
2837
3778
|
densityModel,
|
|
2838
3779
|
setDensityModel,
|
|
2839
3780
|
columnOrderModel: localStorageColumnOrder,
|
|
2840
|
-
setColumnOrderModel: setLocalStorageColumnOrder
|
|
2841
|
-
rowGroupingModel: localStorageRowGrouping,
|
|
2842
|
-
setRowGroupingModel: setLocalStorageRowGrouping,
|
|
2843
|
-
aggregationModel: localStorageAggregation,
|
|
2844
|
-
setAggregationModel: setLocalStorageAggregation,
|
|
2845
|
-
pivotModel: localStoragePivot,
|
|
2846
|
-
setPivotModel: setLocalStoragePivot,
|
|
2847
|
-
pivotActive: localStoragePivotActive,
|
|
2848
|
-
setPivotActive: setLocalStoragePivotActive
|
|
3781
|
+
setColumnOrderModel: setLocalStorageColumnOrder
|
|
2849
3782
|
} = useTableStates(id, localStorageVersion);
|
|
2850
3783
|
|
|
2851
3784
|
// clearing up old version keys, triggering only on first render
|
|
2852
3785
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
2853
|
-
const onColumnDimensionChange = useCallback(
|
|
3786
|
+
const onColumnDimensionChange = useCallback(_ref => {
|
|
2854
3787
|
let {
|
|
2855
3788
|
newWidth,
|
|
2856
3789
|
field
|
|
2857
|
-
} =
|
|
3790
|
+
} = _ref;
|
|
2858
3791
|
setDimensionModel(_objectSpread2(_objectSpread2({}, dimensionModel), {}, {
|
|
2859
3792
|
[field]: newWidth
|
|
2860
3793
|
}));
|
|
@@ -2867,10 +3800,6 @@ const useStatefulTable = props => {
|
|
|
2867
3800
|
pinnedColumnsModel,
|
|
2868
3801
|
density: densityParsed,
|
|
2869
3802
|
columnOrderModel: columnOrderParsed,
|
|
2870
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2871
|
-
aggregationModel: aggregationParsed,
|
|
2872
|
-
pivotModel: pivotParsed,
|
|
2873
|
-
pivotActive: pivotActiveParsed,
|
|
2874
3803
|
pendingSearch
|
|
2875
3804
|
} = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, initialState, {
|
|
2876
3805
|
localStorageFilters,
|
|
@@ -2886,15 +3815,7 @@ const useStatefulTable = props => {
|
|
|
2886
3815
|
localStorageDensity: densityModel,
|
|
2887
3816
|
setLocalStorageDensity: setDensityModel,
|
|
2888
3817
|
localStorageColumnOrder,
|
|
2889
|
-
setLocalStorageColumnOrder
|
|
2890
|
-
localStorageRowGrouping,
|
|
2891
|
-
setLocalStorageRowGrouping,
|
|
2892
|
-
localStorageAggregation,
|
|
2893
|
-
setLocalStorageAggregation,
|
|
2894
|
-
localStoragePivot,
|
|
2895
|
-
setLocalStoragePivot,
|
|
2896
|
-
localStoragePivotActive: localStoragePivotActive,
|
|
2897
|
-
setLocalStoragePivotActive: setLocalStoragePivotActive
|
|
3818
|
+
setLocalStorageColumnOrder
|
|
2898
3819
|
});
|
|
2899
3820
|
|
|
2900
3821
|
// Sync URL in an effect rather than during render to comply with React rules
|
|
@@ -2903,45 +3824,6 @@ const useStatefulTable = props => {
|
|
|
2903
3824
|
historyReplace(pendingSearch);
|
|
2904
3825
|
}
|
|
2905
3826
|
}, [pendingSearch, historyReplace]);
|
|
2906
|
-
|
|
2907
|
-
// Stabilise parsed model references to prevent MUI v8 from resetting
|
|
2908
|
-
// pagination on every render due to new object identity.
|
|
2909
|
-
const filterParsedRef = useRef(filterParsed);
|
|
2910
|
-
if (!isDeepEqual(filterParsedRef.current, filterParsed)) {
|
|
2911
|
-
filterParsedRef.current = filterParsed;
|
|
2912
|
-
}
|
|
2913
|
-
const sortModelParsedRef = useRef(sortModelParsed);
|
|
2914
|
-
if (!isDeepEqual(sortModelParsedRef.current, sortModelParsed)) {
|
|
2915
|
-
sortModelParsedRef.current = sortModelParsed;
|
|
2916
|
-
}
|
|
2917
|
-
const paginationModelParsedRef = useRef(paginationModelParsed);
|
|
2918
|
-
if (!isDeepEqual(paginationModelParsedRef.current, paginationModelParsed)) {
|
|
2919
|
-
paginationModelParsedRef.current = paginationModelParsed;
|
|
2920
|
-
}
|
|
2921
|
-
const visibilityModelRef = useRef(visibilityModel);
|
|
2922
|
-
if (!isDeepEqual(visibilityModelRef.current, visibilityModel)) {
|
|
2923
|
-
visibilityModelRef.current = visibilityModel;
|
|
2924
|
-
}
|
|
2925
|
-
const pinnedColumnsModelRef = useRef(pinnedColumnsModel);
|
|
2926
|
-
if (!isDeepEqual(pinnedColumnsModelRef.current, pinnedColumnsModel)) {
|
|
2927
|
-
pinnedColumnsModelRef.current = pinnedColumnsModel;
|
|
2928
|
-
}
|
|
2929
|
-
const columnOrderParsedRef = useRef(columnOrderParsed);
|
|
2930
|
-
if (!isDeepEqual(columnOrderParsedRef.current, columnOrderParsed)) {
|
|
2931
|
-
columnOrderParsedRef.current = columnOrderParsed;
|
|
2932
|
-
}
|
|
2933
|
-
const rowGroupingParsedRef = useRef(rowGroupingParsed);
|
|
2934
|
-
if (!isDeepEqual(rowGroupingParsedRef.current, rowGroupingParsed)) {
|
|
2935
|
-
rowGroupingParsedRef.current = rowGroupingParsed;
|
|
2936
|
-
}
|
|
2937
|
-
const aggregationParsedRef = useRef(aggregationParsed);
|
|
2938
|
-
if (!isDeepEqual(aggregationParsedRef.current, aggregationParsed)) {
|
|
2939
|
-
aggregationParsedRef.current = aggregationParsed;
|
|
2940
|
-
}
|
|
2941
|
-
const pivotParsedRef = useRef(pivotParsed);
|
|
2942
|
-
if (!isDeepEqual(pivotParsedRef.current, pivotParsed)) {
|
|
2943
|
-
pivotParsedRef.current = pivotParsed;
|
|
2944
|
-
}
|
|
2945
3827
|
const columns = useMemo(() => propsColumns.map(column => {
|
|
2946
3828
|
return _objectSpread2(_objectSpread2({}, column), {}, {
|
|
2947
3829
|
width: dimensionModel[column.field] || column.width || 100
|
|
@@ -2950,61 +3832,56 @@ const useStatefulTable = props => {
|
|
|
2950
3832
|
if (apiRef.current) {
|
|
2951
3833
|
/** Add resetPage method to apiRef. */
|
|
2952
3834
|
apiRef.current.resetPage = () => {
|
|
2953
|
-
|
|
2954
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPage(0);
|
|
3835
|
+
apiRef.current.setPage(0);
|
|
2955
3836
|
};
|
|
2956
3837
|
}
|
|
2957
3838
|
const defaultColumnOrder = (_initialState$columns = initialState === null || initialState === void 0 ? void 0 : (_initialState$columns2 = initialState.columns) === null || _initialState$columns2 === void 0 ? void 0 : _initialState$columns2.orderedFields) !== null && _initialState$columns !== void 0 ? _initialState$columns : propsColumns.map(c => c.field);
|
|
2958
3839
|
|
|
3840
|
+
// Helper to build the current DataGridModel for updateUrl calls
|
|
3841
|
+
const buildModel = function () {
|
|
3842
|
+
var _apiRef$current$state, _apiRef$current;
|
|
3843
|
+
let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3844
|
+
return _objectSpread2({
|
|
3845
|
+
filterModel: filterParsed,
|
|
3846
|
+
sortModel: sortModelParsed,
|
|
3847
|
+
paginationModel: paginationModelParsed,
|
|
3848
|
+
columnsModel: (_apiRef$current$state = (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.state.columns.columnVisibilityModel) !== null && _apiRef$current$state !== void 0 ? _apiRef$current$state : {},
|
|
3849
|
+
pinnedColumnsModel: pinnedColumnsModel,
|
|
3850
|
+
density: densityParsed,
|
|
3851
|
+
columnOrderModel: columnOrderParsed,
|
|
3852
|
+
defaultColumnOrder
|
|
3853
|
+
}, overrides);
|
|
3854
|
+
};
|
|
3855
|
+
|
|
2959
3856
|
// Subscribe to density changes via stateChange event (MUI v6 has no densityChange event)
|
|
2960
3857
|
useEffect(() => {
|
|
2961
3858
|
const api = apiRef.current;
|
|
2962
3859
|
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
2963
3860
|
let prevDensity = densityParsed;
|
|
2964
3861
|
const unsub = api.subscribeEvent('stateChange', () => {
|
|
2965
|
-
const currentDensity = api.state.density;
|
|
3862
|
+
const currentDensity = api.state.density.value;
|
|
2966
3863
|
if (currentDensity !== prevDensity) {
|
|
2967
3864
|
prevDensity = currentDensity;
|
|
2968
|
-
updateUrl({
|
|
2969
|
-
filterModel: filterParsed,
|
|
2970
|
-
sortModel: sortModelParsed,
|
|
2971
|
-
paginationModel: paginationModelParsed,
|
|
3865
|
+
updateUrl(buildModel({
|
|
2972
3866
|
columnsModel: api.state.columns.columnVisibilityModel,
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
columnOrderModel: columnOrderParsed,
|
|
2976
|
-
defaultColumnOrder,
|
|
2977
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2978
|
-
aggregationModel: aggregationParsed,
|
|
2979
|
-
pivotModel: pivotParsed,
|
|
2980
|
-
pivotActive: pivotActiveParsed
|
|
2981
|
-
}, search, localStorageVersion, historyReplace, columns);
|
|
3867
|
+
density: currentDensity
|
|
3868
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
2982
3869
|
}
|
|
2983
3870
|
});
|
|
2984
3871
|
return unsub;
|
|
2985
|
-
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder,
|
|
3872
|
+
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder, search, localStorageVersion, historyReplace, columns]);
|
|
2986
3873
|
|
|
2987
3874
|
// Subscribe to column order changes via columnOrderChange (drag-drop) and columnIndexChange (programmatic setColumnIndex)
|
|
2988
3875
|
useEffect(() => {
|
|
2989
3876
|
const api = apiRef.current;
|
|
2990
3877
|
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
3878
|
+
const isDeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
2991
3879
|
const handleColumnOrderChange = () => {
|
|
2992
3880
|
const orderedFields = api.state.columns.orderedFields;
|
|
2993
3881
|
if (orderedFields && !isDeepEqual(orderedFields, columnOrderParsed)) {
|
|
2994
|
-
updateUrl({
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
paginationModel: paginationModelParsed,
|
|
2998
|
-
columnsModel: api.state.columns.columnVisibilityModel,
|
|
2999
|
-
pinnedColumnsModel,
|
|
3000
|
-
density: densityParsed,
|
|
3001
|
-
columnOrderModel: orderedFields,
|
|
3002
|
-
defaultColumnOrder,
|
|
3003
|
-
rowGroupingModel: rowGroupingParsed,
|
|
3004
|
-
aggregationModel: aggregationParsed,
|
|
3005
|
-
pivotModel: pivotParsed,
|
|
3006
|
-
pivotActive: pivotActiveParsed
|
|
3007
|
-
}, search, localStorageVersion, historyReplace, columns);
|
|
3882
|
+
updateUrl(buildModel({
|
|
3883
|
+
columnOrderModel: orderedFields
|
|
3884
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3008
3885
|
}
|
|
3009
3886
|
};
|
|
3010
3887
|
const unsub1 = api.subscribeEvent('columnOrderChange', handleColumnOrderChange);
|
|
@@ -3013,120 +3890,69 @@ const useStatefulTable = props => {
|
|
|
3013
3890
|
unsub1();
|
|
3014
3891
|
unsub2();
|
|
3015
3892
|
};
|
|
3016
|
-
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed,
|
|
3017
|
-
|
|
3018
|
-
// Helper to build the current DataGridModel for updateUrl calls
|
|
3019
|
-
const buildModel = function () {
|
|
3020
|
-
var _apiRef$current$state, _apiRef$current2;
|
|
3021
|
-
let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3022
|
-
return _objectSpread2({
|
|
3023
|
-
filterModel: filterParsed,
|
|
3024
|
-
sortModel: sortModelParsed,
|
|
3025
|
-
paginationModel: paginationModelParsed,
|
|
3026
|
-
columnsModel: (_apiRef$current$state = (_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.state.columns.columnVisibilityModel) !== null && _apiRef$current$state !== void 0 ? _apiRef$current$state : {},
|
|
3027
|
-
pinnedColumnsModel: pinnedColumnsModel,
|
|
3028
|
-
density: densityParsed,
|
|
3029
|
-
columnOrderModel: columnOrderParsed,
|
|
3030
|
-
defaultColumnOrder,
|
|
3031
|
-
rowGroupingModel: rowGroupingParsed,
|
|
3032
|
-
aggregationModel: aggregationParsed,
|
|
3033
|
-
pivotModel: pivotParsed,
|
|
3034
|
-
pivotActive: pivotActiveParsed
|
|
3035
|
-
}, overrides);
|
|
3036
|
-
};
|
|
3037
|
-
|
|
3038
|
-
// Stable GridPivotModel identity — only recompute when the simplified value changes.
|
|
3039
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3040
|
-
const pivotModelMui = useMemo(() => toGridPivotModel(pivotParsed), [JSON.stringify(pivotParsed)]);
|
|
3893
|
+
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed, search, localStorageVersion, historyReplace, columns]);
|
|
3041
3894
|
|
|
3042
3895
|
// Track last emitted values for deep-equal guards to avoid feedback loops.
|
|
3043
|
-
// Initialised from the current parsed values; updated only when we actually fire.
|
|
3044
3896
|
const lastEmittedFilterRef = useRef(filterParsed);
|
|
3045
3897
|
const lastEmittedSortRef = useRef(sortModelParsed);
|
|
3046
3898
|
const lastEmittedPaginationRef = useRef(paginationModelParsed);
|
|
3047
|
-
const
|
|
3899
|
+
const isModelDeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
3048
3900
|
return {
|
|
3049
3901
|
apiRef,
|
|
3050
3902
|
columns,
|
|
3051
3903
|
density: densityParsed,
|
|
3052
|
-
columnOrderModel:
|
|
3053
|
-
rowGroupingModel: rowGroupingParsedRef.current,
|
|
3054
|
-
aggregationModel: aggregationParsedRef.current,
|
|
3055
|
-
pivotModel: pivotModelMui,
|
|
3056
|
-
pivotActive: pivotActiveParsed,
|
|
3904
|
+
columnOrderModel: columnOrderParsed,
|
|
3057
3905
|
onFilterModelChange: (model, details) => {
|
|
3058
3906
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
3059
3907
|
items: model.items.map(item => {
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
item.type = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
3908
|
+
const column = apiRef.current.getColumn(item.field);
|
|
3909
|
+
item.type = column.type || 'string';
|
|
3063
3910
|
return item;
|
|
3064
3911
|
}),
|
|
3065
3912
|
quickFilterValues: model.quickFilterValues || []
|
|
3066
3913
|
});
|
|
3067
|
-
if (
|
|
3914
|
+
if (isModelDeepEqual(filterModel, lastEmittedFilterRef.current)) return;
|
|
3068
3915
|
lastEmittedFilterRef.current = filterModel;
|
|
3916
|
+
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
3069
3917
|
updateUrl(buildModel({
|
|
3070
3918
|
filterModel
|
|
3071
3919
|
}), search, localStorageVersion, historyReplace, columns);
|
|
3072
|
-
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
3073
3920
|
},
|
|
3074
|
-
filterModel:
|
|
3921
|
+
filterModel: filterParsed,
|
|
3075
3922
|
onSortModelChange: (model, details) => {
|
|
3076
|
-
if (
|
|
3923
|
+
if (isModelDeepEqual(model, lastEmittedSortRef.current)) return;
|
|
3077
3924
|
lastEmittedSortRef.current = model;
|
|
3925
|
+
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
3078
3926
|
updateUrl(buildModel({
|
|
3079
3927
|
sortModel: model
|
|
3080
3928
|
}), search, localStorageVersion, historyReplace, columns);
|
|
3081
|
-
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
3082
3929
|
},
|
|
3083
|
-
sortModel:
|
|
3930
|
+
sortModel: sortModelParsed,
|
|
3084
3931
|
onPinnedColumnsChange: (pinnedColumns, details) => {
|
|
3085
|
-
var _apiRef$current$state2, _apiRef$current4, _apiRef$current4$stat, _apiRef$current4$stat2;
|
|
3086
|
-
// While pivot mode is active, MUI Premium emits synthetic pinned-column
|
|
3087
|
-
// models (e.g. `__row_group_by_columns_group__` for the grouping column)
|
|
3088
|
-
// that must not be persisted to the URL / localStorage. Read the live
|
|
3089
|
-
// grid state from apiRef rather than the parsed URL value because the
|
|
3090
|
-
// URL lags by a tick during pivot enable/disable transitions. Consumer
|
|
3091
|
-
// callbacks are always forwarded so observers can still react.
|
|
3092
|
-
const pivotActiveLive = (_apiRef$current$state2 = (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : (_apiRef$current4$stat = _apiRef$current4.state) === null || _apiRef$current4$stat === void 0 ? void 0 : (_apiRef$current4$stat2 = _apiRef$current4$stat.pivoting) === null || _apiRef$current4$stat2 === void 0 ? void 0 : _apiRef$current4$stat2.active) !== null && _apiRef$current$state2 !== void 0 ? _apiRef$current$state2 : pivotActiveParsed;
|
|
3093
|
-
if (!pivotActiveLive) {
|
|
3094
|
-
updateUrl(buildModel({
|
|
3095
|
-
pinnedColumnsModel: pinnedColumns
|
|
3096
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3097
|
-
}
|
|
3098
3932
|
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
3933
|
+
updateUrl(buildModel({
|
|
3934
|
+
pinnedColumnsModel: pinnedColumns
|
|
3935
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3099
3936
|
},
|
|
3100
|
-
pinnedColumns:
|
|
3101
|
-
paginationModel:
|
|
3937
|
+
pinnedColumns: pinnedColumnsModel,
|
|
3938
|
+
paginationModel: paginationModelParsed,
|
|
3102
3939
|
onPaginationModelChange: (model, details) => {
|
|
3103
3940
|
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
3104
3941
|
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
3105
3942
|
});
|
|
3106
|
-
if (
|
|
3943
|
+
if (isModelDeepEqual(paginationModel, lastEmittedPaginationRef.current)) return;
|
|
3107
3944
|
lastEmittedPaginationRef.current = paginationModel;
|
|
3945
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
3108
3946
|
updateUrl(buildModel({
|
|
3109
3947
|
paginationModel
|
|
3110
3948
|
}), search, localStorageVersion, historyReplace, columns);
|
|
3111
|
-
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
3112
3949
|
},
|
|
3113
|
-
columnVisibilityModel:
|
|
3950
|
+
columnVisibilityModel: visibilityModel,
|
|
3114
3951
|
onColumnVisibilityModelChange: (columnsVisibilityModel, details) => {
|
|
3115
|
-
var _apiRef$current$state3, _apiRef$current5, _apiRef$current5$stat, _apiRef$current5$stat2;
|
|
3116
|
-
// While pivot mode is active, MUI Premium emits synthetic visibility
|
|
3117
|
-
// models that whitelist only the pivot value fields (hiding every base
|
|
3118
|
-
// column). Persisting that to the URL would re-hide all base columns
|
|
3119
|
-
// on the next load (see getColumnVisibilityFromString whitelist logic).
|
|
3120
|
-
// Read the live grid state rather than the parsed URL value because the
|
|
3121
|
-
// URL lags by a tick during pivot enable/disable transitions. Consumer
|
|
3122
|
-
// callbacks are always forwarded.
|
|
3123
|
-
const pivotActiveLive = (_apiRef$current$state3 = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : (_apiRef$current5$stat = _apiRef$current5.state) === null || _apiRef$current5$stat === void 0 ? void 0 : (_apiRef$current5$stat2 = _apiRef$current5$stat.pivoting) === null || _apiRef$current5$stat2 === void 0 ? void 0 : _apiRef$current5$stat2.active) !== null && _apiRef$current$state3 !== void 0 ? _apiRef$current$state3 : pivotActiveParsed;
|
|
3124
|
-
if (!pivotActiveLive) {
|
|
3125
|
-
updateUrl(buildModel({
|
|
3126
|
-
columnsModel: columnsVisibilityModel
|
|
3127
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3128
|
-
}
|
|
3129
3952
|
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
3953
|
+
updateUrl(buildModel({
|
|
3954
|
+
columnsModel: columnsVisibilityModel
|
|
3955
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3130
3956
|
},
|
|
3131
3957
|
onColumnWidthChange: (params, event, details) => {
|
|
3132
3958
|
propsOnColumnWidthChange === null || propsOnColumnWidthChange === void 0 ? void 0 : propsOnColumnWidthChange(params, event, details);
|
|
@@ -3134,38 +3960,11 @@ const useStatefulTable = props => {
|
|
|
3134
3960
|
newWidth: params.width,
|
|
3135
3961
|
field: params.colDef.field
|
|
3136
3962
|
});
|
|
3137
|
-
},
|
|
3138
|
-
onRowGroupingModelChange: (model, details) => {
|
|
3139
|
-
updateUrl(buildModel({
|
|
3140
|
-
rowGroupingModel: model
|
|
3141
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3142
|
-
propsOnRowGroupingModelChange === null || propsOnRowGroupingModelChange === void 0 ? void 0 : propsOnRowGroupingModelChange(model, details);
|
|
3143
|
-
},
|
|
3144
|
-
onAggregationModelChange: (model, details) => {
|
|
3145
|
-
updateUrl(buildModel({
|
|
3146
|
-
aggregationModel: model
|
|
3147
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3148
|
-
propsOnAggregationModelChange === null || propsOnAggregationModelChange === void 0 ? void 0 : propsOnAggregationModelChange(model, details);
|
|
3149
|
-
},
|
|
3150
|
-
onPivotModelChange: model => {
|
|
3151
|
-
const simplified = fromGridPivotModel(model);
|
|
3152
|
-
if (isDeepEqual(simplified, lastEmittedPivotRef.current)) return;
|
|
3153
|
-
lastEmittedPivotRef.current = simplified;
|
|
3154
|
-
updateUrl(buildModel({
|
|
3155
|
-
pivotModel: simplified
|
|
3156
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3157
|
-
propsOnPivotModelChange === null || propsOnPivotModelChange === void 0 ? void 0 : propsOnPivotModelChange(model);
|
|
3158
|
-
},
|
|
3159
|
-
onPivotActiveChange: active => {
|
|
3160
|
-
if (active === pivotActiveParsed) return;
|
|
3161
|
-
updateUrl(buildModel({
|
|
3162
|
-
pivotActive: active
|
|
3163
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
3164
3963
|
}
|
|
3165
3964
|
};
|
|
3166
3965
|
};
|
|
3167
3966
|
|
|
3168
|
-
const _excluded = ["apiRef", "autoHeight", "className", "columns", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "previousLocalStorageVersions", "onFilterModelChange", "rowSelectionModel", "onColumnWidthChange", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "
|
|
3967
|
+
const _excluded = ["apiRef", "autoHeight", "className", "columns", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "previousLocalStorageVersions", "onFilterModelChange", "rowSelectionModel", "onColumnWidthChange", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "selectionBannerPlacement", "paginationProps", "rows", "pageSizeOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
|
|
3169
3968
|
const COMPONENT_NAME = 'DataGrid';
|
|
3170
3969
|
const CLASSNAME = 'redsift-datagrid';
|
|
3171
3970
|
|
|
@@ -3249,11 +4048,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3249
4048
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
3250
4049
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
3251
4050
|
onSortModelChange: propsOnSortModelChange,
|
|
3252
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3253
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3254
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3255
4051
|
pagination,
|
|
3256
4052
|
paginationPlacement = 'both',
|
|
4053
|
+
selectionBannerPlacement = 'top',
|
|
3257
4054
|
paginationProps,
|
|
3258
4055
|
rows,
|
|
3259
4056
|
pageSizeOptions,
|
|
@@ -3261,26 +4058,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3261
4058
|
theme: propsTheme,
|
|
3262
4059
|
useRouter,
|
|
3263
4060
|
paginationMode = 'client',
|
|
3264
|
-
rowCount
|
|
3265
|
-
density: _density,
|
|
3266
|
-
dataSource,
|
|
3267
|
-
filterMode: propsFilterMode,
|
|
3268
|
-
sortingMode: propsSortingMode
|
|
4061
|
+
rowCount
|
|
3269
4062
|
} = props,
|
|
3270
4063
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
3271
|
-
const theme = useTheme(propsTheme);
|
|
4064
|
+
const theme = useTheme$1(propsTheme);
|
|
3272
4065
|
const _apiRef = useGridApiRef();
|
|
3273
4066
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
4067
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar;
|
|
3274
4068
|
LicenseInfo.setLicenseKey(license);
|
|
3275
4069
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
3276
|
-
|
|
3277
|
-
// When dataSource is present, MUI manages filter/sort/pagination internally.
|
|
3278
|
-
// We must not pass controlled models — only initialState (one-time) and
|
|
3279
|
-
// write-only onChange handlers for URL/localStorage persistence.
|
|
3280
|
-
const isDataSourceMode = Boolean(dataSource);
|
|
3281
|
-
const effectivePaginationMode = isDataSourceMode ? 'server' : paginationMode;
|
|
3282
|
-
const effectiveFilterMode = isDataSourceMode ? 'server' : propsFilterMode;
|
|
3283
|
-
const effectiveSortingMode = isDataSourceMode ? 'server' : propsSortingMode;
|
|
3284
4070
|
const {
|
|
3285
4071
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
3286
4072
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
@@ -3314,15 +4100,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3314
4100
|
pinnedColumns,
|
|
3315
4101
|
sortModel,
|
|
3316
4102
|
onColumnWidthChange,
|
|
3317
|
-
columnOrderModel
|
|
3318
|
-
rowGroupingModel,
|
|
3319
|
-
aggregationModel,
|
|
3320
|
-
pivotModel,
|
|
3321
|
-
pivotActive,
|
|
3322
|
-
onRowGroupingModelChange,
|
|
3323
|
-
onAggregationModelChange,
|
|
3324
|
-
onPivotModelChange,
|
|
3325
|
-
onPivotActiveChange
|
|
4103
|
+
columnOrderModel
|
|
3326
4104
|
} = useStatefulTable({
|
|
3327
4105
|
apiRef: apiRef,
|
|
3328
4106
|
initialState,
|
|
@@ -3333,68 +4111,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3333
4111
|
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
3334
4112
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
3335
4113
|
onSortModelChange: controlledOnSortModelChange,
|
|
3336
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3337
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3338
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3339
4114
|
useRouter: useRouter,
|
|
3340
4115
|
localStorageVersion,
|
|
3341
4116
|
previousLocalStorageVersions
|
|
3342
4117
|
});
|
|
3343
|
-
|
|
3344
|
-
// In dataSource mode, track pagination locally for the custom pagination slots
|
|
3345
|
-
// (rendered outside DataGridPremium). MUI owns the actual pagination state internally.
|
|
3346
|
-
const [dataSourcePaginationModel, setDataSourcePaginationModel] = useState(paginationModel);
|
|
3347
|
-
|
|
3348
|
-
// The pagination model to use for display in pagination slots
|
|
3349
|
-
const activePaginationModel = isDataSourceMode ? dataSourcePaginationModel : paginationModel;
|
|
3350
|
-
|
|
3351
|
-
// Wrap onPaginationModelChange to also track state locally in dataSource mode
|
|
3352
|
-
const wrappedOnPaginationModelChange = useCallback((model, details) => {
|
|
3353
|
-
if (isDataSourceMode) {
|
|
3354
|
-
setDataSourcePaginationModel(model);
|
|
3355
|
-
}
|
|
3356
|
-
onPaginationModelChange(model, details);
|
|
3357
|
-
}, [isDataSourceMode, onPaginationModelChange]);
|
|
3358
|
-
|
|
3359
|
-
// In dataSource mode, pagination changes from our custom pagination slots
|
|
3360
|
-
// (rendered outside MUI's pagination state) route through apiRef so MUI's
|
|
3361
|
-
// internal page state updates and dataSource.getRows() refetches with the
|
|
3362
|
-
// new params. The `paginationModelChange` subscription below picks up the
|
|
3363
|
-
// resulting state change and propagates it to URL/localStorage and local
|
|
3364
|
-
// React state via wrappedOnPaginationModelChange.
|
|
3365
|
-
const dataSourcePaginationChange = useCallback(model => {
|
|
3366
|
-
var _apiRef$current;
|
|
3367
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPaginationModel(model);
|
|
3368
|
-
}, [apiRef]);
|
|
3369
|
-
|
|
3370
|
-
// In dataSource mode, subscribe to MUI's `paginationModelChange` event so
|
|
3371
|
-
// URL state stays in sync with MUI's internal pagination regardless of how
|
|
3372
|
-
// it changed (slot click, apiRef.setPaginationModel from consumer code,
|
|
3373
|
-
// MUI internal updates, etc.). Relying on MUI's `onPaginationModelChange`
|
|
3374
|
-
// prop callback alone is not sufficient: in pivot/GroupedData strategy mode
|
|
3375
|
-
// and with `paginationModel` seeded via `initialState` (rather than as a
|
|
3376
|
-
// controlled prop), the prop callback can be missed under certain
|
|
3377
|
-
// re-render orderings. The event fires reliably whenever the internal
|
|
3378
|
-
// state changes via `setState('setPaginationModel')`, see
|
|
3379
|
-
// `useGridStateInitialization.setState` → `publishEvent(changeEvent, …)`.
|
|
3380
|
-
// The deep-equal guard inside `useStatefulTable.onPaginationModelChange`
|
|
3381
|
-
// dedupes any duplicate emits, so overlap with the prop callback is safe.
|
|
3382
|
-
useEffect(() => {
|
|
3383
|
-
if (!isDataSourceMode) return;
|
|
3384
|
-
const api = apiRef.current;
|
|
3385
|
-
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
3386
|
-
return api.subscribeEvent('paginationModelChange', model => {
|
|
3387
|
-
wrappedOnPaginationModelChange({
|
|
3388
|
-
page: model.page,
|
|
3389
|
-
pageSize: model.pageSize
|
|
3390
|
-
}, {
|
|
3391
|
-
reason: 'paginationModelChange'
|
|
3392
|
-
});
|
|
3393
|
-
});
|
|
3394
|
-
}, [isDataSourceMode, apiRef, wrappedOnPaginationModelChange]);
|
|
3395
|
-
const [rowSelectionModel, setRowSelectionModel] = useState(() => normalizeRowSelectionModel(propsRowSelectionModel));
|
|
4118
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3396
4119
|
useEffect(() => {
|
|
3397
|
-
setRowSelectionModel(
|
|
4120
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3398
4121
|
}, [propsRowSelectionModel]);
|
|
3399
4122
|
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
3400
4123
|
setRowSelectionModel(selectionModel);
|
|
@@ -3408,41 +4131,25 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3408
4131
|
pageSize: paginationModel.pageSize
|
|
3409
4132
|
});
|
|
3410
4133
|
|
|
3411
|
-
// Version counter to force re-renders when selectionStatus ref changes
|
|
3412
|
-
const [, forceSelectionUpdate] = useState(0);
|
|
3413
|
-
|
|
3414
4134
|
// The checkboxSelectionVisibleOnly should only be applied to client-side pagination,
|
|
3415
4135
|
// for server-side pagination it produces inconsistent behavior when selecting all rows in pages 2 and beyond
|
|
3416
|
-
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(
|
|
4136
|
+
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(paginationMode != 'server');
|
|
3417
4137
|
|
|
3418
|
-
//
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
setGridReady(true);
|
|
3425
|
-
}
|
|
3426
|
-
});
|
|
3427
|
-
|
|
3428
|
-
// Sync persisted density via apiRef — initialState only applies on mount,
|
|
3429
|
-
// so this handles SPA back/forward navigation where controlledDensity changes after mount
|
|
3430
|
-
useEffect(() => {
|
|
3431
|
-
if (apiRef.current) {
|
|
3432
|
-
apiRef.current.setDensity(controlledDensity);
|
|
3433
|
-
}
|
|
3434
|
-
}, [controlledDensity, apiRef]);
|
|
4138
|
+
// Banner and pager placements are independent. `belowToolbar` (for either) renders
|
|
4139
|
+
// in the toolbar-slot row, and only applies when pagination is on.
|
|
4140
|
+
const bannerAtTop = selectionBannerPlacement === 'top';
|
|
4141
|
+
const bannerAtBottom = selectionBannerPlacement === 'bottom';
|
|
4142
|
+
const bannerBelowToolbar = selectionBannerPlacement === 'belowToolbar' && Boolean(pagination);
|
|
4143
|
+
const pagerBelowToolbar = paginationPlacement === 'belowToolbar' && Boolean(pagination);
|
|
3435
4144
|
|
|
3436
4145
|
// in server-side pagination we want to update the selection status
|
|
3437
4146
|
// every time we navigate between pages, resize our page or select something
|
|
3438
4147
|
useEffect(() => {
|
|
3439
|
-
if (
|
|
3440
|
-
onServerSideSelectionStatusChange(rowSelectionModel, apiRef, selectionStatusRef,
|
|
4148
|
+
if (paginationMode == 'server') {
|
|
4149
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatusRef, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
3441
4150
|
}
|
|
3442
|
-
}, [rowSelectionModel,
|
|
3443
|
-
|
|
3444
|
-
// In dataSource mode MUI provides rows internally; skip the guard.
|
|
3445
|
-
if (!isDataSourceMode && !Array.isArray(rows)) {
|
|
4151
|
+
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize, rows]);
|
|
4152
|
+
if (!Array.isArray(rows)) {
|
|
3446
4153
|
return null;
|
|
3447
4154
|
}
|
|
3448
4155
|
|
|
@@ -3451,15 +4158,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3451
4158
|
// receive the fresh value in the same render cycle — no extra re-render needed.
|
|
3452
4159
|
// The ref is kept in sync for the onRowSelectionModelChange callback's deselect logic.
|
|
3453
4160
|
let selectionStatus = selectionStatusRef.current;
|
|
3454
|
-
if (pagination &&
|
|
4161
|
+
if (pagination && paginationMode !== 'server' && Array.isArray(rowSelectionModel) && rowSelectionModel.length > 0) {
|
|
3455
4162
|
try {
|
|
3456
|
-
|
|
3457
|
-
// MUI's paginated selectors use apiRef internal state which may be stale when
|
|
3458
|
-
// paginationModel prop changes — our React state is always up to date.
|
|
3459
|
-
const allFilteredEntries = gridFilteredSortedRowEntriesSelector(apiRef);
|
|
3460
|
-
const pageStart = activePaginationModel.page * activePaginationModel.pageSize;
|
|
3461
|
-
const pageEntries = allFilteredEntries.slice(pageStart, pageStart + activePaginationModel.pageSize);
|
|
3462
|
-
const selectableRowsInPage = isRowSelectable ? pageEntries.filter(_ref => {
|
|
4163
|
+
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
3463
4164
|
let {
|
|
3464
4165
|
model
|
|
3465
4166
|
} = _ref;
|
|
@@ -3471,29 +4172,24 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3471
4172
|
id
|
|
3472
4173
|
} = _ref2;
|
|
3473
4174
|
return id;
|
|
3474
|
-
}) :
|
|
3475
|
-
let {
|
|
3476
|
-
id
|
|
3477
|
-
} = _ref3;
|
|
3478
|
-
return id;
|
|
3479
|
-
});
|
|
4175
|
+
}) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
|
|
3480
4176
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3481
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
4177
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref3 => {
|
|
3482
4178
|
let {
|
|
3483
4179
|
model
|
|
3484
|
-
} =
|
|
4180
|
+
} = _ref3;
|
|
3485
4181
|
return isRowSelectable({
|
|
3486
4182
|
row: model
|
|
3487
4183
|
});
|
|
3488
|
-
}).map(
|
|
4184
|
+
}).map(_ref4 => {
|
|
3489
4185
|
let {
|
|
3490
4186
|
id
|
|
3491
|
-
} =
|
|
4187
|
+
} = _ref4;
|
|
3492
4188
|
return id;
|
|
3493
4189
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3494
4190
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3495
|
-
const numberOfSelectedRows =
|
|
3496
|
-
const selectedOnCurrentPage = selectableRowsInPage.filter(id =>
|
|
4191
|
+
const numberOfSelectedRows = rowSelectionModel.length;
|
|
4192
|
+
const selectedOnCurrentPage = selectableRowsInPage.filter(id => rowSelectionModel.includes(id));
|
|
3497
4193
|
if (numberOfSelectedRows === numberOfSelectableRowsInTable && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
3498
4194
|
selectionStatus = {
|
|
3499
4195
|
type: 'table',
|
|
@@ -3518,7 +4214,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3518
4214
|
} catch {
|
|
3519
4215
|
// apiRef may not be initialized on first render
|
|
3520
4216
|
}
|
|
3521
|
-
} else if (pagination &&
|
|
4217
|
+
} else if (pagination && paginationMode !== 'server') {
|
|
3522
4218
|
selectionStatus = {
|
|
3523
4219
|
type: 'none',
|
|
3524
4220
|
numberOfSelectedRows: 0
|
|
@@ -3547,233 +4243,158 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3547
4243
|
ref: datagridRef,
|
|
3548
4244
|
className: classNames(StatefulDataGrid.className, className),
|
|
3549
4245
|
$height: height
|
|
3550
|
-
},
|
|
3551
|
-
displaySelection: true,
|
|
3552
|
-
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3553
|
-
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3554
|
-
selectionStatus: selectionStatus,
|
|
3555
|
-
paginationModel: activePaginationModel,
|
|
3556
|
-
onPaginationModelChange: isDataSourceMode ? dataSourcePaginationChange : onPaginationModelChange,
|
|
3557
|
-
pageSizeOptions: pageSizeOptions,
|
|
3558
|
-
paginationProps: paginationProps,
|
|
3559
|
-
rowCount: rowCount
|
|
3560
|
-
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
3561
|
-
displaySelection: true,
|
|
3562
|
-
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3563
|
-
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3564
|
-
selectionStatus: selectionStatus,
|
|
3565
|
-
apiRef: apiRef,
|
|
3566
|
-
isRowSelectable: isRowSelectable,
|
|
3567
|
-
paginationModel: activePaginationModel,
|
|
3568
|
-
onPaginationModelChange: onPaginationModelChange,
|
|
3569
|
-
pageSizeOptions: pageSizeOptions,
|
|
3570
|
-
paginationProps: paginationProps
|
|
3571
|
-
}) : null, /*#__PURE__*/React__default.createElement(DataGridPremium, _extends({}, forwardedProps, {
|
|
4246
|
+
}, /*#__PURE__*/React__default.createElement(DataGridPro, _extends$2({}, forwardedProps, {
|
|
3572
4247
|
apiRef: apiRef,
|
|
3573
|
-
dataSource: dataSource,
|
|
3574
4248
|
columns: columns,
|
|
4249
|
+
columnVisibilityModel: columnVisibilityModel,
|
|
4250
|
+
density: controlledDensity,
|
|
4251
|
+
filterModel: filterModel,
|
|
3575
4252
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
4253
|
+
onFilterModelChange: onFilterModelChange,
|
|
4254
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3576
4255
|
onPinnedColumnsChange: onPinnedColumnsChange,
|
|
4256
|
+
onSortModelChange: onSortModelChange,
|
|
4257
|
+
paginationModel: paginationModel,
|
|
4258
|
+
pinnedColumns: pinnedColumns,
|
|
4259
|
+
sortModel: sortModel,
|
|
3577
4260
|
pageSizeOptions: pageSizeOptions,
|
|
3578
4261
|
onColumnWidthChange: onColumnWidthChange,
|
|
3579
|
-
onRowGroupingModelChange: onRowGroupingModelChange,
|
|
3580
|
-
onAggregationModelChange: onAggregationModelChange,
|
|
3581
|
-
onPivotModelChange: onPivotModelChange,
|
|
3582
|
-
pivotActive: pivotActive,
|
|
3583
|
-
onPivotActiveChange: onPivotActiveChange
|
|
3584
|
-
// In dataSource mode: models are uncontrolled (MUI owns them),
|
|
3585
|
-
// onChange handlers are write-only for URL/localStorage persistence,
|
|
3586
|
-
// and initialState seeds MUI on mount from the persisted URL state.
|
|
3587
|
-
// columnVisibilityModel / pinnedColumns / rowGroupingModel /
|
|
3588
|
-
// aggregationModel / pivotModel are also uncontrolled here to
|
|
3589
|
-
// avoid a controlled re-render race with consumer-side
|
|
3590
|
-
// microtask-deferred history updates (otherwise user toggles
|
|
3591
|
-
// flip back when MUI re-emits with the stale controlled value).
|
|
3592
|
-
// pivotModel specifically also carries `hidden`/`sort` field
|
|
3593
|
-
// metadata that our simplified URL representation strips — so
|
|
3594
|
-
// controlling it would prevent users from unchecking fields in
|
|
3595
|
-
// the pivot panel (the controlled prop would immediately re-add
|
|
3596
|
-
// them). Consumers needing programmatic changes should use the
|
|
3597
|
-
// apiRef imperative API.
|
|
3598
|
-
}, isDataSourceMode ? {
|
|
3599
|
-
onFilterModelChange: onFilterModelChange,
|
|
3600
|
-
onSortModelChange: onSortModelChange,
|
|
3601
|
-
onPaginationModelChange: wrappedOnPaginationModelChange,
|
|
3602
4262
|
initialState: _objectSpread2(_objectSpread2({}, initialState), {}, {
|
|
3603
|
-
density: controlledDensity,
|
|
3604
|
-
columns: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.columns), {}, {
|
|
3605
|
-
orderedFields: columnOrderModel,
|
|
3606
|
-
columnVisibilityModel
|
|
3607
|
-
}),
|
|
3608
|
-
pinnedColumns,
|
|
3609
|
-
rowGrouping: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.rowGrouping), {}, {
|
|
3610
|
-
model: rowGroupingModel
|
|
3611
|
-
}),
|
|
3612
|
-
aggregation: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.aggregation), {}, {
|
|
3613
|
-
model: aggregationModel
|
|
3614
|
-
}),
|
|
3615
|
-
filter: {
|
|
3616
|
-
filterModel
|
|
3617
|
-
},
|
|
3618
|
-
sorting: {
|
|
3619
|
-
sortModel
|
|
3620
|
-
},
|
|
3621
|
-
pagination: {
|
|
3622
|
-
paginationModel
|
|
3623
|
-
},
|
|
3624
|
-
pivoting: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.pivoting), {}, {
|
|
3625
|
-
model: pivotModel,
|
|
3626
|
-
enabled: pivotActive
|
|
3627
|
-
})
|
|
3628
|
-
})
|
|
3629
|
-
} : {
|
|
3630
|
-
columnVisibilityModel,
|
|
3631
|
-
pinnedColumns,
|
|
3632
|
-
rowGroupingModel,
|
|
3633
|
-
aggregationModel,
|
|
3634
|
-
filterModel,
|
|
3635
|
-
sortModel,
|
|
3636
|
-
paginationModel,
|
|
3637
|
-
pivotModel,
|
|
3638
|
-
onFilterModelChange: onFilterModelChange,
|
|
3639
|
-
onSortModelChange: onSortModelChange,
|
|
3640
|
-
onPaginationModelChange: wrappedOnPaginationModelChange,
|
|
3641
|
-
initialState: _objectSpread2(_objectSpread2({}, initialState), {}, {
|
|
3642
|
-
density: controlledDensity,
|
|
3643
4263
|
columns: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.columns), {}, {
|
|
3644
4264
|
orderedFields: columnOrderModel
|
|
3645
4265
|
})
|
|
3646
|
-
})
|
|
3647
|
-
}, {
|
|
4266
|
+
}),
|
|
3648
4267
|
isRowSelectable: isRowSelectable,
|
|
3649
4268
|
pagination: pagination,
|
|
3650
|
-
paginationMode:
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
keepNonExistentRowsSelected: effectivePaginationMode == 'server',
|
|
3654
|
-
rows: isDataSourceMode ? [] : rows,
|
|
4269
|
+
paginationMode: paginationMode,
|
|
4270
|
+
keepNonExistentRowsSelected: paginationMode == 'server',
|
|
4271
|
+
rows: rows,
|
|
3655
4272
|
rowCount: rowCount,
|
|
3656
4273
|
autoHeight: autoHeight,
|
|
3657
4274
|
checkboxSelectionVisibleOnly: checkboxSelectionVisibleOnly,
|
|
3658
|
-
disableRowSelectionExcludeModel: true,
|
|
3659
|
-
showToolbar: !hideToolbar,
|
|
3660
4275
|
slots: _objectSpread2(_objectSpread2({
|
|
3661
4276
|
baseButton: BaseButton,
|
|
3662
4277
|
baseCheckbox: BaseCheckbox,
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
4278
|
+
// baseTextField,
|
|
4279
|
+
basePopper: BasePopper,
|
|
4280
|
+
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4281
|
+
displayName: "ColumnFilteredIcon"
|
|
3666
4282
|
})),
|
|
3667
|
-
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3668
|
-
displayName: "
|
|
4283
|
+
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4284
|
+
displayName: "ColumnSelectorIcon"
|
|
3669
4285
|
})),
|
|
3670
|
-
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3671
|
-
displayName: "
|
|
4286
|
+
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4287
|
+
displayName: "ColumnSortedAscendingIcon"
|
|
3672
4288
|
})),
|
|
3673
|
-
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3674
|
-
displayName: "
|
|
4289
|
+
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4290
|
+
displayName: "ColumnSortedDescendingIcon"
|
|
3675
4291
|
})),
|
|
3676
|
-
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3677
|
-
displayName: "
|
|
4292
|
+
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4293
|
+
displayName: "DensityCompactIcon"
|
|
3678
4294
|
})),
|
|
3679
|
-
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3680
|
-
displayName: "
|
|
4295
|
+
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4296
|
+
displayName: "DensityStandardIcon"
|
|
3681
4297
|
})),
|
|
3682
|
-
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3683
|
-
displayName: "
|
|
4298
|
+
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4299
|
+
displayName: "DensityComfortableIcon"
|
|
3684
4300
|
})),
|
|
3685
|
-
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3686
|
-
displayName: "
|
|
4301
|
+
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4302
|
+
displayName: "DetailPanelCollapseIcon"
|
|
3687
4303
|
})),
|
|
3688
|
-
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3689
|
-
displayName: "
|
|
4304
|
+
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4305
|
+
displayName: "DetailPanelExpandIcon"
|
|
3690
4306
|
})),
|
|
3691
|
-
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3692
|
-
displayName: "
|
|
4307
|
+
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
4308
|
+
displayName: "ExportIcon"
|
|
3693
4309
|
})),
|
|
3694
|
-
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({
|
|
3695
|
-
displayName: "
|
|
3696
|
-
}))
|
|
4310
|
+
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({
|
|
4311
|
+
displayName: "OpenFilterButtonIcon"
|
|
4312
|
+
}, props))
|
|
3697
4313
|
}, slots), {}, {
|
|
4314
|
+
toolbar: ToolbarWrapper,
|
|
3698
4315
|
pagination: props => {
|
|
3699
|
-
return pagination ?
|
|
3700
|
-
displaySelection:
|
|
4316
|
+
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$2({}, props, {
|
|
4317
|
+
displaySelection: bannerAtBottom,
|
|
3701
4318
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3702
4319
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
3703
4320
|
selectionStatus: selectionStatus,
|
|
3704
|
-
paginationModel:
|
|
3705
|
-
|
|
3706
|
-
// state stays in sync with the displayed model and dataSource.getRows()
|
|
3707
|
-
// re-fetches with the new params. MUI then fires onPaginationModelChange
|
|
3708
|
-
// via the prop, which updates URL/localStorage via useStatefulTable.
|
|
3709
|
-
// Without this the bottom slot only updated local React state + URL,
|
|
3710
|
-
// leaving MUI on its previous internal page (no refetch, stale display).
|
|
3711
|
-
,
|
|
3712
|
-
onPaginationModelChange: isDataSourceMode ? dataSourcePaginationChange : wrappedOnPaginationModelChange,
|
|
4321
|
+
paginationModel: paginationModel,
|
|
4322
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3713
4323
|
pageSizeOptions: pageSizeOptions,
|
|
3714
4324
|
paginationProps: paginationProps,
|
|
4325
|
+
paginationMode: paginationMode,
|
|
3715
4326
|
rowCount: rowCount
|
|
3716
|
-
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends({}, props, {
|
|
3717
|
-
displaySelection:
|
|
4327
|
+
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends$2({}, props, {
|
|
4328
|
+
displaySelection: bannerAtBottom,
|
|
3718
4329
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3719
4330
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
3720
4331
|
selectionStatus: selectionStatus,
|
|
3721
4332
|
apiRef: apiRef,
|
|
3722
4333
|
isRowSelectable: isRowSelectable,
|
|
3723
|
-
paginationModel:
|
|
3724
|
-
onPaginationModelChange:
|
|
4334
|
+
paginationModel: paginationModel,
|
|
4335
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3725
4336
|
pageSizeOptions: pageSizeOptions,
|
|
3726
|
-
paginationProps: paginationProps
|
|
4337
|
+
paginationProps: paginationProps,
|
|
4338
|
+
paginationMode: paginationMode
|
|
3727
4339
|
})) : null;
|
|
3728
4340
|
}
|
|
3729
4341
|
}),
|
|
3730
|
-
slotProps: _objectSpread2({}, slotProps),
|
|
4342
|
+
slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
|
|
4343
|
+
toolbar: _objectSpread2({
|
|
4344
|
+
hideToolbar,
|
|
4345
|
+
RenderedToolbar,
|
|
4346
|
+
filterModel,
|
|
4347
|
+
onFilterModelChange,
|
|
4348
|
+
pagination,
|
|
4349
|
+
displaySelection: bannerAtTop || bannerBelowToolbar,
|
|
4350
|
+
displayPagination: ['top', 'both'].includes(paginationPlacement) || pagerBelowToolbar,
|
|
4351
|
+
displayRowsPerPage: pagerBelowToolbar,
|
|
4352
|
+
selectionStatus,
|
|
4353
|
+
apiRef,
|
|
4354
|
+
isRowSelectable,
|
|
4355
|
+
paginationModel,
|
|
4356
|
+
onPaginationModelChange,
|
|
4357
|
+
pageSizeOptions,
|
|
4358
|
+
paginationProps,
|
|
4359
|
+
paginationMode,
|
|
4360
|
+
rowCount
|
|
4361
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
|
|
4362
|
+
}),
|
|
3731
4363
|
rowSelectionModel: rowSelectionModel,
|
|
3732
4364
|
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
3733
|
-
if (pagination &&
|
|
3734
|
-
|
|
3735
|
-
// to avoid stale apiRef pagination state.
|
|
3736
|
-
const allFilteredEntries = gridFilteredSortedRowEntriesSelector(apiRef);
|
|
3737
|
-
const pageStart = activePaginationModel.page * activePaginationModel.pageSize;
|
|
3738
|
-
const pageEntries = allFilteredEntries.slice(pageStart, pageStart + activePaginationModel.pageSize);
|
|
3739
|
-
const selectableRowsInPage = isRowSelectable ? pageEntries.filter(_ref6 => {
|
|
4365
|
+
if (pagination && paginationMode != 'server') {
|
|
4366
|
+
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref5 => {
|
|
3740
4367
|
let {
|
|
3741
4368
|
model
|
|
3742
|
-
} =
|
|
4369
|
+
} = _ref5;
|
|
3743
4370
|
return isRowSelectable({
|
|
3744
4371
|
row: model
|
|
3745
4372
|
});
|
|
3746
|
-
}).map(
|
|
4373
|
+
}).map(_ref6 => {
|
|
3747
4374
|
let {
|
|
3748
4375
|
id
|
|
3749
|
-
} =
|
|
3750
|
-
return id;
|
|
3751
|
-
}) : pageEntries.map(_ref8 => {
|
|
3752
|
-
let {
|
|
3753
|
-
id
|
|
3754
|
-
} = _ref8;
|
|
4376
|
+
} = _ref6;
|
|
3755
4377
|
return id;
|
|
3756
|
-
});
|
|
4378
|
+
}) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
|
|
3757
4379
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3758
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
4380
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref7 => {
|
|
3759
4381
|
let {
|
|
3760
4382
|
model
|
|
3761
|
-
} =
|
|
4383
|
+
} = _ref7;
|
|
3762
4384
|
return isRowSelectable({
|
|
3763
4385
|
row: model
|
|
3764
4386
|
});
|
|
3765
|
-
}).map(
|
|
4387
|
+
}).map(_ref8 => {
|
|
3766
4388
|
let {
|
|
3767
4389
|
id
|
|
3768
|
-
} =
|
|
4390
|
+
} = _ref8;
|
|
3769
4391
|
return id;
|
|
3770
4392
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3771
4393
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3772
|
-
const numberOfSelectedRows =
|
|
4394
|
+
const numberOfSelectedRows = newSelectionModel.length;
|
|
3773
4395
|
if (selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable - numberOfSelectableRowsInPage || selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable || selectionStatusRef.current.type === 'page' && numberOfSelectedRows === numberOfSelectableRowsInPage) {
|
|
3774
4396
|
setTimeout(() => {
|
|
3775
|
-
|
|
3776
|
-
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.selectRows([], true, true);
|
|
4397
|
+
apiRef.current.selectRows([], true, true);
|
|
3777
4398
|
}, 0);
|
|
3778
4399
|
}
|
|
3779
4400
|
if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
@@ -3797,7 +4418,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3797
4418
|
numberOfSelectedRows
|
|
3798
4419
|
};
|
|
3799
4420
|
}
|
|
3800
|
-
forceSelectionUpdate(v => v + 1);
|
|
3801
4421
|
}
|
|
3802
4422
|
onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
|
|
3803
4423
|
},
|
|
@@ -3815,5 +4435,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3815
4435
|
StatefulDataGrid.className = CLASSNAME;
|
|
3816
4436
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
3817
4437
|
|
|
3818
|
-
export {
|
|
4438
|
+
export { clearAllVersionStorage as $, ARRAY_IS_EMPTY as A, Box$1 as B, CONTAINS_ANY_OF as C, DOES_NOT_CONTAIN as D, ENDS_WITH_ANY_OF as E, IS as F, IS_NOT as G, HAS_WITH_SELECT as H, IS_ANY_OF as I, getGridStringOperators as J, getGridStringArrayOperators as K, getGridStringArrayOperatorsWithSelect as L, getGridStringArrayOperatorsWithSelectOnStringArrayColumns as M, FILTER_MODEL_KEY as N, SORT_MODEL_KEY as O, PAGINATION_MODEL_KEY as P, PINNED_COLUMNS as Q, DIMENSION_MODEL_KEY as R, STARTS_WITH_ANY_OF as S, TextField$1 as T, FILTER_SEARCH_KEY as U, VISIBILITY_MODEL_KEY as V, DENSITY_MODEL_KEY as W, COLUMN_ORDER_MODEL_KEY as X, CATEGORIES as Y, buildStorageKey as Z, clearPreviousVersionStorage as _, DOES_NOT_EQUAL as a, resetStatefulDataGridState as a0, resetColumnVisibility as a1, convertToDisplayFormat as a2, convertFromDisplayFormat as a3, getDecodedSearchFromUrl as a4, buildQueryParamsString as a5, areSearchStringsEqual as a6, decodeValue as a7, encodeValue as a8, urlSearchParamsToString as a9, numberOperatorEncoder as aa, numberOperatorDecoder as ab, isOperatorValueValid as ac, isValueValid as ad, getFilterModelFromString as ae, getSearchParamsFromFilterModel as af, getSortingFromString as ag, getSearchParamsFromSorting as ah, getPaginationFromString as ai, getSearchParamsFromPagination as aj, getColumnVisibilityFromString as ak, getSearchParamsFromColumnVisibility as al, getPinnedColumnsFromString as am, getSearchParamsFromPinnedColumns as an, getSearchParamsFromTab as ao, getDensityFromString as ap, getSearchParamsFromDensity as aq, getColumnOrderFromString as ar, getSearchParamsFromColumnOrder as as, getSearchParamsFromVersion as at, getFinalSearch as au, getModelsParsedOrUpdateLocalStorage as av, updateUrl as aw, areFilterModelsEquivalent as ax, StatefulDataGrid as ay, DOES_NOT_START_WITH as b, DOES_NOT_END_WITH as c, IS_NOT_ANY_OF as d, DOES_NOT_CONTAIN_ANY_OF as e, DOES_NOT_START_WITH_ANY_OF as f, DOES_NOT_END_WITH_ANY_OF as g, IS_BETWEEN as h, IS_WITH_SELECT as i, IS_NOT_WITH_SELECT as j, IS_ANY_OF_WITH_SELECT as k, IS_NOT_ANY_OF_WITH_SELECT as l, ARRAY_IS_NOT_EMPTY as m, DOES_NOT_HAVE_WITH_SELECT as n, operatorList as o, HAS_ANY_OF_WITH_SELECT as p, HAS_ALL_OF_WITH_SELECT as q, DOES_NOT_HAVE_ANY_OF_WITH_SELECT as r, HAS_ONLY_WITH_SELECT as s, HAS as t, DOES_NOT_HAVE as u, HAS_ANY_OF as v, HAS_ALL_OF as w, DOES_NOT_HAVE_ANY_OF as x, HAS_ONLY as y, getGridNumericOperators as z };
|
|
3819
4439
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|