@mui/x-data-grid 8.0.0-alpha.3 → 8.0.0-alpha.4
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 +274 -0
- package/DataGrid/DataGrid.js +5 -5
- package/README.md +1 -1
- package/components/GridRow.js +1 -1
- package/components/cell/GridActionsCell.js +8 -1
- package/components/cell/GridCell.js +1 -1
- package/components/panel/GridColumnsPanel.js +1 -2
- package/components/panel/GridPanelContent.js +7 -3
- package/components/panel/GridPanelFooter.d.ts +1 -1
- package/components/panel/GridPanelFooter.js +4 -3
- package/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/constants/dataGridPropsDefaultValues.js +1 -1
- package/hooks/core/useGridStateInitialization.js +3 -3
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
- package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
- package/hooks/features/filter/useGridFilter.js +1 -1
- package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/overlays/useGridOverlays.js +3 -1
- package/hooks/features/pagination/gridPaginationSelector.d.ts +15 -9
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/hooks/features/rowSelection/utils.d.ts +1 -1
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
- package/hooks/features/rows/gridRowsSelector.d.ts +23 -12
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/hooks/features/rows/useGridRows.js +5 -5
- package/hooks/features/sorting/gridSortingSelector.d.ts +10 -5
- package/hooks/features/sorting/gridSortingSelector.js +11 -0
- package/hooks/features/sorting/index.d.ts +2 -1
- package/hooks/features/sorting/index.js +1 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/hooks/utils/useGridSelector.d.ts +4 -6
- package/hooks/utils/useGridSelector.js +6 -44
- package/index.js +1 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/locales/roRO.js +18 -20
- package/models/api/gridStateApi.d.ts +1 -1
- package/models/controlStateItem.d.ts +2 -2
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +5 -5
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridActionsCell.js +8 -1
- package/modern/components/cell/GridCell.js +1 -1
- package/modern/components/panel/GridColumnsPanel.js +1 -2
- package/modern/components/panel/GridPanelContent.js +7 -3
- package/modern/components/panel/GridPanelFooter.js +4 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/modern/constants/dataGridPropsDefaultValues.js +1 -1
- package/modern/hooks/core/useGridStateInitialization.js +3 -3
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/overlays/useGridOverlays.js +3 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/modern/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/modern/hooks/features/rows/useGridRows.js +5 -5
- package/modern/hooks/features/sorting/gridSortingSelector.js +11 -0
- package/modern/hooks/features/sorting/index.js +1 -1
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/modern/hooks/utils/useGridSelector.js +6 -44
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -2
- package/modern/locales/roRO.js +18 -20
- package/modern/utils/createSelector.js +1 -120
- package/node/DataGrid/DataGrid.js +5 -5
- package/node/components/GridRow.js +1 -1
- package/node/components/cell/GridActionsCell.js +8 -1
- package/node/components/cell/GridCell.js +1 -1
- package/node/components/panel/GridColumnsPanel.js +1 -2
- package/node/components/panel/GridPanelContent.js +7 -3
- package/node/components/panel/GridPanelFooter.js +5 -4
- package/node/components/panel/filterPanel/GridFilterForm.js +15 -15
- package/node/constants/dataGridPropsDefaultValues.js +1 -1
- package/node/hooks/core/useGridStateInitialization.js +3 -3
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/overlays/useGridOverlays.js +3 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +5 -4
- package/node/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/node/hooks/features/rows/useGridRows.js +5 -5
- package/node/hooks/features/sorting/gridSortingSelector.js +12 -1
- package/node/hooks/features/sorting/index.js +24 -16
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -8
- package/node/hooks/utils/useGridSelector.js +8 -47
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -22
- package/node/locales/roRO.js +18 -20
- package/node/utils/createSelector.js +4 -125
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -16
- package/utils/createSelector.js +1 -120
|
@@ -92,10 +92,7 @@ export const useGridVirtualScroller = () => {
|
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
94
94
|
const initialRect = node.getBoundingClientRect();
|
|
95
|
-
let lastSize =
|
|
96
|
-
width: initialRect.width,
|
|
97
|
-
height: initialRect.height
|
|
98
|
-
};
|
|
95
|
+
let lastSize = roundDimensions(initialRect);
|
|
99
96
|
apiRef.current.publishEvent('resize', lastSize);
|
|
100
97
|
if (typeof ResizeObserver === 'undefined') {
|
|
101
98
|
return undefined;
|
|
@@ -105,10 +102,7 @@ export const useGridVirtualScroller = () => {
|
|
|
105
102
|
if (!entry) {
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
108
|
-
const newSize =
|
|
109
|
-
width: entry.contentRect.width,
|
|
110
|
-
height: entry.contentRect.height
|
|
111
|
-
};
|
|
105
|
+
const newSize = roundDimensions(entry.contentRect);
|
|
112
106
|
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
113
107
|
return;
|
|
114
108
|
}
|
|
@@ -784,4 +778,13 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
|
|
|
784
778
|
// eslint unable to figure out enum exhaustiveness
|
|
785
779
|
throw new Error('unreachable');
|
|
786
780
|
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// Round to avoid issues with subpixel rendering
|
|
784
|
+
// https://github.com/mui/mui-x/issues/15721
|
|
785
|
+
function roundDimensions(dimensions) {
|
|
786
|
+
return {
|
|
787
|
+
width: Math.round(dimensions.width * 10) / 10,
|
|
788
|
+
height: Math.round(dimensions.height * 10) / 10
|
|
789
|
+
};
|
|
787
790
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
3
2
|
import type { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
4
|
-
import type { OutputSelector
|
|
5
|
-
type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) |
|
|
6
|
-
export declare const objectShallowCompare:
|
|
3
|
+
import type { OutputSelector } from '../../utils/createSelector';
|
|
4
|
+
type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) | OutputSelector<Api['state'], Args, T>;
|
|
5
|
+
export declare const objectShallowCompare: (a: unknown, b: unknown) => boolean;
|
|
7
6
|
export declare const argsEqual: (prev: any, curr: any) => boolean;
|
|
8
|
-
export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: React.MutableRefObject<Api>, selector:
|
|
9
|
-
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: React.MutableRefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <U = T>(a: U, b: U) => boolean) => T;
|
|
7
|
+
export declare const useGridSelector: <Api extends GridApiCommon, Args, T>(apiRef: React.MutableRefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <U = T>(a: U, b: U) => boolean) => T;
|
|
10
8
|
export {};
|
|
@@ -6,20 +6,11 @@ import { useOnMount } from "./useOnMount.js";
|
|
|
6
6
|
function isOutputSelector(selector) {
|
|
7
7
|
return selector.acceptsApiRef;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
function applySelector(apiRef, selector) {
|
|
11
|
-
if (isOutputSelector(selector)) {
|
|
12
|
-
return selector(apiRef);
|
|
13
|
-
}
|
|
14
|
-
return selector(apiRef.current.state);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// TODO v8: Rename this function to `applySelector`
|
|
18
|
-
function applySelectorV8(apiRef, selector, args, instanceId) {
|
|
9
|
+
function applySelector(apiRef, selector, args, instanceId) {
|
|
19
10
|
if (isOutputSelector(selector)) {
|
|
20
11
|
return selector(apiRef, args);
|
|
21
12
|
}
|
|
22
|
-
return selector(apiRef.current.state, instanceId);
|
|
13
|
+
return selector(apiRef.current.state, args, instanceId);
|
|
23
14
|
}
|
|
24
15
|
const defaultCompare = Object.is;
|
|
25
16
|
export const objectShallowCompare = fastObjectShallowCompare;
|
|
@@ -44,36 +35,7 @@ const createRefs = () => ({
|
|
|
44
35
|
selector: null,
|
|
45
36
|
args: null
|
|
46
37
|
});
|
|
47
|
-
|
|
48
|
-
// TODO v8: Remove this function
|
|
49
|
-
export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
50
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
51
|
-
if (!apiRef.current.state) {
|
|
52
|
-
warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const refs = useLazyRef(createRefs);
|
|
56
|
-
const didInit = refs.current.selector !== null;
|
|
57
|
-
const [state, setState] = React.useState(
|
|
58
|
-
// We don't use an initialization function to avoid allocations
|
|
59
|
-
didInit ? null : applySelector(apiRef, selector));
|
|
60
|
-
refs.current.state = state;
|
|
61
|
-
refs.current.equals = equals;
|
|
62
|
-
refs.current.selector = selector;
|
|
63
|
-
useOnMount(() => {
|
|
64
|
-
return apiRef.current.store.subscribe(() => {
|
|
65
|
-
const newState = applySelector(apiRef, refs.current.selector);
|
|
66
|
-
if (!refs.current.equals(refs.current.state, newState)) {
|
|
67
|
-
refs.current.state = newState;
|
|
68
|
-
setState(newState);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
return state;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// TODO v8: Rename this function to `useGridSelector`
|
|
76
|
-
export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
|
|
38
|
+
export const useGridSelector = (apiRef, selector, args = undefined, equals = defaultCompare) => {
|
|
77
39
|
if (process.env.NODE_ENV !== 'production') {
|
|
78
40
|
if (!apiRef.current.state) {
|
|
79
41
|
warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
|
|
@@ -83,14 +45,14 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
83
45
|
const didInit = refs.current.selector !== null;
|
|
84
46
|
const [state, setState] = React.useState(
|
|
85
47
|
// We don't use an initialization function to avoid allocations
|
|
86
|
-
didInit ? null :
|
|
48
|
+
didInit ? null : applySelector(apiRef, selector, args, apiRef.current.instanceId));
|
|
87
49
|
refs.current.state = state;
|
|
88
50
|
refs.current.equals = equals;
|
|
89
51
|
refs.current.selector = selector;
|
|
90
52
|
const prevArgs = refs.current.args;
|
|
91
53
|
refs.current.args = args;
|
|
92
54
|
if (didInit && !argsEqual(prevArgs, args)) {
|
|
93
|
-
const newState =
|
|
55
|
+
const newState = applySelector(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
94
56
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
95
57
|
refs.current.state = newState;
|
|
96
58
|
setState(newState);
|
|
@@ -98,7 +60,7 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
98
60
|
}
|
|
99
61
|
useOnMount(() => {
|
|
100
62
|
return apiRef.current.store.subscribe(() => {
|
|
101
|
-
const newState =
|
|
63
|
+
const newState = applySelector(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
102
64
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
103
65
|
refs.current.state = newState;
|
|
104
66
|
setState(newState);
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { useGridRowSelection, rowSelectionStateInitializer, } from '../hooks/fea
|
|
|
58
58
|
export { useGridRowSelectionPreProcessors } from '../hooks/features/rowSelection/useGridRowSelectionPreProcessors';
|
|
59
59
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
60
60
|
export type { GridSortingModelApplier } from '../hooks/features/sorting/gridSortingState';
|
|
61
|
+
export { gridSortedRowIndexLookupSelector } from '../hooks/features/sorting/gridSortingSelector';
|
|
61
62
|
export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
62
63
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
63
64
|
export { dimensionsStateInitializer, useGridDimensions, } from '../hooks/features/dimensions/useGridDimensions';
|
|
@@ -76,8 +77,7 @@ export type * from '../models/props/DataGridProps';
|
|
|
76
77
|
export type * from '../models/gridDataSource';
|
|
77
78
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
78
79
|
export * from '../utils/createControllablePromise';
|
|
79
|
-
export { createSelector,
|
|
80
|
-
export { useGridSelectorV8 } from '../hooks/utils/useGridSelector';
|
|
80
|
+
export { createSelector, createSelectorMemoized } from '../utils/createSelector';
|
|
81
81
|
export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
82
82
|
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
|
|
83
83
|
export { isNavigationKey, isPasteShortcut, isCopyShortcut } from '../utils/keyboardUtils';
|
package/internals/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export { calculatePinnedRowsHeight } from "../hooks/features/rows/gridRowsUtils.
|
|
|
47
47
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
|
|
48
48
|
export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
|
|
49
49
|
export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
|
|
50
|
+
export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/gridSortingSelector.js";
|
|
50
51
|
export { useGridScroll } from "../hooks/features/scroll/useGridScroll.js";
|
|
51
52
|
export { useGridEvents } from "../hooks/features/events/useGridEvents.js";
|
|
52
53
|
export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features/dimensions/useGridDimensions.js";
|
|
@@ -61,8 +62,7 @@ export { useGridVisibleRows, getVisibleRows } from "../hooks/utils/useGridVisibl
|
|
|
61
62
|
export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js";
|
|
62
63
|
export { getColumnsToExport, defaultGetRowsToExport } from "../hooks/features/export/utils.js";
|
|
63
64
|
export * from "../utils/createControllablePromise.js";
|
|
64
|
-
export { createSelector,
|
|
65
|
-
export { useGridSelectorV8 } from "../hooks/utils/useGridSelector.js";
|
|
65
|
+
export { createSelector, createSelectorMemoized } from "../utils/createSelector.js";
|
|
66
66
|
export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
67
67
|
export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from "../utils/domUtils.js";
|
|
68
68
|
export { isNavigationKey, isPasteShortcut, isCopyShortcut } from "../utils/keyboardUtils.js";
|
package/locales/roRO.js
CHANGED
|
@@ -24,16 +24,15 @@ const roROGrid = {
|
|
|
24
24
|
toolbarQuickFilterLabel: 'Căutare',
|
|
25
25
|
toolbarQuickFilterDeleteIconLabel: 'Ștergere',
|
|
26
26
|
// Prompt toolbar field
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
toolbarPromptControlPlaceholder: 'Scrie un prompt…',
|
|
28
|
+
toolbarPromptControlWithRecordingPlaceholder: 'Scrie sau înregistrează un prompt…',
|
|
29
|
+
toolbarPromptControlRecordingPlaceholder: 'Ascultare prompt…',
|
|
30
|
+
toolbarPromptControlLabel: 'Introducere prompt',
|
|
31
|
+
toolbarPromptControlRecordButtonDefaultLabel: 'Înregistrează',
|
|
32
|
+
toolbarPromptControlRecordButtonActiveLabel: 'Oprește înregistrare',
|
|
33
|
+
toolbarPromptControlSendActionLabel: 'Trimite',
|
|
34
|
+
toolbarPromptControlSendActionAriaLabel: 'Trimite prompt',
|
|
35
|
+
toolbarPromptControlErrorMessage: 'A apărut o eroare la procesare. Încercați din nou cu un alt prompt.',
|
|
37
36
|
// Export selector toolbar button text
|
|
38
37
|
toolbarExport: 'Export',
|
|
39
38
|
toolbarExportLabel: 'Export',
|
|
@@ -41,12 +40,11 @@ const roROGrid = {
|
|
|
41
40
|
toolbarExportPrint: 'Printare',
|
|
42
41
|
toolbarExportExcel: 'Download în format Excel',
|
|
43
42
|
// Columns management text
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
columnsManagementSearchTitle: 'Caută',
|
|
44
|
+
columnsManagementNoColumns: 'Nicio coloană',
|
|
45
|
+
columnsManagementShowHideAllText: 'Arată/Ascunde tot',
|
|
46
|
+
columnsManagementReset: 'Resetează',
|
|
47
|
+
columnsManagementDeleteIconLabel: 'Șterge',
|
|
50
48
|
// Filter panel text
|
|
51
49
|
filterPanelAddFilter: 'Adăugare filtru',
|
|
52
50
|
filterPanelRemoveAll: 'Șterge tot',
|
|
@@ -60,9 +58,9 @@ const roROGrid = {
|
|
|
60
58
|
filterPanelInputPlaceholder: 'Filtrare valoare',
|
|
61
59
|
// Filter operators text
|
|
62
60
|
filterOperatorContains: 'conține',
|
|
63
|
-
|
|
61
|
+
filterOperatorDoesNotContain: 'nu conține',
|
|
64
62
|
filterOperatorEquals: 'este egal cu',
|
|
65
|
-
|
|
63
|
+
filterOperatorDoesNotEqual: 'nu este egal cu',
|
|
66
64
|
filterOperatorStartsWith: 'începe cu',
|
|
67
65
|
filterOperatorEndsWith: 'se termină cu',
|
|
68
66
|
filterOperatorIs: 'este',
|
|
@@ -82,9 +80,9 @@ const roROGrid = {
|
|
|
82
80
|
'filterOperator<=': '<=',
|
|
83
81
|
// Header filter operators text
|
|
84
82
|
headerFilterOperatorContains: 'Conține',
|
|
85
|
-
|
|
83
|
+
headerFilterOperatorDoesNotContain: 'Nu conține',
|
|
86
84
|
headerFilterOperatorEquals: 'Egal cu',
|
|
87
|
-
|
|
85
|
+
headerFilterOperatorDoesNotEqual: 'Nu este egal cu',
|
|
88
86
|
headerFilterOperatorStartsWith: 'Începe cu',
|
|
89
87
|
headerFilterOperatorEndsWith: 'Se termină cu',
|
|
90
88
|
headerFilterOperatorIs: 'Este',
|
|
@@ -33,5 +33,5 @@ export interface GridStatePrivateApi<State extends GridStateCommunity> {
|
|
|
33
33
|
* Updates a control state that binds the model, the onChange prop, and the grid state together.
|
|
34
34
|
* @param {GridControlStateItem>} controlState The [[GridControlStateItem]] to be registered.
|
|
35
35
|
*/
|
|
36
|
-
registerControlState: <E extends keyof GridControlledStateEventLookup>(controlState: GridControlStateItem<State, E>) => void;
|
|
36
|
+
registerControlState: <E extends keyof GridControlledStateEventLookup, Args>(controlState: GridControlStateItem<State, Args, E>) => void;
|
|
37
37
|
}
|
|
@@ -2,10 +2,10 @@ import { GridCallbackDetails } from './api/gridCallbackDetails';
|
|
|
2
2
|
import type { GridEventLookup, GridControlledStateEventLookup } from './events';
|
|
3
3
|
import type { OutputSelector } from '../utils/createSelector';
|
|
4
4
|
import { GridStateCommunity } from './gridStateCommunity';
|
|
5
|
-
export interface GridControlStateItem<State extends GridStateCommunity, E extends keyof GridControlledStateEventLookup> {
|
|
5
|
+
export interface GridControlStateItem<State extends GridStateCommunity, Args, E extends keyof GridControlledStateEventLookup> {
|
|
6
6
|
stateId: string;
|
|
7
7
|
propModel?: GridEventLookup[E]['params'];
|
|
8
|
-
stateSelector: OutputSelector<State, GridControlledStateEventLookup[E]['params']> | ((state: State) => GridControlledStateEventLookup[E]['params']);
|
|
8
|
+
stateSelector: OutputSelector<State, Args, GridControlledStateEventLookup[E]['params']> | ((state: State) => GridControlledStateEventLookup[E]['params']);
|
|
9
9
|
propOnChange?: (model: GridControlledStateEventLookup[E]['params'], details: GridCallbackDetails) => void;
|
|
10
10
|
changeEvent: E;
|
|
11
11
|
}
|
|
@@ -352,7 +352,7 @@ export interface DataGridPropsWithDefaultValues<R extends GridValidRowModel = an
|
|
|
352
352
|
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
|
|
353
353
|
* @default false
|
|
354
354
|
*/
|
|
355
|
-
|
|
355
|
+
rowSpanning: boolean;
|
|
356
356
|
/**
|
|
357
357
|
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
|
|
358
358
|
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.
|
|
@@ -701,6 +701,11 @@ DataGridRaw.propTypes = {
|
|
|
701
701
|
* @default "margin"
|
|
702
702
|
*/
|
|
703
703
|
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
|
|
704
|
+
/**
|
|
705
|
+
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
|
|
706
|
+
* @default false
|
|
707
|
+
*/
|
|
708
|
+
rowSpanning: PropTypes.bool,
|
|
704
709
|
/**
|
|
705
710
|
* Override the height/width of the Data Grid inner scrollbar.
|
|
706
711
|
*/
|
|
@@ -746,11 +751,6 @@ DataGridRaw.propTypes = {
|
|
|
746
751
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
747
752
|
*/
|
|
748
753
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
749
|
-
/**
|
|
750
|
-
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
|
|
751
|
-
* @default false
|
|
752
|
-
*/
|
|
753
|
-
unstable_rowSpanning: PropTypes.bool,
|
|
754
754
|
/**
|
|
755
755
|
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
|
|
756
756
|
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.
|
|
@@ -144,7 +144,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
144
144
|
disableColumnReorder
|
|
145
145
|
} = rootProps;
|
|
146
146
|
const rowReordering = rootProps.rowReordering;
|
|
147
|
-
const heightEntry = useGridSelector(apiRef, () => _extends({}, apiRef.current.getRowHeightEntry(rowId)), objectShallowCompare);
|
|
147
|
+
const heightEntry = useGridSelector(apiRef, () => _extends({}, apiRef.current.getRowHeightEntry(rowId)), undefined, objectShallowCompare);
|
|
148
148
|
const style = React.useMemo(() => {
|
|
149
149
|
if (isNotVisible) {
|
|
150
150
|
return {
|
|
@@ -89,6 +89,13 @@ function GridActionsCell(props) {
|
|
|
89
89
|
const hideMenu = () => {
|
|
90
90
|
setOpen(false);
|
|
91
91
|
};
|
|
92
|
+
const toggleMenu = () => {
|
|
93
|
+
if (open) {
|
|
94
|
+
hideMenu();
|
|
95
|
+
} else {
|
|
96
|
+
showMenu();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
92
99
|
const handleTouchRippleRef = index => instance => {
|
|
93
100
|
touchRippleRefs.current[index] = instance;
|
|
94
101
|
};
|
|
@@ -159,7 +166,7 @@ function GridActionsCell(props) {
|
|
|
159
166
|
"aria-controls": open ? menuId : undefined,
|
|
160
167
|
role: "menuitem",
|
|
161
168
|
size: "small",
|
|
162
|
-
onClick:
|
|
169
|
+
onClick: toggleMenu,
|
|
163
170
|
touchRippleRef: handleTouchRippleRef(buttonId),
|
|
164
171
|
tabIndex: focusedButtonIndex === iconButtons.length ? tabIndex : -1
|
|
165
172
|
}, rootProps.slotProps?.baseIconButton, {
|
|
@@ -120,7 +120,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
120
120
|
const result = apiRef.current.getCellParams(rowId, field);
|
|
121
121
|
result.api = apiRef.current;
|
|
122
122
|
return result;
|
|
123
|
-
}, objectShallowCompare);
|
|
123
|
+
}, undefined, objectShallowCompare);
|
|
124
124
|
const isSelected = useGridSelector(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
125
125
|
id: rowId,
|
|
126
126
|
field
|
|
@@ -2,13 +2,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { GridPanelWrapper } from "./GridPanelWrapper.js";
|
|
5
|
-
import { GridColumnsManagement } from "../columnsManagement/index.js";
|
|
6
5
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
function GridColumnsPanel(props) {
|
|
9
8
|
const rootProps = useGridRootProps();
|
|
10
9
|
return /*#__PURE__*/_jsx(GridPanelWrapper, _extends({}, props, {
|
|
11
|
-
children: /*#__PURE__*/_jsx(
|
|
10
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.columnsManagement, _extends({}, rootProps.slotProps?.columnsManagement))
|
|
12
11
|
}));
|
|
13
12
|
}
|
|
14
13
|
process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
@@ -22,13 +22,17 @@ const GridPanelContentRoot = styled('div', {
|
|
|
22
22
|
name: 'MuiDataGrid',
|
|
23
23
|
slot: 'PanelContent',
|
|
24
24
|
overridesResolver: (props, styles) => styles.panelContent
|
|
25
|
-
})({
|
|
25
|
+
})(({
|
|
26
|
+
theme
|
|
27
|
+
}) => ({
|
|
26
28
|
display: 'flex',
|
|
27
29
|
flexDirection: 'column',
|
|
28
30
|
overflow: 'auto',
|
|
29
31
|
flex: '1 1',
|
|
30
|
-
maxHeight: 400
|
|
31
|
-
|
|
32
|
+
maxHeight: 400,
|
|
33
|
+
padding: theme.spacing(2.5, 1.5, 2, 1),
|
|
34
|
+
gap: theme.spacing(2.5)
|
|
35
|
+
}));
|
|
32
36
|
function GridPanelContent(props) {
|
|
33
37
|
const {
|
|
34
38
|
className
|
|
@@ -4,7 +4,7 @@ const _excluded = ["className"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { styled } from '@mui/
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
8
|
import composeClasses from '@mui/utils/composeClasses';
|
|
9
9
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
10
10
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
@@ -25,9 +25,10 @@ const GridPanelFooterRoot = styled('div', {
|
|
|
25
25
|
})(({
|
|
26
26
|
theme
|
|
27
27
|
}) => ({
|
|
28
|
-
padding: theme.spacing(
|
|
28
|
+
padding: theme.spacing(1),
|
|
29
29
|
display: 'flex',
|
|
30
|
-
justifyContent: 'space-between'
|
|
30
|
+
justifyContent: 'space-between',
|
|
31
|
+
borderTop: `1px solid ${theme.palette.divider}`
|
|
31
32
|
}));
|
|
32
33
|
function GridPanelFooter(props) {
|
|
33
34
|
const {
|
|
@@ -39,27 +39,22 @@ const GridFilterFormRoot = styled('div', {
|
|
|
39
39
|
theme
|
|
40
40
|
}) => ({
|
|
41
41
|
display: 'flex',
|
|
42
|
-
|
|
42
|
+
gap: theme.spacing(1.5)
|
|
43
43
|
}));
|
|
44
44
|
const FilterFormDeleteIcon = styled('div', {
|
|
45
45
|
name: 'MuiDataGrid',
|
|
46
46
|
slot: 'FilterFormDeleteIcon',
|
|
47
47
|
overridesResolver: (_, styles) => styles.filterFormDeleteIcon
|
|
48
|
-
})(
|
|
49
|
-
theme
|
|
50
|
-
}) => ({
|
|
48
|
+
})({
|
|
51
49
|
flexShrink: 0,
|
|
52
|
-
justifyContent: '
|
|
53
|
-
|
|
54
|
-
marginBottom: theme.spacing(0.2)
|
|
55
|
-
}));
|
|
50
|
+
justifyContent: 'center'
|
|
51
|
+
});
|
|
56
52
|
const FilterFormLogicOperatorInput = styled('div', {
|
|
57
53
|
name: 'MuiDataGrid',
|
|
58
54
|
slot: 'FilterFormLogicOperatorInput',
|
|
59
55
|
overridesResolver: (_, styles) => styles.filterFormLogicOperatorInput
|
|
60
56
|
})({
|
|
61
|
-
minWidth:
|
|
62
|
-
marginRight: 5,
|
|
57
|
+
minWidth: 75,
|
|
63
58
|
justifyContent: 'end'
|
|
64
59
|
});
|
|
65
60
|
const FilterFormColumnInput = styled('div', {
|
|
@@ -261,7 +256,6 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
261
256
|
ownerState: rootProps
|
|
262
257
|
}, other, {
|
|
263
258
|
children: [/*#__PURE__*/_jsx(FilterFormDeleteIcon, _extends({
|
|
264
|
-
variant: "standard",
|
|
265
259
|
as: rootProps.slots.baseFormControl
|
|
266
260
|
}, baseFormControlProps, deleteIconProps, {
|
|
267
261
|
className: clsx(classes.deleteIcon, baseFormControlProps.className, deleteIconProps.className),
|
|
@@ -278,7 +272,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
278
272
|
})
|
|
279
273
|
}))
|
|
280
274
|
})), /*#__PURE__*/_jsx(FilterFormLogicOperatorInput, _extends({
|
|
281
|
-
variant: "
|
|
275
|
+
variant: "outlined",
|
|
276
|
+
size: "small",
|
|
282
277
|
as: rootProps.slots.baseFormControl
|
|
283
278
|
}, baseFormControlProps, logicOperatorInputProps, {
|
|
284
279
|
sx: [hasLogicOperatorColumn ? {
|
|
@@ -308,7 +303,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
308
303
|
}), apiRef.current.getLocaleText(getLogicOperatorLocaleKey(logicOperator))))
|
|
309
304
|
}))
|
|
310
305
|
})), /*#__PURE__*/_jsxs(FilterFormColumnInput, _extends({
|
|
311
|
-
variant: "
|
|
306
|
+
variant: "outlined",
|
|
307
|
+
size: "small",
|
|
312
308
|
as: rootProps.slots.baseFormControl
|
|
313
309
|
}, baseFormControlProps, columnInputProps, {
|
|
314
310
|
className: clsx(classes.columnInput, baseFormControlProps.className, columnInputProps.className),
|
|
@@ -333,7 +329,8 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
333
329
|
}), getColumnLabel(col)))
|
|
334
330
|
}))]
|
|
335
331
|
})), /*#__PURE__*/_jsxs(FilterFormOperatorInput, _extends({
|
|
336
|
-
variant: "
|
|
332
|
+
variant: "outlined",
|
|
333
|
+
size: "small",
|
|
337
334
|
as: rootProps.slots.baseFormControl
|
|
338
335
|
}, baseFormControlProps, operatorInputProps, {
|
|
339
336
|
className: clsx(classes.operatorInput, baseFormControlProps.className, operatorInputProps.className),
|
|
@@ -359,12 +356,15 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
359
356
|
}), operator.label || apiRef.current.getLocaleText(`filterOperator${capitalize(operator.value)}`)))
|
|
360
357
|
}))]
|
|
361
358
|
})), /*#__PURE__*/_jsx(FilterFormValueInput, _extends({
|
|
362
|
-
variant: "
|
|
359
|
+
variant: "outlined",
|
|
360
|
+
size: "small",
|
|
363
361
|
as: rootProps.slots.baseFormControl
|
|
364
362
|
}, baseFormControlProps, valueInputPropsOther, {
|
|
365
363
|
className: clsx(classes.valueInput, baseFormControlProps.className, valueInputPropsOther.className),
|
|
366
364
|
ownerState: rootProps,
|
|
367
365
|
children: currentOperator?.InputComponent ? /*#__PURE__*/_jsx(currentOperator.InputComponent, _extends({
|
|
366
|
+
variant: "outlined",
|
|
367
|
+
size: "small",
|
|
368
368
|
apiRef: apiRef,
|
|
369
369
|
item: item,
|
|
370
370
|
applyValue: applyFilterChanges,
|
|
@@ -48,11 +48,11 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
48
48
|
rows: [],
|
|
49
49
|
rowSelection: true,
|
|
50
50
|
rowSpacingType: 'margin',
|
|
51
|
+
rowSpanning: false,
|
|
51
52
|
showCellVerticalBorder: false,
|
|
52
53
|
showColumnVerticalBorder: false,
|
|
53
54
|
sortingMode: 'client',
|
|
54
55
|
sortingOrder: ['asc', 'desc', null],
|
|
55
56
|
throttleRowsMs: 0,
|
|
56
|
-
unstable_rowSpanning: false,
|
|
57
57
|
virtualizeColumnsWithAutoRowHeight: false
|
|
58
58
|
};
|
|
@@ -24,8 +24,8 @@ export const useGridStateInitialization = apiRef => {
|
|
|
24
24
|
const updatedControlStateIds = [];
|
|
25
25
|
Object.keys(controlStateMapRef.current).forEach(stateId => {
|
|
26
26
|
const controlState = controlStateMapRef.current[stateId];
|
|
27
|
-
const oldSubState = controlState.stateSelector(apiRef.current.state, apiRef.current.instanceId);
|
|
28
|
-
const newSubState = controlState.stateSelector(newState, apiRef.current.instanceId);
|
|
27
|
+
const oldSubState = controlState.stateSelector(apiRef.current.state, undefined, apiRef.current.instanceId);
|
|
28
|
+
const newSubState = controlState.stateSelector(newState, undefined, apiRef.current.instanceId);
|
|
29
29
|
if (newSubState === oldSubState) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
@@ -57,7 +57,7 @@ export const useGridStateInitialization = apiRef => {
|
|
|
57
57
|
hasPropChanged
|
|
58
58
|
} = updatedControlStateIds[0];
|
|
59
59
|
const controlState = controlStateMapRef.current[stateId];
|
|
60
|
-
const model = controlState.stateSelector(newState, apiRef.current.instanceId);
|
|
60
|
+
const model = controlState.stateSelector(newState, undefined, apiRef.current.instanceId);
|
|
61
61
|
if (controlState.propOnChange && hasPropChanged) {
|
|
62
62
|
controlState.propOnChange(model, {
|
|
63
63
|
reason,
|
|
@@ -59,7 +59,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
59
59
|
});
|
|
60
60
|
const updateFilteredRows = React.useCallback(() => {
|
|
61
61
|
apiRef.current.setState(state => {
|
|
62
|
-
const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
|
|
62
|
+
const filterModel = gridFilterModelSelector(state, undefined, apiRef.current.instanceId);
|
|
63
63
|
const filterState = apiRef.current.getFilterState(filterModel);
|
|
64
64
|
const newState = _extends({}, state, {
|
|
65
65
|
filter: _extends({}, state.filter, filterState)
|
|
@@ -5,6 +5,7 @@ import { useGridApiContext } from "../../utils/useGridApiContext.js";
|
|
|
5
5
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
6
6
|
import { gridExpandedRowCountSelector } from "../filter/index.js";
|
|
7
7
|
import { gridRowCountSelector, gridRowsLoadingSelector } from "../rows/index.js";
|
|
8
|
+
import { gridPinnedRowsCountSelector } from "../rows/gridRowsSelector.js";
|
|
8
9
|
import { GridOverlayWrapper } from "../../../components/base/GridOverlays.js";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
/**
|
|
@@ -16,7 +17,8 @@ export const useGridOverlays = () => {
|
|
|
16
17
|
const rootProps = useGridRootProps();
|
|
17
18
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
18
19
|
const visibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
|
|
19
|
-
const
|
|
20
|
+
const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
21
|
+
const noRows = totalRowCount === 0 && pinnedRowsCount === 0;
|
|
20
22
|
const loading = useGridSelector(apiRef, gridRowsLoadingSelector);
|
|
21
23
|
const showNoRowsOverlay = !loading && noRows;
|
|
22
24
|
const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
|
|
@@ -313,11 +313,12 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
313
313
|
|
|
314
314
|
const isMultipleSelectionDisabled = !checkboxSelection && !hasCtrlKey && !isKeyboardEvent(event);
|
|
315
315
|
const resetSelection = !canHaveMultipleSelection || isMultipleSelectionDisabled;
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
318
|
-
apiRef.current.selectRow(id,
|
|
316
|
+
const selectedRowsCount = apiRef.current.getSelectedRows().size;
|
|
317
|
+
if (canHaveMultipleSelection && selectedRowsCount > 1 && !hasCtrlKey) {
|
|
318
|
+
apiRef.current.selectRow(id, true, resetSelection);
|
|
319
319
|
} else {
|
|
320
|
-
apiRef.current.
|
|
320
|
+
const isSelected = apiRef.current.isRowSelected(id);
|
|
321
|
+
apiRef.current.selectRow(id, !isSelected, resetSelection);
|
|
321
322
|
}
|
|
322
323
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection]);
|
|
323
324
|
const handleRowClick = React.useCallback((params, event) => {
|