@mui/x-data-grid 5.8.0 → 5.11.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 +333 -66
- package/DataGrid/DataGrid.js +36 -2
- package/DataGrid/useDataGridComponent.js +3 -1
- package/DataGrid/useDataGridProps.js +2 -1
- package/LICENSE +21 -0
- package/README.md +7 -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 +4 -0
- package/components/GridRow.js +58 -28
- 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 +5 -5
- package/components/cell/GridActionsCell.d.ts +5 -1
- package/components/cell/GridActionsCell.js +179 -21
- package/components/cell/GridActionsCellItem.d.ts +66 -4
- package/components/cell/GridActionsCellItem.js +7 -5
- package/components/cell/GridCell.d.ts +1 -0
- package/components/cell/GridCell.js +36 -15
- 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 +30 -6
- package/components/cell/GridEditSingleSelectCell.d.ts +12 -4
- package/components/cell/GridEditSingleSelectCell.js +50 -18
- package/components/cell/index.d.ts +2 -0
- package/components/cell/index.js +2 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +19 -23
- package/components/columnHeaders/GridColumnHeaders.d.ts +2 -1
- package/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/components/columnHeaders/GridColumnHeadersInner.d.ts +2 -0
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +3 -3
- package/components/columnSelection/GridCellCheckboxRenderer.js +22 -6
- 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/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/GridPanel.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/panel/filterPanel/GridFilterForm.js +14 -10
- package/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -15
- package/components/panel/filterPanel/GridFilterInputValue.js +22 -15
- package/components/toolbar/GridToolbar.d.ts +12 -2
- package/components/toolbar/GridToolbar.js +30 -7
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- 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 +88 -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/GridVirtualScroller.js +2 -0
- package/components/virtualization/GridVirtualScrollerContent.d.ts +4 -1
- package/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/components/virtualization/GridVirtualScrollerRenderZone.d.ts +4 -1
- package/constants/defaultGridSlotsComponents.js +3 -2
- package/constants/gridClasses.d.ts +20 -0
- package/constants/gridClasses.js +1 -1
- package/constants/gridDetailPanelToggleField.d.ts +1 -0
- package/constants/gridDetailPanelToggleField.js +2 -0
- package/constants/localeTextConstants.js +8 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +39 -15
- package/hooks/core/pipeProcessing/index.d.ts +1 -0
- package/hooks/core/pipeProcessing/index.js +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +8 -3
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +3 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +0 -3
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- 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.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +81 -16
- package/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +19 -1
- package/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/hooks/features/columns/useGridColumnSpanning.d.ts +7 -0
- package/hooks/features/columns/useGridColumnSpanning.js +108 -0
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +30 -25
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +10 -11
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +151 -42
- package/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/hooks/features/editRows/useGridEditing.new.js +7 -3
- 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 +145 -57
- 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 +32 -15
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/focus/useGridFocus.js +48 -42
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -12
- 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 +2 -0
- package/hooks/features/rows/gridRowsSelector.js +2 -0
- package/hooks/features/rows/gridRowsState.d.ts +7 -7
- package/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/hooks/features/rows/gridRowsUtils.js +25 -1
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +121 -61
- package/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/hooks/features/scroll/useGridScroll.d.ts +2 -0
- package/hooks/features/scroll/useGridScroll.js +31 -4
- package/hooks/features/selection/useGridSelection.d.ts +1 -1
- package/hooks/features/selection/useGridSelection.js +15 -11
- package/hooks/features/sorting/useGridSorting.js +17 -18
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +9 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +68 -32
- 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 +6 -2
- package/legacy/DataGrid/DataGrid.js +36 -2
- package/legacy/DataGrid/useDataGridComponent.js +3 -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 +56 -28
- 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 +5 -5
- package/legacy/components/cell/GridActionsCell.js +197 -27
- package/legacy/components/cell/GridActionsCellItem.js +7 -5
- package/legacy/components/cell/GridCell.js +37 -15
- package/legacy/components/cell/GridEditBooleanCell.js +132 -11
- package/legacy/components/cell/GridEditDateCell.js +148 -42
- package/legacy/components/cell/GridEditInputCell.js +62 -13
- package/legacy/components/cell/GridEditSingleSelectCell.js +65 -28
- package/legacy/components/cell/index.js +2 -0
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +19 -23
- package/legacy/components/columnHeaders/GridColumnHeaders.js +2 -3
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +23 -6
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +4 -5
- package/legacy/components/containers/GridFooterContainer.js +11 -2
- 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/GridPanel.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/panel/filterPanel/GridFilterForm.js +14 -10
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -17
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +22 -17
- package/legacy/components/toolbar/GridToolbar.js +31 -6
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/legacy/components/toolbar/GridToolbarExport.js +18 -19
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +103 -0
- package/legacy/components/toolbar/index.js +3 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +2 -0
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/legacy/constants/defaultGridSlotsComponents.js +3 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/gridDetailPanelToggleField.js +2 -0
- package/legacy/constants/localeTextConstants.js +8 -1
- package/legacy/hooks/core/pipeProcessing/index.js +2 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +60 -24
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- 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 +94 -16
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +79 -22
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +106 -0
- package/legacy/hooks/features/columns/useGridColumns.js +30 -25
- package/legacy/hooks/features/dimensions/useGridDimensions.js +10 -11
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +225 -89
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/legacy/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/legacy/hooks/features/editRows/useGridEditing.old.js +4 -5
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +157 -65
- 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 +32 -15
- package/legacy/hooks/features/focus/useGridFocus.js +50 -44
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -11
- 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 +6 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +27 -1
- package/legacy/hooks/features/rows/useGridRows.js +131 -61
- package/legacy/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/legacy/hooks/features/scroll/useGridScroll.js +31 -4
- package/legacy/hooks/features/selection/useGridSelection.js +15 -11
- package/legacy/hooks/features/sorting/useGridSorting.js +12 -15
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +79 -42
- 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 +6 -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 +127 -0
- package/legacy/locales/index.js +1 -0
- 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/api/gridColumnSpanning.js +1 -0
- package/legacy/models/events/gridEvents.js +10 -3
- package/legacy/models/gridColumnSpanning.js +1 -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.d.ts +2 -0
- package/locales/huHU.js +115 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- 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/gridApiCommon.d.ts +2 -1
- package/models/api/gridColumnSpanning.d.ts +28 -0
- package/models/api/gridColumnSpanning.js +1 -0
- package/models/api/gridCoreApi.d.ts +10 -0
- package/models/api/gridEditingApi.d.ts +72 -7
- 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 +18 -0
- package/models/events/gridEventLookup.d.ts +296 -11
- package/models/events/gridEvents.d.ts +10 -258
- package/models/events/gridEvents.js +10 -3
- package/models/gridColumnSpanning.d.ts +12 -0
- package/models/gridColumnSpanning.js +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- 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/gridCellParams.d.ts +12 -2
- package/models/params/gridRowParams.d.ts +5 -0
- package/models/props/DataGridProps.d.ts +57 -29
- package/modern/DataGrid/DataGrid.js +36 -2
- package/modern/DataGrid/useDataGridComponent.js +3 -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 +56 -26
- 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 +5 -5
- package/modern/components/cell/GridActionsCell.js +179 -21
- package/modern/components/cell/GridActionsCellItem.js +7 -5
- package/modern/components/cell/GridCell.js +36 -15
- package/modern/components/cell/GridEditBooleanCell.js +101 -6
- package/modern/components/cell/GridEditDateCell.js +99 -5
- package/modern/components/cell/GridEditInputCell.js +30 -6
- package/modern/components/cell/GridEditSingleSelectCell.js +48 -16
- package/modern/components/cell/index.js +2 -0
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +19 -23
- package/modern/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +22 -6
- package/modern/components/columnSelection/GridHeaderCheckbox.js +4 -5
- package/modern/components/containers/GridFooterContainer.js +11 -2
- 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/GridPanel.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/panel/filterPanel/GridFilterForm.js +10 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +11 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +20 -13
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +20 -13
- package/modern/components/toolbar/GridToolbar.js +30 -7
- package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/modern/components/toolbar/GridToolbarExport.js +15 -20
- package/modern/components/toolbar/GridToolbarQuickFilter.js +86 -0
- package/modern/components/toolbar/index.js +3 -2
- package/modern/components/virtualization/GridVirtualScroller.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/modern/constants/defaultGridSlotsComponents.js +3 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/gridDetailPanelToggleField.js +2 -0
- package/modern/constants/localeTextConstants.js +8 -1
- package/modern/hooks/core/pipeProcessing/index.js +2 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- 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 +81 -16
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +3 -3
- package/modern/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/modern/hooks/features/columns/useGridColumnSpanning.js +106 -0
- package/modern/hooks/features/columns/useGridColumns.js +30 -25
- package/modern/hooks/features/dimensions/useGridDimensions.js +10 -11
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +149 -42
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +20 -21
- package/modern/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/modern/hooks/features/editRows/useGridEditing.old.js +4 -5
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +143 -57
- 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 +32 -15
- package/modern/hooks/features/focus/useGridFocus.js +48 -42
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +41 -12
- 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 +2 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +23 -1
- package/modern/hooks/features/rows/useGridRows.js +121 -61
- package/modern/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/modern/hooks/features/scroll/useGridScroll.js +29 -4
- package/modern/hooks/features/selection/useGridSelection.js +15 -11
- package/modern/hooks/features/sorting/useGridSorting.js +17 -18
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +68 -28
- 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 +6 -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 +115 -0
- package/modern/locales/index.js +1 -0
- 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/api/gridColumnSpanning.js +1 -0
- package/modern/models/events/gridEvents.js +10 -3
- package/modern/models/gridColumnSpanning.js +1 -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 +36 -2
- package/node/DataGrid/useDataGridComponent.js +4 -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 +59 -29
- 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 +4 -5
- package/node/components/cell/GridActionsCell.js +181 -21
- package/node/components/cell/GridActionsCellItem.js +7 -4
- package/node/components/cell/GridCell.js +35 -14
- package/node/components/cell/GridEditBooleanCell.js +100 -5
- package/node/components/cell/GridEditDateCell.js +98 -4
- package/node/components/cell/GridEditInputCell.js +30 -6
- package/node/components/cell/GridEditSingleSelectCell.js +50 -18
- package/node/components/cell/index.js +26 -0
- package/node/components/columnHeaders/GridColumnHeaderItem.js +19 -24
- package/node/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +22 -7
- package/node/components/columnSelection/GridHeaderCheckbox.js +4 -6
- package/node/components/containers/GridFooterContainer.js +10 -1
- 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/GridPanel.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/panel/filterPanel/GridFilterForm.js +15 -10
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +14 -8
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +23 -15
- package/node/components/panel/filterPanel/GridFilterInputValue.js +23 -15
- package/node/components/toolbar/GridToolbar.js +32 -7
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/toolbar/GridToolbarExport.js +14 -19
- package/node/components/toolbar/GridToolbarQuickFilter.js +111 -0
- package/node/components/toolbar/index.js +42 -11
- package/node/components/virtualization/GridVirtualScroller.js +2 -0
- package/node/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/gridDetailPanelToggleField.js +9 -0
- package/node/constants/localeTextConstants.js +8 -1
- package/node/hooks/core/pipeProcessing/index.js +13 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +51 -20
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +42 -0
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -3
- 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 +85 -17
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +3 -4
- package/node/hooks/features/columns/gridColumnsUtils.js +65 -9
- package/node/hooks/features/columns/useGridColumnSpanning.js +128 -0
- package/node/hooks/features/columns/useGridColumns.js +29 -25
- package/node/hooks/features/dimensions/useGridDimensions.js +10 -12
- package/node/hooks/features/editRows/useGridCellEditing.new.js +151 -42
- package/node/hooks/features/editRows/useGridCellEditing.old.js +20 -22
- package/node/hooks/features/editRows/useGridEditing.new.js +6 -2
- package/node/hooks/features/editRows/useGridEditing.old.js +4 -6
- package/node/hooks/features/editRows/useGridRowEditing.new.js +143 -57
- 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 +33 -16
- package/node/hooks/features/focus/useGridFocus.js +48 -43
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +44 -13
- 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 +5 -1
- package/node/hooks/features/rows/gridRowsUtils.js +29 -1
- package/node/hooks/features/rows/useGridRows.js +122 -61
- package/node/hooks/features/rows/useGridRowsMeta.js +6 -14
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -0
- package/node/hooks/features/scroll/useGridScroll.js +32 -3
- package/node/hooks/features/selection/useGridSelection.js +16 -12
- package/node/hooks/features/sorting/useGridSorting.js +17 -19
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +73 -33
- 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 +47 -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 +125 -0
- package/node/locales/index.js +13 -0
- 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/api/gridColumnSpanning.js +5 -0
- package/node/models/events/gridEvents.js +10 -3
- package/node/models/gridColumnSpanning.js +5 -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 +4 -4
- package/utils/createSelector.d.ts +2 -1
- package/utils/createSelector.js +20 -2
- package/utils/domUtils.d.ts +2 -2
- package/utils/exportAs.d.ts +2 -2
- package/utils/exportAs.js +1 -1
|
@@ -7,18 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.useGridRowEditing = void 0;
|
|
9
9
|
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
10
|
var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
|
|
13
11
|
|
|
12
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
|
+
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
15
|
|
|
16
16
|
var React = _interopRequireWildcard(require("react"));
|
|
17
17
|
|
|
18
18
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
19
19
|
|
|
20
|
-
var _gridEvents = require("../../../models/events/gridEvents");
|
|
21
|
-
|
|
22
20
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
23
21
|
|
|
24
22
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -31,8 +29,13 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
31
29
|
|
|
32
30
|
var _warning = require("../../../utils/warning");
|
|
33
31
|
|
|
32
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
33
|
+
|
|
34
34
|
var _gridRowParams = require("../../../models/params/gridRowParams");
|
|
35
35
|
|
|
36
|
+
const _excluded = ["id"],
|
|
37
|
+
_excluded2 = ["id"];
|
|
38
|
+
|
|
36
39
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
40
|
|
|
38
41
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -40,11 +43,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
40
43
|
const missingOnProcessRowUpdateErrorWarning = (0, _warning.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');
|
|
41
44
|
|
|
42
45
|
const useGridRowEditing = (apiRef, props) => {
|
|
46
|
+
const [rowModesModel, setRowModesModel] = React.useState({});
|
|
47
|
+
const prevRowModesModel = React.useRef({});
|
|
43
48
|
const focusTimeout = React.useRef(null);
|
|
44
49
|
const nextFocusedCell = React.useRef(null);
|
|
45
50
|
const {
|
|
46
51
|
processRowUpdate,
|
|
47
|
-
onProcessRowUpdateError
|
|
52
|
+
onProcessRowUpdateError,
|
|
53
|
+
rowModesModel: rowModesModelProp,
|
|
54
|
+
onRowModesModelChange,
|
|
55
|
+
signature
|
|
48
56
|
} = props;
|
|
49
57
|
|
|
50
58
|
const runIfEditModeIsRow = callback => (...args) => {
|
|
@@ -79,7 +87,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
79
87
|
field: params.field,
|
|
80
88
|
reason: _gridRowParams.GridRowEditStartReasons.cellDoubleClick
|
|
81
89
|
});
|
|
82
|
-
apiRef.current.publishEvent(
|
|
90
|
+
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
83
91
|
}, [apiRef]);
|
|
84
92
|
const handleCellFocusIn = React.useCallback(params => {
|
|
85
93
|
nextFocusedCell.current = params;
|
|
@@ -105,12 +113,17 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
105
113
|
focusTimeout.current = null;
|
|
106
114
|
|
|
107
115
|
if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
|
|
116
|
+
// The row might have been deleted during the click
|
|
117
|
+
if (!apiRef.current.getRow(params.id)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
108
121
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
109
122
|
const newParams = (0, _extends2.default)({}, rowParams, {
|
|
110
123
|
field: params.field,
|
|
111
124
|
reason: _gridRowParams.GridRowEditStopReasons.rowFocusOut
|
|
112
125
|
});
|
|
113
|
-
apiRef.current.publishEvent(
|
|
126
|
+
apiRef.current.publishEvent('rowEditStop', newParams, event);
|
|
114
127
|
}
|
|
115
128
|
});
|
|
116
129
|
}, [apiRef]);
|
|
@@ -151,7 +164,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
151
164
|
reason,
|
|
152
165
|
field: params.field
|
|
153
166
|
});
|
|
154
|
-
apiRef.current.publishEvent(
|
|
167
|
+
apiRef.current.publishEvent('rowEditStop', newParams, event);
|
|
155
168
|
}
|
|
156
169
|
} else if (params.isEditable) {
|
|
157
170
|
let reason;
|
|
@@ -174,28 +187,26 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
174
187
|
field: params.field,
|
|
175
188
|
reason
|
|
176
189
|
});
|
|
177
|
-
apiRef.current.publishEvent(
|
|
190
|
+
apiRef.current.publishEvent('rowEditStart', newParams, event);
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
193
|
}, [apiRef]);
|
|
181
|
-
const handleRowEditStart = React.useCallback(
|
|
194
|
+
const handleRowEditStart = React.useCallback(params => {
|
|
182
195
|
const {
|
|
183
196
|
id,
|
|
184
197
|
field,
|
|
185
198
|
reason
|
|
186
199
|
} = params;
|
|
187
|
-
|
|
200
|
+
const startRowEditModeParams = {
|
|
188
201
|
id,
|
|
189
202
|
fieldToFocus: field
|
|
190
|
-
}
|
|
203
|
+
};
|
|
191
204
|
|
|
192
205
|
if (reason === _gridRowParams.GridRowEditStartReasons.deleteKeyDown || reason === _gridRowParams.GridRowEditStartReasons.printableKeyDown) {
|
|
193
|
-
|
|
194
|
-
id,
|
|
195
|
-
field: field,
|
|
196
|
-
value: ''
|
|
197
|
-
}, event);
|
|
206
|
+
startRowEditModeParams.deleteValue = !!field;
|
|
198
207
|
}
|
|
208
|
+
|
|
209
|
+
apiRef.current.startRowEditMode(startRowEditModeParams);
|
|
199
210
|
}, [apiRef]);
|
|
200
211
|
const handleRowEditStop = React.useCallback(params => {
|
|
201
212
|
const {
|
|
@@ -232,14 +243,14 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
232
243
|
cellToFocusAfter
|
|
233
244
|
});
|
|
234
245
|
}, [apiRef]);
|
|
235
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
236
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
237
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
238
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
239
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
240
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
241
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
242
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
246
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellDoubleClick', runIfEditModeIsRow(handleCellDoubleClick));
|
|
247
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellFocusIn', runIfEditModeIsRow(handleCellFocusIn));
|
|
248
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellFocusOut', runIfEditModeIsRow(handleCellFocusOut));
|
|
249
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', runIfEditModeIsRow(handleCellKeyDown));
|
|
250
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowEditStart', runIfEditModeIsRow(handleRowEditStart));
|
|
251
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowEditStop', runIfEditModeIsRow(handleRowEditStop));
|
|
252
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowEditStart', props.onRowEditStart);
|
|
253
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowEditStop', props.onRowEditStop);
|
|
243
254
|
const getRowMode = React.useCallback(id => {
|
|
244
255
|
if (props.editMode === _gridEditRowModel.GridEditModes.Cell) {
|
|
245
256
|
return _gridEditRowModel.GridRowModes.View;
|
|
@@ -249,6 +260,34 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
249
260
|
const isEditing = editingState[id] && Object.keys(editingState[id]).length > 0;
|
|
250
261
|
return isEditing ? _gridEditRowModel.GridRowModes.Edit : _gridEditRowModel.GridRowModes.View;
|
|
251
262
|
}, [apiRef, props.editMode]);
|
|
263
|
+
const updateRowModesModel = React.useCallback(newModel => {
|
|
264
|
+
const isNewModelDifferentFromProp = newModel !== props.rowModesModel;
|
|
265
|
+
|
|
266
|
+
if (onRowModesModelChange && isNewModelDifferentFromProp) {
|
|
267
|
+
const details = signature === _useGridApiEventHandler.GridSignature.DataGridPro ? {
|
|
268
|
+
api: apiRef.current
|
|
269
|
+
} : {};
|
|
270
|
+
onRowModesModelChange(newModel, details);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (props.rowModesModel && isNewModelDifferentFromProp) {
|
|
274
|
+
return; // The prop always win
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
setRowModesModel(newModel);
|
|
278
|
+
apiRef.current.publishEvent('rowModesModelChange', newModel);
|
|
279
|
+
}, [apiRef, onRowModesModelChange, props.rowModesModel, signature]);
|
|
280
|
+
const updateRowInRowModesModel = React.useCallback((id, newProps) => {
|
|
281
|
+
const newModel = (0, _extends2.default)({}, rowModesModel);
|
|
282
|
+
|
|
283
|
+
if (newProps !== null) {
|
|
284
|
+
newModel[id] = (0, _extends2.default)({}, newProps);
|
|
285
|
+
} else {
|
|
286
|
+
delete newModel[id];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
updateRowModesModel(newModel);
|
|
290
|
+
}, [rowModesModel, updateRowModesModel]);
|
|
252
291
|
const updateOrDeleteRowState = React.useCallback((id, newProps) => {
|
|
253
292
|
apiRef.current.setState(state => {
|
|
254
293
|
const newEditingState = (0, _extends2.default)({}, state.editRows);
|
|
@@ -288,16 +327,21 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
288
327
|
apiRef.current.forceUpdate();
|
|
289
328
|
}, [apiRef]);
|
|
290
329
|
const startRowEditMode = React.useCallback(params => {
|
|
330
|
+
const {
|
|
331
|
+
id
|
|
332
|
+
} = params,
|
|
333
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(params, _excluded);
|
|
334
|
+
throwIfNotInMode(id, _gridEditRowModel.GridRowModes.View);
|
|
335
|
+
updateRowInRowModesModel(id, (0, _extends2.default)({
|
|
336
|
+
mode: _gridEditRowModel.GridRowModes.Edit
|
|
337
|
+
}, other));
|
|
338
|
+
}, [throwIfNotInMode, updateRowInRowModesModel]);
|
|
339
|
+
const updateStateToStartRowEditMode = React.useCallback(params => {
|
|
291
340
|
const {
|
|
292
341
|
id,
|
|
293
|
-
fieldToFocus
|
|
342
|
+
fieldToFocus,
|
|
343
|
+
deleteValue
|
|
294
344
|
} = params;
|
|
295
|
-
throwIfNotInMode(id, _gridEditRowModel.GridRowModes.View);
|
|
296
|
-
|
|
297
|
-
if (apiRef.current.getRowMode(id) === _gridEditRowModel.GridRowModes.Edit) {
|
|
298
|
-
throw new Error(`MUI: The cell with id=${id} is already in edit mode.`);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
345
|
const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
|
|
302
346
|
const newProps = columnFields.reduce((acc, field) => {
|
|
303
347
|
const cellParams = apiRef.current.getCellParams(id, field);
|
|
@@ -306,8 +350,9 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
306
350
|
return acc;
|
|
307
351
|
}
|
|
308
352
|
|
|
353
|
+
const shouldDeleteValue = deleteValue && fieldToFocus === field;
|
|
309
354
|
acc[field] = {
|
|
310
|
-
value: apiRef.current.getCellValue(id, field),
|
|
355
|
+
value: shouldDeleteValue ? '' : apiRef.current.getCellValue(id, field),
|
|
311
356
|
error: false,
|
|
312
357
|
isProcessingProps: false
|
|
313
358
|
};
|
|
@@ -318,26 +363,37 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
318
363
|
if (fieldToFocus) {
|
|
319
364
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
320
365
|
}
|
|
321
|
-
}, [apiRef,
|
|
366
|
+
}, [apiRef, updateOrDeleteRowState]);
|
|
322
367
|
const stopRowEditMode = React.useCallback(params => {
|
|
368
|
+
const {
|
|
369
|
+
id
|
|
370
|
+
} = params,
|
|
371
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(params, _excluded2);
|
|
372
|
+
throwIfNotInMode(id, _gridEditRowModel.GridRowModes.Edit);
|
|
373
|
+
updateRowInRowModesModel(id, (0, _extends2.default)({
|
|
374
|
+
mode: _gridEditRowModel.GridRowModes.View
|
|
375
|
+
}, other));
|
|
376
|
+
}, [throwIfNotInMode, updateRowInRowModesModel]);
|
|
377
|
+
const updateStateToStopRowEditMode = React.useCallback(params => {
|
|
323
378
|
const {
|
|
324
379
|
id,
|
|
325
380
|
ignoreModifications,
|
|
326
381
|
field: focusedField,
|
|
327
382
|
cellToFocusAfter = 'none'
|
|
328
383
|
} = params;
|
|
329
|
-
throwIfNotInMode(id, _gridEditRowModel.GridRowModes.Edit);
|
|
330
384
|
apiRef.current.unstable_runPendingEditCellValueMutation(id);
|
|
331
385
|
|
|
332
|
-
const
|
|
386
|
+
const finishRowEditMode = () => {
|
|
333
387
|
if (cellToFocusAfter !== 'none' && focusedField) {
|
|
334
388
|
apiRef.current.unstable_moveFocusToRelativeCell(id, focusedField, cellToFocusAfter);
|
|
335
389
|
}
|
|
390
|
+
|
|
391
|
+
updateOrDeleteRowState(id, null);
|
|
392
|
+
updateRowInRowModesModel(id, null);
|
|
336
393
|
};
|
|
337
394
|
|
|
338
395
|
if (ignoreModifications) {
|
|
339
|
-
|
|
340
|
-
updateOrDeleteRowState(id, null);
|
|
396
|
+
finishRowEditMode();
|
|
341
397
|
return;
|
|
342
398
|
}
|
|
343
399
|
|
|
@@ -355,19 +411,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
355
411
|
return;
|
|
356
412
|
}
|
|
357
413
|
|
|
358
|
-
|
|
359
|
-
Object.entries(editingState[id]).forEach(([field, fieldProps]) => {
|
|
360
|
-
const column = apiRef.current.getColumn(field);
|
|
361
|
-
|
|
362
|
-
if (column.valueSetter) {
|
|
363
|
-
rowUpdate = column.valueSetter({
|
|
364
|
-
value: fieldProps.value,
|
|
365
|
-
row: rowUpdate
|
|
366
|
-
});
|
|
367
|
-
} else {
|
|
368
|
-
rowUpdate[field] = fieldProps.value;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
414
|
+
const rowUpdate = apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
371
415
|
|
|
372
416
|
if (processRowUpdate) {
|
|
373
417
|
const handleError = errorThrown => {
|
|
@@ -381,18 +425,16 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
381
425
|
try {
|
|
382
426
|
Promise.resolve(processRowUpdate(rowUpdate, row)).then(finalRowUpdate => {
|
|
383
427
|
apiRef.current.updateRows([finalRowUpdate]);
|
|
384
|
-
|
|
385
|
-
updateOrDeleteRowState(id, null);
|
|
428
|
+
finishRowEditMode();
|
|
386
429
|
}).catch(handleError);
|
|
387
430
|
} catch (errorThrown) {
|
|
388
431
|
handleError(errorThrown);
|
|
389
432
|
}
|
|
390
433
|
} else {
|
|
391
434
|
apiRef.current.updateRows([rowUpdate]);
|
|
392
|
-
|
|
393
|
-
updateOrDeleteRowState(id, null);
|
|
435
|
+
finishRowEditMode();
|
|
394
436
|
}
|
|
395
|
-
}, [apiRef, onProcessRowUpdateError, processRowUpdate,
|
|
437
|
+
}, [apiRef, onProcessRowUpdateError, processRowUpdate, updateOrDeleteRowState, updateRowInRowModesModel]);
|
|
396
438
|
const setRowEditingEditCellValue = React.useCallback(params => {
|
|
397
439
|
const {
|
|
398
440
|
id,
|
|
@@ -504,13 +546,57 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
504
546
|
});
|
|
505
547
|
});
|
|
506
548
|
}, [apiRef, throwIfNotEditable, updateOrDeleteFieldState]);
|
|
549
|
+
const getRowWithUpdatedValuesFromRowEditing = React.useCallback(id => {
|
|
550
|
+
const editingState = (0, _gridEditRowsSelector.gridEditRowsStateSelector)(apiRef.current.state);
|
|
551
|
+
const row = apiRef.current.getRow(id);
|
|
552
|
+
let rowUpdate = (0, _extends2.default)({}, row);
|
|
553
|
+
Object.entries(editingState[id]).forEach(([field, fieldProps]) => {
|
|
554
|
+
const column = apiRef.current.getColumn(field);
|
|
555
|
+
|
|
556
|
+
if (column.valueSetter) {
|
|
557
|
+
rowUpdate = column.valueSetter({
|
|
558
|
+
value: fieldProps.value,
|
|
559
|
+
row: rowUpdate
|
|
560
|
+
});
|
|
561
|
+
} else {
|
|
562
|
+
rowUpdate[field] = fieldProps.value;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
return rowUpdate;
|
|
566
|
+
}, [apiRef]);
|
|
507
567
|
const editingApi = {
|
|
508
568
|
getRowMode,
|
|
509
569
|
startRowEditMode,
|
|
510
570
|
stopRowEditMode,
|
|
511
|
-
unstable_setRowEditingEditCellValue: setRowEditingEditCellValue
|
|
571
|
+
unstable_setRowEditingEditCellValue: setRowEditingEditCellValue,
|
|
572
|
+
unstable_getRowWithUpdatedValuesFromRowEditing: getRowWithUpdatedValuesFromRowEditing
|
|
512
573
|
};
|
|
513
574
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, editingApi, 'EditingApi');
|
|
575
|
+
React.useEffect(() => {
|
|
576
|
+
if (rowModesModelProp) {
|
|
577
|
+
updateRowModesModel(rowModesModelProp);
|
|
578
|
+
}
|
|
579
|
+
}, [rowModesModelProp, updateRowModesModel]);
|
|
580
|
+
React.useEffect(() => {
|
|
581
|
+
const idToIdLookup = (0, _gridRowsSelector.gridRowsIdToIdLookupSelector)(apiRef);
|
|
582
|
+
Object.entries(rowModesModel).forEach(([id, params]) => {
|
|
583
|
+
var _prevRowModesModel$cu, _idToIdLookup$id;
|
|
584
|
+
|
|
585
|
+
const prevMode = ((_prevRowModesModel$cu = prevRowModesModel.current[id]) == null ? void 0 : _prevRowModesModel$cu.mode) || _gridEditRowModel.GridRowModes.View;
|
|
586
|
+
const originalId = (_idToIdLookup$id = idToIdLookup[id]) != null ? _idToIdLookup$id : id;
|
|
587
|
+
|
|
588
|
+
if (params.mode === _gridEditRowModel.GridRowModes.Edit && prevMode === _gridEditRowModel.GridRowModes.View) {
|
|
589
|
+
updateStateToStartRowEditMode((0, _extends2.default)({
|
|
590
|
+
id: originalId
|
|
591
|
+
}, params));
|
|
592
|
+
} else if (params.mode === _gridEditRowModel.GridRowModes.View && prevMode === _gridEditRowModel.GridRowModes.Edit) {
|
|
593
|
+
updateStateToStopRowEditMode((0, _extends2.default)({
|
|
594
|
+
id: originalId
|
|
595
|
+
}, params));
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
prevRowModesModel.current = rowModesModel;
|
|
599
|
+
}, [apiRef, rowModesModel, updateStateToStartRowEditMode, updateStateToStopRowEditMode]);
|
|
514
600
|
};
|
|
515
601
|
|
|
516
602
|
exports.useGridRowEditing = useGridRowEditing;
|
|
@@ -23,8 +23,6 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
23
23
|
|
|
24
24
|
var _gridEditRowsSelector = require("./gridEditRowsSelector");
|
|
25
25
|
|
|
26
|
-
var _gridEvents = require("../../../models/events/gridEvents");
|
|
27
|
-
|
|
28
26
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
29
27
|
|
|
30
28
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
@@ -140,12 +138,12 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
140
138
|
return false;
|
|
141
139
|
}
|
|
142
140
|
|
|
143
|
-
apiRef.current.publishEvent(
|
|
141
|
+
apiRef.current.publishEvent('rowEditCommit', id, event);
|
|
144
142
|
return true;
|
|
145
143
|
});
|
|
146
144
|
}
|
|
147
145
|
|
|
148
|
-
apiRef.current.publishEvent(
|
|
146
|
+
apiRef.current.publishEvent('rowEditCommit', id, event);
|
|
149
147
|
return true;
|
|
150
148
|
}, [apiRef, props.editMode, (_props$experimentalFe2 = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe2.preventCommitWhileValidating]);
|
|
151
149
|
const setRowEditingEditCellValue = React.useCallback(params => {
|
|
@@ -217,7 +215,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
217
215
|
if (event.key === 'Enter') {
|
|
218
216
|
var _props$experimentalFe3;
|
|
219
217
|
|
|
220
|
-
// TODO: check the return before firing
|
|
218
|
+
// TODO: check the return before firing 'rowEditStop'
|
|
221
219
|
// On cell editing, it won't exits the edit mode with error
|
|
222
220
|
const isValid = await apiRef.current.commitRowChange(params.id);
|
|
223
221
|
|
|
@@ -225,12 +223,12 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
225
223
|
return;
|
|
226
224
|
}
|
|
227
225
|
|
|
228
|
-
apiRef.current.publishEvent(
|
|
226
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
229
227
|
} else if (event.key === 'Escape') {
|
|
230
|
-
apiRef.current.publishEvent(
|
|
228
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
231
229
|
}
|
|
232
230
|
} else if (event.key === 'Enter') {
|
|
233
|
-
apiRef.current.publishEvent(
|
|
231
|
+
apiRef.current.publishEvent('rowEditStart', rowParams, event);
|
|
234
232
|
}
|
|
235
233
|
}, [apiRef, (_props$experimentalFe4 = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe4.preventCommitWhileValidating]);
|
|
236
234
|
const handleCellDoubleClick = React.useCallback((params, event) => {
|
|
@@ -239,7 +237,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
239
237
|
}
|
|
240
238
|
|
|
241
239
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
242
|
-
apiRef.current.publishEvent(
|
|
240
|
+
apiRef.current.publishEvent('rowEditStart', rowParams, event);
|
|
243
241
|
}, [apiRef]);
|
|
244
242
|
const handleEditCellPropsChange = React.useCallback(params => {
|
|
245
243
|
const row = apiRef.current.getRow(params.id);
|
|
@@ -272,7 +270,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
272
270
|
apiRef.current.setRowMode(params.id, _gridEditRowModel.GridRowModes.View);
|
|
273
271
|
|
|
274
272
|
if (event.key === 'Enter') {
|
|
275
|
-
apiRef.current.publishEvent(
|
|
273
|
+
apiRef.current.publishEvent('cellNavigationKeyDown', params, event);
|
|
276
274
|
}
|
|
277
275
|
}, [apiRef]);
|
|
278
276
|
const handleRowEditCommit = React.useCallback(id => {
|
|
@@ -319,7 +317,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
319
317
|
if (((_nextFocusedCell$curr = nextFocusedCell.current) == null ? void 0 : _nextFocusedCell$curr.id) !== params.id) {
|
|
320
318
|
await apiRef.current.commitRowChange(params.id, event);
|
|
321
319
|
const rowParams = apiRef.current.getRowParams(params.id);
|
|
322
|
-
apiRef.current.publishEvent(
|
|
320
|
+
apiRef.current.publishEvent('rowEditStop', rowParams, event);
|
|
323
321
|
}
|
|
324
322
|
});
|
|
325
323
|
};
|
|
@@ -337,18 +335,18 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
337
335
|
const params = apiRef.current.getCellParams(cell.id, cell.field);
|
|
338
336
|
commitPropsAndExit(params, {});
|
|
339
337
|
});
|
|
340
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
341
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
342
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
343
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
344
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
345
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
346
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
347
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
348
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef,
|
|
349
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
350
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
351
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
338
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', buildCallback(handleCellKeyDown));
|
|
339
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellDoubleClick', buildCallback(handleCellDoubleClick));
|
|
340
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'editCellPropsChange', buildCallback(handleEditCellPropsChange));
|
|
341
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowEditStart', buildCallback(handleRowEditStart));
|
|
342
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowEditStop', buildCallback(handleRowEditStop));
|
|
343
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowEditCommit', buildCallback(handleRowEditCommit));
|
|
344
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellFocusIn', buildCallback(handleCellFocusIn));
|
|
345
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellFocusOut', buildCallback(handleCellFocusOut));
|
|
346
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderDragStart', buildCallback(handleColumnHeaderDragStart));
|
|
347
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowEditCommit', props.onRowEditCommit);
|
|
348
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowEditStart', props.onRowEditStart);
|
|
349
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowEditStop', props.onRowEditStop);
|
|
352
350
|
};
|
|
353
351
|
|
|
354
352
|
exports.useGridRowEditing = useGridRowEditing;
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useGridEvents = useGridEvents;
|
|
7
7
|
|
|
8
|
-
var _events = require("../../../models/events");
|
|
9
|
-
|
|
10
8
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -14,21 +12,21 @@ var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
|
14
12
|
* @requires useGridColumns (event) - can be after, async only
|
|
15
13
|
*/
|
|
16
14
|
function useGridEvents(apiRef, props) {
|
|
17
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
18
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
19
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
20
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
21
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
22
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
23
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
24
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
25
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
26
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
27
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
28
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
29
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
30
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
31
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
32
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
33
|
-
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef,
|
|
15
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderClick', props.onColumnHeaderClick);
|
|
16
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderDoubleClick', props.onColumnHeaderDoubleClick);
|
|
17
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderOver', props.onColumnHeaderOver);
|
|
18
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderOut', props.onColumnHeaderOut);
|
|
19
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderEnter', props.onColumnHeaderEnter);
|
|
20
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnHeaderLeave', props.onColumnHeaderLeave);
|
|
21
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'columnOrderChange', props.onColumnOrderChange);
|
|
22
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellClick', props.onCellClick);
|
|
23
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellDoubleClick', props.onCellDoubleClick);
|
|
24
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellKeyDown', props.onCellKeyDown);
|
|
25
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'cellFocusOut', props.onCellFocusOut);
|
|
26
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'preferencePanelClose', props.onPreferencePanelClose);
|
|
27
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'preferencePanelOpen', props.onPreferencePanelOpen);
|
|
28
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowDoubleClick', props.onRowDoubleClick);
|
|
29
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rowClick', props.onRowClick);
|
|
30
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'componentError', props.onError);
|
|
31
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'stateChange', props.onStateChange);
|
|
34
32
|
}
|
|
@@ -9,7 +9,7 @@ var _colDef = require("../../../../colDef");
|
|
|
9
9
|
|
|
10
10
|
var _warning = require("../../../../utils/warning");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const serializeCellValue = (value, delimiterCharacter) => {
|
|
13
13
|
if (typeof value === 'string') {
|
|
14
14
|
const formattedValue = value.replace(/"/g, '""'); // Make sure value containing delimiter or line break won't be split into multiple rows
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ const serialiseCellValue = (value, delimiterCharacter) => {
|
|
|
25
25
|
|
|
26
26
|
const objectFormattedValueWarning = (0, _warning.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.']);
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const serializeRow = (id, columns, getCellParams, delimiterCharacter) => columns.map(column => {
|
|
29
29
|
const cellParams = getCellParams(id, column.field);
|
|
30
30
|
|
|
31
31
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -34,7 +34,7 @@ const serialiseRow = (id, columns, getCellParams, delimiterCharacter) => columns
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
return
|
|
37
|
+
return serializeCellValue(cellParams.formattedValue, delimiterCharacter);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
function buildCSV(options) {
|
|
@@ -45,12 +45,12 @@ function buildCSV(options) {
|
|
|
45
45
|
delimiterCharacter,
|
|
46
46
|
includeHeaders
|
|
47
47
|
} = options;
|
|
48
|
-
const CSVBody = rowIds.reduce((acc, id) => `${acc}${
|
|
48
|
+
const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow(id, columns, getCellParams, delimiterCharacter).join(delimiterCharacter)}\r\n`, '').trim();
|
|
49
49
|
|
|
50
50
|
if (!includeHeaders) {
|
|
51
51
|
return CSVBody;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const CSVHead = `${columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column =>
|
|
54
|
+
const CSVHead = `${columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => serializeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
|
|
55
55
|
return `${CSVHead}${CSVBody}`.trim();
|
|
56
56
|
}
|
|
@@ -9,8 +9,6 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
11
11
|
|
|
12
|
-
var _filter = require("../filter");
|
|
13
|
-
|
|
14
12
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
15
13
|
|
|
16
14
|
var _exportAs = require("../../../utils/exportAs");
|
|
@@ -19,22 +17,16 @@ var _csvSerializer = require("./serializers/csvSerializer");
|
|
|
19
17
|
|
|
20
18
|
var _utils = require("./utils");
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
var _GridToolbarExport = require("../../../components/toolbar/GridToolbarExport");
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
apiRef
|
|
28
|
-
}) => {
|
|
29
|
-
const filteredSortedRowIds = (0, _filter.gridFilteredSortedRowIdsSelector)(apiRef);
|
|
30
|
-
const selectedRows = apiRef.current.getSelectedRows();
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
29
|
|
|
36
|
-
return filteredSortedRowIds;
|
|
37
|
-
};
|
|
38
30
|
/**
|
|
39
31
|
* @requires useGridColumns (state)
|
|
40
32
|
* @requires useGridFilter (state)
|
|
@@ -42,8 +34,6 @@ const defaultGetRowsToExport = ({
|
|
|
42
34
|
* @requires useGridSelection (state)
|
|
43
35
|
* @requires useGridParamsApi (method)
|
|
44
36
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
37
|
const useGridCsvExport = apiRef => {
|
|
48
38
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridCsvExport');
|
|
49
39
|
const getDataAsCsv = React.useCallback((options = {}) => {
|
|
@@ -54,7 +44,7 @@ const useGridCsvExport = apiRef => {
|
|
|
54
44
|
apiRef,
|
|
55
45
|
options
|
|
56
46
|
});
|
|
57
|
-
const getRowsToExport = (_options$getRowsToExp = options.getRowsToExport) != null ? _options$getRowsToExp : defaultGetRowsToExport;
|
|
47
|
+
const getRowsToExport = (_options$getRowsToExp = options.getRowsToExport) != null ? _options$getRowsToExp : _utils.defaultGetRowsToExport;
|
|
58
48
|
const exportedRowIds = getRowsToExport({
|
|
59
49
|
apiRef
|
|
60
50
|
});
|
|
@@ -79,6 +69,25 @@ const useGridCsvExport = apiRef => {
|
|
|
79
69
|
exportDataAsCsv
|
|
80
70
|
};
|
|
81
71
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, csvExportApi, 'GridCsvExportApi');
|
|
72
|
+
/**
|
|
73
|
+
* PRE-PROCESSING
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
const addExportMenuButtons = React.useCallback((initialValue, options) => {
|
|
77
|
+
var _options$csvOptions;
|
|
78
|
+
|
|
79
|
+
if ((_options$csvOptions = options.csvOptions) != null && _options$csvOptions.disableToolbarButton) {
|
|
80
|
+
return initialValue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return [...initialValue, {
|
|
84
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridToolbarExport.GridCsvExportMenuItem, {
|
|
85
|
+
options: options.csvOptions
|
|
86
|
+
}),
|
|
87
|
+
componentName: 'csvExport'
|
|
88
|
+
}];
|
|
89
|
+
}, []);
|
|
90
|
+
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportMenu', addExportMenuButtons);
|
|
82
91
|
};
|
|
83
92
|
|
|
84
93
|
exports.useGridCsvExport = useGridCsvExport;
|