@infinite-table/infinite-react 0.1.2 → 0.1.3
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 +167 -96
- package/index.esm.css +5 -4
- package/index.esm.js +985 -680
- package/index.js +1017 -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,9 @@ 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
|
+
console.log(columnVisibility, colId, result2);
|
|
1251
|
+
return result2;
|
|
1255
1252
|
});
|
|
1256
1253
|
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1257
1254
|
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
@@ -1280,7 +1277,10 @@ var getComputedVisibleColumns = ({
|
|
|
1280
1277
|
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1281
1278
|
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1282
1279
|
};
|
|
1283
|
-
let colSizing = columnSizing.get(colId) || {
|
|
1280
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1281
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1282
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1283
|
+
};
|
|
1284
1284
|
if (colSizing.width != null) {
|
|
1285
1285
|
delete colTypeSizing.flex;
|
|
1286
1286
|
}
|
|
@@ -1567,7 +1567,6 @@ var useComputedVisibleColumns = ({
|
|
|
1567
1567
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1568
1568
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1569
1569
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1570
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1571
1570
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1572
1571
|
const {
|
|
1573
1572
|
computedRemainingSpace,
|
|
@@ -1623,7 +1622,6 @@ var useComputedVisibleColumns = ({
|
|
|
1623
1622
|
pinnedStartMaxWidth,
|
|
1624
1623
|
columnPinning,
|
|
1625
1624
|
columnsRenderId,
|
|
1626
|
-
visibilityRenderId,
|
|
1627
1625
|
columnsSizingRenderId,
|
|
1628
1626
|
pinningRenderId,
|
|
1629
1627
|
columnTypesRenderId
|
|
@@ -1648,7 +1646,7 @@ var useComputedVisibleColumns = ({
|
|
|
1648
1646
|
return result;
|
|
1649
1647
|
};
|
|
1650
1648
|
|
|
1651
|
-
// src/utils/sortAscending.ts
|
|
1649
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1652
1650
|
var sortAscending = (a, b) => a - b;
|
|
1653
1651
|
|
|
1654
1652
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
@@ -1755,9 +1753,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1755
1753
|
if (currentValue === value) {
|
|
1756
1754
|
return;
|
|
1757
1755
|
}
|
|
1758
|
-
|
|
1756
|
+
let notifyTheChange = true;
|
|
1759
1757
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1760
|
-
interceptedActions[key](value, { actions, state: state2 })
|
|
1758
|
+
if (interceptedActions[key](value, { actions, state: state2 }) === false) {
|
|
1759
|
+
notifyTheChange = false;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
if (notifyTheChange) {
|
|
1763
|
+
notifyChange(props, stateKey, value);
|
|
1761
1764
|
}
|
|
1762
1765
|
const forwardFn = propsToForward[key];
|
|
1763
1766
|
if (typeof forwardFn === "function") {
|
|
@@ -1835,9 +1838,12 @@ function getComponentStateRoot(config) {
|
|
|
1835
1838
|
const getProps = useLatest(props);
|
|
1836
1839
|
const theReducer = (previousState, action) => {
|
|
1837
1840
|
var _a2;
|
|
1841
|
+
if (action.type === "REPLACE_STATE") {
|
|
1842
|
+
return action.payload;
|
|
1843
|
+
}
|
|
1838
1844
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1839
1845
|
const mappedState = action.payload.mappedState;
|
|
1840
|
-
const updatedProps = action.payload.
|
|
1846
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1841
1847
|
const newState = Object.assign({}, previousState);
|
|
1842
1848
|
if (mappedState) {
|
|
1843
1849
|
Object.assign(newState, mappedState);
|
|
@@ -1891,8 +1897,9 @@ function getComponentStateRoot(config) {
|
|
|
1891
1897
|
const currentProps = props;
|
|
1892
1898
|
const newMappedState = {};
|
|
1893
1899
|
let newMappedStateCount = 0;
|
|
1894
|
-
const
|
|
1895
|
-
let
|
|
1900
|
+
const updatedPropsToState = {};
|
|
1901
|
+
let updatedPropsToStateCount = 0;
|
|
1902
|
+
const rawUpdatedProps = {};
|
|
1896
1903
|
for (var k in props) {
|
|
1897
1904
|
const key = k;
|
|
1898
1905
|
const oldValue = prevProps[key];
|
|
@@ -1903,6 +1910,7 @@ function getComponentStateRoot(config) {
|
|
|
1903
1910
|
if (oldValue === newValue) {
|
|
1904
1911
|
continue;
|
|
1905
1912
|
}
|
|
1913
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1906
1914
|
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1907
1915
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1908
1916
|
let valueToSet = newValue;
|
|
@@ -1915,22 +1923,30 @@ function getComponentStateRoot(config) {
|
|
|
1915
1923
|
newMappedStateCount++;
|
|
1916
1924
|
}
|
|
1917
1925
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1918
|
-
|
|
1919
|
-
|
|
1926
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1927
|
+
updatedPropsToStateCount++;
|
|
1920
1928
|
}
|
|
1921
1929
|
}
|
|
1922
1930
|
}
|
|
1923
|
-
if (
|
|
1931
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1924
1932
|
debug2("Triggered by new values for the following props", ...[
|
|
1925
1933
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1926
|
-
...Object.keys(
|
|
1934
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1927
1935
|
]);
|
|
1928
|
-
|
|
1936
|
+
const action = {
|
|
1929
1937
|
payload: {
|
|
1930
1938
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1931
|
-
|
|
1939
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1932
1940
|
}
|
|
1933
|
-
}
|
|
1941
|
+
};
|
|
1942
|
+
dispatch(action);
|
|
1943
|
+
if (config.onPropChange) {
|
|
1944
|
+
for (var prop in rawUpdatedProps)
|
|
1945
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
1946
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
1947
|
+
config.onPropChange({ name: prop, newValue, oldValue }, props, actions);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1934
1950
|
}
|
|
1935
1951
|
});
|
|
1936
1952
|
return /* @__PURE__ */ createElement2(Context.Provider, {
|
|
@@ -2002,35 +2018,38 @@ function useColumnGroups() {
|
|
|
2002
2018
|
return interceptMap(collapsedColumnGroups, {
|
|
2003
2019
|
set: (key, visibleCol) => {
|
|
2004
2020
|
const colIds = key.slice(1);
|
|
2005
|
-
const
|
|
2021
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2006
2022
|
colIds.forEach((colId) => {
|
|
2007
|
-
columnVisibility
|
|
2023
|
+
columnVisibility[colId] = false;
|
|
2008
2024
|
});
|
|
2009
|
-
columnVisibility
|
|
2025
|
+
delete columnVisibility[visibleCol];
|
|
2026
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2010
2027
|
},
|
|
2011
2028
|
beforeClear: (currentCollapsedGroups) => {
|
|
2012
|
-
const
|
|
2029
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2013
2030
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2014
2031
|
keys.forEach((key) => {
|
|
2015
2032
|
const colIds = key.slice(1);
|
|
2016
2033
|
colIds.forEach((colId) => {
|
|
2017
|
-
columnVisibility
|
|
2034
|
+
delete columnVisibility[colId];
|
|
2018
2035
|
});
|
|
2019
2036
|
});
|
|
2037
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2020
2038
|
},
|
|
2021
2039
|
delete: (key) => {
|
|
2022
|
-
const
|
|
2040
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2023
2041
|
const colIds = key.slice(1);
|
|
2024
2042
|
colIds.forEach((colId) => {
|
|
2025
|
-
columnVisibility
|
|
2043
|
+
delete columnVisibility[colId];
|
|
2026
2044
|
});
|
|
2045
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2027
2046
|
}
|
|
2028
2047
|
});
|
|
2029
2048
|
}, [collapsedColumnGroups]);
|
|
2030
2049
|
}
|
|
2031
2050
|
|
|
2032
2051
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
2033
|
-
import { useEffect as useEffect9, useMemo as
|
|
2052
|
+
import { useEffect as useEffect9, useMemo as useMemo4 } from "react";
|
|
2034
2053
|
|
|
2035
2054
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2036
2055
|
import {
|
|
@@ -2375,190 +2394,9 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2375
2394
|
};
|
|
2376
2395
|
|
|
2377
2396
|
// 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
|
-
};
|
|
2397
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState4 } from "react";
|
|
2559
2398
|
|
|
2560
|
-
// src/
|
|
2561
|
-
import { useMemo as useMemo4 } from "react";
|
|
2399
|
+
// src/utils/DeepMap/once.ts
|
|
2562
2400
|
function once(fn) {
|
|
2563
2401
|
let called = false;
|
|
2564
2402
|
let result = null;
|
|
@@ -2572,14 +2410,8 @@ function once(fn) {
|
|
|
2572
2410
|
};
|
|
2573
2411
|
return onceFn;
|
|
2574
2412
|
}
|
|
2575
|
-
function useOnce(fn) {
|
|
2576
|
-
const onceFn = useMemo4(() => {
|
|
2577
|
-
return once(fn);
|
|
2578
|
-
}, []);
|
|
2579
|
-
return onceFn();
|
|
2580
|
-
}
|
|
2581
2413
|
|
|
2582
|
-
// src/utils/DeepMap.ts
|
|
2414
|
+
// src/utils/DeepMap/index.ts
|
|
2583
2415
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2584
2416
|
var DeepMap = class {
|
|
2585
2417
|
constructor(initial) {
|
|
@@ -2831,72 +2663,663 @@ var DeepMap = class {
|
|
|
2831
2663
|
}
|
|
2832
2664
|
};
|
|
2833
2665
|
|
|
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;
|
|
2666
|
+
// src/utils/groupAndPivot/index.ts
|
|
2667
|
+
var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
|
|
2668
|
+
function DEFAULT_TO_KEY(value) {
|
|
2669
|
+
return value;
|
|
2670
|
+
}
|
|
2671
|
+
function initReducers(reducers) {
|
|
2672
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2673
|
+
return {};
|
|
2852
2674
|
}
|
|
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]));
|
|
2675
|
+
const result = {};
|
|
2676
|
+
for (let key in reducers)
|
|
2677
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2678
|
+
result[key] = reducers[key].initialValue;
|
|
2869
2679
|
}
|
|
2680
|
+
return result;
|
|
2681
|
+
}
|
|
2682
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
2683
|
+
var _a, _b;
|
|
2684
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2685
|
+
return;
|
|
2870
2686
|
}
|
|
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"';
|
|
2687
|
+
for (let key in reducers)
|
|
2688
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2689
|
+
const reducer = reducers[key];
|
|
2690
|
+
if (typeof reducer.reducer !== "function") {
|
|
2691
|
+
continue;
|
|
2894
2692
|
}
|
|
2895
|
-
|
|
2693
|
+
const currentValue = reducerResults[key];
|
|
2694
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
2695
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
2896
2696
|
}
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2697
|
+
}
|
|
2698
|
+
function lazyGroup(groupParams, rootData) {
|
|
2699
|
+
const {
|
|
2700
|
+
reducers = {},
|
|
2701
|
+
pivot,
|
|
2702
|
+
groupBy,
|
|
2703
|
+
mappings
|
|
2704
|
+
} = groupParams;
|
|
2705
|
+
const deepMap = new DeepMap();
|
|
2706
|
+
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
2707
|
+
const last = pivotIndex === pivot2.length - 1;
|
|
2708
|
+
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
2709
|
+
for (var k in values)
|
|
2710
|
+
if (values.hasOwnProperty(k)) {
|
|
2711
|
+
const pivotKey = k;
|
|
2712
|
+
currentPivotKeys2.push(pivotKey);
|
|
2713
|
+
topLevelPivotColumns.set(currentPivotKeys2, true);
|
|
2714
|
+
pivotDeepMap.set(currentPivotKeys2, {
|
|
2715
|
+
reducerResults: values[k][(mappings == null ? void 0 : mappings.totals) || "totals"] || {},
|
|
2716
|
+
items: []
|
|
2717
|
+
});
|
|
2718
|
+
if (!last) {
|
|
2719
|
+
traverseValues(pivotDeepMap, values[k], pivot2, pivotIndex + 1, currentPivotKeys2);
|
|
2720
|
+
}
|
|
2721
|
+
currentPivotKeys2.pop();
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2725
|
+
let currentPivotKeys = [];
|
|
2726
|
+
const initialReducerValue = initReducers(reducers);
|
|
2727
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2728
|
+
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2729
|
+
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2730
|
+
const dataArray = lazyGroupRowInfo.items;
|
|
2731
|
+
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2732
|
+
if (!dataArray[i]) {
|
|
2733
|
+
const deepMapGroupValue2 = {
|
|
2734
|
+
items: [],
|
|
2735
|
+
reducerResults: {}
|
|
2736
|
+
};
|
|
2737
|
+
deepMap.set([...currentGroupKeys, `not-loaded-yet-${i}`], deepMapGroupValue2);
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
const dataObject = dataArray[i].data;
|
|
2741
|
+
const dataKeys = dataArray[i].keys;
|
|
2742
|
+
let item = dataObject;
|
|
2743
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
2744
|
+
const key = item[groupByProperty];
|
|
2745
|
+
currentGroupKeys.push(key);
|
|
2746
|
+
const deepMapGroupValue = {
|
|
2747
|
+
items: [],
|
|
2748
|
+
reducerResults: dataArray[i].aggregations || {}
|
|
2749
|
+
};
|
|
2750
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2751
|
+
if (pivot) {
|
|
2752
|
+
const pivotDeepMap = deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2753
|
+
const pivotContainer = dataArray[i].pivot;
|
|
2754
|
+
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
2755
|
+
}
|
|
2756
|
+
currentGroupKeys.pop();
|
|
2757
|
+
}
|
|
2758
|
+
next == null ? void 0 : next();
|
|
2759
|
+
});
|
|
2760
|
+
const result = {
|
|
2761
|
+
deepMap,
|
|
2762
|
+
groupParams,
|
|
2763
|
+
initialData: rootData,
|
|
2764
|
+
reducerResults: globalReducerResults
|
|
2765
|
+
};
|
|
2766
|
+
if (pivot) {
|
|
2767
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2768
|
+
result.pivot = pivot;
|
|
2769
|
+
}
|
|
2770
|
+
return result;
|
|
2771
|
+
}
|
|
2772
|
+
function group(groupParams, data) {
|
|
2773
|
+
const {
|
|
2774
|
+
groupBy,
|
|
2775
|
+
defaultToKey = DEFAULT_TO_KEY,
|
|
2776
|
+
pivot,
|
|
2777
|
+
reducers
|
|
2778
|
+
} = groupParams;
|
|
2779
|
+
const groupByLength = groupBy.length;
|
|
2780
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2781
|
+
const deepMap = new DeepMap();
|
|
2782
|
+
let currentGroupKeys = [];
|
|
2783
|
+
let currentPivotKeys = [];
|
|
2784
|
+
const initialReducerValue = initReducers(reducers);
|
|
2785
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2786
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
2787
|
+
let item = data[i];
|
|
2788
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
2789
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
2790
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
2791
|
+
currentGroupKeys.push(key);
|
|
2792
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
2793
|
+
const deepMapGroupValue = {
|
|
2794
|
+
items: [],
|
|
2795
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
2796
|
+
};
|
|
2797
|
+
if (pivot) {
|
|
2798
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2799
|
+
}
|
|
2800
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2801
|
+
}
|
|
2802
|
+
const {
|
|
2803
|
+
items: currentGroupItems,
|
|
2804
|
+
reducerResults,
|
|
2805
|
+
pivotDeepMap
|
|
2806
|
+
} = deepMap.get(currentGroupKeys);
|
|
2807
|
+
currentGroupItems.push(item);
|
|
2808
|
+
if (reducers) {
|
|
2809
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
2810
|
+
}
|
|
2811
|
+
if (pivot) {
|
|
2812
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
2813
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
2814
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
2815
|
+
currentPivotKeys.push(pivotKey);
|
|
2816
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
2817
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
2818
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
2819
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
2820
|
+
items: []
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
const {
|
|
2824
|
+
reducerResults: pivotReducerResults,
|
|
2825
|
+
items: pivotGroupItems
|
|
2826
|
+
} = pivotDeepMap.get(currentPivotKeys);
|
|
2827
|
+
pivotGroupItems.push(item);
|
|
2828
|
+
if (reducers) {
|
|
2829
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
currentPivotKeys.length = 0;
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
if (reducers) {
|
|
2836
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
2837
|
+
}
|
|
2838
|
+
currentGroupKeys.length = 0;
|
|
2839
|
+
}
|
|
2840
|
+
if (reducers) {
|
|
2841
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
2842
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
2843
|
+
if (pivot) {
|
|
2844
|
+
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
2845
|
+
completeReducers(reducers, pivotReducerResults, items);
|
|
2846
|
+
next2 == null ? void 0 : next2();
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
next == null ? void 0 : next();
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
if (reducers) {
|
|
2853
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
2854
|
+
}
|
|
2855
|
+
const result = {
|
|
2856
|
+
deepMap,
|
|
2857
|
+
groupParams,
|
|
2858
|
+
initialData: data,
|
|
2859
|
+
reducerResults: globalReducerResults
|
|
2860
|
+
};
|
|
2861
|
+
if (pivot) {
|
|
2862
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2863
|
+
result.pivot = pivot;
|
|
2864
|
+
}
|
|
2865
|
+
return result;
|
|
2866
|
+
}
|
|
2867
|
+
function flatten(groupResult) {
|
|
2868
|
+
const { groupParams, deepMap } = groupResult;
|
|
2869
|
+
const groupByLength = groupParams.groupBy.length;
|
|
2870
|
+
const result = [];
|
|
2871
|
+
deepMap.topDownKeys().reduce((acc, key) => {
|
|
2872
|
+
if (key.length === groupByLength) {
|
|
2873
|
+
const items = deepMap.get(key).items;
|
|
2874
|
+
acc.push(...items);
|
|
2875
|
+
}
|
|
2876
|
+
return acc;
|
|
2877
|
+
}, result);
|
|
2878
|
+
return result;
|
|
2879
|
+
}
|
|
2880
|
+
function getEnhancedGroupData(options, deepMapValue) {
|
|
2881
|
+
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2882
|
+
const groupNesting = groupKeys.length;
|
|
2883
|
+
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
2884
|
+
let data = null;
|
|
2885
|
+
if (Object.keys(reducerResults).length > 0) {
|
|
2886
|
+
data = {};
|
|
2887
|
+
for (let key in reducers)
|
|
2888
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2889
|
+
const reducer = reducers[key];
|
|
2890
|
+
const field = reducer.field;
|
|
2891
|
+
if (field) {
|
|
2892
|
+
data[field] = reducerResults[key];
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
const enhancedGroupData = {
|
|
2897
|
+
data,
|
|
2898
|
+
groupCount: groupItems.length,
|
|
2899
|
+
groupData: groupItems,
|
|
2900
|
+
groupKeys,
|
|
2901
|
+
id: groupKeys,
|
|
2902
|
+
collapsed,
|
|
2903
|
+
parents,
|
|
2904
|
+
collapsedChildrenCount: 0,
|
|
2905
|
+
collapsedGroupsCount: 0,
|
|
2906
|
+
indexInParentGroups: options.indexInParentGroups,
|
|
2907
|
+
indexInGroup: options.indexInGroup,
|
|
2908
|
+
indexInAll: options.indexInAll,
|
|
2909
|
+
value: groupKeys[groupKeys.length - 1],
|
|
2910
|
+
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/DataSource/privateHooks/useLoadData.ts
|
|
3033
|
+
var SKIP_DATA_CHANGES_KEYS = {
|
|
3034
|
+
originalDataArray: true,
|
|
3035
|
+
changes: true
|
|
3036
|
+
};
|
|
3037
|
+
function buildDataSourceDataParams(componentState, overrides) {
|
|
3038
|
+
var _a, _b;
|
|
3039
|
+
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
3040
|
+
const dataSourceParams = {
|
|
3041
|
+
originalDataArray: componentState.originalDataArray,
|
|
3042
|
+
sortInfo,
|
|
3043
|
+
groupBy: componentState.groupBy,
|
|
3044
|
+
pivotBy: componentState.pivotBy,
|
|
3045
|
+
aggregationReducers: componentState.aggregationReducers
|
|
3046
|
+
};
|
|
3047
|
+
if (componentState.livePagination !== void 0) {
|
|
3048
|
+
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3049
|
+
dataSourceParams.cursorId = componentState.cursorId;
|
|
3050
|
+
}
|
|
3051
|
+
if (componentState.fullLazyLoad) {
|
|
3052
|
+
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3053
|
+
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3054
|
+
dataSourceParams.lazyLoadStartIndex = 0;
|
|
3055
|
+
}
|
|
3056
|
+
dataSourceParams.groupKeys = [];
|
|
3057
|
+
}
|
|
3058
|
+
if (overrides) {
|
|
3059
|
+
Object.assign(dataSourceParams, overrides);
|
|
3060
|
+
}
|
|
3061
|
+
const changes = {};
|
|
3062
|
+
const oldDataSourceParams = componentState.dataParams || {};
|
|
3063
|
+
for (let k in dataSourceParams) {
|
|
3064
|
+
if (dataSourceParams.hasOwnProperty(k) && !SKIP_DATA_CHANGES_KEYS[k]) {
|
|
3065
|
+
const key = k;
|
|
3066
|
+
if (dataSourceParams[key] !== oldDataSourceParams[key]) {
|
|
3067
|
+
changes[key] = true;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
dataSourceParams.changes = changes;
|
|
3072
|
+
return dataSourceParams;
|
|
3073
|
+
}
|
|
3074
|
+
function loadData(data, componentState, actions, overrides) {
|
|
3075
|
+
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3076
|
+
if (typeof data === "function") {
|
|
3077
|
+
data = data(dataParams);
|
|
3078
|
+
}
|
|
3079
|
+
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3080
|
+
if (dataIsPromise) {
|
|
3081
|
+
actions.loading = true;
|
|
3082
|
+
}
|
|
3083
|
+
Promise.resolve(data).then((dataParam) => {
|
|
3084
|
+
var _a, _b, _c;
|
|
3085
|
+
let dataArray = [];
|
|
3086
|
+
let skipAssign = false;
|
|
3087
|
+
if (Array.isArray(dataParam.data)) {
|
|
3088
|
+
const remoteData = dataParam;
|
|
3089
|
+
dataArray = remoteData.data;
|
|
3090
|
+
if (remoteData.livePaginationCursor !== void 0) {
|
|
3091
|
+
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
3092
|
+
}
|
|
3093
|
+
if (remoteData.mappings) {
|
|
3094
|
+
actions.pivotMappings = remoteData.mappings;
|
|
3095
|
+
}
|
|
3096
|
+
if (componentState.fullLazyLoad && dataParams.groupKeys) {
|
|
3097
|
+
const lazyGroupData = DeepMap.clone(componentState.originalLazyGroupData);
|
|
3098
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3099
|
+
const newGroupRowInfo = {
|
|
3100
|
+
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
3101
|
+
items: dataArray
|
|
3102
|
+
};
|
|
3103
|
+
if (dataParams.lazyLoadBatchSize) {
|
|
3104
|
+
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3105
|
+
const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
|
|
3106
|
+
items: [],
|
|
3107
|
+
totalCount: newGroupRowInfo.totalCount
|
|
3108
|
+
};
|
|
3109
|
+
currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
|
|
3110
|
+
const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
|
|
3111
|
+
const end = start + ((_c = dataParams.lazyLoadBatchSize) != null ? _c : dataArray.length);
|
|
3112
|
+
for (let i = start; i < end; i++) {
|
|
3113
|
+
currentGroupRowInfo.items[i] = newGroupRowInfo.items[i - start];
|
|
3114
|
+
}
|
|
3115
|
+
if (!existingGroupRowInfo) {
|
|
3116
|
+
lazyGroupData.set(key, currentGroupRowInfo);
|
|
3117
|
+
}
|
|
3118
|
+
} else {
|
|
3119
|
+
lazyGroupData.set(key, newGroupRowInfo);
|
|
3120
|
+
}
|
|
3121
|
+
skipAssign = true;
|
|
3122
|
+
actions.originalLazyGroupData = lazyGroupData;
|
|
3123
|
+
}
|
|
3124
|
+
} else {
|
|
3125
|
+
dataArray = dataParam;
|
|
3126
|
+
}
|
|
3127
|
+
if (!skipAssign) {
|
|
3128
|
+
actions.originalDataArray = dataArray;
|
|
3129
|
+
}
|
|
3130
|
+
if (dataIsPromise) {
|
|
3131
|
+
actions.loading = false;
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
}
|
|
3135
|
+
function useLoadData() {
|
|
3136
|
+
const {
|
|
3137
|
+
getComponentState,
|
|
3138
|
+
componentActions: actions,
|
|
3139
|
+
componentState
|
|
3140
|
+
} = useComponentState();
|
|
3141
|
+
const {
|
|
3142
|
+
data,
|
|
3143
|
+
notifyScrollbarsChange,
|
|
3144
|
+
sortInfo,
|
|
3145
|
+
groupBy,
|
|
3146
|
+
pivotBy,
|
|
3147
|
+
livePagination,
|
|
3148
|
+
livePaginationCursor,
|
|
3149
|
+
cursorId: stateCursorId,
|
|
3150
|
+
lazyLoadBatchSize,
|
|
3151
|
+
notifyScrollStop
|
|
3152
|
+
} = componentState;
|
|
3153
|
+
const [scrollbars, setScrollbars] = useState4({
|
|
3154
|
+
vertical: false,
|
|
3155
|
+
horizontal: false
|
|
3156
|
+
});
|
|
3157
|
+
const scrollbarsRef = useRef6(scrollbars);
|
|
3158
|
+
useEffect8(() => {
|
|
3159
|
+
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
3160
|
+
if (!scrollbars2) {
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
scrollbarsRef.current = scrollbars2;
|
|
3164
|
+
setScrollbars(scrollbars2);
|
|
3165
|
+
});
|
|
3166
|
+
return () => notifyScrollbarsChange.destroy();
|
|
3167
|
+
}, [notifyScrollbarsChange]);
|
|
3168
|
+
useEffect8(() => {
|
|
3169
|
+
const frameId = requestAnimationFrame(() => {
|
|
3170
|
+
var _a;
|
|
3171
|
+
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical) && livePaginationCursor) {
|
|
3172
|
+
actions.cursorId = livePaginationCursor;
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
return () => cancelAnimationFrame(frameId);
|
|
3176
|
+
}, [livePaginationCursor]);
|
|
3177
|
+
useEffect8(() => {
|
|
3178
|
+
const { livePaginationCursor: livePaginationCursor2, livePagination: livePagination2 } = getComponentState();
|
|
3179
|
+
if (!scrollbars.vertical && livePagination2) {
|
|
3180
|
+
if (livePaginationCursor2) {
|
|
3181
|
+
actions.cursorId = livePaginationCursor2;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
}, [scrollbars.vertical]);
|
|
3185
|
+
const depsObject = {
|
|
3186
|
+
sortInfo,
|
|
3187
|
+
groupBy,
|
|
3188
|
+
pivotBy,
|
|
3189
|
+
cursorId: livePagination ? stateCursorId : null
|
|
3190
|
+
};
|
|
3191
|
+
const initialRef = useRef6(true);
|
|
3192
|
+
useEffect8(() => {
|
|
3193
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3194
|
+
return notifyScrollStop.onChange((param) => {
|
|
3195
|
+
console.log("scroll stop", param);
|
|
3196
|
+
if (!param) {
|
|
3197
|
+
return;
|
|
3198
|
+
}
|
|
3199
|
+
const componentState2 = getComponentState();
|
|
3200
|
+
const {
|
|
3201
|
+
firstVisibleRowIndex: startIndex,
|
|
3202
|
+
lastVisibleRowIndex: endIndex
|
|
3203
|
+
} = param;
|
|
3204
|
+
const firstBatchStart = Math.floor(startIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3205
|
+
const lastBatchStart = Math.floor(endIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3206
|
+
const isRowLoaded = (index) => componentState2.dataArray[index].data != null;
|
|
3207
|
+
for (let batchStartIndex = firstBatchStart; batchStartIndex <= lastBatchStart; batchStartIndex = batchStartIndex + lazyLoadBatchSize) {
|
|
3208
|
+
if (!isRowLoaded(batchStartIndex)) {
|
|
3209
|
+
loadData(componentState2.data, componentState2, actions, {
|
|
3210
|
+
lazyLoadBatchSize,
|
|
3211
|
+
lazyLoadStartIndex: batchStartIndex
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
return;
|
|
3218
|
+
}, [lazyLoadBatchSize]);
|
|
3219
|
+
useEffectWithChanges(() => {
|
|
3220
|
+
const componentState2 = getComponentState();
|
|
3221
|
+
if (typeof componentState2.data !== "function") {
|
|
3222
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3223
|
+
}
|
|
3224
|
+
}, { data });
|
|
3225
|
+
useEffectWithChanges(() => {
|
|
3226
|
+
const componentState2 = getComponentState();
|
|
3227
|
+
if (typeof componentState2.data === "function") {
|
|
3228
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3229
|
+
}
|
|
3230
|
+
}, __spreadProps(__spreadValues({}, depsObject), { data }));
|
|
3231
|
+
useEffectWithChanges((_changes, _prevValues) => {
|
|
3232
|
+
const componentState2 = getComponentState();
|
|
3233
|
+
if (initialRef.current) {
|
|
3234
|
+
initialRef.current = false;
|
|
3235
|
+
actions.dataParams = buildDataSourceDataParams(componentState2);
|
|
3236
|
+
}
|
|
3237
|
+
}, depsObject);
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
3241
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
3242
|
+
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
3243
|
+
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
3244
|
+
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
3245
|
+
if (weakMap && weakMap.has(sortInfo)) {
|
|
3246
|
+
const prevResult = weakMap.get(sortInfo);
|
|
3247
|
+
if (prevResult && prevResult.length === result.length) {
|
|
3248
|
+
return prevResult;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
if (weakMap && sortInfo) {
|
|
3252
|
+
weakMap.set(sortInfo, result);
|
|
3253
|
+
}
|
|
3254
|
+
return result;
|
|
3255
|
+
};
|
|
3256
|
+
|
|
3257
|
+
// src/components/DataSource/GroupRowsState.ts
|
|
3258
|
+
var GroupRowsState = class {
|
|
3259
|
+
constructor(state) {
|
|
3260
|
+
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
3261
|
+
}
|
|
3262
|
+
getState() {
|
|
3263
|
+
var _a, _b, _c, _d;
|
|
3264
|
+
return {
|
|
3265
|
+
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
3266
|
+
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
3267
|
+
};
|
|
3268
|
+
}
|
|
3269
|
+
destroy() {
|
|
3270
|
+
var _a, _b;
|
|
3271
|
+
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
3272
|
+
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
3273
|
+
delete this.expandedMap;
|
|
3274
|
+
delete this.collapsedMap;
|
|
3275
|
+
}
|
|
3276
|
+
update(state) {
|
|
3277
|
+
var _a, _b, _c, _d;
|
|
3278
|
+
this.initialState = state;
|
|
3279
|
+
const { collapsedRows, expandedRows } = this.initialState;
|
|
3280
|
+
this.collapsedAll = collapsedRows === true;
|
|
3281
|
+
this.expandedAll = expandedRows === true;
|
|
3282
|
+
if (this.collapsedAll && this.expandedAll) {
|
|
3283
|
+
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
3284
|
+
}
|
|
3285
|
+
if (collapsedRows !== true) {
|
|
3286
|
+
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
3287
|
+
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
3288
|
+
}
|
|
3289
|
+
if (expandedRows !== true) {
|
|
3290
|
+
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
3291
|
+
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
areAllCollapsed() {
|
|
3295
|
+
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
3296
|
+
}
|
|
3297
|
+
areAllExpanded() {
|
|
3298
|
+
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
3299
|
+
}
|
|
3300
|
+
collapseAll() {
|
|
3301
|
+
this.update({
|
|
3302
|
+
collapsedRows: true,
|
|
3303
|
+
expandedRows: []
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
expandAll() {
|
|
3307
|
+
this.update({
|
|
3308
|
+
expandedRows: true,
|
|
3309
|
+
collapsedRows: []
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
isGroupRowExpanded(keys) {
|
|
3313
|
+
var _a, _b;
|
|
3314
|
+
if (this.expandedAll === true) {
|
|
3315
|
+
if (this.collapsedAll === true) {
|
|
3316
|
+
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
3317
|
+
}
|
|
3318
|
+
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
3319
|
+
}
|
|
3320
|
+
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
3321
|
+
}
|
|
3322
|
+
isGroupRowCollapsed(keys) {
|
|
2900
3323
|
return !this.isGroupRowExpanded(keys);
|
|
2901
3324
|
}
|
|
2902
3325
|
setGroupRowExpanded(keys, shouldExpand) {
|
|
@@ -2942,7 +3365,7 @@ var GroupRowsState = class {
|
|
|
2942
3365
|
};
|
|
2943
3366
|
|
|
2944
3367
|
// src/utils/shallowEqualObjects.ts
|
|
2945
|
-
function shallowEqualObjects(objA, objB) {
|
|
3368
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
2946
3369
|
if (objA === objB) {
|
|
2947
3370
|
return true;
|
|
2948
3371
|
}
|
|
@@ -2951,12 +3374,21 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2951
3374
|
}
|
|
2952
3375
|
var aKeys = Object.keys(objA);
|
|
2953
3376
|
var bKeys = Object.keys(objB);
|
|
3377
|
+
if (ignoreKeys) {
|
|
3378
|
+
aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3379
|
+
bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3380
|
+
}
|
|
2954
3381
|
var len = aKeys.length;
|
|
2955
3382
|
if (bKeys.length !== len) {
|
|
2956
3383
|
return false;
|
|
2957
3384
|
}
|
|
2958
3385
|
for (var i = 0; i < len; i++) {
|
|
2959
3386
|
var key = aKeys[i];
|
|
3387
|
+
if (ignoreKeys) {
|
|
3388
|
+
if (ignoreKeys.has(key)) {
|
|
3389
|
+
continue;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
2960
3392
|
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2961
3393
|
return false;
|
|
2962
3394
|
}
|
|
@@ -2967,12 +3399,12 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2967
3399
|
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2968
3400
|
var map = new WeakMap();
|
|
2969
3401
|
var getCompareDefault = (a) => a;
|
|
2970
|
-
function discardCallsWithEqualArg(fn, timeframe = 50,
|
|
3402
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
2971
3403
|
map.set(fn, {
|
|
2972
3404
|
lastCallTime: 0,
|
|
2973
3405
|
lastCallArg: null
|
|
2974
3406
|
});
|
|
2975
|
-
const getCompare =
|
|
3407
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
2976
3408
|
return (arg) => {
|
|
2977
3409
|
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2978
3410
|
lastCallTime: 0,
|
|
@@ -2993,350 +3425,172 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
|
2993
3425
|
}
|
|
2994
3426
|
|
|
2995
3427
|
// src/components/DataSource/state/getInitialState.ts
|
|
3428
|
+
var defaultCursorId = Symbol("cursorId");
|
|
2996
3429
|
function initSetupState2() {
|
|
2997
3430
|
const now = Date.now();
|
|
2998
3431
|
const originalDataArray = [];
|
|
2999
3432
|
const dataArray = [];
|
|
3433
|
+
const originalLazyGroupData = new DeepMap();
|
|
3000
3434
|
return {
|
|
3001
3435
|
dataParams: void 0,
|
|
3002
3436
|
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3437
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
3003
3438
|
pivotTotalColumnPosition: "end",
|
|
3439
|
+
originalLazyGroupData,
|
|
3004
3440
|
originalDataArray,
|
|
3005
|
-
|
|
3441
|
+
cursorId: defaultCursorId,
|
|
3006
3442
|
showSeparatePivotColumnForSingleAggregation: false,
|
|
3007
3443
|
propsCache: new Map([
|
|
3008
3444
|
["sortInfo", new WeakMap()]
|
|
3009
3445
|
]),
|
|
3446
|
+
pivotMappings: void 0,
|
|
3010
3447
|
pivotColumns: void 0,
|
|
3011
|
-
pivotColumnGroups: void 0,
|
|
3012
|
-
dataArray,
|
|
3013
|
-
updatedAt: now,
|
|
3014
|
-
groupedAt: 0,
|
|
3015
|
-
sortedAt: 0,
|
|
3016
|
-
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);
|
|
3448
|
+
pivotColumnGroups: void 0,
|
|
3449
|
+
dataArray,
|
|
3450
|
+
updatedAt: now,
|
|
3451
|
+
groupedAt: 0,
|
|
3452
|
+
sortedAt: 0,
|
|
3453
|
+
reducedAt: now,
|
|
3454
|
+
generateGroupRows: true,
|
|
3455
|
+
groupDeepMap: void 0,
|
|
3456
|
+
postSortDataArray: void 0,
|
|
3457
|
+
postGroupDataArray: void 0,
|
|
3458
|
+
lastSortDataArray: void 0,
|
|
3459
|
+
lastGroupDataArray: void 0
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
3463
|
+
const obj = __spreadValues({}, dataParams);
|
|
3464
|
+
delete obj.originalDataArray;
|
|
3465
|
+
return obj;
|
|
3466
|
+
}
|
|
3467
|
+
var forwardProps3 = (setupState) => {
|
|
3468
|
+
return {
|
|
3469
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3470
|
+
fullLazyLoad: 1,
|
|
3471
|
+
data: 1,
|
|
3472
|
+
pivotBy: 1,
|
|
3473
|
+
primaryKey: 1,
|
|
3474
|
+
livePagination: 1,
|
|
3475
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3476
|
+
aggregationReducers: 1,
|
|
3477
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3478
|
+
loading: (loading) => loading != null ? loading : false,
|
|
3479
|
+
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
3480
|
+
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
3481
|
+
groupRowsState: (groupRowsState) => {
|
|
3482
|
+
return groupRowsState || new GroupRowsState({
|
|
3483
|
+
expandedRows: true,
|
|
3484
|
+
collapsedRows: []
|
|
3485
|
+
});
|
|
3169
3486
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
}
|
|
3184
|
-
if (reducers) {
|
|
3185
|
-
completeReducers(reducers, globalReducerResults, data);
|
|
3186
|
-
}
|
|
3487
|
+
};
|
|
3488
|
+
};
|
|
3489
|
+
function getLivePaginationCursorValue(livePaginationCursorProp, state) {
|
|
3490
|
+
const livePaginationCursor = typeof livePaginationCursorProp === "function" ? livePaginationCursorProp({
|
|
3491
|
+
array: state.originalDataArray,
|
|
3492
|
+
length: state.originalDataArray.length,
|
|
3493
|
+
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3494
|
+
}) : livePaginationCursorProp;
|
|
3495
|
+
return livePaginationCursor;
|
|
3496
|
+
}
|
|
3497
|
+
function mapPropsToState2(params) {
|
|
3498
|
+
const { props, state, oldState } = params;
|
|
3499
|
+
const controlledSort = isControlledValue(props.sortInfo);
|
|
3187
3500
|
const result = {
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
initialData: data,
|
|
3191
|
-
reducerResults: globalReducerResults
|
|
3501
|
+
controlledSort,
|
|
3502
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3192
3503
|
};
|
|
3193
|
-
if (
|
|
3194
|
-
|
|
3195
|
-
|
|
3504
|
+
if (props.livePagination) {
|
|
3505
|
+
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
3506
|
+
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? dataArrayChanged ? getLivePaginationCursorValue(props.livePaginationCursor, state) : state.livePaginationCursor : props.livePaginationCursor;
|
|
3507
|
+
result.livePaginationCursor = livePaginationCursor;
|
|
3196
3508
|
}
|
|
3197
3509
|
return result;
|
|
3198
3510
|
}
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3511
|
+
var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
3512
|
+
function onPropChange(params, props, actions) {
|
|
3513
|
+
const { name, newValue } = params;
|
|
3514
|
+
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3515
|
+
if (props.fullLazyLoad) {
|
|
3516
|
+
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3517
|
+
}
|
|
3518
|
+
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
3519
|
+
actions.groupRowsState = new GroupRowsState({
|
|
3520
|
+
collapsedRows: true,
|
|
3521
|
+
expandedRows: []
|
|
3522
|
+
});
|
|
3207
3523
|
}
|
|
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
3524
|
}
|
|
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
3525
|
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3526
|
+
var debugDataParams = dbg("DataSource:dataParams");
|
|
3527
|
+
function getInterceptActions() {
|
|
3528
|
+
return {
|
|
3529
|
+
sortInfo: (sortInfo, { actions, state }) => {
|
|
3530
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3531
|
+
sortInfo,
|
|
3532
|
+
livePaginationCursor: null
|
|
3533
|
+
});
|
|
3534
|
+
actions.dataParams = dataParams;
|
|
3535
|
+
if (state.livePagination) {
|
|
3536
|
+
requestAnimationFrame(() => {
|
|
3537
|
+
actions.livePaginationCursor = null;
|
|
3538
|
+
});
|
|
3258
3539
|
}
|
|
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;
|
|
3540
|
+
},
|
|
3541
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3542
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3543
|
+
groupBy,
|
|
3544
|
+
livePaginationCursor: null
|
|
3299
3545
|
});
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3546
|
+
actions.dataParams = dataParams;
|
|
3547
|
+
if (state.livePagination) {
|
|
3548
|
+
requestAnimationFrame(() => {
|
|
3549
|
+
actions.livePaginationCursor = null;
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
},
|
|
3553
|
+
pivotBy: (pivotBy, { actions, state }) => {
|
|
3554
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3555
|
+
pivotBy,
|
|
3556
|
+
livePaginationCursor: null
|
|
3557
|
+
});
|
|
3558
|
+
actions.dataParams = dataParams;
|
|
3559
|
+
if (state.livePagination) {
|
|
3560
|
+
requestAnimationFrame(() => {
|
|
3561
|
+
actions.livePaginationCursor = null;
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
},
|
|
3565
|
+
cursorId: (cursorId, { actions, state }) => {
|
|
3566
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3567
|
+
cursorId
|
|
3568
|
+
});
|
|
3569
|
+
actions.dataParams = dataParams;
|
|
3570
|
+
},
|
|
3571
|
+
livePaginationCursor: (livePaginationCursor, { actions, state }) => {
|
|
3572
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3573
|
+
livePaginationCursor
|
|
3574
|
+
});
|
|
3575
|
+
actions.dataParams = dataParams;
|
|
3576
|
+
},
|
|
3577
|
+
dataParams: (dataParams, { state }) => {
|
|
3578
|
+
if (shallowEqualObjects(dataParams, state.dataParams, new Set([
|
|
3579
|
+
"changes",
|
|
3580
|
+
"originalDataArray"
|
|
3581
|
+
]))) {
|
|
3582
|
+
return false;
|
|
3326
3583
|
}
|
|
3584
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3585
|
+
return true;
|
|
3327
3586
|
}
|
|
3328
|
-
parents.pop();
|
|
3329
|
-
indexInParentGroups.pop();
|
|
3330
|
-
});
|
|
3331
|
-
return {
|
|
3332
|
-
data: result
|
|
3333
3587
|
};
|
|
3334
3588
|
}
|
|
3335
3589
|
|
|
3336
3590
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3337
3591
|
function prepareColumn(column) {
|
|
3338
3592
|
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3339
|
-
if (pivotByForColumn.column) {
|
|
3593
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3340
3594
|
if (typeof pivotByForColumn.column === "function") {
|
|
3341
3595
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3342
3596
|
} else {
|
|
@@ -3347,7 +3601,7 @@ function prepareColumn(column) {
|
|
|
3347
3601
|
}
|
|
3348
3602
|
function prepareColumnGroup(columnGroup) {
|
|
3349
3603
|
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3350
|
-
if (pivotByForColumnGroup.columnGroup) {
|
|
3604
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3351
3605
|
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3352
3606
|
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3353
3607
|
} else {
|
|
@@ -3376,6 +3630,9 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3376
3630
|
valueGetter: (params) => {
|
|
3377
3631
|
var _a;
|
|
3378
3632
|
const { rowInfo } = params;
|
|
3633
|
+
if (!rowInfo.data) {
|
|
3634
|
+
return "Loading ... TODO replace this with a loading indicator";
|
|
3635
|
+
}
|
|
3379
3636
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3380
3637
|
}
|
|
3381
3638
|
}
|
|
@@ -3407,7 +3664,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3407
3664
|
}));
|
|
3408
3665
|
}
|
|
3409
3666
|
aggregationReducers.forEach((reducer, index) => {
|
|
3410
|
-
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.id;
|
|
3667
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3411
3668
|
const computedPivotColumn = prepareColumn({
|
|
3412
3669
|
pivotBy,
|
|
3413
3670
|
pivotColumn: true,
|
|
@@ -3426,7 +3683,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3426
3683
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3427
3684
|
}
|
|
3428
3685
|
});
|
|
3429
|
-
const columnId = `${keys.join("/")}
|
|
3686
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3430
3687
|
columns.set(columnId, computedPivotColumn);
|
|
3431
3688
|
});
|
|
3432
3689
|
} else {
|
|
@@ -3459,7 +3716,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3459
3716
|
}));
|
|
3460
3717
|
}
|
|
3461
3718
|
aggregationReducers.forEach((reducer, index) => {
|
|
3462
|
-
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.id} total`;
|
|
3719
|
+
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.name || reducer.id} total`;
|
|
3463
3720
|
const computedPivotColumn = prepareColumn({
|
|
3464
3721
|
columnGroup: columnGroupId,
|
|
3465
3722
|
header,
|
|
@@ -3478,7 +3735,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3478
3735
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3479
3736
|
}
|
|
3480
3737
|
});
|
|
3481
|
-
columns.set(`total:${keys.join("/")}
|
|
3738
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3482
3739
|
});
|
|
3483
3740
|
}
|
|
3484
3741
|
}
|
|
@@ -3487,15 +3744,22 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3487
3744
|
}
|
|
3488
3745
|
});
|
|
3489
3746
|
if (columns.size === 1) {
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3747
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3748
|
+
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
3749
|
+
header: `${reducer.name || reducer.id} total`,
|
|
3750
|
+
pivotBy,
|
|
3751
|
+
pivotColumn: true,
|
|
3752
|
+
pivotTotalColumn: true,
|
|
3753
|
+
pivotAggregator: reducer,
|
|
3754
|
+
pivotAggregatorIndex: index,
|
|
3755
|
+
pivotGroupKeys: [],
|
|
3756
|
+
pivotGroupKey: "",
|
|
3757
|
+
pivotIndex: -1,
|
|
3758
|
+
valueGetter: ({ rowInfo }) => {
|
|
3759
|
+
var _a;
|
|
3760
|
+
return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
|
|
3761
|
+
}
|
|
3762
|
+
}));
|
|
3499
3763
|
});
|
|
3500
3764
|
}
|
|
3501
3765
|
const result = {
|
|
@@ -3532,10 +3796,11 @@ function concludeReducer(params) {
|
|
|
3532
3796
|
const { state, previousState } = params;
|
|
3533
3797
|
const sortInfo = state.sortInfo;
|
|
3534
3798
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3535
|
-
const
|
|
3536
|
-
"originalDataArray"
|
|
3537
|
-
"sortInfo"
|
|
3799
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3800
|
+
"originalDataArray"
|
|
3538
3801
|
]);
|
|
3802
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3803
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3539
3804
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3540
3805
|
const groupBy = state.groupBy;
|
|
3541
3806
|
const pivotBy = state.pivotBy;
|
|
@@ -3543,6 +3808,7 @@ function concludeReducer(params) {
|
|
|
3543
3808
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3544
3809
|
"generateGroupRows",
|
|
3545
3810
|
"originalDataArray",
|
|
3811
|
+
"originalLazyGroupData",
|
|
3546
3812
|
"groupBy",
|
|
3547
3813
|
"groupRowsState",
|
|
3548
3814
|
"pivotBy",
|
|
@@ -3567,7 +3833,12 @@ function concludeReducer(params) {
|
|
|
3567
3833
|
};
|
|
3568
3834
|
if (shouldGroup) {
|
|
3569
3835
|
if (shouldGroupAgain) {
|
|
3570
|
-
const groupResult =
|
|
3836
|
+
const groupResult = state.fullLazyLoad ? lazyGroup({
|
|
3837
|
+
groupBy,
|
|
3838
|
+
pivot: pivotBy,
|
|
3839
|
+
mappings: state.pivotMappings,
|
|
3840
|
+
reducers: state.aggregationReducers
|
|
3841
|
+
}, state.originalLazyGroupData) : group({
|
|
3571
3842
|
groupBy,
|
|
3572
3843
|
pivot: pivotBy,
|
|
3573
3844
|
reducers: state.aggregationReducers
|
|
@@ -3635,6 +3906,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3635
3906
|
forwardProps: forwardProps3,
|
|
3636
3907
|
concludeReducer,
|
|
3637
3908
|
mapPropsToState: mapPropsToState2,
|
|
3909
|
+
onPropChange,
|
|
3638
3910
|
interceptActions: getInterceptActions()
|
|
3639
3911
|
});
|
|
3640
3912
|
function DataSourceCmp({ children }) {
|
|
@@ -3666,16 +3938,22 @@ function DataSource(props) {
|
|
|
3666
3938
|
function useToggleGroupRow() {
|
|
3667
3939
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3668
3940
|
const toggleGroupRow = useCallback4((groupKeys) => {
|
|
3669
|
-
const
|
|
3941
|
+
const state = getDataSourceState();
|
|
3942
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3670
3943
|
newState.toggleGroupRow(groupKeys);
|
|
3671
3944
|
dataSourceActions.groupRowsState = newState;
|
|
3945
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
3946
|
+
loadData(state.data, state, dataSourceActions, {
|
|
3947
|
+
groupKeys
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3672
3950
|
}, []);
|
|
3673
3951
|
return toggleGroupRow;
|
|
3674
3952
|
}
|
|
3675
3953
|
|
|
3676
3954
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
3677
3955
|
function useGroupByMap(groupBy) {
|
|
3678
|
-
const groupByMap =
|
|
3956
|
+
const groupByMap = useMemo4(() => {
|
|
3679
3957
|
return groupBy.reduce((acc, groupBy2, index) => {
|
|
3680
3958
|
acc.set(groupBy2.field, {
|
|
3681
3959
|
groupBy: groupBy2,
|
|
@@ -3863,7 +4141,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3863
4141
|
const currentState = getComponentState();
|
|
3864
4142
|
const { computedColumns } = currentState;
|
|
3865
4143
|
let updated = false;
|
|
3866
|
-
const columnVisibility =
|
|
4144
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3867
4145
|
const cols = computedColumns;
|
|
3868
4146
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
3869
4147
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
@@ -3874,9 +4152,9 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3874
4152
|
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3875
4153
|
updated = true;
|
|
3876
4154
|
if (shouldBeHidden) {
|
|
3877
|
-
columnVisibility
|
|
4155
|
+
columnVisibility[colId] = false;
|
|
3878
4156
|
} else {
|
|
3879
|
-
columnVisibility
|
|
4157
|
+
delete columnVisibility[colId];
|
|
3880
4158
|
}
|
|
3881
4159
|
});
|
|
3882
4160
|
if (updated) {
|
|
@@ -3973,9 +4251,6 @@ function useComputed() {
|
|
|
3973
4251
|
var _a2;
|
|
3974
4252
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3975
4253
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3976
|
-
if (getDataSourceState().livePagination) {
|
|
3977
|
-
dataSourceActions.livePaginationCursor = null;
|
|
3978
|
-
}
|
|
3979
4254
|
}, [getDataSourceState]);
|
|
3980
4255
|
const columns = componentState.computedColumns;
|
|
3981
4256
|
const {
|
|
@@ -4230,7 +4505,7 @@ var InfiniteTableCell = memo3(InfiniteTableCellFn);
|
|
|
4230
4505
|
var import_binary_search = __toModule(require_binary_search());
|
|
4231
4506
|
import {
|
|
4232
4507
|
useCallback as useCallback6,
|
|
4233
|
-
useMemo as
|
|
4508
|
+
useMemo as useMemo5,
|
|
4234
4509
|
useRef as useRef7,
|
|
4235
4510
|
useState as useState6
|
|
4236
4511
|
} from "react";
|
|
@@ -4277,8 +4552,8 @@ var useColumnPointerEvents = ({
|
|
|
4277
4552
|
const dragging = draggingDiff != null;
|
|
4278
4553
|
const { componentActions, computed } = useInfiniteTable();
|
|
4279
4554
|
const { computedColumnOrder } = computed;
|
|
4280
|
-
const column =
|
|
4281
|
-
const { columnIndex, columnWidth, columnsArray } =
|
|
4555
|
+
const column = useMemo5(() => columns.get(columnId), [columnId, columns]);
|
|
4556
|
+
const { columnIndex, columnWidth, columnsArray } = useMemo5(() => {
|
|
4282
4557
|
const columnsArray2 = Array.from(columns.values());
|
|
4283
4558
|
return {
|
|
4284
4559
|
columnsArray: columnsArray2,
|
|
@@ -4601,10 +4876,10 @@ import {
|
|
|
4601
4876
|
createElement as createElement12,
|
|
4602
4877
|
memo as memo4
|
|
4603
4878
|
} from "react";
|
|
4604
|
-
import { useLayoutEffect as
|
|
4879
|
+
import { useLayoutEffect as useLayoutEffect3, useState as useState8 } from "react";
|
|
4605
4880
|
function AvoidReactDiffFn(props) {
|
|
4606
4881
|
const [children, setChildren] = useState8(props.updater.get());
|
|
4607
|
-
|
|
4882
|
+
useLayoutEffect3(() => {
|
|
4608
4883
|
const remove = props.updater.onChange((children2) => {
|
|
4609
4884
|
setChildren(children2);
|
|
4610
4885
|
});
|
|
@@ -4615,7 +4890,7 @@ function AvoidReactDiffFn(props) {
|
|
|
4615
4890
|
var AvoidReactDiff = memo4(AvoidReactDiffFn);
|
|
4616
4891
|
|
|
4617
4892
|
// src/components/RawList/useVirtualRenderer.ts
|
|
4618
|
-
import { useMemo as
|
|
4893
|
+
import { useMemo as useMemo6 } from "react";
|
|
4619
4894
|
|
|
4620
4895
|
// src/components/RawList/ReactVirtualRenderer.tsx
|
|
4621
4896
|
import {
|
|
@@ -4931,7 +5206,7 @@ function createRenderer(brain) {
|
|
|
4931
5206
|
function useVirtualRenderer({
|
|
4932
5207
|
brain
|
|
4933
5208
|
}) {
|
|
4934
|
-
return
|
|
5209
|
+
return useMemo6(() => {
|
|
4935
5210
|
return createRenderer(brain);
|
|
4936
5211
|
}, [brain]);
|
|
4937
5212
|
}
|
|
@@ -4969,7 +5244,7 @@ function RawListFn(props) {
|
|
|
4969
5244
|
var RawList = memo5(RawListFn);
|
|
4970
5245
|
|
|
4971
5246
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4972
|
-
var
|
|
5247
|
+
var debug3 = dbg("Header");
|
|
4973
5248
|
var { rootClassName: rootClassName4 } = internalProps;
|
|
4974
5249
|
var TableHeaderClassName = `${rootClassName4}Header`;
|
|
4975
5250
|
function InfiniteTableHeaderFn(props) {
|
|
@@ -4983,7 +5258,7 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4983
5258
|
const column = columns[columnIndex];
|
|
4984
5259
|
if (!column) {
|
|
4985
5260
|
if (true) {
|
|
4986
|
-
|
|
5261
|
+
debug3("Cannot find column to render at ", columnIndex);
|
|
4987
5262
|
}
|
|
4988
5263
|
return null;
|
|
4989
5264
|
}
|
|
@@ -5023,7 +5298,7 @@ var InfiniteTableHeader = memo6(InfiniteTableHeaderFn);
|
|
|
5023
5298
|
import {
|
|
5024
5299
|
createElement as createElement18,
|
|
5025
5300
|
memo as memo7,
|
|
5026
|
-
useMemo as
|
|
5301
|
+
useMemo as useMemo7,
|
|
5027
5302
|
useRef as useRef10
|
|
5028
5303
|
} from "react";
|
|
5029
5304
|
|
|
@@ -5237,7 +5512,7 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
|
|
|
5237
5512
|
} = useInfiniteTable();
|
|
5238
5513
|
const domRef = useRef10(null);
|
|
5239
5514
|
const hasColumnGroups = computedColumnGroups.size > 0;
|
|
5240
|
-
const columnHeaderGroups =
|
|
5515
|
+
const columnHeaderGroups = useMemo7(() => {
|
|
5241
5516
|
return hasColumnGroups ? renderColumnHeaderGroups({
|
|
5242
5517
|
columnGroups: computedColumnGroups,
|
|
5243
5518
|
columnGroupsDepthsMap,
|
|
@@ -5322,6 +5597,9 @@ function TableHeaderWrapper(props) {
|
|
|
5322
5597
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5323
5598
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5324
5599
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5600
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5601
|
+
left: computedPinnedStartWidth
|
|
5602
|
+
} : void 0;
|
|
5325
5603
|
const header = virtualizeHeader ? /* @__PURE__ */ createElement19(InfiniteTableHeader, {
|
|
5326
5604
|
columns: computedUnpinnedColumns,
|
|
5327
5605
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5336,6 +5614,7 @@ function TableHeaderWrapper(props) {
|
|
|
5336
5614
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5337
5615
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5338
5616
|
}) : /* @__PURE__ */ createElement19(InfiniteTableHeaderUnvirtualized, {
|
|
5617
|
+
style: unvirtualizedStyle,
|
|
5339
5618
|
brain,
|
|
5340
5619
|
scrollable: true,
|
|
5341
5620
|
pinning: false,
|
|
@@ -5500,7 +5779,7 @@ var scrollTransformTargetCls = "mlx2t3";
|
|
|
5500
5779
|
var UPDATE_SCROLL2 = (node, scrollPosition) => {
|
|
5501
5780
|
node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, ${-scrollPosition.scrollTop}px, 0px)`;
|
|
5502
5781
|
};
|
|
5503
|
-
var
|
|
5782
|
+
var debug4 = dbg("VirtuaList");
|
|
5504
5783
|
var rootClassName7 = "InfiniteList";
|
|
5505
5784
|
var VirtualList = (props) => {
|
|
5506
5785
|
const _a = props, {
|
|
@@ -5540,7 +5819,7 @@ var VirtualList = (props) => {
|
|
|
5540
5819
|
const removeOnRenderCount = virtualBrain.onRenderCountChange((renderCount) => {
|
|
5541
5820
|
renderCountRef.current = renderCount;
|
|
5542
5821
|
if (true) {
|
|
5543
|
-
|
|
5822
|
+
debug4.extend(mainAxis)(`Render count change ${renderCount}`);
|
|
5544
5823
|
}
|
|
5545
5824
|
rerender();
|
|
5546
5825
|
});
|
|
@@ -6042,7 +6321,6 @@ var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf",
|
|
|
6042
6321
|
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
6043
6322
|
|
|
6044
6323
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
6045
|
-
var DELAY = 200;
|
|
6046
6324
|
var TableClassName = internalProps.rootClassName;
|
|
6047
6325
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
6048
6326
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -6053,15 +6331,25 @@ var useOnContainerScroll = ({
|
|
|
6053
6331
|
}) => {
|
|
6054
6332
|
const {
|
|
6055
6333
|
componentState: {
|
|
6334
|
+
scrollStopDelay,
|
|
6056
6335
|
scrollerDOMRef,
|
|
6057
6336
|
domRef,
|
|
6058
6337
|
scrollToBottomOffset,
|
|
6059
6338
|
onScrollToBottom,
|
|
6060
6339
|
onScrollToTop,
|
|
6340
|
+
onScrollStop: onScrollStopFromProps,
|
|
6061
6341
|
bodySize
|
|
6062
6342
|
}
|
|
6063
6343
|
} = useInfiniteTable();
|
|
6064
|
-
const {
|
|
6344
|
+
const {
|
|
6345
|
+
componentActions: dataSourceActions,
|
|
6346
|
+
getState: getDataSourceState,
|
|
6347
|
+
componentState: { notifyScrollStop }
|
|
6348
|
+
} = useDataSourceContextValue();
|
|
6349
|
+
const onScrollStop = useCallback13((param) => {
|
|
6350
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6351
|
+
notifyScrollStop(param);
|
|
6352
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
6065
6353
|
const timeoutIdRef = useRef15(0);
|
|
6066
6354
|
const scrollingRef = useRef15(false);
|
|
6067
6355
|
const scrollTopMaxRef = useRef15(0);
|
|
@@ -6080,9 +6368,17 @@ var useOnContainerScroll = ({
|
|
|
6080
6368
|
timeoutIdRef.current = setTimeout(() => {
|
|
6081
6369
|
setScrolling(false);
|
|
6082
6370
|
timeoutIdRef.current = 0;
|
|
6083
|
-
},
|
|
6371
|
+
}, scrollStopDelay);
|
|
6084
6372
|
}
|
|
6085
6373
|
if (prevScrolling !== scrolling) {
|
|
6374
|
+
if (!scrolling) {
|
|
6375
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6376
|
+
onScrollStop({
|
|
6377
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6378
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6379
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6380
|
+
});
|
|
6381
|
+
}
|
|
6086
6382
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
6087
6383
|
if (!classList) {
|
|
6088
6384
|
return;
|
|
@@ -6093,7 +6389,7 @@ var useOnContainerScroll = ({
|
|
|
6093
6389
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
6094
6390
|
}
|
|
6095
6391
|
}
|
|
6096
|
-
}, []);
|
|
6392
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
6097
6393
|
const onContainerScroll = useCallback13((scrollInfo) => {
|
|
6098
6394
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6099
6395
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
@@ -6123,7 +6419,7 @@ var useOnContainerScroll = ({
|
|
|
6123
6419
|
if (isScrollBottom) {
|
|
6124
6420
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
6125
6421
|
if (getDataSourceState().livePagination) {
|
|
6126
|
-
dataSourceActions.
|
|
6422
|
+
dataSourceActions.cursorId = Date.now();
|
|
6127
6423
|
}
|
|
6128
6424
|
}
|
|
6129
6425
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -6136,7 +6432,7 @@ var useOnContainerScroll = ({
|
|
|
6136
6432
|
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6137
6433
|
import {
|
|
6138
6434
|
createElement as createElement29,
|
|
6139
|
-
useMemo as
|
|
6435
|
+
useMemo as useMemo8
|
|
6140
6436
|
} from "react";
|
|
6141
6437
|
import { useCallback as useCallback15 } from "react";
|
|
6142
6438
|
|
|
@@ -6242,7 +6538,7 @@ function PinnedRowsContainer(props) {
|
|
|
6242
6538
|
brain,
|
|
6243
6539
|
renderRow
|
|
6244
6540
|
} = props;
|
|
6245
|
-
const style =
|
|
6541
|
+
const style = useMemo8(() => {
|
|
6246
6542
|
const result = pinning === "end" ? {
|
|
6247
6543
|
width: rowWidth,
|
|
6248
6544
|
height,
|
|
@@ -6415,6 +6711,15 @@ function usePinnedStartRendering(params) {
|
|
|
6415
6711
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6416
6712
|
import { useEffect as useEffect21 } from "react";
|
|
6417
6713
|
|
|
6714
|
+
// src/components/hooks/useOnce.ts
|
|
6715
|
+
import { useMemo as useMemo9 } from "react";
|
|
6716
|
+
function useOnce(fn) {
|
|
6717
|
+
const onceFn = useMemo9(() => {
|
|
6718
|
+
return once(fn);
|
|
6719
|
+
}, []);
|
|
6720
|
+
return onceFn();
|
|
6721
|
+
}
|
|
6722
|
+
|
|
6418
6723
|
// src/components/VirtualBrain/index.ts
|
|
6419
6724
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6420
6725
|
var initialScrollPosition2 = {
|
|
@@ -7310,7 +7615,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7310
7615
|
const valid = useMemo11(() => {
|
|
7311
7616
|
let valid2 = isValidLicense(licenseKey, {
|
|
7312
7617
|
publishedAt: 1624970570587,
|
|
7313
|
-
version: "0.1.
|
|
7618
|
+
version: "0.1.3"
|
|
7314
7619
|
});
|
|
7315
7620
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7316
7621
|
return true;
|
|
@@ -7324,11 +7629,11 @@ var useLicense = (licenseKey = "") => {
|
|
|
7324
7629
|
import {
|
|
7325
7630
|
createElement as createElement31,
|
|
7326
7631
|
useCallback as useCallback19,
|
|
7327
|
-
useLayoutEffect as
|
|
7632
|
+
useLayoutEffect as useLayoutEffect4
|
|
7328
7633
|
} from "react";
|
|
7329
7634
|
import { useRef as useRef19 } from "react";
|
|
7330
7635
|
var error = err("CSSVariableWatch");
|
|
7331
|
-
var
|
|
7636
|
+
var debug5 = dbg("CSSVariableWatch");
|
|
7332
7637
|
var WRAPPER_STYLE = {
|
|
7333
7638
|
position: "absolute",
|
|
7334
7639
|
pointerEvents: "none",
|
|
@@ -7347,11 +7652,11 @@ var useCSSVariableWatch = (params) => {
|
|
|
7347
7652
|
}
|
|
7348
7653
|
}, [params.onChange]);
|
|
7349
7654
|
useResizeObserver(params.ref, onResize, { earlyAttach: true });
|
|
7350
|
-
|
|
7655
|
+
useLayoutEffect4(() => {
|
|
7351
7656
|
const value = params.ref.current.getBoundingClientRect().height;
|
|
7352
7657
|
if (value) {
|
|
7353
7658
|
lastValueRef.current = value;
|
|
7354
|
-
|
|
7659
|
+
debug5(`Variable ${params.varName} found and equals ${value}.`);
|
|
7355
7660
|
params.onChange(value);
|
|
7356
7661
|
} else {
|
|
7357
7662
|
error(`Specified variable ${params.varName} not found or does not have a numeric value.`);
|
|
@@ -7549,7 +7854,7 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7549
7854
|
const licenseValid = useLicense(licenseKey);
|
|
7550
7855
|
const domProps = useDOMProps(componentState.domProps);
|
|
7551
7856
|
const LoadMaskCmp = (_a = components == null ? void 0 : components.LoadMask) != null ? _a : LoadMask;
|
|
7552
|
-
|
|
7857
|
+
useLayoutEffect5(() => {
|
|
7553
7858
|
const dataSourceState = getDataSourceState();
|
|
7554
7859
|
const { onScrollbarsChange } = getInfiniteTableState();
|
|
7555
7860
|
const { notifyScrollbarsChange } = dataSourceState;
|