@mui/x-data-grid 7.17.0 → 7.19.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 +208 -5
- package/DataGrid/DataGrid.js +16 -1
- package/DataGrid/useDataGridComponent.js +3 -0
- package/DataGrid/useDataGridProps.js +2 -1
- package/components/GridRow.js +1 -0
- package/components/cell/GridCell.js +33 -9
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridRoot.js +1 -1
- package/components/containers/GridRootStyles.js +32 -23
- package/components/containers/GridToolbarContainer.js +1 -1
- package/components/menu/GridMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/GridPanel.js +1 -1
- package/components/panel/GridPanelContent.js +1 -1
- package/components/panel/GridPanelFooter.js +1 -1
- package/components/panel/GridPanelHeader.js +1 -1
- package/components/panel/GridPanelWrapper.js +1 -1
- package/components/panel/filterPanel/filterPanelUtils.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/components/virtualization/GridBottomContainer.d.ts +1 -1
- package/components/virtualization/GridBottomContainer.js +18 -1
- package/components/virtualization/GridMainContainer.js +3 -1
- package/components/virtualization/GridTopContainer.d.ts +1 -1
- package/components/virtualization/GridTopContainer.js +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/components/virtualization/GridVirtualScroller.js +1 -0
- package/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
- package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -19
- package/hooks/features/editing/useGridRowEditing.js +7 -2
- package/hooks/features/editing/utils.d.ts +2 -0
- package/hooks/features/editing/utils.js +15 -0
- package/hooks/features/export/useGridPrintExport.js +2 -1
- package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
- package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
- package/hooks/features/focus/useGridFocus.js +2 -1
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
- package/hooks/features/keyboardNavigation/utils.d.ts +17 -0
- package/hooks/features/keyboardNavigation/utils.js +58 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +9 -9
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/hooks/features/rowSelection/utils.d.ts +10 -0
- package/hooks/features/rowSelection/utils.js +156 -1
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +4 -0
- package/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +10 -0
- package/hooks/features/rows/gridRowSpanningUtils.js +42 -0
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -14
- package/hooks/features/rows/useGridRowSpanning.d.ts +27 -0
- package/hooks/features/rows/useGridRowSpanning.js +257 -0
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +7 -1
- package/hooks/features/scroll/useGridScroll.js +19 -19
- package/hooks/features/sorting/gridSortingSelector.d.ts +4 -4
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/hooks/utils/useGridApiEventHandler.js +0 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +2 -0
- package/locales/bgBG.js +8 -9
- package/locales/deDE.js +4 -4
- package/locales/frFR.js +4 -4
- package/locales/hrHR.d.ts +1 -1
- package/locales/hrHR.js +69 -46
- package/locales/jaJP.js +1 -2
- package/locales/ptPT.d.ts +1 -1
- package/locales/ptPT.js +4 -4
- package/locales/viVN.js +20 -20
- package/locales/zhHK.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +4 -0
- package/models/gridRowSelectionModel.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +30 -1
- package/modern/DataGrid/DataGrid.js +16 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -0
- package/modern/DataGrid/useDataGridProps.js +2 -1
- package/modern/components/GridRow.js +1 -0
- package/modern/components/cell/GridCell.js +33 -9
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/modern/components/containers/GridRoot.js +1 -1
- package/modern/components/containers/GridRootStyles.js +32 -23
- package/modern/components/containers/GridToolbarContainer.js +1 -1
- package/modern/components/menu/GridMenu.js +1 -1
- package/modern/components/panel/GridPanel.js +1 -1
- package/modern/components/panel/GridPanelContent.js +1 -1
- package/modern/components/panel/GridPanelFooter.js +1 -1
- package/modern/components/panel/GridPanelHeader.js +1 -1
- package/modern/components/panel/GridPanelWrapper.js +1 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/modern/components/virtualization/GridBottomContainer.js +18 -1
- package/modern/components/virtualization/GridMainContainer.js +3 -1
- package/modern/components/virtualization/GridTopContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/modern/components/virtualization/GridVirtualScroller.js +1 -0
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
- package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/modern/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -19
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -2
- package/modern/hooks/features/editing/utils.js +15 -0
- package/modern/hooks/features/export/useGridPrintExport.js +2 -1
- package/modern/hooks/features/focus/useGridFocus.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
- package/modern/hooks/features/keyboardNavigation/utils.js +58 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/modern/hooks/features/rowSelection/utils.js +156 -1
- package/modern/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
- package/modern/hooks/features/rows/gridRowSpanningUtils.js +42 -0
- package/modern/hooks/features/rows/useGridRowSpanning.js +257 -0
- package/modern/hooks/features/rows/useGridRows.js +7 -1
- package/modern/hooks/features/scroll/useGridScroll.js +19 -19
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -0
- package/modern/locales/bgBG.js +8 -9
- package/modern/locales/deDE.js +4 -4
- package/modern/locales/frFR.js +4 -4
- package/modern/locales/hrHR.js +69 -46
- package/modern/locales/jaJP.js +1 -2
- package/modern/locales/ptPT.js +4 -4
- package/modern/locales/viVN.js +20 -20
- package/modern/utils/createSelector.js +6 -0
- package/modern/utils/domUtils.js +12 -12
- package/node/DataGrid/DataGrid.js +16 -1
- package/node/DataGrid/useDataGridComponent.js +3 -0
- package/node/DataGrid/useDataGridProps.js +2 -1
- package/node/components/GridRow.js +1 -0
- package/node/components/cell/GridCell.js +33 -9
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/node/components/containers/GridRoot.js +1 -1
- package/node/components/containers/GridRootStyles.js +32 -23
- package/node/components/containers/GridToolbarContainer.js +1 -1
- package/node/components/menu/GridMenu.js +1 -1
- package/node/components/panel/GridPanel.js +1 -1
- package/node/components/panel/GridPanelContent.js +1 -1
- package/node/components/panel/GridPanelFooter.js +1 -1
- package/node/components/panel/GridPanelHeader.js +1 -1
- package/node/components/panel/GridPanelWrapper.js +1 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/node/components/virtualization/GridBottomContainer.js +18 -1
- package/node/components/virtualization/GridMainContainer.js +3 -1
- package/node/components/virtualization/GridTopContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/node/components/virtualization/GridVirtualScroller.js +1 -0
- package/node/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -11
- package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/node/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/node/hooks/features/editing/useGridCellEditing.js +3 -19
- package/node/hooks/features/editing/useGridRowEditing.js +7 -2
- package/node/hooks/features/editing/utils.js +22 -0
- package/node/hooks/features/export/useGridPrintExport.js +2 -1
- package/node/hooks/features/focus/useGridFocus.js +2 -1
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +16 -53
- package/node/hooks/features/keyboardNavigation/utils.js +68 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +102 -26
- package/node/hooks/features/rowSelection/utils.js +160 -1
- package/node/hooks/features/rows/gridRowSpanningSelectors.js +11 -0
- package/node/hooks/features/rows/gridRowSpanningUtils.js +52 -0
- package/node/hooks/features/rows/useGridRowSpanning.js +267 -0
- package/node/hooks/features/rows/useGridRows.js +7 -1
- package/node/hooks/features/scroll/useGridScroll.js +19 -19
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/node/hooks/utils/useGridApiEventHandler.js +0 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +38 -15
- package/node/locales/bgBG.js +8 -9
- package/node/locales/deDE.js +4 -4
- package/node/locales/frFR.js +4 -4
- package/node/locales/hrHR.js +69 -46
- package/node/locales/jaJP.js +1 -2
- package/node/locales/ptPT.js +4 -4
- package/node/locales/viVN.js +20 -20
- package/node/utils/createSelector.js +6 -0
- package/node/utils/domUtils.js +12 -12
- package/package.json +3 -3
- package/utils/createSelector.js +6 -0
- package/utils/domUtils.d.ts +4 -4
- package/utils/domUtils.js +12 -12
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["field", "id", "
|
|
3
|
+
const _excluded = ["field", "id", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses, unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
7
7
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
8
8
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
10
|
+
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
11
|
+
import { getCheckboxPropsSelector } from "../../hooks/features/rowSelection/utils.js";
|
|
10
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
13
|
const useUtilityClasses = ownerState => {
|
|
12
14
|
const {
|
|
@@ -21,7 +23,6 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
21
23
|
const {
|
|
22
24
|
field,
|
|
23
25
|
id,
|
|
24
|
-
value: isChecked,
|
|
25
26
|
rowNode,
|
|
26
27
|
hasFocus,
|
|
27
28
|
tabIndex
|
|
@@ -69,21 +70,28 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
69
70
|
event.stopPropagation();
|
|
70
71
|
}
|
|
71
72
|
}, []);
|
|
73
|
+
const isSelectable = apiRef.current.isRowSelectable(id);
|
|
74
|
+
const checkboxPropsSelector = getCheckboxPropsSelector(id, rootProps.rowSelectionPropagation?.parents ?? false);
|
|
75
|
+
const {
|
|
76
|
+
isIndeterminate,
|
|
77
|
+
isChecked
|
|
78
|
+
} = useGridSelector(apiRef, checkboxPropsSelector);
|
|
72
79
|
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
|
|
73
80
|
return null;
|
|
74
81
|
}
|
|
75
|
-
const isSelectable = apiRef.current.isRowSelectable(id);
|
|
76
82
|
const label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
|
|
83
|
+
const checked = rootProps.indeterminateCheckboxAction === 'select' ? isChecked && !isIndeterminate : isChecked;
|
|
77
84
|
return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
|
|
78
85
|
ref: handleRef,
|
|
79
86
|
tabIndex: tabIndex,
|
|
80
|
-
checked:
|
|
87
|
+
checked: checked,
|
|
81
88
|
onChange: handleChange,
|
|
82
89
|
className: classes.root,
|
|
83
90
|
inputProps: {
|
|
84
91
|
'aria-label': label
|
|
85
92
|
},
|
|
86
93
|
onKeyDown: handleKeyDown,
|
|
94
|
+
indeterminate: isIndeterminate,
|
|
87
95
|
disabled: !isSelectable,
|
|
88
96
|
touchRippleRef: rippleRef /* FIXME: typing error */
|
|
89
97
|
}, rootProps.slotProps?.baseCheckbox, other));
|
|
@@ -46,7 +46,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
46
46
|
}
|
|
47
47
|
return /*#__PURE__*/_jsx(GridRootStyles, _extends({
|
|
48
48
|
ref: handleRef,
|
|
49
|
-
className: clsx(
|
|
49
|
+
className: clsx(classes.root, className),
|
|
50
50
|
ownerState: ownerState
|
|
51
51
|
}, other));
|
|
52
52
|
});
|
|
@@ -170,14 +170,28 @@ export const GridRootStyles = styled('div', {
|
|
|
170
170
|
const hoverOpacity = (t.vars || t).palette.action.hoverOpacity;
|
|
171
171
|
const hoverColor = (t.vars || t).palette.action.hover;
|
|
172
172
|
const selectedOpacity = (t.vars || t).palette.action.selectedOpacity;
|
|
173
|
+
const selectedHoverOpacity = t.vars ? `calc(${hoverOpacity} + ${selectedOpacity})` // TODO: Improve type
|
|
174
|
+
: hoverOpacity + selectedOpacity;
|
|
173
175
|
const selectedBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / ${selectedOpacity})` : alpha(t.palette.primary.main, selectedOpacity);
|
|
174
|
-
const selectedHoverBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} /
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
const selectedHoverBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / ${selectedHoverOpacity})` : alpha(t.palette.primary.main, selectedHoverOpacity);
|
|
177
|
+
const blendFn = t.vars ? blendCssVars : blend;
|
|
178
|
+
const getPinnedBackgroundStyles = backgroundColor => ({
|
|
179
|
+
[`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
|
|
180
|
+
backgroundColor,
|
|
181
|
+
'&.Mui-selected': {
|
|
182
|
+
backgroundColor: blendFn(backgroundColor, selectedBackground, selectedOpacity),
|
|
183
|
+
'&:hover': {
|
|
184
|
+
backgroundColor: blendFn(backgroundColor, selectedBackground, selectedHoverOpacity)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
const pinnedBackgroundColor = blendFn(pinnedBackground, hoverColor, hoverOpacity);
|
|
190
|
+
const pinnedHoverStyles = getPinnedBackgroundStyles(pinnedBackgroundColor);
|
|
191
|
+
const pinnedSelectedBackgroundColor = blendFn(pinnedBackground, selectedBackground, selectedOpacity);
|
|
192
|
+
const pinnedSelectedStyles = getPinnedBackgroundStyles(pinnedSelectedBackgroundColor);
|
|
193
|
+
const pinnedSelectedHoverBackgroundColor = blendFn(pinnedBackground, selectedHoverBackground, selectedHoverOpacity);
|
|
194
|
+
const pinnedSelectedHoverStyles = getPinnedBackgroundStyles(pinnedSelectedHoverBackgroundColor);
|
|
181
195
|
const selectedStyles = {
|
|
182
196
|
backgroundColor: selectedBackground,
|
|
183
197
|
'&:hover': {
|
|
@@ -617,24 +631,15 @@ export const GridRootStyles = styled('div', {
|
|
|
617
631
|
[`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
|
|
618
632
|
position: 'sticky',
|
|
619
633
|
zIndex: 3,
|
|
620
|
-
background: 'var(--DataGrid-pinnedBackground)'
|
|
634
|
+
background: 'var(--DataGrid-pinnedBackground)',
|
|
635
|
+
'&.Mui-selected': {
|
|
636
|
+
backgroundColor: pinnedSelectedBackgroundColor
|
|
637
|
+
}
|
|
621
638
|
},
|
|
622
639
|
[`& .${c.virtualScrollerContent} .${c.row}`]: {
|
|
623
|
-
'&:hover':
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
[`&.Mui-selected`]: {
|
|
629
|
-
[`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
|
|
630
|
-
backgroundColor: pinnedSelectedBackground
|
|
631
|
-
},
|
|
632
|
-
'&:hover': {
|
|
633
|
-
[`& .${c['cell--pinnedLeft']}, & .${c['cell--pinnedRight']}`]: {
|
|
634
|
-
backgroundColor: pinnedSelectedHoverBackground
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
640
|
+
'&:hover': pinnedHoverStyles,
|
|
641
|
+
'&.Mui-selected': pinnedSelectedStyles,
|
|
642
|
+
'&.Mui-selected:hover': pinnedSelectedHoverStyles
|
|
638
643
|
},
|
|
639
644
|
[`& .${c.cellOffsetLeft}`]: {
|
|
640
645
|
flex: '0 0 auto',
|
|
@@ -747,4 +752,8 @@ function blend(background, overlay, opacity, gamma = 1) {
|
|
|
747
752
|
type: 'rgb',
|
|
748
753
|
values: rgb
|
|
749
754
|
});
|
|
755
|
+
}
|
|
756
|
+
const removeOpacity = color => `rgb(from ${color} r g b / 1)`;
|
|
757
|
+
function blendCssVars(background, overlay, opacity) {
|
|
758
|
+
return `color-mix(in srgb,${background}, ${removeOpacity(overlay)} calc(${opacity} * 100%))`;
|
|
750
759
|
}
|
|
@@ -44,7 +44,7 @@ const GridToolbarContainer = /*#__PURE__*/React.forwardRef(function GridToolbarC
|
|
|
44
44
|
}
|
|
45
45
|
return /*#__PURE__*/_jsx(GridToolbarContainerRoot, _extends({
|
|
46
46
|
ref: ref,
|
|
47
|
-
className: clsx(
|
|
47
|
+
className: clsx(classes.root, className),
|
|
48
48
|
ownerState: rootProps
|
|
49
49
|
}, other, {
|
|
50
50
|
children: children
|
|
@@ -85,7 +85,7 @@ function GridMenu(props) {
|
|
|
85
85
|
};
|
|
86
86
|
return /*#__PURE__*/_jsx(GridMenuRoot, _extends({
|
|
87
87
|
as: rootProps.slots.basePopper,
|
|
88
|
-
className: clsx(
|
|
88
|
+
className: clsx(classes.root, className),
|
|
89
89
|
ownerState: rootProps,
|
|
90
90
|
open: open,
|
|
91
91
|
anchorEl: target,
|
|
@@ -84,7 +84,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
84
84
|
return /*#__PURE__*/_jsx(GridPanelRoot, _extends({
|
|
85
85
|
ref: ref,
|
|
86
86
|
placement: "bottom-start",
|
|
87
|
-
className: clsx(
|
|
87
|
+
className: clsx(classes.panel, className),
|
|
88
88
|
ownerState: rootProps,
|
|
89
89
|
anchorEl: anchorEl,
|
|
90
90
|
modifiers: modifiers
|
|
@@ -37,7 +37,7 @@ function GridPanelContent(props) {
|
|
|
37
37
|
const rootProps = useGridRootProps();
|
|
38
38
|
const classes = useUtilityClasses(rootProps);
|
|
39
39
|
return /*#__PURE__*/_jsx(GridPanelContentRoot, _extends({
|
|
40
|
-
className: clsx(
|
|
40
|
+
className: clsx(classes.root, className),
|
|
41
41
|
ownerState: rootProps
|
|
42
42
|
}, other));
|
|
43
43
|
}
|
|
@@ -37,7 +37,7 @@ function GridPanelFooter(props) {
|
|
|
37
37
|
const rootProps = useGridRootProps();
|
|
38
38
|
const classes = useUtilityClasses(rootProps);
|
|
39
39
|
return /*#__PURE__*/_jsx(GridPanelFooterRoot, _extends({
|
|
40
|
-
className: clsx(
|
|
40
|
+
className: clsx(classes.root, className),
|
|
41
41
|
ownerState: rootProps
|
|
42
42
|
}, other));
|
|
43
43
|
}
|
|
@@ -35,7 +35,7 @@ function GridPanelHeader(props) {
|
|
|
35
35
|
const rootProps = useGridRootProps();
|
|
36
36
|
const classes = useUtilityClasses(rootProps);
|
|
37
37
|
return /*#__PURE__*/_jsx(GridPanelHeaderRoot, _extends({
|
|
38
|
-
className: clsx(
|
|
38
|
+
className: clsx(classes.root, className),
|
|
39
39
|
ownerState: rootProps
|
|
40
40
|
}, other));
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ const GridPanelWrapper = /*#__PURE__*/React.forwardRef(function GridPanelWrapper
|
|
|
48
48
|
children: /*#__PURE__*/_jsx(GridPanelWrapperRoot, _extends({
|
|
49
49
|
ref: ref,
|
|
50
50
|
tabIndex: -1,
|
|
51
|
-
className: clsx(
|
|
51
|
+
className: clsx(classes.root, className),
|
|
52
52
|
ownerState: rootProps
|
|
53
53
|
}, other))
|
|
54
54
|
}));
|
|
@@ -93,7 +93,7 @@ function GridToolbarQuickFilter(props) {
|
|
|
93
93
|
variant: "standard",
|
|
94
94
|
value: searchValue,
|
|
95
95
|
onChange: handleSearchValueChange,
|
|
96
|
-
className: clsx(
|
|
96
|
+
className: clsx(classes.root, className),
|
|
97
97
|
placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
|
|
98
98
|
"aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
|
|
99
99
|
type: "search"
|
|
@@ -4,6 +4,9 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { styled } from '@mui/system';
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import { gridClasses, getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
7
|
+
import { gridDimensionsSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
8
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
|
+
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
7
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
11
|
const useUtilityClasses = () => {
|
|
9
12
|
const slots = {
|
|
@@ -18,8 +21,22 @@ const Element = styled('div')({
|
|
|
18
21
|
});
|
|
19
22
|
export function GridBottomContainer(props) {
|
|
20
23
|
const classes = useUtilityClasses();
|
|
24
|
+
const apiRef = useGridApiContext();
|
|
25
|
+
const {
|
|
26
|
+
viewportOuterSize,
|
|
27
|
+
minimumSize,
|
|
28
|
+
hasScrollX,
|
|
29
|
+
scrollbarSize
|
|
30
|
+
} = useGridSelector(apiRef, gridDimensionsSelector);
|
|
31
|
+
const scrollHeight = hasScrollX ? scrollbarSize : 0;
|
|
32
|
+
const offset = Math.max(viewportOuterSize.height - minimumSize.height -
|
|
33
|
+
// Subtract scroll height twice to account for GridVirtualScrollerFiller and horizontal scrollbar
|
|
34
|
+
2 * scrollHeight, 0);
|
|
21
35
|
return /*#__PURE__*/_jsx(Element, _extends({}, props, {
|
|
22
|
-
className: clsx(classes.root,
|
|
36
|
+
className: clsx(classes.root, gridClasses['container--bottom']),
|
|
37
|
+
style: {
|
|
38
|
+
transform: `translateY(${offset}px)`
|
|
39
|
+
},
|
|
23
40
|
role: "presentation"
|
|
24
41
|
}));
|
|
25
42
|
}
|
|
@@ -16,7 +16,9 @@ const Element = styled('div', {
|
|
|
16
16
|
})({
|
|
17
17
|
flexGrow: 1,
|
|
18
18
|
position: 'relative',
|
|
19
|
-
overflow: 'hidden'
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column'
|
|
20
22
|
});
|
|
21
23
|
export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
22
24
|
const rootProps = useGridRootProps();
|
|
@@ -19,7 +19,7 @@ const Element = styled('div')({
|
|
|
19
19
|
export function GridTopContainer(props) {
|
|
20
20
|
const classes = useUtilityClasses();
|
|
21
21
|
return /*#__PURE__*/_jsx(Element, _extends({}, props, {
|
|
22
|
-
className: clsx(classes.root,
|
|
22
|
+
className: clsx(classes.root, gridClasses['container--top']),
|
|
23
23
|
role: "presentation"
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -21,9 +21,6 @@ const Scrollbar = styled('div')({
|
|
|
21
21
|
position: 'absolute',
|
|
22
22
|
display: 'inline-block',
|
|
23
23
|
zIndex: 6,
|
|
24
|
-
'& > div': {
|
|
25
|
-
display: 'inline-block'
|
|
26
|
-
},
|
|
27
24
|
// In macOS Safari and Gnome Web, scrollbars are overlaid and don't affect the layout. So we consider
|
|
28
25
|
// their size to be 0px throughout all the calculations, but the floating scrollbar container does need
|
|
29
26
|
// to appear and have a real size. We set it to 14px because it seems like an acceptable value and we
|
|
@@ -55,9 +52,6 @@ const ScrollbarHorizontal = styled(Scrollbar)({
|
|
|
55
52
|
},
|
|
56
53
|
bottom: '0px'
|
|
57
54
|
});
|
|
58
|
-
const Content = styled('div')({
|
|
59
|
-
display: 'inline-block'
|
|
60
|
-
});
|
|
61
55
|
const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualScrollbar(props, ref) {
|
|
62
56
|
const apiRef = useGridPrivateApiContext();
|
|
63
57
|
const rootProps = useGridRootProps();
|
|
@@ -127,7 +121,7 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
127
121
|
className: classes.root,
|
|
128
122
|
tabIndex: -1,
|
|
129
123
|
"aria-hidden": "true",
|
|
130
|
-
children: /*#__PURE__*/_jsx(
|
|
124
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
131
125
|
ref: contentRef,
|
|
132
126
|
className: classes.content
|
|
133
127
|
})
|
|
@@ -44,10 +44,9 @@ function GridVirtualScrollerFiller({
|
|
|
44
44
|
leftPinnedWidth,
|
|
45
45
|
rightPinnedWidth
|
|
46
46
|
} = useGridSelector(apiRef, gridDimensionsSelector);
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
if (height === 0) {
|
|
47
|
+
const height = hasScrollX ? scrollbarSize : 0;
|
|
48
|
+
const needsLastRowBorder = viewportOuterSize.height - minimumSize.height > 0;
|
|
49
|
+
if (height === 0 && !needsLastRowBorder) {
|
|
51
50
|
return null;
|
|
52
51
|
}
|
|
53
52
|
return /*#__PURE__*/_jsxs(Filler, {
|
|
@@ -53,7 +53,7 @@ export const useGridColumnHeaders = props => {
|
|
|
53
53
|
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
54
54
|
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
55
55
|
const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
56
|
-
const offsetLeft = computeOffsetLeft(columnPositions, renderContext,
|
|
56
|
+
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
|
|
57
57
|
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
|
|
58
58
|
React.useEffect(() => {
|
|
59
59
|
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
@@ -83,7 +83,6 @@ export const useGridColumnHeaders = props => {
|
|
|
83
83
|
const getColumnsToRender = params => {
|
|
84
84
|
const {
|
|
85
85
|
renderContext: currentContext = renderContext,
|
|
86
|
-
// TODO: `minFirstColumn` is not used anymore, could be refactored out.
|
|
87
86
|
maxLastColumn = visibleColumns.length
|
|
88
87
|
} = params || {};
|
|
89
88
|
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
@@ -123,16 +122,22 @@ export const useGridColumnHeaders = props => {
|
|
|
123
122
|
computedWidth
|
|
124
123
|
}) => {
|
|
125
124
|
let style;
|
|
126
|
-
|
|
125
|
+
const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
|
|
126
|
+
const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;
|
|
127
|
+
if (isLeftPinned || isRightPinned) {
|
|
127
128
|
const pinnedOffset = getPinnedCellOffset(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
|
|
129
|
+
let side = isLeftPinned ? 'left' : 'right';
|
|
130
|
+
if (isRtl) {
|
|
131
|
+
side = isLeftPinned ? 'right' : 'left';
|
|
132
|
+
}
|
|
128
133
|
if (pinnedPosition === 'left') {
|
|
129
134
|
style = {
|
|
130
|
-
|
|
135
|
+
[side]: pinnedOffset
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
if (pinnedPosition === 'right') {
|
|
134
139
|
style = {
|
|
135
|
-
|
|
140
|
+
[side]: pinnedOffset
|
|
136
141
|
};
|
|
137
142
|
}
|
|
138
143
|
}
|
|
@@ -191,18 +196,15 @@ export const useGridColumnHeaders = props => {
|
|
|
191
196
|
children: [leftRenderContext && getColumnHeaders({
|
|
192
197
|
position: GridPinnedColumnPosition.LEFT,
|
|
193
198
|
renderContext: leftRenderContext,
|
|
194
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
195
199
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
196
200
|
}, {
|
|
197
201
|
disableReorder: true
|
|
198
202
|
}), getColumnHeaders({
|
|
199
203
|
renderContext,
|
|
200
|
-
minFirstColumn: pinnedColumns.left.length,
|
|
201
204
|
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
202
205
|
}), rightRenderContext && getColumnHeaders({
|
|
203
206
|
position: GridPinnedColumnPosition.RIGHT,
|
|
204
207
|
renderContext: rightRenderContext,
|
|
205
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
206
208
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
207
209
|
}, {
|
|
208
210
|
disableReorder: true,
|
|
@@ -282,7 +284,7 @@ export const useGridColumnHeaders = props => {
|
|
|
282
284
|
depth: depth,
|
|
283
285
|
isLastColumn: headerInfo.colIndex === visibleColumns.length - headerInfo.fields.length,
|
|
284
286
|
maxDepth: headerGroupingMaxDepth,
|
|
285
|
-
height: dimensions.
|
|
287
|
+
height: dimensions.groupHeaderHeight,
|
|
286
288
|
hasFocus: hasFocus,
|
|
287
289
|
tabIndex: tabIndex,
|
|
288
290
|
pinnedPosition: pinnedPosition,
|
|
@@ -309,7 +311,6 @@ export const useGridColumnHeaders = props => {
|
|
|
309
311
|
params: {
|
|
310
312
|
position: GridPinnedColumnPosition.LEFT,
|
|
311
313
|
renderContext: leftRenderContext,
|
|
312
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
313
314
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
314
315
|
}
|
|
315
316
|
}), getColumnGroupHeaders({
|
|
@@ -322,7 +323,6 @@ export const useGridColumnHeaders = props => {
|
|
|
322
323
|
params: {
|
|
323
324
|
position: GridPinnedColumnPosition.RIGHT,
|
|
324
325
|
renderContext: rightRenderContext,
|
|
325
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
326
326
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
327
327
|
}
|
|
328
328
|
})]
|
|
@@ -302,13 +302,13 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
302
302
|
}
|
|
303
303
|
refs.groupHeaderElements = findGroupHeaderElementsFromField(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
|
|
304
304
|
refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);
|
|
305
|
-
refs.fillerLeft = findGridElement(apiRef.current, 'filler--pinnedLeft');
|
|
306
|
-
refs.fillerRight = findGridElement(apiRef.current, 'filler--pinnedRight');
|
|
305
|
+
refs.fillerLeft = findGridElement(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
|
|
306
|
+
refs.fillerRight = findGridElement(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
|
|
307
307
|
const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
|
|
308
|
-
refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement);
|
|
309
|
-
refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
|
|
310
|
-
refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
|
|
311
|
-
refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
|
|
308
|
+
refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
309
|
+
refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
310
|
+
refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
311
|
+
refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
312
312
|
resizeDirection.current = getResizeDirection(separator, isRtl);
|
|
313
313
|
initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
|
|
314
314
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import resolveProps from '@mui/utils/resolveProps';
|
|
2
3
|
import { DEFAULT_GRID_COL_TYPE_KEY, GRID_STRING_COL_DEF, getGridDefaultColumnTypes } from "../../../colDef/index.js";
|
|
3
4
|
import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from "./gridColumnsSelector.js";
|
|
4
5
|
import { clamp } from "../../../utils/utils.js";
|
|
@@ -275,9 +276,9 @@ export const createColumnsState = ({
|
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
});
|
|
278
|
-
columnsState.lookup[field] = _extends({},
|
|
279
|
+
columnsState.lookup[field] = resolveProps(existingState, _extends({}, newColumn, {
|
|
279
280
|
hasBeenResized
|
|
280
|
-
});
|
|
281
|
+
}));
|
|
281
282
|
});
|
|
282
283
|
if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
|
|
283
284
|
Object.keys(columnsState.lookup).forEach(field => {
|
|
@@ -29,6 +29,7 @@ const EMPTY_DIMENSIONS = {
|
|
|
29
29
|
hasScrollY: false,
|
|
30
30
|
scrollbarSize: 0,
|
|
31
31
|
headerHeight: 0,
|
|
32
|
+
groupHeaderHeight: 0,
|
|
32
33
|
headerFilterHeight: 0,
|
|
33
34
|
rowWidth: 0,
|
|
34
35
|
rowHeight: 0,
|
|
@@ -55,6 +56,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
55
56
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
56
57
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
57
58
|
const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
59
|
+
const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
58
60
|
const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
59
61
|
const columnsTotalWidth = roundToDecimalPlaces(gridColumnsTotalWidthSelector(apiRef), 6);
|
|
60
62
|
const headersTotalHeight = getTotalHeaderHeight(apiRef, props);
|
|
@@ -175,6 +177,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
175
177
|
hasScrollY,
|
|
176
178
|
scrollbarSize,
|
|
177
179
|
headerHeight,
|
|
180
|
+
groupHeaderHeight,
|
|
178
181
|
headerFilterHeight,
|
|
179
182
|
rowWidth,
|
|
180
183
|
rowHeight,
|
|
@@ -191,7 +194,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
191
194
|
apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
|
|
192
195
|
}
|
|
193
196
|
apiRef.current.updateRenderContext?.();
|
|
194
|
-
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
197
|
+
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
195
198
|
const apiPublic = {
|
|
196
199
|
resize,
|
|
197
200
|
getRootDimensions
|
|
@@ -14,6 +14,7 @@ import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js
|
|
|
14
14
|
import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
|
|
15
15
|
import { deepClone } from "../../../utils/utils.js";
|
|
16
16
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from "../../../models/params/gridEditCellParams.js";
|
|
17
|
+
import { getDefaultCellValue } from "./utils.js";
|
|
17
18
|
export const useGridCellEditing = (apiRef, props) => {
|
|
18
19
|
const [cellModesModel, setCellModesModel] = React.useState({});
|
|
19
20
|
const cellModesModelRef = React.useRef(cellModesModel);
|
|
@@ -67,7 +68,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
67
68
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
68
69
|
if (params.cellMode === GridCellModes.Edit) {
|
|
69
70
|
// Wait until IME is settled for Asian languages like Japanese and Chinese
|
|
70
|
-
// TODO:
|
|
71
|
+
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
|
|
71
72
|
if (event.which === 229) {
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
@@ -249,24 +250,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
249
250
|
} = params;
|
|
250
251
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
251
252
|
if (deleteValue) {
|
|
252
|
-
|
|
253
|
-
switch (fieldType) {
|
|
254
|
-
case 'boolean':
|
|
255
|
-
newValue = false;
|
|
256
|
-
break;
|
|
257
|
-
case 'date':
|
|
258
|
-
case 'dateTime':
|
|
259
|
-
case 'number':
|
|
260
|
-
newValue = undefined;
|
|
261
|
-
break;
|
|
262
|
-
case 'singleSelect':
|
|
263
|
-
newValue = null;
|
|
264
|
-
break;
|
|
265
|
-
case 'string':
|
|
266
|
-
default:
|
|
267
|
-
newValue = '';
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
253
|
+
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
270
254
|
} else if (initialValue) {
|
|
271
255
|
newValue = initialValue;
|
|
272
256
|
}
|
|
@@ -16,6 +16,7 @@ import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js
|
|
|
16
16
|
import { deepClone } from "../../../utils/utils.js";
|
|
17
17
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from "../../../models/params/gridRowParams.js";
|
|
18
18
|
import { GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
|
|
19
|
+
import { getDefaultCellValue } from "./utils.js";
|
|
19
20
|
export const useGridRowEditing = (apiRef, props) => {
|
|
20
21
|
const [rowModesModel, setRowModesModel] = React.useState({});
|
|
21
22
|
const rowModesModelRef = React.useRef(rowModesModel);
|
|
@@ -109,7 +110,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
109
110
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
110
111
|
if (params.cellMode === GridRowModes.Edit) {
|
|
111
112
|
// Wait until IME is settled for Asian languages like Japanese and Chinese
|
|
112
|
-
// TODO:
|
|
113
|
+
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
|
|
113
114
|
if (event.which === 229) {
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
@@ -319,7 +320,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
319
320
|
}
|
|
320
321
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
321
322
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
322
|
-
|
|
323
|
+
if (deleteValue) {
|
|
324
|
+
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
325
|
+
} else if (initialValue) {
|
|
326
|
+
newValue = initialValue;
|
|
327
|
+
}
|
|
323
328
|
}
|
|
324
329
|
acc[field] = {
|
|
325
330
|
value: newValue,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getDefaultCellValue = colDef => {
|
|
2
|
+
switch (colDef.type) {
|
|
3
|
+
case 'boolean':
|
|
4
|
+
return false;
|
|
5
|
+
case 'date':
|
|
6
|
+
case 'dateTime':
|
|
7
|
+
case 'number':
|
|
8
|
+
return undefined;
|
|
9
|
+
case 'singleSelect':
|
|
10
|
+
return null;
|
|
11
|
+
case 'string':
|
|
12
|
+
default:
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -38,6 +38,7 @@ function buildPrintWindow(title) {
|
|
|
38
38
|
* @requires useGridParamsApi (method)
|
|
39
39
|
*/
|
|
40
40
|
export const useGridPrintExport = (apiRef, props) => {
|
|
41
|
+
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
41
42
|
const logger = useGridLogger(apiRef, 'useGridPrintExport');
|
|
42
43
|
const doc = React.useRef(null);
|
|
43
44
|
const previousGridState = React.useRef(null);
|
|
@@ -46,7 +47,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
46
47
|
const previousVirtualizationState = React.useRef();
|
|
47
48
|
React.useEffect(() => {
|
|
48
49
|
doc.current = ownerDocument(apiRef.current.rootElementRef.current);
|
|
49
|
-
}, [apiRef]);
|
|
50
|
+
}, [apiRef, hasRootReference]);
|
|
50
51
|
|
|
51
52
|
// Returns a promise because updateColumns triggers state update and
|
|
52
53
|
// the new state needs to be in place before the grid can be sized correctly
|
|
@@ -34,6 +34,7 @@ export const focusStateInitializer = state => _extends({}, state, {
|
|
|
34
34
|
export const useGridFocus = (apiRef, props) => {
|
|
35
35
|
const logger = useGridLogger(apiRef, 'useGridFocus');
|
|
36
36
|
const lastClickedCell = React.useRef(null);
|
|
37
|
+
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
37
38
|
const publishCellFocusOut = React.useCallback((cell, event) => {
|
|
38
39
|
if (cell) {
|
|
39
40
|
// The row might have been deleted
|
|
@@ -380,7 +381,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
380
381
|
return () => {
|
|
381
382
|
doc.removeEventListener('mouseup', handleDocumentClick);
|
|
382
383
|
};
|
|
383
|
-
}, [apiRef, handleDocumentClick]);
|
|
384
|
+
}, [apiRef, hasRootReference, handleDocumentClick]);
|
|
384
385
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
385
386
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
386
387
|
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|