@mui/x-data-grid 7.0.0-beta.6 → 7.0.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 +311 -12
- package/DataGrid/DataGrid.js +57 -17
- package/DataGrid/useDataGridComponent.js +3 -0
- package/DataGrid/useDataGridProps.js +6 -7
- package/README.md +1 -1
- package/components/GridColumnHeaders.d.ts +1 -2
- package/components/GridColumnHeaders.js +6 -17
- package/components/GridFooter.js +2 -3
- package/components/GridHeader.js +1 -2
- package/components/GridHeaders.js +1 -4
- package/components/GridPagination.d.ts +6 -5
- package/components/GridPagination.js +14 -11
- package/components/GridRow.d.ts +1 -1
- package/components/GridRow.js +17 -36
- package/components/GridScrollArea.d.ts +10 -0
- package/components/GridScrollArea.js +150 -0
- package/components/base/GridFooterPlaceholder.js +1 -2
- package/components/base/GridOverlays.js +3 -6
- package/components/cell/GridActionsCell.js +4 -6
- package/components/cell/GridActionsCellItem.d.ts +8 -25
- package/components/cell/GridActionsCellItem.js +8 -5
- package/components/cell/GridBooleanCell.d.ts +1 -0
- package/components/cell/GridBooleanCell.js +3 -2
- package/components/cell/GridCell.d.ts +7 -0
- package/components/cell/GridCell.js +18 -11
- package/components/cell/GridEditBooleanCell.js +1 -2
- package/components/cell/GridEditDateCell.js +2 -3
- package/components/cell/GridEditInputCell.js +2 -2
- package/components/cell/GridEditSingleSelectCell.js +5 -8
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -3
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +22 -13
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +2 -3
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +26 -12
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/components/columnHeaders/GridColumnHeaderTitle.js +2 -3
- package/components/columnHeaders/GridGenericColumnHeaderItem.d.ts +1 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +7 -6
- package/components/columnSelection/GridCellCheckboxRenderer.js +3 -5
- package/components/columnSelection/GridHeaderCheckbox.js +1 -2
- package/components/columnsManagement/GridColumnsManagement.js +17 -21
- package/components/containers/GridRoot.js +3 -3
- package/components/containers/GridRootStyles.js +12 -20
- package/components/menu/GridMenu.js +4 -6
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +2 -3
- package/components/panel/GridColumnsPanel.js +1 -2
- package/components/panel/GridPanel.d.ts +1 -10
- package/components/panel/GridPanel.js +1 -2
- package/components/panel/GridPreferencesPanel.js +2 -3
- package/components/panel/filterPanel/GridFilterForm.js +24 -27
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +3 -4
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +11 -15
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +10 -14
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +10 -11
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +5 -7
- package/components/panel/filterPanel/GridFilterPanel.js +5 -9
- package/components/panel/filterPanel/filterPanelUtils.js +1 -1
- package/components/toolbar/GridToolbarColumnsButton.js +3 -5
- package/components/toolbar/GridToolbarDensitySelector.js +8 -10
- package/components/toolbar/GridToolbarExport.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +3 -5
- package/components/toolbar/GridToolbarFilterButton.js +3 -5
- package/components/toolbar/GridToolbarQuickFilter.js +4 -5
- package/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/components/virtualization/GridVirtualScroller.js +6 -1
- package/components/virtualization/GridVirtualScrollerContent.js +1 -2
- package/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.js +1 -2
- package/constants/gridClasses.d.ts +6 -32
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +1 -2
- package/hooks/core/useGridApiInitialization.js +4 -6
- package/hooks/features/clipboard/useGridClipboard.js +6 -5
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -16
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +4 -8
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +12 -23
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +23 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +186 -101
- package/hooks/features/columnMenu/useGridColumnMenuSlots.js +2 -2
- package/hooks/features/columnResize/columnResizeSelector.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/hooks/features/columnResize/columnResizeState.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeState.js +1 -0
- package/hooks/features/columnResize/gridColumnResizeApi.d.ts +44 -0
- package/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/hooks/features/columnResize/index.d.ts +3 -0
- package/hooks/features/columnResize/index.js +3 -0
- package/hooks/features/columnResize/useGridColumnResize.d.ts +10 -0
- package/hooks/features/columnResize/useGridColumnResize.js +553 -0
- package/hooks/features/columns/gridColumnsSelector.js +1 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +0 -9
- package/hooks/features/columns/gridColumnsUtils.js +5 -22
- package/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/hooks/features/columns/useGridColumns.js +11 -19
- package/hooks/features/density/densitySelector.d.ts +4 -2
- package/hooks/features/density/densitySelector.js +8 -2
- package/hooks/features/density/densityState.d.ts +1 -4
- package/hooks/features/density/useGridDensity.d.ts +2 -4
- package/hooks/features/density/useGridDensity.js +21 -29
- package/hooks/features/dimensions/useGridDimensions.js +7 -10
- package/hooks/features/editing/useGridCellEditing.js +25 -8
- package/hooks/features/editing/useGridEditing.js +1 -2
- package/hooks/features/editing/useGridRowEditing.js +4 -6
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -0
- package/hooks/features/export/serializers/csvSerializer.js +25 -16
- package/hooks/features/export/useGridCsvExport.js +9 -10
- package/hooks/features/export/useGridPrintExport.js +17 -22
- package/hooks/features/export/utils.js +2 -3
- package/hooks/features/filter/gridFilterSelector.js +15 -22
- package/hooks/features/filter/gridFilterUtils.js +10 -16
- package/hooks/features/filter/useGridFilter.js +9 -15
- package/hooks/features/focus/useGridFocus.js +5 -6
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +1 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +23 -5
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -2
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +19 -2
- package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
- package/hooks/features/pagination/gridPaginationSelector.js +9 -4
- package/hooks/features/pagination/useGridPagination.d.ts +1 -6
- package/hooks/features/pagination/useGridPagination.js +9 -158
- package/hooks/features/pagination/useGridPaginationModel.d.ts +11 -0
- package/hooks/features/pagination/useGridPaginationModel.js +165 -0
- package/hooks/features/pagination/useGridRowCount.d.ts +8 -0
- package/hooks/features/pagination/useGridRowCount.js +94 -0
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +7 -12
- package/hooks/features/rowSelection/useGridRowSelection.js +11 -16
- package/hooks/features/rows/gridRowsSelector.js +11 -19
- package/hooks/features/rows/gridRowsUtils.js +7 -9
- package/hooks/features/rows/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +4 -13
- package/hooks/features/rows/useGridRowsMeta.js +7 -13
- package/hooks/features/scroll/useGridScroll.js +3 -4
- package/hooks/features/sorting/gridSortingSelector.js +4 -7
- package/hooks/features/sorting/useGridSorting.js +8 -14
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +4 -4
- package/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -3
- package/hooks/features/virtualization/useGridVirtualScroller.js +220 -71
- package/hooks/utils/useGridApiEventHandler.js +5 -10
- package/hooks/utils/useGridNativeEventListener.js +1 -2
- package/hooks/utils/useLazyRef.d.ts +1 -2
- package/hooks/utils/useLazyRef.js +1 -11
- package/hooks/utils/useOnMount.d.ts +1 -2
- package/hooks/utils/useOnMount.js +1 -7
- package/hooks/utils/useTimeout.d.ts +1 -11
- package/hooks/utils/useTimeout.js +1 -36
- package/index.js +1 -1
- package/internals/index.d.ts +3 -1
- package/internals/index.js +2 -1
- package/internals/utils/getPinnedCellOffset.d.ts +3 -0
- package/internals/utils/getPinnedCellOffset.js +17 -0
- package/internals/utils/useProps.js +1 -2
- package/joy/joySlots.js +18 -63
- package/locales/jaJP.js +3 -4
- package/material/index.js +0 -2
- package/models/api/gridApiCommon.d.ts +3 -3
- package/models/api/gridCoreApi.d.ts +1 -5
- package/models/api/gridRowsMetaApi.d.ts +1 -1
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +13 -0
- package/models/gridExport.d.ts +6 -0
- package/models/gridHeaderFilteringModel.d.ts +1 -0
- package/models/gridSlotsComponent.d.ts +0 -5
- package/models/gridStateCommunity.d.ts +3 -0
- package/models/params/gridScrollParams.d.ts +5 -3
- package/models/props/DataGridProps.d.ts +58 -28
- package/modern/DataGrid/DataGrid.js +57 -17
- package/modern/DataGrid/useDataGridComponent.js +3 -0
- package/modern/DataGrid/useDataGridProps.js +6 -7
- package/modern/components/GridColumnHeaders.js +6 -17
- package/modern/components/GridHeaders.js +1 -4
- package/modern/components/GridPagination.js +13 -6
- package/modern/components/GridRow.js +4 -19
- package/modern/components/GridScrollArea.js +150 -0
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridActionsCellItem.js +4 -0
- package/modern/components/cell/GridBooleanCell.js +3 -2
- package/modern/components/cell/GridCell.js +11 -3
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +18 -8
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +21 -6
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +6 -5
- package/modern/components/containers/GridRoot.js +3 -3
- package/modern/components/containers/GridRootStyles.js +12 -20
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +5 -5
- package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/modern/components/virtualization/GridVirtualScroller.js +6 -1
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +184 -97
- package/modern/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/modern/hooks/features/columnResize/columnResizeState.js +1 -0
- package/modern/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/modern/hooks/features/columnResize/index.js +3 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +553 -0
- package/modern/hooks/features/columns/gridColumnsUtils.js +4 -20
- package/modern/hooks/features/density/densitySelector.js +8 -2
- package/modern/hooks/features/density/useGridDensity.js +21 -29
- package/modern/hooks/features/dimensions/useGridDimensions.js +4 -5
- package/modern/hooks/features/editing/useGridCellEditing.js +22 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
- package/modern/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/modern/hooks/features/export/useGridCsvExport.js +2 -1
- package/modern/hooks/features/export/useGridPrintExport.js +8 -7
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +21 -2
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/modern/hooks/features/pagination/useGridPagination.js +8 -149
- package/modern/hooks/features/pagination/useGridPaginationModel.js +165 -0
- package/modern/hooks/features/pagination/useGridRowCount.js +94 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
- package/modern/hooks/features/scroll/useGridScroll.js +1 -1
- package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/modern/hooks/utils/useLazyRef.js +1 -11
- package/modern/hooks/utils/useOnMount.js +1 -7
- package/modern/hooks/utils/useTimeout.js +1 -36
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/getPinnedCellOffset.js +17 -0
- package/modern/joy/joySlots.js +11 -50
- package/modern/locales/jaJP.js +3 -4
- package/modern/material/index.js +0 -2
- package/modern/models/api/index.js +0 -1
- package/modern/utils/cellBorderUtils.js +8 -0
- package/modern/utils/createSelector.js +1 -1
- package/modern/utils/domUtils.js +144 -0
- package/modern/utils/keyboardUtils.js +1 -1
- package/node/DataGrid/DataGrid.js +57 -17
- package/node/DataGrid/useDataGridComponent.js +3 -0
- package/node/DataGrid/useDataGridProps.js +6 -7
- package/node/components/GridColumnHeaders.js +6 -16
- package/node/components/GridHeaders.js +1 -4
- package/node/components/GridPagination.js +10 -4
- package/node/components/GridRow.js +3 -18
- package/node/components/GridScrollArea.js +158 -0
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridActionsCellItem.js +4 -0
- package/node/components/cell/GridBooleanCell.js +3 -2
- package/node/components/cell/GridCell.js +12 -4
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/node/components/columnHeaders/GridColumnGroupHeader.js +18 -8
- package/node/components/columnHeaders/GridColumnHeaderItem.js +21 -6
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +6 -5
- package/node/components/containers/GridRoot.js +2 -2
- package/node/components/containers/GridRootStyles.js +12 -20
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +4 -4
- package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/node/components/virtualization/GridVirtualScroller.js +6 -1
- package/node/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +190 -103
- package/node/hooks/features/columnResize/columnResizeSelector.js +10 -0
- package/node/hooks/features/columnResize/columnResizeState.js +5 -0
- package/node/hooks/features/columnResize/gridColumnResizeApi.js +16 -0
- package/node/hooks/features/columnResize/index.js +38 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +564 -0
- package/node/hooks/features/columns/gridColumnsUtils.js +4 -21
- package/node/hooks/features/density/densitySelector.js +9 -3
- package/node/hooks/features/density/useGridDensity.js +22 -30
- package/node/hooks/features/dimensions/useGridDimensions.js +4 -5
- package/node/hooks/features/editing/useGridCellEditing.js +22 -3
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- package/node/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/node/hooks/features/export/useGridCsvExport.js +2 -1
- package/node/hooks/features/export/useGridPrintExport.js +8 -7
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +4 -1
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +21 -2
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/node/hooks/features/pagination/useGridPagination.js +9 -153
- package/node/hooks/features/pagination/useGridPaginationModel.js +176 -0
- package/node/hooks/features/pagination/useGridRowCount.js +103 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/hooks/features/scroll/useGridScroll.js +1 -1
- package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/node/hooks/utils/useLazyRef.js +7 -13
- package/node/hooks/utils/useOnMount.js +8 -10
- package/node/hooks/utils/useTimeout.js +7 -37
- package/node/index.js +1 -1
- package/node/internals/index.js +27 -8
- package/node/internals/utils/getPinnedCellOffset.js +24 -0
- package/node/joy/joySlots.js +11 -50
- package/node/locales/jaJP.js +3 -4
- package/node/material/index.js +0 -2
- package/node/models/api/index.js +0 -11
- package/node/utils/cellBorderUtils.js +16 -0
- package/node/utils/createSelector.js +1 -1
- package/node/utils/domUtils.js +155 -0
- package/node/utils/keyboardUtils.js +1 -1
- package/package.json +4 -4
- package/utils/cellBorderUtils.d.ts +3 -0
- package/utils/cellBorderUtils.js +8 -0
- package/utils/createSelector.js +9 -9
- package/utils/domUtils.d.ts +14 -1
- package/utils/domUtils.js +144 -0
- package/utils/getGridLocalization.js +9 -12
- package/utils/keyboardUtils.js +1 -1
- package/components/columnHeaders/GridColumnHeadersInner.d.ts +0 -8
- package/components/columnHeaders/GridColumnHeadersInner.js +0 -58
- package/modern/components/columnHeaders/GridColumnHeadersInner.js +0 -58
- package/node/components/columnHeaders/GridColumnHeadersInner.js +0 -67
|
@@ -8,7 +8,7 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
8
8
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
9
9
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
10
10
|
import { defaultGetRowsToExport, getColumnsToExport } from './utils';
|
|
11
|
-
import {
|
|
11
|
+
import { getDerivedPaginationModel } from '../pagination/useGridPaginationModel';
|
|
12
12
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
13
13
|
import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
|
|
14
14
|
import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
|
|
@@ -75,7 +75,6 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
75
75
|
apiRef.current.setRows(newRows);
|
|
76
76
|
}, [apiRef]);
|
|
77
77
|
const handlePrintWindowLoad = React.useCallback((printWindow, options) => {
|
|
78
|
-
var _querySelector, _querySelector2;
|
|
79
78
|
const normalizeOptions = _extends({
|
|
80
79
|
copyStyles: true,
|
|
81
80
|
hideToolbar: false,
|
|
@@ -96,19 +95,14 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
96
95
|
|
|
97
96
|
// See https://support.google.com/chrome/thread/191619088?hl=en&msgid=193009642
|
|
98
97
|
gridClone.style.contain = 'size';
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
columnHeadersInner.style.width = '100%';
|
|
102
|
-
let gridToolbarElementHeight = ((_querySelector = gridRootElement.querySelector(`.${gridClasses.toolbarContainer}`)) == null ? void 0 : _querySelector.offsetHeight) || 0;
|
|
103
|
-
let gridFooterElementHeight = ((_querySelector2 = gridRootElement.querySelector(`.${gridClasses.footerContainer}`)) == null ? void 0 : _querySelector2.offsetHeight) || 0;
|
|
98
|
+
let gridToolbarElementHeight = gridRootElement.querySelector(`.${gridClasses.toolbarContainer}`)?.offsetHeight || 0;
|
|
99
|
+
let gridFooterElementHeight = gridRootElement.querySelector(`.${gridClasses.footerContainer}`)?.offsetHeight || 0;
|
|
104
100
|
if (normalizeOptions.hideToolbar) {
|
|
105
|
-
|
|
106
|
-
(_gridClone$querySelec = gridClone.querySelector(`.${gridClasses.toolbarContainer}`)) == null || _gridClone$querySelec.remove();
|
|
101
|
+
gridClone.querySelector(`.${gridClasses.toolbarContainer}`)?.remove();
|
|
107
102
|
gridToolbarElementHeight = 0;
|
|
108
103
|
}
|
|
109
104
|
if (normalizeOptions.hideFooter) {
|
|
110
|
-
|
|
111
|
-
(_gridClone$querySelec2 = gridClone.querySelector(`.${gridClasses.footerContainer}`)) == null || _gridClone$querySelec2.remove();
|
|
105
|
+
gridClone.querySelector(`.${gridClasses.footerContainer}`)?.remove();
|
|
112
106
|
gridFooterElementHeight = 0;
|
|
113
107
|
}
|
|
114
108
|
|
|
@@ -189,13 +183,12 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
189
183
|
}
|
|
190
184
|
}, [apiRef, doc, props.columnHeaderHeight]);
|
|
191
185
|
const handlePrintWindowAfterPrint = React.useCallback(printWindow => {
|
|
192
|
-
var _previousGridState$cu;
|
|
193
186
|
// Remove the print iframe
|
|
194
187
|
doc.current.body.removeChild(printWindow);
|
|
195
188
|
|
|
196
189
|
// Revert grid to previous state
|
|
197
190
|
apiRef.current.restoreState(previousGridState.current || {});
|
|
198
|
-
if (!
|
|
191
|
+
if (!previousGridState.current?.columns?.columnVisibilityModel) {
|
|
199
192
|
// if the apiRef.current.exportState(); did not exported the column visibility, we update it
|
|
200
193
|
apiRef.current.setColumnVisibilityModel(previousColumnVisibility.current);
|
|
201
194
|
}
|
|
@@ -208,7 +201,6 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
208
201
|
previousRows.current = [];
|
|
209
202
|
}, [apiRef]);
|
|
210
203
|
const exportDataAsPrint = React.useCallback(async options => {
|
|
211
|
-
var _options$getRowsToExp;
|
|
212
204
|
logger.debug(`Export data as Print`);
|
|
213
205
|
if (!apiRef.current.rootElementRef.current) {
|
|
214
206
|
throw new Error('MUI X: No grid root element available.');
|
|
@@ -223,16 +215,20 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
223
215
|
page: 0,
|
|
224
216
|
pageSize: visibleRowCount
|
|
225
217
|
};
|
|
226
|
-
apiRef.current.
|
|
227
|
-
|
|
228
|
-
|
|
218
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
219
|
+
pagination: _extends({}, state.pagination, {
|
|
220
|
+
paginationModel: getDerivedPaginationModel(state.pagination,
|
|
221
|
+
// Using signature `DataGridPro` to allow more than 100 rows in the print export
|
|
222
|
+
'DataGridPro', paginationModel)
|
|
223
|
+
})
|
|
224
|
+
}));
|
|
229
225
|
apiRef.current.forceUpdate();
|
|
230
226
|
}
|
|
231
|
-
await updateGridColumnsForPrint(options
|
|
232
|
-
updateGridRowsForPrint(
|
|
227
|
+
await updateGridColumnsForPrint(options?.fields, options?.allColumns, options?.includeCheckboxes);
|
|
228
|
+
updateGridRowsForPrint(options?.getRowsToExport ?? defaultGetRowsToExport);
|
|
233
229
|
apiRef.current.unstable_setVirtualization(false);
|
|
234
230
|
await raf(); // wait for the state changes to take action
|
|
235
|
-
const printWindow = buildPrintWindow(options
|
|
231
|
+
const printWindow = buildPrintWindow(options?.fileName);
|
|
236
232
|
if (process.env.NODE_ENV === 'test') {
|
|
237
233
|
doc.current.body.appendChild(printWindow);
|
|
238
234
|
// In test env, run the all pipeline without waiting for loading
|
|
@@ -261,8 +257,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
261
257
|
* PRE-PROCESSING
|
|
262
258
|
*/
|
|
263
259
|
const addExportMenuButtons = React.useCallback((initialValue, options) => {
|
|
264
|
-
|
|
265
|
-
if ((_options$printOptions = options.printOptions) != null && _options$printOptions.disableToolbarButton) {
|
|
260
|
+
if (options.printOptions?.disableToolbarButton) {
|
|
266
261
|
return initialValue;
|
|
267
262
|
}
|
|
268
263
|
return [...initialValue, {
|
|
@@ -21,14 +21,13 @@ export const getColumnsToExport = ({
|
|
|
21
21
|
export const defaultGetRowsToExport = ({
|
|
22
22
|
apiRef
|
|
23
23
|
}) => {
|
|
24
|
-
var _pinnedRows$top, _pinnedRows$bottom;
|
|
25
24
|
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
26
25
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
27
26
|
const selectedRows = apiRef.current.getSelectedRows();
|
|
28
27
|
const bodyRows = filteredSortedRowIds.filter(id => rowTree[id].type !== 'footer');
|
|
29
28
|
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
30
|
-
const topPinnedRowsIds =
|
|
31
|
-
const bottomPinnedRowsIds =
|
|
29
|
+
const topPinnedRowsIds = pinnedRows?.top?.map(row => row.id) || [];
|
|
30
|
+
const bottomPinnedRowsIds = pinnedRows?.bottom?.map(row => row.id) || [];
|
|
32
31
|
bodyRows.unshift(...topPinnedRowsIds);
|
|
33
32
|
bodyRows.push(...bottomPinnedRowsIds);
|
|
34
33
|
if (selectedRows.size > 0) {
|
|
@@ -74,10 +74,7 @@ export const gridFilteredSortedTopLevelRowEntriesSelector = createSelectorMemoiz
|
|
|
74
74
|
if (rowTreeDepth < 2) {
|
|
75
75
|
return visibleSortedRows;
|
|
76
76
|
}
|
|
77
|
-
return visibleSortedRows.filter(row =>
|
|
78
|
-
var _rowTree$row$id;
|
|
79
|
-
return ((_rowTree$row$id = rowTree[row.id]) == null ? void 0 : _rowTree$row$id.depth) === 0;
|
|
80
|
-
});
|
|
77
|
+
return visibleSortedRows.filter(row => rowTree[row.id]?.depth === 0);
|
|
81
78
|
});
|
|
82
79
|
|
|
83
80
|
/**
|
|
@@ -96,24 +93,20 @@ export const gridFilteredTopLevelRowCountSelector = createSelector(gridFilteredS
|
|
|
96
93
|
* @category Filtering
|
|
97
94
|
* @ignore - do not document.
|
|
98
95
|
*/
|
|
99
|
-
export const gridFilterActiveItemsSelector = createSelectorMemoized(gridFilterModelSelector, gridColumnLookupSelector, (filterModel, columnLookup) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
return !filterOperator.InputComponent || item.value != null && ((_item$value = item.value) == null ? void 0 : _item$value.toString()) !== '';
|
|
115
|
-
});
|
|
116
|
-
});
|
|
96
|
+
export const gridFilterActiveItemsSelector = createSelectorMemoized(gridFilterModelSelector, gridColumnLookupSelector, (filterModel, columnLookup) => filterModel.items?.filter(item => {
|
|
97
|
+
if (!item.field) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const column = columnLookup[item.field];
|
|
101
|
+
if (!column?.filterOperators || column?.filterOperators?.length === 0) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
const filterOperator = column.filterOperators.find(operator => operator.value === item.operator);
|
|
105
|
+
if (!filterOperator) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return !filterOperator.InputComponent || item.value != null && item.value?.toString() !== '';
|
|
109
|
+
}));
|
|
117
110
|
/**
|
|
118
111
|
* @category Filtering
|
|
119
112
|
* @ignore - do not document.
|
|
@@ -87,9 +87,8 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
|
|
|
87
87
|
}
|
|
88
88
|
let parsedValue;
|
|
89
89
|
if (column.valueParser) {
|
|
90
|
-
var _filterItem$value;
|
|
91
90
|
const parser = column.valueParser;
|
|
92
|
-
parsedValue = Array.isArray(filterItem.value) ?
|
|
91
|
+
parsedValue = Array.isArray(filterItem.value) ? filterItem.value?.map(x => parser(x, undefined, column, apiRef)) : parser(filterItem.value, undefined, column, apiRef);
|
|
93
92
|
} else {
|
|
94
93
|
parsedValue = filterItem.value;
|
|
95
94
|
}
|
|
@@ -103,7 +102,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
|
|
|
103
102
|
value: parsedValue
|
|
104
103
|
});
|
|
105
104
|
const filterOperators = column.filterOperators;
|
|
106
|
-
if (!
|
|
105
|
+
if (!filterOperators?.length) {
|
|
107
106
|
throw new Error(`MUI X: No filter operators found for column '${column.field}'.`);
|
|
108
107
|
}
|
|
109
108
|
const filterOperator = filterOperators.find(operator => operator.value === newFilterItem.operator);
|
|
@@ -157,7 +156,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
// We generate a new function with `new Function()` to avoid expensive patterns for JS engines
|
|
160
|
-
// such as a dynamic object assignment,
|
|
159
|
+
// such as a dynamic object assignment, for example `{ [dynamicKey]: value }`.
|
|
161
160
|
const filterItemCore = new Function('appliers', 'row', 'shouldApplyFilter', `"use strict";
|
|
162
161
|
${appliers.map((applier, i) => `const shouldApply${i} = !shouldApplyFilter || shouldApplyFilter(${JSON.stringify(applier.item.field)});`).join('\n')}
|
|
163
162
|
|
|
@@ -173,8 +172,7 @@ return result$$;`.replaceAll('$$', String(filterItemsApplierId)));
|
|
|
173
172
|
return filterItem;
|
|
174
173
|
};
|
|
175
174
|
export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
176
|
-
|
|
177
|
-
return (_filterModel$quickFil = filterModel.quickFilterExcludeHiddenColumns) != null ? _filterModel$quickFil : true;
|
|
175
|
+
return filterModel.quickFilterExcludeHiddenColumns ?? true;
|
|
178
176
|
};
|
|
179
177
|
|
|
180
178
|
/**
|
|
@@ -184,8 +182,7 @@ export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
|
184
182
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
185
183
|
*/
|
|
186
184
|
const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
187
|
-
|
|
188
|
-
const quickFilterValues = (_filterModel$quickFil2 = (_filterModel$quickFil3 = filterModel.quickFilterValues) == null ? void 0 : _filterModel$quickFil3.filter(Boolean)) != null ? _filterModel$quickFil2 : [];
|
|
185
|
+
const quickFilterValues = filterModel.quickFilterValues?.filter(Boolean) ?? [];
|
|
189
186
|
if (quickFilterValues.length === 0) {
|
|
190
187
|
return null;
|
|
191
188
|
}
|
|
@@ -197,7 +194,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
|
197
194
|
const publicApiRef = getPublicApiRef(apiRef);
|
|
198
195
|
columnFields.forEach(field => {
|
|
199
196
|
const column = apiRef.current.getColumn(field);
|
|
200
|
-
const getApplyQuickFilterFn = column
|
|
197
|
+
const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
|
|
201
198
|
if (getApplyQuickFilterFn) {
|
|
202
199
|
appliersPerField.push({
|
|
203
200
|
column,
|
|
@@ -252,9 +249,8 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef, disableEval) =
|
|
|
252
249
|
const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef, disableEval);
|
|
253
250
|
const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
|
|
254
251
|
return function isRowMatchingFilters(row, shouldApplyFilter, result) {
|
|
255
|
-
|
|
256
|
-
result.
|
|
257
|
-
result.passingQuickFilterValues = (_isRowMatchingQuickFi = isRowMatchingQuickFilter == null ? void 0 : isRowMatchingQuickFilter(row, shouldApplyFilter)) != null ? _isRowMatchingQuickFi : null;
|
|
252
|
+
result.passingFilterItems = isRowMatchingFilterItems?.(row, shouldApplyFilter) ?? null;
|
|
253
|
+
result.passingQuickFilterValues = isRowMatchingQuickFilter?.(row, shouldApplyFilter) ?? null;
|
|
258
254
|
};
|
|
259
255
|
};
|
|
260
256
|
const isNotNull = result => result != null;
|
|
@@ -271,12 +267,11 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
|
|
|
271
267
|
|
|
272
268
|
// get result for filter items model
|
|
273
269
|
if (cleanedFilterItemResults.length > 0) {
|
|
274
|
-
var _filterModel$logicOpe;
|
|
275
270
|
// Return true if the item pass with one of the rows
|
|
276
271
|
const filterItemPredicate = item => {
|
|
277
272
|
return cleanedFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
|
|
278
273
|
};
|
|
279
|
-
const logicOperator =
|
|
274
|
+
const logicOperator = filterModel.logicOperator ?? getDefaultGridFilterModel().logicOperator;
|
|
280
275
|
if (logicOperator === GridLogicOperator.And) {
|
|
281
276
|
const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
282
277
|
if (!passesAllFilters) {
|
|
@@ -292,12 +287,11 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
|
|
|
292
287
|
|
|
293
288
|
// get result for quick filter model
|
|
294
289
|
if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
|
|
295
|
-
var _filterModel$quickFil4;
|
|
296
290
|
// Return true if the item pass with one of the rows
|
|
297
291
|
const quickFilterValuePredicate = value => {
|
|
298
292
|
return cleanedQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
|
|
299
293
|
};
|
|
300
|
-
const quickFilterLogicOperator =
|
|
294
|
+
const quickFilterLogicOperator = filterModel.quickFilterLogicOperator ?? getDefaultGridFilterModel().quickFilterLogicOperator;
|
|
301
295
|
if (quickFilterLogicOperator === GridLogicOperator.And) {
|
|
302
296
|
const passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
|
|
303
297
|
if (!passesAllQuickFilterValues) {
|
|
@@ -18,8 +18,7 @@ import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilter
|
|
|
18
18
|
import { isDeepEqual } from '../../../utils/utils';
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
export const filterStateInitializer = (state, props, apiRef) => {
|
|
21
|
-
|
|
22
|
-
const filterModel = (_ref = (_props$filterModel = props.filterModel) != null ? _props$filterModel : (_props$initialState = props.initialState) == null || (_props$initialState = _props$initialState.filter) == null ? void 0 : _props$initialState.filterModel) != null ? _ref : getDefaultGridFilterModel();
|
|
21
|
+
const filterModel = props.filterModel ?? props.initialState?.filter?.filterModel ?? getDefaultGridFilterModel();
|
|
23
22
|
return _extends({}, state, {
|
|
24
23
|
filter: {
|
|
25
24
|
filterModel: sanitizeFilterModel(filterModel, props.disableMultipleColumnsFiltering, apiRef),
|
|
@@ -49,7 +48,6 @@ function createMemoizedValues() {
|
|
|
49
48
|
* @requires useGridRows (event)
|
|
50
49
|
*/
|
|
51
50
|
export const useGridFilter = (apiRef, props) => {
|
|
52
|
-
var _props$initialState3, _props$slotProps2;
|
|
53
51
|
const logger = useGridLogger(apiRef, 'useGridFilter');
|
|
54
52
|
apiRef.current.registerControlState({
|
|
55
53
|
stateId: 'filter',
|
|
@@ -64,7 +62,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
64
62
|
const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef, props.disableEval) : null;
|
|
65
63
|
const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
|
|
66
64
|
isRowMatchingFilters,
|
|
67
|
-
filterModel: filterModel
|
|
65
|
+
filterModel: filterModel ?? getDefaultGridFilterModel()
|
|
68
66
|
});
|
|
69
67
|
const newState = _extends({}, state, {
|
|
70
68
|
filter: _extends({}, state.filter, filteringResult)
|
|
@@ -133,7 +131,6 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
133
131
|
if (targetColumnField) {
|
|
134
132
|
const filterModel = gridFilterModelSelector(apiRef);
|
|
135
133
|
const filterItemsWithValue = filterModel.items.filter(item => {
|
|
136
|
-
var _column$filterOperato;
|
|
137
134
|
if (item.value !== undefined) {
|
|
138
135
|
// Some filters like `isAnyOf` support array as `item.value`.
|
|
139
136
|
// If array is empty, we want to remove it from the filter model.
|
|
@@ -143,8 +140,8 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
143
140
|
return true;
|
|
144
141
|
}
|
|
145
142
|
const column = apiRef.current.getColumn(item.field);
|
|
146
|
-
const filterOperator =
|
|
147
|
-
const requiresFilterValue = typeof
|
|
143
|
+
const filterOperator = column.filterOperators?.find(operator => operator.value === item.operator);
|
|
144
|
+
const requiresFilterValue = typeof filterOperator?.requiresFilterValue === 'undefined' ? true : filterOperator?.requiresFilterValue;
|
|
148
145
|
|
|
149
146
|
// Operators like `isEmpty` don't have and don't require `item.value`.
|
|
150
147
|
// So we don't want to remove them from the filter model if `item.value === undefined`.
|
|
@@ -224,7 +221,6 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
224
221
|
* PRE-PROCESSING
|
|
225
222
|
*/
|
|
226
223
|
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
227
|
-
var _props$initialState2;
|
|
228
224
|
const filterModelToExport = gridFilterModelSelector(apiRef);
|
|
229
225
|
const shouldExportFilterModel =
|
|
230
226
|
// Always export if the `exportOnlyDirtyModels` property is not activated
|
|
@@ -232,7 +228,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
232
228
|
// Always export if the model is controlled
|
|
233
229
|
props.filterModel != null ||
|
|
234
230
|
// Always export if the model has been initialized
|
|
235
|
-
|
|
231
|
+
props.initialState?.filter?.filterModel != null ||
|
|
236
232
|
// Export if the model is not equal to the default value
|
|
237
233
|
!isDeepEqual(filterModelToExport, getDefaultGridFilterModel());
|
|
238
234
|
if (!shouldExportFilterModel) {
|
|
@@ -243,10 +239,9 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
243
239
|
filterModel: filterModelToExport
|
|
244
240
|
}
|
|
245
241
|
});
|
|
246
|
-
}, [apiRef, props.filterModel,
|
|
242
|
+
}, [apiRef, props.filterModel, props.initialState?.filter?.filterModel]);
|
|
247
243
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
248
|
-
|
|
249
|
-
const filterModel = (_context$stateToResto = context.stateToRestore.filter) == null ? void 0 : _context$stateToResto.filterModel;
|
|
244
|
+
const filterModel = context.stateToRestore.filter?.filterModel;
|
|
250
245
|
if (filterModel == null) {
|
|
251
246
|
return params;
|
|
252
247
|
}
|
|
@@ -257,12 +252,11 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
257
252
|
}, [apiRef, props.disableMultipleColumnsFiltering]);
|
|
258
253
|
const preferencePanelPreProcessing = React.useCallback((initialValue, value) => {
|
|
259
254
|
if (value === GridPreferencePanelsValue.filters) {
|
|
260
|
-
var _props$slotProps;
|
|
261
255
|
const FilterPanel = props.slots.filterPanel;
|
|
262
|
-
return /*#__PURE__*/_jsx(FilterPanel, _extends({},
|
|
256
|
+
return /*#__PURE__*/_jsx(FilterPanel, _extends({}, props.slotProps?.filterPanel));
|
|
263
257
|
}
|
|
264
258
|
return initialValue;
|
|
265
|
-
}, [props.slots.filterPanel,
|
|
259
|
+
}, [props.slots.filterPanel, props.slotProps?.filterPanel]);
|
|
266
260
|
const {
|
|
267
261
|
getRowId
|
|
268
262
|
} = props;
|
|
@@ -44,7 +44,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
44
44
|
}, [apiRef]);
|
|
45
45
|
const setCellFocus = React.useCallback((id, field) => {
|
|
46
46
|
const focusedCell = gridFocusCellSelector(apiRef);
|
|
47
|
-
if (
|
|
47
|
+
if (focusedCell?.id === id && focusedCell?.field === field) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
apiRef.current.setState(state => {
|
|
@@ -252,8 +252,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
252
252
|
apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
253
253
|
}, [apiRef]);
|
|
254
254
|
const handleBlur = React.useCallback((_, event) => {
|
|
255
|
-
|
|
256
|
-
if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes(gridClasses.columnHeader)) {
|
|
255
|
+
if (event.relatedTarget?.className.includes(gridClasses.columnHeader)) {
|
|
257
256
|
return;
|
|
258
257
|
}
|
|
259
258
|
logger.debug(`Clearing focus`);
|
|
@@ -286,11 +285,11 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
286
285
|
}
|
|
287
286
|
return;
|
|
288
287
|
}
|
|
289
|
-
if (
|
|
288
|
+
if (cellParams?.id === focusedCell.id && cellParams?.field === focusedCell.field) {
|
|
290
289
|
return;
|
|
291
290
|
}
|
|
292
291
|
const cellElement = apiRef.current.getCellElement(focusedCell.id, focusedCell.field);
|
|
293
|
-
if (cellElement
|
|
292
|
+
if (cellElement?.contains(event.target)) {
|
|
294
293
|
return;
|
|
295
294
|
}
|
|
296
295
|
if (cellParams) {
|
|
@@ -316,7 +315,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
316
315
|
return;
|
|
317
316
|
}
|
|
318
317
|
const cell = gridFocusCellSelector(apiRef);
|
|
319
|
-
if (
|
|
318
|
+
if (cell?.id !== params.id || cell?.field !== params.field) {
|
|
320
319
|
apiRef.current.setCellFocus(params.id, params.field);
|
|
321
320
|
}
|
|
322
321
|
}, [apiRef]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
export declare const gridHeaderFilteringStateSelector: (state: GridStateCommunity) => import("../../../models/gridHeaderFilteringModel").GridHeaderFilteringState;
|
|
3
|
+
export declare const gridHeaderFilteringEnabledSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, boolean>;
|
|
3
4
|
export declare const gridHeaderFilteringEditFieldSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
4
5
|
export declare const gridHeaderFilteringMenuSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string | null>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createSelector } from '../../../utils/createSelector';
|
|
2
2
|
export const gridHeaderFilteringStateSelector = state => state.headerFiltering;
|
|
3
|
+
export const gridHeaderFilteringEnabledSelector = createSelector(gridHeaderFilteringStateSelector,
|
|
4
|
+
// No initialization in MIT, so we need to default to false to be used by `getTotalHeaderHeight`
|
|
5
|
+
headerFilteringState => headerFilteringState?.enabled ?? false);
|
|
3
6
|
export const gridHeaderFilteringEditFieldSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
|
|
4
7
|
export const gridHeaderFilteringMenuSelector = createSelector(gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
|
|
@@ -3,17 +3,20 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { useGridLogger } from '../../utils';
|
|
5
5
|
import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
6
|
-
export const headerFilteringStateInitializer = state => _extends({}, state, {
|
|
6
|
+
export const headerFilteringStateInitializer = (state, props) => _extends({}, state, {
|
|
7
|
+
// @ts-expect-error Access `Pro` prop in MIT
|
|
7
8
|
headerFiltering: {
|
|
9
|
+
enabled: props.headerFilters ?? false,
|
|
8
10
|
editing: null,
|
|
9
11
|
menuOpen: null
|
|
10
12
|
}
|
|
11
13
|
});
|
|
12
14
|
export const useGridHeaderFiltering = (apiRef, props) => {
|
|
13
15
|
const logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
|
|
16
|
+
// @ts-expect-error Access `Pro` prop in MIT
|
|
17
|
+
const isHeaderFilteringEnabled = props.headerFilters ?? false;
|
|
14
18
|
const setHeaderFilterState = React.useCallback(headerFilterState => {
|
|
15
19
|
apiRef.current.setState(state => {
|
|
16
|
-
var _headerFilterState$ed, _headerFilterState$me;
|
|
17
20
|
// Safety check to avoid MIT users from using it
|
|
18
21
|
// This hook should ultimately be moved to the Pro package
|
|
19
22
|
if (props.signature === 'DataGrid') {
|
|
@@ -21,13 +24,14 @@ export const useGridHeaderFiltering = (apiRef, props) => {
|
|
|
21
24
|
}
|
|
22
25
|
return _extends({}, state, {
|
|
23
26
|
headerFiltering: {
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
enabled: isHeaderFilteringEnabled ?? false,
|
|
28
|
+
editing: headerFilterState.editing ?? null,
|
|
29
|
+
menuOpen: headerFilterState.menuOpen ?? null
|
|
26
30
|
}
|
|
27
31
|
});
|
|
28
32
|
});
|
|
29
33
|
apiRef.current.forceUpdate();
|
|
30
|
-
}, [apiRef, props.signature]);
|
|
34
|
+
}, [apiRef, props.signature, isHeaderFilteringEnabled]);
|
|
31
35
|
const startHeaderFilterEditMode = React.useCallback(field => {
|
|
32
36
|
logger.debug(`Starting edit mode on header filter for field: ${field}`);
|
|
33
37
|
apiRef.current.setHeaderFilterState({
|
|
@@ -88,4 +92,18 @@ export const useGridHeaderFiltering = (apiRef, props) => {
|
|
|
88
92
|
};
|
|
89
93
|
useGridApiMethod(apiRef, headerFilterApi, 'public');
|
|
90
94
|
useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* EFFECTS
|
|
98
|
+
*/
|
|
99
|
+
const isFirstRender = React.useRef(true);
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (isFirstRender.current) {
|
|
102
|
+
isFirstRender.current = false;
|
|
103
|
+
} else {
|
|
104
|
+
apiRef.current.setHeaderFilterState({
|
|
105
|
+
enabled: isHeaderFilteringEnabled
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}, [apiRef, isHeaderFilteringEnabled]);
|
|
91
109
|
};
|
package/hooks/features/index.js
CHANGED
|
@@ -127,8 +127,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
127
127
|
apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
|
|
128
128
|
}, [apiRef, logger]);
|
|
129
129
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
130
|
-
|
|
131
|
-
return (_currentPageRows$rowI = currentPageRows[rowIndex]) == null ? void 0 : _currentPageRows$rowI.id;
|
|
130
|
+
return currentPageRows[rowIndex]?.id;
|
|
132
131
|
}, [currentPageRows]);
|
|
133
132
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
134
133
|
const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { GridPaginationModel } from '../../../models/gridPaginationProps';
|
|
2
2
|
export interface GridPaginationState {
|
|
3
3
|
paginationModel: GridPaginationModel;
|
|
4
|
+
rowCount: number;
|
|
4
5
|
}
|
|
5
6
|
export interface GridPaginationInitialState {
|
|
6
7
|
paginationModel?: Partial<GridPaginationModel>;
|
|
8
|
+
rowCount?: number;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
|
-
* The pagination API interface that is available in the grid `apiRef`.
|
|
11
|
+
* The pagination model API interface that is available in the grid `apiRef`.
|
|
10
12
|
*/
|
|
11
|
-
export interface
|
|
13
|
+
export interface GridPaginationModelApi {
|
|
12
14
|
/**
|
|
13
15
|
* Sets the displayed page to the value given by `page`.
|
|
14
16
|
* @param {number} page The new page number.
|
|
@@ -25,3 +27,18 @@ export interface GridPaginationApi {
|
|
|
25
27
|
*/
|
|
26
28
|
setPaginationModel: (model: GridPaginationModel) => void;
|
|
27
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The pagination row count API interface that is available in the grid `apiRef`.
|
|
32
|
+
*/
|
|
33
|
+
export interface GridPaginationRowCountApi {
|
|
34
|
+
/**
|
|
35
|
+
* Sets the `rowCount` to a new value.
|
|
36
|
+
* @param {number} rowCount The new row count value.
|
|
37
|
+
*/
|
|
38
|
+
setRowCount: (rowCount: number) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The pagination API interface that is available in the grid `apiRef`.
|
|
42
|
+
*/
|
|
43
|
+
export interface GridPaginationApi extends GridPaginationModelApi, GridPaginationRowCountApi {
|
|
44
|
+
}
|
|
@@ -9,6 +9,11 @@ export declare const gridPaginationSelector: (state: GridStateCommunity) => impo
|
|
|
9
9
|
* @category Pagination
|
|
10
10
|
*/
|
|
11
11
|
export declare const gridPaginationModelSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridPaginationModel>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the row count
|
|
14
|
+
* @category Pagination
|
|
15
|
+
*/
|
|
16
|
+
export declare const gridPaginationRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
|
|
12
17
|
/**
|
|
13
18
|
* Get the index of the page to render if the pagination is enabled
|
|
14
19
|
* @category Pagination
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSelector, createSelectorMemoized } from '../../../utils/createSelector';
|
|
2
|
-
import {
|
|
2
|
+
import { gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
3
3
|
import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
4
4
|
import { getPageCount } from './gridPaginationUtils';
|
|
5
5
|
|
|
@@ -15,6 +15,12 @@ export const gridPaginationSelector = state => state.pagination;
|
|
|
15
15
|
*/
|
|
16
16
|
export const gridPaginationModelSelector = createSelector(gridPaginationSelector, pagination => pagination.paginationModel);
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Get the row count
|
|
20
|
+
* @category Pagination
|
|
21
|
+
*/
|
|
22
|
+
export const gridPaginationRowCountSelector = createSelector(gridPaginationSelector, pagination => pagination.rowCount);
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* Get the index of the page to render if the pagination is enabled
|
|
20
26
|
* @category Pagination
|
|
@@ -31,7 +37,7 @@ export const gridPageSizeSelector = createSelector(gridPaginationModelSelector,
|
|
|
31
37
|
* Get the amount of pages needed to display all the rows if the pagination is enabled
|
|
32
38
|
* @category Pagination
|
|
33
39
|
*/
|
|
34
|
-
export const gridPageCountSelector = createSelector(
|
|
40
|
+
export const gridPageCountSelector = createSelector(gridPageSizeSelector, gridPaginationRowCountSelector, (pageSize, rowCount) => getPageCount(rowCount, pageSize));
|
|
35
41
|
|
|
36
42
|
/**
|
|
37
43
|
* Get the index of the first and the last row to include in the current page if the pagination is enabled.
|
|
@@ -60,9 +66,8 @@ export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginat
|
|
|
60
66
|
let lastRowIndex = firstRowIndex;
|
|
61
67
|
let topLevelRowAdded = 0;
|
|
62
68
|
while (lastRowIndex < visibleSortedRowEntries.length && topLevelRowAdded <= topLevelRowsInCurrentPageCount) {
|
|
63
|
-
var _rowTree$row$id;
|
|
64
69
|
const row = visibleSortedRowEntries[lastRowIndex];
|
|
65
|
-
const depth =
|
|
70
|
+
const depth = rowTree[row.id]?.depth;
|
|
66
71
|
if (depth === undefined) {
|
|
67
72
|
lastRowIndex += 1;
|
|
68
73
|
} else {
|
|
@@ -2,14 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
-
import { GridPaginationState } from './gridPaginationInterfaces';
|
|
6
|
-
import { GridPaginationModel } from '../../../models/gridPaginationProps';
|
|
7
5
|
export declare const paginationStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'paginationModel' | 'rowCount' | 'initialState' | 'autoPageSize' | 'signature'>>;
|
|
8
|
-
export declare const mergeStateWithPaginationModel: (rowCount: number, signature: DataGridProcessedProps['signature'], paginationModelProp?: GridPaginationModel) => (paginationState: GridPaginationState) => {
|
|
9
|
-
paginationModel: GridPaginationModel;
|
|
10
|
-
};
|
|
11
6
|
/**
|
|
12
7
|
* @requires useGridFilter (state)
|
|
13
8
|
* @requires useGridDimensions (event) - can be after
|
|
14
9
|
*/
|
|
15
|
-
export declare const useGridPagination: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props:
|
|
10
|
+
export declare const useGridPagination: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
|