@redsift/table 11.8.1-muiv5 → 11.8.1
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/BasePopper.js +2 -2
- package/_internal/ControlledPagination.js +32 -24
- package/_internal/ControlledPagination.js.map +1 -1
- package/_internal/DataGrid2.js +64 -80
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/GridToolbarFilterSemanticField2.js +12 -12
- package/_internal/GridToolbarFilterSemanticField2.js.map +1 -1
- package/_internal/Portal.js +1 -1
- package/_internal/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +1932 -238
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/TextCell2.js +1 -1
- package/_internal/Toolbar2.js +3 -3
- package/_internal/Toolbar2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +11 -17
- package/_internal/ToolbarWrapper2.js.map +1 -1
- package/_internal/_rollupPluginBabelHelpers.js +1 -1
- package/_internal/useControlledDatagridState.js +24 -1859
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +82 -79
- package/index.js +48 -3
- package/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,15 +1,1791 @@
|
|
|
1
|
-
import { _ as _objectSpread2,
|
|
1
|
+
import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends$1 } from './_rollupPluginBabelHelpers.js';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import React__default, { useCallback, useEffect, useMemo, forwardRef, useRef, useState } from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
|
-
import { useTheme, ThemeProvider, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite } from '@redsift/design-system';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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, DataGridPro, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
|
|
7
|
+
import { L as LicenseInfo, u as useControlledDatagridState, T as ThemeProvider$1, S as StyledDataGrid } from './useControlledDatagridState.js';
|
|
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, f as formControlState, i as isAdornedStart, a as isFilled, F as FormControlContext, b as useId, c as Select, I as Input, d as FilledInput, O as OutlinedInput, o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination } from './ControlledPagination.js';
|
|
8
12
|
import { T as Toolbar } from './Toolbar2.js';
|
|
9
|
-
import { o as onServerSideSelectionStatusChange, S as ServerSideControlledPagination, C as ControlledPagination } from './ControlledPagination.js';
|
|
10
13
|
import { B as BaseButton, a as BaseCheckbox, c as BasePopper, b as BaseIcon } from './BasePopper.js';
|
|
11
14
|
import { T as ToolbarWrapper } from './ToolbarWrapper2.js';
|
|
12
15
|
|
|
16
|
+
function isMuiElement(element, muiNames) {
|
|
17
|
+
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const _excluded$7 = ["sx"];
|
|
21
|
+
const splitProps = props => {
|
|
22
|
+
var _props$theme$unstable, _props$theme;
|
|
23
|
+
const result = {
|
|
24
|
+
systemProps: {},
|
|
25
|
+
otherProps: {}
|
|
26
|
+
};
|
|
27
|
+
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;
|
|
28
|
+
Object.keys(props).forEach(prop => {
|
|
29
|
+
if (config[prop]) {
|
|
30
|
+
result.systemProps[prop] = props[prop];
|
|
31
|
+
} else {
|
|
32
|
+
result.otherProps[prop] = props[prop];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
function extendSxProp(props) {
|
|
38
|
+
const {
|
|
39
|
+
sx: inSx
|
|
40
|
+
} = props,
|
|
41
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
42
|
+
const {
|
|
43
|
+
systemProps,
|
|
44
|
+
otherProps
|
|
45
|
+
} = splitProps(other);
|
|
46
|
+
let finalSx;
|
|
47
|
+
if (Array.isArray(inSx)) {
|
|
48
|
+
finalSx = [systemProps, ...inSx];
|
|
49
|
+
} else if (typeof inSx === 'function') {
|
|
50
|
+
finalSx = (...args) => {
|
|
51
|
+
const result = inSx(...args);
|
|
52
|
+
if (!isPlainObject(result)) {
|
|
53
|
+
return systemProps;
|
|
54
|
+
}
|
|
55
|
+
return _extends({}, systemProps, result);
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
finalSx = _extends({}, systemProps, inSx);
|
|
59
|
+
}
|
|
60
|
+
return _extends({}, otherProps, {
|
|
61
|
+
sx: finalSx
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const _excluded$6 = ["className", "component"];
|
|
66
|
+
function createBox(options = {}) {
|
|
67
|
+
const {
|
|
68
|
+
themeId,
|
|
69
|
+
defaultTheme,
|
|
70
|
+
defaultClassName = 'MuiBox-root',
|
|
71
|
+
generateClassName
|
|
72
|
+
} = options;
|
|
73
|
+
const BoxRoot = styled('div', {
|
|
74
|
+
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
|
75
|
+
})(styleFunctionSx);
|
|
76
|
+
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
77
|
+
const theme = useTheme(defaultTheme);
|
|
78
|
+
const _extendSxProp = extendSxProp(inProps),
|
|
79
|
+
{
|
|
80
|
+
className,
|
|
81
|
+
component = 'div'
|
|
82
|
+
} = _extendSxProp,
|
|
83
|
+
other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded$6);
|
|
84
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BoxRoot, _extends({
|
|
85
|
+
as: component,
|
|
86
|
+
ref: ref,
|
|
87
|
+
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
88
|
+
theme: themeId ? theme[themeId] || theme : theme
|
|
89
|
+
}, other));
|
|
90
|
+
});
|
|
91
|
+
return Box;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const defaultTheme = createTheme();
|
|
95
|
+
const Box = createBox({
|
|
96
|
+
themeId: THEME_ID,
|
|
97
|
+
defaultTheme,
|
|
98
|
+
defaultClassName: 'MuiBox-root',
|
|
99
|
+
generateClassName: ClassNameGenerator.generate
|
|
100
|
+
});
|
|
101
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
|
102
|
+
// ----------------------------- Warning --------------------------------
|
|
103
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
105
|
+
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* @ignore
|
|
108
|
+
*/
|
|
109
|
+
children: PropTypes.node,
|
|
110
|
+
/**
|
|
111
|
+
* The component used for the root node.
|
|
112
|
+
* Either a string to use a HTML element or a component.
|
|
113
|
+
*/
|
|
114
|
+
component: PropTypes.elementType,
|
|
115
|
+
/**
|
|
116
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
117
|
+
*/
|
|
118
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
119
|
+
} : void 0;
|
|
120
|
+
var Box$1 = Box;
|
|
121
|
+
|
|
122
|
+
function getFormLabelUtilityClasses(slot) {
|
|
123
|
+
return generateUtilityClass('MuiFormLabel', slot);
|
|
124
|
+
}
|
|
125
|
+
const formLabelClasses = generateUtilityClasses('MuiFormLabel', ['root', 'colorSecondary', 'focused', 'disabled', 'error', 'filled', 'required', 'asterisk']);
|
|
126
|
+
var formLabelClasses$1 = formLabelClasses;
|
|
127
|
+
|
|
128
|
+
const _excluded$5 = ["children", "className", "color", "component", "disabled", "error", "filled", "focused", "required"];
|
|
129
|
+
const useUtilityClasses$4 = ownerState => {
|
|
130
|
+
const {
|
|
131
|
+
classes,
|
|
132
|
+
color,
|
|
133
|
+
focused,
|
|
134
|
+
disabled,
|
|
135
|
+
error,
|
|
136
|
+
filled,
|
|
137
|
+
required
|
|
138
|
+
} = ownerState;
|
|
139
|
+
const slots = {
|
|
140
|
+
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', filled && 'filled', focused && 'focused', required && 'required'],
|
|
141
|
+
asterisk: ['asterisk', error && 'error']
|
|
142
|
+
};
|
|
143
|
+
return composeClasses(slots, getFormLabelUtilityClasses, classes);
|
|
144
|
+
};
|
|
145
|
+
const FormLabelRoot = styled$1('label', {
|
|
146
|
+
name: 'MuiFormLabel',
|
|
147
|
+
slot: 'Root',
|
|
148
|
+
overridesResolver: ({
|
|
149
|
+
ownerState
|
|
150
|
+
}, styles) => {
|
|
151
|
+
return _extends({}, styles.root, ownerState.color === 'secondary' && styles.colorSecondary, ownerState.filled && styles.filled);
|
|
152
|
+
}
|
|
153
|
+
})(({
|
|
154
|
+
theme,
|
|
155
|
+
ownerState
|
|
156
|
+
}) => _extends({
|
|
157
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
158
|
+
}, theme.typography.body1, {
|
|
159
|
+
lineHeight: '1.4375em',
|
|
160
|
+
padding: 0,
|
|
161
|
+
position: 'relative',
|
|
162
|
+
[`&.${formLabelClasses$1.focused}`]: {
|
|
163
|
+
color: (theme.vars || theme).palette[ownerState.color].main
|
|
164
|
+
},
|
|
165
|
+
[`&.${formLabelClasses$1.disabled}`]: {
|
|
166
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
167
|
+
},
|
|
168
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
169
|
+
color: (theme.vars || theme).palette.error.main
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
172
|
+
const AsteriskComponent = styled$1('span', {
|
|
173
|
+
name: 'MuiFormLabel',
|
|
174
|
+
slot: 'Asterisk',
|
|
175
|
+
overridesResolver: (props, styles) => styles.asterisk
|
|
176
|
+
})(({
|
|
177
|
+
theme
|
|
178
|
+
}) => ({
|
|
179
|
+
[`&.${formLabelClasses$1.error}`]: {
|
|
180
|
+
color: (theme.vars || theme).palette.error.main
|
|
181
|
+
}
|
|
182
|
+
}));
|
|
183
|
+
const FormLabel = /*#__PURE__*/React.forwardRef(function FormLabel(inProps, ref) {
|
|
184
|
+
const props = useThemeProps({
|
|
185
|
+
props: inProps,
|
|
186
|
+
name: 'MuiFormLabel'
|
|
187
|
+
});
|
|
188
|
+
const {
|
|
189
|
+
children,
|
|
190
|
+
className,
|
|
191
|
+
component = 'label'
|
|
192
|
+
} = props,
|
|
193
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
194
|
+
const muiFormControl = useFormControl();
|
|
195
|
+
const fcs = formControlState({
|
|
196
|
+
props,
|
|
197
|
+
muiFormControl,
|
|
198
|
+
states: ['color', 'required', 'focused', 'disabled', 'error', 'filled']
|
|
199
|
+
});
|
|
200
|
+
const ownerState = _extends({}, props, {
|
|
201
|
+
color: fcs.color || 'primary',
|
|
202
|
+
component,
|
|
203
|
+
disabled: fcs.disabled,
|
|
204
|
+
error: fcs.error,
|
|
205
|
+
filled: fcs.filled,
|
|
206
|
+
focused: fcs.focused,
|
|
207
|
+
required: fcs.required
|
|
208
|
+
});
|
|
209
|
+
const classes = useUtilityClasses$4(ownerState);
|
|
210
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(FormLabelRoot, _extends({
|
|
211
|
+
as: component,
|
|
212
|
+
ownerState: ownerState,
|
|
213
|
+
className: clsx(classes.root, className),
|
|
214
|
+
ref: ref
|
|
215
|
+
}, other, {
|
|
216
|
+
children: [children, fcs.required && /*#__PURE__*/jsxRuntimeExports.jsxs(AsteriskComponent, {
|
|
217
|
+
ownerState: ownerState,
|
|
218
|
+
"aria-hidden": true,
|
|
219
|
+
className: classes.asterisk,
|
|
220
|
+
children: ["\u2009", '*']
|
|
221
|
+
})]
|
|
222
|
+
}));
|
|
223
|
+
});
|
|
224
|
+
process.env.NODE_ENV !== "production" ? FormLabel.propTypes /* remove-proptypes */ = {
|
|
225
|
+
// ----------------------------- Warning --------------------------------
|
|
226
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
227
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
228
|
+
// ----------------------------------------------------------------------
|
|
229
|
+
/**
|
|
230
|
+
* The content of the component.
|
|
231
|
+
*/
|
|
232
|
+
children: PropTypes.node,
|
|
233
|
+
/**
|
|
234
|
+
* Override or extend the styles applied to the component.
|
|
235
|
+
*/
|
|
236
|
+
classes: PropTypes.object,
|
|
237
|
+
/**
|
|
238
|
+
* @ignore
|
|
239
|
+
*/
|
|
240
|
+
className: PropTypes.string,
|
|
241
|
+
/**
|
|
242
|
+
* The color of the component.
|
|
243
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
244
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
245
|
+
*/
|
|
246
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
247
|
+
/**
|
|
248
|
+
* The component used for the root node.
|
|
249
|
+
* Either a string to use a HTML element or a component.
|
|
250
|
+
*/
|
|
251
|
+
component: PropTypes.elementType,
|
|
252
|
+
/**
|
|
253
|
+
* If `true`, the label should be displayed in a disabled state.
|
|
254
|
+
*/
|
|
255
|
+
disabled: PropTypes.bool,
|
|
256
|
+
/**
|
|
257
|
+
* If `true`, the label is displayed in an error state.
|
|
258
|
+
*/
|
|
259
|
+
error: PropTypes.bool,
|
|
260
|
+
/**
|
|
261
|
+
* If `true`, the label should use filled classes key.
|
|
262
|
+
*/
|
|
263
|
+
filled: PropTypes.bool,
|
|
264
|
+
/**
|
|
265
|
+
* If `true`, the input of this label is focused (used by `FormGroup` components).
|
|
266
|
+
*/
|
|
267
|
+
focused: PropTypes.bool,
|
|
268
|
+
/**
|
|
269
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
270
|
+
*/
|
|
271
|
+
required: PropTypes.bool,
|
|
272
|
+
/**
|
|
273
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
274
|
+
*/
|
|
275
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
276
|
+
} : void 0;
|
|
277
|
+
var FormLabel$1 = FormLabel;
|
|
278
|
+
|
|
279
|
+
function getInputLabelUtilityClasses(slot) {
|
|
280
|
+
return generateUtilityClass('MuiInputLabel', slot);
|
|
281
|
+
}
|
|
282
|
+
generateUtilityClasses('MuiInputLabel', ['root', 'focused', 'disabled', 'error', 'required', 'asterisk', 'formControl', 'sizeSmall', 'shrink', 'animated', 'standard', 'filled', 'outlined']);
|
|
283
|
+
|
|
284
|
+
const _excluded$4 = ["disableAnimation", "margin", "shrink", "variant", "className"];
|
|
285
|
+
const useUtilityClasses$3 = ownerState => {
|
|
286
|
+
const {
|
|
287
|
+
classes,
|
|
288
|
+
formControl,
|
|
289
|
+
size,
|
|
290
|
+
shrink,
|
|
291
|
+
disableAnimation,
|
|
292
|
+
variant,
|
|
293
|
+
required
|
|
294
|
+
} = ownerState;
|
|
295
|
+
const slots = {
|
|
296
|
+
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size === 'small' && 'sizeSmall', variant],
|
|
297
|
+
asterisk: [required && 'asterisk']
|
|
298
|
+
};
|
|
299
|
+
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
|
300
|
+
return _extends({}, classes, composedClasses);
|
|
301
|
+
};
|
|
302
|
+
const InputLabelRoot = styled$1(FormLabel$1, {
|
|
303
|
+
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
|
304
|
+
name: 'MuiInputLabel',
|
|
305
|
+
slot: 'Root',
|
|
306
|
+
overridesResolver: (props, styles) => {
|
|
307
|
+
const {
|
|
308
|
+
ownerState
|
|
309
|
+
} = props;
|
|
310
|
+
return [{
|
|
311
|
+
[`& .${formLabelClasses$1.asterisk}`]: styles.asterisk
|
|
312
|
+
}, styles.root, ownerState.formControl && styles.formControl, ownerState.size === 'small' && styles.sizeSmall, ownerState.shrink && styles.shrink, !ownerState.disableAnimation && styles.animated, styles[ownerState.variant]];
|
|
313
|
+
}
|
|
314
|
+
})(({
|
|
315
|
+
theme,
|
|
316
|
+
ownerState
|
|
317
|
+
}) => _extends({
|
|
318
|
+
display: 'block',
|
|
319
|
+
transformOrigin: 'top left',
|
|
320
|
+
whiteSpace: 'nowrap',
|
|
321
|
+
overflow: 'hidden',
|
|
322
|
+
textOverflow: 'ellipsis',
|
|
323
|
+
maxWidth: '100%'
|
|
324
|
+
}, ownerState.formControl && {
|
|
325
|
+
position: 'absolute',
|
|
326
|
+
left: 0,
|
|
327
|
+
top: 0,
|
|
328
|
+
// slight alteration to spec spacing to match visual spec result
|
|
329
|
+
transform: 'translate(0, 20px) scale(1)'
|
|
330
|
+
}, ownerState.size === 'small' && {
|
|
331
|
+
// Compensation for the `Input.inputSizeSmall` style.
|
|
332
|
+
transform: 'translate(0, 17px) scale(1)'
|
|
333
|
+
}, ownerState.shrink && {
|
|
334
|
+
transform: 'translate(0, -1.5px) scale(0.75)',
|
|
335
|
+
transformOrigin: 'top left',
|
|
336
|
+
maxWidth: '133%'
|
|
337
|
+
}, !ownerState.disableAnimation && {
|
|
338
|
+
transition: theme.transitions.create(['color', 'transform', 'max-width'], {
|
|
339
|
+
duration: theme.transitions.duration.shorter,
|
|
340
|
+
easing: theme.transitions.easing.easeOut
|
|
341
|
+
})
|
|
342
|
+
}, ownerState.variant === 'filled' && _extends({
|
|
343
|
+
// Chrome's autofill feature gives the input field a yellow background.
|
|
344
|
+
// Since the input field is behind the label in the HTML tree,
|
|
345
|
+
// the input field is drawn last and hides the label with an opaque background color.
|
|
346
|
+
// zIndex: 1 will raise the label above opaque background-colors of input.
|
|
347
|
+
zIndex: 1,
|
|
348
|
+
pointerEvents: 'none',
|
|
349
|
+
transform: 'translate(12px, 16px) scale(1)',
|
|
350
|
+
maxWidth: 'calc(100% - 24px)'
|
|
351
|
+
}, ownerState.size === 'small' && {
|
|
352
|
+
transform: 'translate(12px, 13px) scale(1)'
|
|
353
|
+
}, ownerState.shrink && _extends({
|
|
354
|
+
userSelect: 'none',
|
|
355
|
+
pointerEvents: 'auto',
|
|
356
|
+
transform: 'translate(12px, 7px) scale(0.75)',
|
|
357
|
+
maxWidth: 'calc(133% - 24px)'
|
|
358
|
+
}, ownerState.size === 'small' && {
|
|
359
|
+
transform: 'translate(12px, 4px) scale(0.75)'
|
|
360
|
+
})), ownerState.variant === 'outlined' && _extends({
|
|
361
|
+
// see comment above on filled.zIndex
|
|
362
|
+
zIndex: 1,
|
|
363
|
+
pointerEvents: 'none',
|
|
364
|
+
transform: 'translate(14px, 16px) scale(1)',
|
|
365
|
+
maxWidth: 'calc(100% - 24px)'
|
|
366
|
+
}, ownerState.size === 'small' && {
|
|
367
|
+
transform: 'translate(14px, 9px) scale(1)'
|
|
368
|
+
}, ownerState.shrink && {
|
|
369
|
+
userSelect: 'none',
|
|
370
|
+
pointerEvents: 'auto',
|
|
371
|
+
// Theoretically, we should have (8+5)*2/0.75 = 34px
|
|
372
|
+
// but it feels a better when it bleeds a bit on the left, so 32px.
|
|
373
|
+
maxWidth: 'calc(133% - 32px)',
|
|
374
|
+
transform: 'translate(14px, -9px) scale(0.75)'
|
|
375
|
+
})));
|
|
376
|
+
const InputLabel = /*#__PURE__*/React.forwardRef(function InputLabel(inProps, ref) {
|
|
377
|
+
const props = useThemeProps({
|
|
378
|
+
name: 'MuiInputLabel',
|
|
379
|
+
props: inProps
|
|
380
|
+
});
|
|
381
|
+
const {
|
|
382
|
+
disableAnimation = false,
|
|
383
|
+
shrink: shrinkProp,
|
|
384
|
+
className
|
|
385
|
+
} = props,
|
|
386
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
387
|
+
const muiFormControl = useFormControl();
|
|
388
|
+
let shrink = shrinkProp;
|
|
389
|
+
if (typeof shrink === 'undefined' && muiFormControl) {
|
|
390
|
+
shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
|
391
|
+
}
|
|
392
|
+
const fcs = formControlState({
|
|
393
|
+
props,
|
|
394
|
+
muiFormControl,
|
|
395
|
+
states: ['size', 'variant', 'required']
|
|
396
|
+
});
|
|
397
|
+
const ownerState = _extends({}, props, {
|
|
398
|
+
disableAnimation,
|
|
399
|
+
formControl: muiFormControl,
|
|
400
|
+
shrink,
|
|
401
|
+
size: fcs.size,
|
|
402
|
+
variant: fcs.variant,
|
|
403
|
+
required: fcs.required
|
|
404
|
+
});
|
|
405
|
+
const classes = useUtilityClasses$3(ownerState);
|
|
406
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(InputLabelRoot, _extends({
|
|
407
|
+
"data-shrink": shrink,
|
|
408
|
+
ownerState: ownerState,
|
|
409
|
+
ref: ref,
|
|
410
|
+
className: clsx(classes.root, className)
|
|
411
|
+
}, other, {
|
|
412
|
+
classes: classes
|
|
413
|
+
}));
|
|
414
|
+
});
|
|
415
|
+
process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes */ = {
|
|
416
|
+
// ----------------------------- Warning --------------------------------
|
|
417
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
418
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
419
|
+
// ----------------------------------------------------------------------
|
|
420
|
+
/**
|
|
421
|
+
* The content of the component.
|
|
422
|
+
*/
|
|
423
|
+
children: PropTypes.node,
|
|
424
|
+
/**
|
|
425
|
+
* Override or extend the styles applied to the component.
|
|
426
|
+
*/
|
|
427
|
+
classes: PropTypes.object,
|
|
428
|
+
/**
|
|
429
|
+
* @ignore
|
|
430
|
+
*/
|
|
431
|
+
className: PropTypes.string,
|
|
432
|
+
/**
|
|
433
|
+
* The color of the component.
|
|
434
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
435
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
436
|
+
*/
|
|
437
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
|
438
|
+
/**
|
|
439
|
+
* If `true`, the transition animation is disabled.
|
|
440
|
+
* @default false
|
|
441
|
+
*/
|
|
442
|
+
disableAnimation: PropTypes.bool,
|
|
443
|
+
/**
|
|
444
|
+
* If `true`, the component is disabled.
|
|
445
|
+
*/
|
|
446
|
+
disabled: PropTypes.bool,
|
|
447
|
+
/**
|
|
448
|
+
* If `true`, the label is displayed in an error state.
|
|
449
|
+
*/
|
|
450
|
+
error: PropTypes.bool,
|
|
451
|
+
/**
|
|
452
|
+
* If `true`, the `input` of this label is focused.
|
|
453
|
+
*/
|
|
454
|
+
focused: PropTypes.bool,
|
|
455
|
+
/**
|
|
456
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
457
|
+
* FormControl.
|
|
458
|
+
*/
|
|
459
|
+
margin: PropTypes.oneOf(['dense']),
|
|
460
|
+
/**
|
|
461
|
+
* if `true`, the label will indicate that the `input` is required.
|
|
462
|
+
*/
|
|
463
|
+
required: PropTypes.bool,
|
|
464
|
+
/**
|
|
465
|
+
* If `true`, the label is shrunk.
|
|
466
|
+
*/
|
|
467
|
+
shrink: PropTypes.bool,
|
|
468
|
+
/**
|
|
469
|
+
* The size of the component.
|
|
470
|
+
* @default 'normal'
|
|
471
|
+
*/
|
|
472
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['normal', 'small']), PropTypes.string]),
|
|
473
|
+
/**
|
|
474
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
475
|
+
*/
|
|
476
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
477
|
+
/**
|
|
478
|
+
* The variant to use.
|
|
479
|
+
*/
|
|
480
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
481
|
+
} : void 0;
|
|
482
|
+
var InputLabel$1 = InputLabel;
|
|
483
|
+
|
|
484
|
+
function getFormControlUtilityClasses(slot) {
|
|
485
|
+
return generateUtilityClass('MuiFormControl', slot);
|
|
486
|
+
}
|
|
487
|
+
generateUtilityClasses('MuiFormControl', ['root', 'marginNone', 'marginNormal', 'marginDense', 'fullWidth', 'disabled']);
|
|
488
|
+
|
|
489
|
+
const _excluded$3 = ["children", "className", "color", "component", "disabled", "error", "focused", "fullWidth", "hiddenLabel", "margin", "required", "size", "variant"];
|
|
490
|
+
const useUtilityClasses$2 = ownerState => {
|
|
491
|
+
const {
|
|
492
|
+
classes,
|
|
493
|
+
margin,
|
|
494
|
+
fullWidth
|
|
495
|
+
} = ownerState;
|
|
496
|
+
const slots = {
|
|
497
|
+
root: ['root', margin !== 'none' && `margin${capitalize(margin)}`, fullWidth && 'fullWidth']
|
|
498
|
+
};
|
|
499
|
+
return composeClasses(slots, getFormControlUtilityClasses, classes);
|
|
500
|
+
};
|
|
501
|
+
const FormControlRoot = styled$1('div', {
|
|
502
|
+
name: 'MuiFormControl',
|
|
503
|
+
slot: 'Root',
|
|
504
|
+
overridesResolver: ({
|
|
505
|
+
ownerState
|
|
506
|
+
}, styles) => {
|
|
507
|
+
return _extends({}, styles.root, styles[`margin${capitalize(ownerState.margin)}`], ownerState.fullWidth && styles.fullWidth);
|
|
508
|
+
}
|
|
509
|
+
})(({
|
|
510
|
+
ownerState
|
|
511
|
+
}) => _extends({
|
|
512
|
+
display: 'inline-flex',
|
|
513
|
+
flexDirection: 'column',
|
|
514
|
+
position: 'relative',
|
|
515
|
+
// Reset fieldset default style.
|
|
516
|
+
minWidth: 0,
|
|
517
|
+
padding: 0,
|
|
518
|
+
margin: 0,
|
|
519
|
+
border: 0,
|
|
520
|
+
verticalAlign: 'top'
|
|
521
|
+
}, ownerState.margin === 'normal' && {
|
|
522
|
+
marginTop: 16,
|
|
523
|
+
marginBottom: 8
|
|
524
|
+
}, ownerState.margin === 'dense' && {
|
|
525
|
+
marginTop: 8,
|
|
526
|
+
marginBottom: 4
|
|
527
|
+
}, ownerState.fullWidth && {
|
|
528
|
+
width: '100%'
|
|
529
|
+
}));
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Provides context such as filled/focused/error/required for form inputs.
|
|
533
|
+
* Relying on the context provides high flexibility and ensures that the state always stays
|
|
534
|
+
* consistent across the children of the `FormControl`.
|
|
535
|
+
* This context is used by the following components:
|
|
536
|
+
*
|
|
537
|
+
* - FormLabel
|
|
538
|
+
* - FormHelperText
|
|
539
|
+
* - Input
|
|
540
|
+
* - InputLabel
|
|
541
|
+
*
|
|
542
|
+
* You can find one composition example below and more going to [the demos](/material-ui/react-text-field/#components).
|
|
543
|
+
*
|
|
544
|
+
* ```jsx
|
|
545
|
+
* <FormControl>
|
|
546
|
+
* <InputLabel htmlFor="my-input">Email address</InputLabel>
|
|
547
|
+
* <Input id="my-input" aria-describedby="my-helper-text" />
|
|
548
|
+
* <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
|
549
|
+
* </FormControl>
|
|
550
|
+
* ```
|
|
551
|
+
*
|
|
552
|
+
* ⚠️ Only one `InputBase` can be used within a FormControl because it creates visual inconsistencies.
|
|
553
|
+
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
|
554
|
+
*/
|
|
555
|
+
const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps, ref) {
|
|
556
|
+
const props = useThemeProps({
|
|
557
|
+
props: inProps,
|
|
558
|
+
name: 'MuiFormControl'
|
|
559
|
+
});
|
|
560
|
+
const {
|
|
561
|
+
children,
|
|
562
|
+
className,
|
|
563
|
+
color = 'primary',
|
|
564
|
+
component = 'div',
|
|
565
|
+
disabled = false,
|
|
566
|
+
error = false,
|
|
567
|
+
focused: visuallyFocused,
|
|
568
|
+
fullWidth = false,
|
|
569
|
+
hiddenLabel = false,
|
|
570
|
+
margin = 'none',
|
|
571
|
+
required = false,
|
|
572
|
+
size = 'medium',
|
|
573
|
+
variant = 'outlined'
|
|
574
|
+
} = props,
|
|
575
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
576
|
+
const ownerState = _extends({}, props, {
|
|
577
|
+
color,
|
|
578
|
+
component,
|
|
579
|
+
disabled,
|
|
580
|
+
error,
|
|
581
|
+
fullWidth,
|
|
582
|
+
hiddenLabel,
|
|
583
|
+
margin,
|
|
584
|
+
required,
|
|
585
|
+
size,
|
|
586
|
+
variant
|
|
587
|
+
});
|
|
588
|
+
const classes = useUtilityClasses$2(ownerState);
|
|
589
|
+
const [adornedStart, setAdornedStart] = React.useState(() => {
|
|
590
|
+
// We need to iterate through the children and find the Input in order
|
|
591
|
+
// to fully support server-side rendering.
|
|
592
|
+
let initialAdornedStart = false;
|
|
593
|
+
if (children) {
|
|
594
|
+
React.Children.forEach(children, child => {
|
|
595
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
const input = isMuiElement(child, ['Select']) ? child.props.input : child;
|
|
599
|
+
if (input && isAdornedStart(input.props)) {
|
|
600
|
+
initialAdornedStart = true;
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
return initialAdornedStart;
|
|
605
|
+
});
|
|
606
|
+
const [filled, setFilled] = React.useState(() => {
|
|
607
|
+
// We need to iterate through the children and find the Input in order
|
|
608
|
+
// to fully support server-side rendering.
|
|
609
|
+
let initialFilled = false;
|
|
610
|
+
if (children) {
|
|
611
|
+
React.Children.forEach(children, child => {
|
|
612
|
+
if (!isMuiElement(child, ['Input', 'Select'])) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
|
|
616
|
+
initialFilled = true;
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return initialFilled;
|
|
621
|
+
});
|
|
622
|
+
const [focusedState, setFocused] = React.useState(false);
|
|
623
|
+
if (disabled && focusedState) {
|
|
624
|
+
setFocused(false);
|
|
625
|
+
}
|
|
626
|
+
const focused = visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState;
|
|
627
|
+
let registerEffect;
|
|
628
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
629
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
630
|
+
const registeredInput = React.useRef(false);
|
|
631
|
+
registerEffect = () => {
|
|
632
|
+
if (registeredInput.current) {
|
|
633
|
+
console.error(['MUI: There are multiple `InputBase` components inside a FormControl.', 'This creates visual inconsistencies, only use one `InputBase`.'].join('\n'));
|
|
634
|
+
}
|
|
635
|
+
registeredInput.current = true;
|
|
636
|
+
return () => {
|
|
637
|
+
registeredInput.current = false;
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
const childContext = React.useMemo(() => {
|
|
642
|
+
return {
|
|
643
|
+
adornedStart,
|
|
644
|
+
setAdornedStart,
|
|
645
|
+
color,
|
|
646
|
+
disabled,
|
|
647
|
+
error,
|
|
648
|
+
filled,
|
|
649
|
+
focused,
|
|
650
|
+
fullWidth,
|
|
651
|
+
hiddenLabel,
|
|
652
|
+
size,
|
|
653
|
+
onBlur: () => {
|
|
654
|
+
setFocused(false);
|
|
655
|
+
},
|
|
656
|
+
onEmpty: () => {
|
|
657
|
+
setFilled(false);
|
|
658
|
+
},
|
|
659
|
+
onFilled: () => {
|
|
660
|
+
setFilled(true);
|
|
661
|
+
},
|
|
662
|
+
onFocus: () => {
|
|
663
|
+
setFocused(true);
|
|
664
|
+
},
|
|
665
|
+
registerEffect,
|
|
666
|
+
required,
|
|
667
|
+
variant
|
|
668
|
+
};
|
|
669
|
+
}, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, required, size, variant]);
|
|
670
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormControlContext.Provider, {
|
|
671
|
+
value: childContext,
|
|
672
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(FormControlRoot, _extends({
|
|
673
|
+
as: component,
|
|
674
|
+
ownerState: ownerState,
|
|
675
|
+
className: clsx(classes.root, className),
|
|
676
|
+
ref: ref
|
|
677
|
+
}, other, {
|
|
678
|
+
children: children
|
|
679
|
+
}))
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
process.env.NODE_ENV !== "production" ? FormControl.propTypes /* remove-proptypes */ = {
|
|
683
|
+
// ----------------------------- Warning --------------------------------
|
|
684
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
685
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
686
|
+
// ----------------------------------------------------------------------
|
|
687
|
+
/**
|
|
688
|
+
* The content of the component.
|
|
689
|
+
*/
|
|
690
|
+
children: PropTypes.node,
|
|
691
|
+
/**
|
|
692
|
+
* Override or extend the styles applied to the component.
|
|
693
|
+
*/
|
|
694
|
+
classes: PropTypes.object,
|
|
695
|
+
/**
|
|
696
|
+
* @ignore
|
|
697
|
+
*/
|
|
698
|
+
className: PropTypes.string,
|
|
699
|
+
/**
|
|
700
|
+
* The color of the component.
|
|
701
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
702
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
703
|
+
* @default 'primary'
|
|
704
|
+
*/
|
|
705
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
706
|
+
/**
|
|
707
|
+
* The component used for the root node.
|
|
708
|
+
* Either a string to use a HTML element or a component.
|
|
709
|
+
*/
|
|
710
|
+
component: PropTypes.elementType,
|
|
711
|
+
/**
|
|
712
|
+
* If `true`, the label, input and helper text should be displayed in a disabled state.
|
|
713
|
+
* @default false
|
|
714
|
+
*/
|
|
715
|
+
disabled: PropTypes.bool,
|
|
716
|
+
/**
|
|
717
|
+
* If `true`, the label is displayed in an error state.
|
|
718
|
+
* @default false
|
|
719
|
+
*/
|
|
720
|
+
error: PropTypes.bool,
|
|
721
|
+
/**
|
|
722
|
+
* If `true`, the component is displayed in focused state.
|
|
723
|
+
*/
|
|
724
|
+
focused: PropTypes.bool,
|
|
725
|
+
/**
|
|
726
|
+
* If `true`, the component will take up the full width of its container.
|
|
727
|
+
* @default false
|
|
728
|
+
*/
|
|
729
|
+
fullWidth: PropTypes.bool,
|
|
730
|
+
/**
|
|
731
|
+
* If `true`, the label is hidden.
|
|
732
|
+
* This is used to increase density for a `FilledInput`.
|
|
733
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
734
|
+
* @default false
|
|
735
|
+
*/
|
|
736
|
+
hiddenLabel: PropTypes.bool,
|
|
737
|
+
/**
|
|
738
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
739
|
+
* @default 'none'
|
|
740
|
+
*/
|
|
741
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
742
|
+
/**
|
|
743
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
744
|
+
* @default false
|
|
745
|
+
*/
|
|
746
|
+
required: PropTypes.bool,
|
|
747
|
+
/**
|
|
748
|
+
* The size of the component.
|
|
749
|
+
* @default 'medium'
|
|
750
|
+
*/
|
|
751
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
752
|
+
/**
|
|
753
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
754
|
+
*/
|
|
755
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
756
|
+
/**
|
|
757
|
+
* The variant to use.
|
|
758
|
+
* @default 'outlined'
|
|
759
|
+
*/
|
|
760
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
761
|
+
} : void 0;
|
|
762
|
+
var FormControl$1 = FormControl;
|
|
763
|
+
|
|
764
|
+
function getFormHelperTextUtilityClasses(slot) {
|
|
765
|
+
return generateUtilityClass('MuiFormHelperText', slot);
|
|
766
|
+
}
|
|
767
|
+
const formHelperTextClasses = generateUtilityClasses('MuiFormHelperText', ['root', 'error', 'disabled', 'sizeSmall', 'sizeMedium', 'contained', 'focused', 'filled', 'required']);
|
|
768
|
+
var formHelperTextClasses$1 = formHelperTextClasses;
|
|
769
|
+
|
|
770
|
+
var _span;
|
|
771
|
+
const _excluded$2 = ["children", "className", "component", "disabled", "error", "filled", "focused", "margin", "required", "variant"];
|
|
772
|
+
const useUtilityClasses$1 = ownerState => {
|
|
773
|
+
const {
|
|
774
|
+
classes,
|
|
775
|
+
contained,
|
|
776
|
+
size,
|
|
777
|
+
disabled,
|
|
778
|
+
error,
|
|
779
|
+
filled,
|
|
780
|
+
focused,
|
|
781
|
+
required
|
|
782
|
+
} = ownerState;
|
|
783
|
+
const slots = {
|
|
784
|
+
root: ['root', disabled && 'disabled', error && 'error', size && `size${capitalize(size)}`, contained && 'contained', focused && 'focused', filled && 'filled', required && 'required']
|
|
785
|
+
};
|
|
786
|
+
return composeClasses(slots, getFormHelperTextUtilityClasses, classes);
|
|
787
|
+
};
|
|
788
|
+
const FormHelperTextRoot = styled$1('p', {
|
|
789
|
+
name: 'MuiFormHelperText',
|
|
790
|
+
slot: 'Root',
|
|
791
|
+
overridesResolver: (props, styles) => {
|
|
792
|
+
const {
|
|
793
|
+
ownerState
|
|
794
|
+
} = props;
|
|
795
|
+
return [styles.root, ownerState.size && styles[`size${capitalize(ownerState.size)}`], ownerState.contained && styles.contained, ownerState.filled && styles.filled];
|
|
796
|
+
}
|
|
797
|
+
})(({
|
|
798
|
+
theme,
|
|
799
|
+
ownerState
|
|
800
|
+
}) => _extends({
|
|
801
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
802
|
+
}, theme.typography.caption, {
|
|
803
|
+
textAlign: 'left',
|
|
804
|
+
marginTop: 3,
|
|
805
|
+
marginRight: 0,
|
|
806
|
+
marginBottom: 0,
|
|
807
|
+
marginLeft: 0,
|
|
808
|
+
[`&.${formHelperTextClasses$1.disabled}`]: {
|
|
809
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
810
|
+
},
|
|
811
|
+
[`&.${formHelperTextClasses$1.error}`]: {
|
|
812
|
+
color: (theme.vars || theme).palette.error.main
|
|
813
|
+
}
|
|
814
|
+
}, ownerState.size === 'small' && {
|
|
815
|
+
marginTop: 4
|
|
816
|
+
}, ownerState.contained && {
|
|
817
|
+
marginLeft: 14,
|
|
818
|
+
marginRight: 14
|
|
819
|
+
}));
|
|
820
|
+
const FormHelperText = /*#__PURE__*/React.forwardRef(function FormHelperText(inProps, ref) {
|
|
821
|
+
const props = useThemeProps({
|
|
822
|
+
props: inProps,
|
|
823
|
+
name: 'MuiFormHelperText'
|
|
824
|
+
});
|
|
825
|
+
const {
|
|
826
|
+
children,
|
|
827
|
+
className,
|
|
828
|
+
component = 'p'
|
|
829
|
+
} = props,
|
|
830
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
831
|
+
const muiFormControl = useFormControl();
|
|
832
|
+
const fcs = formControlState({
|
|
833
|
+
props,
|
|
834
|
+
muiFormControl,
|
|
835
|
+
states: ['variant', 'size', 'disabled', 'error', 'filled', 'focused', 'required']
|
|
836
|
+
});
|
|
837
|
+
const ownerState = _extends({}, props, {
|
|
838
|
+
component,
|
|
839
|
+
contained: fcs.variant === 'filled' || fcs.variant === 'outlined',
|
|
840
|
+
variant: fcs.variant,
|
|
841
|
+
size: fcs.size,
|
|
842
|
+
disabled: fcs.disabled,
|
|
843
|
+
error: fcs.error,
|
|
844
|
+
filled: fcs.filled,
|
|
845
|
+
focused: fcs.focused,
|
|
846
|
+
required: fcs.required
|
|
847
|
+
});
|
|
848
|
+
const classes = useUtilityClasses$1(ownerState);
|
|
849
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperTextRoot, _extends({
|
|
850
|
+
as: component,
|
|
851
|
+
ownerState: ownerState,
|
|
852
|
+
className: clsx(classes.root, className),
|
|
853
|
+
ref: ref
|
|
854
|
+
}, other, {
|
|
855
|
+
children: children === ' ' ? // notranslate needed while Google Translate will not fix zero-width space issue
|
|
856
|
+
_span || (_span = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
857
|
+
className: "notranslate",
|
|
858
|
+
children: "\u200B"
|
|
859
|
+
})) : children
|
|
860
|
+
}));
|
|
861
|
+
});
|
|
862
|
+
process.env.NODE_ENV !== "production" ? FormHelperText.propTypes /* remove-proptypes */ = {
|
|
863
|
+
// ----------------------------- Warning --------------------------------
|
|
864
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
865
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
866
|
+
// ----------------------------------------------------------------------
|
|
867
|
+
/**
|
|
868
|
+
* The content of the component.
|
|
869
|
+
*
|
|
870
|
+
* If `' '` is provided, the component reserves one line height for displaying a future message.
|
|
871
|
+
*/
|
|
872
|
+
children: PropTypes.node,
|
|
873
|
+
/**
|
|
874
|
+
* Override or extend the styles applied to the component.
|
|
875
|
+
*/
|
|
876
|
+
classes: PropTypes.object,
|
|
877
|
+
/**
|
|
878
|
+
* @ignore
|
|
879
|
+
*/
|
|
880
|
+
className: PropTypes.string,
|
|
881
|
+
/**
|
|
882
|
+
* The component used for the root node.
|
|
883
|
+
* Either a string to use a HTML element or a component.
|
|
884
|
+
*/
|
|
885
|
+
component: PropTypes.elementType,
|
|
886
|
+
/**
|
|
887
|
+
* If `true`, the helper text should be displayed in a disabled state.
|
|
888
|
+
*/
|
|
889
|
+
disabled: PropTypes.bool,
|
|
890
|
+
/**
|
|
891
|
+
* If `true`, helper text should be displayed in an error state.
|
|
892
|
+
*/
|
|
893
|
+
error: PropTypes.bool,
|
|
894
|
+
/**
|
|
895
|
+
* If `true`, the helper text should use filled classes key.
|
|
896
|
+
*/
|
|
897
|
+
filled: PropTypes.bool,
|
|
898
|
+
/**
|
|
899
|
+
* If `true`, the helper text should use focused classes key.
|
|
900
|
+
*/
|
|
901
|
+
focused: PropTypes.bool,
|
|
902
|
+
/**
|
|
903
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
904
|
+
* FormControl.
|
|
905
|
+
*/
|
|
906
|
+
margin: PropTypes.oneOf(['dense']),
|
|
907
|
+
/**
|
|
908
|
+
* If `true`, the helper text should use required classes key.
|
|
909
|
+
*/
|
|
910
|
+
required: PropTypes.bool,
|
|
911
|
+
/**
|
|
912
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
913
|
+
*/
|
|
914
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
915
|
+
/**
|
|
916
|
+
* The variant to use.
|
|
917
|
+
*/
|
|
918
|
+
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
|
919
|
+
} : void 0;
|
|
920
|
+
var FormHelperText$1 = FormHelperText;
|
|
921
|
+
|
|
922
|
+
function getTextFieldUtilityClass(slot) {
|
|
923
|
+
return generateUtilityClass('MuiTextField', slot);
|
|
924
|
+
}
|
|
925
|
+
generateUtilityClasses('MuiTextField', ['root']);
|
|
926
|
+
|
|
927
|
+
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"];
|
|
928
|
+
const variantComponent = {
|
|
929
|
+
standard: Input,
|
|
930
|
+
filled: FilledInput,
|
|
931
|
+
outlined: OutlinedInput
|
|
932
|
+
};
|
|
933
|
+
const useUtilityClasses = ownerState => {
|
|
934
|
+
const {
|
|
935
|
+
classes
|
|
936
|
+
} = ownerState;
|
|
937
|
+
const slots = {
|
|
938
|
+
root: ['root']
|
|
939
|
+
};
|
|
940
|
+
return composeClasses(slots, getTextFieldUtilityClass, classes);
|
|
941
|
+
};
|
|
942
|
+
const TextFieldRoot = styled$1(FormControl$1, {
|
|
943
|
+
name: 'MuiTextField',
|
|
944
|
+
slot: 'Root',
|
|
945
|
+
overridesResolver: (props, styles) => styles.root
|
|
946
|
+
})({});
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* The `TextField` is a convenience wrapper for the most common cases (80%).
|
|
950
|
+
* It cannot be all things to all people, otherwise the API would grow out of control.
|
|
951
|
+
*
|
|
952
|
+
* ## Advanced Configuration
|
|
953
|
+
*
|
|
954
|
+
* It's important to understand that the text field is a simple abstraction
|
|
955
|
+
* on top of the following components:
|
|
956
|
+
*
|
|
957
|
+
* - [FormControl](/material-ui/api/form-control/)
|
|
958
|
+
* - [InputLabel](/material-ui/api/input-label/)
|
|
959
|
+
* - [FilledInput](/material-ui/api/filled-input/)
|
|
960
|
+
* - [OutlinedInput](/material-ui/api/outlined-input/)
|
|
961
|
+
* - [Input](/material-ui/api/input/)
|
|
962
|
+
* - [FormHelperText](/material-ui/api/form-helper-text/)
|
|
963
|
+
*
|
|
964
|
+
* If you wish to alter the props applied to the `input` element, you can do so as follows:
|
|
965
|
+
*
|
|
966
|
+
* ```jsx
|
|
967
|
+
* const inputProps = {
|
|
968
|
+
* step: 300,
|
|
969
|
+
* };
|
|
970
|
+
*
|
|
971
|
+
* return <TextField id="time" type="time" inputProps={inputProps} />;
|
|
972
|
+
* ```
|
|
973
|
+
*
|
|
974
|
+
* For advanced cases, please look at the source of TextField by clicking on the
|
|
975
|
+
* "Edit this page" button above. Consider either:
|
|
976
|
+
*
|
|
977
|
+
* - using the upper case props for passing values directly to the components
|
|
978
|
+
* - using the underlying components directly as shown in the demos
|
|
979
|
+
*/
|
|
980
|
+
const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
|
|
981
|
+
const props = useThemeProps({
|
|
982
|
+
props: inProps,
|
|
983
|
+
name: 'MuiTextField'
|
|
984
|
+
});
|
|
985
|
+
const {
|
|
986
|
+
autoComplete,
|
|
987
|
+
autoFocus = false,
|
|
988
|
+
children,
|
|
989
|
+
className,
|
|
990
|
+
color = 'primary',
|
|
991
|
+
defaultValue,
|
|
992
|
+
disabled = false,
|
|
993
|
+
error = false,
|
|
994
|
+
FormHelperTextProps,
|
|
995
|
+
fullWidth = false,
|
|
996
|
+
helperText,
|
|
997
|
+
id: idOverride,
|
|
998
|
+
InputLabelProps,
|
|
999
|
+
inputProps,
|
|
1000
|
+
InputProps,
|
|
1001
|
+
inputRef,
|
|
1002
|
+
label,
|
|
1003
|
+
maxRows,
|
|
1004
|
+
minRows,
|
|
1005
|
+
multiline = false,
|
|
1006
|
+
name,
|
|
1007
|
+
onBlur,
|
|
1008
|
+
onChange,
|
|
1009
|
+
onClick,
|
|
1010
|
+
onFocus,
|
|
1011
|
+
placeholder,
|
|
1012
|
+
required = false,
|
|
1013
|
+
rows,
|
|
1014
|
+
select = false,
|
|
1015
|
+
SelectProps,
|
|
1016
|
+
type,
|
|
1017
|
+
value,
|
|
1018
|
+
variant = 'outlined'
|
|
1019
|
+
} = props,
|
|
1020
|
+
other = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
1021
|
+
const ownerState = _extends({}, props, {
|
|
1022
|
+
autoFocus,
|
|
1023
|
+
color,
|
|
1024
|
+
disabled,
|
|
1025
|
+
error,
|
|
1026
|
+
fullWidth,
|
|
1027
|
+
multiline,
|
|
1028
|
+
required,
|
|
1029
|
+
select,
|
|
1030
|
+
variant
|
|
1031
|
+
});
|
|
1032
|
+
const classes = useUtilityClasses(ownerState);
|
|
1033
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1034
|
+
if (select && !children) {
|
|
1035
|
+
console.error('MUI: `children` must be passed when using the `TextField` component with `select`.');
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
const InputMore = {};
|
|
1039
|
+
if (variant === 'outlined') {
|
|
1040
|
+
if (InputLabelProps && typeof InputLabelProps.shrink !== 'undefined') {
|
|
1041
|
+
InputMore.notched = InputLabelProps.shrink;
|
|
1042
|
+
}
|
|
1043
|
+
InputMore.label = label;
|
|
1044
|
+
}
|
|
1045
|
+
if (select) {
|
|
1046
|
+
// unset defaults from textbox inputs
|
|
1047
|
+
if (!SelectProps || !SelectProps.native) {
|
|
1048
|
+
InputMore.id = undefined;
|
|
1049
|
+
}
|
|
1050
|
+
InputMore['aria-describedby'] = undefined;
|
|
1051
|
+
}
|
|
1052
|
+
const id = useId(idOverride);
|
|
1053
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
1054
|
+
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
1055
|
+
const InputComponent = variantComponent[variant];
|
|
1056
|
+
const InputElement = /*#__PURE__*/jsxRuntimeExports.jsx(InputComponent, _extends({
|
|
1057
|
+
"aria-describedby": helperTextId,
|
|
1058
|
+
autoComplete: autoComplete,
|
|
1059
|
+
autoFocus: autoFocus,
|
|
1060
|
+
defaultValue: defaultValue,
|
|
1061
|
+
fullWidth: fullWidth,
|
|
1062
|
+
multiline: multiline,
|
|
1063
|
+
name: name,
|
|
1064
|
+
rows: rows,
|
|
1065
|
+
maxRows: maxRows,
|
|
1066
|
+
minRows: minRows,
|
|
1067
|
+
type: type,
|
|
1068
|
+
value: value,
|
|
1069
|
+
id: id,
|
|
1070
|
+
inputRef: inputRef,
|
|
1071
|
+
onBlur: onBlur,
|
|
1072
|
+
onChange: onChange,
|
|
1073
|
+
onFocus: onFocus,
|
|
1074
|
+
onClick: onClick,
|
|
1075
|
+
placeholder: placeholder,
|
|
1076
|
+
inputProps: inputProps
|
|
1077
|
+
}, InputMore, InputProps));
|
|
1078
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(TextFieldRoot, _extends({
|
|
1079
|
+
className: clsx(classes.root, className),
|
|
1080
|
+
disabled: disabled,
|
|
1081
|
+
error: error,
|
|
1082
|
+
fullWidth: fullWidth,
|
|
1083
|
+
ref: ref,
|
|
1084
|
+
required: required,
|
|
1085
|
+
color: color,
|
|
1086
|
+
variant: variant,
|
|
1087
|
+
ownerState: ownerState
|
|
1088
|
+
}, other, {
|
|
1089
|
+
children: [label != null && label !== '' && /*#__PURE__*/jsxRuntimeExports.jsx(InputLabel$1, _extends({
|
|
1090
|
+
htmlFor: id,
|
|
1091
|
+
id: inputLabelId
|
|
1092
|
+
}, InputLabelProps, {
|
|
1093
|
+
children: label
|
|
1094
|
+
})), select ? /*#__PURE__*/jsxRuntimeExports.jsx(Select, _extends({
|
|
1095
|
+
"aria-describedby": helperTextId,
|
|
1096
|
+
id: id,
|
|
1097
|
+
labelId: inputLabelId,
|
|
1098
|
+
value: value,
|
|
1099
|
+
input: InputElement
|
|
1100
|
+
}, SelectProps, {
|
|
1101
|
+
children: children
|
|
1102
|
+
})) : InputElement, helperText && /*#__PURE__*/jsxRuntimeExports.jsx(FormHelperText$1, _extends({
|
|
1103
|
+
id: helperTextId
|
|
1104
|
+
}, FormHelperTextProps, {
|
|
1105
|
+
children: helperText
|
|
1106
|
+
}))]
|
|
1107
|
+
}));
|
|
1108
|
+
});
|
|
1109
|
+
process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes */ = {
|
|
1110
|
+
// ----------------------------- Warning --------------------------------
|
|
1111
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
1112
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
1113
|
+
// ----------------------------------------------------------------------
|
|
1114
|
+
/**
|
|
1115
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
1116
|
+
* The name can be confusing, as it's more like an autofill.
|
|
1117
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
1118
|
+
*/
|
|
1119
|
+
autoComplete: PropTypes.string,
|
|
1120
|
+
/**
|
|
1121
|
+
* If `true`, the `input` element is focused during the first mount.
|
|
1122
|
+
* @default false
|
|
1123
|
+
*/
|
|
1124
|
+
autoFocus: PropTypes.bool,
|
|
1125
|
+
/**
|
|
1126
|
+
* @ignore
|
|
1127
|
+
*/
|
|
1128
|
+
children: PropTypes.node,
|
|
1129
|
+
/**
|
|
1130
|
+
* Override or extend the styles applied to the component.
|
|
1131
|
+
*/
|
|
1132
|
+
classes: PropTypes.object,
|
|
1133
|
+
/**
|
|
1134
|
+
* @ignore
|
|
1135
|
+
*/
|
|
1136
|
+
className: PropTypes.string,
|
|
1137
|
+
/**
|
|
1138
|
+
* The color of the component.
|
|
1139
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
1140
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
|
|
1141
|
+
* @default 'primary'
|
|
1142
|
+
*/
|
|
1143
|
+
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
|
1144
|
+
/**
|
|
1145
|
+
* The default value. Use when the component is not controlled.
|
|
1146
|
+
*/
|
|
1147
|
+
defaultValue: PropTypes.any,
|
|
1148
|
+
/**
|
|
1149
|
+
* If `true`, the component is disabled.
|
|
1150
|
+
* @default false
|
|
1151
|
+
*/
|
|
1152
|
+
disabled: PropTypes.bool,
|
|
1153
|
+
/**
|
|
1154
|
+
* If `true`, the label is displayed in an error state.
|
|
1155
|
+
* @default false
|
|
1156
|
+
*/
|
|
1157
|
+
error: PropTypes.bool,
|
|
1158
|
+
/**
|
|
1159
|
+
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
1160
|
+
*/
|
|
1161
|
+
FormHelperTextProps: PropTypes.object,
|
|
1162
|
+
/**
|
|
1163
|
+
* If `true`, the input will take up the full width of its container.
|
|
1164
|
+
* @default false
|
|
1165
|
+
*/
|
|
1166
|
+
fullWidth: PropTypes.bool,
|
|
1167
|
+
/**
|
|
1168
|
+
* The helper text content.
|
|
1169
|
+
*/
|
|
1170
|
+
helperText: PropTypes.node,
|
|
1171
|
+
/**
|
|
1172
|
+
* The id of the `input` element.
|
|
1173
|
+
* Use this prop to make `label` and `helperText` accessible for screen readers.
|
|
1174
|
+
*/
|
|
1175
|
+
id: PropTypes.string,
|
|
1176
|
+
/**
|
|
1177
|
+
* Props applied to the [`InputLabel`](/material-ui/api/input-label/) element.
|
|
1178
|
+
* Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
|
|
1179
|
+
*/
|
|
1180
|
+
InputLabelProps: PropTypes.object,
|
|
1181
|
+
/**
|
|
1182
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
1183
|
+
*/
|
|
1184
|
+
inputProps: PropTypes.object,
|
|
1185
|
+
/**
|
|
1186
|
+
* Props applied to the Input element.
|
|
1187
|
+
* It will be a [`FilledInput`](/material-ui/api/filled-input/),
|
|
1188
|
+
* [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/)
|
|
1189
|
+
* component depending on the `variant` prop value.
|
|
1190
|
+
*/
|
|
1191
|
+
InputProps: PropTypes.object,
|
|
1192
|
+
/**
|
|
1193
|
+
* Pass a ref to the `input` element.
|
|
1194
|
+
*/
|
|
1195
|
+
inputRef: refType,
|
|
1196
|
+
/**
|
|
1197
|
+
* The label content.
|
|
1198
|
+
*/
|
|
1199
|
+
label: PropTypes.node,
|
|
1200
|
+
/**
|
|
1201
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
1202
|
+
* @default 'none'
|
|
1203
|
+
*/
|
|
1204
|
+
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
|
1205
|
+
/**
|
|
1206
|
+
* Maximum number of rows to display when multiline option is set to true.
|
|
1207
|
+
*/
|
|
1208
|
+
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1209
|
+
/**
|
|
1210
|
+
* Minimum number of rows to display when multiline option is set to true.
|
|
1211
|
+
*/
|
|
1212
|
+
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1213
|
+
/**
|
|
1214
|
+
* If `true`, a `textarea` element is rendered instead of an input.
|
|
1215
|
+
* @default false
|
|
1216
|
+
*/
|
|
1217
|
+
multiline: PropTypes.bool,
|
|
1218
|
+
/**
|
|
1219
|
+
* Name attribute of the `input` element.
|
|
1220
|
+
*/
|
|
1221
|
+
name: PropTypes.string,
|
|
1222
|
+
/**
|
|
1223
|
+
* @ignore
|
|
1224
|
+
*/
|
|
1225
|
+
onBlur: PropTypes.func,
|
|
1226
|
+
/**
|
|
1227
|
+
* Callback fired when the value is changed.
|
|
1228
|
+
*
|
|
1229
|
+
* @param {object} event The event source of the callback.
|
|
1230
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
1231
|
+
*/
|
|
1232
|
+
onChange: PropTypes.func,
|
|
1233
|
+
/**
|
|
1234
|
+
* @ignore
|
|
1235
|
+
*/
|
|
1236
|
+
onClick: PropTypes.func,
|
|
1237
|
+
/**
|
|
1238
|
+
* @ignore
|
|
1239
|
+
*/
|
|
1240
|
+
onFocus: PropTypes.func,
|
|
1241
|
+
/**
|
|
1242
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
1243
|
+
*/
|
|
1244
|
+
placeholder: PropTypes.string,
|
|
1245
|
+
/**
|
|
1246
|
+
* If `true`, the label is displayed as required and the `input` element is required.
|
|
1247
|
+
* @default false
|
|
1248
|
+
*/
|
|
1249
|
+
required: PropTypes.bool,
|
|
1250
|
+
/**
|
|
1251
|
+
* Number of rows to display when multiline option is set to true.
|
|
1252
|
+
*/
|
|
1253
|
+
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1254
|
+
/**
|
|
1255
|
+
* Render a [`Select`](/material-ui/api/select/) element while passing the Input element to `Select` as `input` parameter.
|
|
1256
|
+
* If this option is set you must pass the options of the select as children.
|
|
1257
|
+
* @default false
|
|
1258
|
+
*/
|
|
1259
|
+
select: PropTypes.bool,
|
|
1260
|
+
/**
|
|
1261
|
+
* Props applied to the [`Select`](/material-ui/api/select/) element.
|
|
1262
|
+
*/
|
|
1263
|
+
SelectProps: PropTypes.object,
|
|
1264
|
+
/**
|
|
1265
|
+
* The size of the component.
|
|
1266
|
+
*/
|
|
1267
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
1268
|
+
/**
|
|
1269
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
1270
|
+
*/
|
|
1271
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1272
|
+
/**
|
|
1273
|
+
* 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).
|
|
1274
|
+
*/
|
|
1275
|
+
type: PropTypes /* @typescript-to-proptypes-ignore */.string,
|
|
1276
|
+
/**
|
|
1277
|
+
* The value of the `input` element, required for a controlled component.
|
|
1278
|
+
*/
|
|
1279
|
+
value: PropTypes.any,
|
|
1280
|
+
/**
|
|
1281
|
+
* The variant to use.
|
|
1282
|
+
* @default 'outlined'
|
|
1283
|
+
*/
|
|
1284
|
+
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
|
1285
|
+
} : void 0;
|
|
1286
|
+
var TextField$1 = TextField;
|
|
1287
|
+
|
|
1288
|
+
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
1289
|
+
const InputNumberInterval = props => {
|
|
1290
|
+
var _item$value;
|
|
1291
|
+
const {
|
|
1292
|
+
item,
|
|
1293
|
+
applyValue,
|
|
1294
|
+
focusElementRef = null
|
|
1295
|
+
} = props;
|
|
1296
|
+
const filterTimeout = React.useRef();
|
|
1297
|
+
const [filterValueState, setFilterValueState] = React.useState((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : '');
|
|
1298
|
+
const [applying, setIsApplying] = React.useState(false);
|
|
1299
|
+
React.useEffect(() => {
|
|
1300
|
+
return () => {
|
|
1301
|
+
clearTimeout(filterTimeout.current);
|
|
1302
|
+
};
|
|
1303
|
+
}, []);
|
|
1304
|
+
React.useEffect(() => {
|
|
1305
|
+
var _item$value2;
|
|
1306
|
+
const itemValue = (_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : [undefined, undefined];
|
|
1307
|
+
setFilterValueState(itemValue);
|
|
1308
|
+
}, [item.value]);
|
|
1309
|
+
const updateFilterValue = (lowerBound, upperBound) => {
|
|
1310
|
+
clearTimeout(filterTimeout.current);
|
|
1311
|
+
setFilterValueState([lowerBound, upperBound]);
|
|
1312
|
+
setIsApplying(true);
|
|
1313
|
+
filterTimeout.current = setTimeout(() => {
|
|
1314
|
+
setIsApplying(false);
|
|
1315
|
+
applyValue(_objectSpread2(_objectSpread2({}, item), {}, {
|
|
1316
|
+
value: [lowerBound, upperBound]
|
|
1317
|
+
}));
|
|
1318
|
+
}, SUBMIT_FILTER_STROKE_TIME);
|
|
1319
|
+
};
|
|
1320
|
+
const handleUpperFilterChange = event => {
|
|
1321
|
+
const newUpperBound = event.target.value;
|
|
1322
|
+
updateFilterValue(filterValueState[0], newUpperBound);
|
|
1323
|
+
};
|
|
1324
|
+
const handleLowerFilterChange = event => {
|
|
1325
|
+
const newLowerBound = event.target.value;
|
|
1326
|
+
updateFilterValue(newLowerBound, filterValueState[1]);
|
|
1327
|
+
};
|
|
1328
|
+
return /*#__PURE__*/React.createElement(Box$1, {
|
|
1329
|
+
sx: {
|
|
1330
|
+
display: 'inline-flex',
|
|
1331
|
+
flexDirection: 'row',
|
|
1332
|
+
alignItems: 'end',
|
|
1333
|
+
height: 48,
|
|
1334
|
+
pl: '20px'
|
|
1335
|
+
}
|
|
1336
|
+
}, /*#__PURE__*/React.createElement(TextField$1, {
|
|
1337
|
+
name: "lower-bound-input",
|
|
1338
|
+
placeholder: "From",
|
|
1339
|
+
label: "From",
|
|
1340
|
+
variant: "standard",
|
|
1341
|
+
value: Number(filterValueState[0]),
|
|
1342
|
+
onChange: handleLowerFilterChange,
|
|
1343
|
+
type: "number",
|
|
1344
|
+
inputRef: focusElementRef,
|
|
1345
|
+
sx: {
|
|
1346
|
+
mr: 2
|
|
1347
|
+
}
|
|
1348
|
+
}), /*#__PURE__*/React.createElement(TextField$1, {
|
|
1349
|
+
name: "upper-bound-input",
|
|
1350
|
+
placeholder: "To",
|
|
1351
|
+
label: "To",
|
|
1352
|
+
variant: "standard",
|
|
1353
|
+
value: Number(filterValueState[1]),
|
|
1354
|
+
onChange: handleUpperFilterChange,
|
|
1355
|
+
type: "number",
|
|
1356
|
+
InputProps: applying ? {
|
|
1357
|
+
endAdornment: /*#__PURE__*/React.createElement(Icon, {
|
|
1358
|
+
icon: mdiSync
|
|
1359
|
+
})
|
|
1360
|
+
} : {}
|
|
1361
|
+
}));
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
const isBetweenOperator = {
|
|
1365
|
+
label: 'is between',
|
|
1366
|
+
value: 'isBetween',
|
|
1367
|
+
getApplyFilterFn: filterItem => {
|
|
1368
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1369
|
+
return null;
|
|
1370
|
+
}
|
|
1371
|
+
if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
|
|
1372
|
+
return null;
|
|
1373
|
+
}
|
|
1374
|
+
if (filterItem.value[0] == null || filterItem.value[1] == null) {
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
if (typeof filterItem.value[0] !== 'number' || typeof filterItem.value[1] !== 'number') {
|
|
1378
|
+
return null;
|
|
1379
|
+
}
|
|
1380
|
+
return params => {
|
|
1381
|
+
return params.value !== null && params.value !== undefined && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
1382
|
+
};
|
|
1383
|
+
},
|
|
1384
|
+
InputComponent: InputNumberInterval
|
|
1385
|
+
};
|
|
1386
|
+
const IS_BETWEEN = isBetweenOperator;
|
|
1387
|
+
|
|
1388
|
+
const getGridNumericOperators = () => [...getGridNumericOperators$1(), IS_BETWEEN];
|
|
1389
|
+
|
|
1390
|
+
const doesNotContain = {
|
|
1391
|
+
label: 'does not contain',
|
|
1392
|
+
value: 'doesNotContain',
|
|
1393
|
+
getApplyFilterFn: filterItem => {
|
|
1394
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
return params => {
|
|
1398
|
+
if (filterItem.value.length === 0) {
|
|
1399
|
+
return true;
|
|
1400
|
+
}
|
|
1401
|
+
if (String(params.value).indexOf(filterItem.value) !== -1) {
|
|
1402
|
+
return false;
|
|
1403
|
+
}
|
|
1404
|
+
return true;
|
|
1405
|
+
};
|
|
1406
|
+
},
|
|
1407
|
+
InputComponent: GridFilterInputValue
|
|
1408
|
+
};
|
|
1409
|
+
const DOES_NOT_CONTAIN = doesNotContain;
|
|
1410
|
+
|
|
1411
|
+
const doesNotEqual = {
|
|
1412
|
+
label: 'does not equal',
|
|
1413
|
+
value: 'doesNotEqual',
|
|
1414
|
+
getApplyFilterFn: filterItem => {
|
|
1415
|
+
if (!filterItem.field || !filterItem.value || !filterItem.value) {
|
|
1416
|
+
return null;
|
|
1417
|
+
}
|
|
1418
|
+
return params => {
|
|
1419
|
+
if (filterItem.value.length === 0) {
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
1422
|
+
if (String(params.value) === filterItem.value) {
|
|
1423
|
+
return false;
|
|
1424
|
+
}
|
|
1425
|
+
return true;
|
|
1426
|
+
};
|
|
1427
|
+
},
|
|
1428
|
+
InputComponent: GridFilterInputValue
|
|
1429
|
+
};
|
|
1430
|
+
const DOES_NOT_EQUAL = doesNotEqual;
|
|
1431
|
+
|
|
1432
|
+
const doesNotHaveOperator = {
|
|
1433
|
+
label: "doesn't have",
|
|
1434
|
+
value: 'doesNotHave',
|
|
1435
|
+
getApplyFilterFn: filterItem => {
|
|
1436
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1437
|
+
return null;
|
|
1438
|
+
}
|
|
1439
|
+
return params => {
|
|
1440
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1441
|
+
return !cellValues.map(value => String(value)).includes(filterItem.value);
|
|
1442
|
+
};
|
|
1443
|
+
},
|
|
1444
|
+
InputComponent: GridFilterInputValue
|
|
1445
|
+
};
|
|
1446
|
+
const DOES_NOT_HAVE = doesNotHaveOperator;
|
|
1447
|
+
const DOES_NOT_HAVE_WITH_SELECT = _objectSpread2(_objectSpread2({}, DOES_NOT_HAVE), {}, {
|
|
1448
|
+
InputComponent: GridFilterInputSingleSelect
|
|
1449
|
+
});
|
|
1450
|
+
|
|
1451
|
+
const hasOperator = {
|
|
1452
|
+
label: 'has',
|
|
1453
|
+
value: 'has',
|
|
1454
|
+
getApplyFilterFn: filterItem => {
|
|
1455
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
return params => {
|
|
1459
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1460
|
+
return cellValues.map(value => String(value)).includes(filterItem.value);
|
|
1461
|
+
};
|
|
1462
|
+
},
|
|
1463
|
+
InputComponent: GridFilterInputValue
|
|
1464
|
+
};
|
|
1465
|
+
const HAS = hasOperator;
|
|
1466
|
+
const HAS_WITH_SELECT = _objectSpread2(_objectSpread2({}, HAS), {}, {
|
|
1467
|
+
InputComponent: GridFilterInputSingleSelect
|
|
1468
|
+
});
|
|
1469
|
+
|
|
1470
|
+
const hasOnlyOperator = {
|
|
1471
|
+
label: 'has only',
|
|
1472
|
+
value: 'hasOnly',
|
|
1473
|
+
getApplyFilterFn: filterItem => {
|
|
1474
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1475
|
+
return null;
|
|
1476
|
+
}
|
|
1477
|
+
return params => {
|
|
1478
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1479
|
+
return cellValues.length === 1 && String(cellValues[0]) === filterItem.value;
|
|
1480
|
+
};
|
|
1481
|
+
},
|
|
1482
|
+
InputComponent: GridFilterInputValue
|
|
1483
|
+
};
|
|
1484
|
+
const HAS_ONLY = hasOnlyOperator;
|
|
1485
|
+
const HAS_ONLY_WITH_SELECT = _objectSpread2(_objectSpread2({}, HAS_ONLY), {}, {
|
|
1486
|
+
InputComponent: GridFilterInputSingleSelect
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
const isOperator = {
|
|
1490
|
+
label: 'is',
|
|
1491
|
+
value: 'is',
|
|
1492
|
+
getApplyFilterFn: filterItem => {
|
|
1493
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1494
|
+
return null;
|
|
1495
|
+
}
|
|
1496
|
+
return params => {
|
|
1497
|
+
if (Array.isArray(params.value)) {
|
|
1498
|
+
return false;
|
|
1499
|
+
}
|
|
1500
|
+
return String(params.value) === filterItem.value;
|
|
1501
|
+
};
|
|
1502
|
+
},
|
|
1503
|
+
InputComponent: GridFilterInputValue
|
|
1504
|
+
};
|
|
1505
|
+
const IS = isOperator;
|
|
1506
|
+
const IS_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS), {}, {
|
|
1507
|
+
InputComponent: GridFilterInputSingleSelect
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
const isNotOperator = {
|
|
1511
|
+
label: 'is not',
|
|
1512
|
+
value: 'isNot',
|
|
1513
|
+
getApplyFilterFn: filterItem => {
|
|
1514
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
return params => {
|
|
1518
|
+
if (Array.isArray(params.value)) {
|
|
1519
|
+
return true;
|
|
1520
|
+
}
|
|
1521
|
+
return String(params.value) !== filterItem.value;
|
|
1522
|
+
};
|
|
1523
|
+
},
|
|
1524
|
+
InputComponent: GridFilterInputValue
|
|
1525
|
+
};
|
|
1526
|
+
const IS_NOT = isNotOperator;
|
|
1527
|
+
const IS_NOT_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS_NOT), {}, {
|
|
1528
|
+
InputComponent: GridFilterInputSingleSelect
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
const containsAnyOfOperator = {
|
|
1532
|
+
label: 'contains any of',
|
|
1533
|
+
value: 'containsAnyOf',
|
|
1534
|
+
getApplyFilterFn: filterItem => {
|
|
1535
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1536
|
+
return null;
|
|
1537
|
+
}
|
|
1538
|
+
return params => {
|
|
1539
|
+
if (filterItem.value.length === 0) {
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1543
|
+
let match = false;
|
|
1544
|
+
filterItem.value.forEach(filteredValue => {
|
|
1545
|
+
paramValues.forEach(paramValue => {
|
|
1546
|
+
if (String(paramValue).indexOf(filteredValue) !== -1) {
|
|
1547
|
+
match = true;
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
});
|
|
1551
|
+
return match;
|
|
1552
|
+
};
|
|
1553
|
+
},
|
|
1554
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1555
|
+
};
|
|
1556
|
+
const containsAnyOfCIOperator = {
|
|
1557
|
+
label: 'contains any of (case insensitive)',
|
|
1558
|
+
value: 'containsAnyOf',
|
|
1559
|
+
getApplyFilterFn: filterItem => {
|
|
1560
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1561
|
+
return null;
|
|
1562
|
+
}
|
|
1563
|
+
return params => {
|
|
1564
|
+
if (filterItem.value.length === 0) {
|
|
1565
|
+
return true;
|
|
1566
|
+
}
|
|
1567
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1568
|
+
const paramValuesLower = paramValues.map(item => String(item).toLowerCase());
|
|
1569
|
+
let match = false;
|
|
1570
|
+
filterItem.value.forEach(filteredValue => {
|
|
1571
|
+
if (paramValuesLower.indexOf(filteredValue.toLowerCase()) !== -1) {
|
|
1572
|
+
match = true;
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
return match;
|
|
1576
|
+
};
|
|
1577
|
+
},
|
|
1578
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1579
|
+
};
|
|
1580
|
+
const CONTAINS_ANY_OF = containsAnyOfOperator;
|
|
1581
|
+
const CONTAINS_ANY_OF_I = containsAnyOfCIOperator;
|
|
1582
|
+
|
|
1583
|
+
const endsWithAnyOfOperator = {
|
|
1584
|
+
label: 'ends with any of',
|
|
1585
|
+
value: 'endsWithAnyOf',
|
|
1586
|
+
getApplyFilterFn: filterItem => {
|
|
1587
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1588
|
+
return null;
|
|
1589
|
+
}
|
|
1590
|
+
return params => {
|
|
1591
|
+
if (filterItem.value.length === 0) {
|
|
1592
|
+
return true;
|
|
1593
|
+
}
|
|
1594
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1595
|
+
let match = false;
|
|
1596
|
+
filterItem.value.forEach(filteredValue => {
|
|
1597
|
+
paramValues.forEach(paramValue => {
|
|
1598
|
+
if (String(paramValue).endsWith(filteredValue)) {
|
|
1599
|
+
match = true;
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
1603
|
+
return match;
|
|
1604
|
+
};
|
|
1605
|
+
},
|
|
1606
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1607
|
+
};
|
|
1608
|
+
const ENDS_WITH_ANY_OF = endsWithAnyOfOperator;
|
|
1609
|
+
|
|
1610
|
+
const isAnyOfOperator = {
|
|
1611
|
+
label: 'is any of',
|
|
1612
|
+
value: 'isAnyOf',
|
|
1613
|
+
getApplyFilterFn: filterItem => {
|
|
1614
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1617
|
+
return params => {
|
|
1618
|
+
if (filterItem.value.length === 0) {
|
|
1619
|
+
return true;
|
|
1620
|
+
}
|
|
1621
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1622
|
+
for (const paramValue of paramValues) {
|
|
1623
|
+
if (filterItem.value.includes(String(paramValue))) {
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return false;
|
|
1628
|
+
};
|
|
1629
|
+
},
|
|
1630
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1631
|
+
};
|
|
1632
|
+
const IS_ANY_OF = isAnyOfOperator;
|
|
1633
|
+
const IS_ANY_OF_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS_ANY_OF), {}, {
|
|
1634
|
+
InputComponent: GridFilterInputMultipleSingleSelect
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
const isAnyOfIOperator = {
|
|
1638
|
+
label: 'is any of (case-insensitive)',
|
|
1639
|
+
value: 'isAnyOfI',
|
|
1640
|
+
getApplyFilterFn: filterItem => {
|
|
1641
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1642
|
+
return null;
|
|
1643
|
+
}
|
|
1644
|
+
const lowerCaseFilterValues = filterItem.value.map(v => String(v).toLowerCase());
|
|
1645
|
+
return params => {
|
|
1646
|
+
if (filterItem.value.length === 0) {
|
|
1647
|
+
return true;
|
|
1648
|
+
}
|
|
1649
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1650
|
+
for (const paramValue of paramValues) {
|
|
1651
|
+
if (lowerCaseFilterValues.includes(String(paramValue).toLowerCase())) {
|
|
1652
|
+
return true;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
return false;
|
|
1656
|
+
};
|
|
1657
|
+
},
|
|
1658
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1659
|
+
};
|
|
1660
|
+
const IS_ANY_OF_I = isAnyOfIOperator;
|
|
1661
|
+
const IS_ANY_OF_I_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS_ANY_OF_I), {}, {
|
|
1662
|
+
InputComponent: GridFilterInputMultipleSingleSelect
|
|
1663
|
+
});
|
|
1664
|
+
|
|
1665
|
+
const hasAnyOfOperator = {
|
|
1666
|
+
label: 'has any of',
|
|
1667
|
+
value: 'hasAnyOf',
|
|
1668
|
+
getApplyFilterFn: filterItem => {
|
|
1669
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1670
|
+
return null;
|
|
1671
|
+
}
|
|
1672
|
+
return params => {
|
|
1673
|
+
if (filterItem.value.length === 0) {
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1677
|
+
const filterItemValues = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
1678
|
+
return filterItemValues.some(v => cellValues.map(value => String(value)).includes(v));
|
|
1679
|
+
};
|
|
1680
|
+
},
|
|
1681
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1682
|
+
};
|
|
1683
|
+
const HAS_ANY_OF = hasAnyOfOperator;
|
|
1684
|
+
const HAS_ANY_OF_WITH_SELECT = _objectSpread2(_objectSpread2({}, HAS_ANY_OF), {}, {
|
|
1685
|
+
InputComponent: GridFilterInputMultipleSingleSelect
|
|
1686
|
+
});
|
|
1687
|
+
|
|
1688
|
+
const isNotAnyOfOperator = {
|
|
1689
|
+
label: 'is not any of',
|
|
1690
|
+
value: 'isNotAnyOf',
|
|
1691
|
+
getApplyFilterFn: filterItem => {
|
|
1692
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1693
|
+
return null;
|
|
1694
|
+
}
|
|
1695
|
+
return params => {
|
|
1696
|
+
if (filterItem.value.length === 0) {
|
|
1697
|
+
return true;
|
|
1698
|
+
}
|
|
1699
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1700
|
+
for (const paramValue of paramValues) {
|
|
1701
|
+
if (filterItem.value.includes(String(paramValue))) {
|
|
1702
|
+
return false;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return true;
|
|
1706
|
+
};
|
|
1707
|
+
},
|
|
1708
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1709
|
+
};
|
|
1710
|
+
const IS_NOT_ANY_OF = isNotAnyOfOperator;
|
|
1711
|
+
const IS_NOT_ANY_OF_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS_NOT_ANY_OF), {}, {
|
|
1712
|
+
InputComponent: GridFilterInputMultipleSingleSelect
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
const startsWithAnyOfOperator = {
|
|
1716
|
+
label: 'starts with any of',
|
|
1717
|
+
value: 'startsWithAnyOf',
|
|
1718
|
+
getApplyFilterFn: filterItem => {
|
|
1719
|
+
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
return params => {
|
|
1723
|
+
if (filterItem.value.length === 0) {
|
|
1724
|
+
return true;
|
|
1725
|
+
}
|
|
1726
|
+
const paramValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1727
|
+
let match = false;
|
|
1728
|
+
filterItem.value.forEach(filteredValue => {
|
|
1729
|
+
paramValues.forEach(paramValue => {
|
|
1730
|
+
if (String(paramValue).startsWith(filteredValue)) {
|
|
1731
|
+
match = true;
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
});
|
|
1735
|
+
return match;
|
|
1736
|
+
};
|
|
1737
|
+
},
|
|
1738
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1739
|
+
};
|
|
1740
|
+
const STARTS_WITH_ANY_OF = startsWithAnyOfOperator;
|
|
1741
|
+
|
|
1742
|
+
const doesNotHaveAnyOf = {
|
|
1743
|
+
label: "doesn't have any of",
|
|
1744
|
+
value: 'doesNotHaveAnyOf',
|
|
1745
|
+
getApplyFilterFn: filterItem => {
|
|
1746
|
+
if (!filterItem.field || !filterItem.value || !Array.isArray(filterItem.value) || filterItem.value.length === 0) {
|
|
1747
|
+
return null;
|
|
1748
|
+
}
|
|
1749
|
+
return params => {
|
|
1750
|
+
const cellValues = Array.isArray(params.value) ? params.value : [params.value];
|
|
1751
|
+
|
|
1752
|
+
// Return true only if none of the filter values are in the cell values
|
|
1753
|
+
return filterItem.value.every(filterVal => !cellValues.map(value => String(value)).includes(filterVal));
|
|
1754
|
+
};
|
|
1755
|
+
},
|
|
1756
|
+
InputComponent: GridFilterInputMultipleValue
|
|
1757
|
+
};
|
|
1758
|
+
const DOES_NOT_HAVE_ANY_OF = doesNotHaveAnyOf;
|
|
1759
|
+
const DOES_NOT_HAVE_ANY_OF_WITH_SELECT = _objectSpread2(_objectSpread2({}, DOES_NOT_HAVE_ANY_OF), {}, {
|
|
1760
|
+
InputComponent: GridFilterInputMultipleSingleSelect
|
|
1761
|
+
});
|
|
1762
|
+
|
|
1763
|
+
const getGridStringArrayOperators = () => [CONTAINS_ANY_OF, ENDS_WITH_ANY_OF, IS_ANY_OF, IS_ANY_OF_I, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF];
|
|
1764
|
+
const getGridStringArrayOperatorsWithSelect = () => [CONTAINS_ANY_OF, ENDS_WITH_ANY_OF, IS_ANY_OF_WITH_SELECT, IS_ANY_OF_I_WITH_SELECT, IS_NOT_WITH_SELECT, IS_WITH_SELECT, STARTS_WITH_ANY_OF];
|
|
1765
|
+
const getGridStringArrayOperatorsWithSelectOnStringArrayColumns = () => [HAS_WITH_SELECT, HAS_ANY_OF_WITH_SELECT, HAS_ONLY_WITH_SELECT, DOES_NOT_HAVE_WITH_SELECT, DOES_NOT_HAVE_ANY_OF_WITH_SELECT];
|
|
1766
|
+
|
|
1767
|
+
const getGridStringOperators = () => [...getGridStringOperators$1().filter(operator => !['isAnyOf'].includes(operator.value)), DOES_NOT_CONTAIN, DOES_NOT_EQUAL, ...getGridStringArrayOperators()];
|
|
1768
|
+
|
|
1769
|
+
// istanbul ignore file
|
|
1770
|
+
const operatorList = {
|
|
1771
|
+
// Default types
|
|
1772
|
+
string: getGridStringOperators$1(),
|
|
1773
|
+
number: getGridNumericOperators$1(),
|
|
1774
|
+
boolean: getGridBooleanOperators(),
|
|
1775
|
+
date: getGridDateOperators(),
|
|
1776
|
+
dateTime: getGridDateOperators(true),
|
|
1777
|
+
singleSelect: getGridSingleSelectOperators(),
|
|
1778
|
+
// Extended types
|
|
1779
|
+
rsString: getGridStringOperators(),
|
|
1780
|
+
rsNumber: getGridNumericOperators(),
|
|
1781
|
+
rsSingleSelect: [CONTAINS_ANY_OF, ENDS_WITH_ANY_OF, IS_ANY_OF_WITH_SELECT, IS_NOT_WITH_SELECT, IS_WITH_SELECT, STARTS_WITH_ANY_OF],
|
|
1782
|
+
rsSingleSelectWithShortOperatorList: [IS_WITH_SELECT, IS_NOT_WITH_SELECT, IS_ANY_OF_WITH_SELECT],
|
|
1783
|
+
rsMultipleSelect: [HAS_WITH_SELECT, HAS_ANY_OF_WITH_SELECT, HAS_ONLY_WITH_SELECT, DOES_NOT_HAVE_WITH_SELECT, DOES_NOT_HAVE_ANY_OF_WITH_SELECT],
|
|
1784
|
+
rsMultipleSelectWithShortOperatorList: [HAS_WITH_SELECT, DOES_NOT_HAVE_WITH_SELECT, HAS_ANY_OF_WITH_SELECT],
|
|
1785
|
+
// Custom types
|
|
1786
|
+
rsStringArray: getGridStringArrayOperators()
|
|
1787
|
+
};
|
|
1788
|
+
|
|
13
1789
|
const PAGINATION_MODEL_KEY = 'paginationModel';
|
|
14
1790
|
const FILTER_MODEL_KEY = 'filterModel';
|
|
15
1791
|
const SORT_MODEL_KEY = 'sortModel';
|
|
@@ -148,42 +1924,39 @@ const numberOperatorDecoder = {
|
|
|
148
1924
|
lt: '<',
|
|
149
1925
|
lte: '<='
|
|
150
1926
|
};
|
|
151
|
-
const isOperatorValueValid = (
|
|
152
|
-
const column = columns.find(column => column.field ===
|
|
1927
|
+
const isOperatorValueValid = (field, operator, columns) => {
|
|
1928
|
+
const column = columns.find(column => column.field === field);
|
|
153
1929
|
if (!column) {
|
|
154
1930
|
return false;
|
|
155
1931
|
}
|
|
156
1932
|
const columnType = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
157
|
-
const operators = operatorList[columnType];
|
|
1933
|
+
const operators = column.filterOperators || operatorList[columnType];
|
|
158
1934
|
if (!operators) {
|
|
159
1935
|
return false;
|
|
160
1936
|
}
|
|
161
|
-
|
|
162
|
-
return !!operators.filterOperators.find(op => columnType === 'number' && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
163
|
-
}
|
|
164
|
-
return !!operators.find(op => ['number', 'rsNumber'].includes(columnType) && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
1937
|
+
return !!operators.find(op => columnType === 'number' && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operator : op.value === operator);
|
|
165
1938
|
};
|
|
166
1939
|
const listOperators = ['containsAnyOf', 'doesNotContainAnyOf', 'endsWithAnyOf', 'doesNotEndWithAnyOf', 'hasAnyOf', 'doesNotHaveAnyOf', 'isAnyOf', 'isNotAnyOf', 'startsWithAnyOf', 'doesNotStartWithAnyOf'];
|
|
167
1940
|
|
|
168
1941
|
// Check if the value doesn't break
|
|
169
|
-
const isValueValid = (value,
|
|
1942
|
+
const isValueValid = (value, field, columns, operator) => {
|
|
170
1943
|
var _column$type;
|
|
171
1944
|
// every field accepts undefined as value for default
|
|
172
1945
|
if (value === undefined || value === '') {
|
|
173
1946
|
return true;
|
|
174
1947
|
}
|
|
175
1948
|
|
|
176
|
-
// xxxAnyOf accepts as value only lists, and we are
|
|
1949
|
+
// xxxAnyOf accepts as value only lists, and we are declaring them in the
|
|
177
1950
|
// URL as `list=[...]`
|
|
178
|
-
if (listOperators.includes(
|
|
1951
|
+
if (listOperators.includes(operator)) {
|
|
179
1952
|
return Array.isArray(value) || value === '';
|
|
180
1953
|
}
|
|
181
1954
|
|
|
182
1955
|
// We are accepting arrays only if they are of the 'xxxAnyOf' type
|
|
183
|
-
if (Array.isArray(value) && !listOperators.includes(
|
|
1956
|
+
if (Array.isArray(value) && !listOperators.includes(operator)) {
|
|
184
1957
|
return false;
|
|
185
1958
|
}
|
|
186
|
-
const column = columns.find(column => column.field ===
|
|
1959
|
+
const column = columns.find(column => column.field === field);
|
|
187
1960
|
if (!column) {
|
|
188
1961
|
return false;
|
|
189
1962
|
}
|
|
@@ -221,7 +1994,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
221
1994
|
if (!searchString) {
|
|
222
1995
|
return 'invalid';
|
|
223
1996
|
}
|
|
224
|
-
let
|
|
1997
|
+
let logicOperator = GridLogicOperator.And;
|
|
225
1998
|
let quickFilterValues = [];
|
|
226
1999
|
const searchParams = new URLSearchParams();
|
|
227
2000
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
@@ -229,7 +2002,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
229
2002
|
searchParams.set(key, value);
|
|
230
2003
|
}
|
|
231
2004
|
if (key === '_logicOperator') {
|
|
232
|
-
|
|
2005
|
+
logicOperator = value === GridLogicOperator.And || value === GridLogicOperator.Or ? value : GridLogicOperator.And;
|
|
233
2006
|
}
|
|
234
2007
|
if (key === '_quickFilterValues') {
|
|
235
2008
|
try {
|
|
@@ -248,7 +2021,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
248
2021
|
if (isInvalid) {
|
|
249
2022
|
return;
|
|
250
2023
|
}
|
|
251
|
-
const field = key.split('[')[0].slice(1);
|
|
2024
|
+
const field = key.split('[')[0].slice(1);
|
|
252
2025
|
if (!fields.includes(field)) {
|
|
253
2026
|
return;
|
|
254
2027
|
}
|
|
@@ -265,7 +2038,6 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
265
2038
|
return;
|
|
266
2039
|
}
|
|
267
2040
|
const operator = splitRight[0];
|
|
268
|
-
// if the operator is not part of the valid operators invalidate the URL
|
|
269
2041
|
if (!isOperatorValueValid(field, operator, columns) || Array.isArray(operator)) {
|
|
270
2042
|
isInvalid = true;
|
|
271
2043
|
return;
|
|
@@ -277,41 +2049,37 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
277
2049
|
return;
|
|
278
2050
|
}
|
|
279
2051
|
items.push({
|
|
280
|
-
|
|
281
|
-
|
|
2052
|
+
field,
|
|
2053
|
+
operator: columnType === 'number' && Object.keys(numberOperatorDecoder).includes(operator) ? numberOperatorDecoder[operator] : operator,
|
|
282
2054
|
id,
|
|
283
2055
|
value: listOperators.includes(operator) && decodedValue === '' ? [] : decodedValue,
|
|
284
2056
|
type
|
|
285
2057
|
});
|
|
286
2058
|
});
|
|
287
|
-
|
|
288
|
-
// If we found some condition that results in an invalid URL,
|
|
289
|
-
// return the empty filterModel (this will trigger the localStorage)
|
|
290
|
-
// and will pick up the last valid search
|
|
291
2059
|
if (isInvalid) {
|
|
292
2060
|
return 'invalid';
|
|
293
2061
|
}
|
|
294
2062
|
return {
|
|
295
2063
|
items,
|
|
296
|
-
|
|
2064
|
+
logicOperator,
|
|
297
2065
|
quickFilterValues
|
|
298
2066
|
};
|
|
299
2067
|
};
|
|
300
2068
|
const getSearchParamsFromFilterModel = filterModel => {
|
|
301
2069
|
var _filterModel$quickFil;
|
|
302
2070
|
const searchParams = new URLSearchParams();
|
|
303
|
-
searchParams.set('_logicOperator', filterModel['
|
|
2071
|
+
searchParams.set('_logicOperator', filterModel['logicOperator'] || '');
|
|
304
2072
|
filterModel['items'].forEach(item => {
|
|
305
2073
|
const {
|
|
306
|
-
|
|
307
|
-
|
|
2074
|
+
field,
|
|
2075
|
+
operator,
|
|
308
2076
|
value,
|
|
309
2077
|
type
|
|
310
2078
|
} = item;
|
|
311
|
-
if (Object.keys(numberOperatorEncoder).includes(
|
|
312
|
-
searchParams.set(`_${
|
|
2079
|
+
if (Object.keys(numberOperatorEncoder).includes(operator)) {
|
|
2080
|
+
searchParams.set(`_${field}[${numberOperatorEncoder[operator]},${encodeValue(type)}]`, encodeValue(value));
|
|
313
2081
|
} else {
|
|
314
|
-
searchParams.set(`_${
|
|
2082
|
+
searchParams.set(`_${field}[${encodeValue(operator)},${encodeValue(type)}]`, encodeValue(value));
|
|
315
2083
|
}
|
|
316
2084
|
});
|
|
317
2085
|
if ((_filterModel$quickFil = filterModel.quickFilterValues) !== null && _filterModel$quickFil !== void 0 && _filterModel$quickFil.length) {
|
|
@@ -327,7 +2095,7 @@ const getSearchParamsFromFilterModel = filterModel => {
|
|
|
327
2095
|
const getFilterModel = (search, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion) => {
|
|
328
2096
|
const defaultValue = initialState && initialState.filter && initialState.filter.filterModel ? initialState.filter.filterModel : {
|
|
329
2097
|
items: [],
|
|
330
|
-
|
|
2098
|
+
logicOperator: GridLogicOperator.And
|
|
331
2099
|
};
|
|
332
2100
|
if (isNewVersion) {
|
|
333
2101
|
return defaultValue;
|
|
@@ -466,13 +2234,38 @@ const getPaginationModel = (search, localStoragePagination, setLocalStoragePagin
|
|
|
466
2234
|
|
|
467
2235
|
/** COLUMN VISIBILITY */
|
|
468
2236
|
|
|
2237
|
+
const getColumnVisibilityFromString = (searchString, columns) => {
|
|
2238
|
+
if (!searchString) {
|
|
2239
|
+
return 'invalid';
|
|
2240
|
+
}
|
|
2241
|
+
const searchParams = new URLSearchParams(searchString);
|
|
2242
|
+
const value = searchParams.get('_columnVisibility');
|
|
2243
|
+
if (value === '' || value === null || value === '[]') {
|
|
2244
|
+
return 'invalid';
|
|
2245
|
+
}
|
|
2246
|
+
const parsedFields = value.slice(1, value.length - 1).split(',');
|
|
2247
|
+
const fields = columns.map(column => column.field);
|
|
2248
|
+
const visibility = {};
|
|
2249
|
+
for (const field of fields) {
|
|
2250
|
+
visibility[field] = false;
|
|
2251
|
+
}
|
|
2252
|
+
for (const parsedField of parsedFields) {
|
|
2253
|
+
if (fields.includes(parsedField)) {
|
|
2254
|
+
visibility[parsedField] = true;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
if (Object.values(visibility).filter(v => v === true).length === 0) {
|
|
2258
|
+
return 'invalid';
|
|
2259
|
+
}
|
|
2260
|
+
return visibility;
|
|
2261
|
+
};
|
|
469
2262
|
const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
470
2263
|
const searchParams = new URLSearchParams();
|
|
471
|
-
const
|
|
2264
|
+
const fields = columns.map(column => column.field);
|
|
472
2265
|
|
|
473
2266
|
// if column visibility model is empty, show all columns
|
|
474
2267
|
if (Object.keys(columnVisibility).length == 0) {
|
|
475
|
-
searchParams.set('_columnVisibility', `[${
|
|
2268
|
+
searchParams.set('_columnVisibility', `[${fields.join(',')}]`);
|
|
476
2269
|
return searchParams;
|
|
477
2270
|
}
|
|
478
2271
|
const finalColumnVisibility = columns.filter(c => {
|
|
@@ -483,63 +2276,10 @@ const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
|
483
2276
|
[colName]: true
|
|
484
2277
|
});
|
|
485
2278
|
}, columnVisibility);
|
|
486
|
-
const visibleColumns =
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
488
|
-
.filter(_ref => {
|
|
489
|
-
let [_, visible] = _ref;
|
|
490
|
-
return visible;
|
|
491
|
-
})
|
|
492
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
493
|
-
.map(_ref2 => {
|
|
494
|
-
let [column, _] = _ref2;
|
|
495
|
-
return encodeValue(column);
|
|
496
|
-
});
|
|
2279
|
+
const visibleColumns = fields.filter(column => finalColumnVisibility[column] !== false);
|
|
497
2280
|
searchParams.set('_columnVisibility', `[${visibleColumns.join(',')}]`);
|
|
498
2281
|
return searchParams;
|
|
499
2282
|
};
|
|
500
|
-
const getColumnVisibilityFromString = (notParsed, tableColumns) => {
|
|
501
|
-
if (!notParsed || notParsed.length === 1 && notParsed[0] === '?') {
|
|
502
|
-
return 'invalid';
|
|
503
|
-
}
|
|
504
|
-
// remove the initial ? if present
|
|
505
|
-
const parsed = notParsed[0] === '?' ? notParsed.slice(1) : notParsed;
|
|
506
|
-
const visibility = {};
|
|
507
|
-
let exist = false;
|
|
508
|
-
let visibleColumnsCount = 0;
|
|
509
|
-
for (const item of parsed.split('&')) {
|
|
510
|
-
// if it's not column visibility field, skip
|
|
511
|
-
const fieldURL = item.split('=')[0];
|
|
512
|
-
if (fieldURL !== '_columnVisibility') {
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
// e.g. item = _columnVisibility[abc,def]
|
|
516
|
-
const left = item.split(']')[0];
|
|
517
|
-
if (left.split('[').length < 2) {
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
const encodedValues = item.split('[')[1].split(']')[0];
|
|
521
|
-
if (typeof encodedValues !== 'string') {
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
exist = true;
|
|
525
|
-
const columnFields = tableColumns.map(column => column.field);
|
|
526
|
-
// TODO: Add validation that , is present
|
|
527
|
-
const columns = encodedValues.split(',').map(value => decodeValue(value));
|
|
528
|
-
|
|
529
|
-
// for each column, check if it's visible and add it to visibility model
|
|
530
|
-
for (const column of columnFields) {
|
|
531
|
-
const isColumnVisible = columns.includes(column);
|
|
532
|
-
visibility[column] = isColumnVisible;
|
|
533
|
-
if (isColumnVisible) {
|
|
534
|
-
visibleColumnsCount += 1;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
if (visibleColumnsCount === 0 && !exist) {
|
|
539
|
-
return 'invalid';
|
|
540
|
-
}
|
|
541
|
-
return visibility;
|
|
542
|
-
};
|
|
543
2283
|
|
|
544
2284
|
// Rules:
|
|
545
2285
|
// - if we have something in the URL, use that info
|
|
@@ -600,8 +2340,8 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
600
2340
|
if (typeof encodedValues !== 'string') {
|
|
601
2341
|
continue;
|
|
602
2342
|
}
|
|
603
|
-
const
|
|
604
|
-
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' &&
|
|
2343
|
+
const fields = [...tableColumns.map(column => column.field), '__check__'];
|
|
2344
|
+
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' && fields.includes(val));
|
|
605
2345
|
if (fieldURL === '_pinnedColumnsLeft') {
|
|
606
2346
|
pinnedColumns['left'] = columns;
|
|
607
2347
|
}
|
|
@@ -609,9 +2349,9 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
609
2349
|
pinnedColumns['right'] = columns;
|
|
610
2350
|
}
|
|
611
2351
|
}
|
|
612
|
-
return pinnedColumns
|
|
613
|
-
left: pinnedColumns
|
|
614
|
-
right: pinnedColumns
|
|
2352
|
+
return pinnedColumns.left && pinnedColumns.left.length > 0 || pinnedColumns.right && pinnedColumns.right.length > 0 ? {
|
|
2353
|
+
left: pinnedColumns.left || [],
|
|
2354
|
+
right: pinnedColumns.right || []
|
|
615
2355
|
} : 'invalid';
|
|
616
2356
|
};
|
|
617
2357
|
const getSearchParamsFromPinnedColumns = pinnedColumns => {
|
|
@@ -661,7 +2401,7 @@ const getSearchParamsFromTab = search => {
|
|
|
661
2401
|
}
|
|
662
2402
|
return searchParams;
|
|
663
2403
|
};
|
|
664
|
-
const getFinalSearch =
|
|
2404
|
+
const getFinalSearch = _ref => {
|
|
665
2405
|
let {
|
|
666
2406
|
search,
|
|
667
2407
|
localStorageVersion,
|
|
@@ -671,7 +2411,7 @@ const getFinalSearch = _ref3 => {
|
|
|
671
2411
|
columnsVisibilityModel,
|
|
672
2412
|
pinnedColumnsModel,
|
|
673
2413
|
columns
|
|
674
|
-
} =
|
|
2414
|
+
} = _ref;
|
|
675
2415
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
676
2416
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
677
2417
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -736,14 +2476,14 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
736
2476
|
pinnedColumnsModel
|
|
737
2477
|
};
|
|
738
2478
|
};
|
|
739
|
-
const updateUrl = (
|
|
2479
|
+
const updateUrl = (_ref2, search, localStorageVersion, historyReplace, columns) => {
|
|
740
2480
|
let {
|
|
741
2481
|
filterModel,
|
|
742
2482
|
sortModel,
|
|
743
2483
|
paginationModel,
|
|
744
2484
|
columnsModel: columnsVisibilityModel,
|
|
745
2485
|
pinnedColumnsModel
|
|
746
|
-
} =
|
|
2486
|
+
} = _ref2;
|
|
747
2487
|
const newSearch = getFinalSearch({
|
|
748
2488
|
search,
|
|
749
2489
|
localStorageVersion,
|
|
@@ -764,17 +2504,17 @@ const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns)
|
|
|
764
2504
|
// do not use it for equivalence (e.g. with value `3` and undefined we
|
|
765
2505
|
// will get 0).
|
|
766
2506
|
const compareFilters = (firstFilter, secondFilter) => {
|
|
767
|
-
if (firstFilter.
|
|
2507
|
+
if (firstFilter.field < secondFilter.field) {
|
|
768
2508
|
return -1;
|
|
769
|
-
} else if (firstFilter.
|
|
2509
|
+
} else if (firstFilter.field > secondFilter.field) {
|
|
770
2510
|
return 1;
|
|
771
2511
|
}
|
|
772
|
-
if (firstFilter.
|
|
2512
|
+
if (firstFilter.operator === undefined || secondFilter.operator === undefined) {
|
|
773
2513
|
return 0;
|
|
774
2514
|
}
|
|
775
|
-
if (firstFilter.
|
|
2515
|
+
if (firstFilter.operator < secondFilter.operator) {
|
|
776
2516
|
return -1;
|
|
777
|
-
} else if (firstFilter.
|
|
2517
|
+
} else if (firstFilter.operator > secondFilter.operator) {
|
|
778
2518
|
return 1;
|
|
779
2519
|
}
|
|
780
2520
|
if (firstFilter.value < secondFilter.value) {
|
|
@@ -785,18 +2525,18 @@ const compareFilters = (firstFilter, secondFilter) => {
|
|
|
785
2525
|
return 0;
|
|
786
2526
|
};
|
|
787
2527
|
const areFiltersEquivalent = (firstFilter, secondFilter) => {
|
|
788
|
-
return firstFilter.
|
|
2528
|
+
return firstFilter.field === secondFilter.field && firstFilter.operator === secondFilter.operator && firstFilter.value === secondFilter.value;
|
|
789
2529
|
};
|
|
790
2530
|
const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
791
2531
|
const {
|
|
792
2532
|
items,
|
|
793
|
-
|
|
2533
|
+
logicOperator
|
|
794
2534
|
} = filterModel;
|
|
795
2535
|
const {
|
|
796
2536
|
items: itemsToMatch,
|
|
797
|
-
|
|
2537
|
+
logicOperator: logicOperatorToMatch
|
|
798
2538
|
} = filterModelToMatch;
|
|
799
|
-
if (
|
|
2539
|
+
if (logicOperator !== logicOperatorToMatch) {
|
|
800
2540
|
return false;
|
|
801
2541
|
}
|
|
802
2542
|
if (items.length !== itemsToMatch.length) {
|
|
@@ -809,7 +2549,7 @@ const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
|
809
2549
|
const filterToCompare = itemsToMatch[i];
|
|
810
2550
|
|
|
811
2551
|
// compareFilters return 0 if and only if the filters have the same
|
|
812
|
-
//
|
|
2552
|
+
// field, operator, and value
|
|
813
2553
|
if (!areFiltersEquivalent(filter, filterToCompare)) {
|
|
814
2554
|
return false;
|
|
815
2555
|
}
|
|
@@ -818,8 +2558,6 @@ const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
|
818
2558
|
};
|
|
819
2559
|
|
|
820
2560
|
// Get and Set data from LocalStorage WITHOUT useState
|
|
821
|
-
|
|
822
|
-
// triggering a state update and consecutive re-render
|
|
823
2561
|
const useFetchState = (defaultValue, key) => {
|
|
824
2562
|
let stickyValue = null;
|
|
825
2563
|
try {
|
|
@@ -827,16 +2565,7 @@ const useFetchState = (defaultValue, key) => {
|
|
|
827
2565
|
} catch (e) {
|
|
828
2566
|
console.error('StatefulDataGrid: error getting item from local storage: ', e);
|
|
829
2567
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
// TODO: temporary workaround to avoid clashes when someone had sorting on the now-removed screenshot field (renamed to num_annotations)
|
|
833
|
-
// Consider upgrading the Datagrid component library as the exception handling was added in this PR: https://github.com/mui-org/material-ui-x/pull/3224
|
|
834
|
-
if (parsedValue instanceof Array) {
|
|
835
|
-
const fields = (parsedValue || []).map(item => item.field);
|
|
836
|
-
if (fields.includes('screenshot') || fields.includes('diffs')) {
|
|
837
|
-
parsedValue = defaultValue;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
2568
|
+
const parsedValue = stickyValue !== null && stickyValue !== undefined && stickyValue !== 'undefined' ? JSON.parse(stickyValue) : defaultValue;
|
|
840
2569
|
const updateValue = useCallback(value => {
|
|
841
2570
|
try {
|
|
842
2571
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -847,6 +2576,8 @@ const useFetchState = (defaultValue, key) => {
|
|
|
847
2576
|
return [parsedValue, updateValue];
|
|
848
2577
|
};
|
|
849
2578
|
|
|
2579
|
+
// import useLocalStorage from './useLocalStorage';
|
|
2580
|
+
|
|
850
2581
|
const useTableStates = (id, version) => {
|
|
851
2582
|
const [paginationModel, setPaginationModel] = useFetchState('', buildStorageKey({
|
|
852
2583
|
id,
|
|
@@ -903,8 +2634,7 @@ const useStatefulTable = props => {
|
|
|
903
2634
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
904
2635
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
905
2636
|
onFilterModelChange: propsOnFilterModelChange,
|
|
906
|
-
|
|
907
|
-
onPageSizeChange: propsOnPageSizeChange,
|
|
2637
|
+
onPaginationModelChange: propsOnPaginationModelChange,
|
|
908
2638
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
909
2639
|
onSortModelChange: propsOnSortModelChange,
|
|
910
2640
|
useRouter,
|
|
@@ -934,7 +2664,7 @@ const useStatefulTable = props => {
|
|
|
934
2664
|
setDimensionModel
|
|
935
2665
|
} = useTableStates(id, localStorageVersion);
|
|
936
2666
|
|
|
937
|
-
// clearing up old version keys
|
|
2667
|
+
// clearing up old version keys, triggering only on first render
|
|
938
2668
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
939
2669
|
const onColumnDimensionChange = useCallback(_ref => {
|
|
940
2670
|
let {
|
|
@@ -967,7 +2697,6 @@ const useStatefulTable = props => {
|
|
|
967
2697
|
column.width = dimensionModel[column.field] || column.width || 100;
|
|
968
2698
|
return column;
|
|
969
2699
|
}), [propsColumns, dimensionModel]);
|
|
970
|
-
|
|
971
2700
|
/** Add resetPage method to apiRef. */
|
|
972
2701
|
apiRef.current.resetPage = () => {
|
|
973
2702
|
apiRef.current.setPage(0);
|
|
@@ -978,7 +2707,7 @@ const useStatefulTable = props => {
|
|
|
978
2707
|
onFilterModelChange: (model, details) => {
|
|
979
2708
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
980
2709
|
items: model.items.map(item => {
|
|
981
|
-
const column = apiRef.current.getColumn(item.
|
|
2710
|
+
const column = apiRef.current.getColumn(item.field);
|
|
982
2711
|
item.type = column.type || 'string';
|
|
983
2712
|
return item;
|
|
984
2713
|
}),
|
|
@@ -1016,33 +2745,16 @@ const useStatefulTable = props => {
|
|
|
1016
2745
|
}, search, localStorageVersion, historyReplace, columns);
|
|
1017
2746
|
},
|
|
1018
2747
|
pinnedColumns: pinnedColumnsModel,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
filterModel: filterParsed,
|
|
1026
|
-
sortModel: sortModelParsed,
|
|
1027
|
-
paginationModel: {
|
|
1028
|
-
page,
|
|
1029
|
-
pageSize: paginationModelParsed.pageSize,
|
|
1030
|
-
direction
|
|
1031
|
-
},
|
|
1032
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
1033
|
-
pinnedColumnsModel: pinnedColumnsModel
|
|
1034
|
-
}, search, localStorageVersion, historyReplace, columns);
|
|
1035
|
-
},
|
|
1036
|
-
onPageSizeChange: (pageSize, details) => {
|
|
1037
|
-
propsOnPageSizeChange === null || propsOnPageSizeChange === void 0 ? void 0 : propsOnPageSizeChange(pageSize, details);
|
|
2748
|
+
paginationModel: paginationModelParsed,
|
|
2749
|
+
onPaginationModelChange: (model, details) => {
|
|
2750
|
+
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2751
|
+
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
2752
|
+
});
|
|
2753
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
1038
2754
|
updateUrl({
|
|
1039
2755
|
filterModel: filterParsed,
|
|
1040
2756
|
sortModel: sortModelParsed,
|
|
1041
|
-
paginationModel:
|
|
1042
|
-
page: paginationModelParsed.page,
|
|
1043
|
-
pageSize,
|
|
1044
|
-
direction: paginationModelParsed.direction
|
|
1045
|
-
},
|
|
2757
|
+
paginationModel: paginationModel,
|
|
1046
2758
|
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
1047
2759
|
pinnedColumnsModel: pinnedColumnsModel
|
|
1048
2760
|
}, search, localStorageVersion, historyReplace, columns);
|
|
@@ -1068,7 +2780,7 @@ const useStatefulTable = props => {
|
|
|
1068
2780
|
};
|
|
1069
2781
|
};
|
|
1070
2782
|
|
|
1071
|
-
const _excluded = ["apiRef", "autoHeight", "className", "columns", "
|
|
2783
|
+
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"];
|
|
1072
2784
|
const COMPONENT_NAME = 'DataGrid';
|
|
1073
2785
|
const CLASSNAME = 'redsift-datagrid';
|
|
1074
2786
|
const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -1078,15 +2790,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1078
2790
|
autoHeight,
|
|
1079
2791
|
className,
|
|
1080
2792
|
columns,
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
componentsProps,
|
|
2793
|
+
slots,
|
|
2794
|
+
slotProps,
|
|
1084
2795
|
filterModel: propsFilterModel,
|
|
1085
2796
|
columnVisibilityModel: propsColumnVisibilityModel,
|
|
1086
2797
|
pinnedColumns: propsPinnedColumns,
|
|
1087
2798
|
sortModel: propsSortModel,
|
|
1088
|
-
|
|
1089
|
-
pageSize: propsPageSize,
|
|
2799
|
+
paginationModel: propsPaginationModel,
|
|
1090
2800
|
height: propsHeight,
|
|
1091
2801
|
hideToolbar,
|
|
1092
2802
|
initialState,
|
|
@@ -1095,11 +2805,10 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1095
2805
|
localStorageVersion,
|
|
1096
2806
|
previousLocalStorageVersions,
|
|
1097
2807
|
onFilterModelChange: propsOnFilterModelChange,
|
|
1098
|
-
|
|
2808
|
+
rowSelectionModel: propsRowSelectionModel,
|
|
1099
2809
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
onSelectionModelChange: propsOnSelectionModelChange,
|
|
2810
|
+
onPaginationModelChange: propsOnPaginationModelChange,
|
|
2811
|
+
onRowSelectionModelChange: propsOnRowSelectionModelChange,
|
|
1103
2812
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
1104
2813
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
1105
2814
|
onSortModelChange: propsOnSortModelChange,
|
|
@@ -1107,7 +2816,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1107
2816
|
paginationPlacement = 'both',
|
|
1108
2817
|
paginationProps,
|
|
1109
2818
|
rows,
|
|
1110
|
-
|
|
2819
|
+
pageSizeOptions,
|
|
1111
2820
|
sx,
|
|
1112
2821
|
theme: propsTheme,
|
|
1113
2822
|
useRouter,
|
|
@@ -1115,46 +2824,41 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1115
2824
|
rowCount
|
|
1116
2825
|
} = props,
|
|
1117
2826
|
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
1118
|
-
const theme = useTheme(propsTheme);
|
|
2827
|
+
const theme = useTheme$1(propsTheme);
|
|
1119
2828
|
const _apiRef = useGridApiRef();
|
|
1120
2829
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
1121
|
-
const RenderedToolbar =
|
|
2830
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar;
|
|
1122
2831
|
LicenseInfo.setLicenseKey(license);
|
|
1123
2832
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
1124
2833
|
const {
|
|
1125
2834
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
1126
2835
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
1127
|
-
|
|
1128
|
-
onPageSizeChange: controlledOnPageSizeChange,
|
|
2836
|
+
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
1129
2837
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
1130
2838
|
onSortModelChange: controlledOnSortModelChange
|
|
1131
2839
|
} = useControlledDatagridState({
|
|
1132
2840
|
initialState,
|
|
1133
|
-
|
|
2841
|
+
pageSizeOptions,
|
|
1134
2842
|
propsColumnVisibilityModel,
|
|
1135
2843
|
propsFilterModel,
|
|
1136
2844
|
propsOnColumnVisibilityModelChange,
|
|
1137
2845
|
propsOnFilterModelChange,
|
|
1138
2846
|
propsOnPinnedColumnsChange,
|
|
1139
2847
|
propsOnSortModelChange,
|
|
1140
|
-
|
|
1141
|
-
propsPageSize,
|
|
2848
|
+
propsPaginationModel,
|
|
1142
2849
|
propsPinnedColumns,
|
|
1143
2850
|
propsSortModel,
|
|
1144
|
-
|
|
1145
|
-
propsOnPageSizeChange
|
|
2851
|
+
propsOnPaginationModelChange
|
|
1146
2852
|
});
|
|
1147
2853
|
const {
|
|
1148
2854
|
columnVisibilityModel,
|
|
1149
2855
|
filterModel,
|
|
1150
2856
|
onColumnVisibilityModelChange,
|
|
1151
2857
|
onFilterModelChange,
|
|
1152
|
-
|
|
1153
|
-
onPageSizeChange,
|
|
2858
|
+
onPaginationModelChange,
|
|
1154
2859
|
onPinnedColumnsChange,
|
|
1155
2860
|
onSortModelChange,
|
|
1156
|
-
|
|
1157
|
-
pageSize,
|
|
2861
|
+
paginationModel,
|
|
1158
2862
|
pinnedColumns,
|
|
1159
2863
|
sortModel,
|
|
1160
2864
|
onColumnWidthChange
|
|
@@ -1165,40 +2869,39 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1165
2869
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
1166
2870
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
1167
2871
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
1168
|
-
|
|
1169
|
-
onPageSizeChange: controlledOnPageSizeChange,
|
|
2872
|
+
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
1170
2873
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
1171
2874
|
onSortModelChange: controlledOnSortModelChange,
|
|
1172
2875
|
useRouter: useRouter,
|
|
1173
2876
|
localStorageVersion,
|
|
1174
2877
|
previousLocalStorageVersions
|
|
1175
2878
|
});
|
|
1176
|
-
const [
|
|
2879
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
1177
2880
|
useEffect(() => {
|
|
1178
|
-
|
|
1179
|
-
}, [
|
|
1180
|
-
const
|
|
1181
|
-
if (
|
|
1182
|
-
|
|
2881
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
2882
|
+
}, [propsRowSelectionModel]);
|
|
2883
|
+
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
2884
|
+
if (propsOnRowSelectionModelChange) {
|
|
2885
|
+
propsOnRowSelectionModelChange(selectionModel, details);
|
|
1183
2886
|
} else {
|
|
1184
|
-
|
|
2887
|
+
setRowSelectionModel(selectionModel);
|
|
1185
2888
|
}
|
|
1186
2889
|
};
|
|
1187
2890
|
const selectionStatus = useRef({
|
|
1188
2891
|
type: 'none',
|
|
1189
2892
|
numberOfSelectedRows: 0,
|
|
1190
2893
|
numberOfSelectedRowsInPage: 0,
|
|
1191
|
-
page,
|
|
1192
|
-
pageSize: pageSize
|
|
2894
|
+
page: paginationModel.page,
|
|
2895
|
+
pageSize: paginationModel.pageSize
|
|
1193
2896
|
});
|
|
1194
2897
|
|
|
1195
2898
|
// in server-side pagination we want to update the selection status
|
|
1196
2899
|
// every time we navigate between pages, resize our page or select something
|
|
1197
2900
|
useEffect(() => {
|
|
1198
2901
|
if (paginationMode == 'server') {
|
|
1199
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
2902
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatus, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
1200
2903
|
}
|
|
1201
|
-
}, [
|
|
2904
|
+
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize]);
|
|
1202
2905
|
if (!Array.isArray(rows)) {
|
|
1203
2906
|
return null;
|
|
1204
2907
|
}
|
|
@@ -1224,22 +2927,20 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1224
2927
|
ref: datagridRef,
|
|
1225
2928
|
className: classNames(StatefulDataGrid.className, className),
|
|
1226
2929
|
$height: height
|
|
1227
|
-
}, /*#__PURE__*/React__default.createElement(DataGridPro, _extends({}, forwardedProps, {
|
|
2930
|
+
}, /*#__PURE__*/React__default.createElement(DataGridPro, _extends$1({}, forwardedProps, {
|
|
1228
2931
|
apiRef: apiRef,
|
|
1229
2932
|
columns: columns,
|
|
1230
2933
|
columnVisibilityModel: columnVisibilityModel,
|
|
1231
2934
|
filterModel: filterModel,
|
|
1232
2935
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
1233
2936
|
onFilterModelChange: onFilterModelChange,
|
|
1234
|
-
|
|
1235
|
-
onPageSizeChange: onPageSizeChange,
|
|
2937
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
1236
2938
|
onPinnedColumnsChange: onPinnedColumnsChange,
|
|
1237
2939
|
onSortModelChange: onSortModelChange,
|
|
1238
|
-
|
|
1239
|
-
pageSize: pageSize,
|
|
2940
|
+
paginationModel: paginationModel,
|
|
1240
2941
|
pinnedColumns: pinnedColumns,
|
|
1241
2942
|
sortModel: sortModel,
|
|
1242
|
-
|
|
2943
|
+
pageSizeOptions: pageSizeOptions,
|
|
1243
2944
|
onColumnWidthChange: onColumnWidthChange,
|
|
1244
2945
|
initialState: initialState,
|
|
1245
2946
|
isRowSelectable: isRowSelectable,
|
|
@@ -1250,79 +2951,74 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1250
2951
|
rowCount: rowCount,
|
|
1251
2952
|
autoHeight: autoHeight,
|
|
1252
2953
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends({}, props, {
|
|
2954
|
+
slots: _objectSpread2(_objectSpread2({
|
|
2955
|
+
baseButton: BaseButton,
|
|
2956
|
+
baseCheckbox: BaseCheckbox,
|
|
2957
|
+
// baseTextField,
|
|
2958
|
+
basePopper: BasePopper,
|
|
2959
|
+
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1260
2960
|
displayName: "ColumnFilteredIcon"
|
|
1261
2961
|
})),
|
|
1262
|
-
|
|
2962
|
+
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1263
2963
|
displayName: "ColumnSelectorIcon"
|
|
1264
2964
|
})),
|
|
1265
|
-
|
|
2965
|
+
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1266
2966
|
displayName: "ColumnSortedAscendingIcon"
|
|
1267
2967
|
})),
|
|
1268
|
-
|
|
2968
|
+
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1269
2969
|
displayName: "ColumnSortedDescendingIcon"
|
|
1270
2970
|
})),
|
|
1271
|
-
|
|
2971
|
+
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1272
2972
|
displayName: "DensityCompactIcon"
|
|
1273
2973
|
})),
|
|
1274
|
-
|
|
2974
|
+
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1275
2975
|
displayName: "DensityStandardIcon"
|
|
1276
2976
|
})),
|
|
1277
|
-
|
|
2977
|
+
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1278
2978
|
displayName: "DensityComfortableIcon"
|
|
1279
2979
|
})),
|
|
1280
|
-
|
|
2980
|
+
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1281
2981
|
displayName: "DetailPanelCollapseIcon"
|
|
1282
2982
|
})),
|
|
1283
|
-
|
|
2983
|
+
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1284
2984
|
displayName: "DetailPanelExpandIcon"
|
|
1285
2985
|
})),
|
|
1286
|
-
|
|
2986
|
+
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
1287
2987
|
displayName: "ExportIcon"
|
|
1288
2988
|
})),
|
|
1289
|
-
|
|
2989
|
+
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
1290
2990
|
displayName: "OpenFilterButtonIcon"
|
|
1291
2991
|
}, props))
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends({}, props, {
|
|
2992
|
+
}, slots), {}, {
|
|
2993
|
+
toolbar: ToolbarWrapper,
|
|
2994
|
+
pagination: props => {
|
|
2995
|
+
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
1296
2996
|
displaySelection: false,
|
|
1297
2997
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
1298
2998
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
1299
2999
|
selectionStatus: selectionStatus.current,
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
onPageSizeChange: onPageSizeChange,
|
|
1304
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
3000
|
+
paginationModel: paginationModel,
|
|
3001
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3002
|
+
pageSizeOptions: pageSizeOptions,
|
|
1305
3003
|
paginationProps: paginationProps,
|
|
1306
3004
|
paginationMode: paginationMode,
|
|
1307
3005
|
rowCount: rowCount
|
|
1308
|
-
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends({}, props, {
|
|
3006
|
+
})) : /*#__PURE__*/React__default.createElement(ControlledPagination, _extends$1({}, props, {
|
|
1309
3007
|
displaySelection: false,
|
|
1310
3008
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
1311
3009
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
1312
3010
|
selectionStatus: selectionStatus.current,
|
|
1313
3011
|
apiRef: apiRef,
|
|
1314
3012
|
isRowSelectable: isRowSelectable,
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
onPageSizeChange: onPageSizeChange,
|
|
1319
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
3013
|
+
paginationModel: paginationModel,
|
|
3014
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
3015
|
+
pageSizeOptions: pageSizeOptions,
|
|
1320
3016
|
paginationProps: paginationProps,
|
|
1321
3017
|
paginationMode: paginationMode
|
|
1322
3018
|
})) : null;
|
|
1323
3019
|
}
|
|
1324
3020
|
}),
|
|
1325
|
-
|
|
3021
|
+
slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
|
|
1326
3022
|
toolbar: _objectSpread2({
|
|
1327
3023
|
hideToolbar,
|
|
1328
3024
|
RenderedToolbar,
|
|
@@ -1333,18 +3029,16 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1333
3029
|
selectionStatus,
|
|
1334
3030
|
apiRef,
|
|
1335
3031
|
isRowSelectable,
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
onPageSizeChange,
|
|
1340
|
-
rowsPerPageOptions,
|
|
3032
|
+
paginationModel,
|
|
3033
|
+
onPaginationModelChange,
|
|
3034
|
+
pageSizeOptions,
|
|
1341
3035
|
paginationProps,
|
|
1342
3036
|
paginationMode,
|
|
1343
3037
|
rowCount
|
|
1344
|
-
},
|
|
3038
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
|
|
1345
3039
|
}),
|
|
1346
|
-
|
|
1347
|
-
|
|
3040
|
+
rowSelectionModel: rowSelectionModel,
|
|
3041
|
+
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
1348
3042
|
if (pagination && paginationMode != 'server') {
|
|
1349
3043
|
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
1350
3044
|
let {
|
|
@@ -1402,7 +3096,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1402
3096
|
};
|
|
1403
3097
|
}
|
|
1404
3098
|
}
|
|
1405
|
-
|
|
3099
|
+
onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
|
|
1406
3100
|
},
|
|
1407
3101
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
1408
3102
|
'.MuiDataGrid-columnHeaders': {
|
|
@@ -1418,5 +3112,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1418
3112
|
StatefulDataGrid.className = CLASSNAME;
|
|
1419
3113
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
1420
3114
|
|
|
1421
|
-
export {
|
|
3115
|
+
export { getSearchParamsFromPagination as $, PINNED_COLUMNS as A, DIMENSION_MODEL_KEY as B, CONTAINS_ANY_OF as C, DOES_NOT_CONTAIN as D, ENDS_WITH_ANY_OF as E, FILTER_MODEL_KEY as F, FILTER_SEARCH_KEY as G, HAS as H, IS_BETWEEN as I, CATEGORIES as J, buildStorageKey as K, clearPreviousVersionStorage as L, decodeValue as M, encodeValue as N, urlSearchParamsToString as O, PAGINATION_MODEL_KEY as P, numberOperatorEncoder as Q, numberOperatorDecoder as R, STARTS_WITH_ANY_OF as S, isOperatorValueValid as T, isValueValid as U, VISIBILITY_MODEL_KEY as V, getFilterModelFromString as W, getSearchParamsFromFilterModel as X, getSortingFromString as Y, getSearchParamsFromSorting as Z, getPaginationFromString as _, DOES_NOT_EQUAL as a, getColumnVisibilityFromString as a0, getSearchParamsFromColumnVisibility as a1, getPinnedColumnsFromString as a2, getSearchParamsFromPinnedColumns as a3, getSearchParamsFromTab as a4, getFinalSearch as a5, getModelsParsedOrUpdateLocalStorage as a6, updateUrl as a7, areFilterModelsEquivalent as a8, StatefulDataGrid as a9, DOES_NOT_HAVE as b, DOES_NOT_HAVE_WITH_SELECT as c, HAS_WITH_SELECT as d, HAS_ONLY as e, HAS_ONLY_WITH_SELECT as f, getGridNumericOperators as g, IS as h, IS_WITH_SELECT as i, IS_NOT as j, IS_NOT_WITH_SELECT as k, getGridStringOperators as l, CONTAINS_ANY_OF_I as m, IS_ANY_OF as n, operatorList as o, IS_ANY_OF_WITH_SELECT as p, IS_ANY_OF_I as q, IS_ANY_OF_I_WITH_SELECT as r, HAS_ANY_OF as s, HAS_ANY_OF_WITH_SELECT as t, IS_NOT_ANY_OF as u, IS_NOT_ANY_OF_WITH_SELECT as v, getGridStringArrayOperators as w, getGridStringArrayOperatorsWithSelect as x, getGridStringArrayOperatorsWithSelectOnStringArrayColumns as y, SORT_MODEL_KEY as z };
|
|
1422
3116
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|