@mui/x-data-grid 6.4.0 → 6.5.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 +56 -0
- package/DataGrid/useDataGridProps.js +5 -12
- package/colDef/gridNumericOperators.js +0 -6
- package/components/cell/GridEditInputCell.js +4 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
- package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +2 -1
- package/constants/localeTextConstants.js +26 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +9 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editing/useGridEditing.js +0 -3
- package/hooks/features/focus/gridFocusState.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/hooks/features/focus/useGridFocus.js +55 -9
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/hooks/features/headerFiltering/index.d.ts +1 -0
- package/hooks/features/headerFiltering/index.js +1 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +2 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/hooks/features/rows/useGridRows.js +16 -1
- package/index.js +1 -1
- package/internals/index.d.ts +6 -1
- package/internals/index.js +4 -0
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/internals/utils/useProps.d.ts +8 -0
- package/internals/utils/useProps.js +13 -0
- package/legacy/DataGrid/useDataGridProps.js +8 -8
- package/legacy/colDef/gridNumericOperators.js +0 -6
- package/legacy/components/cell/GridEditInputCell.js +4 -1
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/panel/filterPanel/index.js +2 -1
- package/legacy/constants/localeTextConstants.js +26 -0
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/legacy/hooks/features/editing/useGridEditing.js +0 -3
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +10 -0
- package/legacy/hooks/features/focus/useGridFocus.js +58 -9
- package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
- package/legacy/hooks/features/headerFiltering/index.js +1 -0
- package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
- package/legacy/hooks/features/index.js +2 -1
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/legacy/hooks/features/rows/useGridRows.js +16 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +4 -0
- package/legacy/internals/utils/index.js +2 -1
- package/legacy/internals/utils/useProps.js +11 -0
- package/legacy/locales/arSD.js +28 -0
- package/legacy/locales/beBY.js +28 -0
- package/legacy/locales/bgBG.js +28 -0
- package/legacy/locales/csCZ.js +36 -8
- package/legacy/locales/daDK.js +28 -0
- package/legacy/locales/deDE.js +28 -0
- package/legacy/locales/elGR.js +27 -0
- package/legacy/locales/esES.js +28 -0
- package/legacy/locales/faIR.js +28 -0
- package/legacy/locales/fiFI.js +28 -0
- package/legacy/locales/frFR.js +28 -0
- package/legacy/locales/heIL.js +30 -2
- package/legacy/locales/huHU.js +28 -0
- package/legacy/locales/itIT.js +28 -0
- package/legacy/locales/jaJP.js +28 -0
- package/legacy/locales/koKR.js +28 -0
- package/legacy/locales/nbNO.js +28 -0
- package/legacy/locales/nlNL.js +28 -0
- package/legacy/locales/plPL.js +28 -0
- package/legacy/locales/ptBR.js +28 -0
- package/legacy/locales/roRO.js +28 -0
- package/legacy/locales/ruRU.js +28 -0
- package/legacy/locales/skSK.js +28 -0
- package/legacy/locales/svSE.js +28 -0
- package/legacy/locales/trTR.js +28 -0
- package/legacy/locales/ukUA.js +28 -0
- package/legacy/locales/urPK.js +28 -0
- package/legacy/locales/viVN.js +27 -0
- package/legacy/locales/zhCN.js +28 -0
- package/legacy/locales/zhTW.js +28 -0
- package/legacy/material/index.js +2 -0
- package/legacy/models/api/gridHeaderFilteringApi.js +1 -0
- package/legacy/models/gridHeaderFilteringModel.js +1 -0
- package/legacy/models/index.js +0 -1
- package/locales/arSD.js +28 -0
- package/locales/beBY.js +28 -0
- package/locales/bgBG.js +28 -0
- package/locales/csCZ.js +36 -8
- package/locales/daDK.js +28 -0
- package/locales/deDE.js +28 -0
- package/locales/elGR.js +27 -0
- package/locales/esES.js +28 -0
- package/locales/faIR.js +28 -0
- package/locales/fiFI.js +28 -0
- package/locales/frFR.js +28 -0
- package/locales/heIL.js +30 -2
- package/locales/huHU.js +28 -0
- package/locales/itIT.js +28 -0
- package/locales/jaJP.js +28 -0
- package/locales/koKR.js +28 -0
- package/locales/nbNO.js +28 -0
- package/locales/nlNL.js +28 -0
- package/locales/plPL.js +28 -0
- package/locales/ptBR.js +28 -0
- package/locales/roRO.js +28 -0
- package/locales/ruRU.js +28 -0
- package/locales/skSK.js +28 -0
- package/locales/svSE.js +28 -0
- package/locales/trTR.js +28 -0
- package/locales/ukUA.js +28 -0
- package/locales/urPK.js +28 -0
- package/locales/viVN.js +27 -0
- package/locales/zhCN.js +28 -0
- package/locales/zhTW.js +28 -0
- package/material/index.d.ts +3 -66
- package/material/index.js +2 -0
- package/models/api/gridApiCommon.d.ts +3 -2
- package/models/api/gridCoreApi.d.ts +4 -0
- package/models/api/gridFocusApi.d.ts +6 -0
- package/models/api/gridHeaderFilteringApi.d.ts +30 -0
- package/models/api/gridHeaderFilteringApi.js +1 -0
- package/models/api/gridLocaleTextApi.d.ts +25 -0
- package/models/events/gridEventLookup.d.ts +27 -1
- package/models/gridFilterOperator.d.ts +4 -0
- package/models/gridHeaderFilteringModel.d.ts +5 -0
- package/models/gridHeaderFilteringModel.js +1 -0
- package/models/gridSlotsComponent.d.ts +16 -4
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/index.d.ts +1 -1
- package/models/index.js +0 -1
- package/modern/DataGrid/useDataGridProps.js +5 -12
- package/modern/colDef/gridNumericOperators.js +0 -6
- package/modern/components/cell/GridEditInputCell.js +4 -1
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/panel/filterPanel/index.js +2 -1
- package/modern/constants/localeTextConstants.js +26 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editing/useGridEditing.js +0 -3
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/modern/hooks/features/focus/useGridFocus.js +55 -9
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/modern/hooks/features/headerFiltering/index.js +1 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/modern/hooks/features/rows/useGridRows.js +16 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +4 -0
- package/modern/internals/utils/index.js +2 -1
- package/modern/internals/utils/useProps.js +13 -0
- package/modern/locales/arSD.js +28 -0
- package/modern/locales/beBY.js +28 -0
- package/modern/locales/bgBG.js +28 -0
- package/modern/locales/csCZ.js +36 -8
- package/modern/locales/daDK.js +28 -0
- package/modern/locales/deDE.js +28 -0
- package/modern/locales/elGR.js +27 -0
- package/modern/locales/esES.js +28 -0
- package/modern/locales/faIR.js +28 -0
- package/modern/locales/fiFI.js +28 -0
- package/modern/locales/frFR.js +28 -0
- package/modern/locales/heIL.js +30 -2
- package/modern/locales/huHU.js +28 -0
- package/modern/locales/itIT.js +28 -0
- package/modern/locales/jaJP.js +28 -0
- package/modern/locales/koKR.js +28 -0
- package/modern/locales/nbNO.js +28 -0
- package/modern/locales/nlNL.js +28 -0
- package/modern/locales/plPL.js +28 -0
- package/modern/locales/ptBR.js +28 -0
- package/modern/locales/roRO.js +28 -0
- package/modern/locales/ruRU.js +28 -0
- package/modern/locales/skSK.js +28 -0
- package/modern/locales/svSE.js +28 -0
- package/modern/locales/trTR.js +28 -0
- package/modern/locales/ukUA.js +28 -0
- package/modern/locales/urPK.js +28 -0
- package/modern/locales/viVN.js +27 -0
- package/modern/locales/zhCN.js +28 -0
- package/modern/locales/zhTW.js +28 -0
- package/modern/material/index.js +2 -0
- package/modern/models/api/gridHeaderFilteringApi.js +1 -0
- package/modern/models/gridHeaderFilteringModel.js +1 -0
- package/modern/models/index.js +0 -1
- package/node/DataGrid/useDataGridProps.js +4 -11
- package/node/colDef/gridNumericOperators.js +0 -6
- package/node/components/cell/GridEditInputCell.js +4 -1
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
- package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
- package/node/components/panel/filterPanel/index.js +26 -8
- package/node/constants/localeTextConstants.js +26 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editing/useGridEditing.js +0 -3
- package/node/hooks/features/focus/gridFocusStateSelector.js +9 -1
- package/node/hooks/features/focus/useGridFocus.js +55 -9
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
- package/node/hooks/features/headerFiltering/index.js +16 -0
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/node/hooks/features/rows/useGridRows.js +16 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +46 -0
- package/node/internals/utils/index.js +11 -0
- package/node/internals/utils/useProps.js +22 -0
- package/node/locales/arSD.js +28 -0
- package/node/locales/beBY.js +28 -0
- package/node/locales/bgBG.js +28 -0
- package/node/locales/csCZ.js +36 -8
- package/node/locales/daDK.js +28 -0
- package/node/locales/deDE.js +28 -0
- package/node/locales/elGR.js +27 -0
- package/node/locales/esES.js +28 -0
- package/node/locales/faIR.js +28 -0
- package/node/locales/fiFI.js +28 -0
- package/node/locales/frFR.js +28 -0
- package/node/locales/heIL.js +30 -2
- package/node/locales/huHU.js +28 -0
- package/node/locales/itIT.js +28 -0
- package/node/locales/jaJP.js +28 -0
- package/node/locales/koKR.js +28 -0
- package/node/locales/nbNO.js +28 -0
- package/node/locales/nlNL.js +28 -0
- package/node/locales/plPL.js +28 -0
- package/node/locales/ptBR.js +28 -0
- package/node/locales/roRO.js +28 -0
- package/node/locales/ruRU.js +28 -0
- package/node/locales/skSK.js +28 -0
- package/node/locales/svSE.js +28 -0
- package/node/locales/trTR.js +28 -0
- package/node/locales/ukUA.js +28 -0
- package/node/locales/urPK.js +28 -0
- package/node/locales/viVN.js +27 -0
- package/node/locales/zhCN.js +28 -0
- package/node/locales/zhTW.js +28 -0
- package/node/material/index.js +2 -0
- package/node/models/api/gridHeaderFilteringApi.js +5 -0
- package/node/models/gridHeaderFilteringModel.js +5 -0
- package/node/models/index.js +0 -11
- package/package.json +1 -1
|
@@ -209,4 +209,4 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
209
209
|
*/
|
|
210
210
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
211
211
|
} : void 0;
|
|
212
|
-
export { GridFilterPanel };
|
|
212
|
+
export { GridFilterPanel, getGridFilter };
|
|
@@ -2,7 +2,9 @@ export * from './GridFilterForm';
|
|
|
2
2
|
export * from './GridFilterInputValue';
|
|
3
3
|
export * from './GridFilterInputDate';
|
|
4
4
|
export * from './GridFilterInputSingleSelect';
|
|
5
|
+
export * from './GridFilterInputBoolean';
|
|
5
6
|
export * from './GridFilterInputValueProps';
|
|
6
|
-
export
|
|
7
|
+
export { GridFilterPanel } from './GridFilterPanel';
|
|
8
|
+
export type { GetColumnForNewFilterArgs } from './GridFilterPanel';
|
|
7
9
|
export * from './GridFilterInputMultipleValue';
|
|
8
10
|
export * from './GridFilterInputMultipleSingleSelect';
|
|
@@ -2,7 +2,8 @@ export * from './GridFilterForm';
|
|
|
2
2
|
export * from './GridFilterInputValue';
|
|
3
3
|
export * from './GridFilterInputDate';
|
|
4
4
|
export * from './GridFilterInputSingleSelect';
|
|
5
|
+
export * from './GridFilterInputBoolean';
|
|
5
6
|
export * from './GridFilterInputValueProps';
|
|
6
|
-
export
|
|
7
|
+
export { GridFilterPanel } from './GridFilterPanel';
|
|
7
8
|
export * from './GridFilterInputMultipleValue';
|
|
8
9
|
export * from './GridFilterInputMultipleSingleSelect';
|
|
@@ -58,6 +58,32 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
58
58
|
filterOperatorIsEmpty: 'is empty',
|
|
59
59
|
filterOperatorIsNotEmpty: 'is not empty',
|
|
60
60
|
filterOperatorIsAnyOf: 'is any of',
|
|
61
|
+
'filterOperator=': '=',
|
|
62
|
+
'filterOperator!=': '!=',
|
|
63
|
+
'filterOperator>': '>',
|
|
64
|
+
'filterOperator>=': '>=',
|
|
65
|
+
'filterOperator<': '<',
|
|
66
|
+
'filterOperator<=': '<=',
|
|
67
|
+
// Header filter operators text
|
|
68
|
+
headerFilterOperatorContains: 'Contains',
|
|
69
|
+
headerFilterOperatorEquals: 'Equals',
|
|
70
|
+
headerFilterOperatorStartsWith: 'Starts with',
|
|
71
|
+
headerFilterOperatorEndsWith: 'Ends with',
|
|
72
|
+
headerFilterOperatorIs: 'Is',
|
|
73
|
+
headerFilterOperatorNot: 'Is not',
|
|
74
|
+
headerFilterOperatorAfter: 'Is after',
|
|
75
|
+
headerFilterOperatorOnOrAfter: 'Is on or after',
|
|
76
|
+
headerFilterOperatorBefore: 'Is before',
|
|
77
|
+
headerFilterOperatorOnOrBefore: 'Is on or before',
|
|
78
|
+
headerFilterOperatorIsEmpty: 'Is empty',
|
|
79
|
+
headerFilterOperatorIsNotEmpty: 'Is not empty',
|
|
80
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
81
|
+
'headerFilterOperator=': 'Equals',
|
|
82
|
+
'headerFilterOperator!=': 'Not equals',
|
|
83
|
+
'headerFilterOperator>': 'Is greater than',
|
|
84
|
+
'headerFilterOperator>=': 'Is greater than or equal to',
|
|
85
|
+
'headerFilterOperator<': 'Is less than',
|
|
86
|
+
'headerFilterOperator<=': 'Is less than or equal to',
|
|
61
87
|
// Filter values text
|
|
62
88
|
filterValueAny: 'any',
|
|
63
89
|
filterValueTrue: 'true',
|
|
@@ -25,7 +25,7 @@ export interface UseGridColumnHeadersProps {
|
|
|
25
25
|
columnGroupsHeaderStructure: GridGroupingStructure[][];
|
|
26
26
|
hasOtherElementInTabSequence: boolean;
|
|
27
27
|
}
|
|
28
|
-
interface GetHeadersParams {
|
|
28
|
+
export interface GetHeadersParams {
|
|
29
29
|
renderContext: GridRenderContext | null;
|
|
30
30
|
minFirstColumn?: number;
|
|
31
31
|
maxLastColumn?: number;
|
|
@@ -33,6 +33,13 @@ interface GetHeadersParams {
|
|
|
33
33
|
export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) => {
|
|
34
34
|
renderContext: GridRenderContext | null;
|
|
35
35
|
getColumnHeaders: (params?: GetHeadersParams, other?: {}) => JSX.Element | null;
|
|
36
|
+
getColumnsToRender: (params?: GetHeadersParams) => {
|
|
37
|
+
renderedColumns: GridStateColDef[];
|
|
38
|
+
firstColumnToRender: number;
|
|
39
|
+
lastColumnToRender: number;
|
|
40
|
+
minFirstColumn: number;
|
|
41
|
+
maxLastColumn: number;
|
|
42
|
+
} | null;
|
|
36
43
|
getColumnGroupHeaders: (params?: GetHeadersParams) => JSX.Element[] | null;
|
|
37
44
|
isDragging: boolean;
|
|
38
45
|
getRootProps: (other?: {}) => {
|
|
@@ -46,5 +53,5 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
|
|
|
46
53
|
ref: ((instance: HTMLDivElement | null) => void) | null;
|
|
47
54
|
role: string;
|
|
48
55
|
};
|
|
56
|
+
headerHeight: number;
|
|
49
57
|
};
|
|
50
|
-
export {};
|
|
@@ -263,7 +263,7 @@ export const useGridColumnHeaders = props => {
|
|
|
263
263
|
const tabIndex = columnGroupHeaderTabIndexState !== null && columnGroupHeaderTabIndexState.depth === depth && columnFields.includes(columnGroupHeaderTabIndexState.field) ? 0 : -1;
|
|
264
264
|
const headerInfo = {
|
|
265
265
|
groupId,
|
|
266
|
-
width: columnFields.
|
|
266
|
+
width: columnFields.reduce((acc, field) => acc + apiRef.current.getColumn(field).computedWidth, 0),
|
|
267
267
|
fields: columnFields,
|
|
268
268
|
colIndex: columnIndex,
|
|
269
269
|
hasFocus,
|
|
@@ -319,6 +319,7 @@ export const useGridColumnHeaders = props => {
|
|
|
319
319
|
return {
|
|
320
320
|
renderContext,
|
|
321
321
|
getColumnHeaders,
|
|
322
|
+
getColumnsToRender,
|
|
322
323
|
getColumnGroupHeaders,
|
|
323
324
|
isDragging: !!dragCol,
|
|
324
325
|
getRootProps: (other = {}) => _extends({
|
|
@@ -327,6 +328,7 @@ export const useGridColumnHeaders = props => {
|
|
|
327
328
|
getInnerProps: () => ({
|
|
328
329
|
ref: handleInnerRef,
|
|
329
330
|
role: 'rowgroup'
|
|
330
|
-
})
|
|
331
|
+
}),
|
|
332
|
+
headerHeight
|
|
331
333
|
};
|
|
332
334
|
};
|
|
@@ -155,8 +155,8 @@ export function useGridDimensions(apiRef, props) {
|
|
|
155
155
|
if (!mainEl) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
const height = mainEl.
|
|
159
|
-
const width = mainEl.
|
|
158
|
+
const height = mainEl.clientHeight || 0;
|
|
159
|
+
const width = mainEl.clientWidth || 0;
|
|
160
160
|
const win = ownerWindow(mainEl);
|
|
161
161
|
const computedStyle = win.getComputedStyle(mainEl);
|
|
162
162
|
const paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
@@ -29,9 +29,6 @@ export const useGridEditing = (apiRef, props) => {
|
|
|
29
29
|
if (isCellEditableProp) {
|
|
30
30
|
return isCellEditableProp(params);
|
|
31
31
|
}
|
|
32
|
-
if (params.rowNode.type === 'pinnedRow') {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
32
|
return true;
|
|
36
33
|
}, [isCellEditableProp]);
|
|
37
34
|
const maybeDebounce = (id, field, debounceMs, callback) => {
|
|
@@ -9,10 +9,12 @@ export type GridColumnGroupIdentifier = {
|
|
|
9
9
|
export interface GridFocusState {
|
|
10
10
|
cell: GridCellCoordinates | null;
|
|
11
11
|
columnHeader: GridColumnIdentifier | null;
|
|
12
|
+
columnHeaderFilter: GridColumnIdentifier | null;
|
|
12
13
|
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
13
14
|
}
|
|
14
15
|
export interface GridTabIndexState {
|
|
15
16
|
cell: GridCellCoordinates | null;
|
|
16
17
|
columnHeader: GridColumnIdentifier | null;
|
|
18
|
+
columnHeaderFilter: GridColumnIdentifier | null;
|
|
17
19
|
columnGroupHeader: GridColumnGroupIdentifier | null;
|
|
18
20
|
}
|
|
@@ -3,8 +3,10 @@ import { GridFocusState, GridTabIndexState } from './gridFocusState';
|
|
|
3
3
|
export declare const gridFocusStateSelector: (state: GridStateCommunity) => GridFocusState;
|
|
4
4
|
export declare const gridFocusCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
5
5
|
export declare const gridFocusColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
|
+
export declare const unstable_gridFocusColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
6
7
|
export declare const unstable_gridFocusColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
7
8
|
export declare const gridTabIndexStateSelector: (state: GridStateCommunity) => GridTabIndexState;
|
|
8
9
|
export declare const gridTabIndexCellSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridCellCoordinates | null>;
|
|
9
10
|
export declare const gridTabIndexColumnHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
11
|
+
export declare const unstable_gridTabIndexColumnHeaderFilterSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnIdentifier | null>;
|
|
10
12
|
export declare const unstable_gridTabIndexColumnGroupHeaderSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("./gridFocusState").GridColumnGroupIdentifier | null>;
|
|
@@ -3,11 +3,17 @@ export const gridFocusStateSelector = state => state.focus;
|
|
|
3
3
|
export const gridFocusCellSelector = createSelector(gridFocusStateSelector, focusState => focusState.cell);
|
|
4
4
|
export const gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeader);
|
|
5
5
|
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnHeaderFilter);
|
|
8
|
+
|
|
6
9
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
10
|
export const unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, focusState => focusState.columnGroupHeader);
|
|
8
11
|
export const gridTabIndexStateSelector = state => state.tabIndex;
|
|
9
12
|
export const gridTabIndexCellSelector = createSelector(gridTabIndexStateSelector, state => state.cell);
|
|
10
13
|
export const gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeader);
|
|
11
14
|
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
export const unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, state => state.columnHeaderFilter);
|
|
17
|
+
|
|
12
18
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
19
|
export const unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, state => state.columnGroupHeader);
|
|
@@ -9,15 +9,18 @@ import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } fr
|
|
|
9
9
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
10
10
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
11
|
import { clamp } from '../../../utils/utils';
|
|
12
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
12
13
|
export const focusStateInitializer = state => _extends({}, state, {
|
|
13
14
|
focus: {
|
|
14
15
|
cell: null,
|
|
15
16
|
columnHeader: null,
|
|
17
|
+
columnHeaderFilter: null,
|
|
16
18
|
columnGroupHeader: null
|
|
17
19
|
},
|
|
18
20
|
tabIndex: {
|
|
19
21
|
cell: null,
|
|
20
22
|
columnHeader: null,
|
|
23
|
+
columnHeaderFilter: null,
|
|
21
24
|
columnGroupHeader: null
|
|
22
25
|
}
|
|
23
26
|
});
|
|
@@ -52,6 +55,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
52
55
|
field
|
|
53
56
|
},
|
|
54
57
|
columnHeader: null,
|
|
58
|
+
columnHeaderFilter: null,
|
|
55
59
|
columnGroupHeader: null
|
|
56
60
|
},
|
|
57
61
|
focus: {
|
|
@@ -60,6 +64,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
60
64
|
field
|
|
61
65
|
},
|
|
62
66
|
columnHeader: null,
|
|
67
|
+
columnHeaderFilter: null,
|
|
63
68
|
columnGroupHeader: null
|
|
64
69
|
}
|
|
65
70
|
});
|
|
@@ -87,6 +92,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
87
92
|
columnHeader: {
|
|
88
93
|
field
|
|
89
94
|
},
|
|
95
|
+
columnHeaderFilter: null,
|
|
90
96
|
cell: null,
|
|
91
97
|
columnGroupHeader: null
|
|
92
98
|
},
|
|
@@ -94,6 +100,33 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
94
100
|
columnHeader: {
|
|
95
101
|
field
|
|
96
102
|
},
|
|
103
|
+
columnHeaderFilter: null,
|
|
104
|
+
cell: null,
|
|
105
|
+
columnGroupHeader: null
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
apiRef.current.forceUpdate();
|
|
110
|
+
}, [apiRef, logger, publishCellFocusOut]);
|
|
111
|
+
const setColumnHeaderFilterFocus = React.useCallback((field, event = {}) => {
|
|
112
|
+
const cell = gridFocusCellSelector(apiRef);
|
|
113
|
+
publishCellFocusOut(cell, event);
|
|
114
|
+
apiRef.current.setState(state => {
|
|
115
|
+
logger.debug(`Focusing on column header filter with colIndex=${field}`);
|
|
116
|
+
return _extends({}, state, {
|
|
117
|
+
tabIndex: {
|
|
118
|
+
columnHeader: null,
|
|
119
|
+
columnHeaderFilter: {
|
|
120
|
+
field
|
|
121
|
+
},
|
|
122
|
+
cell: null,
|
|
123
|
+
columnGroupHeader: null
|
|
124
|
+
},
|
|
125
|
+
focus: {
|
|
126
|
+
columnHeader: null,
|
|
127
|
+
columnHeaderFilter: {
|
|
128
|
+
field
|
|
129
|
+
},
|
|
97
130
|
cell: null,
|
|
98
131
|
columnGroupHeader: null
|
|
99
132
|
}
|
|
@@ -114,6 +147,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
114
147
|
depth
|
|
115
148
|
},
|
|
116
149
|
columnHeader: null,
|
|
150
|
+
columnHeaderFilter: null,
|
|
117
151
|
cell: null
|
|
118
152
|
},
|
|
119
153
|
focus: {
|
|
@@ -122,6 +156,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
122
156
|
depth
|
|
123
157
|
},
|
|
124
158
|
columnHeader: null,
|
|
159
|
+
columnHeaderFilter: null,
|
|
125
160
|
cell: null
|
|
126
161
|
}
|
|
127
162
|
});
|
|
@@ -131,8 +166,16 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
131
166
|
const getColumnGroupHeaderFocus = React.useCallback(() => unstable_gridFocusColumnGroupHeaderSelector(apiRef), [apiRef]);
|
|
132
167
|
const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
|
|
133
168
|
let columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
134
|
-
let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
135
169
|
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
170
|
+
const currentPage = getVisibleRows(apiRef, {
|
|
171
|
+
pagination: props.pagination,
|
|
172
|
+
paginationMode: props.paginationMode
|
|
173
|
+
});
|
|
174
|
+
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
175
|
+
|
|
176
|
+
// Include pinned rows as well
|
|
177
|
+
const currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
|
|
178
|
+
let rowIndexToFocus = currentPageRows.findIndex(row => row.id === id);
|
|
136
179
|
if (direction === 'right') {
|
|
137
180
|
columnIndexToFocus += 1;
|
|
138
181
|
} else if (direction === 'left') {
|
|
@@ -140,14 +183,10 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
140
183
|
} else {
|
|
141
184
|
rowIndexToFocus += 1;
|
|
142
185
|
}
|
|
143
|
-
const currentPage = getVisibleRows(apiRef, {
|
|
144
|
-
pagination: props.pagination,
|
|
145
|
-
paginationMode: props.paginationMode
|
|
146
|
-
});
|
|
147
186
|
if (columnIndexToFocus >= visibleColumns.length) {
|
|
148
187
|
// Go to next row if we are after the last column
|
|
149
188
|
rowIndexToFocus += 1;
|
|
150
|
-
if (rowIndexToFocus <
|
|
189
|
+
if (rowIndexToFocus < currentPageRows.length) {
|
|
151
190
|
// Go to first column of the next row if there's one more row
|
|
152
191
|
columnIndexToFocus = 0;
|
|
153
192
|
}
|
|
@@ -159,8 +198,11 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
159
198
|
columnIndexToFocus = visibleColumns.length - 1;
|
|
160
199
|
}
|
|
161
200
|
}
|
|
162
|
-
rowIndexToFocus = clamp(rowIndexToFocus, 0,
|
|
163
|
-
const rowToFocus =
|
|
201
|
+
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPageRows.length - 1);
|
|
202
|
+
const rowToFocus = currentPageRows[rowIndexToFocus];
|
|
203
|
+
if (!rowToFocus) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
164
206
|
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
165
207
|
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
166
208
|
if (direction === 'left' || direction === 'below') {
|
|
@@ -214,6 +256,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
214
256
|
focus: {
|
|
215
257
|
cell: null,
|
|
216
258
|
columnHeader: null,
|
|
259
|
+
columnHeaderFilter: null,
|
|
217
260
|
columnGroupHeader: null
|
|
218
261
|
}
|
|
219
262
|
}));
|
|
@@ -252,6 +295,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
252
295
|
focus: {
|
|
253
296
|
cell: null,
|
|
254
297
|
columnHeader: null,
|
|
298
|
+
columnHeaderFilter: null,
|
|
255
299
|
columnGroupHeader: null
|
|
256
300
|
}
|
|
257
301
|
}));
|
|
@@ -280,6 +324,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
280
324
|
focus: {
|
|
281
325
|
cell: null,
|
|
282
326
|
columnHeader: null,
|
|
327
|
+
columnHeaderFilter: null,
|
|
283
328
|
columnGroupHeader: null
|
|
284
329
|
}
|
|
285
330
|
}));
|
|
@@ -287,7 +332,8 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
287
332
|
}, [apiRef]);
|
|
288
333
|
const focusApi = {
|
|
289
334
|
setCellFocus,
|
|
290
|
-
setColumnHeaderFocus
|
|
335
|
+
setColumnHeaderFocus,
|
|
336
|
+
setColumnHeaderFilterFocus
|
|
291
337
|
};
|
|
292
338
|
const focusPrivateApi = {
|
|
293
339
|
moveFocusToRelativeCell,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
|
+
export declare const unstable_gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
|
|
3
|
+
export declare const unstable_gridHeaderFilteringEditFieldSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
4
|
+
export declare const unstable_gridHeaderFilteringMenuSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { createSelector } from '../../../utils/createSelector';
|
|
3
|
+
export const unstable_gridHeaderFilteringStateSelector = state => state.headerFiltering;
|
|
4
|
+
export const unstable_gridHeaderFilteringEditFieldSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
|
|
5
|
+
export const unstable_gridHeaderFilteringMenuSelector = createSelector(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridHeaderFilteringSelectors';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridHeaderFilteringSelectors';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
+
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const headerFilteringStateInitializer: GridStateInitializer;
|
|
6
|
+
export declare const useGridHeaderFiltering: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'signature'>) => void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
|
+
import { useGridLogger } from '../../utils';
|
|
5
|
+
import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
6
|
+
export const headerFilteringStateInitializer = state => _extends({}, state, {
|
|
7
|
+
headerFiltering: {
|
|
8
|
+
editing: null,
|
|
9
|
+
menuOpen: null
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export const useGridHeaderFiltering = (apiRef, props) => {
|
|
13
|
+
const logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
|
|
14
|
+
const setHeaderFilterState = React.useCallback(headerFilterState => {
|
|
15
|
+
apiRef.current.setState(state => {
|
|
16
|
+
var _headerFilterState$ed, _headerFilterState$me;
|
|
17
|
+
// Safety check to avoid MIT users from using it
|
|
18
|
+
// This hook should ultimately be moved to the Pro package
|
|
19
|
+
if (props.signature === 'DataGrid') {
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
return _extends({}, state, {
|
|
23
|
+
headerFiltering: {
|
|
24
|
+
editing: (_headerFilterState$ed = headerFilterState.editing) != null ? _headerFilterState$ed : null,
|
|
25
|
+
menuOpen: (_headerFilterState$me = headerFilterState.menuOpen) != null ? _headerFilterState$me : null
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
apiRef.current.forceUpdate();
|
|
30
|
+
}, [apiRef, props.signature]);
|
|
31
|
+
const startHeaderFilterEditMode = React.useCallback(field => {
|
|
32
|
+
logger.debug(`Starting edit mode on header filter for field: ${field}`);
|
|
33
|
+
apiRef.current.setHeaderFilterState({
|
|
34
|
+
editing: field
|
|
35
|
+
});
|
|
36
|
+
}, [apiRef, logger]);
|
|
37
|
+
const stopHeaderFilterEditMode = React.useCallback(() => {
|
|
38
|
+
logger.debug(`Stopping edit mode on header filter`);
|
|
39
|
+
apiRef.current.setHeaderFilterState({
|
|
40
|
+
editing: null
|
|
41
|
+
});
|
|
42
|
+
}, [apiRef, logger]);
|
|
43
|
+
const showHeaderFilterMenu = React.useCallback(field => {
|
|
44
|
+
logger.debug(`Opening header filter menu for field: ${field}`);
|
|
45
|
+
apiRef.current.setHeaderFilterState({
|
|
46
|
+
menuOpen: field
|
|
47
|
+
});
|
|
48
|
+
}, [apiRef, logger]);
|
|
49
|
+
const hideHeaderFilterMenu = React.useCallback(() => {
|
|
50
|
+
logger.debug(`Hiding header filter menu for active field`);
|
|
51
|
+
let fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
|
|
52
|
+
if (fieldToFocus) {
|
|
53
|
+
const columnLookup = gridColumnLookupSelector(apiRef);
|
|
54
|
+
const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
55
|
+
const orderedFields = gridColumnFieldsSelector(apiRef);
|
|
56
|
+
|
|
57
|
+
// If the column was removed from the grid, we need to find the closest visible field
|
|
58
|
+
if (!columnLookup[fieldToFocus]) {
|
|
59
|
+
fieldToFocus = orderedFields[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// If the field to focus is hidden, we need to find the closest visible field
|
|
63
|
+
if (columnVisibilityModel[fieldToFocus] === false) {
|
|
64
|
+
// contains visible column fields + the field that was just hidden
|
|
65
|
+
const visibleOrderedFields = orderedFields.filter(field => {
|
|
66
|
+
if (field === fieldToFocus) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return columnVisibilityModel[field] !== false;
|
|
70
|
+
});
|
|
71
|
+
const fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
|
|
72
|
+
fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
|
|
73
|
+
}
|
|
74
|
+
apiRef.current.setHeaderFilterState({
|
|
75
|
+
menuOpen: null
|
|
76
|
+
});
|
|
77
|
+
apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
|
|
78
|
+
}
|
|
79
|
+
}, [apiRef, logger]);
|
|
80
|
+
const headerFilterPrivateApi = {
|
|
81
|
+
setHeaderFilterState
|
|
82
|
+
};
|
|
83
|
+
const headerFilterApi = {
|
|
84
|
+
startHeaderFilterEditMode,
|
|
85
|
+
stopHeaderFilterEditMode,
|
|
86
|
+
showHeaderFilterMenu,
|
|
87
|
+
hideHeaderFilterMenu
|
|
88
|
+
};
|
|
89
|
+
useGridApiMethod(apiRef, headerFilterApi, 'public');
|
|
90
|
+
useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
|
|
91
|
+
};
|
package/hooks/features/index.js
CHANGED
|
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
|
10
10
|
* @requires useGridScroll (method) - can be after
|
|
11
11
|
* @requires useGridColumnSpanning (method) - can be after
|
|
12
12
|
*/
|
|
13
|
-
export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode' | 'getRowId'>) => void;
|
|
13
|
+
export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode' | 'getRowId' | 'experimentalFeatures' | 'signature'>) => void;
|