@infinite-table/infinite-react 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +5 -4
- package/index.d.ts +192 -106
- package/index.esm.css +5 -4
- package/index.esm.js +997 -650
- package/index.js +1026 -679
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -635,7 +635,8 @@ __export(exports, {
|
|
|
635
635
|
interceptMap: () => interceptMap,
|
|
636
636
|
multisort: () => multisort,
|
|
637
637
|
useComponentState: () => useComponentState,
|
|
638
|
-
useDataSource: () => useDataSource
|
|
638
|
+
useDataSource: () => useDataSource,
|
|
639
|
+
useEffectWithChanges: () => useEffectWithChanges
|
|
639
640
|
});
|
|
640
641
|
|
|
641
642
|
// src/components/InfiniteTable/index.tsx
|
|
@@ -720,14 +721,21 @@ var ScrollListener = class {
|
|
|
720
721
|
};
|
|
721
722
|
|
|
722
723
|
// src/components/InfiniteTable/utils/toMap.ts
|
|
723
|
-
function toMap(mapOrObject) {
|
|
724
|
+
function toMap(mapOrObject, weakMapCache) {
|
|
724
725
|
if (!mapOrObject) {
|
|
725
726
|
return new Map();
|
|
726
727
|
}
|
|
727
728
|
if (mapOrObject instanceof Map) {
|
|
728
729
|
return mapOrObject;
|
|
729
730
|
}
|
|
730
|
-
|
|
731
|
+
if (weakMapCache && weakMapCache.has(mapOrObject)) {
|
|
732
|
+
return weakMapCache.get(mapOrObject);
|
|
733
|
+
}
|
|
734
|
+
const result = new Map(Object.entries(mapOrObject));
|
|
735
|
+
if (weakMapCache) {
|
|
736
|
+
weakMapCache.set(mapOrObject, result);
|
|
737
|
+
}
|
|
738
|
+
return result;
|
|
731
739
|
}
|
|
732
740
|
|
|
733
741
|
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
@@ -753,12 +761,10 @@ function computeColumnGroupsDepths(columnGroups) {
|
|
|
753
761
|
}
|
|
754
762
|
|
|
755
763
|
// src/components/InfiniteTable/state/getInitialState.ts
|
|
756
|
-
function toColumnTypesMap(mapOrObject) {
|
|
757
|
-
return toMap(mapOrObject);
|
|
758
|
-
}
|
|
759
764
|
function initSetupState() {
|
|
760
765
|
const columnsGeneratedForGrouping = new Map();
|
|
761
766
|
return {
|
|
767
|
+
propsCache: new Map([]),
|
|
762
768
|
columnShifts: null,
|
|
763
769
|
domRef: (0, import_react2.createRef)(),
|
|
764
770
|
scrollerDOMRef: (0, import_react2.createRef)(),
|
|
@@ -783,12 +789,8 @@ function initSetupState() {
|
|
|
783
789
|
columnsWhenInlineGroupRenderStrategy: void 0
|
|
784
790
|
};
|
|
785
791
|
}
|
|
786
|
-
var forwardProps = () => {
|
|
792
|
+
var forwardProps = (setupState) => {
|
|
787
793
|
return {
|
|
788
|
-
columns: (columns) => {
|
|
789
|
-
var _a;
|
|
790
|
-
return (_a = toMap(columns)) != null ? _a : new Map();
|
|
791
|
-
},
|
|
792
794
|
scrollTopId: 1,
|
|
793
795
|
components: 1,
|
|
794
796
|
loadingText: 1,
|
|
@@ -806,6 +808,7 @@ var forwardProps = () => {
|
|
|
806
808
|
onBlurWithin: 1,
|
|
807
809
|
onScrollToTop: 1,
|
|
808
810
|
onScrollToBottom: 1,
|
|
811
|
+
onScrollStop: 1,
|
|
809
812
|
scrollToBottomOffset: 1,
|
|
810
813
|
rowStyle: 1,
|
|
811
814
|
rowProps: 1,
|
|
@@ -816,6 +819,7 @@ var forwardProps = () => {
|
|
|
816
819
|
pivotRowLabelsColumn: 1,
|
|
817
820
|
pivotColumnGroups: 1,
|
|
818
821
|
onScrollbarsChange: 1,
|
|
822
|
+
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
819
823
|
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
820
824
|
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
821
825
|
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
@@ -834,21 +838,13 @@ var forwardProps = () => {
|
|
|
834
838
|
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
835
839
|
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
836
840
|
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
columnSizing: (columnSizing) => {
|
|
843
|
-
var _a;
|
|
844
|
-
return (_a = toMap(columnSizing)) != null ? _a : new Map();
|
|
845
|
-
},
|
|
846
|
-
columnTypes: (columnTypes) => {
|
|
847
|
-
var _a;
|
|
848
|
-
return (_a = toColumnTypesMap(columnTypes)) != null ? _a : new Map();
|
|
849
|
-
},
|
|
841
|
+
columns: (columns) => toMap(columns, setupState.propsCache.get("columns")),
|
|
842
|
+
columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
|
|
843
|
+
columnPinning: (columnPinning) => toMap(columnPinning, setupState.propsCache.get("columnPinning")),
|
|
844
|
+
columnSizing: (columnSizing) => toMap(columnSizing, setupState.propsCache.get("columnSizing")),
|
|
845
|
+
columnTypes: (columnTypes) => toMap(columnTypes, setupState.propsCache.get("columnTypes")),
|
|
850
846
|
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
851
|
-
columnGroups: (columnGroups) => columnGroups
|
|
847
|
+
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
852
848
|
};
|
|
853
849
|
};
|
|
854
850
|
function getGroupRenderStrategy(options) {
|
|
@@ -1223,11 +1219,11 @@ function getColumnComputedType(column, columnTypes) {
|
|
|
1223
1219
|
// src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
|
|
1224
1220
|
var logError = err("getComputedVisibleColumns");
|
|
1225
1221
|
var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
|
|
1226
|
-
return
|
|
1222
|
+
return columnVisibility[colId] !== false;
|
|
1227
1223
|
};
|
|
1228
1224
|
var getComputedPinned = (colId, columnPinning) => {
|
|
1229
1225
|
const pinned = columnPinning.get(colId);
|
|
1230
|
-
const computedPinned = pinned === "start"
|
|
1226
|
+
const computedPinned = pinned === "start" ? "start" : pinned === "end" ? "end" : false;
|
|
1231
1227
|
return computedPinned;
|
|
1232
1228
|
};
|
|
1233
1229
|
var getComputedVisibleColumns = ({
|
|
@@ -1259,7 +1255,8 @@ var getComputedVisibleColumns = ({
|
|
|
1259
1255
|
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1260
1256
|
return false;
|
|
1261
1257
|
}
|
|
1262
|
-
|
|
1258
|
+
const result2 = isColumnVisible(columnVisibility, columnVisibilityAssumeVisible, colId);
|
|
1259
|
+
return result2;
|
|
1263
1260
|
});
|
|
1264
1261
|
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1265
1262
|
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
@@ -1285,10 +1282,13 @@ var getComputedVisibleColumns = ({
|
|
|
1285
1282
|
const colTypeSizing = {
|
|
1286
1283
|
minWidth: colType == null ? void 0 : colType.minWidth,
|
|
1287
1284
|
maxWidth: colType == null ? void 0 : colType.maxWidth,
|
|
1288
|
-
width: colType == null ? void 0 : colType.
|
|
1289
|
-
flex: colType == null ? void 0 : colType.
|
|
1285
|
+
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1286
|
+
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1287
|
+
};
|
|
1288
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1289
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1290
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1290
1291
|
};
|
|
1291
|
-
let colSizing = columnSizing.get(colId) || {};
|
|
1292
1292
|
if (colSizing.width != null) {
|
|
1293
1293
|
delete colTypeSizing.flex;
|
|
1294
1294
|
}
|
|
@@ -1339,7 +1339,7 @@ var getComputedVisibleColumns = ({
|
|
|
1339
1339
|
});
|
|
1340
1340
|
const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
|
|
1341
1341
|
columnsArray.forEach((c, i) => {
|
|
1342
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1342
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1343
1343
|
const id = visibleColumnOrder[i];
|
|
1344
1344
|
const nextColumnId = visibleColumnOrder[i + 1];
|
|
1345
1345
|
const colType = getColumnComputedType(c, columnTypes);
|
|
@@ -1400,6 +1400,7 @@ var getComputedVisibleColumns = ({
|
|
|
1400
1400
|
const result2 = __spreadProps(__spreadValues({
|
|
1401
1401
|
align: colType.align,
|
|
1402
1402
|
verticalAlign: colType.verticalAlign,
|
|
1403
|
+
valueGetter: colType.valueGetter,
|
|
1403
1404
|
renderValue: colType.renderValue,
|
|
1404
1405
|
render: colType.render
|
|
1405
1406
|
}, c), {
|
|
@@ -1407,7 +1408,7 @@ var getComputedVisibleColumns = ({
|
|
|
1407
1408
|
computedAbsoluteOffset,
|
|
1408
1409
|
computedPinningOffset,
|
|
1409
1410
|
computedOffset,
|
|
1410
|
-
computedSortable: (_e = (_d = c.sortable) != null ? _d : sortable) != null ? _e : true,
|
|
1411
|
+
computedSortable: (_f = (_e = (_d = c.sortable) != null ? _d : colType.sortable) != null ? _e : sortable) != null ? _f : true,
|
|
1411
1412
|
computedSortInfo,
|
|
1412
1413
|
computedSortIndex,
|
|
1413
1414
|
computedMultiSort: multiSort,
|
|
@@ -1416,14 +1417,14 @@ var getComputedVisibleColumns = ({
|
|
|
1416
1417
|
computedSortedDesc,
|
|
1417
1418
|
computedVisibleIndex: i,
|
|
1418
1419
|
computedPinned,
|
|
1419
|
-
computedDraggable: (
|
|
1420
|
+
computedDraggable: (_h = (_g = c.draggable) != null ? _g : draggableColumns) != null ? _h : true,
|
|
1420
1421
|
computedFirstInCategory,
|
|
1421
1422
|
computedLastInCategory,
|
|
1422
1423
|
computedFirst: i === 0,
|
|
1423
1424
|
computedLast,
|
|
1424
1425
|
toggleSort,
|
|
1425
1426
|
id,
|
|
1426
|
-
header: (
|
|
1427
|
+
header: (_k = (_j = (_i = c.header) != null ? _i : colType.header) != null ? _j : c.name) != null ? _k : c.field
|
|
1427
1428
|
});
|
|
1428
1429
|
computedOffset += computedWidth;
|
|
1429
1430
|
computedVisibleColumnsMap.set(result2.id, result2);
|
|
@@ -1574,7 +1575,6 @@ var useComputedVisibleColumns = ({
|
|
|
1574
1575
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1575
1576
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1576
1577
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1577
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1578
1578
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1579
1579
|
const {
|
|
1580
1580
|
computedRemainingSpace,
|
|
@@ -1630,7 +1630,6 @@ var useComputedVisibleColumns = ({
|
|
|
1630
1630
|
pinnedStartMaxWidth,
|
|
1631
1631
|
columnPinning,
|
|
1632
1632
|
columnsRenderId,
|
|
1633
|
-
visibilityRenderId,
|
|
1634
1633
|
columnsSizingRenderId,
|
|
1635
1634
|
pinningRenderId,
|
|
1636
1635
|
columnTypesRenderId
|
|
@@ -1655,11 +1654,11 @@ var useComputedVisibleColumns = ({
|
|
|
1655
1654
|
return result;
|
|
1656
1655
|
};
|
|
1657
1656
|
|
|
1658
|
-
// src/utils/sortAscending.ts
|
|
1657
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1659
1658
|
var sortAscending = (a, b) => a - b;
|
|
1660
1659
|
|
|
1661
1660
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
1662
|
-
var
|
|
1661
|
+
var import_react18 = __toModule(require("react"));
|
|
1663
1662
|
|
|
1664
1663
|
// src/components/hooks/useComponentState.tsx
|
|
1665
1664
|
var React2 = __toModule(require("react"));
|
|
@@ -1751,9 +1750,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1751
1750
|
if (currentValue === value) {
|
|
1752
1751
|
return;
|
|
1753
1752
|
}
|
|
1754
|
-
|
|
1753
|
+
let notifyTheChange = true;
|
|
1755
1754
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1756
|
-
interceptedActions[key](value, { actions, state: state2 })
|
|
1755
|
+
if (interceptedActions[key](value, { actions, state: state2 }) === false) {
|
|
1756
|
+
notifyTheChange = false;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (notifyTheChange) {
|
|
1760
|
+
notifyChange(props, stateKey, value);
|
|
1757
1761
|
}
|
|
1758
1762
|
const forwardFn = propsToForward[key];
|
|
1759
1763
|
if (typeof forwardFn === "function") {
|
|
@@ -1794,12 +1798,14 @@ function forwardProps2(propsToForward, props) {
|
|
|
1794
1798
|
function getComponentStateRoot(config) {
|
|
1795
1799
|
return React2.memo(function ComponentStateRoot(props) {
|
|
1796
1800
|
var _a, _b;
|
|
1801
|
+
const [initialSetupState] = (0, import_react11.useState)(() => {
|
|
1802
|
+
return config.initSetupState ? config.initSetupState() : {};
|
|
1803
|
+
});
|
|
1797
1804
|
const propsToStateSetRef = (0, import_react11.useRef)(new Set());
|
|
1798
|
-
const propsToForward = (0, import_react11.useMemo)(() => config.forwardProps ? config.forwardProps() : {}, []);
|
|
1805
|
+
const propsToForward = (0, import_react11.useMemo)(() => config.forwardProps ? config.forwardProps(initialSetupState) : {}, [initialSetupState]);
|
|
1799
1806
|
const parentState = (_b = (_a = config.getParentState) == null ? void 0 : _a.call(config)) != null ? _b : null;
|
|
1800
1807
|
const getParentState = useLatest(parentState);
|
|
1801
1808
|
const [wholeState] = (0, import_react11.useState)(() => {
|
|
1802
|
-
const initialSetupState = config.initSetupState ? config.initSetupState() : {};
|
|
1803
1809
|
let mappedState = {};
|
|
1804
1810
|
if (propsToForward) {
|
|
1805
1811
|
mappedState = forwardProps2(propsToForward, props);
|
|
@@ -1829,9 +1835,12 @@ function getComponentStateRoot(config) {
|
|
|
1829
1835
|
const getProps = useLatest(props);
|
|
1830
1836
|
const theReducer = (previousState, action) => {
|
|
1831
1837
|
var _a2;
|
|
1838
|
+
if (action.type === "REPLACE_STATE") {
|
|
1839
|
+
return action.payload;
|
|
1840
|
+
}
|
|
1832
1841
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1833
1842
|
const mappedState = action.payload.mappedState;
|
|
1834
|
-
const updatedProps = action.payload.
|
|
1843
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1835
1844
|
const newState = Object.assign({}, previousState);
|
|
1836
1845
|
if (mappedState) {
|
|
1837
1846
|
Object.assign(newState, mappedState);
|
|
@@ -1885,8 +1894,9 @@ function getComponentStateRoot(config) {
|
|
|
1885
1894
|
const currentProps = props;
|
|
1886
1895
|
const newMappedState = {};
|
|
1887
1896
|
let newMappedStateCount = 0;
|
|
1888
|
-
const
|
|
1889
|
-
let
|
|
1897
|
+
const updatedPropsToState = {};
|
|
1898
|
+
let updatedPropsToStateCount = 0;
|
|
1899
|
+
const rawUpdatedProps = {};
|
|
1890
1900
|
for (var k in props) {
|
|
1891
1901
|
const key = k;
|
|
1892
1902
|
const oldValue = prevProps[key];
|
|
@@ -1897,6 +1907,7 @@ function getComponentStateRoot(config) {
|
|
|
1897
1907
|
if (oldValue === newValue) {
|
|
1898
1908
|
continue;
|
|
1899
1909
|
}
|
|
1910
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1900
1911
|
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1901
1912
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1902
1913
|
let valueToSet = newValue;
|
|
@@ -1909,22 +1920,30 @@ function getComponentStateRoot(config) {
|
|
|
1909
1920
|
newMappedStateCount++;
|
|
1910
1921
|
}
|
|
1911
1922
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1912
|
-
|
|
1913
|
-
|
|
1923
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1924
|
+
updatedPropsToStateCount++;
|
|
1914
1925
|
}
|
|
1915
1926
|
}
|
|
1916
1927
|
}
|
|
1917
|
-
if (
|
|
1928
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1918
1929
|
debug2("Triggered by new values for the following props", ...[
|
|
1919
1930
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1920
|
-
...Object.keys(
|
|
1931
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1921
1932
|
]);
|
|
1922
|
-
|
|
1933
|
+
const action = {
|
|
1923
1934
|
payload: {
|
|
1924
1935
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1925
|
-
|
|
1936
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1926
1937
|
}
|
|
1927
|
-
}
|
|
1938
|
+
};
|
|
1939
|
+
dispatch(action);
|
|
1940
|
+
if (config.onPropChange) {
|
|
1941
|
+
for (var prop in rawUpdatedProps)
|
|
1942
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
1943
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
1944
|
+
config.onPropChange({ name: prop, newValue, oldValue }, props, actions);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1928
1947
|
}
|
|
1929
1948
|
});
|
|
1930
1949
|
return /* @__PURE__ */ React2.createElement(Context.Provider, {
|
|
@@ -1992,35 +2011,38 @@ function useColumnGroups() {
|
|
|
1992
2011
|
return interceptMap(collapsedColumnGroups, {
|
|
1993
2012
|
set: (key, visibleCol) => {
|
|
1994
2013
|
const colIds = key.slice(1);
|
|
1995
|
-
const
|
|
2014
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
1996
2015
|
colIds.forEach((colId) => {
|
|
1997
|
-
columnVisibility
|
|
2016
|
+
columnVisibility[colId] = false;
|
|
1998
2017
|
});
|
|
1999
|
-
columnVisibility
|
|
2018
|
+
delete columnVisibility[visibleCol];
|
|
2019
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2000
2020
|
},
|
|
2001
2021
|
beforeClear: (currentCollapsedGroups) => {
|
|
2002
|
-
const
|
|
2022
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2003
2023
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2004
2024
|
keys.forEach((key) => {
|
|
2005
2025
|
const colIds = key.slice(1);
|
|
2006
2026
|
colIds.forEach((colId) => {
|
|
2007
|
-
columnVisibility
|
|
2027
|
+
delete columnVisibility[colId];
|
|
2008
2028
|
});
|
|
2009
2029
|
});
|
|
2030
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2010
2031
|
},
|
|
2011
2032
|
delete: (key) => {
|
|
2012
|
-
const
|
|
2033
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2013
2034
|
const colIds = key.slice(1);
|
|
2014
2035
|
colIds.forEach((colId) => {
|
|
2015
|
-
columnVisibility
|
|
2036
|
+
delete columnVisibility[colId];
|
|
2016
2037
|
});
|
|
2038
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2017
2039
|
}
|
|
2018
2040
|
});
|
|
2019
2041
|
}, [collapsedColumnGroups]);
|
|
2020
2042
|
}
|
|
2021
2043
|
|
|
2022
2044
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
2023
|
-
var
|
|
2045
|
+
var import_react17 = __toModule(require("react"));
|
|
2024
2046
|
|
|
2025
2047
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2026
2048
|
var React6 = __toModule(require("react"));
|
|
@@ -2275,7 +2297,7 @@ function getSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps) {
|
|
|
2275
2297
|
}
|
|
2276
2298
|
|
|
2277
2299
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
2278
|
-
var
|
|
2300
|
+
var import_react16 = __toModule(require("react"));
|
|
2279
2301
|
|
|
2280
2302
|
// src/components/DataSource/index.tsx
|
|
2281
2303
|
var React8 = __toModule(require("react"));
|
|
@@ -2357,164 +2379,7 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2357
2379
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2358
2380
|
var import_react15 = __toModule(require("react"));
|
|
2359
2381
|
|
|
2360
|
-
// src/
|
|
2361
|
-
var import_react14 = __toModule(require("react"));
|
|
2362
|
-
function useEffectWithChanges(fn, deps) {
|
|
2363
|
-
const prevRef = (0, import_react14.useRef)({});
|
|
2364
|
-
const oldValuesRef = (0, import_react14.useRef)({});
|
|
2365
|
-
const oldValues = oldValuesRef.current;
|
|
2366
|
-
const changesRef = (0, import_react14.useRef)({});
|
|
2367
|
-
const changes = changesRef.current;
|
|
2368
|
-
const useEffectDeps = [];
|
|
2369
|
-
for (let k in deps) {
|
|
2370
|
-
if (deps.hasOwnProperty(k)) {
|
|
2371
|
-
if (deps[k] !== prevRef.current[k]) {
|
|
2372
|
-
changes[k] = deps[k];
|
|
2373
|
-
oldValues[k] = prevRef.current[k];
|
|
2374
|
-
}
|
|
2375
|
-
useEffectDeps.push(deps[k]);
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
prevRef.current = deps;
|
|
2379
|
-
(0, import_react14.useEffect)(() => {
|
|
2380
|
-
const changes2 = changesRef.current;
|
|
2381
|
-
const result = fn(changes2, oldValues);
|
|
2382
|
-
changesRef.current = {};
|
|
2383
|
-
oldValuesRef.current = {};
|
|
2384
|
-
return result;
|
|
2385
|
-
}, useEffectDeps);
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2389
|
-
function buildDataSourceDataParams(componentState) {
|
|
2390
|
-
var _a, _b;
|
|
2391
|
-
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
2392
|
-
const dataSourceParams = {
|
|
2393
|
-
originalDataArray: componentState.originalDataArray,
|
|
2394
|
-
sortInfo,
|
|
2395
|
-
groupBy: componentState.groupBy,
|
|
2396
|
-
pivotBy: componentState.pivotBy
|
|
2397
|
-
};
|
|
2398
|
-
if (componentState.livePagination !== void 0) {
|
|
2399
|
-
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2400
|
-
}
|
|
2401
|
-
return dataSourceParams;
|
|
2402
|
-
}
|
|
2403
|
-
function notifyDataParamsChanged(componentState, actions) {
|
|
2404
|
-
var _a;
|
|
2405
|
-
if (typeof componentState.data === "function") {
|
|
2406
|
-
loadData(componentState.data, componentState, actions);
|
|
2407
|
-
}
|
|
2408
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2409
|
-
(_a = componentState.onDataParamsChange) == null ? void 0 : _a.call(componentState, dataParams);
|
|
2410
|
-
}
|
|
2411
|
-
function loadData(data, componentState, actions) {
|
|
2412
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2413
|
-
if (typeof data === "function") {
|
|
2414
|
-
data = data(dataParams);
|
|
2415
|
-
}
|
|
2416
|
-
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
2417
|
-
if (dataIsPromise) {
|
|
2418
|
-
actions.loading = true;
|
|
2419
|
-
}
|
|
2420
|
-
Promise.resolve(data).then((dataParam) => {
|
|
2421
|
-
let dataArray = [];
|
|
2422
|
-
if (Array.isArray(dataParam.data)) {
|
|
2423
|
-
const remoteData = dataParam;
|
|
2424
|
-
dataArray = remoteData.data;
|
|
2425
|
-
if (remoteData.livePaginationCursor !== void 0) {
|
|
2426
|
-
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
2427
|
-
}
|
|
2428
|
-
} else {
|
|
2429
|
-
dataArray = dataParam;
|
|
2430
|
-
}
|
|
2431
|
-
actions.originalDataArray = dataArray;
|
|
2432
|
-
if (dataIsPromise) {
|
|
2433
|
-
actions.loading = false;
|
|
2434
|
-
}
|
|
2435
|
-
});
|
|
2436
|
-
}
|
|
2437
|
-
function useLoadData() {
|
|
2438
|
-
const {
|
|
2439
|
-
getComponentState,
|
|
2440
|
-
componentActions: actions,
|
|
2441
|
-
componentState: { data }
|
|
2442
|
-
} = useComponentState();
|
|
2443
|
-
(0, import_react15.useLayoutEffect)(() => {
|
|
2444
|
-
loadData(data, getComponentState(), actions);
|
|
2445
|
-
}, [data]);
|
|
2446
|
-
useLivePagination();
|
|
2447
|
-
}
|
|
2448
|
-
function useLivePagination() {
|
|
2449
|
-
const {
|
|
2450
|
-
getComponentState,
|
|
2451
|
-
componentActions: actions,
|
|
2452
|
-
componentState
|
|
2453
|
-
} = useComponentState();
|
|
2454
|
-
const {
|
|
2455
|
-
notifyScrollbarsChange,
|
|
2456
|
-
sortInfo,
|
|
2457
|
-
groupBy,
|
|
2458
|
-
pivotBy,
|
|
2459
|
-
livePaginationCursor,
|
|
2460
|
-
scrollBottomId
|
|
2461
|
-
} = componentState;
|
|
2462
|
-
const [scrollbars, setScrollbars] = (0, import_react15.useState)({
|
|
2463
|
-
vertical: false,
|
|
2464
|
-
horizontal: false
|
|
2465
|
-
});
|
|
2466
|
-
const scrollbarsRef = (0, import_react15.useRef)(scrollbars);
|
|
2467
|
-
(0, import_react15.useEffect)(() => {
|
|
2468
|
-
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
2469
|
-
if (!scrollbars2) {
|
|
2470
|
-
return;
|
|
2471
|
-
}
|
|
2472
|
-
scrollbarsRef.current = scrollbars2;
|
|
2473
|
-
setScrollbars(scrollbars2);
|
|
2474
|
-
});
|
|
2475
|
-
return () => notifyScrollbarsChange.destroy();
|
|
2476
|
-
}, [notifyScrollbarsChange]);
|
|
2477
|
-
const [cursorId, updateCursorId] = (0, import_react15.useState)(void 0);
|
|
2478
|
-
(0, import_react15.useEffect)(() => {
|
|
2479
|
-
const frameId = requestAnimationFrame(() => {
|
|
2480
|
-
var _a;
|
|
2481
|
-
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical)) {
|
|
2482
|
-
updateCursorId(livePaginationCursor);
|
|
2483
|
-
}
|
|
2484
|
-
});
|
|
2485
|
-
return () => cancelAnimationFrame(frameId);
|
|
2486
|
-
}, [livePaginationCursor]);
|
|
2487
|
-
(0, import_react15.useEffect)(() => {
|
|
2488
|
-
const { livePaginationCursor: livePaginationCursor2, livePagination } = getComponentState();
|
|
2489
|
-
if (!scrollbars.vertical && livePagination) {
|
|
2490
|
-
updateCursorId(livePaginationCursor2);
|
|
2491
|
-
}
|
|
2492
|
-
}, [scrollbars.vertical]);
|
|
2493
|
-
(0, import_react15.useEffect)(() => {
|
|
2494
|
-
updateCursorId(scrollBottomId);
|
|
2495
|
-
}, [scrollBottomId]);
|
|
2496
|
-
const depsObject = {
|
|
2497
|
-
sortInfo,
|
|
2498
|
-
groupBy,
|
|
2499
|
-
pivotBy,
|
|
2500
|
-
cursorId
|
|
2501
|
-
};
|
|
2502
|
-
useEffectWithChanges(() => {
|
|
2503
|
-
if (cursorId === void 0) {
|
|
2504
|
-
return;
|
|
2505
|
-
}
|
|
2506
|
-
notifyDataParamsChanged(getComponentState(), actions);
|
|
2507
|
-
}, depsObject);
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
2511
|
-
var normalizeSortInfo = (sortInfo) => {
|
|
2512
|
-
sortInfo = sortInfo != null ? sortInfo : [];
|
|
2513
|
-
return Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
2514
|
-
};
|
|
2515
|
-
|
|
2516
|
-
// src/components/hooks/useOnce.ts
|
|
2517
|
-
var import_react16 = __toModule(require("react"));
|
|
2382
|
+
// src/utils/DeepMap/once.ts
|
|
2518
2383
|
function once(fn) {
|
|
2519
2384
|
let called = false;
|
|
2520
2385
|
let result = null;
|
|
@@ -2528,14 +2393,8 @@ function once(fn) {
|
|
|
2528
2393
|
};
|
|
2529
2394
|
return onceFn;
|
|
2530
2395
|
}
|
|
2531
|
-
function useOnce(fn) {
|
|
2532
|
-
const onceFn = (0, import_react16.useMemo)(() => {
|
|
2533
|
-
return once(fn);
|
|
2534
|
-
}, []);
|
|
2535
|
-
return onceFn();
|
|
2536
|
-
}
|
|
2537
2396
|
|
|
2538
|
-
// src/utils/DeepMap.ts
|
|
2397
|
+
// src/utils/DeepMap/index.ts
|
|
2539
2398
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2540
2399
|
var DeepMap = class {
|
|
2541
2400
|
constructor(initial) {
|
|
@@ -2787,76 +2646,667 @@ var DeepMap = class {
|
|
|
2787
2646
|
}
|
|
2788
2647
|
};
|
|
2789
2648
|
|
|
2790
|
-
// src/
|
|
2791
|
-
var
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
return {
|
|
2798
|
-
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
2799
|
-
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
2800
|
-
};
|
|
2801
|
-
}
|
|
2802
|
-
destroy() {
|
|
2803
|
-
var _a, _b;
|
|
2804
|
-
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
2805
|
-
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
2806
|
-
delete this.expandedMap;
|
|
2807
|
-
delete this.collapsedMap;
|
|
2649
|
+
// src/utils/groupAndPivot/index.ts
|
|
2650
|
+
var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
|
|
2651
|
+
function DEFAULT_TO_KEY(value) {
|
|
2652
|
+
return value;
|
|
2653
|
+
}
|
|
2654
|
+
function initReducers(reducers) {
|
|
2655
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2656
|
+
return {};
|
|
2808
2657
|
}
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
this.collapsedAll = collapsedRows === true;
|
|
2814
|
-
this.expandedAll = expandedRows === true;
|
|
2815
|
-
if (this.collapsedAll && this.expandedAll) {
|
|
2816
|
-
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
2817
|
-
}
|
|
2818
|
-
if (collapsedRows !== true) {
|
|
2819
|
-
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
2820
|
-
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
2821
|
-
}
|
|
2822
|
-
if (expandedRows !== true) {
|
|
2823
|
-
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
2824
|
-
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
2658
|
+
const result = {};
|
|
2659
|
+
for (let key in reducers)
|
|
2660
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2661
|
+
result[key] = reducers[key].initialValue;
|
|
2825
2662
|
}
|
|
2663
|
+
return result;
|
|
2664
|
+
}
|
|
2665
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
2666
|
+
var _a, _b;
|
|
2667
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2668
|
+
return;
|
|
2826
2669
|
}
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
}
|
|
2833
|
-
collapseAll() {
|
|
2834
|
-
this.update({
|
|
2835
|
-
collapsedRows: true,
|
|
2836
|
-
expandedRows: []
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
expandAll() {
|
|
2840
|
-
this.update({
|
|
2841
|
-
expandedRows: true,
|
|
2842
|
-
collapsedRows: []
|
|
2843
|
-
});
|
|
2844
|
-
}
|
|
2845
|
-
isGroupRowExpanded(keys) {
|
|
2846
|
-
var _a, _b;
|
|
2847
|
-
if (this.expandedAll === true) {
|
|
2848
|
-
if (this.collapsedAll === true) {
|
|
2849
|
-
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
2670
|
+
for (let key in reducers)
|
|
2671
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2672
|
+
const reducer = reducers[key];
|
|
2673
|
+
if (typeof reducer.reducer !== "function") {
|
|
2674
|
+
continue;
|
|
2850
2675
|
}
|
|
2851
|
-
|
|
2676
|
+
const currentValue = reducerResults[key];
|
|
2677
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
2678
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
2852
2679
|
}
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2680
|
+
}
|
|
2681
|
+
function lazyGroup(groupParams, rootData) {
|
|
2682
|
+
const {
|
|
2683
|
+
reducers = {},
|
|
2684
|
+
pivot,
|
|
2685
|
+
groupBy,
|
|
2686
|
+
mappings
|
|
2687
|
+
} = groupParams;
|
|
2688
|
+
const deepMap = new DeepMap();
|
|
2689
|
+
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
2690
|
+
const last = pivotIndex === pivot2.length - 1;
|
|
2691
|
+
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
2692
|
+
for (var k in values)
|
|
2693
|
+
if (values.hasOwnProperty(k)) {
|
|
2694
|
+
const pivotKey = k;
|
|
2695
|
+
currentPivotKeys2.push(pivotKey);
|
|
2696
|
+
topLevelPivotColumns.set(currentPivotKeys2, true);
|
|
2697
|
+
pivotDeepMap.set(currentPivotKeys2, {
|
|
2698
|
+
reducerResults: values[k][(mappings == null ? void 0 : mappings.totals) || "totals"] || {},
|
|
2699
|
+
items: []
|
|
2700
|
+
});
|
|
2701
|
+
if (!last) {
|
|
2702
|
+
traverseValues(pivotDeepMap, values[k], pivot2, pivotIndex + 1, currentPivotKeys2);
|
|
2703
|
+
}
|
|
2704
|
+
currentPivotKeys2.pop();
|
|
2705
|
+
}
|
|
2857
2706
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2707
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2708
|
+
let currentPivotKeys = [];
|
|
2709
|
+
const initialReducerValue = initReducers(reducers);
|
|
2710
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2711
|
+
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2712
|
+
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2713
|
+
const dataArray = lazyGroupRowInfo.items;
|
|
2714
|
+
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2715
|
+
if (!dataArray[i]) {
|
|
2716
|
+
const deepMapGroupValue2 = {
|
|
2717
|
+
items: [],
|
|
2718
|
+
reducerResults: {}
|
|
2719
|
+
};
|
|
2720
|
+
deepMap.set([...currentGroupKeys, `not-loaded-yet-${i}`], deepMapGroupValue2);
|
|
2721
|
+
continue;
|
|
2722
|
+
}
|
|
2723
|
+
const dataObject = dataArray[i].data;
|
|
2724
|
+
const dataKeys = dataArray[i].keys;
|
|
2725
|
+
let item = dataObject;
|
|
2726
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
2727
|
+
const key = item[groupByProperty];
|
|
2728
|
+
currentGroupKeys.push(key);
|
|
2729
|
+
const deepMapGroupValue = {
|
|
2730
|
+
items: [],
|
|
2731
|
+
reducerResults: dataArray[i].aggregations || {}
|
|
2732
|
+
};
|
|
2733
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2734
|
+
if (pivot) {
|
|
2735
|
+
const pivotDeepMap = deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2736
|
+
const pivotContainer = dataArray[i].pivot;
|
|
2737
|
+
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
2738
|
+
}
|
|
2739
|
+
currentGroupKeys.pop();
|
|
2740
|
+
}
|
|
2741
|
+
next == null ? void 0 : next();
|
|
2742
|
+
});
|
|
2743
|
+
const result = {
|
|
2744
|
+
deepMap,
|
|
2745
|
+
groupParams,
|
|
2746
|
+
initialData: rootData,
|
|
2747
|
+
reducerResults: globalReducerResults
|
|
2748
|
+
};
|
|
2749
|
+
if (pivot) {
|
|
2750
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2751
|
+
result.pivot = pivot;
|
|
2752
|
+
}
|
|
2753
|
+
return result;
|
|
2754
|
+
}
|
|
2755
|
+
function group(groupParams, data) {
|
|
2756
|
+
const {
|
|
2757
|
+
groupBy,
|
|
2758
|
+
defaultToKey = DEFAULT_TO_KEY,
|
|
2759
|
+
pivot,
|
|
2760
|
+
reducers
|
|
2761
|
+
} = groupParams;
|
|
2762
|
+
const groupByLength = groupBy.length;
|
|
2763
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2764
|
+
const deepMap = new DeepMap();
|
|
2765
|
+
let currentGroupKeys = [];
|
|
2766
|
+
let currentPivotKeys = [];
|
|
2767
|
+
const initialReducerValue = initReducers(reducers);
|
|
2768
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2769
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
2770
|
+
let item = data[i];
|
|
2771
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
2772
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
2773
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
2774
|
+
currentGroupKeys.push(key);
|
|
2775
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
2776
|
+
const deepMapGroupValue = {
|
|
2777
|
+
items: [],
|
|
2778
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
2779
|
+
};
|
|
2780
|
+
if (pivot) {
|
|
2781
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2782
|
+
}
|
|
2783
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2784
|
+
}
|
|
2785
|
+
const {
|
|
2786
|
+
items: currentGroupItems,
|
|
2787
|
+
reducerResults,
|
|
2788
|
+
pivotDeepMap
|
|
2789
|
+
} = deepMap.get(currentGroupKeys);
|
|
2790
|
+
currentGroupItems.push(item);
|
|
2791
|
+
if (reducers) {
|
|
2792
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
2793
|
+
}
|
|
2794
|
+
if (pivot) {
|
|
2795
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
2796
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
2797
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
2798
|
+
currentPivotKeys.push(pivotKey);
|
|
2799
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
2800
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
2801
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
2802
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
2803
|
+
items: []
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
const {
|
|
2807
|
+
reducerResults: pivotReducerResults,
|
|
2808
|
+
items: pivotGroupItems
|
|
2809
|
+
} = pivotDeepMap.get(currentPivotKeys);
|
|
2810
|
+
pivotGroupItems.push(item);
|
|
2811
|
+
if (reducers) {
|
|
2812
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
currentPivotKeys.length = 0;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
if (reducers) {
|
|
2819
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
2820
|
+
}
|
|
2821
|
+
currentGroupKeys.length = 0;
|
|
2822
|
+
}
|
|
2823
|
+
if (reducers) {
|
|
2824
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
2825
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
2826
|
+
if (pivot) {
|
|
2827
|
+
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
2828
|
+
completeReducers(reducers, pivotReducerResults, items);
|
|
2829
|
+
next2 == null ? void 0 : next2();
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
next == null ? void 0 : next();
|
|
2833
|
+
});
|
|
2834
|
+
}
|
|
2835
|
+
if (reducers) {
|
|
2836
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
2837
|
+
}
|
|
2838
|
+
const result = {
|
|
2839
|
+
deepMap,
|
|
2840
|
+
groupParams,
|
|
2841
|
+
initialData: data,
|
|
2842
|
+
reducerResults: globalReducerResults
|
|
2843
|
+
};
|
|
2844
|
+
if (pivot) {
|
|
2845
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2846
|
+
result.pivot = pivot;
|
|
2847
|
+
}
|
|
2848
|
+
return result;
|
|
2849
|
+
}
|
|
2850
|
+
function flatten(groupResult) {
|
|
2851
|
+
const { groupParams, deepMap } = groupResult;
|
|
2852
|
+
const groupByLength = groupParams.groupBy.length;
|
|
2853
|
+
const result = [];
|
|
2854
|
+
deepMap.topDownKeys().reduce((acc, key) => {
|
|
2855
|
+
if (key.length === groupByLength) {
|
|
2856
|
+
const items = deepMap.get(key).items;
|
|
2857
|
+
acc.push(...items);
|
|
2858
|
+
}
|
|
2859
|
+
return acc;
|
|
2860
|
+
}, result);
|
|
2861
|
+
return result;
|
|
2862
|
+
}
|
|
2863
|
+
function getEnhancedGroupData(options, deepMapValue) {
|
|
2864
|
+
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2865
|
+
const groupNesting = groupKeys.length;
|
|
2866
|
+
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
2867
|
+
let data = null;
|
|
2868
|
+
if (Object.keys(reducerResults).length > 0) {
|
|
2869
|
+
data = {};
|
|
2870
|
+
for (let key in reducers)
|
|
2871
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2872
|
+
const reducer = reducers[key];
|
|
2873
|
+
const field = reducer.field;
|
|
2874
|
+
if (field) {
|
|
2875
|
+
data[field] = reducerResults[key];
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
const enhancedGroupData = {
|
|
2880
|
+
data,
|
|
2881
|
+
groupCount: groupItems.length,
|
|
2882
|
+
groupData: groupItems,
|
|
2883
|
+
groupKeys,
|
|
2884
|
+
id: groupKeys,
|
|
2885
|
+
collapsed,
|
|
2886
|
+
parents,
|
|
2887
|
+
collapsedChildrenCount: 0,
|
|
2888
|
+
collapsedGroupsCount: 0,
|
|
2889
|
+
indexInParentGroups: options.indexInParentGroups,
|
|
2890
|
+
indexInGroup: options.indexInGroup,
|
|
2891
|
+
indexInAll: options.indexInAll,
|
|
2892
|
+
value: groupKeys[groupKeys.length - 1],
|
|
2893
|
+
groupBy: groupBy.slice(0, groupNesting),
|
|
2894
|
+
isGroupRow: true,
|
|
2895
|
+
pivotValuesMap: pivotDeepMap,
|
|
2896
|
+
groupNesting,
|
|
2897
|
+
reducerResults
|
|
2898
|
+
};
|
|
2899
|
+
return enhancedGroupData;
|
|
2900
|
+
}
|
|
2901
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
2902
|
+
if (reducers) {
|
|
2903
|
+
for (let key in reducers)
|
|
2904
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2905
|
+
const reducer = reducers[key];
|
|
2906
|
+
if (reducer.done) {
|
|
2907
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
return reducerResults;
|
|
2912
|
+
}
|
|
2913
|
+
function enhancedFlatten(param) {
|
|
2914
|
+
const {
|
|
2915
|
+
groupResult,
|
|
2916
|
+
toPrimaryKey,
|
|
2917
|
+
groupRowsState,
|
|
2918
|
+
generateGroupRows,
|
|
2919
|
+
reducers = {}
|
|
2920
|
+
} = param;
|
|
2921
|
+
const { groupParams, deepMap, pivot } = groupResult;
|
|
2922
|
+
const { groupBy } = groupParams;
|
|
2923
|
+
const groupByStrings = groupBy.map((g) => g.field);
|
|
2924
|
+
const result = [];
|
|
2925
|
+
const parents = [];
|
|
2926
|
+
const indexInParentGroups = [];
|
|
2927
|
+
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
2928
|
+
var _a;
|
|
2929
|
+
const items = deepMapValue.items;
|
|
2930
|
+
const groupNesting = groupKeys.length;
|
|
2931
|
+
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
2932
|
+
const enhancedGroupData = getEnhancedGroupData({
|
|
2933
|
+
groupBy: groupByStrings,
|
|
2934
|
+
parents: Array.from(parents),
|
|
2935
|
+
reducers,
|
|
2936
|
+
indexInGroup,
|
|
2937
|
+
indexInParentGroups: Array.from(indexInParentGroups),
|
|
2938
|
+
indexInAll: result.length,
|
|
2939
|
+
groupKeys,
|
|
2940
|
+
collapsed
|
|
2941
|
+
}, deepMapValue);
|
|
2942
|
+
const include = generateGroupRows || collapsed;
|
|
2943
|
+
if (include) {
|
|
2944
|
+
result.push(enhancedGroupData);
|
|
2945
|
+
}
|
|
2946
|
+
if (collapsed) {
|
|
2947
|
+
parents.forEach((parent) => {
|
|
2948
|
+
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
2949
|
+
parent.collapsedGroupsCount += 1;
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2952
|
+
indexInParentGroups.push(indexInGroup);
|
|
2953
|
+
parents.push(enhancedGroupData);
|
|
2954
|
+
if (!collapsed) {
|
|
2955
|
+
if (!next) {
|
|
2956
|
+
if (!pivot) {
|
|
2957
|
+
const startIndex = result.length;
|
|
2958
|
+
result.push(...items.map((item, index) => {
|
|
2959
|
+
return {
|
|
2960
|
+
id: toPrimaryKey(item),
|
|
2961
|
+
data: item,
|
|
2962
|
+
isGroupRow: false,
|
|
2963
|
+
collapsed: false,
|
|
2964
|
+
groupKeys,
|
|
2965
|
+
parents: Array.from(parents),
|
|
2966
|
+
indexInParentGroups: [...indexInParentGroups, index],
|
|
2967
|
+
indexInGroup: index,
|
|
2968
|
+
indexInAll: startIndex + index,
|
|
2969
|
+
groupBy: groupByStrings,
|
|
2970
|
+
groupNesting,
|
|
2971
|
+
groupCount: enhancedGroupData.groupCount
|
|
2972
|
+
};
|
|
2973
|
+
}));
|
|
2974
|
+
}
|
|
2975
|
+
} else {
|
|
2976
|
+
next();
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
parents.pop();
|
|
2980
|
+
indexInParentGroups.pop();
|
|
2981
|
+
});
|
|
2982
|
+
return {
|
|
2983
|
+
data: result
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
// src/components/hooks/useEffectWithChanges.ts
|
|
2988
|
+
var import_react14 = __toModule(require("react"));
|
|
2989
|
+
function useEffectWithChanges(fn, deps) {
|
|
2990
|
+
const prevRef = (0, import_react14.useRef)({});
|
|
2991
|
+
const oldValuesRef = (0, import_react14.useRef)({});
|
|
2992
|
+
const oldValues = oldValuesRef.current;
|
|
2993
|
+
const changesRef = (0, import_react14.useRef)({});
|
|
2994
|
+
const changes = changesRef.current;
|
|
2995
|
+
const useEffectDeps = [];
|
|
2996
|
+
for (let k in deps) {
|
|
2997
|
+
if (deps.hasOwnProperty(k)) {
|
|
2998
|
+
if (deps[k] !== prevRef.current[k]) {
|
|
2999
|
+
changes[k] = deps[k];
|
|
3000
|
+
oldValues[k] = prevRef.current[k];
|
|
3001
|
+
}
|
|
3002
|
+
useEffectDeps.push(deps[k]);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
prevRef.current = deps;
|
|
3006
|
+
(0, import_react14.useEffect)(() => {
|
|
3007
|
+
const changes2 = changesRef.current;
|
|
3008
|
+
const result = fn(changes2, oldValues);
|
|
3009
|
+
changesRef.current = {};
|
|
3010
|
+
oldValuesRef.current = {};
|
|
3011
|
+
return result;
|
|
3012
|
+
}, useEffectDeps);
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
3016
|
+
var SKIP_DATA_CHANGES_KEYS = {
|
|
3017
|
+
originalDataArray: true,
|
|
3018
|
+
changes: true
|
|
3019
|
+
};
|
|
3020
|
+
function buildDataSourceDataParams(componentState, overrides) {
|
|
3021
|
+
var _a, _b;
|
|
3022
|
+
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
3023
|
+
const dataSourceParams = {
|
|
3024
|
+
originalDataArray: componentState.originalDataArray,
|
|
3025
|
+
sortInfo,
|
|
3026
|
+
groupBy: componentState.groupBy,
|
|
3027
|
+
pivotBy: componentState.pivotBy,
|
|
3028
|
+
aggregationReducers: componentState.aggregationReducers
|
|
3029
|
+
};
|
|
3030
|
+
if (componentState.livePagination !== void 0) {
|
|
3031
|
+
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3032
|
+
dataSourceParams.cursorId = componentState.cursorId;
|
|
3033
|
+
}
|
|
3034
|
+
if (componentState.fullLazyLoad) {
|
|
3035
|
+
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3036
|
+
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3037
|
+
dataSourceParams.lazyLoadStartIndex = 0;
|
|
3038
|
+
}
|
|
3039
|
+
dataSourceParams.groupKeys = [];
|
|
3040
|
+
}
|
|
3041
|
+
if (overrides) {
|
|
3042
|
+
Object.assign(dataSourceParams, overrides);
|
|
3043
|
+
}
|
|
3044
|
+
const changes = {};
|
|
3045
|
+
const oldDataSourceParams = componentState.dataParams || {};
|
|
3046
|
+
for (let k in dataSourceParams) {
|
|
3047
|
+
if (dataSourceParams.hasOwnProperty(k) && !SKIP_DATA_CHANGES_KEYS[k]) {
|
|
3048
|
+
const key = k;
|
|
3049
|
+
if (dataSourceParams[key] !== oldDataSourceParams[key]) {
|
|
3050
|
+
changes[key] = true;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
dataSourceParams.changes = changes;
|
|
3055
|
+
return dataSourceParams;
|
|
3056
|
+
}
|
|
3057
|
+
function loadData(data, componentState, actions, overrides) {
|
|
3058
|
+
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3059
|
+
if (typeof data === "function") {
|
|
3060
|
+
data = data(dataParams);
|
|
3061
|
+
}
|
|
3062
|
+
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3063
|
+
if (dataIsPromise) {
|
|
3064
|
+
actions.loading = true;
|
|
3065
|
+
}
|
|
3066
|
+
Promise.resolve(data).then((dataParam) => {
|
|
3067
|
+
var _a, _b, _c;
|
|
3068
|
+
let dataArray = [];
|
|
3069
|
+
let skipAssign = false;
|
|
3070
|
+
if (Array.isArray(dataParam.data)) {
|
|
3071
|
+
const remoteData = dataParam;
|
|
3072
|
+
dataArray = remoteData.data;
|
|
3073
|
+
if (remoteData.livePaginationCursor !== void 0) {
|
|
3074
|
+
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
3075
|
+
}
|
|
3076
|
+
if (remoteData.mappings) {
|
|
3077
|
+
actions.pivotMappings = remoteData.mappings;
|
|
3078
|
+
}
|
|
3079
|
+
if (componentState.fullLazyLoad && dataParams.groupKeys) {
|
|
3080
|
+
const lazyGroupData = DeepMap.clone(componentState.originalLazyGroupData);
|
|
3081
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3082
|
+
const newGroupRowInfo = {
|
|
3083
|
+
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
3084
|
+
items: dataArray
|
|
3085
|
+
};
|
|
3086
|
+
if (dataParams.lazyLoadBatchSize) {
|
|
3087
|
+
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3088
|
+
const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
|
|
3089
|
+
items: [],
|
|
3090
|
+
totalCount: newGroupRowInfo.totalCount
|
|
3091
|
+
};
|
|
3092
|
+
currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
|
|
3093
|
+
const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
|
|
3094
|
+
const end = start + ((_c = dataParams.lazyLoadBatchSize) != null ? _c : dataArray.length);
|
|
3095
|
+
for (let i = start; i < end; i++) {
|
|
3096
|
+
currentGroupRowInfo.items[i] = newGroupRowInfo.items[i - start];
|
|
3097
|
+
}
|
|
3098
|
+
if (!existingGroupRowInfo) {
|
|
3099
|
+
lazyGroupData.set(key, currentGroupRowInfo);
|
|
3100
|
+
}
|
|
3101
|
+
} else {
|
|
3102
|
+
lazyGroupData.set(key, newGroupRowInfo);
|
|
3103
|
+
}
|
|
3104
|
+
skipAssign = true;
|
|
3105
|
+
actions.originalLazyGroupData = lazyGroupData;
|
|
3106
|
+
}
|
|
3107
|
+
} else {
|
|
3108
|
+
dataArray = dataParam;
|
|
3109
|
+
}
|
|
3110
|
+
if (!skipAssign) {
|
|
3111
|
+
actions.originalDataArray = dataArray;
|
|
3112
|
+
}
|
|
3113
|
+
if (dataIsPromise) {
|
|
3114
|
+
actions.loading = false;
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
}
|
|
3118
|
+
function useLoadData() {
|
|
3119
|
+
const {
|
|
3120
|
+
getComponentState,
|
|
3121
|
+
componentActions: actions,
|
|
3122
|
+
componentState
|
|
3123
|
+
} = useComponentState();
|
|
3124
|
+
const {
|
|
3125
|
+
data,
|
|
3126
|
+
notifyScrollbarsChange,
|
|
3127
|
+
sortInfo,
|
|
3128
|
+
groupBy,
|
|
3129
|
+
pivotBy,
|
|
3130
|
+
livePagination,
|
|
3131
|
+
livePaginationCursor,
|
|
3132
|
+
cursorId: stateCursorId,
|
|
3133
|
+
lazyLoadBatchSize,
|
|
3134
|
+
notifyScrollStop
|
|
3135
|
+
} = componentState;
|
|
3136
|
+
const [scrollbars, setScrollbars] = (0, import_react15.useState)({
|
|
3137
|
+
vertical: false,
|
|
3138
|
+
horizontal: false
|
|
3139
|
+
});
|
|
3140
|
+
const scrollbarsRef = (0, import_react15.useRef)(scrollbars);
|
|
3141
|
+
(0, import_react15.useEffect)(() => {
|
|
3142
|
+
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
3143
|
+
if (!scrollbars2) {
|
|
3144
|
+
return;
|
|
3145
|
+
}
|
|
3146
|
+
scrollbarsRef.current = scrollbars2;
|
|
3147
|
+
setScrollbars(scrollbars2);
|
|
3148
|
+
});
|
|
3149
|
+
return () => notifyScrollbarsChange.destroy();
|
|
3150
|
+
}, [notifyScrollbarsChange]);
|
|
3151
|
+
(0, import_react15.useEffect)(() => {
|
|
3152
|
+
const frameId = requestAnimationFrame(() => {
|
|
3153
|
+
var _a;
|
|
3154
|
+
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical) && livePaginationCursor) {
|
|
3155
|
+
actions.cursorId = livePaginationCursor;
|
|
3156
|
+
}
|
|
3157
|
+
});
|
|
3158
|
+
return () => cancelAnimationFrame(frameId);
|
|
3159
|
+
}, [livePaginationCursor]);
|
|
3160
|
+
(0, import_react15.useEffect)(() => {
|
|
3161
|
+
const { livePaginationCursor: livePaginationCursor2, livePagination: livePagination2 } = getComponentState();
|
|
3162
|
+
if (!scrollbars.vertical && livePagination2) {
|
|
3163
|
+
if (livePaginationCursor2) {
|
|
3164
|
+
actions.cursorId = livePaginationCursor2;
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
}, [scrollbars.vertical]);
|
|
3168
|
+
const depsObject = {
|
|
3169
|
+
sortInfo,
|
|
3170
|
+
groupBy,
|
|
3171
|
+
pivotBy,
|
|
3172
|
+
cursorId: livePagination ? stateCursorId : null
|
|
3173
|
+
};
|
|
3174
|
+
const initialRef = (0, import_react15.useRef)(true);
|
|
3175
|
+
(0, import_react15.useEffect)(() => {
|
|
3176
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3177
|
+
return notifyScrollStop.onChange((param) => {
|
|
3178
|
+
console.log("scroll stop", param);
|
|
3179
|
+
if (!param) {
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3182
|
+
const componentState2 = getComponentState();
|
|
3183
|
+
const {
|
|
3184
|
+
firstVisibleRowIndex: startIndex,
|
|
3185
|
+
lastVisibleRowIndex: endIndex
|
|
3186
|
+
} = param;
|
|
3187
|
+
const firstBatchStart = Math.floor(startIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3188
|
+
const lastBatchStart = Math.floor(endIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3189
|
+
const isRowLoaded = (index) => componentState2.dataArray[index].data != null;
|
|
3190
|
+
for (let batchStartIndex = firstBatchStart; batchStartIndex <= lastBatchStart; batchStartIndex = batchStartIndex + lazyLoadBatchSize) {
|
|
3191
|
+
if (!isRowLoaded(batchStartIndex)) {
|
|
3192
|
+
loadData(componentState2.data, componentState2, actions, {
|
|
3193
|
+
lazyLoadBatchSize,
|
|
3194
|
+
lazyLoadStartIndex: batchStartIndex
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
return;
|
|
3201
|
+
}, [lazyLoadBatchSize]);
|
|
3202
|
+
useEffectWithChanges(() => {
|
|
3203
|
+
const componentState2 = getComponentState();
|
|
3204
|
+
if (typeof componentState2.data !== "function") {
|
|
3205
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3206
|
+
}
|
|
3207
|
+
}, { data });
|
|
3208
|
+
useEffectWithChanges(() => {
|
|
3209
|
+
const componentState2 = getComponentState();
|
|
3210
|
+
if (typeof componentState2.data === "function") {
|
|
3211
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3212
|
+
}
|
|
3213
|
+
}, __spreadProps(__spreadValues({}, depsObject), { data }));
|
|
3214
|
+
useEffectWithChanges((_changes, _prevValues) => {
|
|
3215
|
+
const componentState2 = getComponentState();
|
|
3216
|
+
if (initialRef.current) {
|
|
3217
|
+
initialRef.current = false;
|
|
3218
|
+
actions.dataParams = buildDataSourceDataParams(componentState2);
|
|
3219
|
+
}
|
|
3220
|
+
}, depsObject);
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
3224
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
3225
|
+
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
3226
|
+
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
3227
|
+
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
3228
|
+
if (weakMap && weakMap.has(sortInfo)) {
|
|
3229
|
+
const prevResult = weakMap.get(sortInfo);
|
|
3230
|
+
if (prevResult && prevResult.length === result.length) {
|
|
3231
|
+
return prevResult;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
if (weakMap && sortInfo) {
|
|
3235
|
+
weakMap.set(sortInfo, result);
|
|
3236
|
+
}
|
|
3237
|
+
return result;
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
// src/components/DataSource/GroupRowsState.ts
|
|
3241
|
+
var GroupRowsState = class {
|
|
3242
|
+
constructor(state) {
|
|
3243
|
+
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
3244
|
+
}
|
|
3245
|
+
getState() {
|
|
3246
|
+
var _a, _b, _c, _d;
|
|
3247
|
+
return {
|
|
3248
|
+
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
3249
|
+
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
3250
|
+
};
|
|
3251
|
+
}
|
|
3252
|
+
destroy() {
|
|
3253
|
+
var _a, _b;
|
|
3254
|
+
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
3255
|
+
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
3256
|
+
delete this.expandedMap;
|
|
3257
|
+
delete this.collapsedMap;
|
|
3258
|
+
}
|
|
3259
|
+
update(state) {
|
|
3260
|
+
var _a, _b, _c, _d;
|
|
3261
|
+
this.initialState = state;
|
|
3262
|
+
const { collapsedRows, expandedRows } = this.initialState;
|
|
3263
|
+
this.collapsedAll = collapsedRows === true;
|
|
3264
|
+
this.expandedAll = expandedRows === true;
|
|
3265
|
+
if (this.collapsedAll && this.expandedAll) {
|
|
3266
|
+
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
3267
|
+
}
|
|
3268
|
+
if (collapsedRows !== true) {
|
|
3269
|
+
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
3270
|
+
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
3271
|
+
}
|
|
3272
|
+
if (expandedRows !== true) {
|
|
3273
|
+
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
3274
|
+
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
areAllCollapsed() {
|
|
3278
|
+
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
3279
|
+
}
|
|
3280
|
+
areAllExpanded() {
|
|
3281
|
+
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
3282
|
+
}
|
|
3283
|
+
collapseAll() {
|
|
3284
|
+
this.update({
|
|
3285
|
+
collapsedRows: true,
|
|
3286
|
+
expandedRows: []
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
expandAll() {
|
|
3290
|
+
this.update({
|
|
3291
|
+
expandedRows: true,
|
|
3292
|
+
collapsedRows: []
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
isGroupRowExpanded(keys) {
|
|
3296
|
+
var _a, _b;
|
|
3297
|
+
if (this.expandedAll === true) {
|
|
3298
|
+
if (this.collapsedAll === true) {
|
|
3299
|
+
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
3300
|
+
}
|
|
3301
|
+
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
3302
|
+
}
|
|
3303
|
+
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
3304
|
+
}
|
|
3305
|
+
isGroupRowCollapsed(keys) {
|
|
3306
|
+
return !this.isGroupRowExpanded(keys);
|
|
3307
|
+
}
|
|
3308
|
+
setGroupRowExpanded(keys, shouldExpand) {
|
|
3309
|
+
var _a;
|
|
2860
3310
|
if (shouldExpand === this.isGroupRowExpanded(keys)) {
|
|
2861
3311
|
return;
|
|
2862
3312
|
}
|
|
@@ -2898,7 +3348,7 @@ var GroupRowsState = class {
|
|
|
2898
3348
|
};
|
|
2899
3349
|
|
|
2900
3350
|
// src/utils/shallowEqualObjects.ts
|
|
2901
|
-
function shallowEqualObjects(objA, objB) {
|
|
3351
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
2902
3352
|
if (objA === objB) {
|
|
2903
3353
|
return true;
|
|
2904
3354
|
}
|
|
@@ -2907,12 +3357,21 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2907
3357
|
}
|
|
2908
3358
|
var aKeys = Object.keys(objA);
|
|
2909
3359
|
var bKeys = Object.keys(objB);
|
|
3360
|
+
if (ignoreKeys) {
|
|
3361
|
+
aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3362
|
+
bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3363
|
+
}
|
|
2910
3364
|
var len = aKeys.length;
|
|
2911
3365
|
if (bKeys.length !== len) {
|
|
2912
3366
|
return false;
|
|
2913
3367
|
}
|
|
2914
3368
|
for (var i = 0; i < len; i++) {
|
|
2915
3369
|
var key = aKeys[i];
|
|
3370
|
+
if (ignoreKeys) {
|
|
3371
|
+
if (ignoreKeys.has(key)) {
|
|
3372
|
+
continue;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
2916
3375
|
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2917
3376
|
return false;
|
|
2918
3377
|
}
|
|
@@ -2923,12 +3382,12 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2923
3382
|
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2924
3383
|
var map = new WeakMap();
|
|
2925
3384
|
var getCompareDefault = (a) => a;
|
|
2926
|
-
function discardCallsWithEqualArg(fn, timeframe = 50,
|
|
3385
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
2927
3386
|
map.set(fn, {
|
|
2928
3387
|
lastCallTime: 0,
|
|
2929
3388
|
lastCallArg: null
|
|
2930
3389
|
});
|
|
2931
|
-
const getCompare =
|
|
3390
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
2932
3391
|
return (arg) => {
|
|
2933
3392
|
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2934
3393
|
lastCallTime: 0,
|
|
@@ -2949,17 +3408,25 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
|
2949
3408
|
}
|
|
2950
3409
|
|
|
2951
3410
|
// src/components/DataSource/state/getInitialState.ts
|
|
3411
|
+
var defaultCursorId = Symbol("cursorId");
|
|
2952
3412
|
function initSetupState2() {
|
|
2953
3413
|
const now = Date.now();
|
|
2954
3414
|
const originalDataArray = [];
|
|
2955
3415
|
const dataArray = [];
|
|
3416
|
+
const originalLazyGroupData = new DeepMap();
|
|
2956
3417
|
return {
|
|
2957
3418
|
dataParams: void 0,
|
|
2958
3419
|
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3420
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
2959
3421
|
pivotTotalColumnPosition: "end",
|
|
3422
|
+
originalLazyGroupData,
|
|
2960
3423
|
originalDataArray,
|
|
2961
|
-
|
|
3424
|
+
cursorId: defaultCursorId,
|
|
2962
3425
|
showSeparatePivotColumnForSingleAggregation: false,
|
|
3426
|
+
propsCache: new Map([
|
|
3427
|
+
["sortInfo", new WeakMap()]
|
|
3428
|
+
]),
|
|
3429
|
+
pivotMappings: void 0,
|
|
2963
3430
|
pivotColumns: void 0,
|
|
2964
3431
|
pivotColumnGroups: void 0,
|
|
2965
3432
|
dataArray,
|
|
@@ -2975,22 +3442,24 @@ function initSetupState2() {
|
|
|
2975
3442
|
lastGroupDataArray: void 0
|
|
2976
3443
|
};
|
|
2977
3444
|
}
|
|
2978
|
-
function
|
|
3445
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
2979
3446
|
const obj = __spreadValues({}, dataParams);
|
|
2980
3447
|
delete obj.originalDataArray;
|
|
2981
3448
|
return obj;
|
|
2982
3449
|
}
|
|
2983
|
-
var forwardProps3 = () => {
|
|
3450
|
+
var forwardProps3 = (setupState) => {
|
|
2984
3451
|
return {
|
|
2985
|
-
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100,
|
|
3452
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3453
|
+
fullLazyLoad: 1,
|
|
2986
3454
|
data: 1,
|
|
2987
3455
|
pivotBy: 1,
|
|
2988
3456
|
primaryKey: 1,
|
|
2989
3457
|
livePagination: 1,
|
|
2990
|
-
|
|
3458
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
2991
3459
|
aggregationReducers: 1,
|
|
3460
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
2992
3461
|
loading: (loading) => loading != null ? loading : false,
|
|
2993
|
-
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo),
|
|
3462
|
+
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
2994
3463
|
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
2995
3464
|
groupRowsState: (groupRowsState) => {
|
|
2996
3465
|
return groupRowsState || new GroupRowsState({
|
|
@@ -3000,288 +3469,111 @@ var forwardProps3 = () => {
|
|
|
3000
3469
|
}
|
|
3001
3470
|
};
|
|
3002
3471
|
};
|
|
3003
|
-
function
|
|
3004
|
-
const
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
}
|
|
3011
|
-
function getInterceptActions() {
|
|
3012
|
-
return {
|
|
3013
|
-
sortInfo: (sortInfo, { actions, state }) => {
|
|
3014
|
-
const dataParams = buildDataSourceDataParams(state);
|
|
3015
|
-
dataParams.sortInfo = sortInfo;
|
|
3016
|
-
actions.dataParams = dataParams;
|
|
3017
|
-
}
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
|
|
3021
|
-
// src/utils/groupAndPivot/index.ts
|
|
3022
|
-
function DEFAULT_TO_KEY(value) {
|
|
3023
|
-
return value;
|
|
3024
|
-
}
|
|
3025
|
-
function initReducers(reducers) {
|
|
3026
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3027
|
-
return {};
|
|
3028
|
-
}
|
|
3029
|
-
const result = {};
|
|
3030
|
-
for (let key in reducers)
|
|
3031
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3032
|
-
result[key] = reducers[key].initialValue;
|
|
3033
|
-
}
|
|
3034
|
-
return result;
|
|
3035
|
-
}
|
|
3036
|
-
function computeReducersFor(data, reducers, reducerResults) {
|
|
3037
|
-
var _a, _b;
|
|
3038
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3039
|
-
return;
|
|
3040
|
-
}
|
|
3041
|
-
for (let key in reducers)
|
|
3042
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3043
|
-
const reducer = reducers[key];
|
|
3044
|
-
const currentValue = reducerResults[key];
|
|
3045
|
-
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
3046
|
-
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
3047
|
-
}
|
|
3472
|
+
function getLivePaginationCursorValue(livePaginationCursorProp, state) {
|
|
3473
|
+
const livePaginationCursor = typeof livePaginationCursorProp === "function" ? livePaginationCursorProp({
|
|
3474
|
+
array: state.originalDataArray,
|
|
3475
|
+
length: state.originalDataArray.length,
|
|
3476
|
+
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3477
|
+
}) : livePaginationCursorProp;
|
|
3478
|
+
return livePaginationCursor;
|
|
3048
3479
|
}
|
|
3049
|
-
function
|
|
3050
|
-
const {
|
|
3051
|
-
|
|
3052
|
-
defaultToKey = DEFAULT_TO_KEY,
|
|
3053
|
-
pivot,
|
|
3054
|
-
reducers
|
|
3055
|
-
} = groupParams;
|
|
3056
|
-
const groupByLength = groupBy.length;
|
|
3057
|
-
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3058
|
-
const deepMap = new DeepMap();
|
|
3059
|
-
let currentGroupKeys = [];
|
|
3060
|
-
let currentPivotKeys = [];
|
|
3061
|
-
const initialReducerValue = initReducers(reducers);
|
|
3062
|
-
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3063
|
-
for (let i = 0, len = data.length; i < len; i++) {
|
|
3064
|
-
let item = data[i];
|
|
3065
|
-
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
3066
|
-
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
3067
|
-
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
3068
|
-
currentGroupKeys.push(key);
|
|
3069
|
-
if (!deepMap.has(currentGroupKeys)) {
|
|
3070
|
-
const deepMapGroupValue = {
|
|
3071
|
-
items: [],
|
|
3072
|
-
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3073
|
-
};
|
|
3074
|
-
if (pivot) {
|
|
3075
|
-
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3076
|
-
}
|
|
3077
|
-
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3078
|
-
}
|
|
3079
|
-
const {
|
|
3080
|
-
items: currentGroupItems,
|
|
3081
|
-
reducerResults,
|
|
3082
|
-
pivotDeepMap
|
|
3083
|
-
} = deepMap.get(currentGroupKeys);
|
|
3084
|
-
currentGroupItems.push(item);
|
|
3085
|
-
if (reducers) {
|
|
3086
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3087
|
-
}
|
|
3088
|
-
if (pivot) {
|
|
3089
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3090
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3091
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3092
|
-
currentPivotKeys.push(pivotKey);
|
|
3093
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3094
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3095
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3096
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3097
|
-
items: []
|
|
3098
|
-
});
|
|
3099
|
-
}
|
|
3100
|
-
const {
|
|
3101
|
-
reducerResults: pivotReducerResults,
|
|
3102
|
-
items: pivotGroupItems
|
|
3103
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3104
|
-
pivotGroupItems.push(item);
|
|
3105
|
-
if (reducers) {
|
|
3106
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3107
|
-
}
|
|
3108
|
-
}
|
|
3109
|
-
currentPivotKeys.length = 0;
|
|
3110
|
-
}
|
|
3111
|
-
}
|
|
3112
|
-
if (reducers) {
|
|
3113
|
-
computeReducersFor(item, reducers, globalReducerResults);
|
|
3114
|
-
}
|
|
3115
|
-
currentGroupKeys.length = 0;
|
|
3116
|
-
}
|
|
3117
|
-
if (reducers) {
|
|
3118
|
-
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
3119
|
-
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
3120
|
-
if (pivot) {
|
|
3121
|
-
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
3122
|
-
completeReducers(reducers, pivotReducerResults, items);
|
|
3123
|
-
next2 == null ? void 0 : next2();
|
|
3124
|
-
});
|
|
3125
|
-
}
|
|
3126
|
-
next == null ? void 0 : next();
|
|
3127
|
-
});
|
|
3128
|
-
}
|
|
3129
|
-
if (reducers) {
|
|
3130
|
-
completeReducers(reducers, globalReducerResults, data);
|
|
3131
|
-
}
|
|
3480
|
+
function mapPropsToState2(params) {
|
|
3481
|
+
const { props, state, oldState } = params;
|
|
3482
|
+
const controlledSort = isControlledValue(props.sortInfo);
|
|
3132
3483
|
const result = {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
initialData: data,
|
|
3136
|
-
reducerResults: globalReducerResults
|
|
3484
|
+
controlledSort,
|
|
3485
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3137
3486
|
};
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3140
|
-
|
|
3487
|
+
if (props.livePagination) {
|
|
3488
|
+
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
3489
|
+
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? dataArrayChanged ? getLivePaginationCursorValue(props.livePaginationCursor, state) : state.livePaginationCursor : props.livePaginationCursor;
|
|
3490
|
+
result.livePaginationCursor = livePaginationCursor;
|
|
3141
3491
|
}
|
|
3142
3492
|
return result;
|
|
3143
3493
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
const
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3494
|
+
var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
3495
|
+
function onPropChange(params, props, actions) {
|
|
3496
|
+
const { name, newValue } = params;
|
|
3497
|
+
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3498
|
+
if (props.fullLazyLoad) {
|
|
3499
|
+
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3500
|
+
}
|
|
3501
|
+
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
3502
|
+
actions.groupRowsState = new GroupRowsState({
|
|
3503
|
+
collapsedRows: true,
|
|
3504
|
+
expandedRows: []
|
|
3505
|
+
});
|
|
3152
3506
|
}
|
|
3153
|
-
return acc;
|
|
3154
|
-
}, result);
|
|
3155
|
-
return result;
|
|
3156
|
-
}
|
|
3157
|
-
function getEnhancedGroupData(options, deepMapValue) {
|
|
3158
|
-
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
3159
|
-
const groupNesting = groupKeys.length;
|
|
3160
|
-
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
3161
|
-
let data = null;
|
|
3162
|
-
if (Object.keys(reducerResults).length > 0) {
|
|
3163
|
-
data = {};
|
|
3164
|
-
for (let key in reducers)
|
|
3165
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3166
|
-
const reducer = reducers[key];
|
|
3167
|
-
const field = reducer.field;
|
|
3168
|
-
if (field) {
|
|
3169
|
-
data[field] = reducerResults[key];
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
3507
|
}
|
|
3173
|
-
const enhancedGroupData = {
|
|
3174
|
-
data,
|
|
3175
|
-
groupCount: groupItems.length,
|
|
3176
|
-
groupData: groupItems,
|
|
3177
|
-
groupKeys,
|
|
3178
|
-
id: groupKeys,
|
|
3179
|
-
collapsed,
|
|
3180
|
-
parents,
|
|
3181
|
-
collapsedChildrenCount: 0,
|
|
3182
|
-
collapsedGroupsCount: 0,
|
|
3183
|
-
indexInParentGroups: options.indexInParentGroups,
|
|
3184
|
-
indexInGroup: options.indexInGroup,
|
|
3185
|
-
indexInAll: options.indexInAll,
|
|
3186
|
-
value: groupKeys[groupKeys.length - 1],
|
|
3187
|
-
groupBy: groupBy.slice(0, groupNesting),
|
|
3188
|
-
isGroupRow: true,
|
|
3189
|
-
pivotValuesMap: pivotDeepMap,
|
|
3190
|
-
groupNesting,
|
|
3191
|
-
reducerResults
|
|
3192
|
-
};
|
|
3193
|
-
return enhancedGroupData;
|
|
3194
3508
|
}
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3509
|
+
var debugDataParams = dbg("DataSource:dataParams");
|
|
3510
|
+
function getInterceptActions() {
|
|
3511
|
+
return {
|
|
3512
|
+
sortInfo: (sortInfo, { actions, state }) => {
|
|
3513
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3514
|
+
sortInfo,
|
|
3515
|
+
livePaginationCursor: null
|
|
3516
|
+
});
|
|
3517
|
+
actions.dataParams = dataParams;
|
|
3518
|
+
if (state.livePagination) {
|
|
3519
|
+
requestAnimationFrame(() => {
|
|
3520
|
+
actions.livePaginationCursor = null;
|
|
3521
|
+
});
|
|
3203
3522
|
}
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
groupResult,
|
|
3210
|
-
toPrimaryKey,
|
|
3211
|
-
groupRowsState,
|
|
3212
|
-
generateGroupRows,
|
|
3213
|
-
reducers = {}
|
|
3214
|
-
} = param;
|
|
3215
|
-
const { groupParams, deepMap, pivot } = groupResult;
|
|
3216
|
-
const { groupBy } = groupParams;
|
|
3217
|
-
const groupByStrings = groupBy.map((g) => g.field);
|
|
3218
|
-
const result = [];
|
|
3219
|
-
const parents = [];
|
|
3220
|
-
const indexInParentGroups = [];
|
|
3221
|
-
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
3222
|
-
var _a;
|
|
3223
|
-
const items = deepMapValue.items;
|
|
3224
|
-
const groupNesting = groupKeys.length;
|
|
3225
|
-
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
3226
|
-
const enhancedGroupData = getEnhancedGroupData({
|
|
3227
|
-
groupBy: groupByStrings,
|
|
3228
|
-
parents: Array.from(parents),
|
|
3229
|
-
reducers,
|
|
3230
|
-
indexInGroup,
|
|
3231
|
-
indexInParentGroups: Array.from(indexInParentGroups),
|
|
3232
|
-
indexInAll: result.length,
|
|
3233
|
-
groupKeys,
|
|
3234
|
-
collapsed
|
|
3235
|
-
}, deepMapValue);
|
|
3236
|
-
const include = generateGroupRows || collapsed;
|
|
3237
|
-
if (include) {
|
|
3238
|
-
result.push(enhancedGroupData);
|
|
3239
|
-
}
|
|
3240
|
-
if (collapsed) {
|
|
3241
|
-
parents.forEach((parent) => {
|
|
3242
|
-
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
3243
|
-
parent.collapsedGroupsCount += 1;
|
|
3523
|
+
},
|
|
3524
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3525
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3526
|
+
groupBy,
|
|
3527
|
+
livePaginationCursor: null
|
|
3244
3528
|
});
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3529
|
+
actions.dataParams = dataParams;
|
|
3530
|
+
if (state.livePagination) {
|
|
3531
|
+
requestAnimationFrame(() => {
|
|
3532
|
+
actions.livePaginationCursor = null;
|
|
3533
|
+
});
|
|
3534
|
+
}
|
|
3535
|
+
},
|
|
3536
|
+
pivotBy: (pivotBy, { actions, state }) => {
|
|
3537
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3538
|
+
pivotBy,
|
|
3539
|
+
livePaginationCursor: null
|
|
3540
|
+
});
|
|
3541
|
+
actions.dataParams = dataParams;
|
|
3542
|
+
if (state.livePagination) {
|
|
3543
|
+
requestAnimationFrame(() => {
|
|
3544
|
+
actions.livePaginationCursor = null;
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
cursorId: (cursorId, { actions, state }) => {
|
|
3549
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3550
|
+
cursorId
|
|
3551
|
+
});
|
|
3552
|
+
actions.dataParams = dataParams;
|
|
3553
|
+
},
|
|
3554
|
+
livePaginationCursor: (livePaginationCursor, { actions, state }) => {
|
|
3555
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3556
|
+
livePaginationCursor
|
|
3557
|
+
});
|
|
3558
|
+
actions.dataParams = dataParams;
|
|
3559
|
+
},
|
|
3560
|
+
dataParams: (dataParams, { state }) => {
|
|
3561
|
+
if (shallowEqualObjects(dataParams, state.dataParams, new Set([
|
|
3562
|
+
"changes",
|
|
3563
|
+
"originalDataArray"
|
|
3564
|
+
]))) {
|
|
3565
|
+
return false;
|
|
3271
3566
|
}
|
|
3567
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3568
|
+
return true;
|
|
3272
3569
|
}
|
|
3273
|
-
parents.pop();
|
|
3274
|
-
indexInParentGroups.pop();
|
|
3275
|
-
});
|
|
3276
|
-
return {
|
|
3277
|
-
data: result
|
|
3278
3570
|
};
|
|
3279
3571
|
}
|
|
3280
3572
|
|
|
3281
3573
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3282
3574
|
function prepareColumn(column) {
|
|
3283
3575
|
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3284
|
-
if (pivotByForColumn.column) {
|
|
3576
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3285
3577
|
if (typeof pivotByForColumn.column === "function") {
|
|
3286
3578
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3287
3579
|
} else {
|
|
@@ -3292,7 +3584,7 @@ function prepareColumn(column) {
|
|
|
3292
3584
|
}
|
|
3293
3585
|
function prepareColumnGroup(columnGroup) {
|
|
3294
3586
|
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3295
|
-
if (pivotByForColumnGroup.columnGroup) {
|
|
3587
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3296
3588
|
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3297
3589
|
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3298
3590
|
} else {
|
|
@@ -3321,6 +3613,9 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3321
3613
|
valueGetter: (params) => {
|
|
3322
3614
|
var _a;
|
|
3323
3615
|
const { rowInfo } = params;
|
|
3616
|
+
if (!rowInfo.data) {
|
|
3617
|
+
return "Loading ... TODO replace this with a loading indicator";
|
|
3618
|
+
}
|
|
3324
3619
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3325
3620
|
}
|
|
3326
3621
|
}
|
|
@@ -3352,7 +3647,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3352
3647
|
}));
|
|
3353
3648
|
}
|
|
3354
3649
|
aggregationReducers.forEach((reducer, index) => {
|
|
3355
|
-
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.id;
|
|
3650
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3356
3651
|
const computedPivotColumn = prepareColumn({
|
|
3357
3652
|
pivotBy,
|
|
3358
3653
|
pivotColumn: true,
|
|
@@ -3371,7 +3666,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3371
3666
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3372
3667
|
}
|
|
3373
3668
|
});
|
|
3374
|
-
const columnId = `${keys.join("/")}
|
|
3669
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3375
3670
|
columns.set(columnId, computedPivotColumn);
|
|
3376
3671
|
});
|
|
3377
3672
|
} else {
|
|
@@ -3404,7 +3699,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3404
3699
|
}));
|
|
3405
3700
|
}
|
|
3406
3701
|
aggregationReducers.forEach((reducer, index) => {
|
|
3407
|
-
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.id} total`;
|
|
3702
|
+
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.name || reducer.id} total`;
|
|
3408
3703
|
const computedPivotColumn = prepareColumn({
|
|
3409
3704
|
columnGroup: columnGroupId,
|
|
3410
3705
|
header,
|
|
@@ -3423,7 +3718,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3423
3718
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3424
3719
|
}
|
|
3425
3720
|
});
|
|
3426
|
-
columns.set(`total:${keys.join("/")}
|
|
3721
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3427
3722
|
});
|
|
3428
3723
|
}
|
|
3429
3724
|
}
|
|
@@ -3432,15 +3727,22 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3432
3727
|
}
|
|
3433
3728
|
});
|
|
3434
3729
|
if (columns.size === 1) {
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3730
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3731
|
+
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
3732
|
+
header: `${reducer.name || reducer.id} total`,
|
|
3733
|
+
pivotBy,
|
|
3734
|
+
pivotColumn: true,
|
|
3735
|
+
pivotTotalColumn: true,
|
|
3736
|
+
pivotAggregator: reducer,
|
|
3737
|
+
pivotAggregatorIndex: index,
|
|
3738
|
+
pivotGroupKeys: [],
|
|
3739
|
+
pivotGroupKey: "",
|
|
3740
|
+
pivotIndex: -1,
|
|
3741
|
+
valueGetter: ({ rowInfo }) => {
|
|
3742
|
+
var _a;
|
|
3743
|
+
return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
|
|
3744
|
+
}
|
|
3745
|
+
}));
|
|
3444
3746
|
});
|
|
3445
3747
|
}
|
|
3446
3748
|
const result = {
|
|
@@ -3477,10 +3779,11 @@ function concludeReducer(params) {
|
|
|
3477
3779
|
const { state, previousState } = params;
|
|
3478
3780
|
const sortInfo = state.sortInfo;
|
|
3479
3781
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3480
|
-
const
|
|
3481
|
-
"originalDataArray"
|
|
3482
|
-
"sortInfo"
|
|
3782
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3783
|
+
"originalDataArray"
|
|
3483
3784
|
]);
|
|
3785
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3786
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3484
3787
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3485
3788
|
const groupBy = state.groupBy;
|
|
3486
3789
|
const pivotBy = state.pivotBy;
|
|
@@ -3488,6 +3791,7 @@ function concludeReducer(params) {
|
|
|
3488
3791
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3489
3792
|
"generateGroupRows",
|
|
3490
3793
|
"originalDataArray",
|
|
3794
|
+
"originalLazyGroupData",
|
|
3491
3795
|
"groupBy",
|
|
3492
3796
|
"groupRowsState",
|
|
3493
3797
|
"pivotBy",
|
|
@@ -3512,7 +3816,12 @@ function concludeReducer(params) {
|
|
|
3512
3816
|
};
|
|
3513
3817
|
if (shouldGroup) {
|
|
3514
3818
|
if (shouldGroupAgain) {
|
|
3515
|
-
const groupResult =
|
|
3819
|
+
const groupResult = state.fullLazyLoad ? lazyGroup({
|
|
3820
|
+
groupBy,
|
|
3821
|
+
pivot: pivotBy,
|
|
3822
|
+
mappings: state.pivotMappings,
|
|
3823
|
+
reducers: state.aggregationReducers
|
|
3824
|
+
}, state.originalLazyGroupData) : group({
|
|
3516
3825
|
groupBy,
|
|
3517
3826
|
pivot: pivotBy,
|
|
3518
3827
|
reducers: state.aggregationReducers
|
|
@@ -3580,6 +3889,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3580
3889
|
forwardProps: forwardProps3,
|
|
3581
3890
|
concludeReducer,
|
|
3582
3891
|
mapPropsToState: mapPropsToState2,
|
|
3892
|
+
onPropChange,
|
|
3583
3893
|
interceptActions: getInterceptActions()
|
|
3584
3894
|
});
|
|
3585
3895
|
function DataSourceCmp({ children }) {
|
|
@@ -3610,17 +3920,23 @@ function DataSource(props) {
|
|
|
3610
3920
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
3611
3921
|
function useToggleGroupRow() {
|
|
3612
3922
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3613
|
-
const toggleGroupRow = (0,
|
|
3614
|
-
const
|
|
3923
|
+
const toggleGroupRow = (0, import_react16.useCallback)((groupKeys) => {
|
|
3924
|
+
const state = getDataSourceState();
|
|
3925
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3615
3926
|
newState.toggleGroupRow(groupKeys);
|
|
3616
3927
|
dataSourceActions.groupRowsState = newState;
|
|
3928
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
3929
|
+
loadData(state.data, state, dataSourceActions, {
|
|
3930
|
+
groupKeys
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3617
3933
|
}, []);
|
|
3618
3934
|
return toggleGroupRow;
|
|
3619
3935
|
}
|
|
3620
3936
|
|
|
3621
3937
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
3622
3938
|
function useGroupByMap(groupBy) {
|
|
3623
|
-
const groupByMap = (0,
|
|
3939
|
+
const groupByMap = (0, import_react17.useMemo)(() => {
|
|
3624
3940
|
return groupBy.reduce((acc, groupBy2, index) => {
|
|
3625
3941
|
acc.set(groupBy2.field, {
|
|
3626
3942
|
groupBy: groupBy2,
|
|
@@ -3640,10 +3956,10 @@ function useColumnsWhen() {
|
|
|
3640
3956
|
componentState: { groupRenderStrategy, pivotTotalColumnPosition }
|
|
3641
3957
|
} = useComponentState();
|
|
3642
3958
|
const groupByMap = useGroupByMap(groupBy);
|
|
3643
|
-
(0,
|
|
3959
|
+
(0, import_react17.useEffect)(() => {
|
|
3644
3960
|
dataSourceActions.generateGroupRows = groupRenderStrategy !== "inline";
|
|
3645
3961
|
}, [groupRenderStrategy]);
|
|
3646
|
-
(0,
|
|
3962
|
+
(0, import_react17.useEffect)(() => {
|
|
3647
3963
|
dataSourceActions.pivotTotalColumnPosition = pivotTotalColumnPosition;
|
|
3648
3964
|
}, [pivotTotalColumnPosition]);
|
|
3649
3965
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
@@ -3706,7 +4022,7 @@ function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
|
3706
4022
|
});
|
|
3707
4023
|
return computedColumns.size === 0 ? void 0 : computedColumns;
|
|
3708
4024
|
}
|
|
3709
|
-
(0,
|
|
4025
|
+
(0, import_react17.useEffect)(() => {
|
|
3710
4026
|
const update = () => {
|
|
3711
4027
|
componentActions.columnsWhenInlineGroupRenderStrategy = computeColumnsWhenInlineGroupRenderStrategy(columns, groupByMap, groupRenderStrategy, toggleGroupRow);
|
|
3712
4028
|
};
|
|
@@ -3732,7 +4048,7 @@ function useColumnsWhenPivoting() {
|
|
|
3732
4048
|
}
|
|
3733
4049
|
} = useComponentState();
|
|
3734
4050
|
const toggleGroupRow = useToggleGroupRow();
|
|
3735
|
-
(0,
|
|
4051
|
+
(0, import_react17.useEffect)(() => {
|
|
3736
4052
|
const computedPivotColumns = getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, {
|
|
3737
4053
|
pivotColumn,
|
|
3738
4054
|
pivotRowLabelsColumn,
|
|
@@ -3753,7 +4069,7 @@ function useColumnsWhenGrouping() {
|
|
|
3753
4069
|
componentState: { columns, groupColumn, groupRenderStrategy, pivotColumns }
|
|
3754
4070
|
} = useComponentState();
|
|
3755
4071
|
const toggleGroupRow = useToggleGroupRow();
|
|
3756
|
-
(0,
|
|
4072
|
+
(0, import_react17.useEffect)(() => {
|
|
3757
4073
|
if (pivotColumns) {
|
|
3758
4074
|
return;
|
|
3759
4075
|
}
|
|
@@ -3790,7 +4106,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3790
4106
|
groupRenderStrategy
|
|
3791
4107
|
}
|
|
3792
4108
|
} = useComponentState();
|
|
3793
|
-
(0,
|
|
4109
|
+
(0, import_react17.useEffect)(() => {
|
|
3794
4110
|
if (groupRenderStrategy !== "multi-column") {
|
|
3795
4111
|
return;
|
|
3796
4112
|
}
|
|
@@ -3808,7 +4124,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3808
4124
|
const currentState = getComponentState();
|
|
3809
4125
|
const { computedColumns } = currentState;
|
|
3810
4126
|
let updated = false;
|
|
3811
|
-
const columnVisibility =
|
|
4127
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3812
4128
|
const cols = computedColumns;
|
|
3813
4129
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
3814
4130
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
@@ -3819,9 +4135,9 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3819
4135
|
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3820
4136
|
updated = true;
|
|
3821
4137
|
if (shouldBeHidden) {
|
|
3822
|
-
columnVisibility
|
|
4138
|
+
columnVisibility[colId] = false;
|
|
3823
4139
|
} else {
|
|
3824
|
-
columnVisibility
|
|
4140
|
+
delete columnVisibility[colId];
|
|
3825
4141
|
}
|
|
3826
4142
|
});
|
|
3827
4143
|
if (updated) {
|
|
@@ -3884,7 +4200,8 @@ function useComputed() {
|
|
|
3884
4200
|
const { componentActions, componentState } = useComponentState();
|
|
3885
4201
|
const {
|
|
3886
4202
|
componentActions: dataSourceActions,
|
|
3887
|
-
componentState: dataSourceState
|
|
4203
|
+
componentState: dataSourceState,
|
|
4204
|
+
getState: getDataSourceState
|
|
3888
4205
|
} = useDataSourceContextValue();
|
|
3889
4206
|
const {
|
|
3890
4207
|
columnOrder,
|
|
@@ -3895,7 +4212,7 @@ function useComputed() {
|
|
|
3895
4212
|
bodySize,
|
|
3896
4213
|
showSeparatePivotColumnForSingleAggregation
|
|
3897
4214
|
} = componentState;
|
|
3898
|
-
(0,
|
|
4215
|
+
(0, import_react18.useState)(() => {
|
|
3899
4216
|
componentState.onRowHeightCSSVarChange.onChange((rowHeight) => {
|
|
3900
4217
|
if (rowHeight) {
|
|
3901
4218
|
componentActions.rowHeight = rowHeight;
|
|
@@ -3907,17 +4224,17 @@ function useComputed() {
|
|
|
3907
4224
|
}
|
|
3908
4225
|
});
|
|
3909
4226
|
});
|
|
3910
|
-
(0,
|
|
4227
|
+
(0, import_react18.useEffect)(() => {
|
|
3911
4228
|
dataSourceActions.showSeparatePivotColumnForSingleAggregation = showSeparatePivotColumnForSingleAggregation;
|
|
3912
4229
|
}, [showSeparatePivotColumnForSingleAggregation]);
|
|
3913
4230
|
const { multiSort } = dataSourceState;
|
|
3914
4231
|
useColumnGroups();
|
|
3915
4232
|
useColumnsWhen();
|
|
3916
|
-
const setSortInfo = (0,
|
|
4233
|
+
const setSortInfo = (0, import_react18.useCallback)((sortInfo) => {
|
|
3917
4234
|
var _a2;
|
|
3918
4235
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3919
4236
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3920
|
-
}, []);
|
|
4237
|
+
}, [getDataSourceState]);
|
|
3921
4238
|
const columns = componentState.computedColumns;
|
|
3922
4239
|
const {
|
|
3923
4240
|
computedColumnOrder,
|
|
@@ -4073,20 +4390,20 @@ var HeaderWrapperCls = "_12zfob1v _16lm1iw16 _16lm1iw1 _16lm1iwj _16lm1iw10";
|
|
|
4073
4390
|
|
|
4074
4391
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4075
4392
|
var React17 = __toModule(require("react"));
|
|
4076
|
-
var
|
|
4393
|
+
var import_react26 = __toModule(require("react"));
|
|
4077
4394
|
|
|
4078
4395
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
|
|
4079
4396
|
var React13 = __toModule(require("react"));
|
|
4080
|
-
var
|
|
4397
|
+
var import_react22 = __toModule(require("react"));
|
|
4081
4398
|
|
|
4082
4399
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx
|
|
4083
4400
|
var React11 = __toModule(require("react"));
|
|
4084
4401
|
|
|
4085
4402
|
// src/components/InfiniteTable/hooks/useInfiniteTableState.ts
|
|
4086
|
-
var
|
|
4403
|
+
var import_react19 = __toModule(require("react"));
|
|
4087
4404
|
var useInfiniteTableState = () => {
|
|
4088
4405
|
const TableContext2 = getInfiniteTableContext();
|
|
4089
|
-
const { componentState } = (0,
|
|
4406
|
+
const { componentState } = (0, import_react19.useContext)(TableContext2);
|
|
4090
4407
|
return componentState;
|
|
4091
4408
|
};
|
|
4092
4409
|
|
|
@@ -4152,7 +4469,7 @@ var InfiniteTableCell = React11.memo(InfiniteTableCellFn);
|
|
|
4152
4469
|
|
|
4153
4470
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
4154
4471
|
var import_binary_search = __toModule(require_binary_search());
|
|
4155
|
-
var
|
|
4472
|
+
var import_react20 = __toModule(require("react"));
|
|
4156
4473
|
|
|
4157
4474
|
// src/components/InfiniteTable/utils/moveXatY.ts
|
|
4158
4475
|
var moveXatY = (arr, dragIndex, dropIndex) => {
|
|
@@ -4186,18 +4503,18 @@ var useColumnPointerEvents = ({
|
|
|
4186
4503
|
columns,
|
|
4187
4504
|
computedRemainingSpace
|
|
4188
4505
|
}) => {
|
|
4189
|
-
const [draggingDiff, setDraggingDiff] = (0,
|
|
4190
|
-
const [proxyOffset, setProxyOffset] = (0,
|
|
4191
|
-
const breakpointsRef = (0,
|
|
4192
|
-
const pointerMoveRef = (0,
|
|
4193
|
-
const didDragRef = (0,
|
|
4194
|
-
const initialClientPos = (0,
|
|
4195
|
-
const currentDropIndexRef = (0,
|
|
4506
|
+
const [draggingDiff, setDraggingDiff] = (0, import_react20.useState)(null);
|
|
4507
|
+
const [proxyOffset, setProxyOffset] = (0, import_react20.useState)(null);
|
|
4508
|
+
const breakpointsRef = (0, import_react20.useRef)([]);
|
|
4509
|
+
const pointerMoveRef = (0, import_react20.useRef)(null);
|
|
4510
|
+
const didDragRef = (0, import_react20.useRef)(false);
|
|
4511
|
+
const initialClientPos = (0, import_react20.useRef)(null);
|
|
4512
|
+
const currentDropIndexRef = (0, import_react20.useRef)(null);
|
|
4196
4513
|
const dragging = draggingDiff != null;
|
|
4197
4514
|
const { componentActions, computed } = useInfiniteTable();
|
|
4198
4515
|
const { computedColumnOrder } = computed;
|
|
4199
|
-
const column = (0,
|
|
4200
|
-
const { columnIndex, columnWidth, columnsArray } = (0,
|
|
4516
|
+
const column = (0, import_react20.useMemo)(() => columns.get(columnId), [columnId, columns]);
|
|
4517
|
+
const { columnIndex, columnWidth, columnsArray } = (0, import_react20.useMemo)(() => {
|
|
4201
4518
|
const columnsArray2 = Array.from(columns.values());
|
|
4202
4519
|
return {
|
|
4203
4520
|
columnsArray: columnsArray2,
|
|
@@ -4205,8 +4522,8 @@ var useColumnPointerEvents = ({
|
|
|
4205
4522
|
columnWidth: column.computedWidth
|
|
4206
4523
|
};
|
|
4207
4524
|
}, [columns, columnId, column]);
|
|
4208
|
-
let cursorRef = (0,
|
|
4209
|
-
const onPointerDown = (0,
|
|
4525
|
+
let cursorRef = (0, import_react20.useRef)("auto");
|
|
4526
|
+
const onPointerDown = (0, import_react20.useCallback)((e) => {
|
|
4210
4527
|
const target = domRef.current;
|
|
4211
4528
|
cursorRef.current = target.style.cursor;
|
|
4212
4529
|
didDragRef.current = false;
|
|
@@ -4269,7 +4586,7 @@ var useColumnPointerEvents = ({
|
|
|
4269
4586
|
target.addEventListener("pointermove", onPointerMove);
|
|
4270
4587
|
target.setPointerCapture(e.pointerId);
|
|
4271
4588
|
}, [columns, column, columnIndex, columnsArray, computedRemainingSpace]);
|
|
4272
|
-
const onPointerUp = (0,
|
|
4589
|
+
const onPointerUp = (0, import_react20.useCallback)((e) => {
|
|
4273
4590
|
const target = domRef.current;
|
|
4274
4591
|
target.style.cursor = cursorRef.current;
|
|
4275
4592
|
target.releasePointerCapture(e.pointerId);
|
|
@@ -4344,7 +4661,7 @@ var import_react_dom = __toModule(require("react-dom"));
|
|
|
4344
4661
|
|
|
4345
4662
|
// src/components/InfiniteTable/components/icons/SortIcon.tsx
|
|
4346
4663
|
var React12 = __toModule(require("react"));
|
|
4347
|
-
var
|
|
4664
|
+
var import_react21 = __toModule(require("react"));
|
|
4348
4665
|
var defaultLineStyle = {
|
|
4349
4666
|
marginTop: 2,
|
|
4350
4667
|
marginBottom: 2,
|
|
@@ -4352,8 +4669,8 @@ var defaultLineStyle = {
|
|
|
4352
4669
|
};
|
|
4353
4670
|
function SortIcon(props) {
|
|
4354
4671
|
var _a;
|
|
4355
|
-
const [rendered, setRendered] = (0,
|
|
4356
|
-
const [opacity, setOpacity] = (0,
|
|
4672
|
+
const [rendered, setRendered] = (0, import_react21.useState)(true);
|
|
4673
|
+
const [opacity, setOpacity] = (0, import_react21.useState)(0);
|
|
4357
4674
|
const { direction, lineWidth = 1, style, className, index } = props;
|
|
4358
4675
|
const showIndex = index != null && index > 0;
|
|
4359
4676
|
const size = (_a = props.size) != null ? _a : 16;
|
|
@@ -4367,7 +4684,7 @@ function SortIcon(props) {
|
|
|
4367
4684
|
}), props.lineStyle), {
|
|
4368
4685
|
opacity
|
|
4369
4686
|
});
|
|
4370
|
-
(0,
|
|
4687
|
+
(0, import_react21.useEffect)(() => {
|
|
4371
4688
|
const newOpacity = direction != 0 ? 1 : 0;
|
|
4372
4689
|
if (!rendered && newOpacity) {
|
|
4373
4690
|
setRendered(true);
|
|
@@ -4444,8 +4761,8 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4444
4761
|
className: `${baseCls}__sort-icon ${HeaderSortIconCls}`,
|
|
4445
4762
|
direction: column.computedSorted ? column.computedSortedAsc ? 1 : -1 : 0
|
|
4446
4763
|
});
|
|
4447
|
-
const domRef = (0,
|
|
4448
|
-
const ref = (0,
|
|
4764
|
+
const domRef = (0, import_react22.useRef)(null);
|
|
4765
|
+
const ref = (0, import_react22.useCallback)((node) => {
|
|
4449
4766
|
var _a2;
|
|
4450
4767
|
domRef.current = node;
|
|
4451
4768
|
(_a2 = props.domRef) == null ? void 0 : _a2.call(props, node);
|
|
@@ -4454,7 +4771,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4454
4771
|
computed: { computedRemainingSpace },
|
|
4455
4772
|
componentState: { portalDOMRef }
|
|
4456
4773
|
} = useInfiniteTable();
|
|
4457
|
-
(0,
|
|
4774
|
+
(0, import_react22.useEffect)(() => {
|
|
4458
4775
|
let clearOnResize = null;
|
|
4459
4776
|
const node = domRef.current;
|
|
4460
4777
|
if (onResize && node) {
|
|
@@ -4507,14 +4824,14 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4507
4824
|
|
|
4508
4825
|
// src/components/RawList/index.tsx
|
|
4509
4826
|
var React16 = __toModule(require("react"));
|
|
4510
|
-
var
|
|
4827
|
+
var import_react25 = __toModule(require("react"));
|
|
4511
4828
|
|
|
4512
4829
|
// src/components/RawList/AvoidReactDiff.tsx
|
|
4513
4830
|
var React14 = __toModule(require("react"));
|
|
4514
|
-
var
|
|
4831
|
+
var import_react23 = __toModule(require("react"));
|
|
4515
4832
|
function AvoidReactDiffFn(props) {
|
|
4516
|
-
const [children, setChildren] = (0,
|
|
4517
|
-
(0,
|
|
4833
|
+
const [children, setChildren] = (0, import_react23.useState)(props.updater.get());
|
|
4834
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
4518
4835
|
const remove = props.updater.onChange((children2) => {
|
|
4519
4836
|
setChildren(children2);
|
|
4520
4837
|
});
|
|
@@ -4525,7 +4842,7 @@ function AvoidReactDiffFn(props) {
|
|
|
4525
4842
|
var AvoidReactDiff = React14.memo(AvoidReactDiffFn);
|
|
4526
4843
|
|
|
4527
4844
|
// src/components/RawList/useVirtualRenderer.ts
|
|
4528
|
-
var
|
|
4845
|
+
var import_react24 = __toModule(require("react"));
|
|
4529
4846
|
|
|
4530
4847
|
// src/components/RawList/ReactVirtualRenderer.tsx
|
|
4531
4848
|
var React15 = __toModule(require("react"));
|
|
@@ -4839,7 +5156,7 @@ function createRenderer(brain) {
|
|
|
4839
5156
|
function useVirtualRenderer({
|
|
4840
5157
|
brain
|
|
4841
5158
|
}) {
|
|
4842
|
-
return (0,
|
|
5159
|
+
return (0, import_react24.useMemo)(() => {
|
|
4843
5160
|
return createRenderer(brain);
|
|
4844
5161
|
}, [brain]);
|
|
4845
5162
|
}
|
|
@@ -4852,7 +5169,7 @@ function RawListFn(props) {
|
|
|
4852
5169
|
debugChannel
|
|
4853
5170
|
});
|
|
4854
5171
|
const getRenderItem = useLatest(renderItem);
|
|
4855
|
-
(0,
|
|
5172
|
+
(0, import_react25.useEffect)(() => {
|
|
4856
5173
|
const renderRange = brain.getRenderRange();
|
|
4857
5174
|
renderer.renderRange(renderRange, {
|
|
4858
5175
|
renderItem,
|
|
@@ -4860,7 +5177,7 @@ function RawListFn(props) {
|
|
|
4860
5177
|
onRender: onRenderUpdater
|
|
4861
5178
|
});
|
|
4862
5179
|
}, [brain, renderItem, onRenderUpdater]);
|
|
4863
|
-
(0,
|
|
5180
|
+
(0, import_react25.useEffect)(() => {
|
|
4864
5181
|
const remove = brain.onRenderRangeChange((renderRange) => {
|
|
4865
5182
|
renderer.renderRange(renderRange, {
|
|
4866
5183
|
force: false,
|
|
@@ -4887,7 +5204,7 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4887
5204
|
componentState: { headerHeight }
|
|
4888
5205
|
} = useInfiniteTable();
|
|
4889
5206
|
const { computedVisibleColumnsMap } = computed;
|
|
4890
|
-
const renderColumn = (0,
|
|
5207
|
+
const renderColumn = (0, import_react26.useCallback)(({ domRef: domRef2, itemIndex: columnIndex }) => {
|
|
4891
5208
|
const column = columns[columnIndex];
|
|
4892
5209
|
if (!column) {
|
|
4893
5210
|
if (true) {
|
|
@@ -4902,14 +5219,14 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4902
5219
|
columns: computedVisibleColumnsMap
|
|
4903
5220
|
});
|
|
4904
5221
|
}, [computedVisibleColumnsMap, columns, repaintId, headerHeight]);
|
|
4905
|
-
(0,
|
|
5222
|
+
(0, import_react26.useEffect)(() => {
|
|
4906
5223
|
const onScroll = (scrollPosition) => {
|
|
4907
5224
|
domRef.current.style.transform = `translate3d(-${scrollPosition.scrollLeft}px, 0px, 0px)`;
|
|
4908
5225
|
};
|
|
4909
5226
|
const removeOnScroll = brain.onScroll(onScroll);
|
|
4910
5227
|
return removeOnScroll;
|
|
4911
5228
|
}, [brain]);
|
|
4912
|
-
const domRef = (0,
|
|
5229
|
+
const domRef = (0, import_react26.useRef)(null);
|
|
4913
5230
|
const headerCls = HeaderClsRecipe({
|
|
4914
5231
|
pinned: pinning,
|
|
4915
5232
|
overflow: false,
|
|
@@ -5101,7 +5418,7 @@ function renderColumnHeaderGroups(config) {
|
|
|
5101
5418
|
}
|
|
5102
5419
|
|
|
5103
5420
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderUnvirtualized.tsx
|
|
5104
|
-
var
|
|
5421
|
+
var import_react27 = __toModule(require("react"));
|
|
5105
5422
|
var { rootClassName: rootClassName5 } = internalProps;
|
|
5106
5423
|
var TableHeaderClassName2 = `${rootClassName5}Header`;
|
|
5107
5424
|
var UPDATE_SCROLL = (node, scrollPosition) => {
|
|
@@ -5167,7 +5484,7 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
|
|
|
5167
5484
|
if (totalWidth != null) {
|
|
5168
5485
|
style.width = availableWidth;
|
|
5169
5486
|
}
|
|
5170
|
-
(0,
|
|
5487
|
+
(0, import_react27.useEffect)(() => {
|
|
5171
5488
|
const scroller = brain || scrollListener;
|
|
5172
5489
|
if (!scroller || !scrollable) {
|
|
5173
5490
|
return;
|
|
@@ -5221,6 +5538,9 @@ function TableHeaderWrapper(props) {
|
|
|
5221
5538
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5222
5539
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5223
5540
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5541
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5542
|
+
left: computedPinnedStartWidth
|
|
5543
|
+
} : void 0;
|
|
5224
5544
|
const header = virtualizeHeader ? /* @__PURE__ */ React21.createElement(InfiniteTableHeader, {
|
|
5225
5545
|
columns: computedUnpinnedColumns,
|
|
5226
5546
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5235,6 +5555,7 @@ function TableHeaderWrapper(props) {
|
|
|
5235
5555
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5236
5556
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5237
5557
|
}) : /* @__PURE__ */ React21.createElement(InfiniteTableHeaderUnvirtualized, {
|
|
5558
|
+
style: unvirtualizedStyle,
|
|
5238
5559
|
brain,
|
|
5239
5560
|
scrollable: true,
|
|
5240
5561
|
pinning: false,
|
|
@@ -5281,12 +5602,12 @@ function TableHeaderWrapper(props) {
|
|
|
5281
5602
|
|
|
5282
5603
|
// src/components/VirtualScrollContainer/index.tsx
|
|
5283
5604
|
var React22 = __toModule(require("react"));
|
|
5284
|
-
var
|
|
5605
|
+
var import_react29 = __toModule(require("react"));
|
|
5285
5606
|
|
|
5286
5607
|
// src/components/hooks/useOnScroll.ts
|
|
5287
|
-
var
|
|
5608
|
+
var import_react28 = __toModule(require("react"));
|
|
5288
5609
|
var useOnScroll = (domRef, onScroll) => {
|
|
5289
|
-
(0,
|
|
5610
|
+
(0, import_react28.useEffect)(() => {
|
|
5290
5611
|
const domNode = domRef == null ? void 0 : domRef.current;
|
|
5291
5612
|
const scrollFn = (event) => {
|
|
5292
5613
|
const node = event.target;
|
|
@@ -5332,7 +5653,7 @@ var VirtualScrollContainer = React22.forwardRef(function VirtualScrollContainer2
|
|
|
5332
5653
|
className,
|
|
5333
5654
|
style
|
|
5334
5655
|
} = props;
|
|
5335
|
-
const domRef = ref != null ? ref : (0,
|
|
5656
|
+
const domRef = ref != null ? ref : (0, import_react29.useRef)(null);
|
|
5336
5657
|
useOnScroll(domRef, onContainerScroll);
|
|
5337
5658
|
return /* @__PURE__ */ React22.createElement("div", {
|
|
5338
5659
|
ref: domRef,
|
|
@@ -5367,14 +5688,14 @@ var import_react41 = __toModule(require("react"));
|
|
|
5367
5688
|
|
|
5368
5689
|
// src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
|
|
5369
5690
|
var React29 = __toModule(require("react"));
|
|
5370
|
-
var
|
|
5691
|
+
var import_react33 = __toModule(require("react"));
|
|
5371
5692
|
|
|
5372
5693
|
// src/components/VirtualList/VirtualRowList.tsx
|
|
5373
5694
|
var React25 = __toModule(require("react"));
|
|
5374
5695
|
|
|
5375
5696
|
// src/components/VirtualList/VirtualList.tsx
|
|
5376
5697
|
var React24 = __toModule(require("react"));
|
|
5377
|
-
var
|
|
5698
|
+
var import_react30 = __toModule(require("react"));
|
|
5378
5699
|
|
|
5379
5700
|
// src/components/VirtualList/VirtualList.css.ts
|
|
5380
5701
|
var VirtualListCls = "_16lm1iw1 _16lm1iw8 _16lm1iw0";
|
|
@@ -5417,11 +5738,11 @@ var VirtualList = (props) => {
|
|
|
5417
5738
|
"onContainerScroll",
|
|
5418
5739
|
"children"
|
|
5419
5740
|
]);
|
|
5420
|
-
const domRef = (0,
|
|
5741
|
+
const domRef = (0, import_react30.useRef)(null);
|
|
5421
5742
|
const [, rerender] = useRerender();
|
|
5422
|
-
const [totalSize, setTotalSize] = (0,
|
|
5423
|
-
const renderCountRef = (0,
|
|
5424
|
-
(0,
|
|
5743
|
+
const [totalSize, setTotalSize] = (0, import_react30.useState)(0);
|
|
5744
|
+
const renderCountRef = (0, import_react30.useRef)(0);
|
|
5745
|
+
(0, import_react30.useEffect)(() => {
|
|
5425
5746
|
const removeOnRenderCount = virtualBrain.onRenderCountChange((renderCount) => {
|
|
5426
5747
|
renderCountRef.current = renderCount;
|
|
5427
5748
|
if (true) {
|
|
@@ -5440,7 +5761,7 @@ var VirtualList = (props) => {
|
|
|
5440
5761
|
removeOnTotalSizeChange();
|
|
5441
5762
|
};
|
|
5442
5763
|
}, [virtualBrain]);
|
|
5443
|
-
(0,
|
|
5764
|
+
(0, import_react30.useEffect)(() => {
|
|
5444
5765
|
const onScroll = (scrollPosition) => {
|
|
5445
5766
|
UPDATE_SCROLL2(domRef.current, scrollPosition);
|
|
5446
5767
|
};
|
|
@@ -5494,7 +5815,7 @@ var VirtualRowList = (props) => {
|
|
|
5494
5815
|
|
|
5495
5816
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx
|
|
5496
5817
|
var React27 = __toModule(require("react"));
|
|
5497
|
-
var
|
|
5818
|
+
var import_react32 = __toModule(require("react"));
|
|
5498
5819
|
|
|
5499
5820
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx
|
|
5500
5821
|
var React26 = __toModule(require("react"));
|
|
@@ -5604,7 +5925,7 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5604
5925
|
var InfiniteTableColumnCell = React26.memo(InfiniteTableColumnCellFn);
|
|
5605
5926
|
|
|
5606
5927
|
// src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts
|
|
5607
|
-
var
|
|
5928
|
+
var import_react31 = __toModule(require("react"));
|
|
5608
5929
|
|
|
5609
5930
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts
|
|
5610
5931
|
var { rootClassName: rootClassName9 } = internalProps;
|
|
@@ -5629,8 +5950,8 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5629
5950
|
domRef: domRefFromProps,
|
|
5630
5951
|
rowInfo
|
|
5631
5952
|
} = props;
|
|
5632
|
-
const domRef = (0,
|
|
5633
|
-
const rowDOMRef = (0,
|
|
5953
|
+
const domRef = (0, import_react31.useRef)(null);
|
|
5954
|
+
const rowDOMRef = (0, import_react31.useCallback)((node) => {
|
|
5634
5955
|
domRefFromProps(node);
|
|
5635
5956
|
domRef.current = node;
|
|
5636
5957
|
}, []);
|
|
@@ -5661,7 +5982,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5661
5982
|
}), `${InfiniteTableRowClassName}--${rowInfo.isGroupRow ? "group" : "normal"}-row`, inlineGroupRoot ? `${InfiniteTableRowClassName}--inline-group-row` : "", showZebraRows ? `${InfiniteTableRowClassName}--${odd ? "odd" : "even"}` : null, showHoverRows ? `${InfiniteTableRowClassName}--show-hover` : null, domProps == null ? void 0 : domProps.className, rowProps == null ? void 0 : rowProps.className, rowComputedClassName);
|
|
5662
5983
|
const initialMouseEnter = rowProps == null ? void 0 : rowProps.onMouseEnter;
|
|
5663
5984
|
const initialMouseLeave = rowProps == null ? void 0 : rowProps.onMouseLeave;
|
|
5664
|
-
const onMouseEnter = (0,
|
|
5985
|
+
const onMouseEnter = (0, import_react31.useCallback)((event) => {
|
|
5665
5986
|
var _a;
|
|
5666
5987
|
initialMouseEnter == null ? void 0 : initialMouseEnter(event);
|
|
5667
5988
|
const rowIndex2 = ((_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex) * 1;
|
|
@@ -5675,7 +5996,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5675
5996
|
const rows = parentNode.querySelectorAll(hoverSelector.join(","));
|
|
5676
5997
|
rows.forEach((row) => row.classList.add(InfiniteTableRowClassName__hover, RowHoverCls));
|
|
5677
5998
|
}, [initialMouseEnter, showHoverRows]);
|
|
5678
|
-
const onMouseLeave = (0,
|
|
5999
|
+
const onMouseLeave = (0, import_react31.useCallback)((event) => {
|
|
5679
6000
|
var _a;
|
|
5680
6001
|
initialMouseLeave == null ? void 0 : initialMouseLeave(event);
|
|
5681
6002
|
const rowIndex2 = (_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex;
|
|
@@ -5731,7 +6052,7 @@ function InfiniteTableRowFn(props) {
|
|
|
5731
6052
|
width: rowWidth,
|
|
5732
6053
|
height: rowHeight
|
|
5733
6054
|
}, domProps.style);
|
|
5734
|
-
const renderCellRef = (0,
|
|
6055
|
+
const renderCellRef = (0, import_react32.useRef)(null);
|
|
5735
6056
|
const renderCell = React27.useCallback(({ domRef, itemIndex }) => {
|
|
5736
6057
|
const column = columns[itemIndex];
|
|
5737
6058
|
if (!column) {
|
|
@@ -5835,7 +6156,7 @@ function useUnpinnedRendering(params) {
|
|
|
5835
6156
|
} = params;
|
|
5836
6157
|
const { virtualizeColumns } = getState();
|
|
5837
6158
|
const shouldVirtualizeColumns = typeof virtualizeColumns === "function" ? virtualizeColumns(computedUnpinnedColumns) : virtualizeColumns != null ? virtualizeColumns : true;
|
|
5838
|
-
const renderRowUnpinned = (0,
|
|
6159
|
+
const renderRowUnpinned = (0, import_react33.useCallback)((rowParams) => {
|
|
5839
6160
|
const dataArray = getData();
|
|
5840
6161
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
5841
6162
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -5901,7 +6222,7 @@ function useUnpinnedRendering(params) {
|
|
|
5901
6222
|
}
|
|
5902
6223
|
|
|
5903
6224
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5904
|
-
var
|
|
6225
|
+
var import_react34 = __toModule(require("react"));
|
|
5905
6226
|
|
|
5906
6227
|
// src/components/InfiniteTable/InfiniteCls.css.ts
|
|
5907
6228
|
var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
@@ -5914,7 +6235,6 @@ var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf",
|
|
|
5914
6235
|
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
5915
6236
|
|
|
5916
6237
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5917
|
-
var DELAY = 200;
|
|
5918
6238
|
var TableClassName = internalProps.rootClassName;
|
|
5919
6239
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
5920
6240
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -5925,23 +6245,33 @@ var useOnContainerScroll = ({
|
|
|
5925
6245
|
}) => {
|
|
5926
6246
|
const {
|
|
5927
6247
|
componentState: {
|
|
6248
|
+
scrollStopDelay,
|
|
5928
6249
|
scrollerDOMRef,
|
|
5929
6250
|
domRef,
|
|
5930
6251
|
scrollToBottomOffset,
|
|
5931
6252
|
onScrollToBottom,
|
|
5932
6253
|
onScrollToTop,
|
|
6254
|
+
onScrollStop: onScrollStopFromProps,
|
|
5933
6255
|
bodySize
|
|
5934
6256
|
}
|
|
5935
6257
|
} = useInfiniteTable();
|
|
5936
|
-
const {
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
6258
|
+
const {
|
|
6259
|
+
componentActions: dataSourceActions,
|
|
6260
|
+
getState: getDataSourceState,
|
|
6261
|
+
componentState: { notifyScrollStop }
|
|
6262
|
+
} = useDataSourceContextValue();
|
|
6263
|
+
const onScrollStop = (0, import_react34.useCallback)((param) => {
|
|
6264
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6265
|
+
notifyScrollStop(param);
|
|
6266
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
6267
|
+
const timeoutIdRef = (0, import_react34.useRef)(0);
|
|
6268
|
+
const scrollingRef = (0, import_react34.useRef)(false);
|
|
6269
|
+
const scrollTopMaxRef = (0, import_react34.useRef)(0);
|
|
6270
|
+
(0, import_react34.useEffect)(() => {
|
|
5941
6271
|
const { current: node } = scrollerDOMRef;
|
|
5942
6272
|
scrollTopMaxRef.current = node.scrollHeight - node.clientHeight;
|
|
5943
6273
|
}, [reservedContentHeight, bodySize.height]);
|
|
5944
|
-
const setScrolling = (0,
|
|
6274
|
+
const setScrolling = (0, import_react34.useCallback)((scrolling) => {
|
|
5945
6275
|
var _a;
|
|
5946
6276
|
const prevScrolling = scrollingRef.current;
|
|
5947
6277
|
scrollingRef.current = scrolling;
|
|
@@ -5952,9 +6282,17 @@ var useOnContainerScroll = ({
|
|
|
5952
6282
|
timeoutIdRef.current = setTimeout(() => {
|
|
5953
6283
|
setScrolling(false);
|
|
5954
6284
|
timeoutIdRef.current = 0;
|
|
5955
|
-
},
|
|
6285
|
+
}, scrollStopDelay);
|
|
5956
6286
|
}
|
|
5957
6287
|
if (prevScrolling !== scrolling) {
|
|
6288
|
+
if (!scrolling) {
|
|
6289
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6290
|
+
onScrollStop({
|
|
6291
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6292
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6293
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6294
|
+
});
|
|
6295
|
+
}
|
|
5958
6296
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
5959
6297
|
if (!classList) {
|
|
5960
6298
|
return;
|
|
@@ -5965,8 +6303,8 @@ var useOnContainerScroll = ({
|
|
|
5965
6303
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
5966
6304
|
}
|
|
5967
6305
|
}
|
|
5968
|
-
}, []);
|
|
5969
|
-
const onContainerScroll = (0,
|
|
6306
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
6307
|
+
const onContainerScroll = (0, import_react34.useCallback)((scrollInfo) => {
|
|
5970
6308
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
5971
6309
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
5972
6310
|
setScrolling(true);
|
|
@@ -5976,15 +6314,15 @@ var useOnContainerScroll = ({
|
|
|
5976
6314
|
domRef.current,
|
|
5977
6315
|
setScrolling
|
|
5978
6316
|
]);
|
|
5979
|
-
const scrollPositionRef = (0,
|
|
6317
|
+
const scrollPositionRef = (0, import_react34.useRef)({
|
|
5980
6318
|
scrollLeft: 0,
|
|
5981
6319
|
scrollTop: 0
|
|
5982
6320
|
});
|
|
5983
|
-
const applyScrollHorizontal = (0,
|
|
6321
|
+
const applyScrollHorizontal = (0, import_react34.useCallback)(({ scrollLeft }) => {
|
|
5984
6322
|
scrollPositionRef.current.scrollLeft = scrollLeft;
|
|
5985
6323
|
onContainerScroll(scrollPositionRef.current);
|
|
5986
6324
|
}, [onContainerScroll]);
|
|
5987
|
-
const applyScrollVertical = (0,
|
|
6325
|
+
const applyScrollVertical = (0, import_react34.useCallback)(({ scrollTop }) => {
|
|
5988
6326
|
scrollPositionRef.current.scrollTop = scrollTop;
|
|
5989
6327
|
onContainerScroll(scrollPositionRef.current);
|
|
5990
6328
|
if (scrollTop === 0) {
|
|
@@ -5995,7 +6333,7 @@ var useOnContainerScroll = ({
|
|
|
5995
6333
|
if (isScrollBottom) {
|
|
5996
6334
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
5997
6335
|
if (getDataSourceState().livePagination) {
|
|
5998
|
-
dataSourceActions.
|
|
6336
|
+
dataSourceActions.cursorId = Date.now();
|
|
5999
6337
|
}
|
|
6000
6338
|
}
|
|
6001
6339
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -6007,16 +6345,16 @@ var useOnContainerScroll = ({
|
|
|
6007
6345
|
|
|
6008
6346
|
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6009
6347
|
var React31 = __toModule(require("react"));
|
|
6010
|
-
var
|
|
6348
|
+
var import_react37 = __toModule(require("react"));
|
|
6011
6349
|
|
|
6012
6350
|
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
6013
6351
|
var React30 = __toModule(require("react"));
|
|
6014
|
-
var
|
|
6352
|
+
var import_react36 = __toModule(require("react"));
|
|
6015
6353
|
|
|
6016
6354
|
// src/components/hooks/useOnMount.ts
|
|
6017
|
-
var
|
|
6355
|
+
var import_react35 = __toModule(require("react"));
|
|
6018
6356
|
function useOnMount(domRef, props) {
|
|
6019
|
-
(0,
|
|
6357
|
+
(0, import_react35.useEffect)(() => {
|
|
6020
6358
|
const { onMount, onUnmount } = props;
|
|
6021
6359
|
const node = domRef == null ? void 0 : domRef.current;
|
|
6022
6360
|
onMount == null ? void 0 : onMount(node);
|
|
@@ -6047,8 +6385,8 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6047
6385
|
onMount,
|
|
6048
6386
|
onUnmount
|
|
6049
6387
|
} = props;
|
|
6050
|
-
const domRef = (0,
|
|
6051
|
-
const renderItem = (0,
|
|
6388
|
+
const domRef = (0, import_react36.useRef)(null);
|
|
6389
|
+
const renderItem = (0, import_react36.useCallback)((renderProps) => renderRow({
|
|
6052
6390
|
domRef: renderProps.domRef,
|
|
6053
6391
|
rowHeight: renderProps.itemSize,
|
|
6054
6392
|
rowIndex: renderProps.itemIndex
|
|
@@ -6057,7 +6395,7 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6057
6395
|
onMount,
|
|
6058
6396
|
onUnmount
|
|
6059
6397
|
});
|
|
6060
|
-
(0,
|
|
6398
|
+
(0, import_react36.useEffect)(() => {
|
|
6061
6399
|
const onScroll = (scrollPosition) => {
|
|
6062
6400
|
const node = domRef.current;
|
|
6063
6401
|
if (node) {
|
|
@@ -6124,7 +6462,7 @@ function PinnedRowsContainer(props) {
|
|
|
6124
6462
|
}
|
|
6125
6463
|
return result;
|
|
6126
6464
|
}, [height, rowWidth, pinning, hasOverflow]);
|
|
6127
|
-
const updateScroll = (0,
|
|
6465
|
+
const updateScroll = (0, import_react37.useCallback)((node, scrollPosition) => {
|
|
6128
6466
|
UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
|
|
6129
6467
|
}, [hasOverflow, pinnedScrollListener]);
|
|
6130
6468
|
const rowListProps = {
|
|
@@ -6166,7 +6504,7 @@ function PinnedRowsContainer(props) {
|
|
|
6166
6504
|
}
|
|
6167
6505
|
function useRenderPinnedRow(params) {
|
|
6168
6506
|
const { getData, getState, columnsWidth, columns, verticalBrain } = params;
|
|
6169
|
-
const renderPinnedRow = (0,
|
|
6507
|
+
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
6170
6508
|
const dataArray = getData();
|
|
6171
6509
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
6172
6510
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -6282,6 +6620,15 @@ function usePinnedStartRendering(params) {
|
|
|
6282
6620
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6283
6621
|
var import_react40 = __toModule(require("react"));
|
|
6284
6622
|
|
|
6623
|
+
// src/components/hooks/useOnce.ts
|
|
6624
|
+
var import_react38 = __toModule(require("react"));
|
|
6625
|
+
function useOnce(fn) {
|
|
6626
|
+
const onceFn = (0, import_react38.useMemo)(() => {
|
|
6627
|
+
return once(fn);
|
|
6628
|
+
}, []);
|
|
6629
|
+
return onceFn();
|
|
6630
|
+
}
|
|
6631
|
+
|
|
6285
6632
|
// src/components/VirtualBrain/index.ts
|
|
6286
6633
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6287
6634
|
var initialScrollPosition2 = {
|
|
@@ -7172,7 +7519,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7172
7519
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7173
7520
|
let valid2 = isValidLicense(licenseKey, {
|
|
7174
7521
|
publishedAt: 1624970570587,
|
|
7175
|
-
version: "0.1.
|
|
7522
|
+
version: "0.1.4"
|
|
7176
7523
|
});
|
|
7177
7524
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7178
7525
|
return true;
|