@mui/x-data-grid 6.1.0 → 6.2.1
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 +101 -1
- package/components/GridHeader.d.ts +2 -2
- package/components/GridHeader.js +4 -6
- package/components/GridPagination.d.ts +2 -2
- package/components/base/GridBody.d.ts +0 -1
- package/components/base/GridBody.js +32 -15
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridMainContainer.d.ts +3 -1
- package/components/containers/GridMainContainer.js +3 -2
- package/components/containers/GridRoot.js +0 -5
- package/components/index.d.ts +0 -1
- package/components/index.js +0 -1
- package/components/panel/GridColumnsPanel.js +3 -2
- package/components/panel/GridPanel.d.ts +2 -2
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/components/panel/filterPanel/GridFilterPanel.js +5 -2
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
- package/hooks/features/dimensions/useGridDimensions.js +49 -10
- package/hooks/features/export/useGridPrintExport.js +3 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +37 -16
- package/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
- package/index.js +1 -1
- package/joy/index.d.ts +2 -0
- package/joy/index.js +2 -0
- package/joy/joySlots.d.ts +4 -0
- package/joy/joySlots.js +71 -0
- package/joy/package.json +6 -0
- package/legacy/components/GridHeader.js +4 -6
- package/legacy/components/base/GridBody.js +33 -16
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/legacy/components/containers/GridMainContainer.js +3 -2
- package/legacy/components/containers/GridRoot.js +0 -5
- package/legacy/components/index.js +0 -1
- package/legacy/components/panel/GridColumnsPanel.js +3 -2
- package/legacy/components/panel/GridPanel.js +2 -1
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +5 -2
- package/legacy/hooks/features/dimensions/useGridDimensions.js +55 -12
- package/legacy/hooks/features/export/useGridPrintExport.js +3 -1
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +12 -6
- package/legacy/index.js +1 -1
- package/legacy/joy/index.js +2 -0
- package/legacy/joy/joySlots.js +73 -0
- package/legacy/locales/frFR.js +7 -9
- package/legacy/locales/urPK.js +6 -6
- package/legacy/utils/utils.js +1 -1
- package/locales/frFR.js +7 -9
- package/locales/urPK.js +6 -6
- package/material/index.d.ts +1 -1
- package/models/gridSlotsComponent.d.ts +2 -2
- package/modern/components/GridHeader.js +4 -6
- package/modern/components/base/GridBody.js +32 -15
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/modern/components/containers/GridMainContainer.js +3 -2
- package/modern/components/containers/GridRoot.js +0 -5
- package/modern/components/index.js +0 -1
- package/modern/components/panel/GridColumnsPanel.js +3 -2
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
- package/modern/components/panel/filterPanel/GridFilterPanel.js +5 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +48 -10
- package/modern/hooks/features/export/useGridPrintExport.js +3 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
- package/modern/index.js +1 -1
- package/modern/joy/index.js +2 -0
- package/modern/joy/joySlots.js +71 -0
- package/modern/locales/frFR.js +7 -9
- package/modern/locales/urPK.js +6 -6
- package/modern/utils/utils.js +1 -1
- package/node/components/GridHeader.js +5 -8
- package/node/components/base/GridBody.js +32 -15
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/containers/GridMainContainer.js +5 -3
- package/node/components/containers/GridRoot.js +0 -5
- package/node/components/index.js +0 -11
- package/node/components/panel/GridColumnsPanel.js +3 -2
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
- package/node/components/panel/filterPanel/GridFilterPanel.js +5 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +47 -9
- package/node/hooks/features/export/useGridPrintExport.js +3 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -5
- package/node/index.js +1 -1
- package/node/joy/index.js +13 -0
- package/node/joy/joySlots.js +79 -0
- package/node/locales/frFR.js +7 -9
- package/node/locales/urPK.js +6 -6
- package/node/utils/utils.js +1 -1
- package/package.json +1 -1
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +1 -1
- package/components/GridAutoSizer.d.ts +0 -44
- package/components/GridAutoSizer.js +0 -126
- package/legacy/components/GridAutoSizer.js +0 -132
- package/modern/components/GridAutoSizer.js +0 -125
- package/node/components/GridAutoSizer.js +0 -132
|
@@ -8,6 +8,7 @@ import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
|
8
8
|
import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
9
9
|
import { createElement as _createElement } from "react";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const renderSingleSelectOptions = ({
|
|
12
13
|
column: {
|
|
13
14
|
valueOptions,
|
|
@@ -45,10 +46,9 @@ function GridFilterInputSingleSelect(props) {
|
|
|
45
46
|
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
46
47
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
47
48
|
const id = useId();
|
|
49
|
+
const labelId = useId();
|
|
48
50
|
const rootProps = useGridRootProps();
|
|
49
|
-
const
|
|
50
|
-
const isSelectNative = baseSelectProps.native ?? true;
|
|
51
|
-
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
51
|
+
const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? true;
|
|
52
52
|
let resolvedColumn = null;
|
|
53
53
|
if (item.field) {
|
|
54
54
|
const column = apiRef.current.getColumn(item.field);
|
|
@@ -99,33 +99,37 @@ function GridFilterInputSingleSelect(props) {
|
|
|
99
99
|
if (!isSingleSelectColDef(resolvedColumn)) {
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
const label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
103
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
104
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
|
|
105
|
+
id: labelId,
|
|
106
|
+
shrink: true,
|
|
107
|
+
variant: "standard",
|
|
108
|
+
children: label
|
|
109
|
+
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
|
|
110
|
+
id: id,
|
|
111
|
+
label: label,
|
|
112
|
+
labelId: labelId,
|
|
113
|
+
value: filterValueState,
|
|
114
|
+
onChange: onFilterChange,
|
|
115
|
+
variant: "standard",
|
|
116
|
+
type: type || 'text',
|
|
117
|
+
inputProps: {
|
|
118
|
+
ref: focusElementRef,
|
|
119
|
+
placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
120
|
+
},
|
|
117
121
|
native: isSelectNative
|
|
118
|
-
}, rootProps.slotProps?.baseSelect
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
})
|
|
128
|
-
})
|
|
122
|
+
}, others, rootProps.slotProps?.baseSelect, {
|
|
123
|
+
children: renderSingleSelectOptions({
|
|
124
|
+
column: resolvedColumn,
|
|
125
|
+
OptionComponent: rootProps.slots.baseSelectOption,
|
|
126
|
+
getOptionLabel,
|
|
127
|
+
getOptionValue,
|
|
128
|
+
isSelectNative,
|
|
129
|
+
baseSelectOptionProps: rootProps.slotProps?.baseSelectOption
|
|
130
|
+
})
|
|
131
|
+
}))]
|
|
132
|
+
});
|
|
129
133
|
}
|
|
130
134
|
process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
|
|
131
135
|
// ----------------------------- Warning --------------------------------
|
|
@@ -26,6 +26,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
26
26
|
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
27
27
|
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
28
28
|
const lastFilterRef = React.useRef(null);
|
|
29
|
+
const placeholderFilter = React.useRef(null);
|
|
29
30
|
const {
|
|
30
31
|
logicOperators = [GridLogicOperator.And, GridLogicOperator.Or],
|
|
31
32
|
columnsSort,
|
|
@@ -89,8 +90,10 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
89
90
|
if (filterModel.items.length) {
|
|
90
91
|
return filterModel.items;
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
if (!placeholderFilter.current) {
|
|
94
|
+
placeholderFilter.current = getDefaultFilter();
|
|
95
|
+
}
|
|
96
|
+
return placeholderFilter.current ? [placeholderFilter.current] : [];
|
|
94
97
|
}, [filterModel.items, getDefaultFilter]);
|
|
95
98
|
const hasMultipleFilters = items.length > 1;
|
|
96
99
|
const addNewFilter = () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
2
|
+
import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
|
|
3
3
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
4
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
5
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
@@ -10,6 +10,7 @@ import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
|
10
10
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
11
11
|
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
12
12
|
import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
|
|
13
|
+
import { gridClasses } from '../../../constants/gridClasses';
|
|
13
14
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
14
15
|
const hasScroll = ({
|
|
15
16
|
content,
|
|
@@ -113,10 +114,20 @@ export function useGridDimensions(apiRef, props) {
|
|
|
113
114
|
apiRef.current.publishEvent('viewportInnerSizeChange', newFullDimensions.viewportInnerSize);
|
|
114
115
|
}
|
|
115
116
|
}, [apiRef, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, totalHeaderHeight]);
|
|
117
|
+
const [savedSize, setSavedSize] = React.useState();
|
|
118
|
+
const debouncedSetSavedSize = React.useMemo(() => debounce(setSavedSize, 60), []);
|
|
119
|
+
const previousSize = React.useRef();
|
|
120
|
+
useEnhancedEffect(() => {
|
|
121
|
+
if (savedSize) {
|
|
122
|
+
updateGridDimensionsRef();
|
|
123
|
+
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
124
|
+
}
|
|
125
|
+
}, [apiRef, savedSize, updateGridDimensionsRef]);
|
|
126
|
+
|
|
127
|
+
// This is the function called by apiRef.current.resize()
|
|
116
128
|
const resize = React.useCallback(() => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, [apiRef, updateGridDimensionsRef]);
|
|
129
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
130
|
+
}, [apiRef]);
|
|
120
131
|
const getRootDimensions = React.useCallback(() => fullDimensionsRef.current, []);
|
|
121
132
|
const getViewportPageSize = React.useCallback(() => {
|
|
122
133
|
const dimensions = apiRef.current.getRootDimensions();
|
|
@@ -138,17 +149,44 @@ export function useGridDimensions(apiRef, props) {
|
|
|
138
149
|
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
139
150
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
140
151
|
}, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
|
|
152
|
+
const computeSizeAndPublishResizeEvent = React.useCallback(() => {
|
|
153
|
+
const rootEl = apiRef.current.rootElementRef?.current;
|
|
154
|
+
const mainEl = rootEl?.querySelector(`.${gridClasses.main}`);
|
|
155
|
+
if (!mainEl) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const height = mainEl.offsetHeight || 0;
|
|
159
|
+
const width = mainEl.offsetWidth || 0;
|
|
160
|
+
const win = ownerWindow(mainEl);
|
|
161
|
+
const computedStyle = win.getComputedStyle(mainEl);
|
|
162
|
+
const paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
163
|
+
const paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
|
|
164
|
+
const paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
|
|
165
|
+
const paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
|
|
166
|
+
const newHeight = height - paddingTop - paddingBottom;
|
|
167
|
+
const newWidth = width - paddingLeft - paddingRight;
|
|
168
|
+
const hasHeightChanged = newHeight !== previousSize.current?.height;
|
|
169
|
+
const hasWidthChanged = newWidth !== previousSize.current?.width;
|
|
170
|
+
if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
|
|
171
|
+
const size = {
|
|
172
|
+
width: newWidth,
|
|
173
|
+
height: newHeight
|
|
174
|
+
};
|
|
175
|
+
apiRef.current.publishEvent('resize', size);
|
|
176
|
+
previousSize.current = size;
|
|
177
|
+
}
|
|
178
|
+
}, [apiRef]);
|
|
141
179
|
const dimensionsApi = {
|
|
142
180
|
resize,
|
|
143
181
|
getRootDimensions
|
|
144
182
|
};
|
|
145
183
|
const dimensionsPrivateApi = {
|
|
146
184
|
getViewportPageSize,
|
|
147
|
-
updateGridDimensionsRef
|
|
185
|
+
updateGridDimensionsRef,
|
|
186
|
+
computeSizeAndPublishResizeEvent
|
|
148
187
|
};
|
|
149
188
|
useGridApiMethod(apiRef, dimensionsApi, 'public');
|
|
150
189
|
useGridApiMethod(apiRef, dimensionsPrivateApi, 'private');
|
|
151
|
-
const debounceResize = React.useMemo(() => debounce(resize, 60), [resize]);
|
|
152
190
|
const isFirstSizing = React.useRef(true);
|
|
153
191
|
const handleResize = React.useCallback(size => {
|
|
154
192
|
rootDimensionsRef.current = size;
|
|
@@ -165,18 +203,18 @@ export function useGridDimensions(apiRef, props) {
|
|
|
165
203
|
}
|
|
166
204
|
if (isTestEnvironment) {
|
|
167
205
|
// We don't need to debounce the resize for tests.
|
|
168
|
-
|
|
206
|
+
setSavedSize(size);
|
|
169
207
|
isFirstSizing.current = false;
|
|
170
208
|
return;
|
|
171
209
|
}
|
|
172
210
|
if (isFirstSizing.current) {
|
|
173
211
|
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
174
|
-
|
|
212
|
+
setSavedSize(size);
|
|
175
213
|
isFirstSizing.current = false;
|
|
176
214
|
return;
|
|
177
215
|
}
|
|
178
|
-
|
|
179
|
-
}, [props.autoHeight,
|
|
216
|
+
debouncedSetSavedSize(size);
|
|
217
|
+
}, [props.autoHeight, debouncedSetSavedSize, logger]);
|
|
180
218
|
useEnhancedEffect(() => updateGridDimensionsRef(), [updateGridDimensionsRef]);
|
|
181
219
|
useGridApiOptionHandler(apiRef, 'sortedRowsSet', updateGridDimensionsRef);
|
|
182
220
|
useGridApiOptionHandler(apiRef, 'paginationModelChange', updateGridDimensionsRef);
|
|
@@ -121,7 +121,9 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
121
121
|
printDoc.body.classList.add(...normalizeOptions.bodyClassName.split(' '));
|
|
122
122
|
}
|
|
123
123
|
if (normalizeOptions.copyStyles) {
|
|
124
|
-
const
|
|
124
|
+
const rootCandidate = gridRootElement.getRootNode();
|
|
125
|
+
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
|
|
126
|
+
const headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
|
|
125
127
|
for (let i = 0; i < headStyleElements.length; i += 1) {
|
|
126
128
|
const node = headStyleElements[i];
|
|
127
129
|
if (node.tagName === 'STYLE') {
|
|
@@ -11,7 +11,7 @@ import { gridExpandedSortedRowIdsSelector } from '../filter/gridFilterSelector';
|
|
|
11
11
|
import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
|
|
12
12
|
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
13
13
|
import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
|
|
14
|
-
import {
|
|
14
|
+
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
15
15
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
16
16
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
17
17
|
const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
@@ -58,8 +58,6 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
58
58
|
checkboxSelection,
|
|
59
59
|
disableMultipleRowSelection,
|
|
60
60
|
disableRowSelectionOnClick,
|
|
61
|
-
pagination,
|
|
62
|
-
paginationMode,
|
|
63
61
|
isRowSelectable: propIsRowSelectable
|
|
64
62
|
} = props;
|
|
65
63
|
const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
@@ -375,32 +373,13 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
375
373
|
}
|
|
376
374
|
}, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
|
|
377
375
|
React.useEffect(() => {
|
|
378
|
-
if (!props.rowSelection) {
|
|
376
|
+
if (!props.rowSelection || isStateControlled) {
|
|
379
377
|
return;
|
|
380
378
|
}
|
|
381
379
|
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
382
380
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
} = getVisibleRows(apiRef, {
|
|
386
|
-
pagination,
|
|
387
|
-
paginationMode
|
|
388
|
-
});
|
|
389
|
-
const currentPageRowsLookup = currentPageRows.reduce((acc, {
|
|
390
|
-
id
|
|
391
|
-
}) => {
|
|
392
|
-
acc[id] = true;
|
|
393
|
-
return acc;
|
|
394
|
-
}, {});
|
|
395
|
-
const firstSelectableRow = currentSelection.find(id => {
|
|
396
|
-
let isSelectable = true;
|
|
397
|
-
if (isRowSelectable) {
|
|
398
|
-
isSelectable = isRowSelectable(id);
|
|
399
|
-
}
|
|
400
|
-
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
|
|
381
|
+
// See https://github.com/mui/mui-x/issues/8455
|
|
382
|
+
apiRef.current.setRowSelectionModel([]);
|
|
404
383
|
}
|
|
405
|
-
}, [apiRef, canHaveMultipleSelection, checkboxSelection,
|
|
384
|
+
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
406
385
|
};
|
|
@@ -174,11 +174,13 @@ export const useGridVirtualScroller = props => {
|
|
|
174
174
|
height: rootRef.current.clientHeight
|
|
175
175
|
});
|
|
176
176
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
177
|
-
const handleResize = React.useCallback(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
const handleResize = React.useCallback(() => {
|
|
178
|
+
if (rootRef.current) {
|
|
179
|
+
setContainerDimensions({
|
|
180
|
+
width: rootRef.current.clientWidth,
|
|
181
|
+
height: rootRef.current.clientHeight
|
|
182
|
+
});
|
|
183
|
+
}
|
|
182
184
|
}, []);
|
|
183
185
|
useGridApiEventHandler(apiRef, 'debouncedResize', handleResize);
|
|
184
186
|
const updateRenderZonePosition = React.useCallback(nextRenderContext => {
|
|
@@ -304,6 +306,7 @@ export const useGridVirtualScroller = props => {
|
|
|
304
306
|
renderContext
|
|
305
307
|
}) => {
|
|
306
308
|
const {
|
|
309
|
+
onRowRender,
|
|
307
310
|
renderContext: nextRenderContext,
|
|
308
311
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
309
312
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
@@ -387,6 +390,9 @@ export const useGridVirtualScroller = props => {
|
|
|
387
390
|
} else {
|
|
388
391
|
isSelected = apiRef.current.isRowSelectable(id);
|
|
389
392
|
}
|
|
393
|
+
if (onRowRender) {
|
|
394
|
+
onRowRender(id);
|
|
395
|
+
}
|
|
390
396
|
const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
|
|
391
397
|
let tabbableCell = null;
|
|
392
398
|
if (cellTabIndex !== null && cellTabIndex.id === id) {
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["touchRippleRef", "inputProps", "onChange", "color", "size", "checked", "sx", "value", "inputRef"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import JoyCheckbox from '@mui/joy/Checkbox';
|
|
6
|
+
import JoyInput from '@mui/joy/Input';
|
|
7
|
+
import JoyFormControl from '@mui/joy/FormControl';
|
|
8
|
+
import JoyFormLabel from '@mui/joy/FormLabel';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
inputProps,
|
|
14
|
+
onChange,
|
|
15
|
+
checked,
|
|
16
|
+
inputRef
|
|
17
|
+
} = _ref,
|
|
18
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
|
+
return /*#__PURE__*/_jsx(JoyCheckbox, _extends({}, props, {
|
|
20
|
+
slotProps: {
|
|
21
|
+
input: _extends({}, inputProps, {
|
|
22
|
+
ref: inputRef
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
ref: ref,
|
|
26
|
+
checked: checked,
|
|
27
|
+
onChange: onChange
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
const TextField = /*#__PURE__*/React.forwardRef(({
|
|
31
|
+
onChange,
|
|
32
|
+
label,
|
|
33
|
+
placeholder,
|
|
34
|
+
value,
|
|
35
|
+
inputRef,
|
|
36
|
+
type
|
|
37
|
+
}, ref) => {
|
|
38
|
+
return /*#__PURE__*/_jsxs(JoyFormControl, {
|
|
39
|
+
ref: ref,
|
|
40
|
+
children: [/*#__PURE__*/_jsx(JoyFormLabel, {
|
|
41
|
+
sx: {
|
|
42
|
+
fontSize: 12
|
|
43
|
+
},
|
|
44
|
+
children: label
|
|
45
|
+
}), /*#__PURE__*/_jsx(JoyInput, {
|
|
46
|
+
type: type,
|
|
47
|
+
value: value,
|
|
48
|
+
onChange: onChange,
|
|
49
|
+
placeholder: placeholder,
|
|
50
|
+
size: "sm",
|
|
51
|
+
slotProps: {
|
|
52
|
+
input: {
|
|
53
|
+
ref: inputRef
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
const joySlots = {
|
|
60
|
+
baseCheckbox: Checkbox,
|
|
61
|
+
baseTextField: TextField
|
|
62
|
+
// BaseFormControl: MUIFormControl,
|
|
63
|
+
// BaseSelect: MUISelect,
|
|
64
|
+
// BaseSwitch: MUISwitch,
|
|
65
|
+
// BaseButton: MUIButton,
|
|
66
|
+
// BaseIconButton: MUIIconButton,
|
|
67
|
+
// BaseTooltip: MUITooltip,
|
|
68
|
+
// BasePopper: MUIPopper,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default joySlots;
|
package/modern/locales/frFR.js
CHANGED
|
@@ -111,15 +111,13 @@ const frFRGrid = {
|
|
|
111
111
|
expandDetailPanel: 'Afficher',
|
|
112
112
|
collapseDetailPanel: 'Masquer',
|
|
113
113
|
// Row reordering text
|
|
114
|
-
rowReorderingHeaderName: 'Positionnement des lignes'
|
|
115
|
-
|
|
114
|
+
rowReorderingHeaderName: 'Positionnement des lignes',
|
|
116
115
|
// Aggregation
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
aggregationMenuItemHeader: 'Agrégation',
|
|
117
|
+
aggregationFunctionLabelSum: 'Somme',
|
|
118
|
+
aggregationFunctionLabelAvg: 'Moyenne',
|
|
119
|
+
aggregationFunctionLabelMin: 'Minimum',
|
|
120
|
+
aggregationFunctionLabelMax: 'Maximum',
|
|
121
|
+
aggregationFunctionLabelSize: "Nombre d'éléments"
|
|
123
122
|
};
|
|
124
|
-
|
|
125
123
|
export const frFR = getGridLocalization(frFRGrid, frFRCore);
|
package/modern/locales/urPK.js
CHANGED
|
@@ -113,11 +113,11 @@ const urPKGrid = {
|
|
|
113
113
|
// Row reordering text
|
|
114
114
|
rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
|
|
115
115
|
// Aggregation
|
|
116
|
-
aggregationMenuItemHeader: '
|
|
117
|
-
aggregationFunctionLabelSum: '
|
|
118
|
-
aggregationFunctionLabelAvg: '
|
|
119
|
-
aggregationFunctionLabelMin: '
|
|
120
|
-
aggregationFunctionLabelMax: '
|
|
121
|
-
aggregationFunctionLabelSize: '
|
|
116
|
+
aggregationMenuItemHeader: 'ایگریگیشن',
|
|
117
|
+
aggregationFunctionLabelSum: 'کل',
|
|
118
|
+
aggregationFunctionLabelAvg: 'اوسط',
|
|
119
|
+
aggregationFunctionLabelMin: 'کم از کم',
|
|
120
|
+
aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
|
|
121
|
+
aggregationFunctionLabelSize: 'سائز'
|
|
122
122
|
};
|
|
123
123
|
export const urPK = getGridLocalization(urPKGrid, urPKCore);
|
package/modern/utils/utils.js
CHANGED
|
@@ -4,19 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.GridHeader =
|
|
7
|
+
exports.GridHeader = GridHeader;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _useGridRootProps = require("../hooks/utils/useGridRootProps");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
|
|
14
|
+
function GridHeader() {
|
|
15
15
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
16
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
17
|
-
ref: ref
|
|
18
|
-
}, props, {
|
|
16
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
19
17
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.preferencesPanel, (0, _extends2.default)({}, rootProps.slotProps?.preferencesPanel)), rootProps.slots.toolbar && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.toolbar, (0, _extends2.default)({}, rootProps.slotProps?.toolbar))]
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
exports.GridHeader = GridHeader;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -8,10 +8,10 @@ exports.GridBody = GridBody;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _utils = require("@mui/utils");
|
|
11
12
|
var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
|
|
12
13
|
var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
13
14
|
var _GridMainContainer = require("../containers/GridMainContainer");
|
|
14
|
-
var _GridAutoSizer = require("../GridAutoSizer");
|
|
15
15
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
16
16
|
var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
|
|
17
17
|
var _gridFilterSelector = require("../../hooks/features/filter/gridFilterSelector");
|
|
@@ -25,12 +25,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
26
|
function GridBody(props) {
|
|
27
27
|
const {
|
|
28
|
-
children,
|
|
29
28
|
VirtualScrollerComponent,
|
|
30
29
|
ColumnHeadersProps
|
|
31
30
|
} = props;
|
|
32
31
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
33
32
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
33
|
+
const rootRef = React.useRef(null);
|
|
34
34
|
const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
|
|
35
35
|
const filterColumnLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterActiveItemsLookupSelector);
|
|
36
36
|
const sortColumnLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortColumnLookupSelector);
|
|
@@ -47,6 +47,24 @@ function GridBody(props) {
|
|
|
47
47
|
const columnGroupsHeaderStructure = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderStructureSelector);
|
|
48
48
|
const hasOtherElementInTabSequence = !(columnGroupHeaderTabIndexState === null && columnHeaderTabIndexState === null && cellTabIndexState === null);
|
|
49
49
|
const [isVirtualizationDisabled, setIsVirtualizationDisabled] = React.useState(rootProps.disableVirtualization);
|
|
50
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
51
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
52
|
+
const elementToObserve = rootRef.current;
|
|
53
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
54
|
+
return () => {};
|
|
55
|
+
}
|
|
56
|
+
const observer = new ResizeObserver(() => {
|
|
57
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
58
|
+
});
|
|
59
|
+
if (elementToObserve) {
|
|
60
|
+
observer.observe(elementToObserve);
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
if (elementToObserve) {
|
|
64
|
+
observer.unobserve(elementToObserve);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}, [apiRef]);
|
|
50
68
|
const disableVirtualization = React.useCallback(() => {
|
|
51
69
|
setIsVirtualizationDisabled(true);
|
|
52
70
|
}, []);
|
|
@@ -73,10 +91,9 @@ function GridBody(props) {
|
|
|
73
91
|
columnHeadersElementRef: columnHeadersRef,
|
|
74
92
|
virtualScrollerRef
|
|
75
93
|
});
|
|
76
|
-
const
|
|
77
|
-
apiRef.current.publishEvent('resize', size);
|
|
78
|
-
}, [apiRef]);
|
|
94
|
+
const hasDimensions = !!apiRef.current.getRootDimensions();
|
|
79
95
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridMainContainer.GridMainContainer, {
|
|
96
|
+
ref: rootRef,
|
|
80
97
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnHeaders, (0, _extends2.default)({
|
|
81
98
|
ref: columnsContainerRef,
|
|
82
99
|
innerRef: columnHeadersRef,
|
|
@@ -94,15 +111,16 @@ function GridBody(props) {
|
|
|
94
111
|
columnVisibility: columnVisibility,
|
|
95
112
|
columnGroupsHeaderStructure: columnGroupsHeaderStructure,
|
|
96
113
|
hasOtherElementInTabSequence: hasOtherElementInTabSequence
|
|
97
|
-
}, ColumnHeadersProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
}, ColumnHeadersProps)), hasDimensions && /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerComponent
|
|
115
|
+
// The content is only rendered after dimensions are computed because
|
|
116
|
+
// the lazy-loading hook is listening to `renderedRowsIntervalChange`,
|
|
117
|
+
// but only does something if the dimensions are also available.
|
|
118
|
+
// If this event is published while dimensions haven't been computed,
|
|
119
|
+
// the `onFetchRows` prop won't be called during mount.
|
|
120
|
+
, {
|
|
121
|
+
ref: virtualScrollerRef,
|
|
122
|
+
disableVirtualization: isVirtualizationDisabled
|
|
123
|
+
})]
|
|
106
124
|
});
|
|
107
125
|
}
|
|
108
126
|
process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
@@ -110,7 +128,6 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
|
110
128
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
111
129
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
112
130
|
// ----------------------------------------------------------------------
|
|
113
|
-
children: _propTypes.default.node,
|
|
114
131
|
ColumnHeadersProps: _propTypes.default.object,
|
|
115
132
|
VirtualScrollerComponent: _propTypes.default.elementType.isRequired
|
|
116
133
|
} : void 0;
|
|
@@ -44,7 +44,7 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
44
44
|
};
|
|
45
45
|
const classes = useUtilityClasses(ownerState);
|
|
46
46
|
const checkboxElement = React.useRef(null);
|
|
47
|
-
const rippleRef = React.useRef();
|
|
47
|
+
const rippleRef = React.useRef(null);
|
|
48
48
|
const handleRef = (0, _utils.unstable_useForkRef)(checkboxElement, ref);
|
|
49
49
|
const element = apiRef.current.getCellElement(id, field);
|
|
50
50
|
const handleChange = event => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.GridMainContainer =
|
|
6
|
+
exports.GridMainContainer = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _utils = require("@mui/utils");
|
|
9
9
|
var _system = require("@mui/system");
|
|
@@ -32,12 +32,14 @@ const GridMainContainerRoot = (0, _system.styled)('div', {
|
|
|
32
32
|
flexDirection: 'column',
|
|
33
33
|
overflow: 'hidden'
|
|
34
34
|
}));
|
|
35
|
-
|
|
35
|
+
const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
36
36
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
37
37
|
const classes = useUtilityClasses(rootProps);
|
|
38
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridMainContainerRoot, {
|
|
39
|
+
ref: ref,
|
|
39
40
|
className: classes.root,
|
|
40
41
|
ownerState: rootProps,
|
|
41
42
|
children: props.children
|
|
42
43
|
});
|
|
43
|
-
}
|
|
44
|
+
});
|
|
45
|
+
exports.GridMainContainer = GridMainContainer;
|
|
@@ -63,11 +63,6 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
63
63
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
64
64
|
setMountedState(true);
|
|
65
65
|
}, []);
|
|
66
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
67
|
-
if (mountedState) {
|
|
68
|
-
apiRef.current.updateGridDimensionsRef();
|
|
69
|
-
}
|
|
70
|
-
}, [apiRef, mountedState]);
|
|
71
66
|
if (!mountedState) {
|
|
72
67
|
return null;
|
|
73
68
|
}
|
package/node/components/index.js
CHANGED
|
@@ -113,17 +113,6 @@ Object.keys(_GridApiContext).forEach(function (key) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
var _GridAutoSizer = require("./GridAutoSizer");
|
|
117
|
-
Object.keys(_GridAutoSizer).forEach(function (key) {
|
|
118
|
-
if (key === "default" || key === "__esModule") return;
|
|
119
|
-
if (key in exports && exports[key] === _GridAutoSizer[key]) return;
|
|
120
|
-
Object.defineProperty(exports, key, {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function () {
|
|
123
|
-
return _GridAutoSizer[key];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
116
|
var _GridFooter = require("./GridFooter");
|
|
128
117
|
Object.keys(_GridFooter).forEach(function (key) {
|
|
129
118
|
if (key === "default" || key === "__esModule") return;
|