@mui/x-data-grid 7.16.0 → 7.18.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 +184 -4
- package/DataGrid/DataGrid.js +11 -1
- package/DataGrid/useDataGridComponent.js +3 -0
- package/DataGrid/useDataGridProps.js +2 -1
- package/colDef/gridStringOperators.js +49 -33
- package/components/GridRow.js +1 -0
- package/components/cell/GridCell.js +30 -5
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +2 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/components/containers/GridRootStyles.js +3 -7
- package/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/constants/gridClasses.d.ts +10 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +4 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/hooks/features/columnResize/useGridColumnResize.js +6 -6
- 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/serializers/csvSerializer.js +1 -1
- package/hooks/features/export/useGridPrintExport.js +2 -1
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/focus/useGridFocus.js +2 -1
- 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/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/useGridRowSpanning.d.ts +27 -0
- package/hooks/features/rows/useGridRowSpanning.js +257 -0
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- 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/useGridSelector.js +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/index.d.ts +0 -1
- package/internals/utils/index.js +1 -2
- package/internals/utils/propValidation.js +1 -1
- package/locales/arSD.js +4 -0
- package/locales/beBY.js +4 -0
- package/locales/bgBG.js +4 -0
- package/locales/csCZ.js +4 -0
- package/locales/daDK.js +4 -0
- package/locales/deDE.js +4 -0
- package/locales/elGR.js +4 -0
- package/locales/esES.js +4 -0
- package/locales/faIR.js +4 -0
- package/locales/fiFI.js +4 -0
- package/locales/frFR.js +4 -0
- package/locales/heIL.js +4 -0
- package/locales/hrHR.js +4 -0
- package/locales/huHU.js +11 -8
- package/locales/isIS.js +4 -0
- package/locales/itIT.js +4 -0
- package/locales/jaJP.js +4 -0
- package/locales/koKR.js +4 -0
- package/locales/nbNO.js +4 -0
- package/locales/nlNL.js +4 -0
- package/locales/nnNO.js +4 -0
- package/locales/plPL.js +4 -0
- package/locales/ptBR.js +4 -0
- package/locales/ptPT.js +4 -0
- package/locales/roRO.js +4 -0
- package/locales/ruRU.js +4 -0
- package/locales/skSK.js +4 -0
- package/locales/svSE.js +4 -0
- package/locales/trTR.js +4 -0
- package/locales/ukUA.js +4 -0
- package/locales/urPK.js +4 -0
- package/locales/viVN.js +4 -0
- package/locales/zhCN.js +4 -0
- package/locales/zhHK.js +4 -0
- package/locales/zhTW.js +4 -0
- package/models/api/gridLocaleTextApi.d.ts +4 -0
- package/models/colDef/gridColDef.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +10 -0
- package/modern/DataGrid/DataGrid.js +11 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -0
- package/modern/DataGrid/useDataGridProps.js +2 -1
- package/modern/colDef/gridStringOperators.js +49 -33
- package/modern/components/GridRow.js +1 -0
- package/modern/components/cell/GridCell.js +30 -5
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/modern/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/modern/components/containers/GridRootStyles.js +3 -7
- package/modern/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +4 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
- 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/serializers/csvSerializer.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +2 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -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/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/sorting/gridSortingUtils.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
- package/modern/hooks/utils/useGridSelector.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/index.js +1 -2
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/arSD.js +4 -0
- package/modern/locales/beBY.js +4 -0
- package/modern/locales/bgBG.js +4 -0
- package/modern/locales/csCZ.js +4 -0
- package/modern/locales/daDK.js +4 -0
- package/modern/locales/deDE.js +4 -0
- package/modern/locales/elGR.js +4 -0
- package/modern/locales/esES.js +4 -0
- package/modern/locales/faIR.js +4 -0
- package/modern/locales/fiFI.js +4 -0
- package/modern/locales/frFR.js +4 -0
- package/modern/locales/heIL.js +4 -0
- package/modern/locales/hrHR.js +4 -0
- package/modern/locales/huHU.js +11 -8
- package/modern/locales/isIS.js +4 -0
- package/modern/locales/itIT.js +4 -0
- package/modern/locales/jaJP.js +4 -0
- package/modern/locales/koKR.js +4 -0
- package/modern/locales/nbNO.js +4 -0
- package/modern/locales/nlNL.js +4 -0
- package/modern/locales/nnNO.js +4 -0
- package/modern/locales/plPL.js +4 -0
- package/modern/locales/ptBR.js +4 -0
- package/modern/locales/ptPT.js +4 -0
- package/modern/locales/roRO.js +4 -0
- package/modern/locales/ruRU.js +4 -0
- package/modern/locales/skSK.js +4 -0
- package/modern/locales/svSE.js +4 -0
- package/modern/locales/trTR.js +4 -0
- package/modern/locales/ukUA.js +4 -0
- package/modern/locales/urPK.js +4 -0
- package/modern/locales/viVN.js +4 -0
- package/modern/locales/zhCN.js +4 -0
- package/modern/locales/zhHK.js +4 -0
- package/modern/locales/zhTW.js +4 -0
- package/modern/utils/createSelector.js +1 -1
- package/modern/utils/domUtils.js +12 -12
- package/node/DataGrid/DataGrid.js +11 -1
- package/node/DataGrid/useDataGridComponent.js +3 -0
- package/node/DataGrid/useDataGridProps.js +2 -1
- package/node/colDef/gridStringOperators.js +49 -33
- package/node/components/GridRow.js +1 -0
- package/node/components/cell/GridCell.js +30 -5
- package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/node/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/node/components/containers/GridRootStyles.js +3 -7
- package/node/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +4 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
- 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/serializers/csvSerializer.js +1 -1
- package/node/hooks/features/export/useGridPrintExport.js +2 -1
- package/node/hooks/features/filter/gridFilterUtils.js +1 -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/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/sorting/gridSortingUtils.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/node/hooks/utils/useGridApiEventHandler.js +0 -1
- package/node/hooks/utils/useGridSelector.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +15 -0
- package/node/internals/utils/index.js +0 -11
- package/node/internals/utils/propValidation.js +1 -1
- package/node/locales/arSD.js +4 -0
- package/node/locales/beBY.js +4 -0
- package/node/locales/bgBG.js +4 -0
- package/node/locales/csCZ.js +4 -0
- package/node/locales/daDK.js +4 -0
- package/node/locales/deDE.js +4 -0
- package/node/locales/elGR.js +4 -0
- package/node/locales/esES.js +4 -0
- package/node/locales/faIR.js +4 -0
- package/node/locales/fiFI.js +4 -0
- package/node/locales/frFR.js +4 -0
- package/node/locales/heIL.js +4 -0
- package/node/locales/hrHR.js +4 -0
- package/node/locales/huHU.js +11 -8
- package/node/locales/isIS.js +4 -0
- package/node/locales/itIT.js +4 -0
- package/node/locales/jaJP.js +4 -0
- package/node/locales/koKR.js +4 -0
- package/node/locales/nbNO.js +4 -0
- package/node/locales/nlNL.js +4 -0
- package/node/locales/nnNO.js +4 -0
- package/node/locales/plPL.js +4 -0
- package/node/locales/ptBR.js +4 -0
- package/node/locales/ptPT.js +4 -0
- package/node/locales/roRO.js +4 -0
- package/node/locales/ruRU.js +4 -0
- package/node/locales/skSK.js +4 -0
- package/node/locales/svSE.js +4 -0
- package/node/locales/trTR.js +4 -0
- package/node/locales/ukUA.js +4 -0
- package/node/locales/urPK.js +4 -0
- package/node/locales/viVN.js +4 -0
- package/node/locales/zhCN.js +4 -0
- package/node/locales/zhHK.js +4 -0
- package/node/locales/zhTW.js +4 -0
- package/node/utils/createSelector.js +1 -1
- package/node/utils/domUtils.js +12 -12
- package/package.json +3 -3
- package/utils/createSelector.js +1 -1
- package/utils/domUtils.d.ts +4 -4
- package/utils/domUtils.js +12 -12
- package/internals/utils/warning.d.ts +0 -2
- package/internals/utils/warning.js +0 -21
- package/modern/internals/utils/warning.js +0 -21
- package/node/internals/utils/warning.js +0 -28
|
@@ -27,6 +27,7 @@ import { useGridColumnSpanning } from "../hooks/features/columns/useGridColumnSp
|
|
|
27
27
|
import { useGridColumnGrouping, columnGroupsStateInitializer } from "../hooks/features/columnGrouping/useGridColumnGrouping.js";
|
|
28
28
|
import { useGridVirtualization, virtualizationStateInitializer } from "../hooks/features/virtualization/index.js";
|
|
29
29
|
import { columnResizeStateInitializer, useGridColumnResize } from "../hooks/features/columnResize/useGridColumnResize.js";
|
|
30
|
+
import { rowSpanningStateInitializer, useGridRowSpanning } from "../hooks/features/rows/useGridRowSpanning.js";
|
|
30
31
|
export const useDataGridComponent = (inputApiRef, props) => {
|
|
31
32
|
const apiRef = useGridInitialization(inputApiRef, props);
|
|
32
33
|
|
|
@@ -48,6 +49,7 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
48
49
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
49
50
|
useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
|
|
50
51
|
useGridInitializeState(filterStateInitializer, apiRef, props);
|
|
52
|
+
useGridInitializeState(rowSpanningStateInitializer, apiRef, props);
|
|
51
53
|
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
52
54
|
useGridInitializeState(columnResizeStateInitializer, apiRef, props);
|
|
53
55
|
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
@@ -59,6 +61,7 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
59
61
|
useGridRowSelection(apiRef, props);
|
|
60
62
|
useGridColumns(apiRef, props);
|
|
61
63
|
useGridRows(apiRef, props);
|
|
64
|
+
useGridRowSpanning(apiRef, props);
|
|
62
65
|
useGridParamsApi(apiRef);
|
|
63
66
|
useGridColumnSpanning(apiRef);
|
|
64
67
|
useGridColumnGrouping(apiRef, props);
|
|
@@ -73,7 +73,8 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
73
73
|
showColumnVerticalBorder: false,
|
|
74
74
|
sortingMode: 'client',
|
|
75
75
|
sortingOrder: ['asc', 'desc', null],
|
|
76
|
-
throttleRowsMs: 0
|
|
76
|
+
throttleRowsMs: 0,
|
|
77
|
+
unstable_rowSpanning: false
|
|
77
78
|
};
|
|
78
79
|
const defaultSlots = DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
|
|
79
80
|
export const useDataGridProps = inProps => {
|
|
@@ -15,34 +15,58 @@ export const getGridStringQuickFilterFn = value => {
|
|
|
15
15
|
return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
const createContainsFilterFn = (disableTrim, negate) => filterItem => {
|
|
19
|
+
if (!filterItem.value) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const trimmedValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
23
|
+
const filterRegex = new RegExp(escapeRegExp(trimmedValue), 'i');
|
|
24
|
+
return value => {
|
|
25
|
+
if (value == null) {
|
|
26
|
+
return negate;
|
|
27
|
+
}
|
|
28
|
+
const matches = filterRegex.test(String(value));
|
|
29
|
+
return negate ? !matches : matches;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const createEqualityFilterFn = (disableTrim, negate) => filterItem => {
|
|
33
|
+
if (!filterItem.value) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const trimmedValue = disableTrim ? filterItem.value : filterItem.value.trim();
|
|
37
|
+
const collator = new Intl.Collator(undefined, {
|
|
38
|
+
sensitivity: 'base',
|
|
39
|
+
usage: 'search'
|
|
40
|
+
});
|
|
41
|
+
return value => {
|
|
42
|
+
if (value == null) {
|
|
43
|
+
return negate;
|
|
44
|
+
}
|
|
45
|
+
const isEqual = collator.compare(trimmedValue, value.toString()) === 0;
|
|
46
|
+
return negate ? !isEqual : isEqual;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const createEmptyFilterFn = negate => () => {
|
|
50
|
+
return value => {
|
|
51
|
+
const isEmpty = value === '' || value == null;
|
|
52
|
+
return negate ? !isEmpty : isEmpty;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
18
55
|
export const getGridStringOperators = (disableTrim = false) => [{
|
|
19
56
|
value: 'contains',
|
|
20
|
-
getApplyFilterFn:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
|
|
26
|
-
return value => {
|
|
27
|
-
return value != null ? filterRegex.test(String(value)) : false;
|
|
28
|
-
};
|
|
29
|
-
},
|
|
57
|
+
getApplyFilterFn: createContainsFilterFn(disableTrim, false),
|
|
58
|
+
InputComponent: GridFilterInputValue
|
|
59
|
+
}, {
|
|
60
|
+
value: 'doesNotContain',
|
|
61
|
+
getApplyFilterFn: createContainsFilterFn(disableTrim, true),
|
|
30
62
|
InputComponent: GridFilterInputValue
|
|
31
63
|
}, {
|
|
32
64
|
value: 'equals',
|
|
33
|
-
getApplyFilterFn:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const collator = new Intl.Collator(undefined, {
|
|
39
|
-
sensitivity: 'base',
|
|
40
|
-
usage: 'search'
|
|
41
|
-
});
|
|
42
|
-
return value => {
|
|
43
|
-
return value != null ? collator.compare(filterItemValue, value.toString()) === 0 : false;
|
|
44
|
-
};
|
|
45
|
-
},
|
|
65
|
+
getApplyFilterFn: createEqualityFilterFn(disableTrim, false),
|
|
66
|
+
InputComponent: GridFilterInputValue
|
|
67
|
+
}, {
|
|
68
|
+
value: 'doesNotEqual',
|
|
69
|
+
getApplyFilterFn: createEqualityFilterFn(disableTrim, true),
|
|
46
70
|
InputComponent: GridFilterInputValue
|
|
47
71
|
}, {
|
|
48
72
|
value: 'startsWith',
|
|
@@ -72,19 +96,11 @@ export const getGridStringOperators = (disableTrim = false) => [{
|
|
|
72
96
|
InputComponent: GridFilterInputValue
|
|
73
97
|
}, {
|
|
74
98
|
value: 'isEmpty',
|
|
75
|
-
getApplyFilterFn: ()
|
|
76
|
-
return value => {
|
|
77
|
-
return value === '' || value == null;
|
|
78
|
-
};
|
|
79
|
-
},
|
|
99
|
+
getApplyFilterFn: createEmptyFilterFn(false),
|
|
80
100
|
requiresFilterValue: false
|
|
81
101
|
}, {
|
|
82
102
|
value: 'isNotEmpty',
|
|
83
|
-
getApplyFilterFn: ()
|
|
84
|
-
return value => {
|
|
85
|
-
return value !== '' && value != null;
|
|
86
|
-
};
|
|
87
|
-
},
|
|
103
|
+
getApplyFilterFn: createEmptyFilterFn(true),
|
|
88
104
|
requiresFilterValue: false
|
|
89
105
|
}, {
|
|
90
106
|
value: 'isAnyOf',
|
|
@@ -338,6 +338,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
338
338
|
height: PropTypes.number.isRequired,
|
|
339
339
|
width: PropTypes.number.isRequired
|
|
340
340
|
}).isRequired,
|
|
341
|
+
groupHeaderHeight: PropTypes.number.isRequired,
|
|
341
342
|
hasScrollX: PropTypes.bool.isRequired,
|
|
342
343
|
hasScrollY: PropTypes.bool.isRequired,
|
|
343
344
|
headerFilterHeight: PropTypes.number.isRequired,
|
|
@@ -7,6 +7,7 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_ownerDocument as ownerDocument, unstable_capitalize as capitalize } from '@mui/utils';
|
|
9
9
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
10
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
11
|
import { doesSupportPreventScroll } from "../../utils/doesSupportPreventScroll.js";
|
|
11
12
|
import { getDataGridUtilityClass, gridClasses } from "../../constants/gridClasses.js";
|
|
12
13
|
import { GridCellModes } from "../../models/index.js";
|
|
@@ -17,6 +18,7 @@ import { gridFocusCellSelector } from "../../hooks/features/focus/gridFocusState
|
|
|
17
18
|
import { MissingRowIdError } from "../../hooks/features/rows/useGridParamsApi.js";
|
|
18
19
|
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from "../../utils/cellBorderUtils.js";
|
|
19
20
|
import { GridPinnedColumnPosition } from "../../hooks/features/columns/gridColumnsInterfaces.js";
|
|
21
|
+
import { gridRowSpanningHiddenCellsSelector, gridRowSpanningSpannedCellsSelector } from "../../hooks/features/rows/gridRowSpanningSelectors.js";
|
|
20
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
23
|
export let PinnedPosition = /*#__PURE__*/function (PinnedPosition) {
|
|
22
24
|
PinnedPosition[PinnedPosition["NONE"] = 0] = "NONE";
|
|
@@ -106,6 +108,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
106
108
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
107
109
|
const apiRef = useGridApiContext();
|
|
108
110
|
const rootProps = useGridRootProps();
|
|
111
|
+
const isRtl = useRtl();
|
|
109
112
|
const field = column.field;
|
|
110
113
|
const cellParams = useGridSelector(apiRef, () => {
|
|
111
114
|
// This is required because `.getCellParams` tries to get the `state.rows.tree` entry
|
|
@@ -126,6 +129,8 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
126
129
|
id: rowId,
|
|
127
130
|
field
|
|
128
131
|
}));
|
|
132
|
+
const hiddenCells = useGridSelector(apiRef, gridRowSpanningHiddenCellsSelector);
|
|
133
|
+
const spannedCells = useGridSelector(apiRef, gridRowSpanningSpannedCellsSelector);
|
|
129
134
|
const {
|
|
130
135
|
cellMode,
|
|
131
136
|
hasFocus,
|
|
@@ -198,6 +203,8 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
198
203
|
propHandler(event);
|
|
199
204
|
}
|
|
200
205
|
}, [apiRef, field, rowId]);
|
|
206
|
+
const isCellRowSpanned = hiddenCells[rowId]?.[field] ?? false;
|
|
207
|
+
const rowSpan = spannedCells[rowId]?.[field] ?? 1;
|
|
201
208
|
const style = React.useMemo(() => {
|
|
202
209
|
if (isNotVisible) {
|
|
203
210
|
return {
|
|
@@ -210,14 +217,21 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
210
217
|
const cellStyle = _extends({
|
|
211
218
|
'--width': `${width}px`
|
|
212
219
|
}, styleProp);
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
const isLeftPinned = pinnedPosition === PinnedPosition.LEFT;
|
|
221
|
+
const isRightPinned = pinnedPosition === PinnedPosition.RIGHT;
|
|
222
|
+
if (isLeftPinned || isRightPinned) {
|
|
223
|
+
let side = isLeftPinned ? 'left' : 'right';
|
|
224
|
+
if (isRtl) {
|
|
225
|
+
side = isLeftPinned ? 'right' : 'left';
|
|
226
|
+
}
|
|
227
|
+
cellStyle[side] = pinnedOffset;
|
|
215
228
|
}
|
|
216
|
-
if (
|
|
217
|
-
cellStyle.
|
|
229
|
+
if (rowSpan > 1) {
|
|
230
|
+
cellStyle.height = `calc(var(--height) * ${rowSpan})`;
|
|
231
|
+
cellStyle.zIndex = 5;
|
|
218
232
|
}
|
|
219
233
|
return cellStyle;
|
|
220
|
-
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
|
|
234
|
+
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition, isRtl, rowSpan]);
|
|
221
235
|
React.useEffect(() => {
|
|
222
236
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
223
237
|
return;
|
|
@@ -237,6 +251,16 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
237
251
|
}
|
|
238
252
|
}
|
|
239
253
|
}, [hasFocus, cellMode, apiRef]);
|
|
254
|
+
if (isCellRowSpanned) {
|
|
255
|
+
return /*#__PURE__*/_jsx("div", {
|
|
256
|
+
"data-colindex": colIndex,
|
|
257
|
+
role: "presentation",
|
|
258
|
+
style: _extends({}, style, {
|
|
259
|
+
minWidth: 'var(--width)',
|
|
260
|
+
maxWidth: 'var(--width)'
|
|
261
|
+
})
|
|
262
|
+
});
|
|
263
|
+
}
|
|
240
264
|
if (cellParams === EMPTY_CELL_PARAMS) {
|
|
241
265
|
return null;
|
|
242
266
|
}
|
|
@@ -297,6 +321,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
297
321
|
"data-colindex": colIndex,
|
|
298
322
|
"aria-colindex": colIndex + 1,
|
|
299
323
|
"aria-colspan": colSpan,
|
|
324
|
+
"aria-rowspan": rowSpan,
|
|
300
325
|
style: style,
|
|
301
326
|
title: title,
|
|
302
327
|
tabIndex: tabIndex,
|
|
@@ -22,14 +22,19 @@ const useUtilityClasses = ownerState => {
|
|
|
22
22
|
showRightBorder,
|
|
23
23
|
showLeftBorder,
|
|
24
24
|
filterItemsCounter,
|
|
25
|
-
pinnedPosition
|
|
25
|
+
pinnedPosition,
|
|
26
|
+
isLastUnpinned,
|
|
27
|
+
isSiblingFocused
|
|
26
28
|
} = ownerState;
|
|
27
29
|
const isColumnSorted = sortDirection != null;
|
|
28
30
|
const isColumnFiltered = filterItemsCounter != null && filterItemsCounter > 0;
|
|
29
31
|
// todo refactor to a prop on col isNumeric or ?? ie: coltype===price wont work
|
|
30
32
|
const isColumnNumeric = colDef.type === 'number';
|
|
31
33
|
const slots = {
|
|
32
|
-
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', pinnedPosition === 'left' && 'columnHeader--pinnedLeft', pinnedPosition === 'right' && 'columnHeader--pinnedRight'
|
|
34
|
+
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', pinnedPosition === 'left' && 'columnHeader--pinnedLeft', pinnedPosition === 'right' && 'columnHeader--pinnedRight',
|
|
35
|
+
// TODO: Remove classes below and restore `:has` selectors when they are supported in jsdom
|
|
36
|
+
// See https://github.com/mui/mui-x/pull/14559
|
|
37
|
+
isLastUnpinned && 'columnHeader--lastUnpinned', isSiblingFocused && 'columnHeader--siblingFocused'],
|
|
33
38
|
draggableContainer: ['columnHeaderDraggableContainer'],
|
|
34
39
|
titleContainer: ['columnHeaderTitleContainer'],
|
|
35
40
|
titleContainerContent: ['columnHeaderTitleContainerContent']
|
|
@@ -209,7 +214,9 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
|
|
|
209
214
|
indexInSection: PropTypes.number.isRequired,
|
|
210
215
|
isDragging: PropTypes.bool.isRequired,
|
|
211
216
|
isLast: PropTypes.bool.isRequired,
|
|
217
|
+
isLastUnpinned: PropTypes.bool.isRequired,
|
|
212
218
|
isResizing: PropTypes.bool.isRequired,
|
|
219
|
+
isSiblingFocused: PropTypes.bool.isRequired,
|
|
213
220
|
pinnedPosition: PropTypes.oneOf(['left', 'right']),
|
|
214
221
|
sectionLength: PropTypes.number.isRequired,
|
|
215
222
|
separatorSide: PropTypes.oneOf(['left', 'right']),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className"];
|
|
3
|
+
const _excluded = ["className", "aria-label"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -31,6 +31,8 @@ const GridColumnHeaderTitleRoot = styled('div', {
|
|
|
31
31
|
lineHeight: 'normal'
|
|
32
32
|
});
|
|
33
33
|
const ColumnHeaderInnerTitle = /*#__PURE__*/React.forwardRef(function ColumnHeaderInnerTitle(props, ref) {
|
|
34
|
+
// Tooltip adds aria-label to the props, which is not needed since the children prop is a string
|
|
35
|
+
// See https://github.com/mui/mui-x/pull/14482
|
|
34
36
|
const {
|
|
35
37
|
className
|
|
36
38
|
} = props,
|
|
@@ -63,8 +63,7 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
|
|
|
63
63
|
role: "columnheader",
|
|
64
64
|
tabIndex: tabIndex,
|
|
65
65
|
"aria-colindex": colIndex + 1,
|
|
66
|
-
"aria-sort": ariaSort
|
|
67
|
-
"aria-label": headerComponent == null ? label : undefined
|
|
66
|
+
"aria-sort": ariaSort
|
|
68
67
|
}, other, {
|
|
69
68
|
children: [/*#__PURE__*/_jsxs("div", _extends({
|
|
70
69
|
className: classes.draggableContainer,
|
|
@@ -280,12 +280,10 @@ export const GridRootStyles = styled('div', {
|
|
|
280
280
|
// - the column has a left or right border
|
|
281
281
|
// - the next column is pinned right and has a left border
|
|
282
282
|
[`& .${c.columnHeader}:focus,
|
|
283
|
-
& .${c.columnHeader}:focus-within,
|
|
284
|
-
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus),
|
|
285
|
-
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus-within),
|
|
286
283
|
& .${c['columnHeader--withLeftBorder']},
|
|
287
284
|
& .${c['columnHeader--withRightBorder']},
|
|
288
|
-
& .${c
|
|
285
|
+
& .${c['columnHeader--siblingFocused']},
|
|
286
|
+
& .${c['virtualScroller--hasScrollX']} .${c['columnHeader--lastUnpinned']},
|
|
289
287
|
& .${c['virtualScroller--hasScrollX']} .${c['columnHeader--last']}
|
|
290
288
|
`]: {
|
|
291
289
|
[`& .${c.columnSeparator}`]: {
|
|
@@ -400,9 +398,7 @@ export const GridRootStyles = styled('div', {
|
|
|
400
398
|
'@media (hover: none)': {
|
|
401
399
|
[`& .${c.columnHeader}`]: columnHeaderStyles,
|
|
402
400
|
[`& .${c.columnHeader}:focus,
|
|
403
|
-
& .${c
|
|
404
|
-
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus),
|
|
405
|
-
& .${c.columnHeader}:has(+ .${c.columnHeader}:focus-within)`]: {
|
|
401
|
+
& .${c['columnHeader--siblingFocused']}`]: {
|
|
406
402
|
[`.${c['columnSeparator--resizable']}`]: {
|
|
407
403
|
color: (t.vars || t).palette.primary.main
|
|
408
404
|
}
|
|
@@ -74,7 +74,7 @@ const FilterFormOperatorInput = styled('div', {
|
|
|
74
74
|
slot: 'FilterFormOperatorInput',
|
|
75
75
|
overridesResolver: (_, styles) => styles.filterFormOperatorInput
|
|
76
76
|
})({
|
|
77
|
-
width:
|
|
77
|
+
width: 150
|
|
78
78
|
});
|
|
79
79
|
const FilterFormValueInput = styled('div', {
|
|
80
80
|
name: 'MuiDataGrid',
|
|
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClasses as generateUtilityClasses, unstable_gen
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -45,7 +45,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
45
45
|
filterPanelInputPlaceholder: 'Filter value',
|
|
46
46
|
// Filter operators text
|
|
47
47
|
filterOperatorContains: 'contains',
|
|
48
|
+
filterOperatorDoesNotContain: 'does not contain',
|
|
48
49
|
filterOperatorEquals: 'equals',
|
|
50
|
+
filterOperatorDoesNotEqual: 'does not equal',
|
|
49
51
|
filterOperatorStartsWith: 'starts with',
|
|
50
52
|
filterOperatorEndsWith: 'ends with',
|
|
51
53
|
filterOperatorIs: 'is',
|
|
@@ -65,7 +67,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
65
67
|
'filterOperator<=': '<=',
|
|
66
68
|
// Header filter operators text
|
|
67
69
|
headerFilterOperatorContains: 'Contains',
|
|
70
|
+
headerFilterOperatorDoesNotContain: 'Does not contain',
|
|
68
71
|
headerFilterOperatorEquals: 'Equals',
|
|
72
|
+
headerFilterOperatorDoesNotEqual: 'Does not equal',
|
|
69
73
|
headerFilterOperatorStartsWith: 'Starts with',
|
|
70
74
|
headerFilterOperatorEndsWith: 'Ends with',
|
|
71
75
|
headerFilterOperatorIs: 'Is',
|
|
@@ -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
|
}
|
|
@@ -157,6 +162,9 @@ export const useGridColumnHeaders = props => {
|
|
|
157
162
|
columnIndex,
|
|
158
163
|
computedWidth: colDef.computedWidth
|
|
159
164
|
});
|
|
165
|
+
const siblingWithBorderingSeparator = pinnedPosition === GridPinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
166
|
+
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
167
|
+
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
160
168
|
columns.push(/*#__PURE__*/_jsx(GridColumnHeaderItem, _extends({}, sortColumnLookup[colDef.field], {
|
|
161
169
|
columnMenuOpen: open,
|
|
162
170
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
@@ -172,7 +180,9 @@ export const useGridColumnHeaders = props => {
|
|
|
172
180
|
style: style,
|
|
173
181
|
indexInSection: i,
|
|
174
182
|
sectionLength: renderedColumns.length,
|
|
175
|
-
gridHasFiller: gridHasFiller
|
|
183
|
+
gridHasFiller: gridHasFiller,
|
|
184
|
+
isLastUnpinned: isLastUnpinned,
|
|
185
|
+
isSiblingFocused: isSiblingFocused
|
|
176
186
|
}, other), colDef.field));
|
|
177
187
|
}
|
|
178
188
|
return getFillers(params, columns, 0);
|
|
@@ -186,18 +196,15 @@ export const useGridColumnHeaders = props => {
|
|
|
186
196
|
children: [leftRenderContext && getColumnHeaders({
|
|
187
197
|
position: GridPinnedColumnPosition.LEFT,
|
|
188
198
|
renderContext: leftRenderContext,
|
|
189
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
190
199
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
191
200
|
}, {
|
|
192
201
|
disableReorder: true
|
|
193
202
|
}), getColumnHeaders({
|
|
194
203
|
renderContext,
|
|
195
|
-
minFirstColumn: pinnedColumns.left.length,
|
|
196
204
|
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
197
205
|
}), rightRenderContext && getColumnHeaders({
|
|
198
206
|
position: GridPinnedColumnPosition.RIGHT,
|
|
199
207
|
renderContext: rightRenderContext,
|
|
200
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
201
208
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
202
209
|
}, {
|
|
203
210
|
disableReorder: true,
|
|
@@ -277,7 +284,7 @@ export const useGridColumnHeaders = props => {
|
|
|
277
284
|
depth: depth,
|
|
278
285
|
isLastColumn: headerInfo.colIndex === visibleColumns.length - headerInfo.fields.length,
|
|
279
286
|
maxDepth: headerGroupingMaxDepth,
|
|
280
|
-
height: dimensions.
|
|
287
|
+
height: dimensions.groupHeaderHeight,
|
|
281
288
|
hasFocus: hasFocus,
|
|
282
289
|
tabIndex: tabIndex,
|
|
283
290
|
pinnedPosition: pinnedPosition,
|
|
@@ -304,7 +311,6 @@ export const useGridColumnHeaders = props => {
|
|
|
304
311
|
params: {
|
|
305
312
|
position: GridPinnedColumnPosition.LEFT,
|
|
306
313
|
renderContext: leftRenderContext,
|
|
307
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
308
314
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
309
315
|
}
|
|
310
316
|
}), getColumnGroupHeaders({
|
|
@@ -317,7 +323,6 @@ export const useGridColumnHeaders = props => {
|
|
|
317
323
|
params: {
|
|
318
324
|
position: GridPinnedColumnPosition.RIGHT,
|
|
319
325
|
renderContext: rightRenderContext,
|
|
320
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
321
326
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
322
327
|
}
|
|
323
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
|
};
|
|
@@ -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
|
|
@@ -5,15 +5,16 @@ const _excluded = ["id", "field"],
|
|
|
5
5
|
_excluded2 = ["id", "field"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
8
9
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
10
|
import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
10
11
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
11
12
|
import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
|
|
12
13
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
|
|
13
|
-
import { warnOnce } from "../../../internals/utils/warning.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);
|
|
@@ -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
|
}
|
|
@@ -5,17 +5,18 @@ const _excluded = ["id"],
|
|
|
5
5
|
_excluded2 = ["id"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
8
9
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
10
|
import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.js";
|
|
10
11
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
11
12
|
import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
|
|
12
13
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
|
|
13
14
|
import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
14
|
-
import { warnOnce } from "../../../internals/utils/warning.js";
|
|
15
15
|
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);
|
|
@@ -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
|
+
};
|