@mui/x-data-grid 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -2
- package/DataGrid/DataGrid.js +20 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/DataGrid/useDataGridProps.js +3 -1
- package/colDef/gridBooleanColDef.js +19 -1
- package/colDef/gridDateColDef.js +6 -2
- package/colDef/gridSingleSelectColDef.js +21 -1
- package/components/GridPagination.js +3 -1
- package/components/base/GridBody.d.ts +1 -0
- package/components/base/GridBody.js +6 -3
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/GridPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
- package/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/hooks/features/dimensions/useGridDimensions.js +2 -4
- package/hooks/features/editing/useGridCellEditing.js +7 -3
- package/hooks/features/editing/useGridRowEditing.js +7 -3
- package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
- package/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/hooks/features/export/useGridCsvExport.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.js +7 -5
- package/hooks/features/focus/useGridFocus.js +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/index.js +1 -1
- package/internals/index.d.ts +3 -2
- package/internals/index.js +3 -2
- package/joy/icons.d.ts +33 -0
- package/joy/icons.js +433 -0
- package/joy/joySlots.js +254 -42
- package/legacy/DataGrid/DataGrid.js +20 -1
- package/legacy/DataGrid/useDataGridComponent.js +2 -2
- package/legacy/DataGrid/useDataGridProps.js +3 -1
- package/legacy/colDef/gridBooleanColDef.js +21 -1
- package/legacy/colDef/gridDateColDef.js +10 -2
- package/legacy/colDef/gridSingleSelectColDef.js +21 -1
- package/legacy/components/GridPagination.js +3 -1
- package/legacy/components/base/GridBody.js +6 -3
- package/legacy/components/containers/GridRootStyles.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -4
- package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
- package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
- package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
- package/legacy/hooks/features/focus/useGridFocus.js +2 -2
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +3 -2
- package/legacy/joy/icons.js +432 -0
- package/legacy/joy/joySlots.js +273 -54
- package/legacy/locales/deDE.js +2 -2
- package/legacy/locales/frFR.js +6 -6
- package/legacy/locales/ptBR.js +1 -1
- package/legacy/locales/ukUA.js +8 -9
- package/legacy/material/index.js +3 -1
- package/legacy/models/api/index.js +0 -1
- package/legacy/utils/domUtils.js +14 -1
- package/locales/deDE.js +2 -2
- package/locales/frFR.js +6 -6
- package/locales/ptBR.js +1 -1
- package/locales/ukUA.js +8 -9
- package/material/index.d.ts +3 -1
- package/material/index.js +3 -1
- package/models/api/gridApiCommon.d.ts +1 -2
- package/models/api/gridCoreApi.d.ts +4 -0
- package/models/api/index.d.ts +0 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +6 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +19 -0
- package/modern/DataGrid/DataGrid.js +20 -1
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/DataGrid/useDataGridProps.js +3 -1
- package/modern/colDef/gridBooleanColDef.js +19 -1
- package/modern/colDef/gridDateColDef.js +6 -2
- package/modern/colDef/gridSingleSelectColDef.js +21 -1
- package/modern/components/GridPagination.js +2 -1
- package/modern/components/base/GridBody.js +6 -3
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
- package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
- package/modern/hooks/features/export/useGridCsvExport.js +7 -5
- package/modern/hooks/features/focus/useGridFocus.js +2 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +3 -2
- package/modern/joy/icons.js +433 -0
- package/modern/joy/joySlots.js +248 -41
- package/modern/locales/deDE.js +2 -2
- package/modern/locales/frFR.js +6 -6
- package/modern/locales/ptBR.js +1 -1
- package/modern/locales/ukUA.js +8 -9
- package/modern/material/index.js +3 -1
- package/modern/models/api/index.js +0 -1
- package/modern/utils/domUtils.js +13 -1
- package/node/DataGrid/DataGrid.js +20 -1
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/DataGrid/useDataGridProps.js +3 -1
- package/node/colDef/gridBooleanColDef.js +19 -1
- package/node/colDef/gridDateColDef.js +6 -2
- package/node/colDef/gridSingleSelectColDef.js +21 -1
- package/node/components/GridPagination.js +2 -1
- package/node/components/base/GridBody.js +6 -3
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
- package/node/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/node/hooks/features/editing/useGridCellEditing.js +7 -3
- package/node/hooks/features/editing/useGridRowEditing.js +7 -3
- package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/node/hooks/features/export/useGridCsvExport.js +6 -3
- package/node/hooks/features/focus/useGridFocus.js +2 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -1
- package/node/joy/icons.js +471 -0
- package/node/joy/joySlots.js +248 -40
- package/node/locales/deDE.js +2 -2
- package/node/locales/frFR.js +6 -6
- package/node/locales/ptBR.js +1 -1
- package/node/locales/ukUA.js +8 -9
- package/node/material/index.js +3 -1
- package/node/models/api/index.js +0 -11
- package/node/utils/domUtils.js +15 -1
- package/package.json +2 -2
- package/utils/domUtils.d.ts +1 -0
- package/utils/domUtils.js +13 -1
- package/legacy/models/api/gridClipboardApi.js +0 -1
- package/models/api/gridClipboardApi.d.ts +0 -11
- package/models/api/gridClipboardApi.js +0 -1
- package/modern/models/api/gridClipboardApi.js +0 -1
- package/node/models/api/gridClipboardApi.js +0 -5
package/joy/joySlots.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["touchRippleRef", "inputProps", "onChange", "color", "size", "checked", "sx", "value", "inputRef"],
|
|
4
|
-
_excluded2 = ["
|
|
5
|
-
_excluded3 = ["color", "size", "sx"],
|
|
6
|
-
_excluded4 = ["
|
|
4
|
+
_excluded2 = ["onChange", "label", "placeholder", "value", "inputRef", "type", "size", "variant"],
|
|
5
|
+
_excluded3 = ["startIcon", "color", "endIcon", "size", "sx", "variant"],
|
|
6
|
+
_excluded4 = ["color", "size", "sx", "touchRippleRef"],
|
|
7
|
+
_excluded5 = ["name", "checkedIcon", "color", "disableRipple", "disableFocusRipple", "disableTouchRipple", "edge", "icon", "inputProps", "inputRef", "size", "sx", "onChange", "onClick"],
|
|
8
|
+
_excluded6 = ["open", "onOpen", "value", "onChange", "size", "color", "variant", "inputProps", "MenuProps", "inputRef", "error", "native", "fullWidth", "labelId"],
|
|
9
|
+
_excluded7 = ["native"],
|
|
10
|
+
_excluded8 = ["shrink", "variant", "sx"];
|
|
7
11
|
import * as React from 'react';
|
|
8
12
|
import JoyCheckbox from '@mui/joy/Checkbox';
|
|
9
13
|
import JoyInput from '@mui/joy/Input';
|
|
@@ -12,6 +16,15 @@ import JoyFormLabel from '@mui/joy/FormLabel';
|
|
|
12
16
|
import JoyButton from '@mui/joy/Button';
|
|
13
17
|
import JoyIconButton from '@mui/joy/IconButton';
|
|
14
18
|
import JoySwitch from '@mui/joy/Switch';
|
|
19
|
+
import JoySelect from '@mui/joy/Select';
|
|
20
|
+
import JoyOption from '@mui/joy/Option';
|
|
21
|
+
import JoyBox from '@mui/joy/Box';
|
|
22
|
+
import JoyTypography from '@mui/joy/Typography';
|
|
23
|
+
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
24
|
+
import joyIconSlots, { GridKeyboardArrowRight, GridKeyboardArrowLeft } from './icons';
|
|
25
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
26
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
27
|
+
import { gridFilteredTopLevelRowCountSelector, gridPaginationModelSelector } from '../hooks';
|
|
15
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
30
|
function convertColor(color) {
|
|
@@ -33,14 +46,17 @@ function convertSize(size) {
|
|
|
33
46
|
large: 'lg'
|
|
34
47
|
}[size] : size;
|
|
35
48
|
}
|
|
36
|
-
function convertVariant(variant) {
|
|
37
|
-
|
|
49
|
+
function convertVariant(variant, defaultVariant = 'plain') {
|
|
50
|
+
if (!variant) {
|
|
51
|
+
return defaultVariant;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
standard: 'outlined',
|
|
38
55
|
outlined: 'outlined',
|
|
39
56
|
contained: 'solid',
|
|
40
57
|
text: 'plain',
|
|
41
|
-
standard: 'plain',
|
|
42
58
|
filled: 'soft'
|
|
43
|
-
}[variant]
|
|
59
|
+
}[variant] || defaultVariant;
|
|
44
60
|
}
|
|
45
61
|
const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
46
62
|
let {
|
|
@@ -61,37 +77,47 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
61
77
|
onChange: onChange
|
|
62
78
|
}));
|
|
63
79
|
});
|
|
64
|
-
const TextField = /*#__PURE__*/React.forwardRef(({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
const TextField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
81
|
+
var _props$InputProps, _props$inputProps;
|
|
82
|
+
let {
|
|
83
|
+
onChange,
|
|
84
|
+
label,
|
|
85
|
+
placeholder,
|
|
86
|
+
value,
|
|
87
|
+
inputRef,
|
|
88
|
+
type,
|
|
89
|
+
size,
|
|
90
|
+
variant
|
|
91
|
+
} = _ref2,
|
|
92
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
93
|
+
const rootRef = useForkRef(ref, (_props$InputProps = props.InputProps) == null ? void 0 : _props$InputProps.ref);
|
|
94
|
+
const inputForkRef = useForkRef(inputRef, props == null ? void 0 : (_props$inputProps = props.inputProps) == null ? void 0 : _props$inputProps.ref);
|
|
95
|
+
const {
|
|
96
|
+
startAdornment,
|
|
97
|
+
endAdornment
|
|
98
|
+
} = props.InputProps || {};
|
|
72
99
|
return /*#__PURE__*/_jsxs(JoyFormControl, {
|
|
73
|
-
ref:
|
|
100
|
+
ref: rootRef,
|
|
74
101
|
children: [/*#__PURE__*/_jsx(JoyFormLabel, {
|
|
75
|
-
sx: {
|
|
76
|
-
fontSize: 12
|
|
77
|
-
},
|
|
78
102
|
children: label
|
|
79
103
|
}), /*#__PURE__*/_jsx(JoyInput, {
|
|
80
104
|
type: type,
|
|
81
105
|
value: value,
|
|
82
106
|
onChange: onChange,
|
|
83
107
|
placeholder: placeholder,
|
|
84
|
-
|
|
108
|
+
variant: convertVariant(variant, 'outlined'),
|
|
109
|
+
size: convertSize(size),
|
|
85
110
|
slotProps: {
|
|
86
|
-
input: {
|
|
87
|
-
ref:
|
|
88
|
-
}
|
|
89
|
-
}
|
|
111
|
+
input: _extends({}, props == null ? void 0 : props.inputProps, {
|
|
112
|
+
ref: inputForkRef
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
startDecorator: startAdornment,
|
|
116
|
+
endDecorator: endAdornment
|
|
90
117
|
})]
|
|
91
118
|
});
|
|
92
119
|
});
|
|
93
|
-
const Button = /*#__PURE__*/React.forwardRef(function Button(
|
|
94
|
-
var _convertVariant;
|
|
120
|
+
const Button = /*#__PURE__*/React.forwardRef(function Button(_ref3, ref) {
|
|
95
121
|
let {
|
|
96
122
|
startIcon,
|
|
97
123
|
color,
|
|
@@ -99,26 +125,26 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(_ref2, ref) {
|
|
|
99
125
|
size,
|
|
100
126
|
sx,
|
|
101
127
|
variant
|
|
102
|
-
} =
|
|
103
|
-
props = _objectWithoutPropertiesLoose(
|
|
128
|
+
} = _ref3,
|
|
129
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
104
130
|
return /*#__PURE__*/_jsx(JoyButton, _extends({}, props, {
|
|
105
131
|
size: convertSize(size),
|
|
106
132
|
color: convertColor(color),
|
|
107
|
-
variant:
|
|
133
|
+
variant: convertVariant(variant),
|
|
108
134
|
ref: ref,
|
|
109
135
|
startDecorator: startIcon,
|
|
110
136
|
endDecorator: endIcon,
|
|
111
137
|
sx: sx
|
|
112
138
|
}));
|
|
113
139
|
});
|
|
114
|
-
const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(
|
|
140
|
+
const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(_ref4, ref) {
|
|
115
141
|
var _convertColor;
|
|
116
142
|
let {
|
|
117
143
|
color,
|
|
118
144
|
size,
|
|
119
145
|
sx
|
|
120
|
-
} =
|
|
121
|
-
props = _objectWithoutPropertiesLoose(
|
|
146
|
+
} = _ref4,
|
|
147
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
122
148
|
return /*#__PURE__*/_jsx(JoyIconButton, _extends({}, props, {
|
|
123
149
|
size: convertSize(size),
|
|
124
150
|
color: (_convertColor = convertColor(color)) != null ? _convertColor : 'neutral',
|
|
@@ -127,7 +153,7 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(_ref3, ref)
|
|
|
127
153
|
sx: sx
|
|
128
154
|
}));
|
|
129
155
|
});
|
|
130
|
-
const Switch = /*#__PURE__*/React.forwardRef(function Switch(
|
|
156
|
+
const Switch = /*#__PURE__*/React.forwardRef(function Switch(_ref5, ref) {
|
|
131
157
|
let {
|
|
132
158
|
name,
|
|
133
159
|
color: colorProp,
|
|
@@ -139,8 +165,8 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(_ref4, ref) {
|
|
|
139
165
|
sx,
|
|
140
166
|
onChange,
|
|
141
167
|
onClick
|
|
142
|
-
} =
|
|
143
|
-
props = _objectWithoutPropertiesLoose(
|
|
168
|
+
} = _ref5,
|
|
169
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded5);
|
|
144
170
|
return /*#__PURE__*/_jsx(JoySwitch, _extends({}, props, {
|
|
145
171
|
onChange: onChange,
|
|
146
172
|
size: convertSize(size),
|
|
@@ -163,17 +189,203 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(_ref4, ref) {
|
|
|
163
189
|
}), ...(Array.isArray(sx) ? sx : [sx])]
|
|
164
190
|
}));
|
|
165
191
|
});
|
|
166
|
-
const
|
|
192
|
+
const Select = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
193
|
+
let {
|
|
194
|
+
open,
|
|
195
|
+
onOpen,
|
|
196
|
+
value,
|
|
197
|
+
onChange,
|
|
198
|
+
size,
|
|
199
|
+
color,
|
|
200
|
+
variant,
|
|
201
|
+
MenuProps,
|
|
202
|
+
inputRef,
|
|
203
|
+
labelId
|
|
204
|
+
} = _ref6,
|
|
205
|
+
props = _objectWithoutPropertiesLoose(_ref6, _excluded6);
|
|
206
|
+
const handleChange = (event, newValue) => {
|
|
207
|
+
if (event && onChange) {
|
|
208
|
+
// Same as in https://github.com/mui/material-ui/blob/e5558282a8f36856aef1299f3a36f3235e92e770/packages/mui-material/src/Select/SelectInput.js#L288-L300
|
|
209
|
+
|
|
210
|
+
// Redefine target to allow name and value to be read.
|
|
211
|
+
// This allows seamless integration with the most popular form libraries.
|
|
212
|
+
// https://github.com/mui/material-ui/issues/13485#issuecomment-676048492
|
|
213
|
+
// Clone the event to not override `target` of the original event.
|
|
214
|
+
const nativeEvent = event.nativeEvent || event;
|
|
215
|
+
// @ts-ignore The nativeEvent is function, not object
|
|
216
|
+
const clonedEvent = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
|
217
|
+
Object.defineProperty(clonedEvent, 'target', {
|
|
218
|
+
writable: true,
|
|
219
|
+
value: {
|
|
220
|
+
value: newValue,
|
|
221
|
+
name: props.name
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
onChange(clonedEvent, null);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return /*#__PURE__*/_jsx(JoySelect, _extends({}, props, {
|
|
228
|
+
listboxOpen: open,
|
|
229
|
+
onListboxOpenChange: isOpen => {
|
|
230
|
+
if (isOpen) {
|
|
231
|
+
onOpen == null ? void 0 : onOpen({});
|
|
232
|
+
} else {
|
|
233
|
+
var _MenuProps$onClose;
|
|
234
|
+
MenuProps == null ? void 0 : (_MenuProps$onClose = MenuProps.onClose) == null ? void 0 : _MenuProps$onClose.call(MenuProps, {}, undefined);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
size: convertSize(size),
|
|
238
|
+
color: convertColor(color),
|
|
239
|
+
variant: convertVariant(variant, 'outlined'),
|
|
240
|
+
ref: ref,
|
|
241
|
+
value: value,
|
|
242
|
+
onChange: handleChange,
|
|
243
|
+
slotProps: {
|
|
244
|
+
button: {
|
|
245
|
+
'aria-labelledby': labelId,
|
|
246
|
+
ref: inputRef
|
|
247
|
+
},
|
|
248
|
+
listbox: {
|
|
249
|
+
disablePortal: false,
|
|
250
|
+
sx: {
|
|
251
|
+
zIndex: 1350
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}));
|
|
256
|
+
});
|
|
257
|
+
const Option = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
258
|
+
let props = _objectWithoutPropertiesLoose(_ref7, _excluded7);
|
|
259
|
+
return /*#__PURE__*/_jsx(JoyOption, _extends({}, props, {
|
|
260
|
+
ref: ref
|
|
261
|
+
}));
|
|
262
|
+
});
|
|
263
|
+
const InputLabel = /*#__PURE__*/React.forwardRef((_ref8, ref) => {
|
|
264
|
+
let {
|
|
265
|
+
sx
|
|
266
|
+
} = _ref8,
|
|
267
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded8);
|
|
268
|
+
return /*#__PURE__*/_jsx(JoyFormLabel, _extends({}, props, {
|
|
269
|
+
ref: ref,
|
|
270
|
+
sx: sx
|
|
271
|
+
}));
|
|
272
|
+
});
|
|
273
|
+
function labelDisplayedRows({
|
|
274
|
+
from,
|
|
275
|
+
to,
|
|
276
|
+
count
|
|
277
|
+
}) {
|
|
278
|
+
return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
|
279
|
+
}
|
|
280
|
+
const getLabelDisplayedRowsTo = ({
|
|
281
|
+
page,
|
|
282
|
+
pageSize,
|
|
283
|
+
rowCount
|
|
284
|
+
}) => {
|
|
285
|
+
if (rowCount === -1) {
|
|
286
|
+
return (page + 1) * pageSize;
|
|
287
|
+
}
|
|
288
|
+
return pageSize === -1 ? rowCount : Math.min(rowCount, (page + 1) * pageSize);
|
|
289
|
+
};
|
|
290
|
+
const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
291
|
+
var _rootProps$pageSizeOp;
|
|
292
|
+
const apiRef = useGridApiContext();
|
|
293
|
+
const rootProps = useGridRootProps();
|
|
294
|
+
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
295
|
+
const visibleTopLevelRowCount = gridFilteredTopLevelRowCountSelector(apiRef);
|
|
296
|
+
const rowCount = React.useMemo(() => {
|
|
297
|
+
var _ref9, _rootProps$rowCount;
|
|
298
|
+
return (_ref9 = (_rootProps$rowCount = rootProps.rowCount) != null ? _rootProps$rowCount : visibleTopLevelRowCount) != null ? _ref9 : 0;
|
|
299
|
+
}, [rootProps.rowCount, visibleTopLevelRowCount]);
|
|
300
|
+
const lastPage = React.useMemo(() => Math.floor(rowCount / (paginationModel.pageSize || 1)), [rowCount, paginationModel.pageSize]);
|
|
301
|
+
const handlePageChange = React.useCallback(page => {
|
|
302
|
+
apiRef.current.setPage(page);
|
|
303
|
+
}, [apiRef]);
|
|
304
|
+
const page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
|
|
305
|
+
const pageSize = paginationModel.pageSize;
|
|
306
|
+
const pageSizeOptions = (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(pageSize) ? rootProps.pageSizeOptions : [];
|
|
307
|
+
const handleChangeRowsPerPage = (event, newValue) => {
|
|
308
|
+
const newPageSize = Number(newValue);
|
|
309
|
+
apiRef.current.setPageSize(newPageSize);
|
|
310
|
+
};
|
|
311
|
+
return /*#__PURE__*/_jsxs(JoyBox, {
|
|
312
|
+
sx: {
|
|
313
|
+
display: 'flex',
|
|
314
|
+
alignItems: 'center',
|
|
315
|
+
gap: 2,
|
|
316
|
+
justifyContent: 'flex-end',
|
|
317
|
+
px: 2
|
|
318
|
+
},
|
|
319
|
+
ref: ref,
|
|
320
|
+
children: [/*#__PURE__*/_jsxs(JoyFormControl, {
|
|
321
|
+
orientation: "horizontal",
|
|
322
|
+
size: "sm",
|
|
323
|
+
children: [/*#__PURE__*/_jsx(JoyFormLabel, {
|
|
324
|
+
children: "Rows per page:"
|
|
325
|
+
}), /*#__PURE__*/_jsx(JoySelect, {
|
|
326
|
+
onChange: handleChangeRowsPerPage,
|
|
327
|
+
value: pageSize,
|
|
328
|
+
children: pageSizeOptions.map(option => {
|
|
329
|
+
return /*#__PURE__*/_jsx(Option, {
|
|
330
|
+
value: option,
|
|
331
|
+
children: option
|
|
332
|
+
}, option);
|
|
333
|
+
})
|
|
334
|
+
})]
|
|
335
|
+
}), /*#__PURE__*/_jsx(JoyTypography, {
|
|
336
|
+
textAlign: "center",
|
|
337
|
+
fontSize: "xs",
|
|
338
|
+
fontWeight: "md",
|
|
339
|
+
children: labelDisplayedRows({
|
|
340
|
+
from: rowCount === 0 ? 0 : page * pageSize + 1,
|
|
341
|
+
to: getLabelDisplayedRowsTo({
|
|
342
|
+
page,
|
|
343
|
+
pageSize,
|
|
344
|
+
rowCount
|
|
345
|
+
}),
|
|
346
|
+
count: rowCount === -1 ? -1 : rowCount
|
|
347
|
+
})
|
|
348
|
+
}), /*#__PURE__*/_jsxs(JoyBox, {
|
|
349
|
+
sx: {
|
|
350
|
+
display: 'flex',
|
|
351
|
+
gap: 0.5
|
|
352
|
+
},
|
|
353
|
+
children: [/*#__PURE__*/_jsx(JoyIconButton, {
|
|
354
|
+
size: "sm",
|
|
355
|
+
color: "neutral",
|
|
356
|
+
variant: "outlined",
|
|
357
|
+
disabled: page === 0,
|
|
358
|
+
onClick: () => handlePageChange(page - 1),
|
|
359
|
+
sx: {
|
|
360
|
+
bgcolor: 'background.surface'
|
|
361
|
+
},
|
|
362
|
+
children: /*#__PURE__*/_jsx(GridKeyboardArrowLeft, {})
|
|
363
|
+
}), /*#__PURE__*/_jsx(JoyIconButton, {
|
|
364
|
+
size: "sm",
|
|
365
|
+
color: "neutral",
|
|
366
|
+
variant: "outlined",
|
|
367
|
+
disabled: rowCount !== -1 ? page >= Math.ceil(rowCount / pageSize) - 1 : false,
|
|
368
|
+
onClick: () => handlePageChange(page + 1),
|
|
369
|
+
sx: {
|
|
370
|
+
bgcolor: 'background.surface'
|
|
371
|
+
},
|
|
372
|
+
children: /*#__PURE__*/_jsx(GridKeyboardArrowRight, {})
|
|
373
|
+
})]
|
|
374
|
+
})]
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
const joySlots = _extends({}, joyIconSlots, {
|
|
167
378
|
baseCheckbox: Checkbox,
|
|
168
379
|
baseTextField: TextField,
|
|
169
380
|
baseButton: Button,
|
|
170
381
|
baseIconButton: IconButton,
|
|
171
|
-
baseSwitch: Switch
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
382
|
+
baseSwitch: Switch,
|
|
383
|
+
baseSelect: Select,
|
|
384
|
+
baseSelectOption: Option,
|
|
385
|
+
baseInputLabel: InputLabel,
|
|
386
|
+
baseFormControl: JoyFormControl,
|
|
175
387
|
// BaseTooltip: MUITooltip,
|
|
176
388
|
// BasePopper: MUIPopper,
|
|
177
|
-
|
|
178
|
-
|
|
389
|
+
pagination: Pagination
|
|
390
|
+
});
|
|
179
391
|
export default joySlots;
|
|
@@ -68,6 +68,11 @@ DataGridRaw.propTypes = {
|
|
|
68
68
|
* Override or extend the styles applied to the component.
|
|
69
69
|
*/
|
|
70
70
|
classes: PropTypes.object,
|
|
71
|
+
/**
|
|
72
|
+
* The character used to separate cell values when copying to the clipboard.
|
|
73
|
+
* @default '\t'
|
|
74
|
+
*/
|
|
75
|
+
clipboardCopyCellDelimiter: PropTypes.string,
|
|
71
76
|
/**
|
|
72
77
|
* Number of extra columns to be rendered before/after the visible slice.
|
|
73
78
|
* @default 3
|
|
@@ -328,6 +333,11 @@ DataGridRaw.propTypes = {
|
|
|
328
333
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
329
334
|
*/
|
|
330
335
|
onCellModesModelChange: PropTypes.func,
|
|
336
|
+
/**
|
|
337
|
+
* Callback called when the data is copied to the clipboard.
|
|
338
|
+
* @param {string} data The data copied to the clipboard.
|
|
339
|
+
*/
|
|
340
|
+
onClipboardCopy: PropTypes.func,
|
|
331
341
|
/**
|
|
332
342
|
* Callback fired when a click event comes from a column header element.
|
|
333
343
|
* @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
|
|
@@ -613,5 +623,14 @@ DataGridRaw.propTypes = {
|
|
|
613
623
|
/**
|
|
614
624
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
615
625
|
*/
|
|
616
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
626
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
627
|
+
/**
|
|
628
|
+
* If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
629
|
+
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
630
|
+
* @default: false
|
|
631
|
+
*/
|
|
632
|
+
unstable_ignoreValueFormatterDuringExport: PropTypes.oneOfType([PropTypes.shape({
|
|
633
|
+
clipboardExport: PropTypes.bool,
|
|
634
|
+
csvExport: PropTypes.bool
|
|
635
|
+
}), PropTypes.bool])
|
|
617
636
|
};
|
|
@@ -67,9 +67,9 @@ export var useDataGridComponent = function useDataGridComponent(inputApiRef, pro
|
|
|
67
67
|
useGridRowsMeta(privateApiRef, props);
|
|
68
68
|
useGridScroll(privateApiRef, props);
|
|
69
69
|
useGridColumnMenu(privateApiRef);
|
|
70
|
-
useGridCsvExport(privateApiRef);
|
|
70
|
+
useGridCsvExport(privateApiRef, props);
|
|
71
71
|
useGridPrintExport(privateApiRef, props);
|
|
72
|
-
useGridClipboard(privateApiRef);
|
|
72
|
+
useGridClipboard(privateApiRef, props);
|
|
73
73
|
useGridDimensions(privateApiRef, props);
|
|
74
74
|
useGridEvents(privateApiRef, props);
|
|
75
75
|
useGridStatePersistence(privateApiRef);
|
|
@@ -66,7 +66,9 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
66
66
|
disableColumnReorder: false,
|
|
67
67
|
disableColumnResize: false,
|
|
68
68
|
keepNonExistentRowsSelected: false,
|
|
69
|
-
keepColumnPositionIfDraggedOutside: false
|
|
69
|
+
keepColumnPositionIfDraggedOutside: false,
|
|
70
|
+
unstable_ignoreValueFormatterDuringExport: false,
|
|
71
|
+
clipboardCopyCellDelimiter: '\t'
|
|
70
72
|
};
|
|
71
73
|
var defaultSlots = uncapitalizeObjectKeys(DATA_GRID_DEFAULT_SLOTS_COMPONENTS);
|
|
72
74
|
export var useDataGridProps = function useDataGridProps(inProps) {
|
|
@@ -9,6 +9,22 @@ function gridBooleanFormatter(_ref) {
|
|
|
9
9
|
api = _ref.api;
|
|
10
10
|
return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
|
|
11
11
|
}
|
|
12
|
+
var stringToBoolean = function stringToBoolean(value) {
|
|
13
|
+
switch (value.toLowerCase().trim()) {
|
|
14
|
+
case 'true':
|
|
15
|
+
case 'yes':
|
|
16
|
+
case '1':
|
|
17
|
+
return true;
|
|
18
|
+
case 'false':
|
|
19
|
+
case 'no':
|
|
20
|
+
case '0':
|
|
21
|
+
case 'null':
|
|
22
|
+
case 'undefined':
|
|
23
|
+
return false;
|
|
24
|
+
default:
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
export var GRID_BOOLEAN_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
13
29
|
type: 'boolean',
|
|
14
30
|
align: 'center',
|
|
@@ -20,5 +36,9 @@ export var GRID_BOOLEAN_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
20
36
|
filterOperators: getGridBooleanOperators(),
|
|
21
37
|
getApplyQuickFilterFn: undefined,
|
|
22
38
|
// @ts-ignore
|
|
23
|
-
aggregable: false
|
|
39
|
+
aggregable: false,
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
pastedValueParser: function pastedValueParser(value) {
|
|
42
|
+
return stringToBoolean(value);
|
|
43
|
+
}
|
|
24
44
|
});
|
|
@@ -48,7 +48,11 @@ export var GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
48
48
|
valueFormatter: gridDateFormatter,
|
|
49
49
|
filterOperators: getGridDateOperators(),
|
|
50
50
|
renderEditCell: renderEditDateCell,
|
|
51
|
-
getApplyQuickFilterFn: undefined
|
|
51
|
+
getApplyQuickFilterFn: undefined,
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
pastedValueParser: function pastedValueParser(value) {
|
|
54
|
+
return new Date(value);
|
|
55
|
+
}
|
|
52
56
|
});
|
|
53
57
|
export var GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
54
58
|
type: 'dateTime',
|
|
@@ -56,5 +60,9 @@ export var GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
56
60
|
valueFormatter: gridDateTimeFormatter,
|
|
57
61
|
filterOperators: getGridDateOperators(true),
|
|
58
62
|
renderEditCell: renderEditDateCell,
|
|
59
|
-
getApplyQuickFilterFn: undefined
|
|
63
|
+
getApplyQuickFilterFn: undefined,
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
pastedValueParser: function pastedValueParser(value) {
|
|
66
|
+
return new Date(value);
|
|
67
|
+
}
|
|
60
68
|
});
|
|
@@ -52,5 +52,25 @@ export var GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
52
52
|
return valueOption ? colDef.getOptionLabel(valueOption) : '';
|
|
53
53
|
},
|
|
54
54
|
renderEditCell: renderEditSingleSelectCell,
|
|
55
|
-
filterOperators: getGridSingleSelectOperators()
|
|
55
|
+
filterOperators: getGridSingleSelectOperators(),
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
pastedValueParser: function pastedValueParser(value, params) {
|
|
58
|
+
var colDef = params.colDef;
|
|
59
|
+
var colDefValueOptions = colDef.valueOptions;
|
|
60
|
+
var valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
|
|
61
|
+
field: colDef.field
|
|
62
|
+
}) : colDefValueOptions || [];
|
|
63
|
+
var getOptionValue = colDef.getOptionValue;
|
|
64
|
+
var valueOption = valueOptions.find(function (option) {
|
|
65
|
+
if (getOptionValue(option) === value) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
70
|
+
if (valueOption) {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
// do not paste the value if it is not in the valueOptions
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
56
76
|
});
|
|
@@ -43,9 +43,11 @@ export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginatio
|
|
|
43
43
|
apiRef.current.setPage(page);
|
|
44
44
|
}, [apiRef]);
|
|
45
45
|
if (process.env.NODE_ENV !== 'production') {
|
|
46
|
+
var _rootProps$pagination, _rootProps$pagination2;
|
|
46
47
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
47
48
|
var warnedOnceMissingInPageSizeOptions = React.useRef(false);
|
|
48
|
-
|
|
49
|
+
var pageSize = (_rootProps$pagination = (_rootProps$pagination2 = rootProps.paginationModel) == null ? void 0 : _rootProps$pagination2.pageSize) != null ? _rootProps$pagination : paginationModel.pageSize;
|
|
50
|
+
if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
|
|
49
51
|
console.warn(["MUI: The page size `".concat(paginationModel.pageSize, "` is not preset in the `pageSizeOptions`"), "Add it to show the pagination select."].join('\n'));
|
|
50
52
|
warnedOnceMissingInPageSizeOptions.current = true;
|
|
51
53
|
}
|
|
@@ -18,7 +18,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
function GridBody(props) {
|
|
20
20
|
var VirtualScrollerComponent = props.VirtualScrollerComponent,
|
|
21
|
-
ColumnHeadersProps = props.ColumnHeadersProps
|
|
21
|
+
ColumnHeadersProps = props.ColumnHeadersProps,
|
|
22
|
+
children = props.children;
|
|
22
23
|
var apiRef = useGridPrivateApiContext();
|
|
23
24
|
var rootProps = useGridRootProps();
|
|
24
25
|
var rootRef = React.useRef(null);
|
|
@@ -90,7 +91,8 @@ function GridBody(props) {
|
|
|
90
91
|
apiRef.current.register('private', {
|
|
91
92
|
columnHeadersContainerElementRef: columnsContainerRef,
|
|
92
93
|
columnHeadersElementRef: columnHeadersRef,
|
|
93
|
-
virtualScrollerRef: virtualScrollerRef
|
|
94
|
+
virtualScrollerRef: virtualScrollerRef,
|
|
95
|
+
mainElementRef: rootRef
|
|
94
96
|
});
|
|
95
97
|
var hasDimensions = !!apiRef.current.getRootDimensions();
|
|
96
98
|
return /*#__PURE__*/_jsxs(GridMainContainer, {
|
|
@@ -121,7 +123,7 @@ function GridBody(props) {
|
|
|
121
123
|
, {
|
|
122
124
|
ref: virtualScrollerRef,
|
|
123
125
|
disableVirtualization: isVirtualizationDisabled
|
|
124
|
-
})]
|
|
126
|
+
}), children]
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
129
|
process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
@@ -129,6 +131,7 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
|
129
131
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
130
132
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
131
133
|
// ----------------------------------------------------------------------
|
|
134
|
+
children: PropTypes.node,
|
|
132
135
|
ColumnHeadersProps: PropTypes.object,
|
|
133
136
|
VirtualScrollerComponent: PropTypes.elementType.isRequired
|
|
134
137
|
} : void 0;
|
|
@@ -39,6 +39,7 @@ export var GridRootStyles = styled('div', {
|
|
|
39
39
|
outline: 'none',
|
|
40
40
|
height: '100%',
|
|
41
41
|
display: 'flex',
|
|
42
|
+
overflow: 'hidden',
|
|
42
43
|
flexDirection: 'column',
|
|
43
44
|
overflowAnchor: 'none'
|
|
44
45
|
}, _defineProperty(_extends2, "&.".concat(gridClasses.autoHeight), _defineProperty({
|
|
@@ -4,7 +4,6 @@ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "col
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
|
7
|
-
import Chip from '@mui/material/Chip';
|
|
8
7
|
import { unstable_useId as useId } from '@mui/utils';
|
|
9
8
|
import { isSingleSelectColDef } from './filterPanelUtils';
|
|
10
9
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
@@ -108,7 +107,7 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
108
107
|
getOptionLabel: getOptionLabel,
|
|
109
108
|
renderTags: function renderTags(value, getTagProps) {
|
|
110
109
|
return value.map(function (option, index) {
|
|
111
|
-
return /*#__PURE__*/_jsx(
|
|
110
|
+
return /*#__PURE__*/_jsx(rootProps.slots.baseChip, _extends({
|
|
112
111
|
variant: "outlined",
|
|
113
112
|
size: "small",
|
|
114
113
|
label: getOptionLabel(option)
|
|
@@ -6,7 +6,6 @@ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "col
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
9
|
-
import Chip from '@mui/material/Chip';
|
|
10
9
|
import { unstable_useId as useId } from '@mui/utils';
|
|
11
10
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -59,7 +58,7 @@ function GridFilterInputMultipleValue(props) {
|
|
|
59
58
|
onChange: handleChange,
|
|
60
59
|
renderTags: function renderTags(value, getTagProps) {
|
|
61
60
|
return value.map(function (option, index) {
|
|
62
|
-
return /*#__PURE__*/_jsx(
|
|
61
|
+
return /*#__PURE__*/_jsx(rootProps.slots.baseChip, _extends({
|
|
63
62
|
variant: "outlined",
|
|
64
63
|
size: "small",
|
|
65
64
|
label: option
|
|
@@ -73,7 +73,9 @@ var GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolbar
|
|
|
73
73
|
ownerState: rootProps,
|
|
74
74
|
children: activeFilters.map(function (item, index) {
|
|
75
75
|
return _extends({}, lookup[item.field] && /*#__PURE__*/_jsx("li", {
|
|
76
|
-
children: "".concat(lookup[item.field].headerName || item.field, "\n ").concat(getOperatorLabel(item), "\n ").concat(
|
|
76
|
+
children: "".concat(lookup[item.field].headerName || item.field, "\n ").concat(getOperatorLabel(item), "\n ").concat(
|
|
77
|
+
// implicit check for null and undefined
|
|
78
|
+
item.value != null ? getFilterItemValue(item) : '')
|
|
77
79
|
}, index));
|
|
78
80
|
})
|
|
79
81
|
})]
|