@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
|
@@ -12,6 +12,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
14
14
|
var _utils = require("@mui/utils");
|
|
15
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
16
|
+
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
|
15
17
|
var _styles = require("@mui/material/styles");
|
|
16
18
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
17
19
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
@@ -34,13 +36,31 @@ var _useGridVirtualization = require("./useGridVirtualization");
|
|
|
34
36
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
35
37
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
36
38
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
39
|
+
const MINIMUM_COLUMN_WIDTH = 50;
|
|
40
|
+
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
41
|
+
ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
|
|
42
|
+
ScrollDirection[ScrollDirection["UP"] = 1] = "UP";
|
|
43
|
+
ScrollDirection[ScrollDirection["DOWN"] = 2] = "DOWN";
|
|
44
|
+
ScrollDirection[ScrollDirection["LEFT"] = 3] = "LEFT";
|
|
45
|
+
ScrollDirection[ScrollDirection["RIGHT"] = 4] = "RIGHT";
|
|
46
|
+
return ScrollDirection;
|
|
47
|
+
}(ScrollDirection || {});
|
|
48
|
+
const EMPTY_SCROLL_POSITION = {
|
|
49
|
+
top: 0,
|
|
50
|
+
left: 0
|
|
51
|
+
};
|
|
37
52
|
const EMPTY_DETAIL_PANELS = exports.EMPTY_DETAIL_PANELS = Object.freeze(new Map());
|
|
53
|
+
const createScrollCache = (rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
|
|
54
|
+
direction: ScrollDirection.NONE,
|
|
55
|
+
buffer: bufferForDirection(ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
|
|
56
|
+
});
|
|
57
|
+
const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
|
|
38
58
|
const useGridVirtualScroller = () => {
|
|
39
59
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
40
60
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
41
61
|
const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
|
|
42
|
-
const enabled = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationEnabledSelector);
|
|
43
|
-
const enabledForColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationColumnEnabledSelector);
|
|
62
|
+
const enabled = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationEnabledSelector) && !isJSDOM;
|
|
63
|
+
const enabledForColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationColumnEnabledSelector) && !isJSDOM;
|
|
44
64
|
const dimensions = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridDimensionsSelector);
|
|
45
65
|
const outerSize = dimensions.viewportOuterSize;
|
|
46
66
|
const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
|
|
@@ -62,19 +82,34 @@ const useGridVirtualScroller = () => {
|
|
|
62
82
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
63
83
|
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
64
84
|
(0, _useResizeObserver.useResizeObserver)(mainRef, () => apiRef.current.resize());
|
|
65
|
-
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
* Scroll context logic
|
|
88
|
+
* ====================
|
|
89
|
+
* We only render the cells contained in the `renderContext`. However, when the user starts scrolling the grid
|
|
90
|
+
* in a direction, we want to render as many cells as possible in that direction, as to avoid presenting white
|
|
91
|
+
* areas if the user scrolls too fast/far and the viewport ends up in a region we haven't rendered yet. To render
|
|
92
|
+
* more cells, we store some offsets to add to the viewport in `scrollCache.buffer`. Those offsets make the render
|
|
93
|
+
* context wider in the direction the user is going, but also makes the buffer around the viewport `0` for the
|
|
94
|
+
* dimension (horizontal or vertical) in which the user is not scrolling. So if the normal viewport is 8 columns
|
|
95
|
+
* wide, with a 1 column buffer (10 columns total), then we want it to be exactly 8 columns wide during vertical
|
|
96
|
+
* scroll.
|
|
97
|
+
* However, we don't want the rows in the old context to re-render from e.g. 10 columns to 8 columns, because that's
|
|
98
|
+
* work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
|
|
99
|
+
* that are part of this old context will keep their same render context as to avoid re-rendering.
|
|
100
|
+
*/
|
|
101
|
+
const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
102
|
+
const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
66
103
|
const previousRowContext = React.useRef(_useGridVirtualization.EMPTY_RENDER_CONTEXT);
|
|
67
104
|
const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}).current;
|
|
72
|
-
const prevTotalWidth = React.useRef(columnsTotalWidth);
|
|
105
|
+
const scrollTimeout = (0, _useTimeout.default)();
|
|
106
|
+
const frozenContext = React.useRef(undefined);
|
|
107
|
+
const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
73
108
|
const focusedCell = {
|
|
74
109
|
rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
|
|
75
110
|
columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
|
|
76
111
|
};
|
|
77
|
-
const updateRenderContext = React.useCallback(
|
|
112
|
+
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
78
113
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
79
114
|
return;
|
|
80
115
|
}
|
|
@@ -94,41 +129,67 @@ const useGridVirtualScroller = () => {
|
|
|
94
129
|
previousRowContext.current = nextRenderContext;
|
|
95
130
|
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
96
131
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
|
|
132
|
+
previousContextScrollPosition.current = scrollPosition.current;
|
|
133
|
+
}, [apiRef, dimensions.isReady]);
|
|
100
134
|
const triggerUpdateRenderContext = () => {
|
|
101
|
-
const
|
|
102
|
-
|
|
135
|
+
const newScroll = {
|
|
136
|
+
top: scrollerRef.current.scrollTop,
|
|
137
|
+
left: scrollerRef.current.scrollLeft
|
|
138
|
+
};
|
|
139
|
+
const dx = newScroll.left - scrollPosition.current.left;
|
|
140
|
+
const dy = newScroll.top - scrollPosition.current.top;
|
|
141
|
+
const isScrolling = dx !== 0 || dy !== 0;
|
|
142
|
+
scrollPosition.current = newScroll;
|
|
143
|
+
const direction = isScrolling ? directionForDelta(dx, dy) : ScrollDirection.NONE;
|
|
103
144
|
|
|
104
145
|
// Since previous render, we have scrolled...
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
146
|
+
const rowScroll = Math.abs(scrollPosition.current.top - previousContextScrollPosition.current.top);
|
|
147
|
+
const columnScroll = Math.abs(scrollPosition.current.left - previousContextScrollPosition.current.left);
|
|
148
|
+
|
|
149
|
+
// PERF: use the computed minimum column width instead of a static one
|
|
150
|
+
const didCrossThreshold = rowScroll >= dimensions.rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
|
|
151
|
+
const didChangeDirection = scrollCache.direction !== direction;
|
|
152
|
+
const shouldUpdate = didCrossThreshold || didChangeDirection;
|
|
110
153
|
if (!shouldUpdate) {
|
|
111
|
-
return
|
|
154
|
+
return renderContext;
|
|
112
155
|
}
|
|
113
156
|
|
|
157
|
+
// Render a new context
|
|
158
|
+
|
|
159
|
+
if (didChangeDirection) {
|
|
160
|
+
switch (direction) {
|
|
161
|
+
case ScrollDirection.NONE:
|
|
162
|
+
case ScrollDirection.LEFT:
|
|
163
|
+
case ScrollDirection.RIGHT:
|
|
164
|
+
frozenContext.current = undefined;
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
frozenContext.current = renderContext;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
scrollCache.direction = direction;
|
|
172
|
+
scrollCache.buffer = bufferForDirection(direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
|
|
173
|
+
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
174
|
+
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
175
|
+
|
|
114
176
|
// Prevents batching render context changes
|
|
115
177
|
ReactDOM.flushSync(() => {
|
|
116
|
-
updateRenderContext(nextRenderContext
|
|
178
|
+
updateRenderContext(nextRenderContext);
|
|
117
179
|
});
|
|
180
|
+
scrollTimeout.start(1000, triggerUpdateRenderContext);
|
|
118
181
|
return nextRenderContext;
|
|
119
182
|
};
|
|
120
183
|
const forceUpdateRenderContext = () => {
|
|
121
184
|
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
122
|
-
const
|
|
123
|
-
updateRenderContext(nextRenderContext
|
|
185
|
+
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
186
|
+
updateRenderContext(nextRenderContext);
|
|
124
187
|
};
|
|
125
188
|
const handleScroll = (0, _utils.unstable_useEventCallback)(event => {
|
|
126
189
|
const {
|
|
127
190
|
scrollTop,
|
|
128
191
|
scrollLeft
|
|
129
192
|
} = event.currentTarget;
|
|
130
|
-
scrollPosition.top = scrollTop;
|
|
131
|
-
scrollPosition.left = scrollLeft;
|
|
132
193
|
|
|
133
194
|
// On iOS and macOS, negative offsets are possible when swiping past the start
|
|
134
195
|
if (scrollTop < 0) {
|
|
@@ -161,8 +222,7 @@ const useGridVirtualScroller = () => {
|
|
|
161
222
|
if (!params.rows && !currentPage.range) {
|
|
162
223
|
return [];
|
|
163
224
|
}
|
|
164
|
-
const
|
|
165
|
-
const currentRenderContext = params.renderContext ?? renderContext;
|
|
225
|
+
const baseRenderContext = params.renderContext ?? renderContext;
|
|
166
226
|
const isLastSection = !hasBottomPinnedRows && params.position === undefined || hasBottomPinnedRows && params.position === 'bottom';
|
|
167
227
|
const isPinnedSection = params.position !== undefined;
|
|
168
228
|
let rowIndexOffset;
|
|
@@ -180,8 +240,8 @@ const useGridVirtualScroller = () => {
|
|
|
180
240
|
break;
|
|
181
241
|
}
|
|
182
242
|
const rowModels = params.rows ?? currentPage.rows;
|
|
183
|
-
const firstRowToRender =
|
|
184
|
-
const lastRowToRender = Math.min(
|
|
243
|
+
const firstRowToRender = baseRenderContext.firstRowIndex;
|
|
244
|
+
const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
|
|
185
245
|
const rowIndexes = params.rows ? (0, _utils3.range)(0, params.rows.length) : (0, _utils3.range)(firstRowToRender, lastRowToRender);
|
|
186
246
|
let virtualRowIndex = -1;
|
|
187
247
|
if (!isPinnedSection && focusedCell.rowIndex !== -1) {
|
|
@@ -196,6 +256,7 @@ const useGridVirtualScroller = () => {
|
|
|
196
256
|
}
|
|
197
257
|
const rows = [];
|
|
198
258
|
const rowProps = rootProps.slotProps?.row;
|
|
259
|
+
const columnPositions = (0, _gridColumnsSelector.gridColumnPositionsSelector)(apiRef);
|
|
199
260
|
rowIndexes.forEach(rowIndexInPage => {
|
|
200
261
|
const {
|
|
201
262
|
id,
|
|
@@ -260,6 +321,10 @@ const useGridVirtualScroller = () => {
|
|
|
260
321
|
const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
|
|
261
322
|
tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
|
|
262
323
|
}
|
|
324
|
+
let currentRenderContext = baseRenderContext;
|
|
325
|
+
if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
326
|
+
currentRenderContext = frozenContext.current;
|
|
327
|
+
}
|
|
263
328
|
const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, theme.direction, pinnedColumns.left.length);
|
|
264
329
|
const rowIndex = (currentPage?.range?.firstRowIndex || 0) + rowIndexOffset + rowIndexInPage;
|
|
265
330
|
rows.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.row, (0, _extends2.default)({
|
|
@@ -331,11 +396,11 @@ const useGridVirtualScroller = () => {
|
|
|
331
396
|
}, [enabled, gridRootRef, scrollerRef]);
|
|
332
397
|
(0, _useRunOnce.useRunOnce)(outerSize.width !== 0, () => {
|
|
333
398
|
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
334
|
-
const
|
|
335
|
-
updateRenderContext(initialRenderContext
|
|
399
|
+
const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
400
|
+
updateRenderContext(initialRenderContext);
|
|
336
401
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
337
|
-
top: scrollPosition.top,
|
|
338
|
-
left: scrollPosition.left,
|
|
402
|
+
top: scrollPosition.current.top,
|
|
403
|
+
left: scrollPosition.current.left,
|
|
339
404
|
renderContext: initialRenderContext
|
|
340
405
|
});
|
|
341
406
|
});
|
|
@@ -382,26 +447,31 @@ exports.useGridVirtualScroller = useGridVirtualScroller;
|
|
|
382
447
|
function inputsSelector(apiRef, rootProps, enabled, enabledForColumns) {
|
|
383
448
|
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
|
|
384
449
|
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, rootProps);
|
|
450
|
+
const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
451
|
+
const lastRowId = apiRef.current.state.rows.dataRowIds.at(-1);
|
|
452
|
+
const lastColumn = visibleColumns.at(-1);
|
|
385
453
|
return {
|
|
386
454
|
enabled,
|
|
387
455
|
enabledForColumns,
|
|
388
456
|
apiRef,
|
|
389
457
|
autoHeight: rootProps.autoHeight,
|
|
390
|
-
|
|
391
|
-
|
|
458
|
+
rowBufferPx: rootProps.rowBufferPx,
|
|
459
|
+
columnBufferPx: rootProps.columnBufferPx,
|
|
392
460
|
leftPinnedWidth: dimensions.leftPinnedWidth,
|
|
393
461
|
columnsTotalWidth: dimensions.columnsTotalWidth,
|
|
394
462
|
viewportInnerWidth: dimensions.viewportInnerSize.width,
|
|
395
463
|
viewportInnerHeight: dimensions.viewportInnerSize.height,
|
|
464
|
+
lastRowHeight: lastRowId !== undefined ? apiRef.current.unstable_getRowHeight(lastRowId) : 0,
|
|
465
|
+
lastColumnWidth: lastColumn?.computedWidth ?? 0,
|
|
396
466
|
rowsMeta: (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef.current.state),
|
|
397
467
|
columnPositions: (0, _gridColumnsSelector.gridColumnPositionsSelector)(apiRef),
|
|
398
468
|
rows: currentPage.rows,
|
|
399
469
|
range: currentPage.range,
|
|
400
470
|
pinnedColumns: (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef),
|
|
401
|
-
visibleColumns
|
|
471
|
+
visibleColumns
|
|
402
472
|
};
|
|
403
473
|
}
|
|
404
|
-
function computeRenderContext(inputs, scrollPosition) {
|
|
474
|
+
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
405
475
|
let renderContext;
|
|
406
476
|
if (!inputs.enabled) {
|
|
407
477
|
renderContext = {
|
|
@@ -419,7 +489,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
419
489
|
|
|
420
490
|
// Clamp the value because the search may return an index out of bounds.
|
|
421
491
|
// In the last index, this is not needed because Array.slice doesn't include it.
|
|
422
|
-
const firstRowIndex = Math.min(getNearestIndexToRender(inputs, top
|
|
492
|
+
const firstRowIndex = Math.min(getNearestIndexToRender(inputs, top, {
|
|
493
|
+
atStart: true,
|
|
494
|
+
lastPosition: inputs.rowsMeta.positions[inputs.rowsMeta.positions.length - 1] + inputs.lastRowHeight
|
|
495
|
+
}), inputs.rowsMeta.positions.length - 1);
|
|
423
496
|
const lastRowIndex = inputs.autoHeight ? firstRowIndex + inputs.rows.length : getNearestIndexToRender(inputs, top + inputs.viewportInnerHeight);
|
|
424
497
|
let firstColumnIndex = 0;
|
|
425
498
|
let lastColumnIndex = inputs.columnPositions.length;
|
|
@@ -430,7 +503,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
430
503
|
lastIndex: lastRowIndex,
|
|
431
504
|
minFirstIndex: 0,
|
|
432
505
|
maxLastIndex: inputs.rows.length,
|
|
433
|
-
|
|
506
|
+
bufferBefore: scrollCache.buffer.rowBefore,
|
|
507
|
+
bufferAfter: scrollCache.buffer.rowAfter,
|
|
508
|
+
positions: inputs.rowsMeta.positions,
|
|
509
|
+
lastSize: inputs.lastRowHeight
|
|
434
510
|
});
|
|
435
511
|
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
436
512
|
const row = inputs.rows[i];
|
|
@@ -451,10 +527,10 @@ function computeRenderContext(inputs, scrollPosition) {
|
|
|
451
527
|
lastColumnIndex
|
|
452
528
|
};
|
|
453
529
|
}
|
|
454
|
-
const actualRenderContext = deriveRenderContext(inputs
|
|
455
|
-
return
|
|
530
|
+
const actualRenderContext = deriveRenderContext(inputs, renderContext, scrollCache);
|
|
531
|
+
return actualRenderContext;
|
|
456
532
|
}
|
|
457
|
-
function getNearestIndexToRender(inputs, offset) {
|
|
533
|
+
function getNearestIndexToRender(inputs, offset, options) {
|
|
458
534
|
const lastMeasuredIndexRelativeToAllRows = inputs.apiRef.current.getLastMeasuredRowIndex();
|
|
459
535
|
let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
|
|
460
536
|
if (inputs.range?.lastRowIndex && !allRowsMeasured) {
|
|
@@ -465,14 +541,14 @@ function getNearestIndexToRender(inputs, offset) {
|
|
|
465
541
|
if (allRowsMeasured || inputs.rowsMeta.positions[lastMeasuredIndexRelativeToCurrentPage] >= offset) {
|
|
466
542
|
// If all rows were measured (when no row has "auto" as height) or all rows before the offset
|
|
467
543
|
// were measured, then use a binary search because it's faster.
|
|
468
|
-
return binarySearch(offset, inputs.rowsMeta.positions);
|
|
544
|
+
return binarySearch(offset, inputs.rowsMeta.positions, options);
|
|
469
545
|
}
|
|
470
546
|
|
|
471
547
|
// Otherwise, use an exponential search.
|
|
472
548
|
// If rows have "auto" as height, their positions will be based on estimated heights.
|
|
473
549
|
// In this case, we can skip several steps until we find a position higher than the offset.
|
|
474
550
|
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
475
|
-
return exponentialSearch(offset, inputs.rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage);
|
|
551
|
+
return exponentialSearch(offset, inputs.rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage, options);
|
|
476
552
|
}
|
|
477
553
|
|
|
478
554
|
/**
|
|
@@ -480,27 +556,33 @@ function getNearestIndexToRender(inputs, offset) {
|
|
|
480
556
|
* computes the actual render context based on pinned elements, buffer dimensions and
|
|
481
557
|
* spanning.
|
|
482
558
|
*/
|
|
483
|
-
function deriveRenderContext(
|
|
559
|
+
function deriveRenderContext(inputs, nextRenderContext, scrollCache) {
|
|
484
560
|
const [firstRowToRender, lastRowToRender] = getIndexesToRender({
|
|
485
561
|
firstIndex: nextRenderContext.firstRowIndex,
|
|
486
562
|
lastIndex: nextRenderContext.lastRowIndex,
|
|
487
563
|
minFirstIndex: 0,
|
|
488
|
-
maxLastIndex: rows.length,
|
|
489
|
-
|
|
564
|
+
maxLastIndex: inputs.rows.length,
|
|
565
|
+
bufferBefore: scrollCache.buffer.rowBefore,
|
|
566
|
+
bufferAfter: scrollCache.buffer.rowAfter,
|
|
567
|
+
positions: inputs.rowsMeta.positions,
|
|
568
|
+
lastSize: inputs.lastRowHeight
|
|
490
569
|
});
|
|
491
570
|
const [initialFirstColumnToRender, lastColumnToRender] = getIndexesToRender({
|
|
492
571
|
firstIndex: nextRenderContext.firstColumnIndex,
|
|
493
572
|
lastIndex: nextRenderContext.lastColumnIndex,
|
|
494
|
-
minFirstIndex: pinnedColumns.left.length,
|
|
495
|
-
maxLastIndex: visibleColumns.length - pinnedColumns.right.length,
|
|
496
|
-
|
|
573
|
+
minFirstIndex: inputs.pinnedColumns.left.length,
|
|
574
|
+
maxLastIndex: inputs.visibleColumns.length - inputs.pinnedColumns.right.length,
|
|
575
|
+
bufferBefore: scrollCache.buffer.columnBefore,
|
|
576
|
+
bufferAfter: scrollCache.buffer.columnAfter,
|
|
577
|
+
positions: inputs.columnPositions,
|
|
578
|
+
lastSize: inputs.lastColumnWidth
|
|
497
579
|
});
|
|
498
580
|
const firstColumnToRender = (0, _gridColumnsUtils.getFirstNonSpannedColumnToRender)({
|
|
499
581
|
firstColumnToRender: initialFirstColumnToRender,
|
|
500
|
-
apiRef,
|
|
582
|
+
apiRef: inputs.apiRef,
|
|
501
583
|
firstRowToRender,
|
|
502
584
|
lastRowToRender,
|
|
503
|
-
visibleRows: rows
|
|
585
|
+
visibleRows: inputs.rows
|
|
504
586
|
});
|
|
505
587
|
return {
|
|
506
588
|
firstRowIndex: firstRowToRender,
|
|
@@ -533,22 +615,32 @@ function binarySearch(offset, positions, options = undefined, sliceStart = 0, sl
|
|
|
533
615
|
}
|
|
534
616
|
return isBefore ? binarySearch(offset, positions, options, sliceStart, pivot) : binarySearch(offset, positions, options, pivot + 1, sliceEnd);
|
|
535
617
|
}
|
|
536
|
-
function exponentialSearch(offset, positions, index) {
|
|
618
|
+
function exponentialSearch(offset, positions, index, options = undefined) {
|
|
537
619
|
let interval = 1;
|
|
538
620
|
while (index < positions.length && Math.abs(positions[index]) < offset) {
|
|
539
621
|
index += interval;
|
|
540
622
|
interval *= 2;
|
|
541
623
|
}
|
|
542
|
-
return binarySearch(offset, positions,
|
|
624
|
+
return binarySearch(offset, positions, options, Math.floor(index / 2), Math.min(index, positions.length));
|
|
543
625
|
}
|
|
544
626
|
function getIndexesToRender({
|
|
545
627
|
firstIndex,
|
|
546
628
|
lastIndex,
|
|
547
|
-
|
|
629
|
+
bufferBefore,
|
|
630
|
+
bufferAfter,
|
|
548
631
|
minFirstIndex,
|
|
549
|
-
maxLastIndex
|
|
632
|
+
maxLastIndex,
|
|
633
|
+
positions,
|
|
634
|
+
lastSize
|
|
550
635
|
}) {
|
|
551
|
-
|
|
636
|
+
const firstPosition = positions[firstIndex] - bufferBefore;
|
|
637
|
+
const lastPosition = positions[lastIndex] + bufferAfter;
|
|
638
|
+
const firstIndexPadded = binarySearch(firstPosition, positions, {
|
|
639
|
+
atStart: true,
|
|
640
|
+
lastPosition: positions[positions.length - 1] + lastSize
|
|
641
|
+
});
|
|
642
|
+
const lastIndexPadded = binarySearch(lastPosition, positions);
|
|
643
|
+
return [(0, _utils3.clamp)(firstIndexPadded, minFirstIndex, maxLastIndex), (0, _utils3.clamp)(lastIndexPadded, minFirstIndex, maxLastIndex)];
|
|
552
644
|
}
|
|
553
645
|
function areRenderContextsEqual(context1, context2) {
|
|
554
646
|
if (context1 === context2) {
|
|
@@ -560,4 +652,66 @@ function computeOffsetLeft(columnPositions, renderContext, direction, pinnedLeft
|
|
|
560
652
|
const factor = direction === 'ltr' ? 1 : -1;
|
|
561
653
|
const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
|
|
562
654
|
return left;
|
|
655
|
+
}
|
|
656
|
+
function directionForDelta(dx, dy) {
|
|
657
|
+
if (dx === 0 && dy === 0) {
|
|
658
|
+
return ScrollDirection.NONE;
|
|
659
|
+
}
|
|
660
|
+
/* eslint-disable */
|
|
661
|
+
if (Math.abs(dy) >= Math.abs(dx)) {
|
|
662
|
+
if (dy > 0) {
|
|
663
|
+
return ScrollDirection.DOWN;
|
|
664
|
+
} else {
|
|
665
|
+
return ScrollDirection.UP;
|
|
666
|
+
}
|
|
667
|
+
} else {
|
|
668
|
+
if (dx > 0) {
|
|
669
|
+
return ScrollDirection.RIGHT;
|
|
670
|
+
} else {
|
|
671
|
+
return ScrollDirection.LEFT;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
/* eslint-enable */
|
|
675
|
+
}
|
|
676
|
+
function bufferForDirection(direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
|
|
677
|
+
switch (direction) {
|
|
678
|
+
case ScrollDirection.NONE:
|
|
679
|
+
return {
|
|
680
|
+
rowAfter: rowBufferPx,
|
|
681
|
+
rowBefore: rowBufferPx,
|
|
682
|
+
columnAfter: columnBufferPx,
|
|
683
|
+
columnBefore: columnBufferPx
|
|
684
|
+
};
|
|
685
|
+
case ScrollDirection.LEFT:
|
|
686
|
+
return {
|
|
687
|
+
rowAfter: 0,
|
|
688
|
+
rowBefore: 0,
|
|
689
|
+
columnAfter: 0,
|
|
690
|
+
columnBefore: horizontalBuffer
|
|
691
|
+
};
|
|
692
|
+
case ScrollDirection.RIGHT:
|
|
693
|
+
return {
|
|
694
|
+
rowAfter: 0,
|
|
695
|
+
rowBefore: 0,
|
|
696
|
+
columnAfter: horizontalBuffer,
|
|
697
|
+
columnBefore: 0
|
|
698
|
+
};
|
|
699
|
+
case ScrollDirection.UP:
|
|
700
|
+
return {
|
|
701
|
+
rowAfter: 0,
|
|
702
|
+
rowBefore: verticalBuffer,
|
|
703
|
+
columnAfter: 0,
|
|
704
|
+
columnBefore: 0
|
|
705
|
+
};
|
|
706
|
+
case ScrollDirection.DOWN:
|
|
707
|
+
return {
|
|
708
|
+
rowAfter: verticalBuffer,
|
|
709
|
+
rowBefore: 0,
|
|
710
|
+
columnAfter: 0,
|
|
711
|
+
columnBefore: 0
|
|
712
|
+
};
|
|
713
|
+
default:
|
|
714
|
+
// eslint unable to figure out enum exhaustiveness
|
|
715
|
+
throw new Error('unreachable');
|
|
716
|
+
}
|
|
563
717
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const UNINITIALIZED = {};
|
|
11
|
-
|
|
12
|
-
// See https://github.com/facebook/react/issues/14490 for when to use this.
|
|
13
|
-
function useLazyRef(init, initArg) {
|
|
14
|
-
const ref = React.useRef(UNINITIALIZED);
|
|
15
|
-
if (ref.current === UNINITIALIZED) {
|
|
16
|
-
ref.current = init(initArg);
|
|
7
|
+
Object.defineProperty(exports, "useLazyRef", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _useLazyRef.default;
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
});
|
|
13
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
React.useEffect(fn, EMPTY);
|
|
14
|
-
/* eslint-enable react-hooks/exhaustive-deps */
|
|
15
|
-
}
|
|
7
|
+
Object.defineProperty(exports, "useOnMount", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _useOnMount.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _useOnMount = _interopRequireDefault(require("@mui/utils/useOnMount"));
|
|
@@ -1,43 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
'use client';
|
|
3
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class Timeout {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.currentId = null;
|
|
14
|
-
this.clear = () => {
|
|
15
|
-
if (this.currentId !== null) {
|
|
16
|
-
clearTimeout(this.currentId);
|
|
17
|
-
this.currentId = null;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
this.disposeEffect = () => {
|
|
21
|
-
return this.clear;
|
|
22
|
-
};
|
|
7
|
+
Object.defineProperty(exports, "useTimeout", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _useTimeout.default;
|
|
23
11
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
29
|
-
*/
|
|
30
|
-
start(delay, fn) {
|
|
31
|
-
this.clear();
|
|
32
|
-
this.currentId = setTimeout(() => {
|
|
33
|
-
this.currentId = null;
|
|
34
|
-
fn();
|
|
35
|
-
}, delay);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.Timeout = Timeout;
|
|
39
|
-
function useTimeout() {
|
|
40
|
-
const timeout = (0, _useLazyRef.useLazyRef)(Timeout.create).current;
|
|
41
|
-
(0, _useOnMount.useOnMount)(timeout.disposeEffect);
|
|
42
|
-
return timeout;
|
|
43
|
-
}
|
|
12
|
+
});
|
|
13
|
+
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
package/node/index.js
CHANGED
package/node/internals/index.js
CHANGED
|
@@ -9,7 +9,6 @@ var _exportNames = {
|
|
|
9
9
|
GridVirtualScrollerRenderZone: true,
|
|
10
10
|
GridHeaders: true,
|
|
11
11
|
GridBaseColumnHeaders: true,
|
|
12
|
-
GridColumnHeadersInner: true,
|
|
13
12
|
DATA_GRID_DEFAULT_SLOTS_COMPONENTS: true,
|
|
14
13
|
getGridFilter: true,
|
|
15
14
|
useGridRegisterPipeProcessor: true,
|
|
@@ -72,6 +71,8 @@ var _exportNames = {
|
|
|
72
71
|
useGridStatePersistence: true,
|
|
73
72
|
useGridVirtualScroller: true,
|
|
74
73
|
EMPTY_DETAIL_PANELS: true,
|
|
74
|
+
useGridColumnResize: true,
|
|
75
|
+
columnResizeStateInitializer: true,
|
|
75
76
|
useTimeout: true,
|
|
76
77
|
useGridVisibleRows: true,
|
|
77
78
|
getVisibleRows: true,
|
|
@@ -120,12 +121,6 @@ Object.defineProperty(exports, "GridBaseColumnHeaders", {
|
|
|
120
121
|
return _GridBaseColumnHeaders.GridBaseColumnHeaders;
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
|
-
Object.defineProperty(exports, "GridColumnHeadersInner", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () {
|
|
126
|
-
return _GridColumnHeadersInner.GridColumnHeadersInner;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
124
|
Object.defineProperty(exports, "GridHeaders", {
|
|
130
125
|
enumerable: true,
|
|
131
126
|
get: function () {
|
|
@@ -180,6 +175,12 @@ Object.defineProperty(exports, "columnMenuStateInitializer", {
|
|
|
180
175
|
return _useGridColumnMenu.columnMenuStateInitializer;
|
|
181
176
|
}
|
|
182
177
|
});
|
|
178
|
+
Object.defineProperty(exports, "columnResizeStateInitializer", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function () {
|
|
181
|
+
return _useGridColumnResize.columnResizeStateInitializer;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
183
184
|
Object.defineProperty(exports, "columnsStateInitializer", {
|
|
184
185
|
enumerable: true,
|
|
185
186
|
get: function () {
|
|
@@ -414,6 +415,12 @@ Object.defineProperty(exports, "useGridColumnMenu", {
|
|
|
414
415
|
return _useGridColumnMenu.useGridColumnMenu;
|
|
415
416
|
}
|
|
416
417
|
});
|
|
418
|
+
Object.defineProperty(exports, "useGridColumnResize", {
|
|
419
|
+
enumerable: true,
|
|
420
|
+
get: function () {
|
|
421
|
+
return _useGridColumnResize.useGridColumnResize;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
417
424
|
Object.defineProperty(exports, "useGridColumnSpanning", {
|
|
418
425
|
enumerable: true,
|
|
419
426
|
get: function () {
|
|
@@ -605,7 +612,6 @@ var _GridVirtualScrollerContent = require("../components/virtualization/GridVirt
|
|
|
605
612
|
var _GridVirtualScrollerRenderZone = require("../components/virtualization/GridVirtualScrollerRenderZone");
|
|
606
613
|
var _GridHeaders = require("../components/GridHeaders");
|
|
607
614
|
var _GridBaseColumnHeaders = require("../components/columnHeaders/GridBaseColumnHeaders");
|
|
608
|
-
var _GridColumnHeadersInner = require("../components/columnHeaders/GridColumnHeadersInner");
|
|
609
615
|
var _defaultGridSlotsComponents = require("../constants/defaultGridSlotsComponents");
|
|
610
616
|
var _GridFilterPanel = require("../components/panel/filterPanel/GridFilterPanel");
|
|
611
617
|
var _pipeProcessing = require("../hooks/core/pipeProcessing");
|
|
@@ -693,6 +699,7 @@ Object.keys(_virtualization).forEach(function (key) {
|
|
|
693
699
|
}
|
|
694
700
|
});
|
|
695
701
|
});
|
|
702
|
+
var _useGridColumnResize = require("../hooks/features/columnResize/useGridColumnResize");
|
|
696
703
|
var _useTimeout = require("../hooks/utils/useTimeout");
|
|
697
704
|
var _useGridVisibleRows = require("../hooks/utils/useGridVisibleRows");
|
|
698
705
|
var _useGridInitializeState = require("../hooks/utils/useGridInitializeState");
|
|
@@ -750,6 +757,18 @@ Object.keys(_getPublicApiRef).forEach(function (key) {
|
|
|
750
757
|
}
|
|
751
758
|
});
|
|
752
759
|
});
|
|
760
|
+
var _cellBorderUtils = require("../utils/cellBorderUtils");
|
|
761
|
+
Object.keys(_cellBorderUtils).forEach(function (key) {
|
|
762
|
+
if (key === "default" || key === "__esModule") return;
|
|
763
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
764
|
+
if (key in exports && exports[key] === _cellBorderUtils[key]) return;
|
|
765
|
+
Object.defineProperty(exports, key, {
|
|
766
|
+
enumerable: true,
|
|
767
|
+
get: function () {
|
|
768
|
+
return _cellBorderUtils[key];
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
});
|
|
753
772
|
var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
|
|
754
773
|
var _utils3 = require("../hooks/utils");
|
|
755
774
|
Object.keys(_utils3).forEach(function (key) {
|