@mui/x-data-grid 8.0.0-alpha.2 → 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 +376 -0
- package/DataGrid/DataGrid.js +5 -13
- 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/columnSelection/GridHeaderCheckbox.js +4 -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 -2
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +25 -9
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +3 -6
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- 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/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +3 -3
- 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/gridRowsInterfaces.d.ts +1 -8
- package/hooks/features/rows/gridRowsSelector.d.ts +23 -13
- package/hooks/features/rows/gridRowsSelector.js +0 -1
- package/hooks/features/rows/gridRowsUtils.js +0 -9
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/hooks/features/rows/useGridRows.js +16 -18
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- 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 +3 -3
- package/internals/index.js +3 -3
- package/locales/heIL.js +14 -16
- package/locales/roRO.js +18 -20
- package/locales/trTR.js +12 -14
- package/models/api/gridStateApi.d.ts +1 -1
- package/models/controlStateItem.d.ts +2 -2
- package/models/events/gridEventLookup.d.ts +1 -0
- package/models/gridDataSource.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +1 -9
- package/modern/DataGrid/DataGrid.js +5 -13
- 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/columnSelection/GridHeaderCheckbox.js +4 -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 -2
- package/modern/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +5 -1
- package/modern/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/modern/hooks/core/useGridStateInitialization.js +3 -3
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.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/gridRowsSelector.js +0 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -9
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/modern/hooks/features/rows/useGridRows.js +16 -18
- 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 +3 -3
- package/modern/locales/heIL.js +14 -16
- package/modern/locales/roRO.js +18 -20
- package/modern/locales/trTR.js +12 -14
- package/modern/utils/createSelector.js +1 -120
- package/node/DataGrid/DataGrid.js +5 -13
- 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/columnSelection/GridHeaderCheckbox.js +4 -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 -2
- package/node/hooks/core/strategyProcessing/gridStrategyProcessingApi.js +7 -1
- package/node/hooks/core/strategyProcessing/useGridStrategyProcessing.js +7 -8
- package/node/hooks/core/useGridStateInitialization.js +3 -3
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +2 -2
- 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/gridRowsSelector.js +1 -2
- package/node/hooks/features/rows/gridRowsUtils.js +0 -9
- package/node/hooks/features/rows/index.js +0 -7
- package/node/hooks/features/rows/useGridRowSpanning.js +16 -8
- package/node/hooks/features/rows/useGridRows.js +15 -17
- 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 +15 -22
- package/node/locales/heIL.js +14 -16
- package/node/locales/roRO.js +18 -20
- package/node/locales/trTR.js +12 -14
- 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
package/package.json
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Selector, SelectorResultArray } from 'reselect';
|
|
3
3
|
import type { GridCoreApi } from '../models/api/gridCoreApi';
|
|
4
|
-
export interface OutputSelector<State, Result> {
|
|
5
|
-
(apiRef: React.MutableRefObject<{
|
|
6
|
-
state: State;
|
|
7
|
-
instanceId: GridCoreApi['instanceId'];
|
|
8
|
-
}>): Result;
|
|
9
|
-
(state: State, instanceId: GridCoreApi['instanceId']): Result;
|
|
10
|
-
acceptsApiRef: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface OutputSelectorV8<State, Args, Result> {
|
|
4
|
+
export interface OutputSelector<State, Args, Result> {
|
|
13
5
|
(apiRef: React.MutableRefObject<{
|
|
14
6
|
state: State;
|
|
15
7
|
instanceId: GridCoreApi['instanceId'];
|
|
16
8
|
}>, args?: Args): Result;
|
|
17
|
-
(state: State, instanceId
|
|
9
|
+
(state: State, args?: Args, instanceId?: GridCoreApi['instanceId']): Result;
|
|
18
10
|
acceptsApiRef: boolean;
|
|
19
11
|
}
|
|
20
12
|
type StateFromSelector<T> = T extends (first: infer F, ...args: any[]) => any ? F extends {
|
|
@@ -24,19 +16,15 @@ type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends
|
|
|
24
16
|
f: infer F,
|
|
25
17
|
...other: infer R
|
|
26
18
|
] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
|
|
27
|
-
type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
|
|
28
19
|
type SelectorResultArrayWithArgs<Selectors extends ReadonlyArray<Selector<any>>, Args> = [
|
|
29
20
|
...SelectorResultArray<Selectors>,
|
|
30
21
|
Args
|
|
31
22
|
];
|
|
32
|
-
type
|
|
23
|
+
type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Args, Result> = [
|
|
33
24
|
selectors: [...Selectors],
|
|
34
25
|
combiner: (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result
|
|
35
26
|
] | [...Selectors, (...args: SelectorResultArrayWithArgs<Selectors, Args>) => Result];
|
|
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>;
|
|
27
|
+
type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Args, Result>(...items: SelectorArgs<Selectors, Args, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Args, Result>;
|
|
38
28
|
export declare const createSelector: CreateSelectorFunction;
|
|
39
|
-
export declare const createSelectorV8: CreateSelectorFunctionV8;
|
|
40
29
|
export declare const createSelectorMemoized: CreateSelectorFunction;
|
|
41
|
-
export declare const createSelectorMemoizedV8: CreateSelectorFunctionV8;
|
|
42
30
|
export {};
|
package/utils/createSelector.js
CHANGED
|
@@ -8,19 +8,6 @@ const reselectCreateSelector = createSelectorCreator({
|
|
|
8
8
|
equalityCheck: Object.is
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
|
|
12
|
-
// TODO v8: Remove this type
|
|
13
|
-
|
|
14
|
-
// TODO v8: Rename this type to `OutputSelector`
|
|
15
|
-
|
|
16
|
-
// TODO v8: Remove this type
|
|
17
|
-
|
|
18
|
-
// TODO v8: Rename this type to `SelectorArgs`
|
|
19
|
-
|
|
20
|
-
// TODO v8: Remove this type
|
|
21
|
-
|
|
22
|
-
// TODO v8: Rename this type to `CreateSelectorFunction`
|
|
23
|
-
|
|
24
11
|
const cache = new WeakMap();
|
|
25
12
|
function checkIsAPIRef(value) {
|
|
26
13
|
return 'current' in value && 'instanceId' in value.current;
|
|
@@ -28,83 +15,12 @@ function checkIsAPIRef(value) {
|
|
|
28
15
|
const DEFAULT_INSTANCE_ID = {
|
|
29
16
|
id: 'default'
|
|
30
17
|
};
|
|
31
|
-
|
|
32
|
-
// TODO v8: Remove this function
|
|
33
18
|
export const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
34
19
|
if (other.length > 0) {
|
|
35
20
|
throw new Error('Unsupported number of selectors');
|
|
36
21
|
}
|
|
37
22
|
let selector;
|
|
38
23
|
|
|
39
|
-
// eslint-disable-next-line id-denylist
|
|
40
|
-
if (a && b && c && d && e && f) {
|
|
41
|
-
selector = (stateOrApiRef, instanceIdParam) => {
|
|
42
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
43
|
-
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
44
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
45
|
-
const va = a(state, instanceId);
|
|
46
|
-
const vb = b(state, instanceId);
|
|
47
|
-
const vc = c(state, instanceId);
|
|
48
|
-
const vd = d(state, instanceId);
|
|
49
|
-
const ve = e(state, instanceId);
|
|
50
|
-
return f(va, vb, vc, vd, ve);
|
|
51
|
-
};
|
|
52
|
-
// eslint-disable-next-line id-denylist
|
|
53
|
-
} else if (a && b && c && d && e) {
|
|
54
|
-
selector = (stateOrApiRef, instanceIdParam) => {
|
|
55
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
56
|
-
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
57
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
58
|
-
const va = a(state, instanceId);
|
|
59
|
-
const vb = b(state, instanceId);
|
|
60
|
-
const vc = c(state, instanceId);
|
|
61
|
-
const vd = d(state, instanceId);
|
|
62
|
-
return e(va, vb, vc, vd);
|
|
63
|
-
};
|
|
64
|
-
} else if (a && b && c && d) {
|
|
65
|
-
selector = (stateOrApiRef, instanceIdParam) => {
|
|
66
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
67
|
-
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
68
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
69
|
-
const va = a(state, instanceId);
|
|
70
|
-
const vb = b(state, instanceId);
|
|
71
|
-
const vc = c(state, instanceId);
|
|
72
|
-
return d(va, vb, vc);
|
|
73
|
-
};
|
|
74
|
-
} else if (a && b && c) {
|
|
75
|
-
selector = (stateOrApiRef, instanceIdParam) => {
|
|
76
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
77
|
-
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
78
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
79
|
-
const va = a(state, instanceId);
|
|
80
|
-
const vb = b(state, instanceId);
|
|
81
|
-
return c(va, vb);
|
|
82
|
-
};
|
|
83
|
-
} else if (a && b) {
|
|
84
|
-
selector = (stateOrApiRef, instanceIdParam) => {
|
|
85
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
86
|
-
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
87
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
88
|
-
const va = a(state, instanceId);
|
|
89
|
-
return b(va);
|
|
90
|
-
};
|
|
91
|
-
} else {
|
|
92
|
-
throw new Error('Missing arguments');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// We use this property to detect if the selector was created with createSelector
|
|
96
|
-
// or it's only a simple function the receives the state and returns part of it.
|
|
97
|
-
selector.acceptsApiRef = true;
|
|
98
|
-
return selector;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// TODO v8: Rename this function to `createSelector`
|
|
102
|
-
export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
|
|
103
|
-
if (other.length > 0) {
|
|
104
|
-
throw new Error('Unsupported number of selectors');
|
|
105
|
-
}
|
|
106
|
-
let selector;
|
|
107
|
-
|
|
108
24
|
// eslint-disable-next-line id-denylist
|
|
109
25
|
if (a && b && c && d && e && f) {
|
|
110
26
|
selector = (stateOrApiRef, args, instanceIdParam) => {
|
|
@@ -166,49 +82,14 @@ export const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
|
|
|
166
82
|
selector.acceptsApiRef = true;
|
|
167
83
|
return selector;
|
|
168
84
|
};
|
|
169
|
-
|
|
170
|
-
// TODO v8: Remove this function
|
|
171
85
|
export const createSelectorMemoized = (...args) => {
|
|
172
|
-
const selector = (stateOrApiRef, instanceId) => {
|
|
173
|
-
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
174
|
-
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
|
|
175
|
-
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
176
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
177
|
-
if (cacheKey.id === 'default') {
|
|
178
|
-
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)`.']);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const cacheArgsInit = cache.get(cacheKey);
|
|
182
|
-
const cacheArgs = cacheArgsInit ?? new Map();
|
|
183
|
-
const cacheFn = cacheArgs?.get(args);
|
|
184
|
-
if (cacheArgs && cacheFn) {
|
|
185
|
-
// We pass the cache key because the called selector might have as
|
|
186
|
-
// dependency another selector created with this `createSelector`.
|
|
187
|
-
return cacheFn(state, cacheKey);
|
|
188
|
-
}
|
|
189
|
-
const fn = reselectCreateSelector(...args);
|
|
190
|
-
if (!cacheArgsInit) {
|
|
191
|
-
cache.set(cacheKey, cacheArgs);
|
|
192
|
-
}
|
|
193
|
-
cacheArgs.set(args, fn);
|
|
194
|
-
return fn(state, cacheKey);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// We use this property to detect if the selector was created with createSelector
|
|
198
|
-
// or it's only a simple function the receives the state and returns part of it.
|
|
199
|
-
selector.acceptsApiRef = true;
|
|
200
|
-
return selector;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// TODO v8: Rename this function to `createSelectorMemoized`
|
|
204
|
-
export const createSelectorMemoizedV8 = (...args) => {
|
|
205
86
|
const selector = (stateOrApiRef, selectorArgs, instanceId) => {
|
|
206
87
|
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
207
88
|
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
|
|
208
89
|
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
209
90
|
if (process.env.NODE_ENV !== 'production') {
|
|
210
91
|
if (cacheKey.id === 'default') {
|
|
211
|
-
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)`.']);
|
|
92
|
+
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, args, apiRef.current.instanceId)`.']);
|
|
212
93
|
}
|
|
213
94
|
}
|
|
214
95
|
const cacheArgsInit = cache.get(cacheKey);
|