@infinite-table/infinite-react 0.1.2 → 0.2.1
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/index.css +5 -4
- package/index.d.ts +280 -198
- package/index.esm.css +5 -4
- package/index.esm.js +1112 -673
- package/index.js +1151 -712
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -193,11 +193,11 @@ var require_common = __commonJS({
|
|
|
193
193
|
let enableOverride = null;
|
|
194
194
|
let namespacesCache;
|
|
195
195
|
let enabledCache;
|
|
196
|
-
function
|
|
197
|
-
if (!
|
|
196
|
+
function debug6(...args) {
|
|
197
|
+
if (!debug6.enabled) {
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
const self =
|
|
200
|
+
const self = debug6;
|
|
201
201
|
const curr = Number(new Date());
|
|
202
202
|
const ms = curr - (prevTime || curr);
|
|
203
203
|
self.diff = ms;
|
|
@@ -227,12 +227,12 @@ var require_common = __commonJS({
|
|
|
227
227
|
const logFn = self.log || createDebug.log;
|
|
228
228
|
logFn.apply(self, args);
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Object.defineProperty(
|
|
230
|
+
debug6.namespace = namespace;
|
|
231
|
+
debug6.useColors = createDebug.useColors();
|
|
232
|
+
debug6.color = createDebug.selectColor(namespace);
|
|
233
|
+
debug6.extend = extend;
|
|
234
|
+
debug6.destroy = createDebug.destroy;
|
|
235
|
+
Object.defineProperty(debug6, "enabled", {
|
|
236
236
|
enumerable: true,
|
|
237
237
|
configurable: false,
|
|
238
238
|
get: () => {
|
|
@@ -250,9 +250,9 @@ var require_common = __commonJS({
|
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
if (typeof createDebug.init === "function") {
|
|
253
|
-
createDebug.init(
|
|
253
|
+
createDebug.init(debug6);
|
|
254
254
|
}
|
|
255
|
-
return
|
|
255
|
+
return debug6;
|
|
256
256
|
}
|
|
257
257
|
function extend(namespace, delimiter) {
|
|
258
258
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -622,7 +622,7 @@ import {
|
|
|
622
622
|
createElement as createElement33,
|
|
623
623
|
memo as memo13,
|
|
624
624
|
useEffect as useEffect24,
|
|
625
|
-
useLayoutEffect as
|
|
625
|
+
useLayoutEffect as useLayoutEffect5
|
|
626
626
|
} from "react";
|
|
627
627
|
|
|
628
628
|
// src/components/InfiniteTable/internalProps.ts
|
|
@@ -704,14 +704,21 @@ var ScrollListener = class {
|
|
|
704
704
|
};
|
|
705
705
|
|
|
706
706
|
// src/components/InfiniteTable/utils/toMap.ts
|
|
707
|
-
function toMap(mapOrObject) {
|
|
707
|
+
function toMap(mapOrObject, weakMapCache) {
|
|
708
708
|
if (!mapOrObject) {
|
|
709
709
|
return new Map();
|
|
710
710
|
}
|
|
711
711
|
if (mapOrObject instanceof Map) {
|
|
712
712
|
return mapOrObject;
|
|
713
713
|
}
|
|
714
|
-
|
|
714
|
+
if (weakMapCache && weakMapCache.has(mapOrObject)) {
|
|
715
|
+
return weakMapCache.get(mapOrObject);
|
|
716
|
+
}
|
|
717
|
+
const result = new Map(Object.entries(mapOrObject));
|
|
718
|
+
if (weakMapCache) {
|
|
719
|
+
weakMapCache.set(mapOrObject, result);
|
|
720
|
+
}
|
|
721
|
+
return result;
|
|
715
722
|
}
|
|
716
723
|
|
|
717
724
|
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
@@ -737,12 +744,10 @@ function computeColumnGroupsDepths(columnGroups) {
|
|
|
737
744
|
}
|
|
738
745
|
|
|
739
746
|
// src/components/InfiniteTable/state/getInitialState.ts
|
|
740
|
-
function toColumnTypesMap(mapOrObject) {
|
|
741
|
-
return toMap(mapOrObject);
|
|
742
|
-
}
|
|
743
747
|
function initSetupState() {
|
|
744
748
|
const columnsGeneratedForGrouping = new Map();
|
|
745
749
|
return {
|
|
750
|
+
propsCache: new Map([]),
|
|
746
751
|
columnShifts: null,
|
|
747
752
|
domRef: createRef(),
|
|
748
753
|
scrollerDOMRef: createRef(),
|
|
@@ -767,12 +772,8 @@ function initSetupState() {
|
|
|
767
772
|
columnsWhenInlineGroupRenderStrategy: void 0
|
|
768
773
|
};
|
|
769
774
|
}
|
|
770
|
-
var forwardProps = () => {
|
|
775
|
+
var forwardProps = (setupState) => {
|
|
771
776
|
return {
|
|
772
|
-
columns: (columns) => {
|
|
773
|
-
var _a;
|
|
774
|
-
return (_a = toMap(columns)) != null ? _a : new Map();
|
|
775
|
-
},
|
|
776
777
|
scrollTopId: 1,
|
|
777
778
|
components: 1,
|
|
778
779
|
loadingText: 1,
|
|
@@ -790,6 +791,7 @@ var forwardProps = () => {
|
|
|
790
791
|
onBlurWithin: 1,
|
|
791
792
|
onScrollToTop: 1,
|
|
792
793
|
onScrollToBottom: 1,
|
|
794
|
+
onScrollStop: 1,
|
|
793
795
|
scrollToBottomOffset: 1,
|
|
794
796
|
rowStyle: 1,
|
|
795
797
|
rowProps: 1,
|
|
@@ -800,6 +802,7 @@ var forwardProps = () => {
|
|
|
800
802
|
pivotRowLabelsColumn: 1,
|
|
801
803
|
pivotColumnGroups: 1,
|
|
802
804
|
onScrollbarsChange: 1,
|
|
805
|
+
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
803
806
|
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
804
807
|
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
805
808
|
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
@@ -818,21 +821,13 @@ var forwardProps = () => {
|
|
|
818
821
|
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
819
822
|
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
820
823
|
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
columnSizing: (columnSizing) => {
|
|
827
|
-
var _a;
|
|
828
|
-
return (_a = toMap(columnSizing)) != null ? _a : new Map();
|
|
829
|
-
},
|
|
830
|
-
columnTypes: (columnTypes) => {
|
|
831
|
-
var _a;
|
|
832
|
-
return (_a = toColumnTypesMap(columnTypes)) != null ? _a : new Map();
|
|
833
|
-
},
|
|
824
|
+
columns: (columns) => toMap(columns, setupState.propsCache.get("columns")),
|
|
825
|
+
columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
|
|
826
|
+
columnPinning: (columnPinning) => toMap(columnPinning, setupState.propsCache.get("columnPinning")),
|
|
827
|
+
columnSizing: (columnSizing) => toMap(columnSizing, setupState.propsCache.get("columnSizing")),
|
|
828
|
+
columnTypes: (columnTypes) => toMap(columnTypes, setupState.propsCache.get("columnTypes")),
|
|
834
829
|
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
835
|
-
columnGroups: (columnGroups) => columnGroups
|
|
830
|
+
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
836
831
|
};
|
|
837
832
|
};
|
|
838
833
|
function getGroupRenderStrategy(options) {
|
|
@@ -1215,11 +1210,11 @@ function getColumnComputedType(column, columnTypes) {
|
|
|
1215
1210
|
// src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
|
|
1216
1211
|
var logError = err("getComputedVisibleColumns");
|
|
1217
1212
|
var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
|
|
1218
|
-
return
|
|
1213
|
+
return columnVisibility[colId] !== false;
|
|
1219
1214
|
};
|
|
1220
1215
|
var getComputedPinned = (colId, columnPinning) => {
|
|
1221
1216
|
const pinned = columnPinning.get(colId);
|
|
1222
|
-
const computedPinned = pinned === "start"
|
|
1217
|
+
const computedPinned = pinned === "start" ? "start" : pinned === "end" ? "end" : false;
|
|
1223
1218
|
return computedPinned;
|
|
1224
1219
|
};
|
|
1225
1220
|
var getComputedVisibleColumns = ({
|
|
@@ -1251,7 +1246,8 @@ var getComputedVisibleColumns = ({
|
|
|
1251
1246
|
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1252
1247
|
return false;
|
|
1253
1248
|
}
|
|
1254
|
-
|
|
1249
|
+
const result2 = isColumnVisible(columnVisibility, columnVisibilityAssumeVisible, colId);
|
|
1250
|
+
return result2;
|
|
1255
1251
|
});
|
|
1256
1252
|
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1257
1253
|
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
@@ -1280,7 +1276,10 @@ var getComputedVisibleColumns = ({
|
|
|
1280
1276
|
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1281
1277
|
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1282
1278
|
};
|
|
1283
|
-
let colSizing = columnSizing.get(colId) || {
|
|
1279
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1280
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1281
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1282
|
+
};
|
|
1284
1283
|
if (colSizing.width != null) {
|
|
1285
1284
|
delete colTypeSizing.flex;
|
|
1286
1285
|
}
|
|
@@ -1567,7 +1566,6 @@ var useComputedVisibleColumns = ({
|
|
|
1567
1566
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1568
1567
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1569
1568
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1570
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1571
1569
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1572
1570
|
const {
|
|
1573
1571
|
computedRemainingSpace,
|
|
@@ -1623,7 +1621,6 @@ var useComputedVisibleColumns = ({
|
|
|
1623
1621
|
pinnedStartMaxWidth,
|
|
1624
1622
|
columnPinning,
|
|
1625
1623
|
columnsRenderId,
|
|
1626
|
-
visibilityRenderId,
|
|
1627
1624
|
columnsSizingRenderId,
|
|
1628
1625
|
pinningRenderId,
|
|
1629
1626
|
columnTypesRenderId
|
|
@@ -1648,7 +1645,7 @@ var useComputedVisibleColumns = ({
|
|
|
1648
1645
|
return result;
|
|
1649
1646
|
};
|
|
1650
1647
|
|
|
1651
|
-
// src/utils/sortAscending.ts
|
|
1648
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1652
1649
|
var sortAscending = (a, b) => a - b;
|
|
1653
1650
|
|
|
1654
1651
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
@@ -1755,9 +1752,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1755
1752
|
if (currentValue === value) {
|
|
1756
1753
|
return;
|
|
1757
1754
|
}
|
|
1758
|
-
|
|
1755
|
+
let notifyTheChange = true;
|
|
1759
1756
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1760
|
-
interceptedActions[key](value, { actions, state: state2 })
|
|
1757
|
+
if (interceptedActions[key](value, { actions, state: state2 }) === false) {
|
|
1758
|
+
notifyTheChange = false;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (notifyTheChange) {
|
|
1762
|
+
notifyChange(props, stateKey, value);
|
|
1761
1763
|
}
|
|
1762
1764
|
const forwardFn = propsToForward[key];
|
|
1763
1765
|
if (typeof forwardFn === "function") {
|
|
@@ -1835,9 +1837,12 @@ function getComponentStateRoot(config) {
|
|
|
1835
1837
|
const getProps = useLatest(props);
|
|
1836
1838
|
const theReducer = (previousState, action) => {
|
|
1837
1839
|
var _a2;
|
|
1840
|
+
if (action.type === "REPLACE_STATE") {
|
|
1841
|
+
return action.payload;
|
|
1842
|
+
}
|
|
1838
1843
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1839
1844
|
const mappedState = action.payload.mappedState;
|
|
1840
|
-
const updatedProps = action.payload.
|
|
1845
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1841
1846
|
const newState = Object.assign({}, previousState);
|
|
1842
1847
|
if (mappedState) {
|
|
1843
1848
|
Object.assign(newState, mappedState);
|
|
@@ -1891,8 +1896,9 @@ function getComponentStateRoot(config) {
|
|
|
1891
1896
|
const currentProps = props;
|
|
1892
1897
|
const newMappedState = {};
|
|
1893
1898
|
let newMappedStateCount = 0;
|
|
1894
|
-
const
|
|
1895
|
-
let
|
|
1899
|
+
const updatedPropsToState = {};
|
|
1900
|
+
let updatedPropsToStateCount = 0;
|
|
1901
|
+
const rawUpdatedProps = {};
|
|
1896
1902
|
for (var k in props) {
|
|
1897
1903
|
const key = k;
|
|
1898
1904
|
const oldValue = prevProps[key];
|
|
@@ -1903,6 +1909,7 @@ function getComponentStateRoot(config) {
|
|
|
1903
1909
|
if (oldValue === newValue) {
|
|
1904
1910
|
continue;
|
|
1905
1911
|
}
|
|
1912
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1906
1913
|
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1907
1914
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1908
1915
|
let valueToSet = newValue;
|
|
@@ -1915,22 +1922,30 @@ function getComponentStateRoot(config) {
|
|
|
1915
1922
|
newMappedStateCount++;
|
|
1916
1923
|
}
|
|
1917
1924
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1918
|
-
|
|
1919
|
-
|
|
1925
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1926
|
+
updatedPropsToStateCount++;
|
|
1920
1927
|
}
|
|
1921
1928
|
}
|
|
1922
1929
|
}
|
|
1923
|
-
if (
|
|
1930
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1924
1931
|
debug2("Triggered by new values for the following props", ...[
|
|
1925
1932
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1926
|
-
...Object.keys(
|
|
1933
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1927
1934
|
]);
|
|
1928
|
-
|
|
1935
|
+
const action = {
|
|
1929
1936
|
payload: {
|
|
1930
1937
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1931
|
-
|
|
1938
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1932
1939
|
}
|
|
1933
|
-
}
|
|
1940
|
+
};
|
|
1941
|
+
dispatch(action);
|
|
1942
|
+
if (config.onPropChange) {
|
|
1943
|
+
for (var prop in rawUpdatedProps)
|
|
1944
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
1945
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
1946
|
+
config.onPropChange({ name: prop, newValue, oldValue }, props, actions);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1934
1949
|
}
|
|
1935
1950
|
});
|
|
1936
1951
|
return /* @__PURE__ */ createElement2(Context.Provider, {
|
|
@@ -2002,28 +2017,31 @@ function useColumnGroups() {
|
|
|
2002
2017
|
return interceptMap(collapsedColumnGroups, {
|
|
2003
2018
|
set: (key, visibleCol) => {
|
|
2004
2019
|
const colIds = key.slice(1);
|
|
2005
|
-
const
|
|
2020
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2006
2021
|
colIds.forEach((colId) => {
|
|
2007
|
-
columnVisibility
|
|
2022
|
+
columnVisibility[colId] = false;
|
|
2008
2023
|
});
|
|
2009
|
-
columnVisibility
|
|
2024
|
+
delete columnVisibility[visibleCol];
|
|
2025
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2010
2026
|
},
|
|
2011
2027
|
beforeClear: (currentCollapsedGroups) => {
|
|
2012
|
-
const
|
|
2028
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2013
2029
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2014
2030
|
keys.forEach((key) => {
|
|
2015
2031
|
const colIds = key.slice(1);
|
|
2016
2032
|
colIds.forEach((colId) => {
|
|
2017
|
-
columnVisibility
|
|
2033
|
+
delete columnVisibility[colId];
|
|
2018
2034
|
});
|
|
2019
2035
|
});
|
|
2036
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2020
2037
|
},
|
|
2021
2038
|
delete: (key) => {
|
|
2022
|
-
const
|
|
2039
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2023
2040
|
const colIds = key.slice(1);
|
|
2024
2041
|
colIds.forEach((colId) => {
|
|
2025
|
-
columnVisibility
|
|
2042
|
+
delete columnVisibility[colId];
|
|
2026
2043
|
});
|
|
2044
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2027
2045
|
}
|
|
2028
2046
|
});
|
|
2029
2047
|
}, [collapsedColumnGroups]);
|
|
@@ -2375,190 +2393,9 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2375
2393
|
};
|
|
2376
2394
|
|
|
2377
2395
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2378
|
-
import { useEffect as useEffect8,
|
|
2379
|
-
|
|
2380
|
-
// src/components/hooks/useEffectWithChanges.ts
|
|
2381
|
-
import { useEffect as useEffect7, useRef as useRef5 } from "react";
|
|
2382
|
-
function useEffectWithChanges(fn, deps) {
|
|
2383
|
-
const prevRef = useRef5({});
|
|
2384
|
-
const oldValuesRef = useRef5({});
|
|
2385
|
-
const oldValues = oldValuesRef.current;
|
|
2386
|
-
const changesRef = useRef5({});
|
|
2387
|
-
const changes = changesRef.current;
|
|
2388
|
-
const useEffectDeps = [];
|
|
2389
|
-
for (let k in deps) {
|
|
2390
|
-
if (deps.hasOwnProperty(k)) {
|
|
2391
|
-
if (deps[k] !== prevRef.current[k]) {
|
|
2392
|
-
changes[k] = deps[k];
|
|
2393
|
-
oldValues[k] = prevRef.current[k];
|
|
2394
|
-
}
|
|
2395
|
-
useEffectDeps.push(deps[k]);
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
prevRef.current = deps;
|
|
2399
|
-
useEffect7(() => {
|
|
2400
|
-
const changes2 = changesRef.current;
|
|
2401
|
-
const result = fn(changes2, oldValues);
|
|
2402
|
-
changesRef.current = {};
|
|
2403
|
-
oldValuesRef.current = {};
|
|
2404
|
-
return result;
|
|
2405
|
-
}, useEffectDeps);
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2409
|
-
var debug3 = dbg("DataSource:useLoadData");
|
|
2410
|
-
function anonimizeValues(arg) {
|
|
2411
|
-
const result = {};
|
|
2412
|
-
for (var k in arg)
|
|
2413
|
-
if (arg.hasOwnProperty(k)) {
|
|
2414
|
-
result[k] = true;
|
|
2415
|
-
}
|
|
2416
|
-
return result;
|
|
2417
|
-
}
|
|
2418
|
-
function buildDataSourceDataParams(componentState, changes) {
|
|
2419
|
-
var _a, _b;
|
|
2420
|
-
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
2421
|
-
const dataSourceParams = {
|
|
2422
|
-
originalDataArray: componentState.originalDataArray,
|
|
2423
|
-
sortInfo,
|
|
2424
|
-
groupBy: componentState.groupBy,
|
|
2425
|
-
pivotBy: componentState.pivotBy
|
|
2426
|
-
};
|
|
2427
|
-
if (componentState.livePagination !== void 0) {
|
|
2428
|
-
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2429
|
-
}
|
|
2430
|
-
if (changes !== void 0) {
|
|
2431
|
-
dataSourceParams.changes = changes;
|
|
2432
|
-
}
|
|
2433
|
-
return dataSourceParams;
|
|
2434
|
-
}
|
|
2435
|
-
function notifyDataParamsChanged(componentState, actions, changes) {
|
|
2436
|
-
var _a;
|
|
2437
|
-
if (typeof componentState.data === "function") {
|
|
2438
|
-
loadData(componentState.data, componentState, actions);
|
|
2439
|
-
}
|
|
2440
|
-
const dataParams = buildDataSourceDataParams(componentState, changes);
|
|
2441
|
-
(_a = componentState.onDataParamsChange) == null ? void 0 : _a.call(componentState, dataParams);
|
|
2442
|
-
}
|
|
2443
|
-
function loadData(data, componentState, actions) {
|
|
2444
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2445
|
-
if (typeof data === "function") {
|
|
2446
|
-
data = data(dataParams);
|
|
2447
|
-
}
|
|
2448
|
-
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
2449
|
-
if (dataIsPromise) {
|
|
2450
|
-
actions.loading = true;
|
|
2451
|
-
}
|
|
2452
|
-
Promise.resolve(data).then((dataParam) => {
|
|
2453
|
-
let dataArray = [];
|
|
2454
|
-
if (Array.isArray(dataParam.data)) {
|
|
2455
|
-
const remoteData = dataParam;
|
|
2456
|
-
dataArray = remoteData.data;
|
|
2457
|
-
if (remoteData.livePaginationCursor !== void 0) {
|
|
2458
|
-
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
2459
|
-
}
|
|
2460
|
-
} else {
|
|
2461
|
-
dataArray = dataParam;
|
|
2462
|
-
}
|
|
2463
|
-
actions.originalDataArray = dataArray;
|
|
2464
|
-
if (dataIsPromise) {
|
|
2465
|
-
actions.loading = false;
|
|
2466
|
-
}
|
|
2467
|
-
});
|
|
2468
|
-
}
|
|
2469
|
-
function useLoadData() {
|
|
2470
|
-
const {
|
|
2471
|
-
getComponentState,
|
|
2472
|
-
componentActions: actions,
|
|
2473
|
-
componentState: { data }
|
|
2474
|
-
} = useComponentState();
|
|
2475
|
-
useLayoutEffect3(() => {
|
|
2476
|
-
loadData(data, getComponentState(), actions);
|
|
2477
|
-
}, [data]);
|
|
2478
|
-
useLivePagination();
|
|
2479
|
-
}
|
|
2480
|
-
function useLivePagination() {
|
|
2481
|
-
const {
|
|
2482
|
-
getComponentState,
|
|
2483
|
-
componentActions: actions,
|
|
2484
|
-
componentState
|
|
2485
|
-
} = useComponentState();
|
|
2486
|
-
const {
|
|
2487
|
-
notifyScrollbarsChange,
|
|
2488
|
-
sortInfo,
|
|
2489
|
-
groupBy,
|
|
2490
|
-
pivotBy,
|
|
2491
|
-
livePaginationCursor,
|
|
2492
|
-
scrollBottomId
|
|
2493
|
-
} = componentState;
|
|
2494
|
-
const [scrollbars, setScrollbars] = useState4({
|
|
2495
|
-
vertical: false,
|
|
2496
|
-
horizontal: false
|
|
2497
|
-
});
|
|
2498
|
-
const scrollbarsRef = useRef6(scrollbars);
|
|
2499
|
-
useEffect8(() => {
|
|
2500
|
-
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
2501
|
-
if (!scrollbars2) {
|
|
2502
|
-
return;
|
|
2503
|
-
}
|
|
2504
|
-
scrollbarsRef.current = scrollbars2;
|
|
2505
|
-
setScrollbars(scrollbars2);
|
|
2506
|
-
});
|
|
2507
|
-
return () => notifyScrollbarsChange.destroy();
|
|
2508
|
-
}, [notifyScrollbarsChange]);
|
|
2509
|
-
const [cursorId, updateCursorId] = useState4(void 0);
|
|
2510
|
-
useEffect8(() => {
|
|
2511
|
-
const frameId = requestAnimationFrame(() => {
|
|
2512
|
-
var _a;
|
|
2513
|
-
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical)) {
|
|
2514
|
-
updateCursorId(livePaginationCursor);
|
|
2515
|
-
}
|
|
2516
|
-
});
|
|
2517
|
-
return () => cancelAnimationFrame(frameId);
|
|
2518
|
-
}, [livePaginationCursor]);
|
|
2519
|
-
useEffect8(() => {
|
|
2520
|
-
const { livePaginationCursor: livePaginationCursor2, livePagination } = getComponentState();
|
|
2521
|
-
if (!scrollbars.vertical && livePagination) {
|
|
2522
|
-
updateCursorId(livePaginationCursor2);
|
|
2523
|
-
}
|
|
2524
|
-
}, [scrollbars.vertical]);
|
|
2525
|
-
useEffect8(() => {
|
|
2526
|
-
updateCursorId(scrollBottomId);
|
|
2527
|
-
}, [scrollBottomId]);
|
|
2528
|
-
const depsObject = {
|
|
2529
|
-
sortInfo,
|
|
2530
|
-
groupBy,
|
|
2531
|
-
pivotBy,
|
|
2532
|
-
livePaginationCursor: cursorId
|
|
2533
|
-
};
|
|
2534
|
-
useEffectWithChanges((changes, prevValues) => {
|
|
2535
|
-
if (cursorId === void 0) {
|
|
2536
|
-
return;
|
|
2537
|
-
}
|
|
2538
|
-
debug3("onDataParamsChange triggered because the following values have changed", changes, "old values", prevValues);
|
|
2539
|
-
notifyDataParamsChanged(getComponentState(), actions, anonimizeValues(changes));
|
|
2540
|
-
}, depsObject);
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
2544
|
-
var EMPTY_ARRAY = Object.freeze([]);
|
|
2545
|
-
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
2546
|
-
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
2547
|
-
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
2548
|
-
if (weakMap && weakMap.has(sortInfo)) {
|
|
2549
|
-
const prevResult = weakMap.get(sortInfo);
|
|
2550
|
-
if (prevResult && prevResult.length === result.length) {
|
|
2551
|
-
return prevResult;
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
if (weakMap && sortInfo) {
|
|
2555
|
-
weakMap.set(sortInfo, result);
|
|
2556
|
-
}
|
|
2557
|
-
return result;
|
|
2558
|
-
};
|
|
2396
|
+
import { useEffect as useEffect8, useMemo as useMemo4, useRef as useRef6, useState as useState4 } from "react";
|
|
2559
2397
|
|
|
2560
|
-
// src/
|
|
2561
|
-
import { useMemo as useMemo4 } from "react";
|
|
2398
|
+
// src/utils/DeepMap/once.ts
|
|
2562
2399
|
function once(fn) {
|
|
2563
2400
|
let called = false;
|
|
2564
2401
|
let result = null;
|
|
@@ -2572,14 +2409,8 @@ function once(fn) {
|
|
|
2572
2409
|
};
|
|
2573
2410
|
return onceFn;
|
|
2574
2411
|
}
|
|
2575
|
-
function useOnce(fn) {
|
|
2576
|
-
const onceFn = useMemo4(() => {
|
|
2577
|
-
return once(fn);
|
|
2578
|
-
}, []);
|
|
2579
|
-
return onceFn();
|
|
2580
|
-
}
|
|
2581
2412
|
|
|
2582
|
-
// src/utils/DeepMap.ts
|
|
2413
|
+
// src/utils/DeepMap/index.ts
|
|
2583
2414
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2584
2415
|
var DeepMap = class {
|
|
2585
2416
|
constructor(initial) {
|
|
@@ -2831,75 +2662,781 @@ var DeepMap = class {
|
|
|
2831
2662
|
}
|
|
2832
2663
|
};
|
|
2833
2664
|
|
|
2834
|
-
// src/
|
|
2835
|
-
var
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
return {
|
|
2842
|
-
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
2843
|
-
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
destroy() {
|
|
2847
|
-
var _a, _b;
|
|
2848
|
-
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
2849
|
-
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
2850
|
-
delete this.expandedMap;
|
|
2851
|
-
delete this.collapsedMap;
|
|
2665
|
+
// src/utils/groupAndPivot/index.ts
|
|
2666
|
+
var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
|
|
2667
|
+
function DEFAULT_TO_KEY(value) {
|
|
2668
|
+
return value;
|
|
2669
|
+
}
|
|
2670
|
+
function initReducers(reducers) {
|
|
2671
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2672
|
+
return {};
|
|
2852
2673
|
}
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
this.collapsedAll = collapsedRows === true;
|
|
2858
|
-
this.expandedAll = expandedRows === true;
|
|
2859
|
-
if (this.collapsedAll && this.expandedAll) {
|
|
2860
|
-
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
2861
|
-
}
|
|
2862
|
-
if (collapsedRows !== true) {
|
|
2863
|
-
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
2864
|
-
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
2865
|
-
}
|
|
2866
|
-
if (expandedRows !== true) {
|
|
2867
|
-
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
2868
|
-
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
2674
|
+
const result = {};
|
|
2675
|
+
for (let key in reducers)
|
|
2676
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2677
|
+
result[key] = reducers[key].initialValue;
|
|
2869
2678
|
}
|
|
2679
|
+
return result;
|
|
2680
|
+
}
|
|
2681
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
2682
|
+
var _a, _b;
|
|
2683
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2684
|
+
return;
|
|
2870
2685
|
}
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
}
|
|
2877
|
-
collapseAll() {
|
|
2878
|
-
this.update({
|
|
2879
|
-
collapsedRows: true,
|
|
2880
|
-
expandedRows: []
|
|
2881
|
-
});
|
|
2882
|
-
}
|
|
2883
|
-
expandAll() {
|
|
2884
|
-
this.update({
|
|
2885
|
-
expandedRows: true,
|
|
2886
|
-
collapsedRows: []
|
|
2887
|
-
});
|
|
2888
|
-
}
|
|
2889
|
-
isGroupRowExpanded(keys) {
|
|
2890
|
-
var _a, _b;
|
|
2891
|
-
if (this.expandedAll === true) {
|
|
2892
|
-
if (this.collapsedAll === true) {
|
|
2893
|
-
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
2686
|
+
for (let key in reducers)
|
|
2687
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2688
|
+
const reducer = reducers[key];
|
|
2689
|
+
if (typeof reducer.reducer !== "function") {
|
|
2690
|
+
continue;
|
|
2894
2691
|
}
|
|
2895
|
-
|
|
2692
|
+
const currentValue = reducerResults[key];
|
|
2693
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
2694
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
2896
2695
|
}
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2696
|
+
}
|
|
2697
|
+
function lazyGroup(groupParams, rootData) {
|
|
2698
|
+
const {
|
|
2699
|
+
reducers = {},
|
|
2700
|
+
pivot,
|
|
2701
|
+
groupBy,
|
|
2702
|
+
mappings
|
|
2703
|
+
} = groupParams;
|
|
2704
|
+
const deepMap = new DeepMap();
|
|
2705
|
+
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
2706
|
+
const last = pivotIndex === pivot2.length - 1;
|
|
2707
|
+
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
2708
|
+
for (var k in values)
|
|
2709
|
+
if (values.hasOwnProperty(k)) {
|
|
2710
|
+
const pivotKey = k;
|
|
2711
|
+
currentPivotKeys2.push(pivotKey);
|
|
2712
|
+
topLevelPivotColumns.set(currentPivotKeys2, true);
|
|
2713
|
+
pivotDeepMap.set(currentPivotKeys2, {
|
|
2714
|
+
reducerResults: values[k][(mappings == null ? void 0 : mappings.totals) || "totals"] || {},
|
|
2715
|
+
items: []
|
|
2716
|
+
});
|
|
2717
|
+
if (!last) {
|
|
2718
|
+
traverseValues(pivotDeepMap, values[k], pivot2, pivotIndex + 1, currentPivotKeys2);
|
|
2719
|
+
}
|
|
2720
|
+
currentPivotKeys2.pop();
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2724
|
+
let currentPivotKeys = [];
|
|
2725
|
+
const initialReducerValue = initReducers(reducers);
|
|
2726
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2727
|
+
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2728
|
+
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2729
|
+
const dataArray = lazyGroupRowInfo.items;
|
|
2730
|
+
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2731
|
+
if (!dataArray[i]) {
|
|
2732
|
+
const deepMapGroupValue2 = {
|
|
2733
|
+
items: [],
|
|
2734
|
+
reducerResults: {}
|
|
2735
|
+
};
|
|
2736
|
+
deepMap.set([...currentGroupKeys, `not-loaded-yet-${i}`], deepMapGroupValue2);
|
|
2737
|
+
continue;
|
|
2738
|
+
}
|
|
2739
|
+
const dataObject = dataArray[i].data;
|
|
2740
|
+
const dataKeys = dataArray[i].keys;
|
|
2741
|
+
let item = dataObject;
|
|
2742
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
2743
|
+
const key = item[groupByProperty];
|
|
2744
|
+
currentGroupKeys.push(key);
|
|
2745
|
+
const deepMapGroupValue = {
|
|
2746
|
+
items: [],
|
|
2747
|
+
reducerResults: dataArray[i].aggregations || {}
|
|
2748
|
+
};
|
|
2749
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2750
|
+
if (pivot) {
|
|
2751
|
+
const pivotDeepMap = deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2752
|
+
const pivotContainer = dataArray[i].pivot;
|
|
2753
|
+
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
2754
|
+
}
|
|
2755
|
+
currentGroupKeys.pop();
|
|
2756
|
+
}
|
|
2757
|
+
next == null ? void 0 : next();
|
|
2758
|
+
});
|
|
2759
|
+
const result = {
|
|
2760
|
+
deepMap,
|
|
2761
|
+
groupParams,
|
|
2762
|
+
initialData: rootData,
|
|
2763
|
+
reducerResults: globalReducerResults
|
|
2764
|
+
};
|
|
2765
|
+
if (pivot) {
|
|
2766
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2767
|
+
result.pivot = pivot;
|
|
2768
|
+
}
|
|
2769
|
+
return result;
|
|
2770
|
+
}
|
|
2771
|
+
function group(groupParams, data) {
|
|
2772
|
+
const {
|
|
2773
|
+
groupBy,
|
|
2774
|
+
defaultToKey = DEFAULT_TO_KEY,
|
|
2775
|
+
pivot,
|
|
2776
|
+
reducers
|
|
2777
|
+
} = groupParams;
|
|
2778
|
+
const groupByLength = groupBy.length;
|
|
2779
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2780
|
+
const deepMap = new DeepMap();
|
|
2781
|
+
let currentGroupKeys = [];
|
|
2782
|
+
let currentPivotKeys = [];
|
|
2783
|
+
const initialReducerValue = initReducers(reducers);
|
|
2784
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2785
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
2786
|
+
let item = data[i];
|
|
2787
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
2788
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
2789
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
2790
|
+
currentGroupKeys.push(key);
|
|
2791
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
2792
|
+
const deepMapGroupValue = {
|
|
2793
|
+
items: [],
|
|
2794
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
2795
|
+
};
|
|
2796
|
+
if (pivot) {
|
|
2797
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2798
|
+
}
|
|
2799
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2800
|
+
}
|
|
2801
|
+
const {
|
|
2802
|
+
items: currentGroupItems,
|
|
2803
|
+
reducerResults,
|
|
2804
|
+
pivotDeepMap
|
|
2805
|
+
} = deepMap.get(currentGroupKeys);
|
|
2806
|
+
currentGroupItems.push(item);
|
|
2807
|
+
if (reducers) {
|
|
2808
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
2809
|
+
}
|
|
2810
|
+
if (pivot) {
|
|
2811
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
2812
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
2813
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
2814
|
+
currentPivotKeys.push(pivotKey);
|
|
2815
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
2816
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
2817
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
2818
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
2819
|
+
items: []
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
const {
|
|
2823
|
+
reducerResults: pivotReducerResults,
|
|
2824
|
+
items: pivotGroupItems
|
|
2825
|
+
} = pivotDeepMap.get(currentPivotKeys);
|
|
2826
|
+
pivotGroupItems.push(item);
|
|
2827
|
+
if (reducers) {
|
|
2828
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
currentPivotKeys.length = 0;
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
if (reducers) {
|
|
2835
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
2836
|
+
}
|
|
2837
|
+
currentGroupKeys.length = 0;
|
|
2838
|
+
}
|
|
2839
|
+
if (reducers) {
|
|
2840
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
2841
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
2842
|
+
if (pivot) {
|
|
2843
|
+
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
2844
|
+
completeReducers(reducers, pivotReducerResults, items);
|
|
2845
|
+
next2 == null ? void 0 : next2();
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
next == null ? void 0 : next();
|
|
2849
|
+
});
|
|
2850
|
+
}
|
|
2851
|
+
if (reducers) {
|
|
2852
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
2853
|
+
}
|
|
2854
|
+
const result = {
|
|
2855
|
+
deepMap,
|
|
2856
|
+
groupParams,
|
|
2857
|
+
initialData: data,
|
|
2858
|
+
reducerResults: globalReducerResults
|
|
2859
|
+
};
|
|
2860
|
+
if (pivot) {
|
|
2861
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2862
|
+
result.pivot = pivot;
|
|
2863
|
+
}
|
|
2864
|
+
return result;
|
|
2865
|
+
}
|
|
2866
|
+
function flatten(groupResult) {
|
|
2867
|
+
const { groupParams, deepMap } = groupResult;
|
|
2868
|
+
const groupByLength = groupParams.groupBy.length;
|
|
2869
|
+
const result = [];
|
|
2870
|
+
deepMap.topDownKeys().reduce((acc, key) => {
|
|
2871
|
+
if (key.length === groupByLength) {
|
|
2872
|
+
const items = deepMap.get(key).items;
|
|
2873
|
+
acc.push(...items);
|
|
2874
|
+
}
|
|
2875
|
+
return acc;
|
|
2876
|
+
}, result);
|
|
2877
|
+
return result;
|
|
2878
|
+
}
|
|
2879
|
+
function getEnhancedGroupData(options, deepMapValue) {
|
|
2880
|
+
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2881
|
+
const groupNesting = groupKeys.length;
|
|
2882
|
+
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
2883
|
+
let data = null;
|
|
2884
|
+
if (Object.keys(reducerResults).length > 0) {
|
|
2885
|
+
data = {};
|
|
2886
|
+
for (let key in reducers)
|
|
2887
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2888
|
+
const reducer = reducers[key];
|
|
2889
|
+
const field = reducer.field;
|
|
2890
|
+
if (field) {
|
|
2891
|
+
data[field] = reducerResults[key];
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
const enhancedGroupData = {
|
|
2896
|
+
data,
|
|
2897
|
+
groupCount: groupItems.length,
|
|
2898
|
+
groupData: groupItems,
|
|
2899
|
+
groupKeys,
|
|
2900
|
+
id: groupKeys,
|
|
2901
|
+
collapsed,
|
|
2902
|
+
parents,
|
|
2903
|
+
collapsedChildrenCount: 0,
|
|
2904
|
+
collapsedGroupsCount: 0,
|
|
2905
|
+
indexInParentGroups: options.indexInParentGroups,
|
|
2906
|
+
indexInGroup: options.indexInGroup,
|
|
2907
|
+
indexInAll: options.indexInAll,
|
|
2908
|
+
value: groupKeys[groupKeys.length - 1],
|
|
2909
|
+
rootGroupBy: groupBy,
|
|
2910
|
+
groupBy: groupNesting === groupBy.length ? groupBy : groupBy.slice(0, groupNesting),
|
|
2911
|
+
isGroupRow: true,
|
|
2912
|
+
pivotValuesMap: pivotDeepMap,
|
|
2913
|
+
groupNesting,
|
|
2914
|
+
reducerResults
|
|
2915
|
+
};
|
|
2916
|
+
return enhancedGroupData;
|
|
2917
|
+
}
|
|
2918
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
2919
|
+
if (reducers) {
|
|
2920
|
+
for (let key in reducers)
|
|
2921
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2922
|
+
const reducer = reducers[key];
|
|
2923
|
+
if (reducer.done) {
|
|
2924
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
return reducerResults;
|
|
2929
|
+
}
|
|
2930
|
+
function enhancedFlatten(param) {
|
|
2931
|
+
const {
|
|
2932
|
+
groupResult,
|
|
2933
|
+
toPrimaryKey,
|
|
2934
|
+
groupRowsState,
|
|
2935
|
+
generateGroupRows,
|
|
2936
|
+
reducers = {}
|
|
2937
|
+
} = param;
|
|
2938
|
+
const { groupParams, deepMap, pivot } = groupResult;
|
|
2939
|
+
const { groupBy } = groupParams;
|
|
2940
|
+
const groupByStrings = groupBy.map((g) => g.field);
|
|
2941
|
+
const result = [];
|
|
2942
|
+
const parents = [];
|
|
2943
|
+
const indexInParentGroups = [];
|
|
2944
|
+
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
2945
|
+
var _a;
|
|
2946
|
+
const items = deepMapValue.items;
|
|
2947
|
+
const groupNesting = groupKeys.length;
|
|
2948
|
+
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
2949
|
+
const enhancedGroupData = getEnhancedGroupData({
|
|
2950
|
+
groupBy: groupByStrings,
|
|
2951
|
+
parents: Array.from(parents),
|
|
2952
|
+
reducers,
|
|
2953
|
+
indexInGroup,
|
|
2954
|
+
indexInParentGroups: Array.from(indexInParentGroups),
|
|
2955
|
+
indexInAll: result.length,
|
|
2956
|
+
groupKeys,
|
|
2957
|
+
collapsed
|
|
2958
|
+
}, deepMapValue);
|
|
2959
|
+
const include = generateGroupRows || collapsed;
|
|
2960
|
+
if (include) {
|
|
2961
|
+
result.push(enhancedGroupData);
|
|
2962
|
+
}
|
|
2963
|
+
if (collapsed) {
|
|
2964
|
+
parents.forEach((parent) => {
|
|
2965
|
+
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
2966
|
+
parent.collapsedGroupsCount += 1;
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
indexInParentGroups.push(indexInGroup);
|
|
2970
|
+
parents.push(enhancedGroupData);
|
|
2971
|
+
if (!collapsed) {
|
|
2972
|
+
if (!next) {
|
|
2973
|
+
if (!pivot) {
|
|
2974
|
+
const startIndex = result.length;
|
|
2975
|
+
result.push(...items.map((item, index) => {
|
|
2976
|
+
return {
|
|
2977
|
+
id: toPrimaryKey(item),
|
|
2978
|
+
data: item,
|
|
2979
|
+
isGroupRow: false,
|
|
2980
|
+
collapsed: false,
|
|
2981
|
+
groupKeys,
|
|
2982
|
+
parents: Array.from(parents),
|
|
2983
|
+
indexInParentGroups: [...indexInParentGroups, index],
|
|
2984
|
+
indexInGroup: index,
|
|
2985
|
+
indexInAll: startIndex + index,
|
|
2986
|
+
groupBy: groupByStrings,
|
|
2987
|
+
groupNesting,
|
|
2988
|
+
groupCount: enhancedGroupData.groupCount
|
|
2989
|
+
};
|
|
2990
|
+
}));
|
|
2991
|
+
}
|
|
2992
|
+
} else {
|
|
2993
|
+
next();
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
parents.pop();
|
|
2997
|
+
indexInParentGroups.pop();
|
|
2998
|
+
});
|
|
2999
|
+
return {
|
|
3000
|
+
data: result
|
|
3001
|
+
};
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
// src/components/hooks/useEffectWithChanges.ts
|
|
3005
|
+
import { useEffect as useEffect7, useRef as useRef5 } from "react";
|
|
3006
|
+
function useEffectWithChanges(fn, deps) {
|
|
3007
|
+
const prevRef = useRef5({});
|
|
3008
|
+
const oldValuesRef = useRef5({});
|
|
3009
|
+
const oldValues = oldValuesRef.current;
|
|
3010
|
+
const changesRef = useRef5({});
|
|
3011
|
+
const changes = changesRef.current;
|
|
3012
|
+
const useEffectDeps = [];
|
|
3013
|
+
for (let k in deps) {
|
|
3014
|
+
if (deps.hasOwnProperty(k)) {
|
|
3015
|
+
if (deps[k] !== prevRef.current[k]) {
|
|
3016
|
+
changes[k] = deps[k];
|
|
3017
|
+
oldValues[k] = prevRef.current[k];
|
|
3018
|
+
}
|
|
3019
|
+
useEffectDeps.push(deps[k]);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
prevRef.current = deps;
|
|
3023
|
+
useEffect7(() => {
|
|
3024
|
+
const changes2 = changesRef.current;
|
|
3025
|
+
const result = fn(changes2, oldValues);
|
|
3026
|
+
changesRef.current = {};
|
|
3027
|
+
oldValuesRef.current = {};
|
|
3028
|
+
return result;
|
|
3029
|
+
}, useEffectDeps);
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
// src/components/utils/debounce.ts
|
|
3033
|
+
function debounce(fn, { wait }) {
|
|
3034
|
+
let timeout = null;
|
|
3035
|
+
return function(...args) {
|
|
3036
|
+
const context = this;
|
|
3037
|
+
if (timeout !== null) {
|
|
3038
|
+
clearTimeout(timeout);
|
|
3039
|
+
}
|
|
3040
|
+
timeout = setTimeout(() => {
|
|
3041
|
+
fn.apply(context, args);
|
|
3042
|
+
}, wait);
|
|
3043
|
+
};
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
3047
|
+
var getRafPromise = () => new Promise((resolve) => {
|
|
3048
|
+
requestAnimationFrame(resolve);
|
|
3049
|
+
});
|
|
3050
|
+
var SKIP_DATA_CHANGES_KEYS = {
|
|
3051
|
+
originalDataArray: true,
|
|
3052
|
+
changes: true
|
|
3053
|
+
};
|
|
3054
|
+
function getChangeDetect() {
|
|
3055
|
+
var _a;
|
|
3056
|
+
const perfNow = (_a = getGlobal().performance) == null ? void 0 : _a.now();
|
|
3057
|
+
return `${Date.now()}:${perfNow}`;
|
|
3058
|
+
}
|
|
3059
|
+
function buildDataSourceDataParams(componentState, overrides) {
|
|
3060
|
+
var _a, _b;
|
|
3061
|
+
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
3062
|
+
const dataSourceParams = {
|
|
3063
|
+
originalDataArray: componentState.originalDataArray,
|
|
3064
|
+
sortInfo,
|
|
3065
|
+
groupBy: componentState.groupBy,
|
|
3066
|
+
pivotBy: componentState.pivotBy,
|
|
3067
|
+
aggregationReducers: componentState.aggregationReducers
|
|
3068
|
+
};
|
|
3069
|
+
if (componentState.livePagination !== void 0) {
|
|
3070
|
+
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3071
|
+
dataSourceParams.cursorId = componentState.cursorId;
|
|
3072
|
+
}
|
|
3073
|
+
if (componentState.fullLazyLoad) {
|
|
3074
|
+
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3075
|
+
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3076
|
+
dataSourceParams.lazyLoadStartIndex = 0;
|
|
3077
|
+
}
|
|
3078
|
+
dataSourceParams.groupKeys = [];
|
|
3079
|
+
}
|
|
3080
|
+
if (overrides) {
|
|
3081
|
+
Object.assign(dataSourceParams, overrides);
|
|
3082
|
+
}
|
|
3083
|
+
const changes = {};
|
|
3084
|
+
const oldDataSourceParams = componentState.dataParams || {};
|
|
3085
|
+
for (let k in dataSourceParams) {
|
|
3086
|
+
if (dataSourceParams.hasOwnProperty(k) && !SKIP_DATA_CHANGES_KEYS[k]) {
|
|
3087
|
+
const key = k;
|
|
3088
|
+
if (dataSourceParams[key] !== oldDataSourceParams[key]) {
|
|
3089
|
+
changes[key] = true;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
dataSourceParams.changes = changes;
|
|
3094
|
+
return dataSourceParams;
|
|
3095
|
+
}
|
|
3096
|
+
function loadData(data, componentState, actions, overrides) {
|
|
3097
|
+
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3098
|
+
if (typeof data === "function") {
|
|
3099
|
+
data = data(dataParams);
|
|
3100
|
+
}
|
|
3101
|
+
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3102
|
+
if (dataIsPromise && !componentState.fullLazyLoad) {
|
|
3103
|
+
actions.loading = true;
|
|
3104
|
+
}
|
|
3105
|
+
return Promise.resolve(data).then((dataParam) => {
|
|
3106
|
+
var _a, _b, _c;
|
|
3107
|
+
let dataArray = [];
|
|
3108
|
+
let skipAssign = false;
|
|
3109
|
+
if (Array.isArray(dataParam.data)) {
|
|
3110
|
+
const remoteData = dataParam;
|
|
3111
|
+
dataArray = remoteData.data;
|
|
3112
|
+
if (remoteData.livePaginationCursor !== void 0) {
|
|
3113
|
+
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
3114
|
+
}
|
|
3115
|
+
if (remoteData.mappings) {
|
|
3116
|
+
actions.pivotMappings = remoteData.mappings;
|
|
3117
|
+
}
|
|
3118
|
+
if (componentState.fullLazyLoad && dataParams.groupKeys) {
|
|
3119
|
+
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3120
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3121
|
+
const newGroupRowInfo = {
|
|
3122
|
+
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
3123
|
+
items: dataArray
|
|
3124
|
+
};
|
|
3125
|
+
if (dataParams.lazyLoadBatchSize) {
|
|
3126
|
+
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3127
|
+
const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
|
|
3128
|
+
items: [],
|
|
3129
|
+
totalCount: newGroupRowInfo.totalCount
|
|
3130
|
+
};
|
|
3131
|
+
currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
|
|
3132
|
+
const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
|
|
3133
|
+
const end = Math.min((_c = remoteData.totalCount) != null ? _c : start + dataParams.lazyLoadBatchSize);
|
|
3134
|
+
for (let i = start; i < end; i++) {
|
|
3135
|
+
currentGroupRowInfo.items[i] = newGroupRowInfo.items[i - start];
|
|
3136
|
+
}
|
|
3137
|
+
if (!existingGroupRowInfo) {
|
|
3138
|
+
lazyGroupData.set(key, currentGroupRowInfo);
|
|
3139
|
+
}
|
|
3140
|
+
} else {
|
|
3141
|
+
lazyGroupData.set(key, newGroupRowInfo);
|
|
3142
|
+
}
|
|
3143
|
+
skipAssign = true;
|
|
3144
|
+
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3145
|
+
}
|
|
3146
|
+
} else {
|
|
3147
|
+
dataArray = dataParam;
|
|
3148
|
+
}
|
|
3149
|
+
if (!skipAssign) {
|
|
3150
|
+
actions.originalDataArray = dataArray;
|
|
3151
|
+
}
|
|
3152
|
+
if (dataIsPromise && !componentState.fullLazyLoad) {
|
|
3153
|
+
actions.loading = false;
|
|
3154
|
+
}
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
function useLoadData() {
|
|
3158
|
+
const {
|
|
3159
|
+
getComponentState,
|
|
3160
|
+
componentActions: actions,
|
|
3161
|
+
componentState
|
|
3162
|
+
} = useComponentState();
|
|
3163
|
+
const {
|
|
3164
|
+
data,
|
|
3165
|
+
notifyScrollbarsChange,
|
|
3166
|
+
sortInfo,
|
|
3167
|
+
groupBy,
|
|
3168
|
+
pivotBy,
|
|
3169
|
+
livePagination,
|
|
3170
|
+
livePaginationCursor,
|
|
3171
|
+
cursorId: stateCursorId
|
|
3172
|
+
} = componentState;
|
|
3173
|
+
const [scrollbars, setScrollbars] = useState4({
|
|
3174
|
+
vertical: false,
|
|
3175
|
+
horizontal: false
|
|
3176
|
+
});
|
|
3177
|
+
const scrollbarsRef = useRef6(scrollbars);
|
|
3178
|
+
useEffect8(() => {
|
|
3179
|
+
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
3180
|
+
if (!scrollbars2) {
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
scrollbarsRef.current = scrollbars2;
|
|
3184
|
+
setScrollbars(scrollbars2);
|
|
3185
|
+
});
|
|
3186
|
+
return () => notifyScrollbarsChange.destroy();
|
|
3187
|
+
}, [notifyScrollbarsChange]);
|
|
3188
|
+
useEffect8(() => {
|
|
3189
|
+
const frameId = requestAnimationFrame(() => {
|
|
3190
|
+
var _a;
|
|
3191
|
+
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical) && livePaginationCursor) {
|
|
3192
|
+
actions.cursorId = livePaginationCursor;
|
|
3193
|
+
}
|
|
3194
|
+
});
|
|
3195
|
+
return () => cancelAnimationFrame(frameId);
|
|
3196
|
+
}, [livePaginationCursor]);
|
|
3197
|
+
useEffect8(() => {
|
|
3198
|
+
const { livePaginationCursor: livePaginationCursor2, livePagination: livePagination2 } = getComponentState();
|
|
3199
|
+
if (!scrollbars.vertical && livePagination2) {
|
|
3200
|
+
if (livePaginationCursor2) {
|
|
3201
|
+
actions.cursorId = livePaginationCursor2;
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
}, [scrollbars.vertical]);
|
|
3205
|
+
const depsObject = {
|
|
3206
|
+
sortInfo,
|
|
3207
|
+
groupBy,
|
|
3208
|
+
pivotBy,
|
|
3209
|
+
cursorId: livePagination ? stateCursorId : null
|
|
3210
|
+
};
|
|
3211
|
+
const initialRef = useRef6(true);
|
|
3212
|
+
useLazyLoadRange();
|
|
3213
|
+
useEffectWithChanges(() => {
|
|
3214
|
+
const componentState2 = getComponentState();
|
|
3215
|
+
if (typeof componentState2.data !== "function") {
|
|
3216
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3217
|
+
}
|
|
3218
|
+
}, { data });
|
|
3219
|
+
useEffectWithChanges(() => {
|
|
3220
|
+
const componentState2 = getComponentState();
|
|
3221
|
+
if (typeof componentState2.data === "function") {
|
|
3222
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3223
|
+
}
|
|
3224
|
+
}, __spreadProps(__spreadValues({}, depsObject), { data }));
|
|
3225
|
+
useEffectWithChanges((_changes, _prevValues) => {
|
|
3226
|
+
const componentState2 = getComponentState();
|
|
3227
|
+
if (initialRef.current) {
|
|
3228
|
+
initialRef.current = false;
|
|
3229
|
+
actions.dataParams = buildDataSourceDataParams(componentState2);
|
|
3230
|
+
}
|
|
3231
|
+
}, depsObject);
|
|
3232
|
+
}
|
|
3233
|
+
function useLazyLoadRange() {
|
|
3234
|
+
const {
|
|
3235
|
+
getComponentState,
|
|
3236
|
+
componentActions: actions,
|
|
3237
|
+
componentState
|
|
3238
|
+
} = useComponentState();
|
|
3239
|
+
const loadingCache = useMemo4(() => {
|
|
3240
|
+
return new Map();
|
|
3241
|
+
}, [componentState.data]);
|
|
3242
|
+
globalThis.loadingCache = loadingCache;
|
|
3243
|
+
const {
|
|
3244
|
+
lazyLoadBatchSize,
|
|
3245
|
+
notifyRenderRangeChange,
|
|
3246
|
+
dataArray,
|
|
3247
|
+
scrollStopDelayUpdatedByTable
|
|
3248
|
+
} = componentState;
|
|
3249
|
+
const latestRenderRangeRef = useRef6(null);
|
|
3250
|
+
const loadRange = (param, cache = loadingCache) => {
|
|
3251
|
+
const componentState2 = getComponentState();
|
|
3252
|
+
param = param || latestRenderRangeRef.current;
|
|
3253
|
+
if (!param) {
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
3256
|
+
const { renderStartIndex: startIndex, renderEndIndex: endIndex } = param;
|
|
3257
|
+
if (!lazyLoadBatchSize || lazyLoadBatchSize <= 0) {
|
|
3258
|
+
return;
|
|
3259
|
+
}
|
|
3260
|
+
lazyLoadRange({
|
|
3261
|
+
startIndex,
|
|
3262
|
+
endIndex,
|
|
3263
|
+
lazyLoadBatchSize,
|
|
3264
|
+
componentState: componentState2,
|
|
3265
|
+
componentActions: actions
|
|
3266
|
+
}, cache);
|
|
3267
|
+
};
|
|
3268
|
+
const debouncedLoadRange = useMemo4(() => debounce(loadRange, { wait: scrollStopDelayUpdatedByTable }), [scrollStopDelayUpdatedByTable]);
|
|
3269
|
+
useEffect8(() => {
|
|
3270
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3271
|
+
return notifyRenderRangeChange.onChange((param) => {
|
|
3272
|
+
latestRenderRangeRef.current = param;
|
|
3273
|
+
loadRange(param, loadingCache);
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
return;
|
|
3277
|
+
}, [lazyLoadBatchSize, loadingCache]);
|
|
3278
|
+
useEffect8(() => {
|
|
3279
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3280
|
+
debouncedLoadRange();
|
|
3281
|
+
}
|
|
3282
|
+
return;
|
|
3283
|
+
}, [dataArray]);
|
|
3284
|
+
}
|
|
3285
|
+
function lazyLoadRange(options, cache) {
|
|
3286
|
+
const {
|
|
3287
|
+
startIndex,
|
|
3288
|
+
endIndex,
|
|
3289
|
+
lazyLoadBatchSize,
|
|
3290
|
+
componentState,
|
|
3291
|
+
componentActions
|
|
3292
|
+
} = options;
|
|
3293
|
+
const { dataArray } = componentState;
|
|
3294
|
+
const isRowLoaded = (index) => dataArray[index].data != null;
|
|
3295
|
+
const perGroupFnCalls = new DeepMap();
|
|
3296
|
+
const rootGroupKeys = ["_______xxx______"];
|
|
3297
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
3298
|
+
const rowInfo = dataArray[i];
|
|
3299
|
+
if (!rowInfo) {
|
|
3300
|
+
continue;
|
|
3301
|
+
}
|
|
3302
|
+
const rowLoaded = rowInfo.data != null;
|
|
3303
|
+
const parentGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
|
|
3304
|
+
if (rowInfo.groupKeys) {
|
|
3305
|
+
parentGroupKeys.pop();
|
|
3306
|
+
}
|
|
3307
|
+
const cacheKeys = parentGroupKeys.length ? parentGroupKeys : rootGroupKeys;
|
|
3308
|
+
const indexInGroup = rowInfo.indexInGroup;
|
|
3309
|
+
if (!rowLoaded) {
|
|
3310
|
+
let fnCalls = perGroupFnCalls.get(cacheKeys);
|
|
3311
|
+
const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3312
|
+
const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
|
|
3313
|
+
const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
|
|
3314
|
+
const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
|
|
3315
|
+
const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
|
|
3316
|
+
if (batchStartRowLoaded || (fnCalls == null ? void 0 : fnCalls[batchStartRowId])) {
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
const shouldSetFnCalls = !fnCalls;
|
|
3320
|
+
fnCalls = fnCalls || {};
|
|
3321
|
+
const currentFnCall = {
|
|
3322
|
+
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3323
|
+
lazyLoadBatchSize,
|
|
3324
|
+
groupKeys: parentGroupKeys
|
|
3325
|
+
};
|
|
3326
|
+
if (!fnCalls[batchStartRowId]) {
|
|
3327
|
+
fnCalls[batchStartRowId] = currentFnCall;
|
|
3328
|
+
}
|
|
3329
|
+
if (shouldSetFnCalls) {
|
|
3330
|
+
perGroupFnCalls.set(cacheKeys, fnCalls);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
let initialPromise = Promise.resolve(true);
|
|
3335
|
+
const allFnCalls = [];
|
|
3336
|
+
perGroupFnCalls.topDownValues().forEach((record) => {
|
|
3337
|
+
allFnCalls.push(...Object.values(record));
|
|
3338
|
+
});
|
|
3339
|
+
allFnCalls.reduce((promise, fnCall) => {
|
|
3340
|
+
const cacheKey = `${fnCall.groupKeys.join("-")}:${fnCall.lazyLoadStartIndex}`;
|
|
3341
|
+
if (cache && cache.has(cacheKey)) {
|
|
3342
|
+
return promise;
|
|
3343
|
+
}
|
|
3344
|
+
cache == null ? void 0 : cache.set(cacheKey, true);
|
|
3345
|
+
const args = [componentState.data, componentState, componentActions, fnCall];
|
|
3346
|
+
return promise.then(() => getRafPromise()).then(() => loadData(...args)).then(() => {
|
|
3347
|
+
requestAnimationFrame(() => {
|
|
3348
|
+
cache == null ? void 0 : cache.delete(cacheKey);
|
|
3349
|
+
});
|
|
3350
|
+
});
|
|
3351
|
+
}, initialPromise);
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
3355
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
3356
|
+
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
3357
|
+
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
3358
|
+
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
3359
|
+
if (weakMap && weakMap.has(sortInfo)) {
|
|
3360
|
+
const prevResult = weakMap.get(sortInfo);
|
|
3361
|
+
if (prevResult && prevResult.length === result.length) {
|
|
3362
|
+
return prevResult;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
if (weakMap && sortInfo) {
|
|
3366
|
+
weakMap.set(sortInfo, result);
|
|
3367
|
+
}
|
|
3368
|
+
return result;
|
|
3369
|
+
};
|
|
3370
|
+
|
|
3371
|
+
// src/components/DataSource/GroupRowsState.ts
|
|
3372
|
+
var GroupRowsState = class {
|
|
3373
|
+
constructor(state) {
|
|
3374
|
+
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
3375
|
+
}
|
|
3376
|
+
getState() {
|
|
3377
|
+
var _a, _b, _c, _d;
|
|
3378
|
+
return {
|
|
3379
|
+
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
3380
|
+
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
3381
|
+
};
|
|
3382
|
+
}
|
|
3383
|
+
destroy() {
|
|
3384
|
+
var _a, _b;
|
|
3385
|
+
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
3386
|
+
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
3387
|
+
delete this.expandedMap;
|
|
3388
|
+
delete this.collapsedMap;
|
|
3389
|
+
}
|
|
3390
|
+
update(state) {
|
|
3391
|
+
var _a, _b, _c, _d;
|
|
3392
|
+
this.initialState = state;
|
|
3393
|
+
const { collapsedRows, expandedRows } = this.initialState;
|
|
3394
|
+
this.collapsedAll = collapsedRows === true;
|
|
3395
|
+
this.expandedAll = expandedRows === true;
|
|
3396
|
+
if (this.collapsedAll && this.expandedAll) {
|
|
3397
|
+
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
3398
|
+
}
|
|
3399
|
+
if (collapsedRows !== true) {
|
|
3400
|
+
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
3401
|
+
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
3402
|
+
}
|
|
3403
|
+
if (expandedRows !== true) {
|
|
3404
|
+
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
3405
|
+
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
areAllCollapsed() {
|
|
3409
|
+
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
3410
|
+
}
|
|
3411
|
+
areAllExpanded() {
|
|
3412
|
+
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
3413
|
+
}
|
|
3414
|
+
collapseAll() {
|
|
3415
|
+
this.update({
|
|
3416
|
+
collapsedRows: true,
|
|
3417
|
+
expandedRows: []
|
|
3418
|
+
});
|
|
3419
|
+
}
|
|
3420
|
+
expandAll() {
|
|
3421
|
+
this.update({
|
|
3422
|
+
expandedRows: true,
|
|
3423
|
+
collapsedRows: []
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
isGroupRowExpanded(keys) {
|
|
3427
|
+
var _a, _b;
|
|
3428
|
+
if (this.expandedAll === true) {
|
|
3429
|
+
if (this.collapsedAll === true) {
|
|
3430
|
+
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
3431
|
+
}
|
|
3432
|
+
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
3433
|
+
}
|
|
3434
|
+
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
3435
|
+
}
|
|
3436
|
+
isGroupRowCollapsed(keys) {
|
|
3437
|
+
return !this.isGroupRowExpanded(keys);
|
|
3438
|
+
}
|
|
3439
|
+
setGroupRowExpanded(keys, shouldExpand) {
|
|
2903
3440
|
var _a;
|
|
2904
3441
|
if (shouldExpand === this.isGroupRowExpanded(keys)) {
|
|
2905
3442
|
return;
|
|
@@ -2942,7 +3479,7 @@ var GroupRowsState = class {
|
|
|
2942
3479
|
};
|
|
2943
3480
|
|
|
2944
3481
|
// src/utils/shallowEqualObjects.ts
|
|
2945
|
-
function shallowEqualObjects(objA, objB) {
|
|
3482
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
2946
3483
|
if (objA === objB) {
|
|
2947
3484
|
return true;
|
|
2948
3485
|
}
|
|
@@ -2951,12 +3488,21 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2951
3488
|
}
|
|
2952
3489
|
var aKeys = Object.keys(objA);
|
|
2953
3490
|
var bKeys = Object.keys(objB);
|
|
3491
|
+
if (ignoreKeys) {
|
|
3492
|
+
aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3493
|
+
bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3494
|
+
}
|
|
2954
3495
|
var len = aKeys.length;
|
|
2955
3496
|
if (bKeys.length !== len) {
|
|
2956
3497
|
return false;
|
|
2957
3498
|
}
|
|
2958
3499
|
for (var i = 0; i < len; i++) {
|
|
2959
3500
|
var key = aKeys[i];
|
|
3501
|
+
if (ignoreKeys) {
|
|
3502
|
+
if (ignoreKeys.has(key)) {
|
|
3503
|
+
continue;
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
2960
3506
|
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2961
3507
|
return false;
|
|
2962
3508
|
}
|
|
@@ -2967,12 +3513,12 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2967
3513
|
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2968
3514
|
var map = new WeakMap();
|
|
2969
3515
|
var getCompareDefault = (a) => a;
|
|
2970
|
-
function discardCallsWithEqualArg(fn, timeframe = 50,
|
|
3516
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
2971
3517
|
map.set(fn, {
|
|
2972
3518
|
lastCallTime: 0,
|
|
2973
3519
|
lastCallArg: null
|
|
2974
3520
|
});
|
|
2975
|
-
const getCompare =
|
|
3521
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
2976
3522
|
return (arg) => {
|
|
2977
3523
|
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2978
3524
|
lastCallTime: 0,
|
|
@@ -2993,20 +3539,28 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
|
2993
3539
|
}
|
|
2994
3540
|
|
|
2995
3541
|
// src/components/DataSource/state/getInitialState.ts
|
|
3542
|
+
var defaultCursorId = Symbol("cursorId");
|
|
2996
3543
|
function initSetupState2() {
|
|
2997
3544
|
const now = Date.now();
|
|
2998
3545
|
const originalDataArray = [];
|
|
2999
3546
|
const dataArray = [];
|
|
3547
|
+
const originalLazyGroupData = new DeepMap();
|
|
3000
3548
|
return {
|
|
3001
3549
|
dataParams: void 0,
|
|
3002
3550
|
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3551
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
3552
|
+
notifyRenderRangeChange: buildSubscriptionCallback(),
|
|
3003
3553
|
pivotTotalColumnPosition: "end",
|
|
3554
|
+
scrollStopDelayUpdatedByTable: 100,
|
|
3555
|
+
originalLazyGroupData,
|
|
3556
|
+
originalLazyGroupDataChangeDetect: 0,
|
|
3004
3557
|
originalDataArray,
|
|
3005
|
-
|
|
3558
|
+
cursorId: defaultCursorId,
|
|
3006
3559
|
showSeparatePivotColumnForSingleAggregation: false,
|
|
3007
3560
|
propsCache: new Map([
|
|
3008
3561
|
["sortInfo", new WeakMap()]
|
|
3009
3562
|
]),
|
|
3563
|
+
pivotMappings: void 0,
|
|
3010
3564
|
pivotColumns: void 0,
|
|
3011
3565
|
pivotColumnGroups: void 0,
|
|
3012
3566
|
dataArray,
|
|
@@ -3014,329 +3568,146 @@ function initSetupState2() {
|
|
|
3014
3568
|
groupedAt: 0,
|
|
3015
3569
|
sortedAt: 0,
|
|
3016
3570
|
reducedAt: now,
|
|
3017
|
-
generateGroupRows: true,
|
|
3018
|
-
groupDeepMap: void 0,
|
|
3019
|
-
postSortDataArray: void 0,
|
|
3020
|
-
postGroupDataArray: void 0,
|
|
3021
|
-
lastSortDataArray: void 0,
|
|
3022
|
-
lastGroupDataArray: void 0
|
|
3023
|
-
};
|
|
3024
|
-
}
|
|
3025
|
-
function
|
|
3026
|
-
const obj = __spreadValues({}, dataParams);
|
|
3027
|
-
delete obj.originalDataArray;
|
|
3028
|
-
return obj;
|
|
3029
|
-
}
|
|
3030
|
-
var forwardProps3 = (setupState) => {
|
|
3031
|
-
return {
|
|
3032
|
-
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100,
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
};
|
|
3049
|
-
function mapPropsToState2(params) {
|
|
3050
|
-
const { props, state } = params;
|
|
3051
|
-
const controlledSort = isControlledValue(props.sortInfo);
|
|
3052
|
-
const result = {
|
|
3053
|
-
controlledSort,
|
|
3054
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3055
|
-
};
|
|
3056
|
-
if (props.livePagination) {
|
|
3057
|
-
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? props.livePaginationCursor({
|
|
3058
|
-
array: state.originalDataArray,
|
|
3059
|
-
length: state.originalDataArray.length,
|
|
3060
|
-
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3061
|
-
}) : props.livePaginationCursor;
|
|
3062
|
-
result.livePaginationCursor = livePaginationCursor;
|
|
3063
|
-
}
|
|
3064
|
-
return result;
|
|
3065
|
-
}
|
|
3066
|
-
function getInterceptActions() {
|
|
3067
|
-
return {
|
|
3068
|
-
sortInfo: (sortInfo, { actions, state }) => {
|
|
3069
|
-
const dataParams = buildDataSourceDataParams(state);
|
|
3070
|
-
dataParams.sortInfo = sortInfo;
|
|
3071
|
-
actions.dataParams = dataParams;
|
|
3072
|
-
}
|
|
3073
|
-
};
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
// src/utils/groupAndPivot/index.ts
|
|
3077
|
-
function DEFAULT_TO_KEY(value) {
|
|
3078
|
-
return value;
|
|
3079
|
-
}
|
|
3080
|
-
function initReducers(reducers) {
|
|
3081
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3082
|
-
return {};
|
|
3083
|
-
}
|
|
3084
|
-
const result = {};
|
|
3085
|
-
for (let key in reducers)
|
|
3086
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3087
|
-
result[key] = reducers[key].initialValue;
|
|
3088
|
-
}
|
|
3089
|
-
return result;
|
|
3090
|
-
}
|
|
3091
|
-
function computeReducersFor(data, reducers, reducerResults) {
|
|
3092
|
-
var _a, _b;
|
|
3093
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3094
|
-
return;
|
|
3095
|
-
}
|
|
3096
|
-
for (let key in reducers)
|
|
3097
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3098
|
-
const reducer = reducers[key];
|
|
3099
|
-
const currentValue = reducerResults[key];
|
|
3100
|
-
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
3101
|
-
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
function group(groupParams, data) {
|
|
3105
|
-
const {
|
|
3106
|
-
groupBy,
|
|
3107
|
-
defaultToKey = DEFAULT_TO_KEY,
|
|
3108
|
-
pivot,
|
|
3109
|
-
reducers
|
|
3110
|
-
} = groupParams;
|
|
3111
|
-
const groupByLength = groupBy.length;
|
|
3112
|
-
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3113
|
-
const deepMap = new DeepMap();
|
|
3114
|
-
let currentGroupKeys = [];
|
|
3115
|
-
let currentPivotKeys = [];
|
|
3116
|
-
const initialReducerValue = initReducers(reducers);
|
|
3117
|
-
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3118
|
-
for (let i = 0, len = data.length; i < len; i++) {
|
|
3119
|
-
let item = data[i];
|
|
3120
|
-
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
3121
|
-
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
3122
|
-
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
3123
|
-
currentGroupKeys.push(key);
|
|
3124
|
-
if (!deepMap.has(currentGroupKeys)) {
|
|
3125
|
-
const deepMapGroupValue = {
|
|
3126
|
-
items: [],
|
|
3127
|
-
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3128
|
-
};
|
|
3129
|
-
if (pivot) {
|
|
3130
|
-
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3131
|
-
}
|
|
3132
|
-
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3133
|
-
}
|
|
3134
|
-
const {
|
|
3135
|
-
items: currentGroupItems,
|
|
3136
|
-
reducerResults,
|
|
3137
|
-
pivotDeepMap
|
|
3138
|
-
} = deepMap.get(currentGroupKeys);
|
|
3139
|
-
currentGroupItems.push(item);
|
|
3140
|
-
if (reducers) {
|
|
3141
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3142
|
-
}
|
|
3143
|
-
if (pivot) {
|
|
3144
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3145
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3146
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3147
|
-
currentPivotKeys.push(pivotKey);
|
|
3148
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3149
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3150
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3151
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3152
|
-
items: []
|
|
3153
|
-
});
|
|
3154
|
-
}
|
|
3155
|
-
const {
|
|
3156
|
-
reducerResults: pivotReducerResults,
|
|
3157
|
-
items: pivotGroupItems
|
|
3158
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3159
|
-
pivotGroupItems.push(item);
|
|
3160
|
-
if (reducers) {
|
|
3161
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
currentPivotKeys.length = 0;
|
|
3165
|
-
}
|
|
3166
|
-
}
|
|
3167
|
-
if (reducers) {
|
|
3168
|
-
computeReducersFor(item, reducers, globalReducerResults);
|
|
3571
|
+
generateGroupRows: true,
|
|
3572
|
+
groupDeepMap: void 0,
|
|
3573
|
+
postSortDataArray: void 0,
|
|
3574
|
+
postGroupDataArray: void 0,
|
|
3575
|
+
lastSortDataArray: void 0,
|
|
3576
|
+
lastGroupDataArray: void 0
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
3580
|
+
const obj = __spreadValues({}, dataParams);
|
|
3581
|
+
delete obj.originalDataArray;
|
|
3582
|
+
return obj;
|
|
3583
|
+
}
|
|
3584
|
+
var forwardProps3 = (setupState) => {
|
|
3585
|
+
return {
|
|
3586
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3587
|
+
fullLazyLoad: 1,
|
|
3588
|
+
data: 1,
|
|
3589
|
+
pivotBy: 1,
|
|
3590
|
+
primaryKey: 1,
|
|
3591
|
+
livePagination: 1,
|
|
3592
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3593
|
+
aggregationReducers: 1,
|
|
3594
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3595
|
+
loading: (loading) => loading != null ? loading : false,
|
|
3596
|
+
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
3597
|
+
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
3598
|
+
groupRowsState: (groupRowsState) => {
|
|
3599
|
+
return groupRowsState || new GroupRowsState({
|
|
3600
|
+
expandedRows: true,
|
|
3601
|
+
collapsedRows: []
|
|
3602
|
+
});
|
|
3169
3603
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
}
|
|
3184
|
-
if (reducers) {
|
|
3185
|
-
completeReducers(reducers, globalReducerResults, data);
|
|
3186
|
-
}
|
|
3604
|
+
};
|
|
3605
|
+
};
|
|
3606
|
+
function getLivePaginationCursorValue(livePaginationCursorProp, state) {
|
|
3607
|
+
const livePaginationCursor = typeof livePaginationCursorProp === "function" ? livePaginationCursorProp({
|
|
3608
|
+
array: state.originalDataArray,
|
|
3609
|
+
length: state.originalDataArray.length,
|
|
3610
|
+
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3611
|
+
}) : livePaginationCursorProp;
|
|
3612
|
+
return livePaginationCursor;
|
|
3613
|
+
}
|
|
3614
|
+
function mapPropsToState2(params) {
|
|
3615
|
+
const { props, state, oldState } = params;
|
|
3616
|
+
const controlledSort = isControlledValue(props.sortInfo);
|
|
3187
3617
|
const result = {
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
initialData: data,
|
|
3191
|
-
reducerResults: globalReducerResults
|
|
3618
|
+
controlledSort,
|
|
3619
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3192
3620
|
};
|
|
3193
|
-
if (
|
|
3194
|
-
|
|
3195
|
-
|
|
3621
|
+
if (props.livePagination) {
|
|
3622
|
+
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
3623
|
+
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? dataArrayChanged ? getLivePaginationCursorValue(props.livePaginationCursor, state) : state.livePaginationCursor : props.livePaginationCursor;
|
|
3624
|
+
result.livePaginationCursor = livePaginationCursor;
|
|
3196
3625
|
}
|
|
3197
3626
|
return result;
|
|
3198
3627
|
}
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3628
|
+
var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
3629
|
+
function onPropChange(params, props, actions) {
|
|
3630
|
+
const { name, newValue } = params;
|
|
3631
|
+
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3632
|
+
if (props.fullLazyLoad) {
|
|
3633
|
+
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3634
|
+
}
|
|
3635
|
+
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
3636
|
+
actions.groupRowsState = new GroupRowsState({
|
|
3637
|
+
collapsedRows: true,
|
|
3638
|
+
expandedRows: []
|
|
3639
|
+
});
|
|
3207
3640
|
}
|
|
3208
|
-
return acc;
|
|
3209
|
-
}, result);
|
|
3210
|
-
return result;
|
|
3211
|
-
}
|
|
3212
|
-
function getEnhancedGroupData(options, deepMapValue) {
|
|
3213
|
-
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
3214
|
-
const groupNesting = groupKeys.length;
|
|
3215
|
-
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
3216
|
-
let data = null;
|
|
3217
|
-
if (Object.keys(reducerResults).length > 0) {
|
|
3218
|
-
data = {};
|
|
3219
|
-
for (let key in reducers)
|
|
3220
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3221
|
-
const reducer = reducers[key];
|
|
3222
|
-
const field = reducer.field;
|
|
3223
|
-
if (field) {
|
|
3224
|
-
data[field] = reducerResults[key];
|
|
3225
|
-
}
|
|
3226
|
-
}
|
|
3227
3641
|
}
|
|
3228
|
-
const enhancedGroupData = {
|
|
3229
|
-
data,
|
|
3230
|
-
groupCount: groupItems.length,
|
|
3231
|
-
groupData: groupItems,
|
|
3232
|
-
groupKeys,
|
|
3233
|
-
id: groupKeys,
|
|
3234
|
-
collapsed,
|
|
3235
|
-
parents,
|
|
3236
|
-
collapsedChildrenCount: 0,
|
|
3237
|
-
collapsedGroupsCount: 0,
|
|
3238
|
-
indexInParentGroups: options.indexInParentGroups,
|
|
3239
|
-
indexInGroup: options.indexInGroup,
|
|
3240
|
-
indexInAll: options.indexInAll,
|
|
3241
|
-
value: groupKeys[groupKeys.length - 1],
|
|
3242
|
-
groupBy: groupBy.slice(0, groupNesting),
|
|
3243
|
-
isGroupRow: true,
|
|
3244
|
-
pivotValuesMap: pivotDeepMap,
|
|
3245
|
-
groupNesting,
|
|
3246
|
-
reducerResults
|
|
3247
|
-
};
|
|
3248
|
-
return enhancedGroupData;
|
|
3249
3642
|
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3643
|
+
var debugDataParams = dbg("DataSource:dataParams");
|
|
3644
|
+
function getInterceptActions() {
|
|
3645
|
+
return {
|
|
3646
|
+
sortInfo: (sortInfo, { actions, state }) => {
|
|
3647
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3648
|
+
sortInfo,
|
|
3649
|
+
livePaginationCursor: null
|
|
3650
|
+
});
|
|
3651
|
+
actions.dataParams = dataParams;
|
|
3652
|
+
if (state.livePagination) {
|
|
3653
|
+
requestAnimationFrame(() => {
|
|
3654
|
+
actions.livePaginationCursor = null;
|
|
3655
|
+
});
|
|
3258
3656
|
}
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
groupResult,
|
|
3265
|
-
toPrimaryKey,
|
|
3266
|
-
groupRowsState,
|
|
3267
|
-
generateGroupRows,
|
|
3268
|
-
reducers = {}
|
|
3269
|
-
} = param;
|
|
3270
|
-
const { groupParams, deepMap, pivot } = groupResult;
|
|
3271
|
-
const { groupBy } = groupParams;
|
|
3272
|
-
const groupByStrings = groupBy.map((g) => g.field);
|
|
3273
|
-
const result = [];
|
|
3274
|
-
const parents = [];
|
|
3275
|
-
const indexInParentGroups = [];
|
|
3276
|
-
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
3277
|
-
var _a;
|
|
3278
|
-
const items = deepMapValue.items;
|
|
3279
|
-
const groupNesting = groupKeys.length;
|
|
3280
|
-
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
3281
|
-
const enhancedGroupData = getEnhancedGroupData({
|
|
3282
|
-
groupBy: groupByStrings,
|
|
3283
|
-
parents: Array.from(parents),
|
|
3284
|
-
reducers,
|
|
3285
|
-
indexInGroup,
|
|
3286
|
-
indexInParentGroups: Array.from(indexInParentGroups),
|
|
3287
|
-
indexInAll: result.length,
|
|
3288
|
-
groupKeys,
|
|
3289
|
-
collapsed
|
|
3290
|
-
}, deepMapValue);
|
|
3291
|
-
const include = generateGroupRows || collapsed;
|
|
3292
|
-
if (include) {
|
|
3293
|
-
result.push(enhancedGroupData);
|
|
3294
|
-
}
|
|
3295
|
-
if (collapsed) {
|
|
3296
|
-
parents.forEach((parent) => {
|
|
3297
|
-
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
3298
|
-
parent.collapsedGroupsCount += 1;
|
|
3657
|
+
},
|
|
3658
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3659
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3660
|
+
groupBy,
|
|
3661
|
+
livePaginationCursor: null
|
|
3299
3662
|
});
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
if (!pivot) {
|
|
3306
|
-
const startIndex = result.length;
|
|
3307
|
-
result.push(...items.map((item, index) => {
|
|
3308
|
-
return {
|
|
3309
|
-
id: toPrimaryKey(item),
|
|
3310
|
-
data: item,
|
|
3311
|
-
isGroupRow: false,
|
|
3312
|
-
collapsed: false,
|
|
3313
|
-
groupKeys,
|
|
3314
|
-
parents: Array.from(parents),
|
|
3315
|
-
indexInParentGroups: [...indexInParentGroups, index],
|
|
3316
|
-
indexInGroup: index,
|
|
3317
|
-
indexInAll: startIndex + index,
|
|
3318
|
-
groupBy: groupByStrings,
|
|
3319
|
-
groupNesting,
|
|
3320
|
-
groupCount: enhancedGroupData.groupCount
|
|
3321
|
-
};
|
|
3322
|
-
}));
|
|
3323
|
-
}
|
|
3324
|
-
} else {
|
|
3325
|
-
next();
|
|
3663
|
+
actions.dataParams = dataParams;
|
|
3664
|
+
if (state.livePagination) {
|
|
3665
|
+
requestAnimationFrame(() => {
|
|
3666
|
+
actions.livePaginationCursor = null;
|
|
3667
|
+
});
|
|
3326
3668
|
}
|
|
3669
|
+
},
|
|
3670
|
+
pivotBy: (pivotBy, { actions, state }) => {
|
|
3671
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3672
|
+
pivotBy,
|
|
3673
|
+
livePaginationCursor: null
|
|
3674
|
+
});
|
|
3675
|
+
actions.dataParams = dataParams;
|
|
3676
|
+
if (state.livePagination) {
|
|
3677
|
+
requestAnimationFrame(() => {
|
|
3678
|
+
actions.livePaginationCursor = null;
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
},
|
|
3682
|
+
cursorId: (cursorId, { actions, state }) => {
|
|
3683
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3684
|
+
cursorId
|
|
3685
|
+
});
|
|
3686
|
+
actions.dataParams = dataParams;
|
|
3687
|
+
},
|
|
3688
|
+
livePaginationCursor: (livePaginationCursor, { actions, state }) => {
|
|
3689
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3690
|
+
livePaginationCursor
|
|
3691
|
+
});
|
|
3692
|
+
actions.dataParams = dataParams;
|
|
3693
|
+
},
|
|
3694
|
+
dataParams: (dataParams, { state }) => {
|
|
3695
|
+
if (shallowEqualObjects(dataParams, state.dataParams, new Set([
|
|
3696
|
+
"changes",
|
|
3697
|
+
"originalDataArray"
|
|
3698
|
+
]))) {
|
|
3699
|
+
return false;
|
|
3700
|
+
}
|
|
3701
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3702
|
+
return true;
|
|
3327
3703
|
}
|
|
3328
|
-
parents.pop();
|
|
3329
|
-
indexInParentGroups.pop();
|
|
3330
|
-
});
|
|
3331
|
-
return {
|
|
3332
|
-
data: result
|
|
3333
3704
|
};
|
|
3334
3705
|
}
|
|
3335
3706
|
|
|
3336
3707
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3337
3708
|
function prepareColumn(column) {
|
|
3338
3709
|
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3339
|
-
if (pivotByForColumn.column) {
|
|
3710
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3340
3711
|
if (typeof pivotByForColumn.column === "function") {
|
|
3341
3712
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3342
3713
|
} else {
|
|
@@ -3347,7 +3718,7 @@ function prepareColumn(column) {
|
|
|
3347
3718
|
}
|
|
3348
3719
|
function prepareColumnGroup(columnGroup) {
|
|
3349
3720
|
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3350
|
-
if (pivotByForColumnGroup.columnGroup) {
|
|
3721
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3351
3722
|
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3352
3723
|
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3353
3724
|
} else {
|
|
@@ -3376,6 +3747,9 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3376
3747
|
valueGetter: (params) => {
|
|
3377
3748
|
var _a;
|
|
3378
3749
|
const { rowInfo } = params;
|
|
3750
|
+
if (!rowInfo.data) {
|
|
3751
|
+
return "Loading ...";
|
|
3752
|
+
}
|
|
3379
3753
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3380
3754
|
}
|
|
3381
3755
|
}
|
|
@@ -3407,7 +3781,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3407
3781
|
}));
|
|
3408
3782
|
}
|
|
3409
3783
|
aggregationReducers.forEach((reducer, index) => {
|
|
3410
|
-
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.id;
|
|
3784
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3411
3785
|
const computedPivotColumn = prepareColumn({
|
|
3412
3786
|
pivotBy,
|
|
3413
3787
|
pivotColumn: true,
|
|
@@ -3426,7 +3800,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3426
3800
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3427
3801
|
}
|
|
3428
3802
|
});
|
|
3429
|
-
const columnId = `${keys.join("/")}
|
|
3803
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3430
3804
|
columns.set(columnId, computedPivotColumn);
|
|
3431
3805
|
});
|
|
3432
3806
|
} else {
|
|
@@ -3459,7 +3833,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3459
3833
|
}));
|
|
3460
3834
|
}
|
|
3461
3835
|
aggregationReducers.forEach((reducer, index) => {
|
|
3462
|
-
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.id} total`;
|
|
3836
|
+
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.name || reducer.id} total`;
|
|
3463
3837
|
const computedPivotColumn = prepareColumn({
|
|
3464
3838
|
columnGroup: columnGroupId,
|
|
3465
3839
|
header,
|
|
@@ -3478,7 +3852,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3478
3852
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3479
3853
|
}
|
|
3480
3854
|
});
|
|
3481
|
-
columns.set(`total:${keys.join("/")}
|
|
3855
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3482
3856
|
});
|
|
3483
3857
|
}
|
|
3484
3858
|
}
|
|
@@ -3487,15 +3861,22 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3487
3861
|
}
|
|
3488
3862
|
});
|
|
3489
3863
|
if (columns.size === 1) {
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3864
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3865
|
+
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
3866
|
+
header: `${reducer.name || reducer.id} total`,
|
|
3867
|
+
pivotBy,
|
|
3868
|
+
pivotColumn: true,
|
|
3869
|
+
pivotTotalColumn: true,
|
|
3870
|
+
pivotAggregator: reducer,
|
|
3871
|
+
pivotAggregatorIndex: index,
|
|
3872
|
+
pivotGroupKeys: [],
|
|
3873
|
+
pivotGroupKey: "",
|
|
3874
|
+
pivotIndex: -1,
|
|
3875
|
+
valueGetter: ({ rowInfo }) => {
|
|
3876
|
+
var _a;
|
|
3877
|
+
return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
|
|
3878
|
+
}
|
|
3879
|
+
}));
|
|
3499
3880
|
});
|
|
3500
3881
|
}
|
|
3501
3882
|
const result = {
|
|
@@ -3532,10 +3913,11 @@ function concludeReducer(params) {
|
|
|
3532
3913
|
const { state, previousState } = params;
|
|
3533
3914
|
const sortInfo = state.sortInfo;
|
|
3534
3915
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3535
|
-
const
|
|
3536
|
-
"originalDataArray"
|
|
3537
|
-
"sortInfo"
|
|
3916
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3917
|
+
"originalDataArray"
|
|
3538
3918
|
]);
|
|
3919
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3920
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3539
3921
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3540
3922
|
const groupBy = state.groupBy;
|
|
3541
3923
|
const pivotBy = state.pivotBy;
|
|
@@ -3543,6 +3925,8 @@ function concludeReducer(params) {
|
|
|
3543
3925
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3544
3926
|
"generateGroupRows",
|
|
3545
3927
|
"originalDataArray",
|
|
3928
|
+
"originalLazyGroupData",
|
|
3929
|
+
"originalLazyGroupDataChangeDetect",
|
|
3546
3930
|
"groupBy",
|
|
3547
3931
|
"groupRowsState",
|
|
3548
3932
|
"pivotBy",
|
|
@@ -3567,7 +3951,12 @@ function concludeReducer(params) {
|
|
|
3567
3951
|
};
|
|
3568
3952
|
if (shouldGroup) {
|
|
3569
3953
|
if (shouldGroupAgain) {
|
|
3570
|
-
const groupResult =
|
|
3954
|
+
const groupResult = state.fullLazyLoad ? lazyGroup({
|
|
3955
|
+
groupBy,
|
|
3956
|
+
pivot: pivotBy,
|
|
3957
|
+
mappings: state.pivotMappings,
|
|
3958
|
+
reducers: state.aggregationReducers
|
|
3959
|
+
}, state.originalLazyGroupData) : group({
|
|
3571
3960
|
groupBy,
|
|
3572
3961
|
pivot: pivotBy,
|
|
3573
3962
|
reducers: state.aggregationReducers
|
|
@@ -3635,6 +4024,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3635
4024
|
forwardProps: forwardProps3,
|
|
3636
4025
|
concludeReducer,
|
|
3637
4026
|
mapPropsToState: mapPropsToState2,
|
|
4027
|
+
onPropChange,
|
|
3638
4028
|
interceptActions: getInterceptActions()
|
|
3639
4029
|
});
|
|
3640
4030
|
function DataSourceCmp({ children }) {
|
|
@@ -3666,9 +4056,15 @@ function DataSource(props) {
|
|
|
3666
4056
|
function useToggleGroupRow() {
|
|
3667
4057
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3668
4058
|
const toggleGroupRow = useCallback4((groupKeys) => {
|
|
3669
|
-
const
|
|
4059
|
+
const state = getDataSourceState();
|
|
4060
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3670
4061
|
newState.toggleGroupRow(groupKeys);
|
|
3671
4062
|
dataSourceActions.groupRowsState = newState;
|
|
4063
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
4064
|
+
loadData(state.data, state, dataSourceActions, {
|
|
4065
|
+
groupKeys
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
3672
4068
|
}, []);
|
|
3673
4069
|
return toggleGroupRow;
|
|
3674
4070
|
}
|
|
@@ -3863,7 +4259,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3863
4259
|
const currentState = getComponentState();
|
|
3864
4260
|
const { computedColumns } = currentState;
|
|
3865
4261
|
let updated = false;
|
|
3866
|
-
const columnVisibility =
|
|
4262
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3867
4263
|
const cols = computedColumns;
|
|
3868
4264
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
3869
4265
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
@@ -3874,9 +4270,9 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3874
4270
|
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3875
4271
|
updated = true;
|
|
3876
4272
|
if (shouldBeHidden) {
|
|
3877
|
-
columnVisibility
|
|
4273
|
+
columnVisibility[colId] = false;
|
|
3878
4274
|
} else {
|
|
3879
|
-
columnVisibility
|
|
4275
|
+
delete columnVisibility[colId];
|
|
3880
4276
|
}
|
|
3881
4277
|
});
|
|
3882
4278
|
if (updated) {
|
|
@@ -3973,9 +4369,6 @@ function useComputed() {
|
|
|
3973
4369
|
var _a2;
|
|
3974
4370
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3975
4371
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3976
|
-
if (getDataSourceState().livePagination) {
|
|
3977
|
-
dataSourceActions.livePaginationCursor = null;
|
|
3978
|
-
}
|
|
3979
4372
|
}, [getDataSourceState]);
|
|
3980
4373
|
const columns = componentState.computedColumns;
|
|
3981
4374
|
const {
|
|
@@ -4601,10 +4994,10 @@ import {
|
|
|
4601
4994
|
createElement as createElement12,
|
|
4602
4995
|
memo as memo4
|
|
4603
4996
|
} from "react";
|
|
4604
|
-
import { useLayoutEffect as
|
|
4997
|
+
import { useLayoutEffect as useLayoutEffect3, useState as useState8 } from "react";
|
|
4605
4998
|
function AvoidReactDiffFn(props) {
|
|
4606
4999
|
const [children, setChildren] = useState8(props.updater.get());
|
|
4607
|
-
|
|
5000
|
+
useLayoutEffect3(() => {
|
|
4608
5001
|
const remove = props.updater.onChange((children2) => {
|
|
4609
5002
|
setChildren(children2);
|
|
4610
5003
|
});
|
|
@@ -4969,7 +5362,7 @@ function RawListFn(props) {
|
|
|
4969
5362
|
var RawList = memo5(RawListFn);
|
|
4970
5363
|
|
|
4971
5364
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4972
|
-
var
|
|
5365
|
+
var debug3 = dbg("Header");
|
|
4973
5366
|
var { rootClassName: rootClassName4 } = internalProps;
|
|
4974
5367
|
var TableHeaderClassName = `${rootClassName4}Header`;
|
|
4975
5368
|
function InfiniteTableHeaderFn(props) {
|
|
@@ -4983,7 +5376,7 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4983
5376
|
const column = columns[columnIndex];
|
|
4984
5377
|
if (!column) {
|
|
4985
5378
|
if (true) {
|
|
4986
|
-
|
|
5379
|
+
debug3("Cannot find column to render at ", columnIndex);
|
|
4987
5380
|
}
|
|
4988
5381
|
return null;
|
|
4989
5382
|
}
|
|
@@ -5322,6 +5715,9 @@ function TableHeaderWrapper(props) {
|
|
|
5322
5715
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5323
5716
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5324
5717
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5718
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5719
|
+
left: computedPinnedStartWidth
|
|
5720
|
+
} : void 0;
|
|
5325
5721
|
const header = virtualizeHeader ? /* @__PURE__ */ createElement19(InfiniteTableHeader, {
|
|
5326
5722
|
columns: computedUnpinnedColumns,
|
|
5327
5723
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5336,6 +5732,7 @@ function TableHeaderWrapper(props) {
|
|
|
5336
5732
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5337
5733
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5338
5734
|
}) : /* @__PURE__ */ createElement19(InfiniteTableHeaderUnvirtualized, {
|
|
5735
|
+
style: unvirtualizedStyle,
|
|
5339
5736
|
brain,
|
|
5340
5737
|
scrollable: true,
|
|
5341
5738
|
pinning: false,
|
|
@@ -5470,7 +5867,7 @@ function SpacePlaceholderFn(props) {
|
|
|
5470
5867
|
var SpacePlaceholder = memo8(SpacePlaceholderFn);
|
|
5471
5868
|
|
|
5472
5869
|
// src/components/InfiniteTable/hooks/useListRendering.tsx
|
|
5473
|
-
import { useCallback as useCallback17, useEffect as useEffect22, useMemo as
|
|
5870
|
+
import { useCallback as useCallback17, useEffect as useEffect22, useMemo as useMemo11, useRef as useRef17 } from "react";
|
|
5474
5871
|
|
|
5475
5872
|
// src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
|
|
5476
5873
|
import {
|
|
@@ -5500,7 +5897,7 @@ var scrollTransformTargetCls = "mlx2t3";
|
|
|
5500
5897
|
var UPDATE_SCROLL2 = (node, scrollPosition) => {
|
|
5501
5898
|
node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, ${-scrollPosition.scrollTop}px, 0px)`;
|
|
5502
5899
|
};
|
|
5503
|
-
var
|
|
5900
|
+
var debug4 = dbg("VirtuaList");
|
|
5504
5901
|
var rootClassName7 = "InfiniteList";
|
|
5505
5902
|
var VirtualList = (props) => {
|
|
5506
5903
|
const _a = props, {
|
|
@@ -5540,7 +5937,7 @@ var VirtualList = (props) => {
|
|
|
5540
5937
|
const removeOnRenderCount = virtualBrain.onRenderCountChange((renderCount) => {
|
|
5541
5938
|
renderCountRef.current = renderCount;
|
|
5542
5939
|
if (true) {
|
|
5543
|
-
|
|
5940
|
+
debug4.extend(mainAxis)(`Render count change ${renderCount}`);
|
|
5544
5941
|
}
|
|
5545
5942
|
rerender();
|
|
5546
5943
|
});
|
|
@@ -5644,6 +6041,9 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5644
6041
|
}
|
|
5645
6042
|
const { data, isGroupRow, groupBy } = rowInfo;
|
|
5646
6043
|
const groupRowInfo = null;
|
|
6044
|
+
if (rowInfo.indexInAll === 0 && column.groupByField && column.groupByField === "stack") {
|
|
6045
|
+
debugger;
|
|
6046
|
+
}
|
|
5647
6047
|
let value = isGroupRow && groupBy && column.groupByField ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
|
|
5648
6048
|
if (column.valueGetter) {
|
|
5649
6049
|
value = column.valueGetter(isGroupRow ? {
|
|
@@ -6042,7 +6442,6 @@ var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf",
|
|
|
6042
6442
|
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
6043
6443
|
|
|
6044
6444
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
6045
|
-
var DELAY = 200;
|
|
6046
6445
|
var TableClassName = internalProps.rootClassName;
|
|
6047
6446
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
6048
6447
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -6053,15 +6452,25 @@ var useOnContainerScroll = ({
|
|
|
6053
6452
|
}) => {
|
|
6054
6453
|
const {
|
|
6055
6454
|
componentState: {
|
|
6455
|
+
scrollStopDelay,
|
|
6056
6456
|
scrollerDOMRef,
|
|
6057
6457
|
domRef,
|
|
6058
6458
|
scrollToBottomOffset,
|
|
6059
6459
|
onScrollToBottom,
|
|
6060
6460
|
onScrollToTop,
|
|
6461
|
+
onScrollStop: onScrollStopFromProps,
|
|
6061
6462
|
bodySize
|
|
6062
6463
|
}
|
|
6063
6464
|
} = useInfiniteTable();
|
|
6064
|
-
const {
|
|
6465
|
+
const {
|
|
6466
|
+
componentActions: dataSourceActions,
|
|
6467
|
+
getState: getDataSourceState,
|
|
6468
|
+
componentState: { notifyScrollStop }
|
|
6469
|
+
} = useDataSourceContextValue();
|
|
6470
|
+
const onScrollStop = useCallback13((param) => {
|
|
6471
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6472
|
+
notifyScrollStop(param);
|
|
6473
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
6065
6474
|
const timeoutIdRef = useRef15(0);
|
|
6066
6475
|
const scrollingRef = useRef15(false);
|
|
6067
6476
|
const scrollTopMaxRef = useRef15(0);
|
|
@@ -6080,9 +6489,17 @@ var useOnContainerScroll = ({
|
|
|
6080
6489
|
timeoutIdRef.current = setTimeout(() => {
|
|
6081
6490
|
setScrolling(false);
|
|
6082
6491
|
timeoutIdRef.current = 0;
|
|
6083
|
-
},
|
|
6492
|
+
}, scrollStopDelay);
|
|
6084
6493
|
}
|
|
6085
6494
|
if (prevScrolling !== scrolling) {
|
|
6495
|
+
if (!scrolling) {
|
|
6496
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6497
|
+
onScrollStop({
|
|
6498
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6499
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6500
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6501
|
+
});
|
|
6502
|
+
}
|
|
6086
6503
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
6087
6504
|
if (!classList) {
|
|
6088
6505
|
return;
|
|
@@ -6093,7 +6510,7 @@ var useOnContainerScroll = ({
|
|
|
6093
6510
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
6094
6511
|
}
|
|
6095
6512
|
}
|
|
6096
|
-
}, []);
|
|
6513
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
6097
6514
|
const onContainerScroll = useCallback13((scrollInfo) => {
|
|
6098
6515
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6099
6516
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
@@ -6123,7 +6540,7 @@ var useOnContainerScroll = ({
|
|
|
6123
6540
|
if (isScrollBottom) {
|
|
6124
6541
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
6125
6542
|
if (getDataSourceState().livePagination) {
|
|
6126
|
-
dataSourceActions.
|
|
6543
|
+
dataSourceActions.cursorId = Date.now();
|
|
6127
6544
|
}
|
|
6128
6545
|
}
|
|
6129
6546
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -6415,6 +6832,15 @@ function usePinnedStartRendering(params) {
|
|
|
6415
6832
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6416
6833
|
import { useEffect as useEffect21 } from "react";
|
|
6417
6834
|
|
|
6835
|
+
// src/components/hooks/useOnce.ts
|
|
6836
|
+
import { useMemo as useMemo10 } from "react";
|
|
6837
|
+
function useOnce(fn) {
|
|
6838
|
+
const onceFn = useMemo10(() => {
|
|
6839
|
+
return once(fn);
|
|
6840
|
+
}, []);
|
|
6841
|
+
return onceFn();
|
|
6842
|
+
}
|
|
6843
|
+
|
|
6418
6844
|
// src/components/VirtualBrain/index.ts
|
|
6419
6845
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6420
6846
|
var initialScrollPosition2 = {
|
|
@@ -6949,7 +7375,7 @@ function useListRendering(param) {
|
|
|
6949
7375
|
repaintIdRef.current++;
|
|
6950
7376
|
}
|
|
6951
7377
|
const repaintId = repaintIdRef.current;
|
|
6952
|
-
const rowSpan =
|
|
7378
|
+
const rowSpan = useMemo11(() => {
|
|
6953
7379
|
const colsWithRowspan = computedVisibleColumns.filter((col) => typeof col.rowspan === "function");
|
|
6954
7380
|
return colsWithRowspan.length ? ({ itemIndex }) => {
|
|
6955
7381
|
let maxSpan = 1;
|
|
@@ -6987,7 +7413,7 @@ function useListRendering(param) {
|
|
|
6987
7413
|
const hasHorizontalScrollbar = computedUnpinnedColumnsWidth > bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth;
|
|
6988
7414
|
const reservedContentHeight = verticalVirtualBrain.getTotalSize() + (hasHorizontalScrollbar ? getScrollbarWidth() : 0);
|
|
6989
7415
|
const hasVerticalScrollbar = bodySize.height > 0 && bodySize.height < reservedContentHeight;
|
|
6990
|
-
const scrollbars =
|
|
7416
|
+
const scrollbars = useMemo11(() => ({
|
|
6991
7417
|
vertical: hasVerticalScrollbar,
|
|
6992
7418
|
horizontal: hasHorizontalScrollbar
|
|
6993
7419
|
}), [hasVerticalScrollbar, hasHorizontalScrollbar]);
|
|
@@ -7157,7 +7583,7 @@ var InfiniteTableLicenseFooter = forwardRef3(function InfiniteTableLicenseFooter
|
|
|
7157
7583
|
});
|
|
7158
7584
|
|
|
7159
7585
|
// src/components/InfiniteTable/hooks/useLicense/useLicense.ts
|
|
7160
|
-
import { useMemo as
|
|
7586
|
+
import { useMemo as useMemo12 } from "react";
|
|
7161
7587
|
|
|
7162
7588
|
// src/components/InfiniteTable/hooks/useLicense/crc32.ts
|
|
7163
7589
|
var DEFAULT_ReversedPolynomial = 3988292384;
|
|
@@ -7307,10 +7733,10 @@ var origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
|
7307
7733
|
var [_fullUrl, protocol, sandboxUrl] = Array.from(SANDBOX_REGEX.exec(origin) || []);
|
|
7308
7734
|
var isInsideSandbox = protocol === "https" && sandboxUrl === "sandpack.codesandbox.io";
|
|
7309
7735
|
var useLicense = (licenseKey = "") => {
|
|
7310
|
-
const valid =
|
|
7736
|
+
const valid = useMemo12(() => {
|
|
7311
7737
|
let valid2 = isValidLicense(licenseKey, {
|
|
7312
7738
|
publishedAt: 1624970570587,
|
|
7313
|
-
version: "0.1
|
|
7739
|
+
version: "0.2.1"
|
|
7314
7740
|
});
|
|
7315
7741
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7316
7742
|
return true;
|
|
@@ -7324,11 +7750,11 @@ var useLicense = (licenseKey = "") => {
|
|
|
7324
7750
|
import {
|
|
7325
7751
|
createElement as createElement31,
|
|
7326
7752
|
useCallback as useCallback19,
|
|
7327
|
-
useLayoutEffect as
|
|
7753
|
+
useLayoutEffect as useLayoutEffect4
|
|
7328
7754
|
} from "react";
|
|
7329
7755
|
import { useRef as useRef19 } from "react";
|
|
7330
7756
|
var error = err("CSSVariableWatch");
|
|
7331
|
-
var
|
|
7757
|
+
var debug5 = dbg("CSSVariableWatch");
|
|
7332
7758
|
var WRAPPER_STYLE = {
|
|
7333
7759
|
position: "absolute",
|
|
7334
7760
|
pointerEvents: "none",
|
|
@@ -7347,11 +7773,11 @@ var useCSSVariableWatch = (params) => {
|
|
|
7347
7773
|
}
|
|
7348
7774
|
}, [params.onChange]);
|
|
7349
7775
|
useResizeObserver(params.ref, onResize, { earlyAttach: true });
|
|
7350
|
-
|
|
7776
|
+
useLayoutEffect4(() => {
|
|
7351
7777
|
const value = params.ref.current.getBoundingClientRect().height;
|
|
7352
7778
|
if (value) {
|
|
7353
7779
|
lastValueRef.current = value;
|
|
7354
|
-
|
|
7780
|
+
debug5(`Variable ${params.varName} found and equals ${value}.`);
|
|
7355
7781
|
params.onChange(value);
|
|
7356
7782
|
} else {
|
|
7357
7783
|
error(`Specified variable ${params.varName} not found or does not have a numeric value.`);
|
|
@@ -7512,7 +7938,8 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7512
7938
|
} = useInfiniteTable();
|
|
7513
7939
|
const {
|
|
7514
7940
|
componentState: { dataArray, loading },
|
|
7515
|
-
getState: getDataSourceState
|
|
7941
|
+
getState: getDataSourceState,
|
|
7942
|
+
componentActions: dataSourceActions
|
|
7516
7943
|
} = useDataSourceContextValue();
|
|
7517
7944
|
const {
|
|
7518
7945
|
domRef,
|
|
@@ -7525,7 +7952,8 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7525
7952
|
onHeaderHeightCSSVarChange,
|
|
7526
7953
|
rowHeightCSSVar,
|
|
7527
7954
|
headerHeightCSSVar,
|
|
7528
|
-
components
|
|
7955
|
+
components,
|
|
7956
|
+
scrollStopDelay
|
|
7529
7957
|
} = componentState;
|
|
7530
7958
|
const { columnShifts, bodySize } = componentState;
|
|
7531
7959
|
const {
|
|
@@ -7538,6 +7966,7 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7538
7966
|
scrollbars,
|
|
7539
7967
|
applyScrollVertical,
|
|
7540
7968
|
horizontalVirtualBrain,
|
|
7969
|
+
verticalVirtualBrain,
|
|
7541
7970
|
reservedContentHeight
|
|
7542
7971
|
} = useListRendering({
|
|
7543
7972
|
getComputed,
|
|
@@ -7546,10 +7975,17 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7546
7975
|
bodySize,
|
|
7547
7976
|
computed
|
|
7548
7977
|
});
|
|
7978
|
+
useEffect24(() => {
|
|
7979
|
+
const dataSourceState = getDataSourceState();
|
|
7980
|
+
const onChange = debounce((renderRange) => {
|
|
7981
|
+
dataSourceState.notifyRenderRangeChange(renderRange);
|
|
7982
|
+
}, { wait: scrollStopDelay });
|
|
7983
|
+
return verticalVirtualBrain.onRenderRangeChange(onChange);
|
|
7984
|
+
}, [verticalVirtualBrain, scrollStopDelay]);
|
|
7549
7985
|
const licenseValid = useLicense(licenseKey);
|
|
7550
7986
|
const domProps = useDOMProps(componentState.domProps);
|
|
7551
7987
|
const LoadMaskCmp = (_a = components == null ? void 0 : components.LoadMask) != null ? _a : LoadMask;
|
|
7552
|
-
|
|
7988
|
+
useLayoutEffect5(() => {
|
|
7553
7989
|
const dataSourceState = getDataSourceState();
|
|
7554
7990
|
const { onScrollbarsChange } = getInfiniteTableState();
|
|
7555
7991
|
const { notifyScrollbarsChange } = dataSourceState;
|
|
@@ -7558,6 +7994,9 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7558
7994
|
}
|
|
7559
7995
|
notifyScrollbarsChange(scrollbars);
|
|
7560
7996
|
}, [scrollbars]);
|
|
7997
|
+
useEffect24(() => {
|
|
7998
|
+
dataSourceActions.scrollStopDelayUpdatedByTable = scrollStopDelay;
|
|
7999
|
+
}, [scrollStopDelay]);
|
|
7561
8000
|
return /* @__PURE__ */ createElement33("div", __spreadValues({
|
|
7562
8001
|
ref: domRef
|
|
7563
8002
|
}, domProps), header ? /* @__PURE__ */ createElement33(TableHeaderWrapper, {
|