@mui/x-data-grid 5.9.0 → 5.11.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 +284 -10
- package/DataGrid/DataGrid.js +35 -1
- package/DataGrid/useDataGridProps.js +2 -1
- package/README.md +5 -4
- package/colDef/gridActionsColDef.js +2 -1
- package/colDef/gridBooleanColDef.js +2 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/colDef/gridDateColDef.js +4 -2
- package/colDef/gridNumericColDef.js +3 -2
- package/colDef/gridNumericOperators.d.ts +2 -0
- package/colDef/gridNumericOperators.js +11 -0
- package/colDef/gridSingleSelectColDef.js +3 -2
- package/colDef/gridSingleSelectOperators.d.ts +3 -0
- package/colDef/gridSingleSelectOperators.js +52 -0
- package/colDef/gridStringColDef.js +3 -2
- package/colDef/gridStringOperators.d.ts +2 -0
- package/colDef/gridStringOperators.js +12 -0
- package/components/GridFooter.d.ts +4 -2
- package/components/GridFooter.js +11 -2
- package/components/GridRow.js +9 -5
- package/components/GridRowCount.d.ts +4 -1
- package/components/GridRowCount.js +1 -0
- package/components/GridScrollArea.js +3 -4
- package/components/GridSelectedRowCount.d.ts +4 -1
- package/components/GridSelectedRowCount.js +2 -1
- package/components/base/GridBody.js +1 -2
- package/components/base/GridOverlays.js +2 -3
- package/components/cell/GridActionsCell.js +13 -4
- package/components/cell/GridCell.js +8 -8
- package/components/cell/GridEditBooleanCell.d.ts +15 -3
- package/components/cell/GridEditBooleanCell.js +101 -6
- package/components/cell/GridEditDateCell.d.ts +16 -4
- package/components/cell/GridEditDateCell.js +99 -5
- package/components/cell/GridEditInputCell.d.ts +11 -5
- package/components/cell/GridEditInputCell.js +29 -5
- package/components/cell/GridEditSingleSelectCell.d.ts +12 -4
- package/components/cell/GridEditSingleSelectCell.js +28 -5
- package/components/cell/index.d.ts +2 -0
- package/components/cell/index.js +2 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +15 -16
- package/components/columnHeaders/GridColumnHeaders.d.ts +2 -0
- package/components/columnHeaders/GridColumnHeadersInner.d.ts +2 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/components/columnSelection/GridHeaderCheckbox.js +4 -5
- package/components/containers/GridFooterContainer.d.ts +8 -2
- package/components/containers/GridFooterContainer.js +11 -2
- package/components/containers/GridRoot.js +25 -5
- package/components/containers/GridRootStyles.js +36 -1
- package/components/containers/GridToolbarContainer.d.ts +8 -2
- package/components/containers/GridToolbarContainer.js +12 -2
- package/components/menu/GridMenu.js +1 -0
- package/components/panel/GridPanelContent.d.ts +8 -1
- package/components/panel/GridPanelContent.js +13 -2
- package/components/panel/GridPanelFooter.d.ts +8 -1
- package/components/panel/GridPanelFooter.js +13 -2
- package/components/panel/GridPanelHeader.d.ts +8 -1
- package/components/panel/GridPanelHeader.js +13 -2
- package/components/toolbar/GridToolbar.d.ts +12 -2
- package/components/toolbar/GridToolbar.js +30 -7
- package/components/toolbar/GridToolbarExport.d.ts +5 -4
- package/components/toolbar/GridToolbarExport.js +15 -20
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +20 -0
- package/components/toolbar/GridToolbarQuickFilter.js +87 -0
- package/components/toolbar/index.d.ts +3 -1
- package/components/toolbar/index.js +3 -2
- package/components/virtualization/GridVirtualScroller.d.ts +4 -1
- package/components/virtualization/GridVirtualScrollerContent.d.ts +4 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.d.ts +4 -1
- package/constants/defaultGridSlotsComponents.js +4 -2
- package/constants/gridClasses.d.ts +32 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +8 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +11 -0
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +4 -4
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +6 -7
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/core/useGridErrorHandler.js +1 -2
- package/hooks/core/useGridStateInitialization.js +1 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -6
- package/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +8 -9
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +133 -32
- package/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/hooks/features/editRows/useGridEditing.old.js +4 -5
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +122 -42
- package/hooks/features/editRows/useGridRowEditing.old.js +21 -22
- package/hooks/features/events/useGridEvents.js +17 -18
- package/hooks/features/export/serializers/csvSerializer.js +5 -5
- package/hooks/features/export/useGridCsvExport.js +23 -16
- package/hooks/features/export/useGridPrintExport.js +22 -0
- package/hooks/features/export/utils.d.ts +3 -1
- package/hooks/features/export/utils.js +13 -0
- package/hooks/features/filter/gridFilterState.d.ts +1 -2
- package/hooks/features/filter/gridFilterState.js +3 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +8 -0
- package/hooks/features/filter/gridFilterUtils.js +84 -2
- package/hooks/features/filter/useGridFilter.js +20 -8
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/focus/useGridFocus.js +29 -33
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -5
- package/hooks/features/pagination/useGridPage.js +3 -4
- package/hooks/features/pagination/useGridPageSize.js +2 -3
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +4 -6
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -0
- package/hooks/features/rows/gridRowsSelector.js +1 -0
- package/hooks/features/rows/gridRowsState.d.ts +16 -11
- package/hooks/features/rows/gridRowsUtils.d.ts +14 -1
- package/hooks/features/rows/gridRowsUtils.js +79 -1
- package/hooks/features/rows/useGridRows.js +148 -128
- package/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/hooks/features/scroll/useGridScroll.js +6 -1
- package/hooks/features/selection/useGridSelection.d.ts +1 -1
- package/hooks/features/selection/useGridSelection.js +13 -10
- package/hooks/features/sorting/useGridSorting.js +8 -9
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +14 -5
- package/hooks/utils/useGridApiEventHandler.d.ts +4 -1
- package/hooks/utils/useGridApiEventHandler.js +22 -9
- package/hooks/utils/useGridNativeEventListener.js +1 -2
- package/hooks/utils/useGridSelector.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/internals/index.d.ts +4 -1
- package/internals/index.js +5 -2
- package/legacy/DataGrid/DataGrid.js +35 -1
- package/legacy/DataGrid/useDataGridProps.js +2 -1
- package/legacy/colDef/gridActionsColDef.js +2 -1
- package/legacy/colDef/gridBooleanColDef.js +2 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/legacy/colDef/gridDateColDef.js +4 -2
- package/legacy/colDef/gridNumericColDef.js +3 -2
- package/legacy/colDef/gridNumericOperators.js +28 -18
- package/legacy/colDef/gridSingleSelectColDef.js +3 -2
- package/legacy/colDef/gridSingleSelectOperators.js +55 -6
- package/legacy/colDef/gridStringColDef.js +3 -2
- package/legacy/colDef/gridStringOperators.js +25 -14
- package/legacy/components/GridFooter.js +11 -2
- package/legacy/components/GridRow.js +9 -5
- package/legacy/components/GridRowCount.js +1 -0
- package/legacy/components/GridScrollArea.js +3 -4
- package/legacy/components/GridSelectedRowCount.js +2 -1
- package/legacy/components/base/GridBody.js +1 -2
- package/legacy/components/base/GridOverlays.js +2 -3
- package/legacy/components/cell/GridActionsCell.js +13 -4
- package/legacy/components/cell/GridCell.js +8 -8
- package/legacy/components/cell/GridEditBooleanCell.js +132 -11
- package/legacy/components/cell/GridEditDateCell.js +148 -42
- package/legacy/components/cell/GridEditInputCell.js +61 -12
- package/legacy/components/cell/GridEditSingleSelectCell.js +41 -13
- package/legacy/components/cell/index.js +2 -0
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +15 -16
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +4 -5
- package/legacy/components/containers/GridFooterContainer.js +11 -2
- package/legacy/components/containers/GridRoot.js +23 -5
- package/legacy/components/containers/GridRootStyles.js +26 -5
- package/legacy/components/containers/GridToolbarContainer.js +12 -2
- package/legacy/components/menu/GridMenu.js +1 -0
- package/legacy/components/panel/GridPanelContent.js +13 -2
- package/legacy/components/panel/GridPanelFooter.js +13 -2
- package/legacy/components/panel/GridPanelHeader.js +13 -2
- package/legacy/components/toolbar/GridToolbar.js +31 -6
- package/legacy/components/toolbar/GridToolbarExport.js +18 -19
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +102 -0
- package/legacy/components/toolbar/index.js +3 -2
- package/legacy/constants/defaultGridSlotsComponents.js +4 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +8 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -10
- package/legacy/hooks/core/strategyProcessing/useGridStrategyProcessing.js +6 -7
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/core/useGridErrorHandler.js +1 -2
- package/legacy/hooks/core/useGridStateInitialization.js +1 -2
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -6
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/legacy/hooks/features/columns/useGridColumns.js +8 -9
- package/legacy/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +213 -83
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/legacy/hooks/features/editRows/useGridEditing.old.js +4 -5
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +126 -42
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +20 -21
- package/legacy/hooks/features/events/useGridEvents.js +17 -18
- package/legacy/hooks/features/export/serializers/csvSerializer.js +5 -5
- package/legacy/hooks/features/export/useGridCsvExport.js +24 -17
- package/legacy/hooks/features/export/useGridPrintExport.js +22 -0
- package/legacy/hooks/features/export/utils.js +14 -0
- package/legacy/hooks/features/filter/gridFilterState.js +3 -1
- package/legacy/hooks/features/filter/gridFilterUtils.js +96 -2
- package/legacy/hooks/features/filter/useGridFilter.js +20 -8
- package/legacy/hooks/features/focus/useGridFocus.js +31 -35
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -5
- package/legacy/hooks/features/pagination/useGridPage.js +3 -4
- package/legacy/hooks/features/pagination/useGridPageSize.js +2 -3
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +4 -6
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +82 -1
- package/legacy/hooks/features/rows/useGridRows.js +164 -131
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/legacy/hooks/features/scroll/useGridScroll.js +6 -1
- package/legacy/hooks/features/selection/useGridSelection.js +13 -10
- package/legacy/hooks/features/sorting/useGridSorting.js +8 -9
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +14 -5
- package/legacy/hooks/utils/useGridApiEventHandler.js +20 -9
- package/legacy/hooks/utils/useGridNativeEventListener.js +1 -2
- package/legacy/hooks/utils/useGridSelector.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 +7 -0
- package/legacy/locales/daDK.js +8 -1
- package/legacy/locales/deDE.js +10 -3
- package/legacy/locales/elGR.js +7 -0
- package/legacy/locales/esES.js +7 -0
- package/legacy/locales/faIR.js +8 -1
- package/legacy/locales/fiFI.js +7 -0
- package/legacy/locales/frFR.js +7 -0
- package/legacy/locales/heIL.js +8 -1
- package/legacy/locales/huHU.js +8 -1
- package/legacy/locales/itIT.js +7 -0
- package/legacy/locales/jaJP.js +7 -0
- package/legacy/locales/koKR.js +7 -0
- package/legacy/locales/nlNL.js +7 -0
- package/legacy/locales/plPL.js +8 -1
- package/legacy/locales/ptBR.js +8 -1
- package/legacy/locales/ruRU.js +7 -0
- package/legacy/locales/skSK.js +7 -0
- package/legacy/locales/trTR.js +8 -1
- package/legacy/locales/ukUA.js +7 -0
- package/legacy/locales/viVN.js +7 -0
- package/legacy/locales/zhCN.js +7 -0
- package/legacy/models/events/gridEvents.js +8 -0
- package/legacy/models/index.js +4 -3
- package/legacy/utils/createSelector.js +18 -2
- package/legacy/utils/exportAs.js +1 -1
- package/locales/arSD.js +8 -1
- package/locales/bgBG.js +8 -1
- package/locales/csCZ.js +7 -0
- package/locales/daDK.js +8 -1
- package/locales/deDE.js +10 -3
- package/locales/elGR.js +7 -0
- package/locales/esES.js +7 -0
- package/locales/faIR.js +8 -1
- package/locales/fiFI.js +7 -0
- package/locales/frFR.js +7 -0
- package/locales/heIL.js +8 -1
- package/locales/huHU.js +8 -1
- package/locales/itIT.js +7 -0
- package/locales/jaJP.js +7 -0
- package/locales/koKR.js +7 -0
- package/locales/nlNL.js +7 -0
- package/locales/plPL.js +8 -1
- package/locales/ptBR.js +8 -1
- package/locales/ruRU.js +7 -0
- package/locales/skSK.js +7 -0
- package/locales/trTR.js +8 -1
- package/locales/ukUA.js +7 -0
- package/locales/viVN.js +7 -0
- package/locales/zhCN.js +7 -0
- package/models/api/gridCoreApi.d.ts +10 -0
- package/models/api/gridEditingApi.d.ts +23 -4
- package/models/api/gridFilterApi.d.ts +5 -0
- package/models/api/gridFocusApi.d.ts +1 -0
- package/models/api/gridLocaleTextApi.d.ts +5 -0
- package/models/api/gridRowApi.d.ts +34 -0
- package/models/api/index.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +13 -0
- package/models/events/gridEventLookup.d.ts +293 -3
- package/models/events/gridEvents.d.ts +8 -251
- package/models/events/gridEvents.js +8 -0
- package/models/gridExport.d.ts +29 -2
- package/models/gridFilterModel.d.ts +11 -0
- package/models/gridFilterOperator.d.ts +1 -1
- package/models/gridIconSlotsComponent.d.ts +10 -0
- package/models/gridStateCommunity.d.ts +0 -2
- package/models/index.d.ts +1 -1
- package/models/index.js +4 -3
- package/models/props/DataGridProps.d.ts +56 -28
- package/modern/DataGrid/DataGrid.js +35 -1
- package/modern/DataGrid/useDataGridProps.js +2 -1
- package/modern/colDef/gridActionsColDef.js +2 -1
- package/modern/colDef/gridBooleanColDef.js +2 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/modern/colDef/gridDateColDef.js +4 -2
- package/modern/colDef/gridNumericColDef.js +3 -2
- package/modern/colDef/gridNumericOperators.js +11 -0
- package/modern/colDef/gridSingleSelectColDef.js +3 -2
- package/modern/colDef/gridSingleSelectOperators.js +52 -0
- package/modern/colDef/gridStringColDef.js +3 -2
- package/modern/colDef/gridStringOperators.js +12 -0
- package/modern/components/GridFooter.js +11 -2
- package/modern/components/GridRow.js +9 -5
- package/modern/components/GridRowCount.js +1 -0
- package/modern/components/GridScrollArea.js +3 -4
- package/modern/components/GridSelectedRowCount.js +2 -1
- package/modern/components/base/GridBody.js +1 -2
- package/modern/components/base/GridOverlays.js +2 -3
- package/modern/components/cell/GridActionsCell.js +14 -3
- package/modern/components/cell/GridCell.js +8 -8
- package/modern/components/cell/GridEditBooleanCell.js +101 -6
- package/modern/components/cell/GridEditDateCell.js +99 -5
- package/modern/components/cell/GridEditInputCell.js +29 -5
- package/modern/components/cell/GridEditSingleSelectCell.js +28 -5
- package/modern/components/cell/index.js +2 -0
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +15 -16
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -3
- package/modern/components/columnSelection/GridHeaderCheckbox.js +4 -5
- package/modern/components/containers/GridFooterContainer.js +11 -2
- package/modern/components/containers/GridRoot.js +25 -3
- package/modern/components/containers/GridRootStyles.js +36 -1
- package/modern/components/containers/GridToolbarContainer.js +12 -2
- package/modern/components/menu/GridMenu.js +1 -0
- package/modern/components/panel/GridPanelContent.js +13 -2
- package/modern/components/panel/GridPanelFooter.js +13 -2
- package/modern/components/panel/GridPanelHeader.js +13 -2
- package/modern/components/toolbar/GridToolbar.js +30 -7
- package/modern/components/toolbar/GridToolbarExport.js +15 -20
- package/modern/components/toolbar/GridToolbarQuickFilter.js +85 -0
- package/modern/components/toolbar/index.js +3 -2
- package/modern/constants/defaultGridSlotsComponents.js +4 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +8 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -9
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +6 -7
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/core/useGridErrorHandler.js +1 -2
- package/modern/hooks/core/useGridStateInitialization.js +1 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -6
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/modern/hooks/features/columns/useGridColumns.js +8 -9
- package/modern/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +131 -32
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/modern/hooks/features/editRows/useGridEditing.old.js +4 -5
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +120 -42
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +21 -22
- package/modern/hooks/features/events/useGridEvents.js +17 -18
- package/modern/hooks/features/export/serializers/csvSerializer.js +5 -5
- package/modern/hooks/features/export/useGridCsvExport.js +21 -16
- package/modern/hooks/features/export/useGridPrintExport.js +20 -0
- package/modern/hooks/features/export/utils.js +13 -0
- package/modern/hooks/features/filter/gridFilterState.js +3 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +80 -2
- package/modern/hooks/features/filter/useGridFilter.js +20 -8
- package/modern/hooks/features/focus/useGridFocus.js +29 -33
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -5
- package/modern/hooks/features/pagination/useGridPage.js +3 -4
- package/modern/hooks/features/pagination/useGridPageSize.js +2 -3
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +4 -6
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +77 -1
- package/modern/hooks/features/rows/useGridRows.js +148 -128
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/modern/hooks/features/scroll/useGridScroll.js +6 -1
- package/modern/hooks/features/selection/useGridSelection.js +13 -10
- package/modern/hooks/features/sorting/useGridSorting.js +8 -9
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +14 -5
- package/modern/hooks/utils/useGridApiEventHandler.js +20 -9
- package/modern/hooks/utils/useGridNativeEventListener.js +1 -2
- package/modern/hooks/utils/useGridSelector.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 +7 -0
- package/modern/locales/daDK.js +8 -1
- package/modern/locales/deDE.js +10 -3
- package/modern/locales/elGR.js +7 -0
- package/modern/locales/esES.js +7 -0
- package/modern/locales/faIR.js +8 -1
- package/modern/locales/fiFI.js +7 -0
- package/modern/locales/frFR.js +7 -0
- package/modern/locales/heIL.js +8 -1
- package/modern/locales/huHU.js +8 -1
- package/modern/locales/itIT.js +7 -0
- package/modern/locales/jaJP.js +7 -0
- package/modern/locales/koKR.js +7 -0
- package/modern/locales/nlNL.js +7 -0
- package/modern/locales/plPL.js +8 -1
- package/modern/locales/ptBR.js +8 -1
- package/modern/locales/ruRU.js +7 -0
- package/modern/locales/skSK.js +7 -0
- package/modern/locales/trTR.js +8 -1
- package/modern/locales/ukUA.js +7 -0
- package/modern/locales/viVN.js +7 -0
- package/modern/locales/zhCN.js +7 -0
- package/modern/models/events/gridEvents.js +8 -0
- package/modern/models/index.js +4 -3
- package/modern/utils/createSelector.js +20 -2
- package/modern/utils/exportAs.js +1 -1
- package/node/DataGrid/DataGrid.js +35 -1
- package/node/DataGrid/useDataGridProps.js +2 -1
- package/node/colDef/gridActionsColDef.js +2 -1
- package/node/colDef/gridBooleanColDef.js +2 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/node/colDef/gridDateColDef.js +4 -2
- package/node/colDef/gridNumericColDef.js +2 -1
- package/node/colDef/gridNumericOperators.js +15 -1
- package/node/colDef/gridSingleSelectColDef.js +2 -1
- package/node/colDef/gridSingleSelectOperators.js +56 -1
- package/node/colDef/gridStringColDef.js +2 -1
- package/node/colDef/gridStringOperators.js +16 -1
- package/node/components/GridFooter.js +10 -1
- package/node/components/GridRow.js +9 -6
- package/node/components/GridRowCount.js +1 -0
- package/node/components/GridScrollArea.js +3 -5
- package/node/components/GridSelectedRowCount.js +2 -1
- package/node/components/base/GridBody.js +1 -3
- package/node/components/base/GridOverlays.js +2 -4
- package/node/components/cell/GridActionsCell.js +13 -4
- package/node/components/cell/GridCell.js +7 -7
- package/node/components/cell/GridEditBooleanCell.js +100 -5
- package/node/components/cell/GridEditDateCell.js +98 -4
- package/node/components/cell/GridEditInputCell.js +29 -5
- package/node/components/cell/GridEditSingleSelectCell.js +28 -6
- package/node/components/cell/index.js +26 -0
- package/node/components/columnHeaders/GridColumnHeaderItem.js +15 -17
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -4
- package/node/components/columnSelection/GridHeaderCheckbox.js +4 -6
- package/node/components/containers/GridFooterContainer.js +10 -1
- package/node/components/containers/GridRoot.js +24 -3
- package/node/components/containers/GridRootStyles.js +36 -1
- package/node/components/containers/GridToolbarContainer.js +11 -1
- package/node/components/menu/GridMenu.js +1 -0
- package/node/components/panel/GridPanelContent.js +11 -1
- package/node/components/panel/GridPanelFooter.js +11 -1
- package/node/components/panel/GridPanelHeader.js +11 -1
- package/node/components/toolbar/GridToolbar.js +32 -7
- package/node/components/toolbar/GridToolbarExport.js +14 -19
- package/node/components/toolbar/GridToolbarQuickFilter.js +109 -0
- package/node/components/toolbar/index.js +42 -11
- package/node/constants/defaultGridSlotsComponents.js +3 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +8 -1
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +10 -8
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +6 -8
- package/node/hooks/core/useGridApiInitialization.js +3 -4
- package/node/hooks/core/useGridErrorHandler.js +1 -3
- package/node/hooks/core/useGridStateInitialization.js +1 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -7
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +3 -4
- package/node/hooks/features/columns/useGridColumnSpanning.js +1 -3
- package/node/hooks/features/columns/useGridColumns.js +8 -10
- package/node/hooks/features/dimensions/useGridDimensions.js +8 -10
- package/node/hooks/features/editRows/useGridCellEditing.new.js +133 -32
- package/node/hooks/features/editRows/useGridCellEditing.old.js +20 -22
- package/node/hooks/features/editRows/useGridEditing.old.js +4 -6
- package/node/hooks/features/editRows/useGridRowEditing.new.js +122 -43
- package/node/hooks/features/editRows/useGridRowEditing.old.js +21 -23
- package/node/hooks/features/events/useGridEvents.js +17 -19
- package/node/hooks/features/export/serializers/csvSerializer.js +5 -5
- package/node/hooks/features/export/useGridCsvExport.js +26 -17
- package/node/hooks/features/export/useGridPrintExport.js +25 -0
- package/node/hooks/features/export/utils.js +19 -2
- package/node/hooks/features/filter/gridFilterState.js +3 -1
- package/node/hooks/features/filter/gridFilterUtils.js +92 -3
- package/node/hooks/features/filter/useGridFilter.js +21 -9
- package/node/hooks/features/focus/useGridFocus.js +29 -34
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -6
- package/node/hooks/features/pagination/useGridPage.js +3 -5
- package/node/hooks/features/pagination/useGridPageSize.js +2 -4
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +4 -8
- package/node/hooks/features/rows/gridRowsSelector.js +3 -1
- package/node/hooks/features/rows/gridRowsUtils.js +95 -1
- package/node/hooks/features/rows/useGridRows.js +150 -126
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/node/hooks/features/scroll/useGridScroll.js +6 -1
- package/node/hooks/features/selection/useGridSelection.js +13 -11
- package/node/hooks/features/sorting/useGridSorting.js +8 -10
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +14 -6
- package/node/hooks/utils/useGridApiEventHandler.js +22 -10
- package/node/hooks/utils/useGridNativeEventListener.js +1 -3
- package/node/hooks/utils/useGridSelector.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +39 -3
- package/node/locales/arSD.js +8 -1
- package/node/locales/bgBG.js +8 -1
- package/node/locales/csCZ.js +7 -0
- package/node/locales/daDK.js +8 -1
- package/node/locales/deDE.js +10 -3
- package/node/locales/elGR.js +7 -0
- package/node/locales/esES.js +7 -0
- package/node/locales/faIR.js +8 -1
- package/node/locales/fiFI.js +7 -0
- package/node/locales/frFR.js +7 -0
- package/node/locales/heIL.js +8 -1
- package/node/locales/huHU.js +8 -1
- package/node/locales/itIT.js +7 -0
- package/node/locales/jaJP.js +7 -0
- package/node/locales/koKR.js +7 -0
- package/node/locales/nlNL.js +7 -0
- package/node/locales/plPL.js +8 -1
- package/node/locales/ptBR.js +8 -1
- package/node/locales/ruRU.js +7 -0
- package/node/locales/skSK.js +7 -0
- package/node/locales/trTR.js +8 -1
- package/node/locales/ukUA.js +7 -0
- package/node/locales/viVN.js +7 -0
- package/node/locales/zhCN.js +7 -0
- package/node/models/events/gridEvents.js +8 -0
- package/node/models/index.js +0 -13
- package/node/utils/createSelector.js +25 -4
- package/node/utils/exportAs.js +1 -1
- package/package.json +3 -2
- package/utils/createSelector.d.ts +2 -1
- package/utils/createSelector.js +20 -2
- package/utils/exportAs.d.ts +2 -2
- package/utils/exportAs.js +1 -1
|
@@ -11,4 +11,12 @@ export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, d
|
|
|
11
11
|
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
12
12
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
13
13
|
*/
|
|
14
|
+
export declare const buildAggregatedFilterItemsApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier | null;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a method to easily check if a row is matching the current quick filter.
|
|
17
|
+
* @param {any[]} values The model with which we want to filter the rows.
|
|
18
|
+
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
19
|
+
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildAggregatedQuickFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier | null;
|
|
14
22
|
export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { GridLinkOperator } from '../../../models';
|
|
3
3
|
import { buildWarning } from '../../../utils/warning';
|
|
4
|
+
import { gridColumnFieldsSelector } from '../columns';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Adds default values to the optional fields of a filter items.
|
|
@@ -76,7 +77,7 @@ export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFil
|
|
|
76
77
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
77
78
|
*/
|
|
78
79
|
|
|
79
|
-
export const
|
|
80
|
+
export const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
80
81
|
const {
|
|
81
82
|
items,
|
|
82
83
|
linkOperator = GridLinkOperator.And
|
|
@@ -144,7 +145,7 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
return (rowId, shouldApplyFilter) => {
|
|
147
|
-
const filteredAppliers = shouldApplyFilter ? appliers.filter(applier => shouldApplyFilter(applier.item)) : appliers; // Return `false` as soon as we have a failing filter
|
|
148
|
+
const filteredAppliers = shouldApplyFilter ? appliers.filter(applier => shouldApplyFilter(applier.item.columnField)) : appliers; // Return `false` as soon as we have a failing filter
|
|
148
149
|
|
|
149
150
|
if (linkOperator === GridLinkOperator.And) {
|
|
150
151
|
return filteredAppliers.every(applier => applier.fn(rowId));
|
|
@@ -153,4 +154,85 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
|
153
154
|
|
|
154
155
|
return filteredAppliers.some(applier => applier.fn(rowId));
|
|
155
156
|
};
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Generates a method to easily check if a row is matching the current quick filter.
|
|
160
|
+
* @param {any[]} values The model with which we want to filter the rows.
|
|
161
|
+
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
162
|
+
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
export const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
166
|
+
const {
|
|
167
|
+
quickFilterValues = [],
|
|
168
|
+
quickFilterLogicOperator = GridLinkOperator.And
|
|
169
|
+
} = filterModel;
|
|
170
|
+
|
|
171
|
+
if (quickFilterValues.length === 0) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const columnsFields = gridColumnFieldsSelector(apiRef);
|
|
176
|
+
const appliersPerColumnField = {};
|
|
177
|
+
columnsFields.forEach(field => {
|
|
178
|
+
const column = apiRef.current.getColumn(field);
|
|
179
|
+
const getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
|
|
180
|
+
|
|
181
|
+
if (!getApplyQuickFilterFn) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
appliersPerColumnField[field] = quickFilterValues.map(value => getApplyQuickFilterFn(value, column, apiRef));
|
|
186
|
+
}); // If some value does not have an applier we ignore them
|
|
187
|
+
|
|
188
|
+
const sanitizedQuickFilterValues = quickFilterValues.filter((value, index) => Object.keys(appliersPerColumnField).some(field => appliersPerColumnField[field][index] != null));
|
|
189
|
+
return (rowId, shouldApplyFilter) => {
|
|
190
|
+
const usedCellParams = {};
|
|
191
|
+
Object.keys(appliersPerColumnField).forEach(columnField => {
|
|
192
|
+
if (!shouldApplyFilter || shouldApplyFilter(columnField)) {
|
|
193
|
+
usedCellParams[columnField] = apiRef.current.getCellParams(rowId, columnField);
|
|
194
|
+
}
|
|
195
|
+
}); // Return `false` as soon as we have a quick filter value that does not match any column
|
|
196
|
+
|
|
197
|
+
if (quickFilterLogicOperator === GridLinkOperator.And) {
|
|
198
|
+
return sanitizedQuickFilterValues.every((value, index) => Object.keys(appliersPerColumnField).some(field => {
|
|
199
|
+
var _appliersPerColumnFie, _appliersPerColumnFie2;
|
|
200
|
+
|
|
201
|
+
if (appliersPerColumnField[field][index] == null) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (_appliersPerColumnFie = (_appliersPerColumnFie2 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie.call(_appliersPerColumnFie2, usedCellParams[field]);
|
|
206
|
+
}));
|
|
207
|
+
} // Return `true` as soon as we have have a quick filter value that match any column
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
return sanitizedQuickFilterValues.some((value, index) => Object.keys(appliersPerColumnField).some(field => {
|
|
211
|
+
var _appliersPerColumnFie3, _appliersPerColumnFie4;
|
|
212
|
+
|
|
213
|
+
if (appliersPerColumnField[field][index] == null) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return (_appliersPerColumnFie3 = (_appliersPerColumnFie4 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie3.call(_appliersPerColumnFie4, usedCellParams[field]);
|
|
218
|
+
}));
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
export const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
222
|
+
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef);
|
|
223
|
+
const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
|
|
224
|
+
|
|
225
|
+
if (isRowMatchingFilterItems == null && isRowMatchingQuickFilter == null) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (isRowMatchingFilterItems == null) {
|
|
230
|
+
return isRowMatchingQuickFilter;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (isRowMatchingQuickFilter == null) {
|
|
234
|
+
return isRowMatchingFilterItems;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return (rowId, shouldApplyFilter) => isRowMatchingFilterItems(rowId, shouldApplyFilter) && isRowMatchingQuickFilter(rowId, shouldApplyFilter);
|
|
156
238
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { GridEvents } from '../../../models/events';
|
|
4
3
|
import { GridFeatureModeConstant } from '../../../models/gridFeatureMode';
|
|
5
4
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
6
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -14,6 +13,7 @@ import { gridRowIdsSelector } from '../rows';
|
|
|
14
13
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
15
14
|
import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
|
|
16
15
|
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel } from './gridFilterUtils';
|
|
16
|
+
import { isDeepEqual } from '../../../utils/utils';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
export const filterStateInitializer = (state, props, apiRef) => {
|
|
19
19
|
var _ref, _props$filterModel, _props$initialState, _props$initialState$f;
|
|
@@ -42,7 +42,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
42
42
|
propModel: props.filterModel,
|
|
43
43
|
propOnChange: props.onFilterModelChange,
|
|
44
44
|
stateSelector: gridFilterModelSelector,
|
|
45
|
-
changeEvent:
|
|
45
|
+
changeEvent: 'filterModelChange'
|
|
46
46
|
});
|
|
47
47
|
const updateFilteredRows = React.useCallback(() => {
|
|
48
48
|
apiRef.current.setState(state => {
|
|
@@ -55,7 +55,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
55
55
|
filter: _extends({}, state.filter, filteringResult)
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
-
apiRef.current.publishEvent(
|
|
58
|
+
apiRef.current.publishEvent('filteredRowsSet');
|
|
59
59
|
}, [props.filterMode, apiRef]);
|
|
60
60
|
/**
|
|
61
61
|
* API METHODS
|
|
@@ -135,6 +135,17 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
135
135
|
linkOperator
|
|
136
136
|
}));
|
|
137
137
|
}, [apiRef]);
|
|
138
|
+
const setQuickFilterValues = React.useCallback(values => {
|
|
139
|
+
const filterModel = gridFilterModelSelector(apiRef);
|
|
140
|
+
|
|
141
|
+
if (isDeepEqual(filterModel.quickFilterValues, values)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
apiRef.current.setFilterModel(_extends({}, filterModel, {
|
|
146
|
+
quickFilterValues: [...values]
|
|
147
|
+
}));
|
|
148
|
+
}, [apiRef]);
|
|
138
149
|
const setFilterModel = React.useCallback(model => {
|
|
139
150
|
const currentModel = gridFilterModelSelector(apiRef);
|
|
140
151
|
|
|
@@ -156,7 +167,8 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
156
167
|
setFilterModel,
|
|
157
168
|
showFilterPanel,
|
|
158
169
|
hideFilterPanel,
|
|
159
|
-
getVisibleRowModels
|
|
170
|
+
getVisibleRowModels,
|
|
171
|
+
setQuickFilterValues
|
|
160
172
|
};
|
|
161
173
|
useGridApiMethod(apiRef, filterApi, 'GridFilterApi');
|
|
162
174
|
/**
|
|
@@ -251,10 +263,10 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
251
263
|
}, [apiRef]); // Do not call `apiRef.current.forceUpdate` to avoid re-render before updating the sorted rows.
|
|
252
264
|
// Otherwise, the state is not consistent during the render
|
|
253
265
|
|
|
254
|
-
useGridApiEventHandler(apiRef,
|
|
255
|
-
useGridApiEventHandler(apiRef,
|
|
256
|
-
useGridApiEventHandler(apiRef,
|
|
257
|
-
useGridApiEventHandler(apiRef,
|
|
266
|
+
useGridApiEventHandler(apiRef, 'rowsSet', updateFilteredRows);
|
|
267
|
+
useGridApiEventHandler(apiRef, 'rowExpansionChange', apiRef.current.unstable_applyFilters);
|
|
268
|
+
useGridApiEventHandler(apiRef, 'columnsChange', handleColumnsChange);
|
|
269
|
+
useGridApiEventHandler(apiRef, 'activeStrategyProcessorChange', handleStrategyProcessorChange);
|
|
258
270
|
/**
|
|
259
271
|
* 1ST RENDER
|
|
260
272
|
*/
|
|
@@ -8,4 +8,4 @@ export declare const focusStateInitializer: GridStateInitializer;
|
|
|
8
8
|
* @requires useGridRows (method)
|
|
9
9
|
* @requires useGridEditing (event)
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridFocus: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, '
|
|
11
|
+
export declare const useGridFocus: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ownerDocument } from '@mui/material/utils';
|
|
4
|
-
import { GridEvents } from '../../../models/events';
|
|
5
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
6
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
@@ -30,14 +29,9 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
30
29
|
const logger = useGridLogger(apiRef, 'useGridFocus');
|
|
31
30
|
const lastClickedCell = React.useRef(null);
|
|
32
31
|
const setCellFocus = React.useCallback((id, field) => {
|
|
33
|
-
// The row might have been deleted
|
|
34
|
-
if (!apiRef.current.getRow(id)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
32
|
const focusedCell = gridFocusCellSelector(apiRef);
|
|
39
33
|
|
|
40
|
-
if ((focusedCell == null ? void 0 : focusedCell.id) === id && focusedCell.field === field) {
|
|
34
|
+
if ((focusedCell == null ? void 0 : focusedCell.id) === id && (focusedCell == null ? void 0 : focusedCell.field) === field) {
|
|
41
35
|
return;
|
|
42
36
|
}
|
|
43
37
|
|
|
@@ -60,14 +54,19 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
60
54
|
}
|
|
61
55
|
});
|
|
62
56
|
});
|
|
63
|
-
apiRef.current.forceUpdate();
|
|
64
|
-
|
|
57
|
+
apiRef.current.forceUpdate(); // The row might have been deleted
|
|
58
|
+
|
|
59
|
+
if (!apiRef.current.getRow(id)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
apiRef.current.publishEvent('cellFocusIn', apiRef.current.getCellParams(id, field));
|
|
65
64
|
}, [apiRef, logger]);
|
|
66
65
|
const setColumnHeaderFocus = React.useCallback((field, event = {}) => {
|
|
67
66
|
const cell = gridFocusCellSelector(apiRef);
|
|
68
67
|
|
|
69
68
|
if (cell) {
|
|
70
|
-
apiRef.current.publishEvent(
|
|
69
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(cell.id, cell.field), event);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
apiRef.current.setState(state => {
|
|
@@ -196,7 +195,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
196
195
|
// Publishes an event to notify that the focus was lost
|
|
197
196
|
|
|
198
197
|
|
|
199
|
-
apiRef.current.publishEvent(
|
|
198
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field), event);
|
|
200
199
|
|
|
201
200
|
if (cellParams) {
|
|
202
201
|
apiRef.current.setCellFocus(cellParams.id, cellParams.field);
|
|
@@ -221,27 +220,23 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
221
220
|
apiRef.current.setCellFocus(params.id, params.field);
|
|
222
221
|
}
|
|
223
222
|
}, [apiRef]);
|
|
223
|
+
const handleRowSet = React.useCallback(() => {
|
|
224
|
+
const cell = gridFocusCellSelector(apiRef); // If the focused cell is in a row which does not exist anymore, then remove the focus
|
|
225
|
+
|
|
226
|
+
if (cell && !apiRef.current.getRow(cell.id)) {
|
|
227
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
228
|
+
focus: {
|
|
229
|
+
cell: null,
|
|
230
|
+
columnHeader: null
|
|
231
|
+
}
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
}, [apiRef]);
|
|
224
235
|
useGridApiMethod(apiRef, {
|
|
225
236
|
setCellFocus,
|
|
226
237
|
setColumnHeaderFocus,
|
|
227
238
|
unstable_moveFocusToRelativeCell: moveFocusToRelativeCell
|
|
228
239
|
}, 'GridFocusApi');
|
|
229
|
-
React.useEffect(() => {
|
|
230
|
-
const cell = gridFocusCellSelector(apiRef);
|
|
231
|
-
|
|
232
|
-
if (cell) {
|
|
233
|
-
const updatedRow = apiRef.current.getRow(cell.id);
|
|
234
|
-
|
|
235
|
-
if (!updatedRow) {
|
|
236
|
-
apiRef.current.setState(state => _extends({}, state, {
|
|
237
|
-
focus: {
|
|
238
|
-
cell: null,
|
|
239
|
-
columnHeader: null
|
|
240
|
-
}
|
|
241
|
-
}));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}, [apiRef, props.rows]);
|
|
245
240
|
React.useEffect(() => {
|
|
246
241
|
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
247
242
|
doc.addEventListener('click', handleDocumentClick);
|
|
@@ -249,10 +244,11 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
249
244
|
doc.removeEventListener('click', handleDocumentClick);
|
|
250
245
|
};
|
|
251
246
|
}, [apiRef, handleDocumentClick]);
|
|
252
|
-
useGridApiEventHandler(apiRef,
|
|
253
|
-
useGridApiEventHandler(apiRef,
|
|
254
|
-
useGridApiEventHandler(apiRef,
|
|
255
|
-
useGridApiEventHandler(apiRef,
|
|
256
|
-
useGridApiEventHandler(apiRef,
|
|
257
|
-
useGridApiEventHandler(apiRef,
|
|
247
|
+
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
248
|
+
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
249
|
+
useGridApiEventHandler(apiRef, 'cellMouseUp', handleCellMouseUp);
|
|
250
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
251
|
+
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
252
|
+
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
253
|
+
useGridApiEventHandler(apiRef, 'rowsSet', handleRowSet);
|
|
258
254
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridEvents } from '../../../models/events';
|
|
3
2
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
4
3
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
4
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
@@ -316,10 +315,10 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
316
315
|
const cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
317
316
|
|
|
318
317
|
if (cellParams.cellMode !== GridCellModes.Edit && isNavigationKey(event.key)) {
|
|
319
|
-
apiRef.current.publishEvent(
|
|
318
|
+
apiRef.current.publishEvent('cellNavigationKeyDown', cellParams, event);
|
|
320
319
|
}
|
|
321
320
|
}, [apiRef]);
|
|
322
|
-
useGridApiEventHandler(apiRef,
|
|
323
|
-
useGridApiEventHandler(apiRef,
|
|
324
|
-
useGridApiEventHandler(apiRef,
|
|
321
|
+
useGridApiEventHandler(apiRef, 'cellNavigationKeyDown', handleCellNavigationKeyDown);
|
|
322
|
+
useGridApiEventHandler(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
323
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
325
324
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from '../../utils';
|
|
4
|
-
import { GridEvents } from '../../../models/events';
|
|
5
4
|
import { gridVisibleTopLevelRowCountSelector } from '../filter';
|
|
6
5
|
import { gridPageSelector, gridPageSizeSelector } from './gridPaginationSelector';
|
|
7
6
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
@@ -45,7 +44,7 @@ export const useGridPage = (apiRef, props) => {
|
|
|
45
44
|
propModel: props.page,
|
|
46
45
|
propOnChange: props.onPageChange,
|
|
47
46
|
stateSelector: gridPageSelector,
|
|
48
|
-
changeEvent:
|
|
47
|
+
changeEvent: 'pageChange'
|
|
49
48
|
});
|
|
50
49
|
/**
|
|
51
50
|
* API METHODS
|
|
@@ -114,8 +113,8 @@ export const useGridPage = (apiRef, props) => {
|
|
|
114
113
|
rowIndex: gridPageSelector(apiRef) * gridPageSizeSelector(apiRef)
|
|
115
114
|
});
|
|
116
115
|
|
|
117
|
-
useGridApiEventHandler(apiRef,
|
|
118
|
-
useGridApiEventHandler(apiRef,
|
|
116
|
+
useGridApiEventHandler(apiRef, 'pageSizeChange', handlePageSizeChange);
|
|
117
|
+
useGridApiEventHandler(apiRef, 'pageChange', handlePageChange);
|
|
119
118
|
/**
|
|
120
119
|
* EFFECTS
|
|
121
120
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { GridEvents } from '../../../models/events';
|
|
4
3
|
import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelector } from '../../utils';
|
|
5
4
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
6
5
|
import { gridDensityRowHeightSelector } from '../density';
|
|
@@ -27,7 +26,7 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
27
26
|
propModel: props.pageSize,
|
|
28
27
|
propOnChange: props.onPageSizeChange,
|
|
29
28
|
stateSelector: gridPageSizeSelector,
|
|
30
|
-
changeEvent:
|
|
29
|
+
changeEvent: 'pageSizeChange'
|
|
31
30
|
});
|
|
32
31
|
/**
|
|
33
32
|
* API METHODS
|
|
@@ -100,7 +99,7 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
100
99
|
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
101
100
|
apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
|
|
102
101
|
}, [apiRef, props.autoPageSize, rowHeight]);
|
|
103
|
-
useGridApiEventHandler(apiRef,
|
|
102
|
+
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
104
103
|
/**
|
|
105
104
|
* EFFECTS
|
|
106
105
|
*/
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { GridEvents } from '../../../models/events';
|
|
4
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
6
5
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
7
6
|
import { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
|
|
8
|
-
import { useGridSelector } from '../../utils/useGridSelector';
|
|
9
7
|
export const preferencePanelStateInitializer = (state, props) => {
|
|
10
8
|
var _props$initialState$p, _props$initialState;
|
|
11
9
|
|
|
@@ -21,7 +19,6 @@ export const preferencePanelStateInitializer = (state, props) => {
|
|
|
21
19
|
|
|
22
20
|
export const useGridPreferencesPanel = apiRef => {
|
|
23
21
|
const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
24
|
-
const preferencePanelState = useGridSelector(apiRef, gridPreferencePanelStateSelector);
|
|
25
22
|
const hideTimeout = React.useRef();
|
|
26
23
|
const immediateTimeout = React.useRef();
|
|
27
24
|
/**
|
|
@@ -30,9 +27,10 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
30
27
|
|
|
31
28
|
const hidePreferences = React.useCallback(() => {
|
|
32
29
|
logger.debug('Hiding Preferences Panel');
|
|
30
|
+
const preferencePanelState = gridPreferencePanelStateSelector(apiRef.current.state);
|
|
33
31
|
|
|
34
32
|
if (preferencePanelState.openedPanelValue) {
|
|
35
|
-
apiRef.current.publishEvent(
|
|
33
|
+
apiRef.current.publishEvent('preferencePanelClose', {
|
|
36
34
|
openedPanelValue: preferencePanelState.openedPanelValue
|
|
37
35
|
});
|
|
38
36
|
}
|
|
@@ -43,7 +41,7 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
43
41
|
}
|
|
44
42
|
}));
|
|
45
43
|
apiRef.current.forceUpdate();
|
|
46
|
-
}, [apiRef, logger
|
|
44
|
+
}, [apiRef, logger]); // This is to prevent the preferences from closing when you open a select box or another panel,
|
|
47
45
|
// The issue is in MUI core V4 => Fixed in V5
|
|
48
46
|
|
|
49
47
|
const doNotHidePanel = React.useCallback(() => {
|
|
@@ -63,7 +61,7 @@ export const useGridPreferencesPanel = apiRef => {
|
|
|
63
61
|
openedPanelValue: newValue
|
|
64
62
|
})
|
|
65
63
|
}));
|
|
66
|
-
apiRef.current.publishEvent(
|
|
64
|
+
apiRef.current.publishEvent('preferencePanelOpen', {
|
|
67
65
|
openedPanelValue: newValue
|
|
68
66
|
});
|
|
69
67
|
apiRef.current.forceUpdate();
|
|
@@ -4,6 +4,7 @@ export declare const gridRowCountSelector: import("../../../utils/createSelector
|
|
|
4
4
|
export declare const gridRowsLoadingSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, boolean | undefined>;
|
|
5
5
|
export declare const gridTopLevelRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
6
6
|
export declare const gridRowsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowsLookup<any>>;
|
|
7
|
+
export declare const gridRowsIdToIdLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<string, import("../../..").GridRowId>>;
|
|
7
8
|
export declare const gridRowTreeSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowTreeConfig>;
|
|
8
9
|
export declare const gridRowGroupingNameSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string>;
|
|
9
10
|
export declare const gridRowTreeDepthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
@@ -4,6 +4,7 @@ export const gridRowCountSelector = createSelector(gridRowsStateSelector, rows =
|
|
|
4
4
|
export const gridRowsLoadingSelector = createSelector(gridRowsStateSelector, rows => rows.loading);
|
|
5
5
|
export const gridTopLevelRowCountSelector = createSelector(gridRowsStateSelector, rows => rows.totalTopLevelRowCount);
|
|
6
6
|
export const gridRowsLookupSelector = createSelector(gridRowsStateSelector, rows => rows.idRowsLookup);
|
|
7
|
+
export const gridRowsIdToIdLookupSelector = createSelector(gridRowsStateSelector, rows => rows.idToIdLookup);
|
|
7
8
|
export const gridRowTreeSelector = createSelector(gridRowsStateSelector, rows => rows.tree);
|
|
8
9
|
export const gridRowGroupingNameSelector = createSelector(gridRowsStateSelector, rows => rows.groupingName);
|
|
9
10
|
export const gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, rows => rows.treeDepth);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { GridRowId, GridRowsLookup, GridRowTreeConfig } from '../../../models/gridRows';
|
|
2
|
+
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
export interface GridRowTreeCreationParams {
|
|
4
4
|
ids: GridRowId[];
|
|
5
5
|
idRowsLookup: GridRowsLookup;
|
|
6
|
+
idToIdLookup: Record<string, GridRowId>;
|
|
6
7
|
previousTree: GridRowTreeConfig | null;
|
|
7
8
|
}
|
|
8
9
|
export interface GridRowTreeCreationValue {
|
|
@@ -15,20 +16,18 @@ export interface GridRowTreeCreationValue {
|
|
|
15
16
|
treeDepth: number;
|
|
16
17
|
ids: GridRowId[];
|
|
17
18
|
idRowsLookup: GridRowsLookup;
|
|
19
|
+
idToIdLookup: Record<string, GridRowId>;
|
|
18
20
|
}
|
|
19
|
-
export
|
|
20
|
-
export interface GridRowsInternalCacheState {
|
|
21
|
-
value: GridRowInternalCacheValue;
|
|
21
|
+
export interface GridRowsInternalCache extends Omit<GridRowTreeCreationParams, 'previousTree'> {
|
|
22
22
|
/**
|
|
23
23
|
* The rows as they were the last time all the rows have been updated at once
|
|
24
24
|
* It is used to avoid processing several time the same set of rows
|
|
25
25
|
*/
|
|
26
|
-
rowsBeforePartialUpdates:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
lastUpdateMs: number;
|
|
26
|
+
rowsBeforePartialUpdates: DataGridProcessedProps['rows'];
|
|
27
|
+
/**
|
|
28
|
+
* The value of the `loading` prop since the last time that the rows state was updated.
|
|
29
|
+
*/
|
|
30
|
+
loadingPropBeforePartialUpdates: DataGridProcessedProps['loading'];
|
|
32
31
|
}
|
|
33
32
|
export interface GridRowsState extends GridRowTreeCreationValue {
|
|
34
33
|
/**
|
|
@@ -45,4 +44,10 @@ export interface GridRowsState extends GridRowTreeCreationValue {
|
|
|
45
44
|
* It does not count the expanded children rows.
|
|
46
45
|
*/
|
|
47
46
|
totalTopLevelRowCount: number;
|
|
47
|
+
/**
|
|
48
|
+
* Tree returned by the `rowTreeCreation` strategy processor.
|
|
49
|
+
* It is used to re-apply the `hydrateRows` pipe processor without having to recreate the tree.
|
|
50
|
+
*/
|
|
51
|
+
groupingResponseBeforeRowHydration: GridRowTreeCreationValue;
|
|
48
52
|
}
|
|
53
|
+
export declare type GridHydrateRowsValue = GridRowTreeCreationValue;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridRowId, GridRowIdGetter, GridRowModel, GridRowTreeConfig } from '../../../models';
|
|
3
|
+
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
5
|
+
import { GridRowsInternalCache, GridRowsState } from './gridRowsState';
|
|
2
6
|
/**
|
|
3
7
|
* A helper function to check if the id provided is valid.
|
|
4
8
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
@@ -6,3 +10,12 @@ import { GridRowId, GridRowModel } from '../../../models';
|
|
|
6
10
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
7
11
|
*/
|
|
8
12
|
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
|
|
13
|
+
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter<any> | undefined, detailErrorMessage?: string | undefined) => GridRowId;
|
|
14
|
+
export declare const createRowsInternalCache: ({ rows, getRowId, loading, }: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading'>) => GridRowsInternalCache;
|
|
15
|
+
export declare const getRowsStateFromCache: ({ apiRef, previousTree, rowCountProp, loadingProp, }: {
|
|
16
|
+
apiRef: React.MutableRefObject<GridApiCommunity>;
|
|
17
|
+
previousTree: GridRowTreeConfig | null;
|
|
18
|
+
rowCountProp: number | undefined;
|
|
19
|
+
loadingProp: boolean | undefined;
|
|
20
|
+
}) => GridRowsState;
|
|
21
|
+
export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean) => GridRowId[];
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["rowsBeforePartialUpdates"];
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* A helper function to check if the id provided is valid.
|
|
3
7
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
@@ -8,4 +12,78 @@ export function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was p
|
|
|
8
12
|
if (id == null) {
|
|
9
13
|
throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
10
14
|
}
|
|
11
|
-
}
|
|
15
|
+
}
|
|
16
|
+
export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
|
|
17
|
+
const id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
18
|
+
checkGridRowIdIsValid(id, rowModel, detailErrorMessage);
|
|
19
|
+
return id;
|
|
20
|
+
};
|
|
21
|
+
export const createRowsInternalCache = ({
|
|
22
|
+
rows,
|
|
23
|
+
getRowId,
|
|
24
|
+
loading
|
|
25
|
+
}) => {
|
|
26
|
+
const cache = {
|
|
27
|
+
rowsBeforePartialUpdates: rows,
|
|
28
|
+
loadingPropBeforePartialUpdates: loading,
|
|
29
|
+
idRowsLookup: {},
|
|
30
|
+
idToIdLookup: {},
|
|
31
|
+
ids: []
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < rows.length; i += 1) {
|
|
35
|
+
const row = rows[i];
|
|
36
|
+
const id = getRowIdFromRowModel(row, getRowId);
|
|
37
|
+
cache.idRowsLookup[id] = row;
|
|
38
|
+
cache.idToIdLookup[id] = id;
|
|
39
|
+
cache.ids.push(id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return cache;
|
|
43
|
+
};
|
|
44
|
+
export const getRowsStateFromCache = ({
|
|
45
|
+
apiRef,
|
|
46
|
+
previousTree,
|
|
47
|
+
rowCountProp,
|
|
48
|
+
loadingProp
|
|
49
|
+
}) => {
|
|
50
|
+
const _apiRef$current$unsta = apiRef.current.unstable_caches.rows,
|
|
51
|
+
cacheForGrouping = _objectWithoutPropertiesLoose(_apiRef$current$unsta, _excluded);
|
|
52
|
+
|
|
53
|
+
const rowCount = rowCountProp != null ? rowCountProp : 0;
|
|
54
|
+
const groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', _extends({}, cacheForGrouping, {
|
|
55
|
+
previousTree
|
|
56
|
+
}));
|
|
57
|
+
const processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
58
|
+
const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null).length;
|
|
59
|
+
return _extends({}, processedGroupingResponse, {
|
|
60
|
+
groupingResponseBeforeRowHydration: groupingResponse,
|
|
61
|
+
loading: loadingProp,
|
|
62
|
+
totalRowCount: Math.max(rowCount, processedGroupingResponse.ids.length),
|
|
63
|
+
totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
|
|
67
|
+
var _tree$parentId;
|
|
68
|
+
|
|
69
|
+
const children = (_tree$parentId = tree[parentId]) == null ? void 0 : _tree$parentId.children;
|
|
70
|
+
|
|
71
|
+
if (children == null) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const validDescendants = [];
|
|
76
|
+
|
|
77
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
78
|
+
const child = children[i];
|
|
79
|
+
const childNode = tree[child];
|
|
80
|
+
|
|
81
|
+
if (!skipAutoGeneratedRows || !childNode.isAutoGenerated) {
|
|
82
|
+
validDescendants.push(child);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
validDescendants.push(...getTreeNodeDescendants(tree, childNode.id, skipAutoGeneratedRows));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return validDescendants;
|
|
89
|
+
};
|