@infinite-table/infinite-react 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +5 -4
- package/index.d.ts +191 -107
- package/index.esm.css +5 -4
- package/index.esm.js +994 -644
- package/index.js +1023 -673
- 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) => {
|
|
@@ -1288,7 +1285,10 @@ var getComputedVisibleColumns = ({
|
|
|
1288
1285
|
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1289
1286
|
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1290
1287
|
};
|
|
1291
|
-
let colSizing = columnSizing.get(colId) || {
|
|
1288
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1289
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1290
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1291
|
+
};
|
|
1292
1292
|
if (colSizing.width != null) {
|
|
1293
1293
|
delete colTypeSizing.flex;
|
|
1294
1294
|
}
|
|
@@ -1575,7 +1575,6 @@ var useComputedVisibleColumns = ({
|
|
|
1575
1575
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1576
1576
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1577
1577
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1578
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1579
1578
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1580
1579
|
const {
|
|
1581
1580
|
computedRemainingSpace,
|
|
@@ -1631,7 +1630,6 @@ var useComputedVisibleColumns = ({
|
|
|
1631
1630
|
pinnedStartMaxWidth,
|
|
1632
1631
|
columnPinning,
|
|
1633
1632
|
columnsRenderId,
|
|
1634
|
-
visibilityRenderId,
|
|
1635
1633
|
columnsSizingRenderId,
|
|
1636
1634
|
pinningRenderId,
|
|
1637
1635
|
columnTypesRenderId
|
|
@@ -1656,11 +1654,11 @@ var useComputedVisibleColumns = ({
|
|
|
1656
1654
|
return result;
|
|
1657
1655
|
};
|
|
1658
1656
|
|
|
1659
|
-
// src/utils/sortAscending.ts
|
|
1657
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1660
1658
|
var sortAscending = (a, b) => a - b;
|
|
1661
1659
|
|
|
1662
1660
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
1663
|
-
var
|
|
1661
|
+
var import_react18 = __toModule(require("react"));
|
|
1664
1662
|
|
|
1665
1663
|
// src/components/hooks/useComponentState.tsx
|
|
1666
1664
|
var React2 = __toModule(require("react"));
|
|
@@ -1752,9 +1750,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1752
1750
|
if (currentValue === value) {
|
|
1753
1751
|
return;
|
|
1754
1752
|
}
|
|
1755
|
-
|
|
1753
|
+
let notifyTheChange = true;
|
|
1756
1754
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1757
|
-
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);
|
|
1758
1761
|
}
|
|
1759
1762
|
const forwardFn = propsToForward[key];
|
|
1760
1763
|
if (typeof forwardFn === "function") {
|
|
@@ -1795,12 +1798,14 @@ function forwardProps2(propsToForward, props) {
|
|
|
1795
1798
|
function getComponentStateRoot(config) {
|
|
1796
1799
|
return React2.memo(function ComponentStateRoot(props) {
|
|
1797
1800
|
var _a, _b;
|
|
1801
|
+
const [initialSetupState] = (0, import_react11.useState)(() => {
|
|
1802
|
+
return config.initSetupState ? config.initSetupState() : {};
|
|
1803
|
+
});
|
|
1798
1804
|
const propsToStateSetRef = (0, import_react11.useRef)(new Set());
|
|
1799
|
-
const propsToForward = (0, import_react11.useMemo)(() => config.forwardProps ? config.forwardProps() : {}, []);
|
|
1805
|
+
const propsToForward = (0, import_react11.useMemo)(() => config.forwardProps ? config.forwardProps(initialSetupState) : {}, [initialSetupState]);
|
|
1800
1806
|
const parentState = (_b = (_a = config.getParentState) == null ? void 0 : _a.call(config)) != null ? _b : null;
|
|
1801
1807
|
const getParentState = useLatest(parentState);
|
|
1802
1808
|
const [wholeState] = (0, import_react11.useState)(() => {
|
|
1803
|
-
const initialSetupState = config.initSetupState ? config.initSetupState() : {};
|
|
1804
1809
|
let mappedState = {};
|
|
1805
1810
|
if (propsToForward) {
|
|
1806
1811
|
mappedState = forwardProps2(propsToForward, props);
|
|
@@ -1830,9 +1835,12 @@ function getComponentStateRoot(config) {
|
|
|
1830
1835
|
const getProps = useLatest(props);
|
|
1831
1836
|
const theReducer = (previousState, action) => {
|
|
1832
1837
|
var _a2;
|
|
1838
|
+
if (action.type === "REPLACE_STATE") {
|
|
1839
|
+
return action.payload;
|
|
1840
|
+
}
|
|
1833
1841
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1834
1842
|
const mappedState = action.payload.mappedState;
|
|
1835
|
-
const updatedProps = action.payload.
|
|
1843
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1836
1844
|
const newState = Object.assign({}, previousState);
|
|
1837
1845
|
if (mappedState) {
|
|
1838
1846
|
Object.assign(newState, mappedState);
|
|
@@ -1886,8 +1894,9 @@ function getComponentStateRoot(config) {
|
|
|
1886
1894
|
const currentProps = props;
|
|
1887
1895
|
const newMappedState = {};
|
|
1888
1896
|
let newMappedStateCount = 0;
|
|
1889
|
-
const
|
|
1890
|
-
let
|
|
1897
|
+
const updatedPropsToState = {};
|
|
1898
|
+
let updatedPropsToStateCount = 0;
|
|
1899
|
+
const rawUpdatedProps = {};
|
|
1891
1900
|
for (var k in props) {
|
|
1892
1901
|
const key = k;
|
|
1893
1902
|
const oldValue = prevProps[key];
|
|
@@ -1898,6 +1907,7 @@ function getComponentStateRoot(config) {
|
|
|
1898
1907
|
if (oldValue === newValue) {
|
|
1899
1908
|
continue;
|
|
1900
1909
|
}
|
|
1910
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1901
1911
|
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1902
1912
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1903
1913
|
let valueToSet = newValue;
|
|
@@ -1910,22 +1920,30 @@ function getComponentStateRoot(config) {
|
|
|
1910
1920
|
newMappedStateCount++;
|
|
1911
1921
|
}
|
|
1912
1922
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1913
|
-
|
|
1914
|
-
|
|
1923
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1924
|
+
updatedPropsToStateCount++;
|
|
1915
1925
|
}
|
|
1916
1926
|
}
|
|
1917
1927
|
}
|
|
1918
|
-
if (
|
|
1928
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1919
1929
|
debug2("Triggered by new values for the following props", ...[
|
|
1920
1930
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1921
|
-
...Object.keys(
|
|
1931
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1922
1932
|
]);
|
|
1923
|
-
|
|
1933
|
+
const action = {
|
|
1924
1934
|
payload: {
|
|
1925
1935
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1926
|
-
|
|
1936
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1927
1937
|
}
|
|
1928
|
-
}
|
|
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
|
+
}
|
|
1929
1947
|
}
|
|
1930
1948
|
});
|
|
1931
1949
|
return /* @__PURE__ */ React2.createElement(Context.Provider, {
|
|
@@ -1993,35 +2011,38 @@ function useColumnGroups() {
|
|
|
1993
2011
|
return interceptMap(collapsedColumnGroups, {
|
|
1994
2012
|
set: (key, visibleCol) => {
|
|
1995
2013
|
const colIds = key.slice(1);
|
|
1996
|
-
const
|
|
2014
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
1997
2015
|
colIds.forEach((colId) => {
|
|
1998
|
-
columnVisibility
|
|
2016
|
+
columnVisibility[colId] = false;
|
|
1999
2017
|
});
|
|
2000
|
-
columnVisibility
|
|
2018
|
+
delete columnVisibility[visibleCol];
|
|
2019
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2001
2020
|
},
|
|
2002
2021
|
beforeClear: (currentCollapsedGroups) => {
|
|
2003
|
-
const
|
|
2022
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2004
2023
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2005
2024
|
keys.forEach((key) => {
|
|
2006
2025
|
const colIds = key.slice(1);
|
|
2007
2026
|
colIds.forEach((colId) => {
|
|
2008
|
-
columnVisibility
|
|
2027
|
+
delete columnVisibility[colId];
|
|
2009
2028
|
});
|
|
2010
2029
|
});
|
|
2030
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2011
2031
|
},
|
|
2012
2032
|
delete: (key) => {
|
|
2013
|
-
const
|
|
2033
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2014
2034
|
const colIds = key.slice(1);
|
|
2015
2035
|
colIds.forEach((colId) => {
|
|
2016
|
-
columnVisibility
|
|
2036
|
+
delete columnVisibility[colId];
|
|
2017
2037
|
});
|
|
2038
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2018
2039
|
}
|
|
2019
2040
|
});
|
|
2020
2041
|
}, [collapsedColumnGroups]);
|
|
2021
2042
|
}
|
|
2022
2043
|
|
|
2023
2044
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
2024
|
-
var
|
|
2045
|
+
var import_react17 = __toModule(require("react"));
|
|
2025
2046
|
|
|
2026
2047
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2027
2048
|
var React6 = __toModule(require("react"));
|
|
@@ -2276,7 +2297,7 @@ function getSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps) {
|
|
|
2276
2297
|
}
|
|
2277
2298
|
|
|
2278
2299
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
2279
|
-
var
|
|
2300
|
+
var import_react16 = __toModule(require("react"));
|
|
2280
2301
|
|
|
2281
2302
|
// src/components/DataSource/index.tsx
|
|
2282
2303
|
var React8 = __toModule(require("react"));
|
|
@@ -2358,164 +2379,7 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2358
2379
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2359
2380
|
var import_react15 = __toModule(require("react"));
|
|
2360
2381
|
|
|
2361
|
-
// src/
|
|
2362
|
-
var import_react14 = __toModule(require("react"));
|
|
2363
|
-
function useEffectWithChanges(fn, deps) {
|
|
2364
|
-
const prevRef = (0, import_react14.useRef)({});
|
|
2365
|
-
const oldValuesRef = (0, import_react14.useRef)({});
|
|
2366
|
-
const oldValues = oldValuesRef.current;
|
|
2367
|
-
const changesRef = (0, import_react14.useRef)({});
|
|
2368
|
-
const changes = changesRef.current;
|
|
2369
|
-
const useEffectDeps = [];
|
|
2370
|
-
for (let k in deps) {
|
|
2371
|
-
if (deps.hasOwnProperty(k)) {
|
|
2372
|
-
if (deps[k] !== prevRef.current[k]) {
|
|
2373
|
-
changes[k] = deps[k];
|
|
2374
|
-
oldValues[k] = prevRef.current[k];
|
|
2375
|
-
}
|
|
2376
|
-
useEffectDeps.push(deps[k]);
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
prevRef.current = deps;
|
|
2380
|
-
(0, import_react14.useEffect)(() => {
|
|
2381
|
-
const changes2 = changesRef.current;
|
|
2382
|
-
const result = fn(changes2, oldValues);
|
|
2383
|
-
changesRef.current = {};
|
|
2384
|
-
oldValuesRef.current = {};
|
|
2385
|
-
return result;
|
|
2386
|
-
}, useEffectDeps);
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2390
|
-
function buildDataSourceDataParams(componentState) {
|
|
2391
|
-
var _a, _b;
|
|
2392
|
-
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
2393
|
-
const dataSourceParams = {
|
|
2394
|
-
originalDataArray: componentState.originalDataArray,
|
|
2395
|
-
sortInfo,
|
|
2396
|
-
groupBy: componentState.groupBy,
|
|
2397
|
-
pivotBy: componentState.pivotBy
|
|
2398
|
-
};
|
|
2399
|
-
if (componentState.livePagination !== void 0) {
|
|
2400
|
-
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2401
|
-
}
|
|
2402
|
-
return dataSourceParams;
|
|
2403
|
-
}
|
|
2404
|
-
function notifyDataParamsChanged(componentState, actions) {
|
|
2405
|
-
var _a;
|
|
2406
|
-
if (typeof componentState.data === "function") {
|
|
2407
|
-
loadData(componentState.data, componentState, actions);
|
|
2408
|
-
}
|
|
2409
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2410
|
-
(_a = componentState.onDataParamsChange) == null ? void 0 : _a.call(componentState, dataParams);
|
|
2411
|
-
}
|
|
2412
|
-
function loadData(data, componentState, actions) {
|
|
2413
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2414
|
-
if (typeof data === "function") {
|
|
2415
|
-
data = data(dataParams);
|
|
2416
|
-
}
|
|
2417
|
-
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
2418
|
-
if (dataIsPromise) {
|
|
2419
|
-
actions.loading = true;
|
|
2420
|
-
}
|
|
2421
|
-
Promise.resolve(data).then((dataParam) => {
|
|
2422
|
-
let dataArray = [];
|
|
2423
|
-
if (Array.isArray(dataParam.data)) {
|
|
2424
|
-
const remoteData = dataParam;
|
|
2425
|
-
dataArray = remoteData.data;
|
|
2426
|
-
if (remoteData.livePaginationCursor !== void 0) {
|
|
2427
|
-
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
2428
|
-
}
|
|
2429
|
-
} else {
|
|
2430
|
-
dataArray = dataParam;
|
|
2431
|
-
}
|
|
2432
|
-
actions.originalDataArray = dataArray;
|
|
2433
|
-
if (dataIsPromise) {
|
|
2434
|
-
actions.loading = false;
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2437
|
-
}
|
|
2438
|
-
function useLoadData() {
|
|
2439
|
-
const {
|
|
2440
|
-
getComponentState,
|
|
2441
|
-
componentActions: actions,
|
|
2442
|
-
componentState: { data }
|
|
2443
|
-
} = useComponentState();
|
|
2444
|
-
(0, import_react15.useLayoutEffect)(() => {
|
|
2445
|
-
loadData(data, getComponentState(), actions);
|
|
2446
|
-
}, [data]);
|
|
2447
|
-
useLivePagination();
|
|
2448
|
-
}
|
|
2449
|
-
function useLivePagination() {
|
|
2450
|
-
const {
|
|
2451
|
-
getComponentState,
|
|
2452
|
-
componentActions: actions,
|
|
2453
|
-
componentState
|
|
2454
|
-
} = useComponentState();
|
|
2455
|
-
const {
|
|
2456
|
-
notifyScrollbarsChange,
|
|
2457
|
-
sortInfo,
|
|
2458
|
-
groupBy,
|
|
2459
|
-
pivotBy,
|
|
2460
|
-
livePaginationCursor,
|
|
2461
|
-
scrollBottomId
|
|
2462
|
-
} = componentState;
|
|
2463
|
-
const [scrollbars, setScrollbars] = (0, import_react15.useState)({
|
|
2464
|
-
vertical: false,
|
|
2465
|
-
horizontal: false
|
|
2466
|
-
});
|
|
2467
|
-
const scrollbarsRef = (0, import_react15.useRef)(scrollbars);
|
|
2468
|
-
(0, import_react15.useEffect)(() => {
|
|
2469
|
-
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
2470
|
-
if (!scrollbars2) {
|
|
2471
|
-
return;
|
|
2472
|
-
}
|
|
2473
|
-
scrollbarsRef.current = scrollbars2;
|
|
2474
|
-
setScrollbars(scrollbars2);
|
|
2475
|
-
});
|
|
2476
|
-
return () => notifyScrollbarsChange.destroy();
|
|
2477
|
-
}, [notifyScrollbarsChange]);
|
|
2478
|
-
const [cursorId, updateCursorId] = (0, import_react15.useState)(void 0);
|
|
2479
|
-
(0, import_react15.useEffect)(() => {
|
|
2480
|
-
const frameId = requestAnimationFrame(() => {
|
|
2481
|
-
var _a;
|
|
2482
|
-
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical)) {
|
|
2483
|
-
updateCursorId(livePaginationCursor);
|
|
2484
|
-
}
|
|
2485
|
-
});
|
|
2486
|
-
return () => cancelAnimationFrame(frameId);
|
|
2487
|
-
}, [livePaginationCursor]);
|
|
2488
|
-
(0, import_react15.useEffect)(() => {
|
|
2489
|
-
const { livePaginationCursor: livePaginationCursor2, livePagination } = getComponentState();
|
|
2490
|
-
if (!scrollbars.vertical && livePagination) {
|
|
2491
|
-
updateCursorId(livePaginationCursor2);
|
|
2492
|
-
}
|
|
2493
|
-
}, [scrollbars.vertical]);
|
|
2494
|
-
(0, import_react15.useEffect)(() => {
|
|
2495
|
-
updateCursorId(scrollBottomId);
|
|
2496
|
-
}, [scrollBottomId]);
|
|
2497
|
-
const depsObject = {
|
|
2498
|
-
sortInfo,
|
|
2499
|
-
groupBy,
|
|
2500
|
-
pivotBy,
|
|
2501
|
-
cursorId
|
|
2502
|
-
};
|
|
2503
|
-
useEffectWithChanges(() => {
|
|
2504
|
-
if (cursorId === void 0) {
|
|
2505
|
-
return;
|
|
2506
|
-
}
|
|
2507
|
-
notifyDataParamsChanged(getComponentState(), actions);
|
|
2508
|
-
}, depsObject);
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
2512
|
-
var normalizeSortInfo = (sortInfo) => {
|
|
2513
|
-
sortInfo = sortInfo != null ? sortInfo : [];
|
|
2514
|
-
return Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
2515
|
-
};
|
|
2516
|
-
|
|
2517
|
-
// src/components/hooks/useOnce.ts
|
|
2518
|
-
var import_react16 = __toModule(require("react"));
|
|
2382
|
+
// src/utils/DeepMap/once.ts
|
|
2519
2383
|
function once(fn) {
|
|
2520
2384
|
let called = false;
|
|
2521
2385
|
let result = null;
|
|
@@ -2529,14 +2393,8 @@ function once(fn) {
|
|
|
2529
2393
|
};
|
|
2530
2394
|
return onceFn;
|
|
2531
2395
|
}
|
|
2532
|
-
function useOnce(fn) {
|
|
2533
|
-
const onceFn = (0, import_react16.useMemo)(() => {
|
|
2534
|
-
return once(fn);
|
|
2535
|
-
}, []);
|
|
2536
|
-
return onceFn();
|
|
2537
|
-
}
|
|
2538
2396
|
|
|
2539
|
-
// src/utils/DeepMap.ts
|
|
2397
|
+
// src/utils/DeepMap/index.ts
|
|
2540
2398
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2541
2399
|
var DeepMap = class {
|
|
2542
2400
|
constructor(initial) {
|
|
@@ -2788,76 +2646,668 @@ var DeepMap = class {
|
|
|
2788
2646
|
}
|
|
2789
2647
|
};
|
|
2790
2648
|
|
|
2791
|
-
// src/
|
|
2792
|
-
var
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
return {
|
|
2799
|
-
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
2800
|
-
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
2801
|
-
};
|
|
2802
|
-
}
|
|
2803
|
-
destroy() {
|
|
2804
|
-
var _a, _b;
|
|
2805
|
-
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
2806
|
-
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
2807
|
-
delete this.expandedMap;
|
|
2808
|
-
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 {};
|
|
2809
2657
|
}
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
this.collapsedAll = collapsedRows === true;
|
|
2815
|
-
this.expandedAll = expandedRows === true;
|
|
2816
|
-
if (this.collapsedAll && this.expandedAll) {
|
|
2817
|
-
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
2818
|
-
}
|
|
2819
|
-
if (collapsedRows !== true) {
|
|
2820
|
-
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
2821
|
-
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
2822
|
-
}
|
|
2823
|
-
if (expandedRows !== true) {
|
|
2824
|
-
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
2825
|
-
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;
|
|
2826
2662
|
}
|
|
2663
|
+
return result;
|
|
2664
|
+
}
|
|
2665
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
2666
|
+
var _a, _b;
|
|
2667
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2668
|
+
return;
|
|
2827
2669
|
}
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
}
|
|
2834
|
-
collapseAll() {
|
|
2835
|
-
this.update({
|
|
2836
|
-
collapsedRows: true,
|
|
2837
|
-
expandedRows: []
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
expandAll() {
|
|
2841
|
-
this.update({
|
|
2842
|
-
expandedRows: true,
|
|
2843
|
-
collapsedRows: []
|
|
2844
|
-
});
|
|
2845
|
-
}
|
|
2846
|
-
isGroupRowExpanded(keys) {
|
|
2847
|
-
var _a, _b;
|
|
2848
|
-
if (this.expandedAll === true) {
|
|
2849
|
-
if (this.collapsedAll === true) {
|
|
2850
|
-
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;
|
|
2851
2675
|
}
|
|
2852
|
-
|
|
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);
|
|
2853
2679
|
}
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
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
|
+
}
|
|
2858
2706
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
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
|
+
rootGroupBy: groupBy,
|
|
2894
|
+
groupBy: groupNesting === groupBy.length ? groupBy : groupBy.slice(0, groupNesting),
|
|
2895
|
+
isGroupRow: true,
|
|
2896
|
+
pivotValuesMap: pivotDeepMap,
|
|
2897
|
+
groupNesting,
|
|
2898
|
+
reducerResults
|
|
2899
|
+
};
|
|
2900
|
+
return enhancedGroupData;
|
|
2901
|
+
}
|
|
2902
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
2903
|
+
if (reducers) {
|
|
2904
|
+
for (let key in reducers)
|
|
2905
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2906
|
+
const reducer = reducers[key];
|
|
2907
|
+
if (reducer.done) {
|
|
2908
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
return reducerResults;
|
|
2913
|
+
}
|
|
2914
|
+
function enhancedFlatten(param) {
|
|
2915
|
+
const {
|
|
2916
|
+
groupResult,
|
|
2917
|
+
toPrimaryKey,
|
|
2918
|
+
groupRowsState,
|
|
2919
|
+
generateGroupRows,
|
|
2920
|
+
reducers = {}
|
|
2921
|
+
} = param;
|
|
2922
|
+
const { groupParams, deepMap, pivot } = groupResult;
|
|
2923
|
+
const { groupBy } = groupParams;
|
|
2924
|
+
const groupByStrings = groupBy.map((g) => g.field);
|
|
2925
|
+
const result = [];
|
|
2926
|
+
const parents = [];
|
|
2927
|
+
const indexInParentGroups = [];
|
|
2928
|
+
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
2929
|
+
var _a;
|
|
2930
|
+
const items = deepMapValue.items;
|
|
2931
|
+
const groupNesting = groupKeys.length;
|
|
2932
|
+
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
2933
|
+
const enhancedGroupData = getEnhancedGroupData({
|
|
2934
|
+
groupBy: groupByStrings,
|
|
2935
|
+
parents: Array.from(parents),
|
|
2936
|
+
reducers,
|
|
2937
|
+
indexInGroup,
|
|
2938
|
+
indexInParentGroups: Array.from(indexInParentGroups),
|
|
2939
|
+
indexInAll: result.length,
|
|
2940
|
+
groupKeys,
|
|
2941
|
+
collapsed
|
|
2942
|
+
}, deepMapValue);
|
|
2943
|
+
const include = generateGroupRows || collapsed;
|
|
2944
|
+
if (include) {
|
|
2945
|
+
result.push(enhancedGroupData);
|
|
2946
|
+
}
|
|
2947
|
+
if (collapsed) {
|
|
2948
|
+
parents.forEach((parent) => {
|
|
2949
|
+
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
2950
|
+
parent.collapsedGroupsCount += 1;
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
indexInParentGroups.push(indexInGroup);
|
|
2954
|
+
parents.push(enhancedGroupData);
|
|
2955
|
+
if (!collapsed) {
|
|
2956
|
+
if (!next) {
|
|
2957
|
+
if (!pivot) {
|
|
2958
|
+
const startIndex = result.length;
|
|
2959
|
+
result.push(...items.map((item, index) => {
|
|
2960
|
+
return {
|
|
2961
|
+
id: toPrimaryKey(item),
|
|
2962
|
+
data: item,
|
|
2963
|
+
isGroupRow: false,
|
|
2964
|
+
collapsed: false,
|
|
2965
|
+
groupKeys,
|
|
2966
|
+
parents: Array.from(parents),
|
|
2967
|
+
indexInParentGroups: [...indexInParentGroups, index],
|
|
2968
|
+
indexInGroup: index,
|
|
2969
|
+
indexInAll: startIndex + index,
|
|
2970
|
+
groupBy: groupByStrings,
|
|
2971
|
+
groupNesting,
|
|
2972
|
+
groupCount: enhancedGroupData.groupCount
|
|
2973
|
+
};
|
|
2974
|
+
}));
|
|
2975
|
+
}
|
|
2976
|
+
} else {
|
|
2977
|
+
next();
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
parents.pop();
|
|
2981
|
+
indexInParentGroups.pop();
|
|
2982
|
+
});
|
|
2983
|
+
return {
|
|
2984
|
+
data: result
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
// src/components/hooks/useEffectWithChanges.ts
|
|
2989
|
+
var import_react14 = __toModule(require("react"));
|
|
2990
|
+
function useEffectWithChanges(fn, deps) {
|
|
2991
|
+
const prevRef = (0, import_react14.useRef)({});
|
|
2992
|
+
const oldValuesRef = (0, import_react14.useRef)({});
|
|
2993
|
+
const oldValues = oldValuesRef.current;
|
|
2994
|
+
const changesRef = (0, import_react14.useRef)({});
|
|
2995
|
+
const changes = changesRef.current;
|
|
2996
|
+
const useEffectDeps = [];
|
|
2997
|
+
for (let k in deps) {
|
|
2998
|
+
if (deps.hasOwnProperty(k)) {
|
|
2999
|
+
if (deps[k] !== prevRef.current[k]) {
|
|
3000
|
+
changes[k] = deps[k];
|
|
3001
|
+
oldValues[k] = prevRef.current[k];
|
|
3002
|
+
}
|
|
3003
|
+
useEffectDeps.push(deps[k]);
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
prevRef.current = deps;
|
|
3007
|
+
(0, import_react14.useEffect)(() => {
|
|
3008
|
+
const changes2 = changesRef.current;
|
|
3009
|
+
const result = fn(changes2, oldValues);
|
|
3010
|
+
changesRef.current = {};
|
|
3011
|
+
oldValuesRef.current = {};
|
|
3012
|
+
return result;
|
|
3013
|
+
}, useEffectDeps);
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
3017
|
+
var SKIP_DATA_CHANGES_KEYS = {
|
|
3018
|
+
originalDataArray: true,
|
|
3019
|
+
changes: true
|
|
3020
|
+
};
|
|
3021
|
+
function buildDataSourceDataParams(componentState, overrides) {
|
|
3022
|
+
var _a, _b;
|
|
3023
|
+
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
3024
|
+
const dataSourceParams = {
|
|
3025
|
+
originalDataArray: componentState.originalDataArray,
|
|
3026
|
+
sortInfo,
|
|
3027
|
+
groupBy: componentState.groupBy,
|
|
3028
|
+
pivotBy: componentState.pivotBy,
|
|
3029
|
+
aggregationReducers: componentState.aggregationReducers
|
|
3030
|
+
};
|
|
3031
|
+
if (componentState.livePagination !== void 0) {
|
|
3032
|
+
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3033
|
+
dataSourceParams.cursorId = componentState.cursorId;
|
|
3034
|
+
}
|
|
3035
|
+
if (componentState.fullLazyLoad) {
|
|
3036
|
+
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3037
|
+
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3038
|
+
dataSourceParams.lazyLoadStartIndex = 0;
|
|
3039
|
+
}
|
|
3040
|
+
dataSourceParams.groupKeys = [];
|
|
3041
|
+
}
|
|
3042
|
+
if (overrides) {
|
|
3043
|
+
Object.assign(dataSourceParams, overrides);
|
|
3044
|
+
}
|
|
3045
|
+
const changes = {};
|
|
3046
|
+
const oldDataSourceParams = componentState.dataParams || {};
|
|
3047
|
+
for (let k in dataSourceParams) {
|
|
3048
|
+
if (dataSourceParams.hasOwnProperty(k) && !SKIP_DATA_CHANGES_KEYS[k]) {
|
|
3049
|
+
const key = k;
|
|
3050
|
+
if (dataSourceParams[key] !== oldDataSourceParams[key]) {
|
|
3051
|
+
changes[key] = true;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
dataSourceParams.changes = changes;
|
|
3056
|
+
return dataSourceParams;
|
|
3057
|
+
}
|
|
3058
|
+
function loadData(data, componentState, actions, overrides) {
|
|
3059
|
+
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3060
|
+
if (typeof data === "function") {
|
|
3061
|
+
data = data(dataParams);
|
|
3062
|
+
}
|
|
3063
|
+
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3064
|
+
if (dataIsPromise) {
|
|
3065
|
+
actions.loading = true;
|
|
3066
|
+
}
|
|
3067
|
+
Promise.resolve(data).then((dataParam) => {
|
|
3068
|
+
var _a, _b, _c;
|
|
3069
|
+
let dataArray = [];
|
|
3070
|
+
let skipAssign = false;
|
|
3071
|
+
if (Array.isArray(dataParam.data)) {
|
|
3072
|
+
const remoteData = dataParam;
|
|
3073
|
+
dataArray = remoteData.data;
|
|
3074
|
+
if (remoteData.livePaginationCursor !== void 0) {
|
|
3075
|
+
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
3076
|
+
}
|
|
3077
|
+
if (remoteData.mappings) {
|
|
3078
|
+
actions.pivotMappings = remoteData.mappings;
|
|
3079
|
+
}
|
|
3080
|
+
if (componentState.fullLazyLoad && dataParams.groupKeys) {
|
|
3081
|
+
const lazyGroupData = DeepMap.clone(componentState.originalLazyGroupData);
|
|
3082
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3083
|
+
const newGroupRowInfo = {
|
|
3084
|
+
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
3085
|
+
items: dataArray
|
|
3086
|
+
};
|
|
3087
|
+
if (dataParams.lazyLoadBatchSize) {
|
|
3088
|
+
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3089
|
+
const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
|
|
3090
|
+
items: [],
|
|
3091
|
+
totalCount: newGroupRowInfo.totalCount
|
|
3092
|
+
};
|
|
3093
|
+
currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
|
|
3094
|
+
const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
|
|
3095
|
+
const end = start + ((_c = dataParams.lazyLoadBatchSize) != null ? _c : dataArray.length);
|
|
3096
|
+
for (let i = start; i < end; i++) {
|
|
3097
|
+
currentGroupRowInfo.items[i] = newGroupRowInfo.items[i - start];
|
|
3098
|
+
}
|
|
3099
|
+
if (!existingGroupRowInfo) {
|
|
3100
|
+
lazyGroupData.set(key, currentGroupRowInfo);
|
|
3101
|
+
}
|
|
3102
|
+
} else {
|
|
3103
|
+
lazyGroupData.set(key, newGroupRowInfo);
|
|
3104
|
+
}
|
|
3105
|
+
skipAssign = true;
|
|
3106
|
+
actions.originalLazyGroupData = lazyGroupData;
|
|
3107
|
+
}
|
|
3108
|
+
} else {
|
|
3109
|
+
dataArray = dataParam;
|
|
3110
|
+
}
|
|
3111
|
+
if (!skipAssign) {
|
|
3112
|
+
actions.originalDataArray = dataArray;
|
|
3113
|
+
}
|
|
3114
|
+
if (dataIsPromise) {
|
|
3115
|
+
actions.loading = false;
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
function useLoadData() {
|
|
3120
|
+
const {
|
|
3121
|
+
getComponentState,
|
|
3122
|
+
componentActions: actions,
|
|
3123
|
+
componentState
|
|
3124
|
+
} = useComponentState();
|
|
3125
|
+
const {
|
|
3126
|
+
data,
|
|
3127
|
+
notifyScrollbarsChange,
|
|
3128
|
+
sortInfo,
|
|
3129
|
+
groupBy,
|
|
3130
|
+
pivotBy,
|
|
3131
|
+
livePagination,
|
|
3132
|
+
livePaginationCursor,
|
|
3133
|
+
cursorId: stateCursorId,
|
|
3134
|
+
lazyLoadBatchSize,
|
|
3135
|
+
notifyScrollStop
|
|
3136
|
+
} = componentState;
|
|
3137
|
+
const [scrollbars, setScrollbars] = (0, import_react15.useState)({
|
|
3138
|
+
vertical: false,
|
|
3139
|
+
horizontal: false
|
|
3140
|
+
});
|
|
3141
|
+
const scrollbarsRef = (0, import_react15.useRef)(scrollbars);
|
|
3142
|
+
(0, import_react15.useEffect)(() => {
|
|
3143
|
+
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
3144
|
+
if (!scrollbars2) {
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
scrollbarsRef.current = scrollbars2;
|
|
3148
|
+
setScrollbars(scrollbars2);
|
|
3149
|
+
});
|
|
3150
|
+
return () => notifyScrollbarsChange.destroy();
|
|
3151
|
+
}, [notifyScrollbarsChange]);
|
|
3152
|
+
(0, import_react15.useEffect)(() => {
|
|
3153
|
+
const frameId = requestAnimationFrame(() => {
|
|
3154
|
+
var _a;
|
|
3155
|
+
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical) && livePaginationCursor) {
|
|
3156
|
+
actions.cursorId = livePaginationCursor;
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
return () => cancelAnimationFrame(frameId);
|
|
3160
|
+
}, [livePaginationCursor]);
|
|
3161
|
+
(0, import_react15.useEffect)(() => {
|
|
3162
|
+
const { livePaginationCursor: livePaginationCursor2, livePagination: livePagination2 } = getComponentState();
|
|
3163
|
+
if (!scrollbars.vertical && livePagination2) {
|
|
3164
|
+
if (livePaginationCursor2) {
|
|
3165
|
+
actions.cursorId = livePaginationCursor2;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
}, [scrollbars.vertical]);
|
|
3169
|
+
const depsObject = {
|
|
3170
|
+
sortInfo,
|
|
3171
|
+
groupBy,
|
|
3172
|
+
pivotBy,
|
|
3173
|
+
cursorId: livePagination ? stateCursorId : null
|
|
3174
|
+
};
|
|
3175
|
+
const initialRef = (0, import_react15.useRef)(true);
|
|
3176
|
+
(0, import_react15.useEffect)(() => {
|
|
3177
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3178
|
+
return notifyScrollStop.onChange((param) => {
|
|
3179
|
+
console.log("scroll stop", param);
|
|
3180
|
+
if (!param) {
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
const componentState2 = getComponentState();
|
|
3184
|
+
const {
|
|
3185
|
+
firstVisibleRowIndex: startIndex,
|
|
3186
|
+
lastVisibleRowIndex: endIndex
|
|
3187
|
+
} = param;
|
|
3188
|
+
const firstBatchStart = Math.floor(startIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3189
|
+
const lastBatchStart = Math.floor(endIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3190
|
+
const isRowLoaded = (index) => componentState2.dataArray[index].data != null;
|
|
3191
|
+
for (let batchStartIndex = firstBatchStart; batchStartIndex <= lastBatchStart; batchStartIndex = batchStartIndex + lazyLoadBatchSize) {
|
|
3192
|
+
if (!isRowLoaded(batchStartIndex)) {
|
|
3193
|
+
loadData(componentState2.data, componentState2, actions, {
|
|
3194
|
+
lazyLoadBatchSize,
|
|
3195
|
+
lazyLoadStartIndex: batchStartIndex
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
});
|
|
3200
|
+
}
|
|
3201
|
+
return;
|
|
3202
|
+
}, [lazyLoadBatchSize]);
|
|
3203
|
+
useEffectWithChanges(() => {
|
|
3204
|
+
const componentState2 = getComponentState();
|
|
3205
|
+
if (typeof componentState2.data !== "function") {
|
|
3206
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3207
|
+
}
|
|
3208
|
+
}, { data });
|
|
3209
|
+
useEffectWithChanges(() => {
|
|
3210
|
+
const componentState2 = getComponentState();
|
|
3211
|
+
if (typeof componentState2.data === "function") {
|
|
3212
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3213
|
+
}
|
|
3214
|
+
}, __spreadProps(__spreadValues({}, depsObject), { data }));
|
|
3215
|
+
useEffectWithChanges((_changes, _prevValues) => {
|
|
3216
|
+
const componentState2 = getComponentState();
|
|
3217
|
+
if (initialRef.current) {
|
|
3218
|
+
initialRef.current = false;
|
|
3219
|
+
actions.dataParams = buildDataSourceDataParams(componentState2);
|
|
3220
|
+
}
|
|
3221
|
+
}, depsObject);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
3225
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
3226
|
+
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
3227
|
+
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
3228
|
+
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
3229
|
+
if (weakMap && weakMap.has(sortInfo)) {
|
|
3230
|
+
const prevResult = weakMap.get(sortInfo);
|
|
3231
|
+
if (prevResult && prevResult.length === result.length) {
|
|
3232
|
+
return prevResult;
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
if (weakMap && sortInfo) {
|
|
3236
|
+
weakMap.set(sortInfo, result);
|
|
3237
|
+
}
|
|
3238
|
+
return result;
|
|
3239
|
+
};
|
|
3240
|
+
|
|
3241
|
+
// src/components/DataSource/GroupRowsState.ts
|
|
3242
|
+
var GroupRowsState = class {
|
|
3243
|
+
constructor(state) {
|
|
3244
|
+
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
3245
|
+
}
|
|
3246
|
+
getState() {
|
|
3247
|
+
var _a, _b, _c, _d;
|
|
3248
|
+
return {
|
|
3249
|
+
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
3250
|
+
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
3251
|
+
};
|
|
3252
|
+
}
|
|
3253
|
+
destroy() {
|
|
3254
|
+
var _a, _b;
|
|
3255
|
+
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
3256
|
+
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
3257
|
+
delete this.expandedMap;
|
|
3258
|
+
delete this.collapsedMap;
|
|
3259
|
+
}
|
|
3260
|
+
update(state) {
|
|
3261
|
+
var _a, _b, _c, _d;
|
|
3262
|
+
this.initialState = state;
|
|
3263
|
+
const { collapsedRows, expandedRows } = this.initialState;
|
|
3264
|
+
this.collapsedAll = collapsedRows === true;
|
|
3265
|
+
this.expandedAll = expandedRows === true;
|
|
3266
|
+
if (this.collapsedAll && this.expandedAll) {
|
|
3267
|
+
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
3268
|
+
}
|
|
3269
|
+
if (collapsedRows !== true) {
|
|
3270
|
+
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
3271
|
+
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
3272
|
+
}
|
|
3273
|
+
if (expandedRows !== true) {
|
|
3274
|
+
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
3275
|
+
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
areAllCollapsed() {
|
|
3279
|
+
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
3280
|
+
}
|
|
3281
|
+
areAllExpanded() {
|
|
3282
|
+
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
3283
|
+
}
|
|
3284
|
+
collapseAll() {
|
|
3285
|
+
this.update({
|
|
3286
|
+
collapsedRows: true,
|
|
3287
|
+
expandedRows: []
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
expandAll() {
|
|
3291
|
+
this.update({
|
|
3292
|
+
expandedRows: true,
|
|
3293
|
+
collapsedRows: []
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
isGroupRowExpanded(keys) {
|
|
3297
|
+
var _a, _b;
|
|
3298
|
+
if (this.expandedAll === true) {
|
|
3299
|
+
if (this.collapsedAll === true) {
|
|
3300
|
+
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
3301
|
+
}
|
|
3302
|
+
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
3303
|
+
}
|
|
3304
|
+
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
3305
|
+
}
|
|
3306
|
+
isGroupRowCollapsed(keys) {
|
|
3307
|
+
return !this.isGroupRowExpanded(keys);
|
|
3308
|
+
}
|
|
3309
|
+
setGroupRowExpanded(keys, shouldExpand) {
|
|
3310
|
+
var _a;
|
|
2861
3311
|
if (shouldExpand === this.isGroupRowExpanded(keys)) {
|
|
2862
3312
|
return;
|
|
2863
3313
|
}
|
|
@@ -2899,7 +3349,7 @@ var GroupRowsState = class {
|
|
|
2899
3349
|
};
|
|
2900
3350
|
|
|
2901
3351
|
// src/utils/shallowEqualObjects.ts
|
|
2902
|
-
function shallowEqualObjects(objA, objB) {
|
|
3352
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
2903
3353
|
if (objA === objB) {
|
|
2904
3354
|
return true;
|
|
2905
3355
|
}
|
|
@@ -2908,12 +3358,21 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2908
3358
|
}
|
|
2909
3359
|
var aKeys = Object.keys(objA);
|
|
2910
3360
|
var bKeys = Object.keys(objB);
|
|
3361
|
+
if (ignoreKeys) {
|
|
3362
|
+
aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3363
|
+
bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3364
|
+
}
|
|
2911
3365
|
var len = aKeys.length;
|
|
2912
3366
|
if (bKeys.length !== len) {
|
|
2913
3367
|
return false;
|
|
2914
3368
|
}
|
|
2915
3369
|
for (var i = 0; i < len; i++) {
|
|
2916
3370
|
var key = aKeys[i];
|
|
3371
|
+
if (ignoreKeys) {
|
|
3372
|
+
if (ignoreKeys.has(key)) {
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
2917
3376
|
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2918
3377
|
return false;
|
|
2919
3378
|
}
|
|
@@ -2924,12 +3383,12 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2924
3383
|
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2925
3384
|
var map = new WeakMap();
|
|
2926
3385
|
var getCompareDefault = (a) => a;
|
|
2927
|
-
function discardCallsWithEqualArg(fn, timeframe = 50,
|
|
3386
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
2928
3387
|
map.set(fn, {
|
|
2929
3388
|
lastCallTime: 0,
|
|
2930
3389
|
lastCallArg: null
|
|
2931
3390
|
});
|
|
2932
|
-
const getCompare =
|
|
3391
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
2933
3392
|
return (arg) => {
|
|
2934
3393
|
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2935
3394
|
lastCallTime: 0,
|
|
@@ -2950,17 +3409,25 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
|
2950
3409
|
}
|
|
2951
3410
|
|
|
2952
3411
|
// src/components/DataSource/state/getInitialState.ts
|
|
3412
|
+
var defaultCursorId = Symbol("cursorId");
|
|
2953
3413
|
function initSetupState2() {
|
|
2954
3414
|
const now = Date.now();
|
|
2955
3415
|
const originalDataArray = [];
|
|
2956
3416
|
const dataArray = [];
|
|
3417
|
+
const originalLazyGroupData = new DeepMap();
|
|
2957
3418
|
return {
|
|
2958
3419
|
dataParams: void 0,
|
|
2959
3420
|
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3421
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
2960
3422
|
pivotTotalColumnPosition: "end",
|
|
3423
|
+
originalLazyGroupData,
|
|
2961
3424
|
originalDataArray,
|
|
2962
|
-
|
|
3425
|
+
cursorId: defaultCursorId,
|
|
2963
3426
|
showSeparatePivotColumnForSingleAggregation: false,
|
|
3427
|
+
propsCache: new Map([
|
|
3428
|
+
["sortInfo", new WeakMap()]
|
|
3429
|
+
]),
|
|
3430
|
+
pivotMappings: void 0,
|
|
2964
3431
|
pivotColumns: void 0,
|
|
2965
3432
|
pivotColumnGroups: void 0,
|
|
2966
3433
|
dataArray,
|
|
@@ -2976,22 +3443,24 @@ function initSetupState2() {
|
|
|
2976
3443
|
lastGroupDataArray: void 0
|
|
2977
3444
|
};
|
|
2978
3445
|
}
|
|
2979
|
-
function
|
|
3446
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
2980
3447
|
const obj = __spreadValues({}, dataParams);
|
|
2981
3448
|
delete obj.originalDataArray;
|
|
2982
3449
|
return obj;
|
|
2983
3450
|
}
|
|
2984
|
-
var forwardProps3 = () => {
|
|
3451
|
+
var forwardProps3 = (setupState) => {
|
|
2985
3452
|
return {
|
|
2986
|
-
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100,
|
|
3453
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3454
|
+
fullLazyLoad: 1,
|
|
2987
3455
|
data: 1,
|
|
2988
3456
|
pivotBy: 1,
|
|
2989
3457
|
primaryKey: 1,
|
|
2990
3458
|
livePagination: 1,
|
|
2991
|
-
|
|
3459
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
2992
3460
|
aggregationReducers: 1,
|
|
3461
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
2993
3462
|
loading: (loading) => loading != null ? loading : false,
|
|
2994
|
-
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo),
|
|
3463
|
+
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
2995
3464
|
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
2996
3465
|
groupRowsState: (groupRowsState) => {
|
|
2997
3466
|
return groupRowsState || new GroupRowsState({
|
|
@@ -3001,288 +3470,111 @@ var forwardProps3 = () => {
|
|
|
3001
3470
|
}
|
|
3002
3471
|
};
|
|
3003
3472
|
};
|
|
3004
|
-
function
|
|
3005
|
-
const
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
}
|
|
3012
|
-
function getInterceptActions() {
|
|
3013
|
-
return {
|
|
3014
|
-
sortInfo: (sortInfo, { actions, state }) => {
|
|
3015
|
-
const dataParams = buildDataSourceDataParams(state);
|
|
3016
|
-
dataParams.sortInfo = sortInfo;
|
|
3017
|
-
actions.dataParams = dataParams;
|
|
3018
|
-
}
|
|
3019
|
-
};
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
// src/utils/groupAndPivot/index.ts
|
|
3023
|
-
function DEFAULT_TO_KEY(value) {
|
|
3024
|
-
return value;
|
|
3025
|
-
}
|
|
3026
|
-
function initReducers(reducers) {
|
|
3027
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3028
|
-
return {};
|
|
3029
|
-
}
|
|
3030
|
-
const result = {};
|
|
3031
|
-
for (let key in reducers)
|
|
3032
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3033
|
-
result[key] = reducers[key].initialValue;
|
|
3034
|
-
}
|
|
3035
|
-
return result;
|
|
3036
|
-
}
|
|
3037
|
-
function computeReducersFor(data, reducers, reducerResults) {
|
|
3038
|
-
var _a, _b;
|
|
3039
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3040
|
-
return;
|
|
3041
|
-
}
|
|
3042
|
-
for (let key in reducers)
|
|
3043
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3044
|
-
const reducer = reducers[key];
|
|
3045
|
-
const currentValue = reducerResults[key];
|
|
3046
|
-
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
3047
|
-
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
3048
|
-
}
|
|
3473
|
+
function getLivePaginationCursorValue(livePaginationCursorProp, state) {
|
|
3474
|
+
const livePaginationCursor = typeof livePaginationCursorProp === "function" ? livePaginationCursorProp({
|
|
3475
|
+
array: state.originalDataArray,
|
|
3476
|
+
length: state.originalDataArray.length,
|
|
3477
|
+
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3478
|
+
}) : livePaginationCursorProp;
|
|
3479
|
+
return livePaginationCursor;
|
|
3049
3480
|
}
|
|
3050
|
-
function
|
|
3051
|
-
const {
|
|
3052
|
-
|
|
3053
|
-
defaultToKey = DEFAULT_TO_KEY,
|
|
3054
|
-
pivot,
|
|
3055
|
-
reducers
|
|
3056
|
-
} = groupParams;
|
|
3057
|
-
const groupByLength = groupBy.length;
|
|
3058
|
-
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3059
|
-
const deepMap = new DeepMap();
|
|
3060
|
-
let currentGroupKeys = [];
|
|
3061
|
-
let currentPivotKeys = [];
|
|
3062
|
-
const initialReducerValue = initReducers(reducers);
|
|
3063
|
-
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3064
|
-
for (let i = 0, len = data.length; i < len; i++) {
|
|
3065
|
-
let item = data[i];
|
|
3066
|
-
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
3067
|
-
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
3068
|
-
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
3069
|
-
currentGroupKeys.push(key);
|
|
3070
|
-
if (!deepMap.has(currentGroupKeys)) {
|
|
3071
|
-
const deepMapGroupValue = {
|
|
3072
|
-
items: [],
|
|
3073
|
-
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3074
|
-
};
|
|
3075
|
-
if (pivot) {
|
|
3076
|
-
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3077
|
-
}
|
|
3078
|
-
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3079
|
-
}
|
|
3080
|
-
const {
|
|
3081
|
-
items: currentGroupItems,
|
|
3082
|
-
reducerResults,
|
|
3083
|
-
pivotDeepMap
|
|
3084
|
-
} = deepMap.get(currentGroupKeys);
|
|
3085
|
-
currentGroupItems.push(item);
|
|
3086
|
-
if (reducers) {
|
|
3087
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3088
|
-
}
|
|
3089
|
-
if (pivot) {
|
|
3090
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3091
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3092
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3093
|
-
currentPivotKeys.push(pivotKey);
|
|
3094
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3095
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3096
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3097
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3098
|
-
items: []
|
|
3099
|
-
});
|
|
3100
|
-
}
|
|
3101
|
-
const {
|
|
3102
|
-
reducerResults: pivotReducerResults,
|
|
3103
|
-
items: pivotGroupItems
|
|
3104
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3105
|
-
pivotGroupItems.push(item);
|
|
3106
|
-
if (reducers) {
|
|
3107
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3108
|
-
}
|
|
3109
|
-
}
|
|
3110
|
-
currentPivotKeys.length = 0;
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
if (reducers) {
|
|
3114
|
-
computeReducersFor(item, reducers, globalReducerResults);
|
|
3115
|
-
}
|
|
3116
|
-
currentGroupKeys.length = 0;
|
|
3117
|
-
}
|
|
3118
|
-
if (reducers) {
|
|
3119
|
-
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
3120
|
-
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
3121
|
-
if (pivot) {
|
|
3122
|
-
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
3123
|
-
completeReducers(reducers, pivotReducerResults, items);
|
|
3124
|
-
next2 == null ? void 0 : next2();
|
|
3125
|
-
});
|
|
3126
|
-
}
|
|
3127
|
-
next == null ? void 0 : next();
|
|
3128
|
-
});
|
|
3129
|
-
}
|
|
3130
|
-
if (reducers) {
|
|
3131
|
-
completeReducers(reducers, globalReducerResults, data);
|
|
3132
|
-
}
|
|
3481
|
+
function mapPropsToState2(params) {
|
|
3482
|
+
const { props, state, oldState } = params;
|
|
3483
|
+
const controlledSort = isControlledValue(props.sortInfo);
|
|
3133
3484
|
const result = {
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
initialData: data,
|
|
3137
|
-
reducerResults: globalReducerResults
|
|
3485
|
+
controlledSort,
|
|
3486
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3138
3487
|
};
|
|
3139
|
-
if (
|
|
3140
|
-
|
|
3141
|
-
|
|
3488
|
+
if (props.livePagination) {
|
|
3489
|
+
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
3490
|
+
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? dataArrayChanged ? getLivePaginationCursorValue(props.livePaginationCursor, state) : state.livePaginationCursor : props.livePaginationCursor;
|
|
3491
|
+
result.livePaginationCursor = livePaginationCursor;
|
|
3142
3492
|
}
|
|
3143
3493
|
return result;
|
|
3144
3494
|
}
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
const
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3495
|
+
var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
3496
|
+
function onPropChange(params, props, actions) {
|
|
3497
|
+
const { name, newValue } = params;
|
|
3498
|
+
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3499
|
+
if (props.fullLazyLoad) {
|
|
3500
|
+
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3501
|
+
}
|
|
3502
|
+
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
3503
|
+
actions.groupRowsState = new GroupRowsState({
|
|
3504
|
+
collapsedRows: true,
|
|
3505
|
+
expandedRows: []
|
|
3506
|
+
});
|
|
3153
3507
|
}
|
|
3154
|
-
return acc;
|
|
3155
|
-
}, result);
|
|
3156
|
-
return result;
|
|
3157
|
-
}
|
|
3158
|
-
function getEnhancedGroupData(options, deepMapValue) {
|
|
3159
|
-
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
3160
|
-
const groupNesting = groupKeys.length;
|
|
3161
|
-
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
3162
|
-
let data = null;
|
|
3163
|
-
if (Object.keys(reducerResults).length > 0) {
|
|
3164
|
-
data = {};
|
|
3165
|
-
for (let key in reducers)
|
|
3166
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3167
|
-
const reducer = reducers[key];
|
|
3168
|
-
const field = reducer.field;
|
|
3169
|
-
if (field) {
|
|
3170
|
-
data[field] = reducerResults[key];
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
3508
|
}
|
|
3174
|
-
const enhancedGroupData = {
|
|
3175
|
-
data,
|
|
3176
|
-
groupCount: groupItems.length,
|
|
3177
|
-
groupData: groupItems,
|
|
3178
|
-
groupKeys,
|
|
3179
|
-
id: groupKeys,
|
|
3180
|
-
collapsed,
|
|
3181
|
-
parents,
|
|
3182
|
-
collapsedChildrenCount: 0,
|
|
3183
|
-
collapsedGroupsCount: 0,
|
|
3184
|
-
indexInParentGroups: options.indexInParentGroups,
|
|
3185
|
-
indexInGroup: options.indexInGroup,
|
|
3186
|
-
indexInAll: options.indexInAll,
|
|
3187
|
-
value: groupKeys[groupKeys.length - 1],
|
|
3188
|
-
groupBy: groupBy.slice(0, groupNesting),
|
|
3189
|
-
isGroupRow: true,
|
|
3190
|
-
pivotValuesMap: pivotDeepMap,
|
|
3191
|
-
groupNesting,
|
|
3192
|
-
reducerResults
|
|
3193
|
-
};
|
|
3194
|
-
return enhancedGroupData;
|
|
3195
3509
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3510
|
+
var debugDataParams = dbg("DataSource:dataParams");
|
|
3511
|
+
function getInterceptActions() {
|
|
3512
|
+
return {
|
|
3513
|
+
sortInfo: (sortInfo, { actions, state }) => {
|
|
3514
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3515
|
+
sortInfo,
|
|
3516
|
+
livePaginationCursor: null
|
|
3517
|
+
});
|
|
3518
|
+
actions.dataParams = dataParams;
|
|
3519
|
+
if (state.livePagination) {
|
|
3520
|
+
requestAnimationFrame(() => {
|
|
3521
|
+
actions.livePaginationCursor = null;
|
|
3522
|
+
});
|
|
3204
3523
|
}
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
groupResult,
|
|
3211
|
-
toPrimaryKey,
|
|
3212
|
-
groupRowsState,
|
|
3213
|
-
generateGroupRows,
|
|
3214
|
-
reducers = {}
|
|
3215
|
-
} = param;
|
|
3216
|
-
const { groupParams, deepMap, pivot } = groupResult;
|
|
3217
|
-
const { groupBy } = groupParams;
|
|
3218
|
-
const groupByStrings = groupBy.map((g) => g.field);
|
|
3219
|
-
const result = [];
|
|
3220
|
-
const parents = [];
|
|
3221
|
-
const indexInParentGroups = [];
|
|
3222
|
-
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
3223
|
-
var _a;
|
|
3224
|
-
const items = deepMapValue.items;
|
|
3225
|
-
const groupNesting = groupKeys.length;
|
|
3226
|
-
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
3227
|
-
const enhancedGroupData = getEnhancedGroupData({
|
|
3228
|
-
groupBy: groupByStrings,
|
|
3229
|
-
parents: Array.from(parents),
|
|
3230
|
-
reducers,
|
|
3231
|
-
indexInGroup,
|
|
3232
|
-
indexInParentGroups: Array.from(indexInParentGroups),
|
|
3233
|
-
indexInAll: result.length,
|
|
3234
|
-
groupKeys,
|
|
3235
|
-
collapsed
|
|
3236
|
-
}, deepMapValue);
|
|
3237
|
-
const include = generateGroupRows || collapsed;
|
|
3238
|
-
if (include) {
|
|
3239
|
-
result.push(enhancedGroupData);
|
|
3240
|
-
}
|
|
3241
|
-
if (collapsed) {
|
|
3242
|
-
parents.forEach((parent) => {
|
|
3243
|
-
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
3244
|
-
parent.collapsedGroupsCount += 1;
|
|
3524
|
+
},
|
|
3525
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3526
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3527
|
+
groupBy,
|
|
3528
|
+
livePaginationCursor: null
|
|
3245
3529
|
});
|
|
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
|
-
|
|
3271
|
-
|
|
3530
|
+
actions.dataParams = dataParams;
|
|
3531
|
+
if (state.livePagination) {
|
|
3532
|
+
requestAnimationFrame(() => {
|
|
3533
|
+
actions.livePaginationCursor = null;
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
},
|
|
3537
|
+
pivotBy: (pivotBy, { actions, state }) => {
|
|
3538
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3539
|
+
pivotBy,
|
|
3540
|
+
livePaginationCursor: null
|
|
3541
|
+
});
|
|
3542
|
+
actions.dataParams = dataParams;
|
|
3543
|
+
if (state.livePagination) {
|
|
3544
|
+
requestAnimationFrame(() => {
|
|
3545
|
+
actions.livePaginationCursor = null;
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3548
|
+
},
|
|
3549
|
+
cursorId: (cursorId, { actions, state }) => {
|
|
3550
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3551
|
+
cursorId
|
|
3552
|
+
});
|
|
3553
|
+
actions.dataParams = dataParams;
|
|
3554
|
+
},
|
|
3555
|
+
livePaginationCursor: (livePaginationCursor, { actions, state }) => {
|
|
3556
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3557
|
+
livePaginationCursor
|
|
3558
|
+
});
|
|
3559
|
+
actions.dataParams = dataParams;
|
|
3560
|
+
},
|
|
3561
|
+
dataParams: (dataParams, { state }) => {
|
|
3562
|
+
if (shallowEqualObjects(dataParams, state.dataParams, new Set([
|
|
3563
|
+
"changes",
|
|
3564
|
+
"originalDataArray"
|
|
3565
|
+
]))) {
|
|
3566
|
+
return false;
|
|
3272
3567
|
}
|
|
3568
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3569
|
+
return true;
|
|
3273
3570
|
}
|
|
3274
|
-
parents.pop();
|
|
3275
|
-
indexInParentGroups.pop();
|
|
3276
|
-
});
|
|
3277
|
-
return {
|
|
3278
|
-
data: result
|
|
3279
3571
|
};
|
|
3280
3572
|
}
|
|
3281
3573
|
|
|
3282
3574
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3283
3575
|
function prepareColumn(column) {
|
|
3284
3576
|
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3285
|
-
if (pivotByForColumn.column) {
|
|
3577
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3286
3578
|
if (typeof pivotByForColumn.column === "function") {
|
|
3287
3579
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3288
3580
|
} else {
|
|
@@ -3293,7 +3585,7 @@ function prepareColumn(column) {
|
|
|
3293
3585
|
}
|
|
3294
3586
|
function prepareColumnGroup(columnGroup) {
|
|
3295
3587
|
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3296
|
-
if (pivotByForColumnGroup.columnGroup) {
|
|
3588
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3297
3589
|
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3298
3590
|
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3299
3591
|
} else {
|
|
@@ -3322,6 +3614,9 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3322
3614
|
valueGetter: (params) => {
|
|
3323
3615
|
var _a;
|
|
3324
3616
|
const { rowInfo } = params;
|
|
3617
|
+
if (!rowInfo.data) {
|
|
3618
|
+
return "Loading ... TODO replace this with a loading indicator";
|
|
3619
|
+
}
|
|
3325
3620
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3326
3621
|
}
|
|
3327
3622
|
}
|
|
@@ -3353,7 +3648,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3353
3648
|
}));
|
|
3354
3649
|
}
|
|
3355
3650
|
aggregationReducers.forEach((reducer, index) => {
|
|
3356
|
-
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.id;
|
|
3651
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3357
3652
|
const computedPivotColumn = prepareColumn({
|
|
3358
3653
|
pivotBy,
|
|
3359
3654
|
pivotColumn: true,
|
|
@@ -3372,7 +3667,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3372
3667
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3373
3668
|
}
|
|
3374
3669
|
});
|
|
3375
|
-
const columnId = `${keys.join("/")}
|
|
3670
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3376
3671
|
columns.set(columnId, computedPivotColumn);
|
|
3377
3672
|
});
|
|
3378
3673
|
} else {
|
|
@@ -3405,7 +3700,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3405
3700
|
}));
|
|
3406
3701
|
}
|
|
3407
3702
|
aggregationReducers.forEach((reducer, index) => {
|
|
3408
|
-
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.id} total`;
|
|
3703
|
+
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.name || reducer.id} total`;
|
|
3409
3704
|
const computedPivotColumn = prepareColumn({
|
|
3410
3705
|
columnGroup: columnGroupId,
|
|
3411
3706
|
header,
|
|
@@ -3424,7 +3719,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3424
3719
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3425
3720
|
}
|
|
3426
3721
|
});
|
|
3427
|
-
columns.set(`total:${keys.join("/")}
|
|
3722
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3428
3723
|
});
|
|
3429
3724
|
}
|
|
3430
3725
|
}
|
|
@@ -3433,15 +3728,22 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3433
3728
|
}
|
|
3434
3729
|
});
|
|
3435
3730
|
if (columns.size === 1) {
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3731
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3732
|
+
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
3733
|
+
header: `${reducer.name || reducer.id} total`,
|
|
3734
|
+
pivotBy,
|
|
3735
|
+
pivotColumn: true,
|
|
3736
|
+
pivotTotalColumn: true,
|
|
3737
|
+
pivotAggregator: reducer,
|
|
3738
|
+
pivotAggregatorIndex: index,
|
|
3739
|
+
pivotGroupKeys: [],
|
|
3740
|
+
pivotGroupKey: "",
|
|
3741
|
+
pivotIndex: -1,
|
|
3742
|
+
valueGetter: ({ rowInfo }) => {
|
|
3743
|
+
var _a;
|
|
3744
|
+
return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
|
|
3745
|
+
}
|
|
3746
|
+
}));
|
|
3445
3747
|
});
|
|
3446
3748
|
}
|
|
3447
3749
|
const result = {
|
|
@@ -3478,10 +3780,11 @@ function concludeReducer(params) {
|
|
|
3478
3780
|
const { state, previousState } = params;
|
|
3479
3781
|
const sortInfo = state.sortInfo;
|
|
3480
3782
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3481
|
-
const
|
|
3482
|
-
"originalDataArray"
|
|
3483
|
-
"sortInfo"
|
|
3783
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3784
|
+
"originalDataArray"
|
|
3484
3785
|
]);
|
|
3786
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3787
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3485
3788
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3486
3789
|
const groupBy = state.groupBy;
|
|
3487
3790
|
const pivotBy = state.pivotBy;
|
|
@@ -3489,6 +3792,7 @@ function concludeReducer(params) {
|
|
|
3489
3792
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3490
3793
|
"generateGroupRows",
|
|
3491
3794
|
"originalDataArray",
|
|
3795
|
+
"originalLazyGroupData",
|
|
3492
3796
|
"groupBy",
|
|
3493
3797
|
"groupRowsState",
|
|
3494
3798
|
"pivotBy",
|
|
@@ -3513,7 +3817,12 @@ function concludeReducer(params) {
|
|
|
3513
3817
|
};
|
|
3514
3818
|
if (shouldGroup) {
|
|
3515
3819
|
if (shouldGroupAgain) {
|
|
3516
|
-
const groupResult =
|
|
3820
|
+
const groupResult = state.fullLazyLoad ? lazyGroup({
|
|
3821
|
+
groupBy,
|
|
3822
|
+
pivot: pivotBy,
|
|
3823
|
+
mappings: state.pivotMappings,
|
|
3824
|
+
reducers: state.aggregationReducers
|
|
3825
|
+
}, state.originalLazyGroupData) : group({
|
|
3517
3826
|
groupBy,
|
|
3518
3827
|
pivot: pivotBy,
|
|
3519
3828
|
reducers: state.aggregationReducers
|
|
@@ -3581,6 +3890,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3581
3890
|
forwardProps: forwardProps3,
|
|
3582
3891
|
concludeReducer,
|
|
3583
3892
|
mapPropsToState: mapPropsToState2,
|
|
3893
|
+
onPropChange,
|
|
3584
3894
|
interceptActions: getInterceptActions()
|
|
3585
3895
|
});
|
|
3586
3896
|
function DataSourceCmp({ children }) {
|
|
@@ -3611,17 +3921,23 @@ function DataSource(props) {
|
|
|
3611
3921
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
3612
3922
|
function useToggleGroupRow() {
|
|
3613
3923
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3614
|
-
const toggleGroupRow = (0,
|
|
3615
|
-
const
|
|
3924
|
+
const toggleGroupRow = (0, import_react16.useCallback)((groupKeys) => {
|
|
3925
|
+
const state = getDataSourceState();
|
|
3926
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3616
3927
|
newState.toggleGroupRow(groupKeys);
|
|
3617
3928
|
dataSourceActions.groupRowsState = newState;
|
|
3929
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
3930
|
+
loadData(state.data, state, dataSourceActions, {
|
|
3931
|
+
groupKeys
|
|
3932
|
+
});
|
|
3933
|
+
}
|
|
3618
3934
|
}, []);
|
|
3619
3935
|
return toggleGroupRow;
|
|
3620
3936
|
}
|
|
3621
3937
|
|
|
3622
3938
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
3623
3939
|
function useGroupByMap(groupBy) {
|
|
3624
|
-
const groupByMap = (0,
|
|
3940
|
+
const groupByMap = (0, import_react17.useMemo)(() => {
|
|
3625
3941
|
return groupBy.reduce((acc, groupBy2, index) => {
|
|
3626
3942
|
acc.set(groupBy2.field, {
|
|
3627
3943
|
groupBy: groupBy2,
|
|
@@ -3641,10 +3957,10 @@ function useColumnsWhen() {
|
|
|
3641
3957
|
componentState: { groupRenderStrategy, pivotTotalColumnPosition }
|
|
3642
3958
|
} = useComponentState();
|
|
3643
3959
|
const groupByMap = useGroupByMap(groupBy);
|
|
3644
|
-
(0,
|
|
3960
|
+
(0, import_react17.useEffect)(() => {
|
|
3645
3961
|
dataSourceActions.generateGroupRows = groupRenderStrategy !== "inline";
|
|
3646
3962
|
}, [groupRenderStrategy]);
|
|
3647
|
-
(0,
|
|
3963
|
+
(0, import_react17.useEffect)(() => {
|
|
3648
3964
|
dataSourceActions.pivotTotalColumnPosition = pivotTotalColumnPosition;
|
|
3649
3965
|
}, [pivotTotalColumnPosition]);
|
|
3650
3966
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
@@ -3707,7 +4023,7 @@ function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
|
3707
4023
|
});
|
|
3708
4024
|
return computedColumns.size === 0 ? void 0 : computedColumns;
|
|
3709
4025
|
}
|
|
3710
|
-
(0,
|
|
4026
|
+
(0, import_react17.useEffect)(() => {
|
|
3711
4027
|
const update = () => {
|
|
3712
4028
|
componentActions.columnsWhenInlineGroupRenderStrategy = computeColumnsWhenInlineGroupRenderStrategy(columns, groupByMap, groupRenderStrategy, toggleGroupRow);
|
|
3713
4029
|
};
|
|
@@ -3733,7 +4049,7 @@ function useColumnsWhenPivoting() {
|
|
|
3733
4049
|
}
|
|
3734
4050
|
} = useComponentState();
|
|
3735
4051
|
const toggleGroupRow = useToggleGroupRow();
|
|
3736
|
-
(0,
|
|
4052
|
+
(0, import_react17.useEffect)(() => {
|
|
3737
4053
|
const computedPivotColumns = getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, {
|
|
3738
4054
|
pivotColumn,
|
|
3739
4055
|
pivotRowLabelsColumn,
|
|
@@ -3754,7 +4070,7 @@ function useColumnsWhenGrouping() {
|
|
|
3754
4070
|
componentState: { columns, groupColumn, groupRenderStrategy, pivotColumns }
|
|
3755
4071
|
} = useComponentState();
|
|
3756
4072
|
const toggleGroupRow = useToggleGroupRow();
|
|
3757
|
-
(0,
|
|
4073
|
+
(0, import_react17.useEffect)(() => {
|
|
3758
4074
|
if (pivotColumns) {
|
|
3759
4075
|
return;
|
|
3760
4076
|
}
|
|
@@ -3791,7 +4107,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3791
4107
|
groupRenderStrategy
|
|
3792
4108
|
}
|
|
3793
4109
|
} = useComponentState();
|
|
3794
|
-
(0,
|
|
4110
|
+
(0, import_react17.useEffect)(() => {
|
|
3795
4111
|
if (groupRenderStrategy !== "multi-column") {
|
|
3796
4112
|
return;
|
|
3797
4113
|
}
|
|
@@ -3809,7 +4125,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3809
4125
|
const currentState = getComponentState();
|
|
3810
4126
|
const { computedColumns } = currentState;
|
|
3811
4127
|
let updated = false;
|
|
3812
|
-
const columnVisibility =
|
|
4128
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3813
4129
|
const cols = computedColumns;
|
|
3814
4130
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
3815
4131
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
@@ -3820,9 +4136,9 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3820
4136
|
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3821
4137
|
updated = true;
|
|
3822
4138
|
if (shouldBeHidden) {
|
|
3823
|
-
columnVisibility
|
|
4139
|
+
columnVisibility[colId] = false;
|
|
3824
4140
|
} else {
|
|
3825
|
-
columnVisibility
|
|
4141
|
+
delete columnVisibility[colId];
|
|
3826
4142
|
}
|
|
3827
4143
|
});
|
|
3828
4144
|
if (updated) {
|
|
@@ -3885,7 +4201,8 @@ function useComputed() {
|
|
|
3885
4201
|
const { componentActions, componentState } = useComponentState();
|
|
3886
4202
|
const {
|
|
3887
4203
|
componentActions: dataSourceActions,
|
|
3888
|
-
componentState: dataSourceState
|
|
4204
|
+
componentState: dataSourceState,
|
|
4205
|
+
getState: getDataSourceState
|
|
3889
4206
|
} = useDataSourceContextValue();
|
|
3890
4207
|
const {
|
|
3891
4208
|
columnOrder,
|
|
@@ -3896,7 +4213,7 @@ function useComputed() {
|
|
|
3896
4213
|
bodySize,
|
|
3897
4214
|
showSeparatePivotColumnForSingleAggregation
|
|
3898
4215
|
} = componentState;
|
|
3899
|
-
(0,
|
|
4216
|
+
(0, import_react18.useState)(() => {
|
|
3900
4217
|
componentState.onRowHeightCSSVarChange.onChange((rowHeight) => {
|
|
3901
4218
|
if (rowHeight) {
|
|
3902
4219
|
componentActions.rowHeight = rowHeight;
|
|
@@ -3908,17 +4225,17 @@ function useComputed() {
|
|
|
3908
4225
|
}
|
|
3909
4226
|
});
|
|
3910
4227
|
});
|
|
3911
|
-
(0,
|
|
4228
|
+
(0, import_react18.useEffect)(() => {
|
|
3912
4229
|
dataSourceActions.showSeparatePivotColumnForSingleAggregation = showSeparatePivotColumnForSingleAggregation;
|
|
3913
4230
|
}, [showSeparatePivotColumnForSingleAggregation]);
|
|
3914
4231
|
const { multiSort } = dataSourceState;
|
|
3915
4232
|
useColumnGroups();
|
|
3916
4233
|
useColumnsWhen();
|
|
3917
|
-
const setSortInfo = (0,
|
|
4234
|
+
const setSortInfo = (0, import_react18.useCallback)((sortInfo) => {
|
|
3918
4235
|
var _a2;
|
|
3919
4236
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3920
4237
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3921
|
-
}, []);
|
|
4238
|
+
}, [getDataSourceState]);
|
|
3922
4239
|
const columns = componentState.computedColumns;
|
|
3923
4240
|
const {
|
|
3924
4241
|
computedColumnOrder,
|
|
@@ -4074,20 +4391,20 @@ var HeaderWrapperCls = "_12zfob1v _16lm1iw16 _16lm1iw1 _16lm1iwj _16lm1iw10";
|
|
|
4074
4391
|
|
|
4075
4392
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4076
4393
|
var React17 = __toModule(require("react"));
|
|
4077
|
-
var
|
|
4394
|
+
var import_react26 = __toModule(require("react"));
|
|
4078
4395
|
|
|
4079
4396
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
|
|
4080
4397
|
var React13 = __toModule(require("react"));
|
|
4081
|
-
var
|
|
4398
|
+
var import_react22 = __toModule(require("react"));
|
|
4082
4399
|
|
|
4083
4400
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx
|
|
4084
4401
|
var React11 = __toModule(require("react"));
|
|
4085
4402
|
|
|
4086
4403
|
// src/components/InfiniteTable/hooks/useInfiniteTableState.ts
|
|
4087
|
-
var
|
|
4404
|
+
var import_react19 = __toModule(require("react"));
|
|
4088
4405
|
var useInfiniteTableState = () => {
|
|
4089
4406
|
const TableContext2 = getInfiniteTableContext();
|
|
4090
|
-
const { componentState } = (0,
|
|
4407
|
+
const { componentState } = (0, import_react19.useContext)(TableContext2);
|
|
4091
4408
|
return componentState;
|
|
4092
4409
|
};
|
|
4093
4410
|
|
|
@@ -4153,7 +4470,7 @@ var InfiniteTableCell = React11.memo(InfiniteTableCellFn);
|
|
|
4153
4470
|
|
|
4154
4471
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
4155
4472
|
var import_binary_search = __toModule(require_binary_search());
|
|
4156
|
-
var
|
|
4473
|
+
var import_react20 = __toModule(require("react"));
|
|
4157
4474
|
|
|
4158
4475
|
// src/components/InfiniteTable/utils/moveXatY.ts
|
|
4159
4476
|
var moveXatY = (arr, dragIndex, dropIndex) => {
|
|
@@ -4187,18 +4504,18 @@ var useColumnPointerEvents = ({
|
|
|
4187
4504
|
columns,
|
|
4188
4505
|
computedRemainingSpace
|
|
4189
4506
|
}) => {
|
|
4190
|
-
const [draggingDiff, setDraggingDiff] = (0,
|
|
4191
|
-
const [proxyOffset, setProxyOffset] = (0,
|
|
4192
|
-
const breakpointsRef = (0,
|
|
4193
|
-
const pointerMoveRef = (0,
|
|
4194
|
-
const didDragRef = (0,
|
|
4195
|
-
const initialClientPos = (0,
|
|
4196
|
-
const currentDropIndexRef = (0,
|
|
4507
|
+
const [draggingDiff, setDraggingDiff] = (0, import_react20.useState)(null);
|
|
4508
|
+
const [proxyOffset, setProxyOffset] = (0, import_react20.useState)(null);
|
|
4509
|
+
const breakpointsRef = (0, import_react20.useRef)([]);
|
|
4510
|
+
const pointerMoveRef = (0, import_react20.useRef)(null);
|
|
4511
|
+
const didDragRef = (0, import_react20.useRef)(false);
|
|
4512
|
+
const initialClientPos = (0, import_react20.useRef)(null);
|
|
4513
|
+
const currentDropIndexRef = (0, import_react20.useRef)(null);
|
|
4197
4514
|
const dragging = draggingDiff != null;
|
|
4198
4515
|
const { componentActions, computed } = useInfiniteTable();
|
|
4199
4516
|
const { computedColumnOrder } = computed;
|
|
4200
|
-
const column = (0,
|
|
4201
|
-
const { columnIndex, columnWidth, columnsArray } = (0,
|
|
4517
|
+
const column = (0, import_react20.useMemo)(() => columns.get(columnId), [columnId, columns]);
|
|
4518
|
+
const { columnIndex, columnWidth, columnsArray } = (0, import_react20.useMemo)(() => {
|
|
4202
4519
|
const columnsArray2 = Array.from(columns.values());
|
|
4203
4520
|
return {
|
|
4204
4521
|
columnsArray: columnsArray2,
|
|
@@ -4206,8 +4523,8 @@ var useColumnPointerEvents = ({
|
|
|
4206
4523
|
columnWidth: column.computedWidth
|
|
4207
4524
|
};
|
|
4208
4525
|
}, [columns, columnId, column]);
|
|
4209
|
-
let cursorRef = (0,
|
|
4210
|
-
const onPointerDown = (0,
|
|
4526
|
+
let cursorRef = (0, import_react20.useRef)("auto");
|
|
4527
|
+
const onPointerDown = (0, import_react20.useCallback)((e) => {
|
|
4211
4528
|
const target = domRef.current;
|
|
4212
4529
|
cursorRef.current = target.style.cursor;
|
|
4213
4530
|
didDragRef.current = false;
|
|
@@ -4270,7 +4587,7 @@ var useColumnPointerEvents = ({
|
|
|
4270
4587
|
target.addEventListener("pointermove", onPointerMove);
|
|
4271
4588
|
target.setPointerCapture(e.pointerId);
|
|
4272
4589
|
}, [columns, column, columnIndex, columnsArray, computedRemainingSpace]);
|
|
4273
|
-
const onPointerUp = (0,
|
|
4590
|
+
const onPointerUp = (0, import_react20.useCallback)((e) => {
|
|
4274
4591
|
const target = domRef.current;
|
|
4275
4592
|
target.style.cursor = cursorRef.current;
|
|
4276
4593
|
target.releasePointerCapture(e.pointerId);
|
|
@@ -4345,7 +4662,7 @@ var import_react_dom = __toModule(require("react-dom"));
|
|
|
4345
4662
|
|
|
4346
4663
|
// src/components/InfiniteTable/components/icons/SortIcon.tsx
|
|
4347
4664
|
var React12 = __toModule(require("react"));
|
|
4348
|
-
var
|
|
4665
|
+
var import_react21 = __toModule(require("react"));
|
|
4349
4666
|
var defaultLineStyle = {
|
|
4350
4667
|
marginTop: 2,
|
|
4351
4668
|
marginBottom: 2,
|
|
@@ -4353,8 +4670,8 @@ var defaultLineStyle = {
|
|
|
4353
4670
|
};
|
|
4354
4671
|
function SortIcon(props) {
|
|
4355
4672
|
var _a;
|
|
4356
|
-
const [rendered, setRendered] = (0,
|
|
4357
|
-
const [opacity, setOpacity] = (0,
|
|
4673
|
+
const [rendered, setRendered] = (0, import_react21.useState)(true);
|
|
4674
|
+
const [opacity, setOpacity] = (0, import_react21.useState)(0);
|
|
4358
4675
|
const { direction, lineWidth = 1, style, className, index } = props;
|
|
4359
4676
|
const showIndex = index != null && index > 0;
|
|
4360
4677
|
const size = (_a = props.size) != null ? _a : 16;
|
|
@@ -4368,7 +4685,7 @@ function SortIcon(props) {
|
|
|
4368
4685
|
}), props.lineStyle), {
|
|
4369
4686
|
opacity
|
|
4370
4687
|
});
|
|
4371
|
-
(0,
|
|
4688
|
+
(0, import_react21.useEffect)(() => {
|
|
4372
4689
|
const newOpacity = direction != 0 ? 1 : 0;
|
|
4373
4690
|
if (!rendered && newOpacity) {
|
|
4374
4691
|
setRendered(true);
|
|
@@ -4445,8 +4762,8 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4445
4762
|
className: `${baseCls}__sort-icon ${HeaderSortIconCls}`,
|
|
4446
4763
|
direction: column.computedSorted ? column.computedSortedAsc ? 1 : -1 : 0
|
|
4447
4764
|
});
|
|
4448
|
-
const domRef = (0,
|
|
4449
|
-
const ref = (0,
|
|
4765
|
+
const domRef = (0, import_react22.useRef)(null);
|
|
4766
|
+
const ref = (0, import_react22.useCallback)((node) => {
|
|
4450
4767
|
var _a2;
|
|
4451
4768
|
domRef.current = node;
|
|
4452
4769
|
(_a2 = props.domRef) == null ? void 0 : _a2.call(props, node);
|
|
@@ -4455,7 +4772,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4455
4772
|
computed: { computedRemainingSpace },
|
|
4456
4773
|
componentState: { portalDOMRef }
|
|
4457
4774
|
} = useInfiniteTable();
|
|
4458
|
-
(0,
|
|
4775
|
+
(0, import_react22.useEffect)(() => {
|
|
4459
4776
|
let clearOnResize = null;
|
|
4460
4777
|
const node = domRef.current;
|
|
4461
4778
|
if (onResize && node) {
|
|
@@ -4508,14 +4825,14 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4508
4825
|
|
|
4509
4826
|
// src/components/RawList/index.tsx
|
|
4510
4827
|
var React16 = __toModule(require("react"));
|
|
4511
|
-
var
|
|
4828
|
+
var import_react25 = __toModule(require("react"));
|
|
4512
4829
|
|
|
4513
4830
|
// src/components/RawList/AvoidReactDiff.tsx
|
|
4514
4831
|
var React14 = __toModule(require("react"));
|
|
4515
|
-
var
|
|
4832
|
+
var import_react23 = __toModule(require("react"));
|
|
4516
4833
|
function AvoidReactDiffFn(props) {
|
|
4517
|
-
const [children, setChildren] = (0,
|
|
4518
|
-
(0,
|
|
4834
|
+
const [children, setChildren] = (0, import_react23.useState)(props.updater.get());
|
|
4835
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
4519
4836
|
const remove = props.updater.onChange((children2) => {
|
|
4520
4837
|
setChildren(children2);
|
|
4521
4838
|
});
|
|
@@ -4526,7 +4843,7 @@ function AvoidReactDiffFn(props) {
|
|
|
4526
4843
|
var AvoidReactDiff = React14.memo(AvoidReactDiffFn);
|
|
4527
4844
|
|
|
4528
4845
|
// src/components/RawList/useVirtualRenderer.ts
|
|
4529
|
-
var
|
|
4846
|
+
var import_react24 = __toModule(require("react"));
|
|
4530
4847
|
|
|
4531
4848
|
// src/components/RawList/ReactVirtualRenderer.tsx
|
|
4532
4849
|
var React15 = __toModule(require("react"));
|
|
@@ -4840,7 +5157,7 @@ function createRenderer(brain) {
|
|
|
4840
5157
|
function useVirtualRenderer({
|
|
4841
5158
|
brain
|
|
4842
5159
|
}) {
|
|
4843
|
-
return (0,
|
|
5160
|
+
return (0, import_react24.useMemo)(() => {
|
|
4844
5161
|
return createRenderer(brain);
|
|
4845
5162
|
}, [brain]);
|
|
4846
5163
|
}
|
|
@@ -4853,7 +5170,7 @@ function RawListFn(props) {
|
|
|
4853
5170
|
debugChannel
|
|
4854
5171
|
});
|
|
4855
5172
|
const getRenderItem = useLatest(renderItem);
|
|
4856
|
-
(0,
|
|
5173
|
+
(0, import_react25.useEffect)(() => {
|
|
4857
5174
|
const renderRange = brain.getRenderRange();
|
|
4858
5175
|
renderer.renderRange(renderRange, {
|
|
4859
5176
|
renderItem,
|
|
@@ -4861,7 +5178,7 @@ function RawListFn(props) {
|
|
|
4861
5178
|
onRender: onRenderUpdater
|
|
4862
5179
|
});
|
|
4863
5180
|
}, [brain, renderItem, onRenderUpdater]);
|
|
4864
|
-
(0,
|
|
5181
|
+
(0, import_react25.useEffect)(() => {
|
|
4865
5182
|
const remove = brain.onRenderRangeChange((renderRange) => {
|
|
4866
5183
|
renderer.renderRange(renderRange, {
|
|
4867
5184
|
force: false,
|
|
@@ -4888,7 +5205,7 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4888
5205
|
componentState: { headerHeight }
|
|
4889
5206
|
} = useInfiniteTable();
|
|
4890
5207
|
const { computedVisibleColumnsMap } = computed;
|
|
4891
|
-
const renderColumn = (0,
|
|
5208
|
+
const renderColumn = (0, import_react26.useCallback)(({ domRef: domRef2, itemIndex: columnIndex }) => {
|
|
4892
5209
|
const column = columns[columnIndex];
|
|
4893
5210
|
if (!column) {
|
|
4894
5211
|
if (true) {
|
|
@@ -4903,14 +5220,14 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4903
5220
|
columns: computedVisibleColumnsMap
|
|
4904
5221
|
});
|
|
4905
5222
|
}, [computedVisibleColumnsMap, columns, repaintId, headerHeight]);
|
|
4906
|
-
(0,
|
|
5223
|
+
(0, import_react26.useEffect)(() => {
|
|
4907
5224
|
const onScroll = (scrollPosition) => {
|
|
4908
5225
|
domRef.current.style.transform = `translate3d(-${scrollPosition.scrollLeft}px, 0px, 0px)`;
|
|
4909
5226
|
};
|
|
4910
5227
|
const removeOnScroll = brain.onScroll(onScroll);
|
|
4911
5228
|
return removeOnScroll;
|
|
4912
5229
|
}, [brain]);
|
|
4913
|
-
const domRef = (0,
|
|
5230
|
+
const domRef = (0, import_react26.useRef)(null);
|
|
4914
5231
|
const headerCls = HeaderClsRecipe({
|
|
4915
5232
|
pinned: pinning,
|
|
4916
5233
|
overflow: false,
|
|
@@ -5102,7 +5419,7 @@ function renderColumnHeaderGroups(config) {
|
|
|
5102
5419
|
}
|
|
5103
5420
|
|
|
5104
5421
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderUnvirtualized.tsx
|
|
5105
|
-
var
|
|
5422
|
+
var import_react27 = __toModule(require("react"));
|
|
5106
5423
|
var { rootClassName: rootClassName5 } = internalProps;
|
|
5107
5424
|
var TableHeaderClassName2 = `${rootClassName5}Header`;
|
|
5108
5425
|
var UPDATE_SCROLL = (node, scrollPosition) => {
|
|
@@ -5168,7 +5485,7 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
|
|
|
5168
5485
|
if (totalWidth != null) {
|
|
5169
5486
|
style.width = availableWidth;
|
|
5170
5487
|
}
|
|
5171
|
-
(0,
|
|
5488
|
+
(0, import_react27.useEffect)(() => {
|
|
5172
5489
|
const scroller = brain || scrollListener;
|
|
5173
5490
|
if (!scroller || !scrollable) {
|
|
5174
5491
|
return;
|
|
@@ -5222,6 +5539,9 @@ function TableHeaderWrapper(props) {
|
|
|
5222
5539
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5223
5540
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5224
5541
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5542
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5543
|
+
left: computedPinnedStartWidth
|
|
5544
|
+
} : void 0;
|
|
5225
5545
|
const header = virtualizeHeader ? /* @__PURE__ */ React21.createElement(InfiniteTableHeader, {
|
|
5226
5546
|
columns: computedUnpinnedColumns,
|
|
5227
5547
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5236,6 +5556,7 @@ function TableHeaderWrapper(props) {
|
|
|
5236
5556
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5237
5557
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5238
5558
|
}) : /* @__PURE__ */ React21.createElement(InfiniteTableHeaderUnvirtualized, {
|
|
5559
|
+
style: unvirtualizedStyle,
|
|
5239
5560
|
brain,
|
|
5240
5561
|
scrollable: true,
|
|
5241
5562
|
pinning: false,
|
|
@@ -5282,12 +5603,12 @@ function TableHeaderWrapper(props) {
|
|
|
5282
5603
|
|
|
5283
5604
|
// src/components/VirtualScrollContainer/index.tsx
|
|
5284
5605
|
var React22 = __toModule(require("react"));
|
|
5285
|
-
var
|
|
5606
|
+
var import_react29 = __toModule(require("react"));
|
|
5286
5607
|
|
|
5287
5608
|
// src/components/hooks/useOnScroll.ts
|
|
5288
|
-
var
|
|
5609
|
+
var import_react28 = __toModule(require("react"));
|
|
5289
5610
|
var useOnScroll = (domRef, onScroll) => {
|
|
5290
|
-
(0,
|
|
5611
|
+
(0, import_react28.useEffect)(() => {
|
|
5291
5612
|
const domNode = domRef == null ? void 0 : domRef.current;
|
|
5292
5613
|
const scrollFn = (event) => {
|
|
5293
5614
|
const node = event.target;
|
|
@@ -5333,7 +5654,7 @@ var VirtualScrollContainer = React22.forwardRef(function VirtualScrollContainer2
|
|
|
5333
5654
|
className,
|
|
5334
5655
|
style
|
|
5335
5656
|
} = props;
|
|
5336
|
-
const domRef = ref != null ? ref : (0,
|
|
5657
|
+
const domRef = ref != null ? ref : (0, import_react29.useRef)(null);
|
|
5337
5658
|
useOnScroll(domRef, onContainerScroll);
|
|
5338
5659
|
return /* @__PURE__ */ React22.createElement("div", {
|
|
5339
5660
|
ref: domRef,
|
|
@@ -5368,14 +5689,14 @@ var import_react41 = __toModule(require("react"));
|
|
|
5368
5689
|
|
|
5369
5690
|
// src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
|
|
5370
5691
|
var React29 = __toModule(require("react"));
|
|
5371
|
-
var
|
|
5692
|
+
var import_react33 = __toModule(require("react"));
|
|
5372
5693
|
|
|
5373
5694
|
// src/components/VirtualList/VirtualRowList.tsx
|
|
5374
5695
|
var React25 = __toModule(require("react"));
|
|
5375
5696
|
|
|
5376
5697
|
// src/components/VirtualList/VirtualList.tsx
|
|
5377
5698
|
var React24 = __toModule(require("react"));
|
|
5378
|
-
var
|
|
5699
|
+
var import_react30 = __toModule(require("react"));
|
|
5379
5700
|
|
|
5380
5701
|
// src/components/VirtualList/VirtualList.css.ts
|
|
5381
5702
|
var VirtualListCls = "_16lm1iw1 _16lm1iw8 _16lm1iw0";
|
|
@@ -5418,11 +5739,11 @@ var VirtualList = (props) => {
|
|
|
5418
5739
|
"onContainerScroll",
|
|
5419
5740
|
"children"
|
|
5420
5741
|
]);
|
|
5421
|
-
const domRef = (0,
|
|
5742
|
+
const domRef = (0, import_react30.useRef)(null);
|
|
5422
5743
|
const [, rerender] = useRerender();
|
|
5423
|
-
const [totalSize, setTotalSize] = (0,
|
|
5424
|
-
const renderCountRef = (0,
|
|
5425
|
-
(0,
|
|
5744
|
+
const [totalSize, setTotalSize] = (0, import_react30.useState)(0);
|
|
5745
|
+
const renderCountRef = (0, import_react30.useRef)(0);
|
|
5746
|
+
(0, import_react30.useEffect)(() => {
|
|
5426
5747
|
const removeOnRenderCount = virtualBrain.onRenderCountChange((renderCount) => {
|
|
5427
5748
|
renderCountRef.current = renderCount;
|
|
5428
5749
|
if (true) {
|
|
@@ -5441,7 +5762,7 @@ var VirtualList = (props) => {
|
|
|
5441
5762
|
removeOnTotalSizeChange();
|
|
5442
5763
|
};
|
|
5443
5764
|
}, [virtualBrain]);
|
|
5444
|
-
(0,
|
|
5765
|
+
(0, import_react30.useEffect)(() => {
|
|
5445
5766
|
const onScroll = (scrollPosition) => {
|
|
5446
5767
|
UPDATE_SCROLL2(domRef.current, scrollPosition);
|
|
5447
5768
|
};
|
|
@@ -5495,7 +5816,7 @@ var VirtualRowList = (props) => {
|
|
|
5495
5816
|
|
|
5496
5817
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx
|
|
5497
5818
|
var React27 = __toModule(require("react"));
|
|
5498
|
-
var
|
|
5819
|
+
var import_react32 = __toModule(require("react"));
|
|
5499
5820
|
|
|
5500
5821
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx
|
|
5501
5822
|
var React26 = __toModule(require("react"));
|
|
@@ -5523,6 +5844,9 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5523
5844
|
}
|
|
5524
5845
|
const { data, isGroupRow, groupBy } = rowInfo;
|
|
5525
5846
|
const groupRowInfo = null;
|
|
5847
|
+
if (rowInfo.indexInAll === 0 && column.groupByField && column.groupByField === "stack") {
|
|
5848
|
+
debugger;
|
|
5849
|
+
}
|
|
5526
5850
|
let value = isGroupRow && groupBy && column.groupByField ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
|
|
5527
5851
|
if (column.valueGetter) {
|
|
5528
5852
|
value = column.valueGetter(isGroupRow ? {
|
|
@@ -5605,7 +5929,7 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5605
5929
|
var InfiniteTableColumnCell = React26.memo(InfiniteTableColumnCellFn);
|
|
5606
5930
|
|
|
5607
5931
|
// src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts
|
|
5608
|
-
var
|
|
5932
|
+
var import_react31 = __toModule(require("react"));
|
|
5609
5933
|
|
|
5610
5934
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts
|
|
5611
5935
|
var { rootClassName: rootClassName9 } = internalProps;
|
|
@@ -5630,8 +5954,8 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5630
5954
|
domRef: domRefFromProps,
|
|
5631
5955
|
rowInfo
|
|
5632
5956
|
} = props;
|
|
5633
|
-
const domRef = (0,
|
|
5634
|
-
const rowDOMRef = (0,
|
|
5957
|
+
const domRef = (0, import_react31.useRef)(null);
|
|
5958
|
+
const rowDOMRef = (0, import_react31.useCallback)((node) => {
|
|
5635
5959
|
domRefFromProps(node);
|
|
5636
5960
|
domRef.current = node;
|
|
5637
5961
|
}, []);
|
|
@@ -5662,7 +5986,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5662
5986
|
}), `${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);
|
|
5663
5987
|
const initialMouseEnter = rowProps == null ? void 0 : rowProps.onMouseEnter;
|
|
5664
5988
|
const initialMouseLeave = rowProps == null ? void 0 : rowProps.onMouseLeave;
|
|
5665
|
-
const onMouseEnter = (0,
|
|
5989
|
+
const onMouseEnter = (0, import_react31.useCallback)((event) => {
|
|
5666
5990
|
var _a;
|
|
5667
5991
|
initialMouseEnter == null ? void 0 : initialMouseEnter(event);
|
|
5668
5992
|
const rowIndex2 = ((_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex) * 1;
|
|
@@ -5676,7 +6000,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5676
6000
|
const rows = parentNode.querySelectorAll(hoverSelector.join(","));
|
|
5677
6001
|
rows.forEach((row) => row.classList.add(InfiniteTableRowClassName__hover, RowHoverCls));
|
|
5678
6002
|
}, [initialMouseEnter, showHoverRows]);
|
|
5679
|
-
const onMouseLeave = (0,
|
|
6003
|
+
const onMouseLeave = (0, import_react31.useCallback)((event) => {
|
|
5680
6004
|
var _a;
|
|
5681
6005
|
initialMouseLeave == null ? void 0 : initialMouseLeave(event);
|
|
5682
6006
|
const rowIndex2 = (_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex;
|
|
@@ -5732,7 +6056,7 @@ function InfiniteTableRowFn(props) {
|
|
|
5732
6056
|
width: rowWidth,
|
|
5733
6057
|
height: rowHeight
|
|
5734
6058
|
}, domProps.style);
|
|
5735
|
-
const renderCellRef = (0,
|
|
6059
|
+
const renderCellRef = (0, import_react32.useRef)(null);
|
|
5736
6060
|
const renderCell = React27.useCallback(({ domRef, itemIndex }) => {
|
|
5737
6061
|
const column = columns[itemIndex];
|
|
5738
6062
|
if (!column) {
|
|
@@ -5836,7 +6160,7 @@ function useUnpinnedRendering(params) {
|
|
|
5836
6160
|
} = params;
|
|
5837
6161
|
const { virtualizeColumns } = getState();
|
|
5838
6162
|
const shouldVirtualizeColumns = typeof virtualizeColumns === "function" ? virtualizeColumns(computedUnpinnedColumns) : virtualizeColumns != null ? virtualizeColumns : true;
|
|
5839
|
-
const renderRowUnpinned = (0,
|
|
6163
|
+
const renderRowUnpinned = (0, import_react33.useCallback)((rowParams) => {
|
|
5840
6164
|
const dataArray = getData();
|
|
5841
6165
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
5842
6166
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -5902,7 +6226,7 @@ function useUnpinnedRendering(params) {
|
|
|
5902
6226
|
}
|
|
5903
6227
|
|
|
5904
6228
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5905
|
-
var
|
|
6229
|
+
var import_react34 = __toModule(require("react"));
|
|
5906
6230
|
|
|
5907
6231
|
// src/components/InfiniteTable/InfiniteCls.css.ts
|
|
5908
6232
|
var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
@@ -5915,7 +6239,6 @@ var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf",
|
|
|
5915
6239
|
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
5916
6240
|
|
|
5917
6241
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5918
|
-
var DELAY = 200;
|
|
5919
6242
|
var TableClassName = internalProps.rootClassName;
|
|
5920
6243
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
5921
6244
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -5926,23 +6249,33 @@ var useOnContainerScroll = ({
|
|
|
5926
6249
|
}) => {
|
|
5927
6250
|
const {
|
|
5928
6251
|
componentState: {
|
|
6252
|
+
scrollStopDelay,
|
|
5929
6253
|
scrollerDOMRef,
|
|
5930
6254
|
domRef,
|
|
5931
6255
|
scrollToBottomOffset,
|
|
5932
6256
|
onScrollToBottom,
|
|
5933
6257
|
onScrollToTop,
|
|
6258
|
+
onScrollStop: onScrollStopFromProps,
|
|
5934
6259
|
bodySize
|
|
5935
6260
|
}
|
|
5936
6261
|
} = useInfiniteTable();
|
|
5937
|
-
const {
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
6262
|
+
const {
|
|
6263
|
+
componentActions: dataSourceActions,
|
|
6264
|
+
getState: getDataSourceState,
|
|
6265
|
+
componentState: { notifyScrollStop }
|
|
6266
|
+
} = useDataSourceContextValue();
|
|
6267
|
+
const onScrollStop = (0, import_react34.useCallback)((param) => {
|
|
6268
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6269
|
+
notifyScrollStop(param);
|
|
6270
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
6271
|
+
const timeoutIdRef = (0, import_react34.useRef)(0);
|
|
6272
|
+
const scrollingRef = (0, import_react34.useRef)(false);
|
|
6273
|
+
const scrollTopMaxRef = (0, import_react34.useRef)(0);
|
|
6274
|
+
(0, import_react34.useEffect)(() => {
|
|
5942
6275
|
const { current: node } = scrollerDOMRef;
|
|
5943
6276
|
scrollTopMaxRef.current = node.scrollHeight - node.clientHeight;
|
|
5944
6277
|
}, [reservedContentHeight, bodySize.height]);
|
|
5945
|
-
const setScrolling = (0,
|
|
6278
|
+
const setScrolling = (0, import_react34.useCallback)((scrolling) => {
|
|
5946
6279
|
var _a;
|
|
5947
6280
|
const prevScrolling = scrollingRef.current;
|
|
5948
6281
|
scrollingRef.current = scrolling;
|
|
@@ -5953,9 +6286,17 @@ var useOnContainerScroll = ({
|
|
|
5953
6286
|
timeoutIdRef.current = setTimeout(() => {
|
|
5954
6287
|
setScrolling(false);
|
|
5955
6288
|
timeoutIdRef.current = 0;
|
|
5956
|
-
},
|
|
6289
|
+
}, scrollStopDelay);
|
|
5957
6290
|
}
|
|
5958
6291
|
if (prevScrolling !== scrolling) {
|
|
6292
|
+
if (!scrolling) {
|
|
6293
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6294
|
+
onScrollStop({
|
|
6295
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6296
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6297
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6298
|
+
});
|
|
6299
|
+
}
|
|
5959
6300
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
5960
6301
|
if (!classList) {
|
|
5961
6302
|
return;
|
|
@@ -5966,8 +6307,8 @@ var useOnContainerScroll = ({
|
|
|
5966
6307
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
5967
6308
|
}
|
|
5968
6309
|
}
|
|
5969
|
-
}, []);
|
|
5970
|
-
const onContainerScroll = (0,
|
|
6310
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
6311
|
+
const onContainerScroll = (0, import_react34.useCallback)((scrollInfo) => {
|
|
5971
6312
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
5972
6313
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
5973
6314
|
setScrolling(true);
|
|
@@ -5977,15 +6318,15 @@ var useOnContainerScroll = ({
|
|
|
5977
6318
|
domRef.current,
|
|
5978
6319
|
setScrolling
|
|
5979
6320
|
]);
|
|
5980
|
-
const scrollPositionRef = (0,
|
|
6321
|
+
const scrollPositionRef = (0, import_react34.useRef)({
|
|
5981
6322
|
scrollLeft: 0,
|
|
5982
6323
|
scrollTop: 0
|
|
5983
6324
|
});
|
|
5984
|
-
const applyScrollHorizontal = (0,
|
|
6325
|
+
const applyScrollHorizontal = (0, import_react34.useCallback)(({ scrollLeft }) => {
|
|
5985
6326
|
scrollPositionRef.current.scrollLeft = scrollLeft;
|
|
5986
6327
|
onContainerScroll(scrollPositionRef.current);
|
|
5987
6328
|
}, [onContainerScroll]);
|
|
5988
|
-
const applyScrollVertical = (0,
|
|
6329
|
+
const applyScrollVertical = (0, import_react34.useCallback)(({ scrollTop }) => {
|
|
5989
6330
|
scrollPositionRef.current.scrollTop = scrollTop;
|
|
5990
6331
|
onContainerScroll(scrollPositionRef.current);
|
|
5991
6332
|
if (scrollTop === 0) {
|
|
@@ -5996,7 +6337,7 @@ var useOnContainerScroll = ({
|
|
|
5996
6337
|
if (isScrollBottom) {
|
|
5997
6338
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
5998
6339
|
if (getDataSourceState().livePagination) {
|
|
5999
|
-
dataSourceActions.
|
|
6340
|
+
dataSourceActions.cursorId = Date.now();
|
|
6000
6341
|
}
|
|
6001
6342
|
}
|
|
6002
6343
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -6008,16 +6349,16 @@ var useOnContainerScroll = ({
|
|
|
6008
6349
|
|
|
6009
6350
|
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6010
6351
|
var React31 = __toModule(require("react"));
|
|
6011
|
-
var
|
|
6352
|
+
var import_react37 = __toModule(require("react"));
|
|
6012
6353
|
|
|
6013
6354
|
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
6014
6355
|
var React30 = __toModule(require("react"));
|
|
6015
|
-
var
|
|
6356
|
+
var import_react36 = __toModule(require("react"));
|
|
6016
6357
|
|
|
6017
6358
|
// src/components/hooks/useOnMount.ts
|
|
6018
|
-
var
|
|
6359
|
+
var import_react35 = __toModule(require("react"));
|
|
6019
6360
|
function useOnMount(domRef, props) {
|
|
6020
|
-
(0,
|
|
6361
|
+
(0, import_react35.useEffect)(() => {
|
|
6021
6362
|
const { onMount, onUnmount } = props;
|
|
6022
6363
|
const node = domRef == null ? void 0 : domRef.current;
|
|
6023
6364
|
onMount == null ? void 0 : onMount(node);
|
|
@@ -6048,8 +6389,8 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6048
6389
|
onMount,
|
|
6049
6390
|
onUnmount
|
|
6050
6391
|
} = props;
|
|
6051
|
-
const domRef = (0,
|
|
6052
|
-
const renderItem = (0,
|
|
6392
|
+
const domRef = (0, import_react36.useRef)(null);
|
|
6393
|
+
const renderItem = (0, import_react36.useCallback)((renderProps) => renderRow({
|
|
6053
6394
|
domRef: renderProps.domRef,
|
|
6054
6395
|
rowHeight: renderProps.itemSize,
|
|
6055
6396
|
rowIndex: renderProps.itemIndex
|
|
@@ -6058,7 +6399,7 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6058
6399
|
onMount,
|
|
6059
6400
|
onUnmount
|
|
6060
6401
|
});
|
|
6061
|
-
(0,
|
|
6402
|
+
(0, import_react36.useEffect)(() => {
|
|
6062
6403
|
const onScroll = (scrollPosition) => {
|
|
6063
6404
|
const node = domRef.current;
|
|
6064
6405
|
if (node) {
|
|
@@ -6125,7 +6466,7 @@ function PinnedRowsContainer(props) {
|
|
|
6125
6466
|
}
|
|
6126
6467
|
return result;
|
|
6127
6468
|
}, [height, rowWidth, pinning, hasOverflow]);
|
|
6128
|
-
const updateScroll = (0,
|
|
6469
|
+
const updateScroll = (0, import_react37.useCallback)((node, scrollPosition) => {
|
|
6129
6470
|
UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
|
|
6130
6471
|
}, [hasOverflow, pinnedScrollListener]);
|
|
6131
6472
|
const rowListProps = {
|
|
@@ -6167,7 +6508,7 @@ function PinnedRowsContainer(props) {
|
|
|
6167
6508
|
}
|
|
6168
6509
|
function useRenderPinnedRow(params) {
|
|
6169
6510
|
const { getData, getState, columnsWidth, columns, verticalBrain } = params;
|
|
6170
|
-
const renderPinnedRow = (0,
|
|
6511
|
+
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
6171
6512
|
const dataArray = getData();
|
|
6172
6513
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
6173
6514
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -6283,6 +6624,15 @@ function usePinnedStartRendering(params) {
|
|
|
6283
6624
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6284
6625
|
var import_react40 = __toModule(require("react"));
|
|
6285
6626
|
|
|
6627
|
+
// src/components/hooks/useOnce.ts
|
|
6628
|
+
var import_react38 = __toModule(require("react"));
|
|
6629
|
+
function useOnce(fn) {
|
|
6630
|
+
const onceFn = (0, import_react38.useMemo)(() => {
|
|
6631
|
+
return once(fn);
|
|
6632
|
+
}, []);
|
|
6633
|
+
return onceFn();
|
|
6634
|
+
}
|
|
6635
|
+
|
|
6286
6636
|
// src/components/VirtualBrain/index.ts
|
|
6287
6637
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6288
6638
|
var initialScrollPosition2 = {
|
|
@@ -7173,7 +7523,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7173
7523
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7174
7524
|
let valid2 = isValidLicense(licenseKey, {
|
|
7175
7525
|
publishedAt: 1624970570587,
|
|
7176
|
-
version: "0.
|
|
7526
|
+
version: "0.2.0"
|
|
7177
7527
|
});
|
|
7178
7528
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7179
7529
|
return true;
|