@mui/x-data-grid 5.13.1 → 5.15.1
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 +147 -6
- package/DataGrid/DataGrid.js +6 -0
- package/DataGrid/useDataGridComponent.js +1 -1
- package/DataGrid/useDataGridProps.js +1 -0
- package/colDef/gridActionsColDef.js +2 -0
- package/colDef/gridBooleanColDef.js +3 -1
- package/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridStringColDef.d.ts +3 -0
- package/colDef/gridStringColDef.js +6 -0
- package/components/GridRow.js +5 -1
- package/components/base/GridOverlays.js +4 -1
- package/components/cell/GridBooleanCell.d.ts +5 -2
- package/components/cell/GridBooleanCell.js +93 -2
- package/components/cell/GridEditDateCell.js +5 -1
- package/components/cell/GridEditInputCell.d.ts +2 -5
- package/components/cell/GridEditInputCell.js +13 -14
- package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
- package/components/cell/GridEditSingleSelectCell.js +11 -4
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/components/containers/GridRoot.js +4 -2
- package/components/containers/GridRootStyles.js +10 -0
- package/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/components/toolbar/GridToolbarExport.js +20 -10
- package/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/constants/envConstants.d.ts +1 -1
- package/constants/envConstants.js +2 -11
- package/constants/gridClasses.d.ts +41 -1
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +9 -2
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
- package/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -6
- package/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +11 -9
- package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/hooks/features/editRows/useGridEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +7 -8
- package/hooks/features/export/utils.d.ts +1 -1
- package/hooks/features/export/utils.js +16 -2
- package/hooks/features/filter/gridFilterUtils.js +6 -0
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +11 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -34
- package/hooks/features/pagination/useGridPage.js +4 -3
- package/hooks/features/pagination/useGridPageSize.js +7 -4
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -0
- package/hooks/features/rows/gridRowsSelector.js +20 -1
- package/hooks/features/rows/gridRowsState.d.ts +8 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +5 -1
- package/hooks/features/rows/gridRowsUtils.js +21 -3
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/hooks/features/scroll/useGridScroll.js +7 -2
- package/hooks/features/selection/useGridSelection.js +28 -10
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -0
- package/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +42 -6
- package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +12 -1
- package/hooks/features/statePersistence/index.d.ts +1 -1
- package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +32 -18
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.js +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +6 -3
- package/internals/index.js +5 -2
- package/legacy/DataGrid/DataGrid.js +6 -0
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/DataGrid/useDataGridProps.js +1 -0
- package/legacy/colDef/gridActionsColDef.js +2 -0
- package/legacy/colDef/gridBooleanColDef.js +3 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/legacy/colDef/gridStringColDef.js +6 -0
- package/legacy/components/GridRow.js +5 -1
- package/legacy/components/base/GridOverlays.js +4 -1
- package/legacy/components/cell/GridBooleanCell.js +93 -2
- package/legacy/components/cell/GridEditDateCell.js +5 -1
- package/legacy/components/cell/GridEditInputCell.js +13 -14
- package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
- package/legacy/components/cell/index.js +1 -0
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +11 -1
- package/legacy/components/containers/GridRoot.js +4 -2
- package/legacy/components/containers/GridRootStyles.js +3 -3
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +14 -5
- package/legacy/components/toolbar/GridToolbarExport.js +20 -10
- package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
- package/legacy/constants/envConstants.js +2 -11
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +9 -2
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/legacy/hooks/features/columns/useGridColumns.js +13 -8
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +11 -9
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/legacy/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +7 -8
- package/legacy/hooks/features/export/utils.js +21 -2
- package/legacy/hooks/features/filter/gridFilterUtils.js +6 -0
- package/legacy/hooks/features/filter/useGridFilter.js +11 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +47 -34
- package/legacy/hooks/features/pagination/useGridPage.js +4 -3
- package/legacy/hooks/features/pagination/useGridPageSize.js +7 -4
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/legacy/hooks/features/rows/gridRowsSelector.js +23 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +21 -3
- package/legacy/hooks/features/rows/index.js +1 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/legacy/hooks/features/scroll/useGridScroll.js +7 -2
- package/legacy/hooks/features/selection/useGridSelection.js +30 -12
- package/legacy/hooks/features/sorting/gridSortingUtils.js +11 -12
- package/legacy/hooks/features/sorting/useGridSorting.js +42 -6
- package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +33 -18
- package/legacy/hooks/utils/useGridNativeEventListener.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +5 -2
- package/legacy/locales/arSD.js +8 -1
- package/legacy/locales/bgBG.js +8 -1
- package/legacy/locales/csCZ.js +8 -1
- package/legacy/locales/daDK.js +8 -1
- package/legacy/locales/deDE.js +9 -2
- package/legacy/locales/elGR.js +8 -1
- package/legacy/locales/esES.js +8 -1
- package/legacy/locales/faIR.js +8 -1
- package/legacy/locales/fiFI.js +8 -1
- package/legacy/locales/frFR.js +9 -2
- package/legacy/locales/heIL.js +9 -2
- package/legacy/locales/huHU.js +8 -1
- package/legacy/locales/index.js +2 -1
- package/legacy/locales/itIT.js +21 -14
- package/legacy/locales/jaJP.js +11 -4
- package/legacy/locales/koKR.js +35 -24
- package/legacy/locales/nbNO.js +9 -2
- package/legacy/locales/nlNL.js +9 -2
- package/legacy/locales/plPL.js +8 -1
- package/legacy/locales/ptBR.js +9 -2
- package/legacy/locales/roRO.js +9 -2
- package/legacy/locales/ruRU.js +8 -1
- package/legacy/locales/skSK.js +9 -2
- package/legacy/locales/svSE.js +9 -2
- package/legacy/locales/trTR.js +8 -1
- package/legacy/locales/ukUA.js +8 -1
- package/legacy/locales/viVN.js +8 -1
- package/legacy/locales/zhCN.js +38 -27
- package/legacy/locales/zhTW.js +135 -0
- package/legacy/models/events/gridEvents.js +1 -0
- package/legacy/utils/keyboardUtils.js +8 -5
- package/locales/arSD.js +8 -1
- package/locales/bgBG.js +8 -1
- package/locales/csCZ.js +8 -1
- package/locales/daDK.js +8 -1
- package/locales/deDE.js +9 -2
- package/locales/elGR.js +8 -1
- package/locales/esES.js +8 -1
- package/locales/faIR.js +8 -1
- package/locales/fiFI.js +8 -1
- package/locales/frFR.js +9 -2
- package/locales/heIL.js +9 -2
- package/locales/huHU.js +8 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +2 -1
- package/locales/itIT.js +21 -14
- package/locales/jaJP.js +11 -4
- package/locales/koKR.js +31 -24
- package/locales/nbNO.js +9 -2
- package/locales/nlNL.js +9 -2
- package/locales/plPL.js +8 -1
- package/locales/ptBR.js +9 -2
- package/locales/roRO.js +9 -2
- package/locales/ruRU.js +8 -1
- package/locales/skSK.js +9 -2
- package/locales/svSE.js +9 -2
- package/locales/trTR.js +8 -1
- package/locales/ukUA.js +8 -1
- package/locales/viVN.js +8 -1
- package/locales/zhCN.js +34 -27
- package/locales/zhTW.d.ts +2 -0
- package/locales/zhTW.js +123 -0
- package/models/api/gridColumnSpanning.d.ts +2 -0
- package/models/api/gridLocaleTextApi.d.ts +8 -2
- package/models/api/gridSelectionApi.d.ts +6 -0
- package/models/events/gridEvents.d.ts +1 -0
- package/models/events/gridEvents.js +1 -0
- package/models/gridRows.d.ts +15 -1
- package/models/params/gridCellParams.d.ts +4 -4
- package/models/props/DataGridProps.d.ts +5 -0
- package/modern/DataGrid/DataGrid.js +6 -0
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/DataGrid/useDataGridProps.js +1 -0
- package/modern/colDef/gridActionsColDef.js +2 -0
- package/modern/colDef/gridBooleanColDef.js +3 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/modern/colDef/gridStringColDef.js +6 -0
- package/modern/components/GridRow.js +5 -1
- package/modern/components/base/GridOverlays.js +4 -1
- package/modern/components/cell/GridBooleanCell.js +93 -2
- package/modern/components/cell/GridEditDateCell.js +5 -1
- package/modern/components/cell/GridEditInputCell.js +13 -14
- package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
- package/modern/components/cell/index.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/modern/components/containers/GridRoot.js +4 -2
- package/modern/components/containers/GridRootStyles.js +10 -0
- package/modern/components/toolbar/GridToolbarDensitySelector.js +11 -4
- package/modern/components/toolbar/GridToolbarExport.js +20 -10
- package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
- package/modern/constants/envConstants.js +2 -11
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +9 -2
- package/modern/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/modern/hooks/features/columns/useGridColumns.js +10 -5
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +9 -9
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/modern/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +7 -8
- package/modern/hooks/features/export/utils.js +10 -2
- package/modern/hooks/features/filter/gridFilterUtils.js +6 -0
- package/modern/hooks/features/filter/useGridFilter.js +8 -3
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -30
- package/modern/hooks/features/pagination/useGridPage.js +4 -3
- package/modern/hooks/features/pagination/useGridPageSize.js +7 -4
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +8 -4
- package/modern/hooks/features/rows/gridRowsSelector.js +18 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +19 -3
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +17 -4
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/modern/hooks/features/scroll/useGridScroll.js +5 -2
- package/modern/hooks/features/selection/useGridSelection.js +28 -10
- package/modern/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/modern/hooks/features/sorting/useGridSorting.js +38 -6
- package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +31 -17
- package/modern/hooks/utils/useGridNativeEventListener.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +5 -2
- package/modern/locales/arSD.js +8 -1
- package/modern/locales/bgBG.js +8 -1
- package/modern/locales/csCZ.js +8 -1
- package/modern/locales/daDK.js +8 -1
- package/modern/locales/deDE.js +9 -2
- package/modern/locales/elGR.js +8 -1
- package/modern/locales/esES.js +8 -1
- package/modern/locales/faIR.js +8 -1
- package/modern/locales/fiFI.js +8 -1
- package/modern/locales/frFR.js +9 -2
- package/modern/locales/heIL.js +9 -2
- package/modern/locales/huHU.js +8 -1
- package/modern/locales/index.js +2 -1
- package/modern/locales/itIT.js +21 -14
- package/modern/locales/jaJP.js +11 -4
- package/modern/locales/koKR.js +31 -24
- package/modern/locales/nbNO.js +9 -2
- package/modern/locales/nlNL.js +9 -2
- package/modern/locales/plPL.js +8 -1
- package/modern/locales/ptBR.js +9 -2
- package/modern/locales/roRO.js +9 -2
- package/modern/locales/ruRU.js +8 -1
- package/modern/locales/skSK.js +9 -2
- package/modern/locales/svSE.js +9 -2
- package/modern/locales/trTR.js +8 -1
- package/modern/locales/ukUA.js +8 -1
- package/modern/locales/viVN.js +8 -1
- package/modern/locales/zhCN.js +34 -27
- package/modern/locales/zhTW.js +123 -0
- package/modern/models/events/gridEvents.js +1 -0
- package/modern/utils/keyboardUtils.js +7 -2
- package/node/DataGrid/DataGrid.js +6 -0
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/DataGrid/useDataGridProps.js +1 -0
- package/node/colDef/gridActionsColDef.js +2 -0
- package/node/colDef/gridBooleanColDef.js +3 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/node/colDef/gridStringColDef.js +5 -0
- package/node/components/GridRow.js +5 -1
- package/node/components/base/GridOverlays.js +4 -1
- package/node/components/cell/GridBooleanCell.js +93 -2
- package/node/components/cell/GridEditDateCell.js +7 -1
- package/node/components/cell/GridEditInputCell.js +15 -16
- package/node/components/cell/GridEditSingleSelectCell.js +10 -4
- package/node/components/cell/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
- package/node/components/containers/GridRoot.js +3 -1
- package/node/components/containers/GridRootStyles.js +10 -0
- package/node/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/node/components/toolbar/GridToolbarExport.js +16 -10
- package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/node/constants/envConstants.js +2 -13
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +9 -2
- package/node/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/node/hooks/features/columns/useGridColumns.js +13 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +7 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +11 -9
- package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/node/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +7 -8
- package/node/hooks/features/export/utils.js +17 -2
- package/node/hooks/features/filter/gridFilterUtils.js +7 -0
- package/node/hooks/features/filter/useGridFilter.js +11 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -34
- package/node/hooks/features/pagination/useGridPage.js +4 -3
- package/node/hooks/features/pagination/useGridPageSize.js +8 -4
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/node/hooks/features/rows/gridRowsSelector.js +24 -2
- package/node/hooks/features/rows/gridRowsUtils.js +23 -2
- package/node/hooks/features/rows/index.js +70 -12
- package/node/hooks/features/rows/useGridRowsMeta.js +20 -4
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/node/hooks/features/scroll/useGridScroll.js +7 -1
- package/node/hooks/features/selection/useGridSelection.js +28 -10
- package/node/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/node/hooks/features/sorting/useGridSorting.js +42 -6
- package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +32 -18
- package/node/hooks/utils/useGridNativeEventListener.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +46 -0
- package/node/locales/arSD.js +8 -1
- package/node/locales/bgBG.js +8 -1
- package/node/locales/csCZ.js +8 -1
- package/node/locales/daDK.js +8 -1
- package/node/locales/deDE.js +9 -2
- package/node/locales/elGR.js +8 -1
- package/node/locales/esES.js +8 -1
- package/node/locales/faIR.js +8 -1
- package/node/locales/fiFI.js +8 -1
- package/node/locales/frFR.js +9 -2
- package/node/locales/heIL.js +9 -2
- package/node/locales/huHU.js +8 -1
- package/node/locales/index.js +13 -0
- package/node/locales/itIT.js +21 -14
- package/node/locales/jaJP.js +11 -4
- package/node/locales/koKR.js +31 -24
- package/node/locales/nbNO.js +9 -2
- package/node/locales/nlNL.js +9 -2
- package/node/locales/plPL.js +8 -1
- package/node/locales/ptBR.js +9 -2
- package/node/locales/roRO.js +9 -2
- package/node/locales/ruRU.js +8 -1
- package/node/locales/skSK.js +9 -2
- package/node/locales/svSE.js +9 -2
- package/node/locales/trTR.js +8 -1
- package/node/locales/ukUA.js +8 -1
- package/node/locales/viVN.js +8 -1
- package/node/locales/zhCN.js +34 -27
- package/node/locales/zhTW.js +133 -0
- package/node/models/events/gridEvents.js +1 -0
- package/node/utils/keyboardUtils.js +10 -4
- package/package.json +1 -1
- package/utils/getGridLocalization.d.ts +1 -1
- package/utils/keyboardUtils.d.ts +2 -2
- package/utils/keyboardUtils.js +7 -2
|
@@ -28,6 +28,7 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
28
28
|
field,
|
|
29
29
|
id,
|
|
30
30
|
value: isChecked,
|
|
31
|
+
rowNode,
|
|
31
32
|
hasFocus,
|
|
32
33
|
tabIndex
|
|
33
34
|
} = props,
|
|
@@ -77,8 +78,18 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
77
78
|
apiRef.current.publishEvent('cellNavigationKeyDown', props, event);
|
|
78
79
|
}
|
|
79
80
|
}, [apiRef, props]);
|
|
80
|
-
|
|
81
|
+
|
|
82
|
+
if (rowNode.position === 'footer') {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const isSelectable = apiRef.current.isRowSelectable(id);
|
|
81
87
|
const label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
|
|
88
|
+
|
|
89
|
+
if (rowNode.isPinned) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
return /*#__PURE__*/_jsx(rootProps.components.BaseCheckbox, _extends({
|
|
83
94
|
ref: handleRef,
|
|
84
95
|
tabIndex: tabIndex,
|
|
@@ -12,7 +12,7 @@ import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
|
12
12
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
13
13
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
14
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
15
|
-
import { gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
15
|
+
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
16
16
|
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
|
|
@@ -43,6 +43,7 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
43
43
|
const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
44
44
|
const rootContainerRef = React.useRef(null);
|
|
45
45
|
const handleRef = useForkRef(rootContainerRef, ref);
|
|
46
|
+
const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
46
47
|
const ownerState = {
|
|
47
48
|
density: densityValue,
|
|
48
49
|
classes: rootProps.classes,
|
|
@@ -70,7 +71,8 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
70
71
|
className: clsx(className, classes.root),
|
|
71
72
|
role: "grid",
|
|
72
73
|
"aria-colcount": visibleColumns.length,
|
|
73
|
-
"aria-rowcount": totalRowCount
|
|
74
|
+
"aria-rowcount": totalRowCount + pinnedRowsCount + 1 // +1 for the header row
|
|
75
|
+
,
|
|
74
76
|
"aria-multiselectable": !rootProps.disableMultipleSelection,
|
|
75
77
|
"aria-label": rootProps['aria-label'],
|
|
76
78
|
"aria-labelledby": rootProps['aria-labelledby']
|
|
@@ -6,6 +6,16 @@ export const GridRootStyles = styled('div', {
|
|
|
6
6
|
slot: 'Root',
|
|
7
7
|
overridesResolver: (props, styles) => [{
|
|
8
8
|
[`&.${gridClasses.autoHeight}`]: styles.autoHeight
|
|
9
|
+
}, {
|
|
10
|
+
[`&.${gridClasses.aggregationColumnHeader}`]: styles.aggregationColumnHeader
|
|
11
|
+
}, {
|
|
12
|
+
[`&.${gridClasses['aggregationColumnHeader--alignLeft']}`]: styles['aggregationColumnHeader--alignLeft']
|
|
13
|
+
}, {
|
|
14
|
+
[`&.${gridClasses['aggregationColumnHeader--alignCenter']}`]: styles['aggregationColumnHeader--alignCenter']
|
|
15
|
+
}, {
|
|
16
|
+
[`&.${gridClasses['aggregationColumnHeader--alignRight']}`]: styles['aggregationColumnHeader--alignRight']
|
|
17
|
+
}, {
|
|
18
|
+
[`&.${gridClasses.aggregationColumnHeaderLabel}`]: styles.aggregationColumnHeaderLabel
|
|
9
19
|
}, {
|
|
10
20
|
[`& .${gridClasses.editBooleanCell}`]: styles.editBooleanCell
|
|
11
21
|
}, {
|
|
@@ -59,11 +59,20 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
59
59
|
}, [densityValue, rootProps]);
|
|
60
60
|
|
|
61
61
|
const handleDensitySelectorOpen = event => {
|
|
62
|
-
setOpen(
|
|
62
|
+
setOpen(prevOpen => !prevOpen);
|
|
63
63
|
onClick == null ? void 0 : onClick(event);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const
|
|
66
|
+
const handleDensitySelectorClickAway = event => {
|
|
67
|
+
var _buttonRef$current;
|
|
68
|
+
|
|
69
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
70
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setOpen(false);
|
|
75
|
+
};
|
|
67
76
|
|
|
68
77
|
const handleDensityUpdate = newDensity => {
|
|
69
78
|
apiRef.current.setDensity(newDensity);
|
|
@@ -76,7 +85,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
if (isHideMenuKey(event.key)) {
|
|
79
|
-
|
|
88
|
+
setOpen(false);
|
|
80
89
|
}
|
|
81
90
|
}; // Disable the button if the corresponding is disabled
|
|
82
91
|
|
|
@@ -109,7 +118,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
109
118
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
110
119
|
open: open,
|
|
111
120
|
target: buttonRef.current,
|
|
112
|
-
onClickAway:
|
|
121
|
+
onClickAway: handleDensitySelectorClickAway,
|
|
113
122
|
position: "bottom-start",
|
|
114
123
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
115
124
|
id: densityMenuId,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["hideMenu", "options"],
|
|
4
|
+
_excluded2 = ["hideMenu", "options"],
|
|
5
|
+
_excluded3 = ["csvOptions", "printOptions", "excelOptions"];
|
|
4
6
|
import * as React from 'react';
|
|
5
7
|
import PropTypes from 'prop-types';
|
|
6
8
|
import MenuItem from '@mui/material/MenuItem';
|
|
@@ -9,31 +11,39 @@ import { GridToolbarExportContainer } from './GridToolbarExportContainer';
|
|
|
9
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
12
|
export const GridCsvExportMenuItem = props => {
|
|
11
13
|
const apiRef = useGridApiContext();
|
|
14
|
+
|
|
12
15
|
const {
|
|
13
16
|
hideMenu,
|
|
14
17
|
options
|
|
15
|
-
} = props
|
|
16
|
-
|
|
18
|
+
} = props,
|
|
19
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
20
|
+
|
|
21
|
+
return /*#__PURE__*/_jsx(MenuItem, _extends({
|
|
17
22
|
onClick: () => {
|
|
18
23
|
apiRef.current.exportDataAsCsv(options);
|
|
19
24
|
hideMenu == null ? void 0 : hideMenu();
|
|
20
|
-
}
|
|
25
|
+
}
|
|
26
|
+
}, other, {
|
|
21
27
|
children: apiRef.current.getLocaleText('toolbarExportCSV')
|
|
22
|
-
});
|
|
28
|
+
}));
|
|
23
29
|
};
|
|
24
30
|
export const GridPrintExportMenuItem = props => {
|
|
25
31
|
const apiRef = useGridApiContext();
|
|
32
|
+
|
|
26
33
|
const {
|
|
27
34
|
hideMenu,
|
|
28
35
|
options
|
|
29
|
-
} = props
|
|
30
|
-
|
|
36
|
+
} = props,
|
|
37
|
+
other = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
38
|
+
|
|
39
|
+
return /*#__PURE__*/_jsx(MenuItem, _extends({
|
|
31
40
|
onClick: () => {
|
|
32
41
|
apiRef.current.exportDataAsPrint(options);
|
|
33
42
|
hideMenu == null ? void 0 : hideMenu();
|
|
34
|
-
}
|
|
43
|
+
}
|
|
44
|
+
}, other, {
|
|
35
45
|
children: apiRef.current.getLocaleText('toolbarExportPrint')
|
|
36
|
-
});
|
|
46
|
+
}));
|
|
37
47
|
};
|
|
38
48
|
const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
|
|
39
49
|
const {
|
|
@@ -41,7 +51,7 @@ const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExpo
|
|
|
41
51
|
printOptions = {},
|
|
42
52
|
excelOptions
|
|
43
53
|
} = props,
|
|
44
|
-
other = _objectWithoutPropertiesLoose(props,
|
|
54
|
+
other = _objectWithoutPropertiesLoose(props, _excluded3);
|
|
45
55
|
|
|
46
56
|
const apiRef = useGridApiContext();
|
|
47
57
|
const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors('exportMenu', [], {
|
|
@@ -29,7 +29,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
29
29
|
const handleRef = useForkRef(ref, buttonRef);
|
|
30
30
|
|
|
31
31
|
const handleMenuOpen = event => {
|
|
32
|
-
setOpen(
|
|
32
|
+
setOpen(prevOpen => !prevOpen);
|
|
33
33
|
onClick == null ? void 0 : onClick(event);
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -45,6 +45,17 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const handleMenuClickAway = event => {
|
|
49
|
+
var _buttonRef$current;
|
|
50
|
+
|
|
51
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
52
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setOpen(false);
|
|
57
|
+
};
|
|
58
|
+
|
|
48
59
|
if (children == null) {
|
|
49
60
|
return null;
|
|
50
61
|
}
|
|
@@ -66,7 +77,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
66
77
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
67
78
|
open: open,
|
|
68
79
|
target: buttonRef.current,
|
|
69
|
-
onClickAway:
|
|
80
|
+
onClickAway: handleMenuClickAway,
|
|
70
81
|
position: "bottom-start",
|
|
71
82
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
72
83
|
id: menuId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GRID_EXPERIMENTAL_ENABLED
|
|
1
|
+
export declare const GRID_EXPERIMENTAL_ENABLED = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// A guide to feature toggling (deprecated)
|
|
2
2
|
//
|
|
3
3
|
// The feature toggle is:
|
|
4
4
|
// - independent from the NODE_ENV
|
|
@@ -15,13 +15,4 @@ import { localStorageAvailable } from '../utils/utils'; // A guide to feature to
|
|
|
15
15
|
//
|
|
16
16
|
// Developers (users) are discouraged to enable the experimental feature by setting the GRID_EXPERIMENTAL_ENABLED env.
|
|
17
17
|
// Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
|
|
18
|
-
|
|
19
|
-
let experimentalEnabled = false;
|
|
20
|
-
|
|
21
|
-
if (typeof process !== 'undefined' && process.env.GRID_EXPERIMENTAL_ENABLED !== undefined && localStorageAvailable() && window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED')) {
|
|
22
|
-
experimentalEnabled = window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED') === 'true';
|
|
23
|
-
} else if (typeof process !== 'undefined') {
|
|
24
|
-
experimentalEnabled = process.env.GRID_EXPERIMENTAL_ENABLED === 'true';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const GRID_EXPERIMENTAL_ENABLED = experimentalEnabled;
|
|
18
|
+
export const GRID_EXPERIMENTAL_ENABLED = false;
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
export interface GridClasses {
|
|
2
2
|
/**
|
|
3
|
-
* Styles applied to the root element of the cell with type="actions"
|
|
3
|
+
* Styles applied to the root element of the cell with type="actions".
|
|
4
4
|
*/
|
|
5
5
|
actionsCell: string;
|
|
6
|
+
/**
|
|
7
|
+
* Styles applied to the root element of the column header when aggregated.
|
|
8
|
+
*/
|
|
9
|
+
aggregationColumnHeader: string;
|
|
10
|
+
/**
|
|
11
|
+
* Styles applied to the root element of the header when aggregation if `headerAlign="left"`.
|
|
12
|
+
*/
|
|
13
|
+
'aggregationColumnHeader--alignLeft': string;
|
|
14
|
+
/**
|
|
15
|
+
* Styles applied to the root element of the header when aggregation if `headerAlign="center"`.
|
|
16
|
+
*/
|
|
17
|
+
'aggregationColumnHeader--alignCenter': string;
|
|
18
|
+
/**
|
|
19
|
+
* Styles applied to the root element of the header when aggregation if `headerAlign="right"`.
|
|
20
|
+
*/
|
|
21
|
+
'aggregationColumnHeader--alignRight': string;
|
|
22
|
+
/**
|
|
23
|
+
* Styles applied to the aggregation label in the column header when aggregated.
|
|
24
|
+
*/
|
|
25
|
+
aggregationColumnHeaderLabel: string;
|
|
6
26
|
/**
|
|
7
27
|
* Styles applied to the root element if `autoHeight={true}`.
|
|
8
28
|
*/
|
|
@@ -175,6 +195,10 @@ export interface GridClasses {
|
|
|
175
195
|
* Styles applied to the detail panel toggle cell element if expanded.
|
|
176
196
|
*/
|
|
177
197
|
'detailPanelToggleCell--expanded': string;
|
|
198
|
+
/**
|
|
199
|
+
* Styles applied to the root element of the cell inside a footer row.
|
|
200
|
+
*/
|
|
201
|
+
footerCell: string;
|
|
178
202
|
/**
|
|
179
203
|
* Styles applied to the panel element.
|
|
180
204
|
*/
|
|
@@ -420,6 +444,22 @@ export interface GridClasses {
|
|
|
420
444
|
* Styles applied to the toggle of the grouping criteria cell
|
|
421
445
|
*/
|
|
422
446
|
groupingCriteriaCellToggle: string;
|
|
447
|
+
/**
|
|
448
|
+
* Styles applied to the pinned rows container.
|
|
449
|
+
*/
|
|
450
|
+
pinnedRows: string;
|
|
451
|
+
/**
|
|
452
|
+
* Styles applied to the top pinned rows container.
|
|
453
|
+
*/
|
|
454
|
+
'pinnedRows--top': string;
|
|
455
|
+
/**
|
|
456
|
+
* Styles applied to the bottom pinned rows container.
|
|
457
|
+
*/
|
|
458
|
+
'pinnedRows--bottom': string;
|
|
459
|
+
/**
|
|
460
|
+
* Styles applied to pinned rows render zones.
|
|
461
|
+
*/
|
|
462
|
+
pinnedRowsRenderZone: string;
|
|
423
463
|
}
|
|
424
464
|
export declare type GridClassKey = keyof GridClasses;
|
|
425
465
|
export declare function getDataGridUtilityClass(slot: string): string;
|
package/constants/gridClasses.js
CHANGED
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -19,7 +19,7 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
19
19
|
toolbarFiltersTooltipShow: 'Show filters',
|
|
20
20
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} active filters` : `${count} active filter`,
|
|
21
21
|
// Quick filter toolbar field
|
|
22
|
-
toolbarQuickFilterPlaceholder: 'Search
|
|
22
|
+
toolbarQuickFilterPlaceholder: 'Search…',
|
|
23
23
|
toolbarQuickFilterLabel: 'Search',
|
|
24
24
|
toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
25
25
|
// Export selector toolbar button text
|
|
@@ -111,5 +111,12 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
111
111
|
// Used core components translation keys
|
|
112
112
|
MuiTablePagination: {},
|
|
113
113
|
// Row reordering text
|
|
114
|
-
rowReorderingHeaderName: 'Row reordering'
|
|
114
|
+
rowReorderingHeaderName: 'Row reordering',
|
|
115
|
+
// Aggregation
|
|
116
|
+
aggregationMenuItemHeader: 'Aggregation',
|
|
117
|
+
aggregationFunctionLabelSum: 'sum',
|
|
118
|
+
aggregationFunctionLabelAvg: 'avg',
|
|
119
|
+
aggregationFunctionLabelMin: 'min',
|
|
120
|
+
aggregationFunctionLabelMax: 'max',
|
|
121
|
+
aggregationFunctionLabelSize: 'size'
|
|
115
122
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridCellIndexCoordinates, GridScrollParams, GridColDef } from '../../../models';
|
|
3
3
|
import { GridInitialStateCommunity } from '../../../models/gridStateCommunity';
|
|
4
|
-
import { GridRestoreStatePreProcessingContext, GridRestoreStatePreProcessingValue } from '../../features/statePersistence/gridStatePersistenceInterface';
|
|
4
|
+
import { GridExportStateParams, GridRestoreStatePreProcessingContext, GridRestoreStatePreProcessingValue } from '../../features/statePersistence/gridStatePersistenceInterface';
|
|
5
5
|
import { GridHydrateColumnsValue } from '../../features/columns/gridColumnsInterfaces';
|
|
6
6
|
import { GridRowEntry } from '../../../models/gridRows';
|
|
7
7
|
import { GridHydrateRowsValue } from '../../features/rows/gridRowsState';
|
|
@@ -14,6 +14,7 @@ export interface GridPipeProcessingLookup {
|
|
|
14
14
|
};
|
|
15
15
|
exportState: {
|
|
16
16
|
value: GridInitialStateCommunity;
|
|
17
|
+
context: GridExportStateParams;
|
|
17
18
|
};
|
|
18
19
|
hydrateColumns: {
|
|
19
20
|
value: GridHydrateColumnsValue;
|
|
@@ -28,11 +28,11 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
28
28
|
columnIndex,
|
|
29
29
|
rowId,
|
|
30
30
|
minFirstColumnIndex,
|
|
31
|
-
maxLastColumnIndex
|
|
31
|
+
maxLastColumnIndex,
|
|
32
|
+
columns
|
|
32
33
|
} = params;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const column = visibleColumns[columnIndex];
|
|
34
|
+
const columnsLength = columns.length;
|
|
35
|
+
const column = columns[columnIndex];
|
|
36
36
|
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(apiRef.current.getCellParams(rowId, column.field)) : column.colSpan;
|
|
37
37
|
|
|
38
38
|
if (!colSpan || colSpan === 1) {
|
|
@@ -54,7 +54,7 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
54
54
|
const nextColumnIndex = columnIndex + j; // Cells should be spanned only within their column section (left-pinned, right-pinned and unpinned).
|
|
55
55
|
|
|
56
56
|
if (nextColumnIndex >= minFirstColumnIndex && nextColumnIndex < maxLastColumnIndex) {
|
|
57
|
-
const nextColumn =
|
|
57
|
+
const nextColumn = columns[nextColumnIndex];
|
|
58
58
|
width += nextColumn.computedWidth;
|
|
59
59
|
setCellColSpanInfo(rowId, columnIndex + j, {
|
|
60
60
|
spannedByColSpan: true,
|
|
@@ -80,14 +80,16 @@ export const useGridColumnSpanning = apiRef => {
|
|
|
80
80
|
const calculateColSpan = React.useCallback(({
|
|
81
81
|
rowId,
|
|
82
82
|
minFirstColumn,
|
|
83
|
-
maxLastColumn
|
|
83
|
+
maxLastColumn,
|
|
84
|
+
columns
|
|
84
85
|
}) => {
|
|
85
86
|
for (let i = minFirstColumn; i < maxLastColumn; i += 1) {
|
|
86
87
|
const cellProps = calculateCellColSpan({
|
|
87
88
|
columnIndex: i,
|
|
88
89
|
rowId,
|
|
89
90
|
minFirstColumnIndex: minFirstColumn,
|
|
90
|
-
maxLastColumnIndex: maxLastColumn
|
|
91
|
+
maxLastColumnIndex: maxLastColumn,
|
|
92
|
+
columns
|
|
91
93
|
});
|
|
92
94
|
|
|
93
95
|
if (cellProps.colSpan > 1) {
|
|
@@ -8,4 +8,4 @@ export declare const columnsStateInitializer: GridStateInitializer<Pick<DataGrid
|
|
|
8
8
|
* @requires useGridDimensions (method, event) - can be after
|
|
9
9
|
* TODO: Impossible priority - useGridParamsApi also needs to be after useGridColumns
|
|
10
10
|
*/
|
|
11
|
-
export declare function useGridColumns(apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'columns' | 'onColumnVisibilityChange' | 'columnVisibilityModel' | 'onColumnVisibilityModelChange' | 'columnTypes' | 'components' | 'componentsProps'>): void;
|
|
11
|
+
export declare function useGridColumns(apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState' | 'columns' | 'onColumnVisibilityChange' | 'columnVisibilityModel' | 'onColumnVisibilityModelChange' | 'columnTypes' | 'components' | 'componentsProps'>): void;
|
|
@@ -36,7 +36,7 @@ export const columnsStateInitializer = (state, props, apiRef) => {
|
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
export function useGridColumns(apiRef, props) {
|
|
39
|
-
var _props$componentsProp2;
|
|
39
|
+
var _props$initialState5, _props$componentsProp2;
|
|
40
40
|
|
|
41
41
|
const logger = useGridLogger(apiRef, 'useGridColumns');
|
|
42
42
|
const columnTypes = React.useMemo(() => computeColumnTypes(props.columnTypes), [props.columnTypes]);
|
|
@@ -192,14 +192,21 @@ export function useGridColumns(apiRef, props) {
|
|
|
192
192
|
* PRE-PROCESSING
|
|
193
193
|
*/
|
|
194
194
|
|
|
195
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
195
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
196
196
|
const columnsStateToExport = {};
|
|
197
197
|
|
|
198
198
|
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
199
|
-
|
|
200
|
-
const hasHiddenColumns = Object.values(columnVisibilityModelToExport).some(value => value === false);
|
|
199
|
+
var _props$initialState$c2, _props$initialState4, _props$initialState4$;
|
|
201
200
|
|
|
202
|
-
|
|
201
|
+
const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
|
|
202
|
+
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
203
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
204
|
+
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
205
|
+
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
206
|
+
Object.keys((_props$initialState$c2 = (_props$initialState4 = props.initialState) == null ? void 0 : (_props$initialState4$ = _props$initialState4.columns) == null ? void 0 : _props$initialState4$.columnVisibilityModel) != null ? _props$initialState$c2 : {}).length > 0 || // Always export if the model is not empty
|
|
207
|
+
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
208
|
+
|
|
209
|
+
if (shouldExportColumnVisibilityModel) {
|
|
203
210
|
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
204
211
|
}
|
|
205
212
|
}
|
|
@@ -230,7 +237,7 @@ export function useGridColumns(apiRef, props) {
|
|
|
230
237
|
return _extends({}, prevState, {
|
|
231
238
|
columns: columnsStateToExport
|
|
232
239
|
});
|
|
233
|
-
}, [apiRef]);
|
|
240
|
+
}, [apiRef, props.columnVisibilityModel, (_props$initialState5 = props.initialState) == null ? void 0 : _props$initialState5.columns]);
|
|
234
241
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
235
242
|
var _context$stateToResto;
|
|
236
243
|
|
|
@@ -8,6 +8,7 @@ import { gridDensityHeaderHeightSelector, gridDensityRowHeightSelector } from '.
|
|
|
8
8
|
import { useGridSelector } from '../../utils';
|
|
9
9
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
10
10
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
11
|
+
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
11
12
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
12
13
|
|
|
13
14
|
const hasScroll = ({
|
|
@@ -47,6 +48,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
47
48
|
|
|
48
49
|
const rootElement = (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE.current;
|
|
49
50
|
const columnsTotalWidth = gridColumnsTotalWidthSelector(apiRef);
|
|
51
|
+
const pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
50
52
|
|
|
51
53
|
if (!rootDimensionsRef.current) {
|
|
52
54
|
return;
|
|
@@ -92,7 +94,10 @@ export function useGridDimensions(apiRef, props) {
|
|
|
92
94
|
width: Math.round(columnsTotalWidth),
|
|
93
95
|
height: rowsMeta.currentPageTotalHeight
|
|
94
96
|
},
|
|
95
|
-
container:
|
|
97
|
+
container: {
|
|
98
|
+
width: viewportOuterSize.width,
|
|
99
|
+
height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
|
|
100
|
+
},
|
|
96
101
|
scrollBarSize
|
|
97
102
|
});
|
|
98
103
|
hasScrollY = scrollInformation.hasScrollY;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
export declare const useGridCellEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'editMode' | 'processRowUpdate' | 'onCellEditStart' | 'onCellEditStop' | 'cellModesModel' | 'onCellModesModelChange' | 'onProcessRowUpdateError' | 'signature'>) => void;
|
|
4
|
+
export declare const useGridCellEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'editMode' | 'processRowUpdate' | 'onCellEditStart' | 'onCellEditStop' | 'cellModesModel' | 'onCellModesModelChange' | 'onProcessRowUpdateError' | 'signature' | 'disableIgnoreModificationsIfProcessingProps'>) => void;
|
|
@@ -97,15 +97,14 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
97
97
|
} else if (params.isEditable) {
|
|
98
98
|
let reason;
|
|
99
99
|
|
|
100
|
-
if (isPrintableKey(event
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
100
|
+
if (isPrintableKey(event)) {
|
|
101
|
+
reason = GridCellEditStartReasons.printableKeyDown;
|
|
102
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
105
103
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
106
104
|
} else if (event.key === 'Enter') {
|
|
107
105
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
108
|
-
} else if (event.key === 'Delete') {
|
|
106
|
+
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
107
|
+
// Delete on Windows, Backspace on macOS
|
|
109
108
|
reason = GridCellEditStartReasons.deleteKeyDown;
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -141,6 +140,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
141
140
|
field,
|
|
142
141
|
reason
|
|
143
142
|
} = params;
|
|
143
|
+
apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
|
|
144
144
|
let cellToFocusAfter;
|
|
145
145
|
|
|
146
146
|
if (reason === GridCellEditStopReasons.enterKeyDown) {
|
|
@@ -154,7 +154,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
154
154
|
let ignoreModifications = reason === 'escapeKeyDown';
|
|
155
155
|
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
156
156
|
|
|
157
|
-
if (editingState[id][field].isProcessingProps) {
|
|
157
|
+
if (editingState[id][field].isProcessingProps && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
158
158
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
159
159
|
// In this case, discard the modifications.
|
|
160
160
|
ignoreModifications = true;
|
|
@@ -166,7 +166,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
166
166
|
ignoreModifications,
|
|
167
167
|
cellToFocusAfter
|
|
168
168
|
});
|
|
169
|
-
}, [apiRef]);
|
|
169
|
+
}, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
|
|
170
170
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsCell(handleCellDoubleClick));
|
|
171
171
|
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsCell(handleCellFocusOut));
|
|
172
172
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfEditModeIsCell(handleCellKeyDown));
|
|
@@ -343,6 +343,8 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
343
343
|
}
|
|
344
344
|
}, [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateFieldInCellModesModel, updateOrDeleteFieldState]);
|
|
345
345
|
const setCellEditingEditCellValue = React.useCallback(async params => {
|
|
346
|
+
var _editingState$id, _editingState$id$fiel;
|
|
347
|
+
|
|
346
348
|
const {
|
|
347
349
|
id,
|
|
348
350
|
field,
|
|
@@ -394,7 +396,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
394
396
|
newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
|
|
395
397
|
updateOrDeleteFieldState(id, field, newProps);
|
|
396
398
|
editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
397
|
-
return !editingState[id][field].error;
|
|
399
|
+
return !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel = _editingState$id[field]) != null && _editingState$id$fiel.error);
|
|
398
400
|
}, [apiRef, throwIfNotEditable, throwIfNotInMode, updateOrDeleteFieldState]);
|
|
399
401
|
const getRowWithUpdatedValuesFromCellEditing = React.useCallback((id, field) => {
|
|
400
402
|
const column = apiRef.current.getColumn(field);
|
|
@@ -199,7 +199,7 @@ export const useCellEditing = (apiRef, props) => {
|
|
|
199
199
|
const isEditMode = cellMode === GridCellModes.Edit;
|
|
200
200
|
const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
|
|
201
201
|
|
|
202
|
-
if (!isEditMode && isCellEnterEditModeKeys(event
|
|
202
|
+
if (!isEditMode && isCellEnterEditModeKeys(event) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
|
|
203
203
|
apiRef.current.publishEvent('cellEditStart', params, event);
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -269,7 +269,7 @@ export const useCellEditing = (apiRef, props) => {
|
|
|
269
269
|
|
|
270
270
|
apiRef.current.setCellMode(params.id, params.field, GridCellModes.Edit);
|
|
271
271
|
|
|
272
|
-
if (isKeyboardEvent(event) && isPrintableKey(event
|
|
272
|
+
if (isKeyboardEvent(event) && isPrintableKey(event)) {
|
|
273
273
|
apiRef.current.unstable_setEditCellProps({
|
|
274
274
|
id: params.id,
|
|
275
275
|
field: params.field,
|
|
@@ -3,4 +3,4 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
5
|
export declare const editingStateInitializer: GridStateInitializer;
|
|
6
|
-
export declare const useGridEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'isCellEditable' | 'editMode' | 'processRowUpdate'>) => void;
|
|
6
|
+
export declare const useGridEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'isCellEditable' | 'editMode' | 'processRowUpdate' | 'disableIgnoreModificationsIfProcessingProps'>) => void;
|
|
@@ -30,7 +30,7 @@ export function useGridEditing(apiRef, props) {
|
|
|
30
30
|
stateSelector: gridEditRowsStateSelector,
|
|
31
31
|
changeEvent: 'editRowsModelChange'
|
|
32
32
|
});
|
|
33
|
-
const isCellEditable = React.useCallback(params => !params.rowNode.isAutoGenerated && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
const isCellEditable = React.useCallback(params => !params.rowNode.isAutoGenerated && !params.rowNode.isPinned && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params)), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
34
|
[props.isCellEditable]);
|
|
35
35
|
|
|
36
36
|
const maybeDebounce = (id, field, debounceMs, callback) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
export declare const useGridRowEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'editMode' | 'processRowUpdate' | 'onRowEditStart' | 'onRowEditStop' | 'onProcessRowUpdateError' | 'rowModesModel' | 'onRowModesModelChange' | 'signature'>) => void;
|
|
4
|
+
export declare const useGridRowEditing: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'editMode' | 'processRowUpdate' | 'onRowEditStart' | 'onRowEditStop' | 'onProcessRowUpdateError' | 'rowModesModel' | 'onRowModesModelChange' | 'signature' | 'disableIgnoreModificationsIfProcessingProps'>) => void;
|