@redsift/table 12.5.1 → 12.5.2-muiv6-alpha.2
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 +2449 -0
- package/_internal/BasePopper.js.map +1 -0
- package/_internal/ControlledPagination.js +10538 -0
- package/_internal/ControlledPagination.js.map +1 -0
- package/_internal/DataGrid2.js +76 -115
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/GridToolbarFilterSemanticField2.js +3 -1340
- package/_internal/GridToolbarFilterSemanticField2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/Portal.js +4363 -0
- package/_internal/Portal.js.map +1 -0
- package/_internal/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +1505 -761
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/Toolbar2.js +6 -23
- package/_internal/Toolbar2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +1 -1
- package/_internal/jsx-runtime.js +1342 -0
- package/_internal/jsx-runtime.js.map +1 -0
- package/_internal/useControlledDatagridState.js +211 -13
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +350 -500
- package/index.js +15 -46
- 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 -318
- package/_internal/ServerSideControlledPagination.js.map +0 -1
|
@@ -1,18 +1,1290 @@
|
|
|
1
|
-
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends } from './_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends$1 } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { useCallback, useEffect,
|
|
4
|
-
import { createTheme, ThemeProvider as ThemeProvider$1 } from '@mui/material/styles';
|
|
3
|
+
import React__default, { useCallback, useEffect, useMemo, forwardRef, useRef, useState } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { u as useControlledDatagridState, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
10
|
-
import Box from '@mui/material/Box';
|
|
11
|
-
import TextField from '@mui/material/TextField';
|
|
5
|
+
import { Icon, useTheme as useTheme$1, ThemeProvider, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite } from '@redsift/design-system';
|
|
6
|
+
import { getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputSingleSelect, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLogicOperator, useGridApiRef, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, DataGridPro } from '@mui/x-data-grid-pro';
|
|
7
|
+
import { L as LicenseInfo, u as useControlledDatagridState, T as ThemeProvider$1, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
12
8
|
import { mdiSync } from '@redsift/icons';
|
|
9
|
+
import { _ as _objectWithoutPropertiesLoose, a as _extends, d as defaultSxConfig, i as isPlainObject, s as styled, b as styleFunctionSx, u as useTheme, c as clsx, e as createTheme, T as THEME_ID, C as ClassNameGenerator, P as PropTypes, g as generateUtilityClasses, f as generateUtilityClass, h as styled$1, j as useThemeProps, k as capitalize, l as composeClasses, r as rootShouldForwardProp, m as refType } from './Portal.js';
|
|
10
|
+
import { j as jsxRuntimeExports } from './jsx-runtime.js';
|
|
11
|
+
import { u as useFormControl, a as formControlState, i as isAdornedStart, b as isFilled, F as FormControlContext, c as useId, d as Select, I as Input, e 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
|
+
function isMuiElement(element, muiNames) {
|
|
18
|
+
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const _excluded$7 = ["sx"];
|
|
22
|
+
const splitProps = props => {
|
|
23
|
+
var _props$theme$unstable, _props$theme;
|
|
24
|
+
const result = {
|
|
25
|
+
systemProps: {},
|
|
26
|
+
otherProps: {}
|
|
27
|
+
};
|
|
28
|
+
const config = (_props$theme$unstable = props == null ? void 0 : (_props$theme = props.theme) == null ? void 0 : _props$theme.unstable_sxConfig) != null ? _props$theme$unstable : defaultSxConfig;
|
|
29
|
+
Object.keys(props).forEach(prop => {
|
|
30
|
+
if (config[prop]) {
|
|
31
|
+
result.systemProps[prop] = props[prop];
|
|
32
|
+
} else {
|
|
33
|
+
result.otherProps[prop] = props[prop];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
function extendSxProp(props) {
|
|
39
|
+
const {
|
|
40
|
+
sx: inSx
|
|
41
|
+
} = props,
|
|
42
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
43
|
+
const {
|
|
44
|
+
systemProps,
|
|
45
|
+
otherProps
|
|
46
|
+
} = splitProps(other);
|
|
47
|
+
let finalSx;
|
|
48
|
+
if (Array.isArray(inSx)) {
|
|
49
|
+
finalSx = [systemProps, ...inSx];
|
|
50
|
+
} else if (typeof inSx === 'function') {
|
|
51
|
+
finalSx = (...args) => {
|
|
52
|
+
const result = inSx(...args);
|
|
53
|
+
if (!isPlainObject(result)) {
|
|
54
|
+
return systemProps;
|
|
55
|
+
}
|
|
56
|
+
return _extends({}, systemProps, result);
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
finalSx = _extends({}, systemProps, inSx);
|
|
60
|
+
}
|
|
61
|
+
return _extends({}, otherProps, {
|
|
62
|
+
sx: finalSx
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const _excluded$6 = ["className", "component"];
|
|
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 _extendSxProp = extendSxProp(inProps),
|
|
80
|
+
{
|
|
81
|
+
className,
|
|
82
|
+
component = 'div'
|
|
83
|
+
} = _extendSxProp,
|
|
84
|
+
other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded$6);
|
|
85
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BoxRoot, _extends({
|
|
86
|
+
as: component,
|
|
87
|
+
ref: ref,
|
|
88
|
+
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
89
|
+
theme: themeId ? theme[themeId] || theme : theme
|
|
90
|
+
}, other));
|
|
91
|
+
});
|
|
92
|
+
return Box;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const defaultTheme = createTheme();
|
|
96
|
+
const Box = createBox({
|
|
97
|
+
themeId: THEME_ID,
|
|
98
|
+
defaultTheme,
|
|
99
|
+
defaultClassName: 'MuiBox-root',
|
|
100
|
+
generateClassName: ClassNameGenerator.generate
|
|
101
|
+
});
|
|
102
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
|
103
|
+
// ----------------------------- Warning --------------------------------
|
|
104
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
105
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
106
|
+
// ----------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
children: PropTypes.node,
|
|
111
|
+
/**
|
|
112
|
+
* The component used for the root node.
|
|
113
|
+
* Either a string to use a HTML element or a component.
|
|
114
|
+
*/
|
|
115
|
+
component: PropTypes.elementType,
|
|
116
|
+
/**
|
|
117
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
118
|
+
*/
|
|
119
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
120
|
+
} : void 0;
|
|
121
|
+
var Box$1 = Box;
|
|
122
|
+
|
|
123
|
+
function getFormLabelUtilityClasses(slot) {
|
|
124
|
+
return generateUtilityClass('MuiFormLabel', slot);
|
|
125
|
+
}
|
|
126
|
+
const formLabelClasses = generateUtilityClasses('MuiFormLabel', ['root', 'colorSecondary', 'focused', 'disabled', 'error', 'filled', 'required', 'asterisk']);
|
|
127
|
+
var formLabelClasses$1 = formLabelClasses;
|
|
128
|
+
|
|
129
|
+
const _excluded$5 = ["children", "className", "color", "component", "disabled", "error", "filled", "focused", "required"];
|
|
130
|
+
const useUtilityClasses$4 = ownerState => {
|
|
131
|
+
const {
|
|
132
|
+
classes,
|
|
133
|
+
color,
|
|
134
|
+
focused,
|
|
135
|
+
disabled,
|
|
136
|
+
error,
|
|
137
|
+
filled,
|
|
138
|
+
required
|
|
139
|
+
} = ownerState;
|
|
140
|
+
const slots = {
|
|
141
|
+
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', filled && 'filled', focused && 'focused', required && 'required'],
|
|
142
|
+
asterisk: ['asterisk', error && 'error']
|
|
143
|
+
};
|
|
144
|
+
return composeClasses(slots, getFormLabelUtilityClasses, classes);
|
|
145
|
+
};
|
|
146
|
+
const FormLabelRoot = styled$1('label', {
|
|
147
|
+
name: 'MuiFormLabel',
|
|
148
|
+
slot: 'Root',
|
|
149
|
+
overridesResolver: ({
|
|
150
|
+
ownerState
|
|
151
|
+
}, styles) => {
|
|
152
|
+
return _extends({}, styles.root, ownerState.color === 'secondary' && styles.colorSecondary, ownerState.filled && styles.filled);
|
|
153
|
+
}
|
|
154
|
+
})(({
|
|
155
|
+
theme,
|
|
156
|
+
ownerState
|
|
157
|
+
}) => _extends({
|
|
158
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
159
|
+
}, theme.typography.body1, {
|
|
160
|
+
lineHeight: '1.4375em',
|
|
161
|
+
padding: 0,
|
|
162
|
+
position: 'relative',
|
|
163
|
+
[`&.${formLabelClasses$1.focused}`]: {
|
|
164
|
+
color: (theme.vars || theme).palette[ownerState.color].main
|
|
165
|
+
},
|
|
166
|
+
[`&.${formLabelClasses$1.disabled}`]: {
|
|
167
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
168
|
+
},
|
|
169
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
170
|
+
color: (theme.vars || theme).palette.error.main
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
const AsteriskComponent = styled$1('span', {
|
|
174
|
+
name: 'MuiFormLabel',
|
|
175
|
+
slot: 'Asterisk',
|
|
176
|
+
overridesResolver: (props, styles) => styles.asterisk
|
|
177
|
+
})(({
|
|
178
|
+
theme
|
|
179
|
+
}) => ({
|
|
180
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
181
|
+
color: (theme.vars || theme).palette.error.main
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
const FormLabel = /*#__PURE__*/React.forwardRef(function FormLabel(inProps, ref) {
|
|
185
|
+
const props = useThemeProps({
|
|
186
|
+
props: inProps,
|
|
187
|
+
name: 'MuiFormLabel'
|
|
188
|
+
});
|
|
189
|
+
const {
|
|
190
|
+
children,
|
|
191
|
+
className,
|
|
192
|
+
component = 'label'
|
|
193
|
+
} = props,
|
|
194
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
195
|
+
const muiFormControl = useFormControl();
|
|
196
|
+
const fcs = formControlState({
|
|
197
|
+
props,
|
|
198
|
+
muiFormControl,
|
|
199
|
+
states: ['color', 'required', 'focused', 'disabled', 'error', 'filled']
|
|
200
|
+
});
|
|
201
|
+
const ownerState = _extends({}, props, {
|
|
202
|
+
color: fcs.color || 'primary',
|
|
203
|
+
component,
|
|
204
|
+
disabled: fcs.disabled,
|
|
205
|
+
error: fcs.error,
|
|
206
|
+
filled: fcs.filled,
|
|
207
|
+
focused: fcs.focused,
|
|
208
|
+
required: fcs.required
|
|
209
|
+
});
|
|
210
|
+
const classes = useUtilityClasses$4(ownerState);
|
|
211
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(FormLabelRoot, _extends({
|
|
212
|
+
as: component,
|
|
213
|
+
ownerState: ownerState,
|
|
214
|
+
className: clsx(classes.root, className),
|
|
215
|
+
ref: ref
|
|
216
|
+
}, other, {
|
|
217
|
+
children: [children, fcs.required && /*#__PURE__*/jsxRuntimeExports.jsxs(AsteriskComponent, {
|
|
218
|
+
ownerState: ownerState,
|
|
219
|
+
"aria-hidden": true,
|
|
220
|
+
className: classes.asterisk,
|
|
221
|
+
children: ["\u2009", '*']
|
|
222
|
+
})]
|
|
223
|
+
}));
|
|
224
|
+
});
|
|
225
|
+
process.env.NODE_ENV !== "production" ? FormLabel.propTypes /* remove-proptypes */ = {
|
|
226
|
+
// ----------------------------- Warning --------------------------------
|
|
227
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
228
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
229
|
+
// ----------------------------------------------------------------------
|
|
230
|
+
/**
|
|
231
|
+
* The content of the component.
|
|
232
|
+
*/
|
|
233
|
+
children: PropTypes.node,
|
|
234
|
+
/**
|
|
235
|
+
* Override or extend the styles applied to the component.
|
|
236
|
+
*/
|
|
237
|
+
classes: PropTypes.object,
|
|
238
|
+
/**
|
|
239
|
+
* @ignore
|
|
240
|
+
*/
|
|
241
|
+
className: PropTypes.string,
|
|
242
|
+
/**
|
|
243
|
+
* The color of the component.
|
|
244
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
245
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
246
|
+
*/
|
|
247
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
248
|
+
/**
|
|
249
|
+
* The component used for the root node.
|
|
250
|
+
* Either a string to use a HTML element or a component.
|
|
251
|
+
*/
|
|
252
|
+
component: PropTypes.elementType,
|
|
253
|
+
/**
|
|
254
|
+
* If `true`, the label should be displayed in a disabled state.
|
|
255
|
+
*/
|
|
256
|
+
disabled: PropTypes.bool,
|
|
257
|
+
/**
|
|
258
|
+
* If `true`, the label is displayed in an error state.
|
|
259
|
+
*/
|
|
260
|
+
error: PropTypes.bool,
|
|
261
|
+
/**
|
|
262
|
+
* If `true`, the label should use filled classes key.
|
|
263
|
+
*/
|
|
264
|
+
filled: PropTypes.bool,
|
|
265
|
+
/**
|
|
266
|
+
* If `true`, the input of this label is focused (used by `FormGroup` components).
|
|
267
|
+
*/
|
|
268
|
+
focused: PropTypes.bool,
|
|
269
|
+
/**
|
|
270
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
271
|
+
*/
|
|
272
|
+
required: PropTypes.bool,
|
|
273
|
+
/**
|
|
274
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
275
|
+
*/
|
|
276
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
277
|
+
} : void 0;
|
|
278
|
+
var FormLabel$1 = FormLabel;
|
|
279
|
+
|
|
280
|
+
function getInputLabelUtilityClasses(slot) {
|
|
281
|
+
return generateUtilityClass('MuiInputLabel', slot);
|
|
282
|
+
}
|
|
283
|
+
generateUtilityClasses('MuiInputLabel', ['root', 'focused', 'disabled', 'error', 'required', 'asterisk', 'formControl', 'sizeSmall', 'shrink', 'animated', 'standard', 'filled', 'outlined']);
|
|
284
|
+
|
|
285
|
+
const _excluded$4 = ["disableAnimation", "margin", "shrink", "variant", "className"];
|
|
286
|
+
const useUtilityClasses$3 = ownerState => {
|
|
287
|
+
const {
|
|
288
|
+
classes,
|
|
289
|
+
formControl,
|
|
290
|
+
size,
|
|
291
|
+
shrink,
|
|
292
|
+
disableAnimation,
|
|
293
|
+
variant,
|
|
294
|
+
required
|
|
295
|
+
} = ownerState;
|
|
296
|
+
const slots = {
|
|
297
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size === 'small' && 'sizeSmall', variant],
|
|
298
|
+
asterisk: [required && 'asterisk']
|
|
299
|
+
};
|
|
300
|
+
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
301
|
+
return _extends({}, classes, composedClasses);
|
|
302
|
+
};
|
|
303
|
+
const InputLabelRoot = styled$1(FormLabel$1, {
|
|
304
|
+
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
|
305
|
+
name: 'MuiInputLabel',
|
|
306
|
+
slot: 'Root',
|
|
307
|
+
overridesResolver: (props, styles) => {
|
|
308
|
+
const {
|
|
309
|
+
ownerState
|
|
310
|
+
} = props;
|
|
311
|
+
return [{
|
|
312
|
+
[`& .${formLabelClasses$1.asterisk}`]: styles.asterisk
|
|
313
|
+
}, styles.root, ownerState.formControl && styles.formControl, ownerState.size === 'small' && styles.sizeSmall, ownerState.shrink && styles.shrink, !ownerState.disableAnimation && styles.animated, styles[ownerState.variant]];
|
|
314
|
+
}
|
|
315
|
+
})(({
|
|
316
|
+
theme,
|
|
317
|
+
ownerState
|
|
318
|
+
}) => _extends({
|
|
319
|
+
display: 'block',
|
|
320
|
+
transformOrigin: 'top left',
|
|
321
|
+
whiteSpace: 'nowrap',
|
|
322
|
+
overflow: 'hidden',
|
|
323
|
+
textOverflow: 'ellipsis',
|
|
324
|
+
maxWidth: '100%'
|
|
325
|
+
}, ownerState.formControl && {
|
|
326
|
+
position: 'absolute',
|
|
327
|
+
left: 0,
|
|
328
|
+
top: 0,
|
|
329
|
+
// slight alteration to spec spacing to match visual spec result
|
|
330
|
+
transform: 'translate(0, 20px) scale(1)'
|
|
331
|
+
}, ownerState.size === 'small' && {
|
|
332
|
+
// Compensation for the `Input.inputSizeSmall` style.
|
|
333
|
+
transform: 'translate(0, 17px) scale(1)'
|
|
334
|
+
}, ownerState.shrink && {
|
|
335
|
+
transform: 'translate(0, -1.5px) scale(0.75)',
|
|
336
|
+
transformOrigin: 'top left',
|
|
337
|
+
maxWidth: '133%'
|
|
338
|
+
}, !ownerState.disableAnimation && {
|
|
339
|
+
transition: theme.transitions.create(['color', 'transform', 'max-width'], {
|
|
340
|
+
duration: theme.transitions.duration.shorter,
|
|
341
|
+
easing: theme.transitions.easing.easeOut
|
|
342
|
+
})
|
|
343
|
+
}, ownerState.variant === 'filled' && _extends({
|
|
344
|
+
// Chrome's autofill feature gives the input field a yellow background.
|
|
345
|
+
// Since the input field is behind the label in the HTML tree,
|
|
346
|
+
// the input field is drawn last and hides the label with an opaque background color.
|
|
347
|
+
// zIndex: 1 will raise the label above opaque background-colors of input.
|
|
348
|
+
zIndex: 1,
|
|
349
|
+
pointerEvents: 'none',
|
|
350
|
+
transform: 'translate(12px, 16px) scale(1)',
|
|
351
|
+
maxWidth: 'calc(100% - 24px)'
|
|
352
|
+
}, ownerState.size === 'small' && {
|
|
353
|
+
transform: 'translate(12px, 13px) scale(1)'
|
|
354
|
+
}, ownerState.shrink && _extends({
|
|
355
|
+
userSelect: 'none',
|
|
356
|
+
pointerEvents: 'auto',
|
|
357
|
+
transform: 'translate(12px, 7px) scale(0.75)',
|
|
358
|
+
maxWidth: 'calc(133% - 24px)'
|
|
359
|
+
}, ownerState.size === 'small' && {
|
|
360
|
+
transform: 'translate(12px, 4px) scale(0.75)'
|
|
361
|
+
})), ownerState.variant === 'outlined' && _extends({
|
|
362
|
+
// see comment above on filled.zIndex
|
|
363
|
+
zIndex: 1,
|
|
364
|
+
pointerEvents: 'none',
|
|
365
|
+
transform: 'translate(14px, 16px) scale(1)',
|
|
366
|
+
maxWidth: 'calc(100% - 24px)'
|
|
367
|
+
}, ownerState.size === 'small' && {
|
|
368
|
+
transform: 'translate(14px, 9px) scale(1)'
|
|
369
|
+
}, ownerState.shrink && {
|
|
370
|
+
userSelect: 'none',
|
|
371
|
+
pointerEvents: 'auto',
|
|
372
|
+
// Theoretically, we should have (8+5)*2/0.75 = 34px
|
|
373
|
+
// but it feels a better when it bleeds a bit on the left, so 32px.
|
|
374
|
+
maxWidth: 'calc(133% - 32px)',
|
|
375
|
+
transform: 'translate(14px, -9px) scale(0.75)'
|
|
376
|
+
})));
|
|
377
|
+
const InputLabel = /*#__PURE__*/React.forwardRef(function InputLabel(inProps, ref) {
|
|
378
|
+
const props = useThemeProps({
|
|
379
|
+
name: 'MuiInputLabel',
|
|
380
|
+
props: inProps
|
|
381
|
+
});
|
|
382
|
+
const {
|
|
383
|
+
disableAnimation = false,
|
|
384
|
+
shrink: shrinkProp,
|
|
385
|
+
className
|
|
386
|
+
} = props,
|
|
387
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
388
|
+
const muiFormControl = useFormControl();
|
|
389
|
+
let shrink = shrinkProp;
|
|
390
|
+
if (typeof shrink === 'undefined' && muiFormControl) {
|
|
391
|
+
shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
|
392
|
+
}
|
|
393
|
+
const fcs = formControlState({
|
|
394
|
+
props,
|
|
395
|
+
muiFormControl,
|
|
396
|
+
states: ['size', 'variant', 'required']
|
|
397
|
+
});
|
|
398
|
+
const ownerState = _extends({}, props, {
|
|
399
|
+
disableAnimation,
|
|
400
|
+
formControl: muiFormControl,
|
|
401
|
+
shrink,
|
|
402
|
+
size: fcs.size,
|
|
403
|
+
variant: fcs.variant,
|
|
404
|
+
required: fcs.required
|
|
405
|
+
});
|
|
406
|
+
const classes = useUtilityClasses$3(ownerState);
|
|
407
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(InputLabelRoot, _extends({
|
|
408
|
+
"data-shrink": shrink,
|
|
409
|
+
ownerState: ownerState,
|
|
410
|
+
ref: ref,
|
|
411
|
+
className: clsx(classes.root, className)
|
|
412
|
+
}, other, {
|
|
413
|
+
classes: classes
|
|
414
|
+
}));
|
|
415
|
+
});
|
|
416
|
+
process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes */ = {
|
|
417
|
+
// ----------------------------- Warning --------------------------------
|
|
418
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
419
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
420
|
+
// ----------------------------------------------------------------------
|
|
421
|
+
/**
|
|
422
|
+
* The content of the component.
|
|
423
|
+
*/
|
|
424
|
+
children: PropTypes.node,
|
|
425
|
+
/**
|
|
426
|
+
* Override or extend the styles applied to the component.
|
|
427
|
+
*/
|
|
428
|
+
classes: PropTypes.object,
|
|
429
|
+
/**
|
|
430
|
+
* @ignore
|
|
431
|
+
*/
|
|
432
|
+
className: PropTypes.string,
|
|
433
|
+
/**
|
|
434
|
+
* The color of the component.
|
|
435
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
436
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
437
|
+
*/
|
|
438
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
439
|
+
/**
|
|
440
|
+
* If `true`, the transition animation is disabled.
|
|
441
|
+
* @default false
|
|
442
|
+
*/
|
|
443
|
+
disableAnimation: PropTypes.bool,
|
|
444
|
+
/**
|
|
445
|
+
* If `true`, the component is disabled.
|
|
446
|
+
*/
|
|
447
|
+
disabled: PropTypes.bool,
|
|
448
|
+
/**
|
|
449
|
+
* If `true`, the label is displayed in an error state.
|
|
450
|
+
*/
|
|
451
|
+
error: PropTypes.bool,
|
|
452
|
+
/**
|
|
453
|
+
* If `true`, the `input` of this label is focused.
|
|
454
|
+
*/
|
|
455
|
+
focused: PropTypes.bool,
|
|
456
|
+
/**
|
|
457
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
458
|
+
* FormControl.
|
|
459
|
+
*/
|
|
460
|
+
margin: PropTypes.oneOf(['dense']),
|
|
461
|
+
/**
|
|
462
|
+
* if `true`, the label will indicate that the `input` is required.
|
|
463
|
+
*/
|
|
464
|
+
required: PropTypes.bool,
|
|
465
|
+
/**
|
|
466
|
+
* If `true`, the label is shrunk.
|
|
467
|
+
*/
|
|
468
|
+
shrink: PropTypes.bool,
|
|
469
|
+
/**
|
|
470
|
+
* The size of the component.
|
|
471
|
+
* @default 'normal'
|
|
472
|
+
*/
|
|
473
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['normal', 'small']), PropTypes.string]),
|
|
474
|
+
/**
|
|
475
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
476
|
+
*/
|
|
477
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
478
|
+
/**
|
|
479
|
+
* The variant to use.
|
|
480
|
+
*/
|
|
481
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
482
|
+
} : void 0;
|
|
483
|
+
var InputLabel$1 = InputLabel;
|
|
484
|
+
|
|
485
|
+
function getFormControlUtilityClasses(slot) {
|
|
486
|
+
return generateUtilityClass('MuiFormControl', slot);
|
|
487
|
+
}
|
|
488
|
+
generateUtilityClasses('MuiFormControl', ['root', 'marginNone', 'marginNormal', 'marginDense', 'fullWidth', 'disabled']);
|
|
489
|
+
|
|
490
|
+
const _excluded$3 = ["children", "className", "color", "component", "disabled", "error", "focused", "fullWidth", "hiddenLabel", "margin", "required", "size", "variant"];
|
|
491
|
+
const useUtilityClasses$2 = ownerState => {
|
|
492
|
+
const {
|
|
493
|
+
classes,
|
|
494
|
+
margin,
|
|
495
|
+
fullWidth
|
|
496
|
+
} = ownerState;
|
|
497
|
+
const slots = {
|
|
498
|
+
root: ['root', margin !== 'none' && `margin${capitalize(margin)}`, fullWidth && 'fullWidth']
|
|
499
|
+
};
|
|
500
|
+
return composeClasses(slots, getFormControlUtilityClasses, classes);
|
|
501
|
+
};
|
|
502
|
+
const FormControlRoot = styled$1('div', {
|
|
503
|
+
name: 'MuiFormControl',
|
|
504
|
+
slot: 'Root',
|
|
505
|
+
overridesResolver: ({
|
|
506
|
+
ownerState
|
|
507
|
+
}, styles) => {
|
|
508
|
+
return _extends({}, styles.root, styles[`margin${capitalize(ownerState.margin)}`], ownerState.fullWidth && styles.fullWidth);
|
|
509
|
+
}
|
|
510
|
+
})(({
|
|
511
|
+
ownerState
|
|
512
|
+
}) => _extends({
|
|
513
|
+
display: 'inline-flex',
|
|
514
|
+
flexDirection: 'column',
|
|
515
|
+
position: 'relative',
|
|
516
|
+
// Reset fieldset default style.
|
|
517
|
+
minWidth: 0,
|
|
518
|
+
padding: 0,
|
|
519
|
+
margin: 0,
|
|
520
|
+
border: 0,
|
|
521
|
+
verticalAlign: 'top'
|
|
522
|
+
}, ownerState.margin === 'normal' && {
|
|
523
|
+
marginTop: 16,
|
|
524
|
+
marginBottom: 8
|
|
525
|
+
}, ownerState.margin === 'dense' && {
|
|
526
|
+
marginTop: 8,
|
|
527
|
+
marginBottom: 4
|
|
528
|
+
}, ownerState.fullWidth && {
|
|
529
|
+
width: '100%'
|
|
530
|
+
}));
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Provides context such as filled/focused/error/required for form inputs.
|
|
534
|
+
* Relying on the context provides high flexibility and ensures that the state always stays
|
|
535
|
+
* consistent across the children of the `FormControl`.
|
|
536
|
+
* This context is used by the following components:
|
|
537
|
+
*
|
|
538
|
+
* - FormLabel
|
|
539
|
+
* - FormHelperText
|
|
540
|
+
* - Input
|
|
541
|
+
* - InputLabel
|
|
542
|
+
*
|
|
543
|
+
* You can find one composition example below and more going to [the demos](/material-ui/react-text-field/#components).
|
|
544
|
+
*
|
|
545
|
+
* ```jsx
|
|
546
|
+
* <FormControl>
|
|
547
|
+
* <InputLabel htmlFor="my-input">Email address</InputLabel>
|
|
548
|
+
* <Input id="my-input" aria-describedby="my-helper-text" />
|
|
549
|
+
* <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
|
550
|
+
* </FormControl>
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* ⚠️ Only one `InputBase` can be used within a FormControl because it creates visual inconsistencies.
|
|
554
|
+
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
|
555
|
+
*/
|
|
556
|
+
const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps, ref) {
|
|
557
|
+
const props = useThemeProps({
|
|
558
|
+
props: inProps,
|
|
559
|
+
name: 'MuiFormControl'
|
|
560
|
+
});
|
|
561
|
+
const {
|
|
562
|
+
children,
|
|
563
|
+
className,
|
|
564
|
+
color = 'primary',
|
|
565
|
+
component = 'div',
|
|
566
|
+
disabled = false,
|
|
567
|
+
error = false,
|
|
568
|
+
focused: visuallyFocused,
|
|
569
|
+
fullWidth = false,
|
|
570
|
+
hiddenLabel = false,
|
|
571
|
+
margin = 'none',
|
|
572
|
+
required = false,
|
|
573
|
+
size = 'medium',
|
|
574
|
+
variant = 'outlined'
|
|
575
|
+
} = props,
|
|
576
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
577
|
+
const ownerState = _extends({}, props, {
|
|
578
|
+
color,
|
|
579
|
+
component,
|
|
580
|
+
disabled,
|
|
581
|
+
error,
|
|
582
|
+
fullWidth,
|
|
583
|
+
hiddenLabel,
|
|
584
|
+
margin,
|
|
585
|
+
required,
|
|
586
|
+
size,
|
|
587
|
+
variant
|
|
588
|
+
});
|
|
589
|
+
const classes = useUtilityClasses$2(ownerState);
|
|
590
|
+
const [adornedStart, setAdornedStart] = React.useState(() => {
|
|
591
|
+
// We need to iterate through the children and find the Input in order
|
|
592
|
+
// to fully support server-side rendering.
|
|
593
|
+
let initialAdornedStart = false;
|
|
594
|
+
if (children) {
|
|
595
|
+
React.Children.forEach(children, child => {
|
|
596
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const input = isMuiElement(child, ['Select']) ? child.props.input : child;
|
|
600
|
+
if (input && isAdornedStart(input.props)) {
|
|
601
|
+
initialAdornedStart = true;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
return initialAdornedStart;
|
|
606
|
+
});
|
|
607
|
+
const [filled, setFilled] = React.useState(() => {
|
|
608
|
+
// We need to iterate through the children and find the Input in order
|
|
609
|
+
// to fully support server-side rendering.
|
|
610
|
+
let initialFilled = false;
|
|
611
|
+
if (children) {
|
|
612
|
+
React.Children.forEach(children, child => {
|
|
613
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
|
|
617
|
+
initialFilled = true;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return initialFilled;
|
|
622
|
+
});
|
|
623
|
+
const [focusedState, setFocused] = React.useState(false);
|
|
624
|
+
if (disabled && focusedState) {
|
|
625
|
+
setFocused(false);
|
|
626
|
+
}
|
|
627
|
+
const focused = visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState;
|
|
628
|
+
let registerEffect;
|
|
629
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
630
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
631
|
+
const registeredInput = React.useRef(false);
|
|
632
|
+
registerEffect = () => {
|
|
633
|
+
if (registeredInput.current) {
|
|
634
|
+
console.error(['MUI: There are multiple `InputBase` components inside a FormControl.', 'This creates visual inconsistencies, only use one `InputBase`.'].join('\n'));
|
|
635
|
+
}
|
|
636
|
+
registeredInput.current = true;
|
|
637
|
+
return () => {
|
|
638
|
+
registeredInput.current = false;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const childContext = React.useMemo(() => {
|
|
643
|
+
return {
|
|
644
|
+
adornedStart,
|
|
645
|
+
setAdornedStart,
|
|
646
|
+
color,
|
|
647
|
+
disabled,
|
|
648
|
+
error,
|
|
649
|
+
filled,
|
|
650
|
+
focused,
|
|
651
|
+
fullWidth,
|
|
652
|
+
hiddenLabel,
|
|
653
|
+
size,
|
|
654
|
+
onBlur: () => {
|
|
655
|
+
setFocused(false);
|
|
656
|
+
},
|
|
657
|
+
onEmpty: () => {
|
|
658
|
+
setFilled(false);
|
|
659
|
+
},
|
|
660
|
+
onFilled: () => {
|
|
661
|
+
setFilled(true);
|
|
662
|
+
},
|
|
663
|
+
onFocus: () => {
|
|
664
|
+
setFocused(true);
|
|
665
|
+
},
|
|
666
|
+
registerEffect,
|
|
667
|
+
required,
|
|
668
|
+
variant
|
|
669
|
+
};
|
|
670
|
+
}, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, required, size, variant]);
|
|
671
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormControlContext.Provider, {
|
|
672
|
+
value: childContext,
|
|
673
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(FormControlRoot, _extends({
|
|
674
|
+
as: component,
|
|
675
|
+
ownerState: ownerState,
|
|
676
|
+
className: clsx(classes.root, className),
|
|
677
|
+
ref: ref
|
|
678
|
+
}, other, {
|
|
679
|
+
children: children
|
|
680
|
+
}))
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
process.env.NODE_ENV !== "production" ? FormControl.propTypes /* remove-proptypes */ = {
|
|
684
|
+
// ----------------------------- Warning --------------------------------
|
|
685
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
686
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
687
|
+
// ----------------------------------------------------------------------
|
|
688
|
+
/**
|
|
689
|
+
* The content of the component.
|
|
690
|
+
*/
|
|
691
|
+
children: PropTypes.node,
|
|
692
|
+
/**
|
|
693
|
+
* Override or extend the styles applied to the component.
|
|
694
|
+
*/
|
|
695
|
+
classes: PropTypes.object,
|
|
696
|
+
/**
|
|
697
|
+
* @ignore
|
|
698
|
+
*/
|
|
699
|
+
className: PropTypes.string,
|
|
700
|
+
/**
|
|
701
|
+
* The color of the component.
|
|
702
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
703
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
704
|
+
* @default 'primary'
|
|
705
|
+
*/
|
|
706
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
707
|
+
/**
|
|
708
|
+
* The component used for the root node.
|
|
709
|
+
* Either a string to use a HTML element or a component.
|
|
710
|
+
*/
|
|
711
|
+
component: PropTypes.elementType,
|
|
712
|
+
/**
|
|
713
|
+
* If `true`, the label, input and helper text should be displayed in a disabled state.
|
|
714
|
+
* @default false
|
|
715
|
+
*/
|
|
716
|
+
disabled: PropTypes.bool,
|
|
717
|
+
/**
|
|
718
|
+
* If `true`, the label is displayed in an error state.
|
|
719
|
+
* @default false
|
|
720
|
+
*/
|
|
721
|
+
error: PropTypes.bool,
|
|
722
|
+
/**
|
|
723
|
+
* If `true`, the component is displayed in focused state.
|
|
724
|
+
*/
|
|
725
|
+
focused: PropTypes.bool,
|
|
726
|
+
/**
|
|
727
|
+
* If `true`, the component will take up the full width of its container.
|
|
728
|
+
* @default false
|
|
729
|
+
*/
|
|
730
|
+
fullWidth: PropTypes.bool,
|
|
731
|
+
/**
|
|
732
|
+
* If `true`, the label is hidden.
|
|
733
|
+
* This is used to increase density for a `FilledInput`.
|
|
734
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
735
|
+
* @default false
|
|
736
|
+
*/
|
|
737
|
+
hiddenLabel: PropTypes.bool,
|
|
738
|
+
/**
|
|
739
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
740
|
+
* @default 'none'
|
|
741
|
+
*/
|
|
742
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
743
|
+
/**
|
|
744
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
745
|
+
* @default false
|
|
746
|
+
*/
|
|
747
|
+
required: PropTypes.bool,
|
|
748
|
+
/**
|
|
749
|
+
* The size of the component.
|
|
750
|
+
* @default 'medium'
|
|
751
|
+
*/
|
|
752
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
753
|
+
/**
|
|
754
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
755
|
+
*/
|
|
756
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
757
|
+
/**
|
|
758
|
+
* The variant to use.
|
|
759
|
+
* @default 'outlined'
|
|
760
|
+
*/
|
|
761
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
762
|
+
} : void 0;
|
|
763
|
+
var FormControl$1 = FormControl;
|
|
764
|
+
|
|
765
|
+
function getFormHelperTextUtilityClasses(slot) {
|
|
766
|
+
return generateUtilityClass('MuiFormHelperText', slot);
|
|
767
|
+
}
|
|
768
|
+
const formHelperTextClasses = generateUtilityClasses('MuiFormHelperText', ['root', 'error', 'disabled', 'sizeSmall', 'sizeMedium', 'contained', 'focused', 'filled', 'required']);
|
|
769
|
+
var formHelperTextClasses$1 = formHelperTextClasses;
|
|
770
|
+
|
|
771
|
+
var _span;
|
|
772
|
+
const _excluded$2 = ["children", "className", "component", "disabled", "error", "filled", "focused", "margin", "required", "variant"];
|
|
773
|
+
const useUtilityClasses$1 = ownerState => {
|
|
774
|
+
const {
|
|
775
|
+
classes,
|
|
776
|
+
contained,
|
|
777
|
+
size,
|
|
778
|
+
disabled,
|
|
779
|
+
error,
|
|
780
|
+
filled,
|
|
781
|
+
focused,
|
|
782
|
+
required
|
|
783
|
+
} = ownerState;
|
|
784
|
+
const slots = {
|
|
785
|
+
root: ['root', disabled && 'disabled', error && 'error', size && `size${capitalize(size)}`, contained && 'contained', focused && 'focused', filled && 'filled', required && 'required']
|
|
786
|
+
};
|
|
787
|
+
return composeClasses(slots, getFormHelperTextUtilityClasses, classes);
|
|
788
|
+
};
|
|
789
|
+
const FormHelperTextRoot = styled$1('p', {
|
|
790
|
+
name: 'MuiFormHelperText',
|
|
791
|
+
slot: 'Root',
|
|
792
|
+
overridesResolver: (props, styles) => {
|
|
793
|
+
const {
|
|
794
|
+
ownerState
|
|
795
|
+
} = props;
|
|
796
|
+
return [styles.root, ownerState.size && styles[`size${capitalize(ownerState.size)}`], ownerState.contained && styles.contained, ownerState.filled && styles.filled];
|
|
797
|
+
}
|
|
798
|
+
})(({
|
|
799
|
+
theme,
|
|
800
|
+
ownerState
|
|
801
|
+
}) => _extends({
|
|
802
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
803
|
+
}, theme.typography.caption, {
|
|
804
|
+
textAlign: 'left',
|
|
805
|
+
marginTop: 3,
|
|
806
|
+
marginRight: 0,
|
|
807
|
+
marginBottom: 0,
|
|
808
|
+
marginLeft: 0,
|
|
809
|
+
[`&.${formHelperTextClasses$1.disabled}`]: {
|
|
810
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
811
|
+
},
|
|
812
|
+
[`&.${formHelperTextClasses$1.error}`]: {
|
|
813
|
+
color: (theme.vars || theme).palette.error.main
|
|
814
|
+
}
|
|
815
|
+
}, ownerState.size === 'small' && {
|
|
816
|
+
marginTop: 4
|
|
817
|
+
}, ownerState.contained && {
|
|
818
|
+
marginLeft: 14,
|
|
819
|
+
marginRight: 14
|
|
820
|
+
}));
|
|
821
|
+
const FormHelperText = /*#__PURE__*/React.forwardRef(function FormHelperText(inProps, ref) {
|
|
822
|
+
const props = useThemeProps({
|
|
823
|
+
props: inProps,
|
|
824
|
+
name: 'MuiFormHelperText'
|
|
825
|
+
});
|
|
826
|
+
const {
|
|
827
|
+
children,
|
|
828
|
+
className,
|
|
829
|
+
component = 'p'
|
|
830
|
+
} = props,
|
|
831
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
832
|
+
const muiFormControl = useFormControl();
|
|
833
|
+
const fcs = formControlState({
|
|
834
|
+
props,
|
|
835
|
+
muiFormControl,
|
|
836
|
+
states: ['variant', 'size', 'disabled', 'error', 'filled', 'focused', 'required']
|
|
837
|
+
});
|
|
838
|
+
const ownerState = _extends({}, props, {
|
|
839
|
+
component,
|
|
840
|
+
contained: fcs.variant === 'filled' || fcs.variant === 'outlined',
|
|
841
|
+
variant: fcs.variant,
|
|
842
|
+
size: fcs.size,
|
|
843
|
+
disabled: fcs.disabled,
|
|
844
|
+
error: fcs.error,
|
|
845
|
+
filled: fcs.filled,
|
|
846
|
+
focused: fcs.focused,
|
|
847
|
+
required: fcs.required
|
|
848
|
+
});
|
|
849
|
+
const classes = useUtilityClasses$1(ownerState);
|
|
850
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperTextRoot, _extends({
|
|
851
|
+
as: component,
|
|
852
|
+
ownerState: ownerState,
|
|
853
|
+
className: clsx(classes.root, className),
|
|
854
|
+
ref: ref
|
|
855
|
+
}, other, {
|
|
856
|
+
children: children === ' ' ? // notranslate needed while Google Translate will not fix zero-width space issue
|
|
857
|
+
_span || (_span = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
858
|
+
className: "notranslate",
|
|
859
|
+
children: "\u200B"
|
|
860
|
+
})) : children
|
|
861
|
+
}));
|
|
862
|
+
});
|
|
863
|
+
process.env.NODE_ENV !== "production" ? FormHelperText.propTypes /* remove-proptypes */ = {
|
|
864
|
+
// ----------------------------- Warning --------------------------------
|
|
865
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
866
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
867
|
+
// ----------------------------------------------------------------------
|
|
868
|
+
/**
|
|
869
|
+
* The content of the component.
|
|
870
|
+
*
|
|
871
|
+
* If `' '` is provided, the component reserves one line height for displaying a future message.
|
|
872
|
+
*/
|
|
873
|
+
children: PropTypes.node,
|
|
874
|
+
/**
|
|
875
|
+
* Override or extend the styles applied to the component.
|
|
876
|
+
*/
|
|
877
|
+
classes: PropTypes.object,
|
|
878
|
+
/**
|
|
879
|
+
* @ignore
|
|
880
|
+
*/
|
|
881
|
+
className: PropTypes.string,
|
|
882
|
+
/**
|
|
883
|
+
* The component used for the root node.
|
|
884
|
+
* Either a string to use a HTML element or a component.
|
|
885
|
+
*/
|
|
886
|
+
component: PropTypes.elementType,
|
|
887
|
+
/**
|
|
888
|
+
* If `true`, the helper text should be displayed in a disabled state.
|
|
889
|
+
*/
|
|
890
|
+
disabled: PropTypes.bool,
|
|
891
|
+
/**
|
|
892
|
+
* If `true`, helper text should be displayed in an error state.
|
|
893
|
+
*/
|
|
894
|
+
error: PropTypes.bool,
|
|
895
|
+
/**
|
|
896
|
+
* If `true`, the helper text should use filled classes key.
|
|
897
|
+
*/
|
|
898
|
+
filled: PropTypes.bool,
|
|
899
|
+
/**
|
|
900
|
+
* If `true`, the helper text should use focused classes key.
|
|
901
|
+
*/
|
|
902
|
+
focused: PropTypes.bool,
|
|
903
|
+
/**
|
|
904
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
905
|
+
* FormControl.
|
|
906
|
+
*/
|
|
907
|
+
margin: PropTypes.oneOf(['dense']),
|
|
908
|
+
/**
|
|
909
|
+
* If `true`, the helper text should use required classes key.
|
|
910
|
+
*/
|
|
911
|
+
required: PropTypes.bool,
|
|
912
|
+
/**
|
|
913
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
914
|
+
*/
|
|
915
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
916
|
+
/**
|
|
917
|
+
* The variant to use.
|
|
918
|
+
*/
|
|
919
|
+
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
|
920
|
+
} : void 0;
|
|
921
|
+
var FormHelperText$1 = FormHelperText;
|
|
922
|
+
|
|
923
|
+
function getTextFieldUtilityClass(slot) {
|
|
924
|
+
return generateUtilityClass('MuiTextField', slot);
|
|
925
|
+
}
|
|
926
|
+
generateUtilityClasses('MuiTextField', ['root']);
|
|
927
|
+
|
|
928
|
+
const _excluded$1 = ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onClick", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"];
|
|
929
|
+
const variantComponent = {
|
|
930
|
+
standard: Input,
|
|
931
|
+
filled: FilledInput,
|
|
932
|
+
outlined: OutlinedInput
|
|
933
|
+
};
|
|
934
|
+
const useUtilityClasses = ownerState => {
|
|
935
|
+
const {
|
|
936
|
+
classes
|
|
937
|
+
} = ownerState;
|
|
938
|
+
const slots = {
|
|
939
|
+
root: ['root']
|
|
940
|
+
};
|
|
941
|
+
return composeClasses(slots, getTextFieldUtilityClass, classes);
|
|
942
|
+
};
|
|
943
|
+
const TextFieldRoot = styled$1(FormControl$1, {
|
|
944
|
+
name: 'MuiTextField',
|
|
945
|
+
slot: 'Root',
|
|
946
|
+
overridesResolver: (props, styles) => styles.root
|
|
947
|
+
})({});
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* The `TextField` is a convenience wrapper for the most common cases (80%).
|
|
951
|
+
* It cannot be all things to all people, otherwise the API would grow out of control.
|
|
952
|
+
*
|
|
953
|
+
* ## Advanced Configuration
|
|
954
|
+
*
|
|
955
|
+
* It's important to understand that the text field is a simple abstraction
|
|
956
|
+
* on top of the following components:
|
|
957
|
+
*
|
|
958
|
+
* - [FormControl](/material-ui/api/form-control/)
|
|
959
|
+
* - [InputLabel](/material-ui/api/input-label/)
|
|
960
|
+
* - [FilledInput](/material-ui/api/filled-input/)
|
|
961
|
+
* - [OutlinedInput](/material-ui/api/outlined-input/)
|
|
962
|
+
* - [Input](/material-ui/api/input/)
|
|
963
|
+
* - [FormHelperText](/material-ui/api/form-helper-text/)
|
|
964
|
+
*
|
|
965
|
+
* If you wish to alter the props applied to the `input` element, you can do so as follows:
|
|
966
|
+
*
|
|
967
|
+
* ```jsx
|
|
968
|
+
* const inputProps = {
|
|
969
|
+
* step: 300,
|
|
970
|
+
* };
|
|
971
|
+
*
|
|
972
|
+
* return <TextField id="time" type="time" inputProps={inputProps} />;
|
|
973
|
+
* ```
|
|
974
|
+
*
|
|
975
|
+
* For advanced cases, please look at the source of TextField by clicking on the
|
|
976
|
+
* "Edit this page" button above. Consider either:
|
|
977
|
+
*
|
|
978
|
+
* - using the upper case props for passing values directly to the components
|
|
979
|
+
* - using the underlying components directly as shown in the demos
|
|
980
|
+
*/
|
|
981
|
+
const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
|
|
982
|
+
const props = useThemeProps({
|
|
983
|
+
props: inProps,
|
|
984
|
+
name: 'MuiTextField'
|
|
985
|
+
});
|
|
986
|
+
const {
|
|
987
|
+
autoComplete,
|
|
988
|
+
autoFocus = false,
|
|
989
|
+
children,
|
|
990
|
+
className,
|
|
991
|
+
color = 'primary',
|
|
992
|
+
defaultValue,
|
|
993
|
+
disabled = false,
|
|
994
|
+
error = false,
|
|
995
|
+
FormHelperTextProps,
|
|
996
|
+
fullWidth = false,
|
|
997
|
+
helperText,
|
|
998
|
+
id: idOverride,
|
|
999
|
+
InputLabelProps,
|
|
1000
|
+
inputProps,
|
|
1001
|
+
InputProps,
|
|
1002
|
+
inputRef,
|
|
1003
|
+
label,
|
|
1004
|
+
maxRows,
|
|
1005
|
+
minRows,
|
|
1006
|
+
multiline = false,
|
|
1007
|
+
name,
|
|
1008
|
+
onBlur,
|
|
1009
|
+
onChange,
|
|
1010
|
+
onClick,
|
|
1011
|
+
onFocus,
|
|
1012
|
+
placeholder,
|
|
1013
|
+
required = false,
|
|
1014
|
+
rows,
|
|
1015
|
+
select = false,
|
|
1016
|
+
SelectProps,
|
|
1017
|
+
type,
|
|
1018
|
+
value,
|
|
1019
|
+
variant = 'outlined'
|
|
1020
|
+
} = props,
|
|
1021
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
1022
|
+
const ownerState = _extends({}, props, {
|
|
1023
|
+
autoFocus,
|
|
1024
|
+
color,
|
|
1025
|
+
disabled,
|
|
1026
|
+
error,
|
|
1027
|
+
fullWidth,
|
|
1028
|
+
multiline,
|
|
1029
|
+
required,
|
|
1030
|
+
select,
|
|
1031
|
+
variant
|
|
1032
|
+
});
|
|
1033
|
+
const classes = useUtilityClasses(ownerState);
|
|
1034
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1035
|
+
if (select && !children) {
|
|
1036
|
+
console.error('MUI: `children` must be passed when using the `TextField` component with `select`.');
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
const InputMore = {};
|
|
1040
|
+
if (variant === 'outlined') {
|
|
1041
|
+
if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
|
|
1042
|
+
InputMore.notched = InputLabelProps.shrink;
|
|
1043
|
+
}
|
|
1044
|
+
InputMore.label = label;
|
|
1045
|
+
}
|
|
1046
|
+
if (select) {
|
|
1047
|
+
// unset defaults from textbox inputs
|
|
1048
|
+
if (!SelectProps || !SelectProps.native) {
|
|
1049
|
+
InputMore.id = undefined;
|
|
1050
|
+
}
|
|
1051
|
+
InputMore['aria-describedby'] = undefined;
|
|
1052
|
+
}
|
|
1053
|
+
const id = useId(idOverride);
|
|
1054
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
1055
|
+
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
1056
|
+
const InputComponent = variantComponent[variant];
|
|
1057
|
+
const InputElement = /*#__PURE__*/jsxRuntimeExports.jsx(InputComponent, _extends({
|
|
1058
|
+
"aria-describedby": helperTextId,
|
|
1059
|
+
autoComplete: autoComplete,
|
|
1060
|
+
autoFocus: autoFocus,
|
|
1061
|
+
defaultValue: defaultValue,
|
|
1062
|
+
fullWidth: fullWidth,
|
|
1063
|
+
multiline: multiline,
|
|
1064
|
+
name: name,
|
|
1065
|
+
rows: rows,
|
|
1066
|
+
maxRows: maxRows,
|
|
1067
|
+
minRows: minRows,
|
|
1068
|
+
type: type,
|
|
1069
|
+
value: value,
|
|
1070
|
+
id: id,
|
|
1071
|
+
inputRef: inputRef,
|
|
1072
|
+
onBlur: onBlur,
|
|
1073
|
+
onChange: onChange,
|
|
1074
|
+
onFocus: onFocus,
|
|
1075
|
+
onClick: onClick,
|
|
1076
|
+
placeholder: placeholder,
|
|
1077
|
+
inputProps: inputProps
|
|
1078
|
+
}, InputMore, InputProps));
|
|
1079
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(TextFieldRoot, _extends({
|
|
1080
|
+
className: clsx(classes.root, className),
|
|
1081
|
+
disabled: disabled,
|
|
1082
|
+
error: error,
|
|
1083
|
+
fullWidth: fullWidth,
|
|
1084
|
+
ref: ref,
|
|
1085
|
+
required: required,
|
|
1086
|
+
color: color,
|
|
1087
|
+
variant: variant,
|
|
1088
|
+
ownerState: ownerState
|
|
1089
|
+
}, other, {
|
|
1090
|
+
children: [label != null && label !== '' && /*#__PURE__*/jsxRuntimeExports.jsx(InputLabel$1, _extends({
|
|
1091
|
+
htmlFor: id,
|
|
1092
|
+
id: inputLabelId
|
|
1093
|
+
}, InputLabelProps, {
|
|
1094
|
+
children: label
|
|
1095
|
+
})), select ? /*#__PURE__*/jsxRuntimeExports.jsx(Select, _extends({
|
|
1096
|
+
"aria-describedby": helperTextId,
|
|
1097
|
+
id: id,
|
|
1098
|
+
labelId: inputLabelId,
|
|
1099
|
+
value: value,
|
|
1100
|
+
input: InputElement
|
|
1101
|
+
}, SelectProps, {
|
|
1102
|
+
children: children
|
|
1103
|
+
})) : InputElement, helperText && /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperText$1, _extends({
|
|
1104
|
+
id: helperTextId
|
|
1105
|
+
}, FormHelperTextProps, {
|
|
1106
|
+
children: helperText
|
|
1107
|
+
}))]
|
|
1108
|
+
}));
|
|
1109
|
+
});
|
|
1110
|
+
process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes */ = {
|
|
1111
|
+
// ----------------------------- Warning --------------------------------
|
|
1112
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
1113
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
1114
|
+
// ----------------------------------------------------------------------
|
|
1115
|
+
/**
|
|
1116
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
1117
|
+
* The name can be confusing, as it's more like an autofill.
|
|
1118
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
1119
|
+
*/
|
|
1120
|
+
autoComplete: PropTypes.string,
|
|
1121
|
+
/**
|
|
1122
|
+
* If `true`, the `input` element is focused during the first mount.
|
|
1123
|
+
* @default false
|
|
1124
|
+
*/
|
|
1125
|
+
autoFocus: PropTypes.bool,
|
|
1126
|
+
/**
|
|
1127
|
+
* @ignore
|
|
1128
|
+
*/
|
|
1129
|
+
children: PropTypes.node,
|
|
1130
|
+
/**
|
|
1131
|
+
* Override or extend the styles applied to the component.
|
|
1132
|
+
*/
|
|
1133
|
+
classes: PropTypes.object,
|
|
1134
|
+
/**
|
|
1135
|
+
* @ignore
|
|
1136
|
+
*/
|
|
1137
|
+
className: PropTypes.string,
|
|
1138
|
+
/**
|
|
1139
|
+
* The color of the component.
|
|
1140
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
1141
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
1142
|
+
* @default 'primary'
|
|
1143
|
+
*/
|
|
1144
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
1145
|
+
/**
|
|
1146
|
+
* The default value. Use when the component is not controlled.
|
|
1147
|
+
*/
|
|
1148
|
+
defaultValue: PropTypes.any,
|
|
1149
|
+
/**
|
|
1150
|
+
* If `true`, the component is disabled.
|
|
1151
|
+
* @default false
|
|
1152
|
+
*/
|
|
1153
|
+
disabled: PropTypes.bool,
|
|
1154
|
+
/**
|
|
1155
|
+
* If `true`, the label is displayed in an error state.
|
|
1156
|
+
* @default false
|
|
1157
|
+
*/
|
|
1158
|
+
error: PropTypes.bool,
|
|
1159
|
+
/**
|
|
1160
|
+
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
1161
|
+
*/
|
|
1162
|
+
FormHelperTextProps: PropTypes.object,
|
|
1163
|
+
/**
|
|
1164
|
+
* If `true`, the input will take up the full width of its container.
|
|
1165
|
+
* @default false
|
|
1166
|
+
*/
|
|
1167
|
+
fullWidth: PropTypes.bool,
|
|
1168
|
+
/**
|
|
1169
|
+
* The helper text content.
|
|
1170
|
+
*/
|
|
1171
|
+
helperText: PropTypes.node,
|
|
1172
|
+
/**
|
|
1173
|
+
* The id of the `input` element.
|
|
1174
|
+
* Use this prop to make `label` and `helperText` accessible for screen readers.
|
|
1175
|
+
*/
|
|
1176
|
+
id: PropTypes.string,
|
|
1177
|
+
/**
|
|
1178
|
+
* Props applied to the [`InputLabel`](/material-ui/api/input-label/) element.
|
|
1179
|
+
* Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
|
|
1180
|
+
*/
|
|
1181
|
+
InputLabelProps: PropTypes.object,
|
|
1182
|
+
/**
|
|
1183
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
1184
|
+
*/
|
|
1185
|
+
inputProps: PropTypes.object,
|
|
1186
|
+
/**
|
|
1187
|
+
* Props applied to the Input element.
|
|
1188
|
+
* It will be a [`FilledInput`](/material-ui/api/filled-input/),
|
|
1189
|
+
* [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/)
|
|
1190
|
+
* component depending on the `variant` prop value.
|
|
1191
|
+
*/
|
|
1192
|
+
InputProps: PropTypes.object,
|
|
1193
|
+
/**
|
|
1194
|
+
* Pass a ref to the `input` element.
|
|
1195
|
+
*/
|
|
1196
|
+
inputRef: refType,
|
|
1197
|
+
/**
|
|
1198
|
+
* The label content.
|
|
1199
|
+
*/
|
|
1200
|
+
label: PropTypes.node,
|
|
1201
|
+
/**
|
|
1202
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
1203
|
+
* @default 'none'
|
|
1204
|
+
*/
|
|
1205
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
1206
|
+
/**
|
|
1207
|
+
* Maximum number of rows to display when multiline option is set to true.
|
|
1208
|
+
*/
|
|
1209
|
+
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1210
|
+
/**
|
|
1211
|
+
* Minimum number of rows to display when multiline option is set to true.
|
|
1212
|
+
*/
|
|
1213
|
+
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1214
|
+
/**
|
|
1215
|
+
* If `true`, a `textarea` element is rendered instead of an input.
|
|
1216
|
+
* @default false
|
|
1217
|
+
*/
|
|
1218
|
+
multiline: PropTypes.bool,
|
|
1219
|
+
/**
|
|
1220
|
+
* Name attribute of the `input` element.
|
|
1221
|
+
*/
|
|
1222
|
+
name: PropTypes.string,
|
|
1223
|
+
/**
|
|
1224
|
+
* @ignore
|
|
1225
|
+
*/
|
|
1226
|
+
onBlur: PropTypes.func,
|
|
1227
|
+
/**
|
|
1228
|
+
* Callback fired when the value is changed.
|
|
1229
|
+
*
|
|
1230
|
+
* @param {object} event The event source of the callback.
|
|
1231
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
1232
|
+
*/
|
|
1233
|
+
onChange: PropTypes.func,
|
|
1234
|
+
/**
|
|
1235
|
+
* @ignore
|
|
1236
|
+
*/
|
|
1237
|
+
onClick: PropTypes.func,
|
|
1238
|
+
/**
|
|
1239
|
+
* @ignore
|
|
1240
|
+
*/
|
|
1241
|
+
onFocus: PropTypes.func,
|
|
1242
|
+
/**
|
|
1243
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
1244
|
+
*/
|
|
1245
|
+
placeholder: PropTypes.string,
|
|
1246
|
+
/**
|
|
1247
|
+
* If `true`, the label is displayed as required and the `input` element is required.
|
|
1248
|
+
* @default false
|
|
1249
|
+
*/
|
|
1250
|
+
required: PropTypes.bool,
|
|
1251
|
+
/**
|
|
1252
|
+
* Number of rows to display when multiline option is set to true.
|
|
1253
|
+
*/
|
|
1254
|
+
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1255
|
+
/**
|
|
1256
|
+
* Render a [`Select`](/material-ui/api/select/) element while passing the Input element to `Select` as `input` parameter.
|
|
1257
|
+
* If this option is set you must pass the options of the select as children.
|
|
1258
|
+
* @default false
|
|
1259
|
+
*/
|
|
1260
|
+
select: PropTypes.bool,
|
|
1261
|
+
/**
|
|
1262
|
+
* Props applied to the [`Select`](/material-ui/api/select/) element.
|
|
1263
|
+
*/
|
|
1264
|
+
SelectProps: PropTypes.object,
|
|
1265
|
+
/**
|
|
1266
|
+
* The size of the component.
|
|
1267
|
+
*/
|
|
1268
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
1269
|
+
/**
|
|
1270
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
1271
|
+
*/
|
|
1272
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1273
|
+
/**
|
|
1274
|
+
* 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).
|
|
1275
|
+
*/
|
|
1276
|
+
type: PropTypes /* @typescript-to-proptypes-ignore */.string,
|
|
1277
|
+
/**
|
|
1278
|
+
* The value of the `input` element, required for a controlled component.
|
|
1279
|
+
*/
|
|
1280
|
+
value: PropTypes.any,
|
|
1281
|
+
/**
|
|
1282
|
+
* The variant to use.
|
|
1283
|
+
* @default 'outlined'
|
|
1284
|
+
*/
|
|
1285
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
1286
|
+
} : void 0;
|
|
1287
|
+
var TextField$1 = TextField;
|
|
16
1288
|
|
|
17
1289
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
18
1290
|
const InputNumberInterval = props => {
|
|
@@ -54,7 +1326,7 @@ const InputNumberInterval = props => {
|
|
|
54
1326
|
const newLowerBound = event.target.value;
|
|
55
1327
|
updateFilterValue(newLowerBound, filterValueState[1]);
|
|
56
1328
|
};
|
|
57
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
1329
|
+
return /*#__PURE__*/React.createElement(Box$1, {
|
|
58
1330
|
sx: {
|
|
59
1331
|
display: 'inline-flex',
|
|
60
1332
|
flexDirection: 'row',
|
|
@@ -62,7 +1334,7 @@ const InputNumberInterval = props => {
|
|
|
62
1334
|
height: 48,
|
|
63
1335
|
pl: '20px'
|
|
64
1336
|
}
|
|
65
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
1337
|
+
}, /*#__PURE__*/React.createElement(TextField$1, {
|
|
66
1338
|
name: "lower-bound-input",
|
|
67
1339
|
placeholder: "From",
|
|
68
1340
|
label: "From",
|
|
@@ -74,7 +1346,7 @@ const InputNumberInterval = props => {
|
|
|
74
1346
|
sx: {
|
|
75
1347
|
mr: 2
|
|
76
1348
|
}
|
|
77
|
-
}), /*#__PURE__*/React.createElement(TextField, {
|
|
1349
|
+
}), /*#__PURE__*/React.createElement(TextField$1, {
|
|
78
1350
|
name: "upper-bound-input",
|
|
79
1351
|
placeholder: "To",
|
|
80
1352
|
label: "To",
|
|
@@ -106,8 +1378,8 @@ const isBetweenOperator = {
|
|
|
106
1378
|
if (typeof filterItem.value[0] !== 'number' || typeof filterItem.value[1] !== 'number') {
|
|
107
1379
|
return null;
|
|
108
1380
|
}
|
|
109
|
-
return
|
|
110
|
-
return value !== null && value !== undefined && filterItem.value[0] <= value && value <= filterItem.value[1];
|
|
1381
|
+
return params => {
|
|
1382
|
+
return params.value !== null && params.value !== undefined && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
111
1383
|
};
|
|
112
1384
|
},
|
|
113
1385
|
InputComponent: InputNumberInterval
|
|
@@ -123,14 +1395,14 @@ const doesNotContain = {
|
|
|
123
1395
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
124
1396
|
return null;
|
|
125
1397
|
}
|
|
126
|
-
return
|
|
1398
|
+
return params => {
|
|
127
1399
|
if (filterItem.value.length === 0) {
|
|
128
1400
|
return true;
|
|
129
1401
|
}
|
|
130
|
-
if (value == null) {
|
|
1402
|
+
if (params.value == null) {
|
|
131
1403
|
return true;
|
|
132
1404
|
}
|
|
133
|
-
if (String(value).indexOf(filterItem.value) !== -1) {
|
|
1405
|
+
if (String(params.value).indexOf(filterItem.value) !== -1) {
|
|
134
1406
|
return false;
|
|
135
1407
|
}
|
|
136
1408
|
return true;
|
|
@@ -147,11 +1419,11 @@ const doesNotEndWithOperator = {
|
|
|
147
1419
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
148
1420
|
return null;
|
|
149
1421
|
}
|
|
150
|
-
return
|
|
151
|
-
if (value == null) {
|
|
1422
|
+
return params => {
|
|
1423
|
+
if (params.value == null) {
|
|
152
1424
|
return true;
|
|
153
1425
|
}
|
|
154
|
-
return !String(value).endsWith(filterItem.value);
|
|
1426
|
+
return !String(params.value).endsWith(filterItem.value);
|
|
155
1427
|
};
|
|
156
1428
|
},
|
|
157
1429
|
InputComponent: GridFilterInputValue
|
|
@@ -165,11 +1437,11 @@ const doesNotEqual = {
|
|
|
165
1437
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
166
1438
|
return null;
|
|
167
1439
|
}
|
|
168
|
-
return
|
|
169
|
-
if (value == null) {
|
|
1440
|
+
return params => {
|
|
1441
|
+
if (params.value == null) {
|
|
170
1442
|
return true;
|
|
171
1443
|
}
|
|
172
|
-
if (String(value) === filterItem.value) {
|
|
1444
|
+
if (String(params.value) === filterItem.value) {
|
|
173
1445
|
return false;
|
|
174
1446
|
}
|
|
175
1447
|
return true;
|
|
@@ -186,11 +1458,11 @@ const doesNotHaveOperator = {
|
|
|
186
1458
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
187
1459
|
return null;
|
|
188
1460
|
}
|
|
189
|
-
return
|
|
190
|
-
if (value == null) {
|
|
1461
|
+
return params => {
|
|
1462
|
+
if (params.value == null) {
|
|
191
1463
|
return true;
|
|
192
1464
|
}
|
|
193
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1465
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
194
1466
|
return !cellValues.map(value => String(value)).includes(filterItem.value);
|
|
195
1467
|
};
|
|
196
1468
|
},
|
|
@@ -208,11 +1480,11 @@ const doesNotStartWithOperator = {
|
|
|
208
1480
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
209
1481
|
return null;
|
|
210
1482
|
}
|
|
211
|
-
return
|
|
212
|
-
if (value == null) {
|
|
1483
|
+
return params => {
|
|
1484
|
+
if (params.value == null) {
|
|
213
1485
|
return true;
|
|
214
1486
|
}
|
|
215
|
-
return !String(value).startsWith(filterItem.value);
|
|
1487
|
+
return !String(params.value).startsWith(filterItem.value);
|
|
216
1488
|
};
|
|
217
1489
|
},
|
|
218
1490
|
InputComponent: GridFilterInputValue
|
|
@@ -226,11 +1498,11 @@ const hasOperator = {
|
|
|
226
1498
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
227
1499
|
return null;
|
|
228
1500
|
}
|
|
229
|
-
return
|
|
230
|
-
if (value == null) {
|
|
1501
|
+
return params => {
|
|
1502
|
+
if (params.value == null) {
|
|
231
1503
|
return false;
|
|
232
1504
|
}
|
|
233
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1505
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
234
1506
|
return cellValues.map(value => String(value)).includes(filterItem.value);
|
|
235
1507
|
};
|
|
236
1508
|
},
|
|
@@ -248,11 +1520,11 @@ const hasOnlyOperator = {
|
|
|
248
1520
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
249
1521
|
return null;
|
|
250
1522
|
}
|
|
251
|
-
return
|
|
252
|
-
if (value == null) {
|
|
1523
|
+
return params => {
|
|
1524
|
+
if (params.value == null) {
|
|
253
1525
|
return false;
|
|
254
1526
|
}
|
|
255
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1527
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
256
1528
|
return cellValues.length === 1 && String(cellValues[0]) === filterItem.value;
|
|
257
1529
|
};
|
|
258
1530
|
},
|
|
@@ -270,14 +1542,14 @@ const isOperator = {
|
|
|
270
1542
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
271
1543
|
return null;
|
|
272
1544
|
}
|
|
273
|
-
return
|
|
274
|
-
if (value == null) {
|
|
1545
|
+
return params => {
|
|
1546
|
+
if (params.value == null) {
|
|
275
1547
|
return false;
|
|
276
1548
|
}
|
|
277
|
-
if (Array.isArray(value)) {
|
|
1549
|
+
if (Array.isArray(params.value)) {
|
|
278
1550
|
return false;
|
|
279
1551
|
}
|
|
280
|
-
return String(value) === filterItem.value;
|
|
1552
|
+
return String(params.value) === filterItem.value;
|
|
281
1553
|
};
|
|
282
1554
|
},
|
|
283
1555
|
InputComponent: GridFilterInputValue
|
|
@@ -294,14 +1566,14 @@ const isNotOperator = {
|
|
|
294
1566
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
295
1567
|
return null;
|
|
296
1568
|
}
|
|
297
|
-
return
|
|
298
|
-
if (value == null) {
|
|
1569
|
+
return params => {
|
|
1570
|
+
if (params.value == null) {
|
|
299
1571
|
return true;
|
|
300
1572
|
}
|
|
301
|
-
if (Array.isArray(value)) {
|
|
1573
|
+
if (Array.isArray(params.value)) {
|
|
302
1574
|
return true;
|
|
303
1575
|
}
|
|
304
|
-
return String(value) !== filterItem.value;
|
|
1576
|
+
return String(params.value) !== filterItem.value;
|
|
305
1577
|
};
|
|
306
1578
|
},
|
|
307
1579
|
InputComponent: GridFilterInputValue
|
|
@@ -318,14 +1590,14 @@ const containsAnyOfOperator = {
|
|
|
318
1590
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
319
1591
|
return null;
|
|
320
1592
|
}
|
|
321
|
-
return
|
|
1593
|
+
return params => {
|
|
322
1594
|
if (filterItem.value.length === 0) {
|
|
323
1595
|
return true;
|
|
324
1596
|
}
|
|
325
|
-
if (value == null) {
|
|
1597
|
+
if (params.value == null) {
|
|
326
1598
|
return false;
|
|
327
1599
|
}
|
|
328
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1600
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
329
1601
|
let match = false;
|
|
330
1602
|
filterItem.value.forEach(filteredValue => {
|
|
331
1603
|
paramValues.forEach(paramValue => {
|
|
@@ -348,14 +1620,14 @@ const doesNotContainAnyOfOperator = {
|
|
|
348
1620
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
349
1621
|
return null;
|
|
350
1622
|
}
|
|
351
|
-
return
|
|
1623
|
+
return params => {
|
|
352
1624
|
if (filterItem.value.length === 0) {
|
|
353
1625
|
return true;
|
|
354
1626
|
}
|
|
355
|
-
if (value == null) {
|
|
1627
|
+
if (params.value == null) {
|
|
356
1628
|
return true;
|
|
357
1629
|
}
|
|
358
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1630
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
359
1631
|
for (const filteredValue of filterItem.value) {
|
|
360
1632
|
for (const paramValue of paramValues) {
|
|
361
1633
|
if (String(paramValue).indexOf(filteredValue) !== -1) {
|
|
@@ -377,14 +1649,14 @@ const doesNotEndWithAnyOfOperator = {
|
|
|
377
1649
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
378
1650
|
return null;
|
|
379
1651
|
}
|
|
380
|
-
return
|
|
1652
|
+
return params => {
|
|
381
1653
|
if (filterItem.value.length === 0) {
|
|
382
1654
|
return true;
|
|
383
1655
|
}
|
|
384
|
-
if (value == null) {
|
|
1656
|
+
if (params.value == null) {
|
|
385
1657
|
return true;
|
|
386
1658
|
}
|
|
387
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1659
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
388
1660
|
for (const filteredValue of filterItem.value) {
|
|
389
1661
|
for (const paramValue of paramValues) {
|
|
390
1662
|
if (String(paramValue).endsWith(filteredValue)) {
|
|
@@ -406,11 +1678,11 @@ const doesNotHaveAnyOf = {
|
|
|
406
1678
|
if (!filterItem.field || !filterItem.value || !Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
407
1679
|
return null;
|
|
408
1680
|
}
|
|
409
|
-
return
|
|
410
|
-
if (value == null) {
|
|
1681
|
+
return params => {
|
|
1682
|
+
if (params.value == null) {
|
|
411
1683
|
return true;
|
|
412
1684
|
}
|
|
413
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1685
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
414
1686
|
|
|
415
1687
|
// Return true only if none of the filter values are in the cell values
|
|
416
1688
|
return filterItem.value.every(filterVal => !cellValues.map(value => String(value)).includes(filterVal));
|
|
@@ -430,14 +1702,14 @@ const doesNotStartWithAnyOfOperator = {
|
|
|
430
1702
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
431
1703
|
return null;
|
|
432
1704
|
}
|
|
433
|
-
return
|
|
1705
|
+
return params => {
|
|
434
1706
|
if (filterItem.value.length === 0) {
|
|
435
1707
|
return true;
|
|
436
1708
|
}
|
|
437
|
-
if (value == null) {
|
|
1709
|
+
if (params.value == null) {
|
|
438
1710
|
return true;
|
|
439
1711
|
}
|
|
440
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1712
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
441
1713
|
for (const filteredValue of filterItem.value) {
|
|
442
1714
|
for (const paramValue of paramValues) {
|
|
443
1715
|
if (String(paramValue).startsWith(filteredValue)) {
|
|
@@ -459,14 +1731,14 @@ const endsWithAnyOfOperator = {
|
|
|
459
1731
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
460
1732
|
return null;
|
|
461
1733
|
}
|
|
462
|
-
return
|
|
1734
|
+
return params => {
|
|
463
1735
|
if (filterItem.value.length === 0) {
|
|
464
1736
|
return true;
|
|
465
1737
|
}
|
|
466
|
-
if (value == null) {
|
|
1738
|
+
if (params.value == null) {
|
|
467
1739
|
return false;
|
|
468
1740
|
}
|
|
469
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1741
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
470
1742
|
let match = false;
|
|
471
1743
|
filterItem.value.forEach(filteredValue => {
|
|
472
1744
|
paramValues.forEach(paramValue => {
|
|
@@ -489,14 +1761,14 @@ const hasAllOfOperator = {
|
|
|
489
1761
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
490
1762
|
return null;
|
|
491
1763
|
}
|
|
492
|
-
return
|
|
1764
|
+
return params => {
|
|
493
1765
|
if (filterItem.value.length === 0) {
|
|
494
1766
|
return true;
|
|
495
1767
|
}
|
|
496
|
-
if (value == null) {
|
|
1768
|
+
if (params.value == null) {
|
|
497
1769
|
return false;
|
|
498
1770
|
}
|
|
499
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1771
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
500
1772
|
const cellStrings = cellValues.map(value => String(value));
|
|
501
1773
|
const filterItemValues = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
502
1774
|
return filterItemValues.every(v => cellStrings.includes(v));
|
|
@@ -516,14 +1788,14 @@ const hasAnyOfOperator = {
|
|
|
516
1788
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
517
1789
|
return null;
|
|
518
1790
|
}
|
|
519
|
-
return
|
|
1791
|
+
return params => {
|
|
520
1792
|
if (filterItem.value.length === 0) {
|
|
521
1793
|
return true;
|
|
522
1794
|
}
|
|
523
|
-
if (value == null) {
|
|
1795
|
+
if (params.value == null) {
|
|
524
1796
|
return false;
|
|
525
1797
|
}
|
|
526
|
-
const cellValues = Array.isArray(value) ? value : [value];
|
|
1798
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
527
1799
|
const filterItemValues = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
528
1800
|
return filterItemValues.some(v => cellValues.map(value => String(value)).includes(v));
|
|
529
1801
|
};
|
|
@@ -542,14 +1814,14 @@ const isAnyOfOperator = {
|
|
|
542
1814
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
543
1815
|
return null;
|
|
544
1816
|
}
|
|
545
|
-
return
|
|
1817
|
+
return params => {
|
|
546
1818
|
if (filterItem.value.length === 0) {
|
|
547
1819
|
return true;
|
|
548
1820
|
}
|
|
549
|
-
if (value == null) {
|
|
1821
|
+
if (params.value == null) {
|
|
550
1822
|
return false;
|
|
551
1823
|
}
|
|
552
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1824
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
553
1825
|
for (const paramValue of paramValues) {
|
|
554
1826
|
if (filterItem.value.includes(String(paramValue))) {
|
|
555
1827
|
return true;
|
|
@@ -572,14 +1844,14 @@ const isNotAnyOfOperator = {
|
|
|
572
1844
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
573
1845
|
return null;
|
|
574
1846
|
}
|
|
575
|
-
return
|
|
1847
|
+
return params => {
|
|
576
1848
|
if (filterItem.value.length === 0) {
|
|
577
1849
|
return true;
|
|
578
1850
|
}
|
|
579
|
-
if (value == null) {
|
|
1851
|
+
if (params.value == null) {
|
|
580
1852
|
return true;
|
|
581
1853
|
}
|
|
582
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1854
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
583
1855
|
for (const paramValue of paramValues) {
|
|
584
1856
|
if (filterItem.value.includes(String(paramValue))) {
|
|
585
1857
|
return false;
|
|
@@ -602,14 +1874,14 @@ const startsWithAnyOfOperator = {
|
|
|
602
1874
|
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
603
1875
|
return null;
|
|
604
1876
|
}
|
|
605
|
-
return
|
|
1877
|
+
return params => {
|
|
606
1878
|
if (filterItem.value.length === 0) {
|
|
607
1879
|
return true;
|
|
608
1880
|
}
|
|
609
|
-
if (value == null) {
|
|
1881
|
+
if (params.value == null) {
|
|
610
1882
|
return false;
|
|
611
1883
|
}
|
|
612
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
1884
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
613
1885
|
let match = false;
|
|
614
1886
|
filterItem.value.forEach(filteredValue => {
|
|
615
1887
|
paramValues.forEach(paramValue => {
|
|
@@ -636,15 +1908,15 @@ const isEmptyOperator = {
|
|
|
636
1908
|
value: 'isEmpty',
|
|
637
1909
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
638
1910
|
getApplyFilterFn: _filterItem => {
|
|
639
|
-
return
|
|
640
|
-
if (value == null) {
|
|
1911
|
+
return params => {
|
|
1912
|
+
if (params.value == null) {
|
|
641
1913
|
return true;
|
|
642
1914
|
}
|
|
643
|
-
if (Array.isArray(value)) {
|
|
644
|
-
return value.length === 0;
|
|
1915
|
+
if (Array.isArray(params.value)) {
|
|
1916
|
+
return params.value.length === 0;
|
|
645
1917
|
}
|
|
646
|
-
if (typeof value === 'string') {
|
|
647
|
-
return value.trim() === '';
|
|
1918
|
+
if (typeof params.value === 'string') {
|
|
1919
|
+
return params.value.trim() === '';
|
|
648
1920
|
}
|
|
649
1921
|
return false;
|
|
650
1922
|
};
|
|
@@ -656,15 +1928,15 @@ const isNotEmptyOperator = {
|
|
|
656
1928
|
value: 'isNotEmpty',
|
|
657
1929
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
658
1930
|
getApplyFilterFn: _filterItem => {
|
|
659
|
-
return
|
|
660
|
-
if (value == null) {
|
|
1931
|
+
return params => {
|
|
1932
|
+
if (params.value == null) {
|
|
661
1933
|
return false;
|
|
662
1934
|
}
|
|
663
|
-
if (Array.isArray(value)) {
|
|
664
|
-
return value.length > 0;
|
|
1935
|
+
if (Array.isArray(params.value)) {
|
|
1936
|
+
return params.value.length > 0;
|
|
665
1937
|
}
|
|
666
|
-
if (typeof value === 'string') {
|
|
667
|
-
return value.trim() !== '';
|
|
1938
|
+
if (typeof params.value === 'string') {
|
|
1939
|
+
return params.value.trim() !== '';
|
|
668
1940
|
}
|
|
669
1941
|
return true;
|
|
670
1942
|
};
|
|
@@ -703,10 +1975,7 @@ const DIMENSION_MODEL_KEY = 'dimension';
|
|
|
703
1975
|
const FILTER_SEARCH_KEY = 'searchModel';
|
|
704
1976
|
const DENSITY_MODEL_KEY = 'densityModel';
|
|
705
1977
|
const COLUMN_ORDER_MODEL_KEY = 'columnOrderModel';
|
|
706
|
-
const
|
|
707
|
-
const AGGREGATION_MODEL_KEY = 'aggregationModel';
|
|
708
|
-
const PIVOT_MODEL_KEY = 'pivotModel';
|
|
709
|
-
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];
|
|
1978
|
+
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];
|
|
710
1979
|
const buildStorageKey = _ref => {
|
|
711
1980
|
let {
|
|
712
1981
|
id,
|
|
@@ -753,18 +2022,6 @@ const clearPreviousVersionStorage = (id, previousLocalStorageVersions) => {
|
|
|
753
2022
|
id,
|
|
754
2023
|
version,
|
|
755
2024
|
category: COLUMN_ORDER_MODEL_KEY
|
|
756
|
-
}), buildStorageKey({
|
|
757
|
-
id,
|
|
758
|
-
version,
|
|
759
|
-
category: ROW_GROUPING_MODEL_KEY
|
|
760
|
-
}), buildStorageKey({
|
|
761
|
-
id,
|
|
762
|
-
version,
|
|
763
|
-
category: AGGREGATION_MODEL_KEY
|
|
764
|
-
}), buildStorageKey({
|
|
765
|
-
id,
|
|
766
|
-
version,
|
|
767
|
-
category: PIVOT_MODEL_KEY
|
|
768
2025
|
})];
|
|
769
2026
|
for (const keyToDelete of keysToDelete) {
|
|
770
2027
|
try {
|
|
@@ -787,7 +2044,7 @@ const COMPRESSED_PREFIX = '~';
|
|
|
787
2044
|
* Params listed first are compressed first (least valuable to read in the URL).
|
|
788
2045
|
* The filter aggregate step uses the special key `_filters_aggregate`.
|
|
789
2046
|
*/
|
|
790
|
-
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '
|
|
2047
|
+
const COMPRESSION_PRIORITY = ['_columnOrder', '_columnVisibility', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_filters_aggregate', '_quickFilterValues'];
|
|
791
2048
|
|
|
792
2049
|
/** Params that are always short and should never be compressed. */
|
|
793
2050
|
const NEVER_COMPRESS = new Set(['_sortColumn', '_pagination', '_density', '_logicOperator', 'v', 'tab']);
|
|
@@ -1028,13 +2285,6 @@ const convertToDisplayFormat = search => {
|
|
|
1028
2285
|
const cleanSearch = search.startsWith('?') ? search.slice(1) : search;
|
|
1029
2286
|
const params = cleanSearch.split('&');
|
|
1030
2287
|
const converted = params.map(param => {
|
|
1031
|
-
const eqIndex = param.indexOf('=');
|
|
1032
|
-
if (eqIndex !== -1) {
|
|
1033
|
-
const value = param.slice(eqIndex + 1);
|
|
1034
|
-
// Skip conversion for compressed values — already URL-safe
|
|
1035
|
-
if (isCompressed(value)) return param;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
2288
|
// Handle _sortColumn=[field,direction]
|
|
1039
2289
|
if (param.startsWith('_sortColumn=')) {
|
|
1040
2290
|
const value = param.slice('_sortColumn='.length);
|
|
@@ -1088,6 +2338,7 @@ const convertToDisplayFormat = search => {
|
|
|
1088
2338
|
// Handle _columnOrder=[a,b,c]
|
|
1089
2339
|
if (param.startsWith('_columnOrder=')) {
|
|
1090
2340
|
const value = param.slice('_columnOrder='.length);
|
|
2341
|
+
if (value.startsWith('~')) return param; // compressed — skip
|
|
1091
2342
|
if (value.startsWith('[') && value.endsWith(']')) {
|
|
1092
2343
|
const inner = value.slice(1, -1);
|
|
1093
2344
|
return `_columnOrder=${inner}`;
|
|
@@ -1095,21 +2346,6 @@ const convertToDisplayFormat = search => {
|
|
|
1095
2346
|
return param;
|
|
1096
2347
|
}
|
|
1097
2348
|
|
|
1098
|
-
// Handle _rowGrouping=[a,b,c]
|
|
1099
|
-
if (param.startsWith('_rowGrouping=')) {
|
|
1100
|
-
const value = param.slice('_rowGrouping='.length);
|
|
1101
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
1102
|
-
const inner = value.slice(1, -1);
|
|
1103
|
-
return `_rowGrouping=${inner}`;
|
|
1104
|
-
}
|
|
1105
|
-
return param;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// _aggregation and _pivot do not use bracket notation — pass through
|
|
1109
|
-
if (param.startsWith('_aggregation=') || param.startsWith('_pivot=')) {
|
|
1110
|
-
return param;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
2349
|
// Handle _field[operator,type]=value or _field[operator,type]=list[a,b,c]
|
|
1114
2350
|
const bracketMatch = param.match(/^_([^[]+)\[([^\]]+)\]=(.*)$/);
|
|
1115
2351
|
if (bracketMatch) {
|
|
@@ -1149,13 +2385,6 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1149
2385
|
const cleanSearch = search.startsWith('?') ? search.slice(1) : search;
|
|
1150
2386
|
const params = cleanSearch.split('&');
|
|
1151
2387
|
const converted = params.map(param => {
|
|
1152
|
-
const eqIndex = param.indexOf('=');
|
|
1153
|
-
if (eqIndex !== -1) {
|
|
1154
|
-
const value = param.slice(eqIndex + 1);
|
|
1155
|
-
// Skip conversion for compressed values — already URL-safe
|
|
1156
|
-
if (isCompressed(value)) return param;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
2388
|
// Handle _sortColumn=field.direction or _sortColumn=
|
|
1160
2389
|
if (param.startsWith('_sortColumn=')) {
|
|
1161
2390
|
const value = param.slice('_sortColumn='.length);
|
|
@@ -1208,7 +2437,7 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1208
2437
|
if (param.startsWith('_columnVisibility=')) {
|
|
1209
2438
|
const value = param.slice('_columnVisibility='.length);
|
|
1210
2439
|
// If it already has brackets, leave it alone
|
|
1211
|
-
if (value.startsWith('[')) {
|
|
2440
|
+
if (value.startsWith('[') || value.startsWith('~')) {
|
|
1212
2441
|
return param;
|
|
1213
2442
|
}
|
|
1214
2443
|
return `_columnVisibility=[${value}]`;
|
|
@@ -1217,26 +2446,13 @@ const convertFromDisplayFormat = (search, columns) => {
|
|
|
1217
2446
|
// Handle _columnOrder=a,b,c
|
|
1218
2447
|
if (param.startsWith('_columnOrder=')) {
|
|
1219
2448
|
const value = param.slice('_columnOrder='.length);
|
|
1220
|
-
|
|
2449
|
+
// If it already has brackets or is compressed, leave it alone
|
|
2450
|
+
if (value.startsWith('[') || value.startsWith('~')) {
|
|
1221
2451
|
return param;
|
|
1222
2452
|
}
|
|
1223
2453
|
return `_columnOrder=[${value}]`;
|
|
1224
2454
|
}
|
|
1225
2455
|
|
|
1226
|
-
// Handle _rowGrouping=a,b,c
|
|
1227
|
-
if (param.startsWith('_rowGrouping=')) {
|
|
1228
|
-
const value = param.slice('_rowGrouping='.length);
|
|
1229
|
-
if (value.startsWith('[')) {
|
|
1230
|
-
return param;
|
|
1231
|
-
}
|
|
1232
|
-
return `_rowGrouping=[${value}]`;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
// _aggregation, _pivot, _filters — pass through (no bracket conversion needed)
|
|
1236
|
-
if (param.startsWith('_aggregation=') || param.startsWith('_pivot=') || param.startsWith('_filters=')) {
|
|
1237
|
-
return param;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
2456
|
// Handle field.operator=value (dot notation for filters)
|
|
1241
2457
|
const dotMatch = param.match(/^([^.]+)\.([a-zA-Z_]+)=(.*)$/);
|
|
1242
2458
|
if (dotMatch) {
|
|
@@ -1279,10 +2495,9 @@ const getDecodedSearchFromUrl = (search, columns) => {
|
|
|
1279
2495
|
const hasPaginationDotNotation = /_pagination=[^&[]+\.[^&]+/.test(searchWithoutLeadingQuestion);
|
|
1280
2496
|
const hasPinnedWithoutBrackets = /(_pinnedColumnsLeft|_pinnedColumnsRight)=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1281
2497
|
const hasVisibilityWithoutBrackets = /_columnVisibility=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1282
|
-
const hasColumnOrderWithoutBrackets = /_columnOrder=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1283
|
-
const hasRowGroupingWithoutBrackets = /_rowGrouping=[^&[]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
2498
|
+
const hasColumnOrderWithoutBrackets = /_columnOrder=[^&[~]*(&|$)/.test(searchWithoutLeadingQuestion);
|
|
1284
2499
|
const hasBracketNotation = /\[.*\]=/.test(searchWithoutLeadingQuestion);
|
|
1285
|
-
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets
|
|
2500
|
+
const isDisplayFormat = (hasDotNotationFilter || hasEmptySortColumn || hasSortDotNotation || hasPaginationDotNotation || hasPinnedWithoutBrackets || hasVisibilityWithoutBrackets || hasColumnOrderWithoutBrackets) && !hasBracketNotation;
|
|
1286
2501
|
if (isDisplayFormat) {
|
|
1287
2502
|
return '?' + convertFromDisplayFormat(searchWithoutLeadingQuestion, columns);
|
|
1288
2503
|
}
|
|
@@ -1443,7 +2658,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
1443
2658
|
let quickFilterValues = [];
|
|
1444
2659
|
const searchParams = new URLSearchParams();
|
|
1445
2660
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
1446
|
-
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '
|
|
2661
|
+
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '_density', '_filters'].includes(key)) {
|
|
1447
2662
|
searchParams.set(key, value);
|
|
1448
2663
|
}
|
|
1449
2664
|
if (key === '_logicOperator') {
|
|
@@ -1909,7 +3124,7 @@ const getSearchParamsFromDensity = density => {
|
|
|
1909
3124
|
return searchParams;
|
|
1910
3125
|
};
|
|
1911
3126
|
const getDensityModel = (search, localStorageDensity, setLocalStorageDensity, _initialState, isNewVersion) => {
|
|
1912
|
-
//
|
|
3127
|
+
// MUI v6 GridInitialStatePro does not include density — default to 'compact'
|
|
1913
3128
|
const defaultValue = 'compact';
|
|
1914
3129
|
|
|
1915
3130
|
// Persist initialState-derived density to localStorage so all three sources stay in sync
|
|
@@ -1991,212 +3206,7 @@ const getColumnOrder = (search, columns, localStorageColumnOrder, setLocalStorag
|
|
|
1991
3206
|
persistDefault();
|
|
1992
3207
|
return defaultValue;
|
|
1993
3208
|
};
|
|
1994
|
-
|
|
1995
|
-
/** ROW GROUPING */
|
|
1996
|
-
|
|
1997
|
-
const getRowGroupingFromString = searchString => {
|
|
1998
|
-
if (!searchString) return 'invalid';
|
|
1999
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2000
|
-
const value = searchParams.get('_rowGrouping');
|
|
2001
|
-
if (value === '' || value === null || value === '[]') return 'invalid';
|
|
2002
|
-
const inner = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value;
|
|
2003
|
-
if (!inner) return 'invalid';
|
|
2004
|
-
return inner.split(',').filter(Boolean);
|
|
2005
|
-
};
|
|
2006
|
-
const getSearchParamsFromRowGrouping = rowGrouping => {
|
|
2007
|
-
const searchParams = new URLSearchParams();
|
|
2008
|
-
if (rowGrouping.length > 0) {
|
|
2009
|
-
searchParams.set('_rowGrouping', `[${rowGrouping.join(',')}]`);
|
|
2010
|
-
}
|
|
2011
|
-
return searchParams;
|
|
2012
|
-
};
|
|
2013
|
-
const getRowGroupingModel = (search, localStorageRowGrouping, setLocalStorageRowGrouping, initialState, isNewVersion) => {
|
|
2014
|
-
var _initialState$rowGrou, _initialState$rowGrou2;
|
|
2015
|
-
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 : [];
|
|
2016
|
-
const persistDefault = () => {
|
|
2017
|
-
const searchFromDefault = getSearchParamsFromRowGrouping(defaultValue);
|
|
2018
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2019
|
-
if (searchString !== localStorageRowGrouping) {
|
|
2020
|
-
setLocalStorageRowGrouping(searchString);
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
if (isNewVersion) {
|
|
2024
|
-
persistDefault();
|
|
2025
|
-
return defaultValue;
|
|
2026
|
-
}
|
|
2027
|
-
const fromUrl = getRowGroupingFromString(search);
|
|
2028
|
-
if (fromUrl !== 'invalid') {
|
|
2029
|
-
const searchFromModel = getSearchParamsFromRowGrouping(fromUrl);
|
|
2030
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2031
|
-
if (searchString !== localStorageRowGrouping) {
|
|
2032
|
-
setLocalStorageRowGrouping(searchString);
|
|
2033
|
-
}
|
|
2034
|
-
return fromUrl;
|
|
2035
|
-
}
|
|
2036
|
-
const fromLocalStorage = getRowGroupingFromString(localStorageRowGrouping);
|
|
2037
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2038
|
-
return fromLocalStorage;
|
|
2039
|
-
}
|
|
2040
|
-
persistDefault();
|
|
2041
|
-
return defaultValue;
|
|
2042
|
-
};
|
|
2043
|
-
|
|
2044
|
-
/** AGGREGATION */
|
|
2045
|
-
|
|
2046
|
-
const getAggregationFromString = searchString => {
|
|
2047
|
-
if (!searchString) return 'invalid';
|
|
2048
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2049
|
-
const value = searchParams.get('_aggregation');
|
|
2050
|
-
if (value === '' || value === null) return 'invalid';
|
|
2051
|
-
|
|
2052
|
-
// Format: field1.sum,field2.avg or [field1.sum,field2.avg]
|
|
2053
|
-
const inner = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value;
|
|
2054
|
-
if (!inner) return 'invalid';
|
|
2055
|
-
const model = {};
|
|
2056
|
-
for (const entry of inner.split(',')) {
|
|
2057
|
-
const dotIndex = entry.lastIndexOf('.');
|
|
2058
|
-
if (dotIndex <= 0) return 'invalid';
|
|
2059
|
-
const field = entry.slice(0, dotIndex);
|
|
2060
|
-
const aggFunc = entry.slice(dotIndex + 1);
|
|
2061
|
-
if (!field || !aggFunc) return 'invalid';
|
|
2062
|
-
model[field] = aggFunc;
|
|
2063
|
-
}
|
|
2064
|
-
return Object.keys(model).length > 0 ? model : 'invalid';
|
|
2065
|
-
};
|
|
2066
|
-
const getSearchParamsFromAggregation = aggregation => {
|
|
2067
|
-
const searchParams = new URLSearchParams();
|
|
2068
|
-
const entries = Object.entries(aggregation);
|
|
2069
|
-
if (entries.length > 0) {
|
|
2070
|
-
const value = entries.map(_ref => {
|
|
2071
|
-
let [field, aggFunc] = _ref;
|
|
2072
|
-
return `${field}.${aggFunc}`;
|
|
2073
|
-
}).join(',');
|
|
2074
|
-
searchParams.set('_aggregation', value);
|
|
2075
|
-
}
|
|
2076
|
-
return searchParams;
|
|
2077
|
-
};
|
|
2078
|
-
const getAggregationModel = (search, localStorageAggregation, setLocalStorageAggregation, initialState, isNewVersion) => {
|
|
2079
|
-
var _initialState$aggrega, _initialState$aggrega2;
|
|
2080
|
-
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 : {};
|
|
2081
|
-
const persistDefault = () => {
|
|
2082
|
-
const searchFromDefault = getSearchParamsFromAggregation(defaultValue);
|
|
2083
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2084
|
-
if (searchString !== localStorageAggregation) {
|
|
2085
|
-
setLocalStorageAggregation(searchString);
|
|
2086
|
-
}
|
|
2087
|
-
};
|
|
2088
|
-
if (isNewVersion) {
|
|
2089
|
-
persistDefault();
|
|
2090
|
-
return defaultValue;
|
|
2091
|
-
}
|
|
2092
|
-
const fromUrl = getAggregationFromString(search);
|
|
2093
|
-
if (fromUrl !== 'invalid') {
|
|
2094
|
-
const searchFromModel = getSearchParamsFromAggregation(fromUrl);
|
|
2095
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2096
|
-
if (searchString !== localStorageAggregation) {
|
|
2097
|
-
setLocalStorageAggregation(searchString);
|
|
2098
|
-
}
|
|
2099
|
-
return fromUrl;
|
|
2100
|
-
}
|
|
2101
|
-
const fromLocalStorage = getAggregationFromString(localStorageAggregation);
|
|
2102
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2103
|
-
return fromLocalStorage;
|
|
2104
|
-
}
|
|
2105
|
-
persistDefault();
|
|
2106
|
-
return defaultValue;
|
|
2107
|
-
};
|
|
2108
|
-
|
|
2109
|
-
/** PIVOT */
|
|
2110
|
-
|
|
2111
|
-
/**
|
|
2112
|
-
* Pivot format: `cols:f1,f2;rows:f3;vals:f4.sum,f5.avg`
|
|
2113
|
-
*/
|
|
2114
|
-
const getPivotFromString = searchString => {
|
|
2115
|
-
if (!searchString) return 'invalid';
|
|
2116
|
-
const searchParams = new URLSearchParams(searchString);
|
|
2117
|
-
const value = searchParams.get('_pivot');
|
|
2118
|
-
if (value === '' || value === null) return 'invalid';
|
|
2119
|
-
const model = {
|
|
2120
|
-
columns: [],
|
|
2121
|
-
rows: [],
|
|
2122
|
-
values: []
|
|
2123
|
-
};
|
|
2124
|
-
for (const segment of value.split(';')) {
|
|
2125
|
-
const colonIndex = segment.indexOf(':');
|
|
2126
|
-
if (colonIndex <= 0) return 'invalid';
|
|
2127
|
-
const key = segment.slice(0, colonIndex);
|
|
2128
|
-
const content = segment.slice(colonIndex + 1);
|
|
2129
|
-
if (key === 'cols') {
|
|
2130
|
-
model.columns = content ? content.split(',').filter(Boolean) : [];
|
|
2131
|
-
} else if (key === 'rows') {
|
|
2132
|
-
model.rows = content ? content.split(',').filter(Boolean) : [];
|
|
2133
|
-
} else if (key === 'vals') {
|
|
2134
|
-
if (!content) continue;
|
|
2135
|
-
for (const entry of content.split(',')) {
|
|
2136
|
-
const dotIndex = entry.lastIndexOf('.');
|
|
2137
|
-
if (dotIndex <= 0) return 'invalid';
|
|
2138
|
-
model.values.push({
|
|
2139
|
-
field: entry.slice(0, dotIndex),
|
|
2140
|
-
aggFunc: entry.slice(dotIndex + 1)
|
|
2141
|
-
});
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
// At least one section must have content
|
|
2147
|
-
if (model.columns.length === 0 && model.rows.length === 0 && model.values.length === 0) {
|
|
2148
|
-
return 'invalid';
|
|
2149
|
-
}
|
|
2150
|
-
return model;
|
|
2151
|
-
};
|
|
2152
|
-
const getSearchParamsFromPivot = pivot => {
|
|
2153
|
-
const searchParams = new URLSearchParams();
|
|
2154
|
-
const hasContent = pivot.columns.length > 0 || pivot.rows.length > 0 || pivot.values.length > 0;
|
|
2155
|
-
if (hasContent) {
|
|
2156
|
-
const parts = [];
|
|
2157
|
-
parts.push(`cols:${pivot.columns.join(',')}`);
|
|
2158
|
-
parts.push(`rows:${pivot.rows.join(',')}`);
|
|
2159
|
-
if (pivot.values.length > 0) {
|
|
2160
|
-
parts.push(`vals:${pivot.values.map(v => `${v.field}.${v.aggFunc}`).join(',')}`);
|
|
2161
|
-
}
|
|
2162
|
-
searchParams.set('_pivot', parts.join(';'));
|
|
2163
|
-
}
|
|
2164
|
-
return searchParams;
|
|
2165
|
-
};
|
|
2166
|
-
const getPivotModel = (search, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion) => {
|
|
2167
|
-
const defaultValue = {
|
|
2168
|
-
columns: [],
|
|
2169
|
-
rows: [],
|
|
2170
|
-
values: []
|
|
2171
|
-
};
|
|
2172
|
-
const persistDefault = () => {
|
|
2173
|
-
const searchFromDefault = getSearchParamsFromPivot(defaultValue);
|
|
2174
|
-
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2175
|
-
if (searchString !== localStoragePivot) {
|
|
2176
|
-
setLocalStoragePivot(searchString);
|
|
2177
|
-
}
|
|
2178
|
-
};
|
|
2179
|
-
if (isNewVersion) {
|
|
2180
|
-
persistDefault();
|
|
2181
|
-
return defaultValue;
|
|
2182
|
-
}
|
|
2183
|
-
const fromUrl = getPivotFromString(search);
|
|
2184
|
-
if (fromUrl !== 'invalid') {
|
|
2185
|
-
const searchFromModel = getSearchParamsFromPivot(fromUrl);
|
|
2186
|
-
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2187
|
-
if (searchString !== localStoragePivot) {
|
|
2188
|
-
setLocalStoragePivot(searchString);
|
|
2189
|
-
}
|
|
2190
|
-
return fromUrl;
|
|
2191
|
-
}
|
|
2192
|
-
const fromLocalStorage = getPivotFromString(localStoragePivot);
|
|
2193
|
-
if (fromLocalStorage !== 'invalid') {
|
|
2194
|
-
return fromLocalStorage;
|
|
2195
|
-
}
|
|
2196
|
-
persistDefault();
|
|
2197
|
-
return defaultValue;
|
|
2198
|
-
};
|
|
2199
|
-
const getFinalSearch = _ref2 => {
|
|
3209
|
+
const getFinalSearch = _ref => {
|
|
2200
3210
|
let {
|
|
2201
3211
|
search,
|
|
2202
3212
|
localStorageVersion,
|
|
@@ -2208,11 +3218,8 @@ const getFinalSearch = _ref2 => {
|
|
|
2208
3218
|
density,
|
|
2209
3219
|
columnOrderModel,
|
|
2210
3220
|
defaultColumnOrder,
|
|
2211
|
-
rowGroupingModel,
|
|
2212
|
-
aggregationModel,
|
|
2213
|
-
pivotModel,
|
|
2214
3221
|
columns
|
|
2215
|
-
} =
|
|
3222
|
+
} = _ref;
|
|
2216
3223
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
2217
3224
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
2218
3225
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -2221,9 +3228,6 @@ const getFinalSearch = _ref2 => {
|
|
|
2221
3228
|
const densitySearch = getSearchParamsFromDensity(density);
|
|
2222
3229
|
// Only include _columnOrder in URL when it differs from the default
|
|
2223
3230
|
const columnOrderSearch = columnOrderModel.length !== defaultColumnOrder.length || columnOrderModel.some((field, i) => field !== defaultColumnOrder[i]) ? getSearchParamsFromColumnOrder(columnOrderModel) : new URLSearchParams();
|
|
2224
|
-
const rowGroupingSearch = getSearchParamsFromRowGrouping(rowGroupingModel);
|
|
2225
|
-
const aggregationSearch = getSearchParamsFromAggregation(aggregationModel);
|
|
2226
|
-
const pivotSearch = getSearchParamsFromPivot(pivotModel);
|
|
2227
3231
|
const tabSearch = getSearchParamsFromTab(search);
|
|
2228
3232
|
const searchParams = new URLSearchParams();
|
|
2229
3233
|
for (const [key, value] of new URLSearchParams(search)) {
|
|
@@ -2238,7 +3242,7 @@ const getFinalSearch = _ref2 => {
|
|
|
2238
3242
|
// Encode array as JSON string to preserve all values in one param
|
|
2239
3243
|
searchParams.set('_quickFilterValues', encodeURIComponent(JSON.stringify(filterModel.quickFilterValues)));
|
|
2240
3244
|
}
|
|
2241
|
-
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch
|
|
3245
|
+
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch]);
|
|
2242
3246
|
};
|
|
2243
3247
|
/** Return the state of the table given the URL and the local storage state */
|
|
2244
3248
|
const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, columns, initialState, localStorage) => {
|
|
@@ -2263,13 +3267,7 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2263
3267
|
localStorageDensity,
|
|
2264
3268
|
setLocalStorageDensity,
|
|
2265
3269
|
localStorageColumnOrder,
|
|
2266
|
-
setLocalStorageColumnOrder
|
|
2267
|
-
localStorageRowGrouping,
|
|
2268
|
-
setLocalStorageRowGrouping,
|
|
2269
|
-
localStorageAggregation,
|
|
2270
|
-
setLocalStorageAggregation,
|
|
2271
|
-
localStoragePivot,
|
|
2272
|
-
setLocalStoragePivot
|
|
3270
|
+
setLocalStorageColumnOrder
|
|
2273
3271
|
} = localStorage;
|
|
2274
3272
|
const filterModel = getFilterModel(decodedSearch, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion);
|
|
2275
3273
|
const sortModel = getSortModel(decodedSearch, columns, localStorageSorting, setLocalStorageSorting, initialState, isNewVersion);
|
|
@@ -2278,9 +3276,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2278
3276
|
const pinnedColumnsModel = getPinnedColumns(decodedSearch, columns, localStoragePinnedColumns, setLocalStoragePinnedColumns, initialState, isNewVersion);
|
|
2279
3277
|
const density = getDensityModel(decodedSearch, localStorageDensity, setLocalStorageDensity, initialState, isNewVersion);
|
|
2280
3278
|
const columnOrderModel = getColumnOrder(decodedSearch, columns, localStorageColumnOrder, setLocalStorageColumnOrder, initialState, isNewVersion);
|
|
2281
|
-
const rowGroupingModel = getRowGroupingModel(decodedSearch, localStorageRowGrouping, setLocalStorageRowGrouping, initialState, isNewVersion);
|
|
2282
|
-
const aggregationModel = getAggregationModel(decodedSearch, localStorageAggregation, setLocalStorageAggregation, initialState, isNewVersion);
|
|
2283
|
-
const pivotModel = getPivotModel(decodedSearch, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion);
|
|
2284
3279
|
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);
|
|
2285
3280
|
const finalSearch = getFinalSearch({
|
|
2286
3281
|
localStorageVersion,
|
|
@@ -2293,9 +3288,6 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2293
3288
|
density,
|
|
2294
3289
|
columnOrderModel,
|
|
2295
3290
|
defaultColumnOrder,
|
|
2296
|
-
rowGroupingModel,
|
|
2297
|
-
aggregationModel,
|
|
2298
|
-
pivotModel,
|
|
2299
3291
|
columns
|
|
2300
3292
|
});
|
|
2301
3293
|
const internalSearchString = urlSearchParamsToString(finalSearch);
|
|
@@ -2316,13 +3308,10 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2316
3308
|
pinnedColumnsModel,
|
|
2317
3309
|
density,
|
|
2318
3310
|
columnOrderModel,
|
|
2319
|
-
rowGroupingModel,
|
|
2320
|
-
aggregationModel,
|
|
2321
|
-
pivotModel,
|
|
2322
3311
|
pendingSearch
|
|
2323
3312
|
};
|
|
2324
3313
|
};
|
|
2325
|
-
const updateUrl = (
|
|
3314
|
+
const updateUrl = (_ref2, search, localStorageVersion, historyReplace, columns) => {
|
|
2326
3315
|
let {
|
|
2327
3316
|
filterModel,
|
|
2328
3317
|
sortModel,
|
|
@@ -2331,11 +3320,8 @@ const updateUrl = (_ref3, search, localStorageVersion, historyReplace, columns)
|
|
|
2331
3320
|
pinnedColumnsModel,
|
|
2332
3321
|
density,
|
|
2333
3322
|
columnOrderModel,
|
|
2334
|
-
defaultColumnOrder
|
|
2335
|
-
|
|
2336
|
-
aggregationModel,
|
|
2337
|
-
pivotModel
|
|
2338
|
-
} = _ref3;
|
|
3323
|
+
defaultColumnOrder
|
|
3324
|
+
} = _ref2;
|
|
2339
3325
|
// Convert from display format to internal format if needed
|
|
2340
3326
|
const decodedSearch = getDecodedSearchFromUrl(search, columns);
|
|
2341
3327
|
const newSearch = getFinalSearch({
|
|
@@ -2349,9 +3335,6 @@ const updateUrl = (_ref3, search, localStorageVersion, historyReplace, columns)
|
|
|
2349
3335
|
density,
|
|
2350
3336
|
columnOrderModel,
|
|
2351
3337
|
defaultColumnOrder,
|
|
2352
|
-
rowGroupingModel,
|
|
2353
|
-
aggregationModel,
|
|
2354
|
-
pivotModel,
|
|
2355
3338
|
columns
|
|
2356
3339
|
});
|
|
2357
3340
|
const internalSearchString = urlSearchParamsToString(newSearch);
|
|
@@ -2539,21 +3522,6 @@ const useTableStates = (id, version) => {
|
|
|
2539
3522
|
version,
|
|
2540
3523
|
category: COLUMN_ORDER_MODEL_KEY
|
|
2541
3524
|
}));
|
|
2542
|
-
const [rowGroupingModel, setRowGroupingModel] = useFetchState('', buildStorageKey({
|
|
2543
|
-
id,
|
|
2544
|
-
version,
|
|
2545
|
-
category: ROW_GROUPING_MODEL_KEY
|
|
2546
|
-
}));
|
|
2547
|
-
const [aggregationModel, setAggregationModel] = useFetchState('', buildStorageKey({
|
|
2548
|
-
id,
|
|
2549
|
-
version,
|
|
2550
|
-
category: AGGREGATION_MODEL_KEY
|
|
2551
|
-
}));
|
|
2552
|
-
const [pivotModel, setPivotModel] = useFetchState('', buildStorageKey({
|
|
2553
|
-
id,
|
|
2554
|
-
version,
|
|
2555
|
-
category: PIVOT_MODEL_KEY
|
|
2556
|
-
}));
|
|
2557
3525
|
return {
|
|
2558
3526
|
paginationModel,
|
|
2559
3527
|
setPaginationModel,
|
|
@@ -2570,69 +3538,10 @@ const useTableStates = (id, version) => {
|
|
|
2570
3538
|
densityModel,
|
|
2571
3539
|
setDensityModel,
|
|
2572
3540
|
columnOrderModel,
|
|
2573
|
-
setColumnOrderModel
|
|
2574
|
-
rowGroupingModel,
|
|
2575
|
-
setRowGroupingModel,
|
|
2576
|
-
aggregationModel,
|
|
2577
|
-
setAggregationModel,
|
|
2578
|
-
pivotModel,
|
|
2579
|
-
setPivotModel
|
|
3541
|
+
setColumnOrderModel
|
|
2580
3542
|
};
|
|
2581
3543
|
};
|
|
2582
3544
|
|
|
2583
|
-
/** Convert our simplified PivotModel → MUI's GridPivotModel */
|
|
2584
|
-
const toGridPivotModel = model => ({
|
|
2585
|
-
columns: model.columns.map(field => ({
|
|
2586
|
-
field
|
|
2587
|
-
})),
|
|
2588
|
-
rows: model.rows.map(field => ({
|
|
2589
|
-
field
|
|
2590
|
-
})),
|
|
2591
|
-
values: model.values.map(_ref => {
|
|
2592
|
-
let {
|
|
2593
|
-
field,
|
|
2594
|
-
aggFunc
|
|
2595
|
-
} = _ref;
|
|
2596
|
-
return {
|
|
2597
|
-
field,
|
|
2598
|
-
aggFunc
|
|
2599
|
-
};
|
|
2600
|
-
})
|
|
2601
|
-
});
|
|
2602
|
-
|
|
2603
|
-
/** Convert MUI's GridPivotModel → our simplified PivotModel */
|
|
2604
|
-
const fromGridPivotModel = model => ({
|
|
2605
|
-
columns: model.columns.map(c => c.field),
|
|
2606
|
-
rows: model.rows.map(r => r.field),
|
|
2607
|
-
values: model.values.map(_ref2 => {
|
|
2608
|
-
let {
|
|
2609
|
-
field,
|
|
2610
|
-
aggFunc
|
|
2611
|
-
} = _ref2;
|
|
2612
|
-
return {
|
|
2613
|
-
field,
|
|
2614
|
-
aggFunc
|
|
2615
|
-
};
|
|
2616
|
-
})
|
|
2617
|
-
});
|
|
2618
|
-
|
|
2619
|
-
/**
|
|
2620
|
-
* Deep-equal comparison for plain objects / arrays.
|
|
2621
|
-
* Used to stabilise parsed model references so that MUI v8 does not
|
|
2622
|
-
* reset pagination on every render.
|
|
2623
|
-
*/
|
|
2624
|
-
function isDeepEqual(a, b) {
|
|
2625
|
-
if (a === b) return true;
|
|
2626
|
-
if (a == null || b == null) return false;
|
|
2627
|
-
if (typeof a !== typeof b) return false;
|
|
2628
|
-
if (typeof a !== 'object') return false;
|
|
2629
|
-
const aObj = a;
|
|
2630
|
-
const bObj = b;
|
|
2631
|
-
const aKeys = Object.keys(aObj);
|
|
2632
|
-
const bKeys = Object.keys(bObj);
|
|
2633
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
2634
|
-
return aKeys.every(key => isDeepEqual(aObj[key], bObj[key]));
|
|
2635
|
-
}
|
|
2636
3545
|
const useStatefulTable = props => {
|
|
2637
3546
|
var _initialState$columns, _initialState$columns2;
|
|
2638
3547
|
const {
|
|
@@ -2645,9 +3554,6 @@ const useStatefulTable = props => {
|
|
|
2645
3554
|
onPaginationModelChange: propsOnPaginationModelChange,
|
|
2646
3555
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
2647
3556
|
onSortModelChange: propsOnSortModelChange,
|
|
2648
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
2649
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
2650
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
2651
3557
|
useRouter,
|
|
2652
3558
|
localStorageVersion = 1,
|
|
2653
3559
|
previousLocalStorageVersions = []
|
|
@@ -2676,22 +3582,16 @@ const useStatefulTable = props => {
|
|
|
2676
3582
|
densityModel,
|
|
2677
3583
|
setDensityModel,
|
|
2678
3584
|
columnOrderModel: localStorageColumnOrder,
|
|
2679
|
-
setColumnOrderModel: setLocalStorageColumnOrder
|
|
2680
|
-
rowGroupingModel: localStorageRowGrouping,
|
|
2681
|
-
setRowGroupingModel: setLocalStorageRowGrouping,
|
|
2682
|
-
aggregationModel: localStorageAggregation,
|
|
2683
|
-
setAggregationModel: setLocalStorageAggregation,
|
|
2684
|
-
pivotModel: localStoragePivot,
|
|
2685
|
-
setPivotModel: setLocalStoragePivot
|
|
3585
|
+
setColumnOrderModel: setLocalStorageColumnOrder
|
|
2686
3586
|
} = useTableStates(id, localStorageVersion);
|
|
2687
3587
|
|
|
2688
3588
|
// clearing up old version keys, triggering only on first render
|
|
2689
3589
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
2690
|
-
const onColumnDimensionChange = useCallback(
|
|
3590
|
+
const onColumnDimensionChange = useCallback(_ref => {
|
|
2691
3591
|
let {
|
|
2692
3592
|
newWidth,
|
|
2693
3593
|
field
|
|
2694
|
-
} =
|
|
3594
|
+
} = _ref;
|
|
2695
3595
|
setDimensionModel(_objectSpread2(_objectSpread2({}, dimensionModel), {}, {
|
|
2696
3596
|
[field]: newWidth
|
|
2697
3597
|
}));
|
|
@@ -2704,9 +3604,6 @@ const useStatefulTable = props => {
|
|
|
2704
3604
|
pinnedColumnsModel,
|
|
2705
3605
|
density: densityParsed,
|
|
2706
3606
|
columnOrderModel: columnOrderParsed,
|
|
2707
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2708
|
-
aggregationModel: aggregationParsed,
|
|
2709
|
-
pivotModel: pivotParsed,
|
|
2710
3607
|
pendingSearch
|
|
2711
3608
|
} = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, initialState, {
|
|
2712
3609
|
localStorageFilters,
|
|
@@ -2722,13 +3619,7 @@ const useStatefulTable = props => {
|
|
|
2722
3619
|
localStorageDensity: densityModel,
|
|
2723
3620
|
setLocalStorageDensity: setDensityModel,
|
|
2724
3621
|
localStorageColumnOrder,
|
|
2725
|
-
setLocalStorageColumnOrder
|
|
2726
|
-
localStorageRowGrouping,
|
|
2727
|
-
setLocalStorageRowGrouping,
|
|
2728
|
-
localStorageAggregation,
|
|
2729
|
-
setLocalStorageAggregation,
|
|
2730
|
-
localStoragePivot,
|
|
2731
|
-
setLocalStoragePivot
|
|
3622
|
+
setLocalStorageColumnOrder
|
|
2732
3623
|
});
|
|
2733
3624
|
|
|
2734
3625
|
// Sync URL in an effect rather than during render to comply with React rules
|
|
@@ -2737,45 +3628,6 @@ const useStatefulTable = props => {
|
|
|
2737
3628
|
historyReplace(pendingSearch);
|
|
2738
3629
|
}
|
|
2739
3630
|
}, [pendingSearch, historyReplace]);
|
|
2740
|
-
|
|
2741
|
-
// Stabilise parsed model references to prevent MUI v8 from resetting
|
|
2742
|
-
// pagination on every render due to new object identity.
|
|
2743
|
-
const filterParsedRef = useRef(filterParsed);
|
|
2744
|
-
if (!isDeepEqual(filterParsedRef.current, filterParsed)) {
|
|
2745
|
-
filterParsedRef.current = filterParsed;
|
|
2746
|
-
}
|
|
2747
|
-
const sortModelParsedRef = useRef(sortModelParsed);
|
|
2748
|
-
if (!isDeepEqual(sortModelParsedRef.current, sortModelParsed)) {
|
|
2749
|
-
sortModelParsedRef.current = sortModelParsed;
|
|
2750
|
-
}
|
|
2751
|
-
const paginationModelParsedRef = useRef(paginationModelParsed);
|
|
2752
|
-
if (!isDeepEqual(paginationModelParsedRef.current, paginationModelParsed)) {
|
|
2753
|
-
paginationModelParsedRef.current = paginationModelParsed;
|
|
2754
|
-
}
|
|
2755
|
-
const visibilityModelRef = useRef(visibilityModel);
|
|
2756
|
-
if (!isDeepEqual(visibilityModelRef.current, visibilityModel)) {
|
|
2757
|
-
visibilityModelRef.current = visibilityModel;
|
|
2758
|
-
}
|
|
2759
|
-
const pinnedColumnsModelRef = useRef(pinnedColumnsModel);
|
|
2760
|
-
if (!isDeepEqual(pinnedColumnsModelRef.current, pinnedColumnsModel)) {
|
|
2761
|
-
pinnedColumnsModelRef.current = pinnedColumnsModel;
|
|
2762
|
-
}
|
|
2763
|
-
const columnOrderParsedRef = useRef(columnOrderParsed);
|
|
2764
|
-
if (!isDeepEqual(columnOrderParsedRef.current, columnOrderParsed)) {
|
|
2765
|
-
columnOrderParsedRef.current = columnOrderParsed;
|
|
2766
|
-
}
|
|
2767
|
-
const rowGroupingParsedRef = useRef(rowGroupingParsed);
|
|
2768
|
-
if (!isDeepEqual(rowGroupingParsedRef.current, rowGroupingParsed)) {
|
|
2769
|
-
rowGroupingParsedRef.current = rowGroupingParsed;
|
|
2770
|
-
}
|
|
2771
|
-
const aggregationParsedRef = useRef(aggregationParsed);
|
|
2772
|
-
if (!isDeepEqual(aggregationParsedRef.current, aggregationParsed)) {
|
|
2773
|
-
aggregationParsedRef.current = aggregationParsed;
|
|
2774
|
-
}
|
|
2775
|
-
const pivotParsedRef = useRef(pivotParsed);
|
|
2776
|
-
if (!isDeepEqual(pivotParsedRef.current, pivotParsed)) {
|
|
2777
|
-
pivotParsedRef.current = pivotParsed;
|
|
2778
|
-
}
|
|
2779
3631
|
const columns = useMemo(() => propsColumns.map(column => {
|
|
2780
3632
|
return _objectSpread2(_objectSpread2({}, column), {}, {
|
|
2781
3633
|
width: dimensionModel[column.field] || column.width || 100
|
|
@@ -2784,59 +3636,56 @@ const useStatefulTable = props => {
|
|
|
2784
3636
|
if (apiRef.current) {
|
|
2785
3637
|
/** Add resetPage method to apiRef. */
|
|
2786
3638
|
apiRef.current.resetPage = () => {
|
|
2787
|
-
|
|
2788
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPage(0);
|
|
3639
|
+
apiRef.current.setPage(0);
|
|
2789
3640
|
};
|
|
2790
3641
|
}
|
|
2791
3642
|
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);
|
|
2792
3643
|
|
|
3644
|
+
// Helper to build the current DataGridModel for updateUrl calls
|
|
3645
|
+
const buildModel = function () {
|
|
3646
|
+
var _apiRef$current$state, _apiRef$current;
|
|
3647
|
+
let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3648
|
+
return _objectSpread2({
|
|
3649
|
+
filterModel: filterParsed,
|
|
3650
|
+
sortModel: sortModelParsed,
|
|
3651
|
+
paginationModel: paginationModelParsed,
|
|
3652
|
+
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 : {},
|
|
3653
|
+
pinnedColumnsModel: pinnedColumnsModel,
|
|
3654
|
+
density: densityParsed,
|
|
3655
|
+
columnOrderModel: columnOrderParsed,
|
|
3656
|
+
defaultColumnOrder
|
|
3657
|
+
}, overrides);
|
|
3658
|
+
};
|
|
3659
|
+
|
|
2793
3660
|
// Subscribe to density changes via stateChange event (MUI v6 has no densityChange event)
|
|
2794
3661
|
useEffect(() => {
|
|
2795
3662
|
const api = apiRef.current;
|
|
2796
3663
|
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
2797
3664
|
let prevDensity = densityParsed;
|
|
2798
3665
|
const unsub = api.subscribeEvent('stateChange', () => {
|
|
2799
|
-
const currentDensity = api.state.density;
|
|
3666
|
+
const currentDensity = api.state.density.value;
|
|
2800
3667
|
if (currentDensity !== prevDensity) {
|
|
2801
3668
|
prevDensity = currentDensity;
|
|
2802
|
-
updateUrl({
|
|
2803
|
-
filterModel: filterParsed,
|
|
2804
|
-
sortModel: sortModelParsed,
|
|
2805
|
-
paginationModel: paginationModelParsed,
|
|
3669
|
+
updateUrl(buildModel({
|
|
2806
3670
|
columnsModel: api.state.columns.columnVisibilityModel,
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
columnOrderModel: columnOrderParsed,
|
|
2810
|
-
defaultColumnOrder,
|
|
2811
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2812
|
-
aggregationModel: aggregationParsed,
|
|
2813
|
-
pivotModel: pivotParsed
|
|
2814
|
-
}, search, localStorageVersion, historyReplace, columns);
|
|
3671
|
+
density: currentDensity
|
|
3672
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
2815
3673
|
}
|
|
2816
3674
|
});
|
|
2817
3675
|
return unsub;
|
|
2818
|
-
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder,
|
|
3676
|
+
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder, search, localStorageVersion, historyReplace, columns]);
|
|
2819
3677
|
|
|
2820
3678
|
// Subscribe to column order changes via columnOrderChange (drag-drop) and columnIndexChange (programmatic setColumnIndex)
|
|
2821
3679
|
useEffect(() => {
|
|
2822
3680
|
const api = apiRef.current;
|
|
2823
3681
|
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
3682
|
+
const isDeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
2824
3683
|
const handleColumnOrderChange = () => {
|
|
2825
3684
|
const orderedFields = api.state.columns.orderedFields;
|
|
2826
3685
|
if (orderedFields && !isDeepEqual(orderedFields, columnOrderParsed)) {
|
|
2827
|
-
updateUrl({
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
paginationModel: paginationModelParsed,
|
|
2831
|
-
columnsModel: api.state.columns.columnVisibilityModel,
|
|
2832
|
-
pinnedColumnsModel,
|
|
2833
|
-
density: densityParsed,
|
|
2834
|
-
columnOrderModel: orderedFields,
|
|
2835
|
-
defaultColumnOrder,
|
|
2836
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2837
|
-
aggregationModel: aggregationParsed,
|
|
2838
|
-
pivotModel: pivotParsed
|
|
2839
|
-
}, search, localStorageVersion, historyReplace, columns);
|
|
3686
|
+
updateUrl(buildModel({
|
|
3687
|
+
columnOrderModel: orderedFields
|
|
3688
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
2840
3689
|
}
|
|
2841
3690
|
};
|
|
2842
3691
|
const unsub1 = api.subscribeEvent('columnOrderChange', handleColumnOrderChange);
|
|
@@ -2845,80 +3694,57 @@ const useStatefulTable = props => {
|
|
|
2845
3694
|
unsub1();
|
|
2846
3695
|
unsub2();
|
|
2847
3696
|
};
|
|
2848
|
-
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed,
|
|
2849
|
-
|
|
2850
|
-
// Helper to build the current DataGridModel for updateUrl calls
|
|
2851
|
-
const buildModel = function () {
|
|
2852
|
-
var _apiRef$current$state, _apiRef$current2;
|
|
2853
|
-
let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2854
|
-
return _objectSpread2({
|
|
2855
|
-
filterModel: filterParsed,
|
|
2856
|
-
sortModel: sortModelParsed,
|
|
2857
|
-
paginationModel: paginationModelParsed,
|
|
2858
|
-
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 : {},
|
|
2859
|
-
pinnedColumnsModel: pinnedColumnsModel,
|
|
2860
|
-
density: densityParsed,
|
|
2861
|
-
columnOrderModel: columnOrderParsed,
|
|
2862
|
-
defaultColumnOrder,
|
|
2863
|
-
rowGroupingModel: rowGroupingParsed,
|
|
2864
|
-
aggregationModel: aggregationParsed,
|
|
2865
|
-
pivotModel: pivotParsed
|
|
2866
|
-
}, overrides);
|
|
2867
|
-
};
|
|
3697
|
+
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed, search, localStorageVersion, historyReplace, columns]);
|
|
2868
3698
|
return {
|
|
2869
3699
|
apiRef,
|
|
2870
3700
|
columns,
|
|
2871
3701
|
density: densityParsed,
|
|
2872
|
-
columnOrderModel:
|
|
2873
|
-
rowGroupingModel: rowGroupingParsedRef.current,
|
|
2874
|
-
aggregationModel: aggregationParsedRef.current,
|
|
2875
|
-
pivotModel: toGridPivotModel(pivotParsedRef.current),
|
|
3702
|
+
columnOrderModel: columnOrderParsed,
|
|
2876
3703
|
onFilterModelChange: (model, details) => {
|
|
2877
3704
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2878
3705
|
items: model.items.map(item => {
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
item.type = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
3706
|
+
const column = apiRef.current.getColumn(item.field);
|
|
3707
|
+
item.type = column.type || 'string';
|
|
2882
3708
|
return item;
|
|
2883
3709
|
}),
|
|
2884
3710
|
quickFilterValues: model.quickFilterValues || []
|
|
2885
3711
|
});
|
|
3712
|
+
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
2886
3713
|
updateUrl(buildModel({
|
|
2887
3714
|
filterModel
|
|
2888
3715
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2889
|
-
propsOnFilterModelChange === null || propsOnFilterModelChange === void 0 ? void 0 : propsOnFilterModelChange(filterModel, details);
|
|
2890
3716
|
},
|
|
2891
|
-
filterModel:
|
|
3717
|
+
filterModel: filterParsed,
|
|
2892
3718
|
onSortModelChange: (model, details) => {
|
|
3719
|
+
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
2893
3720
|
updateUrl(buildModel({
|
|
2894
3721
|
sortModel: model
|
|
2895
3722
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2896
|
-
propsOnSortModelChange === null || propsOnSortModelChange === void 0 ? void 0 : propsOnSortModelChange(model, details);
|
|
2897
3723
|
},
|
|
2898
|
-
sortModel:
|
|
3724
|
+
sortModel: sortModelParsed,
|
|
2899
3725
|
onPinnedColumnsChange: (pinnedColumns, details) => {
|
|
3726
|
+
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
2900
3727
|
updateUrl(buildModel({
|
|
2901
3728
|
pinnedColumnsModel: pinnedColumns
|
|
2902
3729
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2903
|
-
propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
|
|
2904
3730
|
},
|
|
2905
|
-
pinnedColumns:
|
|
2906
|
-
paginationModel:
|
|
3731
|
+
pinnedColumns: pinnedColumnsModel,
|
|
3732
|
+
paginationModel: paginationModelParsed,
|
|
2907
3733
|
onPaginationModelChange: (model, details) => {
|
|
2908
3734
|
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2909
3735
|
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
2910
3736
|
});
|
|
3737
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
2911
3738
|
updateUrl(buildModel({
|
|
2912
3739
|
paginationModel
|
|
2913
3740
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2914
|
-
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
2915
3741
|
},
|
|
2916
|
-
columnVisibilityModel:
|
|
3742
|
+
columnVisibilityModel: visibilityModel,
|
|
2917
3743
|
onColumnVisibilityModelChange: (columnsVisibilityModel, details) => {
|
|
3744
|
+
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
2918
3745
|
updateUrl(buildModel({
|
|
2919
3746
|
columnsModel: columnsVisibilityModel
|
|
2920
3747
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2921
|
-
propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
|
|
2922
3748
|
},
|
|
2923
3749
|
onColumnWidthChange: (params, event, details) => {
|
|
2924
3750
|
propsOnColumnWidthChange === null || propsOnColumnWidthChange === void 0 ? void 0 : propsOnColumnWidthChange(params, event, details);
|
|
@@ -2926,30 +3752,11 @@ const useStatefulTable = props => {
|
|
|
2926
3752
|
newWidth: params.width,
|
|
2927
3753
|
field: params.colDef.field
|
|
2928
3754
|
});
|
|
2929
|
-
},
|
|
2930
|
-
onRowGroupingModelChange: (model, details) => {
|
|
2931
|
-
updateUrl(buildModel({
|
|
2932
|
-
rowGroupingModel: model
|
|
2933
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
2934
|
-
propsOnRowGroupingModelChange === null || propsOnRowGroupingModelChange === void 0 ? void 0 : propsOnRowGroupingModelChange(model, details);
|
|
2935
|
-
},
|
|
2936
|
-
onAggregationModelChange: (model, details) => {
|
|
2937
|
-
updateUrl(buildModel({
|
|
2938
|
-
aggregationModel: model
|
|
2939
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
2940
|
-
propsOnAggregationModelChange === null || propsOnAggregationModelChange === void 0 ? void 0 : propsOnAggregationModelChange(model, details);
|
|
2941
|
-
},
|
|
2942
|
-
onPivotModelChange: model => {
|
|
2943
|
-
const simplified = fromGridPivotModel(model);
|
|
2944
|
-
updateUrl(buildModel({
|
|
2945
|
-
pivotModel: simplified
|
|
2946
|
-
}), search, localStorageVersion, historyReplace, columns);
|
|
2947
|
-
propsOnPivotModelChange === null || propsOnPivotModelChange === void 0 ? void 0 : propsOnPivotModelChange(model);
|
|
2948
3755
|
}
|
|
2949
3756
|
};
|
|
2950
3757
|
};
|
|
2951
3758
|
|
|
2952
|
-
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", "
|
|
3759
|
+
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", "paginationProps", "rows", "pageSizeOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
|
|
2953
3760
|
const COMPONENT_NAME = 'DataGrid';
|
|
2954
3761
|
const CLASSNAME = 'redsift-datagrid';
|
|
2955
3762
|
|
|
@@ -3033,9 +3840,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3033
3840
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
3034
3841
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
3035
3842
|
onSortModelChange: propsOnSortModelChange,
|
|
3036
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3037
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3038
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3039
3843
|
pagination,
|
|
3040
3844
|
paginationPlacement = 'both',
|
|
3041
3845
|
paginationProps,
|
|
@@ -3045,13 +3849,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3045
3849
|
theme: propsTheme,
|
|
3046
3850
|
useRouter,
|
|
3047
3851
|
paginationMode = 'client',
|
|
3048
|
-
rowCount
|
|
3049
|
-
density: _density
|
|
3852
|
+
rowCount
|
|
3050
3853
|
} = props,
|
|
3051
3854
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
3052
|
-
const theme = useTheme(propsTheme);
|
|
3855
|
+
const theme = useTheme$1(propsTheme);
|
|
3053
3856
|
const _apiRef = useGridApiRef();
|
|
3054
3857
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
3858
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar;
|
|
3055
3859
|
LicenseInfo.setLicenseKey(license);
|
|
3056
3860
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
3057
3861
|
const {
|
|
@@ -3087,13 +3891,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3087
3891
|
pinnedColumns,
|
|
3088
3892
|
sortModel,
|
|
3089
3893
|
onColumnWidthChange,
|
|
3090
|
-
columnOrderModel
|
|
3091
|
-
rowGroupingModel,
|
|
3092
|
-
aggregationModel,
|
|
3093
|
-
pivotModel,
|
|
3094
|
-
onRowGroupingModelChange,
|
|
3095
|
-
onAggregationModelChange,
|
|
3096
|
-
onPivotModelChange
|
|
3894
|
+
columnOrderModel
|
|
3097
3895
|
} = useStatefulTable({
|
|
3098
3896
|
apiRef: apiRef,
|
|
3099
3897
|
initialState,
|
|
@@ -3104,16 +3902,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3104
3902
|
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
3105
3903
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
3106
3904
|
onSortModelChange: controlledOnSortModelChange,
|
|
3107
|
-
onRowGroupingModelChange: propsOnRowGroupingModelChange,
|
|
3108
|
-
onAggregationModelChange: propsOnAggregationModelChange,
|
|
3109
|
-
onPivotModelChange: propsOnPivotModelChange,
|
|
3110
3905
|
useRouter: useRouter,
|
|
3111
3906
|
localStorageVersion,
|
|
3112
3907
|
previousLocalStorageVersions
|
|
3113
3908
|
});
|
|
3114
|
-
const [rowSelectionModel, setRowSelectionModel] = useState(
|
|
3909
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3115
3910
|
useEffect(() => {
|
|
3116
|
-
setRowSelectionModel(
|
|
3911
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
3117
3912
|
}, [propsRowSelectionModel]);
|
|
3118
3913
|
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
3119
3914
|
setRowSelectionModel(selectionModel);
|
|
@@ -3127,36 +3922,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3127
3922
|
pageSize: paginationModel.pageSize
|
|
3128
3923
|
});
|
|
3129
3924
|
|
|
3130
|
-
// Version counter to force re-renders when selectionStatus ref changes
|
|
3131
|
-
const [, forceSelectionUpdate] = useState(0);
|
|
3132
|
-
|
|
3133
3925
|
// The checkboxSelectionVisibleOnly should only be applied to client-side pagination,
|
|
3134
3926
|
// for server-side pagination it produces inconsistent behavior when selecting all rows in pages 2 and beyond
|
|
3135
3927
|
const checkboxSelectionVisibleOnly = Boolean(pagination) && Boolean(paginationMode != 'server');
|
|
3136
3928
|
|
|
3137
|
-
// Track when the grid API is ready to ensure top pagination renders correctly
|
|
3138
|
-
const [gridReady, setGridReady] = useState(false);
|
|
3139
|
-
|
|
3140
|
-
// Force re-render when the grid API becomes ready (for top pagination)
|
|
3141
|
-
useEffect(() => {
|
|
3142
|
-
if (apiRef.current && !gridReady) {
|
|
3143
|
-
setGridReady(true);
|
|
3144
|
-
}
|
|
3145
|
-
});
|
|
3146
|
-
|
|
3147
|
-
// Sync persisted density via apiRef — initialState only applies on mount,
|
|
3148
|
-
// so this handles SPA back/forward navigation where controlledDensity changes after mount
|
|
3149
|
-
useEffect(() => {
|
|
3150
|
-
if (apiRef.current) {
|
|
3151
|
-
apiRef.current.setDensity(controlledDensity);
|
|
3152
|
-
}
|
|
3153
|
-
}, [controlledDensity, apiRef]);
|
|
3154
|
-
|
|
3155
3929
|
// in server-side pagination we want to update the selection status
|
|
3156
3930
|
// every time we navigate between pages, resize our page or select something
|
|
3157
3931
|
useEffect(() => {
|
|
3158
3932
|
if (paginationMode == 'server') {
|
|
3159
|
-
onServerSideSelectionStatusChange(rowSelectionModel, apiRef, selectionStatusRef,
|
|
3933
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatusRef, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
3160
3934
|
}
|
|
3161
3935
|
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize, rows]);
|
|
3162
3936
|
if (!Array.isArray(rows)) {
|
|
@@ -3168,15 +3942,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3168
3942
|
// receive the fresh value in the same render cycle — no extra re-render needed.
|
|
3169
3943
|
// The ref is kept in sync for the onRowSelectionModelChange callback's deselect logic.
|
|
3170
3944
|
let selectionStatus = selectionStatusRef.current;
|
|
3171
|
-
if (pagination && paginationMode !== 'server' &&
|
|
3945
|
+
if (pagination && paginationMode !== 'server' && Array.isArray(rowSelectionModel) && rowSelectionModel.length > 0) {
|
|
3172
3946
|
try {
|
|
3173
|
-
|
|
3174
|
-
// MUI's paginated selectors use apiRef internal state which may be stale when
|
|
3175
|
-
// paginationModel prop changes — our React state is always up to date.
|
|
3176
|
-
const allFilteredEntries = gridFilteredSortedRowEntriesSelector(apiRef);
|
|
3177
|
-
const pageStart = paginationModel.page * paginationModel.pageSize;
|
|
3178
|
-
const pageEntries = allFilteredEntries.slice(pageStart, pageStart + paginationModel.pageSize);
|
|
3179
|
-
const selectableRowsInPage = isRowSelectable ? pageEntries.filter(_ref => {
|
|
3947
|
+
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
3180
3948
|
let {
|
|
3181
3949
|
model
|
|
3182
3950
|
} = _ref;
|
|
@@ -3188,29 +3956,24 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3188
3956
|
id
|
|
3189
3957
|
} = _ref2;
|
|
3190
3958
|
return id;
|
|
3191
|
-
}) :
|
|
3192
|
-
let {
|
|
3193
|
-
id
|
|
3194
|
-
} = _ref3;
|
|
3195
|
-
return id;
|
|
3196
|
-
});
|
|
3959
|
+
}) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
|
|
3197
3960
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3198
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
3961
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref3 => {
|
|
3199
3962
|
let {
|
|
3200
3963
|
model
|
|
3201
|
-
} =
|
|
3964
|
+
} = _ref3;
|
|
3202
3965
|
return isRowSelectable({
|
|
3203
3966
|
row: model
|
|
3204
3967
|
});
|
|
3205
|
-
}).map(
|
|
3968
|
+
}).map(_ref4 => {
|
|
3206
3969
|
let {
|
|
3207
3970
|
id
|
|
3208
|
-
} =
|
|
3971
|
+
} = _ref4;
|
|
3209
3972
|
return id;
|
|
3210
3973
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3211
3974
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3212
|
-
const numberOfSelectedRows =
|
|
3213
|
-
const selectedOnCurrentPage = selectableRowsInPage.filter(id =>
|
|
3975
|
+
const numberOfSelectedRows = rowSelectionModel.length;
|
|
3976
|
+
const selectedOnCurrentPage = selectableRowsInPage.filter(id => rowSelectionModel.includes(id));
|
|
3214
3977
|
if (numberOfSelectedRows === numberOfSelectableRowsInTable && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
3215
3978
|
selectionStatus = {
|
|
3216
3979
|
type: 'table',
|
|
@@ -3264,31 +4027,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3264
4027
|
ref: datagridRef,
|
|
3265
4028
|
className: classNames(StatefulDataGrid.className, className),
|
|
3266
4029
|
$height: height
|
|
3267
|
-
},
|
|
3268
|
-
displaySelection: true,
|
|
3269
|
-
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3270
|
-
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3271
|
-
selectionStatus: selectionStatus,
|
|
3272
|
-
paginationModel: paginationModel,
|
|
3273
|
-
onPaginationModelChange: onPaginationModelChange,
|
|
3274
|
-
pageSizeOptions: pageSizeOptions,
|
|
3275
|
-
paginationProps: paginationProps,
|
|
3276
|
-
rowCount: rowCount
|
|
3277
|
-
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
3278
|
-
displaySelection: true,
|
|
3279
|
-
displayRowsPerPage: ['top', 'both'].includes(paginationPlacement),
|
|
3280
|
-
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
3281
|
-
selectionStatus: selectionStatus,
|
|
3282
|
-
apiRef: apiRef,
|
|
3283
|
-
isRowSelectable: isRowSelectable,
|
|
3284
|
-
paginationModel: paginationModel,
|
|
3285
|
-
onPaginationModelChange: onPaginationModelChange,
|
|
3286
|
-
pageSizeOptions: pageSizeOptions,
|
|
3287
|
-
paginationProps: paginationProps
|
|
3288
|
-
}) : null, /*#__PURE__*/React__default.createElement(DataGridPremium, _extends({}, forwardedProps, {
|
|
4030
|
+
}, /*#__PURE__*/React__default.createElement(DataGridPro, _extends$1({}, forwardedProps, {
|
|
3289
4031
|
apiRef: apiRef,
|
|
3290
4032
|
columns: columns,
|
|
3291
4033
|
columnVisibilityModel: columnVisibilityModel,
|
|
4034
|
+
density: controlledDensity,
|
|
3292
4035
|
filterModel: filterModel,
|
|
3293
4036
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
3294
4037
|
onFilterModelChange: onFilterModelChange,
|
|
@@ -3300,14 +4043,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3300
4043
|
sortModel: sortModel,
|
|
3301
4044
|
pageSizeOptions: pageSizeOptions,
|
|
3302
4045
|
onColumnWidthChange: onColumnWidthChange,
|
|
3303
|
-
rowGroupingModel: rowGroupingModel,
|
|
3304
|
-
onRowGroupingModelChange: onRowGroupingModelChange,
|
|
3305
|
-
aggregationModel: aggregationModel,
|
|
3306
|
-
onAggregationModelChange: onAggregationModelChange,
|
|
3307
|
-
pivotModel: pivotModel,
|
|
3308
|
-
onPivotModelChange: onPivotModelChange,
|
|
3309
4046
|
initialState: _objectSpread2(_objectSpread2({}, initialState), {}, {
|
|
3310
|
-
density: controlledDensity,
|
|
3311
4047
|
columns: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.columns), {}, {
|
|
3312
4048
|
orderedFields: columnOrderModel
|
|
3313
4049
|
})
|
|
@@ -3320,48 +4056,48 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3320
4056
|
rowCount: rowCount,
|
|
3321
4057
|
autoHeight: autoHeight,
|
|
3322
4058
|
checkboxSelectionVisibleOnly: checkboxSelectionVisibleOnly,
|
|
3323
|
-
disableRowSelectionExcludeModel: true,
|
|
3324
|
-
showToolbar: !hideToolbar,
|
|
3325
4059
|
slots: _objectSpread2(_objectSpread2({
|
|
3326
4060
|
baseButton: BaseButton,
|
|
3327
4061
|
baseCheckbox: BaseCheckbox,
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
4062
|
+
// baseTextField,
|
|
4063
|
+
basePopper: BasePopper,
|
|
4064
|
+
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4065
|
+
displayName: "ColumnFilteredIcon"
|
|
3331
4066
|
})),
|
|
3332
|
-
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3333
|
-
displayName: "
|
|
4067
|
+
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4068
|
+
displayName: "ColumnSelectorIcon"
|
|
3334
4069
|
})),
|
|
3335
|
-
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3336
|
-
displayName: "
|
|
4070
|
+
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4071
|
+
displayName: "ColumnSortedAscendingIcon"
|
|
3337
4072
|
})),
|
|
3338
|
-
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3339
|
-
displayName: "
|
|
4073
|
+
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4074
|
+
displayName: "ColumnSortedDescendingIcon"
|
|
3340
4075
|
})),
|
|
3341
|
-
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3342
|
-
displayName: "
|
|
4076
|
+
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4077
|
+
displayName: "DensityCompactIcon"
|
|
3343
4078
|
})),
|
|
3344
|
-
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3345
|
-
displayName: "
|
|
4079
|
+
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4080
|
+
displayName: "DensityStandardIcon"
|
|
3346
4081
|
})),
|
|
3347
|
-
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3348
|
-
displayName: "
|
|
4082
|
+
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4083
|
+
displayName: "DensityComfortableIcon"
|
|
3349
4084
|
})),
|
|
3350
|
-
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3351
|
-
displayName: "
|
|
4085
|
+
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4086
|
+
displayName: "DetailPanelCollapseIcon"
|
|
3352
4087
|
})),
|
|
3353
|
-
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3354
|
-
displayName: "
|
|
4088
|
+
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4089
|
+
displayName: "DetailPanelExpandIcon"
|
|
3355
4090
|
})),
|
|
3356
|
-
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
3357
|
-
displayName: "
|
|
4091
|
+
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
4092
|
+
displayName: "ExportIcon"
|
|
3358
4093
|
})),
|
|
3359
|
-
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({
|
|
3360
|
-
displayName: "
|
|
3361
|
-
}))
|
|
4094
|
+
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
4095
|
+
displayName: "OpenFilterButtonIcon"
|
|
4096
|
+
}, props))
|
|
3362
4097
|
}, slots), {}, {
|
|
4098
|
+
toolbar: ToolbarWrapper,
|
|
3363
4099
|
pagination: props => {
|
|
3364
|
-
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends({}, props, {
|
|
4100
|
+
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
3365
4101
|
displaySelection: false,
|
|
3366
4102
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3367
4103
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
@@ -3370,8 +4106,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3370
4106
|
onPaginationModelChange: onPaginationModelChange,
|
|
3371
4107
|
pageSizeOptions: pageSizeOptions,
|
|
3372
4108
|
paginationProps: paginationProps,
|
|
4109
|
+
paginationMode: paginationMode,
|
|
3373
4110
|
rowCount: rowCount
|
|
3374
|
-
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends({}, props, {
|
|
4111
|
+
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends$1({}, props, {
|
|
3375
4112
|
displaySelection: false,
|
|
3376
4113
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
3377
4114
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
@@ -3381,57 +4118,65 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3381
4118
|
paginationModel: paginationModel,
|
|
3382
4119
|
onPaginationModelChange: onPaginationModelChange,
|
|
3383
4120
|
pageSizeOptions: pageSizeOptions,
|
|
3384
|
-
paginationProps: paginationProps
|
|
4121
|
+
paginationProps: paginationProps,
|
|
4122
|
+
paginationMode: paginationMode
|
|
3385
4123
|
})) : null;
|
|
3386
4124
|
}
|
|
3387
4125
|
}),
|
|
3388
|
-
slotProps: _objectSpread2({}, slotProps),
|
|
4126
|
+
slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
|
|
4127
|
+
toolbar: _objectSpread2({
|
|
4128
|
+
hideToolbar,
|
|
4129
|
+
RenderedToolbar,
|
|
4130
|
+
filterModel,
|
|
4131
|
+
onFilterModelChange,
|
|
4132
|
+
pagination,
|
|
4133
|
+
paginationPlacement,
|
|
4134
|
+
selectionStatus,
|
|
4135
|
+
apiRef,
|
|
4136
|
+
isRowSelectable,
|
|
4137
|
+
paginationModel,
|
|
4138
|
+
onPaginationModelChange,
|
|
4139
|
+
pageSizeOptions,
|
|
4140
|
+
paginationProps,
|
|
4141
|
+
paginationMode,
|
|
4142
|
+
rowCount
|
|
4143
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
|
|
4144
|
+
}),
|
|
3389
4145
|
rowSelectionModel: rowSelectionModel,
|
|
3390
4146
|
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
3391
4147
|
if (pagination && paginationMode != 'server') {
|
|
3392
|
-
|
|
3393
|
-
// to avoid stale apiRef pagination state.
|
|
3394
|
-
const allFilteredEntries = gridFilteredSortedRowEntriesSelector(apiRef);
|
|
3395
|
-
const pageStart = paginationModel.page * paginationModel.pageSize;
|
|
3396
|
-
const pageEntries = allFilteredEntries.slice(pageStart, pageStart + paginationModel.pageSize);
|
|
3397
|
-
const selectableRowsInPage = isRowSelectable ? pageEntries.filter(_ref6 => {
|
|
4148
|
+
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref5 => {
|
|
3398
4149
|
let {
|
|
3399
4150
|
model
|
|
3400
|
-
} =
|
|
4151
|
+
} = _ref5;
|
|
3401
4152
|
return isRowSelectable({
|
|
3402
4153
|
row: model
|
|
3403
4154
|
});
|
|
3404
|
-
}).map(
|
|
4155
|
+
}).map(_ref6 => {
|
|
3405
4156
|
let {
|
|
3406
4157
|
id
|
|
3407
|
-
} =
|
|
3408
|
-
return id;
|
|
3409
|
-
}) : pageEntries.map(_ref8 => {
|
|
3410
|
-
let {
|
|
3411
|
-
id
|
|
3412
|
-
} = _ref8;
|
|
4158
|
+
} = _ref6;
|
|
3413
4159
|
return id;
|
|
3414
|
-
});
|
|
4160
|
+
}) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
|
|
3415
4161
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
3416
|
-
const selectableRowsInTable = isRowSelectable ?
|
|
4162
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref7 => {
|
|
3417
4163
|
let {
|
|
3418
4164
|
model
|
|
3419
|
-
} =
|
|
4165
|
+
} = _ref7;
|
|
3420
4166
|
return isRowSelectable({
|
|
3421
4167
|
row: model
|
|
3422
4168
|
});
|
|
3423
|
-
}).map(
|
|
4169
|
+
}).map(_ref8 => {
|
|
3424
4170
|
let {
|
|
3425
4171
|
id
|
|
3426
|
-
} =
|
|
4172
|
+
} = _ref8;
|
|
3427
4173
|
return id;
|
|
3428
4174
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
3429
4175
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
3430
|
-
const numberOfSelectedRows =
|
|
4176
|
+
const numberOfSelectedRows = newSelectionModel.length;
|
|
3431
4177
|
if (selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable - numberOfSelectableRowsInPage || selectionStatusRef.current.type === 'table' && numberOfSelectedRows === numberOfSelectableRowsInTable || selectionStatusRef.current.type === 'page' && numberOfSelectedRows === numberOfSelectableRowsInPage) {
|
|
3432
4178
|
setTimeout(() => {
|
|
3433
|
-
|
|
3434
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.selectRows([], true, true);
|
|
4179
|
+
apiRef.current.selectRows([], true, true);
|
|
3435
4180
|
}, 0);
|
|
3436
4181
|
}
|
|
3437
4182
|
if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
|
|
@@ -3455,7 +4200,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3455
4200
|
numberOfSelectedRows
|
|
3456
4201
|
};
|
|
3457
4202
|
}
|
|
3458
|
-
forceSelectionUpdate(v => v + 1);
|
|
3459
4203
|
}
|
|
3460
4204
|
onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
|
|
3461
4205
|
},
|
|
@@ -3473,5 +4217,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3473
4217
|
StatefulDataGrid.className = CLASSNAME;
|
|
3474
4218
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
3475
4219
|
|
|
3476
|
-
export {
|
|
4220
|
+
export { convertToDisplayFormat 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, convertFromDisplayFormat as a0, getDecodedSearchFromUrl as a1, buildQueryParamsString as a2, areSearchStringsEqual as a3, decodeValue as a4, encodeValue as a5, urlSearchParamsToString as a6, numberOperatorEncoder as a7, numberOperatorDecoder as a8, isOperatorValueValid as a9, isValueValid as aa, getFilterModelFromString as ab, getSearchParamsFromFilterModel as ac, getSortingFromString as ad, getSearchParamsFromSorting as ae, getPaginationFromString as af, getSearchParamsFromPagination as ag, getColumnVisibilityFromString as ah, getSearchParamsFromColumnVisibility as ai, getPinnedColumnsFromString as aj, getSearchParamsFromPinnedColumns as ak, getSearchParamsFromTab as al, getDensityFromString as am, getSearchParamsFromDensity as an, getColumnOrderFromString as ao, getSearchParamsFromColumnOrder as ap, getFinalSearch as aq, getModelsParsedOrUpdateLocalStorage as ar, updateUrl as as, areFilterModelsEquivalent as at, StatefulDataGrid as au, 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 };
|
|
3477
4221
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|