@mui/x-data-grid 6.0.0-alpha.13 → 6.0.0-alpha.14
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 +134 -0
- package/DataGrid/DataGrid.js +0 -10
- package/colDef/gridSingleSelectOperators.js +6 -3
- package/components/GridRow.d.ts +2 -2
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/panel/GridPanel.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +6 -56
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.js +14 -2
- package/hooks/features/editing/gridEditingSelectors.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.js +2 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +0 -10
- package/legacy/colDef/gridSingleSelectOperators.js +6 -3
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +3 -56
- package/legacy/hooks/features/clipboard/useGridClipboard.js +14 -2
- package/legacy/hooks/features/export/useGridPrintExport.js +2 -0
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/legacy/index.js +1 -1
- package/legacy/models/gridEditRowModel.js +0 -1
- package/models/api/gridParamsApi.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +14 -14
- package/models/events/gridEventLookup.d.ts +12 -19
- package/models/gridCellClass.d.ts +3 -2
- package/models/gridEditRowModel.d.ts +1 -2
- package/models/gridEditRowModel.js +0 -1
- package/models/gridFilterOperator.d.ts +1 -1
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/params/gridCellParams.d.ts +5 -5
- package/models/params/gridColumnHeaderParams.d.ts +1 -1
- package/models/params/gridEditCellParams.d.ts +2 -2
- package/models/props/DataGridProps.d.ts +1 -11
- package/modern/DataGrid/DataGrid.js +0 -10
- package/modern/colDef/gridSingleSelectOperators.js +4 -3
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +5 -55
- package/modern/hooks/features/clipboard/useGridClipboard.js +13 -1
- package/modern/hooks/features/export/useGridPrintExport.js +2 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/index.js +1 -1
- package/modern/models/gridEditRowModel.js +0 -1
- package/node/DataGrid/DataGrid.js +0 -10
- package/node/colDef/gridSingleSelectOperators.js +4 -3
- package/node/components/panel/filterPanel/GridFilterInputValue.js +5 -55
- package/node/hooks/features/clipboard/useGridClipboard.js +13 -1
- package/node/hooks/features/export/useGridPrintExport.js +2 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +3 -3
- package/node/index.js +1 -1
- package/node/models/gridEditRowModel.js +0 -1
- package/package.json +3 -3
- package/utils/utils.d.ts +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { GridFilterInputSingleSelect } from '../components/panel/filterPanel/GridFilterInputSingleSelect';
|
|
2
2
|
import { GridFilterInputMultipleSingleSelect } from '../components/panel/filterPanel/GridFilterInputMultipleSingleSelect';
|
|
3
|
+
import { isObject } from '../utils/utils';
|
|
3
4
|
const parseObjectValue = value => {
|
|
4
|
-
if (value == null ||
|
|
5
|
+
if (value == null || !isObject(value)) {
|
|
5
6
|
return value;
|
|
6
7
|
}
|
|
7
8
|
return value.value;
|
|
@@ -15,7 +16,7 @@ export const getGridSingleSelectQuickFilterFn = (value, column, apiRef) => {
|
|
|
15
16
|
valueFormatter,
|
|
16
17
|
field
|
|
17
18
|
} = column;
|
|
18
|
-
const potentialValues = [parseObjectValue(value)
|
|
19
|
+
const potentialValues = [parseObjectValue(value)?.toString()];
|
|
19
20
|
const iterableColumnValues = typeof valueOptions === 'function' ? valueOptions({
|
|
20
21
|
field
|
|
21
22
|
}) : valueOptions || [];
|
|
@@ -49,7 +50,7 @@ export const getGridSingleSelectQuickFilterFn = (value, column, apiRef) => {
|
|
|
49
50
|
return ({
|
|
50
51
|
value: columnValue
|
|
51
52
|
}) => {
|
|
52
|
-
return columnValue != null ? potentialValues.includes(parseObjectValue(columnValue)
|
|
53
|
+
return columnValue != null ? potentialValues.includes(parseObjectValue(columnValue)?.toString()) : false;
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
export const getGridSingleSelectOperators = () => [{
|
|
@@ -4,40 +4,9 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useId as useId } from '@mui/utils';
|
|
7
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
8
7
|
import { GridLoadIcon } from '../../icons';
|
|
9
8
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
10
|
-
import { getValueFromValueOptions } from './filterPanelUtils';
|
|
11
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const warnedOnce = {};
|
|
13
|
-
function warnDeprecatedTypeSupport(type) {
|
|
14
|
-
console.warn([`MUI: Using GridFilterInputValue with a "${type}" column is deprecated.`, 'Use GridFilterInputSingleSelect instead.'].join('\n'));
|
|
15
|
-
warnedOnce[type] = true;
|
|
16
|
-
}
|
|
17
|
-
const renderSingleSelectOptions = ({
|
|
18
|
-
valueOptions,
|
|
19
|
-
valueFormatter,
|
|
20
|
-
field
|
|
21
|
-
}, api, OptionComponent) => {
|
|
22
|
-
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
23
|
-
field
|
|
24
|
-
})] : ['', ...(valueOptions || [])];
|
|
25
|
-
return iterableColumnValues.map(option => {
|
|
26
|
-
const isOptionTypeObject = typeof option === 'object';
|
|
27
|
-
const key = isOptionTypeObject ? option.value : option;
|
|
28
|
-
const value = isOptionTypeObject ? option.value : option;
|
|
29
|
-
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
30
|
-
value: option,
|
|
31
|
-
field,
|
|
32
|
-
api
|
|
33
|
-
}) : option;
|
|
34
|
-
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
35
|
-
return /*#__PURE__*/_jsx(OptionComponent, {
|
|
36
|
-
value: value,
|
|
37
|
-
children: content
|
|
38
|
-
}, key);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
10
|
export const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
42
11
|
function GridFilterInputValue(props) {
|
|
43
12
|
const {
|
|
@@ -48,44 +17,25 @@ function GridFilterInputValue(props) {
|
|
|
48
17
|
focusElementRef
|
|
49
18
|
} = props,
|
|
50
19
|
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
51
|
-
if (process.env.NODE_ENV !== 'production' && ['date', 'datetime-local', 'singleSelect'].includes(type) && !warnedOnce[type]) {
|
|
52
|
-
warnDeprecatedTypeSupport(type);
|
|
53
|
-
}
|
|
54
20
|
const filterTimeout = React.useRef();
|
|
55
21
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
56
22
|
const [applying, setIsApplying] = React.useState(false);
|
|
57
23
|
const id = useId();
|
|
58
24
|
const rootProps = useGridRootProps();
|
|
59
|
-
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
60
|
-
const isSelectNative = baseSelectProps.native ?? true;
|
|
61
|
-
const singleSelectProps = type === 'singleSelect' ? {
|
|
62
|
-
select: true,
|
|
63
|
-
SelectProps: _extends({
|
|
64
|
-
native: isSelectNative
|
|
65
|
-
}, rootProps.componentsProps?.baseSelect),
|
|
66
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.field), apiRef.current, isSelectNative ? 'option' : MenuItem)
|
|
67
|
-
} : {};
|
|
68
25
|
const onFilterChange = React.useCallback(event => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const column = apiRef.current.getColumn(item.field);
|
|
73
|
-
const columnValueOptions = typeof column.valueOptions === 'function' ? column.valueOptions({
|
|
74
|
-
field: column.field
|
|
75
|
-
}) : column.valueOptions;
|
|
76
|
-
value = getValueFromValueOptions(value, columnValueOptions);
|
|
77
|
-
}
|
|
26
|
+
const {
|
|
27
|
+
value
|
|
28
|
+
} = event.target;
|
|
78
29
|
clearTimeout(filterTimeout.current);
|
|
79
30
|
setFilterValueState(String(value));
|
|
80
31
|
setIsApplying(true);
|
|
81
|
-
// TODO singleSelect doesn't debounce
|
|
82
32
|
filterTimeout.current = setTimeout(() => {
|
|
83
33
|
applyValue(_extends({}, item, {
|
|
84
34
|
value
|
|
85
35
|
}));
|
|
86
36
|
setIsApplying(false);
|
|
87
37
|
}, SUBMIT_FILTER_STROKE_TIME);
|
|
88
|
-
}, [
|
|
38
|
+
}, [applyValue, item]);
|
|
89
39
|
React.useEffect(() => {
|
|
90
40
|
return () => {
|
|
91
41
|
clearTimeout(filterTimeout.current);
|
|
@@ -111,7 +61,7 @@ function GridFilterInputValue(props) {
|
|
|
111
61
|
shrink: true
|
|
112
62
|
},
|
|
113
63
|
inputRef: focusElementRef
|
|
114
|
-
},
|
|
64
|
+
}, others, rootProps.componentsProps?.baseTextField));
|
|
115
65
|
}
|
|
116
66
|
process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
|
|
117
67
|
// ----------------------------- Warning --------------------------------
|
|
@@ -18,6 +18,18 @@ function writeToClipboardPolyfill(data) {
|
|
|
18
18
|
document.body.removeChild(span);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
function hasNativeSelection(element) {
|
|
22
|
+
if (window.getSelection()?.toString() !== '') {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (!element) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
21
33
|
|
|
22
34
|
/**
|
|
23
35
|
* @requires useGridCsvExport (method)
|
|
@@ -50,7 +62,7 @@ export const useGridClipboard = apiRef => {
|
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
// Do nothing if there's a native selection
|
|
53
|
-
if (
|
|
65
|
+
if (hasNativeSelection(event.target)) {
|
|
54
66
|
return;
|
|
55
67
|
}
|
|
56
68
|
apiRef.current.unstable_copySelectedRowsToClipboard(event.altKey);
|
|
@@ -90,6 +90,8 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
90
90
|
// Allow to overflow to not hide the border of the last row
|
|
91
91
|
const gridMain = gridClone.querySelector(`.${gridClasses.main}`);
|
|
92
92
|
gridMain.style.overflow = 'visible';
|
|
93
|
+
// See https://support.google.com/chrome/thread/191619088?hl=en&msgid=193009642
|
|
94
|
+
gridMain.style.contain = 'size';
|
|
93
95
|
const columnHeaders = gridClone.querySelector(`.${gridClasses.columnHeaders}`);
|
|
94
96
|
const columnHeadersInner = columnHeaders.querySelector(`.${gridClasses.columnHeadersInner}`);
|
|
95
97
|
columnHeadersInner.style.width = '100%';
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["style"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as ReactDOM from 'react-dom';
|
|
6
|
-
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
6
|
+
import { unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
7
7
|
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
|
|
8
8
|
import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
9
9
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
@@ -145,7 +145,7 @@ export const useGridVirtualScroller = props => {
|
|
|
145
145
|
lastColumnIndex
|
|
146
146
|
};
|
|
147
147
|
}, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
|
|
148
|
-
|
|
148
|
+
useEnhancedEffect(() => {
|
|
149
149
|
if (disableVirtualization) {
|
|
150
150
|
renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
|
|
151
151
|
} else {
|
|
@@ -154,7 +154,7 @@ export const useGridVirtualScroller = props => {
|
|
|
154
154
|
rootRef.current.scrollTop = 0;
|
|
155
155
|
}
|
|
156
156
|
}, [disableVirtualization]);
|
|
157
|
-
|
|
157
|
+
useEnhancedEffect(() => {
|
|
158
158
|
setContainerDimensions({
|
|
159
159
|
width: rootRef.current.clientWidth,
|
|
160
160
|
height: rootRef.current.clientHeight
|
|
@@ -219,7 +219,7 @@ export const useGridVirtualScroller = props => {
|
|
|
219
219
|
});
|
|
220
220
|
prevRenderContext.current = nextRenderContext;
|
|
221
221
|
}, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
|
|
222
|
-
|
|
222
|
+
useEnhancedEffect(() => {
|
|
223
223
|
if (containerDimensions.width == null) {
|
|
224
224
|
return;
|
|
225
225
|
}
|
package/modern/index.js
CHANGED
|
@@ -164,10 +164,6 @@ DataGridRaw.propTypes = {
|
|
|
164
164
|
* @default "cell"
|
|
165
165
|
*/
|
|
166
166
|
editMode: _propTypes.default.oneOf(['cell', 'row']),
|
|
167
|
-
/**
|
|
168
|
-
* Set the edit rows model of the grid.
|
|
169
|
-
*/
|
|
170
|
-
editRowsModel: _propTypes.default.object,
|
|
171
167
|
/**
|
|
172
168
|
* An error that will turn the grid into its error state and display the error component.
|
|
173
169
|
*/
|
|
@@ -416,12 +412,6 @@ DataGridRaw.propTypes = {
|
|
|
416
412
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
417
413
|
*/
|
|
418
414
|
onColumnVisibilityModelChange: _propTypes.default.func,
|
|
419
|
-
/**
|
|
420
|
-
* Callback fired when the `editRowsModel` changes.
|
|
421
|
-
* @param {GridEditRowsModel} editRowsModel With all properties from [[GridEditRowsModel]].
|
|
422
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
423
|
-
*/
|
|
424
|
-
onEditRowsModelChange: _propTypes.default.func,
|
|
425
415
|
/**
|
|
426
416
|
* Callback fired when an exception is thrown in the grid.
|
|
427
417
|
* @param {any} args The arguments passed to the `showError` call.
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getGridSingleSelectQuickFilterFn = exports.getGridSingleSelectOperators = void 0;
|
|
7
7
|
var _GridFilterInputSingleSelect = require("../components/panel/filterPanel/GridFilterInputSingleSelect");
|
|
8
8
|
var _GridFilterInputMultipleSingleSelect = require("../components/panel/filterPanel/GridFilterInputMultipleSingleSelect");
|
|
9
|
+
var _utils = require("../utils/utils");
|
|
9
10
|
const parseObjectValue = value => {
|
|
10
|
-
if (value == null ||
|
|
11
|
+
if (value == null || !(0, _utils.isObject)(value)) {
|
|
11
12
|
return value;
|
|
12
13
|
}
|
|
13
14
|
return value.value;
|
|
@@ -21,7 +22,7 @@ const getGridSingleSelectQuickFilterFn = (value, column, apiRef) => {
|
|
|
21
22
|
valueFormatter,
|
|
22
23
|
field
|
|
23
24
|
} = column;
|
|
24
|
-
const potentialValues = [parseObjectValue(value)
|
|
25
|
+
const potentialValues = [parseObjectValue(value)?.toString()];
|
|
25
26
|
const iterableColumnValues = typeof valueOptions === 'function' ? valueOptions({
|
|
26
27
|
field
|
|
27
28
|
}) : valueOptions || [];
|
|
@@ -55,7 +56,7 @@ const getGridSingleSelectQuickFilterFn = (value, column, apiRef) => {
|
|
|
55
56
|
return ({
|
|
56
57
|
value: columnValue
|
|
57
58
|
}) => {
|
|
58
|
-
return columnValue != null ? potentialValues.includes(parseObjectValue(columnValue)
|
|
59
|
+
return columnValue != null ? potentialValues.includes(parseObjectValue(columnValue)?.toString()) : false;
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
exports.getGridSingleSelectQuickFilterFn = getGridSingleSelectQuickFilterFn;
|
|
@@ -11,43 +11,12 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
|
-
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
15
14
|
var _icons = require("../../icons");
|
|
16
15
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
17
|
-
var _filterPanelUtils = require("./filterPanelUtils");
|
|
18
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
17
|
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
|
|
20
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
const warnedOnce = {};
|
|
23
|
-
function warnDeprecatedTypeSupport(type) {
|
|
24
|
-
console.warn([`MUI: Using GridFilterInputValue with a "${type}" column is deprecated.`, 'Use GridFilterInputSingleSelect instead.'].join('\n'));
|
|
25
|
-
warnedOnce[type] = true;
|
|
26
|
-
}
|
|
27
|
-
const renderSingleSelectOptions = ({
|
|
28
|
-
valueOptions,
|
|
29
|
-
valueFormatter,
|
|
30
|
-
field
|
|
31
|
-
}, api, OptionComponent) => {
|
|
32
|
-
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
33
|
-
field
|
|
34
|
-
})] : ['', ...(valueOptions || [])];
|
|
35
|
-
return iterableColumnValues.map(option => {
|
|
36
|
-
const isOptionTypeObject = typeof option === 'object';
|
|
37
|
-
const key = isOptionTypeObject ? option.value : option;
|
|
38
|
-
const value = isOptionTypeObject ? option.value : option;
|
|
39
|
-
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
40
|
-
value: option,
|
|
41
|
-
field,
|
|
42
|
-
api
|
|
43
|
-
}) : option;
|
|
44
|
-
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
45
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
46
|
-
value: value,
|
|
47
|
-
children: content
|
|
48
|
-
}, key);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
20
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
52
21
|
exports.SUBMIT_FILTER_STROKE_TIME = SUBMIT_FILTER_STROKE_TIME;
|
|
53
22
|
function GridFilterInputValue(props) {
|
|
@@ -59,44 +28,25 @@ function GridFilterInputValue(props) {
|
|
|
59
28
|
focusElementRef
|
|
60
29
|
} = props,
|
|
61
30
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
62
|
-
if (process.env.NODE_ENV !== 'production' && ['date', 'datetime-local', 'singleSelect'].includes(type) && !warnedOnce[type]) {
|
|
63
|
-
warnDeprecatedTypeSupport(type);
|
|
64
|
-
}
|
|
65
31
|
const filterTimeout = React.useRef();
|
|
66
32
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
67
33
|
const [applying, setIsApplying] = React.useState(false);
|
|
68
34
|
const id = (0, _utils.unstable_useId)();
|
|
69
35
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
70
|
-
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
71
|
-
const isSelectNative = baseSelectProps.native ?? true;
|
|
72
|
-
const singleSelectProps = type === 'singleSelect' ? {
|
|
73
|
-
select: true,
|
|
74
|
-
SelectProps: (0, _extends2.default)({
|
|
75
|
-
native: isSelectNative
|
|
76
|
-
}, rootProps.componentsProps?.baseSelect),
|
|
77
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.field), apiRef.current, isSelectNative ? 'option' : _MenuItem.default)
|
|
78
|
-
} : {};
|
|
79
36
|
const onFilterChange = React.useCallback(event => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const column = apiRef.current.getColumn(item.field);
|
|
84
|
-
const columnValueOptions = typeof column.valueOptions === 'function' ? column.valueOptions({
|
|
85
|
-
field: column.field
|
|
86
|
-
}) : column.valueOptions;
|
|
87
|
-
value = (0, _filterPanelUtils.getValueFromValueOptions)(value, columnValueOptions);
|
|
88
|
-
}
|
|
37
|
+
const {
|
|
38
|
+
value
|
|
39
|
+
} = event.target;
|
|
89
40
|
clearTimeout(filterTimeout.current);
|
|
90
41
|
setFilterValueState(String(value));
|
|
91
42
|
setIsApplying(true);
|
|
92
|
-
// TODO singleSelect doesn't debounce
|
|
93
43
|
filterTimeout.current = setTimeout(() => {
|
|
94
44
|
applyValue((0, _extends2.default)({}, item, {
|
|
95
45
|
value
|
|
96
46
|
}));
|
|
97
47
|
setIsApplying(false);
|
|
98
48
|
}, SUBMIT_FILTER_STROKE_TIME);
|
|
99
|
-
}, [
|
|
49
|
+
}, [applyValue, item]);
|
|
100
50
|
React.useEffect(() => {
|
|
101
51
|
return () => {
|
|
102
52
|
clearTimeout(filterTimeout.current);
|
|
@@ -122,7 +72,7 @@ function GridFilterInputValue(props) {
|
|
|
122
72
|
shrink: true
|
|
123
73
|
},
|
|
124
74
|
inputRef: focusElementRef
|
|
125
|
-
},
|
|
75
|
+
}, others, rootProps.componentsProps?.baseTextField));
|
|
126
76
|
}
|
|
127
77
|
process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
|
|
128
78
|
// ----------------------------- Warning --------------------------------
|
|
@@ -26,6 +26,18 @@ function writeToClipboardPolyfill(data) {
|
|
|
26
26
|
document.body.removeChild(span);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
function hasNativeSelection(element) {
|
|
30
|
+
if (window.getSelection()?.toString() !== '') {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (!element) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if ((element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
29
41
|
|
|
30
42
|
/**
|
|
31
43
|
* @requires useGridCsvExport (method)
|
|
@@ -58,7 +70,7 @@ const useGridClipboard = apiRef => {
|
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
// Do nothing if there's a native selection
|
|
61
|
-
if (
|
|
73
|
+
if (hasNativeSelection(event.target)) {
|
|
62
74
|
return;
|
|
63
75
|
}
|
|
64
76
|
apiRef.current.unstable_copySelectedRowsToClipboard(event.altKey);
|
|
@@ -99,6 +99,8 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
99
99
|
// Allow to overflow to not hide the border of the last row
|
|
100
100
|
const gridMain = gridClone.querySelector(`.${_gridClasses.gridClasses.main}`);
|
|
101
101
|
gridMain.style.overflow = 'visible';
|
|
102
|
+
// See https://support.google.com/chrome/thread/191619088?hl=en&msgid=193009642
|
|
103
|
+
gridMain.style.contain = 'size';
|
|
102
104
|
const columnHeaders = gridClone.querySelector(`.${_gridClasses.gridClasses.columnHeaders}`);
|
|
103
105
|
const columnHeadersInner = columnHeaders.querySelector(`.${_gridClasses.gridClasses.columnHeadersInner}`);
|
|
104
106
|
columnHeadersInner.style.width = '100%';
|
|
@@ -155,7 +155,7 @@ const useGridVirtualScroller = props => {
|
|
|
155
155
|
lastColumnIndex
|
|
156
156
|
};
|
|
157
157
|
}, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerDimensions]);
|
|
158
|
-
|
|
158
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
159
159
|
if (disableVirtualization) {
|
|
160
160
|
renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
|
|
161
161
|
} else {
|
|
@@ -164,7 +164,7 @@ const useGridVirtualScroller = props => {
|
|
|
164
164
|
rootRef.current.scrollTop = 0;
|
|
165
165
|
}
|
|
166
166
|
}, [disableVirtualization]);
|
|
167
|
-
|
|
167
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
168
168
|
setContainerDimensions({
|
|
169
169
|
width: rootRef.current.clientWidth,
|
|
170
170
|
height: rootRef.current.clientHeight
|
|
@@ -229,7 +229,7 @@ const useGridVirtualScroller = props => {
|
|
|
229
229
|
});
|
|
230
230
|
prevRenderContext.current = nextRenderContext;
|
|
231
231
|
}, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
|
|
232
|
-
|
|
232
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
233
233
|
if (containerDimensions.width == null) {
|
|
234
234
|
return;
|
|
235
235
|
}
|
package/node/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GridRowModes = exports.GridEditModes = exports.GridCellModes = void 0;
|
|
7
|
-
// TODO v6: rename to GridEditingState
|
|
8
7
|
var GridEditModes;
|
|
9
8
|
exports.GridEditModes = GridEditModes;
|
|
10
9
|
(function (GridEditModes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.14",
|
|
4
4
|
"description": "The community edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"directory": "packages/grid/x-data-grid"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/runtime": "^7.20.
|
|
39
|
-
"@mui/utils": "^5.
|
|
38
|
+
"@babel/runtime": "^7.20.7",
|
|
39
|
+
"@mui/utils": "^5.11.2",
|
|
40
40
|
"clsx": "^1.2.1",
|
|
41
41
|
"prop-types": "^15.8.1",
|
|
42
42
|
"reselect": "^4.1.7"
|
package/utils/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function isNumber(value: any): value is number;
|
|
2
2
|
export declare function isFunction(value: any): value is Function;
|
|
3
|
-
export declare function isObject(value: any): value is
|
|
3
|
+
export declare function isObject<TObject = Record<string, any>>(value: any): value is TObject;
|
|
4
4
|
export declare function localStorageAvailable(): boolean;
|
|
5
5
|
export declare function escapeRegExp(value: string): string;
|
|
6
6
|
/**
|