@mui/x-data-grid-pro 8.0.0-beta.3 → 8.1.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 +388 -96
- package/DataGridPro/DataGridPro.js +8 -7
- package/DataGridPro/useDataGridProComponent.d.ts +2 -2
- package/DataGridPro/useDataGridProComponent.js +2 -3
- package/components/GridDetailPanel.js +1 -2
- package/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
- package/esm/DataGridPro/DataGridPro.js +9 -8
- package/esm/DataGridPro/useDataGridProComponent.d.ts +2 -2
- package/esm/DataGridPro/useDataGridProComponent.js +2 -3
- package/esm/components/GridDetailPanel.js +1 -2
- package/esm/components/headerFiltering/GridHeaderFilterMenu.js +2 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +36 -8
- package/esm/hooks/features/dataSource/utils.d.ts +3 -2
- package/esm/hooks/features/dataSource/utils.js +13 -1
- package/esm/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
- package/esm/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
- package/esm/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
- package/esm/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
- package/esm/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +38 -1
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/material/icons.d.ts +3 -6
- package/esm/material/icons.js +1 -1
- package/esm/material/index.d.ts +2 -2
- package/esm/models/dataGridProProps.d.ts +3 -3
- package/esm/models/gridProIconSlotsComponent.d.ts +6 -3
- package/esm/package.json +1 -1
- package/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +3 -6
- package/hooks/features/dataSource/useGridDataSourceBasePro.js +34 -6
- package/hooks/features/dataSource/utils.d.ts +3 -2
- package/hooks/features/dataSource/utils.js +15 -2
- package/hooks/features/detailPanel/useGridDetailPanel.js +4 -3
- package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
- package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
- package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
- package/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +37 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +15 -7
- package/material/icons.d.ts +3 -6
- package/material/icons.js +3 -3
- package/material/index.d.ts +2 -2
- package/models/dataGridProProps.d.ts +3 -3
- package/models/gridProIconSlotsComponent.d.ts +6 -3
- package/package.json +8 -14
- package/esm/utils/releaseInfo.d.ts +0 -1
- package/esm/utils/releaseInfo.js +0 -13
- package/modern/DataGridPro/DataGrid.d.ts +0 -8
- package/modern/DataGridPro/DataGrid.js +0 -19
- package/modern/DataGridPro/DataGridPro.d.ts +0 -16
- package/modern/DataGridPro/DataGridPro.js +0 -1020
- package/modern/DataGridPro/index.d.ts +0 -3
- package/modern/DataGridPro/index.js +0 -3
- package/modern/DataGridPro/useDataGridProComponent.d.ts +0 -4
- package/modern/DataGridPro/useDataGridProComponent.js +0 -105
- package/modern/DataGridPro/useDataGridProProps.d.ts +0 -7
- package/modern/DataGridPro/useDataGridProProps.js +0 -54
- package/modern/components/GridColumnHeaders.d.ts +0 -5
- package/modern/components/GridColumnHeaders.js +0 -92
- package/modern/components/GridColumnMenuPinningItem.d.ts +0 -7
- package/modern/components/GridColumnMenuPinningItem.js +0 -77
- package/modern/components/GridDataSourceTreeDataGroupingCell.d.ts +0 -12
- package/modern/components/GridDataSourceTreeDataGroupingCell.js +0 -107
- package/modern/components/GridDetailPanel.d.ts +0 -14
- package/modern/components/GridDetailPanel.js +0 -53
- package/modern/components/GridDetailPanelToggleCell.d.ts +0 -7
- package/modern/components/GridDetailPanelToggleCell.js +0 -121
- package/modern/components/GridDetailPanels.d.ts +0 -3
- package/modern/components/GridDetailPanels.js +0 -67
- package/modern/components/GridPinnedRows.d.ts +0 -6
- package/modern/components/GridPinnedRows.js +0 -40
- package/modern/components/GridProColumnMenu.d.ts +0 -24
- package/modern/components/GridProColumnMenu.js +0 -21
- package/modern/components/GridRowReorderCell.d.ts +0 -8
- package/modern/components/GridRowReorderCell.js +0 -140
- package/modern/components/GridTreeDataGroupingCell.d.ts +0 -15
- package/modern/components/GridTreeDataGroupingCell.js +0 -133
- package/modern/components/headerFiltering/GridHeaderFilterCell.d.ts +0 -26
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +0 -362
- package/modern/components/headerFiltering/GridHeaderFilterClearButton.d.ts +0 -6
- package/modern/components/headerFiltering/GridHeaderFilterClearButton.js +0 -17
- package/modern/components/headerFiltering/GridHeaderFilterMenu.d.ts +0 -30
- package/modern/components/headerFiltering/GridHeaderFilterMenu.js +0 -137
- package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.d.ts +0 -17
- package/modern/components/headerFiltering/GridHeaderFilterMenuContainer.js +0 -138
- package/modern/components/headerFiltering/index.d.ts +0 -3
- package/modern/components/headerFiltering/index.js +0 -3
- package/modern/components/index.d.ts +0 -6
- package/modern/components/index.js +0 -7
- package/modern/components/reexports.d.ts +0 -1
- package/modern/components/reexports.js +0 -1
- package/modern/constants/dataGridProDefaultSlotsComponents.d.ts +0 -2
- package/modern/constants/dataGridProDefaultSlotsComponents.js +0 -17
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -12
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +0 -143
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +0 -40
- package/modern/hooks/features/columnPinning/gridColumnPinningInterface.js +0 -1
- package/modern/hooks/features/columnPinning/index.d.ts +0 -1
- package/modern/hooks/features/columnPinning/index.js +0 -1
- package/modern/hooks/features/columnPinning/useGridColumnPinning.d.ts +0 -6
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +0 -228
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.d.ts +0 -4
- package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +0 -105
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.d.ts +0 -6
- package/modern/hooks/features/columnReorder/columnReorderInterfaces.js +0 -1
- package/modern/hooks/features/columnReorder/columnReorderSelector.d.ts +0 -3
- package/modern/hooks/features/columnReorder/columnReorderSelector.js +0 -3
- package/modern/hooks/features/columnReorder/index.d.ts +0 -2
- package/modern/hooks/features/columnReorder/index.js +0 -2
- package/modern/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -9
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +0 -242
- package/modern/hooks/features/dataSource/gridDataSourceSelector.d.ts +0 -7
- package/modern/hooks/features/dataSource/gridDataSourceSelector.js +0 -6
- package/modern/hooks/features/dataSource/models.d.ts +0 -75
- package/modern/hooks/features/dataSource/models.js +0 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +0 -33
- package/modern/hooks/features/dataSource/useGridDataSourceBasePro.js +0 -179
- package/modern/hooks/features/dataSource/useGridDataSourcePro.d.ts +0 -6
- package/modern/hooks/features/dataSource/useGridDataSourcePro.js +0 -35
- package/modern/hooks/features/dataSource/utils.d.ts +0 -29
- package/modern/hooks/features/dataSource/utils.js +0 -82
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +0 -41
- package/modern/hooks/features/detailPanel/gridDetailPanelInterface.js +0 -1
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -14
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +0 -5
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.d.ts +0 -4
- package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +0 -34
- package/modern/hooks/features/detailPanel/index.d.ts +0 -3
- package/modern/hooks/features/detailPanel/index.js +0 -3
- package/modern/hooks/features/detailPanel/useGridDetailPanel.d.ts +0 -6
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +0 -191
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.d.ts +0 -4
- package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +0 -43
- package/modern/hooks/features/index.d.ts +0 -7
- package/modern/hooks/features/index.js +0 -8
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -9
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +0 -104
- package/modern/hooks/features/lazyLoader/useGridLazyLoader.d.ts +0 -10
- package/modern/hooks/features/lazyLoader/useGridLazyLoader.js +0 -90
- package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +0 -5
- package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +0 -34
- package/modern/hooks/features/lazyLoader/utils.d.ts +0 -18
- package/modern/hooks/features/lazyLoader/utils.js +0 -34
- package/modern/hooks/features/rowPinning/gridRowPinningInterface.d.ts +0 -17
- package/modern/hooks/features/rowPinning/gridRowPinningInterface.js +0 -1
- package/modern/hooks/features/rowPinning/gridRowPinningSelector.d.ts +0 -1
- package/modern/hooks/features/rowPinning/gridRowPinningSelector.js +0 -1
- package/modern/hooks/features/rowPinning/index.d.ts +0 -1
- package/modern/hooks/features/rowPinning/index.js +0 -1
- package/modern/hooks/features/rowPinning/useGridRowPinning.d.ts +0 -6
- package/modern/hooks/features/rowPinning/useGridRowPinning.js +0 -52
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +0 -38
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +0 -119
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.d.ts +0 -2
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +0 -20
- package/modern/hooks/features/rowReorder/index.d.ts +0 -1
- package/modern/hooks/features/rowReorder/index.js +0 -1
- package/modern/hooks/features/rowReorder/useGridRowReorder.d.ts +0 -8
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +0 -141
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +0 -4
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +0 -46
- package/modern/hooks/features/rows/index.d.ts +0 -1
- package/modern/hooks/features/rows/index.js +0 -1
- package/modern/hooks/features/rows/useGridRowAriaAttributes.d.ts +0 -3
- package/modern/hooks/features/rows/useGridRowAriaAttributes.js +0 -37
- package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.d.ts +0 -10
- package/modern/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.js +0 -325
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +0 -4
- package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +0 -148
- package/modern/hooks/features/serverSideTreeData/utils.d.ts +0 -7
- package/modern/hooks/features/serverSideTreeData/utils.js +0 -18
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.d.ts +0 -8
- package/modern/hooks/features/treeData/gridTreeDataGroupColDef.js +0 -27
- package/modern/hooks/features/treeData/gridTreeDataUtils.d.ts +0 -22
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -95
- package/modern/hooks/features/treeData/index.d.ts +0 -1
- package/modern/hooks/features/treeData/index.js +0 -1
- package/modern/hooks/features/treeData/useGridTreeData.d.ts +0 -4
- package/modern/hooks/features/treeData/useGridTreeData.js +0 -22
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +0 -4
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +0 -148
- package/modern/hooks/index.d.ts +0 -1
- package/modern/hooks/index.js +0 -1
- package/modern/hooks/utils/useGridApiContext.d.ts +0 -4
- package/modern/hooks/utils/useGridApiContext.js +0 -2
- package/modern/hooks/utils/useGridApiRef.d.ts +0 -4
- package/modern/hooks/utils/useGridApiRef.js +0 -2
- package/modern/hooks/utils/useGridAriaAttributes.d.ts +0 -2
- package/modern/hooks/utils/useGridAriaAttributes.js +0 -11
- package/modern/hooks/utils/useGridPrivateApiContext.d.ts +0 -2
- package/modern/hooks/utils/useGridPrivateApiContext.js +0 -2
- package/modern/hooks/utils/useGridRootProps.d.ts +0 -2
- package/modern/hooks/utils/useGridRootProps.js +0 -2
- package/modern/index.d.ts +0 -22
- package/modern/index.js +0 -25
- package/modern/internals/index.d.ts +0 -33
- package/modern/internals/index.js +0 -38
- package/modern/internals/propValidation.d.ts +0 -3
- package/modern/internals/propValidation.js +0 -2
- package/modern/locales.d.ts +0 -1
- package/modern/locales.js +0 -1
- package/modern/material/icons.d.ts +0 -6
- package/modern/material/icons.js +0 -17
- package/modern/material/index.d.ts +0 -5
- package/modern/material/index.js +0 -8
- package/modern/models/dataGridProProps.d.ts +0 -222
- package/modern/models/dataGridProProps.js +0 -1
- package/modern/models/gridApiPro.d.ts +0 -11
- package/modern/models/gridApiPro.js +0 -1
- package/modern/models/gridFetchRowsParams.d.ts +0 -22
- package/modern/models/gridFetchRowsParams.js +0 -1
- package/modern/models/gridGroupingColDefOverride.d.ts +0 -30
- package/modern/models/gridGroupingColDefOverride.js +0 -1
- package/modern/models/gridProIconSlotsComponent.d.ts +0 -13
- package/modern/models/gridProIconSlotsComponent.js +0 -1
- package/modern/models/gridProSlotProps.d.ts +0 -8
- package/modern/models/gridProSlotProps.js +0 -1
- package/modern/models/gridProSlotsComponent.d.ts +0 -18
- package/modern/models/gridProSlotsComponent.js +0 -1
- package/modern/models/gridRowOrderChangeParams.d.ts +0 -18
- package/modern/models/gridRowOrderChangeParams.js +0 -1
- package/modern/models/gridRowScrollEndParams.d.ts +0 -18
- package/modern/models/gridRowScrollEndParams.js +0 -1
- package/modern/models/gridStatePro.d.ts +0 -19
- package/modern/models/gridStatePro.js +0 -1
- package/modern/models/index.d.ts +0 -7
- package/modern/models/index.js +0 -7
- package/modern/package.json +0 -1
- package/modern/themeAugmentation/index.d.ts +0 -2
- package/modern/themeAugmentation/index.js +0 -4
- package/modern/themeAugmentation/overrides.d.ts +0 -7
- package/modern/themeAugmentation/overrides.js +0 -1
- package/modern/themeAugmentation/props.d.ts +0 -15
- package/modern/themeAugmentation/props.js +0 -1
- package/modern/typeOverloads/index.d.ts +0 -1
- package/modern/typeOverloads/index.js +0 -1
- package/modern/typeOverloads/modules.d.ts +0 -70
- package/modern/typeOverloads/modules.js +0 -1
- package/modern/typeOverloads/reexports.d.ts +0 -17
- package/modern/typeOverloads/reexports.js +0 -15
- package/modern/utils/index.d.ts +0 -1
- package/modern/utils/index.js +0 -1
- package/modern/utils/releaseInfo.d.ts +0 -1
- package/modern/utils/releaseInfo.js +0 -13
- package/modern/utils/tree/createRowTree.d.ts +0 -17
- package/modern/utils/tree/createRowTree.js +0 -37
- package/modern/utils/tree/index.d.ts +0 -1
- package/modern/utils/tree/index.js +0 -1
- package/modern/utils/tree/insertDataRowInTree.d.ts +0 -69
- package/modern/utils/tree/insertDataRowInTree.js +0 -141
- package/modern/utils/tree/models.d.ts +0 -14
- package/modern/utils/tree/models.js +0 -1
- package/modern/utils/tree/removeDataRowFromTree.d.ts +0 -45
- package/modern/utils/tree/removeDataRowFromTree.js +0 -94
- package/modern/utils/tree/sortRowTree.d.ts +0 -15
- package/modern/utils/tree/sortRowTree.js +0 -114
- package/modern/utils/tree/updateRowTree.d.ts +0 -20
- package/modern/utils/tree/updateRowTree.js +0 -88
- package/modern/utils/tree/utils.d.ts +0 -54
- package/modern/utils/tree/utils.js +0 -197
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils/releaseInfo.d.ts +0 -1
- package/utils/releaseInfo.js +0 -20
- /package/esm/{locales.d.ts → locales/index.d.ts} +0 -0
- /package/esm/{locales.js → locales/index.js} +0 -0
- /package/{locales.d.ts → locales/index.d.ts} +0 -0
- /package/{locales.js → locales/index.js} +0 -0
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["operators", "item", "field", "buttonRef", "headerFilterMenuRef", "disabled", "showClearItem", "clearFilterItem"];
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { useGridApiContext, useGridSelector } from '@mui/x-data-grid';
|
|
7
|
-
import { refType, unstable_useId as useId } from '@mui/utils';
|
|
8
|
-
import { gridHeaderFilteringMenuSelector } from '@mui/x-data-grid/internals';
|
|
9
|
-
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
function GridHeaderFilterMenuContainer(props) {
|
|
12
|
-
const {
|
|
13
|
-
operators,
|
|
14
|
-
item,
|
|
15
|
-
field,
|
|
16
|
-
buttonRef,
|
|
17
|
-
headerFilterMenuRef,
|
|
18
|
-
disabled = false,
|
|
19
|
-
showClearItem,
|
|
20
|
-
clearFilterItem
|
|
21
|
-
} = props,
|
|
22
|
-
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
23
|
-
const buttonId = useId();
|
|
24
|
-
const menuId = useId();
|
|
25
|
-
const rootProps = useGridRootProps();
|
|
26
|
-
const apiRef = useGridApiContext();
|
|
27
|
-
const menuOpenField = useGridSelector(apiRef, gridHeaderFilteringMenuSelector);
|
|
28
|
-
const open = Boolean(menuOpenField === field && headerFilterMenuRef.current);
|
|
29
|
-
const handleClick = event => {
|
|
30
|
-
headerFilterMenuRef.current = event.currentTarget;
|
|
31
|
-
apiRef.current.showHeaderFilterMenu(field);
|
|
32
|
-
};
|
|
33
|
-
if (!rootProps.slots.headerFilterMenu) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const label = apiRef.current.getLocaleText('filterPanelOperator');
|
|
37
|
-
const labelString = label ? String(label) : undefined;
|
|
38
|
-
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
39
|
-
children: [/*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
40
|
-
id: buttonId,
|
|
41
|
-
ref: buttonRef,
|
|
42
|
-
"aria-label": labelString,
|
|
43
|
-
title: labelString,
|
|
44
|
-
"aria-controls": menuId,
|
|
45
|
-
"aria-expanded": open ? 'true' : undefined,
|
|
46
|
-
"aria-haspopup": "true",
|
|
47
|
-
tabIndex: -1,
|
|
48
|
-
size: "small",
|
|
49
|
-
onClick: handleClick,
|
|
50
|
-
disabled: disabled
|
|
51
|
-
}, rootProps.slotProps?.baseIconButton, {
|
|
52
|
-
children: /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
|
|
53
|
-
color: "primary",
|
|
54
|
-
variant: "dot",
|
|
55
|
-
badgeContent: showClearItem ? 1 : 0,
|
|
56
|
-
children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {
|
|
57
|
-
fontSize: "inherit"
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
})), /*#__PURE__*/_jsx(rootProps.slots.headerFilterMenu, _extends({
|
|
61
|
-
field: field,
|
|
62
|
-
open: open,
|
|
63
|
-
item: item,
|
|
64
|
-
target: headerFilterMenuRef.current,
|
|
65
|
-
operators: operators,
|
|
66
|
-
labelledBy: buttonId,
|
|
67
|
-
id: menuId,
|
|
68
|
-
clearFilterItem: clearFilterItem,
|
|
69
|
-
showClearItem: showClearItem
|
|
70
|
-
}, others))]
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
process.env.NODE_ENV !== "production" ? GridHeaderFilterMenuContainer.propTypes = {
|
|
74
|
-
// ----------------------------- Warning --------------------------------
|
|
75
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
76
|
-
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
77
|
-
// ----------------------------------------------------------------------
|
|
78
|
-
applyFilterChanges: PropTypes.func.isRequired,
|
|
79
|
-
buttonRef: refType,
|
|
80
|
-
clearFilterItem: PropTypes.func,
|
|
81
|
-
disabled: PropTypes.bool,
|
|
82
|
-
field: PropTypes.string.isRequired,
|
|
83
|
-
headerFilterMenuRef: PropTypes.shape({
|
|
84
|
-
current: PropTypes.object
|
|
85
|
-
}).isRequired,
|
|
86
|
-
item: PropTypes.shape({
|
|
87
|
-
field: PropTypes.string.isRequired,
|
|
88
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
89
|
-
operator: PropTypes.string.isRequired,
|
|
90
|
-
value: PropTypes.any
|
|
91
|
-
}).isRequired,
|
|
92
|
-
operators: PropTypes.arrayOf(PropTypes.shape({
|
|
93
|
-
getApplyFilterFn: PropTypes.func.isRequired,
|
|
94
|
-
getValueAsString: PropTypes.func,
|
|
95
|
-
headerLabel: PropTypes.string,
|
|
96
|
-
InputComponent: PropTypes.elementType,
|
|
97
|
-
InputComponentProps: PropTypes.shape({
|
|
98
|
-
apiRef: PropTypes.shape({
|
|
99
|
-
current: PropTypes.object.isRequired
|
|
100
|
-
}),
|
|
101
|
-
applyValue: PropTypes.func,
|
|
102
|
-
className: PropTypes.string,
|
|
103
|
-
clearButton: PropTypes.node,
|
|
104
|
-
disabled: PropTypes.bool,
|
|
105
|
-
focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
106
|
-
current: PropTypes.any.isRequired
|
|
107
|
-
})]),
|
|
108
|
-
headerFilterMenu: PropTypes.node,
|
|
109
|
-
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
110
|
-
current: (props, propName) => {
|
|
111
|
-
if (props[propName] == null) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
115
|
-
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
})]),
|
|
120
|
-
isFilterActive: PropTypes.bool,
|
|
121
|
-
item: PropTypes.shape({
|
|
122
|
-
field: PropTypes.string.isRequired,
|
|
123
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
124
|
-
operator: PropTypes.string.isRequired,
|
|
125
|
-
value: PropTypes.any
|
|
126
|
-
}),
|
|
127
|
-
onBlur: PropTypes.func,
|
|
128
|
-
onFocus: PropTypes.func,
|
|
129
|
-
slotProps: PropTypes.object,
|
|
130
|
-
tabIndex: PropTypes.number
|
|
131
|
-
}),
|
|
132
|
-
label: PropTypes.string,
|
|
133
|
-
requiresFilterValue: PropTypes.bool,
|
|
134
|
-
value: PropTypes.string.isRequired
|
|
135
|
-
})).isRequired,
|
|
136
|
-
showClearItem: PropTypes.bool
|
|
137
|
-
} : void 0;
|
|
138
|
-
export { GridHeaderFilterMenuContainer };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from "./GridTreeDataGroupingCell.js";
|
|
2
|
-
export * from "./GridColumnMenuPinningItem.js";
|
|
3
|
-
export * from "./GridDetailPanelToggleCell.js";
|
|
4
|
-
export * from "./GridRowReorderCell.js";
|
|
5
|
-
export * from "../material/icons.js";
|
|
6
|
-
export * from "./headerFiltering/index.js";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Only export the variable and types that should be publicly exposed and re-exported from `@mui/x-data-grid-pro`
|
|
2
|
-
export * from "./GridTreeDataGroupingCell.js";
|
|
3
|
-
export * from "./GridColumnMenuPinningItem.js";
|
|
4
|
-
export * from "./GridDetailPanelToggleCell.js";
|
|
5
|
-
export * from "./GridRowReorderCell.js";
|
|
6
|
-
export * from "../material/icons.js";
|
|
7
|
-
export * from "./headerFiltering/index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GridProColumnMenu as GridColumnMenu, GRID_COLUMN_MENU_SLOTS_PRO as GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS_PRO as GRID_COLUMN_MENU_SLOT_PROPS } from "./GridProColumnMenu.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GridProColumnMenu as GridColumnMenu, GRID_COLUMN_MENU_SLOTS_PRO as GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS_PRO as GRID_COLUMN_MENU_SLOT_PROPS } from "./GridProColumnMenu.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from '@mui/x-data-grid/internals';
|
|
3
|
-
import { GridProColumnMenu } from "../components/GridProColumnMenu.js";
|
|
4
|
-
import { GridColumnHeaders } from "../components/GridColumnHeaders.js";
|
|
5
|
-
import { GridHeaderFilterMenu } from "../components/headerFiltering/GridHeaderFilterMenu.js";
|
|
6
|
-
import { GridHeaderFilterCell } from "../components/headerFiltering/GridHeaderFilterCell.js";
|
|
7
|
-
import { GridDetailPanels } from "../components/GridDetailPanels.js";
|
|
8
|
-
import { GridPinnedRows } from "../components/GridPinnedRows.js";
|
|
9
|
-
import materialSlots from "../material/index.js";
|
|
10
|
-
export const DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS = _extends({}, DATA_GRID_DEFAULT_SLOTS_COMPONENTS, materialSlots, {
|
|
11
|
-
columnMenu: GridProColumnMenu,
|
|
12
|
-
columnHeaders: GridColumnHeaders,
|
|
13
|
-
detailPanels: GridDetailPanels,
|
|
14
|
-
headerFilterCell: GridHeaderFilterCell,
|
|
15
|
-
headerFilterMenu: GridHeaderFilterMenu,
|
|
16
|
-
pinnedRows: GridPinnedRows
|
|
17
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { UseGridColumnHeadersProps, GetHeadersParams } from '@mui/x-data-grid/internals';
|
|
3
|
-
export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) => {
|
|
4
|
-
getColumnFiltersRow: () => React.JSX.Element | null;
|
|
5
|
-
getFillers: (params: GetHeadersParams | undefined, children: React.ReactNode, leftOverflow: number, borderBottom?: boolean) => React.JSX.Element;
|
|
6
|
-
getColumnHeadersRow: () => React.JSX.Element;
|
|
7
|
-
getColumnGroupHeadersRows: () => React.JSX.Element[] | null;
|
|
8
|
-
isDragging: boolean;
|
|
9
|
-
getInnerProps: () => {
|
|
10
|
-
role: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["getColumnsToRender", "getPinnedCellOffset", "renderContext", "leftRenderContext", "rightRenderContext", "pinnedColumns", "visibleColumns", "columnPositions"];
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { gridFocusColumnHeaderFilterSelector, useGridSelector, gridFilterModelSelector, gridTabIndexColumnHeaderFilterSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
6
|
-
import { gridColumnsTotalWidthSelector, gridHasFillerSelector, gridHeaderFilterHeightSelector, gridVerticalScrollbarWidthSelector, useGridColumnHeaders as useGridColumnHeadersCommunity, useGridPrivateApiContext, getGridFilter, GridColumnHeaderRow, shouldCellShowLeftBorder, shouldCellShowRightBorder, PinnedColumnPosition } from '@mui/x-data-grid/internals';
|
|
7
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
-
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const useUtilityClasses = ownerState => {
|
|
11
|
-
const {
|
|
12
|
-
classes
|
|
13
|
-
} = ownerState;
|
|
14
|
-
return React.useMemo(() => {
|
|
15
|
-
const slots = {
|
|
16
|
-
headerFilterRow: ['headerFilterRow']
|
|
17
|
-
};
|
|
18
|
-
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
19
|
-
}, [classes]);
|
|
20
|
-
};
|
|
21
|
-
const filterItemsCache = Object.create(null);
|
|
22
|
-
export const useGridColumnHeaders = props => {
|
|
23
|
-
const apiRef = useGridPrivateApiContext();
|
|
24
|
-
const {
|
|
25
|
-
headerGroupingMaxDepth,
|
|
26
|
-
hasOtherElementInTabSequence
|
|
27
|
-
} = props;
|
|
28
|
-
const columnHeaderFilterTabIndexState = useGridSelector(apiRef, gridTabIndexColumnHeaderFilterSelector);
|
|
29
|
-
const _useGridColumnHeaders = useGridColumnHeadersCommunity(_extends({}, props, {
|
|
30
|
-
hasOtherElementInTabSequence: hasOtherElementInTabSequence || columnHeaderFilterTabIndexState !== null
|
|
31
|
-
})),
|
|
32
|
-
{
|
|
33
|
-
getColumnsToRender,
|
|
34
|
-
getPinnedCellOffset,
|
|
35
|
-
renderContext,
|
|
36
|
-
leftRenderContext,
|
|
37
|
-
rightRenderContext,
|
|
38
|
-
pinnedColumns,
|
|
39
|
-
visibleColumns,
|
|
40
|
-
columnPositions
|
|
41
|
-
} = _useGridColumnHeaders,
|
|
42
|
-
otherProps = _objectWithoutPropertiesLoose(_useGridColumnHeaders, _excluded);
|
|
43
|
-
const headerFiltersRef = React.useRef(null);
|
|
44
|
-
apiRef.current.register('private', {
|
|
45
|
-
headerFiltersElementRef: headerFiltersRef
|
|
46
|
-
});
|
|
47
|
-
const headerFilterMenuRef = React.useRef(null);
|
|
48
|
-
const rootProps = useGridRootProps();
|
|
49
|
-
const classes = useUtilityClasses(rootProps);
|
|
50
|
-
const disableHeaderFiltering = !rootProps.headerFilters;
|
|
51
|
-
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
52
|
-
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
53
|
-
const gridHasFiller = useGridSelector(apiRef, gridHasFillerSelector);
|
|
54
|
-
const headerFilterHeight = useGridSelector(apiRef, gridHeaderFilterHeightSelector);
|
|
55
|
-
const scrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
|
|
56
|
-
const columnHeaderFilterFocus = useGridSelector(apiRef, gridFocusColumnHeaderFilterSelector);
|
|
57
|
-
const getFilterItem = React.useCallback(colDef => {
|
|
58
|
-
const filterModelItem = filterModel?.items.find(it => it.field === colDef.field && it.operator !== 'isAnyOf');
|
|
59
|
-
if (filterModelItem != null) {
|
|
60
|
-
// there's a valid `filterModelItem` for this column
|
|
61
|
-
return filterModelItem;
|
|
62
|
-
}
|
|
63
|
-
const defaultCachedItem = filterItemsCache[colDef.field];
|
|
64
|
-
if (defaultCachedItem != null) {
|
|
65
|
-
// there's a cached `defaultItem` for this column
|
|
66
|
-
return defaultCachedItem;
|
|
67
|
-
}
|
|
68
|
-
// there's no cached `defaultItem` for this column, let's generate one and cache it
|
|
69
|
-
const defaultItem = getGridFilter(colDef);
|
|
70
|
-
filterItemsCache[colDef.field] = defaultItem;
|
|
71
|
-
return defaultItem;
|
|
72
|
-
}, [filterModel]);
|
|
73
|
-
const getColumnFilters = params => {
|
|
74
|
-
const {
|
|
75
|
-
renderedColumns,
|
|
76
|
-
firstColumnToRender
|
|
77
|
-
} = getColumnsToRender(params);
|
|
78
|
-
const filters = [];
|
|
79
|
-
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
80
|
-
const colDef = renderedColumns[i];
|
|
81
|
-
const columnIndex = firstColumnToRender + i;
|
|
82
|
-
const hasFocus = columnHeaderFilterFocus?.field === colDef.field;
|
|
83
|
-
const isFirstColumn = columnIndex === 0;
|
|
84
|
-
const tabIndexField = columnHeaderFilterTabIndexState?.field;
|
|
85
|
-
const tabIndex = tabIndexField === colDef.field || isFirstColumn && !props.hasOtherElementInTabSequence ? 0 : -1;
|
|
86
|
-
const headerClassName = typeof colDef.headerClassName === 'function' ? colDef.headerClassName({
|
|
87
|
-
field: colDef.field,
|
|
88
|
-
colDef
|
|
89
|
-
}) : colDef.headerClassName;
|
|
90
|
-
const item = getFilterItem(colDef);
|
|
91
|
-
const pinnedPosition = params?.position;
|
|
92
|
-
const pinnedOffset = getPinnedCellOffset(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth);
|
|
93
|
-
const indexInSection = i;
|
|
94
|
-
const sectionLength = renderedColumns.length;
|
|
95
|
-
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
96
|
-
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showColumnVerticalBorder, gridHasFiller);
|
|
97
|
-
filters.push(/*#__PURE__*/_jsx(rootProps.slots.headerFilterCell, _extends({
|
|
98
|
-
colIndex: columnIndex,
|
|
99
|
-
height: headerFilterHeight,
|
|
100
|
-
width: colDef.computedWidth,
|
|
101
|
-
colDef: colDef,
|
|
102
|
-
hasFocus: hasFocus,
|
|
103
|
-
tabIndex: tabIndex,
|
|
104
|
-
headerFilterMenuRef: headerFilterMenuRef,
|
|
105
|
-
headerClassName: headerClassName,
|
|
106
|
-
"data-field": colDef.field,
|
|
107
|
-
item: item,
|
|
108
|
-
pinnedPosition: pinnedPosition,
|
|
109
|
-
pinnedOffset: pinnedOffset,
|
|
110
|
-
showLeftBorder: showLeftBorder,
|
|
111
|
-
showRightBorder: showRightBorder
|
|
112
|
-
}, rootProps.slotProps?.headerFilterCell), `${colDef.field}-filter`));
|
|
113
|
-
}
|
|
114
|
-
return otherProps.getFillers(params, filters, 0, true);
|
|
115
|
-
};
|
|
116
|
-
const getColumnFiltersRow = () => {
|
|
117
|
-
if (disableHeaderFiltering) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
return /*#__PURE__*/_jsxs(GridColumnHeaderRow, {
|
|
121
|
-
ref: headerFiltersRef,
|
|
122
|
-
className: classes.headerFilterRow,
|
|
123
|
-
role: "row",
|
|
124
|
-
"aria-rowindex": headerGroupingMaxDepth + 2,
|
|
125
|
-
ownerState: rootProps,
|
|
126
|
-
children: [leftRenderContext && getColumnFilters({
|
|
127
|
-
position: PinnedColumnPosition.LEFT,
|
|
128
|
-
renderContext: leftRenderContext,
|
|
129
|
-
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
130
|
-
}), getColumnFilters({
|
|
131
|
-
renderContext,
|
|
132
|
-
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
133
|
-
}), rightRenderContext && getColumnFilters({
|
|
134
|
-
position: PinnedColumnPosition.RIGHT,
|
|
135
|
-
renderContext: rightRenderContext,
|
|
136
|
-
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
137
|
-
})]
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
return _extends({}, otherProps, {
|
|
141
|
-
getColumnFiltersRow
|
|
142
|
-
});
|
|
143
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GridPinnedColumnPosition } from '@mui/x-data-grid';
|
|
2
|
-
import { GridPinnedColumnFields } from '@mui/x-data-grid/internals';
|
|
3
|
-
/**
|
|
4
|
-
* The column pinning API interface that is available in the grid [[apiRef]].
|
|
5
|
-
*/
|
|
6
|
-
export interface GridColumnPinningApi {
|
|
7
|
-
/**
|
|
8
|
-
* Pins a column to the left or right side of the grid.
|
|
9
|
-
* @param {string} field The column field to pin.
|
|
10
|
-
* @param {GridPinnedColumnPosition} side Which side to pin the column.
|
|
11
|
-
*/
|
|
12
|
-
pinColumn: (field: string, side: GridPinnedColumnPosition) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Unpins a column.
|
|
15
|
-
* @param {string} field The column field to unpin.
|
|
16
|
-
*/
|
|
17
|
-
unpinColumn: (field: string) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Returns which columns are pinned.
|
|
20
|
-
* @returns {GridPinnedColumnFields} An object containing the pinned columns.
|
|
21
|
-
*/
|
|
22
|
-
getPinnedColumns: () => GridPinnedColumnFields;
|
|
23
|
-
/**
|
|
24
|
-
* Changes the pinned columns.
|
|
25
|
-
* @param {GridPinnedColumnFields} pinnedColumns An object containing the columns to pin.
|
|
26
|
-
*/
|
|
27
|
-
setPinnedColumns: (pinnedColumns: GridPinnedColumnFields) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Returns which side a column is pinned to.
|
|
30
|
-
* @param {string} field The column field to check.
|
|
31
|
-
* @returns {string | false} Which side the column is pinned or `false` if not pinned.
|
|
32
|
-
*/
|
|
33
|
-
isColumnPinned: (field: string) => GridPinnedColumnPosition | false;
|
|
34
|
-
}
|
|
35
|
-
export interface GridColumnPinningInternalCache {
|
|
36
|
-
/**
|
|
37
|
-
* Stores the fields in their original position, before being pinned.
|
|
38
|
-
*/
|
|
39
|
-
orderedFieldsBeforePinningColumns: string[] | null;
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridColumnPinningInterface.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./gridColumnPinningInterface.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridStateInitializer } from '@mui/x-data-grid/internals';
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
5
|
-
export declare const columnPinningStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'pinnedColumns' | 'initialState'>>;
|
|
6
|
-
export declare const useGridColumnPinning: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "disableColumnPinning" | "initialState" | "pinnedColumns" | "onPinnedColumnsChange" | "slotProps" | "slots">) => void;
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, useGridApiMethod, useGridEvent, GridPinnedColumnPosition, gridColumnFieldsSelector } from '@mui/x-data-grid';
|
|
4
|
-
import { useGridRegisterPipeProcessor, gridPinnedColumnsSelector, gridVisiblePinnedColumnDefinitionsSelector } from '@mui/x-data-grid/internals';
|
|
5
|
-
export const columnPinningStateInitializer = (state, props, apiRef) => {
|
|
6
|
-
apiRef.current.caches.columnPinning = {
|
|
7
|
-
orderedFieldsBeforePinningColumns: null
|
|
8
|
-
};
|
|
9
|
-
let model;
|
|
10
|
-
if (props.pinnedColumns) {
|
|
11
|
-
model = props.pinnedColumns;
|
|
12
|
-
} else if (props.initialState?.pinnedColumns) {
|
|
13
|
-
model = props.initialState.pinnedColumns;
|
|
14
|
-
} else {
|
|
15
|
-
model = {};
|
|
16
|
-
}
|
|
17
|
-
return _extends({}, state, {
|
|
18
|
-
pinnedColumns: model
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
export const useGridColumnPinning = (apiRef, props) => {
|
|
22
|
-
const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* PRE-PROCESSING
|
|
26
|
-
*/
|
|
27
|
-
const calculateScrollLeft = React.useCallback((initialValue, params) => {
|
|
28
|
-
const visiblePinnedColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
29
|
-
if (!params.colIndex || visiblePinnedColumns.left.length === 0 && visiblePinnedColumns.right.length === 0) {
|
|
30
|
-
return initialValue;
|
|
31
|
-
}
|
|
32
|
-
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
33
|
-
const columnsTotalWidth = gridColumnsTotalWidthSelector(apiRef);
|
|
34
|
-
const columnPositions = gridColumnPositionsSelector(apiRef);
|
|
35
|
-
const clientWidth = apiRef.current.virtualScrollerRef.current.clientWidth;
|
|
36
|
-
|
|
37
|
-
// When using RTL, `scrollLeft` becomes negative, so we must ensure that we only compare values.
|
|
38
|
-
const scrollLeft = Math.abs(apiRef.current.virtualScrollerRef.current.scrollLeft);
|
|
39
|
-
const offsetWidth = visibleColumns[params.colIndex].computedWidth;
|
|
40
|
-
const offsetLeft = columnPositions[params.colIndex];
|
|
41
|
-
const leftPinnedColumnsWidth = columnPositions[visiblePinnedColumns.left.length];
|
|
42
|
-
const rightPinnedColumnsWidth = columnsTotalWidth - columnPositions[columnPositions.length - visiblePinnedColumns.right.length];
|
|
43
|
-
const elementBottom = offsetLeft + offsetWidth;
|
|
44
|
-
if (elementBottom - (clientWidth - rightPinnedColumnsWidth) > scrollLeft) {
|
|
45
|
-
const left = elementBottom - (clientWidth - rightPinnedColumnsWidth);
|
|
46
|
-
return _extends({}, initialValue, {
|
|
47
|
-
left
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (offsetLeft < scrollLeft + leftPinnedColumnsWidth) {
|
|
51
|
-
const left = offsetLeft - leftPinnedColumnsWidth;
|
|
52
|
-
return _extends({}, initialValue, {
|
|
53
|
-
left
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return initialValue;
|
|
57
|
-
}, [apiRef]);
|
|
58
|
-
const addColumnMenuItems = React.useCallback((columnMenuItems, colDef) => {
|
|
59
|
-
if (props.disableColumnPinning) {
|
|
60
|
-
return columnMenuItems;
|
|
61
|
-
}
|
|
62
|
-
if (colDef.pinnable === false) {
|
|
63
|
-
return columnMenuItems;
|
|
64
|
-
}
|
|
65
|
-
return [...columnMenuItems, 'columnMenuPinningItem'];
|
|
66
|
-
}, [props.disableColumnPinning]);
|
|
67
|
-
const checkIfCanBeReordered = React.useCallback((initialValue, {
|
|
68
|
-
targetIndex
|
|
69
|
-
}) => {
|
|
70
|
-
const visiblePinnedColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
71
|
-
if (visiblePinnedColumns.left.length === 0 && visiblePinnedColumns.right.length === 0) {
|
|
72
|
-
return initialValue;
|
|
73
|
-
}
|
|
74
|
-
if (visiblePinnedColumns.left.length > 0 && targetIndex < visiblePinnedColumns.left.length) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (visiblePinnedColumns.right.length > 0) {
|
|
78
|
-
const visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
79
|
-
const firstRightPinnedColumnIndex = visibleColumns.length - visiblePinnedColumns.right.length;
|
|
80
|
-
return targetIndex >= firstRightPinnedColumnIndex ? false : initialValue;
|
|
81
|
-
}
|
|
82
|
-
return initialValue;
|
|
83
|
-
}, [apiRef]);
|
|
84
|
-
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
85
|
-
const pinnedColumnsToExport = gridPinnedColumnsSelector(apiRef);
|
|
86
|
-
const shouldExportPinnedColumns =
|
|
87
|
-
// Always export if the `exportOnlyDirtyModels` property is not activated
|
|
88
|
-
!context.exportOnlyDirtyModels ||
|
|
89
|
-
// Always export if the model is controlled
|
|
90
|
-
props.pinnedColumns != null ||
|
|
91
|
-
// Always export if the model has been initialized
|
|
92
|
-
props.initialState?.pinnedColumns != null ||
|
|
93
|
-
// Export if the model is not empty
|
|
94
|
-
(pinnedColumnsToExport.left ?? []).length > 0 || (pinnedColumnsToExport.right ?? []).length > 0;
|
|
95
|
-
if (!shouldExportPinnedColumns) {
|
|
96
|
-
return prevState;
|
|
97
|
-
}
|
|
98
|
-
return _extends({}, prevState, {
|
|
99
|
-
pinnedColumns: pinnedColumnsToExport
|
|
100
|
-
});
|
|
101
|
-
}, [apiRef, props.pinnedColumns, props.initialState?.pinnedColumns]);
|
|
102
|
-
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
103
|
-
const newPinnedColumns = context.stateToRestore.pinnedColumns;
|
|
104
|
-
if (newPinnedColumns != null) {
|
|
105
|
-
setState(apiRef, newPinnedColumns);
|
|
106
|
-
}
|
|
107
|
-
return params;
|
|
108
|
-
}, [apiRef]);
|
|
109
|
-
useGridRegisterPipeProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
|
|
110
|
-
useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuItems);
|
|
111
|
-
useGridRegisterPipeProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
|
|
112
|
-
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
113
|
-
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
114
|
-
apiRef.current.registerControlState({
|
|
115
|
-
stateId: 'pinnedColumns',
|
|
116
|
-
propModel: props.pinnedColumns,
|
|
117
|
-
propOnChange: props.onPinnedColumnsChange,
|
|
118
|
-
stateSelector: gridPinnedColumnsSelector,
|
|
119
|
-
changeEvent: 'pinnedColumnsChange'
|
|
120
|
-
});
|
|
121
|
-
const pinColumn = React.useCallback((field, side) => {
|
|
122
|
-
if (apiRef.current.isColumnPinned(field) === side) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const otherSide = side === GridPinnedColumnPosition.RIGHT ? GridPinnedColumnPosition.LEFT : GridPinnedColumnPosition.RIGHT;
|
|
126
|
-
const newPinnedColumns = {
|
|
127
|
-
[side]: [...(pinnedColumns[side] || []), field],
|
|
128
|
-
[otherSide]: (pinnedColumns[otherSide] || []).filter(column => column !== field)
|
|
129
|
-
};
|
|
130
|
-
apiRef.current.setPinnedColumns(newPinnedColumns);
|
|
131
|
-
}, [apiRef, pinnedColumns]);
|
|
132
|
-
const unpinColumn = React.useCallback(field => {
|
|
133
|
-
apiRef.current.setPinnedColumns({
|
|
134
|
-
left: (pinnedColumns.left || []).filter(column => column !== field),
|
|
135
|
-
right: (pinnedColumns.right || []).filter(column => column !== field)
|
|
136
|
-
});
|
|
137
|
-
}, [apiRef, pinnedColumns.left, pinnedColumns.right]);
|
|
138
|
-
const getPinnedColumns = React.useCallback(() => {
|
|
139
|
-
return gridPinnedColumnsSelector(apiRef);
|
|
140
|
-
}, [apiRef]);
|
|
141
|
-
const setPinnedColumns = React.useCallback(newPinnedColumns => {
|
|
142
|
-
setState(apiRef, newPinnedColumns);
|
|
143
|
-
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
144
|
-
}, [apiRef]);
|
|
145
|
-
const isColumnPinned = React.useCallback(field => {
|
|
146
|
-
const leftPinnedColumns = pinnedColumns.left || [];
|
|
147
|
-
if (leftPinnedColumns.includes(field)) {
|
|
148
|
-
return GridPinnedColumnPosition.LEFT;
|
|
149
|
-
}
|
|
150
|
-
const rightPinnedColumns = pinnedColumns.right || [];
|
|
151
|
-
if (rightPinnedColumns.includes(field)) {
|
|
152
|
-
return GridPinnedColumnPosition.RIGHT;
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
}, [pinnedColumns.left, pinnedColumns.right]);
|
|
156
|
-
const columnPinningApi = {
|
|
157
|
-
pinColumn,
|
|
158
|
-
unpinColumn,
|
|
159
|
-
getPinnedColumns,
|
|
160
|
-
setPinnedColumns,
|
|
161
|
-
isColumnPinned
|
|
162
|
-
};
|
|
163
|
-
useGridApiMethod(apiRef, columnPinningApi, 'public');
|
|
164
|
-
const handleColumnOrderChange = params => {
|
|
165
|
-
if (!apiRef.current.caches.columnPinning.orderedFieldsBeforePinningColumns) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const {
|
|
169
|
-
column,
|
|
170
|
-
targetIndex,
|
|
171
|
-
oldIndex
|
|
172
|
-
} = params;
|
|
173
|
-
const delta = targetIndex > oldIndex ? 1 : -1;
|
|
174
|
-
const latestColumnFields = gridColumnFieldsSelector(apiRef);
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* When a column X is reordered to somewhere else, the position where this column X is dropped
|
|
178
|
-
* on must be moved to left or right to make room for it. The ^^^ below represents the column
|
|
179
|
-
* which gave space to receive X.
|
|
180
|
-
*
|
|
181
|
-
* | X | B | C | D | -> | B | C | D | X | (for example X moved to after D, so delta=1)
|
|
182
|
-
* ^^^ ^^^
|
|
183
|
-
*
|
|
184
|
-
* | A | B | C | X | -> | X | A | B | C | (for example X moved before A, so delta=-1)
|
|
185
|
-
* ^^^ ^^^
|
|
186
|
-
*
|
|
187
|
-
* If column P is pinned, it will not move to provide space. However, it will jump to the next
|
|
188
|
-
* non-pinned column.
|
|
189
|
-
*
|
|
190
|
-
* | X | B | P | D | -> | B | D | P | X | (for example X moved to after D, with P pinned)
|
|
191
|
-
* ^^^ ^^^
|
|
192
|
-
*/
|
|
193
|
-
const siblingField = latestColumnFields[targetIndex - delta];
|
|
194
|
-
const newOrderedFieldsBeforePinningColumns = [...apiRef.current.caches.columnPinning.orderedFieldsBeforePinningColumns];
|
|
195
|
-
|
|
196
|
-
// The index to start swapping fields
|
|
197
|
-
let i = newOrderedFieldsBeforePinningColumns.findIndex(currentColumn => currentColumn === column.field);
|
|
198
|
-
// The index of the field to swap with
|
|
199
|
-
let j = i + delta;
|
|
200
|
-
|
|
201
|
-
// When to stop swapping fields.
|
|
202
|
-
// We stop one field before because the swap is done with i + 1 (if delta=1)
|
|
203
|
-
const stop = newOrderedFieldsBeforePinningColumns.findIndex(currentColumn => currentColumn === siblingField);
|
|
204
|
-
while (delta > 0 ? i < stop : i > stop) {
|
|
205
|
-
// If the field to swap with is a pinned column, jump to the next
|
|
206
|
-
while (apiRef.current.isColumnPinned(newOrderedFieldsBeforePinningColumns[j])) {
|
|
207
|
-
j += delta;
|
|
208
|
-
}
|
|
209
|
-
const temp = newOrderedFieldsBeforePinningColumns[i];
|
|
210
|
-
newOrderedFieldsBeforePinningColumns[i] = newOrderedFieldsBeforePinningColumns[j];
|
|
211
|
-
newOrderedFieldsBeforePinningColumns[j] = temp;
|
|
212
|
-
i = j;
|
|
213
|
-
j = i + delta;
|
|
214
|
-
}
|
|
215
|
-
apiRef.current.caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
|
|
216
|
-
};
|
|
217
|
-
useGridEvent(apiRef, 'columnOrderChange', handleColumnOrderChange);
|
|
218
|
-
React.useEffect(() => {
|
|
219
|
-
if (props.pinnedColumns) {
|
|
220
|
-
apiRef.current.setPinnedColumns(props.pinnedColumns);
|
|
221
|
-
}
|
|
222
|
-
}, [apiRef, props.pinnedColumns]);
|
|
223
|
-
};
|
|
224
|
-
function setState(apiRef, model) {
|
|
225
|
-
apiRef.current.setState(state => _extends({}, state, {
|
|
226
|
-
pinnedColumns: model
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
3
|
-
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
4
|
-
export declare const useGridColumnPinningPreProcessors: (apiRef: RefObject<GridPrivateApiPro>, props: DataGridProProcessedProps) => void;
|