@mui/x-data-grid 6.0.3 → 6.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 +119 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +4 -2
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/components/menu/columnMenu/GridColumnMenu.d.ts +5 -5
- package/components/menu/columnMenu/GridColumnMenu.js +30 -30
- package/components/menu/columnMenu/GridColumnMenuProps.d.ts +1 -1
- package/components/panel/GridColumnsPanel.d.ts +8 -0
- package/components/panel/GridColumnsPanel.js +18 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/reexportable.d.ts +1 -1
- package/components/reexportable.js +1 -1
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/features/columnMenu/columnMenuInterfaces.d.ts +11 -11
- package/hooks/features/columnMenu/{useGridColumnMenuComponents.d.ts → useGridColumnMenuSlots.d.ts} +4 -4
- package/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/columns/useGridColumns.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +5 -1
- package/hooks/features/editing/useGridEditing.js +1 -3
- package/hooks/features/editing/useGridRowEditing.js +5 -1
- package/hooks/features/filter/gridFilterState.js +6 -1
- package/hooks/features/filter/useGridFilter.js +6 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +10 -2
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +5 -2
- package/legacy/components/cell/GridEditBooleanCell.js +19 -21
- package/legacy/components/cell/GridEditDateCell.js +69 -39
- package/legacy/components/cell/GridEditInputCell.js +25 -27
- package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
- package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/legacy/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/legacy/components/menu/columnMenu/GridColumnMenu.js +32 -32
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/reexportable.js +1 -1
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +25 -30
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/columns/useGridColumns.js +1 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
- package/legacy/hooks/features/editing/useGridEditing.js +17 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
- package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
- package/legacy/hooks/features/filter/gridFilterState.js +6 -1
- package/legacy/hooks/features/filter/useGridFilter.js +6 -1
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +7 -7
- package/legacy/index.js +10 -2
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/daDK.js +16 -21
- package/legacy/locales/esES.js +1 -1
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nbNO.js +10 -12
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/svSE.js +2 -2
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/locales/coreLocales.js +0 -1
- package/locales/daDK.js +16 -21
- package/locales/esES.js +1 -1
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nbNO.js +10 -12
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/svSE.js +2 -2
- package/models/api/gridCoreApi.d.ts +3 -1
- package/models/api/gridEditingApi.d.ts +4 -0
- package/models/gridColumnGrouping.js +4 -0
- package/models/params/gridRowParams.js +8 -0
- package/modern/components/GridAutoSizer.js +3 -0
- package/modern/components/GridRow.js +4 -2
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/modern/components/menu/columnMenu/GridColumnMenu.js +30 -30
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/reexportable.js +1 -1
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
- package/modern/hooks/features/columns/useGridColumns.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
- package/modern/hooks/features/editing/useGridEditing.js +1 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
- package/modern/hooks/features/filter/gridFilterState.js +6 -1
- package/modern/hooks/features/filter/useGridFilter.js +6 -1
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/modern/index.js +10 -2
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/daDK.js +16 -21
- package/modern/locales/esES.js +1 -1
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nbNO.js +10 -12
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/svSE.js +2 -2
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +4 -2
- package/node/components/cell/GridCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +37 -16
- package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/node/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/node/components/menu/columnMenu/GridColumnMenu.js +33 -33
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/node/components/reexportable.js +4 -4
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +22 -27
- package/node/hooks/features/columns/useGridColumns.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +5 -1
- package/node/hooks/features/editing/useGridEditing.js +1 -3
- package/node/hooks/features/editing/useGridRowEditing.js +5 -1
- package/node/hooks/features/filter/gridFilterState.js +5 -0
- package/node/hooks/features/filter/useGridFilter.js +6 -1
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/node/index.js +7 -7
- package/node/locales/daDK.js +16 -21
- package/node/locales/esES.js +1 -1
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nbNO.js +10 -12
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/svSE.js +2 -2
- package/node/models/gridColumnGrouping.js +4 -0
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/models/params/gridRowParams.js +9 -0
- package/node/utils/createSelector.js +12 -22
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
package/locales/nbNO.js
CHANGED
|
@@ -37,7 +37,7 @@ const nbNOGrid = {
|
|
|
37
37
|
columnsPanelHideAllButton: 'Skjul alle',
|
|
38
38
|
// Filter panel text
|
|
39
39
|
filterPanelAddFilter: 'Legg til filter',
|
|
40
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Fjern alle',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Slett',
|
|
42
42
|
filterPanelLogicOperator: 'Logisk operator',
|
|
43
43
|
filterPanelOperator: 'Operatører',
|
|
@@ -67,7 +67,7 @@ const nbNOGrid = {
|
|
|
67
67
|
// Column menu text
|
|
68
68
|
columnMenuLabel: 'Meny',
|
|
69
69
|
columnMenuShowColumns: 'Vis kolonner',
|
|
70
|
-
|
|
70
|
+
columnMenuManageColumns: 'Administrer kolonner',
|
|
71
71
|
columnMenuFilter: 'Filter',
|
|
72
72
|
columnMenuHideColumn: 'Skjul',
|
|
73
73
|
columnMenuUnsort: 'Usorter',
|
|
@@ -107,19 +107,17 @@ const nbNOGrid = {
|
|
|
107
107
|
groupColumn: name => `Grupper på ${name}`,
|
|
108
108
|
unGroupColumn: name => `Stopp å grupper på ${name}`,
|
|
109
109
|
// Master/detail
|
|
110
|
-
|
|
110
|
+
detailPanelToggle: 'Utvid/kollaps detalj panel',
|
|
111
111
|
expandDetailPanel: 'Utvid',
|
|
112
112
|
collapseDetailPanel: 'Kollaps',
|
|
113
113
|
// Row reordering text
|
|
114
|
-
rowReorderingHeaderName: 'Rad reorganisering'
|
|
115
|
-
|
|
114
|
+
rowReorderingHeaderName: 'Rad reorganisering',
|
|
116
115
|
// Aggregation
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
aggregationMenuItemHeader: 'Aggregering',
|
|
117
|
+
aggregationFunctionLabelSum: 'sum',
|
|
118
|
+
aggregationFunctionLabelAvg: 'snitt',
|
|
119
|
+
aggregationFunctionLabelMin: 'min',
|
|
120
|
+
aggregationFunctionLabelMax: 'maks',
|
|
121
|
+
aggregationFunctionLabelSize: 'størrelse'
|
|
123
122
|
};
|
|
124
|
-
|
|
125
123
|
export const nbNO = getGridLocalization(nbNOGrid, nbNOCore);
|
package/locales/nlNL.js
CHANGED
|
@@ -37,7 +37,7 @@ const nlNLGrid = {
|
|
|
37
37
|
columnsPanelHideAllButton: 'Alles verbergen',
|
|
38
38
|
// Filter panel text
|
|
39
39
|
filterPanelAddFilter: 'Filter toevoegen',
|
|
40
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Alles verwijderen',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Verwijderen',
|
|
42
42
|
filterPanelLogicOperator: 'Logische operator',
|
|
43
43
|
filterPanelOperator: 'Operatoren',
|
|
@@ -67,7 +67,7 @@ const nlNLGrid = {
|
|
|
67
67
|
// Column menu text
|
|
68
68
|
columnMenuLabel: 'Menu',
|
|
69
69
|
columnMenuShowColumns: 'Toon kolommen',
|
|
70
|
-
|
|
70
|
+
columnMenuManageColumns: 'Kolommen beheren',
|
|
71
71
|
columnMenuFilter: 'Filteren',
|
|
72
72
|
columnMenuHideColumn: 'Verbergen',
|
|
73
73
|
columnMenuUnsort: 'Annuleer sortering',
|
|
@@ -107,7 +107,7 @@ const nlNLGrid = {
|
|
|
107
107
|
groupColumn: name => `Groepeer op ${name}`,
|
|
108
108
|
unGroupColumn: name => `Stop groeperen op ${name}`,
|
|
109
109
|
// Master/detail
|
|
110
|
-
|
|
110
|
+
detailPanelToggle: 'Detailmenu in- of uitklappen',
|
|
111
111
|
expandDetailPanel: 'Uitklappen',
|
|
112
112
|
collapseDetailPanel: 'Inklappen',
|
|
113
113
|
// Row reordering text
|
package/locales/ptBR.js
CHANGED
|
@@ -111,15 +111,13 @@ const ptBRGrid = {
|
|
|
111
111
|
expandDetailPanel: 'Expandir',
|
|
112
112
|
collapseDetailPanel: 'Esconder',
|
|
113
113
|
// Row reordering text
|
|
114
|
-
rowReorderingHeaderName: 'Reorganizar linhas'
|
|
115
|
-
|
|
114
|
+
rowReorderingHeaderName: 'Reorganizar linhas',
|
|
116
115
|
// Aggregation
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
aggregationMenuItemHeader: 'Agrupar',
|
|
117
|
+
aggregationFunctionLabelSum: 'soma',
|
|
118
|
+
aggregationFunctionLabelAvg: 'média',
|
|
119
|
+
aggregationFunctionLabelMin: 'mín',
|
|
120
|
+
aggregationFunctionLabelMax: 'máx',
|
|
121
|
+
aggregationFunctionLabelSize: 'tamanho'
|
|
123
122
|
};
|
|
124
|
-
|
|
125
123
|
export const ptBR = getGridLocalization(ptBRGrid, ptBRCore);
|
package/locales/ruRU.js
CHANGED
|
@@ -76,7 +76,7 @@ const ruRUGrid = {
|
|
|
76
76
|
// Column menu text
|
|
77
77
|
columnMenuLabel: 'Меню',
|
|
78
78
|
columnMenuShowColumns: 'Показать столбцы',
|
|
79
|
-
|
|
79
|
+
columnMenuManageColumns: 'Управление колонками',
|
|
80
80
|
columnMenuFilter: 'Фильтр',
|
|
81
81
|
columnMenuHideColumn: 'Скрыть',
|
|
82
82
|
columnMenuUnsort: 'Отменить сортировку',
|
package/locales/svSE.js
CHANGED
|
@@ -37,7 +37,7 @@ const svSEGrid = {
|
|
|
37
37
|
columnsPanelHideAllButton: 'Dölj alla',
|
|
38
38
|
// Filter panel text
|
|
39
39
|
filterPanelAddFilter: 'Lägg till filter',
|
|
40
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Ta bort alla',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Ta bort',
|
|
42
42
|
filterPanelLogicOperator: 'Logisk operatör',
|
|
43
43
|
filterPanelOperator: 'Operatör',
|
|
@@ -67,7 +67,7 @@ const svSEGrid = {
|
|
|
67
67
|
// Column menu text
|
|
68
68
|
columnMenuLabel: 'Meny',
|
|
69
69
|
columnMenuShowColumns: 'Visa kolumner',
|
|
70
|
-
|
|
70
|
+
columnMenuManageColumns: 'Hantera kolumner',
|
|
71
71
|
columnMenuFilter: 'Filtrera',
|
|
72
72
|
columnMenuHideColumn: 'Dölj',
|
|
73
73
|
columnMenuUnsort: 'Osortera',
|
|
@@ -31,7 +31,9 @@ export interface GridCoreApi {
|
|
|
31
31
|
* Unique identifier for each component instance in a page.
|
|
32
32
|
* @ignore - do not document.
|
|
33
33
|
*/
|
|
34
|
-
instanceId:
|
|
34
|
+
instanceId: {
|
|
35
|
+
id: number;
|
|
36
|
+
};
|
|
35
37
|
}
|
|
36
38
|
export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPrivateApi extends GridPrivateApiCommon> {
|
|
37
39
|
/**
|
|
@@ -18,6 +18,10 @@ export type GridRowModesModelProps = ({
|
|
|
18
18
|
export type GridRowModesModel = Record<GridRowId, GridRowModesModelProps>;
|
|
19
19
|
export interface GridEditCellMeta {
|
|
20
20
|
changeReason?: 'debouncedSetEditCellValue' | 'setEditCellValue';
|
|
21
|
+
/**
|
|
22
|
+
* Determines if `setEditCellValue` should be called on the first render to sync the value.
|
|
23
|
+
*/
|
|
24
|
+
unstable_updateValueOnRender?: boolean;
|
|
21
25
|
}
|
|
22
26
|
export interface GridEditingSharedApi {
|
|
23
27
|
/**
|
|
@@ -32,5 +32,13 @@ var GridRowEditStopReasons = /*#__PURE__*/function (GridRowEditStopReasons) {
|
|
|
32
32
|
GridRowEditStopReasons["shiftTabKeyDown"] = "shiftTabKeyDown";
|
|
33
33
|
return GridRowEditStopReasons;
|
|
34
34
|
}(GridRowEditStopReasons || {});
|
|
35
|
+
/**
|
|
36
|
+
* Object passed as parameter in the row `getRowSpacing` callback prop.
|
|
37
|
+
* @demos
|
|
38
|
+
* - [Row spacing](/x/react-data-grid/row-height/#row-spacing)
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The getRowSpacing return value.
|
|
42
|
+
*/
|
|
35
43
|
// https://github.com/mui/mui-x/pull/3738#discussion_r798504277
|
|
36
44
|
export { GridRowEditStartReasons, GridRowEditStopReasons };
|
|
@@ -6,6 +6,9 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { unstable_useForkRef as useForkRef, unstable_ownerWindow as ownerWindow, unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
7
7
|
import createDetectElementResize from '../lib/createDetectElementResize';
|
|
8
8
|
// TODO replace with https://caniuse.com/resizeobserver.
|
|
9
|
+
|
|
10
|
+
// Credit to https://github.com/bvaughn/react-virtualized/blob/master/source/AutoSizer/AutoSizer.js
|
|
11
|
+
// for the sources.
|
|
9
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
13
|
const GridAutoSizer = /*#__PURE__*/React.forwardRef(function AutoSizer(props, ref) {
|
|
11
14
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
4
|
-
_excluded2 = ["changeReason"];
|
|
4
|
+
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import clsx from 'clsx';
|
|
@@ -48,7 +48,7 @@ function EmptyCell({
|
|
|
48
48
|
width
|
|
49
49
|
};
|
|
50
50
|
return /*#__PURE__*/_jsx("div", {
|
|
51
|
-
className:
|
|
51
|
+
className: `${gridClasses.cell} ${gridClasses.withBorderColor}`,
|
|
52
52
|
style: style
|
|
53
53
|
}); // TODO change to .MuiDataGrid-emptyCell or .MuiDataGrid-rowFiller
|
|
54
54
|
}
|
|
@@ -210,6 +210,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
210
210
|
}
|
|
211
211
|
if (editCellState != null && column.renderEditCell) {
|
|
212
212
|
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
|
|
213
|
+
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
213
215
|
const editCellStateRest = _objectWithoutPropertiesLoose(editCellState, _excluded2);
|
|
214
216
|
const params = _extends({}, cellParams, {
|
|
215
217
|
row: updatedRow
|
|
@@ -63,22 +63,25 @@ function GridEditDateCell(props) {
|
|
|
63
63
|
classes: rootProps.classes
|
|
64
64
|
};
|
|
65
65
|
const classes = useUtilityClasses(ownerState);
|
|
66
|
+
const hasUpdatedEditValueOnMount = React.useRef(false);
|
|
67
|
+
const parseValueToDate = React.useCallback(value => {
|
|
68
|
+
if (value === '') {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const [date, time] = value.split('T');
|
|
72
|
+
const [year, month, day] = date.split('-');
|
|
73
|
+
const parsedDate = new Date();
|
|
74
|
+
parsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
75
|
+
parsedDate.setHours(0, 0, 0, 0);
|
|
76
|
+
if (time) {
|
|
77
|
+
const [hours, minutes] = time.split(':');
|
|
78
|
+
parsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
79
|
+
}
|
|
80
|
+
return parsedDate;
|
|
81
|
+
}, []);
|
|
66
82
|
const handleChange = React.useCallback(async event => {
|
|
67
83
|
const newFormattedDate = event.target.value;
|
|
68
|
-
|
|
69
|
-
if (newFormattedDate === '') {
|
|
70
|
-
newParsedDate = null;
|
|
71
|
-
} else {
|
|
72
|
-
const [date, time] = newFormattedDate.split('T');
|
|
73
|
-
const [year, month, day] = date.split('-');
|
|
74
|
-
newParsedDate = new Date();
|
|
75
|
-
newParsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
76
|
-
newParsedDate.setHours(0, 0, 0, 0);
|
|
77
|
-
if (time) {
|
|
78
|
-
const [hours, minutes] = time.split(':');
|
|
79
|
-
newParsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
84
|
+
const newParsedDate = parseValueToDate(newFormattedDate);
|
|
82
85
|
if (onValueChange) {
|
|
83
86
|
await onValueChange(event, newParsedDate);
|
|
84
87
|
}
|
|
@@ -91,7 +94,7 @@ function GridEditDateCell(props) {
|
|
|
91
94
|
field,
|
|
92
95
|
value: newParsedDate
|
|
93
96
|
}, event);
|
|
94
|
-
}, [apiRef, field, id, onValueChange]);
|
|
97
|
+
}, [apiRef, field, id, onValueChange, parseValueToDate]);
|
|
95
98
|
React.useEffect(() => {
|
|
96
99
|
setValueState(state => {
|
|
97
100
|
if (valueTransformed.parsed !== state.parsed && valueTransformed.parsed?.getTime() !== state.parsed?.getTime()) {
|
|
@@ -105,8 +108,26 @@ function GridEditDateCell(props) {
|
|
|
105
108
|
inputRef.current.focus();
|
|
106
109
|
}
|
|
107
110
|
}, [hasFocus]);
|
|
111
|
+
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
112
|
+
const handleInputRef = el => {
|
|
113
|
+
inputRef.current = el;
|
|
114
|
+
if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
115
|
+
const inputValue = inputRef.current.value;
|
|
116
|
+
const parsedDate = parseValueToDate(inputValue);
|
|
117
|
+
setValueState({
|
|
118
|
+
parsed: parsedDate,
|
|
119
|
+
formatted: inputValue
|
|
120
|
+
});
|
|
121
|
+
apiRef.current.setEditCellValue({
|
|
122
|
+
id,
|
|
123
|
+
field,
|
|
124
|
+
value: parsedDate
|
|
125
|
+
});
|
|
126
|
+
hasUpdatedEditValueOnMount.current = true;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
108
129
|
return /*#__PURE__*/_jsx(StyledInputBase, _extends({
|
|
109
|
-
inputRef:
|
|
130
|
+
inputRef: handleInputRef,
|
|
110
131
|
fullWidth: true,
|
|
111
132
|
className: classes.root,
|
|
112
133
|
type: isDateTime ? 'datetime-local' : 'date',
|
|
@@ -37,22 +37,26 @@ export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
|
|
|
37
37
|
}, [apiRef, colDef.field]);
|
|
38
38
|
return /*#__PURE__*/_jsx("div", {
|
|
39
39
|
className: classes.root,
|
|
40
|
-
children: /*#__PURE__*/_jsx(rootProps.slots.
|
|
41
|
-
ref: iconButtonRef,
|
|
42
|
-
tabIndex: -1,
|
|
43
|
-
className: classes.button,
|
|
44
|
-
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
40
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
45
41
|
title: apiRef.current.getLocaleText('columnMenuLabel'),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
enterDelay: 1000
|
|
43
|
+
}, rootProps.slotProps?.baseTooltip, {
|
|
44
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
45
|
+
ref: iconButtonRef,
|
|
46
|
+
tabIndex: -1,
|
|
47
|
+
className: classes.button,
|
|
48
|
+
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
49
|
+
size: "small",
|
|
50
|
+
onClick: handleMenuIconClick,
|
|
51
|
+
"aria-expanded": open ? 'true' : undefined,
|
|
52
|
+
"aria-haspopup": "true",
|
|
53
|
+
"aria-controls": columnMenuId,
|
|
54
|
+
id: columnMenuButtonId
|
|
55
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
56
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
|
|
57
|
+
fontSize: "small"
|
|
58
|
+
})
|
|
59
|
+
}))
|
|
56
60
|
}))
|
|
57
61
|
});
|
|
58
62
|
});
|
|
@@ -46,14 +46,13 @@ const ColumnHeaderInnerTitle = /*#__PURE__*/React.forwardRef(function ColumnHead
|
|
|
46
46
|
function GridColumnHeaderTitle(props) {
|
|
47
47
|
const {
|
|
48
48
|
label,
|
|
49
|
-
description
|
|
50
|
-
columnWidth
|
|
49
|
+
description
|
|
51
50
|
} = props;
|
|
52
51
|
const rootProps = useGridRootProps();
|
|
53
52
|
const titleRef = React.useRef(null);
|
|
54
53
|
const [tooltip, setTooltip] = React.useState('');
|
|
55
|
-
React.
|
|
56
|
-
if (!description && titleRef
|
|
54
|
+
const handleMouseOver = React.useCallback(() => {
|
|
55
|
+
if (!description && titleRef?.current) {
|
|
57
56
|
const isOver = isOverflown(titleRef.current);
|
|
58
57
|
if (isOver) {
|
|
59
58
|
setTooltip(label);
|
|
@@ -61,11 +60,12 @@ function GridColumnHeaderTitle(props) {
|
|
|
61
60
|
setTooltip('');
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
}, [
|
|
63
|
+
}, [description, label]);
|
|
65
64
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
66
65
|
title: description || tooltip
|
|
67
66
|
}, rootProps.slotProps?.baseTooltip, {
|
|
68
67
|
children: /*#__PURE__*/_jsx(ColumnHeaderInnerTitle, {
|
|
68
|
+
onMouseOver: handleMouseOver,
|
|
69
69
|
ref: titleRef,
|
|
70
70
|
children: label
|
|
71
71
|
})
|
|
@@ -20,8 +20,10 @@ function GridColumnHeaderMenu({
|
|
|
20
20
|
const hideMenu = React.useCallback(event => {
|
|
21
21
|
// Prevent triggering the sorting
|
|
22
22
|
event.stopPropagation();
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
if (!target?.contains(event.target)) {
|
|
24
|
+
apiRef.current.hideColumnMenu();
|
|
25
|
+
}
|
|
26
|
+
}, [apiRef, target]);
|
|
25
27
|
if (!target) {
|
|
26
28
|
return null;
|
|
27
29
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["defaultSlots", "defaultSlotProps", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
6
|
+
import { useGridColumnMenuSlots } from '../../../hooks/features/columnMenu/useGridColumnMenuSlots';
|
|
7
7
|
import { GridColumnMenuContainer } from './GridColumnMenuContainer';
|
|
8
8
|
import { GridColumnMenuColumnsItem } from './menuItems/GridColumnMenuColumnsItem';
|
|
9
9
|
import { GridColumnMenuFilterItem } from './menuItems/GridColumnMenuFilterItem';
|
|
10
10
|
import { GridColumnMenuSortItem } from './menuItems/GridColumnMenuSortItem';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export const GRID_COLUMN_MENU_SLOTS = {
|
|
13
|
+
columnMenuSortItem: GridColumnMenuSortItem,
|
|
14
|
+
columnMenuFilterItem: GridColumnMenuFilterItem,
|
|
15
|
+
columnMenuColumnsItem: GridColumnMenuColumnsItem
|
|
16
16
|
};
|
|
17
|
-
export const
|
|
17
|
+
export const GRID_COLUMN_MENU_SLOT_PROPS = {
|
|
18
18
|
columnMenuSortItem: {
|
|
19
19
|
displayOrder: 10
|
|
20
20
|
},
|
|
@@ -27,29 +27,29 @@ export const GRID_COLUMN_MENU_COMPONENTS_PROPS = {
|
|
|
27
27
|
};
|
|
28
28
|
const GridGenericColumnMenu = /*#__PURE__*/React.forwardRef(function GridGenericColumnMenu(props, ref) {
|
|
29
29
|
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
defaultSlots,
|
|
31
|
+
defaultSlotProps,
|
|
32
|
+
slots,
|
|
33
|
+
slotProps
|
|
34
34
|
} = props,
|
|
35
35
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const orderedSlots = useGridColumnMenuSlots(_extends({}, other, {
|
|
37
|
+
defaultSlots,
|
|
38
|
+
defaultSlotProps,
|
|
39
|
+
slots,
|
|
40
|
+
slotProps
|
|
41
41
|
}));
|
|
42
42
|
return /*#__PURE__*/_jsx(GridColumnMenuContainer, _extends({
|
|
43
43
|
ref: ref
|
|
44
44
|
}, other, {
|
|
45
|
-
children:
|
|
45
|
+
children: orderedSlots.map(([Component, otherProps], index) => /*#__PURE__*/_jsx(Component, _extends({}, otherProps), index))
|
|
46
46
|
}));
|
|
47
47
|
});
|
|
48
48
|
const GridColumnMenu = /*#__PURE__*/React.forwardRef(function GridColumnMenu(props, ref) {
|
|
49
49
|
return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({}, props, {
|
|
50
50
|
ref: ref,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
defaultSlots: GRID_COLUMN_MENU_SLOTS,
|
|
52
|
+
defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS
|
|
53
53
|
}));
|
|
54
54
|
});
|
|
55
55
|
process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
|
|
@@ -58,20 +58,20 @@ process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
|
|
|
58
58
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
59
59
|
// ----------------------------------------------------------------------
|
|
60
60
|
colDef: PropTypes.object.isRequired,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*/
|
|
66
|
-
components: PropTypes.object,
|
|
61
|
+
hideMenu: PropTypes.func.isRequired,
|
|
62
|
+
id: PropTypes.string,
|
|
63
|
+
labelledby: PropTypes.string,
|
|
64
|
+
open: PropTypes.bool.isRequired,
|
|
67
65
|
/**
|
|
68
66
|
* Could be used to pass new props or override props specific to a column menu component
|
|
69
67
|
* e.g. `displayOrder`
|
|
70
68
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
slotProps: PropTypes.object,
|
|
70
|
+
/**
|
|
71
|
+
* `slots` could be used to add new and (or) override default column menu items
|
|
72
|
+
* If you register a nee component you must pass it's `displayOrder` in `slotProps`
|
|
73
|
+
* or it will be placed in the end of the list
|
|
74
|
+
*/
|
|
75
|
+
slots: PropTypes.object
|
|
76
76
|
} : void 0;
|
|
77
77
|
export { GridColumnMenu, GridGenericColumnMenu };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton"];
|
|
3
|
+
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
@@ -71,7 +71,8 @@ function GridColumnsPanel(props) {
|
|
|
71
71
|
searchPredicate = defaultSearchPredicate,
|
|
72
72
|
autoFocusSearchField = true,
|
|
73
73
|
disableHideAllButton = false,
|
|
74
|
-
disableShowAllButton = false
|
|
74
|
+
disableShowAllButton = false,
|
|
75
|
+
getTogglableColumns
|
|
75
76
|
} = props,
|
|
76
77
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
77
78
|
const sortedColumns = React.useMemo(() => {
|
|
@@ -109,12 +110,15 @@ function GridColumnsPanel(props) {
|
|
|
109
110
|
setSearchValue(event.target.value);
|
|
110
111
|
}, []);
|
|
111
112
|
const currentColumns = React.useMemo(() => {
|
|
113
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
114
|
+
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
115
|
+
field
|
|
116
|
+
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
112
117
|
if (!searchValue) {
|
|
113
|
-
return
|
|
118
|
+
return togglableSortedColumns;
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, [sortedColumns, searchValue, searchPredicate]);
|
|
120
|
+
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
121
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
118
122
|
const firstSwitchRef = React.useRef(null);
|
|
119
123
|
React.useEffect(() => {
|
|
120
124
|
if (autoFocusSearchField) {
|
|
@@ -192,6 +196,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
192
196
|
autoFocusSearchField: PropTypes.bool,
|
|
193
197
|
disableHideAllButton: PropTypes.bool,
|
|
194
198
|
disableShowAllButton: PropTypes.bool,
|
|
199
|
+
/**
|
|
200
|
+
* Returns the list of togglable columns.
|
|
201
|
+
* If used, only those columns will be displayed in the panel
|
|
202
|
+
* which are passed as the return value of the function.
|
|
203
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
204
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
205
|
+
*/
|
|
206
|
+
getTogglableColumns: PropTypes.func,
|
|
195
207
|
searchPredicate: PropTypes.func,
|
|
196
208
|
slotProps: PropTypes.object,
|
|
197
209
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
@@ -143,7 +143,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
143
143
|
logicOperators: logicOperators,
|
|
144
144
|
columnsSort: columnsSort
|
|
145
145
|
}, filterFormProps), item.id == null ? index : item.id))
|
|
146
|
-
}), !rootProps.disableMultipleColumnsFiltering && !disableAddFilterButton &&
|
|
146
|
+
}), !rootProps.disableMultipleColumnsFiltering && !(disableAddFilterButton && disableRemoveAllButton) ? /*#__PURE__*/_jsxs(GridPanelFooter, {
|
|
147
147
|
children: [!disableAddFilterButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
148
148
|
onClick: addNewFilter,
|
|
149
149
|
startIcon: /*#__PURE__*/_jsx(rootProps.slots.filterPanelAddIcon, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GridColumnMenu,
|
|
1
|
+
export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } from './menu/columnMenu/GridColumnMenu';
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { useGridApiMethod } from '../utils/useGridApiMethod';
|
|
3
3
|
import { GridSignature } from '../utils/useGridApiEventHandler';
|
|
4
4
|
import { EventManager } from '../../utils/EventManager';
|
|
5
|
-
import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
|
|
6
5
|
const isSyntheticEvent = event => {
|
|
7
6
|
return event.isPropagationStopped !== undefined;
|
|
8
7
|
};
|
|
@@ -38,7 +37,9 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
38
37
|
if (!publicApiRef.current) {
|
|
39
38
|
publicApiRef.current = {
|
|
40
39
|
state: {},
|
|
41
|
-
instanceId:
|
|
40
|
+
instanceId: {
|
|
41
|
+
id: globalId
|
|
42
|
+
}
|
|
42
43
|
};
|
|
43
44
|
globalId += 1;
|
|
44
45
|
}
|
|
@@ -76,7 +77,6 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
76
77
|
React.useEffect(() => {
|
|
77
78
|
const api = privateApiRef.current;
|
|
78
79
|
return () => {
|
|
79
|
-
unstable_resetCreateSelectorCache(api.instanceId);
|
|
80
80
|
api.publishEvent('unmount');
|
|
81
81
|
};
|
|
82
82
|
}, [privateApiRef]);
|