@infinite-table/infinite-react 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +5 -4
- package/index.d.ts +167 -96
- package/index.esm.css +5 -4
- package/index.esm.js +985 -680
- package/index.js +1017 -712
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -198,11 +198,11 @@ var require_common = __commonJS({
|
|
|
198
198
|
let enableOverride = null;
|
|
199
199
|
let namespacesCache;
|
|
200
200
|
let enabledCache;
|
|
201
|
-
function
|
|
202
|
-
if (!
|
|
201
|
+
function debug6(...args) {
|
|
202
|
+
if (!debug6.enabled) {
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
const self =
|
|
205
|
+
const self = debug6;
|
|
206
206
|
const curr = Number(new Date());
|
|
207
207
|
const ms = curr - (prevTime || curr);
|
|
208
208
|
self.diff = ms;
|
|
@@ -232,12 +232,12 @@ var require_common = __commonJS({
|
|
|
232
232
|
const logFn = self.log || createDebug.log;
|
|
233
233
|
logFn.apply(self, args);
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
Object.defineProperty(
|
|
235
|
+
debug6.namespace = namespace;
|
|
236
|
+
debug6.useColors = createDebug.useColors();
|
|
237
|
+
debug6.color = createDebug.selectColor(namespace);
|
|
238
|
+
debug6.extend = extend;
|
|
239
|
+
debug6.destroy = createDebug.destroy;
|
|
240
|
+
Object.defineProperty(debug6, "enabled", {
|
|
241
241
|
enumerable: true,
|
|
242
242
|
configurable: false,
|
|
243
243
|
get: () => {
|
|
@@ -255,9 +255,9 @@ var require_common = __commonJS({
|
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
if (typeof createDebug.init === "function") {
|
|
258
|
-
createDebug.init(
|
|
258
|
+
createDebug.init(debug6);
|
|
259
259
|
}
|
|
260
|
-
return
|
|
260
|
+
return debug6;
|
|
261
261
|
}
|
|
262
262
|
function extend(namespace, delimiter) {
|
|
263
263
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -721,14 +721,21 @@ var ScrollListener = class {
|
|
|
721
721
|
};
|
|
722
722
|
|
|
723
723
|
// src/components/InfiniteTable/utils/toMap.ts
|
|
724
|
-
function toMap(mapOrObject) {
|
|
724
|
+
function toMap(mapOrObject, weakMapCache) {
|
|
725
725
|
if (!mapOrObject) {
|
|
726
726
|
return new Map();
|
|
727
727
|
}
|
|
728
728
|
if (mapOrObject instanceof Map) {
|
|
729
729
|
return mapOrObject;
|
|
730
730
|
}
|
|
731
|
-
|
|
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;
|
|
732
739
|
}
|
|
733
740
|
|
|
734
741
|
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
@@ -754,12 +761,10 @@ function computeColumnGroupsDepths(columnGroups) {
|
|
|
754
761
|
}
|
|
755
762
|
|
|
756
763
|
// src/components/InfiniteTable/state/getInitialState.ts
|
|
757
|
-
function toColumnTypesMap(mapOrObject) {
|
|
758
|
-
return toMap(mapOrObject);
|
|
759
|
-
}
|
|
760
764
|
function initSetupState() {
|
|
761
765
|
const columnsGeneratedForGrouping = new Map();
|
|
762
766
|
return {
|
|
767
|
+
propsCache: new Map([]),
|
|
763
768
|
columnShifts: null,
|
|
764
769
|
domRef: (0, import_react2.createRef)(),
|
|
765
770
|
scrollerDOMRef: (0, import_react2.createRef)(),
|
|
@@ -784,12 +789,8 @@ function initSetupState() {
|
|
|
784
789
|
columnsWhenInlineGroupRenderStrategy: void 0
|
|
785
790
|
};
|
|
786
791
|
}
|
|
787
|
-
var forwardProps = () => {
|
|
792
|
+
var forwardProps = (setupState) => {
|
|
788
793
|
return {
|
|
789
|
-
columns: (columns) => {
|
|
790
|
-
var _a;
|
|
791
|
-
return (_a = toMap(columns)) != null ? _a : new Map();
|
|
792
|
-
},
|
|
793
794
|
scrollTopId: 1,
|
|
794
795
|
components: 1,
|
|
795
796
|
loadingText: 1,
|
|
@@ -807,6 +808,7 @@ var forwardProps = () => {
|
|
|
807
808
|
onBlurWithin: 1,
|
|
808
809
|
onScrollToTop: 1,
|
|
809
810
|
onScrollToBottom: 1,
|
|
811
|
+
onScrollStop: 1,
|
|
810
812
|
scrollToBottomOffset: 1,
|
|
811
813
|
rowStyle: 1,
|
|
812
814
|
rowProps: 1,
|
|
@@ -817,6 +819,7 @@ var forwardProps = () => {
|
|
|
817
819
|
pivotRowLabelsColumn: 1,
|
|
818
820
|
pivotColumnGroups: 1,
|
|
819
821
|
onScrollbarsChange: 1,
|
|
822
|
+
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
820
823
|
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
821
824
|
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
822
825
|
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
@@ -835,21 +838,13 @@ var forwardProps = () => {
|
|
|
835
838
|
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
836
839
|
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
837
840
|
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
columnSizing: (columnSizing) => {
|
|
844
|
-
var _a;
|
|
845
|
-
return (_a = toMap(columnSizing)) != null ? _a : new Map();
|
|
846
|
-
},
|
|
847
|
-
columnTypes: (columnTypes) => {
|
|
848
|
-
var _a;
|
|
849
|
-
return (_a = toColumnTypesMap(columnTypes)) != null ? _a : new Map();
|
|
850
|
-
},
|
|
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")),
|
|
851
846
|
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
852
|
-
columnGroups: (columnGroups) => columnGroups
|
|
847
|
+
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
853
848
|
};
|
|
854
849
|
};
|
|
855
850
|
function getGroupRenderStrategy(options) {
|
|
@@ -1224,11 +1219,11 @@ function getColumnComputedType(column, columnTypes) {
|
|
|
1224
1219
|
// src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
|
|
1225
1220
|
var logError = err("getComputedVisibleColumns");
|
|
1226
1221
|
var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
|
|
1227
|
-
return
|
|
1222
|
+
return columnVisibility[colId] !== false;
|
|
1228
1223
|
};
|
|
1229
1224
|
var getComputedPinned = (colId, columnPinning) => {
|
|
1230
1225
|
const pinned = columnPinning.get(colId);
|
|
1231
|
-
const computedPinned = pinned === "start"
|
|
1226
|
+
const computedPinned = pinned === "start" ? "start" : pinned === "end" ? "end" : false;
|
|
1232
1227
|
return computedPinned;
|
|
1233
1228
|
};
|
|
1234
1229
|
var getComputedVisibleColumns = ({
|
|
@@ -1260,7 +1255,9 @@ var getComputedVisibleColumns = ({
|
|
|
1260
1255
|
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1261
1256
|
return false;
|
|
1262
1257
|
}
|
|
1263
|
-
|
|
1258
|
+
const result2 = isColumnVisible(columnVisibility, columnVisibilityAssumeVisible, colId);
|
|
1259
|
+
console.log(columnVisibility, colId, result2);
|
|
1260
|
+
return result2;
|
|
1264
1261
|
});
|
|
1265
1262
|
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1266
1263
|
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
@@ -1289,7 +1286,10 @@ var getComputedVisibleColumns = ({
|
|
|
1289
1286
|
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1290
1287
|
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1291
1288
|
};
|
|
1292
|
-
let colSizing = columnSizing.get(colId) || {
|
|
1289
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1290
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1291
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1292
|
+
};
|
|
1293
1293
|
if (colSizing.width != null) {
|
|
1294
1294
|
delete colTypeSizing.flex;
|
|
1295
1295
|
}
|
|
@@ -1576,7 +1576,6 @@ var useComputedVisibleColumns = ({
|
|
|
1576
1576
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1577
1577
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1578
1578
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1579
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1580
1579
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1581
1580
|
const {
|
|
1582
1581
|
computedRemainingSpace,
|
|
@@ -1632,7 +1631,6 @@ var useComputedVisibleColumns = ({
|
|
|
1632
1631
|
pinnedStartMaxWidth,
|
|
1633
1632
|
columnPinning,
|
|
1634
1633
|
columnsRenderId,
|
|
1635
|
-
visibilityRenderId,
|
|
1636
1634
|
columnsSizingRenderId,
|
|
1637
1635
|
pinningRenderId,
|
|
1638
1636
|
columnTypesRenderId
|
|
@@ -1657,11 +1655,11 @@ var useComputedVisibleColumns = ({
|
|
|
1657
1655
|
return result;
|
|
1658
1656
|
};
|
|
1659
1657
|
|
|
1660
|
-
// src/utils/sortAscending.ts
|
|
1658
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1661
1659
|
var sortAscending = (a, b) => a - b;
|
|
1662
1660
|
|
|
1663
1661
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
1664
|
-
var
|
|
1662
|
+
var import_react18 = __toModule(require("react"));
|
|
1665
1663
|
|
|
1666
1664
|
// src/components/hooks/useComponentState.tsx
|
|
1667
1665
|
var React2 = __toModule(require("react"));
|
|
@@ -1753,9 +1751,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1753
1751
|
if (currentValue === value) {
|
|
1754
1752
|
return;
|
|
1755
1753
|
}
|
|
1756
|
-
|
|
1754
|
+
let notifyTheChange = true;
|
|
1757
1755
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1758
|
-
interceptedActions[key](value, { actions, state: state2 })
|
|
1756
|
+
if (interceptedActions[key](value, { actions, state: state2 }) === false) {
|
|
1757
|
+
notifyTheChange = false;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
if (notifyTheChange) {
|
|
1761
|
+
notifyChange(props, stateKey, value);
|
|
1759
1762
|
}
|
|
1760
1763
|
const forwardFn = propsToForward[key];
|
|
1761
1764
|
if (typeof forwardFn === "function") {
|
|
@@ -1833,9 +1836,12 @@ function getComponentStateRoot(config) {
|
|
|
1833
1836
|
const getProps = useLatest(props);
|
|
1834
1837
|
const theReducer = (previousState, action) => {
|
|
1835
1838
|
var _a2;
|
|
1839
|
+
if (action.type === "REPLACE_STATE") {
|
|
1840
|
+
return action.payload;
|
|
1841
|
+
}
|
|
1836
1842
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1837
1843
|
const mappedState = action.payload.mappedState;
|
|
1838
|
-
const updatedProps = action.payload.
|
|
1844
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1839
1845
|
const newState = Object.assign({}, previousState);
|
|
1840
1846
|
if (mappedState) {
|
|
1841
1847
|
Object.assign(newState, mappedState);
|
|
@@ -1889,8 +1895,9 @@ function getComponentStateRoot(config) {
|
|
|
1889
1895
|
const currentProps = props;
|
|
1890
1896
|
const newMappedState = {};
|
|
1891
1897
|
let newMappedStateCount = 0;
|
|
1892
|
-
const
|
|
1893
|
-
let
|
|
1898
|
+
const updatedPropsToState = {};
|
|
1899
|
+
let updatedPropsToStateCount = 0;
|
|
1900
|
+
const rawUpdatedProps = {};
|
|
1894
1901
|
for (var k in props) {
|
|
1895
1902
|
const key = k;
|
|
1896
1903
|
const oldValue = prevProps[key];
|
|
@@ -1901,6 +1908,7 @@ function getComponentStateRoot(config) {
|
|
|
1901
1908
|
if (oldValue === newValue) {
|
|
1902
1909
|
continue;
|
|
1903
1910
|
}
|
|
1911
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1904
1912
|
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1905
1913
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1906
1914
|
let valueToSet = newValue;
|
|
@@ -1913,22 +1921,30 @@ function getComponentStateRoot(config) {
|
|
|
1913
1921
|
newMappedStateCount++;
|
|
1914
1922
|
}
|
|
1915
1923
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1916
|
-
|
|
1917
|
-
|
|
1924
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1925
|
+
updatedPropsToStateCount++;
|
|
1918
1926
|
}
|
|
1919
1927
|
}
|
|
1920
1928
|
}
|
|
1921
|
-
if (
|
|
1929
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1922
1930
|
debug2("Triggered by new values for the following props", ...[
|
|
1923
1931
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1924
|
-
...Object.keys(
|
|
1932
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1925
1933
|
]);
|
|
1926
|
-
|
|
1934
|
+
const action = {
|
|
1927
1935
|
payload: {
|
|
1928
1936
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1929
|
-
|
|
1937
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1930
1938
|
}
|
|
1931
|
-
}
|
|
1939
|
+
};
|
|
1940
|
+
dispatch(action);
|
|
1941
|
+
if (config.onPropChange) {
|
|
1942
|
+
for (var prop in rawUpdatedProps)
|
|
1943
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
1944
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
1945
|
+
config.onPropChange({ name: prop, newValue, oldValue }, props, actions);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1932
1948
|
}
|
|
1933
1949
|
});
|
|
1934
1950
|
return /* @__PURE__ */ React2.createElement(Context.Provider, {
|
|
@@ -1996,35 +2012,38 @@ function useColumnGroups() {
|
|
|
1996
2012
|
return interceptMap(collapsedColumnGroups, {
|
|
1997
2013
|
set: (key, visibleCol) => {
|
|
1998
2014
|
const colIds = key.slice(1);
|
|
1999
|
-
const
|
|
2015
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2000
2016
|
colIds.forEach((colId) => {
|
|
2001
|
-
columnVisibility
|
|
2017
|
+
columnVisibility[colId] = false;
|
|
2002
2018
|
});
|
|
2003
|
-
columnVisibility
|
|
2019
|
+
delete columnVisibility[visibleCol];
|
|
2020
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2004
2021
|
},
|
|
2005
2022
|
beforeClear: (currentCollapsedGroups) => {
|
|
2006
|
-
const
|
|
2023
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2007
2024
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2008
2025
|
keys.forEach((key) => {
|
|
2009
2026
|
const colIds = key.slice(1);
|
|
2010
2027
|
colIds.forEach((colId) => {
|
|
2011
|
-
columnVisibility
|
|
2028
|
+
delete columnVisibility[colId];
|
|
2012
2029
|
});
|
|
2013
2030
|
});
|
|
2031
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2014
2032
|
},
|
|
2015
2033
|
delete: (key) => {
|
|
2016
|
-
const
|
|
2034
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2017
2035
|
const colIds = key.slice(1);
|
|
2018
2036
|
colIds.forEach((colId) => {
|
|
2019
|
-
columnVisibility
|
|
2037
|
+
delete columnVisibility[colId];
|
|
2020
2038
|
});
|
|
2039
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2021
2040
|
}
|
|
2022
2041
|
});
|
|
2023
2042
|
}, [collapsedColumnGroups]);
|
|
2024
2043
|
}
|
|
2025
2044
|
|
|
2026
2045
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
2027
|
-
var
|
|
2046
|
+
var import_react17 = __toModule(require("react"));
|
|
2028
2047
|
|
|
2029
2048
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2030
2049
|
var React6 = __toModule(require("react"));
|
|
@@ -2279,7 +2298,7 @@ function getSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps) {
|
|
|
2279
2298
|
}
|
|
2280
2299
|
|
|
2281
2300
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
2282
|
-
var
|
|
2301
|
+
var import_react16 = __toModule(require("react"));
|
|
2283
2302
|
|
|
2284
2303
|
// src/components/DataSource/index.tsx
|
|
2285
2304
|
var React8 = __toModule(require("react"));
|
|
@@ -2361,188 +2380,7 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2361
2380
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2362
2381
|
var import_react15 = __toModule(require("react"));
|
|
2363
2382
|
|
|
2364
|
-
// src/
|
|
2365
|
-
var import_react14 = __toModule(require("react"));
|
|
2366
|
-
function useEffectWithChanges(fn, deps) {
|
|
2367
|
-
const prevRef = (0, import_react14.useRef)({});
|
|
2368
|
-
const oldValuesRef = (0, import_react14.useRef)({});
|
|
2369
|
-
const oldValues = oldValuesRef.current;
|
|
2370
|
-
const changesRef = (0, import_react14.useRef)({});
|
|
2371
|
-
const changes = changesRef.current;
|
|
2372
|
-
const useEffectDeps = [];
|
|
2373
|
-
for (let k in deps) {
|
|
2374
|
-
if (deps.hasOwnProperty(k)) {
|
|
2375
|
-
if (deps[k] !== prevRef.current[k]) {
|
|
2376
|
-
changes[k] = deps[k];
|
|
2377
|
-
oldValues[k] = prevRef.current[k];
|
|
2378
|
-
}
|
|
2379
|
-
useEffectDeps.push(deps[k]);
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
prevRef.current = deps;
|
|
2383
|
-
(0, import_react14.useEffect)(() => {
|
|
2384
|
-
const changes2 = changesRef.current;
|
|
2385
|
-
const result = fn(changes2, oldValues);
|
|
2386
|
-
changesRef.current = {};
|
|
2387
|
-
oldValuesRef.current = {};
|
|
2388
|
-
return result;
|
|
2389
|
-
}, useEffectDeps);
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2393
|
-
var debug3 = dbg("DataSource:useLoadData");
|
|
2394
|
-
function anonimizeValues(arg) {
|
|
2395
|
-
const result = {};
|
|
2396
|
-
for (var k in arg)
|
|
2397
|
-
if (arg.hasOwnProperty(k)) {
|
|
2398
|
-
result[k] = true;
|
|
2399
|
-
}
|
|
2400
|
-
return result;
|
|
2401
|
-
}
|
|
2402
|
-
function buildDataSourceDataParams(componentState, changes) {
|
|
2403
|
-
var _a, _b;
|
|
2404
|
-
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
2405
|
-
const dataSourceParams = {
|
|
2406
|
-
originalDataArray: componentState.originalDataArray,
|
|
2407
|
-
sortInfo,
|
|
2408
|
-
groupBy: componentState.groupBy,
|
|
2409
|
-
pivotBy: componentState.pivotBy
|
|
2410
|
-
};
|
|
2411
|
-
if (componentState.livePagination !== void 0) {
|
|
2412
|
-
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2413
|
-
}
|
|
2414
|
-
if (changes !== void 0) {
|
|
2415
|
-
dataSourceParams.changes = changes;
|
|
2416
|
-
}
|
|
2417
|
-
return dataSourceParams;
|
|
2418
|
-
}
|
|
2419
|
-
function notifyDataParamsChanged(componentState, actions, changes) {
|
|
2420
|
-
var _a;
|
|
2421
|
-
if (typeof componentState.data === "function") {
|
|
2422
|
-
loadData(componentState.data, componentState, actions);
|
|
2423
|
-
}
|
|
2424
|
-
const dataParams = buildDataSourceDataParams(componentState, changes);
|
|
2425
|
-
(_a = componentState.onDataParamsChange) == null ? void 0 : _a.call(componentState, dataParams);
|
|
2426
|
-
}
|
|
2427
|
-
function loadData(data, componentState, actions) {
|
|
2428
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2429
|
-
if (typeof data === "function") {
|
|
2430
|
-
data = data(dataParams);
|
|
2431
|
-
}
|
|
2432
|
-
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
2433
|
-
if (dataIsPromise) {
|
|
2434
|
-
actions.loading = true;
|
|
2435
|
-
}
|
|
2436
|
-
Promise.resolve(data).then((dataParam) => {
|
|
2437
|
-
let dataArray = [];
|
|
2438
|
-
if (Array.isArray(dataParam.data)) {
|
|
2439
|
-
const remoteData = dataParam;
|
|
2440
|
-
dataArray = remoteData.data;
|
|
2441
|
-
if (remoteData.livePaginationCursor !== void 0) {
|
|
2442
|
-
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
2443
|
-
}
|
|
2444
|
-
} else {
|
|
2445
|
-
dataArray = dataParam;
|
|
2446
|
-
}
|
|
2447
|
-
actions.originalDataArray = dataArray;
|
|
2448
|
-
if (dataIsPromise) {
|
|
2449
|
-
actions.loading = false;
|
|
2450
|
-
}
|
|
2451
|
-
});
|
|
2452
|
-
}
|
|
2453
|
-
function useLoadData() {
|
|
2454
|
-
const {
|
|
2455
|
-
getComponentState,
|
|
2456
|
-
componentActions: actions,
|
|
2457
|
-
componentState: { data }
|
|
2458
|
-
} = useComponentState();
|
|
2459
|
-
(0, import_react15.useLayoutEffect)(() => {
|
|
2460
|
-
loadData(data, getComponentState(), actions);
|
|
2461
|
-
}, [data]);
|
|
2462
|
-
useLivePagination();
|
|
2463
|
-
}
|
|
2464
|
-
function useLivePagination() {
|
|
2465
|
-
const {
|
|
2466
|
-
getComponentState,
|
|
2467
|
-
componentActions: actions,
|
|
2468
|
-
componentState
|
|
2469
|
-
} = useComponentState();
|
|
2470
|
-
const {
|
|
2471
|
-
notifyScrollbarsChange,
|
|
2472
|
-
sortInfo,
|
|
2473
|
-
groupBy,
|
|
2474
|
-
pivotBy,
|
|
2475
|
-
livePaginationCursor,
|
|
2476
|
-
scrollBottomId
|
|
2477
|
-
} = componentState;
|
|
2478
|
-
const [scrollbars, setScrollbars] = (0, import_react15.useState)({
|
|
2479
|
-
vertical: false,
|
|
2480
|
-
horizontal: false
|
|
2481
|
-
});
|
|
2482
|
-
const scrollbarsRef = (0, import_react15.useRef)(scrollbars);
|
|
2483
|
-
(0, import_react15.useEffect)(() => {
|
|
2484
|
-
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
2485
|
-
if (!scrollbars2) {
|
|
2486
|
-
return;
|
|
2487
|
-
}
|
|
2488
|
-
scrollbarsRef.current = scrollbars2;
|
|
2489
|
-
setScrollbars(scrollbars2);
|
|
2490
|
-
});
|
|
2491
|
-
return () => notifyScrollbarsChange.destroy();
|
|
2492
|
-
}, [notifyScrollbarsChange]);
|
|
2493
|
-
const [cursorId, updateCursorId] = (0, import_react15.useState)(void 0);
|
|
2494
|
-
(0, import_react15.useEffect)(() => {
|
|
2495
|
-
const frameId = requestAnimationFrame(() => {
|
|
2496
|
-
var _a;
|
|
2497
|
-
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical)) {
|
|
2498
|
-
updateCursorId(livePaginationCursor);
|
|
2499
|
-
}
|
|
2500
|
-
});
|
|
2501
|
-
return () => cancelAnimationFrame(frameId);
|
|
2502
|
-
}, [livePaginationCursor]);
|
|
2503
|
-
(0, import_react15.useEffect)(() => {
|
|
2504
|
-
const { livePaginationCursor: livePaginationCursor2, livePagination } = getComponentState();
|
|
2505
|
-
if (!scrollbars.vertical && livePagination) {
|
|
2506
|
-
updateCursorId(livePaginationCursor2);
|
|
2507
|
-
}
|
|
2508
|
-
}, [scrollbars.vertical]);
|
|
2509
|
-
(0, import_react15.useEffect)(() => {
|
|
2510
|
-
updateCursorId(scrollBottomId);
|
|
2511
|
-
}, [scrollBottomId]);
|
|
2512
|
-
const depsObject = {
|
|
2513
|
-
sortInfo,
|
|
2514
|
-
groupBy,
|
|
2515
|
-
pivotBy,
|
|
2516
|
-
livePaginationCursor: cursorId
|
|
2517
|
-
};
|
|
2518
|
-
useEffectWithChanges((changes, prevValues) => {
|
|
2519
|
-
if (cursorId === void 0) {
|
|
2520
|
-
return;
|
|
2521
|
-
}
|
|
2522
|
-
debug3("onDataParamsChange triggered because the following values have changed", changes, "old values", prevValues);
|
|
2523
|
-
notifyDataParamsChanged(getComponentState(), actions, anonimizeValues(changes));
|
|
2524
|
-
}, depsObject);
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
2528
|
-
var EMPTY_ARRAY = Object.freeze([]);
|
|
2529
|
-
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
2530
|
-
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
2531
|
-
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
2532
|
-
if (weakMap && weakMap.has(sortInfo)) {
|
|
2533
|
-
const prevResult = weakMap.get(sortInfo);
|
|
2534
|
-
if (prevResult && prevResult.length === result.length) {
|
|
2535
|
-
return prevResult;
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
if (weakMap && sortInfo) {
|
|
2539
|
-
weakMap.set(sortInfo, result);
|
|
2540
|
-
}
|
|
2541
|
-
return result;
|
|
2542
|
-
};
|
|
2543
|
-
|
|
2544
|
-
// src/components/hooks/useOnce.ts
|
|
2545
|
-
var import_react16 = __toModule(require("react"));
|
|
2383
|
+
// src/utils/DeepMap/once.ts
|
|
2546
2384
|
function once(fn) {
|
|
2547
2385
|
let called = false;
|
|
2548
2386
|
let result = null;
|
|
@@ -2556,14 +2394,8 @@ function once(fn) {
|
|
|
2556
2394
|
};
|
|
2557
2395
|
return onceFn;
|
|
2558
2396
|
}
|
|
2559
|
-
function useOnce(fn) {
|
|
2560
|
-
const onceFn = (0, import_react16.useMemo)(() => {
|
|
2561
|
-
return once(fn);
|
|
2562
|
-
}, []);
|
|
2563
|
-
return onceFn();
|
|
2564
|
-
}
|
|
2565
2397
|
|
|
2566
|
-
// src/utils/DeepMap.ts
|
|
2398
|
+
// src/utils/DeepMap/index.ts
|
|
2567
2399
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2568
2400
|
var DeepMap = class {
|
|
2569
2401
|
constructor(initial) {
|
|
@@ -2815,69 +2647,660 @@ var DeepMap = class {
|
|
|
2815
2647
|
}
|
|
2816
2648
|
};
|
|
2817
2649
|
|
|
2818
|
-
// src/
|
|
2819
|
-
var
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
return {
|
|
2826
|
-
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
2827
|
-
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
2828
|
-
};
|
|
2829
|
-
}
|
|
2830
|
-
destroy() {
|
|
2831
|
-
var _a, _b;
|
|
2832
|
-
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
2833
|
-
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
2834
|
-
delete this.expandedMap;
|
|
2835
|
-
delete this.collapsedMap;
|
|
2650
|
+
// src/utils/groupAndPivot/index.ts
|
|
2651
|
+
var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
|
|
2652
|
+
function DEFAULT_TO_KEY(value) {
|
|
2653
|
+
return value;
|
|
2654
|
+
}
|
|
2655
|
+
function initReducers(reducers) {
|
|
2656
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2657
|
+
return {};
|
|
2836
2658
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
this.collapsedAll = collapsedRows === true;
|
|
2842
|
-
this.expandedAll = expandedRows === true;
|
|
2843
|
-
if (this.collapsedAll && this.expandedAll) {
|
|
2844
|
-
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
2845
|
-
}
|
|
2846
|
-
if (collapsedRows !== true) {
|
|
2847
|
-
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
2848
|
-
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
2849
|
-
}
|
|
2850
|
-
if (expandedRows !== true) {
|
|
2851
|
-
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
2852
|
-
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
2659
|
+
const result = {};
|
|
2660
|
+
for (let key in reducers)
|
|
2661
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2662
|
+
result[key] = reducers[key].initialValue;
|
|
2853
2663
|
}
|
|
2664
|
+
return result;
|
|
2665
|
+
}
|
|
2666
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
2667
|
+
var _a, _b;
|
|
2668
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2669
|
+
return;
|
|
2854
2670
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
}
|
|
2861
|
-
collapseAll() {
|
|
2862
|
-
this.update({
|
|
2863
|
-
collapsedRows: true,
|
|
2864
|
-
expandedRows: []
|
|
2865
|
-
});
|
|
2866
|
-
}
|
|
2867
|
-
expandAll() {
|
|
2868
|
-
this.update({
|
|
2869
|
-
expandedRows: true,
|
|
2870
|
-
collapsedRows: []
|
|
2871
|
-
});
|
|
2872
|
-
}
|
|
2873
|
-
isGroupRowExpanded(keys) {
|
|
2874
|
-
var _a, _b;
|
|
2875
|
-
if (this.expandedAll === true) {
|
|
2876
|
-
if (this.collapsedAll === true) {
|
|
2877
|
-
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
2671
|
+
for (let key in reducers)
|
|
2672
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2673
|
+
const reducer = reducers[key];
|
|
2674
|
+
if (typeof reducer.reducer !== "function") {
|
|
2675
|
+
continue;
|
|
2878
2676
|
}
|
|
2879
|
-
|
|
2880
|
-
|
|
2677
|
+
const currentValue = reducerResults[key];
|
|
2678
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
2679
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
function lazyGroup(groupParams, rootData) {
|
|
2683
|
+
const {
|
|
2684
|
+
reducers = {},
|
|
2685
|
+
pivot,
|
|
2686
|
+
groupBy,
|
|
2687
|
+
mappings
|
|
2688
|
+
} = groupParams;
|
|
2689
|
+
const deepMap = new DeepMap();
|
|
2690
|
+
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
2691
|
+
const last = pivotIndex === pivot2.length - 1;
|
|
2692
|
+
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
2693
|
+
for (var k in values)
|
|
2694
|
+
if (values.hasOwnProperty(k)) {
|
|
2695
|
+
const pivotKey = k;
|
|
2696
|
+
currentPivotKeys2.push(pivotKey);
|
|
2697
|
+
topLevelPivotColumns.set(currentPivotKeys2, true);
|
|
2698
|
+
pivotDeepMap.set(currentPivotKeys2, {
|
|
2699
|
+
reducerResults: values[k][(mappings == null ? void 0 : mappings.totals) || "totals"] || {},
|
|
2700
|
+
items: []
|
|
2701
|
+
});
|
|
2702
|
+
if (!last) {
|
|
2703
|
+
traverseValues(pivotDeepMap, values[k], pivot2, pivotIndex + 1, currentPivotKeys2);
|
|
2704
|
+
}
|
|
2705
|
+
currentPivotKeys2.pop();
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2709
|
+
let currentPivotKeys = [];
|
|
2710
|
+
const initialReducerValue = initReducers(reducers);
|
|
2711
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2712
|
+
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2713
|
+
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2714
|
+
const dataArray = lazyGroupRowInfo.items;
|
|
2715
|
+
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2716
|
+
if (!dataArray[i]) {
|
|
2717
|
+
const deepMapGroupValue2 = {
|
|
2718
|
+
items: [],
|
|
2719
|
+
reducerResults: {}
|
|
2720
|
+
};
|
|
2721
|
+
deepMap.set([...currentGroupKeys, `not-loaded-yet-${i}`], deepMapGroupValue2);
|
|
2722
|
+
continue;
|
|
2723
|
+
}
|
|
2724
|
+
const dataObject = dataArray[i].data;
|
|
2725
|
+
const dataKeys = dataArray[i].keys;
|
|
2726
|
+
let item = dataObject;
|
|
2727
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
2728
|
+
const key = item[groupByProperty];
|
|
2729
|
+
currentGroupKeys.push(key);
|
|
2730
|
+
const deepMapGroupValue = {
|
|
2731
|
+
items: [],
|
|
2732
|
+
reducerResults: dataArray[i].aggregations || {}
|
|
2733
|
+
};
|
|
2734
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2735
|
+
if (pivot) {
|
|
2736
|
+
const pivotDeepMap = deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2737
|
+
const pivotContainer = dataArray[i].pivot;
|
|
2738
|
+
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
2739
|
+
}
|
|
2740
|
+
currentGroupKeys.pop();
|
|
2741
|
+
}
|
|
2742
|
+
next == null ? void 0 : next();
|
|
2743
|
+
});
|
|
2744
|
+
const result = {
|
|
2745
|
+
deepMap,
|
|
2746
|
+
groupParams,
|
|
2747
|
+
initialData: rootData,
|
|
2748
|
+
reducerResults: globalReducerResults
|
|
2749
|
+
};
|
|
2750
|
+
if (pivot) {
|
|
2751
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2752
|
+
result.pivot = pivot;
|
|
2753
|
+
}
|
|
2754
|
+
return result;
|
|
2755
|
+
}
|
|
2756
|
+
function group(groupParams, data) {
|
|
2757
|
+
const {
|
|
2758
|
+
groupBy,
|
|
2759
|
+
defaultToKey = DEFAULT_TO_KEY,
|
|
2760
|
+
pivot,
|
|
2761
|
+
reducers
|
|
2762
|
+
} = groupParams;
|
|
2763
|
+
const groupByLength = groupBy.length;
|
|
2764
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2765
|
+
const deepMap = new DeepMap();
|
|
2766
|
+
let currentGroupKeys = [];
|
|
2767
|
+
let currentPivotKeys = [];
|
|
2768
|
+
const initialReducerValue = initReducers(reducers);
|
|
2769
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2770
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
2771
|
+
let item = data[i];
|
|
2772
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
2773
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
2774
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
2775
|
+
currentGroupKeys.push(key);
|
|
2776
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
2777
|
+
const deepMapGroupValue = {
|
|
2778
|
+
items: [],
|
|
2779
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
2780
|
+
};
|
|
2781
|
+
if (pivot) {
|
|
2782
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2783
|
+
}
|
|
2784
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2785
|
+
}
|
|
2786
|
+
const {
|
|
2787
|
+
items: currentGroupItems,
|
|
2788
|
+
reducerResults,
|
|
2789
|
+
pivotDeepMap
|
|
2790
|
+
} = deepMap.get(currentGroupKeys);
|
|
2791
|
+
currentGroupItems.push(item);
|
|
2792
|
+
if (reducers) {
|
|
2793
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
2794
|
+
}
|
|
2795
|
+
if (pivot) {
|
|
2796
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
2797
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
2798
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
2799
|
+
currentPivotKeys.push(pivotKey);
|
|
2800
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
2801
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
2802
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
2803
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
2804
|
+
items: []
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
const {
|
|
2808
|
+
reducerResults: pivotReducerResults,
|
|
2809
|
+
items: pivotGroupItems
|
|
2810
|
+
} = pivotDeepMap.get(currentPivotKeys);
|
|
2811
|
+
pivotGroupItems.push(item);
|
|
2812
|
+
if (reducers) {
|
|
2813
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
currentPivotKeys.length = 0;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
if (reducers) {
|
|
2820
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
2821
|
+
}
|
|
2822
|
+
currentGroupKeys.length = 0;
|
|
2823
|
+
}
|
|
2824
|
+
if (reducers) {
|
|
2825
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
2826
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
2827
|
+
if (pivot) {
|
|
2828
|
+
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
2829
|
+
completeReducers(reducers, pivotReducerResults, items);
|
|
2830
|
+
next2 == null ? void 0 : next2();
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
next == null ? void 0 : next();
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
if (reducers) {
|
|
2837
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
2838
|
+
}
|
|
2839
|
+
const result = {
|
|
2840
|
+
deepMap,
|
|
2841
|
+
groupParams,
|
|
2842
|
+
initialData: data,
|
|
2843
|
+
reducerResults: globalReducerResults
|
|
2844
|
+
};
|
|
2845
|
+
if (pivot) {
|
|
2846
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2847
|
+
result.pivot = pivot;
|
|
2848
|
+
}
|
|
2849
|
+
return result;
|
|
2850
|
+
}
|
|
2851
|
+
function flatten(groupResult) {
|
|
2852
|
+
const { groupParams, deepMap } = groupResult;
|
|
2853
|
+
const groupByLength = groupParams.groupBy.length;
|
|
2854
|
+
const result = [];
|
|
2855
|
+
deepMap.topDownKeys().reduce((acc, key) => {
|
|
2856
|
+
if (key.length === groupByLength) {
|
|
2857
|
+
const items = deepMap.get(key).items;
|
|
2858
|
+
acc.push(...items);
|
|
2859
|
+
}
|
|
2860
|
+
return acc;
|
|
2861
|
+
}, result);
|
|
2862
|
+
return result;
|
|
2863
|
+
}
|
|
2864
|
+
function getEnhancedGroupData(options, deepMapValue) {
|
|
2865
|
+
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2866
|
+
const groupNesting = groupKeys.length;
|
|
2867
|
+
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
2868
|
+
let data = null;
|
|
2869
|
+
if (Object.keys(reducerResults).length > 0) {
|
|
2870
|
+
data = {};
|
|
2871
|
+
for (let key in reducers)
|
|
2872
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2873
|
+
const reducer = reducers[key];
|
|
2874
|
+
const field = reducer.field;
|
|
2875
|
+
if (field) {
|
|
2876
|
+
data[field] = reducerResults[key];
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
const enhancedGroupData = {
|
|
2881
|
+
data,
|
|
2882
|
+
groupCount: groupItems.length,
|
|
2883
|
+
groupData: groupItems,
|
|
2884
|
+
groupKeys,
|
|
2885
|
+
id: groupKeys,
|
|
2886
|
+
collapsed,
|
|
2887
|
+
parents,
|
|
2888
|
+
collapsedChildrenCount: 0,
|
|
2889
|
+
collapsedGroupsCount: 0,
|
|
2890
|
+
indexInParentGroups: options.indexInParentGroups,
|
|
2891
|
+
indexInGroup: options.indexInGroup,
|
|
2892
|
+
indexInAll: options.indexInAll,
|
|
2893
|
+
value: groupKeys[groupKeys.length - 1],
|
|
2894
|
+
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
|
+
}
|
|
2881
3304
|
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
2882
3305
|
}
|
|
2883
3306
|
isGroupRowCollapsed(keys) {
|
|
@@ -2926,7 +3349,7 @@ var GroupRowsState = class {
|
|
|
2926
3349
|
};
|
|
2927
3350
|
|
|
2928
3351
|
// src/utils/shallowEqualObjects.ts
|
|
2929
|
-
function shallowEqualObjects(objA, objB) {
|
|
3352
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
2930
3353
|
if (objA === objB) {
|
|
2931
3354
|
return true;
|
|
2932
3355
|
}
|
|
@@ -2935,12 +3358,21 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2935
3358
|
}
|
|
2936
3359
|
var aKeys = Object.keys(objA);
|
|
2937
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
|
+
}
|
|
2938
3365
|
var len = aKeys.length;
|
|
2939
3366
|
if (bKeys.length !== len) {
|
|
2940
3367
|
return false;
|
|
2941
3368
|
}
|
|
2942
3369
|
for (var i = 0; i < len; i++) {
|
|
2943
3370
|
var key = aKeys[i];
|
|
3371
|
+
if (ignoreKeys) {
|
|
3372
|
+
if (ignoreKeys.has(key)) {
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
2944
3376
|
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2945
3377
|
return false;
|
|
2946
3378
|
}
|
|
@@ -2951,12 +3383,12 @@ function shallowEqualObjects(objA, objB) {
|
|
|
2951
3383
|
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2952
3384
|
var map = new WeakMap();
|
|
2953
3385
|
var getCompareDefault = (a) => a;
|
|
2954
|
-
function discardCallsWithEqualArg(fn, timeframe = 50,
|
|
3386
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
2955
3387
|
map.set(fn, {
|
|
2956
3388
|
lastCallTime: 0,
|
|
2957
3389
|
lastCallArg: null
|
|
2958
3390
|
});
|
|
2959
|
-
const getCompare =
|
|
3391
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
2960
3392
|
return (arg) => {
|
|
2961
3393
|
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2962
3394
|
lastCallTime: 0,
|
|
@@ -2977,20 +3409,25 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
|
2977
3409
|
}
|
|
2978
3410
|
|
|
2979
3411
|
// src/components/DataSource/state/getInitialState.ts
|
|
3412
|
+
var defaultCursorId = Symbol("cursorId");
|
|
2980
3413
|
function initSetupState2() {
|
|
2981
3414
|
const now = Date.now();
|
|
2982
3415
|
const originalDataArray = [];
|
|
2983
3416
|
const dataArray = [];
|
|
3417
|
+
const originalLazyGroupData = new DeepMap();
|
|
2984
3418
|
return {
|
|
2985
3419
|
dataParams: void 0,
|
|
2986
3420
|
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3421
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
2987
3422
|
pivotTotalColumnPosition: "end",
|
|
3423
|
+
originalLazyGroupData,
|
|
2988
3424
|
originalDataArray,
|
|
2989
|
-
|
|
3425
|
+
cursorId: defaultCursorId,
|
|
2990
3426
|
showSeparatePivotColumnForSingleAggregation: false,
|
|
2991
3427
|
propsCache: new Map([
|
|
2992
3428
|
["sortInfo", new WeakMap()]
|
|
2993
3429
|
]),
|
|
3430
|
+
pivotMappings: void 0,
|
|
2994
3431
|
pivotColumns: void 0,
|
|
2995
3432
|
pivotColumnGroups: void 0,
|
|
2996
3433
|
dataArray,
|
|
@@ -3006,19 +3443,22 @@ function initSetupState2() {
|
|
|
3006
3443
|
lastGroupDataArray: void 0
|
|
3007
3444
|
};
|
|
3008
3445
|
}
|
|
3009
|
-
function
|
|
3446
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
3010
3447
|
const obj = __spreadValues({}, dataParams);
|
|
3011
3448
|
delete obj.originalDataArray;
|
|
3012
3449
|
return obj;
|
|
3013
3450
|
}
|
|
3014
3451
|
var forwardProps3 = (setupState) => {
|
|
3015
3452
|
return {
|
|
3016
|
-
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100,
|
|
3453
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3454
|
+
fullLazyLoad: 1,
|
|
3017
3455
|
data: 1,
|
|
3018
3456
|
pivotBy: 1,
|
|
3019
3457
|
primaryKey: 1,
|
|
3020
3458
|
livePagination: 1,
|
|
3459
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3021
3460
|
aggregationReducers: 1,
|
|
3461
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3022
3462
|
loading: (loading) => loading != null ? loading : false,
|
|
3023
3463
|
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
3024
3464
|
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
@@ -3030,297 +3470,111 @@ var forwardProps3 = (setupState) => {
|
|
|
3030
3470
|
}
|
|
3031
3471
|
};
|
|
3032
3472
|
};
|
|
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;
|
|
3480
|
+
}
|
|
3033
3481
|
function mapPropsToState2(params) {
|
|
3034
|
-
const { props, state } = params;
|
|
3482
|
+
const { props, state, oldState } = params;
|
|
3035
3483
|
const controlledSort = isControlledValue(props.sortInfo);
|
|
3036
3484
|
const result = {
|
|
3037
|
-
controlledSort,
|
|
3038
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3039
|
-
};
|
|
3040
|
-
if (props.livePagination) {
|
|
3041
|
-
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? props.livePaginationCursor({
|
|
3042
|
-
array: state.originalDataArray,
|
|
3043
|
-
length: state.originalDataArray.length,
|
|
3044
|
-
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3045
|
-
}) : props.livePaginationCursor;
|
|
3046
|
-
result.livePaginationCursor = livePaginationCursor;
|
|
3047
|
-
}
|
|
3048
|
-
return result;
|
|
3049
|
-
}
|
|
3050
|
-
function getInterceptActions() {
|
|
3051
|
-
return {
|
|
3052
|
-
sortInfo: (sortInfo, { actions, state }) => {
|
|
3053
|
-
const dataParams = buildDataSourceDataParams(state);
|
|
3054
|
-
dataParams.sortInfo = sortInfo;
|
|
3055
|
-
actions.dataParams = dataParams;
|
|
3056
|
-
}
|
|
3057
|
-
};
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
// src/utils/groupAndPivot/index.ts
|
|
3061
|
-
function DEFAULT_TO_KEY(value) {
|
|
3062
|
-
return value;
|
|
3063
|
-
}
|
|
3064
|
-
function initReducers(reducers) {
|
|
3065
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3066
|
-
return {};
|
|
3067
|
-
}
|
|
3068
|
-
const result = {};
|
|
3069
|
-
for (let key in reducers)
|
|
3070
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3071
|
-
result[key] = reducers[key].initialValue;
|
|
3072
|
-
}
|
|
3073
|
-
return result;
|
|
3074
|
-
}
|
|
3075
|
-
function computeReducersFor(data, reducers, reducerResults) {
|
|
3076
|
-
var _a, _b;
|
|
3077
|
-
if (!reducers || !Object.keys(reducers).length) {
|
|
3078
|
-
return;
|
|
3079
|
-
}
|
|
3080
|
-
for (let key in reducers)
|
|
3081
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3082
|
-
const reducer = reducers[key];
|
|
3083
|
-
const currentValue = reducerResults[key];
|
|
3084
|
-
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
3085
|
-
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
function group(groupParams, data) {
|
|
3089
|
-
const {
|
|
3090
|
-
groupBy,
|
|
3091
|
-
defaultToKey = DEFAULT_TO_KEY,
|
|
3092
|
-
pivot,
|
|
3093
|
-
reducers
|
|
3094
|
-
} = groupParams;
|
|
3095
|
-
const groupByLength = groupBy.length;
|
|
3096
|
-
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3097
|
-
const deepMap = new DeepMap();
|
|
3098
|
-
let currentGroupKeys = [];
|
|
3099
|
-
let currentPivotKeys = [];
|
|
3100
|
-
const initialReducerValue = initReducers(reducers);
|
|
3101
|
-
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3102
|
-
for (let i = 0, len = data.length; i < len; i++) {
|
|
3103
|
-
let item = data[i];
|
|
3104
|
-
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
3105
|
-
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
3106
|
-
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
3107
|
-
currentGroupKeys.push(key);
|
|
3108
|
-
if (!deepMap.has(currentGroupKeys)) {
|
|
3109
|
-
const deepMapGroupValue = {
|
|
3110
|
-
items: [],
|
|
3111
|
-
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3112
|
-
};
|
|
3113
|
-
if (pivot) {
|
|
3114
|
-
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3115
|
-
}
|
|
3116
|
-
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3117
|
-
}
|
|
3118
|
-
const {
|
|
3119
|
-
items: currentGroupItems,
|
|
3120
|
-
reducerResults,
|
|
3121
|
-
pivotDeepMap
|
|
3122
|
-
} = deepMap.get(currentGroupKeys);
|
|
3123
|
-
currentGroupItems.push(item);
|
|
3124
|
-
if (reducers) {
|
|
3125
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3126
|
-
}
|
|
3127
|
-
if (pivot) {
|
|
3128
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3129
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3130
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3131
|
-
currentPivotKeys.push(pivotKey);
|
|
3132
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3133
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3134
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3135
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3136
|
-
items: []
|
|
3137
|
-
});
|
|
3138
|
-
}
|
|
3139
|
-
const {
|
|
3140
|
-
reducerResults: pivotReducerResults,
|
|
3141
|
-
items: pivotGroupItems
|
|
3142
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3143
|
-
pivotGroupItems.push(item);
|
|
3144
|
-
if (reducers) {
|
|
3145
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3146
|
-
}
|
|
3147
|
-
}
|
|
3148
|
-
currentPivotKeys.length = 0;
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
if (reducers) {
|
|
3152
|
-
computeReducersFor(item, reducers, globalReducerResults);
|
|
3153
|
-
}
|
|
3154
|
-
currentGroupKeys.length = 0;
|
|
3155
|
-
}
|
|
3156
|
-
if (reducers) {
|
|
3157
|
-
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
3158
|
-
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
3159
|
-
if (pivot) {
|
|
3160
|
-
deepMapValue.pivotDeepMap.visitDepthFirst(({ items, reducerResults: pivotReducerResults }, _keys2, _indexInGroup2, next2) => {
|
|
3161
|
-
completeReducers(reducers, pivotReducerResults, items);
|
|
3162
|
-
next2 == null ? void 0 : next2();
|
|
3163
|
-
});
|
|
3164
|
-
}
|
|
3165
|
-
next == null ? void 0 : next();
|
|
3166
|
-
});
|
|
3167
|
-
}
|
|
3168
|
-
if (reducers) {
|
|
3169
|
-
completeReducers(reducers, globalReducerResults, data);
|
|
3170
|
-
}
|
|
3171
|
-
const result = {
|
|
3172
|
-
deepMap,
|
|
3173
|
-
groupParams,
|
|
3174
|
-
initialData: data,
|
|
3175
|
-
reducerResults: globalReducerResults
|
|
3485
|
+
controlledSort,
|
|
3486
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3176
3487
|
};
|
|
3177
|
-
if (
|
|
3178
|
-
|
|
3179
|
-
|
|
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;
|
|
3180
3492
|
}
|
|
3181
3493
|
return result;
|
|
3182
3494
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
const
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
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
|
+
});
|
|
3191
3507
|
}
|
|
3192
|
-
return acc;
|
|
3193
|
-
}, result);
|
|
3194
|
-
return result;
|
|
3195
|
-
}
|
|
3196
|
-
function getEnhancedGroupData(options, deepMapValue) {
|
|
3197
|
-
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
3198
|
-
const groupNesting = groupKeys.length;
|
|
3199
|
-
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
3200
|
-
let data = null;
|
|
3201
|
-
if (Object.keys(reducerResults).length > 0) {
|
|
3202
|
-
data = {};
|
|
3203
|
-
for (let key in reducers)
|
|
3204
|
-
if (reducers.hasOwnProperty(key)) {
|
|
3205
|
-
const reducer = reducers[key];
|
|
3206
|
-
const field = reducer.field;
|
|
3207
|
-
if (field) {
|
|
3208
|
-
data[field] = reducerResults[key];
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
3508
|
}
|
|
3212
|
-
const enhancedGroupData = {
|
|
3213
|
-
data,
|
|
3214
|
-
groupCount: groupItems.length,
|
|
3215
|
-
groupData: groupItems,
|
|
3216
|
-
groupKeys,
|
|
3217
|
-
id: groupKeys,
|
|
3218
|
-
collapsed,
|
|
3219
|
-
parents,
|
|
3220
|
-
collapsedChildrenCount: 0,
|
|
3221
|
-
collapsedGroupsCount: 0,
|
|
3222
|
-
indexInParentGroups: options.indexInParentGroups,
|
|
3223
|
-
indexInGroup: options.indexInGroup,
|
|
3224
|
-
indexInAll: options.indexInAll,
|
|
3225
|
-
value: groupKeys[groupKeys.length - 1],
|
|
3226
|
-
groupBy: groupBy.slice(0, groupNesting),
|
|
3227
|
-
isGroupRow: true,
|
|
3228
|
-
pivotValuesMap: pivotDeepMap,
|
|
3229
|
-
groupNesting,
|
|
3230
|
-
reducerResults
|
|
3231
|
-
};
|
|
3232
|
-
return enhancedGroupData;
|
|
3233
3509
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
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
|
+
});
|
|
3242
3523
|
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
groupResult,
|
|
3249
|
-
toPrimaryKey,
|
|
3250
|
-
groupRowsState,
|
|
3251
|
-
generateGroupRows,
|
|
3252
|
-
reducers = {}
|
|
3253
|
-
} = param;
|
|
3254
|
-
const { groupParams, deepMap, pivot } = groupResult;
|
|
3255
|
-
const { groupBy } = groupParams;
|
|
3256
|
-
const groupByStrings = groupBy.map((g) => g.field);
|
|
3257
|
-
const result = [];
|
|
3258
|
-
const parents = [];
|
|
3259
|
-
const indexInParentGroups = [];
|
|
3260
|
-
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
3261
|
-
var _a;
|
|
3262
|
-
const items = deepMapValue.items;
|
|
3263
|
-
const groupNesting = groupKeys.length;
|
|
3264
|
-
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
3265
|
-
const enhancedGroupData = getEnhancedGroupData({
|
|
3266
|
-
groupBy: groupByStrings,
|
|
3267
|
-
parents: Array.from(parents),
|
|
3268
|
-
reducers,
|
|
3269
|
-
indexInGroup,
|
|
3270
|
-
indexInParentGroups: Array.from(indexInParentGroups),
|
|
3271
|
-
indexInAll: result.length,
|
|
3272
|
-
groupKeys,
|
|
3273
|
-
collapsed
|
|
3274
|
-
}, deepMapValue);
|
|
3275
|
-
const include = generateGroupRows || collapsed;
|
|
3276
|
-
if (include) {
|
|
3277
|
-
result.push(enhancedGroupData);
|
|
3278
|
-
}
|
|
3279
|
-
if (collapsed) {
|
|
3280
|
-
parents.forEach((parent) => {
|
|
3281
|
-
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
3282
|
-
parent.collapsedGroupsCount += 1;
|
|
3524
|
+
},
|
|
3525
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3526
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3527
|
+
groupBy,
|
|
3528
|
+
livePaginationCursor: null
|
|
3283
3529
|
});
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
if (!pivot) {
|
|
3290
|
-
const startIndex = result.length;
|
|
3291
|
-
result.push(...items.map((item, index) => {
|
|
3292
|
-
return {
|
|
3293
|
-
id: toPrimaryKey(item),
|
|
3294
|
-
data: item,
|
|
3295
|
-
isGroupRow: false,
|
|
3296
|
-
collapsed: false,
|
|
3297
|
-
groupKeys,
|
|
3298
|
-
parents: Array.from(parents),
|
|
3299
|
-
indexInParentGroups: [...indexInParentGroups, index],
|
|
3300
|
-
indexInGroup: index,
|
|
3301
|
-
indexInAll: startIndex + index,
|
|
3302
|
-
groupBy: groupByStrings,
|
|
3303
|
-
groupNesting,
|
|
3304
|
-
groupCount: enhancedGroupData.groupCount
|
|
3305
|
-
};
|
|
3306
|
-
}));
|
|
3307
|
-
}
|
|
3308
|
-
} else {
|
|
3309
|
-
next();
|
|
3530
|
+
actions.dataParams = dataParams;
|
|
3531
|
+
if (state.livePagination) {
|
|
3532
|
+
requestAnimationFrame(() => {
|
|
3533
|
+
actions.livePaginationCursor = null;
|
|
3534
|
+
});
|
|
3310
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;
|
|
3567
|
+
}
|
|
3568
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3569
|
+
return true;
|
|
3311
3570
|
}
|
|
3312
|
-
parents.pop();
|
|
3313
|
-
indexInParentGroups.pop();
|
|
3314
|
-
});
|
|
3315
|
-
return {
|
|
3316
|
-
data: result
|
|
3317
3571
|
};
|
|
3318
3572
|
}
|
|
3319
3573
|
|
|
3320
3574
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3321
3575
|
function prepareColumn(column) {
|
|
3322
3576
|
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3323
|
-
if (pivotByForColumn.column) {
|
|
3577
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3324
3578
|
if (typeof pivotByForColumn.column === "function") {
|
|
3325
3579
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3326
3580
|
} else {
|
|
@@ -3331,7 +3585,7 @@ function prepareColumn(column) {
|
|
|
3331
3585
|
}
|
|
3332
3586
|
function prepareColumnGroup(columnGroup) {
|
|
3333
3587
|
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3334
|
-
if (pivotByForColumnGroup.columnGroup) {
|
|
3588
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3335
3589
|
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3336
3590
|
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3337
3591
|
} else {
|
|
@@ -3360,6 +3614,9 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3360
3614
|
valueGetter: (params) => {
|
|
3361
3615
|
var _a;
|
|
3362
3616
|
const { rowInfo } = params;
|
|
3617
|
+
if (!rowInfo.data) {
|
|
3618
|
+
return "Loading ... TODO replace this with a loading indicator";
|
|
3619
|
+
}
|
|
3363
3620
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3364
3621
|
}
|
|
3365
3622
|
}
|
|
@@ -3391,7 +3648,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3391
3648
|
}));
|
|
3392
3649
|
}
|
|
3393
3650
|
aggregationReducers.forEach((reducer, index) => {
|
|
3394
|
-
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.id;
|
|
3651
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3395
3652
|
const computedPivotColumn = prepareColumn({
|
|
3396
3653
|
pivotBy,
|
|
3397
3654
|
pivotColumn: true,
|
|
@@ -3410,7 +3667,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3410
3667
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3411
3668
|
}
|
|
3412
3669
|
});
|
|
3413
|
-
const columnId = `${keys.join("/")}
|
|
3670
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3414
3671
|
columns.set(columnId, computedPivotColumn);
|
|
3415
3672
|
});
|
|
3416
3673
|
} else {
|
|
@@ -3443,7 +3700,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3443
3700
|
}));
|
|
3444
3701
|
}
|
|
3445
3702
|
aggregationReducers.forEach((reducer, index) => {
|
|
3446
|
-
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`;
|
|
3447
3704
|
const computedPivotColumn = prepareColumn({
|
|
3448
3705
|
columnGroup: columnGroupId,
|
|
3449
3706
|
header,
|
|
@@ -3462,7 +3719,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3462
3719
|
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3463
3720
|
}
|
|
3464
3721
|
});
|
|
3465
|
-
columns.set(`total:${keys.join("/")}
|
|
3722
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3466
3723
|
});
|
|
3467
3724
|
}
|
|
3468
3725
|
}
|
|
@@ -3471,15 +3728,22 @@ function getPivotColumnsAndColumnGroups({
|
|
|
3471
3728
|
}
|
|
3472
3729
|
});
|
|
3473
3730
|
if (columns.size === 1) {
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
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
|
+
}));
|
|
3483
3747
|
});
|
|
3484
3748
|
}
|
|
3485
3749
|
const result = {
|
|
@@ -3516,10 +3780,11 @@ function concludeReducer(params) {
|
|
|
3516
3780
|
const { state, previousState } = params;
|
|
3517
3781
|
const sortInfo = state.sortInfo;
|
|
3518
3782
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3519
|
-
const
|
|
3520
|
-
"originalDataArray"
|
|
3521
|
-
"sortInfo"
|
|
3783
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3784
|
+
"originalDataArray"
|
|
3522
3785
|
]);
|
|
3786
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3787
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3523
3788
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3524
3789
|
const groupBy = state.groupBy;
|
|
3525
3790
|
const pivotBy = state.pivotBy;
|
|
@@ -3527,6 +3792,7 @@ function concludeReducer(params) {
|
|
|
3527
3792
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3528
3793
|
"generateGroupRows",
|
|
3529
3794
|
"originalDataArray",
|
|
3795
|
+
"originalLazyGroupData",
|
|
3530
3796
|
"groupBy",
|
|
3531
3797
|
"groupRowsState",
|
|
3532
3798
|
"pivotBy",
|
|
@@ -3551,7 +3817,12 @@ function concludeReducer(params) {
|
|
|
3551
3817
|
};
|
|
3552
3818
|
if (shouldGroup) {
|
|
3553
3819
|
if (shouldGroupAgain) {
|
|
3554
|
-
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({
|
|
3555
3826
|
groupBy,
|
|
3556
3827
|
pivot: pivotBy,
|
|
3557
3828
|
reducers: state.aggregationReducers
|
|
@@ -3619,6 +3890,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3619
3890
|
forwardProps: forwardProps3,
|
|
3620
3891
|
concludeReducer,
|
|
3621
3892
|
mapPropsToState: mapPropsToState2,
|
|
3893
|
+
onPropChange,
|
|
3622
3894
|
interceptActions: getInterceptActions()
|
|
3623
3895
|
});
|
|
3624
3896
|
function DataSourceCmp({ children }) {
|
|
@@ -3649,17 +3921,23 @@ function DataSource(props) {
|
|
|
3649
3921
|
// src/components/InfiniteTable/hooks/useToggleGroupRow.ts
|
|
3650
3922
|
function useToggleGroupRow() {
|
|
3651
3923
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3652
|
-
const toggleGroupRow = (0,
|
|
3653
|
-
const
|
|
3924
|
+
const toggleGroupRow = (0, import_react16.useCallback)((groupKeys) => {
|
|
3925
|
+
const state = getDataSourceState();
|
|
3926
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3654
3927
|
newState.toggleGroupRow(groupKeys);
|
|
3655
3928
|
dataSourceActions.groupRowsState = newState;
|
|
3929
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
3930
|
+
loadData(state.data, state, dataSourceActions, {
|
|
3931
|
+
groupKeys
|
|
3932
|
+
});
|
|
3933
|
+
}
|
|
3656
3934
|
}, []);
|
|
3657
3935
|
return toggleGroupRow;
|
|
3658
3936
|
}
|
|
3659
3937
|
|
|
3660
3938
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
3661
3939
|
function useGroupByMap(groupBy) {
|
|
3662
|
-
const groupByMap = (0,
|
|
3940
|
+
const groupByMap = (0, import_react17.useMemo)(() => {
|
|
3663
3941
|
return groupBy.reduce((acc, groupBy2, index) => {
|
|
3664
3942
|
acc.set(groupBy2.field, {
|
|
3665
3943
|
groupBy: groupBy2,
|
|
@@ -3679,10 +3957,10 @@ function useColumnsWhen() {
|
|
|
3679
3957
|
componentState: { groupRenderStrategy, pivotTotalColumnPosition }
|
|
3680
3958
|
} = useComponentState();
|
|
3681
3959
|
const groupByMap = useGroupByMap(groupBy);
|
|
3682
|
-
(0,
|
|
3960
|
+
(0, import_react17.useEffect)(() => {
|
|
3683
3961
|
dataSourceActions.generateGroupRows = groupRenderStrategy !== "inline";
|
|
3684
3962
|
}, [groupRenderStrategy]);
|
|
3685
|
-
(0,
|
|
3963
|
+
(0, import_react17.useEffect)(() => {
|
|
3686
3964
|
dataSourceActions.pivotTotalColumnPosition = pivotTotalColumnPosition;
|
|
3687
3965
|
}, [pivotTotalColumnPosition]);
|
|
3688
3966
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
@@ -3745,7 +4023,7 @@ function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
|
3745
4023
|
});
|
|
3746
4024
|
return computedColumns.size === 0 ? void 0 : computedColumns;
|
|
3747
4025
|
}
|
|
3748
|
-
(0,
|
|
4026
|
+
(0, import_react17.useEffect)(() => {
|
|
3749
4027
|
const update = () => {
|
|
3750
4028
|
componentActions.columnsWhenInlineGroupRenderStrategy = computeColumnsWhenInlineGroupRenderStrategy(columns, groupByMap, groupRenderStrategy, toggleGroupRow);
|
|
3751
4029
|
};
|
|
@@ -3771,7 +4049,7 @@ function useColumnsWhenPivoting() {
|
|
|
3771
4049
|
}
|
|
3772
4050
|
} = useComponentState();
|
|
3773
4051
|
const toggleGroupRow = useToggleGroupRow();
|
|
3774
|
-
(0,
|
|
4052
|
+
(0, import_react17.useEffect)(() => {
|
|
3775
4053
|
const computedPivotColumns = getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, {
|
|
3776
4054
|
pivotColumn,
|
|
3777
4055
|
pivotRowLabelsColumn,
|
|
@@ -3792,7 +4070,7 @@ function useColumnsWhenGrouping() {
|
|
|
3792
4070
|
componentState: { columns, groupColumn, groupRenderStrategy, pivotColumns }
|
|
3793
4071
|
} = useComponentState();
|
|
3794
4072
|
const toggleGroupRow = useToggleGroupRow();
|
|
3795
|
-
(0,
|
|
4073
|
+
(0, import_react17.useEffect)(() => {
|
|
3796
4074
|
if (pivotColumns) {
|
|
3797
4075
|
return;
|
|
3798
4076
|
}
|
|
@@ -3829,7 +4107,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3829
4107
|
groupRenderStrategy
|
|
3830
4108
|
}
|
|
3831
4109
|
} = useComponentState();
|
|
3832
|
-
(0,
|
|
4110
|
+
(0, import_react17.useEffect)(() => {
|
|
3833
4111
|
if (groupRenderStrategy !== "multi-column") {
|
|
3834
4112
|
return;
|
|
3835
4113
|
}
|
|
@@ -3847,7 +4125,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3847
4125
|
const currentState = getComponentState();
|
|
3848
4126
|
const { computedColumns } = currentState;
|
|
3849
4127
|
let updated = false;
|
|
3850
|
-
const columnVisibility =
|
|
4128
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3851
4129
|
const cols = computedColumns;
|
|
3852
4130
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
3853
4131
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
@@ -3858,9 +4136,9 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3858
4136
|
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3859
4137
|
updated = true;
|
|
3860
4138
|
if (shouldBeHidden) {
|
|
3861
|
-
columnVisibility
|
|
4139
|
+
columnVisibility[colId] = false;
|
|
3862
4140
|
} else {
|
|
3863
|
-
columnVisibility
|
|
4141
|
+
delete columnVisibility[colId];
|
|
3864
4142
|
}
|
|
3865
4143
|
});
|
|
3866
4144
|
if (updated) {
|
|
@@ -3935,7 +4213,7 @@ function useComputed() {
|
|
|
3935
4213
|
bodySize,
|
|
3936
4214
|
showSeparatePivotColumnForSingleAggregation
|
|
3937
4215
|
} = componentState;
|
|
3938
|
-
(0,
|
|
4216
|
+
(0, import_react18.useState)(() => {
|
|
3939
4217
|
componentState.onRowHeightCSSVarChange.onChange((rowHeight) => {
|
|
3940
4218
|
if (rowHeight) {
|
|
3941
4219
|
componentActions.rowHeight = rowHeight;
|
|
@@ -3947,19 +4225,16 @@ function useComputed() {
|
|
|
3947
4225
|
}
|
|
3948
4226
|
});
|
|
3949
4227
|
});
|
|
3950
|
-
(0,
|
|
4228
|
+
(0, import_react18.useEffect)(() => {
|
|
3951
4229
|
dataSourceActions.showSeparatePivotColumnForSingleAggregation = showSeparatePivotColumnForSingleAggregation;
|
|
3952
4230
|
}, [showSeparatePivotColumnForSingleAggregation]);
|
|
3953
4231
|
const { multiSort } = dataSourceState;
|
|
3954
4232
|
useColumnGroups();
|
|
3955
4233
|
useColumnsWhen();
|
|
3956
|
-
const setSortInfo = (0,
|
|
4234
|
+
const setSortInfo = (0, import_react18.useCallback)((sortInfo) => {
|
|
3957
4235
|
var _a2;
|
|
3958
4236
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3959
4237
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3960
|
-
if (getDataSourceState().livePagination) {
|
|
3961
|
-
dataSourceActions.livePaginationCursor = null;
|
|
3962
|
-
}
|
|
3963
4238
|
}, [getDataSourceState]);
|
|
3964
4239
|
const columns = componentState.computedColumns;
|
|
3965
4240
|
const {
|
|
@@ -4116,20 +4391,20 @@ var HeaderWrapperCls = "_12zfob1v _16lm1iw16 _16lm1iw1 _16lm1iwj _16lm1iw10";
|
|
|
4116
4391
|
|
|
4117
4392
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4118
4393
|
var React17 = __toModule(require("react"));
|
|
4119
|
-
var
|
|
4394
|
+
var import_react26 = __toModule(require("react"));
|
|
4120
4395
|
|
|
4121
4396
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
|
|
4122
4397
|
var React13 = __toModule(require("react"));
|
|
4123
|
-
var
|
|
4398
|
+
var import_react22 = __toModule(require("react"));
|
|
4124
4399
|
|
|
4125
4400
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx
|
|
4126
4401
|
var React11 = __toModule(require("react"));
|
|
4127
4402
|
|
|
4128
4403
|
// src/components/InfiniteTable/hooks/useInfiniteTableState.ts
|
|
4129
|
-
var
|
|
4404
|
+
var import_react19 = __toModule(require("react"));
|
|
4130
4405
|
var useInfiniteTableState = () => {
|
|
4131
4406
|
const TableContext2 = getInfiniteTableContext();
|
|
4132
|
-
const { componentState } = (0,
|
|
4407
|
+
const { componentState } = (0, import_react19.useContext)(TableContext2);
|
|
4133
4408
|
return componentState;
|
|
4134
4409
|
};
|
|
4135
4410
|
|
|
@@ -4195,7 +4470,7 @@ var InfiniteTableCell = React11.memo(InfiniteTableCellFn);
|
|
|
4195
4470
|
|
|
4196
4471
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
4197
4472
|
var import_binary_search = __toModule(require_binary_search());
|
|
4198
|
-
var
|
|
4473
|
+
var import_react20 = __toModule(require("react"));
|
|
4199
4474
|
|
|
4200
4475
|
// src/components/InfiniteTable/utils/moveXatY.ts
|
|
4201
4476
|
var moveXatY = (arr, dragIndex, dropIndex) => {
|
|
@@ -4229,18 +4504,18 @@ var useColumnPointerEvents = ({
|
|
|
4229
4504
|
columns,
|
|
4230
4505
|
computedRemainingSpace
|
|
4231
4506
|
}) => {
|
|
4232
|
-
const [draggingDiff, setDraggingDiff] = (0,
|
|
4233
|
-
const [proxyOffset, setProxyOffset] = (0,
|
|
4234
|
-
const breakpointsRef = (0,
|
|
4235
|
-
const pointerMoveRef = (0,
|
|
4236
|
-
const didDragRef = (0,
|
|
4237
|
-
const initialClientPos = (0,
|
|
4238
|
-
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);
|
|
4239
4514
|
const dragging = draggingDiff != null;
|
|
4240
4515
|
const { componentActions, computed } = useInfiniteTable();
|
|
4241
4516
|
const { computedColumnOrder } = computed;
|
|
4242
|
-
const column = (0,
|
|
4243
|
-
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)(() => {
|
|
4244
4519
|
const columnsArray2 = Array.from(columns.values());
|
|
4245
4520
|
return {
|
|
4246
4521
|
columnsArray: columnsArray2,
|
|
@@ -4248,8 +4523,8 @@ var useColumnPointerEvents = ({
|
|
|
4248
4523
|
columnWidth: column.computedWidth
|
|
4249
4524
|
};
|
|
4250
4525
|
}, [columns, columnId, column]);
|
|
4251
|
-
let cursorRef = (0,
|
|
4252
|
-
const onPointerDown = (0,
|
|
4526
|
+
let cursorRef = (0, import_react20.useRef)("auto");
|
|
4527
|
+
const onPointerDown = (0, import_react20.useCallback)((e) => {
|
|
4253
4528
|
const target = domRef.current;
|
|
4254
4529
|
cursorRef.current = target.style.cursor;
|
|
4255
4530
|
didDragRef.current = false;
|
|
@@ -4312,7 +4587,7 @@ var useColumnPointerEvents = ({
|
|
|
4312
4587
|
target.addEventListener("pointermove", onPointerMove);
|
|
4313
4588
|
target.setPointerCapture(e.pointerId);
|
|
4314
4589
|
}, [columns, column, columnIndex, columnsArray, computedRemainingSpace]);
|
|
4315
|
-
const onPointerUp = (0,
|
|
4590
|
+
const onPointerUp = (0, import_react20.useCallback)((e) => {
|
|
4316
4591
|
const target = domRef.current;
|
|
4317
4592
|
target.style.cursor = cursorRef.current;
|
|
4318
4593
|
target.releasePointerCapture(e.pointerId);
|
|
@@ -4387,7 +4662,7 @@ var import_react_dom = __toModule(require("react-dom"));
|
|
|
4387
4662
|
|
|
4388
4663
|
// src/components/InfiniteTable/components/icons/SortIcon.tsx
|
|
4389
4664
|
var React12 = __toModule(require("react"));
|
|
4390
|
-
var
|
|
4665
|
+
var import_react21 = __toModule(require("react"));
|
|
4391
4666
|
var defaultLineStyle = {
|
|
4392
4667
|
marginTop: 2,
|
|
4393
4668
|
marginBottom: 2,
|
|
@@ -4395,8 +4670,8 @@ var defaultLineStyle = {
|
|
|
4395
4670
|
};
|
|
4396
4671
|
function SortIcon(props) {
|
|
4397
4672
|
var _a;
|
|
4398
|
-
const [rendered, setRendered] = (0,
|
|
4399
|
-
const [opacity, setOpacity] = (0,
|
|
4673
|
+
const [rendered, setRendered] = (0, import_react21.useState)(true);
|
|
4674
|
+
const [opacity, setOpacity] = (0, import_react21.useState)(0);
|
|
4400
4675
|
const { direction, lineWidth = 1, style, className, index } = props;
|
|
4401
4676
|
const showIndex = index != null && index > 0;
|
|
4402
4677
|
const size = (_a = props.size) != null ? _a : 16;
|
|
@@ -4410,7 +4685,7 @@ function SortIcon(props) {
|
|
|
4410
4685
|
}), props.lineStyle), {
|
|
4411
4686
|
opacity
|
|
4412
4687
|
});
|
|
4413
|
-
(0,
|
|
4688
|
+
(0, import_react21.useEffect)(() => {
|
|
4414
4689
|
const newOpacity = direction != 0 ? 1 : 0;
|
|
4415
4690
|
if (!rendered && newOpacity) {
|
|
4416
4691
|
setRendered(true);
|
|
@@ -4487,8 +4762,8 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4487
4762
|
className: `${baseCls}__sort-icon ${HeaderSortIconCls}`,
|
|
4488
4763
|
direction: column.computedSorted ? column.computedSortedAsc ? 1 : -1 : 0
|
|
4489
4764
|
});
|
|
4490
|
-
const domRef = (0,
|
|
4491
|
-
const ref = (0,
|
|
4765
|
+
const domRef = (0, import_react22.useRef)(null);
|
|
4766
|
+
const ref = (0, import_react22.useCallback)((node) => {
|
|
4492
4767
|
var _a2;
|
|
4493
4768
|
domRef.current = node;
|
|
4494
4769
|
(_a2 = props.domRef) == null ? void 0 : _a2.call(props, node);
|
|
@@ -4497,7 +4772,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4497
4772
|
computed: { computedRemainingSpace },
|
|
4498
4773
|
componentState: { portalDOMRef }
|
|
4499
4774
|
} = useInfiniteTable();
|
|
4500
|
-
(0,
|
|
4775
|
+
(0, import_react22.useEffect)(() => {
|
|
4501
4776
|
let clearOnResize = null;
|
|
4502
4777
|
const node = domRef.current;
|
|
4503
4778
|
if (onResize && node) {
|
|
@@ -4550,14 +4825,14 @@ function InfiniteTableHeaderCell(props) {
|
|
|
4550
4825
|
|
|
4551
4826
|
// src/components/RawList/index.tsx
|
|
4552
4827
|
var React16 = __toModule(require("react"));
|
|
4553
|
-
var
|
|
4828
|
+
var import_react25 = __toModule(require("react"));
|
|
4554
4829
|
|
|
4555
4830
|
// src/components/RawList/AvoidReactDiff.tsx
|
|
4556
4831
|
var React14 = __toModule(require("react"));
|
|
4557
|
-
var
|
|
4832
|
+
var import_react23 = __toModule(require("react"));
|
|
4558
4833
|
function AvoidReactDiffFn(props) {
|
|
4559
|
-
const [children, setChildren] = (0,
|
|
4560
|
-
(0,
|
|
4834
|
+
const [children, setChildren] = (0, import_react23.useState)(props.updater.get());
|
|
4835
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
4561
4836
|
const remove = props.updater.onChange((children2) => {
|
|
4562
4837
|
setChildren(children2);
|
|
4563
4838
|
});
|
|
@@ -4568,7 +4843,7 @@ function AvoidReactDiffFn(props) {
|
|
|
4568
4843
|
var AvoidReactDiff = React14.memo(AvoidReactDiffFn);
|
|
4569
4844
|
|
|
4570
4845
|
// src/components/RawList/useVirtualRenderer.ts
|
|
4571
|
-
var
|
|
4846
|
+
var import_react24 = __toModule(require("react"));
|
|
4572
4847
|
|
|
4573
4848
|
// src/components/RawList/ReactVirtualRenderer.tsx
|
|
4574
4849
|
var React15 = __toModule(require("react"));
|
|
@@ -4882,7 +5157,7 @@ function createRenderer(brain) {
|
|
|
4882
5157
|
function useVirtualRenderer({
|
|
4883
5158
|
brain
|
|
4884
5159
|
}) {
|
|
4885
|
-
return (0,
|
|
5160
|
+
return (0, import_react24.useMemo)(() => {
|
|
4886
5161
|
return createRenderer(brain);
|
|
4887
5162
|
}, [brain]);
|
|
4888
5163
|
}
|
|
@@ -4895,7 +5170,7 @@ function RawListFn(props) {
|
|
|
4895
5170
|
debugChannel
|
|
4896
5171
|
});
|
|
4897
5172
|
const getRenderItem = useLatest(renderItem);
|
|
4898
|
-
(0,
|
|
5173
|
+
(0, import_react25.useEffect)(() => {
|
|
4899
5174
|
const renderRange = brain.getRenderRange();
|
|
4900
5175
|
renderer.renderRange(renderRange, {
|
|
4901
5176
|
renderItem,
|
|
@@ -4903,7 +5178,7 @@ function RawListFn(props) {
|
|
|
4903
5178
|
onRender: onRenderUpdater
|
|
4904
5179
|
});
|
|
4905
5180
|
}, [brain, renderItem, onRenderUpdater]);
|
|
4906
|
-
(0,
|
|
5181
|
+
(0, import_react25.useEffect)(() => {
|
|
4907
5182
|
const remove = brain.onRenderRangeChange((renderRange) => {
|
|
4908
5183
|
renderer.renderRange(renderRange, {
|
|
4909
5184
|
force: false,
|
|
@@ -4920,7 +5195,7 @@ function RawListFn(props) {
|
|
|
4920
5195
|
var RawList = React16.memo(RawListFn);
|
|
4921
5196
|
|
|
4922
5197
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
|
|
4923
|
-
var
|
|
5198
|
+
var debug3 = dbg("Header");
|
|
4924
5199
|
var { rootClassName: rootClassName4 } = internalProps;
|
|
4925
5200
|
var TableHeaderClassName = `${rootClassName4}Header`;
|
|
4926
5201
|
function InfiniteTableHeaderFn(props) {
|
|
@@ -4930,11 +5205,11 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4930
5205
|
componentState: { headerHeight }
|
|
4931
5206
|
} = useInfiniteTable();
|
|
4932
5207
|
const { computedVisibleColumnsMap } = computed;
|
|
4933
|
-
const renderColumn = (0,
|
|
5208
|
+
const renderColumn = (0, import_react26.useCallback)(({ domRef: domRef2, itemIndex: columnIndex }) => {
|
|
4934
5209
|
const column = columns[columnIndex];
|
|
4935
5210
|
if (!column) {
|
|
4936
5211
|
if (true) {
|
|
4937
|
-
|
|
5212
|
+
debug3("Cannot find column to render at ", columnIndex);
|
|
4938
5213
|
}
|
|
4939
5214
|
return null;
|
|
4940
5215
|
}
|
|
@@ -4945,14 +5220,14 @@ function InfiniteTableHeaderFn(props) {
|
|
|
4945
5220
|
columns: computedVisibleColumnsMap
|
|
4946
5221
|
});
|
|
4947
5222
|
}, [computedVisibleColumnsMap, columns, repaintId, headerHeight]);
|
|
4948
|
-
(0,
|
|
5223
|
+
(0, import_react26.useEffect)(() => {
|
|
4949
5224
|
const onScroll = (scrollPosition) => {
|
|
4950
5225
|
domRef.current.style.transform = `translate3d(-${scrollPosition.scrollLeft}px, 0px, 0px)`;
|
|
4951
5226
|
};
|
|
4952
5227
|
const removeOnScroll = brain.onScroll(onScroll);
|
|
4953
5228
|
return removeOnScroll;
|
|
4954
5229
|
}, [brain]);
|
|
4955
|
-
const domRef = (0,
|
|
5230
|
+
const domRef = (0, import_react26.useRef)(null);
|
|
4956
5231
|
const headerCls = HeaderClsRecipe({
|
|
4957
5232
|
pinned: pinning,
|
|
4958
5233
|
overflow: false,
|
|
@@ -5144,7 +5419,7 @@ function renderColumnHeaderGroups(config) {
|
|
|
5144
5419
|
}
|
|
5145
5420
|
|
|
5146
5421
|
// src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderUnvirtualized.tsx
|
|
5147
|
-
var
|
|
5422
|
+
var import_react27 = __toModule(require("react"));
|
|
5148
5423
|
var { rootClassName: rootClassName5 } = internalProps;
|
|
5149
5424
|
var TableHeaderClassName2 = `${rootClassName5}Header`;
|
|
5150
5425
|
var UPDATE_SCROLL = (node, scrollPosition) => {
|
|
@@ -5210,7 +5485,7 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
|
|
|
5210
5485
|
if (totalWidth != null) {
|
|
5211
5486
|
style.width = availableWidth;
|
|
5212
5487
|
}
|
|
5213
|
-
(0,
|
|
5488
|
+
(0, import_react27.useEffect)(() => {
|
|
5214
5489
|
const scroller = brain || scrollListener;
|
|
5215
5490
|
if (!scroller || !scrollable) {
|
|
5216
5491
|
return;
|
|
@@ -5264,6 +5539,9 @@ function TableHeaderWrapper(props) {
|
|
|
5264
5539
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5265
5540
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5266
5541
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5542
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5543
|
+
left: computedPinnedStartWidth
|
|
5544
|
+
} : void 0;
|
|
5267
5545
|
const header = virtualizeHeader ? /* @__PURE__ */ React21.createElement(InfiniteTableHeader, {
|
|
5268
5546
|
columns: computedUnpinnedColumns,
|
|
5269
5547
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5278,6 +5556,7 @@ function TableHeaderWrapper(props) {
|
|
|
5278
5556
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5279
5557
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5280
5558
|
}) : /* @__PURE__ */ React21.createElement(InfiniteTableHeaderUnvirtualized, {
|
|
5559
|
+
style: unvirtualizedStyle,
|
|
5281
5560
|
brain,
|
|
5282
5561
|
scrollable: true,
|
|
5283
5562
|
pinning: false,
|
|
@@ -5324,12 +5603,12 @@ function TableHeaderWrapper(props) {
|
|
|
5324
5603
|
|
|
5325
5604
|
// src/components/VirtualScrollContainer/index.tsx
|
|
5326
5605
|
var React22 = __toModule(require("react"));
|
|
5327
|
-
var
|
|
5606
|
+
var import_react29 = __toModule(require("react"));
|
|
5328
5607
|
|
|
5329
5608
|
// src/components/hooks/useOnScroll.ts
|
|
5330
|
-
var
|
|
5609
|
+
var import_react28 = __toModule(require("react"));
|
|
5331
5610
|
var useOnScroll = (domRef, onScroll) => {
|
|
5332
|
-
(0,
|
|
5611
|
+
(0, import_react28.useEffect)(() => {
|
|
5333
5612
|
const domNode = domRef == null ? void 0 : domRef.current;
|
|
5334
5613
|
const scrollFn = (event) => {
|
|
5335
5614
|
const node = event.target;
|
|
@@ -5375,7 +5654,7 @@ var VirtualScrollContainer = React22.forwardRef(function VirtualScrollContainer2
|
|
|
5375
5654
|
className,
|
|
5376
5655
|
style
|
|
5377
5656
|
} = props;
|
|
5378
|
-
const domRef = ref != null ? ref : (0,
|
|
5657
|
+
const domRef = ref != null ? ref : (0, import_react29.useRef)(null);
|
|
5379
5658
|
useOnScroll(domRef, onContainerScroll);
|
|
5380
5659
|
return /* @__PURE__ */ React22.createElement("div", {
|
|
5381
5660
|
ref: domRef,
|
|
@@ -5410,14 +5689,14 @@ var import_react41 = __toModule(require("react"));
|
|
|
5410
5689
|
|
|
5411
5690
|
// src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
|
|
5412
5691
|
var React29 = __toModule(require("react"));
|
|
5413
|
-
var
|
|
5692
|
+
var import_react33 = __toModule(require("react"));
|
|
5414
5693
|
|
|
5415
5694
|
// src/components/VirtualList/VirtualRowList.tsx
|
|
5416
5695
|
var React25 = __toModule(require("react"));
|
|
5417
5696
|
|
|
5418
5697
|
// src/components/VirtualList/VirtualList.tsx
|
|
5419
5698
|
var React24 = __toModule(require("react"));
|
|
5420
|
-
var
|
|
5699
|
+
var import_react30 = __toModule(require("react"));
|
|
5421
5700
|
|
|
5422
5701
|
// src/components/VirtualList/VirtualList.css.ts
|
|
5423
5702
|
var VirtualListCls = "_16lm1iw1 _16lm1iw8 _16lm1iw0";
|
|
@@ -5428,7 +5707,7 @@ var scrollTransformTargetCls = "mlx2t3";
|
|
|
5428
5707
|
var UPDATE_SCROLL2 = (node, scrollPosition) => {
|
|
5429
5708
|
node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, ${-scrollPosition.scrollTop}px, 0px)`;
|
|
5430
5709
|
};
|
|
5431
|
-
var
|
|
5710
|
+
var debug4 = dbg("VirtuaList");
|
|
5432
5711
|
var rootClassName7 = "InfiniteList";
|
|
5433
5712
|
var VirtualList = (props) => {
|
|
5434
5713
|
const _a = props, {
|
|
@@ -5460,15 +5739,15 @@ var VirtualList = (props) => {
|
|
|
5460
5739
|
"onContainerScroll",
|
|
5461
5740
|
"children"
|
|
5462
5741
|
]);
|
|
5463
|
-
const domRef = (0,
|
|
5742
|
+
const domRef = (0, import_react30.useRef)(null);
|
|
5464
5743
|
const [, rerender] = useRerender();
|
|
5465
|
-
const [totalSize, setTotalSize] = (0,
|
|
5466
|
-
const renderCountRef = (0,
|
|
5467
|
-
(0,
|
|
5744
|
+
const [totalSize, setTotalSize] = (0, import_react30.useState)(0);
|
|
5745
|
+
const renderCountRef = (0, import_react30.useRef)(0);
|
|
5746
|
+
(0, import_react30.useEffect)(() => {
|
|
5468
5747
|
const removeOnRenderCount = virtualBrain.onRenderCountChange((renderCount) => {
|
|
5469
5748
|
renderCountRef.current = renderCount;
|
|
5470
5749
|
if (true) {
|
|
5471
|
-
|
|
5750
|
+
debug4.extend(mainAxis)(`Render count change ${renderCount}`);
|
|
5472
5751
|
}
|
|
5473
5752
|
rerender();
|
|
5474
5753
|
});
|
|
@@ -5483,7 +5762,7 @@ var VirtualList = (props) => {
|
|
|
5483
5762
|
removeOnTotalSizeChange();
|
|
5484
5763
|
};
|
|
5485
5764
|
}, [virtualBrain]);
|
|
5486
|
-
(0,
|
|
5765
|
+
(0, import_react30.useEffect)(() => {
|
|
5487
5766
|
const onScroll = (scrollPosition) => {
|
|
5488
5767
|
UPDATE_SCROLL2(domRef.current, scrollPosition);
|
|
5489
5768
|
};
|
|
@@ -5537,7 +5816,7 @@ var VirtualRowList = (props) => {
|
|
|
5537
5816
|
|
|
5538
5817
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx
|
|
5539
5818
|
var React27 = __toModule(require("react"));
|
|
5540
|
-
var
|
|
5819
|
+
var import_react32 = __toModule(require("react"));
|
|
5541
5820
|
|
|
5542
5821
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx
|
|
5543
5822
|
var React26 = __toModule(require("react"));
|
|
@@ -5647,7 +5926,7 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5647
5926
|
var InfiniteTableColumnCell = React26.memo(InfiniteTableColumnCellFn);
|
|
5648
5927
|
|
|
5649
5928
|
// src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts
|
|
5650
|
-
var
|
|
5929
|
+
var import_react31 = __toModule(require("react"));
|
|
5651
5930
|
|
|
5652
5931
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts
|
|
5653
5932
|
var { rootClassName: rootClassName9 } = internalProps;
|
|
@@ -5672,8 +5951,8 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5672
5951
|
domRef: domRefFromProps,
|
|
5673
5952
|
rowInfo
|
|
5674
5953
|
} = props;
|
|
5675
|
-
const domRef = (0,
|
|
5676
|
-
const rowDOMRef = (0,
|
|
5954
|
+
const domRef = (0, import_react31.useRef)(null);
|
|
5955
|
+
const rowDOMRef = (0, import_react31.useCallback)((node) => {
|
|
5677
5956
|
domRefFromProps(node);
|
|
5678
5957
|
domRef.current = node;
|
|
5679
5958
|
}, []);
|
|
@@ -5704,7 +5983,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5704
5983
|
}), `${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);
|
|
5705
5984
|
const initialMouseEnter = rowProps == null ? void 0 : rowProps.onMouseEnter;
|
|
5706
5985
|
const initialMouseLeave = rowProps == null ? void 0 : rowProps.onMouseLeave;
|
|
5707
|
-
const onMouseEnter = (0,
|
|
5986
|
+
const onMouseEnter = (0, import_react31.useCallback)((event) => {
|
|
5708
5987
|
var _a;
|
|
5709
5988
|
initialMouseEnter == null ? void 0 : initialMouseEnter(event);
|
|
5710
5989
|
const rowIndex2 = ((_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex) * 1;
|
|
@@ -5718,7 +5997,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5718
5997
|
const rows = parentNode.querySelectorAll(hoverSelector.join(","));
|
|
5719
5998
|
rows.forEach((row) => row.classList.add(InfiniteTableRowClassName__hover, RowHoverCls));
|
|
5720
5999
|
}, [initialMouseEnter, showHoverRows]);
|
|
5721
|
-
const onMouseLeave = (0,
|
|
6000
|
+
const onMouseLeave = (0, import_react31.useCallback)((event) => {
|
|
5722
6001
|
var _a;
|
|
5723
6002
|
initialMouseLeave == null ? void 0 : initialMouseLeave(event);
|
|
5724
6003
|
const rowIndex2 = (_a = event.currentTarget) == null ? void 0 : _a.dataset.rowIndex;
|
|
@@ -5774,7 +6053,7 @@ function InfiniteTableRowFn(props) {
|
|
|
5774
6053
|
width: rowWidth,
|
|
5775
6054
|
height: rowHeight
|
|
5776
6055
|
}, domProps.style);
|
|
5777
|
-
const renderCellRef = (0,
|
|
6056
|
+
const renderCellRef = (0, import_react32.useRef)(null);
|
|
5778
6057
|
const renderCell = React27.useCallback(({ domRef, itemIndex }) => {
|
|
5779
6058
|
const column = columns[itemIndex];
|
|
5780
6059
|
if (!column) {
|
|
@@ -5878,7 +6157,7 @@ function useUnpinnedRendering(params) {
|
|
|
5878
6157
|
} = params;
|
|
5879
6158
|
const { virtualizeColumns } = getState();
|
|
5880
6159
|
const shouldVirtualizeColumns = typeof virtualizeColumns === "function" ? virtualizeColumns(computedUnpinnedColumns) : virtualizeColumns != null ? virtualizeColumns : true;
|
|
5881
|
-
const renderRowUnpinned = (0,
|
|
6160
|
+
const renderRowUnpinned = (0, import_react33.useCallback)((rowParams) => {
|
|
5882
6161
|
const dataArray = getData();
|
|
5883
6162
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
5884
6163
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -5944,7 +6223,7 @@ function useUnpinnedRendering(params) {
|
|
|
5944
6223
|
}
|
|
5945
6224
|
|
|
5946
6225
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5947
|
-
var
|
|
6226
|
+
var import_react34 = __toModule(require("react"));
|
|
5948
6227
|
|
|
5949
6228
|
// src/components/InfiniteTable/InfiniteCls.css.ts
|
|
5950
6229
|
var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
@@ -5957,7 +6236,6 @@ var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf",
|
|
|
5957
6236
|
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
5958
6237
|
|
|
5959
6238
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5960
|
-
var DELAY = 200;
|
|
5961
6239
|
var TableClassName = internalProps.rootClassName;
|
|
5962
6240
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
5963
6241
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -5968,23 +6246,33 @@ var useOnContainerScroll = ({
|
|
|
5968
6246
|
}) => {
|
|
5969
6247
|
const {
|
|
5970
6248
|
componentState: {
|
|
6249
|
+
scrollStopDelay,
|
|
5971
6250
|
scrollerDOMRef,
|
|
5972
6251
|
domRef,
|
|
5973
6252
|
scrollToBottomOffset,
|
|
5974
6253
|
onScrollToBottom,
|
|
5975
6254
|
onScrollToTop,
|
|
6255
|
+
onScrollStop: onScrollStopFromProps,
|
|
5976
6256
|
bodySize
|
|
5977
6257
|
}
|
|
5978
6258
|
} = useInfiniteTable();
|
|
5979
|
-
const {
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
6259
|
+
const {
|
|
6260
|
+
componentActions: dataSourceActions,
|
|
6261
|
+
getState: getDataSourceState,
|
|
6262
|
+
componentState: { notifyScrollStop }
|
|
6263
|
+
} = useDataSourceContextValue();
|
|
6264
|
+
const onScrollStop = (0, import_react34.useCallback)((param) => {
|
|
6265
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6266
|
+
notifyScrollStop(param);
|
|
6267
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
6268
|
+
const timeoutIdRef = (0, import_react34.useRef)(0);
|
|
6269
|
+
const scrollingRef = (0, import_react34.useRef)(false);
|
|
6270
|
+
const scrollTopMaxRef = (0, import_react34.useRef)(0);
|
|
6271
|
+
(0, import_react34.useEffect)(() => {
|
|
5984
6272
|
const { current: node } = scrollerDOMRef;
|
|
5985
6273
|
scrollTopMaxRef.current = node.scrollHeight - node.clientHeight;
|
|
5986
6274
|
}, [reservedContentHeight, bodySize.height]);
|
|
5987
|
-
const setScrolling = (0,
|
|
6275
|
+
const setScrolling = (0, import_react34.useCallback)((scrolling) => {
|
|
5988
6276
|
var _a;
|
|
5989
6277
|
const prevScrolling = scrollingRef.current;
|
|
5990
6278
|
scrollingRef.current = scrolling;
|
|
@@ -5995,9 +6283,17 @@ var useOnContainerScroll = ({
|
|
|
5995
6283
|
timeoutIdRef.current = setTimeout(() => {
|
|
5996
6284
|
setScrolling(false);
|
|
5997
6285
|
timeoutIdRef.current = 0;
|
|
5998
|
-
},
|
|
6286
|
+
}, scrollStopDelay);
|
|
5999
6287
|
}
|
|
6000
6288
|
if (prevScrolling !== scrolling) {
|
|
6289
|
+
if (!scrolling) {
|
|
6290
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6291
|
+
onScrollStop({
|
|
6292
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6293
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6294
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6295
|
+
});
|
|
6296
|
+
}
|
|
6001
6297
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
6002
6298
|
if (!classList) {
|
|
6003
6299
|
return;
|
|
@@ -6008,8 +6304,8 @@ var useOnContainerScroll = ({
|
|
|
6008
6304
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
6009
6305
|
}
|
|
6010
6306
|
}
|
|
6011
|
-
}, []);
|
|
6012
|
-
const onContainerScroll = (0,
|
|
6307
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
6308
|
+
const onContainerScroll = (0, import_react34.useCallback)((scrollInfo) => {
|
|
6013
6309
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6014
6310
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6015
6311
|
setScrolling(true);
|
|
@@ -6019,15 +6315,15 @@ var useOnContainerScroll = ({
|
|
|
6019
6315
|
domRef.current,
|
|
6020
6316
|
setScrolling
|
|
6021
6317
|
]);
|
|
6022
|
-
const scrollPositionRef = (0,
|
|
6318
|
+
const scrollPositionRef = (0, import_react34.useRef)({
|
|
6023
6319
|
scrollLeft: 0,
|
|
6024
6320
|
scrollTop: 0
|
|
6025
6321
|
});
|
|
6026
|
-
const applyScrollHorizontal = (0,
|
|
6322
|
+
const applyScrollHorizontal = (0, import_react34.useCallback)(({ scrollLeft }) => {
|
|
6027
6323
|
scrollPositionRef.current.scrollLeft = scrollLeft;
|
|
6028
6324
|
onContainerScroll(scrollPositionRef.current);
|
|
6029
6325
|
}, [onContainerScroll]);
|
|
6030
|
-
const applyScrollVertical = (0,
|
|
6326
|
+
const applyScrollVertical = (0, import_react34.useCallback)(({ scrollTop }) => {
|
|
6031
6327
|
scrollPositionRef.current.scrollTop = scrollTop;
|
|
6032
6328
|
onContainerScroll(scrollPositionRef.current);
|
|
6033
6329
|
if (scrollTop === 0) {
|
|
@@ -6038,7 +6334,7 @@ var useOnContainerScroll = ({
|
|
|
6038
6334
|
if (isScrollBottom) {
|
|
6039
6335
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
6040
6336
|
if (getDataSourceState().livePagination) {
|
|
6041
|
-
dataSourceActions.
|
|
6337
|
+
dataSourceActions.cursorId = Date.now();
|
|
6042
6338
|
}
|
|
6043
6339
|
}
|
|
6044
6340
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -6050,16 +6346,16 @@ var useOnContainerScroll = ({
|
|
|
6050
6346
|
|
|
6051
6347
|
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6052
6348
|
var React31 = __toModule(require("react"));
|
|
6053
|
-
var
|
|
6349
|
+
var import_react37 = __toModule(require("react"));
|
|
6054
6350
|
|
|
6055
6351
|
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
6056
6352
|
var React30 = __toModule(require("react"));
|
|
6057
|
-
var
|
|
6353
|
+
var import_react36 = __toModule(require("react"));
|
|
6058
6354
|
|
|
6059
6355
|
// src/components/hooks/useOnMount.ts
|
|
6060
|
-
var
|
|
6356
|
+
var import_react35 = __toModule(require("react"));
|
|
6061
6357
|
function useOnMount(domRef, props) {
|
|
6062
|
-
(0,
|
|
6358
|
+
(0, import_react35.useEffect)(() => {
|
|
6063
6359
|
const { onMount, onUnmount } = props;
|
|
6064
6360
|
const node = domRef == null ? void 0 : domRef.current;
|
|
6065
6361
|
onMount == null ? void 0 : onMount(node);
|
|
@@ -6090,8 +6386,8 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6090
6386
|
onMount,
|
|
6091
6387
|
onUnmount
|
|
6092
6388
|
} = props;
|
|
6093
|
-
const domRef = (0,
|
|
6094
|
-
const renderItem = (0,
|
|
6389
|
+
const domRef = (0, import_react36.useRef)(null);
|
|
6390
|
+
const renderItem = (0, import_react36.useCallback)((renderProps) => renderRow({
|
|
6095
6391
|
domRef: renderProps.domRef,
|
|
6096
6392
|
rowHeight: renderProps.itemSize,
|
|
6097
6393
|
rowIndex: renderProps.itemIndex
|
|
@@ -6100,7 +6396,7 @@ var RowListWithExternalScrolling = (props) => {
|
|
|
6100
6396
|
onMount,
|
|
6101
6397
|
onUnmount
|
|
6102
6398
|
});
|
|
6103
|
-
(0,
|
|
6399
|
+
(0, import_react36.useEffect)(() => {
|
|
6104
6400
|
const onScroll = (scrollPosition) => {
|
|
6105
6401
|
const node = domRef.current;
|
|
6106
6402
|
if (node) {
|
|
@@ -6167,7 +6463,7 @@ function PinnedRowsContainer(props) {
|
|
|
6167
6463
|
}
|
|
6168
6464
|
return result;
|
|
6169
6465
|
}, [height, rowWidth, pinning, hasOverflow]);
|
|
6170
|
-
const updateScroll = (0,
|
|
6466
|
+
const updateScroll = (0, import_react37.useCallback)((node, scrollPosition) => {
|
|
6171
6467
|
UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
|
|
6172
6468
|
}, [hasOverflow, pinnedScrollListener]);
|
|
6173
6469
|
const rowListProps = {
|
|
@@ -6209,7 +6505,7 @@ function PinnedRowsContainer(props) {
|
|
|
6209
6505
|
}
|
|
6210
6506
|
function useRenderPinnedRow(params) {
|
|
6211
6507
|
const { getData, getState, columnsWidth, columns, verticalBrain } = params;
|
|
6212
|
-
const renderPinnedRow = (0,
|
|
6508
|
+
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
6213
6509
|
const dataArray = getData();
|
|
6214
6510
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
6215
6511
|
const { showZebraRows, showHoverRows } = getState();
|
|
@@ -6325,6 +6621,15 @@ function usePinnedStartRendering(params) {
|
|
|
6325
6621
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6326
6622
|
var import_react40 = __toModule(require("react"));
|
|
6327
6623
|
|
|
6624
|
+
// src/components/hooks/useOnce.ts
|
|
6625
|
+
var import_react38 = __toModule(require("react"));
|
|
6626
|
+
function useOnce(fn) {
|
|
6627
|
+
const onceFn = (0, import_react38.useMemo)(() => {
|
|
6628
|
+
return once(fn);
|
|
6629
|
+
}, []);
|
|
6630
|
+
return onceFn();
|
|
6631
|
+
}
|
|
6632
|
+
|
|
6328
6633
|
// src/components/VirtualBrain/index.ts
|
|
6329
6634
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6330
6635
|
var initialScrollPosition2 = {
|
|
@@ -7215,7 +7520,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7215
7520
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7216
7521
|
let valid2 = isValidLicense(licenseKey, {
|
|
7217
7522
|
publishedAt: 1624970570587,
|
|
7218
|
-
version: "0.1.
|
|
7523
|
+
version: "0.1.3"
|
|
7219
7524
|
});
|
|
7220
7525
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7221
7526
|
return true;
|
|
@@ -7229,7 +7534,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7229
7534
|
var React33 = __toModule(require("react"));
|
|
7230
7535
|
var import_react44 = __toModule(require("react"));
|
|
7231
7536
|
var error = err("CSSVariableWatch");
|
|
7232
|
-
var
|
|
7537
|
+
var debug5 = dbg("CSSVariableWatch");
|
|
7233
7538
|
var WRAPPER_STYLE = {
|
|
7234
7539
|
position: "absolute",
|
|
7235
7540
|
pointerEvents: "none",
|
|
@@ -7252,7 +7557,7 @@ var useCSSVariableWatch = (params) => {
|
|
|
7252
7557
|
const value = params.ref.current.getBoundingClientRect().height;
|
|
7253
7558
|
if (value) {
|
|
7254
7559
|
lastValueRef.current = value;
|
|
7255
|
-
|
|
7560
|
+
debug5(`Variable ${params.varName} found and equals ${value}.`);
|
|
7256
7561
|
params.onChange(value);
|
|
7257
7562
|
} else {
|
|
7258
7563
|
error(`Specified variable ${params.varName} not found or does not have a numeric value.`);
|