@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
|
@@ -102,8 +102,9 @@ function GridColumnsPanel(props) {
|
|
|
102
102
|
const toggleAllColumns = React.useCallback(isVisible => {
|
|
103
103
|
const currentModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
104
104
|
const newModel = (0, _extends2.default)({}, currentModel);
|
|
105
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
105
106
|
columns.forEach(col => {
|
|
106
|
-
if (col.hideable) {
|
|
107
|
+
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
107
108
|
if (isVisible) {
|
|
108
109
|
// delete the key from the model instead of setting it to `true`
|
|
109
110
|
delete newModel[col.field];
|
|
@@ -113,7 +114,7 @@ function GridColumnsPanel(props) {
|
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
116
|
-
}, [apiRef, columns]);
|
|
117
|
+
}, [apiRef, columns, getTogglableColumns]);
|
|
117
118
|
const handleSearchValueChange = React.useCallback(event => {
|
|
118
119
|
setSearchValue(event.target.value);
|
|
119
120
|
}, []);
|
|
@@ -126,5 +126,6 @@ process.env.NODE_ENV !== "production" ? GridPanel.propTypes = {
|
|
|
126
126
|
/**
|
|
127
127
|
* If `true`, the component is shown.
|
|
128
128
|
*/
|
|
129
|
-
open: _propTypes.default.bool.isRequired
|
|
129
|
+
open: _propTypes.default.bool.isRequired,
|
|
130
|
+
ownerState: _propTypes.default.object
|
|
130
131
|
} : void 0;
|
|
@@ -8,6 +8,7 @@ exports.GridFilterInputBoolean = GridFilterInputBoolean;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _utils = require("@mui/utils");
|
|
11
12
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
|
|
@@ -23,6 +24,8 @@ function GridFilterInputBoolean(props) {
|
|
|
23
24
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
24
25
|
const [filterValueState, setFilterValueState] = React.useState(item.value || '');
|
|
25
26
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
27
|
+
const labelId = (0, _utils.unstable_useId)();
|
|
28
|
+
const selectId = (0, _utils.unstable_useId)();
|
|
26
29
|
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
27
30
|
const isSelectNative = baseSelectProps.native ?? true;
|
|
28
31
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
@@ -36,34 +39,39 @@ function GridFilterInputBoolean(props) {
|
|
|
36
39
|
React.useEffect(() => {
|
|
37
40
|
setFilterValueState(item.value || '');
|
|
38
41
|
}, [item.value]);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
44
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
|
|
45
|
+
id: labelId,
|
|
46
|
+
shrink: true,
|
|
47
|
+
variant: "standard",
|
|
48
|
+
children: label
|
|
49
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsxs)(rootProps.slots.baseSelect, (0, _extends2.default)({
|
|
50
|
+
labelId: labelId,
|
|
51
|
+
id: selectId,
|
|
52
|
+
label: label,
|
|
53
|
+
value: filterValueState,
|
|
54
|
+
onChange: onFilterChange,
|
|
55
|
+
variant: "standard",
|
|
47
56
|
native: isSelectNative,
|
|
48
|
-
displayEmpty: true
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
57
|
+
displayEmpty: true,
|
|
58
|
+
inputProps: {
|
|
59
|
+
ref: focusElementRef
|
|
60
|
+
}
|
|
61
|
+
}, others, baseSelectProps, {
|
|
62
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
63
|
+
native: isSelectNative,
|
|
64
|
+
value: "",
|
|
65
|
+
children: apiRef.current.getLocaleText('filterValueAny')
|
|
66
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
67
|
+
native: isSelectNative,
|
|
68
|
+
value: "true",
|
|
69
|
+
children: apiRef.current.getLocaleText('filterValueTrue')
|
|
70
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
71
|
+
native: isSelectNative,
|
|
72
|
+
value: "false",
|
|
73
|
+
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
74
|
+
}))]
|
|
67
75
|
}))]
|
|
68
|
-
})
|
|
76
|
+
});
|
|
69
77
|
}
|
|
@@ -53,10 +53,9 @@ function GridFilterInputSingleSelect(props) {
|
|
|
53
53
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
54
54
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
55
55
|
const id = (0, _utils.unstable_useId)();
|
|
56
|
+
const labelId = (0, _utils.unstable_useId)();
|
|
56
57
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
57
|
-
const
|
|
58
|
-
const isSelectNative = baseSelectProps.native ?? true;
|
|
59
|
-
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
58
|
+
const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? true;
|
|
60
59
|
let resolvedColumn = null;
|
|
61
60
|
if (item.field) {
|
|
62
61
|
const column = apiRef.current.getColumn(item.field);
|
|
@@ -107,33 +106,37 @@ function GridFilterInputSingleSelect(props) {
|
|
|
107
106
|
if (!(0, _filterPanelUtils.isSingleSelectColDef)(resolvedColumn)) {
|
|
108
107
|
return null;
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
const label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
110
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
111
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
|
|
112
|
+
id: labelId,
|
|
113
|
+
shrink: true,
|
|
114
|
+
variant: "standard",
|
|
115
|
+
children: label
|
|
116
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelect, (0, _extends2.default)({
|
|
117
|
+
id: id,
|
|
118
|
+
label: label,
|
|
119
|
+
labelId: labelId,
|
|
120
|
+
value: filterValueState,
|
|
121
|
+
onChange: onFilterChange,
|
|
122
|
+
variant: "standard",
|
|
123
|
+
type: type || 'text',
|
|
124
|
+
inputProps: {
|
|
125
|
+
ref: focusElementRef,
|
|
126
|
+
placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
127
|
+
},
|
|
125
128
|
native: isSelectNative
|
|
126
|
-
}, rootProps.slotProps?.baseSelect
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
})
|
|
136
|
-
})
|
|
129
|
+
}, others, rootProps.slotProps?.baseSelect, {
|
|
130
|
+
children: renderSingleSelectOptions({
|
|
131
|
+
column: resolvedColumn,
|
|
132
|
+
OptionComponent: rootProps.slots.baseSelectOption,
|
|
133
|
+
getOptionLabel,
|
|
134
|
+
getOptionValue,
|
|
135
|
+
isSelectNative,
|
|
136
|
+
baseSelectOptionProps: rootProps.slotProps?.baseSelectOption
|
|
137
|
+
})
|
|
138
|
+
}))]
|
|
139
|
+
});
|
|
137
140
|
}
|
|
138
141
|
process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
|
|
139
142
|
// ----------------------------- Warning --------------------------------
|
|
@@ -34,6 +34,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
34
34
|
const filterModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterModelSelector);
|
|
35
35
|
const filterableColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridFilterableColumnDefinitionsSelector);
|
|
36
36
|
const lastFilterRef = React.useRef(null);
|
|
37
|
+
const placeholderFilter = React.useRef(null);
|
|
37
38
|
const {
|
|
38
39
|
logicOperators = [_gridFilterItem.GridLogicOperator.And, _gridFilterItem.GridLogicOperator.Or],
|
|
39
40
|
columnsSort,
|
|
@@ -97,8 +98,10 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
|
|
|
97
98
|
if (filterModel.items.length) {
|
|
98
99
|
return filterModel.items;
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
if (!placeholderFilter.current) {
|
|
102
|
+
placeholderFilter.current = getDefaultFilter();
|
|
103
|
+
}
|
|
104
|
+
return placeholderFilter.current ? [placeholderFilter.current] : [];
|
|
102
105
|
}, [filterModel.items, getDefaultFilter]);
|
|
103
106
|
const hasMultipleFilters = items.length > 1;
|
|
104
107
|
const addNewFilter = () => {
|
|
@@ -16,6 +16,7 @@ var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
|
16
16
|
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
17
17
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
18
18
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
19
|
+
var _gridClasses = require("../../../constants/gridClasses");
|
|
19
20
|
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); }
|
|
20
21
|
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; }
|
|
21
22
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
@@ -121,10 +122,20 @@ function useGridDimensions(apiRef, props) {
|
|
|
121
122
|
apiRef.current.publishEvent('viewportInnerSizeChange', newFullDimensions.viewportInnerSize);
|
|
122
123
|
}
|
|
123
124
|
}, [apiRef, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, totalHeaderHeight]);
|
|
125
|
+
const [savedSize, setSavedSize] = React.useState();
|
|
126
|
+
const debouncedSetSavedSize = React.useMemo(() => (0, _utils.unstable_debounce)(setSavedSize, 60), []);
|
|
127
|
+
const previousSize = React.useRef();
|
|
128
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
129
|
+
if (savedSize) {
|
|
130
|
+
updateGridDimensionsRef();
|
|
131
|
+
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
132
|
+
}
|
|
133
|
+
}, [apiRef, savedSize, updateGridDimensionsRef]);
|
|
134
|
+
|
|
135
|
+
// This is the function called by apiRef.current.resize()
|
|
124
136
|
const resize = React.useCallback(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}, [apiRef, updateGridDimensionsRef]);
|
|
137
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
138
|
+
}, [apiRef]);
|
|
128
139
|
const getRootDimensions = React.useCallback(() => fullDimensionsRef.current, []);
|
|
129
140
|
const getViewportPageSize = React.useCallback(() => {
|
|
130
141
|
const dimensions = apiRef.current.getRootDimensions();
|
|
@@ -146,17 +157,44 @@ function useGridDimensions(apiRef, props) {
|
|
|
146
157
|
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
147
158
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
148
159
|
}, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
|
|
160
|
+
const computeSizeAndPublishResizeEvent = React.useCallback(() => {
|
|
161
|
+
const rootEl = apiRef.current.rootElementRef?.current;
|
|
162
|
+
const mainEl = rootEl?.querySelector(`.${_gridClasses.gridClasses.main}`);
|
|
163
|
+
if (!mainEl) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const height = mainEl.offsetHeight || 0;
|
|
167
|
+
const width = mainEl.offsetWidth || 0;
|
|
168
|
+
const win = (0, _utils.unstable_ownerWindow)(mainEl);
|
|
169
|
+
const computedStyle = win.getComputedStyle(mainEl);
|
|
170
|
+
const paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
171
|
+
const paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
|
|
172
|
+
const paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
|
|
173
|
+
const paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
|
|
174
|
+
const newHeight = height - paddingTop - paddingBottom;
|
|
175
|
+
const newWidth = width - paddingLeft - paddingRight;
|
|
176
|
+
const hasHeightChanged = newHeight !== previousSize.current?.height;
|
|
177
|
+
const hasWidthChanged = newWidth !== previousSize.current?.width;
|
|
178
|
+
if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
|
|
179
|
+
const size = {
|
|
180
|
+
width: newWidth,
|
|
181
|
+
height: newHeight
|
|
182
|
+
};
|
|
183
|
+
apiRef.current.publishEvent('resize', size);
|
|
184
|
+
previousSize.current = size;
|
|
185
|
+
}
|
|
186
|
+
}, [apiRef]);
|
|
149
187
|
const dimensionsApi = {
|
|
150
188
|
resize,
|
|
151
189
|
getRootDimensions
|
|
152
190
|
};
|
|
153
191
|
const dimensionsPrivateApi = {
|
|
154
192
|
getViewportPageSize,
|
|
155
|
-
updateGridDimensionsRef
|
|
193
|
+
updateGridDimensionsRef,
|
|
194
|
+
computeSizeAndPublishResizeEvent
|
|
156
195
|
};
|
|
157
196
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, dimensionsApi, 'public');
|
|
158
197
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, dimensionsPrivateApi, 'private');
|
|
159
|
-
const debounceResize = React.useMemo(() => (0, _utils.unstable_debounce)(resize, 60), [resize]);
|
|
160
198
|
const isFirstSizing = React.useRef(true);
|
|
161
199
|
const handleResize = React.useCallback(size => {
|
|
162
200
|
rootDimensionsRef.current = size;
|
|
@@ -173,18 +211,18 @@ function useGridDimensions(apiRef, props) {
|
|
|
173
211
|
}
|
|
174
212
|
if (isTestEnvironment) {
|
|
175
213
|
// We don't need to debounce the resize for tests.
|
|
176
|
-
|
|
214
|
+
setSavedSize(size);
|
|
177
215
|
isFirstSizing.current = false;
|
|
178
216
|
return;
|
|
179
217
|
}
|
|
180
218
|
if (isFirstSizing.current) {
|
|
181
219
|
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
182
|
-
|
|
220
|
+
setSavedSize(size);
|
|
183
221
|
isFirstSizing.current = false;
|
|
184
222
|
return;
|
|
185
223
|
}
|
|
186
|
-
|
|
187
|
-
}, [props.autoHeight,
|
|
224
|
+
debouncedSetSavedSize(size);
|
|
225
|
+
}, [props.autoHeight, debouncedSetSavedSize, logger]);
|
|
188
226
|
(0, _utils.unstable_useEnhancedEffect)(() => updateGridDimensionsRef(), [updateGridDimensionsRef]);
|
|
189
227
|
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'sortedRowsSet', updateGridDimensionsRef);
|
|
190
228
|
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'paginationModelChange', updateGridDimensionsRef);
|
|
@@ -130,7 +130,9 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
130
130
|
printDoc.body.classList.add(...normalizeOptions.bodyClassName.split(' '));
|
|
131
131
|
}
|
|
132
132
|
if (normalizeOptions.copyStyles) {
|
|
133
|
-
const
|
|
133
|
+
const rootCandidate = gridRootElement.getRootNode();
|
|
134
|
+
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
|
|
135
|
+
const headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
|
|
134
136
|
for (let i = 0; i < headStyleElements.length; i += 1) {
|
|
135
137
|
const node = headStyleElements[i];
|
|
136
138
|
if (node.tagName === 'STYLE') {
|
|
@@ -68,8 +68,6 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
68
68
|
checkboxSelection,
|
|
69
69
|
disableMultipleRowSelection,
|
|
70
70
|
disableRowSelectionOnClick,
|
|
71
|
-
pagination,
|
|
72
|
-
paginationMode,
|
|
73
71
|
isRowSelectable: propIsRowSelectable
|
|
74
72
|
} = props;
|
|
75
73
|
const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
@@ -385,33 +383,14 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
385
383
|
}
|
|
386
384
|
}, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
|
|
387
385
|
React.useEffect(() => {
|
|
388
|
-
if (!props.rowSelection) {
|
|
386
|
+
if (!props.rowSelection || isStateControlled) {
|
|
389
387
|
return;
|
|
390
388
|
}
|
|
391
389
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
392
390
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
} = (0, _useGridVisibleRows.getVisibleRows)(apiRef, {
|
|
396
|
-
pagination,
|
|
397
|
-
paginationMode
|
|
398
|
-
});
|
|
399
|
-
const currentPageRowsLookup = currentPageRows.reduce((acc, {
|
|
400
|
-
id
|
|
401
|
-
}) => {
|
|
402
|
-
acc[id] = true;
|
|
403
|
-
return acc;
|
|
404
|
-
}, {});
|
|
405
|
-
const firstSelectableRow = currentSelection.find(id => {
|
|
406
|
-
let isSelectable = true;
|
|
407
|
-
if (isRowSelectable) {
|
|
408
|
-
isSelectable = isRowSelectable(id);
|
|
409
|
-
}
|
|
410
|
-
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
|
|
391
|
+
// See https://github.com/mui/mui-x/issues/8455
|
|
392
|
+
apiRef.current.setRowSelectionModel([]);
|
|
414
393
|
}
|
|
415
|
-
}, [apiRef, canHaveMultipleSelection, checkboxSelection,
|
|
394
|
+
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
416
395
|
};
|
|
417
396
|
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -185,11 +185,13 @@ const useGridVirtualScroller = props => {
|
|
|
185
185
|
height: rootRef.current.clientHeight
|
|
186
186
|
});
|
|
187
187
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
188
|
-
const handleResize = React.useCallback(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const handleResize = React.useCallback(() => {
|
|
189
|
+
if (rootRef.current) {
|
|
190
|
+
setContainerDimensions({
|
|
191
|
+
width: rootRef.current.clientWidth,
|
|
192
|
+
height: rootRef.current.clientHeight
|
|
193
|
+
});
|
|
194
|
+
}
|
|
193
195
|
}, []);
|
|
194
196
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'debouncedResize', handleResize);
|
|
195
197
|
const updateRenderZonePosition = React.useCallback(nextRenderContext => {
|
|
@@ -315,6 +317,7 @@ const useGridVirtualScroller = props => {
|
|
|
315
317
|
renderContext
|
|
316
318
|
}) => {
|
|
317
319
|
const {
|
|
320
|
+
onRowRender,
|
|
318
321
|
renderContext: nextRenderContext,
|
|
319
322
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
320
323
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
@@ -398,6 +401,9 @@ const useGridVirtualScroller = props => {
|
|
|
398
401
|
} else {
|
|
399
402
|
isSelected = apiRef.current.isRowSelectable(id);
|
|
400
403
|
}
|
|
404
|
+
if (onRowRender) {
|
|
405
|
+
onRowRender(id);
|
|
406
|
+
}
|
|
401
407
|
const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
|
|
402
408
|
let tabbableCell = null;
|
|
403
409
|
if (cellTabIndex !== null && cellTabIndex.id === id) {
|
package/node/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "unstable_joySlots", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _joySlots.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _joySlots = _interopRequireDefault(require("./joySlots"));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _Checkbox = _interopRequireDefault(require("@mui/joy/Checkbox"));
|
|
12
|
+
var _Input = _interopRequireDefault(require("@mui/joy/Input"));
|
|
13
|
+
var _FormControl = _interopRequireDefault(require("@mui/joy/FormControl"));
|
|
14
|
+
var _FormLabel = _interopRequireDefault(require("@mui/joy/FormLabel"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
const _excluded = ["touchRippleRef", "inputProps", "onChange", "color", "size", "checked", "sx", "value", "inputRef"];
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
20
|
+
let {
|
|
21
|
+
inputProps,
|
|
22
|
+
onChange,
|
|
23
|
+
checked,
|
|
24
|
+
inputRef
|
|
25
|
+
} = _ref,
|
|
26
|
+
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
27
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, (0, _extends2.default)({}, props, {
|
|
28
|
+
slotProps: {
|
|
29
|
+
input: (0, _extends2.default)({}, inputProps, {
|
|
30
|
+
ref: inputRef
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
ref: ref,
|
|
34
|
+
checked: checked,
|
|
35
|
+
onChange: onChange
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
const TextField = /*#__PURE__*/React.forwardRef(({
|
|
39
|
+
onChange,
|
|
40
|
+
label,
|
|
41
|
+
placeholder,
|
|
42
|
+
value,
|
|
43
|
+
inputRef,
|
|
44
|
+
type
|
|
45
|
+
}, ref) => {
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_FormControl.default, {
|
|
47
|
+
ref: ref,
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormLabel.default, {
|
|
49
|
+
sx: {
|
|
50
|
+
fontSize: 12
|
|
51
|
+
},
|
|
52
|
+
children: label
|
|
53
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
|
|
54
|
+
type: type,
|
|
55
|
+
value: value,
|
|
56
|
+
onChange: onChange,
|
|
57
|
+
placeholder: placeholder,
|
|
58
|
+
size: "sm",
|
|
59
|
+
slotProps: {
|
|
60
|
+
input: {
|
|
61
|
+
ref: inputRef
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
const joySlots = {
|
|
68
|
+
baseCheckbox: Checkbox,
|
|
69
|
+
baseTextField: TextField
|
|
70
|
+
// BaseFormControl: MUIFormControl,
|
|
71
|
+
// BaseSelect: MUISelect,
|
|
72
|
+
// BaseSwitch: MUISwitch,
|
|
73
|
+
// BaseButton: MUIButton,
|
|
74
|
+
// BaseIconButton: MUIIconButton,
|
|
75
|
+
// BaseTooltip: MUITooltip,
|
|
76
|
+
// BasePopper: MUIPopper,
|
|
77
|
+
};
|
|
78
|
+
var _default = joySlots;
|
|
79
|
+
exports.default = _default;
|
package/node/locales/frFR.js
CHANGED
|
@@ -117,16 +117,14 @@ const frFRGrid = {
|
|
|
117
117
|
expandDetailPanel: 'Afficher',
|
|
118
118
|
collapseDetailPanel: 'Masquer',
|
|
119
119
|
// Row reordering text
|
|
120
|
-
rowReorderingHeaderName: 'Positionnement des lignes'
|
|
121
|
-
|
|
120
|
+
rowReorderingHeaderName: 'Positionnement des lignes',
|
|
122
121
|
// Aggregation
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
aggregationMenuItemHeader: 'Agrégation',
|
|
123
|
+
aggregationFunctionLabelSum: 'Somme',
|
|
124
|
+
aggregationFunctionLabelAvg: 'Moyenne',
|
|
125
|
+
aggregationFunctionLabelMin: 'Minimum',
|
|
126
|
+
aggregationFunctionLabelMax: 'Maximum',
|
|
127
|
+
aggregationFunctionLabelSize: "Nombre d'éléments"
|
|
129
128
|
};
|
|
130
|
-
|
|
131
129
|
const frFR = (0, _getGridLocalization.getGridLocalization)(frFRGrid, _locale.frFR);
|
|
132
130
|
exports.frFR = frFR;
|
package/node/locales/urPK.js
CHANGED
|
@@ -119,12 +119,12 @@ const urPKGrid = {
|
|
|
119
119
|
// Row reordering text
|
|
120
120
|
rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
|
|
121
121
|
// Aggregation
|
|
122
|
-
aggregationMenuItemHeader: '
|
|
123
|
-
aggregationFunctionLabelSum: '
|
|
124
|
-
aggregationFunctionLabelAvg: '
|
|
125
|
-
aggregationFunctionLabelMin: '
|
|
126
|
-
aggregationFunctionLabelMax: '
|
|
127
|
-
aggregationFunctionLabelSize: '
|
|
122
|
+
aggregationMenuItemHeader: 'ایگریگیشن',
|
|
123
|
+
aggregationFunctionLabelSum: 'کل',
|
|
124
|
+
aggregationFunctionLabelAvg: 'اوسط',
|
|
125
|
+
aggregationFunctionLabelMin: 'کم از کم',
|
|
126
|
+
aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
|
|
127
|
+
aggregationFunctionLabelSize: 'سائز'
|
|
128
128
|
};
|
|
129
129
|
const urPK = (0, _getGridLocalization.getGridLocalization)(urPKGrid, _coreLocales.urPKCore);
|
|
130
130
|
exports.urPK = urPK;
|
package/node/utils/utils.js
CHANGED
package/package.json
CHANGED
package/utils/utils.d.ts
CHANGED
package/utils/utils.js
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface AutoSizerSize {
|
|
3
|
-
height: number;
|
|
4
|
-
width: number;
|
|
5
|
-
}
|
|
6
|
-
export interface AutoSizerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onResize'> {
|
|
7
|
-
/**
|
|
8
|
-
* Function responsible for rendering children.
|
|
9
|
-
* @param {AutoSizerSize} size The grid's size.
|
|
10
|
-
* @returns {React.ReactNode} The children to render.
|
|
11
|
-
*/
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
* Default height to use for initial render; useful for SSR.
|
|
15
|
-
* @default null
|
|
16
|
-
*/
|
|
17
|
-
defaultHeight?: number;
|
|
18
|
-
/**
|
|
19
|
-
* Default width to use for initial render; useful for SSR.
|
|
20
|
-
* @default null
|
|
21
|
-
*/
|
|
22
|
-
defaultWidth?: number;
|
|
23
|
-
/**
|
|
24
|
-
* If `true`, disable dynamic :height property.
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
disableHeight?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* If `true`, disable dynamic :width property.
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
disableWidth?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Nonce of the inlined stylesheet for Content Security Policy.
|
|
35
|
-
*/
|
|
36
|
-
nonce?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Callback to be invoked on-resize.
|
|
39
|
-
* @param {AutoSizerSize} size The grid's size.
|
|
40
|
-
*/
|
|
41
|
-
onResize?: (size: AutoSizerSize) => void;
|
|
42
|
-
}
|
|
43
|
-
declare const GridAutoSizer: React.ForwardRefExoticComponent<AutoSizerProps & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
-
export { GridAutoSizer };
|