@mui/x-data-grid 8.5.0 → 8.5.2
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 +204 -0
- package/components/columnsPanel/ColumnsPanelTrigger.d.ts +1 -1
- package/components/columnsPanel/ColumnsPanelTrigger.js +2 -2
- package/components/containers/GridRootStyles.d.ts +1 -1
- package/components/containers/GridRootStyles.js +6 -0
- package/components/export/ExportCsv.d.ts +1 -1
- package/components/export/ExportCsv.js +2 -2
- package/components/export/ExportPrint.d.ts +1 -1
- package/components/export/ExportPrint.js +2 -2
- package/components/filterPanel/FilterPanelTrigger.d.ts +1 -1
- package/components/filterPanel/FilterPanelTrigger.js +2 -2
- package/components/quickFilter/QuickFilter.d.ts +1 -1
- package/components/quickFilter/QuickFilter.js +2 -2
- package/components/quickFilter/QuickFilterClear.d.ts +1 -1
- package/components/quickFilter/QuickFilterClear.js +2 -2
- package/components/quickFilter/QuickFilterControl.d.ts +1 -1
- package/components/quickFilter/QuickFilterControl.js +2 -2
- package/components/quickFilter/QuickFilterTrigger.d.ts +1 -1
- package/components/quickFilter/QuickFilterTrigger.js +2 -2
- package/components/toolbarV8/Toolbar.d.ts +1 -1
- package/components/toolbarV8/Toolbar.js +2 -2
- package/components/toolbarV8/ToolbarButton.d.ts +1 -1
- package/components/toolbarV8/ToolbarButton.js +2 -2
- package/esm/components/columnsPanel/ColumnsPanelTrigger.d.ts +1 -1
- package/esm/components/columnsPanel/ColumnsPanelTrigger.js +2 -2
- package/esm/components/containers/GridRootStyles.d.ts +1 -1
- package/esm/components/containers/GridRootStyles.js +6 -0
- package/esm/components/export/ExportCsv.d.ts +1 -1
- package/esm/components/export/ExportCsv.js +2 -2
- package/esm/components/export/ExportPrint.d.ts +1 -1
- package/esm/components/export/ExportPrint.js +2 -2
- package/esm/components/filterPanel/FilterPanelTrigger.d.ts +1 -1
- package/esm/components/filterPanel/FilterPanelTrigger.js +2 -2
- package/esm/components/quickFilter/QuickFilter.d.ts +1 -1
- package/esm/components/quickFilter/QuickFilter.js +2 -2
- package/esm/components/quickFilter/QuickFilterClear.d.ts +1 -1
- package/esm/components/quickFilter/QuickFilterClear.js +2 -2
- package/esm/components/quickFilter/QuickFilterControl.d.ts +1 -1
- package/esm/components/quickFilter/QuickFilterControl.js +2 -2
- package/esm/components/quickFilter/QuickFilterTrigger.d.ts +1 -1
- package/esm/components/quickFilter/QuickFilterTrigger.js +2 -2
- package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
- package/esm/components/toolbarV8/Toolbar.js +2 -2
- package/esm/components/toolbarV8/ToolbarButton.d.ts +1 -1
- package/esm/components/toolbarV8/ToolbarButton.js +2 -2
- package/esm/hooks/core/pipeProcessing/useGridPipeProcessing.js +3 -3
- package/esm/hooks/core/useGridApiInitialization.js +1 -1
- package/esm/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +13 -5
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/esm/hooks/features/columnResize/columnResizeSelector.d.ts +3 -1
- package/esm/hooks/features/columns/gridColumnsSelector.d.ts +41 -15
- package/esm/hooks/features/columns/gridColumnsUtils.js +3 -1
- package/esm/hooks/features/dataSource/gridDataSourceSelector.d.ts +4 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +4 -0
- package/esm/hooks/features/density/densitySelector.d.ts +3 -1
- package/esm/hooks/features/dimensions/gridDimensionsSelectors.d.ts +36 -12
- package/esm/hooks/features/editing/gridEditingSelectors.d.ts +8 -4
- package/esm/hooks/features/filter/gridFilterSelector.d.ts +51 -17
- package/esm/hooks/features/filter/gridFilterState.d.ts +2 -1
- package/esm/hooks/features/filter/gridFilterState.js +2 -1
- package/esm/hooks/features/filter/useGridFilter.js +1 -1
- package/esm/hooks/features/focus/gridFocusStateSelector.d.ts +24 -8
- package/esm/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +9 -3
- package/esm/hooks/features/pagination/gridPaginationSelector.d.ts +35 -19
- package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +9 -4
- package/esm/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +3 -1
- package/esm/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +9 -3
- package/esm/hooks/features/rowSelection/useGridRowSelectionPreProcessors.js +9 -5
- package/esm/hooks/features/rowSelection/utils.d.ts +5 -3
- package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +9 -3
- package/esm/hooks/features/rows/gridRowsSelector.d.ts +50 -29
- package/esm/hooks/features/sorting/gridSortingSelector.d.ts +15 -5
- package/esm/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +4 -2
- package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +15 -5
- package/esm/hooks/features/virtualization/gridVirtualizationSelectors.js +3 -1
- package/esm/hooks/utils/index.d.ts +1 -1
- package/esm/hooks/utils/useGridSelector.d.ts +2 -4
- package/esm/hooks/utils/useGridSelector.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +0 -1
- package/esm/internals/index.js +0 -1
- package/esm/locales/arSD.js +5 -6
- package/esm/locales/ptPT.js +4 -4
- package/esm/material/variables.js +1 -2
- package/esm/models/api/gridCoreApi.d.ts +1 -1
- package/esm/models/gridCellClass.d.ts +2 -0
- package/esm/models/gridColumnGrouping.d.ts +2 -0
- package/esm/models/gridColumnGrouping.js +2 -0
- package/esm/models/gridColumnHeaderClass.d.ts +2 -0
- package/esm/models/gridRows.d.ts +2 -0
- package/esm/models/gridSortModel.d.ts +5 -0
- package/esm/models/params/gridRowParams.d.ts +1 -1
- package/esm/models/params/gridRowParams.js +1 -1
- package/esm/utils/createSelector.d.ts +3 -11
- package/esm/utils/createSelector.js +16 -86
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +3 -3
- package/hooks/core/useGridApiInitialization.js +2 -2
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +13 -5
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnResize/columnResizeSelector.d.ts +3 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +41 -15
- package/hooks/features/columns/gridColumnsUtils.js +3 -1
- package/hooks/features/dataSource/gridDataSourceSelector.d.ts +4 -2
- package/hooks/features/dataSource/useGridDataSourceBase.js +4 -0
- package/hooks/features/density/densitySelector.d.ts +3 -1
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +36 -12
- package/hooks/features/editing/gridEditingSelectors.d.ts +8 -4
- package/hooks/features/filter/gridFilterSelector.d.ts +51 -17
- package/hooks/features/filter/gridFilterState.d.ts +2 -1
- package/hooks/features/filter/gridFilterState.js +2 -1
- package/hooks/features/filter/useGridFilter.js +2 -2
- package/hooks/features/focus/gridFocusStateSelector.d.ts +24 -8
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +9 -3
- package/hooks/features/pagination/gridPaginationSelector.d.ts +35 -19
- package/hooks/features/pivoting/gridPivotingSelectors.d.ts +9 -4
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +3 -1
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +9 -3
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.js +9 -5
- package/hooks/features/rowSelection/utils.d.ts +5 -3
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +9 -3
- package/hooks/features/rows/gridRowsSelector.d.ts +50 -29
- package/hooks/features/sorting/gridSortingSelector.d.ts +15 -5
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +4 -2
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +15 -5
- package/hooks/features/virtualization/gridVirtualizationSelectors.js +3 -1
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +2 -4
- package/hooks/utils/useGridSelector.js +4 -4
- package/index.js +1 -1
- package/internals/index.d.ts +0 -1
- package/internals/index.js +0 -8
- package/locales/arSD.js +5 -6
- package/locales/ptPT.js +4 -4
- package/material/variables.js +1 -2
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/gridCellClass.d.ts +2 -0
- package/models/gridColumnGrouping.d.ts +2 -0
- package/models/gridColumnGrouping.js +2 -0
- package/models/gridColumnHeaderClass.d.ts +2 -0
- package/models/gridRows.d.ts +2 -0
- package/models/gridSortModel.d.ts +5 -0
- package/models/params/gridRowParams.d.ts +1 -1
- package/models/params/gridRowParams.js +1 -1
- package/package.json +4 -5
- package/utils/createSelector.d.ts +3 -11
- package/utils/createSelector.js +18 -88
- package/esm/hooks/utils/useGridComponentRenderer.d.ts +0 -12
- package/esm/hooks/utils/useGridComponentRenderer.js +0 -36
- package/esm/utils/Store.d.ts +0 -11
- package/esm/utils/Store.js +0 -24
- package/esm/utils/weakMapMemoize.d.ts +0 -20
- package/esm/utils/weakMapMemoize.js +0 -128
- package/hooks/utils/useGridComponentRenderer.d.ts +0 -12
- package/hooks/utils/useGridComponentRenderer.js +0 -44
- package/utils/Store.d.ts +0 -11
- package/utils/Store.js +0 -31
- package/utils/weakMapMemoize.d.ts +0 -20
- package/utils/weakMapMemoize.js +0 -134
package/utils/createSelector.js
CHANGED
|
@@ -4,64 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createSelectorMemoized = exports.createSelector = exports.createRootSelector = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
const cache = new WeakMap();
|
|
19
|
-
const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
20
|
-
if (other.length > 0) {
|
|
21
|
-
throw new Error('Unsupported number of selectors');
|
|
22
|
-
}
|
|
23
|
-
let selector;
|
|
24
|
-
|
|
25
|
-
// eslint-disable-next-line id-denylist
|
|
26
|
-
if (a && b && c && d && e && f) {
|
|
27
|
-
selector = (apiRef, args) => {
|
|
28
|
-
const va = a(apiRef, args);
|
|
29
|
-
const vb = b(apiRef, args);
|
|
30
|
-
const vc = c(apiRef, args);
|
|
31
|
-
const vd = d(apiRef, args);
|
|
32
|
-
const ve = e(apiRef, args);
|
|
33
|
-
return f(va, vb, vc, vd, ve, args);
|
|
34
|
-
};
|
|
35
|
-
// eslint-disable-next-line id-denylist
|
|
36
|
-
} else if (a && b && c && d && e) {
|
|
37
|
-
selector = (apiRef, args) => {
|
|
38
|
-
const va = a(apiRef, args);
|
|
39
|
-
const vb = b(apiRef, args);
|
|
40
|
-
const vc = c(apiRef, args);
|
|
41
|
-
const vd = d(apiRef, args);
|
|
42
|
-
return e(va, vb, vc, vd, args);
|
|
43
|
-
};
|
|
44
|
-
} else if (a && b && c && d) {
|
|
45
|
-
selector = (apiRef, args) => {
|
|
46
|
-
const va = a(apiRef, args);
|
|
47
|
-
const vb = b(apiRef, args);
|
|
48
|
-
const vc = c(apiRef, args);
|
|
49
|
-
return d(va, vb, vc, args);
|
|
50
|
-
};
|
|
51
|
-
} else if (a && b && c) {
|
|
52
|
-
selector = (apiRef, args) => {
|
|
53
|
-
const va = a(apiRef, args);
|
|
54
|
-
const vb = b(apiRef, args);
|
|
55
|
-
return c(va, vb, args);
|
|
56
|
-
};
|
|
57
|
-
} else if (a && b) {
|
|
58
|
-
selector = (apiRef, args) => {
|
|
59
|
-
const va = a(apiRef, args);
|
|
60
|
-
return b(va, args);
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error('Missing arguments');
|
|
64
|
-
}
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
|
+
const createSelector = (...args) => {
|
|
9
|
+
const baseSelector = (0, _store.createSelector)(...args);
|
|
10
|
+
const selector = (apiRef, a1, a2, a3) => baseSelector(unwrapIfNeeded(apiRef), a1, a2, a3);
|
|
11
|
+
return selector;
|
|
12
|
+
};
|
|
13
|
+
exports.createSelector = createSelector;
|
|
14
|
+
const createSelectorMemoized = (...args) => {
|
|
15
|
+
const baseSelector = (0, _store.createSelectorMemoized)(...args);
|
|
16
|
+
const selector = (apiRef, a1, a2, a3) => baseSelector(unwrapIfNeeded(apiRef), a1, a2, a3);
|
|
65
17
|
return selector;
|
|
66
18
|
};
|
|
67
19
|
|
|
@@ -70,34 +22,12 @@ const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
|
70
22
|
* and strips from the types the possibility of `apiRef` being `null`.
|
|
71
23
|
* Users are warned about this in our documentation https://mui.com/x/react-data-grid/state/#direct-selector-access
|
|
72
24
|
*/
|
|
73
|
-
exports.
|
|
74
|
-
const createRootSelector = fn => (apiRef, args) => fn(apiRef
|
|
25
|
+
exports.createSelectorMemoized = createSelectorMemoized;
|
|
26
|
+
const createRootSelector = fn => (apiRef, args) => fn(unwrapIfNeeded(apiRef), args);
|
|
75
27
|
exports.createRootSelector = createRootSelector;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (cacheArgs && cacheFn) {
|
|
83
|
-
if (!(0, _useGridSelector.argsEqual)(cacheFn.selectorArgs, selectorArgs)) {
|
|
84
|
-
const reselectArgs = selectorArgs !== undefined ? [...args.slice(0, args.length - 1), () => selectorArgs, args[args.length - 1]] : args;
|
|
85
|
-
const fn = reselectCreateSelector(...reselectArgs);
|
|
86
|
-
fn.selectorArgs = selectorArgs;
|
|
87
|
-
cacheArgs.set(args, fn);
|
|
88
|
-
return fn(apiRef, selectorArgs);
|
|
89
|
-
}
|
|
90
|
-
return cacheFn(apiRef, selectorArgs);
|
|
91
|
-
}
|
|
92
|
-
const reselectArgs = selectorArgs !== undefined ? [...args.slice(0, args.length - 1), () => selectorArgs, args[args.length - 1]] : args;
|
|
93
|
-
const fn = reselectCreateSelector(...reselectArgs);
|
|
94
|
-
fn.selectorArgs = selectorArgs;
|
|
95
|
-
if (!cacheArgsInit) {
|
|
96
|
-
cache.set(cacheKey, cacheArgs);
|
|
97
|
-
}
|
|
98
|
-
cacheArgs.set(args, fn);
|
|
99
|
-
return fn(apiRef, selectorArgs);
|
|
100
|
-
};
|
|
101
|
-
return selector;
|
|
102
|
-
};
|
|
103
|
-
exports.createSelectorMemoized = createSelectorMemoized;
|
|
28
|
+
function unwrapIfNeeded(refOrState) {
|
|
29
|
+
if ('current' in refOrState) {
|
|
30
|
+
return refOrState.current.state;
|
|
31
|
+
}
|
|
32
|
+
return refOrState;
|
|
33
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export type RenderProp<Props, State = {}> = ((props: Props, state: State) => React.ReactElement<unknown>) | React.ReactElement<Props>;
|
|
3
|
-
/**
|
|
4
|
-
* Resolves the rendering logic for a component.
|
|
5
|
-
* Handles three scenarios:
|
|
6
|
-
* 1. A render function that receives props and state
|
|
7
|
-
* 2. A React element
|
|
8
|
-
* 3. A default element
|
|
9
|
-
*
|
|
10
|
-
* @ignore - internal hook.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useGridComponentRenderer<Props extends React.HTMLAttributes<any>, State extends Record<string, any>>(defaultElement: keyof React.JSX.IntrinsicElements | React.ComponentType<Props>, render: RenderProp<Props, State> | undefined, props: Props, state?: State): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
/**
|
|
5
|
-
* Resolves the rendering logic for a component.
|
|
6
|
-
* Handles three scenarios:
|
|
7
|
-
* 1. A render function that receives props and state
|
|
8
|
-
* 2. A React element
|
|
9
|
-
* 3. A default element
|
|
10
|
-
*
|
|
11
|
-
* @ignore - internal hook.
|
|
12
|
-
*/
|
|
13
|
-
export function useGridComponentRenderer(defaultElement, render, props, state = {}) {
|
|
14
|
-
if (typeof render === 'function') {
|
|
15
|
-
return render(props, state);
|
|
16
|
-
}
|
|
17
|
-
if (render) {
|
|
18
|
-
if (render.props.className) {
|
|
19
|
-
props.className = clsx(render.props.className, props.className);
|
|
20
|
-
}
|
|
21
|
-
if (render.props.style || props.style) {
|
|
22
|
-
props.style = _extends({}, props.style, render.props.style);
|
|
23
|
-
}
|
|
24
|
-
if (render.props.sx || props.sx) {
|
|
25
|
-
props.sx = mergeSx(props.sx, render.props.sx);
|
|
26
|
-
}
|
|
27
|
-
return /*#__PURE__*/React.cloneElement(render, props);
|
|
28
|
-
}
|
|
29
|
-
return /*#__PURE__*/React.createElement(defaultElement, props);
|
|
30
|
-
}
|
|
31
|
-
function mergeSx(sx1, sx2) {
|
|
32
|
-
if (!sx1 || !sx2) {
|
|
33
|
-
return sx1 || sx2;
|
|
34
|
-
}
|
|
35
|
-
return (Array.isArray(sx1) ? sx1 : [sx1]).concat(Array.isArray(sx2) ? sx2 : [sx2]);
|
|
36
|
-
}
|
package/esm/utils/Store.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type Listener<T> = (value: T) => void;
|
|
2
|
-
export declare class Store<T> {
|
|
3
|
-
value: T;
|
|
4
|
-
listeners: Set<Listener<T>>;
|
|
5
|
-
static create<T>(value: T): Store<T>;
|
|
6
|
-
constructor(value: T);
|
|
7
|
-
subscribe: (fn: Listener<T>) => () => void;
|
|
8
|
-
getSnapshot: () => T;
|
|
9
|
-
update: (value: T) => void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
package/esm/utils/Store.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type AnyNonNullishValue = NonNullable<unknown>;
|
|
2
|
-
type Simplify<T> = T extends AnyFunction ? T : { [KeyType in keyof T]: T[KeyType] } & AnyNonNullishValue;
|
|
3
|
-
type EqualityFn<T = any> = (a: T, b: T) => boolean;
|
|
4
|
-
type DefaultMemoizeFields = {
|
|
5
|
-
clearCache: () => void;
|
|
6
|
-
resultsCount: () => number;
|
|
7
|
-
resetResultsCount: () => void;
|
|
8
|
-
};
|
|
9
|
-
type AnyFunction = (...args: any[]) => any;
|
|
10
|
-
interface WeakMapMemoizeOptions<Result = any> {
|
|
11
|
-
resultEqualityCheck?: EqualityFn<Result>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Inspired by the `weakMapMemoize` function from the `reselect` library.
|
|
15
|
-
*
|
|
16
|
-
* @see {@link https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts `original source code`}
|
|
17
|
-
* @see {@link https://reselect.js.org/api/weakMapMemoize `weakMapMemoize api docs`}
|
|
18
|
-
*/
|
|
19
|
-
export declare function weakMapMemoize<Func extends AnyFunction>(func: Func, options?: WeakMapMemoizeOptions<ReturnType<Func>>): Func & Simplify<DefaultMemoizeFields>;
|
|
20
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Original source:
|
|
2
|
-
// - https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts
|
|
3
|
-
|
|
4
|
-
class StrongRef {
|
|
5
|
-
constructor(value) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
}
|
|
8
|
-
deref() {
|
|
9
|
-
return this.value;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const getWeakRef = () => typeof WeakRef === 'undefined' ? StrongRef : WeakRef;
|
|
13
|
-
const Ref = /** @__PURE__ */getWeakRef();
|
|
14
|
-
const UNTERMINATED = 0;
|
|
15
|
-
const TERMINATED = 1;
|
|
16
|
-
function createCacheNode() {
|
|
17
|
-
return {
|
|
18
|
-
s: UNTERMINATED,
|
|
19
|
-
v: undefined,
|
|
20
|
-
o: null,
|
|
21
|
-
p: null
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Derefences the argument if it is a Ref. Else if it is a value already, return it.
|
|
26
|
-
*
|
|
27
|
-
* @param r - the object to maybe deref
|
|
28
|
-
* @returns The derefenced value if the argument is a Ref, else the argument value itself.
|
|
29
|
-
*/
|
|
30
|
-
function maybeDeref(r) {
|
|
31
|
-
if (r instanceof Ref) {
|
|
32
|
-
return r.deref();
|
|
33
|
-
}
|
|
34
|
-
return r;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Inspired by the `weakMapMemoize` function from the `reselect` library.
|
|
39
|
-
*
|
|
40
|
-
* @see {@link https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts `original source code`}
|
|
41
|
-
* @see {@link https://reselect.js.org/api/weakMapMemoize `weakMapMemoize api docs`}
|
|
42
|
-
*/
|
|
43
|
-
export function weakMapMemoize(func, options = {}) {
|
|
44
|
-
let fnNode = createCacheNode();
|
|
45
|
-
const {
|
|
46
|
-
resultEqualityCheck
|
|
47
|
-
} = options;
|
|
48
|
-
let lastResult;
|
|
49
|
-
let resultsCount = 0;
|
|
50
|
-
function memoized() {
|
|
51
|
-
let cacheNode = fnNode;
|
|
52
|
-
// eslint-disable-next-line prefer-rest-params
|
|
53
|
-
const {
|
|
54
|
-
length
|
|
55
|
-
} = arguments;
|
|
56
|
-
for (let i = 0, l = length; i < l; i += 1) {
|
|
57
|
-
// eslint-disable-next-line prefer-rest-params
|
|
58
|
-
let arg = arguments[i];
|
|
59
|
-
if (typeof arg === 'function' || typeof arg === 'object' && arg !== null) {
|
|
60
|
-
// Following logic is added over the original `weakMapMemoize` to support the proper memoization of the `GridApiRef`
|
|
61
|
-
if ('current' in arg && 'instanceId' in arg.current) {
|
|
62
|
-
arg = arg.current.state;
|
|
63
|
-
}
|
|
64
|
-
// Objects go into a WeakMap
|
|
65
|
-
let objectCache = cacheNode.o;
|
|
66
|
-
if (objectCache === null) {
|
|
67
|
-
objectCache = new WeakMap();
|
|
68
|
-
cacheNode.o = objectCache;
|
|
69
|
-
}
|
|
70
|
-
const objectNode = objectCache.get(arg);
|
|
71
|
-
if (objectNode === undefined) {
|
|
72
|
-
cacheNode = createCacheNode();
|
|
73
|
-
objectCache.set(arg, cacheNode);
|
|
74
|
-
} else {
|
|
75
|
-
cacheNode = objectNode;
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
// Primitives go into a regular Map
|
|
79
|
-
let primitiveCache = cacheNode.p;
|
|
80
|
-
if (primitiveCache === null) {
|
|
81
|
-
primitiveCache = new Map();
|
|
82
|
-
cacheNode.p = primitiveCache;
|
|
83
|
-
}
|
|
84
|
-
const primitiveNode = primitiveCache.get(arg);
|
|
85
|
-
if (primitiveNode === undefined) {
|
|
86
|
-
cacheNode = createCacheNode();
|
|
87
|
-
primitiveCache.set(arg, cacheNode);
|
|
88
|
-
} else {
|
|
89
|
-
cacheNode = primitiveNode;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const terminatedNode = cacheNode;
|
|
94
|
-
let result;
|
|
95
|
-
if (cacheNode.s === TERMINATED) {
|
|
96
|
-
result = cacheNode.v;
|
|
97
|
-
} else {
|
|
98
|
-
// Allow errors to propagate
|
|
99
|
-
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
|
100
|
-
result = func.apply(null, arguments);
|
|
101
|
-
resultsCount += 1;
|
|
102
|
-
if (resultEqualityCheck) {
|
|
103
|
-
// Deref lastResult if it is a Ref
|
|
104
|
-
const lastResultValue = maybeDeref(lastResult);
|
|
105
|
-
if (lastResultValue != null && resultEqualityCheck(lastResultValue, result)) {
|
|
106
|
-
result = lastResultValue;
|
|
107
|
-
if (resultsCount !== 0) {
|
|
108
|
-
resultsCount -= 1;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const needsWeakRef = typeof result === 'object' && result !== null || typeof result === 'function';
|
|
112
|
-
lastResult = needsWeakRef ? /** @__PURE__ */new Ref(result) : result;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
terminatedNode.s = TERMINATED;
|
|
116
|
-
terminatedNode.v = result;
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
memoized.clearCache = () => {
|
|
120
|
-
fnNode = createCacheNode();
|
|
121
|
-
memoized.resetResultsCount();
|
|
122
|
-
};
|
|
123
|
-
memoized.resultsCount = () => resultsCount;
|
|
124
|
-
memoized.resetResultsCount = () => {
|
|
125
|
-
resultsCount = 0;
|
|
126
|
-
};
|
|
127
|
-
return memoized;
|
|
128
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export type RenderProp<Props, State = {}> = ((props: Props, state: State) => React.ReactElement<unknown>) | React.ReactElement<Props>;
|
|
3
|
-
/**
|
|
4
|
-
* Resolves the rendering logic for a component.
|
|
5
|
-
* Handles three scenarios:
|
|
6
|
-
* 1. A render function that receives props and state
|
|
7
|
-
* 2. A React element
|
|
8
|
-
* 3. A default element
|
|
9
|
-
*
|
|
10
|
-
* @ignore - internal hook.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useGridComponentRenderer<Props extends React.HTMLAttributes<any>, State extends Record<string, any>>(defaultElement: keyof React.JSX.IntrinsicElements | React.ComponentType<Props>, render: RenderProp<Props, State> | undefined, props: Props, state?: State): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.useGridComponentRenderer = useGridComponentRenderer;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
|
-
/**
|
|
13
|
-
* Resolves the rendering logic for a component.
|
|
14
|
-
* Handles three scenarios:
|
|
15
|
-
* 1. A render function that receives props and state
|
|
16
|
-
* 2. A React element
|
|
17
|
-
* 3. A default element
|
|
18
|
-
*
|
|
19
|
-
* @ignore - internal hook.
|
|
20
|
-
*/
|
|
21
|
-
function useGridComponentRenderer(defaultElement, render, props, state = {}) {
|
|
22
|
-
if (typeof render === 'function') {
|
|
23
|
-
return render(props, state);
|
|
24
|
-
}
|
|
25
|
-
if (render) {
|
|
26
|
-
if (render.props.className) {
|
|
27
|
-
props.className = (0, _clsx.default)(render.props.className, props.className);
|
|
28
|
-
}
|
|
29
|
-
if (render.props.style || props.style) {
|
|
30
|
-
props.style = (0, _extends2.default)({}, props.style, render.props.style);
|
|
31
|
-
}
|
|
32
|
-
if (render.props.sx || props.sx) {
|
|
33
|
-
props.sx = mergeSx(props.sx, render.props.sx);
|
|
34
|
-
}
|
|
35
|
-
return /*#__PURE__*/React.cloneElement(render, props);
|
|
36
|
-
}
|
|
37
|
-
return /*#__PURE__*/React.createElement(defaultElement, props);
|
|
38
|
-
}
|
|
39
|
-
function mergeSx(sx1, sx2) {
|
|
40
|
-
if (!sx1 || !sx2) {
|
|
41
|
-
return sx1 || sx2;
|
|
42
|
-
}
|
|
43
|
-
return (Array.isArray(sx1) ? sx1 : [sx1]).concat(Array.isArray(sx2) ? sx2 : [sx2]);
|
|
44
|
-
}
|
package/utils/Store.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type Listener<T> = (value: T) => void;
|
|
2
|
-
export declare class Store<T> {
|
|
3
|
-
value: T;
|
|
4
|
-
listeners: Set<Listener<T>>;
|
|
5
|
-
static create<T>(value: T): Store<T>;
|
|
6
|
-
constructor(value: T);
|
|
7
|
-
subscribe: (fn: Listener<T>) => () => void;
|
|
8
|
-
getSnapshot: () => T;
|
|
9
|
-
update: (value: T) => void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
package/utils/Store.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Store = void 0;
|
|
7
|
-
class Store {
|
|
8
|
-
static create(value) {
|
|
9
|
-
return new Store(value);
|
|
10
|
-
}
|
|
11
|
-
constructor(_value) {
|
|
12
|
-
this.value = void 0;
|
|
13
|
-
this.listeners = void 0;
|
|
14
|
-
this.subscribe = fn => {
|
|
15
|
-
this.listeners.add(fn);
|
|
16
|
-
return () => {
|
|
17
|
-
this.listeners.delete(fn);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
this.getSnapshot = () => {
|
|
21
|
-
return this.value;
|
|
22
|
-
};
|
|
23
|
-
this.update = value => {
|
|
24
|
-
this.value = value;
|
|
25
|
-
this.listeners.forEach(l => l(value));
|
|
26
|
-
};
|
|
27
|
-
this.value = _value;
|
|
28
|
-
this.listeners = new Set();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Store = Store;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type AnyNonNullishValue = NonNullable<unknown>;
|
|
2
|
-
type Simplify<T> = T extends AnyFunction ? T : { [KeyType in keyof T]: T[KeyType] } & AnyNonNullishValue;
|
|
3
|
-
type EqualityFn<T = any> = (a: T, b: T) => boolean;
|
|
4
|
-
type DefaultMemoizeFields = {
|
|
5
|
-
clearCache: () => void;
|
|
6
|
-
resultsCount: () => number;
|
|
7
|
-
resetResultsCount: () => void;
|
|
8
|
-
};
|
|
9
|
-
type AnyFunction = (...args: any[]) => any;
|
|
10
|
-
interface WeakMapMemoizeOptions<Result = any> {
|
|
11
|
-
resultEqualityCheck?: EqualityFn<Result>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Inspired by the `weakMapMemoize` function from the `reselect` library.
|
|
15
|
-
*
|
|
16
|
-
* @see {@link https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts `original source code`}
|
|
17
|
-
* @see {@link https://reselect.js.org/api/weakMapMemoize `weakMapMemoize api docs`}
|
|
18
|
-
*/
|
|
19
|
-
export declare function weakMapMemoize<Func extends AnyFunction>(func: Func, options?: WeakMapMemoizeOptions<ReturnType<Func>>): Func & Simplify<DefaultMemoizeFields>;
|
|
20
|
-
export {};
|
package/utils/weakMapMemoize.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.weakMapMemoize = weakMapMemoize;
|
|
7
|
-
// Original source:
|
|
8
|
-
// - https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts
|
|
9
|
-
|
|
10
|
-
class StrongRef {
|
|
11
|
-
constructor(value) {
|
|
12
|
-
this.value = value;
|
|
13
|
-
}
|
|
14
|
-
deref() {
|
|
15
|
-
return this.value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const getWeakRef = () => typeof WeakRef === 'undefined' ? StrongRef : WeakRef;
|
|
19
|
-
const Ref = /** @__PURE__ */getWeakRef();
|
|
20
|
-
const UNTERMINATED = 0;
|
|
21
|
-
const TERMINATED = 1;
|
|
22
|
-
function createCacheNode() {
|
|
23
|
-
return {
|
|
24
|
-
s: UNTERMINATED,
|
|
25
|
-
v: undefined,
|
|
26
|
-
o: null,
|
|
27
|
-
p: null
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Derefences the argument if it is a Ref. Else if it is a value already, return it.
|
|
32
|
-
*
|
|
33
|
-
* @param r - the object to maybe deref
|
|
34
|
-
* @returns The derefenced value if the argument is a Ref, else the argument value itself.
|
|
35
|
-
*/
|
|
36
|
-
function maybeDeref(r) {
|
|
37
|
-
if (r instanceof Ref) {
|
|
38
|
-
return r.deref();
|
|
39
|
-
}
|
|
40
|
-
return r;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Inspired by the `weakMapMemoize` function from the `reselect` library.
|
|
45
|
-
*
|
|
46
|
-
* @see {@link https://github.com/reduxjs/reselect/blob/1c3fc05f041d32cd69c11a7f7deccf0bce6f4598/src/weakMapMemoize.ts `original source code`}
|
|
47
|
-
* @see {@link https://reselect.js.org/api/weakMapMemoize `weakMapMemoize api docs`}
|
|
48
|
-
*/
|
|
49
|
-
function weakMapMemoize(func, options = {}) {
|
|
50
|
-
let fnNode = createCacheNode();
|
|
51
|
-
const {
|
|
52
|
-
resultEqualityCheck
|
|
53
|
-
} = options;
|
|
54
|
-
let lastResult;
|
|
55
|
-
let resultsCount = 0;
|
|
56
|
-
function memoized() {
|
|
57
|
-
let cacheNode = fnNode;
|
|
58
|
-
// eslint-disable-next-line prefer-rest-params
|
|
59
|
-
const {
|
|
60
|
-
length
|
|
61
|
-
} = arguments;
|
|
62
|
-
for (let i = 0, l = length; i < l; i += 1) {
|
|
63
|
-
// eslint-disable-next-line prefer-rest-params
|
|
64
|
-
let arg = arguments[i];
|
|
65
|
-
if (typeof arg === 'function' || typeof arg === 'object' && arg !== null) {
|
|
66
|
-
// Following logic is added over the original `weakMapMemoize` to support the proper memoization of the `GridApiRef`
|
|
67
|
-
if ('current' in arg && 'instanceId' in arg.current) {
|
|
68
|
-
arg = arg.current.state;
|
|
69
|
-
}
|
|
70
|
-
// Objects go into a WeakMap
|
|
71
|
-
let objectCache = cacheNode.o;
|
|
72
|
-
if (objectCache === null) {
|
|
73
|
-
objectCache = new WeakMap();
|
|
74
|
-
cacheNode.o = objectCache;
|
|
75
|
-
}
|
|
76
|
-
const objectNode = objectCache.get(arg);
|
|
77
|
-
if (objectNode === undefined) {
|
|
78
|
-
cacheNode = createCacheNode();
|
|
79
|
-
objectCache.set(arg, cacheNode);
|
|
80
|
-
} else {
|
|
81
|
-
cacheNode = objectNode;
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
// Primitives go into a regular Map
|
|
85
|
-
let primitiveCache = cacheNode.p;
|
|
86
|
-
if (primitiveCache === null) {
|
|
87
|
-
primitiveCache = new Map();
|
|
88
|
-
cacheNode.p = primitiveCache;
|
|
89
|
-
}
|
|
90
|
-
const primitiveNode = primitiveCache.get(arg);
|
|
91
|
-
if (primitiveNode === undefined) {
|
|
92
|
-
cacheNode = createCacheNode();
|
|
93
|
-
primitiveCache.set(arg, cacheNode);
|
|
94
|
-
} else {
|
|
95
|
-
cacheNode = primitiveNode;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const terminatedNode = cacheNode;
|
|
100
|
-
let result;
|
|
101
|
-
if (cacheNode.s === TERMINATED) {
|
|
102
|
-
result = cacheNode.v;
|
|
103
|
-
} else {
|
|
104
|
-
// Allow errors to propagate
|
|
105
|
-
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
|
106
|
-
result = func.apply(null, arguments);
|
|
107
|
-
resultsCount += 1;
|
|
108
|
-
if (resultEqualityCheck) {
|
|
109
|
-
// Deref lastResult if it is a Ref
|
|
110
|
-
const lastResultValue = maybeDeref(lastResult);
|
|
111
|
-
if (lastResultValue != null && resultEqualityCheck(lastResultValue, result)) {
|
|
112
|
-
result = lastResultValue;
|
|
113
|
-
if (resultsCount !== 0) {
|
|
114
|
-
resultsCount -= 1;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const needsWeakRef = typeof result === 'object' && result !== null || typeof result === 'function';
|
|
118
|
-
lastResult = needsWeakRef ? /** @__PURE__ */new Ref(result) : result;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
terminatedNode.s = TERMINATED;
|
|
122
|
-
terminatedNode.v = result;
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
memoized.clearCache = () => {
|
|
126
|
-
fnNode = createCacheNode();
|
|
127
|
-
memoized.resetResultsCount();
|
|
128
|
-
};
|
|
129
|
-
memoized.resultsCount = () => resultsCount;
|
|
130
|
-
memoized.resetResultsCount = () => {
|
|
131
|
-
resultsCount = 0;
|
|
132
|
-
};
|
|
133
|
-
return memoized;
|
|
134
|
-
}
|