@mui/x-data-grid 6.2.0 → 6.3.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 +118 -1
- package/components/GridHeader.d.ts +2 -2
- package/components/GridHeader.js +4 -6
- package/components/base/GridBody.d.ts +0 -1
- package/components/base/GridBody.js +39 -15
- package/components/cell/GridActionsCell.d.ts +2 -3
- package/components/cell/GridActionsCell.js +9 -1
- 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/containers/GridRootStyles.js +3 -1
- 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 +3 -3
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterPanel.js +5 -2
- package/constants/gridClasses.js +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +22 -15
- 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/virtualization/useGridVirtualScroller.d.ts +1 -0
- 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 +179 -0
- package/joy/package.json +6 -0
- package/legacy/components/GridHeader.js +4 -6
- package/legacy/components/base/GridBody.js +40 -16
- package/legacy/components/cell/GridActionsCell.js +11 -2
- 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/containers/GridRootStyles.js +3 -1
- 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/GridFilterPanel.js +5 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/columnGrouping/useGridColumnGrouping.js +22 -15
- package/legacy/hooks/features/dimensions/useGridDimensions.js +55 -12
- package/legacy/hooks/features/export/useGridPrintExport.js +3 -1
- 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 +180 -0
- package/legacy/locales/frFR.js +2 -2
- package/legacy/locales/trTR.js +2 -2
- package/legacy/locales/zhCN.js +2 -2
- package/locales/frFR.js +2 -2
- package/locales/trTR.js +2 -2
- package/locales/zhCN.js +2 -2
- package/material/index.d.ts +2 -2
- package/models/gridSlotsComponent.d.ts +2 -2
- package/modern/components/GridHeader.js +4 -6
- package/modern/components/base/GridBody.js +39 -15
- package/modern/components/cell/GridActionsCell.js +9 -1
- 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/containers/GridRootStyles.js +3 -1
- 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/GridFilterPanel.js +5 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnGrouping/useGridColumnGrouping.js +21 -14
- package/modern/hooks/features/dimensions/useGridDimensions.js +48 -10
- package/modern/hooks/features/export/useGridPrintExport.js +3 -1
- 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 +177 -0
- package/modern/locales/frFR.js +2 -2
- package/modern/locales/trTR.js +2 -2
- package/modern/locales/zhCN.js +2 -2
- package/node/components/GridHeader.js +5 -8
- package/node/components/base/GridBody.js +39 -15
- package/node/components/cell/GridActionsCell.js +9 -1
- 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/containers/GridRootStyles.js +3 -1
- 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/GridFilterPanel.js +5 -2
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnGrouping/useGridColumnGrouping.js +20 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +47 -9
- package/node/hooks/features/export/useGridPrintExport.js +3 -1
- 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 +185 -0
- package/node/locales/frFR.js +2 -2
- package/node/locales/trTR.js +2 -2
- package/node/locales/zhCN.js +2 -2
- package/package.json +3 -3
- 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
|
@@ -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,
|
|
@@ -114,10 +115,20 @@ export function useGridDimensions(apiRef, props) {
|
|
|
114
115
|
apiRef.current.publishEvent('viewportInnerSizeChange', newFullDimensions.viewportInnerSize);
|
|
115
116
|
}
|
|
116
117
|
}, [apiRef, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, totalHeaderHeight]);
|
|
118
|
+
const [savedSize, setSavedSize] = React.useState();
|
|
119
|
+
const debouncedSetSavedSize = React.useMemo(() => debounce(setSavedSize, 60), []);
|
|
120
|
+
const previousSize = React.useRef();
|
|
121
|
+
useEnhancedEffect(() => {
|
|
122
|
+
if (savedSize) {
|
|
123
|
+
updateGridDimensionsRef();
|
|
124
|
+
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
125
|
+
}
|
|
126
|
+
}, [apiRef, savedSize, updateGridDimensionsRef]);
|
|
127
|
+
|
|
128
|
+
// This is the function called by apiRef.current.resize()
|
|
117
129
|
const resize = React.useCallback(() => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}, [apiRef, updateGridDimensionsRef]);
|
|
130
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
131
|
+
}, [apiRef]);
|
|
121
132
|
const getRootDimensions = React.useCallback(() => fullDimensionsRef.current, []);
|
|
122
133
|
const getViewportPageSize = React.useCallback(() => {
|
|
123
134
|
const dimensions = apiRef.current.getRootDimensions();
|
|
@@ -139,17 +150,45 @@ export function useGridDimensions(apiRef, props) {
|
|
|
139
150
|
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
140
151
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
141
152
|
}, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
|
|
153
|
+
const computeSizeAndPublishResizeEvent = React.useCallback(() => {
|
|
154
|
+
var _apiRef$current$rootE2, _previousSize$current, _previousSize$current2;
|
|
155
|
+
const rootEl = (_apiRef$current$rootE2 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE2.current;
|
|
156
|
+
const mainEl = rootEl == null ? void 0 : rootEl.querySelector(`.${gridClasses.main}`);
|
|
157
|
+
if (!mainEl) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const height = mainEl.offsetHeight || 0;
|
|
161
|
+
const width = mainEl.offsetWidth || 0;
|
|
162
|
+
const win = ownerWindow(mainEl);
|
|
163
|
+
const computedStyle = win.getComputedStyle(mainEl);
|
|
164
|
+
const paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
165
|
+
const paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
|
|
166
|
+
const paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
|
|
167
|
+
const paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
|
|
168
|
+
const newHeight = height - paddingTop - paddingBottom;
|
|
169
|
+
const newWidth = width - paddingLeft - paddingRight;
|
|
170
|
+
const hasHeightChanged = newHeight !== ((_previousSize$current = previousSize.current) == null ? void 0 : _previousSize$current.height);
|
|
171
|
+
const hasWidthChanged = newWidth !== ((_previousSize$current2 = previousSize.current) == null ? void 0 : _previousSize$current2.width);
|
|
172
|
+
if (!previousSize.current || hasHeightChanged || hasWidthChanged) {
|
|
173
|
+
const size = {
|
|
174
|
+
width: newWidth,
|
|
175
|
+
height: newHeight
|
|
176
|
+
};
|
|
177
|
+
apiRef.current.publishEvent('resize', size);
|
|
178
|
+
previousSize.current = size;
|
|
179
|
+
}
|
|
180
|
+
}, [apiRef]);
|
|
142
181
|
const dimensionsApi = {
|
|
143
182
|
resize,
|
|
144
183
|
getRootDimensions
|
|
145
184
|
};
|
|
146
185
|
const dimensionsPrivateApi = {
|
|
147
186
|
getViewportPageSize,
|
|
148
|
-
updateGridDimensionsRef
|
|
187
|
+
updateGridDimensionsRef,
|
|
188
|
+
computeSizeAndPublishResizeEvent
|
|
149
189
|
};
|
|
150
190
|
useGridApiMethod(apiRef, dimensionsApi, 'public');
|
|
151
191
|
useGridApiMethod(apiRef, dimensionsPrivateApi, 'private');
|
|
152
|
-
const debounceResize = React.useMemo(() => debounce(resize, 60), [resize]);
|
|
153
192
|
const isFirstSizing = React.useRef(true);
|
|
154
193
|
const handleResize = React.useCallback(size => {
|
|
155
194
|
rootDimensionsRef.current = size;
|
|
@@ -166,18 +205,18 @@ export function useGridDimensions(apiRef, props) {
|
|
|
166
205
|
}
|
|
167
206
|
if (isTestEnvironment) {
|
|
168
207
|
// We don't need to debounce the resize for tests.
|
|
169
|
-
|
|
208
|
+
setSavedSize(size);
|
|
170
209
|
isFirstSizing.current = false;
|
|
171
210
|
return;
|
|
172
211
|
}
|
|
173
212
|
if (isFirstSizing.current) {
|
|
174
213
|
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
175
|
-
|
|
214
|
+
setSavedSize(size);
|
|
176
215
|
isFirstSizing.current = false;
|
|
177
216
|
return;
|
|
178
217
|
}
|
|
179
|
-
|
|
180
|
-
}, [props.autoHeight,
|
|
218
|
+
debouncedSetSavedSize(size);
|
|
219
|
+
}, [props.autoHeight, debouncedSetSavedSize, logger]);
|
|
181
220
|
useEnhancedEffect(() => updateGridDimensionsRef(), [updateGridDimensionsRef]);
|
|
182
221
|
useGridApiOptionHandler(apiRef, 'sortedRowsSet', updateGridDimensionsRef);
|
|
183
222
|
useGridApiOptionHandler(apiRef, 'paginationModelChange', updateGridDimensionsRef);
|
|
@@ -124,7 +124,9 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
124
124
|
printDoc.body.classList.add(...normalizeOptions.bodyClassName.split(' '));
|
|
125
125
|
}
|
|
126
126
|
if (normalizeOptions.copyStyles) {
|
|
127
|
-
const
|
|
127
|
+
const rootCandidate = gridRootElement.getRootNode();
|
|
128
|
+
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc.current;
|
|
129
|
+
const headStyleElements = root.querySelectorAll("style, link[rel='stylesheet']");
|
|
128
130
|
for (let i = 0; i < headStyleElements.length; i += 1) {
|
|
129
131
|
const node = headStyleElements[i];
|
|
130
132
|
if (node.tagName === 'STYLE') {
|
|
@@ -31,6 +31,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
|
|
|
31
31
|
availableSpace?: number | null | undefined;
|
|
32
32
|
rows?: GridRowEntry<import("../../../models").GridValidRowModel>[] | undefined;
|
|
33
33
|
rowIndexOffset?: number | undefined;
|
|
34
|
+
onRowRender?: ((rowId: GridRowId) => void) | undefined;
|
|
34
35
|
}) => JSX.Element[] | null;
|
|
35
36
|
getRootProps: ({ style, ...other }?: {
|
|
36
37
|
style?: {} | undefined;
|
|
@@ -176,11 +176,13 @@ export const useGridVirtualScroller = props => {
|
|
|
176
176
|
height: rootRef.current.clientHeight
|
|
177
177
|
});
|
|
178
178
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
179
|
-
const handleResize = React.useCallback(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
const handleResize = React.useCallback(() => {
|
|
180
|
+
if (rootRef.current) {
|
|
181
|
+
setContainerDimensions({
|
|
182
|
+
width: rootRef.current.clientWidth,
|
|
183
|
+
height: rootRef.current.clientHeight
|
|
184
|
+
});
|
|
185
|
+
}
|
|
184
186
|
}, []);
|
|
185
187
|
useGridApiEventHandler(apiRef, 'debouncedResize', handleResize);
|
|
186
188
|
const updateRenderZonePosition = React.useCallback(nextRenderContext => {
|
|
@@ -307,6 +309,7 @@ export const useGridVirtualScroller = props => {
|
|
|
307
309
|
}) => {
|
|
308
310
|
var _rootProps$slotProps;
|
|
309
311
|
const {
|
|
312
|
+
onRowRender,
|
|
310
313
|
renderContext: nextRenderContext,
|
|
311
314
|
minFirstColumn = renderZoneMinColumnIndex,
|
|
312
315
|
maxLastColumn = renderZoneMaxColumnIndex,
|
|
@@ -391,6 +394,9 @@ export const useGridVirtualScroller = props => {
|
|
|
391
394
|
} else {
|
|
392
395
|
isSelected = apiRef.current.isRowSelectable(id);
|
|
393
396
|
}
|
|
397
|
+
if (onRowRender) {
|
|
398
|
+
onRowRender(id);
|
|
399
|
+
}
|
|
394
400
|
const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
|
|
395
401
|
let tabbableCell = null;
|
|
396
402
|
if (cellTabIndex !== null && cellTabIndex.id === id) {
|
package/index.js
CHANGED
package/joy/index.d.ts
ADDED
package/joy/index.js
ADDED
package/joy/joySlots.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
_excluded2 = ["startIcon", "color", "endIcon", "size", "sx", "variant"],
|
|
5
|
+
_excluded3 = ["color", "size", "sx"],
|
|
6
|
+
_excluded4 = ["name", "checkedIcon", "color", "disableRipple", "disableFocusRipple", "disableTouchRipple", "edge", "icon", "inputProps", "inputRef", "size", "sx", "onChange", "onClick"];
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import JoyCheckbox from '@mui/joy/Checkbox';
|
|
9
|
+
import JoyInput from '@mui/joy/Input';
|
|
10
|
+
import JoyFormControl from '@mui/joy/FormControl';
|
|
11
|
+
import JoyFormLabel from '@mui/joy/FormLabel';
|
|
12
|
+
import JoyButton from '@mui/joy/Button';
|
|
13
|
+
import JoyIconButton from '@mui/joy/IconButton';
|
|
14
|
+
import JoySwitch from '@mui/joy/Switch';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
function convertColor(color) {
|
|
18
|
+
if (color === 'secondary') {
|
|
19
|
+
return 'primary';
|
|
20
|
+
}
|
|
21
|
+
if (color === 'error') {
|
|
22
|
+
return 'danger';
|
|
23
|
+
}
|
|
24
|
+
if (color === 'default' || color === 'inherit') {
|
|
25
|
+
return 'neutral';
|
|
26
|
+
}
|
|
27
|
+
return color;
|
|
28
|
+
}
|
|
29
|
+
function convertSize(size) {
|
|
30
|
+
return size ? {
|
|
31
|
+
small: 'sm',
|
|
32
|
+
medium: 'md',
|
|
33
|
+
large: 'lg'
|
|
34
|
+
}[size] : size;
|
|
35
|
+
}
|
|
36
|
+
function convertVariant(variant) {
|
|
37
|
+
return variant ? {
|
|
38
|
+
outlined: 'outlined',
|
|
39
|
+
contained: 'solid',
|
|
40
|
+
text: 'plain',
|
|
41
|
+
standard: 'plain',
|
|
42
|
+
filled: 'soft'
|
|
43
|
+
}[variant] : variant;
|
|
44
|
+
}
|
|
45
|
+
const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
46
|
+
let {
|
|
47
|
+
inputProps,
|
|
48
|
+
onChange,
|
|
49
|
+
checked,
|
|
50
|
+
inputRef
|
|
51
|
+
} = _ref,
|
|
52
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
53
|
+
return /*#__PURE__*/_jsx(JoyCheckbox, _extends({}, props, {
|
|
54
|
+
slotProps: {
|
|
55
|
+
input: _extends({}, inputProps, {
|
|
56
|
+
ref: inputRef
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
ref: ref,
|
|
60
|
+
checked: checked,
|
|
61
|
+
onChange: onChange
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
const TextField = /*#__PURE__*/React.forwardRef(({
|
|
65
|
+
onChange,
|
|
66
|
+
label,
|
|
67
|
+
placeholder,
|
|
68
|
+
value,
|
|
69
|
+
inputRef,
|
|
70
|
+
type
|
|
71
|
+
}, ref) => {
|
|
72
|
+
return /*#__PURE__*/_jsxs(JoyFormControl, {
|
|
73
|
+
ref: ref,
|
|
74
|
+
children: [/*#__PURE__*/_jsx(JoyFormLabel, {
|
|
75
|
+
sx: {
|
|
76
|
+
fontSize: 12
|
|
77
|
+
},
|
|
78
|
+
children: label
|
|
79
|
+
}), /*#__PURE__*/_jsx(JoyInput, {
|
|
80
|
+
type: type,
|
|
81
|
+
value: value,
|
|
82
|
+
onChange: onChange,
|
|
83
|
+
placeholder: placeholder,
|
|
84
|
+
size: "sm",
|
|
85
|
+
slotProps: {
|
|
86
|
+
input: {
|
|
87
|
+
ref: inputRef
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
const Button = /*#__PURE__*/React.forwardRef(function Button(_ref2, ref) {
|
|
94
|
+
var _convertVariant;
|
|
95
|
+
let {
|
|
96
|
+
startIcon,
|
|
97
|
+
color,
|
|
98
|
+
endIcon,
|
|
99
|
+
size,
|
|
100
|
+
sx,
|
|
101
|
+
variant
|
|
102
|
+
} = _ref2,
|
|
103
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
104
|
+
return /*#__PURE__*/_jsx(JoyButton, _extends({}, props, {
|
|
105
|
+
size: convertSize(size),
|
|
106
|
+
color: convertColor(color),
|
|
107
|
+
variant: (_convertVariant = convertVariant(variant)) != null ? _convertVariant : 'plain',
|
|
108
|
+
ref: ref,
|
|
109
|
+
startDecorator: startIcon,
|
|
110
|
+
endDecorator: endIcon,
|
|
111
|
+
sx: sx
|
|
112
|
+
}));
|
|
113
|
+
});
|
|
114
|
+
const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(_ref3, ref) {
|
|
115
|
+
var _convertColor;
|
|
116
|
+
let {
|
|
117
|
+
color,
|
|
118
|
+
size,
|
|
119
|
+
sx
|
|
120
|
+
} = _ref3,
|
|
121
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
122
|
+
return /*#__PURE__*/_jsx(JoyIconButton, _extends({}, props, {
|
|
123
|
+
size: convertSize(size),
|
|
124
|
+
color: (_convertColor = convertColor(color)) != null ? _convertColor : 'neutral',
|
|
125
|
+
variant: "plain",
|
|
126
|
+
ref: ref,
|
|
127
|
+
sx: sx
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
130
|
+
const Switch = /*#__PURE__*/React.forwardRef(function Switch(_ref4, ref) {
|
|
131
|
+
let {
|
|
132
|
+
name,
|
|
133
|
+
color: colorProp,
|
|
134
|
+
edge,
|
|
135
|
+
icon,
|
|
136
|
+
inputProps,
|
|
137
|
+
inputRef,
|
|
138
|
+
size,
|
|
139
|
+
sx,
|
|
140
|
+
onChange,
|
|
141
|
+
onClick
|
|
142
|
+
} = _ref4,
|
|
143
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
144
|
+
return /*#__PURE__*/_jsx(JoySwitch, _extends({}, props, {
|
|
145
|
+
onChange: onChange,
|
|
146
|
+
size: convertSize(size),
|
|
147
|
+
color: convertColor(colorProp),
|
|
148
|
+
ref: ref,
|
|
149
|
+
slotProps: {
|
|
150
|
+
input: _extends({}, inputProps, {
|
|
151
|
+
name,
|
|
152
|
+
onClick: onClick,
|
|
153
|
+
ref: inputRef
|
|
154
|
+
}),
|
|
155
|
+
thumb: {
|
|
156
|
+
children: icon
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
sx: [_extends({}, edge === 'start' && {
|
|
160
|
+
ml: '-8px'
|
|
161
|
+
}, edge === 'end' && {
|
|
162
|
+
mr: '-8px'
|
|
163
|
+
}), ...(Array.isArray(sx) ? sx : [sx])]
|
|
164
|
+
}));
|
|
165
|
+
});
|
|
166
|
+
const joySlots = {
|
|
167
|
+
baseCheckbox: Checkbox,
|
|
168
|
+
baseTextField: TextField,
|
|
169
|
+
baseButton: Button,
|
|
170
|
+
baseIconButton: IconButton,
|
|
171
|
+
baseSwitch: Switch
|
|
172
|
+
// BaseFormControl: MUIFormControl,
|
|
173
|
+
// baseSelect: Select,
|
|
174
|
+
// baseSelectOption: Option,
|
|
175
|
+
// BaseTooltip: MUITooltip,
|
|
176
|
+
// BasePopper: MUIPopper,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default joySlots;
|
package/joy/package.json
ADDED
|
@@ -3,12 +3,10 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
export
|
|
6
|
+
export function GridHeader() {
|
|
7
7
|
var _rootProps$slotProps, _rootProps$slotProps2;
|
|
8
8
|
var rootProps = useGridRootProps();
|
|
9
|
-
return /*#__PURE__*/_jsxs(
|
|
10
|
-
ref: ref
|
|
11
|
-
}, props, {
|
|
9
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
12
10
|
children: [/*#__PURE__*/_jsx(rootProps.slots.preferencesPanel, _extends({}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.preferencesPanel)), rootProps.slots.toolbar && /*#__PURE__*/_jsx(rootProps.slots.toolbar, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.toolbar))]
|
|
13
|
-
})
|
|
14
|
-
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -2,10 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
5
6
|
import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
|
|
6
7
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
7
8
|
import { GridMainContainer } from '../containers/GridMainContainer';
|
|
8
|
-
import { GridAutoSizer } from '../GridAutoSizer';
|
|
9
9
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
10
10
|
import { gridColumnPositionsSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
|
|
11
11
|
import { gridFilterActiveItemsLookupSelector } from '../../hooks/features/filter/gridFilterSelector';
|
|
@@ -17,11 +17,11 @@ import { gridColumnMenuSelector } from '../../hooks/features/columnMenu/columnMe
|
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
function GridBody(props) {
|
|
20
|
-
var
|
|
21
|
-
VirtualScrollerComponent = props.VirtualScrollerComponent,
|
|
20
|
+
var VirtualScrollerComponent = props.VirtualScrollerComponent,
|
|
22
21
|
ColumnHeadersProps = props.ColumnHeadersProps;
|
|
23
22
|
var apiRef = useGridPrivateApiContext();
|
|
24
23
|
var rootProps = useGridRootProps();
|
|
24
|
+
var rootRef = React.useRef(null);
|
|
25
25
|
var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
26
26
|
var filterColumnLookup = useGridSelector(apiRef, gridFilterActiveItemsLookupSelector);
|
|
27
27
|
var sortColumnLookup = useGridSelector(apiRef, gridSortColumnLookupSelector);
|
|
@@ -41,6 +41,31 @@ function GridBody(props) {
|
|
|
41
41
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
42
42
|
isVirtualizationDisabled = _React$useState2[0],
|
|
43
43
|
setIsVirtualizationDisabled = _React$useState2[1];
|
|
44
|
+
useEnhancedEffect(function () {
|
|
45
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
46
|
+
var elementToObserve = rootRef.current;
|
|
47
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
48
|
+
return function () {};
|
|
49
|
+
}
|
|
50
|
+
var animationFrame;
|
|
51
|
+
var observer = new ResizeObserver(function () {
|
|
52
|
+
// See https://github.com/mui/mui-x/issues/8733
|
|
53
|
+
animationFrame = window.requestAnimationFrame(function () {
|
|
54
|
+
apiRef.current.computeSizeAndPublishResizeEvent();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
if (elementToObserve) {
|
|
58
|
+
observer.observe(elementToObserve);
|
|
59
|
+
}
|
|
60
|
+
return function () {
|
|
61
|
+
if (animationFrame) {
|
|
62
|
+
window.cancelAnimationFrame(animationFrame);
|
|
63
|
+
}
|
|
64
|
+
if (elementToObserve) {
|
|
65
|
+
observer.unobserve(elementToObserve);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, [apiRef]);
|
|
44
69
|
var disableVirtualization = React.useCallback(function () {
|
|
45
70
|
setIsVirtualizationDisabled(true);
|
|
46
71
|
}, []);
|
|
@@ -67,10 +92,9 @@ function GridBody(props) {
|
|
|
67
92
|
columnHeadersElementRef: columnHeadersRef,
|
|
68
93
|
virtualScrollerRef: virtualScrollerRef
|
|
69
94
|
});
|
|
70
|
-
var
|
|
71
|
-
apiRef.current.publishEvent('resize', size);
|
|
72
|
-
}, [apiRef]);
|
|
95
|
+
var hasDimensions = !!apiRef.current.getRootDimensions();
|
|
73
96
|
return /*#__PURE__*/_jsxs(GridMainContainer, {
|
|
97
|
+
ref: rootRef,
|
|
74
98
|
children: [/*#__PURE__*/_jsx(rootProps.slots.columnHeaders, _extends({
|
|
75
99
|
ref: columnsContainerRef,
|
|
76
100
|
innerRef: columnHeadersRef,
|
|
@@ -88,15 +112,16 @@ function GridBody(props) {
|
|
|
88
112
|
columnVisibility: columnVisibility,
|
|
89
113
|
columnGroupsHeaderStructure: columnGroupsHeaderStructure,
|
|
90
114
|
hasOtherElementInTabSequence: hasOtherElementInTabSequence
|
|
91
|
-
}, ColumnHeadersProps)), /*#__PURE__*/_jsx(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
115
|
+
}, ColumnHeadersProps)), hasDimensions && /*#__PURE__*/_jsx(VirtualScrollerComponent
|
|
116
|
+
// The content is only rendered after dimensions are computed because
|
|
117
|
+
// the lazy-loading hook is listening to `renderedRowsIntervalChange`,
|
|
118
|
+
// but only does something if the dimensions are also available.
|
|
119
|
+
// If this event is published while dimensions haven't been computed,
|
|
120
|
+
// the `onFetchRows` prop won't be called during mount.
|
|
121
|
+
, {
|
|
122
|
+
ref: virtualScrollerRef,
|
|
123
|
+
disableVirtualization: isVirtualizationDisabled
|
|
124
|
+
})]
|
|
100
125
|
});
|
|
101
126
|
}
|
|
102
127
|
process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
@@ -104,7 +129,6 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
|
|
|
104
129
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
105
130
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
106
131
|
// ----------------------------------------------------------------------
|
|
107
|
-
children: PropTypes.node,
|
|
108
132
|
ColumnHeadersProps: PropTypes.object,
|
|
109
133
|
VirtualScrollerComponent: PropTypes.elementType.isRequired
|
|
110
134
|
} : void 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["colDef", "id", "hasFocus", "isEditable", "field", "value", "formattedValue", "row", "rowNode", "cellMode", "tabIndex", "position", "focusElementRef"];
|
|
4
|
+
var _excluded = ["api", "colDef", "id", "hasFocus", "isEditable", "field", "value", "formattedValue", "row", "rowNode", "cellMode", "tabIndex", "position", "focusElementRef"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import MenuList from '@mui/material/MenuList';
|
|
@@ -18,7 +18,8 @@ var hasActions = function hasActions(colDef) {
|
|
|
18
18
|
};
|
|
19
19
|
function GridActionsCell(props) {
|
|
20
20
|
var _rootProps$slotProps;
|
|
21
|
-
var
|
|
21
|
+
var api = props.api,
|
|
22
|
+
colDef = props.colDef,
|
|
22
23
|
id = props.id,
|
|
23
24
|
hasFocus = props.hasFocus,
|
|
24
25
|
isEditable = props.isEditable,
|
|
@@ -221,6 +222,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
221
222
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
222
223
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
223
224
|
// ----------------------------------------------------------------------
|
|
225
|
+
api: PropTypes.object,
|
|
224
226
|
/**
|
|
225
227
|
* The mode of the cell.
|
|
226
228
|
*/
|
|
@@ -243,6 +245,9 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
243
245
|
focus: PropTypes.func.isRequired
|
|
244
246
|
})
|
|
245
247
|
})]),
|
|
248
|
+
/**
|
|
249
|
+
* The cell value formatted with the column valueFormatter.
|
|
250
|
+
*/
|
|
246
251
|
formattedValue: PropTypes.any,
|
|
247
252
|
/**
|
|
248
253
|
* If true, the cell is the active element.
|
|
@@ -269,6 +274,10 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
269
274
|
* the tabIndex value.
|
|
270
275
|
*/
|
|
271
276
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
277
|
+
/**
|
|
278
|
+
* The cell value.
|
|
279
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
280
|
+
*/
|
|
272
281
|
value: PropTypes.any
|
|
273
282
|
} : void 0;
|
|
274
283
|
export { GridActionsCell };
|
|
@@ -38,7 +38,7 @@ var GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCell
|
|
|
38
38
|
};
|
|
39
39
|
var classes = useUtilityClasses(ownerState);
|
|
40
40
|
var checkboxElement = React.useRef(null);
|
|
41
|
-
var rippleRef = React.useRef();
|
|
41
|
+
var rippleRef = React.useRef(null);
|
|
42
42
|
var handleRef = useForkRef(checkboxElement, ref);
|
|
43
43
|
var element = apiRef.current.getCellElement(id, field);
|
|
44
44
|
var handleChange = function handleChange(event) {
|
|
@@ -26,12 +26,13 @@ var GridMainContainerRoot = styled('div', {
|
|
|
26
26
|
overflow: 'hidden'
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
|
-
export
|
|
29
|
+
export var GridMainContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
30
30
|
var rootProps = useGridRootProps();
|
|
31
31
|
var classes = useUtilityClasses(rootProps);
|
|
32
32
|
return /*#__PURE__*/_jsx(GridMainContainerRoot, {
|
|
33
|
+
ref: ref,
|
|
33
34
|
className: classes.root,
|
|
34
35
|
ownerState: rootProps,
|
|
35
36
|
children: props.children
|
|
36
37
|
});
|
|
37
|
-
}
|
|
38
|
+
});
|
|
@@ -54,11 +54,6 @@ var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
54
54
|
useEnhancedEffect(function () {
|
|
55
55
|
setMountedState(true);
|
|
56
56
|
}, []);
|
|
57
|
-
useEnhancedEffect(function () {
|
|
58
|
-
if (mountedState) {
|
|
59
|
-
apiRef.current.updateGridDimensionsRef();
|
|
60
|
-
}
|
|
61
|
-
}, [apiRef, mountedState]);
|
|
62
57
|
if (!mountedState) {
|
|
63
58
|
return null;
|
|
64
59
|
}
|
|
@@ -82,7 +82,9 @@ export var GridRootStyles = styled('div', {
|
|
|
82
82
|
minWidth: 0,
|
|
83
83
|
flex: 1,
|
|
84
84
|
whiteSpace: 'nowrap',
|
|
85
|
-
overflow: 'hidden'
|
|
85
|
+
overflow: 'hidden',
|
|
86
|
+
// to anchor the aggregation label
|
|
87
|
+
position: 'relative'
|
|
86
88
|
}), _defineProperty(_extends2, "& .".concat(gridClasses.columnHeaderTitleContainerContent), {
|
|
87
89
|
overflow: 'hidden',
|
|
88
90
|
display: 'flex',
|
|
@@ -108,8 +108,9 @@ function GridColumnsPanel(props) {
|
|
|
108
108
|
var toggleAllColumns = React.useCallback(function (isVisible) {
|
|
109
109
|
var currentModel = gridColumnVisibilityModelSelector(apiRef);
|
|
110
110
|
var newModel = _extends({}, currentModel);
|
|
111
|
+
var togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
111
112
|
columns.forEach(function (col) {
|
|
112
|
-
if (col.hideable) {
|
|
113
|
+
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
113
114
|
if (isVisible) {
|
|
114
115
|
// delete the key from the model instead of setting it to `true`
|
|
115
116
|
delete newModel[col.field];
|
|
@@ -119,7 +120,7 @@ function GridColumnsPanel(props) {
|
|
|
119
120
|
}
|
|
120
121
|
});
|
|
121
122
|
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
122
|
-
}, [apiRef, columns]);
|
|
123
|
+
}, [apiRef, columns, getTogglableColumns]);
|
|
123
124
|
var handleSearchValueChange = React.useCallback(function (event) {
|
|
124
125
|
setSearchValue(event.target.value);
|
|
125
126
|
}, []);
|
|
@@ -132,6 +132,7 @@ process.env.NODE_ENV !== "production" ? GridPanel.propTypes = {
|
|
|
132
132
|
/**
|
|
133
133
|
* If `true`, the component is shown.
|
|
134
134
|
*/
|
|
135
|
-
open: PropTypes.bool.isRequired
|
|
135
|
+
open: PropTypes.bool.isRequired,
|
|
136
|
+
ownerState: PropTypes.object
|
|
136
137
|
} : void 0;
|
|
137
138
|
export { GridPanel };
|
|
@@ -30,6 +30,7 @@ var GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(pro
|
|
|
30
30
|
var filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
31
31
|
var filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
32
32
|
var lastFilterRef = React.useRef(null);
|
|
33
|
+
var placeholderFilter = React.useRef(null);
|
|
33
34
|
var _props$logicOperators = props.logicOperators,
|
|
34
35
|
logicOperators = _props$logicOperators === void 0 ? [GridLogicOperator.And, GridLogicOperator.Or] : _props$logicOperators,
|
|
35
36
|
columnsSort = props.columnsSort,
|
|
@@ -100,8 +101,10 @@ var GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(pro
|
|
|
100
101
|
if (filterModel.items.length) {
|
|
101
102
|
return filterModel.items;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (!placeholderFilter.current) {
|
|
105
|
+
placeholderFilter.current = getDefaultFilter();
|
|
106
|
+
}
|
|
107
|
+
return placeholderFilter.current ? [placeholderFilter.current] : [];
|
|
105
108
|
}, [filterModel.items, getDefaultFilter]);
|
|
106
109
|
var hasMultipleFilters = items.length > 1;
|
|
107
110
|
var addNewFilter = function addNewFilter() {
|