@redsift/table 12.5.5-alpha.2 → 12.5.5-muiv7
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 +2453 -0
- package/_internal/BasePopper.js.map +1 -0
- package/_internal/ControlledPagination.js +11977 -0
- package/_internal/ControlledPagination.js.map +1 -0
- package/_internal/DataGrid2.js +74 -95
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/GridToolbarFilterSemanticField2.js +2 -1339
- package/_internal/GridToolbarFilterSemanticField2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/Portal.js +6563 -0
- package/_internal/Portal.js.map +1 -0
- package/_internal/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +1818 -876
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/Toolbar2.js +1 -1
- 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 +1125 -6
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +310 -489
- package/index.js +143 -153
- 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,1501 @@
|
|
|
1
1
|
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useCallback, useEffect, useRef, useMemo, forwardRef, useState } from 'react';
|
|
4
|
-
import { createTheme, ThemeProvider as ThemeProvider$1 } from '@mui/material/styles';
|
|
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, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite, ThemeProvider } from '@redsift/design-system';
|
|
6
|
+
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef, 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 { d as defaultSxConfig, i as isPlainObject, s as styled, a as styleFunctionSx, c as clsx, g as generateUtilityClasses, b as createTheme, T as THEME_ID, C as ClassNameGenerator, P as PropTypes, e as generateUtilityClass, f as styled$1, u as useDefaultProps, h as composeClasses, r as rootShouldForwardProp, j as refType } from './Portal.js';
|
|
10
|
+
import { j as jsxRuntimeExports } from './jsx-runtime.js';
|
|
11
|
+
import { u as useTheme, m as memoTheme, c as createSimplePaletteValueFilter, a as useFormControl, b as formControlState, d as capitalize, i as isAdornedStart, e as isFilled, F as FormControlContext, h as useId, j as useSlot, k as Select, I as Input, l as FilledInput, O as OutlinedInput, o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination } from './ControlledPagination.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
|
+
const splitProps = props => {
|
|
18
|
+
const result = {
|
|
19
|
+
systemProps: {},
|
|
20
|
+
otherProps: {}
|
|
21
|
+
};
|
|
22
|
+
const config = props?.theme?.unstable_sxConfig ?? defaultSxConfig;
|
|
23
|
+
Object.keys(props).forEach(prop => {
|
|
24
|
+
if (config[prop]) {
|
|
25
|
+
result.systemProps[prop] = props[prop];
|
|
26
|
+
} else {
|
|
27
|
+
result.otherProps[prop] = props[prop];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
function extendSxProp(props) {
|
|
33
|
+
const {
|
|
34
|
+
sx: inSx,
|
|
35
|
+
...other
|
|
36
|
+
} = props;
|
|
37
|
+
const {
|
|
38
|
+
systemProps,
|
|
39
|
+
otherProps
|
|
40
|
+
} = splitProps(other);
|
|
41
|
+
let finalSx;
|
|
42
|
+
if (Array.isArray(inSx)) {
|
|
43
|
+
finalSx = [systemProps, ...inSx];
|
|
44
|
+
} else if (typeof inSx === 'function') {
|
|
45
|
+
finalSx = (...args) => {
|
|
46
|
+
const result = inSx(...args);
|
|
47
|
+
if (!isPlainObject(result)) {
|
|
48
|
+
return systemProps;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...systemProps,
|
|
52
|
+
...result
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
finalSx = {
|
|
57
|
+
...systemProps,
|
|
58
|
+
...inSx
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...otherProps,
|
|
63
|
+
sx: finalSx
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function createBox(options = {}) {
|
|
68
|
+
const {
|
|
69
|
+
themeId,
|
|
70
|
+
defaultTheme,
|
|
71
|
+
defaultClassName = 'MuiBox-root',
|
|
72
|
+
generateClassName
|
|
73
|
+
} = options;
|
|
74
|
+
const BoxRoot = styled('div', {
|
|
75
|
+
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
|
76
|
+
})(styleFunctionSx);
|
|
77
|
+
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
78
|
+
const theme = useTheme(defaultTheme);
|
|
79
|
+
const {
|
|
80
|
+
className,
|
|
81
|
+
component = 'div',
|
|
82
|
+
...other
|
|
83
|
+
} = extendSxProp(inProps);
|
|
84
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BoxRoot, {
|
|
85
|
+
as: component,
|
|
86
|
+
ref: ref,
|
|
87
|
+
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
88
|
+
theme: themeId ? theme[themeId] || theme : theme,
|
|
89
|
+
...other
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return Box;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isMuiElement(element, muiNames) {
|
|
96
|
+
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(
|
|
97
|
+
// For server components `muiName` is avaialble in element.type._payload.value.muiName
|
|
98
|
+
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
|
|
99
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
100
|
+
element.type.muiName ?? element.type?._payload?.value?.muiName) !== -1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const boxClasses = generateUtilityClasses('MuiBox', ['root']);
|
|
104
|
+
var boxClasses$1 = boxClasses;
|
|
105
|
+
|
|
106
|
+
const defaultTheme = createTheme();
|
|
107
|
+
const Box = createBox({
|
|
108
|
+
themeId: THEME_ID,
|
|
109
|
+
defaultTheme,
|
|
110
|
+
defaultClassName: boxClasses$1.root,
|
|
111
|
+
generateClassName: ClassNameGenerator.generate
|
|
112
|
+
});
|
|
113
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
|
114
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
115
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
116
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
117
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
118
|
+
/**
|
|
119
|
+
* @ignore
|
|
120
|
+
*/
|
|
121
|
+
children: PropTypes.node,
|
|
122
|
+
/**
|
|
123
|
+
* The component used for the root node.
|
|
124
|
+
* Either a string to use a HTML element or a component.
|
|
125
|
+
*/
|
|
126
|
+
component: PropTypes.elementType,
|
|
127
|
+
/**
|
|
128
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
129
|
+
*/
|
|
130
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
131
|
+
} : void 0;
|
|
132
|
+
var Box$1 = Box;
|
|
133
|
+
|
|
134
|
+
function getFormLabelUtilityClasses(slot) {
|
|
135
|
+
return generateUtilityClass('MuiFormLabel', slot);
|
|
136
|
+
}
|
|
137
|
+
const formLabelClasses = generateUtilityClasses('MuiFormLabel', ['root', 'colorSecondary', 'focused', 'disabled', 'error', 'filled', 'required', 'asterisk']);
|
|
138
|
+
var formLabelClasses$1 = formLabelClasses;
|
|
139
|
+
|
|
140
|
+
const useUtilityClasses$4 = ownerState => {
|
|
141
|
+
const {
|
|
142
|
+
classes,
|
|
143
|
+
color,
|
|
144
|
+
focused,
|
|
145
|
+
disabled,
|
|
146
|
+
error,
|
|
147
|
+
filled,
|
|
148
|
+
required
|
|
149
|
+
} = ownerState;
|
|
150
|
+
const slots = {
|
|
151
|
+
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', filled && 'filled', focused && 'focused', required && 'required'],
|
|
152
|
+
asterisk: ['asterisk', error && 'error']
|
|
153
|
+
};
|
|
154
|
+
return composeClasses(slots, getFormLabelUtilityClasses, classes);
|
|
155
|
+
};
|
|
156
|
+
const FormLabelRoot = styled$1('label', {
|
|
157
|
+
name: 'MuiFormLabel',
|
|
158
|
+
slot: 'Root',
|
|
159
|
+
overridesResolver: (props, styles) => {
|
|
160
|
+
const {
|
|
161
|
+
ownerState
|
|
162
|
+
} = props;
|
|
163
|
+
return [styles.root, ownerState.color === 'secondary' && styles.colorSecondary, ownerState.filled && styles.filled];
|
|
164
|
+
}
|
|
165
|
+
})(memoTheme(({
|
|
166
|
+
theme
|
|
167
|
+
}) => ({
|
|
168
|
+
color: (theme.vars || theme).palette.text.secondary,
|
|
169
|
+
...theme.typography.body1,
|
|
170
|
+
lineHeight: '1.4375em',
|
|
171
|
+
padding: 0,
|
|
172
|
+
position: 'relative',
|
|
173
|
+
variants: [...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
|
|
174
|
+
props: {
|
|
175
|
+
color
|
|
176
|
+
},
|
|
177
|
+
style: {
|
|
178
|
+
[`&.${formLabelClasses$1.focused}`]: {
|
|
179
|
+
color: (theme.vars || theme).palette[color].main
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
})), {
|
|
183
|
+
props: {},
|
|
184
|
+
style: {
|
|
185
|
+
[`&.${formLabelClasses$1.disabled}`]: {
|
|
186
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
187
|
+
},
|
|
188
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
189
|
+
color: (theme.vars || theme).palette.error.main
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}]
|
|
193
|
+
})));
|
|
194
|
+
const AsteriskComponent = styled$1('span', {
|
|
195
|
+
name: 'MuiFormLabel',
|
|
196
|
+
slot: 'Asterisk',
|
|
197
|
+
overridesResolver: (props, styles) => styles.asterisk
|
|
198
|
+
})(memoTheme(({
|
|
199
|
+
theme
|
|
200
|
+
}) => ({
|
|
201
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
202
|
+
color: (theme.vars || theme).palette.error.main
|
|
203
|
+
}
|
|
204
|
+
})));
|
|
205
|
+
const FormLabel = /*#__PURE__*/React.forwardRef(function FormLabel(inProps, ref) {
|
|
206
|
+
const props = useDefaultProps({
|
|
207
|
+
props: inProps,
|
|
208
|
+
name: 'MuiFormLabel'
|
|
209
|
+
});
|
|
210
|
+
const {
|
|
211
|
+
children,
|
|
212
|
+
className,
|
|
213
|
+
color,
|
|
214
|
+
component = 'label',
|
|
215
|
+
disabled,
|
|
216
|
+
error,
|
|
217
|
+
filled,
|
|
218
|
+
focused,
|
|
219
|
+
required,
|
|
220
|
+
...other
|
|
221
|
+
} = props;
|
|
222
|
+
const muiFormControl = useFormControl();
|
|
223
|
+
const fcs = formControlState({
|
|
224
|
+
props,
|
|
225
|
+
muiFormControl,
|
|
226
|
+
states: ['color', 'required', 'focused', 'disabled', 'error', 'filled']
|
|
227
|
+
});
|
|
228
|
+
const ownerState = {
|
|
229
|
+
...props,
|
|
230
|
+
color: fcs.color || 'primary',
|
|
231
|
+
component,
|
|
232
|
+
disabled: fcs.disabled,
|
|
233
|
+
error: fcs.error,
|
|
234
|
+
filled: fcs.filled,
|
|
235
|
+
focused: fcs.focused,
|
|
236
|
+
required: fcs.required
|
|
237
|
+
};
|
|
238
|
+
const classes = useUtilityClasses$4(ownerState);
|
|
239
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(FormLabelRoot, {
|
|
240
|
+
as: component,
|
|
241
|
+
ownerState: ownerState,
|
|
242
|
+
className: clsx(classes.root, className),
|
|
243
|
+
ref: ref,
|
|
244
|
+
...other,
|
|
245
|
+
children: [children, fcs.required && /*#__PURE__*/jsxRuntimeExports.jsxs(AsteriskComponent, {
|
|
246
|
+
ownerState: ownerState,
|
|
247
|
+
"aria-hidden": true,
|
|
248
|
+
className: classes.asterisk,
|
|
249
|
+
children: ["\u2009", '*']
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
process.env.NODE_ENV !== "production" ? FormLabel.propTypes /* remove-proptypes */ = {
|
|
254
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
255
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
256
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
257
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
258
|
+
/**
|
|
259
|
+
* The content of the component.
|
|
260
|
+
*/
|
|
261
|
+
children: PropTypes.node,
|
|
262
|
+
/**
|
|
263
|
+
* Override or extend the styles applied to the component.
|
|
264
|
+
*/
|
|
265
|
+
classes: PropTypes.object,
|
|
266
|
+
/**
|
|
267
|
+
* @ignore
|
|
268
|
+
*/
|
|
269
|
+
className: PropTypes.string,
|
|
270
|
+
/**
|
|
271
|
+
* The color of the component.
|
|
272
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
273
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
274
|
+
*/
|
|
275
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
276
|
+
/**
|
|
277
|
+
* The component used for the root node.
|
|
278
|
+
* Either a string to use a HTML element or a component.
|
|
279
|
+
*/
|
|
280
|
+
component: PropTypes.elementType,
|
|
281
|
+
/**
|
|
282
|
+
* If `true`, the label should be displayed in a disabled state.
|
|
283
|
+
*/
|
|
284
|
+
disabled: PropTypes.bool,
|
|
285
|
+
/**
|
|
286
|
+
* If `true`, the label is displayed in an error state.
|
|
287
|
+
*/
|
|
288
|
+
error: PropTypes.bool,
|
|
289
|
+
/**
|
|
290
|
+
* If `true`, the label should use filled classes key.
|
|
291
|
+
*/
|
|
292
|
+
filled: PropTypes.bool,
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, the input of this label is focused (used by `FormGroup` components).
|
|
295
|
+
*/
|
|
296
|
+
focused: PropTypes.bool,
|
|
297
|
+
/**
|
|
298
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
299
|
+
*/
|
|
300
|
+
required: PropTypes.bool,
|
|
301
|
+
/**
|
|
302
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
303
|
+
*/
|
|
304
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
305
|
+
} : void 0;
|
|
306
|
+
var FormLabel$1 = FormLabel;
|
|
307
|
+
|
|
308
|
+
function getInputLabelUtilityClasses(slot) {
|
|
309
|
+
return generateUtilityClass('MuiInputLabel', slot);
|
|
310
|
+
}
|
|
311
|
+
generateUtilityClasses('MuiInputLabel', ['root', 'focused', 'disabled', 'error', 'required', 'asterisk', 'formControl', 'sizeSmall', 'shrink', 'animated', 'standard', 'filled', 'outlined']);
|
|
312
|
+
|
|
313
|
+
const useUtilityClasses$3 = ownerState => {
|
|
314
|
+
const {
|
|
315
|
+
classes,
|
|
316
|
+
formControl,
|
|
317
|
+
size,
|
|
318
|
+
shrink,
|
|
319
|
+
disableAnimation,
|
|
320
|
+
variant,
|
|
321
|
+
required
|
|
322
|
+
} = ownerState;
|
|
323
|
+
const slots = {
|
|
324
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== 'normal' && `size${capitalize(size)}`, variant],
|
|
325
|
+
asterisk: [required && 'asterisk']
|
|
326
|
+
};
|
|
327
|
+
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
328
|
+
return {
|
|
329
|
+
...classes,
|
|
330
|
+
// forward the focused, disabled, etc. classes to the FormLabel
|
|
331
|
+
...composedClasses
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
const InputLabelRoot = styled$1(FormLabel$1, {
|
|
335
|
+
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
|
336
|
+
name: 'MuiInputLabel',
|
|
337
|
+
slot: 'Root',
|
|
338
|
+
overridesResolver: (props, styles) => {
|
|
339
|
+
const {
|
|
340
|
+
ownerState
|
|
341
|
+
} = props;
|
|
342
|
+
return [{
|
|
343
|
+
[`& .${formLabelClasses$1.asterisk}`]: styles.asterisk
|
|
344
|
+
}, 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]];
|
|
345
|
+
}
|
|
346
|
+
})(memoTheme(({
|
|
347
|
+
theme
|
|
348
|
+
}) => ({
|
|
349
|
+
display: 'block',
|
|
350
|
+
transformOrigin: 'top left',
|
|
351
|
+
whiteSpace: 'nowrap',
|
|
352
|
+
overflow: 'hidden',
|
|
353
|
+
textOverflow: 'ellipsis',
|
|
354
|
+
maxWidth: '100%',
|
|
355
|
+
variants: [{
|
|
356
|
+
props: ({
|
|
357
|
+
ownerState
|
|
358
|
+
}) => ownerState.formControl,
|
|
359
|
+
style: {
|
|
360
|
+
position: 'absolute',
|
|
361
|
+
left: 0,
|
|
362
|
+
top: 0,
|
|
363
|
+
// slight alteration to spec spacing to match visual spec result
|
|
364
|
+
transform: 'translate(0, 20px) scale(1)'
|
|
365
|
+
}
|
|
366
|
+
}, {
|
|
367
|
+
props: {
|
|
368
|
+
size: 'small'
|
|
369
|
+
},
|
|
370
|
+
style: {
|
|
371
|
+
// Compensation for the `Input.inputSizeSmall` style.
|
|
372
|
+
transform: 'translate(0, 17px) scale(1)'
|
|
373
|
+
}
|
|
374
|
+
}, {
|
|
375
|
+
props: ({
|
|
376
|
+
ownerState
|
|
377
|
+
}) => ownerState.shrink,
|
|
378
|
+
style: {
|
|
379
|
+
transform: 'translate(0, -1.5px) scale(0.75)',
|
|
380
|
+
transformOrigin: 'top left',
|
|
381
|
+
maxWidth: '133%'
|
|
382
|
+
}
|
|
383
|
+
}, {
|
|
384
|
+
props: ({
|
|
385
|
+
ownerState
|
|
386
|
+
}) => !ownerState.disableAnimation,
|
|
387
|
+
style: {
|
|
388
|
+
transition: theme.transitions.create(['color', 'transform', 'max-width'], {
|
|
389
|
+
duration: theme.transitions.duration.shorter,
|
|
390
|
+
easing: theme.transitions.easing.easeOut
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
props: {
|
|
395
|
+
variant: 'filled'
|
|
396
|
+
},
|
|
397
|
+
style: {
|
|
398
|
+
// Chrome's autofill feature gives the input field a yellow background.
|
|
399
|
+
// Since the input field is behind the label in the HTML tree,
|
|
400
|
+
// the input field is drawn last and hides the label with an opaque background color.
|
|
401
|
+
// zIndex: 1 will raise the label above opaque background-colors of input.
|
|
402
|
+
zIndex: 1,
|
|
403
|
+
pointerEvents: 'none',
|
|
404
|
+
transform: 'translate(12px, 16px) scale(1)',
|
|
405
|
+
maxWidth: 'calc(100% - 24px)'
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
props: {
|
|
409
|
+
variant: 'filled',
|
|
410
|
+
size: 'small'
|
|
411
|
+
},
|
|
412
|
+
style: {
|
|
413
|
+
transform: 'translate(12px, 13px) scale(1)'
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
props: ({
|
|
417
|
+
variant,
|
|
418
|
+
ownerState
|
|
419
|
+
}) => variant === 'filled' && ownerState.shrink,
|
|
420
|
+
style: {
|
|
421
|
+
userSelect: 'none',
|
|
422
|
+
pointerEvents: 'auto',
|
|
423
|
+
transform: 'translate(12px, 7px) scale(0.75)',
|
|
424
|
+
maxWidth: 'calc(133% - 24px)'
|
|
425
|
+
}
|
|
426
|
+
}, {
|
|
427
|
+
props: ({
|
|
428
|
+
variant,
|
|
429
|
+
ownerState,
|
|
430
|
+
size
|
|
431
|
+
}) => variant === 'filled' && ownerState.shrink && size === 'small',
|
|
432
|
+
style: {
|
|
433
|
+
transform: 'translate(12px, 4px) scale(0.75)'
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
props: {
|
|
437
|
+
variant: 'outlined'
|
|
438
|
+
},
|
|
439
|
+
style: {
|
|
440
|
+
// see comment above on filled.zIndex
|
|
441
|
+
zIndex: 1,
|
|
442
|
+
pointerEvents: 'none',
|
|
443
|
+
transform: 'translate(14px, 16px) scale(1)',
|
|
444
|
+
maxWidth: 'calc(100% - 24px)'
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
props: {
|
|
448
|
+
variant: 'outlined',
|
|
449
|
+
size: 'small'
|
|
450
|
+
},
|
|
451
|
+
style: {
|
|
452
|
+
transform: 'translate(14px, 9px) scale(1)'
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
props: ({
|
|
456
|
+
variant,
|
|
457
|
+
ownerState
|
|
458
|
+
}) => variant === 'outlined' && ownerState.shrink,
|
|
459
|
+
style: {
|
|
460
|
+
userSelect: 'none',
|
|
461
|
+
pointerEvents: 'auto',
|
|
462
|
+
// Theoretically, we should have (8+5)*2/0.75 = 34px
|
|
463
|
+
// but it feels a better when it bleeds a bit on the left, so 32px.
|
|
464
|
+
maxWidth: 'calc(133% - 32px)',
|
|
465
|
+
transform: 'translate(14px, -9px) scale(0.75)'
|
|
466
|
+
}
|
|
467
|
+
}]
|
|
468
|
+
})));
|
|
469
|
+
const InputLabel = /*#__PURE__*/React.forwardRef(function InputLabel(inProps, ref) {
|
|
470
|
+
const props = useDefaultProps({
|
|
471
|
+
name: 'MuiInputLabel',
|
|
472
|
+
props: inProps
|
|
473
|
+
});
|
|
474
|
+
const {
|
|
475
|
+
disableAnimation = false,
|
|
476
|
+
margin,
|
|
477
|
+
shrink: shrinkProp,
|
|
478
|
+
variant,
|
|
479
|
+
className,
|
|
480
|
+
...other
|
|
481
|
+
} = props;
|
|
482
|
+
const muiFormControl = useFormControl();
|
|
483
|
+
let shrink = shrinkProp;
|
|
484
|
+
if (typeof shrink === 'undefined' && muiFormControl) {
|
|
485
|
+
shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
|
486
|
+
}
|
|
487
|
+
const fcs = formControlState({
|
|
488
|
+
props,
|
|
489
|
+
muiFormControl,
|
|
490
|
+
states: ['size', 'variant', 'required', 'focused']
|
|
491
|
+
});
|
|
492
|
+
const ownerState = {
|
|
493
|
+
...props,
|
|
494
|
+
disableAnimation,
|
|
495
|
+
formControl: muiFormControl,
|
|
496
|
+
shrink,
|
|
497
|
+
size: fcs.size,
|
|
498
|
+
variant: fcs.variant,
|
|
499
|
+
required: fcs.required,
|
|
500
|
+
focused: fcs.focused
|
|
501
|
+
};
|
|
502
|
+
const classes = useUtilityClasses$3(ownerState);
|
|
503
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(InputLabelRoot, {
|
|
504
|
+
"data-shrink": shrink,
|
|
505
|
+
ref: ref,
|
|
506
|
+
className: clsx(classes.root, className),
|
|
507
|
+
...other,
|
|
508
|
+
ownerState: ownerState,
|
|
509
|
+
classes: classes
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes */ = {
|
|
513
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
514
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
515
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
516
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
517
|
+
/**
|
|
518
|
+
* The content of the component.
|
|
519
|
+
*/
|
|
520
|
+
children: PropTypes.node,
|
|
521
|
+
/**
|
|
522
|
+
* Override or extend the styles applied to the component.
|
|
523
|
+
*/
|
|
524
|
+
classes: PropTypes.object,
|
|
525
|
+
/**
|
|
526
|
+
* @ignore
|
|
527
|
+
*/
|
|
528
|
+
className: PropTypes.string,
|
|
529
|
+
/**
|
|
530
|
+
* The color of the component.
|
|
531
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
532
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
533
|
+
*/
|
|
534
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
535
|
+
/**
|
|
536
|
+
* If `true`, the transition animation is disabled.
|
|
537
|
+
* @default false
|
|
538
|
+
*/
|
|
539
|
+
disableAnimation: PropTypes.bool,
|
|
540
|
+
/**
|
|
541
|
+
* If `true`, the component is disabled.
|
|
542
|
+
*/
|
|
543
|
+
disabled: PropTypes.bool,
|
|
544
|
+
/**
|
|
545
|
+
* If `true`, the label is displayed in an error state.
|
|
546
|
+
*/
|
|
547
|
+
error: PropTypes.bool,
|
|
548
|
+
/**
|
|
549
|
+
* If `true`, the `input` of this label is focused.
|
|
550
|
+
*/
|
|
551
|
+
focused: PropTypes.bool,
|
|
552
|
+
/**
|
|
553
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
554
|
+
* FormControl.
|
|
555
|
+
*/
|
|
556
|
+
margin: PropTypes.oneOf(['dense']),
|
|
557
|
+
/**
|
|
558
|
+
* if `true`, the label will indicate that the `input` is required.
|
|
559
|
+
*/
|
|
560
|
+
required: PropTypes.bool,
|
|
561
|
+
/**
|
|
562
|
+
* If `true`, the label is shrunk.
|
|
563
|
+
*/
|
|
564
|
+
shrink: PropTypes.bool,
|
|
565
|
+
/**
|
|
566
|
+
* The size of the component.
|
|
567
|
+
* @default 'normal'
|
|
568
|
+
*/
|
|
569
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['normal', 'small']), PropTypes.string]),
|
|
570
|
+
/**
|
|
571
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
572
|
+
*/
|
|
573
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
574
|
+
/**
|
|
575
|
+
* The variant to use.
|
|
576
|
+
*/
|
|
577
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
578
|
+
} : void 0;
|
|
579
|
+
var InputLabel$1 = InputLabel;
|
|
580
|
+
|
|
581
|
+
function getFormControlUtilityClasses(slot) {
|
|
582
|
+
return generateUtilityClass('MuiFormControl', slot);
|
|
583
|
+
}
|
|
584
|
+
generateUtilityClasses('MuiFormControl', ['root', 'marginNone', 'marginNormal', 'marginDense', 'fullWidth', 'disabled']);
|
|
585
|
+
|
|
586
|
+
const useUtilityClasses$2 = ownerState => {
|
|
587
|
+
const {
|
|
588
|
+
classes,
|
|
589
|
+
margin,
|
|
590
|
+
fullWidth
|
|
591
|
+
} = ownerState;
|
|
592
|
+
const slots = {
|
|
593
|
+
root: ['root', margin !== 'none' && `margin${capitalize(margin)}`, fullWidth && 'fullWidth']
|
|
594
|
+
};
|
|
595
|
+
return composeClasses(slots, getFormControlUtilityClasses, classes);
|
|
596
|
+
};
|
|
597
|
+
const FormControlRoot = styled$1('div', {
|
|
598
|
+
name: 'MuiFormControl',
|
|
599
|
+
slot: 'Root',
|
|
600
|
+
overridesResolver: (props, styles) => {
|
|
601
|
+
const {
|
|
602
|
+
ownerState
|
|
603
|
+
} = props;
|
|
604
|
+
return [styles.root, styles[`margin${capitalize(ownerState.margin)}`], ownerState.fullWidth && styles.fullWidth];
|
|
605
|
+
}
|
|
606
|
+
})({
|
|
607
|
+
display: 'inline-flex',
|
|
608
|
+
flexDirection: 'column',
|
|
609
|
+
position: 'relative',
|
|
610
|
+
// Reset fieldset default style.
|
|
611
|
+
minWidth: 0,
|
|
612
|
+
padding: 0,
|
|
613
|
+
margin: 0,
|
|
614
|
+
border: 0,
|
|
615
|
+
verticalAlign: 'top',
|
|
616
|
+
// Fix alignment issue on Safari.
|
|
617
|
+
variants: [{
|
|
618
|
+
props: {
|
|
619
|
+
margin: 'normal'
|
|
620
|
+
},
|
|
621
|
+
style: {
|
|
622
|
+
marginTop: 16,
|
|
623
|
+
marginBottom: 8
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
props: {
|
|
627
|
+
margin: 'dense'
|
|
628
|
+
},
|
|
629
|
+
style: {
|
|
630
|
+
marginTop: 8,
|
|
631
|
+
marginBottom: 4
|
|
632
|
+
}
|
|
633
|
+
}, {
|
|
634
|
+
props: {
|
|
635
|
+
fullWidth: true
|
|
636
|
+
},
|
|
637
|
+
style: {
|
|
638
|
+
width: '100%'
|
|
639
|
+
}
|
|
640
|
+
}]
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Provides context such as filled/focused/error/required for form inputs.
|
|
645
|
+
* Relying on the context provides high flexibility and ensures that the state always stays
|
|
646
|
+
* consistent across the children of the `FormControl`.
|
|
647
|
+
* This context is used by the following components:
|
|
648
|
+
*
|
|
649
|
+
* - FormLabel
|
|
650
|
+
* - FormHelperText
|
|
651
|
+
* - Input
|
|
652
|
+
* - InputLabel
|
|
653
|
+
*
|
|
654
|
+
* You can find one composition example below and more going to [the demos](/material-ui/react-text-field/#components).
|
|
655
|
+
*
|
|
656
|
+
* ```jsx
|
|
657
|
+
* <FormControl>
|
|
658
|
+
* <InputLabel htmlFor="my-input">Email address</InputLabel>
|
|
659
|
+
* <Input id="my-input" aria-describedby="my-helper-text" />
|
|
660
|
+
* <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
|
661
|
+
* </FormControl>
|
|
662
|
+
* ```
|
|
663
|
+
*
|
|
664
|
+
* ⚠️ Only one `InputBase` can be used within a FormControl because it creates visual inconsistencies.
|
|
665
|
+
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
|
666
|
+
*/
|
|
667
|
+
const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps, ref) {
|
|
668
|
+
const props = useDefaultProps({
|
|
669
|
+
props: inProps,
|
|
670
|
+
name: 'MuiFormControl'
|
|
671
|
+
});
|
|
672
|
+
const {
|
|
673
|
+
children,
|
|
674
|
+
className,
|
|
675
|
+
color = 'primary',
|
|
676
|
+
component = 'div',
|
|
677
|
+
disabled = false,
|
|
678
|
+
error = false,
|
|
679
|
+
focused: visuallyFocused,
|
|
680
|
+
fullWidth = false,
|
|
681
|
+
hiddenLabel = false,
|
|
682
|
+
margin = 'none',
|
|
683
|
+
required = false,
|
|
684
|
+
size = 'medium',
|
|
685
|
+
variant = 'outlined',
|
|
686
|
+
...other
|
|
687
|
+
} = props;
|
|
688
|
+
const ownerState = {
|
|
689
|
+
...props,
|
|
690
|
+
color,
|
|
691
|
+
component,
|
|
692
|
+
disabled,
|
|
693
|
+
error,
|
|
694
|
+
fullWidth,
|
|
695
|
+
hiddenLabel,
|
|
696
|
+
margin,
|
|
697
|
+
required,
|
|
698
|
+
size,
|
|
699
|
+
variant
|
|
700
|
+
};
|
|
701
|
+
const classes = useUtilityClasses$2(ownerState);
|
|
702
|
+
const [adornedStart, setAdornedStart] = React.useState(() => {
|
|
703
|
+
// We need to iterate through the children and find the Input in order
|
|
704
|
+
// to fully support server-side rendering.
|
|
705
|
+
let initialAdornedStart = false;
|
|
706
|
+
if (children) {
|
|
707
|
+
React.Children.forEach(children, child => {
|
|
708
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const input = isMuiElement(child, ['Select']) ? child.props.input : child;
|
|
712
|
+
if (input && isAdornedStart(input.props)) {
|
|
713
|
+
initialAdornedStart = true;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return initialAdornedStart;
|
|
718
|
+
});
|
|
719
|
+
const [filled, setFilled] = React.useState(() => {
|
|
720
|
+
// We need to iterate through the children and find the Input in order
|
|
721
|
+
// to fully support server-side rendering.
|
|
722
|
+
let initialFilled = false;
|
|
723
|
+
if (children) {
|
|
724
|
+
React.Children.forEach(children, child => {
|
|
725
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
|
|
729
|
+
initialFilled = true;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
return initialFilled;
|
|
734
|
+
});
|
|
735
|
+
const [focusedState, setFocused] = React.useState(false);
|
|
736
|
+
if (disabled && focusedState) {
|
|
737
|
+
setFocused(false);
|
|
738
|
+
}
|
|
739
|
+
const focused = visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState;
|
|
740
|
+
let registerEffect;
|
|
741
|
+
const registeredInput = React.useRef(false);
|
|
742
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
743
|
+
registerEffect = () => {
|
|
744
|
+
if (registeredInput.current) {
|
|
745
|
+
console.error(['MUI: There are multiple `InputBase` components inside a FormControl.', 'This creates visual inconsistencies, only use one `InputBase`.'].join('\n'));
|
|
746
|
+
}
|
|
747
|
+
registeredInput.current = true;
|
|
748
|
+
return () => {
|
|
749
|
+
registeredInput.current = false;
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
const onFilled = React.useCallback(() => {
|
|
754
|
+
setFilled(true);
|
|
755
|
+
}, []);
|
|
756
|
+
const onEmpty = React.useCallback(() => {
|
|
757
|
+
setFilled(false);
|
|
758
|
+
}, []);
|
|
759
|
+
const childContext = React.useMemo(() => {
|
|
760
|
+
return {
|
|
761
|
+
adornedStart,
|
|
762
|
+
setAdornedStart,
|
|
763
|
+
color,
|
|
764
|
+
disabled,
|
|
765
|
+
error,
|
|
766
|
+
filled,
|
|
767
|
+
focused,
|
|
768
|
+
fullWidth,
|
|
769
|
+
hiddenLabel,
|
|
770
|
+
size,
|
|
771
|
+
onBlur: () => {
|
|
772
|
+
setFocused(false);
|
|
773
|
+
},
|
|
774
|
+
onFocus: () => {
|
|
775
|
+
setFocused(true);
|
|
776
|
+
},
|
|
777
|
+
onEmpty,
|
|
778
|
+
onFilled,
|
|
779
|
+
registerEffect,
|
|
780
|
+
required,
|
|
781
|
+
variant
|
|
782
|
+
};
|
|
783
|
+
}, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, onEmpty, onFilled, required, size, variant]);
|
|
784
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormControlContext.Provider, {
|
|
785
|
+
value: childContext,
|
|
786
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(FormControlRoot, {
|
|
787
|
+
as: component,
|
|
788
|
+
ownerState: ownerState,
|
|
789
|
+
className: clsx(classes.root, className),
|
|
790
|
+
ref: ref,
|
|
791
|
+
...other,
|
|
792
|
+
children: children
|
|
793
|
+
})
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
process.env.NODE_ENV !== "production" ? FormControl.propTypes /* remove-proptypes */ = {
|
|
797
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
798
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
799
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
800
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
801
|
+
/**
|
|
802
|
+
* The content of the component.
|
|
803
|
+
*/
|
|
804
|
+
children: PropTypes.node,
|
|
805
|
+
/**
|
|
806
|
+
* Override or extend the styles applied to the component.
|
|
807
|
+
*/
|
|
808
|
+
classes: PropTypes.object,
|
|
809
|
+
/**
|
|
810
|
+
* @ignore
|
|
811
|
+
*/
|
|
812
|
+
className: PropTypes.string,
|
|
813
|
+
/**
|
|
814
|
+
* The color of the component.
|
|
815
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
816
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
817
|
+
* @default 'primary'
|
|
818
|
+
*/
|
|
819
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
820
|
+
/**
|
|
821
|
+
* The component used for the root node.
|
|
822
|
+
* Either a string to use a HTML element or a component.
|
|
823
|
+
*/
|
|
824
|
+
component: PropTypes.elementType,
|
|
825
|
+
/**
|
|
826
|
+
* If `true`, the label, input and helper text should be displayed in a disabled state.
|
|
827
|
+
* @default false
|
|
828
|
+
*/
|
|
829
|
+
disabled: PropTypes.bool,
|
|
830
|
+
/**
|
|
831
|
+
* If `true`, the label is displayed in an error state.
|
|
832
|
+
* @default false
|
|
833
|
+
*/
|
|
834
|
+
error: PropTypes.bool,
|
|
835
|
+
/**
|
|
836
|
+
* If `true`, the component is displayed in focused state.
|
|
837
|
+
*/
|
|
838
|
+
focused: PropTypes.bool,
|
|
839
|
+
/**
|
|
840
|
+
* If `true`, the component will take up the full width of its container.
|
|
841
|
+
* @default false
|
|
842
|
+
*/
|
|
843
|
+
fullWidth: PropTypes.bool,
|
|
844
|
+
/**
|
|
845
|
+
* If `true`, the label is hidden.
|
|
846
|
+
* This is used to increase density for a `FilledInput`.
|
|
847
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
848
|
+
* @default false
|
|
849
|
+
*/
|
|
850
|
+
hiddenLabel: PropTypes.bool,
|
|
851
|
+
/**
|
|
852
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
853
|
+
* @default 'none'
|
|
854
|
+
*/
|
|
855
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
856
|
+
/**
|
|
857
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
858
|
+
* @default false
|
|
859
|
+
*/
|
|
860
|
+
required: PropTypes.bool,
|
|
861
|
+
/**
|
|
862
|
+
* The size of the component.
|
|
863
|
+
* @default 'medium'
|
|
864
|
+
*/
|
|
865
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
866
|
+
/**
|
|
867
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
868
|
+
*/
|
|
869
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
870
|
+
/**
|
|
871
|
+
* The variant to use.
|
|
872
|
+
* @default 'outlined'
|
|
873
|
+
*/
|
|
874
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
875
|
+
} : void 0;
|
|
876
|
+
var FormControl$1 = FormControl;
|
|
877
|
+
|
|
878
|
+
function getFormHelperTextUtilityClasses(slot) {
|
|
879
|
+
return generateUtilityClass('MuiFormHelperText', slot);
|
|
880
|
+
}
|
|
881
|
+
const formHelperTextClasses = generateUtilityClasses('MuiFormHelperText', ['root', 'error', 'disabled', 'sizeSmall', 'sizeMedium', 'contained', 'focused', 'filled', 'required']);
|
|
882
|
+
var formHelperTextClasses$1 = formHelperTextClasses;
|
|
883
|
+
|
|
884
|
+
var _span;
|
|
885
|
+
const useUtilityClasses$1 = ownerState => {
|
|
886
|
+
const {
|
|
887
|
+
classes,
|
|
888
|
+
contained,
|
|
889
|
+
size,
|
|
890
|
+
disabled,
|
|
891
|
+
error,
|
|
892
|
+
filled,
|
|
893
|
+
focused,
|
|
894
|
+
required
|
|
895
|
+
} = ownerState;
|
|
896
|
+
const slots = {
|
|
897
|
+
root: ['root', disabled && 'disabled', error && 'error', size && `size${capitalize(size)}`, contained && 'contained', focused && 'focused', filled && 'filled', required && 'required']
|
|
898
|
+
};
|
|
899
|
+
return composeClasses(slots, getFormHelperTextUtilityClasses, classes);
|
|
900
|
+
};
|
|
901
|
+
const FormHelperTextRoot = styled$1('p', {
|
|
902
|
+
name: 'MuiFormHelperText',
|
|
903
|
+
slot: 'Root',
|
|
904
|
+
overridesResolver: (props, styles) => {
|
|
905
|
+
const {
|
|
906
|
+
ownerState
|
|
907
|
+
} = props;
|
|
908
|
+
return [styles.root, ownerState.size && styles[`size${capitalize(ownerState.size)}`], ownerState.contained && styles.contained, ownerState.filled && styles.filled];
|
|
909
|
+
}
|
|
910
|
+
})(memoTheme(({
|
|
911
|
+
theme
|
|
912
|
+
}) => ({
|
|
913
|
+
color: (theme.vars || theme).palette.text.secondary,
|
|
914
|
+
...theme.typography.caption,
|
|
915
|
+
textAlign: 'left',
|
|
916
|
+
marginTop: 3,
|
|
917
|
+
marginRight: 0,
|
|
918
|
+
marginBottom: 0,
|
|
919
|
+
marginLeft: 0,
|
|
920
|
+
[`&.${formHelperTextClasses$1.disabled}`]: {
|
|
921
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
922
|
+
},
|
|
923
|
+
[`&.${formHelperTextClasses$1.error}`]: {
|
|
924
|
+
color: (theme.vars || theme).palette.error.main
|
|
925
|
+
},
|
|
926
|
+
variants: [{
|
|
927
|
+
props: {
|
|
928
|
+
size: 'small'
|
|
929
|
+
},
|
|
930
|
+
style: {
|
|
931
|
+
marginTop: 4
|
|
932
|
+
}
|
|
933
|
+
}, {
|
|
934
|
+
props: ({
|
|
935
|
+
ownerState
|
|
936
|
+
}) => ownerState.contained,
|
|
937
|
+
style: {
|
|
938
|
+
marginLeft: 14,
|
|
939
|
+
marginRight: 14
|
|
940
|
+
}
|
|
941
|
+
}]
|
|
942
|
+
})));
|
|
943
|
+
const FormHelperText = /*#__PURE__*/React.forwardRef(function FormHelperText(inProps, ref) {
|
|
944
|
+
const props = useDefaultProps({
|
|
945
|
+
props: inProps,
|
|
946
|
+
name: 'MuiFormHelperText'
|
|
947
|
+
});
|
|
948
|
+
const {
|
|
949
|
+
children,
|
|
950
|
+
className,
|
|
951
|
+
component = 'p',
|
|
952
|
+
disabled,
|
|
953
|
+
error,
|
|
954
|
+
filled,
|
|
955
|
+
focused,
|
|
956
|
+
margin,
|
|
957
|
+
required,
|
|
958
|
+
variant,
|
|
959
|
+
...other
|
|
960
|
+
} = props;
|
|
961
|
+
const muiFormControl = useFormControl();
|
|
962
|
+
const fcs = formControlState({
|
|
963
|
+
props,
|
|
964
|
+
muiFormControl,
|
|
965
|
+
states: ['variant', 'size', 'disabled', 'error', 'filled', 'focused', 'required']
|
|
966
|
+
});
|
|
967
|
+
const ownerState = {
|
|
968
|
+
...props,
|
|
969
|
+
component,
|
|
970
|
+
contained: fcs.variant === 'filled' || fcs.variant === 'outlined',
|
|
971
|
+
variant: fcs.variant,
|
|
972
|
+
size: fcs.size,
|
|
973
|
+
disabled: fcs.disabled,
|
|
974
|
+
error: fcs.error,
|
|
975
|
+
filled: fcs.filled,
|
|
976
|
+
focused: fcs.focused,
|
|
977
|
+
required: fcs.required
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
// This issue explains why this is required: https://github.com/mui/material-ui/issues/42184
|
|
981
|
+
delete ownerState.ownerState;
|
|
982
|
+
const classes = useUtilityClasses$1(ownerState);
|
|
983
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperTextRoot, {
|
|
984
|
+
as: component,
|
|
985
|
+
className: clsx(classes.root, className),
|
|
986
|
+
ref: ref,
|
|
987
|
+
...other,
|
|
988
|
+
ownerState: ownerState,
|
|
989
|
+
children: children === ' ' ? // notranslate needed while Google Translate will not fix zero-width space issue
|
|
990
|
+
_span || (_span = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
991
|
+
className: "notranslate",
|
|
992
|
+
"aria-hidden": true,
|
|
993
|
+
children: "\u200B"
|
|
994
|
+
})) : children
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
process.env.NODE_ENV !== "production" ? FormHelperText.propTypes /* remove-proptypes */ = {
|
|
998
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
999
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
1000
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
1001
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
1002
|
+
/**
|
|
1003
|
+
* The content of the component.
|
|
1004
|
+
*
|
|
1005
|
+
* If `' '` is provided, the component reserves one line height for displaying a future message.
|
|
1006
|
+
*/
|
|
1007
|
+
children: PropTypes.node,
|
|
1008
|
+
/**
|
|
1009
|
+
* Override or extend the styles applied to the component.
|
|
1010
|
+
*/
|
|
1011
|
+
classes: PropTypes.object,
|
|
1012
|
+
/**
|
|
1013
|
+
* @ignore
|
|
1014
|
+
*/
|
|
1015
|
+
className: PropTypes.string,
|
|
1016
|
+
/**
|
|
1017
|
+
* The component used for the root node.
|
|
1018
|
+
* Either a string to use a HTML element or a component.
|
|
1019
|
+
*/
|
|
1020
|
+
component: PropTypes.elementType,
|
|
1021
|
+
/**
|
|
1022
|
+
* If `true`, the helper text should be displayed in a disabled state.
|
|
1023
|
+
*/
|
|
1024
|
+
disabled: PropTypes.bool,
|
|
1025
|
+
/**
|
|
1026
|
+
* If `true`, helper text should be displayed in an error state.
|
|
1027
|
+
*/
|
|
1028
|
+
error: PropTypes.bool,
|
|
1029
|
+
/**
|
|
1030
|
+
* If `true`, the helper text should use filled classes key.
|
|
1031
|
+
*/
|
|
1032
|
+
filled: PropTypes.bool,
|
|
1033
|
+
/**
|
|
1034
|
+
* If `true`, the helper text should use focused classes key.
|
|
1035
|
+
*/
|
|
1036
|
+
focused: PropTypes.bool,
|
|
1037
|
+
/**
|
|
1038
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
1039
|
+
* FormControl.
|
|
1040
|
+
*/
|
|
1041
|
+
margin: PropTypes.oneOf(['dense']),
|
|
1042
|
+
/**
|
|
1043
|
+
* If `true`, the helper text should use required classes key.
|
|
1044
|
+
*/
|
|
1045
|
+
required: PropTypes.bool,
|
|
1046
|
+
/**
|
|
1047
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
1048
|
+
*/
|
|
1049
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1050
|
+
/**
|
|
1051
|
+
* The variant to use.
|
|
1052
|
+
*/
|
|
1053
|
+
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
|
1054
|
+
} : void 0;
|
|
1055
|
+
var FormHelperText$1 = FormHelperText;
|
|
1056
|
+
|
|
1057
|
+
function getTextFieldUtilityClass(slot) {
|
|
1058
|
+
return generateUtilityClass('MuiTextField', slot);
|
|
1059
|
+
}
|
|
1060
|
+
generateUtilityClasses('MuiTextField', ['root']);
|
|
1061
|
+
|
|
1062
|
+
const variantComponent = {
|
|
1063
|
+
standard: Input,
|
|
1064
|
+
filled: FilledInput,
|
|
1065
|
+
outlined: OutlinedInput
|
|
1066
|
+
};
|
|
1067
|
+
const useUtilityClasses = ownerState => {
|
|
1068
|
+
const {
|
|
1069
|
+
classes
|
|
1070
|
+
} = ownerState;
|
|
1071
|
+
const slots = {
|
|
1072
|
+
root: ['root']
|
|
1073
|
+
};
|
|
1074
|
+
return composeClasses(slots, getTextFieldUtilityClass, classes);
|
|
1075
|
+
};
|
|
1076
|
+
const TextFieldRoot = styled$1(FormControl$1, {
|
|
1077
|
+
name: 'MuiTextField',
|
|
1078
|
+
slot: 'Root',
|
|
1079
|
+
overridesResolver: (props, styles) => styles.root
|
|
1080
|
+
})({});
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* The `TextField` is a convenience wrapper for the most common cases (80%).
|
|
1084
|
+
* It cannot be all things to all people, otherwise the API would grow out of control.
|
|
1085
|
+
*
|
|
1086
|
+
* ## Advanced Configuration
|
|
1087
|
+
*
|
|
1088
|
+
* It's important to understand that the text field is a simple abstraction
|
|
1089
|
+
* on top of the following components:
|
|
1090
|
+
*
|
|
1091
|
+
* - [FormControl](/material-ui/api/form-control/)
|
|
1092
|
+
* - [InputLabel](/material-ui/api/input-label/)
|
|
1093
|
+
* - [FilledInput](/material-ui/api/filled-input/)
|
|
1094
|
+
* - [OutlinedInput](/material-ui/api/outlined-input/)
|
|
1095
|
+
* - [Input](/material-ui/api/input/)
|
|
1096
|
+
* - [FormHelperText](/material-ui/api/form-helper-text/)
|
|
1097
|
+
*
|
|
1098
|
+
* If you wish to alter the props applied to the `input` element, you can do so as follows:
|
|
1099
|
+
*
|
|
1100
|
+
* ```jsx
|
|
1101
|
+
* const inputProps = {
|
|
1102
|
+
* step: 300,
|
|
1103
|
+
* };
|
|
1104
|
+
*
|
|
1105
|
+
* return <TextField id="time" type="time" inputProps={inputProps} />;
|
|
1106
|
+
* ```
|
|
1107
|
+
*
|
|
1108
|
+
* For advanced cases, please look at the source of TextField by clicking on the
|
|
1109
|
+
* "Edit this page" button above. Consider either:
|
|
1110
|
+
*
|
|
1111
|
+
* - using the upper case props for passing values directly to the components
|
|
1112
|
+
* - using the underlying components directly as shown in the demos
|
|
1113
|
+
*/
|
|
1114
|
+
const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
|
|
1115
|
+
const props = useDefaultProps({
|
|
1116
|
+
props: inProps,
|
|
1117
|
+
name: 'MuiTextField'
|
|
1118
|
+
});
|
|
1119
|
+
const {
|
|
1120
|
+
autoComplete,
|
|
1121
|
+
autoFocus = false,
|
|
1122
|
+
children,
|
|
1123
|
+
className,
|
|
1124
|
+
color = 'primary',
|
|
1125
|
+
defaultValue,
|
|
1126
|
+
disabled = false,
|
|
1127
|
+
error = false,
|
|
1128
|
+
FormHelperTextProps: FormHelperTextPropsProp,
|
|
1129
|
+
fullWidth = false,
|
|
1130
|
+
helperText,
|
|
1131
|
+
id: idOverride,
|
|
1132
|
+
InputLabelProps: InputLabelPropsProp,
|
|
1133
|
+
inputProps: inputPropsProp,
|
|
1134
|
+
InputProps: InputPropsProp,
|
|
1135
|
+
inputRef,
|
|
1136
|
+
label,
|
|
1137
|
+
maxRows,
|
|
1138
|
+
minRows,
|
|
1139
|
+
multiline = false,
|
|
1140
|
+
name,
|
|
1141
|
+
onBlur,
|
|
1142
|
+
onChange,
|
|
1143
|
+
onFocus,
|
|
1144
|
+
placeholder,
|
|
1145
|
+
required = false,
|
|
1146
|
+
rows,
|
|
1147
|
+
select = false,
|
|
1148
|
+
SelectProps: SelectPropsProp,
|
|
1149
|
+
slots = {},
|
|
1150
|
+
slotProps = {},
|
|
1151
|
+
type,
|
|
1152
|
+
value,
|
|
1153
|
+
variant = 'outlined',
|
|
1154
|
+
...other
|
|
1155
|
+
} = props;
|
|
1156
|
+
const ownerState = {
|
|
1157
|
+
...props,
|
|
1158
|
+
autoFocus,
|
|
1159
|
+
color,
|
|
1160
|
+
disabled,
|
|
1161
|
+
error,
|
|
1162
|
+
fullWidth,
|
|
1163
|
+
multiline,
|
|
1164
|
+
required,
|
|
1165
|
+
select,
|
|
1166
|
+
variant
|
|
1167
|
+
};
|
|
1168
|
+
const classes = useUtilityClasses(ownerState);
|
|
1169
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1170
|
+
if (select && !children) {
|
|
1171
|
+
console.error('MUI: `children` must be passed when using the `TextField` component with `select`.');
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
const id = useId(idOverride);
|
|
1175
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
1176
|
+
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
1177
|
+
const InputComponent = variantComponent[variant];
|
|
1178
|
+
const externalForwardedProps = {
|
|
1179
|
+
slots,
|
|
1180
|
+
slotProps: {
|
|
1181
|
+
input: InputPropsProp,
|
|
1182
|
+
inputLabel: InputLabelPropsProp,
|
|
1183
|
+
htmlInput: inputPropsProp,
|
|
1184
|
+
formHelperText: FormHelperTextPropsProp,
|
|
1185
|
+
select: SelectPropsProp,
|
|
1186
|
+
...slotProps
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
const inputAdditionalProps = {};
|
|
1190
|
+
const inputLabelSlotProps = externalForwardedProps.slotProps.inputLabel;
|
|
1191
|
+
if (variant === 'outlined') {
|
|
1192
|
+
if (inputLabelSlotProps && typeof inputLabelSlotProps.shrink !== 'undefined') {
|
|
1193
|
+
inputAdditionalProps.notched = inputLabelSlotProps.shrink;
|
|
1194
|
+
}
|
|
1195
|
+
inputAdditionalProps.label = label;
|
|
1196
|
+
}
|
|
1197
|
+
if (select) {
|
|
1198
|
+
// unset defaults from textbox inputs
|
|
1199
|
+
if (!SelectPropsProp || !SelectPropsProp.native) {
|
|
1200
|
+
inputAdditionalProps.id = undefined;
|
|
1201
|
+
}
|
|
1202
|
+
inputAdditionalProps['aria-describedby'] = undefined;
|
|
1203
|
+
}
|
|
1204
|
+
const [RootSlot, rootProps] = useSlot('root', {
|
|
1205
|
+
elementType: TextFieldRoot,
|
|
1206
|
+
shouldForwardComponentProp: true,
|
|
1207
|
+
externalForwardedProps: {
|
|
1208
|
+
...externalForwardedProps,
|
|
1209
|
+
...other
|
|
1210
|
+
},
|
|
1211
|
+
ownerState,
|
|
1212
|
+
className: clsx(classes.root, className),
|
|
1213
|
+
ref,
|
|
1214
|
+
additionalProps: {
|
|
1215
|
+
disabled,
|
|
1216
|
+
error,
|
|
1217
|
+
fullWidth,
|
|
1218
|
+
required,
|
|
1219
|
+
color,
|
|
1220
|
+
variant
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
const [InputSlot, inputProps] = useSlot('input', {
|
|
1224
|
+
elementType: InputComponent,
|
|
1225
|
+
externalForwardedProps,
|
|
1226
|
+
additionalProps: inputAdditionalProps,
|
|
1227
|
+
ownerState
|
|
1228
|
+
});
|
|
1229
|
+
const [InputLabelSlot, inputLabelProps] = useSlot('inputLabel', {
|
|
1230
|
+
elementType: InputLabel$1,
|
|
1231
|
+
externalForwardedProps,
|
|
1232
|
+
ownerState
|
|
1233
|
+
});
|
|
1234
|
+
const [HtmlInputSlot, htmlInputProps] = useSlot('htmlInput', {
|
|
1235
|
+
elementType: 'input',
|
|
1236
|
+
externalForwardedProps,
|
|
1237
|
+
ownerState
|
|
1238
|
+
});
|
|
1239
|
+
const [FormHelperTextSlot, formHelperTextProps] = useSlot('formHelperText', {
|
|
1240
|
+
elementType: FormHelperText$1,
|
|
1241
|
+
externalForwardedProps,
|
|
1242
|
+
ownerState
|
|
1243
|
+
});
|
|
1244
|
+
const [SelectSlot, selectProps] = useSlot('select', {
|
|
1245
|
+
elementType: Select,
|
|
1246
|
+
externalForwardedProps,
|
|
1247
|
+
ownerState
|
|
1248
|
+
});
|
|
1249
|
+
const InputElement = /*#__PURE__*/jsxRuntimeExports.jsx(InputSlot, {
|
|
1250
|
+
"aria-describedby": helperTextId,
|
|
1251
|
+
autoComplete: autoComplete,
|
|
1252
|
+
autoFocus: autoFocus,
|
|
1253
|
+
defaultValue: defaultValue,
|
|
1254
|
+
fullWidth: fullWidth,
|
|
1255
|
+
multiline: multiline,
|
|
1256
|
+
name: name,
|
|
1257
|
+
rows: rows,
|
|
1258
|
+
maxRows: maxRows,
|
|
1259
|
+
minRows: minRows,
|
|
1260
|
+
type: type,
|
|
1261
|
+
value: value,
|
|
1262
|
+
id: id,
|
|
1263
|
+
inputRef: inputRef,
|
|
1264
|
+
onBlur: onBlur,
|
|
1265
|
+
onChange: onChange,
|
|
1266
|
+
onFocus: onFocus,
|
|
1267
|
+
placeholder: placeholder,
|
|
1268
|
+
inputProps: htmlInputProps,
|
|
1269
|
+
slots: {
|
|
1270
|
+
input: slots.htmlInput ? HtmlInputSlot : undefined
|
|
1271
|
+
},
|
|
1272
|
+
...inputProps
|
|
1273
|
+
});
|
|
1274
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(RootSlot, {
|
|
1275
|
+
...rootProps,
|
|
1276
|
+
children: [label != null && label !== '' && /*#__PURE__*/jsxRuntimeExports.jsx(InputLabelSlot, {
|
|
1277
|
+
htmlFor: id,
|
|
1278
|
+
id: inputLabelId,
|
|
1279
|
+
...inputLabelProps,
|
|
1280
|
+
children: label
|
|
1281
|
+
}), select ? /*#__PURE__*/jsxRuntimeExports.jsx(SelectSlot, {
|
|
1282
|
+
"aria-describedby": helperTextId,
|
|
1283
|
+
id: id,
|
|
1284
|
+
labelId: inputLabelId,
|
|
1285
|
+
value: value,
|
|
1286
|
+
input: InputElement,
|
|
1287
|
+
...selectProps,
|
|
1288
|
+
children: children
|
|
1289
|
+
}) : InputElement, helperText && /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperTextSlot, {
|
|
1290
|
+
id: helperTextId,
|
|
1291
|
+
...formHelperTextProps,
|
|
1292
|
+
children: helperText
|
|
1293
|
+
})]
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes */ = {
|
|
1297
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
1298
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
1299
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
1300
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
1301
|
+
/**
|
|
1302
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
1303
|
+
* The name can be confusing, as it's more like an autofill.
|
|
1304
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
1305
|
+
*/
|
|
1306
|
+
autoComplete: PropTypes.string,
|
|
1307
|
+
/**
|
|
1308
|
+
* If `true`, the `input` element is focused during the first mount.
|
|
1309
|
+
* @default false
|
|
1310
|
+
*/
|
|
1311
|
+
autoFocus: PropTypes.bool,
|
|
1312
|
+
/**
|
|
1313
|
+
* @ignore
|
|
1314
|
+
*/
|
|
1315
|
+
children: PropTypes.node,
|
|
1316
|
+
/**
|
|
1317
|
+
* Override or extend the styles applied to the component.
|
|
1318
|
+
*/
|
|
1319
|
+
classes: PropTypes.object,
|
|
1320
|
+
/**
|
|
1321
|
+
* @ignore
|
|
1322
|
+
*/
|
|
1323
|
+
className: PropTypes.string,
|
|
1324
|
+
/**
|
|
1325
|
+
* The color of the component.
|
|
1326
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
1327
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
1328
|
+
* @default 'primary'
|
|
1329
|
+
*/
|
|
1330
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
1331
|
+
/**
|
|
1332
|
+
* The default value. Use when the component is not controlled.
|
|
1333
|
+
*/
|
|
1334
|
+
defaultValue: PropTypes.any,
|
|
1335
|
+
/**
|
|
1336
|
+
* If `true`, the component is disabled.
|
|
1337
|
+
* @default false
|
|
1338
|
+
*/
|
|
1339
|
+
disabled: PropTypes.bool,
|
|
1340
|
+
/**
|
|
1341
|
+
* If `true`, the label is displayed in an error state.
|
|
1342
|
+
* @default false
|
|
1343
|
+
*/
|
|
1344
|
+
error: PropTypes.bool,
|
|
1345
|
+
/**
|
|
1346
|
+
* Props applied to the [`FormHelperText`](https://mui.com/material-ui/api/form-helper-text/) element.
|
|
1347
|
+
* @deprecated Use `slotProps.formHelperText` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1348
|
+
*/
|
|
1349
|
+
FormHelperTextProps: PropTypes.object,
|
|
1350
|
+
/**
|
|
1351
|
+
* If `true`, the input will take up the full width of its container.
|
|
1352
|
+
* @default false
|
|
1353
|
+
*/
|
|
1354
|
+
fullWidth: PropTypes.bool,
|
|
1355
|
+
/**
|
|
1356
|
+
* The helper text content.
|
|
1357
|
+
*/
|
|
1358
|
+
helperText: PropTypes.node,
|
|
1359
|
+
/**
|
|
1360
|
+
* The id of the `input` element.
|
|
1361
|
+
* Use this prop to make `label` and `helperText` accessible for screen readers.
|
|
1362
|
+
*/
|
|
1363
|
+
id: PropTypes.string,
|
|
1364
|
+
/**
|
|
1365
|
+
* Props applied to the [`InputLabel`](https://mui.com/material-ui/api/input-label/) element.
|
|
1366
|
+
* Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
|
|
1367
|
+
* @deprecated Use `slotProps.inputLabel` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1368
|
+
*/
|
|
1369
|
+
InputLabelProps: PropTypes.object,
|
|
1370
|
+
/**
|
|
1371
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
1372
|
+
* @deprecated Use `slotProps.htmlInput` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1373
|
+
*/
|
|
1374
|
+
inputProps: PropTypes.object,
|
|
1375
|
+
/**
|
|
1376
|
+
* Props applied to the Input element.
|
|
1377
|
+
* It will be a [`FilledInput`](https://mui.com/material-ui/api/filled-input/),
|
|
1378
|
+
* [`OutlinedInput`](https://mui.com/material-ui/api/outlined-input/) or [`Input`](https://mui.com/material-ui/api/input/)
|
|
1379
|
+
* component depending on the `variant` prop value.
|
|
1380
|
+
* @deprecated Use `slotProps.input` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1381
|
+
*/
|
|
1382
|
+
InputProps: PropTypes.object,
|
|
1383
|
+
/**
|
|
1384
|
+
* Pass a ref to the `input` element.
|
|
1385
|
+
*/
|
|
1386
|
+
inputRef: refType,
|
|
1387
|
+
/**
|
|
1388
|
+
* The label content.
|
|
1389
|
+
*/
|
|
1390
|
+
label: PropTypes.node,
|
|
1391
|
+
/**
|
|
1392
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
1393
|
+
* @default 'none'
|
|
1394
|
+
*/
|
|
1395
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
1396
|
+
/**
|
|
1397
|
+
* Maximum number of rows to display when multiline option is set to true.
|
|
1398
|
+
*/
|
|
1399
|
+
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1400
|
+
/**
|
|
1401
|
+
* Minimum number of rows to display when multiline option is set to true.
|
|
1402
|
+
*/
|
|
1403
|
+
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1404
|
+
/**
|
|
1405
|
+
* If `true`, a `textarea` element is rendered instead of an input.
|
|
1406
|
+
* @default false
|
|
1407
|
+
*/
|
|
1408
|
+
multiline: PropTypes.bool,
|
|
1409
|
+
/**
|
|
1410
|
+
* Name attribute of the `input` element.
|
|
1411
|
+
*/
|
|
1412
|
+
name: PropTypes.string,
|
|
1413
|
+
/**
|
|
1414
|
+
* @ignore
|
|
1415
|
+
*/
|
|
1416
|
+
onBlur: PropTypes.func,
|
|
1417
|
+
/**
|
|
1418
|
+
* Callback fired when the value is changed.
|
|
1419
|
+
*
|
|
1420
|
+
* @param {object} event The event source of the callback.
|
|
1421
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
1422
|
+
*/
|
|
1423
|
+
onChange: PropTypes.func,
|
|
1424
|
+
/**
|
|
1425
|
+
* @ignore
|
|
1426
|
+
*/
|
|
1427
|
+
onFocus: PropTypes.func,
|
|
1428
|
+
/**
|
|
1429
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
1430
|
+
*/
|
|
1431
|
+
placeholder: PropTypes.string,
|
|
1432
|
+
/**
|
|
1433
|
+
* If `true`, the label is displayed as required and the `input` element is required.
|
|
1434
|
+
* @default false
|
|
1435
|
+
*/
|
|
1436
|
+
required: PropTypes.bool,
|
|
1437
|
+
/**
|
|
1438
|
+
* Number of rows to display when multiline option is set to true.
|
|
1439
|
+
*/
|
|
1440
|
+
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1441
|
+
/**
|
|
1442
|
+
* Render a [`Select`](https://mui.com/material-ui/api/select/) element while passing the Input element to `Select` as `input` parameter.
|
|
1443
|
+
* If this option is set you must pass the options of the select as children.
|
|
1444
|
+
* @default false
|
|
1445
|
+
*/
|
|
1446
|
+
select: PropTypes.bool,
|
|
1447
|
+
/**
|
|
1448
|
+
* Props applied to the [`Select`](https://mui.com/material-ui/api/select/) element.
|
|
1449
|
+
* @deprecated Use `slotProps.select` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
1450
|
+
*/
|
|
1451
|
+
SelectProps: PropTypes.object,
|
|
1452
|
+
/**
|
|
1453
|
+
* The size of the component.
|
|
1454
|
+
* @default 'medium'
|
|
1455
|
+
*/
|
|
1456
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
1457
|
+
/**
|
|
1458
|
+
* The props used for each slot inside.
|
|
1459
|
+
* @default {}
|
|
1460
|
+
*/
|
|
1461
|
+
slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
|
1462
|
+
formHelperText: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
1463
|
+
htmlInput: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
1464
|
+
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
1465
|
+
inputLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
1466
|
+
select: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
1467
|
+
}),
|
|
1468
|
+
/**
|
|
1469
|
+
* The components used for each slot inside.
|
|
1470
|
+
* @default {}
|
|
1471
|
+
*/
|
|
1472
|
+
slots: PropTypes.shape({
|
|
1473
|
+
formHelperText: PropTypes.elementType,
|
|
1474
|
+
htmlInput: PropTypes.elementType,
|
|
1475
|
+
input: PropTypes.elementType,
|
|
1476
|
+
inputLabel: PropTypes.elementType,
|
|
1477
|
+
root: PropTypes.elementType,
|
|
1478
|
+
select: PropTypes.elementType
|
|
1479
|
+
}),
|
|
1480
|
+
/**
|
|
1481
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
1482
|
+
*/
|
|
1483
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1484
|
+
/**
|
|
1485
|
+
* 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).
|
|
1486
|
+
*/
|
|
1487
|
+
type: PropTypes /* @typescript-to-proptypes-ignore */.string,
|
|
1488
|
+
/**
|
|
1489
|
+
* The value of the `input` element, required for a controlled component.
|
|
1490
|
+
*/
|
|
1491
|
+
value: PropTypes.any,
|
|
1492
|
+
/**
|
|
1493
|
+
* The variant to use.
|
|
1494
|
+
* @default 'outlined'
|
|
1495
|
+
*/
|
|
1496
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
1497
|
+
} : void 0;
|
|
1498
|
+
var TextField$1 = TextField;
|
|
16
1499
|
|
|
17
1500
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
18
1501
|
const InputNumberInterval = props => {
|
|
@@ -54,7 +1537,7 @@ const InputNumberInterval = props => {
|
|
|
54
1537
|
const newLowerBound = event.target.value;
|
|
55
1538
|
updateFilterValue(newLowerBound, filterValueState[1]);
|
|
56
1539
|
};
|
|
57
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
1540
|
+
return /*#__PURE__*/React.createElement(Box$1, {
|
|
58
1541
|
sx: {
|
|
59
1542
|
display: 'inline-flex',
|
|
60
1543
|
flexDirection: 'row',
|
|
@@ -62,7 +1545,7 @@ const InputNumberInterval = props => {
|
|
|
62
1545
|
height: 48,
|
|
63
1546
|
pl: '20px'
|
|
64
1547
|
}
|
|
65
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
1548
|
+
}, /*#__PURE__*/React.createElement(TextField$1, {
|
|
66
1549
|
name: "lower-bound-input",
|
|
67
1550
|
placeholder: "From",
|
|
68
1551
|
label: "From",
|
|
@@ -74,7 +1557,7 @@ const InputNumberInterval = props => {
|
|
|
74
1557
|
sx: {
|
|
75
1558
|
mr: 2
|
|
76
1559
|
}
|
|
77
|
-
}), /*#__PURE__*/React.createElement(TextField, {
|
|
1560
|
+
}), /*#__PURE__*/React.createElement(TextField$1, {
|
|
78
1561
|
name: "upper-bound-input",
|
|
79
1562
|
placeholder: "To",
|
|
80
1563
|
label: "To",
|
|
@@ -703,20 +2186,14 @@ const DIMENSION_MODEL_KEY = 'dimension';
|
|
|
703
2186
|
const FILTER_SEARCH_KEY = 'searchModel';
|
|
704
2187
|
const DENSITY_MODEL_KEY = 'densityModel';
|
|
705
2188
|
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];
|
|
2189
|
+
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
2190
|
/**
|
|
714
2191
|
* Build the localStorage key for a specific grid state category.
|
|
715
2192
|
* Consumers can use this to read or clear individual state entries directly.
|
|
716
2193
|
*
|
|
717
2194
|
* @example
|
|
718
2195
|
* ```ts
|
|
719
|
-
* const key = buildStorageKey({ id: pathname, version: 2, category:
|
|
2196
|
+
* const key = buildStorageKey({ id: pathname, version: 2, category: SORT_MODEL_KEY });
|
|
720
2197
|
* localStorage.removeItem(key);
|
|
721
2198
|
* ```
|
|
722
2199
|
*/
|
|
@@ -766,22 +2243,6 @@ const clearPreviousVersionStorage = (id, previousLocalStorageVersions) => {
|
|
|
766
2243
|
id,
|
|
767
2244
|
version,
|
|
768
2245
|
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
2246
|
})];
|
|
786
2247
|
for (const keyToDelete of keysToDelete) {
|
|
787
2248
|
try {
|
|
@@ -808,6 +2269,19 @@ const clearAllVersionStorage = (id, maxVersion) => {
|
|
|
808
2269
|
* Fully reset a `StatefulDataGrid` — clear localStorage for the given versions
|
|
809
2270
|
* and strip all grid-owned URL params (`_*` and `v=`), preserving any non-grid params.
|
|
810
2271
|
*
|
|
2272
|
+
* The function reads `window.location.search` directly so the strip always
|
|
2273
|
+
* operates on the live URL. This matters because consumers typically call this
|
|
2274
|
+
* from a component whose captured `search` snapshot may be stale — for example
|
|
2275
|
+
* when the grid has just written its own keys to the URL via the router adapter
|
|
2276
|
+
* but the parent hasn't re-rendered yet. Falling back to the supplied `search`
|
|
2277
|
+
* is only used in non-browser environments (SSR, unit tests without jsdom).
|
|
2278
|
+
*
|
|
2279
|
+
* The write is performed via `historyReplace(newSearch, { authoritative: true })`.
|
|
2280
|
+
* Adapters with delta/coalescing logic (e.g. `createReactRouterV5Adapter`)
|
|
2281
|
+
* recognise the `authoritative` flag and bypass the delta computation, which
|
|
2282
|
+
* would otherwise drop keys that grew into the URL after the parent's last
|
|
2283
|
+
* captured snapshot. Adapters without delta logic simply ignore the flag.
|
|
2284
|
+
*
|
|
811
2285
|
* Call from within a component where the router values are available:
|
|
812
2286
|
* ```ts
|
|
813
2287
|
* const { search, historyReplace } = useMyRouter();
|
|
@@ -822,7 +2296,8 @@ const resetStatefulDataGridState = _ref2 => {
|
|
|
822
2296
|
historyReplace
|
|
823
2297
|
} = _ref2;
|
|
824
2298
|
clearPreviousVersionStorage(id, versions);
|
|
825
|
-
const
|
|
2299
|
+
const liveSearch = typeof window !== 'undefined' && window.location ? window.location.search : search;
|
|
2300
|
+
const params = new URLSearchParams(liveSearch);
|
|
826
2301
|
const keysToDelete = [];
|
|
827
2302
|
params.forEach((_value, key) => {
|
|
828
2303
|
if (key.startsWith('_') || key === 'v') {
|
|
@@ -832,7 +2307,59 @@ const resetStatefulDataGridState = _ref2 => {
|
|
|
832
2307
|
for (const key of keysToDelete) {
|
|
833
2308
|
params.delete(key);
|
|
834
2309
|
}
|
|
835
|
-
historyReplace(params.toString()
|
|
2310
|
+
historyReplace(params.toString(), {
|
|
2311
|
+
authoritative: true
|
|
2312
|
+
});
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2315
|
+
/**
|
|
2316
|
+
* Reset only the column-visibility state of a `StatefulDataGrid` back to its
|
|
2317
|
+
* default (all columns visible). Clears the persisted `visibilityModel`
|
|
2318
|
+
* localStorage entry for the given versions and strips the `_columnVisibility`
|
|
2319
|
+
* param from the live URL, leaving every other piece of grid state (filters,
|
|
2320
|
+
* sort, pagination, pinned columns, …) untouched.
|
|
2321
|
+
*
|
|
2322
|
+
* This is the visibility-scoped counterpart to `resetStatefulDataGridState`.
|
|
2323
|
+
* Reach for it at transition points where a stale visibility snapshot would
|
|
2324
|
+
* otherwise re-seed and keep base columns hidden. Because it leaves the other
|
|
2325
|
+
* params alone it will not clobber a filter the caller is writing in the same
|
|
2326
|
+
* transition.
|
|
2327
|
+
*
|
|
2328
|
+
* Like `resetStatefulDataGridState`, the URL strip reads `window.location.search`
|
|
2329
|
+
* directly so it operates on the live URL (the caller's captured snapshot may
|
|
2330
|
+
* be stale), and writes via `historyReplace(newSearch, { authoritative: true })`.
|
|
2331
|
+
*
|
|
2332
|
+
* This clears the *persisted* state only. The caller is responsible for
|
|
2333
|
+
* resetting the *live* grid in the same tick:
|
|
2334
|
+
* ```ts
|
|
2335
|
+
* resetColumnVisibility({ id: pathname, versions: [0, 1], search, historyReplace });
|
|
2336
|
+
* apiRef.current?.setColumnVisibilityModel?.({});
|
|
2337
|
+
* ```
|
|
2338
|
+
*/
|
|
2339
|
+
const resetColumnVisibility = _ref3 => {
|
|
2340
|
+
let {
|
|
2341
|
+
id,
|
|
2342
|
+
versions,
|
|
2343
|
+
search,
|
|
2344
|
+
historyReplace
|
|
2345
|
+
} = _ref3;
|
|
2346
|
+
for (const version of versions) {
|
|
2347
|
+
try {
|
|
2348
|
+
window.localStorage.removeItem(buildStorageKey({
|
|
2349
|
+
id,
|
|
2350
|
+
version,
|
|
2351
|
+
category: VISIBILITY_MODEL_KEY
|
|
2352
|
+
}));
|
|
2353
|
+
} catch (e) {
|
|
2354
|
+
// Ignore — storage may be unavailable (SSR, Safari private mode).
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
const liveSearch = typeof window !== 'undefined' && window.location ? window.location.search : search;
|
|
2358
|
+
const params = new URLSearchParams(liveSearch);
|
|
2359
|
+
params.delete('_columnVisibility');
|
|
2360
|
+
historyReplace(params.toString(), {
|
|
2361
|
+
authoritative: true
|
|
2362
|
+
});
|
|
836
2363
|
};
|
|
837
2364
|
|
|
838
2365
|
/** Maximum query string length (chars) before compression kicks in. */
|
|
@@ -846,7 +2373,7 @@ const COMPRESSED_PREFIX = '~';
|
|
|
846
2373
|
* Params listed first are compressed first (least valuable to read in the URL).
|
|
847
2374
|
* The filter aggregate step uses the special key `_filters_aggregate`.
|
|
848
2375
|
*/
|
|
849
|
-
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '
|
|
2376
|
+
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '_quickFilterValues'];
|
|
850
2377
|
|
|
851
2378
|
/** Params that are always short and should never be compressed. */
|
|
852
2379
|
const NEVER_COMPRESS = new Set(['_sortColumn', '_pagination', '_density', '_logicOperator', 'v', 'tab']);
|
|
@@ -924,7 +2451,7 @@ const tryAggregateFilters = (params, filterKeys) => {
|
|
|
924
2451
|
* Filter params are those that start with `_` but are not well-known system params.
|
|
925
2452
|
*/
|
|
926
2453
|
const getFilterParamKeys = params => {
|
|
927
|
-
const systemPrefixes = ['_sortColumn', '_pagination', '_density', '_logicOperator', '_quickFilterValues', '_columnVisibility', '_columnOrder', '_pinnedColumnsLeft', '_pinnedColumnsRight', '
|
|
2454
|
+
const systemPrefixes = ['_sortColumn', '_pagination', '_density', '_logicOperator', '_quickFilterValues', '_columnVisibility', '_columnOrder', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters'];
|
|
928
2455
|
const filterKeys = [];
|
|
929
2456
|
for (const key of params.keys()) {
|
|
930
2457
|
if (!key.startsWith('_')) continue;
|
|
@@ -1134,7 +2661,8 @@ const convertToDisplayFormat = search => {
|
|
|
1134
2661
|
return param;
|
|
1135
2662
|
}
|
|
1136
2663
|
|
|
1137
|
-
// Handle _columnVisibility=[a,b,c
|
|
2664
|
+
// Handle _columnVisibility=[a,b,!c] → a,b,!c (single comma list; hidden fields
|
|
2665
|
+
// are `!`-prefixed. Only the brackets are structural; `!` and `,` are content.)
|
|
1138
2666
|
if (param.startsWith('_columnVisibility=')) {
|
|
1139
2667
|
const value = param.slice('_columnVisibility='.length);
|
|
1140
2668
|
if (value.startsWith('[') && value.endsWith(']')) {
|
|
@@ -1154,21 +2682,6 @@ const convertToDisplayFormat = search => {
|
|
|
1154
2682
|
return param;
|
|
1155
2683
|
}
|
|
1156
2684
|
|
|
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
2685
|
// Handle _field[operator,type]=value or _field[operator,type]=list[a,b,c]
|
|
1173
2686
|
const bracketMatch = param.match(/^_([^[]+)\[([^\]]+)\]=(.*)$/);
|
|
1174
2687
|
if (bracketMatch) {
|
|
@@ -1263,10 +2776,10 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1263
2776
|
return `${key}=[${value}]`;
|
|
1264
2777
|
}
|
|
1265
2778
|
|
|
1266
|
-
// Handle _columnVisibility
|
|
2779
|
+
// Handle _columnVisibility display `a,b,!c` → internal `[a,b,!c]`.
|
|
1267
2780
|
if (param.startsWith('_columnVisibility=')) {
|
|
1268
2781
|
const value = param.slice('_columnVisibility='.length);
|
|
1269
|
-
//
|
|
2782
|
+
// Already internal (bracketed) — leave it alone.
|
|
1270
2783
|
if (value.startsWith('[')) {
|
|
1271
2784
|
return param;
|
|
1272
2785
|
}
|
|
@@ -1282,17 +2795,8 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1282
2795
|
return `_columnOrder=[${value}]`;
|
|
1283
2796
|
}
|
|
1284
2797
|
|
|
1285
|
-
//
|
|
1286
|
-
if (param.startsWith('
|
|
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=')) {
|
|
2798
|
+
// _filters — pass through (no bracket conversion needed)
|
|
2799
|
+
if (param.startsWith('_filters=')) {
|
|
1296
2800
|
return param;
|
|
1297
2801
|
}
|
|
1298
2802
|
|
|
@@ -1339,9 +2843,8 @@ const getDecodedSearchFromUrl = (search, columns) => {
|
|
|
1339
2843
|
const hasPinnedWithoutBrackets = /(_pinnedColumnsLeft|_pinnedColumnsRight)=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1340
2844
|
const hasVisibilityWithoutBrackets = /_columnVisibility=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1341
2845
|
const hasColumnOrderWithoutBrackets = /_columnOrder=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1342
|
-
const hasRowGroupingWithoutBrackets = /_rowGrouping=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1343
2846
|
const hasBracketNotation = /\[.*\]=/.test(searchWithoutLeadingQuestion);
|
|
1344
|
-
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets
|
|
2847
|
+
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets) && !hasBracketNotation;
|
|
1345
2848
|
if (isDisplayFormat) {
|
|
1346
2849
|
return '?' + convertFromDisplayFormat(searchWithoutLeadingQuestion, columns);
|
|
1347
2850
|
}
|
|
@@ -1466,16 +2969,11 @@ const isValueValid = (value, field, columns, operator) => {
|
|
|
1466
2969
|
}
|
|
1467
2970
|
const type = (_column$type = column['type']) !== null && _column$type !== void 0 ? _column$type : 'string';
|
|
1468
2971
|
|
|
1469
|
-
// Only date
|
|
1470
|
-
if (type !== 'date'
|
|
2972
|
+
// Only date fails with 500s, other set themselves as undefined
|
|
2973
|
+
if (type !== 'date') {
|
|
1471
2974
|
return true;
|
|
1472
2975
|
}
|
|
1473
2976
|
|
|
1474
|
-
// just checking that rating is a number.
|
|
1475
|
-
if (type === 'rating') {
|
|
1476
|
-
return !isNaN(Number(value));
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
2977
|
// format: YYYY-MM-DD
|
|
1480
2978
|
// just verifying that the 3 values are numbers to avoid 500s,
|
|
1481
2979
|
// If the value is invalid the form will appear as undefined
|
|
@@ -1502,7 +3000,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
1502
3000
|
let quickFilterValues = [];
|
|
1503
3001
|
const searchParams = new URLSearchParams();
|
|
1504
3002
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
1505
|
-
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '
|
|
3003
|
+
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '_density', '_filters'].includes(key)) {
|
|
1506
3004
|
searchParams.set(key, value);
|
|
1507
3005
|
}
|
|
1508
3006
|
if (key === '_logicOperator') {
|
|
@@ -1779,13 +3277,75 @@ const getColumnVisibilityFromString = (searchString, columns) => {
|
|
|
1779
3277
|
if (value === '' || value === null || value === '[]') {
|
|
1780
3278
|
return 'invalid';
|
|
1781
3279
|
}
|
|
1782
|
-
const parsedFields = value.slice(1, value.length - 1).split(',');
|
|
1783
3280
|
const fields = columns.map(column => column.field);
|
|
3281
|
+
|
|
3282
|
+
// Back-compat READ-ONLY: the short-lived `v:[<visible>];h:[<hidden>]` form written
|
|
3283
|
+
// by 12.5.5-muiv8-alpha.5/alpha.6 (replaced by the URL-safe `!` form below — see
|
|
3284
|
+
// getSearchParamsFromColumnVisibility). Still parsed so any localStorage entry
|
|
3285
|
+
// persisted by those alphas keeps working; never written anymore. The two sets are
|
|
3286
|
+
// split on the fixed `];h:[` separator, so a `[` or `]` inside a field name does
|
|
3287
|
+
// not break parsing.
|
|
3288
|
+
if (value.startsWith('v:[') && value.endsWith(']') && value.includes('];h:[')) {
|
|
3289
|
+
const inner = value.slice('v:['.length, -1);
|
|
3290
|
+
const separatorIndex = inner.indexOf('];h:[');
|
|
3291
|
+
const visibleRaw = inner.slice(0, separatorIndex);
|
|
3292
|
+
const hiddenRaw = inner.slice(separatorIndex + '];h:['.length);
|
|
3293
|
+
const visibleFields = visibleRaw ? visibleRaw.split(',') : [];
|
|
3294
|
+
const hiddenFields = hiddenRaw ? hiddenRaw.split(',') : [];
|
|
3295
|
+
const visibility = {};
|
|
3296
|
+
// Static columns default to visible; only those explicitly hidden are false.
|
|
3297
|
+
// (A column added after the URL was written is absent from both lists and
|
|
3298
|
+
// correctly defaults to visible, matching MUI's behaviour.)
|
|
3299
|
+
for (const field of fields) {
|
|
3300
|
+
visibility[field] = !hiddenFields.includes(field);
|
|
3301
|
+
}
|
|
3302
|
+
// Dynamic keys that are not part of the static `columns` prop — preserve verbatim.
|
|
3303
|
+
for (const field of visibleFields) {
|
|
3304
|
+
if (!fields.includes(field)) {
|
|
3305
|
+
visibility[field] = true;
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
for (const field of hiddenFields) {
|
|
3309
|
+
if (!fields.includes(field)) {
|
|
3310
|
+
visibility[field] = false;
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
return visibility;
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
// Bracketed token list: new `[a,b,!c]` (hidden fields `!`-prefixed) or legacy
|
|
3317
|
+
// `[a,b,c]` (visible-only). Split on the comma delimiter only, so `[`/`]` inside a
|
|
3318
|
+
// dynamic field name survive.
|
|
3319
|
+
const inner = value.slice(1, value.length - 1);
|
|
3320
|
+
const tokens = inner ? inner.split(',') : [];
|
|
3321
|
+
|
|
3322
|
+
// New form iff at least one `!`-prefixed (explicitly hidden) token is present.
|
|
3323
|
+
if (tokens.some(token => token.startsWith('!'))) {
|
|
3324
|
+
const hiddenFields = tokens.filter(token => token.startsWith('!')).map(token => token.slice(1));
|
|
3325
|
+
const visibility = {};
|
|
3326
|
+
// Static columns default to visible; only those explicitly hidden are false.
|
|
3327
|
+
for (const field of fields) {
|
|
3328
|
+
visibility[field] = !hiddenFields.includes(field);
|
|
3329
|
+
}
|
|
3330
|
+
// Dynamic keys not in the static `columns` prop — insert in TOKEN ORDER (do not
|
|
3331
|
+
// regroup visible/hidden) so the writer re-emits a byte-identical URL and the RR
|
|
3332
|
+
// v5 adapter's idempotency guard stops the URL-sync loop (ODM-3033).
|
|
3333
|
+
for (const token of tokens) {
|
|
3334
|
+
const hidden = token.startsWith('!');
|
|
3335
|
+
const field = hidden ? token.slice(1) : token;
|
|
3336
|
+
if (!fields.includes(field)) {
|
|
3337
|
+
visibility[field] = !hidden;
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
return visibility;
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
// Legacy visible-only form: `[<visible>]` (hidden encoded implicitly by absence).
|
|
1784
3344
|
const visibility = {};
|
|
1785
3345
|
for (const field of fields) {
|
|
1786
3346
|
visibility[field] = false;
|
|
1787
3347
|
}
|
|
1788
|
-
for (const parsedField of
|
|
3348
|
+
for (const parsedField of tokens) {
|
|
1789
3349
|
if (fields.includes(parsedField)) {
|
|
1790
3350
|
visibility[parsedField] = true;
|
|
1791
3351
|
}
|
|
@@ -1812,8 +3372,24 @@ const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
|
1812
3372
|
[colName]: true
|
|
1813
3373
|
});
|
|
1814
3374
|
}, columnVisibility);
|
|
1815
|
-
|
|
1816
|
-
|
|
3375
|
+
|
|
3376
|
+
// Serialise a single comma list over the static columns plus any extra keys present
|
|
3377
|
+
// in the model (dynamically-generated fields, preserved in model order). Hidden
|
|
3378
|
+
// fields are prefixed `!`; visible fields are bare. This URL-safe form round-trips
|
|
3379
|
+
// idempotently through `URLSearchParams.toString()` percent-encoding — the earlier
|
|
3380
|
+
// `v:[..];h:[..]` form did NOT (its `:`/`;` were percent-encoded and mis-parsed on
|
|
3381
|
+
// read-back, driving an unbounded `history.replace` loop, ODM-3033). `!` (not `~`,
|
|
3382
|
+
// the compression sentinel — compression.ts COMPRESSED_PREFIX) is used so a leading
|
|
3383
|
+
// hidden field can't be mistaken for a compressed value. The hidden set is still
|
|
3384
|
+
// explicit, so deselected dynamic columns survive reloads.
|
|
3385
|
+
const allFields = [...fields];
|
|
3386
|
+
for (const field of Object.keys(finalColumnVisibility)) {
|
|
3387
|
+
if (!allFields.includes(field)) {
|
|
3388
|
+
allFields.push(field);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
const tokens = allFields.map(column => finalColumnVisibility[column] === false ? `!${column}` : column);
|
|
3392
|
+
searchParams.set('_columnVisibility', `[${tokens.join(',')}]`);
|
|
1817
3393
|
return searchParams;
|
|
1818
3394
|
};
|
|
1819
3395
|
|
|
@@ -2021,274 +3597,6 @@ const getSearchParamsFromColumnOrder = columnOrder => {
|
|
|
2021
3597
|
}
|
|
2022
3598
|
return searchParams;
|
|
2023
3599
|
};
|
|
2024
|
-
const getColumnOrder = (search, columns, localStorageColumnOrder, setLocalStorageColumnOrder, initialState, isNewVersion) => {
|
|
2025
|
-
var _initialState$columns4, _initialState$columns5;
|
|
2026
|
-
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);
|
|
2027
|
-
const persistDefault = () => {
|
|
2028
|
-
const searchFromDefault = getSearchParamsFromColumnOrder(defaultValue);
|
|
2029
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2030
|
-
if (searchString !== localStorageColumnOrder) {
|
|
2031
|
-
setLocalStorageColumnOrder(searchString);
|
|
2032
|
-
}
|
|
2033
|
-
};
|
|
2034
|
-
if (isNewVersion) {
|
|
2035
|
-
persistDefault();
|
|
2036
|
-
return defaultValue;
|
|
2037
|
-
}
|
|
2038
|
-
const fromUrl = getColumnOrderFromString(search);
|
|
2039
|
-
if (fromUrl !== 'invalid') {
|
|
2040
|
-
const searchFromModel = getSearchParamsFromColumnOrder(fromUrl);
|
|
2041
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2042
|
-
if (searchString !== localStorageColumnOrder) {
|
|
2043
|
-
setLocalStorageColumnOrder(searchString);
|
|
2044
|
-
}
|
|
2045
|
-
return fromUrl;
|
|
2046
|
-
}
|
|
2047
|
-
const fromLocalStorage = getColumnOrderFromString(localStorageColumnOrder);
|
|
2048
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2049
|
-
return fromLocalStorage;
|
|
2050
|
-
}
|
|
2051
|
-
persistDefault();
|
|
2052
|
-
return defaultValue;
|
|
2053
|
-
};
|
|
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
3600
|
|
|
2293
3601
|
/**
|
|
2294
3602
|
* Builds the `v=<version>` search param the grid uses to detect stale URLs.
|
|
@@ -2312,37 +3620,37 @@ const getSearchParamsFromVersion = version => {
|
|
|
2312
3620
|
searchParams.set('v', String(version));
|
|
2313
3621
|
return searchParams;
|
|
2314
3622
|
};
|
|
2315
|
-
const
|
|
2316
|
-
var _initialState$
|
|
2317
|
-
const defaultValue = (_initialState$
|
|
3623
|
+
const getColumnOrder = (search, columns, localStorageColumnOrder, setLocalStorageColumnOrder, initialState, isNewVersion) => {
|
|
3624
|
+
var _initialState$columns4, _initialState$columns5;
|
|
3625
|
+
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);
|
|
2318
3626
|
const persistDefault = () => {
|
|
2319
|
-
const searchFromDefault =
|
|
3627
|
+
const searchFromDefault = getSearchParamsFromColumnOrder(defaultValue);
|
|
2320
3628
|
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2321
|
-
if (searchString !==
|
|
2322
|
-
|
|
3629
|
+
if (searchString !== localStorageColumnOrder) {
|
|
3630
|
+
setLocalStorageColumnOrder(searchString);
|
|
2323
3631
|
}
|
|
2324
3632
|
};
|
|
2325
3633
|
if (isNewVersion) {
|
|
2326
3634
|
persistDefault();
|
|
2327
3635
|
return defaultValue;
|
|
2328
3636
|
}
|
|
2329
|
-
const fromUrl =
|
|
3637
|
+
const fromUrl = getColumnOrderFromString(search);
|
|
2330
3638
|
if (fromUrl !== 'invalid') {
|
|
2331
|
-
const searchFromModel =
|
|
3639
|
+
const searchFromModel = getSearchParamsFromColumnOrder(fromUrl);
|
|
2332
3640
|
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2333
|
-
if (searchString !==
|
|
2334
|
-
|
|
3641
|
+
if (searchString !== localStorageColumnOrder) {
|
|
3642
|
+
setLocalStorageColumnOrder(searchString);
|
|
2335
3643
|
}
|
|
2336
3644
|
return fromUrl;
|
|
2337
3645
|
}
|
|
2338
|
-
const fromLocalStorage =
|
|
3646
|
+
const fromLocalStorage = getColumnOrderFromString(localStorageColumnOrder);
|
|
2339
3647
|
if (fromLocalStorage !== 'invalid') {
|
|
2340
3648
|
return fromLocalStorage;
|
|
2341
3649
|
}
|
|
2342
3650
|
persistDefault();
|
|
2343
3651
|
return defaultValue;
|
|
2344
3652
|
};
|
|
2345
|
-
const getFinalSearch =
|
|
3653
|
+
const getFinalSearch = _ref => {
|
|
2346
3654
|
let {
|
|
2347
3655
|
search,
|
|
2348
3656
|
localStorageVersion,
|
|
@@ -2354,12 +3662,8 @@ const getFinalSearch = _ref3 => {
|
|
|
2354
3662
|
density,
|
|
2355
3663
|
columnOrderModel,
|
|
2356
3664
|
defaultColumnOrder,
|
|
2357
|
-
rowGroupingModel,
|
|
2358
|
-
aggregationModel,
|
|
2359
|
-
pivotModel,
|
|
2360
|
-
pivotActive,
|
|
2361
3665
|
columns
|
|
2362
|
-
} =
|
|
3666
|
+
} = _ref;
|
|
2363
3667
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
2364
3668
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
2365
3669
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -2368,10 +3672,6 @@ const getFinalSearch = _ref3 => {
|
|
|
2368
3672
|
const densitySearch = getSearchParamsFromDensity(density);
|
|
2369
3673
|
// Only include _columnOrder in URL when it differs from the default
|
|
2370
3674
|
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
3675
|
const tabSearch = getSearchParamsFromTab(search);
|
|
2376
3676
|
const searchParams = new URLSearchParams();
|
|
2377
3677
|
for (const [key, value] of new URLSearchParams(search)) {
|
|
@@ -2386,7 +3686,7 @@ const getFinalSearch = _ref3 => {
|
|
|
2386
3686
|
// Encode array as JSON string to preserve all values in one param
|
|
2387
3687
|
searchParams.set('_quickFilterValues', encodeURIComponent(JSON.stringify(filterModel.quickFilterValues)));
|
|
2388
3688
|
}
|
|
2389
|
-
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch
|
|
3689
|
+
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch]);
|
|
2390
3690
|
};
|
|
2391
3691
|
/** Return the state of the table given the URL and the local storage state */
|
|
2392
3692
|
const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, columns, initialState, localStorage) => {
|
|
@@ -2426,15 +3726,7 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2426
3726
|
localStorageDensity,
|
|
2427
3727
|
setLocalStorageDensity,
|
|
2428
3728
|
localStorageColumnOrder,
|
|
2429
|
-
setLocalStorageColumnOrder
|
|
2430
|
-
localStorageRowGrouping,
|
|
2431
|
-
setLocalStorageRowGrouping,
|
|
2432
|
-
localStorageAggregation,
|
|
2433
|
-
setLocalStorageAggregation,
|
|
2434
|
-
localStoragePivot,
|
|
2435
|
-
setLocalStoragePivot,
|
|
2436
|
-
localStoragePivotActive,
|
|
2437
|
-
setLocalStoragePivotActive
|
|
3729
|
+
setLocalStorageColumnOrder
|
|
2438
3730
|
} = localStorage;
|
|
2439
3731
|
const filterModel = getFilterModel(decodedSearch, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion);
|
|
2440
3732
|
const sortModel = getSortModel(decodedSearch, columns, localStorageSorting, setLocalStorageSorting, initialState, isNewVersion);
|
|
@@ -2443,10 +3735,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2443
3735
|
const pinnedColumnsModel = getPinnedColumns(decodedSearch, columns, localStoragePinnedColumns, setLocalStoragePinnedColumns, initialState, isNewVersion);
|
|
2444
3736
|
const density = getDensityModel(decodedSearch, localStorageDensity, setLocalStorageDensity, initialState, isNewVersion);
|
|
2445
3737
|
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
3738
|
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
3739
|
const finalSearch = getFinalSearch({
|
|
2452
3740
|
localStorageVersion,
|
|
@@ -2459,10 +3747,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2459
3747
|
density,
|
|
2460
3748
|
columnOrderModel,
|
|
2461
3749
|
defaultColumnOrder,
|
|
2462
|
-
rowGroupingModel,
|
|
2463
|
-
aggregationModel,
|
|
2464
|
-
pivotModel,
|
|
2465
|
-
pivotActive,
|
|
2466
3750
|
columns
|
|
2467
3751
|
});
|
|
2468
3752
|
const internalSearchString = urlSearchParamsToString(finalSearch);
|
|
@@ -2483,14 +3767,10 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2483
3767
|
pinnedColumnsModel,
|
|
2484
3768
|
density,
|
|
2485
3769
|
columnOrderModel,
|
|
2486
|
-
rowGroupingModel,
|
|
2487
|
-
aggregationModel,
|
|
2488
|
-
pivotModel,
|
|
2489
|
-
pivotActive,
|
|
2490
3770
|
pendingSearch
|
|
2491
3771
|
};
|
|
2492
3772
|
};
|
|
2493
|
-
const updateUrl = (
|
|
3773
|
+
const updateUrl = (_ref2, search, localStorageVersion, historyReplace, columns) => {
|
|
2494
3774
|
let {
|
|
2495
3775
|
filterModel,
|
|
2496
3776
|
sortModel,
|
|
@@ -2499,12 +3779,8 @@ const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns)
|
|
|
2499
3779
|
pinnedColumnsModel,
|
|
2500
3780
|
density,
|
|
2501
3781
|
columnOrderModel,
|
|
2502
|
-
defaultColumnOrder
|
|
2503
|
-
|
|
2504
|
-
aggregationModel,
|
|
2505
|
-
pivotModel,
|
|
2506
|
-
pivotActive
|
|
2507
|
-
} = _ref4;
|
|
3782
|
+
defaultColumnOrder
|
|
3783
|
+
} = _ref2;
|
|
2508
3784
|
// Convert from display format to internal format if needed
|
|
2509
3785
|
const decodedSearch = getDecodedSearchFromUrl(search, columns);
|
|
2510
3786
|
const newSearch = getFinalSearch({
|
|
@@ -2518,10 +3794,6 @@ const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns)
|
|
|
2518
3794
|
density,
|
|
2519
3795
|
columnOrderModel,
|
|
2520
3796
|
defaultColumnOrder,
|
|
2521
|
-
rowGroupingModel,
|
|
2522
|
-
aggregationModel,
|
|
2523
|
-
pivotModel,
|
|
2524
|
-
pivotActive,
|
|
2525
3797
|
columns
|
|
2526
3798
|
});
|
|
2527
3799
|
const internalSearchString = urlSearchParamsToString(newSearch);
|
|
@@ -2709,26 +3981,6 @@ const useTableStates = (id, version) => {
|
|
|
2709
3981
|
version,
|
|
2710
3982
|
category: COLUMN_ORDER_MODEL_KEY
|
|
2711
3983
|
}));
|
|
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
3984
|
return {
|
|
2733
3985
|
paginationModel,
|
|
2734
3986
|
setPaginationModel,
|
|
@@ -2745,41 +3997,13 @@ const useTableStates = (id, version) => {
|
|
|
2745
3997
|
densityModel,
|
|
2746
3998
|
setDensityModel,
|
|
2747
3999
|
columnOrderModel,
|
|
2748
|
-
setColumnOrderModel
|
|
2749
|
-
rowGroupingModel,
|
|
2750
|
-
setRowGroupingModel,
|
|
2751
|
-
aggregationModel,
|
|
2752
|
-
setAggregationModel,
|
|
2753
|
-
pivotModel,
|
|
2754
|
-
setPivotModel,
|
|
2755
|
-
pivotActive,
|
|
2756
|
-
setPivotActive
|
|
4000
|
+
setColumnOrderModel
|
|
2757
4001
|
};
|
|
2758
4002
|
};
|
|
2759
4003
|
|
|
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
4004
|
/**
|
|
2781
4005
|
* Deep-equal comparison for plain objects / arrays.
|
|
2782
|
-
* Used to stabilise parsed model references so that MUI
|
|
4006
|
+
* Used to stabilise parsed model references so that MUI does not
|
|
2783
4007
|
* reset pagination on every render.
|
|
2784
4008
|
*/
|
|
2785
4009
|
function isDeepEqual(a, b) {
|
|
@@ -2806,9 +4030,6 @@ const useStatefulTable = props => {
|
|
|
2806
4030
|
onPaginationModelChange: propsOnPaginationModelChange,
|
|
2807
4031
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
2808
4032
|
onSortModelChange: propsOnSortModelChange,
|
|
2809
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
2810
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
2811
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
2812
4033
|
useRouter,
|
|
2813
4034
|
localStorageVersion = 1,
|
|
2814
4035
|
previousLocalStorageVersions = []
|
|
@@ -2837,24 +4058,16 @@ const useStatefulTable = props => {
|
|
|
2837
4058
|
densityModel,
|
|
2838
4059
|
setDensityModel,
|
|
2839
4060
|
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
|
|
4061
|
+
setColumnOrderModel: setLocalStorageColumnOrder
|
|
2849
4062
|
} = useTableStates(id, localStorageVersion);
|
|
2850
4063
|
|
|
2851
4064
|
// clearing up old version keys, triggering only on first render
|
|
2852
4065
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
2853
|
-
const onColumnDimensionChange = useCallback(
|
|
4066
|
+
const onColumnDimensionChange = useCallback(_ref => {
|
|
2854
4067
|
let {
|
|
2855
4068
|
newWidth,
|
|
2856
4069
|
field
|
|
2857
|
-
} =
|
|
4070
|
+
} = _ref;
|
|
2858
4071
|
setDimensionModel(_objectSpread2(_objectSpread2({}, dimensionModel), {}, {
|
|
2859
4072
|
[field]: newWidth
|
|
2860
4073
|
}));
|
|
@@ -2867,10 +4080,6 @@ const useStatefulTable = props => {
|
|
|
2867
4080
|
pinnedColumnsModel,
|
|
2868
4081
|
density: densityParsed,
|
|
2869
4082
|
columnOrderModel: columnOrderParsed,
|
|
2870
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2871
|
-
aggregationModel: aggregationParsed,
|
|
2872
|
-
pivotModel: pivotParsed,
|
|
2873
|
-
pivotActive: pivotActiveParsed,
|
|
2874
4083
|
pendingSearch
|
|
2875
4084
|
} = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, initialState, {
|
|
2876
4085
|
localStorageFilters,
|
|
@@ -2886,15 +4095,7 @@ const useStatefulTable = props => {
|
|
|
2886
4095
|
localStorageDensity: densityModel,
|
|
2887
4096
|
setLocalStorageDensity: setDensityModel,
|
|
2888
4097
|
localStorageColumnOrder,
|
|
2889
|
-
setLocalStorageColumnOrder
|
|
2890
|
-
localStorageRowGrouping,
|
|
2891
|
-
setLocalStorageRowGrouping,
|
|
2892
|
-
localStorageAggregation,
|
|
2893
|
-
setLocalStorageAggregation,
|
|
2894
|
-
localStoragePivot,
|
|
2895
|
-
setLocalStoragePivot,
|
|
2896
|
-
localStoragePivotActive: localStoragePivotActive,
|
|
2897
|
-
setLocalStoragePivotActive: setLocalStoragePivotActive
|
|
4098
|
+
setLocalStorageColumnOrder
|
|
2898
4099
|
});
|
|
2899
4100
|
|
|
2900
4101
|
// Sync URL in an effect rather than during render to comply with React rules
|
|
@@ -2904,7 +4105,7 @@ const useStatefulTable = props => {
|
|
|
2904
4105
|
}
|
|
2905
4106
|
}, [pendingSearch, historyReplace]);
|
|
2906
4107
|
|
|
2907
|
-
// Stabilise parsed model references to prevent MUI
|
|
4108
|
+
// Stabilise parsed model references to prevent MUI from resetting
|
|
2908
4109
|
// pagination on every render due to new object identity.
|
|
2909
4110
|
const filterParsedRef = useRef(filterParsed);
|
|
2910
4111
|
if (!isDeepEqual(filterParsedRef.current, filterParsed)) {
|
|
@@ -2930,18 +4131,6 @@ const useStatefulTable = props => {
|
|
|
2930
4131
|
if (!isDeepEqual(columnOrderParsedRef.current, columnOrderParsed)) {
|
|
2931
4132
|
columnOrderParsedRef.current = columnOrderParsed;
|
|
2932
4133
|
}
|
|
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
4134
|
const columns = useMemo(() => propsColumns.map(column => {
|
|
2946
4135
|
return _objectSpread2(_objectSpread2({}, column), {}, {
|
|
2947
4136
|
width: dimensionModel[column.field] || column.width || 100
|
|
@@ -2950,13 +4139,29 @@ const useStatefulTable = props => {
|
|
|
2950
4139
|
if (apiRef.current) {
|
|
2951
4140
|
/** Add resetPage method to apiRef. */
|
|
2952
4141
|
apiRef.current.resetPage = () => {
|
|
2953
|
-
|
|
2954
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPage(0);
|
|
4142
|
+
apiRef.current.setPage(0);
|
|
2955
4143
|
};
|
|
2956
4144
|
}
|
|
2957
4145
|
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
4146
|
|
|
2959
|
-
//
|
|
4147
|
+
// Helper to build the current DataGridModel for updateUrl calls
|
|
4148
|
+
const buildModel = function () {
|
|
4149
|
+
var _apiRef$current$state, _apiRef$current;
|
|
4150
|
+
let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4151
|
+
return _objectSpread2({
|
|
4152
|
+
filterModel: filterParsed,
|
|
4153
|
+
sortModel: sortModelParsed,
|
|
4154
|
+
paginationModel: paginationModelParsed,
|
|
4155
|
+
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 : {},
|
|
4156
|
+
pinnedColumnsModel: pinnedColumnsModel,
|
|
4157
|
+
density: densityParsed,
|
|
4158
|
+
columnOrderModel: columnOrderParsed,
|
|
4159
|
+
defaultColumnOrder
|
|
4160
|
+
}, overrides);
|
|
4161
|
+
};
|
|
4162
|
+
|
|
4163
|
+
// Subscribe to density changes via stateChange event
|
|
4164
|
+
// (MUI v7 supports onDensityChange, but stateChange works and avoids a larger refactor)
|
|
2960
4165
|
useEffect(() => {
|
|
2961
4166
|
const api = apiRef.current;
|
|
2962
4167
|
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
@@ -2965,24 +4170,14 @@ const useStatefulTable = props => {
|
|
|
2965
4170
|
const currentDensity = api.state.density;
|
|
2966
4171
|
if (currentDensity !== prevDensity) {
|
|
2967
4172
|
prevDensity = currentDensity;
|
|
2968
|
-
updateUrl({
|
|
2969
|
-
filterModel: filterParsed,
|
|
2970
|
-
sortModel: sortModelParsed,
|
|
2971
|
-
paginationModel: paginationModelParsed,
|
|
4173
|
+
updateUrl(buildModel({
|
|
2972
4174
|
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);
|
|
4175
|
+
density: currentDensity
|
|
4176
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
2982
4177
|
}
|
|
2983
4178
|
});
|
|
2984
4179
|
return unsub;
|
|
2985
|
-
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder,
|
|
4180
|
+
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder, search, localStorageVersion, historyReplace, columns]);
|
|
2986
4181
|
|
|
2987
4182
|
// Subscribe to column order changes via columnOrderChange (drag-drop) and columnIndexChange (programmatic setColumnIndex)
|
|
2988
4183
|
useEffect(() => {
|
|
@@ -2991,20 +4186,9 @@ const useStatefulTable = props => {
|
|
|
2991
4186
|
const handleColumnOrderChange = () => {
|
|
2992
4187
|
const orderedFields = api.state.columns.orderedFields;
|
|
2993
4188
|
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);
|
|
4189
|
+
updateUrl(buildModel({
|
|
4190
|
+
columnOrderModel: orderedFields
|
|
4191
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3008
4192
|
}
|
|
3009
4193
|
};
|
|
3010
4194
|
const unsub1 = api.subscribeEvent('columnOrderChange', handleColumnOrderChange);
|
|
@@ -3013,53 +4197,28 @@ const useStatefulTable = props => {
|
|
|
3013
4197
|
unsub1();
|
|
3014
4198
|
unsub2();
|
|
3015
4199
|
};
|
|
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)]);
|
|
4200
|
+
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed, search, localStorageVersion, historyReplace, columns]);
|
|
3041
4201
|
|
|
3042
4202
|
// Track last emitted values for deep-equal guards to avoid feedback loops.
|
|
3043
4203
|
// Initialised from the current parsed values; updated only when we actually fire.
|
|
3044
4204
|
const lastEmittedFilterRef = useRef(filterParsed);
|
|
3045
4205
|
const lastEmittedSortRef = useRef(sortModelParsed);
|
|
3046
4206
|
const lastEmittedPaginationRef = useRef(paginationModelParsed);
|
|
3047
|
-
const lastEmittedPivotRef = useRef(pivotParsed);
|
|
3048
4207
|
return {
|
|
3049
4208
|
apiRef,
|
|
3050
4209
|
columns,
|
|
3051
4210
|
density: densityParsed,
|
|
4211
|
+
onDensityChange: newDensity => {
|
|
4212
|
+
updateUrl(buildModel({
|
|
4213
|
+
density: newDensity
|
|
4214
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
4215
|
+
},
|
|
3052
4216
|
columnOrderModel: columnOrderParsedRef.current,
|
|
3053
|
-
rowGroupingModel: rowGroupingParsedRef.current,
|
|
3054
|
-
aggregationModel: aggregationParsedRef.current,
|
|
3055
|
-
pivotModel: pivotModelMui,
|
|
3056
|
-
pivotActive: pivotActiveParsed,
|
|
3057
4217
|
onFilterModelChange: (model, details) => {
|
|
3058
4218
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
3059
4219
|
items: model.items.map(item => {
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
item.type = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
4220
|
+
const column = apiRef.current.getColumn(item.field);
|
|
4221
|
+
item.type = column.type || 'string';
|
|
3063
4222
|
return item;
|
|
3064
4223
|
}),
|
|
3065
4224
|
quickFilterValues: model.quickFilterValues || []
|
|
@@ -3082,20 +4241,10 @@ const useStatefulTable = props => {
|
|
|
3082
4241
|
},
|
|
3083
4242
|
sortModel: sortModelParsedRef.current,
|
|
3084
4243
|
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
4244
|
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
4245
|
+
updateUrl(buildModel({
|
|
4246
|
+
pinnedColumnsModel: pinnedColumns
|
|
4247
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3099
4248
|
},
|
|
3100
4249
|
pinnedColumns: pinnedColumnsModelRef.current,
|
|
3101
4250
|
paginationModel: paginationModelParsedRef.current,
|
|
@@ -3112,21 +4261,10 @@ const useStatefulTable = props => {
|
|
|
3112
4261
|
},
|
|
3113
4262
|
columnVisibilityModel: visibilityModelRef.current,
|
|
3114
4263
|
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
4264
|
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
4265
|
+
updateUrl(buildModel({
|
|
4266
|
+
columnsModel: columnsVisibilityModel
|
|
4267
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
3130
4268
|
},
|
|
3131
4269
|
onColumnWidthChange: (params, event, details) => {
|
|
3132
4270
|
propsOnColumnWidthChange === null || propsOnColumnWidthChange === void 0 ? void 0 : propsOnColumnWidthChange(params, event, details);
|
|
@@ -3134,38 +4272,11 @@ const useStatefulTable = props => {
|
|
|
3134
4272
|
newWidth: params.width,
|
|
3135
4273
|
field: params.colDef.field
|
|
3136
4274
|
});
|
|
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
4275
|
}
|
|
3165
4276
|
};
|
|
3166
4277
|
};
|
|
3167
4278
|
|
|
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", "
|
|
4279
|
+
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
4280
|
const COMPONENT_NAME = 'DataGrid';
|
|
3170
4281
|
const CLASSNAME = 'redsift-datagrid';
|
|
3171
4282
|
|
|
@@ -3249,11 +4360,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3249
4360
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
3250
4361
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
3251
4362
|
onSortModelChange: propsOnSortModelChange,
|
|
3252
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3253
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3254
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3255
4363
|
pagination,
|
|
3256
4364
|
paginationPlacement = 'both',
|
|
4365
|
+
selectionBannerPlacement = 'top',
|
|
3257
4366
|
paginationProps,
|
|
3258
4367
|
rows,
|
|
3259
4368
|
pageSizeOptions,
|
|
@@ -3261,26 +4370,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3261
4370
|
theme: propsTheme,
|
|
3262
4371
|
useRouter,
|
|
3263
4372
|
paginationMode = 'client',
|
|
3264
|
-
rowCount
|
|
3265
|
-
density: _density,
|
|
3266
|
-
dataSource,
|
|
3267
|
-
filterMode: propsFilterMode,
|
|
3268
|
-
sortingMode: propsSortingMode
|
|
4373
|
+
rowCount
|
|
3269
4374
|
} = props,
|
|
3270
4375
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
3271
|
-
const theme = useTheme(propsTheme);
|
|
4376
|
+
const theme = useTheme$1(propsTheme);
|
|
3272
4377
|
const _apiRef = useGridApiRef();
|
|
3273
4378
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
4379
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar;
|
|
3274
4380
|
LicenseInfo.setLicenseKey(license);
|
|
3275
4381
|
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
4382
|
const {
|
|
3285
4383
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
3286
4384
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
@@ -3306,6 +4404,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3306
4404
|
density: controlledDensity,
|
|
3307
4405
|
filterModel,
|
|
3308
4406
|
onColumnVisibilityModelChange,
|
|
4407
|
+
onDensityChange,
|
|
3309
4408
|
onFilterModelChange,
|
|
3310
4409
|
onPaginationModelChange,
|
|
3311
4410
|
onPinnedColumnsChange,
|
|
@@ -3314,15 +4413,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3314
4413
|
pinnedColumns,
|
|
3315
4414
|
sortModel,
|
|
3316
4415
|
onColumnWidthChange,
|
|
3317
|
-
columnOrderModel
|
|
3318
|
-
rowGroupingModel,
|
|
3319
|
-
aggregationModel,
|
|
3320
|
-
pivotModel,
|
|
3321
|
-
pivotActive,
|
|
3322
|
-
onRowGroupingModelChange,
|
|
3323
|
-
onAggregationModelChange,
|
|
3324
|
-
onPivotModelChange,
|
|
3325
|
-
onPivotActiveChange
|
|
4416
|
+
columnOrderModel
|
|
3326
4417
|
} = useStatefulTable({
|
|
3327
4418
|
apiRef: apiRef,
|
|
3328
4419
|
initialState,
|
|
@@ -3333,68 +4424,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3333
4424
|
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
3334
4425
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
3335
4426
|
onSortModelChange: controlledOnSortModelChange,
|
|
3336
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3337
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3338
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3339
4427
|
useRouter: useRouter,
|
|
3340
4428
|
localStorageVersion,
|
|
3341
4429
|
previousLocalStorageVersions
|
|
3342
4430
|
});
|
|
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.
|
|
4431
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3382
4432
|
useEffect(() => {
|
|
3383
|
-
|
|
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));
|
|
3396
|
-
useEffect(() => {
|
|
3397
|
-
setRowSelectionModel(normalizeRowSelectionModel(propsRowSelectionModel));
|
|
4433
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3398
4434
|
}, [propsRowSelectionModel]);
|
|
3399
4435
|
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
3400
4436
|
setRowSelectionModel(selectionModel);
|
|
@@ -3413,36 +4449,23 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3413
4449
|
|
|
3414
4450
|
// The checkboxSelectionVisibleOnly should only be applied to client-side pagination,
|
|
3415
4451
|
// for server-side pagination it produces inconsistent behavior when selecting all rows in pages 2 and beyond
|
|
3416
|
-
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(
|
|
3417
|
-
|
|
3418
|
-
// Track when the grid API is ready to ensure top pagination renders correctly
|
|
3419
|
-
const [gridReady, setGridReady] = useState(false);
|
|
3420
|
-
|
|
3421
|
-
// Force re-render when the grid API becomes ready (for top pagination)
|
|
3422
|
-
useEffect(() => {
|
|
3423
|
-
if (apiRef.current && !gridReady) {
|
|
3424
|
-
setGridReady(true);
|
|
3425
|
-
}
|
|
3426
|
-
});
|
|
4452
|
+
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(paginationMode != 'server');
|
|
3427
4453
|
|
|
3428
|
-
//
|
|
3429
|
-
//
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
}, [controlledDensity, apiRef]);
|
|
4454
|
+
// Banner and pager placements are independent. `belowToolbar` (for either) renders
|
|
4455
|
+
// in the toolbar-slot row, and only applies when pagination is on.
|
|
4456
|
+
const bannerAtTop = selectionBannerPlacement === 'top';
|
|
4457
|
+
const bannerAtBottom = selectionBannerPlacement === 'bottom';
|
|
4458
|
+
const bannerBelowToolbar = selectionBannerPlacement === 'belowToolbar' && Boolean(pagination);
|
|
4459
|
+
const pagerBelowToolbar = paginationPlacement === 'belowToolbar' && Boolean(pagination);
|
|
3435
4460
|
|
|
3436
4461
|
// in server-side pagination we want to update the selection status
|
|
3437
4462
|
// every time we navigate between pages, resize our page or select something
|
|
3438
4463
|
useEffect(() => {
|
|
3439
|
-
if (
|
|
3440
|
-
onServerSideSelectionStatusChange(rowSelectionModel, apiRef, selectionStatusRef, forceSelectionUpdate, isRowSelectable,
|
|
4464
|
+
if (paginationMode == 'server') {
|
|
4465
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatusRef, forceSelectionUpdate, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
3441
4466
|
}
|
|
3442
|
-
}, [rowSelectionModel,
|
|
3443
|
-
|
|
3444
|
-
// In dataSource mode MUI provides rows internally; skip the guard.
|
|
3445
|
-
if (!isDataSourceMode && !Array.isArray(rows)) {
|
|
4467
|
+
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize, rows]);
|
|
4468
|
+
if (!Array.isArray(rows)) {
|
|
3446
4469
|
return null;
|
|
3447
4470
|
}
|
|
3448
4471
|
|
|
@@ -3451,15 +4474,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3451
4474
|
// receive the fresh value in the same render cycle — no extra re-render needed.
|
|
3452
4475
|
// The ref is kept in sync for the onRowSelectionModelChange callback's deselect logic.
|
|
3453
4476
|
let selectionStatus = selectionStatusRef.current;
|
|
3454
|
-
if (pagination &&
|
|
4477
|
+
if (pagination && paginationMode !== 'server' && Array.isArray(rowSelectionModel) && rowSelectionModel.length > 0) {
|
|
3455
4478
|
try {
|
|
3456
|
-
// Use manual page slicing instead of
|
|
3457
|
-
//
|
|
3458
|
-
//
|
|
3459
|
-
|
|
3460
|
-
const pageStart =
|
|
3461
|
-
const
|
|
3462
|
-
const selectableRowsInPage = isRowSelectable ?
|
|
4479
|
+
// Use manual page slicing with our React state's paginationModel instead of
|
|
4480
|
+
// gridPaginatedVisibleSortedGridRow*Selector(apiRef). In MUI v7, the apiRef's
|
|
4481
|
+
// internal pagination state can lag behind the React state after a page change,
|
|
4482
|
+
// causing the selection status to be one page behind.
|
|
4483
|
+
const pageStart = paginationModel.page * paginationModel.pageSize;
|
|
4484
|
+
const pageEnd = pageStart + paginationModel.pageSize;
|
|
4485
|
+
const selectableRowsInPage = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).slice(pageStart, pageEnd).filter(_ref => {
|
|
3463
4486
|
let {
|
|
3464
4487
|
model
|
|
3465
4488
|
} = _ref;
|
|
@@ -3471,29 +4494,24 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3471
4494
|
id
|
|
3472
4495
|
} = _ref2;
|
|
3473
4496
|
return id;
|
|
3474
|
-
}) :
|
|
3475
|
-
let {
|
|
3476
|
-
id
|
|
3477
|
-
} = _ref3;
|
|
3478
|
-
return id;
|
|
3479
|
-
});
|
|
4497
|
+
}) : gridFilteredSortedRowIdsSelector(apiRef).slice(pageStart, pageEnd);
|
|
3480
4498
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3481
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
4499
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref3 => {
|
|
3482
4500
|
let {
|
|
3483
4501
|
model
|
|
3484
|
-
} =
|
|
4502
|
+
} = _ref3;
|
|
3485
4503
|
return isRowSelectable({
|
|
3486
4504
|
row: model
|
|
3487
4505
|
});
|
|
3488
|
-
}).map(
|
|
4506
|
+
}).map(_ref4 => {
|
|
3489
4507
|
let {
|
|
3490
4508
|
id
|
|
3491
|
-
} =
|
|
4509
|
+
} = _ref4;
|
|
3492
4510
|
return id;
|
|
3493
4511
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3494
4512
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3495
|
-
const numberOfSelectedRows =
|
|
3496
|
-
const selectedOnCurrentPage = selectableRowsInPage.filter(id =>
|
|
4513
|
+
const numberOfSelectedRows = rowSelectionModel.length;
|
|
4514
|
+
const selectedOnCurrentPage = selectableRowsInPage.filter(id => rowSelectionModel.includes(id));
|
|
3497
4515
|
if (numberOfSelectedRows === numberOfSelectableRowsInTable && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
3498
4516
|
selectionStatus = {
|
|
3499
4517
|
type: 'table',
|
|
@@ -3518,7 +4536,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3518
4536
|
} catch {
|
|
3519
4537
|
// apiRef may not be initialized on first render
|
|
3520
4538
|
}
|
|
3521
|
-
} else if (pagination &&
|
|
4539
|
+
} else if (pagination && paginationMode !== 'server') {
|
|
3522
4540
|
selectionStatus = {
|
|
3523
4541
|
type: 'none',
|
|
3524
4542
|
numberOfSelectedRows: 0
|
|
@@ -3547,120 +4565,41 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3547
4565
|
ref: datagridRef,
|
|
3548
4566
|
className: classNames(StatefulDataGrid.className, className),
|
|
3549
4567
|
$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,
|
|
4568
|
+
}, /*#__PURE__*/React__default.createElement(DataGridPro, _extends({}, forwardedProps, {
|
|
3565
4569
|
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, {
|
|
3572
|
-
apiRef: apiRef,
|
|
3573
|
-
dataSource: dataSource,
|
|
3574
4570
|
columns: columns,
|
|
4571
|
+
columnVisibilityModel: columnVisibilityModel,
|
|
4572
|
+
density: controlledDensity,
|
|
4573
|
+
filterModel: filterModel,
|
|
3575
4574
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
4575
|
+
onDensityChange: onDensityChange,
|
|
4576
|
+
onFilterModelChange: onFilterModelChange,
|
|
4577
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3576
4578
|
onPinnedColumnsChange: onPinnedColumnsChange,
|
|
4579
|
+
onSortModelChange: onSortModelChange,
|
|
4580
|
+
paginationModel: paginationModel,
|
|
4581
|
+
pinnedColumns: pinnedColumns,
|
|
4582
|
+
sortModel: sortModel,
|
|
3577
4583
|
pageSizeOptions: pageSizeOptions,
|
|
3578
4584
|
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
4585
|
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
4586
|
columns: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.columns), {}, {
|
|
3644
4587
|
orderedFields: columnOrderModel
|
|
3645
4588
|
})
|
|
3646
|
-
})
|
|
3647
|
-
}, {
|
|
4589
|
+
}),
|
|
3648
4590
|
isRowSelectable: isRowSelectable,
|
|
3649
4591
|
pagination: pagination,
|
|
3650
|
-
paginationMode:
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
keepNonExistentRowsSelected: effectivePaginationMode == 'server',
|
|
3654
|
-
rows: isDataSourceMode ? [] : rows,
|
|
4592
|
+
paginationMode: paginationMode,
|
|
4593
|
+
keepNonExistentRowsSelected: paginationMode == 'server',
|
|
4594
|
+
rows: rows,
|
|
3655
4595
|
rowCount: rowCount,
|
|
3656
4596
|
autoHeight: autoHeight,
|
|
3657
4597
|
checkboxSelectionVisibleOnly: checkboxSelectionVisibleOnly,
|
|
3658
|
-
disableRowSelectionExcludeModel: true,
|
|
3659
|
-
showToolbar: !hideToolbar,
|
|
3660
4598
|
slots: _objectSpread2(_objectSpread2({
|
|
3661
4599
|
baseButton: BaseButton,
|
|
3662
4600
|
baseCheckbox: BaseCheckbox,
|
|
3663
|
-
|
|
4601
|
+
// baseTextField,
|
|
4602
|
+
basePopper: BasePopper,
|
|
3664
4603
|
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3665
4604
|
displayName: "columnFilteredIcon"
|
|
3666
4605
|
})),
|
|
@@ -3695,33 +4634,45 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3695
4634
|
displayName: "openFilterButtonIcon"
|
|
3696
4635
|
}))
|
|
3697
4636
|
}, slots), {}, {
|
|
4637
|
+
toolbar: props => /*#__PURE__*/React__default.createElement(ToolbarWrapper, _extends({}, props, {
|
|
4638
|
+
hideToolbar: hideToolbar,
|
|
4639
|
+
RenderedToolbar: RenderedToolbar,
|
|
4640
|
+
filterModel: filterModel,
|
|
4641
|
+
onFilterModelChange: onFilterModelChange,
|
|
4642
|
+
pagination: pagination,
|
|
4643
|
+
displaySelection: bannerAtTop || bannerBelowToolbar,
|
|
4644
|
+
displayPagination: ['top', 'both'].includes(paginationPlacement) || pagerBelowToolbar,
|
|
4645
|
+
displayRowsPerPage: pagerBelowToolbar,
|
|
4646
|
+
selectionStatus: selectionStatus,
|
|
4647
|
+
apiRef: apiRef,
|
|
4648
|
+
isRowSelectable: isRowSelectable,
|
|
4649
|
+
paginationModel: paginationModel,
|
|
4650
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
4651
|
+
pageSizeOptions: pageSizeOptions,
|
|
4652
|
+
paginationProps: paginationProps,
|
|
4653
|
+
paginationMode: paginationMode,
|
|
4654
|
+
rowCount: rowCount
|
|
4655
|
+
})),
|
|
3698
4656
|
pagination: props => {
|
|
3699
|
-
return pagination ?
|
|
3700
|
-
displaySelection:
|
|
4657
|
+
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends({}, props, {
|
|
4658
|
+
displaySelection: bannerAtBottom,
|
|
3701
4659
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3702
4660
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
3703
4661
|
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,
|
|
4662
|
+
paginationModel: paginationModel,
|
|
4663
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3713
4664
|
pageSizeOptions: pageSizeOptions,
|
|
3714
4665
|
paginationProps: paginationProps,
|
|
3715
4666
|
rowCount: rowCount
|
|
3716
4667
|
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends({}, props, {
|
|
3717
|
-
displaySelection:
|
|
4668
|
+
displaySelection: bannerAtBottom,
|
|
3718
4669
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3719
4670
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
3720
4671
|
selectionStatus: selectionStatus,
|
|
3721
4672
|
apiRef: apiRef,
|
|
3722
4673
|
isRowSelectable: isRowSelectable,
|
|
3723
|
-
paginationModel:
|
|
3724
|
-
onPaginationModelChange:
|
|
4674
|
+
paginationModel: paginationModel,
|
|
4675
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3725
4676
|
pageSizeOptions: pageSizeOptions,
|
|
3726
4677
|
paginationProps: paginationProps
|
|
3727
4678
|
})) : null;
|
|
@@ -3730,50 +4681,41 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3730
4681
|
slotProps: _objectSpread2({}, slotProps),
|
|
3731
4682
|
rowSelectionModel: rowSelectionModel,
|
|
3732
4683
|
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
3733
|
-
if (pagination &&
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
const
|
|
3737
|
-
const pageStart = activePaginationModel.page * activePaginationModel.pageSize;
|
|
3738
|
-
const pageEntries = allFilteredEntries.slice(pageStart, pageStart + activePaginationModel.pageSize);
|
|
3739
|
-
const selectableRowsInPage = isRowSelectable ? pageEntries.filter(_ref6 => {
|
|
4684
|
+
if (pagination && paginationMode != 'server') {
|
|
4685
|
+
const cbPageStart = paginationModel.page * paginationModel.pageSize;
|
|
4686
|
+
const cbPageEnd = cbPageStart + paginationModel.pageSize;
|
|
4687
|
+
const selectableRowsInPage = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).slice(cbPageStart, cbPageEnd).filter(_ref5 => {
|
|
3740
4688
|
let {
|
|
3741
4689
|
model
|
|
3742
|
-
} =
|
|
4690
|
+
} = _ref5;
|
|
3743
4691
|
return isRowSelectable({
|
|
3744
4692
|
row: model
|
|
3745
4693
|
});
|
|
3746
|
-
}).map(
|
|
3747
|
-
let {
|
|
3748
|
-
id
|
|
3749
|
-
} = _ref7;
|
|
3750
|
-
return id;
|
|
3751
|
-
}) : pageEntries.map(_ref8 => {
|
|
4694
|
+
}).map(_ref6 => {
|
|
3752
4695
|
let {
|
|
3753
4696
|
id
|
|
3754
|
-
} =
|
|
4697
|
+
} = _ref6;
|
|
3755
4698
|
return id;
|
|
3756
|
-
});
|
|
4699
|
+
}) : gridFilteredSortedRowIdsSelector(apiRef).slice(cbPageStart, cbPageEnd);
|
|
3757
4700
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3758
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
4701
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref7 => {
|
|
3759
4702
|
let {
|
|
3760
4703
|
model
|
|
3761
|
-
} =
|
|
4704
|
+
} = _ref7;
|
|
3762
4705
|
return isRowSelectable({
|
|
3763
4706
|
row: model
|
|
3764
4707
|
});
|
|
3765
|
-
}).map(
|
|
4708
|
+
}).map(_ref8 => {
|
|
3766
4709
|
let {
|
|
3767
4710
|
id
|
|
3768
|
-
} =
|
|
4711
|
+
} = _ref8;
|
|
3769
4712
|
return id;
|
|
3770
4713
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3771
4714
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3772
|
-
const numberOfSelectedRows =
|
|
4715
|
+
const numberOfSelectedRows = newSelectionModel.length;
|
|
3773
4716
|
if (selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable - numberOfSelectableRowsInPage || selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable || selectionStatusRef.current.type === 'page' && numberOfSelectedRows === numberOfSelectableRowsInPage) {
|
|
3774
4717
|
setTimeout(() => {
|
|
3775
|
-
|
|
3776
|
-
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.selectRows([], true, true);
|
|
4718
|
+
apiRef.current.selectRows([], true, true);
|
|
3777
4719
|
}, 0);
|
|
3778
4720
|
}
|
|
3779
4721
|
if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
@@ -3815,5 +4757,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3815
4757
|
StatefulDataGrid.className = CLASSNAME;
|
|
3816
4758
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
3817
4759
|
|
|
3818
|
-
export {
|
|
4760
|
+
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, getDensityModel as ar, getColumnOrderFromString as as, getSearchParamsFromColumnOrder as at, getSearchParamsFromVersion as au, getFinalSearch as av, getModelsParsedOrUpdateLocalStorage as aw, updateUrl as ax, areFilterModelsEquivalent as ay, StatefulDataGrid as az, 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
4761
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|