@mui/x-data-grid 8.3.1 → 8.5.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 +213 -0
- package/DataGrid/DataGrid.js +5 -3
- package/components/GridApiContext.js +1 -3
- package/components/GridColumnHeaders.js +1 -0
- package/components/GridColumnUnsortedIcon.js +2 -1
- package/components/GridConfigurationContext.js +1 -3
- package/components/GridFooter.js +1 -0
- package/components/GridLoadingOverlay.js +1 -0
- package/components/GridNoColumnsOverlay.js +1 -0
- package/components/GridNoResultsOverlay.js +2 -1
- package/components/GridNoRowsOverlay.js +1 -0
- package/components/GridRow.js +4 -2
- package/components/GridRowCount.js +1 -0
- package/components/GridSelectedRowCount.js +1 -0
- package/components/GridShadowScrollArea.js +1 -0
- package/components/GridSkeletonLoadingOverlay.js +3 -1
- package/components/cell/GridActionsCell.js +5 -4
- package/components/cell/GridActionsCellItem.js +1 -0
- package/components/cell/GridBooleanCell.js +3 -1
- package/components/cell/GridCell.js +11 -7
- package/components/cell/GridEditBooleanCell.js +8 -5
- package/components/cell/GridEditDateCell.js +6 -4
- package/components/cell/GridEditInputCell.js +7 -4
- package/components/cell/GridEditSingleSelectCell.js +4 -3
- package/components/cell/GridSkeletonCell.js +6 -5
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -1
- package/components/columnHeaders/GridBaseColumnHeaders.js +2 -1
- package/components/columnHeaders/GridColumnGroupHeader.js +6 -5
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +5 -4
- package/components/columnHeaders/GridColumnHeaderItem.js +8 -7
- package/components/columnHeaders/GridColumnHeaderSeparator.js +5 -3
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -0
- package/components/columnHeaders/GridColumnHeaderTitle.js +1 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +4 -3
- package/components/columnHeaders/GridIconButtonContainer.js +2 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +5 -4
- package/components/columnSelection/GridHeaderCheckbox.js +1 -0
- package/components/columnsManagement/GridColumnsManagement.js +2 -2
- package/components/columnsPanel/ColumnsPanelTrigger.js +1 -0
- package/components/containers/GridFooterContainer.js +1 -0
- package/components/containers/GridOverlay.js +1 -0
- package/components/containers/GridRoot.js +7 -4
- package/components/containers/GridRootStyles.js +2 -2
- package/components/containers/GridToolbarContainer.js +1 -0
- package/components/export/ExportCsv.js +1 -0
- package/components/export/ExportPrint.js +1 -0
- package/components/filterPanel/FilterPanelTrigger.js +1 -0
- package/components/menu/GridMenu.js +6 -4
- package/components/menu/columnMenu/GridColumnMenu.js +2 -0
- package/components/menu/columnMenu/GridColumnMenuContainer.js +1 -0
- package/components/panel/GridPanel.js +3 -2
- package/components/panel/GridPanelContext.js +1 -0
- package/components/panel/GridPanelWrapper.js +2 -1
- package/components/panel/filterPanel/GridFilterForm.js +10 -7
- package/components/panel/filterPanel/GridFilterInputBoolean.js +5 -4
- package/components/panel/filterPanel/GridFilterInputDate.js +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +2 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +3 -3
- package/components/panel/filterPanel/GridFilterInputValue.js +2 -2
- package/components/panel/filterPanel/GridFilterPanel.js +1 -0
- package/components/quickFilter/QuickFilter.js +2 -2
- package/components/quickFilter/QuickFilterClear.js +1 -0
- package/components/quickFilter/QuickFilterContext.js +1 -0
- package/components/quickFilter/QuickFilterControl.js +3 -2
- package/components/quickFilter/QuickFilterTrigger.js +3 -2
- package/components/toolbar/GridToolbar.js +3 -2
- package/components/toolbar/GridToolbarColumnsButton.js +1 -0
- package/components/toolbar/GridToolbarDensitySelector.js +6 -4
- package/components/toolbar/GridToolbarExport.js +1 -0
- package/components/toolbar/GridToolbarExportContainer.js +6 -4
- package/components/toolbar/GridToolbarFilterButton.js +8 -5
- package/components/toolbarV8/Toolbar.js +59 -32
- package/components/toolbarV8/ToolbarButton.js +3 -2
- package/components/toolbarV8/ToolbarContext.js +1 -0
- package/components/toolbarV8/utils.d.ts +5 -0
- package/components/toolbarV8/utils.js +23 -0
- package/components/virtualization/GridMainContainer.js +2 -1
- package/components/virtualization/GridVirtualScrollbar.js +2 -1
- package/components/virtualization/GridVirtualScrollerContent.js +2 -1
- package/components/virtualization/GridVirtualScrollerRenderZone.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +5 -3
- package/context/GridRootPropsContext.js +1 -3
- package/esm/DataGrid/DataGrid.js +5 -3
- package/esm/components/GridApiContext.js +1 -3
- package/esm/components/GridColumnHeaders.js +1 -0
- package/esm/components/GridColumnUnsortedIcon.js +2 -1
- package/esm/components/GridConfigurationContext.js +1 -3
- package/esm/components/GridFooter.js +1 -0
- package/esm/components/GridLoadingOverlay.js +1 -0
- package/esm/components/GridNoColumnsOverlay.js +1 -0
- package/esm/components/GridNoResultsOverlay.js +2 -1
- package/esm/components/GridNoRowsOverlay.js +1 -0
- package/esm/components/GridRow.js +3 -1
- package/esm/components/GridRowCount.js +1 -0
- package/esm/components/GridSelectedRowCount.js +1 -0
- package/esm/components/GridShadowScrollArea.js +1 -0
- package/esm/components/GridSkeletonLoadingOverlay.js +3 -1
- package/esm/components/cell/GridActionsCell.js +3 -2
- package/esm/components/cell/GridActionsCellItem.js +1 -0
- package/esm/components/cell/GridBooleanCell.js +3 -1
- package/esm/components/cell/GridCell.js +5 -1
- package/esm/components/cell/GridEditBooleanCell.js +5 -2
- package/esm/components/cell/GridEditDateCell.js +4 -2
- package/esm/components/cell/GridEditInputCell.js +5 -2
- package/esm/components/cell/GridEditSingleSelectCell.js +3 -2
- package/esm/components/cell/GridSkeletonCell.js +2 -1
- package/esm/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -1
- package/esm/components/columnHeaders/GridBaseColumnHeaders.js +2 -1
- package/esm/components/columnHeaders/GridColumnGroupHeader.js +2 -1
- package/esm/components/columnHeaders/GridColumnHeaderFilterIconButton.js +2 -1
- package/esm/components/columnHeaders/GridColumnHeaderItem.js +3 -2
- package/esm/components/columnHeaders/GridColumnHeaderSeparator.js +3 -1
- package/esm/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -0
- package/esm/components/columnHeaders/GridColumnHeaderTitle.js +1 -0
- package/esm/components/columnHeaders/GridGenericColumnHeaderItem.js +2 -1
- package/esm/components/columnHeaders/GridIconButtonContainer.js +2 -1
- package/esm/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/esm/components/columnSelection/GridHeaderCheckbox.js +1 -0
- package/esm/components/columnsManagement/GridColumnsManagement.js +2 -2
- package/esm/components/columnsPanel/ColumnsPanelTrigger.js +1 -0
- package/esm/components/containers/GridFooterContainer.js +1 -0
- package/esm/components/containers/GridOverlay.js +1 -0
- package/esm/components/containers/GridRoot.js +4 -1
- package/esm/components/containers/GridRootStyles.js +2 -2
- package/esm/components/containers/GridToolbarContainer.js +1 -0
- package/esm/components/export/ExportCsv.js +1 -0
- package/esm/components/export/ExportPrint.js +1 -0
- package/esm/components/filterPanel/FilterPanelTrigger.js +1 -0
- package/esm/components/menu/GridMenu.js +3 -1
- package/esm/components/menu/columnMenu/GridColumnMenu.js +2 -0
- package/esm/components/menu/columnMenu/GridColumnMenuContainer.js +1 -0
- package/esm/components/panel/GridPanel.js +2 -1
- package/esm/components/panel/GridPanelContext.js +1 -0
- package/esm/components/panel/GridPanelWrapper.js +1 -0
- package/esm/components/panel/filterPanel/GridFilterForm.js +4 -1
- package/esm/components/panel/filterPanel/GridFilterInputBoolean.js +2 -1
- package/esm/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
- package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
- package/esm/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/esm/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/esm/components/panel/filterPanel/GridFilterPanel.js +1 -0
- package/esm/components/quickFilter/QuickFilter.js +1 -1
- package/esm/components/quickFilter/QuickFilterClear.js +1 -0
- package/esm/components/quickFilter/QuickFilterContext.js +1 -0
- package/esm/components/quickFilter/QuickFilterControl.js +2 -1
- package/esm/components/quickFilter/QuickFilterTrigger.js +2 -1
- package/esm/components/toolbar/GridToolbar.js +1 -0
- package/esm/components/toolbar/GridToolbarColumnsButton.js +1 -0
- package/esm/components/toolbar/GridToolbarDensitySelector.js +3 -1
- package/esm/components/toolbar/GridToolbarExport.js +1 -0
- package/esm/components/toolbar/GridToolbarExportContainer.js +3 -1
- package/esm/components/toolbar/GridToolbarFilterButton.js +4 -1
- package/esm/components/toolbarV8/Toolbar.js +59 -32
- package/esm/components/toolbarV8/ToolbarButton.js +2 -1
- package/esm/components/toolbarV8/ToolbarContext.js +1 -0
- package/esm/components/toolbarV8/utils.d.ts +5 -0
- package/esm/components/toolbarV8/utils.js +17 -0
- package/esm/components/virtualization/GridMainContainer.js +2 -1
- package/esm/components/virtualization/GridVirtualScrollbar.js +1 -0
- package/esm/components/virtualization/GridVirtualScrollerContent.js +1 -0
- package/esm/components/virtualization/GridVirtualScrollerRenderZone.js +1 -0
- package/esm/constants/gridClasses.d.ts +4 -0
- package/esm/constants/gridClasses.js +3 -2
- package/esm/context/GridRootPropsContext.js +1 -3
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/esm/hooks/features/columns/gridColumnsSelector.d.ts +9 -0
- package/esm/hooks/features/columns/gridColumnsSelector.js +9 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +1 -1
- package/esm/hooks/features/export/useGridPrintExport.js +1 -1
- package/esm/hooks/features/filter/useGridFilter.js +1 -1
- package/esm/hooks/features/overlays/useGridOverlays.js +1 -0
- package/esm/hooks/features/pagination/useGridPaginationModel.js +1 -1
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/esm/hooks/features/rows/useGridRowsMeta.js +5 -2
- package/esm/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/esm/hooks/features/sorting/useGridSorting.js +5 -5
- package/esm/hooks/utils/useGridPrivateApiContext.js +1 -3
- package/esm/hooks/utils/useRunOnce.js +1 -1
- package/esm/index.js +1 -1
- package/esm/locales/isIS.js +8 -8
- package/esm/material/index.js +14 -0
- package/esm/material/variables.js +5 -0
- package/esm/models/events/gridEventLookup.d.ts +9 -0
- package/esm/models/props/DataGridProps.d.ts +7 -0
- package/esm/utils/composeGridClasses.d.ts +1 -1
- package/esm/utils/composeGridClasses.js +1 -1
- package/esm/utils/css/context.js +2 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +9 -0
- package/hooks/features/columns/gridColumnsSelector.js +10 -3
- package/hooks/features/dataSource/useGridDataSourceBase.js +12 -12
- package/hooks/features/export/useGridPrintExport.js +5 -5
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/overlays/useGridOverlays.js +1 -0
- package/hooks/features/pagination/useGridPaginationModel.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +8 -5
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +6 -6
- package/hooks/utils/useGridPrivateApiContext.js +1 -3
- package/hooks/utils/useRunOnce.js +3 -2
- package/index.js +1 -1
- package/locales/isIS.js +8 -8
- package/material/index.js +14 -0
- package/material/variables.js +5 -0
- package/models/events/gridEventLookup.d.ts +9 -0
- package/models/props/DataGridProps.d.ts +7 -0
- package/package.json +2 -2
- package/utils/composeGridClasses.d.ts +1 -1
- package/utils/composeGridClasses.js +3 -2
- package/utils/css/context.js +2 -1
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["field", "id", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
7
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
8
8
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
9
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
@@ -86,6 +86,7 @@ const GridCellCheckboxForwardRef = forwardRef(function GridCellCheckboxRenderer(
|
|
|
86
86
|
ref: ref
|
|
87
87
|
}));
|
|
88
88
|
});
|
|
89
|
+
if (process.env.NODE_ENV !== "production") GridCellCheckboxForwardRef.displayName = "GridCellCheckboxForwardRef";
|
|
89
90
|
process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
90
91
|
// ----------------------------- Warning --------------------------------
|
|
91
92
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -156,6 +156,7 @@ const GridHeaderCheckbox = forwardRef(function GridHeaderCheckbox(props, ref) {
|
|
|
156
156
|
ref: ref
|
|
157
157
|
}));
|
|
158
158
|
});
|
|
159
|
+
if (process.env.NODE_ENV !== "production") GridHeaderCheckbox.displayName = "GridHeaderCheckbox";
|
|
159
160
|
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes = {
|
|
160
161
|
// ----------------------------- Warning --------------------------------
|
|
161
162
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -173,7 +173,7 @@ function GridColumnsManagement(props) {
|
|
|
173
173
|
className: classes.row,
|
|
174
174
|
disabled: column.hideable === false || pivotActive,
|
|
175
175
|
checked: columnVisibilityModel[column.field] !== false,
|
|
176
|
-
|
|
176
|
+
onChange: toggleColumn,
|
|
177
177
|
name: column.field,
|
|
178
178
|
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined,
|
|
179
179
|
label: column.headerName || column.field,
|
|
@@ -191,7 +191,7 @@ function GridColumnsManagement(props) {
|
|
|
191
191
|
disabled: hideableColumns.length === 0 || pivotActive,
|
|
192
192
|
checked: allHideableColumnsVisible,
|
|
193
193
|
indeterminate: !allHideableColumnsVisible && !allHideableColumnsHidden,
|
|
194
|
-
|
|
194
|
+
onChange: () => toggleAllColumns(!allHideableColumnsVisible),
|
|
195
195
|
name: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
|
|
196
196
|
label: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
|
|
197
197
|
density: "compact"
|
|
@@ -75,6 +75,7 @@ const ColumnsPanelTrigger = forwardRef(function ColumnsPanelTrigger(props, ref)
|
|
|
75
75
|
children: element
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
+
if (process.env.NODE_ENV !== "production") ColumnsPanelTrigger.displayName = "ColumnsPanelTrigger";
|
|
78
79
|
process.env.NODE_ENV !== "production" ? ColumnsPanelTrigger.propTypes = {
|
|
79
80
|
// ----------------------------- Warning --------------------------------
|
|
80
81
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -43,6 +43,7 @@ const GridFooterContainer = forwardRef(function GridFooterContainer(props, ref)
|
|
|
43
43
|
ref: ref
|
|
44
44
|
}));
|
|
45
45
|
});
|
|
46
|
+
if (process.env.NODE_ENV !== "production") GridFooterContainer.displayName = "GridFooterContainer";
|
|
46
47
|
process.env.NODE_ENV !== "production" ? GridFooterContainer.propTypes = {
|
|
47
48
|
// ----------------------------- Warning --------------------------------
|
|
48
49
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -50,6 +50,7 @@ const GridOverlay = forwardRef(function GridOverlay(props, ref) {
|
|
|
50
50
|
ref: ref
|
|
51
51
|
}));
|
|
52
52
|
});
|
|
53
|
+
if (process.env.NODE_ENV !== "production") GridOverlay.displayName = "GridOverlay";
|
|
53
54
|
process.env.NODE_ENV !== "production" ? GridOverlay.propTypes = {
|
|
54
55
|
// ----------------------------- Warning --------------------------------
|
|
55
56
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -4,7 +4,9 @@ const _excluded = ["className", "children", "sidePanel"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import
|
|
7
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
+
import capitalize from '@mui/utils/capitalize';
|
|
9
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
10
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
9
11
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
10
12
|
import { GridRootStyles } from "./GridRootStyles.js";
|
|
@@ -68,6 +70,7 @@ const GridRoot = forwardRef(function GridRoot(props, ref) {
|
|
|
68
70
|
}), sidePanel, cssVariables.tag]
|
|
69
71
|
}));
|
|
70
72
|
});
|
|
73
|
+
if (process.env.NODE_ENV !== "production") GridRoot.displayName = "GridRoot";
|
|
71
74
|
process.env.NODE_ENV !== "production" ? GridRoot.propTypes = {
|
|
72
75
|
// ----------------------------- Warning --------------------------------
|
|
73
76
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -657,7 +657,7 @@ export const GridRootStyles = styled('div', {
|
|
|
657
657
|
borderTop: 'none'
|
|
658
658
|
}
|
|
659
659
|
},
|
|
660
|
-
[`&.${c['root--disableUserSelection']}
|
|
660
|
+
[`&.${c['root--disableUserSelection']}`]: {
|
|
661
661
|
userSelect: 'none'
|
|
662
662
|
},
|
|
663
663
|
[`& .${c['row--dynamicHeight']} > .${c.cell}`]: {
|
|
@@ -715,7 +715,7 @@ export const GridRootStyles = styled('div', {
|
|
|
715
715
|
opacity: vars.colors.interactive.disabledOpacity
|
|
716
716
|
},
|
|
717
717
|
[`& .${c['rowReorderCell--draggable']}`]: {
|
|
718
|
-
cursor: '
|
|
718
|
+
cursor: 'grab',
|
|
719
719
|
opacity: 1
|
|
720
720
|
},
|
|
721
721
|
[`& .${c.rowReorderCellContainer}`]: {
|
|
@@ -56,6 +56,7 @@ const GridToolbarContainer = forwardRef(function GridToolbarContainer(props, ref
|
|
|
56
56
|
children: children
|
|
57
57
|
}));
|
|
58
58
|
});
|
|
59
|
+
if (process.env.NODE_ENV !== "production") GridToolbarContainer.displayName = "GridToolbarContainer";
|
|
59
60
|
process.env.NODE_ENV !== "production" ? GridToolbarContainer.propTypes = {
|
|
60
61
|
// ----------------------------- Warning --------------------------------
|
|
61
62
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -42,6 +42,7 @@ const ExportCsv = forwardRef(function ExportCsv(props, ref) {
|
|
|
42
42
|
children: element
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
|
+
if (process.env.NODE_ENV !== "production") ExportCsv.displayName = "ExportCsv";
|
|
45
46
|
process.env.NODE_ENV !== "production" ? ExportCsv.propTypes = {
|
|
46
47
|
// ----------------------------- Warning --------------------------------
|
|
47
48
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -42,6 +42,7 @@ const ExportPrint = forwardRef(function ExportPrint(props, ref) {
|
|
|
42
42
|
children: element
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
|
+
if (process.env.NODE_ENV !== "production") ExportPrint.displayName = "ExportPrint";
|
|
45
46
|
process.env.NODE_ENV !== "production" ? ExportPrint.propTypes = {
|
|
46
47
|
// ----------------------------- Warning --------------------------------
|
|
47
48
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -78,6 +78,7 @@ const FilterPanelTrigger = forwardRef(function FilterPanelTrigger(props, ref) {
|
|
|
78
78
|
children: element
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
+
if (process.env.NODE_ENV !== "production") FilterPanelTrigger.displayName = "FilterPanelTrigger";
|
|
81
82
|
process.env.NODE_ENV !== "production" ? FilterPanelTrigger.propTypes = {
|
|
82
83
|
// ----------------------------- Warning --------------------------------
|
|
83
84
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -4,7 +4,9 @@ const _excluded = ["open", "target", "onClose", "children", "position", "classNa
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
9
|
+
import HTMLElementType from '@mui/utils/HTMLElementType';
|
|
8
10
|
import { styled } from '@mui/material/styles';
|
|
9
11
|
import { vars } from "../../constants/cssVariables.js";
|
|
10
12
|
import { useCSSVariablesClass } from "../../utils/css/context.js";
|
|
@@ -45,6 +45,7 @@ const GridGenericColumnMenu = forwardRef(function GridGenericColumnMenu(props, r
|
|
|
45
45
|
children: orderedSlots.map(([Component, otherProps], index) => /*#__PURE__*/_jsx(Component, _extends({}, otherProps), index))
|
|
46
46
|
}));
|
|
47
47
|
});
|
|
48
|
+
if (process.env.NODE_ENV !== "production") GridGenericColumnMenu.displayName = "GridGenericColumnMenu";
|
|
48
49
|
process.env.NODE_ENV !== "production" ? GridGenericColumnMenu.propTypes = {
|
|
49
50
|
// ----------------------------- Warning --------------------------------
|
|
50
51
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -84,6 +85,7 @@ const GridColumnMenu = forwardRef(function GridColumnMenu(props, ref) {
|
|
|
84
85
|
defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS
|
|
85
86
|
}));
|
|
86
87
|
});
|
|
88
|
+
if (process.env.NODE_ENV !== "production") GridColumnMenu.displayName = "GridColumnMenu";
|
|
87
89
|
process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
|
|
88
90
|
// ----------------------------- Warning --------------------------------
|
|
89
91
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -45,6 +45,7 @@ const GridColumnMenuContainer = forwardRef(function GridColumnMenuContainer(prop
|
|
|
45
45
|
children: children
|
|
46
46
|
}));
|
|
47
47
|
});
|
|
48
|
+
if (process.env.NODE_ENV !== "production") GridColumnMenuContainer.displayName = "GridColumnMenuContainer";
|
|
48
49
|
process.env.NODE_ENV !== "production" ? GridColumnMenuContainer.propTypes = {
|
|
49
50
|
// ----------------------------- Warning --------------------------------
|
|
50
51
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
|
-
import
|
|
8
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
9
9
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
10
10
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
11
11
|
import { vars } from "../../constants/cssVariables.js";
|
|
@@ -87,6 +87,7 @@ const GridPanel = forwardRef((props, ref) => {
|
|
|
87
87
|
})
|
|
88
88
|
}));
|
|
89
89
|
});
|
|
90
|
+
if (process.env.NODE_ENV !== "production") GridPanel.displayName = "GridPanel";
|
|
90
91
|
process.env.NODE_ENV !== "production" ? GridPanel.propTypes = {
|
|
91
92
|
// ----------------------------- Warning --------------------------------
|
|
92
93
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export const GridPanelContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
|
+
if (process.env.NODE_ENV !== "production") GridPanelContext.displayName = "GridPanelContext";
|
|
4
5
|
export function useGridPanelContext() {
|
|
5
6
|
const context = React.useContext(GridPanelContext);
|
|
6
7
|
if (context === undefined) {
|
|
@@ -5,7 +5,9 @@ const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterCha
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
|
-
import
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import useId from '@mui/utils/useId';
|
|
10
|
+
import capitalize from '@mui/utils/capitalize';
|
|
9
11
|
import { styled } from '@mui/material/styles';
|
|
10
12
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
11
13
|
import { vars } from "../../../constants/cssVariables.js";
|
|
@@ -359,6 +361,7 @@ const GridFilterForm = forwardRef(function GridFilterForm(props, ref) {
|
|
|
359
361
|
}))]
|
|
360
362
|
}));
|
|
361
363
|
});
|
|
364
|
+
if (process.env.NODE_ENV !== "production") GridFilterForm.displayName = "GridFilterForm";
|
|
362
365
|
process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
363
366
|
// ----------------------------- Warning --------------------------------
|
|
364
367
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -3,7 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import refType from '@mui/utils/refType';
|
|
7
|
+
import useId from '@mui/utils/useId';
|
|
7
8
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
function GridFilterInputBoolean(props) {
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "slotProps", "isFilterActive", "headerFilterMenu", "clearButton", "tabIndex", "disabled"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import useId from '@mui/utils/useId';
|
|
7
7
|
import { useTimeout } from "../../../hooks/utils/useTimeout.js";
|
|
8
8
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import useId from '@mui/utils/useId';
|
|
7
7
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
8
8
|
import { getValueOptions, isSingleSelectColDef } from "./filterPanelUtils.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import useId from '@mui/utils/useId';
|
|
5
5
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
function GridFilterInputMultipleValue(props) {
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "isFilterActive", "clearButton", "headerFilterMenu", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import useId from '@mui/utils/useId';
|
|
7
7
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
8
8
|
import { getValueFromValueOptions, getValueOptions, isSingleSelectColDef } from "./filterPanelUtils.js";
|
|
9
9
|
import { createElement as _createElement } from "react";
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "slotProps", "clearButton", "headerFilterMenu"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import useId from '@mui/utils/useId';
|
|
7
7
|
import { useTimeout } from "../../../hooks/utils/useTimeout.js";
|
|
8
8
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -184,6 +184,7 @@ const GridFilterPanel = forwardRef(function GridFilterPanel(props, ref) {
|
|
|
184
184
|
}) : null]
|
|
185
185
|
}));
|
|
186
186
|
});
|
|
187
|
+
if (process.env.NODE_ENV !== "production") GridFilterPanel.displayName = "GridFilterPanel";
|
|
187
188
|
process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
188
189
|
// ----------------------------- Warning --------------------------------
|
|
189
190
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["render", "className", "parser", "formatter", "debounceMs", "defaultExpanded", "expanded", "onExpandedChange"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import debounce from '@mui/utils/debounce';
|
|
7
7
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
8
|
import useId from '@mui/utils/useId';
|
|
9
9
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
@@ -48,6 +48,7 @@ const QuickFilterClear = forwardRef(function QuickFilterClear(props, ref) {
|
|
|
48
48
|
children: element
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
+
if (process.env.NODE_ENV !== "production") QuickFilterClear.displayName = "QuickFilterClear";
|
|
51
52
|
process.env.NODE_ENV !== "production" ? QuickFilterClear.propTypes = {
|
|
52
53
|
// ----------------------------- Warning --------------------------------
|
|
53
54
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export const QuickFilterContext = /*#__PURE__*/React.createContext(undefined);
|
|
3
|
+
if (process.env.NODE_ENV !== "production") QuickFilterContext.displayName = "QuickFilterContext";
|
|
3
4
|
export function useQuickFilterContext() {
|
|
4
5
|
const context = React.useContext(QuickFilterContext);
|
|
5
6
|
if (context === undefined) {
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["render", "className", "slotProps", "onKeyDown", "onChange"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
6
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
7
7
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
8
8
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
@@ -85,6 +85,7 @@ const QuickFilterControl = forwardRef(function QuickFilterControl(props, ref) {
|
|
|
85
85
|
children: element
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
+
if (process.env.NODE_ENV !== "production") QuickFilterControl.displayName = "QuickFilterControl";
|
|
88
89
|
process.env.NODE_ENV !== "production" ? QuickFilterControl.propTypes = {
|
|
89
90
|
// ----------------------------- Warning --------------------------------
|
|
90
91
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -4,7 +4,7 @@ const _excluded = ["render", "className", "onClick"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
7
|
-
import
|
|
7
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
8
8
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
10
10
|
import { useQuickFilterContext } from "./QuickFilterContext.js";
|
|
@@ -53,6 +53,7 @@ const QuickFilterTrigger = forwardRef(function QuickFilterTrigger(props, ref) {
|
|
|
53
53
|
children: element
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
+
if (process.env.NODE_ENV !== "production") QuickFilterTrigger.displayName = "QuickFilterTrigger";
|
|
56
57
|
process.env.NODE_ENV !== "production" ? QuickFilterTrigger.propTypes = {
|
|
57
58
|
// ----------------------------- Warning --------------------------------
|
|
58
59
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -49,6 +49,7 @@ const GridToolbar = forwardRef(function GridToolbar(props, ref) {
|
|
|
49
49
|
}), showQuickFilter && /*#__PURE__*/_jsx(GridToolbarQuickFilter, _extends({}, quickFilterProps))]
|
|
50
50
|
}));
|
|
51
51
|
});
|
|
52
|
+
if (process.env.NODE_ENV !== "production") GridToolbar.displayName = "GridToolbar";
|
|
52
53
|
process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
53
54
|
// ----------------------------- Warning --------------------------------
|
|
54
55
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -68,6 +68,7 @@ const GridToolbarColumnsButton = forwardRef(function GridToolbarColumnsButton(pr
|
|
|
68
68
|
}))
|
|
69
69
|
}));
|
|
70
70
|
});
|
|
71
|
+
if (process.env.NODE_ENV !== "production") GridToolbarColumnsButton.displayName = "GridToolbarColumnsButton";
|
|
71
72
|
process.env.NODE_ENV !== "production" ? GridToolbarColumnsButton.propTypes = {
|
|
72
73
|
// ----------------------------- Warning --------------------------------
|
|
73
74
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import useId from '@mui/utils/useId';
|
|
5
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
5
6
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
6
7
|
import { gridDensitySelector } from "../../hooks/features/density/densitySelector.js";
|
|
7
8
|
import { isHideMenuKey } from "../../utils/keyboardUtils.js";
|
|
@@ -115,6 +116,7 @@ const GridToolbarDensitySelector = forwardRef(function GridToolbarDensitySelecto
|
|
|
115
116
|
})]
|
|
116
117
|
});
|
|
117
118
|
});
|
|
119
|
+
if (process.env.NODE_ENV !== "production") GridToolbarDensitySelector.displayName = "GridToolbarDensitySelector";
|
|
118
120
|
process.env.NODE_ENV !== "production" ? GridToolbarDensitySelector.propTypes = {
|
|
119
121
|
// ----------------------------- Warning --------------------------------
|
|
120
122
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -112,6 +112,7 @@ const GridToolbarExport = forwardRef(function GridToolbarExport(props, ref) {
|
|
|
112
112
|
}))
|
|
113
113
|
}));
|
|
114
114
|
});
|
|
115
|
+
if (process.env.NODE_ENV !== "production") GridToolbarExport.displayName = "GridToolbarExport";
|
|
115
116
|
process.env.NODE_ENV !== "production" ? GridToolbarExport.propTypes = {
|
|
116
117
|
// ----------------------------- Warning --------------------------------
|
|
117
118
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import useId from '@mui/utils/useId';
|
|
5
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
5
6
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
6
7
|
import { isHideMenuKey } from "../../utils/keyboardUtils.js";
|
|
7
8
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
@@ -80,6 +81,7 @@ const GridToolbarExportContainer = forwardRef(function GridToolbarExportContaine
|
|
|
80
81
|
})]
|
|
81
82
|
});
|
|
82
83
|
});
|
|
84
|
+
if (process.env.NODE_ENV !== "production") GridToolbarExportContainer.displayName = "GridToolbarExportContainer";
|
|
83
85
|
process.env.NODE_ENV !== "production" ? GridToolbarExportContainer.propTypes = {
|
|
84
86
|
// ----------------------------- Warning --------------------------------
|
|
85
87
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -2,7 +2,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import
|
|
5
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
6
|
+
import capitalize from '@mui/utils/capitalize';
|
|
7
|
+
import useId from '@mui/utils/useId';
|
|
6
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
7
9
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
8
10
|
import { vars } from "../../constants/cssVariables.js";
|
|
@@ -130,6 +132,7 @@ const GridToolbarFilterButton = forwardRef(function GridToolbarFilterButton(prop
|
|
|
130
132
|
}))
|
|
131
133
|
}));
|
|
132
134
|
});
|
|
135
|
+
if (process.env.NODE_ENV !== "production") GridToolbarFilterButton.displayName = "GridToolbarFilterButton";
|
|
133
136
|
process.env.NODE_ENV !== "production" ? GridToolbarFilterButton.propTypes = {
|
|
134
137
|
// ----------------------------- Warning --------------------------------
|
|
135
138
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -12,6 +12,7 @@ import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
|
12
12
|
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
|
|
13
13
|
import { ToolbarContext } from "./ToolbarContext.js";
|
|
14
14
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
15
|
+
import { sortByDocumentPosition } from "./utils.js";
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
const useUtilityClasses = ownerState => {
|
|
17
18
|
const {
|
|
@@ -59,21 +60,11 @@ const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
|
59
60
|
const classes = useUtilityClasses(rootProps);
|
|
60
61
|
const [focusableItemId, setFocusableItemId] = React.useState(null);
|
|
61
62
|
const [items, setItems] = React.useState([]);
|
|
62
|
-
const
|
|
63
|
-
setItems(prevItems => [...prevItems, {
|
|
64
|
-
id,
|
|
65
|
-
ref: itemRef
|
|
66
|
-
}]);
|
|
67
|
-
}, []);
|
|
68
|
-
const unregisterItem = React.useCallback(id => {
|
|
69
|
-
setItems(prevItems => prevItems.filter(i => i.id !== id));
|
|
70
|
-
if (focusableItemId === id) {
|
|
71
|
-
setFocusableItemId(null);
|
|
72
|
-
}
|
|
73
|
-
}, [focusableItemId]);
|
|
63
|
+
const getSortedItems = React.useCallback(() => items.sort(sortByDocumentPosition), [items]);
|
|
74
64
|
const findEnabledItem = React.useCallback((startIndex, step, wrap = true) => {
|
|
75
65
|
let index = startIndex;
|
|
76
|
-
const
|
|
66
|
+
const sortedItems = getSortedItems();
|
|
67
|
+
const itemCount = sortedItems.length;
|
|
77
68
|
|
|
78
69
|
// Look for enabled items in the specified direction
|
|
79
70
|
for (let i = 0; i < itemCount; i += 1) {
|
|
@@ -93,53 +84,93 @@ const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
|
93
84
|
}
|
|
94
85
|
|
|
95
86
|
// Return if we found an enabled item
|
|
96
|
-
if (!
|
|
87
|
+
if (!sortedItems[index].ref.current?.disabled && sortedItems[index].ref.current?.ariaDisabled !== 'true') {
|
|
97
88
|
return index;
|
|
98
89
|
}
|
|
99
90
|
}
|
|
100
91
|
|
|
101
92
|
// If we've checked all items and found none enabled
|
|
102
93
|
return -1;
|
|
103
|
-
}, [
|
|
94
|
+
}, [getSortedItems]);
|
|
95
|
+
const registerItem = React.useCallback((id, itemRef) => {
|
|
96
|
+
setItems(prevItems => [...prevItems, {
|
|
97
|
+
id,
|
|
98
|
+
ref: itemRef
|
|
99
|
+
}]);
|
|
100
|
+
}, []);
|
|
101
|
+
const unregisterItem = React.useCallback(id => {
|
|
102
|
+
setItems(prevItems => prevItems.filter(i => i.id !== id));
|
|
103
|
+
}, []);
|
|
104
104
|
const onItemKeyDown = React.useCallback(event => {
|
|
105
105
|
if (!focusableItemId) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const sortedItems = getSortedItems();
|
|
109
|
+
const focusableItemIndex = sortedItems.findIndex(item => item.id === focusableItemId);
|
|
109
110
|
let newIndex = -1;
|
|
110
111
|
if (event.key === 'ArrowRight') {
|
|
111
112
|
event.preventDefault();
|
|
112
|
-
newIndex = findEnabledItem(
|
|
113
|
+
newIndex = findEnabledItem(focusableItemIndex, 1);
|
|
113
114
|
} else if (event.key === 'ArrowLeft') {
|
|
114
115
|
event.preventDefault();
|
|
115
|
-
newIndex = findEnabledItem(
|
|
116
|
+
newIndex = findEnabledItem(focusableItemIndex, -1);
|
|
116
117
|
} else if (event.key === 'Home') {
|
|
117
118
|
event.preventDefault();
|
|
118
119
|
newIndex = findEnabledItem(-1, 1, false);
|
|
119
120
|
} else if (event.key === 'End') {
|
|
120
121
|
event.preventDefault();
|
|
121
|
-
newIndex = findEnabledItem(
|
|
122
|
+
newIndex = findEnabledItem(sortedItems.length, -1, false);
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
|
|
125
|
+
// TODO: Check why this is necessary
|
|
126
|
+
if (newIndex >= 0 && newIndex < sortedItems.length) {
|
|
127
|
+
const item = sortedItems[newIndex];
|
|
125
128
|
setFocusableItemId(item.id);
|
|
126
129
|
item.ref.current?.focus();
|
|
127
130
|
}
|
|
128
|
-
}, [
|
|
131
|
+
}, [getSortedItems, focusableItemId, findEnabledItem]);
|
|
129
132
|
const onItemFocus = React.useCallback(id => {
|
|
130
133
|
if (focusableItemId !== id) {
|
|
131
134
|
setFocusableItemId(id);
|
|
132
135
|
}
|
|
133
|
-
}, [focusableItemId]);
|
|
136
|
+
}, [focusableItemId, setFocusableItemId]);
|
|
134
137
|
const onItemDisabled = React.useCallback(id => {
|
|
135
|
-
const
|
|
138
|
+
const sortedItems = getSortedItems();
|
|
139
|
+
const currentIndex = sortedItems.findIndex(item => item.id === id);
|
|
136
140
|
const newIndex = findEnabledItem(currentIndex, 1);
|
|
137
|
-
if (newIndex >= 0 && newIndex <
|
|
138
|
-
const item =
|
|
141
|
+
if (newIndex >= 0 && newIndex < sortedItems.length) {
|
|
142
|
+
const item = sortedItems[newIndex];
|
|
139
143
|
setFocusableItemId(item.id);
|
|
140
144
|
item.ref.current?.focus();
|
|
141
145
|
}
|
|
142
|
-
}, [
|
|
146
|
+
}, [getSortedItems, findEnabledItem]);
|
|
147
|
+
React.useEffect(() => {
|
|
148
|
+
const sortedItems = getSortedItems();
|
|
149
|
+
if (sortedItems.length > 0) {
|
|
150
|
+
// Set initial focusable item
|
|
151
|
+
if (!focusableItemId) {
|
|
152
|
+
setFocusableItemId(sortedItems[0].id);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const focusableItemIndex = sortedItems.findIndex(item => item.id === focusableItemId);
|
|
156
|
+
if (!sortedItems[focusableItemIndex]) {
|
|
157
|
+
// Last item has been removed from the items array
|
|
158
|
+
const item = sortedItems[sortedItems.length - 1];
|
|
159
|
+
if (item) {
|
|
160
|
+
setFocusableItemId(item.id);
|
|
161
|
+
item.ref.current?.focus();
|
|
162
|
+
}
|
|
163
|
+
} else if (focusableItemIndex === -1) {
|
|
164
|
+
// Focused item has been removed from the items array
|
|
165
|
+
const item = sortedItems[focusableItemIndex];
|
|
166
|
+
if (item) {
|
|
167
|
+
setFocusableItemId(item.id);
|
|
168
|
+
item.ref.current?.focus();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
173
|
+
}, [getSortedItems, findEnabledItem]);
|
|
143
174
|
const contextValue = React.useMemo(() => ({
|
|
144
175
|
focusableItemId,
|
|
145
176
|
registerItem,
|
|
@@ -156,16 +187,12 @@ const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
|
156
187
|
}, other, {
|
|
157
188
|
ref
|
|
158
189
|
}));
|
|
159
|
-
React.useEffect(() => {
|
|
160
|
-
if (items.length > 0) {
|
|
161
|
-
setFocusableItemId(items[0].id);
|
|
162
|
-
}
|
|
163
|
-
}, [items]);
|
|
164
190
|
return /*#__PURE__*/_jsx(ToolbarContext.Provider, {
|
|
165
191
|
value: contextValue,
|
|
166
192
|
children: element
|
|
167
193
|
});
|
|
168
194
|
});
|
|
195
|
+
if (process.env.NODE_ENV !== "production") Toolbar.displayName = "Toolbar";
|
|
169
196
|
process.env.NODE_ENV !== "production" ? Toolbar.propTypes = {
|
|
170
197
|
// ----------------------------- Warning --------------------------------
|
|
171
198
|
// | These PropTypes are generated from the TypeScript type definitions |
|