@mui/x-data-grid 5.10.0 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +325 -10
- package/DataGrid/DataGrid.js +61 -2
- package/DataGrid/useDataGridProps.js +2 -1
- package/README.md +4 -5
- 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.d.ts +1 -1
- package/components/GridRow.js +55 -17
- 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/GridActionsCellItem.d.ts +1 -1
- package/components/cell/GridCell.d.ts +2 -1
- package/components/cell/GridCell.js +17 -12
- 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 +19 -19
- 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 +4 -2
- package/components/containers/GridToolbarContainer.d.ts +8 -2
- package/components/containers/GridToolbarContainer.js +12 -2
- package/components/menu/GridMenu.js +9 -2
- package/components/panel/GridColumnsPanel.js +10 -2
- 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/panel/GridPanelWrapper.d.ts +1 -1
- package/components/panel/GridPanelWrapper.js +3 -3
- package/components/panel/filterPanel/GridFilterForm.d.ts +61 -4
- package/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -5
- package/components/panel/filterPanel/GridFilterPanel.js +24 -6
- 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 +3 -2
- package/constants/gridClasses.d.ts +16 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +5 -0
- 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 -4
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -0
- package/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/hooks/features/columns/useGridColumns.js +20 -23
- 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 +140 -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 +128 -42
- package/hooks/features/editRows/useGridRowEditing.old.js +21 -22
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +19 -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 +17 -1
- package/hooks/features/filter/gridFilterUtils.js +85 -4
- package/hooks/features/filter/useGridFilter.js +25 -13
- 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 +130 -129
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +107 -43
- 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 +1 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +33 -14
- 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 +5 -1
- package/internals/index.js +5 -2
- package/legacy/DataGrid/DataGrid.js +61 -2
- 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 +60 -17
- 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 +17 -12
- 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 +21 -19
- 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 +3 -2
- package/legacy/components/containers/GridToolbarContainer.js +12 -2
- package/legacy/components/menu/GridMenu.js +9 -2
- package/legacy/components/panel/GridColumnsPanel.js +12 -2
- 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/panel/GridPanelWrapper.js +3 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +89 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +25 -6
- 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 +3 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +5 -0
- 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 -4
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/legacy/hooks/features/columns/useGridColumns.js +20 -23
- package/legacy/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +220 -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 +132 -42
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +20 -21
- package/legacy/hooks/features/events/useGridEvents.js +19 -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 +97 -4
- package/legacy/hooks/features/filter/useGridFilter.js +25 -13
- 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 +140 -132
- package/legacy/hooks/features/rows/useGridRowsMeta.js +104 -41
- 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 +52 -29
- 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 +5 -0
- package/legacy/locales/bgBG.js +5 -0
- package/legacy/locales/csCZ.js +5 -0
- package/legacy/locales/daDK.js +5 -0
- package/legacy/locales/deDE.js +10 -5
- package/legacy/locales/elGR.js +5 -0
- package/legacy/locales/esES.js +5 -0
- package/legacy/locales/faIR.js +5 -0
- package/legacy/locales/fiFI.js +5 -0
- package/legacy/locales/frFR.js +5 -0
- package/legacy/locales/heIL.js +10 -5
- package/legacy/locales/huHU.js +5 -0
- package/legacy/locales/itIT.js +5 -0
- package/legacy/locales/jaJP.js +5 -0
- package/legacy/locales/koKR.js +5 -0
- package/legacy/locales/nbNO.js +127 -0
- package/legacy/locales/nlNL.js +5 -0
- package/legacy/locales/plPL.js +5 -0
- package/legacy/locales/ptBR.js +5 -0
- package/legacy/locales/ruRU.js +5 -0
- package/legacy/locales/skSK.js +5 -0
- package/legacy/locales/trTR.js +8 -3
- package/legacy/locales/ukUA.js +5 -0
- package/legacy/locales/viVN.js +5 -0
- package/legacy/locales/zhCN.js +5 -0
- package/legacy/models/events/gridEvents.js +4 -0
- package/legacy/models/gridApiCaches.js +1 -0
- package/legacy/models/index.js +4 -3
- package/legacy/models/params/gridMenuParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/legacy/utils/createSelector.js +18 -2
- package/legacy/utils/exportAs.js +1 -1
- package/locales/arSD.js +5 -0
- package/locales/bgBG.js +5 -0
- package/locales/csCZ.js +5 -0
- package/locales/daDK.js +5 -0
- package/locales/deDE.js +10 -5
- package/locales/elGR.js +5 -0
- package/locales/esES.js +5 -0
- package/locales/faIR.js +5 -0
- package/locales/fiFI.js +5 -0
- package/locales/frFR.js +5 -0
- package/locales/heIL.js +10 -5
- package/locales/huHU.js +5 -0
- package/locales/itIT.js +5 -0
- package/locales/jaJP.js +5 -0
- package/locales/koKR.js +5 -0
- package/locales/nbNO.d.ts +2 -0
- package/locales/nbNO.js +115 -0
- package/locales/nlNL.js +5 -0
- package/locales/plPL.js +5 -0
- package/locales/ptBR.js +5 -0
- package/locales/ruRU.js +5 -0
- package/locales/skSK.js +5 -0
- package/locales/trTR.js +8 -3
- package/locales/ukUA.js +5 -0
- package/locales/viVN.js +5 -0
- package/locales/zhCN.js +5 -0
- package/models/api/gridCoreApi.d.ts +6 -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 +4 -0
- package/models/api/gridRowApi.d.ts +28 -0
- package/models/api/gridRowsMetaApi.d.ts +24 -0
- package/models/api/index.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +16 -3
- package/models/events/gridEventLookup.d.ts +286 -4
- package/models/events/gridEvents.d.ts +5 -278
- package/models/events/gridEvents.js +4 -0
- package/models/gridApiCaches.d.ts +6 -0
- package/models/gridApiCaches.js +1 -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 +5 -0
- package/models/gridStateCommunity.d.ts +0 -2
- package/models/index.d.ts +1 -1
- package/models/index.js +4 -3
- package/models/params/gridMenuParams.d.ts +7 -0
- package/models/params/gridMenuParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -1
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +79 -29
- package/modern/DataGrid/DataGrid.js +61 -2
- 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 +55 -17
- 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 +17 -12
- 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 +19 -19
- 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 +4 -2
- package/modern/components/containers/GridToolbarContainer.js +12 -2
- package/modern/components/menu/GridMenu.js +9 -2
- package/modern/components/panel/GridColumnsPanel.js +10 -2
- 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/panel/GridPanelWrapper.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/modern/components/panel/filterPanel/GridFilterPanel.js +24 -6
- 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 +3 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +5 -0
- 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 -4
- package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/modern/hooks/features/columns/useGridColumns.js +19 -22
- package/modern/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +138 -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 +126 -42
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +21 -22
- package/modern/hooks/features/events/useGridEvents.js +19 -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 +81 -4
- package/modern/hooks/features/filter/useGridFilter.js +25 -13
- 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 +130 -129
- package/modern/hooks/features/rows/useGridRowsMeta.js +105 -37
- 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 +33 -14
- 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 +5 -0
- package/modern/locales/bgBG.js +5 -0
- package/modern/locales/csCZ.js +5 -0
- package/modern/locales/daDK.js +5 -0
- package/modern/locales/deDE.js +10 -5
- package/modern/locales/elGR.js +5 -0
- package/modern/locales/esES.js +5 -0
- package/modern/locales/faIR.js +5 -0
- package/modern/locales/fiFI.js +5 -0
- package/modern/locales/frFR.js +5 -0
- package/modern/locales/heIL.js +10 -5
- package/modern/locales/huHU.js +5 -0
- package/modern/locales/itIT.js +5 -0
- package/modern/locales/jaJP.js +5 -0
- package/modern/locales/koKR.js +5 -0
- package/modern/locales/nbNO.js +115 -0
- package/modern/locales/nlNL.js +5 -0
- package/modern/locales/plPL.js +5 -0
- package/modern/locales/ptBR.js +5 -0
- package/modern/locales/ruRU.js +5 -0
- package/modern/locales/skSK.js +5 -0
- package/modern/locales/trTR.js +8 -3
- package/modern/locales/ukUA.js +5 -0
- package/modern/locales/viVN.js +5 -0
- package/modern/locales/zhCN.js +5 -0
- package/modern/models/events/gridEvents.js +4 -0
- package/modern/models/gridApiCaches.js +1 -0
- package/modern/models/index.js +4 -3
- package/modern/models/params/gridMenuParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/modern/utils/createSelector.js +20 -2
- package/modern/utils/exportAs.js +1 -1
- package/node/DataGrid/DataGrid.js +61 -2
- 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 +57 -18
- 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 +16 -11
- 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 +19 -20
- 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 +4 -2
- package/node/components/containers/GridToolbarContainer.js +11 -1
- package/node/components/menu/GridMenu.js +10 -2
- package/node/components/panel/GridColumnsPanel.js +10 -2
- 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/panel/GridPanelWrapper.js +5 -3
- package/node/components/panel/filterPanel/GridFilterForm.js +91 -9
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/node/components/panel/filterPanel/GridFilterPanel.js +26 -6
- 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 +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +5 -0
- 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 -5
- package/node/hooks/features/columns/useGridColumnSpanning.js +1 -3
- package/node/hooks/features/columns/useGridColumns.js +20 -24
- package/node/hooks/features/dimensions/useGridDimensions.js +8 -10
- package/node/hooks/features/editRows/useGridCellEditing.new.js +140 -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 +128 -43
- package/node/hooks/features/editRows/useGridRowEditing.old.js +21 -23
- package/node/hooks/features/events/useGridEvents.js +19 -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 +93 -3
- package/node/hooks/features/filter/useGridFilter.js +25 -13
- 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 +132 -127
- package/node/hooks/features/rows/useGridRowsMeta.js +107 -43
- 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 +33 -15
- 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 +5 -0
- package/node/locales/bgBG.js +5 -0
- package/node/locales/csCZ.js +5 -0
- package/node/locales/daDK.js +5 -0
- package/node/locales/deDE.js +10 -5
- package/node/locales/elGR.js +5 -0
- package/node/locales/esES.js +5 -0
- package/node/locales/faIR.js +5 -0
- package/node/locales/fiFI.js +5 -0
- package/node/locales/frFR.js +5 -0
- package/node/locales/heIL.js +10 -5
- package/node/locales/huHU.js +5 -0
- package/node/locales/itIT.js +5 -0
- package/node/locales/jaJP.js +5 -0
- package/node/locales/koKR.js +5 -0
- package/node/locales/nbNO.js +125 -0
- package/node/locales/nlNL.js +5 -0
- package/node/locales/plPL.js +5 -0
- package/node/locales/ptBR.js +5 -0
- package/node/locales/ruRU.js +5 -0
- package/node/locales/skSK.js +5 -0
- package/node/locales/trTR.js +8 -3
- package/node/locales/ukUA.js +5 -0
- package/node/locales/viVN.js +5 -0
- package/node/locales/zhCN.js +5 -0
- package/node/models/events/gridEvents.js +4 -0
- package/node/models/gridApiCaches.js +5 -0
- package/node/models/index.js +0 -13
- package/node/models/params/gridMenuParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/node/utils/createSelector.js +25 -4
- package/node/utils/exportAs.js +1 -1
- package/package.json +5 -4
- 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
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
1
|
import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
var _excluded = ["id"],
|
|
7
|
+
_excluded2 = ["id"];
|
|
6
8
|
import * as React from 'react';
|
|
7
|
-
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
8
|
-
import { GridEvents } from '../../../models/events/gridEvents';
|
|
9
|
+
import { useGridApiEventHandler, useGridApiOptionHandler, GridSignature } from '../../utils/useGridApiEventHandler';
|
|
9
10
|
import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
|
|
10
11
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
11
12
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
12
13
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
13
14
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
14
15
|
import { buildWarning } from '../../../utils/warning';
|
|
16
|
+
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
15
17
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
16
18
|
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
17
19
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
20
|
+
var _React$useState = React.useState({}),
|
|
21
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
22
|
+
rowModesModel = _React$useState2[0],
|
|
23
|
+
setRowModesModel = _React$useState2[1];
|
|
24
|
+
|
|
25
|
+
var prevRowModesModel = React.useRef({});
|
|
18
26
|
var focusTimeout = React.useRef(null);
|
|
19
27
|
var nextFocusedCell = React.useRef(null);
|
|
20
28
|
var processRowUpdate = props.processRowUpdate,
|
|
21
|
-
onProcessRowUpdateError = props.onProcessRowUpdateError
|
|
29
|
+
onProcessRowUpdateError = props.onProcessRowUpdateError,
|
|
30
|
+
rowModesModelProp = props.rowModesModel,
|
|
31
|
+
onRowModesModelChange = props.onRowModesModelChange,
|
|
32
|
+
signature = props.signature;
|
|
22
33
|
|
|
23
34
|
var runIfEditModeIsRow = function runIfEditModeIsRow(callback) {
|
|
24
35
|
return function () {
|
|
@@ -56,7 +67,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
56
67
|
reason: GridRowEditStartReasons.cellDoubleClick
|
|
57
68
|
});
|
|
58
69
|
|
|
59
|
-
apiRef.current.publishEvent(
|
|
70
|
+
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
60
71
|
}, [apiRef]);
|
|
61
72
|
var handleCellFocusIn = React.useCallback(function (params) {
|
|
62
73
|
nextFocusedCell.current = params;
|
|
@@ -82,6 +93,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
82
93
|
focusTimeout.current = null;
|
|
83
94
|
|
|
84
95
|
if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
|
|
96
|
+
// The row might have been deleted during the click
|
|
97
|
+
if (!apiRef.current.getRow(params.id)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
85
101
|
var rowParams = apiRef.current.getRowParams(params.id);
|
|
86
102
|
|
|
87
103
|
var newParams = _extends({}, rowParams, {
|
|
@@ -89,7 +105,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
89
105
|
reason: GridRowEditStopReasons.rowFocusOut
|
|
90
106
|
});
|
|
91
107
|
|
|
92
|
-
apiRef.current.publishEvent(
|
|
108
|
+
apiRef.current.publishEvent('rowEditStop', newParams, event);
|
|
93
109
|
}
|
|
94
110
|
});
|
|
95
111
|
}, [apiRef]);
|
|
@@ -134,7 +150,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
134
150
|
field: params.field
|
|
135
151
|
});
|
|
136
152
|
|
|
137
|
-
apiRef.current.publishEvent(
|
|
153
|
+
apiRef.current.publishEvent('rowEditStop', newParams, event);
|
|
138
154
|
}
|
|
139
155
|
} else if (params.isEditable) {
|
|
140
156
|
var _reason;
|
|
@@ -159,26 +175,24 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
159
175
|
reason: _reason
|
|
160
176
|
});
|
|
161
177
|
|
|
162
|
-
apiRef.current.publishEvent(
|
|
178
|
+
apiRef.current.publishEvent('rowEditStart', _newParams, event);
|
|
163
179
|
}
|
|
164
180
|
}
|
|
165
181
|
}, [apiRef]);
|
|
166
|
-
var handleRowEditStart = React.useCallback(function (params
|
|
182
|
+
var handleRowEditStart = React.useCallback(function (params) {
|
|
167
183
|
var id = params.id,
|
|
168
184
|
field = params.field,
|
|
169
185
|
reason = params.reason;
|
|
170
|
-
|
|
186
|
+
var startRowEditModeParams = {
|
|
171
187
|
id: id,
|
|
172
188
|
fieldToFocus: field
|
|
173
|
-
}
|
|
189
|
+
};
|
|
174
190
|
|
|
175
191
|
if (reason === GridRowEditStartReasons.deleteKeyDown || reason === GridRowEditStartReasons.printableKeyDown) {
|
|
176
|
-
|
|
177
|
-
id: id,
|
|
178
|
-
field: field,
|
|
179
|
-
value: ''
|
|
180
|
-
}, event);
|
|
192
|
+
startRowEditModeParams.deleteValue = !!field;
|
|
181
193
|
}
|
|
194
|
+
|
|
195
|
+
apiRef.current.startRowEditMode(startRowEditModeParams);
|
|
182
196
|
}, [apiRef]);
|
|
183
197
|
var handleRowEditStop = React.useCallback(function (params) {
|
|
184
198
|
var id = params.id,
|
|
@@ -213,14 +227,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
213
227
|
cellToFocusAfter: cellToFocusAfter
|
|
214
228
|
});
|
|
215
229
|
}, [apiRef]);
|
|
216
|
-
useGridApiEventHandler(apiRef,
|
|
217
|
-
useGridApiEventHandler(apiRef,
|
|
218
|
-
useGridApiEventHandler(apiRef,
|
|
219
|
-
useGridApiEventHandler(apiRef,
|
|
220
|
-
useGridApiEventHandler(apiRef,
|
|
221
|
-
useGridApiEventHandler(apiRef,
|
|
222
|
-
useGridApiOptionHandler(apiRef,
|
|
223
|
-
useGridApiOptionHandler(apiRef,
|
|
230
|
+
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsRow(handleCellDoubleClick));
|
|
231
|
+
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfEditModeIsRow(handleCellFocusIn));
|
|
232
|
+
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsRow(handleCellFocusOut));
|
|
233
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfEditModeIsRow(handleCellKeyDown));
|
|
234
|
+
useGridApiEventHandler(apiRef, 'rowEditStart', runIfEditModeIsRow(handleRowEditStart));
|
|
235
|
+
useGridApiEventHandler(apiRef, 'rowEditStop', runIfEditModeIsRow(handleRowEditStop));
|
|
236
|
+
useGridApiOptionHandler(apiRef, 'rowEditStart', props.onRowEditStart);
|
|
237
|
+
useGridApiOptionHandler(apiRef, 'rowEditStop', props.onRowEditStop);
|
|
224
238
|
var getRowMode = React.useCallback(function (id) {
|
|
225
239
|
if (props.editMode === GridEditModes.Cell) {
|
|
226
240
|
return GridRowModes.View;
|
|
@@ -230,6 +244,34 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
230
244
|
var isEditing = editingState[id] && Object.keys(editingState[id]).length > 0;
|
|
231
245
|
return isEditing ? GridRowModes.Edit : GridRowModes.View;
|
|
232
246
|
}, [apiRef, props.editMode]);
|
|
247
|
+
var updateRowModesModel = React.useCallback(function (newModel) {
|
|
248
|
+
var isNewModelDifferentFromProp = newModel !== props.rowModesModel;
|
|
249
|
+
|
|
250
|
+
if (onRowModesModelChange && isNewModelDifferentFromProp) {
|
|
251
|
+
var details = signature === GridSignature.DataGridPro ? {
|
|
252
|
+
api: apiRef.current
|
|
253
|
+
} : {};
|
|
254
|
+
onRowModesModelChange(newModel, details);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (props.rowModesModel && isNewModelDifferentFromProp) {
|
|
258
|
+
return; // The prop always win
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
setRowModesModel(newModel);
|
|
262
|
+
apiRef.current.publishEvent('rowModesModelChange', newModel);
|
|
263
|
+
}, [apiRef, onRowModesModelChange, props.rowModesModel, signature]);
|
|
264
|
+
var updateRowInRowModesModel = React.useCallback(function (id, newProps) {
|
|
265
|
+
var newModel = _extends({}, rowModesModel);
|
|
266
|
+
|
|
267
|
+
if (newProps !== null) {
|
|
268
|
+
newModel[id] = _extends({}, newProps);
|
|
269
|
+
} else {
|
|
270
|
+
delete newModel[id];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
updateRowModesModel(newModel);
|
|
274
|
+
}, [rowModesModel, updateRowModesModel]);
|
|
233
275
|
var updateOrDeleteRowState = React.useCallback(function (id, newProps) {
|
|
234
276
|
apiRef.current.setState(function (state) {
|
|
235
277
|
var newEditingState = _extends({}, state.editRows);
|
|
@@ -268,13 +310,17 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
268
310
|
}, [apiRef]);
|
|
269
311
|
var startRowEditMode = React.useCallback(function (params) {
|
|
270
312
|
var id = params.id,
|
|
271
|
-
|
|
272
|
-
throwIfNotInMode(id, GridRowModes.View);
|
|
273
|
-
|
|
274
|
-
if (apiRef.current.getRowMode(id) === GridRowModes.Edit) {
|
|
275
|
-
throw new Error("MUI: The cell with id=".concat(id, " is already in edit mode."));
|
|
276
|
-
}
|
|
313
|
+
other = _objectWithoutProperties(params, _excluded);
|
|
277
314
|
|
|
315
|
+
throwIfNotInMode(id, GridRowModes.View);
|
|
316
|
+
updateRowInRowModesModel(id, _extends({
|
|
317
|
+
mode: GridRowModes.Edit
|
|
318
|
+
}, other));
|
|
319
|
+
}, [throwIfNotInMode, updateRowInRowModesModel]);
|
|
320
|
+
var updateStateToStartRowEditMode = React.useCallback(function (params) {
|
|
321
|
+
var id = params.id,
|
|
322
|
+
fieldToFocus = params.fieldToFocus,
|
|
323
|
+
deleteValue = params.deleteValue;
|
|
278
324
|
var columnFields = gridColumnFieldsSelector(apiRef);
|
|
279
325
|
var newProps = columnFields.reduce(function (acc, field) {
|
|
280
326
|
var cellParams = apiRef.current.getCellParams(id, field);
|
|
@@ -283,8 +329,9 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
283
329
|
return acc;
|
|
284
330
|
}
|
|
285
331
|
|
|
332
|
+
var shouldDeleteValue = deleteValue && fieldToFocus === field;
|
|
286
333
|
acc[field] = {
|
|
287
|
-
value: apiRef.current.getCellValue(id, field),
|
|
334
|
+
value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
|
|
288
335
|
error: false,
|
|
289
336
|
isProcessingProps: false
|
|
290
337
|
};
|
|
@@ -295,25 +342,35 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
295
342
|
if (fieldToFocus) {
|
|
296
343
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
297
344
|
}
|
|
298
|
-
}, [apiRef,
|
|
345
|
+
}, [apiRef, updateOrDeleteRowState]);
|
|
299
346
|
var stopRowEditMode = React.useCallback(function (params) {
|
|
347
|
+
var id = params.id,
|
|
348
|
+
other = _objectWithoutProperties(params, _excluded2);
|
|
349
|
+
|
|
350
|
+
throwIfNotInMode(id, GridRowModes.Edit);
|
|
351
|
+
updateRowInRowModesModel(id, _extends({
|
|
352
|
+
mode: GridRowModes.View
|
|
353
|
+
}, other));
|
|
354
|
+
}, [throwIfNotInMode, updateRowInRowModesModel]);
|
|
355
|
+
var updateStateToStopRowEditMode = React.useCallback(function (params) {
|
|
300
356
|
var id = params.id,
|
|
301
357
|
ignoreModifications = params.ignoreModifications,
|
|
302
358
|
focusedField = params.field,
|
|
303
359
|
_params$cellToFocusAf = params.cellToFocusAfter,
|
|
304
360
|
cellToFocusAfter = _params$cellToFocusAf === void 0 ? 'none' : _params$cellToFocusAf;
|
|
305
|
-
throwIfNotInMode(id, GridRowModes.Edit);
|
|
306
361
|
apiRef.current.unstable_runPendingEditCellValueMutation(id);
|
|
307
362
|
|
|
308
|
-
var
|
|
363
|
+
var finishRowEditMode = function finishRowEditMode() {
|
|
309
364
|
if (cellToFocusAfter !== 'none' && focusedField) {
|
|
310
365
|
apiRef.current.unstable_moveFocusToRelativeCell(id, focusedField, cellToFocusAfter);
|
|
311
366
|
}
|
|
367
|
+
|
|
368
|
+
updateOrDeleteRowState(id, null);
|
|
369
|
+
updateRowInRowModesModel(id, null);
|
|
312
370
|
};
|
|
313
371
|
|
|
314
372
|
if (ignoreModifications) {
|
|
315
|
-
|
|
316
|
-
updateOrDeleteRowState(id, null);
|
|
373
|
+
finishRowEditMode();
|
|
317
374
|
return;
|
|
318
375
|
}
|
|
319
376
|
|
|
@@ -324,6 +381,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
324
381
|
});
|
|
325
382
|
|
|
326
383
|
if (isSomeFieldProcessingProps) {
|
|
384
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
327
385
|
return;
|
|
328
386
|
}
|
|
329
387
|
|
|
@@ -332,6 +390,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
332
390
|
});
|
|
333
391
|
|
|
334
392
|
if (hasSomeFieldWithError) {
|
|
393
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
335
394
|
return;
|
|
336
395
|
}
|
|
337
396
|
|
|
@@ -339,6 +398,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
339
398
|
|
|
340
399
|
if (processRowUpdate) {
|
|
341
400
|
var handleError = function handleError(errorThrown) {
|
|
401
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
402
|
+
|
|
342
403
|
if (onProcessRowUpdateError) {
|
|
343
404
|
onProcessRowUpdateError(errorThrown);
|
|
344
405
|
} else {
|
|
@@ -349,18 +410,16 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
349
410
|
try {
|
|
350
411
|
Promise.resolve(processRowUpdate(rowUpdate, row)).then(function (finalRowUpdate) {
|
|
351
412
|
apiRef.current.updateRows([finalRowUpdate]);
|
|
352
|
-
|
|
353
|
-
updateOrDeleteRowState(id, null);
|
|
413
|
+
finishRowEditMode();
|
|
354
414
|
}).catch(handleError);
|
|
355
415
|
} catch (errorThrown) {
|
|
356
416
|
handleError(errorThrown);
|
|
357
417
|
}
|
|
358
418
|
} else {
|
|
359
419
|
apiRef.current.updateRows([rowUpdate]);
|
|
360
|
-
|
|
361
|
-
updateOrDeleteRowState(id, null);
|
|
420
|
+
finishRowEditMode();
|
|
362
421
|
}
|
|
363
|
-
}, [apiRef, onProcessRowUpdateError, processRowUpdate,
|
|
422
|
+
}, [apiRef, onProcessRowUpdateError, processRowUpdate, updateOrDeleteRowState, updateRowInRowModesModel]);
|
|
364
423
|
var setRowEditingEditCellValue = React.useCallback(function (params) {
|
|
365
424
|
var id = params.id,
|
|
366
425
|
field = params.field,
|
|
@@ -513,4 +572,35 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
513
572
|
unstable_getRowWithUpdatedValuesFromRowEditing: getRowWithUpdatedValuesFromRowEditing
|
|
514
573
|
};
|
|
515
574
|
useGridApiMethod(apiRef, editingApi, 'EditingApi');
|
|
575
|
+
React.useEffect(function () {
|
|
576
|
+
if (rowModesModelProp) {
|
|
577
|
+
updateRowModesModel(rowModesModelProp);
|
|
578
|
+
}
|
|
579
|
+
}, [rowModesModelProp, updateRowModesModel]);
|
|
580
|
+
React.useEffect(function () {
|
|
581
|
+
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
582
|
+
|
|
583
|
+
var copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
584
|
+
prevRowModesModel.current = rowModesModel;
|
|
585
|
+
Object.entries(rowModesModel).forEach(function (_ref5) {
|
|
586
|
+
var _copyOfPrevRowModesMo, _idToIdLookup$id;
|
|
587
|
+
|
|
588
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
589
|
+
id = _ref6[0],
|
|
590
|
+
params = _ref6[1];
|
|
591
|
+
|
|
592
|
+
var prevMode = ((_copyOfPrevRowModesMo = copyOfPrevRowModesModel[id]) == null ? void 0 : _copyOfPrevRowModesMo.mode) || GridRowModes.View;
|
|
593
|
+
var originalId = (_idToIdLookup$id = idToIdLookup[id]) != null ? _idToIdLookup$id : id;
|
|
594
|
+
|
|
595
|
+
if (params.mode === GridRowModes.Edit && prevMode === GridRowModes.View) {
|
|
596
|
+
updateStateToStartRowEditMode(_extends({
|
|
597
|
+
id: originalId
|
|
598
|
+
}, params));
|
|
599
|
+
} else if (params.mode === GridRowModes.View && prevMode === GridRowModes.Edit) {
|
|
600
|
+
updateStateToStopRowEditMode(_extends({
|
|
601
|
+
id: originalId
|
|
602
|
+
}, params));
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}, [apiRef, rowModesModel, updateStateToStartRowEditMode, updateStateToStopRowEditMode]);
|
|
516
606
|
};
|
|
@@ -8,7 +8,6 @@ import { GridRowModes, GridEditModes, GridCellModes } from '../../../models/grid
|
|
|
8
8
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
9
9
|
import { gridColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
10
10
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
11
|
-
import { GridEvents } from '../../../models/events/gridEvents';
|
|
12
11
|
import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
|
|
13
12
|
import { useGridApiOptionHandler, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
14
13
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
@@ -148,12 +147,12 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
148
147
|
return false;
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
apiRef.current.publishEvent(
|
|
150
|
+
apiRef.current.publishEvent('rowEditCommit', id, event);
|
|
152
151
|
return true;
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
apiRef.current.publishEvent(
|
|
155
|
+
apiRef.current.publishEvent('rowEditCommit', id, event);
|
|
157
156
|
return true;
|
|
158
157
|
}, [apiRef, props.editMode, (_props$experimentalFe2 = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe2.preventCommitWhileValidating]);
|
|
159
158
|
var setRowEditingEditCellValue = React.useCallback(function (params) {
|
|
@@ -279,13 +278,13 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
279
278
|
return _context3.abrupt("return");
|
|
280
279
|
|
|
281
280
|
case 12:
|
|
282
|
-
apiRef.current.publishEvent(
|
|
281
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
283
282
|
_context3.next = 16;
|
|
284
283
|
break;
|
|
285
284
|
|
|
286
285
|
case 15:
|
|
287
286
|
if (event.key === 'Escape') {
|
|
288
|
-
apiRef.current.publishEvent(
|
|
287
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
289
288
|
}
|
|
290
289
|
|
|
291
290
|
case 16:
|
|
@@ -294,7 +293,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
294
293
|
|
|
295
294
|
case 18:
|
|
296
295
|
if (event.key === 'Enter') {
|
|
297
|
-
apiRef.current.publishEvent(
|
|
296
|
+
apiRef.current.publishEvent('rowEditStart', rowParams, event);
|
|
298
297
|
}
|
|
299
298
|
|
|
300
299
|
case 19:
|
|
@@ -315,7 +314,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
var rowParams = apiRef.current.getRowParams(params.id);
|
|
318
|
-
apiRef.current.publishEvent(
|
|
317
|
+
apiRef.current.publishEvent('rowEditStart', rowParams, event);
|
|
319
318
|
}, [apiRef]);
|
|
320
319
|
var handleEditCellPropsChange = React.useCallback(function (params) {
|
|
321
320
|
var row = apiRef.current.getRow(params.id);
|
|
@@ -378,7 +377,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
378
377
|
apiRef.current.setRowMode(params.id, GridRowModes.View);
|
|
379
378
|
|
|
380
379
|
if (event.key === 'Enter') {
|
|
381
|
-
apiRef.current.publishEvent(
|
|
380
|
+
apiRef.current.publishEvent('cellNavigationKeyDown', params, event);
|
|
382
381
|
}
|
|
383
382
|
}, [apiRef]);
|
|
384
383
|
var handleRowEditCommit = React.useCallback(function (id) {
|
|
@@ -447,7 +446,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
447
446
|
|
|
448
447
|
case 3:
|
|
449
448
|
rowParams = apiRef.current.getRowParams(params.id);
|
|
450
|
-
apiRef.current.publishEvent(
|
|
449
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
451
450
|
|
|
452
451
|
case 5:
|
|
453
452
|
case "end":
|
|
@@ -483,16 +482,16 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
483
482
|
var params = apiRef.current.getCellParams(cell.id, cell.field);
|
|
484
483
|
commitPropsAndExit(params, {});
|
|
485
484
|
});
|
|
486
|
-
useGridApiEventHandler(apiRef,
|
|
487
|
-
useGridApiEventHandler(apiRef,
|
|
488
|
-
useGridApiEventHandler(apiRef,
|
|
489
|
-
useGridApiEventHandler(apiRef,
|
|
490
|
-
useGridApiEventHandler(apiRef,
|
|
491
|
-
useGridApiEventHandler(apiRef,
|
|
492
|
-
useGridApiEventHandler(apiRef,
|
|
493
|
-
useGridApiEventHandler(apiRef,
|
|
494
|
-
useGridApiEventHandler(apiRef,
|
|
495
|
-
useGridApiOptionHandler(apiRef,
|
|
496
|
-
useGridApiOptionHandler(apiRef,
|
|
497
|
-
useGridApiOptionHandler(apiRef,
|
|
485
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', buildCallback(handleCellKeyDown));
|
|
486
|
+
useGridApiEventHandler(apiRef, 'cellDoubleClick', buildCallback(handleCellDoubleClick));
|
|
487
|
+
useGridApiEventHandler(apiRef, 'editCellPropsChange', buildCallback(handleEditCellPropsChange));
|
|
488
|
+
useGridApiEventHandler(apiRef, 'rowEditStart', buildCallback(handleRowEditStart));
|
|
489
|
+
useGridApiEventHandler(apiRef, 'rowEditStop', buildCallback(handleRowEditStop));
|
|
490
|
+
useGridApiEventHandler(apiRef, 'rowEditCommit', buildCallback(handleRowEditCommit));
|
|
491
|
+
useGridApiEventHandler(apiRef, 'cellFocusIn', buildCallback(handleCellFocusIn));
|
|
492
|
+
useGridApiEventHandler(apiRef, 'cellFocusOut', buildCallback(handleCellFocusOut));
|
|
493
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragStart', buildCallback(handleColumnHeaderDragStart));
|
|
494
|
+
useGridApiOptionHandler(apiRef, 'rowEditCommit', props.onRowEditCommit);
|
|
495
|
+
useGridApiOptionHandler(apiRef, 'rowEditStart', props.onRowEditStart);
|
|
496
|
+
useGridApiOptionHandler(apiRef, 'rowEditStop', props.onRowEditStop);
|
|
498
497
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GridEvents } from '../../../models/events';
|
|
2
1
|
import { useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -6,21 +5,23 @@ import { useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
|
6
5
|
* @requires useGridColumns (event) - can be after, async only
|
|
7
6
|
*/
|
|
8
7
|
export function useGridEvents(apiRef, props) {
|
|
9
|
-
useGridApiOptionHandler(apiRef,
|
|
10
|
-
useGridApiOptionHandler(apiRef,
|
|
11
|
-
useGridApiOptionHandler(apiRef,
|
|
12
|
-
useGridApiOptionHandler(apiRef,
|
|
13
|
-
useGridApiOptionHandler(apiRef,
|
|
14
|
-
useGridApiOptionHandler(apiRef,
|
|
15
|
-
useGridApiOptionHandler(apiRef,
|
|
16
|
-
useGridApiOptionHandler(apiRef,
|
|
17
|
-
useGridApiOptionHandler(apiRef,
|
|
18
|
-
useGridApiOptionHandler(apiRef,
|
|
19
|
-
useGridApiOptionHandler(apiRef,
|
|
20
|
-
useGridApiOptionHandler(apiRef,
|
|
21
|
-
useGridApiOptionHandler(apiRef,
|
|
22
|
-
useGridApiOptionHandler(apiRef,
|
|
23
|
-
useGridApiOptionHandler(apiRef,
|
|
24
|
-
useGridApiOptionHandler(apiRef,
|
|
25
|
-
useGridApiOptionHandler(apiRef,
|
|
8
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderClick', props.onColumnHeaderClick);
|
|
9
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderDoubleClick', props.onColumnHeaderDoubleClick);
|
|
10
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderOver', props.onColumnHeaderOver);
|
|
11
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderOut', props.onColumnHeaderOut);
|
|
12
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderEnter', props.onColumnHeaderEnter);
|
|
13
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderLeave', props.onColumnHeaderLeave);
|
|
14
|
+
useGridApiOptionHandler(apiRef, 'columnOrderChange', props.onColumnOrderChange);
|
|
15
|
+
useGridApiOptionHandler(apiRef, 'cellClick', props.onCellClick);
|
|
16
|
+
useGridApiOptionHandler(apiRef, 'cellDoubleClick', props.onCellDoubleClick);
|
|
17
|
+
useGridApiOptionHandler(apiRef, 'cellKeyDown', props.onCellKeyDown);
|
|
18
|
+
useGridApiOptionHandler(apiRef, 'cellFocusOut', props.onCellFocusOut);
|
|
19
|
+
useGridApiOptionHandler(apiRef, 'preferencePanelClose', props.onPreferencePanelClose);
|
|
20
|
+
useGridApiOptionHandler(apiRef, 'preferencePanelOpen', props.onPreferencePanelOpen);
|
|
21
|
+
useGridApiOptionHandler(apiRef, 'menuOpen', props.onMenuOpen);
|
|
22
|
+
useGridApiOptionHandler(apiRef, 'menuClose', props.onMenuClose);
|
|
23
|
+
useGridApiOptionHandler(apiRef, 'rowDoubleClick', props.onRowDoubleClick);
|
|
24
|
+
useGridApiOptionHandler(apiRef, 'rowClick', props.onRowClick);
|
|
25
|
+
useGridApiOptionHandler(apiRef, 'componentError', props.onError);
|
|
26
|
+
useGridApiOptionHandler(apiRef, 'stateChange', props.onStateChange);
|
|
26
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
|
|
2
2
|
import { buildWarning } from '../../../../utils/warning';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var serializeCellValue = function serializeCellValue(value, delimiterCharacter) {
|
|
5
5
|
if (typeof value === 'string') {
|
|
6
6
|
var formattedValue = value.replace(/"/g, '""'); // Make sure value containing delimiter or line break won't be split into multiple rows
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ var serialiseCellValue = function serialiseCellValue(value, delimiterCharacter)
|
|
|
19
19
|
|
|
20
20
|
var objectFormattedValueWarning = buildWarning(['MUI: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var serializeRow = function serializeRow(id, columns, getCellParams, delimiterCharacter) {
|
|
23
23
|
return columns.map(function (column) {
|
|
24
24
|
var cellParams = getCellParams(id, column.field);
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ var serialiseRow = function serialiseRow(id, columns, getCellParams, delimiterCh
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return serializeCellValue(cellParams.formattedValue, delimiterCharacter);
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ export function buildCSV(options) {
|
|
|
40
40
|
delimiterCharacter = options.delimiterCharacter,
|
|
41
41
|
includeHeaders = options.includeHeaders;
|
|
42
42
|
var CSVBody = rowIds.reduce(function (acc, id) {
|
|
43
|
-
return "".concat(acc).concat(
|
|
43
|
+
return "".concat(acc).concat(serializeRow(id, columns, getCellParams, delimiterCharacter).join(delimiterCharacter), "\r\n");
|
|
44
44
|
}, '').trim();
|
|
45
45
|
|
|
46
46
|
if (!includeHeaders) {
|
|
@@ -50,7 +50,7 @@ export function buildCSV(options) {
|
|
|
50
50
|
var CSVHead = "".concat(columns.filter(function (column) {
|
|
51
51
|
return column.field !== GRID_CHECKBOX_SELECTION_COL_DEF.field;
|
|
52
52
|
}).map(function (column) {
|
|
53
|
-
return
|
|
53
|
+
return serializeCellValue(column.headerName || column.field, delimiterCharacter);
|
|
54
54
|
}).join(delimiterCharacter), "\r\n");
|
|
55
55
|
return "".concat(CSVHead).concat(CSVBody).trim();
|
|
56
56
|
}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
3
|
-
import { gridFilteredSortedRowIdsSelector } from '../filter';
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
5
|
import { exportAs } from '../../../utils/exportAs';
|
|
6
6
|
import { buildCSV } from './serializers/csvSerializer';
|
|
7
|
-
import { getColumnsToExport } from './utils';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var apiRef = _ref.apiRef;
|
|
11
|
-
var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
12
|
-
var selectedRows = apiRef.current.getSelectedRows();
|
|
13
|
-
|
|
14
|
-
if (selectedRows.size > 0) {
|
|
15
|
-
return filteredSortedRowIds.filter(function (id) {
|
|
16
|
-
return selectedRows.has(id);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return filteredSortedRowIds;
|
|
21
|
-
};
|
|
7
|
+
import { getColumnsToExport, defaultGetRowsToExport } from './utils';
|
|
8
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
9
|
+
import { GridCsvExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
22
10
|
/**
|
|
23
11
|
* @requires useGridColumns (state)
|
|
24
12
|
* @requires useGridFilter (state)
|
|
@@ -27,7 +15,7 @@ var defaultGetRowsToExport = function defaultGetRowsToExport(_ref) {
|
|
|
27
15
|
* @requires useGridParamsApi (method)
|
|
28
16
|
*/
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
19
|
export var useGridCsvExport = function useGridCsvExport(apiRef) {
|
|
32
20
|
var logger = useGridLogger(apiRef, 'useGridCsvExport');
|
|
33
21
|
var getDataAsCsv = React.useCallback(function () {
|
|
@@ -64,4 +52,23 @@ export var useGridCsvExport = function useGridCsvExport(apiRef) {
|
|
|
64
52
|
exportDataAsCsv: exportDataAsCsv
|
|
65
53
|
};
|
|
66
54
|
useGridApiMethod(apiRef, csvExportApi, 'GridCsvExportApi');
|
|
55
|
+
/**
|
|
56
|
+
* PRE-PROCESSING
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
var addExportMenuButtons = React.useCallback(function (initialValue, options) {
|
|
60
|
+
var _options$csvOptions;
|
|
61
|
+
|
|
62
|
+
if ((_options$csvOptions = options.csvOptions) != null && _options$csvOptions.disableToolbarButton) {
|
|
63
|
+
return initialValue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return [].concat(_toConsumableArray(initialValue), [{
|
|
67
|
+
component: /*#__PURE__*/_jsx(GridCsvExportMenuItem, {
|
|
68
|
+
options: options.csvOptions
|
|
69
|
+
}),
|
|
70
|
+
componentName: 'csvExport'
|
|
71
|
+
}]);
|
|
72
|
+
}, []);
|
|
73
|
+
useGridRegisterPipeProcessor(apiRef, 'exportMenu', addExportMenuButtons);
|
|
67
74
|
};
|
|
@@ -12,6 +12,9 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
12
12
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
13
13
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
14
14
|
import { getColumnsToExport } from './utils';
|
|
15
|
+
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
16
|
+
import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* @requires useGridColumns (state)
|
|
@@ -262,4 +265,23 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
|
|
|
262
265
|
exportDataAsPrint: exportDataAsPrint
|
|
263
266
|
};
|
|
264
267
|
useGridApiMethod(apiRef, printExportApi, 'GridPrintExportApi');
|
|
268
|
+
/**
|
|
269
|
+
* PRE-PROCESSING
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
var addExportMenuButtons = React.useCallback(function (initialValue, options) {
|
|
273
|
+
var _options$printOptions;
|
|
274
|
+
|
|
275
|
+
if ((_options$printOptions = options.printOptions) != null && _options$printOptions.disableToolbarButton) {
|
|
276
|
+
return initialValue;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return [].concat(_toConsumableArray(initialValue), [{
|
|
280
|
+
component: /*#__PURE__*/_jsx(GridPrintExportMenuItem, {
|
|
281
|
+
options: options.printOptions
|
|
282
|
+
}),
|
|
283
|
+
componentName: 'printExport'
|
|
284
|
+
}]);
|
|
285
|
+
}, []);
|
|
286
|
+
useGridRegisterPipeProcessor(apiRef, 'exportMenu', addExportMenuButtons);
|
|
265
287
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
|
|
2
|
+
import { gridFilteredSortedRowIdsSelector } from '../filter';
|
|
2
3
|
export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
3
4
|
var apiRef = _ref.apiRef,
|
|
4
5
|
options = _ref.options;
|
|
@@ -18,4 +19,17 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
|
18
19
|
return validColumns.filter(function (column) {
|
|
19
20
|
return !column.disableExport;
|
|
20
21
|
});
|
|
22
|
+
};
|
|
23
|
+
export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
|
|
24
|
+
var apiRef = _ref2.apiRef;
|
|
25
|
+
var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
26
|
+
var selectedRows = apiRef.current.getSelectedRows();
|
|
27
|
+
|
|
28
|
+
if (selectedRows.size > 0) {
|
|
29
|
+
return filteredSortedRowIds.filter(function (id) {
|
|
30
|
+
return selectedRows.has(id);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return filteredSortedRowIds;
|
|
21
35
|
};
|
|
@@ -2,6 +2,8 @@ import { GridLinkOperator } from '../../../models/gridFilterItem';
|
|
|
2
2
|
export var getDefaultGridFilterModel = function getDefaultGridFilterModel() {
|
|
3
3
|
return {
|
|
4
4
|
items: [],
|
|
5
|
-
linkOperator: GridLinkOperator.And
|
|
5
|
+
linkOperator: GridLinkOperator.And,
|
|
6
|
+
quickFilterValues: [],
|
|
7
|
+
quickFilterLogicOperator: GridLinkOperator.And
|
|
6
8
|
};
|
|
7
9
|
};
|