@mui/x-data-grid 5.8.0 → 5.9.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 +141 -63
- package/DataGrid/DataGrid.js +1 -1
- package/DataGrid/useDataGridComponent.js +3 -1
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/components/GridRow.d.ts +4 -0
- package/components/GridRow.js +49 -23
- package/components/base/GridOverlays.js +4 -3
- package/components/cell/GridActionsCell.d.ts +5 -1
- package/components/cell/GridActionsCell.js +170 -21
- package/components/cell/GridActionsCellItem.d.ts +66 -4
- package/components/cell/GridActionsCellItem.js +7 -5
- package/components/cell/GridCell.d.ts +1 -0
- package/components/cell/GridCell.js +28 -7
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +22 -13
- package/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/components/columnHeaders/GridColumnHeaders.d.ts +0 -1
- package/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +3 -3
- package/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/components/panel/GridPanel.js +1 -0
- package/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -15
- package/components/panel/filterPanel/GridFilterInputValue.js +22 -15
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +2 -0
- package/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/constants/gridDetailPanelToggleField.d.ts +1 -0
- package/constants/gridDetailPanelToggleField.js +2 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +32 -15
- package/hooks/core/pipeProcessing/index.d.ts +1 -0
- package/hooks/core/pipeProcessing/index.js +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +8 -3
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +3 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +0 -3
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +19 -1
- package/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/hooks/features/columns/useGridColumnSpanning.d.ts +7 -0
- package/hooks/features/columns/useGridColumnSpanning.js +109 -0
- package/hooks/features/columns/useGridColumns.js +24 -18
- package/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/hooks/features/filter/useGridFilter.js +14 -9
- package/hooks/features/focus/useGridFocus.js +19 -9
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -7
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -0
- package/hooks/features/rows/gridRowsSelector.js +1 -0
- package/hooks/features/rows/gridRowsState.d.ts +4 -0
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +5 -4
- package/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/hooks/features/scroll/useGridScroll.d.ts +2 -0
- package/hooks/features/scroll/useGridScroll.js +25 -3
- package/hooks/features/selection/useGridSelection.js +3 -2
- package/hooks/features/sorting/useGridSorting.js +10 -10
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +54 -27
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/legacy/DataGrid/DataGrid.js +1 -1
- package/legacy/DataGrid/useDataGridComponent.js +3 -1
- package/legacy/components/GridRow.js +47 -23
- package/legacy/components/base/GridOverlays.js +4 -3
- package/legacy/components/cell/GridActionsCell.js +188 -27
- package/legacy/components/cell/GridActionsCellItem.js +7 -5
- package/legacy/components/cell/GridCell.js +29 -7
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +33 -24
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/legacy/components/columnHeaders/GridColumnHeaders.js +2 -3
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +21 -3
- package/legacy/components/panel/GridPanel.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -17
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +22 -17
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/legacy/components/virtualization/GridVirtualScroller.js +2 -0
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/legacy/constants/gridDetailPanelToggleField.js +2 -0
- package/legacy/hooks/core/pipeProcessing/index.js +2 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +60 -24
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +89 -10
- package/legacy/hooks/features/columns/gridColumnsUtils.js +79 -22
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/legacy/hooks/features/columns/useGridColumns.js +24 -18
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -8
- package/legacy/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +32 -24
- package/legacy/hooks/features/filter/useGridFilter.js +14 -9
- package/legacy/hooks/features/focus/useGridFocus.js +19 -9
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -6
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -0
- package/legacy/hooks/features/rows/useGridRows.js +5 -4
- package/legacy/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/legacy/hooks/features/scroll/useGridScroll.js +25 -3
- package/legacy/hooks/features/selection/useGridSelection.js +3 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +5 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +65 -37
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/locales/huHU.js +120 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/models/api/gridColumnSpanning.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -3
- package/legacy/models/gridColumnSpanning.js +1 -0
- package/locales/huHU.d.ts +2 -0
- package/locales/huHU.js +108 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridColumnSpanning.d.ts +28 -0
- package/models/api/gridColumnSpanning.js +1 -0
- package/models/api/gridEditingApi.d.ts +49 -3
- package/models/colDef/gridColDef.d.ts +5 -0
- package/models/events/gridEventLookup.d.ts +3 -8
- package/models/events/gridEvents.d.ts +9 -14
- package/models/events/gridEvents.js +2 -3
- package/models/gridColumnSpanning.d.ts +12 -0
- package/models/gridColumnSpanning.js +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- package/models/params/gridCellParams.d.ts +12 -2
- package/models/params/gridRowParams.d.ts +5 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +1 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -1
- package/modern/components/GridRow.js +47 -21
- package/modern/components/base/GridOverlays.js +4 -3
- package/modern/components/cell/GridActionsCell.js +168 -21
- package/modern/components/cell/GridActionsCellItem.js +7 -5
- package/modern/components/cell/GridCell.js +28 -7
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +20 -11
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/modern/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/modern/components/panel/GridPanel.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterForm.js +10 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +11 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +20 -13
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +20 -13
- package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/modern/constants/gridDetailPanelToggleField.js +2 -0
- package/modern/hooks/core/pipeProcessing/index.js +2 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/modern/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/modern/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/modern/hooks/features/columns/useGridColumns.js +24 -18
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/modern/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/modern/hooks/features/filter/useGridFilter.js +14 -9
- package/modern/hooks/features/focus/useGridFocus.js +19 -9
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +37 -7
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
- package/modern/hooks/features/rows/useGridRows.js +5 -4
- package/modern/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/modern/hooks/features/scroll/useGridScroll.js +23 -3
- package/modern/hooks/features/selection/useGridSelection.js +3 -2
- package/modern/hooks/features/sorting/useGridSorting.js +10 -10
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +54 -23
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/locales/huHU.js +108 -0
- package/modern/locales/index.js +1 -0
- package/modern/models/api/gridColumnSpanning.js +1 -0
- package/modern/models/events/gridEvents.js +2 -3
- package/modern/models/gridColumnSpanning.js +1 -0
- package/node/DataGrid/DataGrid.js +1 -1
- package/node/DataGrid/useDataGridComponent.js +4 -1
- package/node/components/GridRow.js +50 -23
- package/node/components/base/GridOverlays.js +3 -2
- package/node/components/cell/GridActionsCell.js +172 -21
- package/node/components/cell/GridActionsCellItem.js +7 -4
- package/node/components/cell/GridCell.js +28 -7
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +23 -13
- package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/node/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/node/components/panel/GridPanel.js +1 -0
- package/node/components/panel/filterPanel/GridFilterForm.js +15 -10
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +14 -8
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +23 -15
- package/node/components/panel/filterPanel/GridFilterInputValue.js +23 -15
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +2 -0
- package/node/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/node/constants/gridDetailPanelToggleField.js +9 -0
- package/node/hooks/core/pipeProcessing/index.js +13 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +51 -20
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +42 -0
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +80 -10
- package/node/hooks/features/columns/gridColumnsUtils.js +65 -9
- package/node/hooks/features/columns/useGridColumnSpanning.js +130 -0
- package/node/hooks/features/columns/useGridColumns.js +23 -17
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/node/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/node/hooks/features/editRows/useGridEditing.new.js +6 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +21 -14
- package/node/hooks/features/filter/useGridFilter.js +14 -9
- package/node/hooks/features/focus/useGridFocus.js +19 -9
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +40 -7
- package/node/hooks/features/rows/gridRowsSelector.js +3 -1
- package/node/hooks/features/rows/useGridRows.js +5 -4
- package/node/hooks/features/rows/useGridRowsMeta.js +6 -14
- package/node/hooks/features/scroll/useGridScroll.js +26 -2
- package/node/hooks/features/selection/useGridSelection.js +4 -2
- package/node/hooks/features/sorting/useGridSorting.js +10 -10
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +59 -27
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -0
- package/node/locales/huHU.js +118 -0
- package/node/locales/index.js +13 -0
- package/node/models/api/gridColumnSpanning.js +5 -0
- package/node/models/events/gridEvents.js +2 -3
- package/node/models/gridColumnSpanning.js +5 -0
- package/package.json +4 -4
- package/utils/domUtils.d.ts +2 -2
|
@@ -24,6 +24,7 @@ import { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
|
24
24
|
import { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
25
25
|
import { rowsMetaStateInitializer, useGridRowsMeta } from '../hooks/features/rows/useGridRowsMeta';
|
|
26
26
|
import { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
27
|
+
import { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSpanning';
|
|
27
28
|
export const useDataGridComponent = props => {
|
|
28
29
|
const apiRef = useGridInitialization(undefined, props);
|
|
29
30
|
/**
|
|
@@ -53,12 +54,13 @@ export const useDataGridComponent = props => {
|
|
|
53
54
|
useGridColumns(apiRef, props);
|
|
54
55
|
useGridRows(apiRef, props);
|
|
55
56
|
useGridParamsApi(apiRef);
|
|
57
|
+
useGridColumnSpanning(apiRef);
|
|
56
58
|
const useGridEditing = props.experimentalFeatures?.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
57
59
|
useGridEditing(apiRef, props);
|
|
58
60
|
useGridFocus(apiRef, props);
|
|
59
|
-
useGridSorting(apiRef, props);
|
|
60
61
|
useGridPreferencesPanel(apiRef);
|
|
61
62
|
useGridFilter(apiRef, props);
|
|
63
|
+
useGridSorting(apiRef, props);
|
|
62
64
|
useGridDensity(apiRef, props);
|
|
63
65
|
useGridPagination(apiRef, props);
|
|
64
66
|
useGridRowsMeta(apiRef, props);
|
|
@@ -20,6 +20,7 @@ import { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
|
20
20
|
import { findParentElementFromClassName } from '../utils/domUtils';
|
|
21
21
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
|
|
22
22
|
import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
23
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
26
|
|
|
@@ -59,6 +60,7 @@ function GridRow(props) {
|
|
|
59
60
|
const {
|
|
60
61
|
selected,
|
|
61
62
|
rowId,
|
|
63
|
+
row,
|
|
62
64
|
index,
|
|
63
65
|
style: styleProp,
|
|
64
66
|
rowHeight,
|
|
@@ -130,7 +132,7 @@ function GridRow(props) {
|
|
|
130
132
|
} // User opened a detail panel
|
|
131
133
|
|
|
132
134
|
|
|
133
|
-
if (field ===
|
|
135
|
+
if (field === GRID_DETAIL_PANEL_TOGGLE_FIELD) {
|
|
134
136
|
return;
|
|
135
137
|
} // User is editing a cell
|
|
136
138
|
|
|
@@ -174,7 +176,8 @@ function GridRow(props) {
|
|
|
174
176
|
|
|
175
177
|
const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
|
|
176
178
|
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
177
|
-
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1
|
|
179
|
+
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
180
|
+
indexRelativeToCurrentPage
|
|
178
181
|
});
|
|
179
182
|
|
|
180
183
|
rowClassName = rootProps.getRowClassName(rowParams);
|
|
@@ -207,7 +210,16 @@ function GridRow(props) {
|
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
if (editCellState != null && column.renderEditCell) {
|
|
210
|
-
|
|
213
|
+
let updatedRow = row;
|
|
214
|
+
|
|
215
|
+
if (apiRef.current.unstable_getRowWithUpdatedValues) {
|
|
216
|
+
// Only the new editing API has this method
|
|
217
|
+
updatedRow = apiRef.current.unstable_getRowWithUpdatedValues(rowId, column.field);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const params = _extends({}, cellParams, {
|
|
221
|
+
row: updatedRow
|
|
222
|
+
}, editCellState, {
|
|
211
223
|
api: apiRef.current
|
|
212
224
|
});
|
|
213
225
|
|
|
@@ -223,24 +235,33 @@ function GridRow(props) {
|
|
|
223
235
|
|
|
224
236
|
const hasFocus = cellFocus !== null && cellFocus.id === rowId && cellFocus.field === column.field;
|
|
225
237
|
const tabIndex = cellTabIndex !== null && cellTabIndex.id === rowId && cellTabIndex.field === column.field && cellParams.cellMode === 'view' ? 0 : -1;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
239
|
+
|
|
240
|
+
if (cellColSpanInfo && !cellColSpanInfo.spannedByColSpan) {
|
|
241
|
+
const {
|
|
242
|
+
colSpan,
|
|
243
|
+
width
|
|
244
|
+
} = cellColSpanInfo.cellProps;
|
|
245
|
+
cells.push( /*#__PURE__*/_jsx(rootProps.components.Cell, _extends({
|
|
246
|
+
value: cellParams.value,
|
|
247
|
+
field: column.field,
|
|
248
|
+
width: width,
|
|
249
|
+
rowId: rowId,
|
|
250
|
+
height: rowHeight,
|
|
251
|
+
showRightBorder: showRightBorder,
|
|
252
|
+
formattedValue: cellParams.formattedValue,
|
|
253
|
+
align: column.align || 'left',
|
|
254
|
+
cellMode: cellParams.cellMode,
|
|
255
|
+
colIndex: indexRelativeToAllColumns,
|
|
256
|
+
isEditable: cellParams.isEditable,
|
|
257
|
+
hasFocus: hasFocus,
|
|
258
|
+
tabIndex: tabIndex,
|
|
259
|
+
className: clsx(classNames),
|
|
260
|
+
colSpan: colSpan
|
|
261
|
+
}, rootProps.componentsProps?.cell, {
|
|
262
|
+
children: content
|
|
263
|
+
}), column.field));
|
|
264
|
+
}
|
|
244
265
|
}
|
|
245
266
|
|
|
246
267
|
const emptyCellWidth = containerWidth - columnsTotalWidth;
|
|
@@ -274,6 +295,11 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
274
295
|
containerWidth: PropTypes.number.isRequired,
|
|
275
296
|
editRowsState: PropTypes.object.isRequired,
|
|
276
297
|
firstColumnToRender: PropTypes.number.isRequired,
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Index of the row in the whole sorted and filtered dataset.
|
|
301
|
+
* If some rows above have expanded children, this index also take those children into account.
|
|
302
|
+
*/
|
|
277
303
|
index: PropTypes.number.isRequired,
|
|
278
304
|
isLastVisible: PropTypes.bool,
|
|
279
305
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
|
|
4
4
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
5
5
|
import { gridVisibleRowCountSelector } from '../../hooks/features/filter/gridFilterSelector';
|
|
6
|
-
import { gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
6
|
+
import { gridRowCountSelector, gridRowsLoadingSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
7
7
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
8
8
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
9
9
|
import { gridDensityHeaderHeightSelector } from '../../hooks/features/density/densitySelector';
|
|
@@ -47,8 +47,9 @@ export function GridOverlays() {
|
|
|
47
47
|
const rootProps = useGridRootProps();
|
|
48
48
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
49
49
|
const visibleRowCount = useGridSelector(apiRef, gridVisibleRowCountSelector);
|
|
50
|
-
const
|
|
51
|
-
const
|
|
50
|
+
const loading = useGridSelector(apiRef, gridRowsLoadingSelector);
|
|
51
|
+
const showNoRowsOverlay = !loading && totalRowCount === 0;
|
|
52
|
+
const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
|
|
52
53
|
let overlay = null;
|
|
53
54
|
|
|
54
55
|
if (showNoRowsOverlay) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["colDef", "id", "api", "hasFocus", "isEditable", "field", "value", "formattedValue", "row", "rowNode", "cellMode", "getValue", "tabIndex", "position", "focusElementRef"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
import IconButton from '@mui/material/IconButton';
|
|
@@ -7,26 +9,33 @@ import { unstable_useId as useId } from '@mui/material/utils';
|
|
|
7
9
|
import { gridClasses } from '../../constants/gridClasses';
|
|
8
10
|
import { GridMenu } from '../menu/GridMenu';
|
|
9
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
10
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
15
|
|
|
13
16
|
const hasActions = colDef => typeof colDef.getActions === 'function';
|
|
14
17
|
|
|
15
18
|
const GridActionsCell = props => {
|
|
19
|
+
const {
|
|
20
|
+
colDef,
|
|
21
|
+
id,
|
|
22
|
+
hasFocus,
|
|
23
|
+
tabIndex,
|
|
24
|
+
position = 'bottom-end',
|
|
25
|
+
focusElementRef
|
|
26
|
+
} = props,
|
|
27
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
28
|
+
|
|
29
|
+
const [focusedButtonIndex, setFocusedButtonIndex] = React.useState(-1);
|
|
16
30
|
const [open, setOpen] = React.useState(false);
|
|
31
|
+
const apiRef = useGridApiContext();
|
|
32
|
+
const rootRef = React.useRef(null);
|
|
17
33
|
const buttonRef = React.useRef(null);
|
|
34
|
+
const ignoreCallToFocus = React.useRef(false);
|
|
18
35
|
const touchRippleRefs = React.useRef({});
|
|
19
36
|
const menuId = useId();
|
|
20
37
|
const buttonId = useId();
|
|
21
38
|
const rootProps = useGridRootProps();
|
|
22
|
-
const {
|
|
23
|
-
colDef,
|
|
24
|
-
id,
|
|
25
|
-
api,
|
|
26
|
-
hasFocus,
|
|
27
|
-
position = 'bottom-end'
|
|
28
|
-
} = props; // TODO apply the rest to the root element
|
|
29
|
-
|
|
30
39
|
React.useLayoutEffect(() => {
|
|
31
40
|
if (!hasFocus) {
|
|
32
41
|
Object.entries(touchRippleRefs.current).forEach(([index, ref]) => {
|
|
@@ -36,56 +45,142 @@ const GridActionsCell = props => {
|
|
|
36
45
|
});
|
|
37
46
|
}
|
|
38
47
|
}, [hasFocus]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (focusedButtonIndex >= 0) {
|
|
50
|
+
const child = rootRef.current?.children[focusedButtonIndex];
|
|
51
|
+
child.focus();
|
|
52
|
+
}
|
|
53
|
+
}, [focusedButtonIndex]);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (!hasFocus) {
|
|
56
|
+
setFocusedButtonIndex(-1);
|
|
57
|
+
ignoreCallToFocus.current = false;
|
|
58
|
+
}
|
|
59
|
+
}, [hasFocus]);
|
|
60
|
+
React.useImperativeHandle(focusElementRef, () => ({
|
|
61
|
+
focus() {
|
|
62
|
+
// If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
|
|
63
|
+
if (!ignoreCallToFocus.current) {
|
|
64
|
+
setFocusedButtonIndex(0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}), []);
|
|
39
69
|
|
|
40
70
|
if (!hasActions(colDef)) {
|
|
41
71
|
throw new Error('MUI: Missing the `getActions` property in the `GridColDef`.');
|
|
42
72
|
}
|
|
43
73
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const hideMenu = () => setOpen(false);
|
|
47
|
-
|
|
48
|
-
const options = colDef.getActions(api.getRowParams(id));
|
|
74
|
+
const options = colDef.getActions(apiRef.current.getRowParams(id));
|
|
49
75
|
const iconButtons = options.filter(option => !option.props.showInMenu);
|
|
50
76
|
const menuButtons = options.filter(option => option.props.showInMenu);
|
|
77
|
+
const numberOfButtons = iconButtons.length + (menuButtons.length ? 1 : 0);
|
|
78
|
+
|
|
79
|
+
const showMenu = () => {
|
|
80
|
+
setOpen(true);
|
|
81
|
+
setFocusedButtonIndex(numberOfButtons - 1);
|
|
82
|
+
ignoreCallToFocus.current = true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const hideMenu = () => {
|
|
86
|
+
setOpen(false);
|
|
87
|
+
};
|
|
51
88
|
|
|
52
89
|
const handleTouchRippleRef = index => instance => {
|
|
53
90
|
touchRippleRefs.current[index] = instance;
|
|
54
91
|
};
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
const handleButtonClick = (index, onClick) => event => {
|
|
94
|
+
setFocusedButtonIndex(index);
|
|
95
|
+
ignoreCallToFocus.current = true;
|
|
96
|
+
|
|
97
|
+
if (onClick) {
|
|
98
|
+
onClick(event);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleRootKeyDown = event => {
|
|
103
|
+
if (numberOfButtons <= 1) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let newIndex = focusedButtonIndex;
|
|
108
|
+
|
|
109
|
+
if (event.key === 'ArrowRight') {
|
|
110
|
+
newIndex += 1;
|
|
111
|
+
} else if (event.key === 'ArrowLeft') {
|
|
112
|
+
newIndex -= 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (newIndex < 0 || newIndex >= numberOfButtons) {
|
|
116
|
+
return; // We're already in the first or last item = do nothing and let the grid listen the event
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (newIndex !== focusedButtonIndex) {
|
|
120
|
+
event.preventDefault(); // Prevent scrolling
|
|
121
|
+
|
|
122
|
+
event.stopPropagation(); // Don't stop propagation for other keys, e.g. ArrowUp
|
|
123
|
+
|
|
124
|
+
setFocusedButtonIndex(newIndex);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const handleListKeyDown = event => {
|
|
129
|
+
if (event.key === 'Tab') {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (['Tab', 'Enter', 'Escape'].includes(event.key)) {
|
|
134
|
+
hideMenu();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return /*#__PURE__*/_jsxs("div", _extends({
|
|
139
|
+
role: "menu",
|
|
140
|
+
ref: rootRef,
|
|
141
|
+
tabIndex: -1,
|
|
57
142
|
className: gridClasses.actionsCell,
|
|
143
|
+
onKeyDown: handleRootKeyDown
|
|
144
|
+
}, other, {
|
|
58
145
|
children: [iconButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button, {
|
|
59
146
|
key: index,
|
|
60
|
-
touchRippleRef: handleTouchRippleRef(index)
|
|
61
|
-
|
|
147
|
+
touchRippleRef: handleTouchRippleRef(index),
|
|
148
|
+
onClick: handleButtonClick(index, button.props.onClick),
|
|
149
|
+
tabIndex: focusedButtonIndex === index ? tabIndex : -1
|
|
150
|
+
})), menuButtons.length > 0 && buttonId && /*#__PURE__*/_jsx(IconButton, {
|
|
62
151
|
ref: buttonRef,
|
|
63
152
|
id: buttonId,
|
|
64
|
-
"aria-label":
|
|
153
|
+
"aria-label": apiRef.current.getLocaleText('actionsCellMore'),
|
|
65
154
|
"aria-controls": menuId,
|
|
66
155
|
"aria-expanded": open ? 'true' : undefined,
|
|
67
156
|
"aria-haspopup": "true",
|
|
157
|
+
role: "menuitem",
|
|
68
158
|
size: "small",
|
|
69
159
|
onClick: showMenu,
|
|
160
|
+
touchRippleRef: handleTouchRippleRef(buttonId),
|
|
161
|
+
tabIndex: focusedButtonIndex === iconButtons.length ? tabIndex : -1,
|
|
70
162
|
children: /*#__PURE__*/_jsx(rootProps.components.MoreActionsIcon, {
|
|
71
163
|
fontSize: "small"
|
|
72
164
|
})
|
|
73
165
|
}), menuButtons.length > 0 && /*#__PURE__*/_jsx(GridMenu, {
|
|
74
|
-
id: menuId,
|
|
75
166
|
onClickAway: hideMenu,
|
|
76
167
|
onClick: hideMenu,
|
|
77
168
|
open: open,
|
|
78
169
|
target: buttonRef.current,
|
|
79
170
|
position: position,
|
|
80
|
-
"aria-labelledby": buttonId,
|
|
81
171
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
172
|
+
id: menuId,
|
|
82
173
|
className: gridClasses.menuList,
|
|
174
|
+
onKeyDown: handleListKeyDown,
|
|
175
|
+
"aria-labelledby": buttonId,
|
|
176
|
+
variant: "menu",
|
|
177
|
+
autoFocusItem: true,
|
|
83
178
|
children: menuButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button, {
|
|
84
179
|
key: index
|
|
85
180
|
}))
|
|
86
181
|
})
|
|
87
182
|
})]
|
|
88
|
-
});
|
|
183
|
+
}));
|
|
89
184
|
};
|
|
90
185
|
|
|
91
186
|
process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
@@ -100,11 +195,42 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
100
195
|
*/
|
|
101
196
|
api: PropTypes.any.isRequired,
|
|
102
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The mode of the cell.
|
|
200
|
+
*/
|
|
201
|
+
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
202
|
+
|
|
103
203
|
/**
|
|
104
204
|
* The column of the row that the current cell belongs to.
|
|
105
205
|
*/
|
|
106
206
|
colDef: PropTypes.object.isRequired,
|
|
107
207
|
|
|
208
|
+
/**
|
|
209
|
+
* The column field of the cell that triggered the event.
|
|
210
|
+
*/
|
|
211
|
+
field: PropTypes.string.isRequired,
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A ref allowing to set imperative focus.
|
|
215
|
+
* It can be passed to the element that should receive focus.
|
|
216
|
+
* @ignore - do not document.
|
|
217
|
+
*/
|
|
218
|
+
focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
219
|
+
current: PropTypes.shape({
|
|
220
|
+
focus: PropTypes.func.isRequired
|
|
221
|
+
})
|
|
222
|
+
})]),
|
|
223
|
+
formattedValue: PropTypes.any,
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the cell value of a row and field.
|
|
227
|
+
* @param {GridRowId} id The row id.
|
|
228
|
+
* @param {string} field The field.
|
|
229
|
+
* @returns {any} The cell value.
|
|
230
|
+
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
231
|
+
*/
|
|
232
|
+
getValue: PropTypes.func.isRequired,
|
|
233
|
+
|
|
108
234
|
/**
|
|
109
235
|
* If true, the cell is the active element.
|
|
110
236
|
*/
|
|
@@ -114,7 +240,28 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
114
240
|
* The grid row id.
|
|
115
241
|
*/
|
|
116
242
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
117
|
-
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* If true, the cell is editable.
|
|
246
|
+
*/
|
|
247
|
+
isEditable: PropTypes.bool,
|
|
248
|
+
position: PropTypes.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The row model of the row that the current cell belongs to.
|
|
252
|
+
*/
|
|
253
|
+
row: PropTypes.object.isRequired,
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The node of the row that the current cell belongs to.
|
|
257
|
+
*/
|
|
258
|
+
rowNode: PropTypes.object.isRequired,
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* the tabIndex value.
|
|
262
|
+
*/
|
|
263
|
+
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
264
|
+
value: PropTypes.any
|
|
118
265
|
} : void 0;
|
|
119
266
|
export { GridActionsCell };
|
|
120
267
|
export const renderActionsCell = params => /*#__PURE__*/_jsx(GridActionsCell, _extends({}, params));
|
|
@@ -8,8 +8,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
8
8
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
|
-
const GridActionsCellItem = props => {
|
|
11
|
+
const GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
13
12
|
const {
|
|
14
13
|
label,
|
|
15
14
|
icon,
|
|
@@ -26,7 +25,9 @@ const GridActionsCellItem = props => {
|
|
|
26
25
|
|
|
27
26
|
if (!showInMenu) {
|
|
28
27
|
return /*#__PURE__*/_jsx(IconButton, _extends({
|
|
28
|
+
ref: ref,
|
|
29
29
|
size: "small",
|
|
30
|
+
role: "menuitem",
|
|
30
31
|
"aria-label": label
|
|
31
32
|
}, other, {
|
|
32
33
|
onClick: handleClick,
|
|
@@ -36,14 +37,15 @@ const GridActionsCellItem = props => {
|
|
|
36
37
|
}));
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
return /*#__PURE__*/_jsxs(MenuItem, _extends({
|
|
40
|
+
return /*#__PURE__*/_jsxs(MenuItem, _extends({
|
|
41
|
+
ref: ref
|
|
42
|
+
}, other, {
|
|
40
43
|
onClick: onClick,
|
|
41
44
|
children: [icon && /*#__PURE__*/_jsx(ListItemIcon, {
|
|
42
45
|
children: icon
|
|
43
46
|
}), label]
|
|
44
47
|
}));
|
|
45
|
-
};
|
|
46
|
-
|
|
48
|
+
});
|
|
47
49
|
process.env.NODE_ENV !== "production" ? GridActionsCellItem.propTypes = {
|
|
48
50
|
// ----------------------------- Warning --------------------------------
|
|
49
51
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -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 = ["align", "children", "colIndex", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
3
|
+
const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
4
4
|
|
|
5
5
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
6
6
|
import * as React from 'react';
|
|
@@ -64,6 +64,7 @@ function GridCell(props) {
|
|
|
64
64
|
width,
|
|
65
65
|
className,
|
|
66
66
|
showRightBorder,
|
|
67
|
+
colSpan,
|
|
67
68
|
onClick,
|
|
68
69
|
onDoubleClick,
|
|
69
70
|
onMouseDown,
|
|
@@ -76,6 +77,7 @@ function GridCell(props) {
|
|
|
76
77
|
|
|
77
78
|
const valueToRender = formattedValue == null ? value : formattedValue;
|
|
78
79
|
const cellRef = React.useRef(null);
|
|
80
|
+
const focusElementRef = React.useRef(null);
|
|
79
81
|
const apiRef = useGridApiContext();
|
|
80
82
|
const rootProps = useGridRootProps();
|
|
81
83
|
const ownerState = {
|
|
@@ -126,7 +128,7 @@ function GridCell(props) {
|
|
|
126
128
|
|
|
127
129
|
if (cellRef.current && !cellRef.current.contains(doc.activeElement)) {
|
|
128
130
|
const focusableElement = cellRef.current.querySelector('[tabindex="0"]');
|
|
129
|
-
const elementToFocus = focusableElement || cellRef.current;
|
|
131
|
+
const elementToFocus = focusElementRef.current || focusableElement || cellRef.current;
|
|
130
132
|
|
|
131
133
|
if (doesSupportPreventScroll()) {
|
|
132
134
|
elementToFocus.focus({
|
|
@@ -160,6 +162,26 @@ function GridCell(props) {
|
|
|
160
162
|
};
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
const column = apiRef.current.getColumn(field);
|
|
166
|
+
const managesOwnFocus = column.type === 'actions';
|
|
167
|
+
|
|
168
|
+
const renderChildren = () => {
|
|
169
|
+
if (children == null) {
|
|
170
|
+
return /*#__PURE__*/_jsx("div", {
|
|
171
|
+
className: classes.content,
|
|
172
|
+
children: valueToRender?.toString()
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
|
|
177
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
178
|
+
focusElementRef
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return children;
|
|
183
|
+
};
|
|
184
|
+
|
|
163
185
|
return /*#__PURE__*/_jsx("div", _extends({
|
|
164
186
|
ref: cellRef,
|
|
165
187
|
className: clsx(className, classes.root),
|
|
@@ -167,8 +189,9 @@ function GridCell(props) {
|
|
|
167
189
|
"data-field": field,
|
|
168
190
|
"data-colindex": colIndex,
|
|
169
191
|
"aria-colindex": colIndex + 1,
|
|
192
|
+
"aria-colspan": colSpan,
|
|
170
193
|
style: style,
|
|
171
|
-
tabIndex: cellMode === 'view' || !isEditable ? tabIndex : -1,
|
|
194
|
+
tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
|
|
172
195
|
onClick: publish(GridEvents.cellClick, onClick),
|
|
173
196
|
onDoubleClick: publish(GridEvents.cellDoubleClick, onDoubleClick),
|
|
174
197
|
onMouseDown: publish(GridEvents.cellMouseDown, onMouseDown),
|
|
@@ -178,10 +201,7 @@ function GridCell(props) {
|
|
|
178
201
|
onDragOver: publish(GridEvents.cellDragOver, onDragOver)
|
|
179
202
|
}, other, {
|
|
180
203
|
onFocus: handleFocus,
|
|
181
|
-
children:
|
|
182
|
-
className: classes.content,
|
|
183
|
-
children: valueToRender?.toString()
|
|
184
|
-
})
|
|
204
|
+
children: renderChildren()
|
|
185
205
|
}));
|
|
186
206
|
}
|
|
187
207
|
|
|
@@ -195,6 +215,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
195
215
|
children: PropTypes.node,
|
|
196
216
|
className: PropTypes.string,
|
|
197
217
|
colIndex: PropTypes.number.isRequired,
|
|
218
|
+
colSpan: PropTypes.number,
|
|
198
219
|
field: PropTypes.string.isRequired,
|
|
199
220
|
formattedValue: PropTypes.any,
|
|
200
221
|
hasFocus: PropTypes.bool,
|
|
@@ -118,7 +118,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
118
118
|
/**
|
|
119
119
|
* The cell value formatted with the column valueFormatter.
|
|
120
120
|
*/
|
|
121
|
-
formattedValue: PropTypes.any
|
|
121
|
+
formattedValue: PropTypes.any,
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Get the cell value of a row and field.
|
|
@@ -9,15 +9,19 @@ import { isEscapeKey } from '../../utils/keyboardUtils';
|
|
|
9
9
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
10
10
|
import { GridEditModes } from '../../models/gridEditRowModel';
|
|
11
11
|
import { GridEvents } from '../../models/events/gridEvents';
|
|
12
|
+
import { getValueFromValueOptions } from '../panel/filterPanel/filterPanelUtils';
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
|
|
14
|
-
const renderSingleSelectOptions = option =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const renderSingleSelectOptions = (option, OptionComponent) => {
|
|
16
|
+
const isOptionTypeObject = typeof option === 'object';
|
|
17
|
+
const key = isOptionTypeObject ? option.value : option;
|
|
18
|
+
const value = isOptionTypeObject ? option.value : option;
|
|
19
|
+
const content = isOptionTypeObject ? option.label : option;
|
|
20
|
+
return /*#__PURE__*/_jsx(OptionComponent, {
|
|
21
|
+
value: value,
|
|
22
|
+
children: content
|
|
23
|
+
}, key);
|
|
24
|
+
};
|
|
21
25
|
|
|
22
26
|
function GridEditSingleSelectCell(props) {
|
|
23
27
|
const {
|
|
@@ -36,6 +40,8 @@ function GridEditSingleSelectCell(props) {
|
|
|
36
40
|
const inputRef = React.useRef();
|
|
37
41
|
const rootProps = useGridRootProps();
|
|
38
42
|
const [open, setOpen] = React.useState(rootProps.editMode === 'cell');
|
|
43
|
+
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
44
|
+
const isSelectNative = baseSelectProps.native ?? false;
|
|
39
45
|
let valueOptionsFormatted;
|
|
40
46
|
|
|
41
47
|
if (typeof colDef.valueOptions === 'function') {
|
|
@@ -68,11 +74,13 @@ function GridEditSingleSelectCell(props) {
|
|
|
68
74
|
|
|
69
75
|
const handleChange = async event => {
|
|
70
76
|
setOpen(false);
|
|
71
|
-
const target = event.target;
|
|
77
|
+
const target = event.target; // NativeSelect casts the value to a string.
|
|
78
|
+
|
|
79
|
+
const formattedTargetValue = getValueFromValueOptions(target.value, valueOptionsFormatted);
|
|
72
80
|
const isValid = await api.setEditCellValue({
|
|
73
81
|
id,
|
|
74
82
|
field,
|
|
75
|
-
value:
|
|
83
|
+
value: formattedTargetValue
|
|
76
84
|
}, event);
|
|
77
85
|
|
|
78
86
|
if (rootProps.experimentalFeatures?.newEditingApi) {
|
|
@@ -139,9 +147,10 @@ function GridEditSingleSelectCell(props) {
|
|
|
139
147
|
onClose: handleClose
|
|
140
148
|
},
|
|
141
149
|
error: error,
|
|
150
|
+
native: isSelectNative,
|
|
142
151
|
fullWidth: true
|
|
143
152
|
}, other, rootProps.componentsProps?.baseSelect, {
|
|
144
|
-
children: valueOptionsFormatted.map(renderSingleSelectOptions)
|
|
153
|
+
children: valueOptionsFormatted.map(valueOptions => renderSingleSelectOptions(valueOptions, isSelectNative ? 'option' : MenuItem))
|
|
145
154
|
}));
|
|
146
155
|
}
|
|
147
156
|
|
|
@@ -175,7 +184,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
175
184
|
/**
|
|
176
185
|
* The cell value formatted with the column valueFormatter.
|
|
177
186
|
*/
|
|
178
|
-
formattedValue: PropTypes.any
|
|
187
|
+
formattedValue: PropTypes.any,
|
|
179
188
|
|
|
180
189
|
/**
|
|
181
190
|
* Get the cell value of a row and field.
|
|
@@ -156,14 +156,11 @@ function GridColumnHeaderItem(props) {
|
|
|
156
156
|
|
|
157
157
|
if (hasFocus && !columnMenuState.open) {
|
|
158
158
|
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
} else {
|
|
163
|
-
headerCellRef.current.focus();
|
|
164
|
-
}
|
|
159
|
+
const elementToFocus = focusableElement || headerCellRef.current;
|
|
160
|
+
elementToFocus?.focus();
|
|
161
|
+
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
165
162
|
}
|
|
166
|
-
});
|
|
163
|
+
}, [apiRef, hasFocus]);
|
|
167
164
|
const headerClassName = typeof column.headerClassName === 'function' ? column.headerClassName({
|
|
168
165
|
field: column.field,
|
|
169
166
|
colDef: column
|
|
@@ -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 = ["
|
|
3
|
+
const _excluded = ["className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|