@mui/x-data-grid 6.7.0 → 6.9.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 +145 -5541
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridPagination.d.ts +2 -2
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +33 -79
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/GridEditInputCell.js +9 -9
- package/components/cell/index.d.ts +2 -1
- package/components/cell/index.js +1 -1
- package/components/containers/GridRootStyles.js +30 -16
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/virtualization/GridVirtualScroller.js +4 -9
- package/components/virtualization/GridVirtualScrollerContent.js +11 -20
- package/constants/defaultGridSlotsComponents.js +6 -2
- package/hooks/core/useGridApiInitialization.js +4 -1
- package/hooks/core/useGridStateInitialization.js +2 -9
- package/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterSelector.js +8 -8
- package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
- package/hooks/features/filter/gridFilterUtils.js +19 -13
- package/hooks/features/filter/useGridFilter.js +2 -1
- package/hooks/features/focus/useGridFocus.js +9 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/hooks/features/rows/gridRowsSelector.js +3 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
- package/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridSelector.d.ts +3 -1
- package/hooks/utils/useGridSelector.js +37 -6
- package/hooks/utils/useLazyRef.d.ts +2 -0
- package/hooks/utils/useLazyRef.js +9 -0
- package/hooks/utils/useOnMount.d.ts +2 -0
- package/hooks/utils/useOnMount.js +7 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +35 -79
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/GridEditInputCell.js +9 -9
- package/legacy/components/cell/index.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +20 -17
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/legacy/components/toolbar/GridToolbar.js +2 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
- package/legacy/constants/defaultGridSlotsComponents.js +6 -2
- package/legacy/hooks/core/useGridApiInitialization.js +4 -1
- package/legacy/hooks/core/useGridStateInitialization.js +2 -7
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/legacy/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -8
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +2 -1
- package/legacy/hooks/features/focus/useGridFocus.js +9 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/legacy/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +38 -34
- package/legacy/hooks/utils/index.js +1 -1
- package/legacy/hooks/utils/useGridSelector.js +43 -5
- package/legacy/hooks/utils/useLazyRef.js +9 -0
- package/legacy/hooks/utils/useOnMount.js +7 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/locales/elGR.js +70 -79
- package/legacy/locales/ptBR.js +12 -13
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/createSelector.js +74 -6
- package/legacy/utils/doesSupportPreventScroll.js +13 -0
- package/legacy/utils/fastMemo.js +5 -0
- package/legacy/utils/fastObjectShallowCompare.js +32 -0
- package/legacy/utils/keyboardUtils.js +4 -2
- package/locales/elGR.js +66 -79
- package/locales/ptBR.js +12 -13
- package/models/api/gridCoreApi.d.ts +6 -0
- package/models/colDef/gridColDef.d.ts +4 -3
- package/models/colDef/gridColType.d.ts +3 -1
- package/models/events/gridEventLookup.d.ts +3 -3
- package/modern/components/GridColumnHeaders.js +3 -1
- package/modern/components/GridRow.js +32 -79
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/GridEditInputCell.js +9 -9
- package/modern/components/cell/index.js +1 -1
- package/modern/components/containers/GridRootStyles.js +30 -16
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/virtualization/GridVirtualScroller.js +4 -9
- package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/modern/constants/defaultGridSlotsComponents.js +6 -2
- package/modern/hooks/core/useGridApiInitialization.js +4 -1
- package/modern/hooks/core/useGridStateInitialization.js +2 -9
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/modern/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterSelector.js +8 -8
- package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
- package/modern/hooks/features/filter/useGridFilter.js +2 -1
- package/modern/hooks/features/focus/useGridFocus.js +8 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/modern/hooks/features/pagination/gridPaginationSelector.js +4 -4
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/modern/hooks/features/rows/gridRowsSelector.js +3 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/sorting/gridSortingSelector.js +3 -3
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridSelector.js +37 -6
- package/modern/hooks/utils/useLazyRef.js +9 -0
- package/modern/hooks/utils/useOnMount.js +7 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/elGR.js +66 -79
- package/modern/locales/ptBR.js +12 -13
- package/modern/utils/Store.js +24 -0
- package/modern/utils/createSelector.js +74 -6
- package/modern/utils/doesSupportPreventScroll.js +13 -0
- package/modern/utils/fastMemo.js +5 -0
- package/modern/utils/fastObjectShallowCompare.js +32 -0
- package/modern/utils/keyboardUtils.js +4 -2
- package/node/components/GridColumnHeaders.js +4 -2
- package/node/components/GridRow.js +32 -79
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/GridEditInputCell.js +9 -9
- package/node/components/cell/index.js +17 -10
- package/node/components/containers/GridRootStyles.js +30 -16
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/toolbar/GridToolbar.js +2 -2
- package/node/components/virtualization/GridVirtualScroller.js +4 -9
- package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/node/constants/defaultGridSlotsComponents.js +4 -1
- package/node/hooks/core/useGridApiInitialization.js +4 -1
- package/node/hooks/core/useGridStateInitialization.js +2 -9
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/node/hooks/features/columnGrouping/gridColumnGroupsSelector.js +3 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/columns/gridColumnsSelector.js +6 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterSelector.js +7 -7
- package/node/hooks/features/filter/gridFilterUtils.js +17 -12
- package/node/hooks/features/filter/useGridFilter.js +2 -1
- package/node/hooks/features/focus/useGridFocus.js +8 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/node/hooks/features/pagination/gridPaginationSelector.js +3 -3
- package/node/hooks/features/rowSelection/gridRowSelectionSelector.js +2 -2
- package/node/hooks/features/rows/gridRowsSelector.js +2 -2
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/sorting/gridSortingSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
- package/node/hooks/utils/index.js +14 -10
- package/node/hooks/utils/useGridSelector.js +41 -7
- package/node/hooks/utils/useLazyRef.js +17 -0
- package/node/hooks/utils/useOnMount.js +15 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/elGR.js +66 -79
- package/node/locales/ptBR.js +12 -13
- package/node/utils/Store.js +31 -0
- package/node/utils/createSelector.js +77 -8
- package/node/utils/doesSupportPreventScroll.js +19 -0
- package/node/utils/fastMemo.js +13 -0
- package/node/utils/fastObjectShallowCompare.js +38 -0
- package/node/utils/keyboardUtils.js +4 -2
- package/package.json +2 -2
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/createSelector.d.ts +1 -0
- package/utils/createSelector.js +74 -6
- package/utils/doesSupportPreventScroll.d.ts +1 -0
- package/utils/doesSupportPreventScroll.js +13 -0
- package/utils/fastMemo.d.ts +1 -0
- package/utils/fastMemo.js +5 -0
- package/utils/fastObjectShallowCompare.d.ts +1 -0
- package/utils/fastObjectShallowCompare.js +32 -0
- package/utils/keyboardUtils.js +4 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class Store {
|
|
2
|
+
static create(value) {
|
|
3
|
+
return new Store(value);
|
|
4
|
+
}
|
|
5
|
+
constructor(_value) {
|
|
6
|
+
this.value = void 0;
|
|
7
|
+
this.listeners = void 0;
|
|
8
|
+
this.subscribe = fn => {
|
|
9
|
+
this.listeners.add(fn);
|
|
10
|
+
return () => {
|
|
11
|
+
this.listeners.delete(fn);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
this.getSnapshot = () => {
|
|
15
|
+
return this.value;
|
|
16
|
+
};
|
|
17
|
+
this.update = value => {
|
|
18
|
+
this.value = value;
|
|
19
|
+
this.listeners.forEach(l => l(value));
|
|
20
|
+
};
|
|
21
|
+
this.value = _value;
|
|
22
|
+
this.listeners = new Set();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -4,14 +4,82 @@ const cacheContainer = {
|
|
|
4
4
|
cache: new WeakMap()
|
|
5
5
|
};
|
|
6
6
|
const missingInstanceIdWarning = buildWarning(['MUI: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g `mySelector(state, apiRef.current.instanceId)`.']);
|
|
7
|
-
|
|
7
|
+
function checkIsAPIRef(value) {
|
|
8
|
+
return 'current' in value && 'instanceId' in value.current;
|
|
9
|
+
}
|
|
10
|
+
const DEFAULT_INSTANCE_ID = {
|
|
11
|
+
id: 'default'
|
|
12
|
+
};
|
|
13
|
+
export const createSelector = (a, b, c, d, e, f, ...rest) => {
|
|
14
|
+
if (rest.length > 0) {
|
|
15
|
+
throw new Error('Unsupported number of selectors');
|
|
16
|
+
}
|
|
17
|
+
let selector;
|
|
18
|
+
if (a && b && c && d && e && f) {
|
|
19
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
20
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
21
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
22
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
23
|
+
const va = a(state, instanceId);
|
|
24
|
+
const vb = b(state, instanceId);
|
|
25
|
+
const vc = c(state, instanceId);
|
|
26
|
+
const vd = d(state, instanceId);
|
|
27
|
+
const ve = e(state, instanceId);
|
|
28
|
+
return f(va, vb, vc, vd, ve);
|
|
29
|
+
};
|
|
30
|
+
} else if (a && b && c && d && e) {
|
|
31
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
32
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
33
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
34
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
35
|
+
const va = a(state, instanceId);
|
|
36
|
+
const vb = b(state, instanceId);
|
|
37
|
+
const vc = c(state, instanceId);
|
|
38
|
+
const vd = d(state, instanceId);
|
|
39
|
+
return e(va, vb, vc, vd);
|
|
40
|
+
};
|
|
41
|
+
} else if (a && b && c && d) {
|
|
42
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
43
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
44
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
45
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
46
|
+
const va = a(state, instanceId);
|
|
47
|
+
const vb = b(state, instanceId);
|
|
48
|
+
const vc = c(state, instanceId);
|
|
49
|
+
return d(va, vb, vc);
|
|
50
|
+
};
|
|
51
|
+
} else if (a && b && c) {
|
|
52
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
53
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
54
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
55
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
56
|
+
const va = a(state, instanceId);
|
|
57
|
+
const vb = b(state, instanceId);
|
|
58
|
+
return c(va, vb);
|
|
59
|
+
};
|
|
60
|
+
} else if (a && b) {
|
|
61
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
62
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
63
|
+
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
|
|
64
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
65
|
+
const va = a(state, instanceId);
|
|
66
|
+
return b(va);
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
throw new Error('Missing arguments');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// We use this property to detect if the selector was created with createSelector
|
|
73
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
74
|
+
selector.acceptsApiRef = true;
|
|
75
|
+
return selector;
|
|
76
|
+
};
|
|
77
|
+
export const createSelectorMemoized = (...args) => {
|
|
8
78
|
const selector = (...selectorArgs) => {
|
|
9
79
|
const [stateOrApiRef, instanceId] = selectorArgs;
|
|
10
|
-
const
|
|
11
|
-
const cacheKey =
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
80
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
81
|
+
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
|
|
82
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
15
83
|
if (process.env.NODE_ENV !== 'production') {
|
|
16
84
|
if (cacheKey.id === 'default') {
|
|
17
85
|
missingInstanceIdWarning();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Based on https://stackoverflow.com/a/59518678
|
|
2
|
+
let cachedSupportsPreventScroll;
|
|
3
|
+
export function doesSupportPreventScroll() {
|
|
4
|
+
if (cachedSupportsPreventScroll === undefined) {
|
|
5
|
+
document.createElement('div').focus({
|
|
6
|
+
get preventScroll() {
|
|
7
|
+
cachedSupportsPreventScroll = true;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return cachedSupportsPreventScroll;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const is = Object.is;
|
|
2
|
+
export function fastObjectShallowCompare(a, b) {
|
|
3
|
+
if (a === b) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (!(a instanceof Object) || !(b instanceof Object)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
let aLength = 0;
|
|
10
|
+
let bLength = 0;
|
|
11
|
+
|
|
12
|
+
/* eslint-disable no-restricted-syntax */
|
|
13
|
+
/* eslint-disable guard-for-in */
|
|
14
|
+
for (const key in a) {
|
|
15
|
+
aLength += 1;
|
|
16
|
+
if (!is(a[key], b[key])) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (!(key in b)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
|
|
25
|
+
for (const _ in b) {
|
|
26
|
+
bLength += 1;
|
|
27
|
+
}
|
|
28
|
+
/* eslint-enable no-restricted-syntax */
|
|
29
|
+
/* eslint-enable guard-for-in */
|
|
30
|
+
|
|
31
|
+
return aLength === bLength;
|
|
32
|
+
}
|
|
@@ -10,11 +10,13 @@ export const isDeleteKeys = key => key === 'Delete' || key === 'Backspace';
|
|
|
10
10
|
|
|
11
11
|
// Non printable keys have a name, e.g. "ArrowRight", see the whole list:
|
|
12
12
|
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
|
13
|
-
//
|
|
13
|
+
// So event.key.length === 1 is often enough.
|
|
14
|
+
//
|
|
15
|
+
// However, we also need to ignore shortcuts, for example: select all:
|
|
14
16
|
// - Windows: Ctrl+A, event.ctrlKey is true
|
|
15
17
|
// - macOS: ⌘ Command+A, event.metaKey is true
|
|
16
18
|
export function isPrintableKey(event) {
|
|
17
|
-
return event.key.length === 1 && event.ctrlKey
|
|
19
|
+
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
|
|
18
20
|
}
|
|
19
21
|
export const GRID_MULTIPLE_SELECTION_KEYS = ['Meta', 'Control', 'Shift'];
|
|
20
22
|
export const GRID_CELL_EXIT_EDIT_MODE_KEYS = ['Enter', 'Escape', 'Tab'];
|
|
@@ -9,6 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _fastMemo = require("../utils/fastMemo");
|
|
12
13
|
var _useGridColumnHeaders = require("../hooks/features/columnHeaders/useGridColumnHeaders");
|
|
13
14
|
var _GridBaseColumnHeaders = require("./columnHeaders/GridBaseColumnHeaders");
|
|
14
15
|
var _GridColumnHeadersInner = require("./columnHeaders/GridColumnHeadersInner");
|
|
@@ -68,7 +69,6 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnsHead
|
|
|
68
69
|
}))
|
|
69
70
|
}));
|
|
70
71
|
});
|
|
71
|
-
exports.GridColumnHeaders = GridColumnHeaders;
|
|
72
72
|
process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
73
73
|
// ----------------------------- Warning --------------------------------
|
|
74
74
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -108,4 +108,6 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
|
108
108
|
minColumnIndex: _propTypes.default.number,
|
|
109
109
|
sortColumnLookup: _propTypes.default.object.isRequired,
|
|
110
110
|
visibleColumns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
|
111
|
-
} : void 0;
|
|
111
|
+
} : void 0;
|
|
112
|
+
const MemoizedGridColumnHeaders = (0, _fastMemo.fastMemo)(GridColumnHeaders);
|
|
113
|
+
exports.GridColumnHeaders = MemoizedGridColumnHeaders;
|
|
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
|
+
var _fastMemo = require("../utils/fastMemo");
|
|
14
15
|
var _gridEditRowModel = require("../models/gridEditRowModel");
|
|
15
16
|
var _useGridApiContext = require("../hooks/utils/useGridApiContext");
|
|
16
17
|
var _gridClasses = require("../constants/gridClasses");
|
|
@@ -26,10 +27,10 @@ var _gridSortingSelector = require("../hooks/features/sorting/gridSortingSelecto
|
|
|
26
27
|
var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
|
|
27
28
|
var _gridColumnGroupsSelector = require("../hooks/features/columnGrouping/gridColumnGroupsSelector");
|
|
28
29
|
var _utils2 = require("../utils/utils");
|
|
30
|
+
var _GridCell = require("./cell/GridCell");
|
|
29
31
|
var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
|
|
30
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
32
|
-
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
33
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
|
|
33
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
34
35
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
36
|
const useUtilityClasses = ownerState => {
|
|
@@ -75,8 +76,6 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
75
76
|
containerWidth,
|
|
76
77
|
firstColumnToRender,
|
|
77
78
|
isLastVisible = false,
|
|
78
|
-
focusedCell,
|
|
79
|
-
tabbableCell,
|
|
80
79
|
onClick,
|
|
81
80
|
onDoubleClick,
|
|
82
81
|
onMouseEnter,
|
|
@@ -191,78 +190,27 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
191
190
|
const {
|
|
192
191
|
slots,
|
|
193
192
|
slotProps,
|
|
194
|
-
|
|
195
|
-
disableColumnReorder,
|
|
196
|
-
getCellClassName
|
|
193
|
+
disableColumnReorder
|
|
197
194
|
} = rootProps;
|
|
195
|
+
const CellComponent = slots.cell === _GridCell.GridCellV7 ? _GridCell.GridCellV7 : _GridCell.GridCellWrapper;
|
|
198
196
|
const rowReordering = rootProps.rowReordering;
|
|
199
|
-
const
|
|
200
|
-
const getCell = React.useCallback((column, cellProps) => {
|
|
201
|
-
const cellParams = apiRef.current.getCellParams(rowId, column.field);
|
|
202
|
-
const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
|
|
203
|
-
id: rowId,
|
|
204
|
-
field: column.field
|
|
205
|
-
});
|
|
197
|
+
const getCell = (column, cellProps) => {
|
|
206
198
|
const disableDragEvents = disableColumnReorder && column.disableReorder || !rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
|
|
207
|
-
|
|
208
|
-
classNames.push((0, _clsx.default)(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName));
|
|
209
|
-
}
|
|
210
|
-
const editCellState = editRowsState[rowId] ? editRowsState[rowId][column.field] : null;
|
|
211
|
-
let content;
|
|
212
|
-
if (editCellState == null && column.renderCell) {
|
|
213
|
-
content = column.renderCell((0, _extends2.default)({}, cellParams, {
|
|
214
|
-
api: apiRef.current
|
|
215
|
-
}));
|
|
216
|
-
// TODO move to GridCell
|
|
217
|
-
classNames.push((0, _clsx.default)(_gridClasses.gridClasses['cell--withRenderer'], rootClasses?.['cell--withRenderer']));
|
|
218
|
-
}
|
|
219
|
-
if (editCellState != null && column.renderEditCell) {
|
|
220
|
-
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
|
|
221
|
-
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
223
|
-
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded2);
|
|
224
|
-
const params = (0, _extends2.default)({}, cellParams, {
|
|
225
|
-
row: updatedRow
|
|
226
|
-
}, editCellStateRest, {
|
|
227
|
-
api: apiRef.current
|
|
228
|
-
});
|
|
229
|
-
content = column.renderEditCell(params);
|
|
230
|
-
// TODO move to GridCell
|
|
231
|
-
classNames.push((0, _clsx.default)(_gridClasses.gridClasses['cell--editing'], rootClasses?.['cell--editing']));
|
|
232
|
-
}
|
|
233
|
-
if (getCellClassName) {
|
|
234
|
-
// TODO move to GridCell
|
|
235
|
-
classNames.push(getCellClassName(cellParams));
|
|
236
|
-
}
|
|
237
|
-
const hasFocus = focusedCell === column.field;
|
|
238
|
-
const tabIndex = tabbableCell === column.field ? 0 : -1;
|
|
239
|
-
const isSelected = apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
240
|
-
id: rowId,
|
|
241
|
-
field: column.field
|
|
242
|
-
});
|
|
199
|
+
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
243
200
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CellComponent, (0, _extends2.default)({
|
|
244
|
-
|
|
245
|
-
field: column.field,
|
|
201
|
+
column: column,
|
|
246
202
|
width: cellProps.width,
|
|
247
203
|
rowId: rowId,
|
|
248
204
|
height: rowHeight,
|
|
249
205
|
showRightBorder: cellProps.showRightBorder,
|
|
250
|
-
formattedValue: cellParams.formattedValue,
|
|
251
206
|
align: column.align || 'left',
|
|
252
|
-
cellMode: cellParams.cellMode,
|
|
253
207
|
colIndex: cellProps.indexRelativeToAllColumns,
|
|
254
|
-
isEditable: cellParams.isEditable,
|
|
255
|
-
isSelected: isSelected,
|
|
256
|
-
hasFocus: hasFocus,
|
|
257
|
-
tabIndex: tabIndex,
|
|
258
|
-
className: (0, _clsx.default)(classNames),
|
|
259
208
|
colSpan: cellProps.colSpan,
|
|
260
|
-
disableDragEvents: disableDragEvents
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
|
|
209
|
+
disableDragEvents: disableDragEvents,
|
|
210
|
+
editCellState: editCellState
|
|
211
|
+
}, slotProps?.cell), column.field);
|
|
212
|
+
};
|
|
213
|
+
const sizes = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.unstable_getRowInternalSizes(rowId)), _useGridSelector.objectShallowCompare);
|
|
266
214
|
let minHeight = rowHeight;
|
|
267
215
|
if (minHeight === 'auto' && sizes) {
|
|
268
216
|
let numberOfBaseSizes = 0;
|
|
@@ -311,7 +259,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
311
259
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
312
260
|
}
|
|
313
261
|
const randomNumber = (0, _utils2.randomNumberBetween)(10000, 20, 80);
|
|
314
|
-
const
|
|
262
|
+
const rowNode = apiRef.current.getRowNode(rowId);
|
|
263
|
+
if (!rowNode) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const rowType = rowNode.type;
|
|
315
267
|
const cells = [];
|
|
316
268
|
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
317
269
|
const column = renderedColumns[i];
|
|
@@ -335,7 +287,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
335
287
|
width
|
|
336
288
|
} = cellColSpanInfo.cellProps;
|
|
337
289
|
const contentWidth = Math.round(randomNumber());
|
|
338
|
-
cells.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
290
|
+
cells.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(slots.skeletonCell, {
|
|
339
291
|
width: width,
|
|
340
292
|
contentWidth: contentWidth,
|
|
341
293
|
field: column.field,
|
|
@@ -366,14 +318,13 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
366
318
|
})]
|
|
367
319
|
}));
|
|
368
320
|
});
|
|
369
|
-
exports.GridRow = GridRow;
|
|
370
321
|
process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
371
322
|
// ----------------------------- Warning --------------------------------
|
|
372
323
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
373
324
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
374
325
|
// ----------------------------------------------------------------------
|
|
375
|
-
containerWidth: _propTypes.default.number,
|
|
376
|
-
firstColumnToRender: _propTypes.default.number,
|
|
326
|
+
containerWidth: _propTypes.default.number.isRequired,
|
|
327
|
+
firstColumnToRender: _propTypes.default.number.isRequired,
|
|
377
328
|
/**
|
|
378
329
|
* Determines which cell has focus.
|
|
379
330
|
* If `null`, no cell in this row has focus.
|
|
@@ -383,23 +334,25 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
383
334
|
* Index of the row in the whole sorted and filtered dataset.
|
|
384
335
|
* If some rows above have expanded children, this index also take those children into account.
|
|
385
336
|
*/
|
|
386
|
-
index: _propTypes.default.number,
|
|
337
|
+
index: _propTypes.default.number.isRequired,
|
|
387
338
|
isLastVisible: _propTypes.default.bool,
|
|
388
|
-
lastColumnToRender: _propTypes.default.number,
|
|
339
|
+
lastColumnToRender: _propTypes.default.number.isRequired,
|
|
389
340
|
onClick: _propTypes.default.func,
|
|
390
341
|
onDoubleClick: _propTypes.default.func,
|
|
391
342
|
onMouseEnter: _propTypes.default.func,
|
|
392
343
|
onMouseLeave: _propTypes.default.func,
|
|
393
|
-
position: _propTypes.default.oneOf(['center', 'left', 'right']),
|
|
394
|
-
renderedColumns: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
344
|
+
position: _propTypes.default.oneOf(['center', 'left', 'right']).isRequired,
|
|
345
|
+
renderedColumns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
395
346
|
row: _propTypes.default.object,
|
|
396
|
-
rowHeight: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
|
|
397
|
-
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
398
|
-
selected: _propTypes.default.bool,
|
|
347
|
+
rowHeight: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
|
|
348
|
+
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
349
|
+
selected: _propTypes.default.bool.isRequired,
|
|
399
350
|
/**
|
|
400
351
|
* Determines which cell should be tabbable by having tabIndex=0.
|
|
401
352
|
* If `null`, no cell in this row is in the tab sequence.
|
|
402
353
|
*/
|
|
403
354
|
tabbableCell: _propTypes.default.string,
|
|
404
|
-
visibleColumns: _propTypes.default.arrayOf(_propTypes.default.object)
|
|
405
|
-
} : void 0;
|
|
355
|
+
visibleColumns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
|
356
|
+
} : void 0;
|
|
357
|
+
const MemoizedGridRow = (0, _fastMemo.fastMemo)(GridRow);
|
|
358
|
+
exports.GridRow = MemoizedGridRow;
|