@mui/x-data-grid 7.13.0 → 7.15.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 +151 -2
- package/components/cell/GridActionsCell.js +3 -3
- package/components/cell/GridCell.js +11 -12
- package/components/cell/GridEditSingleSelectCell.js +2 -3
- package/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/GridPanel.js +1 -2
- package/components/panel/filterPanel/GridFilterForm.js +9 -4
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarQuickFilter.js +5 -3
- package/hooks/core/gridCoreSelector.d.ts +1 -1
- package/hooks/core/gridCoreSelector.js +1 -1
- package/hooks/core/useGridInitialization.js +2 -2
- package/hooks/core/{useGridTheme.d.ts → useGridIsRtl.d.ts} +1 -1
- package/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
- package/hooks/features/columnResize/useGridColumnResize.js +5 -5
- package/hooks/features/columns/gridColumnsSelector.js +3 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
- package/hooks/features/rows/useGridParamsApi.js +2 -1
- package/hooks/features/scroll/useGridScroll.js +4 -4
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
- package/hooks/utils/useGridSelector.d.ts +4 -1
- package/hooks/utils/useGridSelector.js +38 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/locales/csCZ.js +4 -5
- package/locales/heIL.js +4 -5
- package/models/gridDataSource.d.ts +6 -6
- package/models/gridStateCommunity.d.ts +1 -2
- package/models/params/gridCellParams.d.ts +4 -0
- package/modern/components/cell/GridActionsCell.js +3 -3
- package/modern/components/cell/GridCell.js +11 -12
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -3
- package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
- package/modern/components/panel/GridPanel.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterForm.js +9 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -3
- package/modern/hooks/core/gridCoreSelector.js +1 -1
- package/modern/hooks/core/useGridInitialization.js +2 -2
- package/modern/hooks/core/{useGridTheme.js → useGridIsRtl.js} +7 -7
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
- package/modern/hooks/features/columnResize/useGridColumnResize.js +5 -5
- package/modern/hooks/features/columns/gridColumnsSelector.js +3 -3
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
- package/modern/hooks/features/rows/useGridParamsApi.js +2 -1
- package/modern/hooks/features/scroll/useGridScroll.js +4 -4
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
- package/modern/hooks/utils/useGridSelector.js +38 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/locales/csCZ.js +4 -5
- package/modern/locales/heIL.js +4 -5
- package/modern/utils/createSelector.js +116 -0
- package/modern/utils/keyboardUtils.js +1 -11
- package/node/components/cell/GridActionsCell.js +3 -3
- package/node/components/cell/GridCell.js +11 -12
- package/node/components/cell/GridEditSingleSelectCell.js +2 -3
- package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
- package/node/components/panel/GridPanel.js +1 -2
- package/node/components/panel/filterPanel/GridFilterForm.js +9 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +5 -3
- package/node/hooks/core/gridCoreSelector.js +3 -3
- package/node/hooks/core/useGridInitialization.js +2 -2
- package/node/hooks/core/{useGridTheme.js → useGridIsRtl.js} +9 -9
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +5 -5
- package/node/hooks/features/columns/gridColumnsSelector.js +2 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +19 -20
- package/node/hooks/features/rows/useGridParamsApi.js +2 -1
- package/node/hooks/features/scroll/useGridScroll.js +4 -4
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +13 -13
- package/node/hooks/utils/useGridSelector.js +41 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +22 -0
- package/node/locales/csCZ.js +4 -5
- package/node/locales/heIL.js +4 -5
- package/node/utils/createSelector.js +119 -2
- package/node/utils/keyboardUtils.js +2 -15
- package/package.json +6 -6
- package/utils/createSelector.d.ts +19 -0
- package/utils/createSelector.js +116 -0
- package/utils/keyboardUtils.d.ts +1 -9
- package/utils/keyboardUtils.js +1 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.0",
|
|
4
4
|
"description": "The Community plan edition of the Data Grid components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"directory": "packages/x-data-grid"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.25.
|
|
41
|
-
"@mui/
|
|
42
|
-
"@mui/utils": "^5.16.5",
|
|
40
|
+
"@babel/runtime": "^7.25.4",
|
|
41
|
+
"@mui/utils": "^5.16.6",
|
|
43
42
|
"clsx": "^2.1.1",
|
|
44
43
|
"prop-types": "^15.8.1",
|
|
45
44
|
"reselect": "^4.1.8",
|
|
46
|
-
"@mui/x-internals": "7.
|
|
45
|
+
"@mui/x-internals": "7.15.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
48
|
"@emotion/react": "^11.9.0",
|
|
50
49
|
"@emotion/styled": "^11.8.1",
|
|
51
|
-
"@mui/material": "^5.15.14",
|
|
50
|
+
"@mui/material": "^5.15.14 || ^6.0.0",
|
|
51
|
+
"@mui/system": "^5.15.14 || ^6.0.0",
|
|
52
52
|
"react": "^17.0.0 || ^18.0.0",
|
|
53
53
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
54
54
|
},
|
|
@@ -9,6 +9,14 @@ export interface OutputSelector<State, Result> {
|
|
|
9
9
|
(state: State, instanceId: GridCoreApi['instanceId']): Result;
|
|
10
10
|
acceptsApiRef: boolean;
|
|
11
11
|
}
|
|
12
|
+
export interface OutputSelectorV8<State, Args, Result> {
|
|
13
|
+
(apiRef: React.MutableRefObject<{
|
|
14
|
+
state: State;
|
|
15
|
+
instanceId: GridCoreApi['instanceId'];
|
|
16
|
+
}>, args: Args): Result;
|
|
17
|
+
(state: State, instanceId: GridCoreApi['instanceId']): Result;
|
|
18
|
+
acceptsApiRef: boolean;
|
|
19
|
+
}
|
|
12
20
|
type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ? F extends {
|
|
13
21
|
state: infer F2;
|
|
14
22
|
} ? F2 : F : never;
|
|
@@ -17,7 +25,18 @@ type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends
|
|
|
17
25
|
...other: infer R
|
|
18
26
|
] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
|
|
19
27
|
type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
|
|
28
|
+
type SelectorResultArrayWithArgs<Selectors extends ReadonlyArray<Selector<any>>, Args> = [
|
|
29
|
+
...SelectorResultArray<Selectors>,
|
|
30
|
+
Args
|
|
31
|
+
];
|
|
32
|
+
type SelectorArgsV8<Selectors extends ReadonlyArray<Selector<any>>, Args, Result> = [
|
|
33
|
+
selectors: [...Selectors],
|
|
34
|
+
combiner: (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result
|
|
35
|
+
] | [...Selectors, (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result];
|
|
20
36
|
type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Result>(...items: SelectorArgs<Selectors, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Result>;
|
|
37
|
+
type CreateSelectorFunctionV8 = <Selectors extends ReadonlyArray<Selector<any>>, Args, Result>(...items: SelectorArgsV8<Selectors, Args, Result>) => OutputSelectorV8<StateFromSelectorList<Selectors>, Args, Result>;
|
|
21
38
|
export declare const createSelector: CreateSelectorFunction;
|
|
39
|
+
export declare const createSelectorV8: CreateSelectorFunctionV8;
|
|
22
40
|
export declare const createSelectorMemoized: CreateSelectorFunction;
|
|
41
|
+
export declare const createSelectorMemoizedV8: CreateSelectorFunctionV8;
|
|
23
42
|
export {};
|
package/utils/createSelector.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { createSelector as reselectCreateSelector } from 'reselect';
|
|
2
2
|
import { warnOnce } from '../internals/utils/warning';
|
|
3
|
+
|
|
4
|
+
// TODO v8: Remove this type
|
|
5
|
+
|
|
6
|
+
// TODO v8: Rename this type to `OutputSelector`
|
|
7
|
+
|
|
8
|
+
// TODO v8: Remove this type
|
|
9
|
+
|
|
10
|
+
// TODO v8: Rename this type to `SelectorArgs`
|
|
11
|
+
|
|
12
|
+
// TODO v8: Remove this type
|
|
13
|
+
|
|
14
|
+
// TODO v8: Rename this type to `CreateSelectorFunction`
|
|
15
|
+
|
|
3
16
|
const cache = new WeakMap();
|
|
4
17
|
function checkIsAPIRef(value) {
|
|
5
18
|
return 'current' in value && 'instanceId' in value.current;
|
|
@@ -7,6 +20,8 @@ function checkIsAPIRef(value) {
|
|
|
7
20
|
const DEFAULT_INSTANCE_ID = {
|
|
8
21
|
id: 'default'
|
|
9
22
|
};
|
|
23
|
+
|
|
24
|
+
// TODO v8: Remove this function
|
|
10
25
|
export const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
11
26
|
if (other.length > 0) {
|
|
12
27
|
throw new Error('Unsupported number of selectors');
|
|
@@ -71,6 +86,74 @@ export const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
|
71
86
|
selector.acceptsApiRef = true;
|
|
72
87
|
return selector;
|
|
73
88
|
};
|
|
89
|
+
|
|
90
|
+
// TODO v8: Rename this function to `createSelector`
|
|
91
|
+
export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
|
|
92
|
+
if (other.length > 0) {
|
|
93
|
+
throw new Error('Unsupported number of selectors');
|
|
94
|
+
}
|
|
95
|
+
let selector;
|
|
96
|
+
if (a && b && c && d && e && f) {
|
|
97
|
+
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
98
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
99
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
100
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
101
|
+
const va = a(state, args, instanceId);
|
|
102
|
+
const vb = b(state, args, instanceId);
|
|
103
|
+
const vc = c(state, args, instanceId);
|
|
104
|
+
const vd = d(state, args, instanceId);
|
|
105
|
+
const ve = e(state, args, instanceId);
|
|
106
|
+
return f(va, vb, vc, vd, ve, args);
|
|
107
|
+
};
|
|
108
|
+
} else if (a && b && c && d && e) {
|
|
109
|
+
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
110
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
111
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
112
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
113
|
+
const va = a(state, args, instanceId);
|
|
114
|
+
const vb = b(state, args, instanceId);
|
|
115
|
+
const vc = c(state, args, instanceId);
|
|
116
|
+
const vd = d(state, args, instanceId);
|
|
117
|
+
return e(va, vb, vc, vd, args);
|
|
118
|
+
};
|
|
119
|
+
} else if (a && b && c && d) {
|
|
120
|
+
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
121
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
122
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
123
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
124
|
+
const va = a(state, args, instanceId);
|
|
125
|
+
const vb = b(state, args, instanceId);
|
|
126
|
+
const vc = c(state, args, instanceId);
|
|
127
|
+
return d(va, vb, vc, args);
|
|
128
|
+
};
|
|
129
|
+
} else if (a && b && c) {
|
|
130
|
+
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
131
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
132
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
133
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
134
|
+
const va = a(state, args, instanceId);
|
|
135
|
+
const vb = b(state, args, instanceId);
|
|
136
|
+
return c(va, vb, args);
|
|
137
|
+
};
|
|
138
|
+
} else if (a && b) {
|
|
139
|
+
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
140
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
141
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
142
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
143
|
+
const va = a(state, args, instanceId);
|
|
144
|
+
return b(va, args);
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
throw new Error('Missing arguments');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// We use this property to detect if the selector was created with createSelector
|
|
151
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
152
|
+
selector.acceptsApiRef = true;
|
|
153
|
+
return selector;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// TODO v8: Remove this function
|
|
74
157
|
export const createSelectorMemoized = (...args) => {
|
|
75
158
|
const selector = (stateOrApiRef, instanceId) => {
|
|
76
159
|
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
@@ -97,6 +180,39 @@ export const createSelectorMemoized = (...args) => {
|
|
|
97
180
|
return fn(state, cacheKey);
|
|
98
181
|
};
|
|
99
182
|
|
|
183
|
+
// We use this property to detect if the selector was created with createSelector
|
|
184
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
185
|
+
selector.acceptsApiRef = true;
|
|
186
|
+
return selector;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// TODO v8: Rename this function to `createSelectorMemoized`
|
|
190
|
+
export const createSelectorMemoizedV8 = (...args) => {
|
|
191
|
+
const selector = (stateOrApiRef, selectorArgs, instanceId) => {
|
|
192
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
193
|
+
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
|
|
194
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
195
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
196
|
+
if (cacheKey.id === 'default') {
|
|
197
|
+
warnOnce(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const cacheArgsInit = cache.get(cacheKey);
|
|
201
|
+
const cacheArgs = cacheArgsInit ?? new Map();
|
|
202
|
+
const cacheFn = cacheArgs?.get(args);
|
|
203
|
+
if (cacheArgs && cacheFn) {
|
|
204
|
+
// We pass the cache key because the called selector might have as
|
|
205
|
+
// dependency another selector created with this `createSelector`.
|
|
206
|
+
return cacheFn(state, selectorArgs, cacheKey);
|
|
207
|
+
}
|
|
208
|
+
const fn = reselectCreateSelector(...args);
|
|
209
|
+
if (!cacheArgsInit) {
|
|
210
|
+
cache.set(cacheKey, cacheArgs);
|
|
211
|
+
}
|
|
212
|
+
cacheArgs.set(args, fn);
|
|
213
|
+
return fn(state, selectorArgs, cacheKey);
|
|
214
|
+
};
|
|
215
|
+
|
|
100
216
|
// We use this property to detect if the selector was created with createSelector
|
|
101
217
|
// or it's only a simple function the receives the state and returns part of it.
|
|
102
218
|
selector.acceptsApiRef = true;
|
package/utils/keyboardUtils.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated there is no meaninfuly logic abstracted, use event.key directly.
|
|
4
|
-
*/
|
|
5
|
-
export declare const isEscapeKey: (key: string) => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated there is no meaninfuly logic abstracted, use event.key directly.
|
|
8
|
-
*/
|
|
9
|
-
export declare const isTabKey: (key: string) => boolean;
|
|
10
2
|
export declare function isPrintableKey(event: React.KeyboardEvent<HTMLElement>): boolean;
|
|
11
3
|
export declare const GRID_MULTIPLE_SELECTION_KEYS: string[];
|
|
12
4
|
export declare const GRID_CELL_EXIT_EDIT_MODE_KEYS: string[];
|
|
@@ -17,5 +9,5 @@ export declare const isCellExitEditModeKeys: (key: string) => boolean;
|
|
|
17
9
|
export declare const isCellEditCommitKeys: (key: string) => boolean;
|
|
18
10
|
export declare const isNavigationKey: (key: string) => boolean;
|
|
19
11
|
export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEvent<HTMLElement>;
|
|
20
|
-
export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) =>
|
|
12
|
+
export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) => key is "Tab" | "Escape";
|
|
21
13
|
export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
|
package/utils/keyboardUtils.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated there is no meaninfuly logic abstracted, use event.key directly.
|
|
3
|
-
*/
|
|
4
|
-
export const isEscapeKey = key => key === 'Escape';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated there is no meaninfuly logic abstracted, use event.key directly.
|
|
8
|
-
*/
|
|
9
|
-
export const isTabKey = key => key === 'Tab';
|
|
10
|
-
|
|
11
1
|
// Non printable keys have a name, for example "ArrowRight", see the whole list:
|
|
12
2
|
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
|
13
3
|
// So event.key.length === 1 is often enough.
|
|
@@ -27,7 +17,7 @@ export const isCellExitEditModeKeys = key => GRID_CELL_EXIT_EDIT_MODE_KEYS.index
|
|
|
27
17
|
export const isCellEditCommitKeys = key => GRID_CELL_EDIT_COMMIT_KEYS.indexOf(key) > -1;
|
|
28
18
|
export const isNavigationKey = key => key.indexOf('Arrow') === 0 || key.indexOf('Page') === 0 || key === ' ' || key === 'Home' || key === 'End';
|
|
29
19
|
export const isKeyboardEvent = event => !!event.key;
|
|
30
|
-
export const isHideMenuKey = key =>
|
|
20
|
+
export const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
|
|
31
21
|
|
|
32
22
|
// In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
|
|
33
23
|
// However, maybe it's overkill to fix, so let's be lazy.
|