@mui/x-data-grid 6.7.0 → 6.8.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 +77 -15
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +23 -69
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/index.d.ts +2 -1
- package/components/cell/index.js +1 -1
- package/components/containers/GridRootStyles.js +30 -16
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/virtualization/GridVirtualScroller.js +4 -9
- package/components/virtualization/GridVirtualScrollerContent.js +11 -20
- package/constants/defaultGridSlotsComponents.js +6 -2
- package/hooks/core/useGridApiInitialization.js +4 -1
- package/hooks/core/useGridStateInitialization.js +2 -9
- package/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
- package/hooks/features/filter/gridFilterUtils.js +19 -13
- package/hooks/features/filter/useGridFilter.js +2 -1
- package/hooks/features/focus/useGridFocus.js +9 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
- package/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridSelector.d.ts +3 -1
- package/hooks/utils/useGridSelector.js +37 -6
- package/hooks/utils/useLazyRef.d.ts +2 -0
- package/hooks/utils/useLazyRef.js +9 -0
- package/hooks/utils/useOnMount.d.ts +2 -0
- package/hooks/utils/useOnMount.js +7 -0
- package/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +25 -69
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/index.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +20 -17
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/legacy/components/toolbar/GridToolbar.js +2 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
- package/legacy/constants/defaultGridSlotsComponents.js +6 -2
- package/legacy/hooks/core/useGridApiInitialization.js +4 -1
- package/legacy/hooks/core/useGridStateInitialization.js +2 -7
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +2 -1
- package/legacy/hooks/features/focus/useGridFocus.js +9 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +38 -34
- package/legacy/hooks/utils/index.js +1 -1
- package/legacy/hooks/utils/useGridSelector.js +43 -5
- package/legacy/hooks/utils/useLazyRef.js +9 -0
- package/legacy/hooks/utils/useOnMount.js +7 -0
- package/legacy/index.js +1 -1
- package/legacy/locales/elGR.js +70 -79
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/doesSupportPreventScroll.js +13 -0
- package/legacy/utils/fastMemo.js +5 -0
- package/legacy/utils/fastObjectShallowCompare.js +32 -0
- package/legacy/utils/keyboardUtils.js +4 -2
- package/locales/elGR.js +66 -79
- package/models/api/gridCoreApi.d.ts +6 -0
- package/models/colDef/gridColDef.d.ts +4 -3
- package/models/colDef/gridColType.d.ts +3 -1
- package/models/events/gridEventLookup.d.ts +3 -3
- package/modern/components/GridColumnHeaders.js +3 -1
- package/modern/components/GridRow.js +22 -69
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/index.js +1 -1
- package/modern/components/containers/GridRootStyles.js +30 -16
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/virtualization/GridVirtualScroller.js +4 -9
- package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/modern/constants/defaultGridSlotsComponents.js +6 -2
- package/modern/hooks/core/useGridApiInitialization.js +4 -1
- package/modern/hooks/core/useGridStateInitialization.js +2 -9
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
- package/modern/hooks/features/filter/useGridFilter.js +2 -1
- package/modern/hooks/features/focus/useGridFocus.js +8 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridSelector.js +37 -6
- package/modern/hooks/utils/useLazyRef.js +9 -0
- package/modern/hooks/utils/useOnMount.js +7 -0
- package/modern/index.js +1 -1
- package/modern/locales/elGR.js +66 -79
- package/modern/utils/Store.js +24 -0
- package/modern/utils/doesSupportPreventScroll.js +13 -0
- package/modern/utils/fastMemo.js +5 -0
- package/modern/utils/fastObjectShallowCompare.js +32 -0
- package/modern/utils/keyboardUtils.js +4 -2
- package/node/components/GridColumnHeaders.js +4 -2
- package/node/components/GridRow.js +22 -69
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/index.js +17 -10
- package/node/components/containers/GridRootStyles.js +30 -16
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/toolbar/GridToolbar.js +2 -2
- package/node/components/virtualization/GridVirtualScroller.js +4 -9
- package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/node/constants/defaultGridSlotsComponents.js +4 -1
- package/node/hooks/core/useGridApiInitialization.js +4 -1
- package/node/hooks/core/useGridStateInitialization.js +2 -9
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterUtils.js +17 -12
- package/node/hooks/features/filter/useGridFilter.js +2 -1
- package/node/hooks/features/focus/useGridFocus.js +8 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
- package/node/hooks/utils/index.js +14 -10
- package/node/hooks/utils/useGridSelector.js +41 -7
- package/node/hooks/utils/useLazyRef.js +17 -0
- package/node/hooks/utils/useOnMount.js +15 -0
- package/node/index.js +1 -1
- package/node/locales/elGR.js +66 -79
- package/node/utils/Store.js +31 -0
- package/node/utils/doesSupportPreventScroll.js +19 -0
- package/node/utils/fastMemo.js +13 -0
- package/node/utils/fastObjectShallowCompare.js +38 -0
- package/node/utils/keyboardUtils.js +4 -2
- package/package.json +1 -1
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/doesSupportPreventScroll.d.ts +1 -0
- package/utils/doesSupportPreventScroll.js +13 -0
- package/utils/fastMemo.d.ts +1 -0
- package/utils/fastMemo.js +5 -0
- package/utils/fastObjectShallowCompare.d.ts +1 -0
- package/utils/fastObjectShallowCompare.js +32 -0
- package/utils/keyboardUtils.js +4 -2
|
@@ -14,8 +14,8 @@ import { GridToolbarQuickFilter } from './GridToolbarQuickFilter';
|
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
var GridToolbar = /*#__PURE__*/React.forwardRef(function GridToolbar(props, ref) {
|
|
17
|
-
// TODO
|
|
18
|
-
// from
|
|
17
|
+
// TODO v7: think about where export option should be passed.
|
|
18
|
+
// from slotProps={{ toolbarExport: { ...exportOption } }} seems to be more appropriate
|
|
19
19
|
var className = props.className,
|
|
20
20
|
csvOptions = props.csvOptions,
|
|
21
21
|
printOptions = props.printOptions,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className"];
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import clsx from 'clsx';
|
|
6
4
|
import { styled } from '@mui/system';
|
|
@@ -31,14 +29,13 @@ var VirtualScrollerRoot = styled('div', {
|
|
|
31
29
|
}
|
|
32
30
|
});
|
|
33
31
|
var GridVirtualScroller = /*#__PURE__*/React.forwardRef(function GridVirtualScroller(props, ref) {
|
|
34
|
-
var className = props.className,
|
|
35
|
-
other = _objectWithoutProperties(props, _excluded);
|
|
36
32
|
var rootProps = useGridRootProps();
|
|
37
33
|
var classes = useUtilityClasses(rootProps);
|
|
38
34
|
return /*#__PURE__*/_jsx(VirtualScrollerRoot, _extends({
|
|
39
|
-
ref: ref
|
|
40
|
-
|
|
35
|
+
ref: ref
|
|
36
|
+
}, props, {
|
|
37
|
+
className: clsx(classes.root, props.className),
|
|
41
38
|
ownerState: rootProps
|
|
42
|
-
}
|
|
39
|
+
}));
|
|
43
40
|
});
|
|
44
41
|
export { GridVirtualScroller };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "style"];
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import clsx from 'clsx';
|
|
6
4
|
import { styled } from '@mui/system';
|
|
@@ -8,9 +6,8 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
|
8
6
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
9
7
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
10
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
var useUtilityClasses = function useUtilityClasses(
|
|
12
|
-
var classes =
|
|
13
|
-
overflowedContent = ownerState.overflowedContent;
|
|
9
|
+
var useUtilityClasses = function useUtilityClasses(props, overflowedContent) {
|
|
10
|
+
var classes = props.classes;
|
|
14
11
|
var slots = {
|
|
15
12
|
root: ['virtualScrollerContent', overflowedContent && 'virtualScrollerContent--overflowed']
|
|
16
13
|
};
|
|
@@ -24,19 +21,15 @@ var VirtualScrollerContentRoot = styled('div', {
|
|
|
24
21
|
}
|
|
25
22
|
})({});
|
|
26
23
|
var GridVirtualScrollerContent = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerContent(props, ref) {
|
|
27
|
-
var
|
|
28
|
-
style = props.style,
|
|
29
|
-
other = _objectWithoutProperties(props, _excluded);
|
|
24
|
+
var _props$style;
|
|
30
25
|
var rootProps = useGridRootProps();
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
var classes = useUtilityClasses(ownerState);
|
|
26
|
+
var overflowedContent = !rootProps.autoHeight && ((_props$style = props.style) == null ? void 0 : _props$style.minHeight) === 'auto';
|
|
27
|
+
var classes = useUtilityClasses(rootProps, overflowedContent);
|
|
35
28
|
return /*#__PURE__*/_jsx(VirtualScrollerContentRoot, _extends({
|
|
36
|
-
ref: ref
|
|
37
|
-
|
|
38
|
-
ownerState:
|
|
39
|
-
|
|
40
|
-
}
|
|
29
|
+
ref: ref
|
|
30
|
+
}, props, {
|
|
31
|
+
ownerState: rootProps,
|
|
32
|
+
className: clsx(classes.root, props.className)
|
|
33
|
+
}));
|
|
41
34
|
});
|
|
42
35
|
export { GridVirtualScrollerContent };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import {
|
|
2
|
+
import { GridSkeletonCell, GridColumnsPanel, GridFilterPanel, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridColumnHeaderFilterIconButton } from '../components';
|
|
3
|
+
import { GridCellV7 } from '../components/cell/GridCell';
|
|
3
4
|
import { GridColumnHeaders } from '../components/GridColumnHeaders';
|
|
4
5
|
import { GridColumnMenu } from '../components/menu/columnMenu/GridColumnMenu';
|
|
5
6
|
import { GridNoResultsOverlay } from '../components/GridNoResultsOverlay';
|
|
6
7
|
import materialSlots from '../material';
|
|
8
|
+
|
|
9
|
+
// TODO: camelCase these key. It's a private helper now.
|
|
10
|
+
// Remove then need to call `uncapitalizeObjectKeys`.
|
|
7
11
|
export var DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, materialSlots, {
|
|
8
|
-
Cell:
|
|
12
|
+
Cell: GridCellV7,
|
|
9
13
|
SkeletonCell: GridSkeletonCell,
|
|
10
14
|
ColumnHeaderFilterIconButton: GridColumnHeaderFilterIconButton,
|
|
11
15
|
ColumnMenu: GridColumnMenu,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Store } from '../../utils/Store';
|
|
2
3
|
import { useGridApiMethod } from '../utils/useGridApiMethod';
|
|
3
4
|
import { GridSignature } from '../utils/useGridApiEventHandler';
|
|
4
5
|
import { EventManager } from '../../utils/EventManager';
|
|
@@ -37,8 +38,10 @@ var wrapPublicApi = function wrapPublicApi(publicApi) {
|
|
|
37
38
|
export function useGridApiInitialization(inputApiRef, props) {
|
|
38
39
|
var publicApiRef = React.useRef();
|
|
39
40
|
if (!publicApiRef.current) {
|
|
41
|
+
var state = {};
|
|
40
42
|
publicApiRef.current = {
|
|
41
|
-
state:
|
|
43
|
+
state: state,
|
|
44
|
+
store: Store.create(state),
|
|
42
45
|
instanceId: {
|
|
43
46
|
id: globalId
|
|
44
47
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
var _excluded = ["stateId"];
|
|
6
4
|
import * as React from 'react';
|
|
7
5
|
import { GridSignature } from '../utils/useGridApiEventHandler';
|
|
8
6
|
import { useGridApiMethod } from '../utils';
|
|
@@ -13,11 +11,7 @@ export var useGridStateInitialization = function useGridStateInitialization(apiR
|
|
|
13
11
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
14
12
|
rawForceUpdate = _React$useState2[1];
|
|
15
13
|
var registerControlState = React.useCallback(function (controlStateItem) {
|
|
16
|
-
|
|
17
|
-
others = _objectWithoutProperties(controlStateItem, _excluded);
|
|
18
|
-
controlStateMapRef.current[stateId] = _extends({}, others, {
|
|
19
|
-
stateId: stateId
|
|
20
|
-
});
|
|
14
|
+
controlStateMapRef.current[controlStateItem.stateId] = controlStateItem;
|
|
21
15
|
}, []);
|
|
22
16
|
var setState = React.useCallback(function (state, reason) {
|
|
23
17
|
var newState;
|
|
@@ -64,6 +58,7 @@ export var useGridStateInitialization = function useGridStateInitialization(apiR
|
|
|
64
58
|
if (apiRef.current.publishEvent) {
|
|
65
59
|
apiRef.current.publishEvent('stateChange', newState);
|
|
66
60
|
}
|
|
61
|
+
apiRef.current.store.update(newState);
|
|
67
62
|
}
|
|
68
63
|
if (updatedControlStateIds.length === 1) {
|
|
69
64
|
var _updatedControlStateI = updatedControlStateIds[0],
|
|
@@ -55,10 +55,7 @@ export var useGridClipboard = function useGridClipboard(apiRef, props) {
|
|
|
55
55
|
var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
|
|
56
56
|
var clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
57
57
|
var handleCopy = React.useCallback(function (event) {
|
|
58
|
-
|
|
59
|
-
// event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
|
|
60
|
-
// be wrong with a Dvorak keyboard (as if pressing J).
|
|
61
|
-
if (String.fromCharCode(event.keyCode) !== 'C' || !isModifierKeyPressed) {
|
|
58
|
+
if (!((event.ctrlKey || event.metaKey) && event.key === 'c')) {
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
64
61
|
|
|
@@ -11,7 +11,7 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
|
11
11
|
import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
|
|
12
12
|
import { getFirstColumnIndexToRender, getTotalHeaderHeight } from '../columns/gridColumnsUtils';
|
|
13
13
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
14
|
-
import { getRenderableIndexes } from '../virtualization/useGridVirtualScroller';
|
|
14
|
+
import { areRenderContextsEqual, getRenderableIndexes } from '../virtualization/useGridVirtualScroller';
|
|
15
15
|
import { GridColumnGroupHeader } from '../../../components/columnHeaders/GridColumnGroupHeader';
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
var GridColumnHeaderRow = styled('div', {
|
|
@@ -62,12 +62,18 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
62
62
|
var _React$useState5 = React.useState(null),
|
|
63
63
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
64
64
|
renderContext = _React$useState6[0],
|
|
65
|
-
|
|
65
|
+
setRenderContextRaw = _React$useState6[1];
|
|
66
66
|
var prevRenderContext = React.useRef(renderContext);
|
|
67
67
|
var prevScrollLeft = React.useRef(0);
|
|
68
68
|
var currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
69
69
|
var totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
|
|
70
70
|
var headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
|
|
71
|
+
var setRenderContext = React.useCallback(function (nextRenderContext) {
|
|
72
|
+
if (renderContext && nextRenderContext && areRenderContextsEqual(renderContext, nextRenderContext)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setRenderContextRaw(nextRenderContext);
|
|
76
|
+
}, [renderContext]);
|
|
71
77
|
React.useEffect(function () {
|
|
72
78
|
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
73
79
|
}, [apiRef]);
|
|
@@ -150,7 +156,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
150
156
|
if (nextRenderContext && canUpdateInnerPosition) {
|
|
151
157
|
updateInnerPosition(nextRenderContext);
|
|
152
158
|
}
|
|
153
|
-
}, [updateInnerPosition]);
|
|
159
|
+
}, [updateInnerPosition, setRenderContext]);
|
|
154
160
|
var handleColumnResizeStart = React.useCallback(function (params) {
|
|
155
161
|
return setResizeCol(params.field);
|
|
156
162
|
}, []);
|
|
@@ -18,7 +18,7 @@ import { buildWarning } from '../../../utils/warning';
|
|
|
18
18
|
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
19
19
|
import { deepClone } from '../../../utils/utils';
|
|
20
20
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
21
|
-
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
21
|
+
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#server-side-persistence.'], 'error');
|
|
22
22
|
export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
23
23
|
var _React$useState = React.useState({}),
|
|
24
24
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -128,7 +128,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
128
128
|
var id = params.id,
|
|
129
129
|
field = params.field,
|
|
130
130
|
reason = params.reason,
|
|
131
|
-
key = params.key
|
|
131
|
+
key = params.key,
|
|
132
|
+
colDef = params.colDef;
|
|
132
133
|
var startCellEditModeParams = {
|
|
133
134
|
id: id,
|
|
134
135
|
field: field
|
|
@@ -139,7 +140,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
139
140
|
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
140
141
|
startCellEditModeParams.deleteValue = true;
|
|
141
142
|
} else {
|
|
142
|
-
|
|
143
|
+
var initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
144
|
+
startCellEditModeParams.initialValue = initialValue;
|
|
143
145
|
}
|
|
144
146
|
} else if (reason === GridCellEditStartReasons.deleteKeyDown) {
|
|
145
147
|
startCellEditModeParams.deleteValue = true;
|
|
@@ -17,7 +17,8 @@ import { buildWarning } from '../../../utils/warning';
|
|
|
17
17
|
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
18
18
|
import { deepClone } from '../../../utils/utils';
|
|
19
19
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
20
|
-
|
|
20
|
+
import { GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
|
|
21
|
+
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#server-side-persistence.'], 'error');
|
|
21
22
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
22
23
|
var _React$useState = React.useState({}),
|
|
23
24
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -120,6 +121,10 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
120
121
|
reason = GridRowEditStopReasons.enterKeyDown;
|
|
121
122
|
} else if (event.key === 'Tab') {
|
|
122
123
|
var columnFields = gridColumnFieldsSelector(apiRef).filter(function (field) {
|
|
124
|
+
var column = apiRef.current.getColumn(field);
|
|
125
|
+
if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
123
128
|
return apiRef.current.isCellEditable(apiRef.current.getCellParams(params.id, field));
|
|
124
129
|
});
|
|
125
130
|
if (event.shiftKey) {
|
|
@@ -144,8 +149,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
if (reason) {
|
|
147
|
-
var
|
|
148
|
-
var newParams = _extends({}, rowParams, {
|
|
152
|
+
var newParams = _extends({}, apiRef.current.getRowParams(params.id), {
|
|
149
153
|
reason: reason,
|
|
150
154
|
field: params.field
|
|
151
155
|
});
|
|
@@ -172,8 +176,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
172
176
|
_reason = GridRowEditStartReasons.deleteKeyDown;
|
|
173
177
|
}
|
|
174
178
|
if (_reason) {
|
|
175
|
-
var
|
|
176
|
-
var _newParams = _extends({},
|
|
179
|
+
var rowParams = apiRef.current.getRowParams(params.id);
|
|
180
|
+
var _newParams = _extends({}, rowParams, {
|
|
177
181
|
field: params.field,
|
|
178
182
|
key: event.key,
|
|
179
183
|
reason: _reason
|
|
@@ -186,7 +190,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
186
190
|
var id = params.id,
|
|
187
191
|
field = params.field,
|
|
188
192
|
reason = params.reason,
|
|
189
|
-
key = params.key
|
|
193
|
+
key = params.key,
|
|
194
|
+
columns = params.columns;
|
|
190
195
|
var startRowEditModeParams = {
|
|
191
196
|
id: id,
|
|
192
197
|
fieldToFocus: field
|
|
@@ -197,7 +202,10 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
197
202
|
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
198
203
|
startRowEditModeParams.deleteValue = !!field;
|
|
199
204
|
} else {
|
|
200
|
-
|
|
205
|
+
var colDef = columns.find(function (col) {
|
|
206
|
+
return col.field === field;
|
|
207
|
+
});
|
|
208
|
+
startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
201
209
|
}
|
|
202
210
|
} else if (reason === GridRowEditStartReasons.deleteKeyDown) {
|
|
203
211
|
startRowEditModeParams.deleteValue = !!field;
|
|
@@ -208,30 +208,32 @@ export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(
|
|
|
208
208
|
};
|
|
209
209
|
};
|
|
210
210
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var
|
|
225
|
-
var
|
|
211
|
+
var isNotNull = function isNotNull(result) {
|
|
212
|
+
return result != null;
|
|
213
|
+
};
|
|
214
|
+
var filterModelItems = function filterModelItems(cache, apiRef, items) {
|
|
215
|
+
if (!cache.cleanedFilterItems) {
|
|
216
|
+
cache.cleanedFilterItems = items.filter(function (item) {
|
|
217
|
+
return getFilterCallbackFromItem(item, apiRef) !== null;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return cache.cleanedFilterItems;
|
|
221
|
+
};
|
|
222
|
+
export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQuickFilterResults, filterModel, apiRef, cache) {
|
|
223
|
+
var cleanedFilterItems = filterModelItems(cache, apiRef, filterModel.items);
|
|
224
|
+
var cleanedFilterItemResults = allFilterItemResults.filter(isNotNull);
|
|
225
|
+
var cleanedQuickFilterResults = allQuickFilterResults.filter(isNotNull);
|
|
226
226
|
|
|
227
227
|
// get result for filter items model
|
|
228
|
-
if (
|
|
228
|
+
if (cleanedFilterItemResults.length > 0) {
|
|
229
|
+
var _filterModel$logicOpe;
|
|
229
230
|
// Return true if the item pass with one of the rows
|
|
230
231
|
var filterItemPredicate = function filterItemPredicate(item) {
|
|
231
|
-
return
|
|
232
|
+
return cleanedFilterItemResults.some(function (filterItemResult) {
|
|
232
233
|
return filterItemResult[item.id];
|
|
233
234
|
});
|
|
234
235
|
};
|
|
236
|
+
var logicOperator = (_filterModel$logicOpe = filterModel.logicOperator) != null ? _filterModel$logicOpe : getDefaultGridFilterModel().logicOperator;
|
|
235
237
|
if (logicOperator === GridLogicOperator.And) {
|
|
236
238
|
var passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
237
239
|
if (!passesAllFilters) {
|
|
@@ -246,13 +248,15 @@ export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQ
|
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
// get result for quick filter model
|
|
249
|
-
if (
|
|
251
|
+
if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
|
|
252
|
+
var _filterModel$quickFil2;
|
|
250
253
|
// Return true if the item pass with one of the rows
|
|
251
254
|
var quickFilterValuePredicate = function quickFilterValuePredicate(value) {
|
|
252
|
-
return
|
|
255
|
+
return cleanedQuickFilterResults.some(function (quickFilterValueResult) {
|
|
253
256
|
return quickFilterValueResult[value];
|
|
254
257
|
});
|
|
255
258
|
};
|
|
259
|
+
var quickFilterLogicOperator = (_filterModel$quickFil2 = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil2 : getDefaultGridFilterModel().quickFilterLogicOperator;
|
|
256
260
|
if (quickFilterLogicOperator === GridLogicOperator.And) {
|
|
257
261
|
var passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
|
|
258
262
|
if (!passesAllQuickFilterValues) {
|
|
@@ -272,6 +272,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
272
272
|
var tree = gridRowTreeSelector(apiRef);
|
|
273
273
|
var rowIds = tree[GRID_ROOT_GROUP_ID].children;
|
|
274
274
|
var filteredRowsLookup = {};
|
|
275
|
+
var filterCache = {};
|
|
275
276
|
for (var i = 0; i < rowIds.length; i += 1) {
|
|
276
277
|
var rowId = rowIds[i];
|
|
277
278
|
var isRowPassing = void 0;
|
|
@@ -281,7 +282,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
281
282
|
var _params$isRowMatching = params.isRowMatchingFilters(rowId),
|
|
282
283
|
passingFilterItems = _params$isRowMatching.passingFilterItems,
|
|
283
284
|
passingQuickFilterValues = _params$isRowMatching.passingQuickFilterValues;
|
|
284
|
-
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
|
|
285
|
+
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef, filterCache);
|
|
285
286
|
}
|
|
286
287
|
filteredRowsLookup[rowId] = isRowPassing;
|
|
287
288
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_ownerDocument as ownerDocument } from '@mui/utils';
|
|
4
|
+
import { gridClasses } from '../../../constants/gridClasses';
|
|
4
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
6
7
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
@@ -243,20 +244,24 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
243
244
|
}
|
|
244
245
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
245
246
|
}, [apiRef]);
|
|
246
|
-
var focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
247
247
|
var handleColumnGroupHeaderFocus = React.useCallback(function (_ref3, event) {
|
|
248
248
|
var fields = _ref3.fields,
|
|
249
249
|
depth = _ref3.depth;
|
|
250
250
|
if (event.target !== event.currentTarget) {
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
var focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
254
|
+
if (focusedColumnGroup !== null && focusedColumnGroup.depth === depth && fields.includes(focusedColumnGroup.field)) {
|
|
254
255
|
// This group cell has already been focused
|
|
255
256
|
return;
|
|
256
257
|
}
|
|
257
258
|
apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
258
|
-
}, [apiRef
|
|
259
|
-
var handleBlur = React.useCallback(function () {
|
|
259
|
+
}, [apiRef]);
|
|
260
|
+
var handleBlur = React.useCallback(function (_, event) {
|
|
261
|
+
var _event$relatedTarget;
|
|
262
|
+
if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes(gridClasses.columnHeader)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
260
265
|
logger.debug("Clearing focus");
|
|
261
266
|
apiRef.current.setState(function (state) {
|
|
262
267
|
return _extends({}, state, {
|
|
@@ -14,7 +14,6 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
14
14
|
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
15
15
|
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
16
16
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
17
|
-
import { useGridSelector } from '../../utils/useGridSelector';
|
|
18
17
|
import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
|
|
19
18
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
20
19
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
@@ -324,12 +323,12 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
324
323
|
event.preventDefault();
|
|
325
324
|
}
|
|
326
325
|
}, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
|
|
327
|
-
var focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
|
|
328
326
|
var handleColumnGroupHeaderKeyDown = React.useCallback(function (params, event) {
|
|
329
327
|
var dimensions = apiRef.current.getRootDimensions();
|
|
330
328
|
if (!dimensions) {
|
|
331
329
|
return;
|
|
332
330
|
}
|
|
331
|
+
var focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
333
332
|
if (focusedColumnGroup === null) {
|
|
334
333
|
return;
|
|
335
334
|
}
|
|
@@ -409,7 +408,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
409
408
|
if (shouldPreventDefault) {
|
|
410
409
|
event.preventDefault();
|
|
411
410
|
}
|
|
412
|
-
}, [apiRef,
|
|
411
|
+
}, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
413
412
|
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
414
413
|
// Ignore portal
|
|
415
414
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1
9
|
import * as React from 'react';
|
|
2
10
|
import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
|
|
3
11
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
12
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
export var MissingRowIdError = /*#__PURE__*/function (_Error) {
|
|
14
|
+
_inherits(MissingRowIdError, _Error);
|
|
15
|
+
var _super = _createSuper(MissingRowIdError);
|
|
16
|
+
function MissingRowIdError() {
|
|
17
|
+
_classCallCheck(this, MissingRowIdError);
|
|
18
|
+
return _super.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
return _createClass(MissingRowIdError);
|
|
21
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
10
22
|
|
|
11
23
|
/**
|
|
12
24
|
* @requires useGridColumns (method)
|
|
@@ -26,7 +38,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
26
38
|
var getRowParams = React.useCallback(function (id) {
|
|
27
39
|
var row = apiRef.current.getRow(id);
|
|
28
40
|
if (!row) {
|
|
29
|
-
throw new
|
|
41
|
+
throw new MissingRowIdError("No row with id #".concat(id, " found"));
|
|
30
42
|
}
|
|
31
43
|
var params = {
|
|
32
44
|
id: id,
|
|
@@ -39,7 +51,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
39
51
|
var row = apiRef.current.getRow(id);
|
|
40
52
|
var rowNode = apiRef.current.getRowNode(id);
|
|
41
53
|
if (!row || !rowNode) {
|
|
42
|
-
throw new
|
|
54
|
+
throw new MissingRowIdError("No row with id #".concat(id, " found"));
|
|
43
55
|
}
|
|
44
56
|
var cellFocus = gridFocusCellSelector(apiRef);
|
|
45
57
|
var cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
@@ -63,7 +75,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
63
75
|
var row = apiRef.current.getRow(id);
|
|
64
76
|
var rowNode = apiRef.current.getRowNode(id);
|
|
65
77
|
if (!row || !rowNode) {
|
|
66
|
-
throw new
|
|
78
|
+
throw new MissingRowIdError("No row with id #".concat(id, " found"));
|
|
67
79
|
}
|
|
68
80
|
var cellFocus = gridFocusCellSelector(apiRef);
|
|
69
81
|
var cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
@@ -77,7 +89,8 @@ export function useGridParamsApi(apiRef) {
|
|
|
77
89
|
hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
|
|
78
90
|
tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
|
|
79
91
|
value: value,
|
|
80
|
-
formattedValue: value
|
|
92
|
+
formattedValue: value,
|
|
93
|
+
isEditable: false
|
|
81
94
|
};
|
|
82
95
|
if (colDef && colDef.valueFormatter) {
|
|
83
96
|
params.formattedValue = colDef.valueFormatter({
|
|
@@ -92,15 +105,10 @@ export function useGridParamsApi(apiRef) {
|
|
|
92
105
|
}, [apiRef]);
|
|
93
106
|
var getCellValue = React.useCallback(function (id, field) {
|
|
94
107
|
var colDef = apiRef.current.getColumn(field);
|
|
95
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
96
|
-
if (!colDef && !warnedOnceMissingColumn) {
|
|
97
|
-
warnMissingColumn(field);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
108
|
if (!colDef || !colDef.valueGetter) {
|
|
101
109
|
var rowModel = apiRef.current.getRow(id);
|
|
102
110
|
if (!rowModel) {
|
|
103
|
-
throw new
|
|
111
|
+
throw new MissingRowIdError("No row with id #".concat(id, " found"));
|
|
104
112
|
}
|
|
105
113
|
return rowModel[field];
|
|
106
114
|
}
|