@infinite-table/infinite-react 0.0.10 → 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 +8 -9
- package/index.d.ts +347 -207
- package/index.esm.css +8 -9
- package/index.esm.js +1307 -864
- package/index.js +1455 -1010
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -622,7 +622,7 @@ import {
|
|
|
622
622
|
createElement as createElement33,
|
|
623
623
|
memo as memo13,
|
|
624
624
|
useEffect as useEffect24,
|
|
625
|
-
useLayoutEffect as
|
|
625
|
+
useLayoutEffect as useLayoutEffect5
|
|
626
626
|
} from "react";
|
|
627
627
|
|
|
628
628
|
// src/components/InfiniteTable/internalProps.ts
|
|
@@ -703,6 +703,24 @@ var ScrollListener = class {
|
|
|
703
703
|
}
|
|
704
704
|
};
|
|
705
705
|
|
|
706
|
+
// src/components/InfiniteTable/utils/toMap.ts
|
|
707
|
+
function toMap(mapOrObject, weakMapCache) {
|
|
708
|
+
if (!mapOrObject) {
|
|
709
|
+
return new Map();
|
|
710
|
+
}
|
|
711
|
+
if (mapOrObject instanceof Map) {
|
|
712
|
+
return mapOrObject;
|
|
713
|
+
}
|
|
714
|
+
if (weakMapCache && weakMapCache.has(mapOrObject)) {
|
|
715
|
+
return weakMapCache.get(mapOrObject);
|
|
716
|
+
}
|
|
717
|
+
const result = new Map(Object.entries(mapOrObject));
|
|
718
|
+
if (weakMapCache) {
|
|
719
|
+
weakMapCache.set(mapOrObject, result);
|
|
720
|
+
}
|
|
721
|
+
return result;
|
|
722
|
+
}
|
|
723
|
+
|
|
706
724
|
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
707
725
|
function computeColumnGroupsDepths(columnGroups) {
|
|
708
726
|
const map2 = new Map();
|
|
@@ -726,21 +744,10 @@ function computeColumnGroupsDepths(columnGroups) {
|
|
|
726
744
|
}
|
|
727
745
|
|
|
728
746
|
// src/components/InfiniteTable/state/getInitialState.ts
|
|
729
|
-
function toMap(mapOrObject) {
|
|
730
|
-
if (!mapOrObject) {
|
|
731
|
-
return new Map();
|
|
732
|
-
}
|
|
733
|
-
if (mapOrObject instanceof Map) {
|
|
734
|
-
return mapOrObject;
|
|
735
|
-
}
|
|
736
|
-
return new Map(Object.entries(mapOrObject));
|
|
737
|
-
}
|
|
738
|
-
function toColumnTypesMap(mapOrObject) {
|
|
739
|
-
return toMap(mapOrObject);
|
|
740
|
-
}
|
|
741
747
|
function initSetupState() {
|
|
742
748
|
const columnsGeneratedForGrouping = new Map();
|
|
743
749
|
return {
|
|
750
|
+
propsCache: new Map([]),
|
|
744
751
|
columnShifts: null,
|
|
745
752
|
domRef: createRef(),
|
|
746
753
|
scrollerDOMRef: createRef(),
|
|
@@ -765,12 +772,8 @@ function initSetupState() {
|
|
|
765
772
|
columnsWhenInlineGroupRenderStrategy: void 0
|
|
766
773
|
};
|
|
767
774
|
}
|
|
768
|
-
var forwardProps = () => {
|
|
775
|
+
var forwardProps = (setupState) => {
|
|
769
776
|
return {
|
|
770
|
-
columns: (columns) => {
|
|
771
|
-
var _a;
|
|
772
|
-
return (_a = toMap(columns)) != null ? _a : new Map();
|
|
773
|
-
},
|
|
774
777
|
scrollTopId: 1,
|
|
775
778
|
components: 1,
|
|
776
779
|
loadingText: 1,
|
|
@@ -788,6 +791,7 @@ var forwardProps = () => {
|
|
|
788
791
|
onBlurWithin: 1,
|
|
789
792
|
onScrollToTop: 1,
|
|
790
793
|
onScrollToBottom: 1,
|
|
794
|
+
onScrollStop: 1,
|
|
791
795
|
scrollToBottomOffset: 1,
|
|
792
796
|
rowStyle: 1,
|
|
793
797
|
rowProps: 1,
|
|
@@ -798,12 +802,14 @@ var forwardProps = () => {
|
|
|
798
802
|
pivotRowLabelsColumn: 1,
|
|
799
803
|
pivotColumnGroups: 1,
|
|
800
804
|
onScrollbarsChange: 1,
|
|
805
|
+
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
801
806
|
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
802
807
|
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
803
808
|
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
804
809
|
columnMaxWidth: (columnMaxWidth) => columnMaxWidth != null ? columnMaxWidth : 2e3,
|
|
805
810
|
columnDefaultWidth: (columnDefaultWidth) => columnDefaultWidth != null ? columnDefaultWidth : 200,
|
|
806
811
|
draggableColumns: (draggableColumns) => draggableColumns != null ? draggableColumns : true,
|
|
812
|
+
showSeparatePivotColumnForSingleAggregation: (showSeparatePivotColumnForSingleAggregation) => showSeparatePivotColumnForSingleAggregation != null ? showSeparatePivotColumnForSingleAggregation : false,
|
|
807
813
|
sortable: (sortable) => sortable != null ? sortable : true,
|
|
808
814
|
hideEmptyGroupColumns: (hideEmptyGroupColumns) => hideEmptyGroupColumns != null ? hideEmptyGroupColumns : false,
|
|
809
815
|
pivotTotalColumnPosition: (pivotTotalColumnPosition) => pivotTotalColumnPosition != null ? pivotTotalColumnPosition : "end",
|
|
@@ -815,31 +821,25 @@ var forwardProps = () => {
|
|
|
815
821
|
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
816
822
|
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
817
823
|
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
},
|
|
824
|
-
columnTypes: (columnTypes) => {
|
|
825
|
-
var _a;
|
|
826
|
-
return (_a = toColumnTypesMap(columnTypes)) != null ? _a : new Map();
|
|
827
|
-
},
|
|
828
|
-
columnAggregations: (columnAggregations) => columnAggregations != null ? columnAggregations : new Map(),
|
|
824
|
+
columns: (columns) => toMap(columns, setupState.propsCache.get("columns")),
|
|
825
|
+
columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
|
|
826
|
+
columnPinning: (columnPinning) => toMap(columnPinning, setupState.propsCache.get("columnPinning")),
|
|
827
|
+
columnSizing: (columnSizing) => toMap(columnSizing, setupState.propsCache.get("columnSizing")),
|
|
828
|
+
columnTypes: (columnTypes) => toMap(columnTypes, setupState.propsCache.get("columnTypes")),
|
|
829
829
|
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
830
|
-
columnGroups: (columnGroups) => columnGroups
|
|
830
|
+
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
831
831
|
};
|
|
832
832
|
};
|
|
833
833
|
function getGroupRenderStrategy(options) {
|
|
834
|
-
const {
|
|
834
|
+
const { groupBy, groupColumn, groupRenderStrategy } = options;
|
|
835
835
|
if (groupRenderStrategy) {
|
|
836
836
|
return groupRenderStrategy;
|
|
837
837
|
}
|
|
838
838
|
if (groupColumn != null && typeof groupColumn === "object") {
|
|
839
839
|
return "single-column";
|
|
840
840
|
}
|
|
841
|
-
const
|
|
842
|
-
if (
|
|
841
|
+
const columnsInGroupBy = groupBy.filter((g) => g.column);
|
|
842
|
+
if (columnsInGroupBy.length) {
|
|
843
843
|
return "multi-column";
|
|
844
844
|
}
|
|
845
845
|
return "multi-column";
|
|
@@ -850,16 +850,17 @@ var mapPropsToState = (params) => {
|
|
|
850
850
|
const computedColumnGroups = state.pivotColumnGroups || state.columnGroups;
|
|
851
851
|
const virtualizeHeader = header && virtualizeColumns && (!computedColumnGroups || (computedColumnGroups == null ? void 0 : computedColumnGroups.size) === 0);
|
|
852
852
|
const columnGroupsDepthsMap = state.columnGroups && state.columnGroups != (oldState == null ? void 0 : oldState.columnGroups) || state.pivotColumnGroups && state.pivotColumnGroups != (oldState == null ? void 0 : oldState.pivotColumnGroups) ? computeColumnGroupsDepths(computedColumnGroups) : state.columnGroupsDepthsMap;
|
|
853
|
-
const
|
|
853
|
+
const groupBy = parentState == null ? void 0 : parentState.groupBy;
|
|
854
854
|
const groupRenderStrategy = getGroupRenderStrategy({
|
|
855
855
|
groupRenderStrategy: props.groupRenderStrategy,
|
|
856
|
-
|
|
856
|
+
groupBy,
|
|
857
857
|
groupColumn: props.groupColumn
|
|
858
858
|
});
|
|
859
|
+
const computedColumns = state.computedPivotColumns || state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
|
|
859
860
|
return {
|
|
860
861
|
groupRenderStrategy,
|
|
861
|
-
|
|
862
|
-
computedColumns
|
|
862
|
+
groupBy,
|
|
863
|
+
computedColumns,
|
|
863
864
|
virtualizeHeader,
|
|
864
865
|
columnGroupsDepthsMap,
|
|
865
866
|
columnGroupsMaxDepth: columnGroupsDepthsMap != state.columnGroupsDepthsMap ? Math.max(...columnGroupsDepthsMap.values(), 0) : state.columnGroupsMaxDepth,
|
|
@@ -1209,11 +1210,11 @@ function getColumnComputedType(column, columnTypes) {
|
|
|
1209
1210
|
// src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
|
|
1210
1211
|
var logError = err("getComputedVisibleColumns");
|
|
1211
1212
|
var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
|
|
1212
|
-
return
|
|
1213
|
+
return columnVisibility[colId] !== false;
|
|
1213
1214
|
};
|
|
1214
1215
|
var getComputedPinned = (colId, columnPinning) => {
|
|
1215
1216
|
const pinned = columnPinning.get(colId);
|
|
1216
|
-
const computedPinned = pinned === "start"
|
|
1217
|
+
const computedPinned = pinned === "start" ? "start" : pinned === "end" ? "end" : false;
|
|
1217
1218
|
return computedPinned;
|
|
1218
1219
|
};
|
|
1219
1220
|
var getComputedVisibleColumns = ({
|
|
@@ -1245,7 +1246,9 @@ var getComputedVisibleColumns = ({
|
|
|
1245
1246
|
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1246
1247
|
return false;
|
|
1247
1248
|
}
|
|
1248
|
-
|
|
1249
|
+
const result2 = isColumnVisible(columnVisibility, columnVisibilityAssumeVisible, colId);
|
|
1250
|
+
console.log(columnVisibility, colId, result2);
|
|
1251
|
+
return result2;
|
|
1249
1252
|
});
|
|
1250
1253
|
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1251
1254
|
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
@@ -1271,10 +1274,13 @@ var getComputedVisibleColumns = ({
|
|
|
1271
1274
|
const colTypeSizing = {
|
|
1272
1275
|
minWidth: colType == null ? void 0 : colType.minWidth,
|
|
1273
1276
|
maxWidth: colType == null ? void 0 : colType.maxWidth,
|
|
1274
|
-
width: colType == null ? void 0 : colType.
|
|
1275
|
-
flex: colType == null ? void 0 : colType.
|
|
1277
|
+
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1278
|
+
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1279
|
+
};
|
|
1280
|
+
let colSizing = columnSizing.get(colId) || {
|
|
1281
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1282
|
+
flex: column == null ? void 0 : column.defaultFlex
|
|
1276
1283
|
};
|
|
1277
|
-
let colSizing = columnSizing.get(colId) || {};
|
|
1278
1284
|
if (colSizing.width != null) {
|
|
1279
1285
|
delete colTypeSizing.flex;
|
|
1280
1286
|
}
|
|
@@ -1325,7 +1331,7 @@ var getComputedVisibleColumns = ({
|
|
|
1325
1331
|
});
|
|
1326
1332
|
const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
|
|
1327
1333
|
columnsArray.forEach((c, i) => {
|
|
1328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1334
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1329
1335
|
const id = visibleColumnOrder[i];
|
|
1330
1336
|
const nextColumnId = visibleColumnOrder[i + 1];
|
|
1331
1337
|
const colType = getColumnComputedType(c, columnTypes);
|
|
@@ -1386,6 +1392,7 @@ var getComputedVisibleColumns = ({
|
|
|
1386
1392
|
const result2 = __spreadProps(__spreadValues({
|
|
1387
1393
|
align: colType.align,
|
|
1388
1394
|
verticalAlign: colType.verticalAlign,
|
|
1395
|
+
valueGetter: colType.valueGetter,
|
|
1389
1396
|
renderValue: colType.renderValue,
|
|
1390
1397
|
render: colType.render
|
|
1391
1398
|
}, c), {
|
|
@@ -1393,7 +1400,7 @@ var getComputedVisibleColumns = ({
|
|
|
1393
1400
|
computedAbsoluteOffset,
|
|
1394
1401
|
computedPinningOffset,
|
|
1395
1402
|
computedOffset,
|
|
1396
|
-
computedSortable: (_e = (_d = c.sortable) != null ? _d : sortable) != null ? _e : true,
|
|
1403
|
+
computedSortable: (_f = (_e = (_d = c.sortable) != null ? _d : colType.sortable) != null ? _e : sortable) != null ? _f : true,
|
|
1397
1404
|
computedSortInfo,
|
|
1398
1405
|
computedSortIndex,
|
|
1399
1406
|
computedMultiSort: multiSort,
|
|
@@ -1402,14 +1409,14 @@ var getComputedVisibleColumns = ({
|
|
|
1402
1409
|
computedSortedDesc,
|
|
1403
1410
|
computedVisibleIndex: i,
|
|
1404
1411
|
computedPinned,
|
|
1405
|
-
computedDraggable: (
|
|
1412
|
+
computedDraggable: (_h = (_g = c.draggable) != null ? _g : draggableColumns) != null ? _h : true,
|
|
1406
1413
|
computedFirstInCategory,
|
|
1407
1414
|
computedLastInCategory,
|
|
1408
1415
|
computedFirst: i === 0,
|
|
1409
1416
|
computedLast,
|
|
1410
1417
|
toggleSort,
|
|
1411
1418
|
id,
|
|
1412
|
-
header: (
|
|
1419
|
+
header: (_k = (_j = (_i = c.header) != null ? _i : colType.header) != null ? _j : c.name) != null ? _k : c.field
|
|
1413
1420
|
});
|
|
1414
1421
|
computedOffset += computedWidth;
|
|
1415
1422
|
computedVisibleColumnsMap.set(result2.id, result2);
|
|
@@ -1560,7 +1567,6 @@ var useComputedVisibleColumns = ({
|
|
|
1560
1567
|
const columnsSizingRenderId = useRerenderOnKeyChange(columnSizing);
|
|
1561
1568
|
const columnTypesRenderId = useRerenderOnKeyChange(columnTypes);
|
|
1562
1569
|
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
1563
|
-
const visibilityRenderId = useRerenderOnKeyChange(columnVisibility);
|
|
1564
1570
|
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
1565
1571
|
const {
|
|
1566
1572
|
computedRemainingSpace,
|
|
@@ -1616,7 +1622,6 @@ var useComputedVisibleColumns = ({
|
|
|
1616
1622
|
pinnedStartMaxWidth,
|
|
1617
1623
|
columnPinning,
|
|
1618
1624
|
columnsRenderId,
|
|
1619
|
-
visibilityRenderId,
|
|
1620
1625
|
columnsSizingRenderId,
|
|
1621
1626
|
pinningRenderId,
|
|
1622
1627
|
columnTypesRenderId
|
|
@@ -1641,52 +1646,21 @@ var useComputedVisibleColumns = ({
|
|
|
1641
1646
|
return result;
|
|
1642
1647
|
};
|
|
1643
1648
|
|
|
1644
|
-
// src/utils/sortAscending.ts
|
|
1649
|
+
// src/utils/DeepMap/sortAscending.ts
|
|
1645
1650
|
var sortAscending = (a, b) => a - b;
|
|
1646
1651
|
|
|
1647
1652
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
1648
|
-
import { useCallback as useCallback5, useState as useState5 } from "react";
|
|
1649
|
-
|
|
1650
|
-
// src/components/InfiniteTable/hooks/useColumnAggregations.ts
|
|
1651
|
-
import { useEffect as useEffect5 } from "react";
|
|
1652
|
-
|
|
1653
|
-
// src/components/DataSource/publicHooks/useDataSourceActions.ts
|
|
1654
|
-
import {
|
|
1655
|
-
useContext as useContext2
|
|
1656
|
-
} from "react";
|
|
1657
|
-
|
|
1658
|
-
// src/components/DataSource/DataSourceContext.ts
|
|
1659
|
-
import {
|
|
1660
|
-
createContext as createContext2
|
|
1661
|
-
} from "react";
|
|
1662
|
-
var DSContext;
|
|
1663
|
-
function getDataSourceContext() {
|
|
1664
|
-
if (DSContext) {
|
|
1665
|
-
return DSContext;
|
|
1666
|
-
}
|
|
1667
|
-
return DSContext = createContext2({
|
|
1668
|
-
getState: () => null,
|
|
1669
|
-
componentState: null,
|
|
1670
|
-
componentActions: null
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
// src/components/DataSource/publicHooks/useDataSourceActions.ts
|
|
1675
|
-
function useDataSourceActions() {
|
|
1676
|
-
const DataSourceContext = getDataSourceContext();
|
|
1677
|
-
const contextValue = useContext2(DataSourceContext);
|
|
1678
|
-
return contextValue.componentActions;
|
|
1679
|
-
}
|
|
1653
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useState as useState5 } from "react";
|
|
1680
1654
|
|
|
1681
1655
|
// src/components/hooks/useComponentState.tsx
|
|
1682
1656
|
import {
|
|
1683
1657
|
createElement as createElement2,
|
|
1684
1658
|
memo,
|
|
1685
|
-
useContext as
|
|
1659
|
+
useContext as useContext2
|
|
1686
1660
|
} from "react";
|
|
1687
1661
|
import {
|
|
1688
1662
|
useReducer,
|
|
1689
|
-
createContext as
|
|
1663
|
+
createContext as createContext2,
|
|
1690
1664
|
useMemo as useMemo3,
|
|
1691
1665
|
useEffect as useEffect4,
|
|
1692
1666
|
useState as useState2,
|
|
@@ -1766,7 +1740,7 @@ function getComponentStateContext() {
|
|
|
1766
1740
|
if (ComponentContext) {
|
|
1767
1741
|
return ComponentContext;
|
|
1768
1742
|
}
|
|
1769
|
-
return ComponentContext =
|
|
1743
|
+
return ComponentContext = createContext2(null);
|
|
1770
1744
|
}
|
|
1771
1745
|
function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward, allowedControlledPropOverrides, interceptedActions) {
|
|
1772
1746
|
const state = getState();
|
|
@@ -1779,9 +1753,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
|
|
|
1779
1753
|
if (currentValue === value) {
|
|
1780
1754
|
return;
|
|
1781
1755
|
}
|
|
1782
|
-
|
|
1756
|
+
let notifyTheChange = true;
|
|
1783
1757
|
if (interceptedActions && typeof interceptedActions[key] === "function") {
|
|
1784
|
-
interceptedActions[key](value, { actions, state: state2 })
|
|
1758
|
+
if (interceptedActions[key](value, { actions, state: state2 }) === false) {
|
|
1759
|
+
notifyTheChange = false;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
if (notifyTheChange) {
|
|
1763
|
+
notifyChange(props, stateKey, value);
|
|
1785
1764
|
}
|
|
1786
1765
|
const forwardFn = propsToForward[key];
|
|
1787
1766
|
if (typeof forwardFn === "function") {
|
|
@@ -1822,12 +1801,14 @@ function forwardProps2(propsToForward, props) {
|
|
|
1822
1801
|
function getComponentStateRoot(config) {
|
|
1823
1802
|
return memo(function ComponentStateRoot(props) {
|
|
1824
1803
|
var _a, _b;
|
|
1804
|
+
const [initialSetupState] = useState2(() => {
|
|
1805
|
+
return config.initSetupState ? config.initSetupState() : {};
|
|
1806
|
+
});
|
|
1825
1807
|
const propsToStateSetRef = useRef4(new Set());
|
|
1826
|
-
const propsToForward = useMemo3(() => config.forwardProps ? config.forwardProps() : {}, []);
|
|
1808
|
+
const propsToForward = useMemo3(() => config.forwardProps ? config.forwardProps(initialSetupState) : {}, [initialSetupState]);
|
|
1827
1809
|
const parentState = (_b = (_a = config.getParentState) == null ? void 0 : _a.call(config)) != null ? _b : null;
|
|
1828
1810
|
const getParentState = useLatest(parentState);
|
|
1829
1811
|
const [wholeState] = useState2(() => {
|
|
1830
|
-
const initialSetupState = config.initSetupState ? config.initSetupState() : {};
|
|
1831
1812
|
let mappedState = {};
|
|
1832
1813
|
if (propsToForward) {
|
|
1833
1814
|
mappedState = forwardProps2(propsToForward, props);
|
|
@@ -1857,9 +1838,12 @@ function getComponentStateRoot(config) {
|
|
|
1857
1838
|
const getProps = useLatest(props);
|
|
1858
1839
|
const theReducer = (previousState, action) => {
|
|
1859
1840
|
var _a2;
|
|
1841
|
+
if (action.type === "REPLACE_STATE") {
|
|
1842
|
+
return action.payload;
|
|
1843
|
+
}
|
|
1860
1844
|
const parentState2 = (_a2 = getParentState == null ? void 0 : getParentState()) != null ? _a2 : null;
|
|
1861
1845
|
const mappedState = action.payload.mappedState;
|
|
1862
|
-
const updatedProps = action.payload.
|
|
1846
|
+
const updatedProps = action.payload.updatedPropsToState;
|
|
1863
1847
|
const newState = Object.assign({}, previousState);
|
|
1864
1848
|
if (mappedState) {
|
|
1865
1849
|
Object.assign(newState, mappedState);
|
|
@@ -1913,8 +1897,9 @@ function getComponentStateRoot(config) {
|
|
|
1913
1897
|
const currentProps = props;
|
|
1914
1898
|
const newMappedState = {};
|
|
1915
1899
|
let newMappedStateCount = 0;
|
|
1916
|
-
const
|
|
1917
|
-
let
|
|
1900
|
+
const updatedPropsToState = {};
|
|
1901
|
+
let updatedPropsToStateCount = 0;
|
|
1902
|
+
const rawUpdatedProps = {};
|
|
1918
1903
|
for (var k in props) {
|
|
1919
1904
|
const key = k;
|
|
1920
1905
|
const oldValue = prevProps[key];
|
|
@@ -1925,7 +1910,8 @@ function getComponentStateRoot(config) {
|
|
|
1925
1910
|
if (oldValue === newValue) {
|
|
1926
1911
|
continue;
|
|
1927
1912
|
}
|
|
1928
|
-
|
|
1913
|
+
rawUpdatedProps[key] = { newValue, oldValue };
|
|
1914
|
+
if (isControlled(key, props) || isControlled(key, prevProps)) {
|
|
1929
1915
|
if (propsToForward.hasOwnProperty(k)) {
|
|
1930
1916
|
let valueToSet = newValue;
|
|
1931
1917
|
const forwardFn = propsToForward[k];
|
|
@@ -1937,22 +1923,30 @@ function getComponentStateRoot(config) {
|
|
|
1937
1923
|
newMappedStateCount++;
|
|
1938
1924
|
}
|
|
1939
1925
|
} else if (propsToStateSetRef.current.has(k)) {
|
|
1940
|
-
|
|
1941
|
-
|
|
1926
|
+
updatedPropsToState[key] = currentProps[key];
|
|
1927
|
+
updatedPropsToStateCount++;
|
|
1942
1928
|
}
|
|
1943
1929
|
}
|
|
1944
1930
|
}
|
|
1945
|
-
if (
|
|
1931
|
+
if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
|
|
1946
1932
|
debug2("Triggered by new values for the following props", ...[
|
|
1947
1933
|
...Object.keys(newMappedState != null ? newMappedState : {}),
|
|
1948
|
-
...Object.keys(
|
|
1934
|
+
...Object.keys(updatedPropsToState != null ? updatedPropsToState : {})
|
|
1949
1935
|
]);
|
|
1950
|
-
|
|
1936
|
+
const action = {
|
|
1951
1937
|
payload: {
|
|
1952
1938
|
mappedState: newMappedStateCount ? newMappedState : null,
|
|
1953
|
-
|
|
1939
|
+
updatedPropsToState: updatedPropsToStateCount ? updatedPropsToState : null
|
|
1954
1940
|
}
|
|
1955
|
-
}
|
|
1941
|
+
};
|
|
1942
|
+
dispatch(action);
|
|
1943
|
+
if (config.onPropChange) {
|
|
1944
|
+
for (var prop in rawUpdatedProps)
|
|
1945
|
+
if (rawUpdatedProps.hasOwnProperty(prop)) {
|
|
1946
|
+
const { newValue, oldValue } = rawUpdatedProps[prop];
|
|
1947
|
+
config.onPropChange({ name: prop, newValue, oldValue }, props, actions);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1956
1950
|
}
|
|
1957
1951
|
});
|
|
1958
1952
|
return /* @__PURE__ */ createElement2(Context.Provider, {
|
|
@@ -1962,56 +1956,44 @@ function getComponentStateRoot(config) {
|
|
|
1962
1956
|
}
|
|
1963
1957
|
function useComponentState() {
|
|
1964
1958
|
const Context = getComponentStateContext();
|
|
1965
|
-
return
|
|
1966
|
-
}
|
|
1967
|
-
|
|
1968
|
-
// src/components/InfiniteTable/hooks/useColumnAggregations.ts
|
|
1969
|
-
function useColumnAggregations() {
|
|
1970
|
-
const {
|
|
1971
|
-
componentState: { columnAggregations },
|
|
1972
|
-
getComponentState
|
|
1973
|
-
} = useComponentState();
|
|
1974
|
-
const dataSourceActions = useDataSourceActions();
|
|
1975
|
-
useEffect5(() => {
|
|
1976
|
-
function updateDataSourceAggregations() {
|
|
1977
|
-
const reducers = [];
|
|
1978
|
-
const componentState = getComponentState();
|
|
1979
|
-
columnAggregations.forEach((aggregator, key) => {
|
|
1980
|
-
var _a;
|
|
1981
|
-
const colField = (_a = componentState.computedColumns.get(key)) == null ? void 0 : _a.field;
|
|
1982
|
-
const newAggregator = __spreadValues({
|
|
1983
|
-
getter: (data) => colField ? data[colField] : data
|
|
1984
|
-
}, aggregator);
|
|
1985
|
-
reducers.push(newAggregator);
|
|
1986
|
-
});
|
|
1987
|
-
dataSourceActions.aggregationReducers = reducers;
|
|
1988
|
-
}
|
|
1989
|
-
updateDataSourceAggregations();
|
|
1990
|
-
return interceptMap(columnAggregations, {
|
|
1991
|
-
clear: updateDataSourceAggregations,
|
|
1992
|
-
delete: updateDataSourceAggregations,
|
|
1993
|
-
set: updateDataSourceAggregations
|
|
1994
|
-
});
|
|
1995
|
-
}, [columnAggregations]);
|
|
1959
|
+
return useContext2(Context);
|
|
1996
1960
|
}
|
|
1997
1961
|
|
|
1998
1962
|
// src/components/DataSource/publicHooks/useDataSource.ts
|
|
1999
1963
|
import {
|
|
2000
|
-
useContext as
|
|
1964
|
+
useContext as useContext3
|
|
1965
|
+
} from "react";
|
|
1966
|
+
|
|
1967
|
+
// src/components/DataSource/DataSourceContext.ts
|
|
1968
|
+
import {
|
|
1969
|
+
createContext as createContext3
|
|
2001
1970
|
} from "react";
|
|
1971
|
+
var DSContext;
|
|
1972
|
+
function getDataSourceContext() {
|
|
1973
|
+
if (DSContext) {
|
|
1974
|
+
return DSContext;
|
|
1975
|
+
}
|
|
1976
|
+
return DSContext = createContext3({
|
|
1977
|
+
getState: () => null,
|
|
1978
|
+
componentState: null,
|
|
1979
|
+
componentActions: null
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
// src/components/DataSource/publicHooks/useDataSource.ts
|
|
2002
1984
|
function useDataSource() {
|
|
2003
1985
|
const DataSourceContext = getDataSourceContext();
|
|
2004
|
-
const contextValue =
|
|
1986
|
+
const contextValue = useContext3(DataSourceContext);
|
|
2005
1987
|
return contextValue.componentState;
|
|
2006
1988
|
}
|
|
2007
1989
|
function useDataSourceContextValue() {
|
|
2008
1990
|
const DataSourceContext = getDataSourceContext();
|
|
2009
|
-
const contextValue =
|
|
1991
|
+
const contextValue = useContext3(DataSourceContext);
|
|
2010
1992
|
return contextValue;
|
|
2011
1993
|
}
|
|
2012
1994
|
|
|
2013
1995
|
// src/components/InfiniteTable/hooks/useColumnGroups.ts
|
|
2014
|
-
import { useEffect as
|
|
1996
|
+
import { useEffect as useEffect5 } from "react";
|
|
2015
1997
|
function useColumnGroups() {
|
|
2016
1998
|
const {
|
|
2017
1999
|
componentState: {
|
|
@@ -2021,7 +2003,7 @@ function useColumnGroups() {
|
|
|
2021
2003
|
componentActions,
|
|
2022
2004
|
getComponentState
|
|
2023
2005
|
} = useComponentState();
|
|
2024
|
-
|
|
2006
|
+
useEffect5(() => {
|
|
2025
2007
|
const recompute = () => {
|
|
2026
2008
|
componentActions.columnGroupsDepthsMap = computeColumnGroupsDepths(computedColumnGroups);
|
|
2027
2009
|
};
|
|
@@ -2032,39 +2014,42 @@ function useColumnGroups() {
|
|
|
2032
2014
|
set: update
|
|
2033
2015
|
});
|
|
2034
2016
|
}, [computedColumnGroups]);
|
|
2035
|
-
|
|
2017
|
+
useEffect5(() => {
|
|
2036
2018
|
return interceptMap(collapsedColumnGroups, {
|
|
2037
2019
|
set: (key, visibleCol) => {
|
|
2038
2020
|
const colIds = key.slice(1);
|
|
2039
|
-
const
|
|
2021
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2040
2022
|
colIds.forEach((colId) => {
|
|
2041
|
-
columnVisibility
|
|
2023
|
+
columnVisibility[colId] = false;
|
|
2042
2024
|
});
|
|
2043
|
-
columnVisibility
|
|
2025
|
+
delete columnVisibility[visibleCol];
|
|
2026
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2044
2027
|
},
|
|
2045
2028
|
beforeClear: (currentCollapsedGroups) => {
|
|
2046
|
-
const
|
|
2029
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2047
2030
|
const keys = [...currentCollapsedGroups.keys()];
|
|
2048
2031
|
keys.forEach((key) => {
|
|
2049
2032
|
const colIds = key.slice(1);
|
|
2050
2033
|
colIds.forEach((colId) => {
|
|
2051
|
-
columnVisibility
|
|
2034
|
+
delete columnVisibility[colId];
|
|
2052
2035
|
});
|
|
2053
2036
|
});
|
|
2037
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2054
2038
|
},
|
|
2055
2039
|
delete: (key) => {
|
|
2056
|
-
const
|
|
2040
|
+
const columnVisibility = __spreadValues({}, getComponentState().columnVisibility);
|
|
2057
2041
|
const colIds = key.slice(1);
|
|
2058
2042
|
colIds.forEach((colId) => {
|
|
2059
|
-
columnVisibility
|
|
2043
|
+
delete columnVisibility[colId];
|
|
2060
2044
|
});
|
|
2045
|
+
componentActions.columnVisibility = columnVisibility;
|
|
2061
2046
|
}
|
|
2062
2047
|
});
|
|
2063
2048
|
}, [collapsedColumnGroups]);
|
|
2064
2049
|
}
|
|
2065
2050
|
|
|
2066
2051
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
2067
|
-
import { useEffect as
|
|
2052
|
+
import { useEffect as useEffect9, useMemo as useMemo4 } from "react";
|
|
2068
2053
|
|
|
2069
2054
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2070
2055
|
import {
|
|
@@ -2077,27 +2062,14 @@ var join = (...args) => args.filter((x) => !!`${x}`).join(" ");
|
|
|
2077
2062
|
// src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
|
|
2078
2063
|
import {
|
|
2079
2064
|
createElement as createElement3,
|
|
2080
|
-
useEffect as
|
|
2065
|
+
useEffect as useEffect6
|
|
2081
2066
|
} from "react";
|
|
2082
2067
|
import { useState as useState3 } from "react";
|
|
2083
2068
|
|
|
2084
|
-
// src/components/InfiniteTable/
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2087
|
-
var
|
|
2088
|
-
var display = { flex: "_16lm1iwj", block: "_16lm1iwk", inlineBlock: "_16lm1iwl" };
|
|
2089
|
-
var fill = { currentColor: "_16lm1iw5", accentColor: "_16lm1iw6" };
|
|
2090
|
-
var flex = { "1": "_16lm1iwc", none: "_16lm1iwd" };
|
|
2091
|
-
var flexFlow = { column: "_16lm1iwz", row: "_16lm1iw10" };
|
|
2092
|
-
var justifyContent = { center: "_16lm1iw13", start: "_16lm1iw14", end: "_16lm1iw15" };
|
|
2093
|
-
var left = { "0": "_16lm1iwt", "100%": "_16lm1iwu" };
|
|
2094
|
-
var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
|
|
2095
|
-
var top = { "0": "_16lm1iwr", "100%": "_16lm1iws" };
|
|
2096
|
-
var transform = { translateZero: "_16lm1iw9", rotate90: "_16lm1iwa" };
|
|
2097
|
-
var transformTranslateZero = "_16lm1iw8";
|
|
2098
|
-
var userSelect = { none: "_16lm1iwm" };
|
|
2099
|
-
var willChange = { transform: "_16lm1iw19" };
|
|
2100
|
-
var zIndex = { "1": "_16lm1iwe", "10": "_16lm1iwf", "1000": "_16lm1iwg", "10000": "_16lm1iwh", "100000": "_16lm1iwi" };
|
|
2069
|
+
// src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts
|
|
2070
|
+
var import_createRuntimeFn = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
2071
|
+
var ExpanderIconCls = "_16lm1iw6 _16lm1iwd _16lm1iwb";
|
|
2072
|
+
var ExpanderIconClsVariants = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwa", false: "_198z9782" } }, defaultVariants: {}, compoundVariants: [] });
|
|
2101
2073
|
|
|
2102
2074
|
// src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
|
|
2103
2075
|
function ExpanderIcon(props) {
|
|
@@ -2111,7 +2083,7 @@ function ExpanderIcon(props) {
|
|
|
2111
2083
|
setExpanded(!expanded);
|
|
2112
2084
|
}
|
|
2113
2085
|
};
|
|
2114
|
-
|
|
2086
|
+
useEffect6(() => {
|
|
2115
2087
|
if (isControlled("expanded", props)) {
|
|
2116
2088
|
setExpanded(props.expanded);
|
|
2117
2089
|
}
|
|
@@ -2124,18 +2096,37 @@ function ExpanderIcon(props) {
|
|
|
2124
2096
|
width: `${size}px`,
|
|
2125
2097
|
style: props.style,
|
|
2126
2098
|
onClick,
|
|
2127
|
-
className: join(props.className,
|
|
2099
|
+
className: join(props.className, ExpanderIconCls, ExpanderIconClsVariants({
|
|
2100
|
+
expanded
|
|
2101
|
+
}), "InfiniteIcon", "InfiniteIcon-expander", `InfiniteIcon-expander--${expanded ? "expanded" : "collapsed"}`)
|
|
2128
2102
|
}, /* @__PURE__ */ createElement3("path", {
|
|
2129
2103
|
d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
|
|
2130
2104
|
}));
|
|
2131
2105
|
}
|
|
2132
2106
|
|
|
2133
2107
|
// src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts
|
|
2134
|
-
var
|
|
2108
|
+
var import_createRuntimeFn2 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
2135
2109
|
var GroupRowExpanderCls = "_7pupv0b";
|
|
2136
|
-
var RowClsRecipe = (0,
|
|
2110
|
+
var RowClsRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_7pupv00", variantClassNames: { zebra: { false: "_7pupv02", even: "_7pupv03", odd: "_7pupv04" }, groupRow: { true: "_7pupv05", false: "_7pupv06" }, inlineGroupRow: { true: "_7pupv07", false: "_7pupv08" }, showHoverRows: { true: "_7pupv09", false: "_7pupv0a" } }, defaultVariants: {}, compoundVariants: [] });
|
|
2137
2111
|
var RowHoverCls = "_7pupv01";
|
|
2138
2112
|
|
|
2113
|
+
// src/components/InfiniteTable/utilities.css.ts
|
|
2114
|
+
var alignItems = { center: "_16lm1iw11", stretch: "_16lm1iw12" };
|
|
2115
|
+
var cssEllipsisClassName = "_16lm1iw1a _16lm1iw1b _16lm1iw16";
|
|
2116
|
+
var cursor = { pointer: "_16lm1iwb" };
|
|
2117
|
+
var display = { flex: "_16lm1iwj", block: "_16lm1iwk", inlineBlock: "_16lm1iwl" };
|
|
2118
|
+
var flex = { "1": "_16lm1iwc", none: "_16lm1iwd" };
|
|
2119
|
+
var flexFlow = { column: "_16lm1iwz", row: "_16lm1iw10" };
|
|
2120
|
+
var justifyContent = { center: "_16lm1iw13", start: "_16lm1iw14", end: "_16lm1iw15" };
|
|
2121
|
+
var left = { "0": "_16lm1iwt", "100%": "_16lm1iwu" };
|
|
2122
|
+
var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
|
|
2123
|
+
var top = { "0": "_16lm1iwr", "100%": "_16lm1iws" };
|
|
2124
|
+
var transform = { translateZero: "_16lm1iw9", rotate90: "_16lm1iwa" };
|
|
2125
|
+
var transformTranslateZero = "_16lm1iw8";
|
|
2126
|
+
var userSelect = { none: "_16lm1iwm" };
|
|
2127
|
+
var willChange = { transform: "_16lm1iw19" };
|
|
2128
|
+
var zIndex = { "1": "_16lm1iwe", "10": "_16lm1iwf", "1000": "_16lm1iwg", "10000": "_16lm1iwh", "100000": "_16lm1iwi" };
|
|
2129
|
+
|
|
2139
2130
|
// src/components/InfiniteTable/state/getComputedPivotColumnsFromDataSourcePivotColumns.tsx
|
|
2140
2131
|
function getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, params) {
|
|
2141
2132
|
if (!pivotColumns) {
|
|
@@ -2145,7 +2136,7 @@ function getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, params)
|
|
|
2145
2136
|
pivotColumn,
|
|
2146
2137
|
pivotRowLabelsColumn,
|
|
2147
2138
|
pivotBy,
|
|
2148
|
-
|
|
2139
|
+
groupBy,
|
|
2149
2140
|
pivotTotalColumnPosition,
|
|
2150
2141
|
toggleGroupRow
|
|
2151
2142
|
} = params;
|
|
@@ -2162,7 +2153,7 @@ function getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, params)
|
|
|
2162
2153
|
column = __spreadValues(__spreadValues({}, column), pivotColumn({
|
|
2163
2154
|
column,
|
|
2164
2155
|
pivotBy,
|
|
2165
|
-
|
|
2156
|
+
groupBy
|
|
2166
2157
|
}));
|
|
2167
2158
|
} else {
|
|
2168
2159
|
column = __spreadValues(__spreadValues({}, column), pivotColumn);
|
|
@@ -2174,7 +2165,7 @@ function getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, params)
|
|
|
2174
2165
|
column = __spreadValues(__spreadValues({}, column), pivotRowLabelsColumn({
|
|
2175
2166
|
column,
|
|
2176
2167
|
pivotBy,
|
|
2177
|
-
|
|
2168
|
+
groupBy
|
|
2178
2169
|
}));
|
|
2179
2170
|
} else {
|
|
2180
2171
|
column = __spreadValues(__spreadValues({}, column), pivotRowLabelsColumn);
|
|
@@ -2183,11 +2174,11 @@ function getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, params)
|
|
|
2183
2174
|
if (!column.render) {
|
|
2184
2175
|
column.render = (renderOptions) => {
|
|
2185
2176
|
var _a;
|
|
2186
|
-
let { value, rowInfo, column: column2,
|
|
2177
|
+
let { value, rowInfo, column: column2, groupBy: groupBy2 } = renderOptions;
|
|
2187
2178
|
if (column2.renderValue) {
|
|
2188
2179
|
value = column2.renderValue(renderOptions);
|
|
2189
2180
|
}
|
|
2190
|
-
const showExpanderIcon = (((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) || 0) <
|
|
2181
|
+
const showExpanderIcon = (((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) || 0) < groupBy2.length;
|
|
2191
2182
|
return /* @__PURE__ */ createElement4("div", {
|
|
2192
2183
|
className: join(display.flex, alignItems.center, GroupRowExpanderCls)
|
|
2193
2184
|
}, showExpanderIcon ? /* @__PURE__ */ createElement4(ExpanderIcon, {
|
|
@@ -2287,7 +2278,7 @@ function getColumnForGroupBy(options, toggleGroupRow, groupColumnFromProps) {
|
|
|
2287
2278
|
function getSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps) {
|
|
2288
2279
|
let generatedGroupColumn = {
|
|
2289
2280
|
header: `Group`,
|
|
2290
|
-
groupByField: options.
|
|
2281
|
+
groupByField: options.groupBy.map((g) => g.field),
|
|
2291
2282
|
sortable: false,
|
|
2292
2283
|
render: (renderOptions) => {
|
|
2293
2284
|
let { value, rowInfo, column } = renderOptions;
|
|
@@ -2403,166 +2394,9 @@ var getMultisortFunction = (sortInfo, get) => {
|
|
|
2403
2394
|
};
|
|
2404
2395
|
|
|
2405
2396
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2406
|
-
import { useEffect as
|
|
2407
|
-
|
|
2408
|
-
// src/components/hooks/useEffectWithChanges.ts
|
|
2409
|
-
import { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
2410
|
-
function useEffectWithChanges(fn, deps) {
|
|
2411
|
-
const prevRef = useRef5({});
|
|
2412
|
-
const oldValuesRef = useRef5({});
|
|
2413
|
-
const oldValues = oldValuesRef.current;
|
|
2414
|
-
const changesRef = useRef5({});
|
|
2415
|
-
const changes = changesRef.current;
|
|
2416
|
-
const useEffectDeps = [];
|
|
2417
|
-
for (let k in deps) {
|
|
2418
|
-
if (deps.hasOwnProperty(k)) {
|
|
2419
|
-
if (deps[k] !== prevRef.current[k]) {
|
|
2420
|
-
changes[k] = deps[k];
|
|
2421
|
-
oldValues[k] = prevRef.current[k];
|
|
2422
|
-
}
|
|
2423
|
-
useEffectDeps.push(deps[k]);
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
prevRef.current = deps;
|
|
2427
|
-
useEffect8(() => {
|
|
2428
|
-
const changes2 = changesRef.current;
|
|
2429
|
-
const result = fn(changes2, oldValues);
|
|
2430
|
-
changesRef.current = {};
|
|
2431
|
-
oldValuesRef.current = {};
|
|
2432
|
-
return result;
|
|
2433
|
-
}, useEffectDeps);
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
2437
|
-
function buildDataSourceDataParams(componentState) {
|
|
2438
|
-
var _a, _b;
|
|
2439
|
-
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
2440
|
-
const dataSourceParams = {
|
|
2441
|
-
originalDataArray: componentState.originalDataArray,
|
|
2442
|
-
sortInfo,
|
|
2443
|
-
groupRowsBy: componentState.groupRowsBy,
|
|
2444
|
-
pivotBy: componentState.pivotBy
|
|
2445
|
-
};
|
|
2446
|
-
if (componentState.livePagination !== void 0) {
|
|
2447
|
-
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2448
|
-
}
|
|
2449
|
-
return dataSourceParams;
|
|
2450
|
-
}
|
|
2451
|
-
function notifyDataParamsChanged(componentState, actions) {
|
|
2452
|
-
var _a;
|
|
2453
|
-
if (typeof componentState.data === "function") {
|
|
2454
|
-
loadData(componentState.data, componentState, actions);
|
|
2455
|
-
}
|
|
2456
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2457
|
-
(_a = componentState.onDataParamsChange) == null ? void 0 : _a.call(componentState, dataParams);
|
|
2458
|
-
}
|
|
2459
|
-
function loadData(data, componentState, actions) {
|
|
2460
|
-
const dataParams = buildDataSourceDataParams(componentState);
|
|
2461
|
-
if (typeof data === "function") {
|
|
2462
|
-
data = data(dataParams);
|
|
2463
|
-
}
|
|
2464
|
-
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
2465
|
-
if (dataIsPromise) {
|
|
2466
|
-
actions.loading = true;
|
|
2467
|
-
}
|
|
2468
|
-
Promise.resolve(data).then((dataParam) => {
|
|
2469
|
-
let dataArray = [];
|
|
2470
|
-
if (Array.isArray(dataParam.data)) {
|
|
2471
|
-
const remoteData = dataParam;
|
|
2472
|
-
dataArray = remoteData.data;
|
|
2473
|
-
if (remoteData.livePaginationCursor !== void 0) {
|
|
2474
|
-
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
2475
|
-
}
|
|
2476
|
-
} else {
|
|
2477
|
-
dataArray = dataParam;
|
|
2478
|
-
}
|
|
2479
|
-
actions.originalDataArray = dataArray;
|
|
2480
|
-
if (dataIsPromise) {
|
|
2481
|
-
actions.loading = false;
|
|
2482
|
-
}
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2485
|
-
function useLoadData() {
|
|
2486
|
-
const {
|
|
2487
|
-
getComponentState,
|
|
2488
|
-
componentActions: actions,
|
|
2489
|
-
componentState: { data }
|
|
2490
|
-
} = useComponentState();
|
|
2491
|
-
useLayoutEffect3(() => {
|
|
2492
|
-
loadData(data, getComponentState(), actions);
|
|
2493
|
-
}, [data]);
|
|
2494
|
-
useLivePagination();
|
|
2495
|
-
}
|
|
2496
|
-
function useLivePagination() {
|
|
2497
|
-
const {
|
|
2498
|
-
getComponentState,
|
|
2499
|
-
componentActions: actions,
|
|
2500
|
-
componentState
|
|
2501
|
-
} = useComponentState();
|
|
2502
|
-
const {
|
|
2503
|
-
notifyScrollbarsChange,
|
|
2504
|
-
sortInfo,
|
|
2505
|
-
groupRowsBy,
|
|
2506
|
-
pivotBy,
|
|
2507
|
-
livePaginationCursor,
|
|
2508
|
-
scrollBottomId
|
|
2509
|
-
} = componentState;
|
|
2510
|
-
const [scrollbars, setScrollbars] = useState4({
|
|
2511
|
-
vertical: false,
|
|
2512
|
-
horizontal: false
|
|
2513
|
-
});
|
|
2514
|
-
const scrollbarsRef = useRef6(scrollbars);
|
|
2515
|
-
useEffect9(() => {
|
|
2516
|
-
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
2517
|
-
if (!scrollbars2) {
|
|
2518
|
-
return;
|
|
2519
|
-
}
|
|
2520
|
-
scrollbarsRef.current = scrollbars2;
|
|
2521
|
-
setScrollbars(scrollbars2);
|
|
2522
|
-
});
|
|
2523
|
-
return () => notifyScrollbarsChange.destroy();
|
|
2524
|
-
}, [notifyScrollbarsChange]);
|
|
2525
|
-
const [cursorId, updateCursorId] = useState4(void 0);
|
|
2526
|
-
useEffect9(() => {
|
|
2527
|
-
const frameId = requestAnimationFrame(() => {
|
|
2528
|
-
var _a;
|
|
2529
|
-
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical)) {
|
|
2530
|
-
updateCursorId(livePaginationCursor);
|
|
2531
|
-
}
|
|
2532
|
-
});
|
|
2533
|
-
return () => cancelAnimationFrame(frameId);
|
|
2534
|
-
}, [livePaginationCursor]);
|
|
2535
|
-
useEffect9(() => {
|
|
2536
|
-
const { livePaginationCursor: livePaginationCursor2, livePagination } = getComponentState();
|
|
2537
|
-
if (!scrollbars.vertical && livePagination) {
|
|
2538
|
-
updateCursorId(livePaginationCursor2);
|
|
2539
|
-
}
|
|
2540
|
-
}, [scrollbars.vertical]);
|
|
2541
|
-
useEffect9(() => {
|
|
2542
|
-
updateCursorId(scrollBottomId);
|
|
2543
|
-
}, [scrollBottomId]);
|
|
2544
|
-
const depsObject = {
|
|
2545
|
-
sortInfo,
|
|
2546
|
-
groupRowsBy,
|
|
2547
|
-
pivotBy,
|
|
2548
|
-
cursorId
|
|
2549
|
-
};
|
|
2550
|
-
useEffectWithChanges(() => {
|
|
2551
|
-
if (cursorId === void 0) {
|
|
2552
|
-
return;
|
|
2553
|
-
}
|
|
2554
|
-
notifyDataParamsChanged(getComponentState(), actions);
|
|
2555
|
-
}, depsObject);
|
|
2556
|
-
}
|
|
2397
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState4 } from "react";
|
|
2557
2398
|
|
|
2558
|
-
// src/
|
|
2559
|
-
var normalizeSortInfo = (sortInfo) => {
|
|
2560
|
-
sortInfo = sortInfo != null ? sortInfo : [];
|
|
2561
|
-
return Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
|
-
// src/components/hooks/useOnce.ts
|
|
2565
|
-
import { useMemo as useMemo4 } from "react";
|
|
2399
|
+
// src/utils/DeepMap/once.ts
|
|
2566
2400
|
function once(fn) {
|
|
2567
2401
|
let called = false;
|
|
2568
2402
|
let result = null;
|
|
@@ -2576,14 +2410,8 @@ function once(fn) {
|
|
|
2576
2410
|
};
|
|
2577
2411
|
return onceFn;
|
|
2578
2412
|
}
|
|
2579
|
-
function useOnce(fn) {
|
|
2580
|
-
const onceFn = useMemo4(() => {
|
|
2581
|
-
return once(fn);
|
|
2582
|
-
}, []);
|
|
2583
|
-
return onceFn();
|
|
2584
|
-
}
|
|
2585
2413
|
|
|
2586
|
-
// src/utils/DeepMap.ts
|
|
2414
|
+
// src/utils/DeepMap/index.ts
|
|
2587
2415
|
var SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
2588
2416
|
var DeepMap = class {
|
|
2589
2417
|
constructor(initial) {
|
|
@@ -2624,6 +2452,13 @@ var DeepMap = class {
|
|
|
2624
2452
|
});
|
|
2625
2453
|
}
|
|
2626
2454
|
}
|
|
2455
|
+
static clone(map2) {
|
|
2456
|
+
const clone = new DeepMap();
|
|
2457
|
+
map2.visit((pair, keys) => {
|
|
2458
|
+
clone.set(keys, pair.value);
|
|
2459
|
+
});
|
|
2460
|
+
return clone;
|
|
2461
|
+
}
|
|
2627
2462
|
set(keys, value) {
|
|
2628
2463
|
let currentMap = this.map;
|
|
2629
2464
|
if (!keys.length) {
|
|
@@ -2828,285 +2663,141 @@ var DeepMap = class {
|
|
|
2828
2663
|
}
|
|
2829
2664
|
};
|
|
2830
2665
|
|
|
2831
|
-
// src/components/DataSource/GroupRowsState.ts
|
|
2832
|
-
var GroupRowsState = class {
|
|
2833
|
-
constructor(state) {
|
|
2834
|
-
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
2835
|
-
}
|
|
2836
|
-
getState() {
|
|
2837
|
-
var _a, _b, _c, _d;
|
|
2838
|
-
return {
|
|
2839
|
-
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
2840
|
-
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
2841
|
-
};
|
|
2842
|
-
}
|
|
2843
|
-
destroy() {
|
|
2844
|
-
var _a, _b;
|
|
2845
|
-
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
2846
|
-
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
2847
|
-
delete this.expandedMap;
|
|
2848
|
-
delete this.collapsedMap;
|
|
2849
|
-
}
|
|
2850
|
-
update(state) {
|
|
2851
|
-
var _a, _b, _c, _d;
|
|
2852
|
-
this.initialState = state;
|
|
2853
|
-
const { collapsedRows, expandedRows } = this.initialState;
|
|
2854
|
-
this.collapsedAll = collapsedRows === true;
|
|
2855
|
-
this.expandedAll = expandedRows === true;
|
|
2856
|
-
if (this.collapsedAll && this.expandedAll) {
|
|
2857
|
-
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
2858
|
-
}
|
|
2859
|
-
if (collapsedRows !== true) {
|
|
2860
|
-
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
2861
|
-
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
2862
|
-
}
|
|
2863
|
-
if (expandedRows !== true) {
|
|
2864
|
-
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
2865
|
-
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
2866
|
-
}
|
|
2867
|
-
}
|
|
2868
|
-
areAllCollapsed() {
|
|
2869
|
-
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
2870
|
-
}
|
|
2871
|
-
areAllExpanded() {
|
|
2872
|
-
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
2873
|
-
}
|
|
2874
|
-
collapseAll() {
|
|
2875
|
-
this.update({
|
|
2876
|
-
collapsedRows: true,
|
|
2877
|
-
expandedRows: []
|
|
2878
|
-
});
|
|
2879
|
-
}
|
|
2880
|
-
expandAll() {
|
|
2881
|
-
this.update({
|
|
2882
|
-
expandedRows: true,
|
|
2883
|
-
collapsedRows: []
|
|
2884
|
-
});
|
|
2885
|
-
}
|
|
2886
|
-
isGroupRowExpanded(keys) {
|
|
2887
|
-
var _a, _b;
|
|
2888
|
-
if (this.expandedAll === true) {
|
|
2889
|
-
if (this.collapsedAll === true) {
|
|
2890
|
-
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
2891
|
-
}
|
|
2892
|
-
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
2893
|
-
}
|
|
2894
|
-
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
2895
|
-
}
|
|
2896
|
-
isGroupRowCollapsed(keys) {
|
|
2897
|
-
return !this.isGroupRowExpanded(keys);
|
|
2898
|
-
}
|
|
2899
|
-
setGroupRowExpanded(keys, shouldExpand) {
|
|
2900
|
-
var _a;
|
|
2901
|
-
if (shouldExpand === this.isGroupRowExpanded(keys)) {
|
|
2902
|
-
return;
|
|
2903
|
-
}
|
|
2904
|
-
if (shouldExpand) {
|
|
2905
|
-
if (this.collapsedAll === true) {
|
|
2906
|
-
if (!this.expandedMap) {
|
|
2907
|
-
throw `No expandedMap found when trying to expand group row ${keys.join(",")}`;
|
|
2908
|
-
}
|
|
2909
|
-
this.expandedMap.set(keys, true);
|
|
2910
|
-
} else if (this.expandedAll === true) {
|
|
2911
|
-
if (!this.collapsedMap) {
|
|
2912
|
-
throw `No collapsedMap found when trying to expand group row ${keys.join(",")}`;
|
|
2913
|
-
}
|
|
2914
|
-
this.collapsedMap.delete(keys);
|
|
2915
|
-
}
|
|
2916
|
-
} else {
|
|
2917
|
-
if (this.expandedAll === true) {
|
|
2918
|
-
if (!this.collapsedMap) {
|
|
2919
|
-
throw `No collapsedMap found when trying to collapse group row ${keys.join(",")}`;
|
|
2920
|
-
}
|
|
2921
|
-
this.collapsedMap.set(keys, true);
|
|
2922
|
-
} else if (this.collapsedAll === true) {
|
|
2923
|
-
if (!this.expandedMap) {
|
|
2924
|
-
throw `No expandedMap found when trying to collapse group row ${keys.join(",")}`;
|
|
2925
|
-
}
|
|
2926
|
-
(_a = this.expandedMap) == null ? void 0 : _a.delete(keys);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
collapseGroupRow(keys) {
|
|
2931
|
-
this.setGroupRowExpanded(keys, false);
|
|
2932
|
-
}
|
|
2933
|
-
expandGroupRow(keys) {
|
|
2934
|
-
this.setGroupRowExpanded(keys, true);
|
|
2935
|
-
}
|
|
2936
|
-
toggleGroupRow(keys) {
|
|
2937
|
-
this.setGroupRowExpanded(keys, !this.isGroupRowExpanded(keys));
|
|
2938
|
-
}
|
|
2939
|
-
};
|
|
2940
|
-
|
|
2941
|
-
// src/utils/shallowEqualObjects.ts
|
|
2942
|
-
function shallowEqualObjects(objA, objB) {
|
|
2943
|
-
if (objA === objB) {
|
|
2944
|
-
return true;
|
|
2945
|
-
}
|
|
2946
|
-
if (!objA || !objB) {
|
|
2947
|
-
return false;
|
|
2948
|
-
}
|
|
2949
|
-
var aKeys = Object.keys(objA);
|
|
2950
|
-
var bKeys = Object.keys(objB);
|
|
2951
|
-
var len = aKeys.length;
|
|
2952
|
-
if (bKeys.length !== len) {
|
|
2953
|
-
return false;
|
|
2954
|
-
}
|
|
2955
|
-
for (var i = 0; i < len; i++) {
|
|
2956
|
-
var key = aKeys[i];
|
|
2957
|
-
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
2958
|
-
return false;
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
return true;
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
// src/components/utils/discardCallsWithEqualArg.ts
|
|
2965
|
-
var map = new WeakMap();
|
|
2966
|
-
var getCompareDefault = (a) => a;
|
|
2967
|
-
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject2) {
|
|
2968
|
-
map.set(fn, {
|
|
2969
|
-
lastCallTime: 0,
|
|
2970
|
-
lastCallArg: null
|
|
2971
|
-
});
|
|
2972
|
-
const getCompare = getCompareObject2 != null ? getCompareObject2 : getCompareDefault;
|
|
2973
|
-
return (arg) => {
|
|
2974
|
-
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
2975
|
-
lastCallTime: 0,
|
|
2976
|
-
lastCallArg: null
|
|
2977
|
-
};
|
|
2978
|
-
const now = Date.now();
|
|
2979
|
-
const diff = now - lastCallTime;
|
|
2980
|
-
const objectsEqual = shallowEqualObjects(getCompare(lastCallArg), getCompare(arg));
|
|
2981
|
-
if (diff < timeframe && objectsEqual) {
|
|
2982
|
-
return;
|
|
2983
|
-
}
|
|
2984
|
-
map.set(fn, {
|
|
2985
|
-
lastCallTime: now,
|
|
2986
|
-
lastCallArg: arg
|
|
2987
|
-
});
|
|
2988
|
-
fn(arg);
|
|
2989
|
-
};
|
|
2990
|
-
}
|
|
2991
|
-
|
|
2992
|
-
// src/components/DataSource/state/getInitialState.ts
|
|
2993
|
-
function initSetupState2() {
|
|
2994
|
-
const now = Date.now();
|
|
2995
|
-
const originalDataArray = [];
|
|
2996
|
-
const dataArray = [];
|
|
2997
|
-
return {
|
|
2998
|
-
dataParams: void 0,
|
|
2999
|
-
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3000
|
-
pivotTotalColumnPosition: "end",
|
|
3001
|
-
originalDataArray,
|
|
3002
|
-
scrollBottomId: Symbol("scrollBottomId"),
|
|
3003
|
-
pivotColumns: void 0,
|
|
3004
|
-
pivotColumnGroups: void 0,
|
|
3005
|
-
dataArray,
|
|
3006
|
-
updatedAt: now,
|
|
3007
|
-
groupedAt: 0,
|
|
3008
|
-
sortedAt: 0,
|
|
3009
|
-
reducedAt: now,
|
|
3010
|
-
generateGroupRows: true,
|
|
3011
|
-
aggregationReducers: void 0,
|
|
3012
|
-
groupDeepMap: void 0,
|
|
3013
|
-
postSortDataArray: void 0,
|
|
3014
|
-
postGroupDataArray: void 0,
|
|
3015
|
-
lastSortDataArray: void 0,
|
|
3016
|
-
lastGroupDataArray: void 0
|
|
3017
|
-
};
|
|
3018
|
-
}
|
|
3019
|
-
function getCompareObject(dataParams) {
|
|
3020
|
-
const obj = __spreadValues({}, dataParams);
|
|
3021
|
-
delete obj.originalDataArray;
|
|
3022
|
-
return obj;
|
|
3023
|
-
}
|
|
3024
|
-
var forwardProps3 = () => {
|
|
3025
|
-
return {
|
|
3026
|
-
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObject) : void 0,
|
|
3027
|
-
remoteCount: 1,
|
|
3028
|
-
data: 1,
|
|
3029
|
-
pivotBy: 1,
|
|
3030
|
-
primaryKey: 1,
|
|
3031
|
-
livePagination: 1,
|
|
3032
|
-
livePaginationCursor: 1,
|
|
3033
|
-
loading: (loading) => loading != null ? loading : false,
|
|
3034
|
-
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo),
|
|
3035
|
-
groupRowsBy: (groupRowsBy) => groupRowsBy != null ? groupRowsBy : [],
|
|
3036
|
-
groupRowsState: (groupRowsState) => {
|
|
3037
|
-
return groupRowsState || new GroupRowsState({
|
|
3038
|
-
expandedRows: true,
|
|
3039
|
-
collapsedRows: []
|
|
3040
|
-
});
|
|
3041
|
-
}
|
|
3042
|
-
};
|
|
3043
|
-
};
|
|
3044
|
-
function mapPropsToState2(params) {
|
|
3045
|
-
const { props } = params;
|
|
3046
|
-
const controlledSort = isControlledValue(props.sortInfo);
|
|
3047
|
-
return {
|
|
3048
|
-
controlledSort,
|
|
3049
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3050
|
-
};
|
|
3051
|
-
}
|
|
3052
|
-
function getInterceptActions() {
|
|
3053
|
-
return {
|
|
3054
|
-
sortInfo: (sortInfo, { actions, state }) => {
|
|
3055
|
-
const dataParams = buildDataSourceDataParams(state);
|
|
3056
|
-
dataParams.sortInfo = sortInfo;
|
|
3057
|
-
actions.dataParams = dataParams;
|
|
3058
|
-
}
|
|
3059
|
-
};
|
|
3060
|
-
}
|
|
3061
|
-
|
|
3062
2666
|
// src/utils/groupAndPivot/index.ts
|
|
2667
|
+
var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
|
|
3063
2668
|
function DEFAULT_TO_KEY(value) {
|
|
3064
2669
|
return value;
|
|
3065
2670
|
}
|
|
3066
2671
|
function initReducers(reducers) {
|
|
3067
|
-
if (!reducers || !reducers.length) {
|
|
3068
|
-
return
|
|
2672
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
2673
|
+
return {};
|
|
3069
2674
|
}
|
|
3070
|
-
|
|
2675
|
+
const result = {};
|
|
2676
|
+
for (let key in reducers)
|
|
2677
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2678
|
+
result[key] = reducers[key].initialValue;
|
|
2679
|
+
}
|
|
2680
|
+
return result;
|
|
3071
2681
|
}
|
|
3072
2682
|
function computeReducersFor(data, reducers, reducerResults) {
|
|
3073
|
-
|
|
2683
|
+
var _a, _b;
|
|
2684
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
3074
2685
|
return;
|
|
3075
2686
|
}
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
2687
|
+
for (let key in reducers)
|
|
2688
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2689
|
+
const reducer = reducers[key];
|
|
2690
|
+
if (typeof reducer.reducer !== "function") {
|
|
2691
|
+
continue;
|
|
2692
|
+
}
|
|
2693
|
+
const currentValue = reducerResults[key];
|
|
2694
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
|
|
2695
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
2696
|
+
}
|
|
3080
2697
|
}
|
|
3081
|
-
function
|
|
2698
|
+
function lazyGroup(groupParams, rootData) {
|
|
3082
2699
|
const {
|
|
3083
|
-
|
|
3084
|
-
defaultToKey = DEFAULT_TO_KEY,
|
|
2700
|
+
reducers = {},
|
|
3085
2701
|
pivot,
|
|
3086
|
-
|
|
2702
|
+
groupBy,
|
|
2703
|
+
mappings
|
|
3087
2704
|
} = groupParams;
|
|
3088
|
-
const groupByLength = groupBy.length;
|
|
3089
|
-
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3090
2705
|
const deepMap = new DeepMap();
|
|
3091
|
-
|
|
2706
|
+
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
2707
|
+
const last = pivotIndex === pivot2.length - 1;
|
|
2708
|
+
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
2709
|
+
for (var k in values)
|
|
2710
|
+
if (values.hasOwnProperty(k)) {
|
|
2711
|
+
const pivotKey = k;
|
|
2712
|
+
currentPivotKeys2.push(pivotKey);
|
|
2713
|
+
topLevelPivotColumns.set(currentPivotKeys2, true);
|
|
2714
|
+
pivotDeepMap.set(currentPivotKeys2, {
|
|
2715
|
+
reducerResults: values[k][(mappings == null ? void 0 : mappings.totals) || "totals"] || {},
|
|
2716
|
+
items: []
|
|
2717
|
+
});
|
|
2718
|
+
if (!last) {
|
|
2719
|
+
traverseValues(pivotDeepMap, values[k], pivot2, pivotIndex + 1, currentPivotKeys2);
|
|
2720
|
+
}
|
|
2721
|
+
currentPivotKeys2.pop();
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
3092
2725
|
let currentPivotKeys = [];
|
|
3093
2726
|
const initialReducerValue = initReducers(reducers);
|
|
3094
|
-
const globalReducerResults =
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
if (!deepMap.has(currentGroupKeys)) {
|
|
3102
|
-
const deepMapGroupValue = {
|
|
2727
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2728
|
+
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2729
|
+
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2730
|
+
const dataArray = lazyGroupRowInfo.items;
|
|
2731
|
+
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2732
|
+
if (!dataArray[i]) {
|
|
2733
|
+
const deepMapGroupValue2 = {
|
|
3103
2734
|
items: [],
|
|
3104
|
-
reducerResults:
|
|
2735
|
+
reducerResults: {}
|
|
3105
2736
|
};
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
2737
|
+
deepMap.set([...currentGroupKeys, `not-loaded-yet-${i}`], deepMapGroupValue2);
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
const dataObject = dataArray[i].data;
|
|
2741
|
+
const dataKeys = dataArray[i].keys;
|
|
2742
|
+
let item = dataObject;
|
|
2743
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
2744
|
+
const key = item[groupByProperty];
|
|
2745
|
+
currentGroupKeys.push(key);
|
|
2746
|
+
const deepMapGroupValue = {
|
|
2747
|
+
items: [],
|
|
2748
|
+
reducerResults: dataArray[i].aggregations || {}
|
|
2749
|
+
};
|
|
2750
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
2751
|
+
if (pivot) {
|
|
2752
|
+
const pivotDeepMap = deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2753
|
+
const pivotContainer = dataArray[i].pivot;
|
|
2754
|
+
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
2755
|
+
}
|
|
2756
|
+
currentGroupKeys.pop();
|
|
2757
|
+
}
|
|
2758
|
+
next == null ? void 0 : next();
|
|
2759
|
+
});
|
|
2760
|
+
const result = {
|
|
2761
|
+
deepMap,
|
|
2762
|
+
groupParams,
|
|
2763
|
+
initialData: rootData,
|
|
2764
|
+
reducerResults: globalReducerResults
|
|
2765
|
+
};
|
|
2766
|
+
if (pivot) {
|
|
2767
|
+
result.topLevelPivotColumns = topLevelPivotColumns;
|
|
2768
|
+
result.pivot = pivot;
|
|
2769
|
+
}
|
|
2770
|
+
return result;
|
|
2771
|
+
}
|
|
2772
|
+
function group(groupParams, data) {
|
|
2773
|
+
const {
|
|
2774
|
+
groupBy,
|
|
2775
|
+
defaultToKey = DEFAULT_TO_KEY,
|
|
2776
|
+
pivot,
|
|
2777
|
+
reducers
|
|
2778
|
+
} = groupParams;
|
|
2779
|
+
const groupByLength = groupBy.length;
|
|
2780
|
+
const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
|
|
2781
|
+
const deepMap = new DeepMap();
|
|
2782
|
+
let currentGroupKeys = [];
|
|
2783
|
+
let currentPivotKeys = [];
|
|
2784
|
+
const initialReducerValue = initReducers(reducers);
|
|
2785
|
+
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
2786
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
2787
|
+
let item = data[i];
|
|
2788
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
2789
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
2790
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
2791
|
+
currentGroupKeys.push(key);
|
|
2792
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
2793
|
+
const deepMapGroupValue = {
|
|
2794
|
+
items: [],
|
|
2795
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
2796
|
+
};
|
|
2797
|
+
if (pivot) {
|
|
2798
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
2799
|
+
}
|
|
2800
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3110
2801
|
}
|
|
3111
2802
|
const {
|
|
3112
2803
|
items: currentGroupItems,
|
|
@@ -3125,7 +2816,7 @@ function group(groupParams, data) {
|
|
|
3125
2816
|
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3126
2817
|
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3127
2818
|
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3128
|
-
reducerResults:
|
|
2819
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3129
2820
|
items: []
|
|
3130
2821
|
});
|
|
3131
2822
|
}
|
|
@@ -3182,196 +2873,870 @@ function flatten(groupResult) {
|
|
|
3182
2873
|
const items = deepMap.get(key).items;
|
|
3183
2874
|
acc.push(...items);
|
|
3184
2875
|
}
|
|
3185
|
-
return acc;
|
|
3186
|
-
}, result);
|
|
3187
|
-
return result;
|
|
3188
|
-
}
|
|
3189
|
-
function getEnhancedGroupData(options, deepMapValue) {
|
|
3190
|
-
const { groupBy, groupKeys, collapsed, parents } = options;
|
|
3191
|
-
const groupNesting = groupKeys.length;
|
|
3192
|
-
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
2876
|
+
return acc;
|
|
2877
|
+
}, result);
|
|
2878
|
+
return result;
|
|
2879
|
+
}
|
|
2880
|
+
function getEnhancedGroupData(options, deepMapValue) {
|
|
2881
|
+
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2882
|
+
const groupNesting = groupKeys.length;
|
|
2883
|
+
const { items: groupItems, reducerResults, pivotDeepMap } = deepMapValue;
|
|
2884
|
+
let data = null;
|
|
2885
|
+
if (Object.keys(reducerResults).length > 0) {
|
|
2886
|
+
data = {};
|
|
2887
|
+
for (let key in reducers)
|
|
2888
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2889
|
+
const reducer = reducers[key];
|
|
2890
|
+
const field = reducer.field;
|
|
2891
|
+
if (field) {
|
|
2892
|
+
data[field] = reducerResults[key];
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
const enhancedGroupData = {
|
|
2897
|
+
data,
|
|
2898
|
+
groupCount: groupItems.length,
|
|
2899
|
+
groupData: groupItems,
|
|
2900
|
+
groupKeys,
|
|
2901
|
+
id: groupKeys,
|
|
2902
|
+
collapsed,
|
|
2903
|
+
parents,
|
|
2904
|
+
collapsedChildrenCount: 0,
|
|
2905
|
+
collapsedGroupsCount: 0,
|
|
2906
|
+
indexInParentGroups: options.indexInParentGroups,
|
|
2907
|
+
indexInGroup: options.indexInGroup,
|
|
2908
|
+
indexInAll: options.indexInAll,
|
|
2909
|
+
value: groupKeys[groupKeys.length - 1],
|
|
2910
|
+
groupBy: groupBy.slice(0, groupNesting),
|
|
2911
|
+
isGroupRow: true,
|
|
2912
|
+
pivotValuesMap: pivotDeepMap,
|
|
2913
|
+
groupNesting,
|
|
2914
|
+
reducerResults
|
|
2915
|
+
};
|
|
2916
|
+
return enhancedGroupData;
|
|
2917
|
+
}
|
|
2918
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
2919
|
+
if (reducers) {
|
|
2920
|
+
for (let key in reducers)
|
|
2921
|
+
if (reducers.hasOwnProperty(key)) {
|
|
2922
|
+
const reducer = reducers[key];
|
|
2923
|
+
if (reducer.done) {
|
|
2924
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
return reducerResults;
|
|
2929
|
+
}
|
|
2930
|
+
function enhancedFlatten(param) {
|
|
2931
|
+
const {
|
|
2932
|
+
groupResult,
|
|
2933
|
+
toPrimaryKey,
|
|
2934
|
+
groupRowsState,
|
|
2935
|
+
generateGroupRows,
|
|
2936
|
+
reducers = {}
|
|
2937
|
+
} = param;
|
|
2938
|
+
const { groupParams, deepMap, pivot } = groupResult;
|
|
2939
|
+
const { groupBy } = groupParams;
|
|
2940
|
+
const groupByStrings = groupBy.map((g) => g.field);
|
|
2941
|
+
const result = [];
|
|
2942
|
+
const parents = [];
|
|
2943
|
+
const indexInParentGroups = [];
|
|
2944
|
+
deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
|
|
2945
|
+
var _a;
|
|
2946
|
+
const items = deepMapValue.items;
|
|
2947
|
+
const groupNesting = groupKeys.length;
|
|
2948
|
+
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
2949
|
+
const enhancedGroupData = getEnhancedGroupData({
|
|
2950
|
+
groupBy: groupByStrings,
|
|
2951
|
+
parents: Array.from(parents),
|
|
2952
|
+
reducers,
|
|
2953
|
+
indexInGroup,
|
|
2954
|
+
indexInParentGroups: Array.from(indexInParentGroups),
|
|
2955
|
+
indexInAll: result.length,
|
|
2956
|
+
groupKeys,
|
|
2957
|
+
collapsed
|
|
2958
|
+
}, deepMapValue);
|
|
2959
|
+
const include = generateGroupRows || collapsed;
|
|
2960
|
+
if (include) {
|
|
2961
|
+
result.push(enhancedGroupData);
|
|
2962
|
+
}
|
|
2963
|
+
if (collapsed) {
|
|
2964
|
+
parents.forEach((parent) => {
|
|
2965
|
+
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
2966
|
+
parent.collapsedGroupsCount += 1;
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
indexInParentGroups.push(indexInGroup);
|
|
2970
|
+
parents.push(enhancedGroupData);
|
|
2971
|
+
if (!collapsed) {
|
|
2972
|
+
if (!next) {
|
|
2973
|
+
if (!pivot) {
|
|
2974
|
+
const startIndex = result.length;
|
|
2975
|
+
result.push(...items.map((item, index) => {
|
|
2976
|
+
return {
|
|
2977
|
+
id: toPrimaryKey(item),
|
|
2978
|
+
data: item,
|
|
2979
|
+
isGroupRow: false,
|
|
2980
|
+
collapsed: false,
|
|
2981
|
+
groupKeys,
|
|
2982
|
+
parents: Array.from(parents),
|
|
2983
|
+
indexInParentGroups: [...indexInParentGroups, index],
|
|
2984
|
+
indexInGroup: index,
|
|
2985
|
+
indexInAll: startIndex + index,
|
|
2986
|
+
groupBy: groupByStrings,
|
|
2987
|
+
groupNesting,
|
|
2988
|
+
groupCount: enhancedGroupData.groupCount
|
|
2989
|
+
};
|
|
2990
|
+
}));
|
|
2991
|
+
}
|
|
2992
|
+
} else {
|
|
2993
|
+
next();
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
parents.pop();
|
|
2997
|
+
indexInParentGroups.pop();
|
|
2998
|
+
});
|
|
2999
|
+
return {
|
|
3000
|
+
data: result
|
|
3001
|
+
};
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
// src/components/hooks/useEffectWithChanges.ts
|
|
3005
|
+
import { useEffect as useEffect7, useRef as useRef5 } from "react";
|
|
3006
|
+
function useEffectWithChanges(fn, deps) {
|
|
3007
|
+
const prevRef = useRef5({});
|
|
3008
|
+
const oldValuesRef = useRef5({});
|
|
3009
|
+
const oldValues = oldValuesRef.current;
|
|
3010
|
+
const changesRef = useRef5({});
|
|
3011
|
+
const changes = changesRef.current;
|
|
3012
|
+
const useEffectDeps = [];
|
|
3013
|
+
for (let k in deps) {
|
|
3014
|
+
if (deps.hasOwnProperty(k)) {
|
|
3015
|
+
if (deps[k] !== prevRef.current[k]) {
|
|
3016
|
+
changes[k] = deps[k];
|
|
3017
|
+
oldValues[k] = prevRef.current[k];
|
|
3018
|
+
}
|
|
3019
|
+
useEffectDeps.push(deps[k]);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
prevRef.current = deps;
|
|
3023
|
+
useEffect7(() => {
|
|
3024
|
+
const changes2 = changesRef.current;
|
|
3025
|
+
const result = fn(changes2, oldValues);
|
|
3026
|
+
changesRef.current = {};
|
|
3027
|
+
oldValuesRef.current = {};
|
|
3028
|
+
return result;
|
|
3029
|
+
}, useEffectDeps);
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
3033
|
+
var SKIP_DATA_CHANGES_KEYS = {
|
|
3034
|
+
originalDataArray: true,
|
|
3035
|
+
changes: true
|
|
3036
|
+
};
|
|
3037
|
+
function buildDataSourceDataParams(componentState, overrides) {
|
|
3038
|
+
var _a, _b;
|
|
3039
|
+
const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
3040
|
+
const dataSourceParams = {
|
|
3041
|
+
originalDataArray: componentState.originalDataArray,
|
|
3042
|
+
sortInfo,
|
|
3043
|
+
groupBy: componentState.groupBy,
|
|
3044
|
+
pivotBy: componentState.pivotBy,
|
|
3045
|
+
aggregationReducers: componentState.aggregationReducers
|
|
3046
|
+
};
|
|
3047
|
+
if (componentState.livePagination !== void 0) {
|
|
3048
|
+
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3049
|
+
dataSourceParams.cursorId = componentState.cursorId;
|
|
3050
|
+
}
|
|
3051
|
+
if (componentState.fullLazyLoad) {
|
|
3052
|
+
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3053
|
+
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3054
|
+
dataSourceParams.lazyLoadStartIndex = 0;
|
|
3055
|
+
}
|
|
3056
|
+
dataSourceParams.groupKeys = [];
|
|
3057
|
+
}
|
|
3058
|
+
if (overrides) {
|
|
3059
|
+
Object.assign(dataSourceParams, overrides);
|
|
3060
|
+
}
|
|
3061
|
+
const changes = {};
|
|
3062
|
+
const oldDataSourceParams = componentState.dataParams || {};
|
|
3063
|
+
for (let k in dataSourceParams) {
|
|
3064
|
+
if (dataSourceParams.hasOwnProperty(k) && !SKIP_DATA_CHANGES_KEYS[k]) {
|
|
3065
|
+
const key = k;
|
|
3066
|
+
if (dataSourceParams[key] !== oldDataSourceParams[key]) {
|
|
3067
|
+
changes[key] = true;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
dataSourceParams.changes = changes;
|
|
3072
|
+
return dataSourceParams;
|
|
3073
|
+
}
|
|
3074
|
+
function loadData(data, componentState, actions, overrides) {
|
|
3075
|
+
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3076
|
+
if (typeof data === "function") {
|
|
3077
|
+
data = data(dataParams);
|
|
3078
|
+
}
|
|
3079
|
+
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3080
|
+
if (dataIsPromise) {
|
|
3081
|
+
actions.loading = true;
|
|
3082
|
+
}
|
|
3083
|
+
Promise.resolve(data).then((dataParam) => {
|
|
3084
|
+
var _a, _b, _c;
|
|
3085
|
+
let dataArray = [];
|
|
3086
|
+
let skipAssign = false;
|
|
3087
|
+
if (Array.isArray(dataParam.data)) {
|
|
3088
|
+
const remoteData = dataParam;
|
|
3089
|
+
dataArray = remoteData.data;
|
|
3090
|
+
if (remoteData.livePaginationCursor !== void 0) {
|
|
3091
|
+
actions.livePaginationCursor = remoteData.livePaginationCursor;
|
|
3092
|
+
}
|
|
3093
|
+
if (remoteData.mappings) {
|
|
3094
|
+
actions.pivotMappings = remoteData.mappings;
|
|
3095
|
+
}
|
|
3096
|
+
if (componentState.fullLazyLoad && dataParams.groupKeys) {
|
|
3097
|
+
const lazyGroupData = DeepMap.clone(componentState.originalLazyGroupData);
|
|
3098
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3099
|
+
const newGroupRowInfo = {
|
|
3100
|
+
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
3101
|
+
items: dataArray
|
|
3102
|
+
};
|
|
3103
|
+
if (dataParams.lazyLoadBatchSize) {
|
|
3104
|
+
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3105
|
+
const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
|
|
3106
|
+
items: [],
|
|
3107
|
+
totalCount: newGroupRowInfo.totalCount
|
|
3108
|
+
};
|
|
3109
|
+
currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
|
|
3110
|
+
const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
|
|
3111
|
+
const end = start + ((_c = dataParams.lazyLoadBatchSize) != null ? _c : dataArray.length);
|
|
3112
|
+
for (let i = start; i < end; i++) {
|
|
3113
|
+
currentGroupRowInfo.items[i] = newGroupRowInfo.items[i - start];
|
|
3114
|
+
}
|
|
3115
|
+
if (!existingGroupRowInfo) {
|
|
3116
|
+
lazyGroupData.set(key, currentGroupRowInfo);
|
|
3117
|
+
}
|
|
3118
|
+
} else {
|
|
3119
|
+
lazyGroupData.set(key, newGroupRowInfo);
|
|
3120
|
+
}
|
|
3121
|
+
skipAssign = true;
|
|
3122
|
+
actions.originalLazyGroupData = lazyGroupData;
|
|
3123
|
+
}
|
|
3124
|
+
} else {
|
|
3125
|
+
dataArray = dataParam;
|
|
3126
|
+
}
|
|
3127
|
+
if (!skipAssign) {
|
|
3128
|
+
actions.originalDataArray = dataArray;
|
|
3129
|
+
}
|
|
3130
|
+
if (dataIsPromise) {
|
|
3131
|
+
actions.loading = false;
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
}
|
|
3135
|
+
function useLoadData() {
|
|
3136
|
+
const {
|
|
3137
|
+
getComponentState,
|
|
3138
|
+
componentActions: actions,
|
|
3139
|
+
componentState
|
|
3140
|
+
} = useComponentState();
|
|
3141
|
+
const {
|
|
3142
|
+
data,
|
|
3143
|
+
notifyScrollbarsChange,
|
|
3144
|
+
sortInfo,
|
|
3145
|
+
groupBy,
|
|
3146
|
+
pivotBy,
|
|
3147
|
+
livePagination,
|
|
3148
|
+
livePaginationCursor,
|
|
3149
|
+
cursorId: stateCursorId,
|
|
3150
|
+
lazyLoadBatchSize,
|
|
3151
|
+
notifyScrollStop
|
|
3152
|
+
} = componentState;
|
|
3153
|
+
const [scrollbars, setScrollbars] = useState4({
|
|
3154
|
+
vertical: false,
|
|
3155
|
+
horizontal: false
|
|
3156
|
+
});
|
|
3157
|
+
const scrollbarsRef = useRef6(scrollbars);
|
|
3158
|
+
useEffect8(() => {
|
|
3159
|
+
notifyScrollbarsChange.onChange((scrollbars2) => {
|
|
3160
|
+
if (!scrollbars2) {
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
scrollbarsRef.current = scrollbars2;
|
|
3164
|
+
setScrollbars(scrollbars2);
|
|
3165
|
+
});
|
|
3166
|
+
return () => notifyScrollbarsChange.destroy();
|
|
3167
|
+
}, [notifyScrollbarsChange]);
|
|
3168
|
+
useEffect8(() => {
|
|
3169
|
+
const frameId = requestAnimationFrame(() => {
|
|
3170
|
+
var _a;
|
|
3171
|
+
if (!((_a = scrollbarsRef.current) == null ? void 0 : _a.vertical) && livePaginationCursor) {
|
|
3172
|
+
actions.cursorId = livePaginationCursor;
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
return () => cancelAnimationFrame(frameId);
|
|
3176
|
+
}, [livePaginationCursor]);
|
|
3177
|
+
useEffect8(() => {
|
|
3178
|
+
const { livePaginationCursor: livePaginationCursor2, livePagination: livePagination2 } = getComponentState();
|
|
3179
|
+
if (!scrollbars.vertical && livePagination2) {
|
|
3180
|
+
if (livePaginationCursor2) {
|
|
3181
|
+
actions.cursorId = livePaginationCursor2;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
}, [scrollbars.vertical]);
|
|
3185
|
+
const depsObject = {
|
|
3186
|
+
sortInfo,
|
|
3187
|
+
groupBy,
|
|
3188
|
+
pivotBy,
|
|
3189
|
+
cursorId: livePagination ? stateCursorId : null
|
|
3190
|
+
};
|
|
3191
|
+
const initialRef = useRef6(true);
|
|
3192
|
+
useEffect8(() => {
|
|
3193
|
+
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3194
|
+
return notifyScrollStop.onChange((param) => {
|
|
3195
|
+
console.log("scroll stop", param);
|
|
3196
|
+
if (!param) {
|
|
3197
|
+
return;
|
|
3198
|
+
}
|
|
3199
|
+
const componentState2 = getComponentState();
|
|
3200
|
+
const {
|
|
3201
|
+
firstVisibleRowIndex: startIndex,
|
|
3202
|
+
lastVisibleRowIndex: endIndex
|
|
3203
|
+
} = param;
|
|
3204
|
+
const firstBatchStart = Math.floor(startIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3205
|
+
const lastBatchStart = Math.floor(endIndex / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3206
|
+
const isRowLoaded = (index) => componentState2.dataArray[index].data != null;
|
|
3207
|
+
for (let batchStartIndex = firstBatchStart; batchStartIndex <= lastBatchStart; batchStartIndex = batchStartIndex + lazyLoadBatchSize) {
|
|
3208
|
+
if (!isRowLoaded(batchStartIndex)) {
|
|
3209
|
+
loadData(componentState2.data, componentState2, actions, {
|
|
3210
|
+
lazyLoadBatchSize,
|
|
3211
|
+
lazyLoadStartIndex: batchStartIndex
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
return;
|
|
3218
|
+
}, [lazyLoadBatchSize]);
|
|
3219
|
+
useEffectWithChanges(() => {
|
|
3220
|
+
const componentState2 = getComponentState();
|
|
3221
|
+
if (typeof componentState2.data !== "function") {
|
|
3222
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3223
|
+
}
|
|
3224
|
+
}, { data });
|
|
3225
|
+
useEffectWithChanges(() => {
|
|
3226
|
+
const componentState2 = getComponentState();
|
|
3227
|
+
if (typeof componentState2.data === "function") {
|
|
3228
|
+
loadData(componentState2.data, componentState2, actions);
|
|
3229
|
+
}
|
|
3230
|
+
}, __spreadProps(__spreadValues({}, depsObject), { data }));
|
|
3231
|
+
useEffectWithChanges((_changes, _prevValues) => {
|
|
3232
|
+
const componentState2 = getComponentState();
|
|
3233
|
+
if (initialRef.current) {
|
|
3234
|
+
initialRef.current = false;
|
|
3235
|
+
actions.dataParams = buildDataSourceDataParams(componentState2);
|
|
3236
|
+
}
|
|
3237
|
+
}, depsObject);
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// src/components/DataSource/state/normalizeSortInfo.ts
|
|
3241
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
3242
|
+
var normalizeSortInfo = (initialSortInfo, weakMap) => {
|
|
3243
|
+
const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
|
|
3244
|
+
const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
|
|
3245
|
+
if (weakMap && weakMap.has(sortInfo)) {
|
|
3246
|
+
const prevResult = weakMap.get(sortInfo);
|
|
3247
|
+
if (prevResult && prevResult.length === result.length) {
|
|
3248
|
+
return prevResult;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
if (weakMap && sortInfo) {
|
|
3252
|
+
weakMap.set(sortInfo, result);
|
|
3253
|
+
}
|
|
3254
|
+
return result;
|
|
3255
|
+
};
|
|
3256
|
+
|
|
3257
|
+
// src/components/DataSource/GroupRowsState.ts
|
|
3258
|
+
var GroupRowsState = class {
|
|
3259
|
+
constructor(state) {
|
|
3260
|
+
this.update(state instanceof GroupRowsState ? state.getState() : state);
|
|
3261
|
+
}
|
|
3262
|
+
getState() {
|
|
3263
|
+
var _a, _b, _c, _d;
|
|
3264
|
+
return {
|
|
3265
|
+
expandedRows: this.expandedAll ? true : (_b = (_a = this.expandedMap) == null ? void 0 : _a.topDownKeys()) != null ? _b : [],
|
|
3266
|
+
collapsedRows: this.collapsedAll ? true : (_d = (_c = this.collapsedMap) == null ? void 0 : _c.topDownKeys()) != null ? _d : []
|
|
3267
|
+
};
|
|
3268
|
+
}
|
|
3269
|
+
destroy() {
|
|
3270
|
+
var _a, _b;
|
|
3271
|
+
(_a = this.expandedMap) == null ? void 0 : _a.clear();
|
|
3272
|
+
(_b = this.collapsedMap) == null ? void 0 : _b.clear();
|
|
3273
|
+
delete this.expandedMap;
|
|
3274
|
+
delete this.collapsedMap;
|
|
3275
|
+
}
|
|
3276
|
+
update(state) {
|
|
3277
|
+
var _a, _b, _c, _d;
|
|
3278
|
+
this.initialState = state;
|
|
3279
|
+
const { collapsedRows, expandedRows } = this.initialState;
|
|
3280
|
+
this.collapsedAll = collapsedRows === true;
|
|
3281
|
+
this.expandedAll = expandedRows === true;
|
|
3282
|
+
if (this.collapsedAll && this.expandedAll) {
|
|
3283
|
+
throw `Cannot have both collapsedRows and expandedRows be true!`;
|
|
3284
|
+
}
|
|
3285
|
+
if (collapsedRows !== true) {
|
|
3286
|
+
(_a = this.collapsedMap) == null ? void 0 : _a.clear();
|
|
3287
|
+
this.collapsedMap = (_b = this.collapsedMap) != null ? _b : new DeepMap(collapsedRows.map((keys) => [keys, true]));
|
|
3288
|
+
}
|
|
3289
|
+
if (expandedRows !== true) {
|
|
3290
|
+
(_c = this.expandedMap) == null ? void 0 : _c.clear();
|
|
3291
|
+
this.expandedMap = (_d = this.expandedMap) != null ? _d : new DeepMap(expandedRows.map((keys) => [keys, true]));
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
areAllCollapsed() {
|
|
3295
|
+
return this.collapsedAll && (this.expandedMap ? this.expandedMap.size === 0 : true);
|
|
3296
|
+
}
|
|
3297
|
+
areAllExpanded() {
|
|
3298
|
+
return this.expandedAll && (this.collapsedMap ? this.collapsedMap.size === 0 : true);
|
|
3299
|
+
}
|
|
3300
|
+
collapseAll() {
|
|
3301
|
+
this.update({
|
|
3302
|
+
collapsedRows: true,
|
|
3303
|
+
expandedRows: []
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
expandAll() {
|
|
3307
|
+
this.update({
|
|
3308
|
+
expandedRows: true,
|
|
3309
|
+
collapsedRows: []
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
isGroupRowExpanded(keys) {
|
|
3313
|
+
var _a, _b;
|
|
3314
|
+
if (this.expandedAll === true) {
|
|
3315
|
+
if (this.collapsedAll === true) {
|
|
3316
|
+
throw 'Cannot have both expandedRows and collapsedRows be "true"';
|
|
3317
|
+
}
|
|
3318
|
+
return !((_a = this.collapsedMap) == null ? void 0 : _a.has(keys));
|
|
3319
|
+
}
|
|
3320
|
+
return (_b = this.expandedMap) == null ? void 0 : _b.has(keys);
|
|
3321
|
+
}
|
|
3322
|
+
isGroupRowCollapsed(keys) {
|
|
3323
|
+
return !this.isGroupRowExpanded(keys);
|
|
3324
|
+
}
|
|
3325
|
+
setGroupRowExpanded(keys, shouldExpand) {
|
|
3326
|
+
var _a;
|
|
3327
|
+
if (shouldExpand === this.isGroupRowExpanded(keys)) {
|
|
3328
|
+
return;
|
|
3329
|
+
}
|
|
3330
|
+
if (shouldExpand) {
|
|
3331
|
+
if (this.collapsedAll === true) {
|
|
3332
|
+
if (!this.expandedMap) {
|
|
3333
|
+
throw `No expandedMap found when trying to expand group row ${keys.join(",")}`;
|
|
3334
|
+
}
|
|
3335
|
+
this.expandedMap.set(keys, true);
|
|
3336
|
+
} else if (this.expandedAll === true) {
|
|
3337
|
+
if (!this.collapsedMap) {
|
|
3338
|
+
throw `No collapsedMap found when trying to expand group row ${keys.join(",")}`;
|
|
3339
|
+
}
|
|
3340
|
+
this.collapsedMap.delete(keys);
|
|
3341
|
+
}
|
|
3342
|
+
} else {
|
|
3343
|
+
if (this.expandedAll === true) {
|
|
3344
|
+
if (!this.collapsedMap) {
|
|
3345
|
+
throw `No collapsedMap found when trying to collapse group row ${keys.join(",")}`;
|
|
3346
|
+
}
|
|
3347
|
+
this.collapsedMap.set(keys, true);
|
|
3348
|
+
} else if (this.collapsedAll === true) {
|
|
3349
|
+
if (!this.expandedMap) {
|
|
3350
|
+
throw `No expandedMap found when trying to collapse group row ${keys.join(",")}`;
|
|
3351
|
+
}
|
|
3352
|
+
(_a = this.expandedMap) == null ? void 0 : _a.delete(keys);
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
collapseGroupRow(keys) {
|
|
3357
|
+
this.setGroupRowExpanded(keys, false);
|
|
3358
|
+
}
|
|
3359
|
+
expandGroupRow(keys) {
|
|
3360
|
+
this.setGroupRowExpanded(keys, true);
|
|
3361
|
+
}
|
|
3362
|
+
toggleGroupRow(keys) {
|
|
3363
|
+
this.setGroupRowExpanded(keys, !this.isGroupRowExpanded(keys));
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
|
|
3367
|
+
// src/utils/shallowEqualObjects.ts
|
|
3368
|
+
function shallowEqualObjects(objA, objB, ignoreKeys) {
|
|
3369
|
+
if (objA === objB) {
|
|
3370
|
+
return true;
|
|
3371
|
+
}
|
|
3372
|
+
if (!objA || !objB) {
|
|
3373
|
+
return false;
|
|
3374
|
+
}
|
|
3375
|
+
var aKeys = Object.keys(objA);
|
|
3376
|
+
var bKeys = Object.keys(objB);
|
|
3377
|
+
if (ignoreKeys) {
|
|
3378
|
+
aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3379
|
+
bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
|
|
3380
|
+
}
|
|
3381
|
+
var len = aKeys.length;
|
|
3382
|
+
if (bKeys.length !== len) {
|
|
3383
|
+
return false;
|
|
3384
|
+
}
|
|
3385
|
+
for (var i = 0; i < len; i++) {
|
|
3386
|
+
var key = aKeys[i];
|
|
3387
|
+
if (ignoreKeys) {
|
|
3388
|
+
if (ignoreKeys.has(key)) {
|
|
3389
|
+
continue;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
3393
|
+
return false;
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
return true;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
// src/components/utils/discardCallsWithEqualArg.ts
|
|
3400
|
+
var map = new WeakMap();
|
|
3401
|
+
var getCompareDefault = (a) => a;
|
|
3402
|
+
function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
|
|
3403
|
+
map.set(fn, {
|
|
3404
|
+
lastCallTime: 0,
|
|
3405
|
+
lastCallArg: null
|
|
3406
|
+
});
|
|
3407
|
+
const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
|
|
3408
|
+
return (arg) => {
|
|
3409
|
+
const { lastCallTime, lastCallArg } = map.get(fn) || {
|
|
3410
|
+
lastCallTime: 0,
|
|
3411
|
+
lastCallArg: null
|
|
3412
|
+
};
|
|
3413
|
+
const now = Date.now();
|
|
3414
|
+
const diff = now - lastCallTime;
|
|
3415
|
+
const objectsEqual = shallowEqualObjects(getCompare(lastCallArg), getCompare(arg));
|
|
3416
|
+
if (diff < timeframe && objectsEqual) {
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
map.set(fn, {
|
|
3420
|
+
lastCallTime: now,
|
|
3421
|
+
lastCallArg: arg
|
|
3422
|
+
});
|
|
3423
|
+
fn(arg);
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
// src/components/DataSource/state/getInitialState.ts
|
|
3428
|
+
var defaultCursorId = Symbol("cursorId");
|
|
3429
|
+
function initSetupState2() {
|
|
3430
|
+
const now = Date.now();
|
|
3431
|
+
const originalDataArray = [];
|
|
3432
|
+
const dataArray = [];
|
|
3433
|
+
const originalLazyGroupData = new DeepMap();
|
|
3434
|
+
return {
|
|
3435
|
+
dataParams: void 0,
|
|
3436
|
+
notifyScrollbarsChange: buildSubscriptionCallback(),
|
|
3437
|
+
notifyScrollStop: buildSubscriptionCallback(),
|
|
3438
|
+
pivotTotalColumnPosition: "end",
|
|
3439
|
+
originalLazyGroupData,
|
|
3440
|
+
originalDataArray,
|
|
3441
|
+
cursorId: defaultCursorId,
|
|
3442
|
+
showSeparatePivotColumnForSingleAggregation: false,
|
|
3443
|
+
propsCache: new Map([
|
|
3444
|
+
["sortInfo", new WeakMap()]
|
|
3445
|
+
]),
|
|
3446
|
+
pivotMappings: void 0,
|
|
3447
|
+
pivotColumns: void 0,
|
|
3448
|
+
pivotColumnGroups: void 0,
|
|
3449
|
+
dataArray,
|
|
3450
|
+
updatedAt: now,
|
|
3451
|
+
groupedAt: 0,
|
|
3452
|
+
sortedAt: 0,
|
|
3453
|
+
reducedAt: now,
|
|
3454
|
+
generateGroupRows: true,
|
|
3455
|
+
groupDeepMap: void 0,
|
|
3456
|
+
postSortDataArray: void 0,
|
|
3457
|
+
postGroupDataArray: void 0,
|
|
3458
|
+
lastSortDataArray: void 0,
|
|
3459
|
+
lastGroupDataArray: void 0
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
function getCompareObjectForDataParams(dataParams) {
|
|
3463
|
+
const obj = __spreadValues({}, dataParams);
|
|
3464
|
+
delete obj.originalDataArray;
|
|
3465
|
+
return obj;
|
|
3466
|
+
}
|
|
3467
|
+
var forwardProps3 = (setupState) => {
|
|
3468
|
+
return {
|
|
3469
|
+
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3470
|
+
fullLazyLoad: 1,
|
|
3471
|
+
data: 1,
|
|
3472
|
+
pivotBy: 1,
|
|
3473
|
+
primaryKey: 1,
|
|
3474
|
+
livePagination: 1,
|
|
3475
|
+
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3476
|
+
aggregationReducers: 1,
|
|
3477
|
+
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3478
|
+
loading: (loading) => loading != null ? loading : false,
|
|
3479
|
+
sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
|
|
3480
|
+
groupBy: (groupBy) => groupBy != null ? groupBy : [],
|
|
3481
|
+
groupRowsState: (groupRowsState) => {
|
|
3482
|
+
return groupRowsState || new GroupRowsState({
|
|
3483
|
+
expandedRows: true,
|
|
3484
|
+
collapsedRows: []
|
|
3485
|
+
});
|
|
3486
|
+
}
|
|
3212
3487
|
};
|
|
3213
|
-
|
|
3488
|
+
};
|
|
3489
|
+
function getLivePaginationCursorValue(livePaginationCursorProp, state) {
|
|
3490
|
+
const livePaginationCursor = typeof livePaginationCursorProp === "function" ? livePaginationCursorProp({
|
|
3491
|
+
array: state.originalDataArray,
|
|
3492
|
+
length: state.originalDataArray.length,
|
|
3493
|
+
lastItem: state.originalDataArray[state.originalDataArray.length - 1]
|
|
3494
|
+
}) : livePaginationCursorProp;
|
|
3495
|
+
return livePaginationCursor;
|
|
3214
3496
|
}
|
|
3215
|
-
function
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3497
|
+
function mapPropsToState2(params) {
|
|
3498
|
+
const { props, state, oldState } = params;
|
|
3499
|
+
const controlledSort = isControlledValue(props.sortInfo);
|
|
3500
|
+
const result = {
|
|
3501
|
+
controlledSort,
|
|
3502
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3503
|
+
};
|
|
3504
|
+
if (props.livePagination) {
|
|
3505
|
+
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
3506
|
+
const livePaginationCursor = typeof props.livePaginationCursor === "function" ? dataArrayChanged ? getLivePaginationCursorValue(props.livePaginationCursor, state) : state.livePaginationCursor : props.livePaginationCursor;
|
|
3507
|
+
result.livePaginationCursor = livePaginationCursor;
|
|
3222
3508
|
}
|
|
3223
|
-
return
|
|
3509
|
+
return result;
|
|
3224
3510
|
}
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
const {
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
const groupNesting = groupKeys.length;
|
|
3237
|
-
const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
|
|
3238
|
-
const enhancedGroupData = getEnhancedGroupData({
|
|
3239
|
-
groupBy: groupByStrings,
|
|
3240
|
-
parents: Array.from(parents),
|
|
3241
|
-
indexInGroup,
|
|
3242
|
-
indexInParentGroups: Array.from(indexInParentGroups),
|
|
3243
|
-
indexInAll: result.length,
|
|
3244
|
-
groupKeys,
|
|
3245
|
-
collapsed
|
|
3246
|
-
}, deepMapValue);
|
|
3247
|
-
const include = generateGroupRows || collapsed;
|
|
3248
|
-
if (include) {
|
|
3249
|
-
result.push(enhancedGroupData);
|
|
3250
|
-
}
|
|
3251
|
-
if (collapsed) {
|
|
3252
|
-
parents.forEach((parent) => {
|
|
3253
|
-
parent.collapsedChildrenCount += enhancedGroupData.groupCount;
|
|
3254
|
-
parent.collapsedGroupsCount += 1;
|
|
3511
|
+
var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
3512
|
+
function onPropChange(params, props, actions) {
|
|
3513
|
+
const { name, newValue } = params;
|
|
3514
|
+
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3515
|
+
if (props.fullLazyLoad) {
|
|
3516
|
+
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3517
|
+
}
|
|
3518
|
+
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
3519
|
+
actions.groupRowsState = new GroupRowsState({
|
|
3520
|
+
collapsedRows: true,
|
|
3521
|
+
expandedRows: []
|
|
3255
3522
|
});
|
|
3256
3523
|
}
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
var debugDataParams = dbg("DataSource:dataParams");
|
|
3527
|
+
function getInterceptActions() {
|
|
3528
|
+
return {
|
|
3529
|
+
sortInfo: (sortInfo, { actions, state }) => {
|
|
3530
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3531
|
+
sortInfo,
|
|
3532
|
+
livePaginationCursor: null
|
|
3533
|
+
});
|
|
3534
|
+
actions.dataParams = dataParams;
|
|
3535
|
+
if (state.livePagination) {
|
|
3536
|
+
requestAnimationFrame(() => {
|
|
3537
|
+
actions.livePaginationCursor = null;
|
|
3538
|
+
});
|
|
3539
|
+
}
|
|
3540
|
+
},
|
|
3541
|
+
groupBy: (groupBy, { actions, state }) => {
|
|
3542
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3543
|
+
groupBy,
|
|
3544
|
+
livePaginationCursor: null
|
|
3545
|
+
});
|
|
3546
|
+
actions.dataParams = dataParams;
|
|
3547
|
+
if (state.livePagination) {
|
|
3548
|
+
requestAnimationFrame(() => {
|
|
3549
|
+
actions.livePaginationCursor = null;
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
},
|
|
3553
|
+
pivotBy: (pivotBy, { actions, state }) => {
|
|
3554
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3555
|
+
pivotBy,
|
|
3556
|
+
livePaginationCursor: null
|
|
3557
|
+
});
|
|
3558
|
+
actions.dataParams = dataParams;
|
|
3559
|
+
if (state.livePagination) {
|
|
3560
|
+
requestAnimationFrame(() => {
|
|
3561
|
+
actions.livePaginationCursor = null;
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
},
|
|
3565
|
+
cursorId: (cursorId, { actions, state }) => {
|
|
3566
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3567
|
+
cursorId
|
|
3568
|
+
});
|
|
3569
|
+
actions.dataParams = dataParams;
|
|
3570
|
+
},
|
|
3571
|
+
livePaginationCursor: (livePaginationCursor, { actions, state }) => {
|
|
3572
|
+
const dataParams = buildDataSourceDataParams(state, {
|
|
3573
|
+
livePaginationCursor
|
|
3574
|
+
});
|
|
3575
|
+
actions.dataParams = dataParams;
|
|
3576
|
+
},
|
|
3577
|
+
dataParams: (dataParams, { state }) => {
|
|
3578
|
+
if (shallowEqualObjects(dataParams, state.dataParams, new Set([
|
|
3579
|
+
"changes",
|
|
3580
|
+
"originalDataArray"
|
|
3581
|
+
]))) {
|
|
3582
|
+
return false;
|
|
3282
3583
|
}
|
|
3584
|
+
debugDataParams("onDataParamsChange triggered because the following values have changed", dataParams == null ? void 0 : dataParams.changes);
|
|
3585
|
+
return true;
|
|
3283
3586
|
}
|
|
3284
|
-
parents.pop();
|
|
3285
|
-
indexInParentGroups.pop();
|
|
3286
|
-
});
|
|
3287
|
-
return {
|
|
3288
|
-
data: result
|
|
3289
3587
|
};
|
|
3290
3588
|
}
|
|
3291
3589
|
|
|
3292
3590
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
3293
|
-
function
|
|
3591
|
+
function prepareColumn(column) {
|
|
3592
|
+
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
3593
|
+
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
3594
|
+
if (typeof pivotByForColumn.column === "function") {
|
|
3595
|
+
Object.assign(column, pivotByForColumn.column({ column }));
|
|
3596
|
+
} else {
|
|
3597
|
+
Object.assign(column, pivotByForColumn.column);
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
return column;
|
|
3601
|
+
}
|
|
3602
|
+
function prepareColumnGroup(columnGroup) {
|
|
3603
|
+
const { pivotByAtIndex: pivotByForColumnGroup } = columnGroup;
|
|
3604
|
+
if (pivotByForColumnGroup == null ? void 0 : pivotByForColumnGroup.columnGroup) {
|
|
3605
|
+
if (typeof pivotByForColumnGroup.columnGroup === "function") {
|
|
3606
|
+
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup({ columnGroup }));
|
|
3607
|
+
} else {
|
|
3608
|
+
Object.assign(columnGroup, pivotByForColumnGroup.columnGroup);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
return columnGroup;
|
|
3612
|
+
}
|
|
3613
|
+
function getPivotColumnsAndColumnGroups({
|
|
3614
|
+
deepMap,
|
|
3615
|
+
pivotBy,
|
|
3616
|
+
pivotTotalColumnPosition,
|
|
3617
|
+
reducers = {},
|
|
3618
|
+
showSeparatePivotColumnForSingleAggregation = false
|
|
3619
|
+
}) {
|
|
3294
3620
|
const pivotLength = pivotBy.length;
|
|
3621
|
+
const aggregationReducers = Object.keys(reducers).map((key) => {
|
|
3622
|
+
return __spreadProps(__spreadValues({}, reducers[key]), { id: key });
|
|
3623
|
+
});
|
|
3295
3624
|
const columns = new Map([
|
|
3296
3625
|
[
|
|
3297
3626
|
"labels",
|
|
3298
3627
|
{
|
|
3299
3628
|
header: "Row labels",
|
|
3629
|
+
pivotBy,
|
|
3300
3630
|
valueGetter: (params) => {
|
|
3301
3631
|
var _a;
|
|
3302
3632
|
const { rowInfo } = params;
|
|
3633
|
+
if (!rowInfo.data) {
|
|
3634
|
+
return "Loading ... TODO replace this with a loading indicator";
|
|
3635
|
+
}
|
|
3303
3636
|
return rowInfo.groupKeys ? rowInfo.groupKeys[((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) - 1] : null;
|
|
3304
3637
|
}
|
|
3305
3638
|
}
|
|
3306
3639
|
]
|
|
3307
3640
|
]);
|
|
3308
3641
|
const columnGroups = new Map();
|
|
3642
|
+
const isSingleAggregationColumn = !showSeparatePivotColumnForSingleAggregation && aggregationReducers.length === 1;
|
|
3309
3643
|
deepMap.visitDepthFirst((_value, keys, _indexInGroup, next) => {
|
|
3310
3644
|
keys = [...keys];
|
|
3311
3645
|
if (pivotTotalColumnPosition === "end") {
|
|
3312
3646
|
next == null ? void 0 : next();
|
|
3313
3647
|
}
|
|
3314
3648
|
if (keys.length === pivotLength) {
|
|
3315
|
-
const parentKeys = keys.slice(0, -1);
|
|
3316
|
-
let columnGroupId = parentKeys.join("/");
|
|
3317
3649
|
const pivotByForColumn = pivotBy[keys.length - 1];
|
|
3318
|
-
let computedPivotColumn = __spreadValues({
|
|
3319
|
-
pivotBy,
|
|
3320
|
-
pivotColumn: true,
|
|
3321
|
-
pivotGroupKeys: keys,
|
|
3322
|
-
pivotGroupKeyForColumn: keys[keys.length - 1],
|
|
3323
|
-
pivotIndexForColumn: keys.length - 1,
|
|
3324
|
-
pivotByForColumn,
|
|
3325
|
-
sortable: false,
|
|
3326
|
-
columnGroup: parentKeys.length ? `${columnGroupId}` : void 0,
|
|
3327
|
-
header: keys[keys.length - 1],
|
|
3328
|
-
valueGetter: ({ rowInfo }) => {
|
|
3329
|
-
var _a, _b, _c;
|
|
3330
|
-
const value = (_c = (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[0]) != null ? _c : null;
|
|
3331
|
-
return value;
|
|
3332
|
-
}
|
|
3333
|
-
}, pivotByForColumn.column);
|
|
3334
|
-
if (pivotByForColumn.column) {
|
|
3335
|
-
if (typeof pivotByForColumn.column === "function") {
|
|
3336
|
-
Object.assign(computedPivotColumn, pivotByForColumn.column({ column: computedPivotColumn }));
|
|
3337
|
-
} else {
|
|
3338
|
-
Object.assign(computedPivotColumn, pivotByForColumn.column);
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
columns.set(`${keys.join("/")}`, computedPivotColumn);
|
|
3342
|
-
} else {
|
|
3343
|
-
const colGroupId = keys.join("/");
|
|
3344
3650
|
const parentKeys = keys.slice(0, -1);
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
columnGroup:
|
|
3353
|
-
|
|
3354
|
-
pivotTotalColumn: true,
|
|
3651
|
+
let parentColumnGroupId = parentKeys.join("/");
|
|
3652
|
+
if (!isSingleAggregationColumn) {
|
|
3653
|
+
const columnGroupId = parentColumnGroupId;
|
|
3654
|
+
parentColumnGroupId = keys.join("/");
|
|
3655
|
+
const pivotGroupKey = keys[keys.length - 1];
|
|
3656
|
+
columnGroups.set(parentColumnGroupId, prepareColumnGroup({
|
|
3657
|
+
header: pivotGroupKey,
|
|
3658
|
+
columnGroup: columnGroupId,
|
|
3659
|
+
pivotBy,
|
|
3355
3660
|
pivotGroupKeys: keys,
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3661
|
+
pivotByAtIndex: pivotByForColumn,
|
|
3662
|
+
pivotIndex: keys.length - 1,
|
|
3663
|
+
pivotGroupKey
|
|
3664
|
+
}));
|
|
3665
|
+
}
|
|
3666
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3667
|
+
const header = isSingleAggregationColumn ? keys[keys.length - 1] : reducer.name || reducer.id;
|
|
3668
|
+
const computedPivotColumn = prepareColumn({
|
|
3359
3669
|
pivotBy,
|
|
3670
|
+
pivotColumn: true,
|
|
3671
|
+
pivotTotalColumn: false,
|
|
3672
|
+
pivotAggregator: reducer,
|
|
3673
|
+
pivotAggregatorIndex: index,
|
|
3674
|
+
pivotGroupKeys: keys,
|
|
3675
|
+
pivotGroupKey: keys[keys.length - 1],
|
|
3676
|
+
pivotIndex: keys.length - 1,
|
|
3677
|
+
pivotByAtIndex: pivotByForColumn,
|
|
3360
3678
|
sortable: false,
|
|
3679
|
+
columnGroup: parentColumnGroupId,
|
|
3680
|
+
header,
|
|
3361
3681
|
valueGetter: ({ rowInfo }) => {
|
|
3362
|
-
var _a, _b
|
|
3363
|
-
|
|
3364
|
-
return value;
|
|
3365
|
-
}
|
|
3366
|
-
}, pivotByForColumn.column);
|
|
3367
|
-
if (pivotByForColumn.column) {
|
|
3368
|
-
if (typeof pivotByForColumn.column === "function") {
|
|
3369
|
-
Object.assign(computedPivotColumn, pivotByForColumn.column({ column: computedPivotColumn }));
|
|
3370
|
-
} else {
|
|
3371
|
-
Object.assign(computedPivotColumn, pivotByForColumn.column);
|
|
3682
|
+
var _a, _b;
|
|
3683
|
+
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3372
3684
|
}
|
|
3685
|
+
});
|
|
3686
|
+
const columnId = `${reducer.id}:${keys.join("/")}`;
|
|
3687
|
+
columns.set(columnId, computedPivotColumn);
|
|
3688
|
+
});
|
|
3689
|
+
} else {
|
|
3690
|
+
const colGroupId = keys.join("/");
|
|
3691
|
+
const parentKeys = keys.slice(0, -1);
|
|
3692
|
+
columnGroups.set(colGroupId, prepareColumnGroup({
|
|
3693
|
+
columnGroup: parentKeys.length ? parentKeys.join("/") : void 0,
|
|
3694
|
+
header: keys[keys.length - 1],
|
|
3695
|
+
pivotBy,
|
|
3696
|
+
pivotGroupKeys: keys,
|
|
3697
|
+
pivotIndex: keys.length - 1,
|
|
3698
|
+
pivotByAtIndex: pivotBy[keys.length - 1],
|
|
3699
|
+
pivotGroupKey: keys[keys.length - 1]
|
|
3700
|
+
}));
|
|
3701
|
+
if (pivotTotalColumnPosition !== false) {
|
|
3702
|
+
const pivotByForColumn = pivotBy[keys.length - 1];
|
|
3703
|
+
let columnGroupId = parentKeys.length ? parentKeys.join("/") : void 0;
|
|
3704
|
+
if (!isSingleAggregationColumn) {
|
|
3705
|
+
let parentGroupForTotalsGroup = columnGroupId;
|
|
3706
|
+
columnGroupId = `total:${keys.join("/")}`;
|
|
3707
|
+
columnGroups.set(columnGroupId, prepareColumnGroup({
|
|
3708
|
+
header: `${keys[keys.length - 1]} total`,
|
|
3709
|
+
columnGroup: parentGroupForTotalsGroup,
|
|
3710
|
+
pivotBy,
|
|
3711
|
+
pivotTotalColumnGroup: true,
|
|
3712
|
+
pivotGroupKeys: keys,
|
|
3713
|
+
pivotIndex: keys.length - 1,
|
|
3714
|
+
pivotByAtIndex: pivotByForColumn,
|
|
3715
|
+
pivotGroupKey: keys[keys.length - 1]
|
|
3716
|
+
}));
|
|
3373
3717
|
}
|
|
3374
|
-
|
|
3718
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3719
|
+
const header = isSingleAggregationColumn ? `${keys[keys.length - 1]} total ` : `${reducer.name || reducer.id} total`;
|
|
3720
|
+
const computedPivotColumn = prepareColumn({
|
|
3721
|
+
columnGroup: columnGroupId,
|
|
3722
|
+
header,
|
|
3723
|
+
pivotAggregator: reducer,
|
|
3724
|
+
pivotAggregatorIndex: index,
|
|
3725
|
+
pivotColumn: true,
|
|
3726
|
+
pivotTotalColumn: true,
|
|
3727
|
+
pivotGroupKeys: keys,
|
|
3728
|
+
pivotGroupKey: keys[keys.length - 1],
|
|
3729
|
+
pivotByAtIndex: pivotByForColumn,
|
|
3730
|
+
pivotIndex: keys.length - 1,
|
|
3731
|
+
pivotBy,
|
|
3732
|
+
sortable: false,
|
|
3733
|
+
valueGetter: ({ rowInfo }) => {
|
|
3734
|
+
var _a, _b;
|
|
3735
|
+
return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
columns.set(`total:${reducer.id}:${keys.join("/")}`, computedPivotColumn);
|
|
3739
|
+
});
|
|
3375
3740
|
}
|
|
3376
3741
|
}
|
|
3377
3742
|
if (pivotTotalColumnPosition === "start" || pivotTotalColumnPosition === false) {
|
|
@@ -3379,12 +3744,22 @@ function getPivotColumnsAndColumnGroups(deepMap, pivotBy, pivotTotalColumnPositi
|
|
|
3379
3744
|
}
|
|
3380
3745
|
});
|
|
3381
3746
|
if (columns.size === 1) {
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3747
|
+
aggregationReducers.forEach((reducer, index) => {
|
|
3748
|
+
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
3749
|
+
header: `${reducer.name || reducer.id} total`,
|
|
3750
|
+
pivotBy,
|
|
3751
|
+
pivotColumn: true,
|
|
3752
|
+
pivotTotalColumn: true,
|
|
3753
|
+
pivotAggregator: reducer,
|
|
3754
|
+
pivotAggregatorIndex: index,
|
|
3755
|
+
pivotGroupKeys: [],
|
|
3756
|
+
pivotGroupKey: "",
|
|
3757
|
+
pivotIndex: -1,
|
|
3758
|
+
valueGetter: ({ rowInfo }) => {
|
|
3759
|
+
var _a;
|
|
3760
|
+
return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
|
|
3761
|
+
}
|
|
3762
|
+
}));
|
|
3388
3763
|
});
|
|
3389
3764
|
}
|
|
3390
3765
|
const result = {
|
|
@@ -3407,29 +3782,39 @@ var haveDepsChanged = (state1, state2, deps) => {
|
|
|
3407
3782
|
return false;
|
|
3408
3783
|
};
|
|
3409
3784
|
function toRowInfo(data, id, index) {
|
|
3410
|
-
return {
|
|
3785
|
+
return {
|
|
3786
|
+
data,
|
|
3787
|
+
collapsed: true,
|
|
3788
|
+
id,
|
|
3789
|
+
indexInAll: index,
|
|
3790
|
+
indexInGroup: index,
|
|
3791
|
+
isGroupRow: false
|
|
3792
|
+
};
|
|
3411
3793
|
}
|
|
3412
3794
|
function concludeReducer(params) {
|
|
3413
3795
|
var _a;
|
|
3414
3796
|
const { state, previousState } = params;
|
|
3415
3797
|
const sortInfo = state.sortInfo;
|
|
3416
3798
|
const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3417
|
-
const
|
|
3418
|
-
"originalDataArray"
|
|
3419
|
-
"sortInfo"
|
|
3799
|
+
const originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3800
|
+
"originalDataArray"
|
|
3420
3801
|
]);
|
|
3802
|
+
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3803
|
+
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3421
3804
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3422
|
-
const groupBy = state.
|
|
3805
|
+
const groupBy = state.groupBy;
|
|
3423
3806
|
const pivotBy = state.pivotBy;
|
|
3424
3807
|
const shouldGroup = groupBy.length || pivotBy;
|
|
3425
3808
|
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3426
3809
|
"generateGroupRows",
|
|
3427
3810
|
"originalDataArray",
|
|
3428
|
-
"
|
|
3811
|
+
"originalLazyGroupData",
|
|
3812
|
+
"groupBy",
|
|
3429
3813
|
"groupRowsState",
|
|
3430
3814
|
"pivotBy",
|
|
3431
3815
|
"aggregationReducers",
|
|
3432
3816
|
"pivotTotalColumnPosition",
|
|
3817
|
+
"showSeparatePivotColumnForSingleAggregation",
|
|
3433
3818
|
"sortInfo"
|
|
3434
3819
|
]);
|
|
3435
3820
|
const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray);
|
|
@@ -3448,20 +3833,32 @@ function concludeReducer(params) {
|
|
|
3448
3833
|
};
|
|
3449
3834
|
if (shouldGroup) {
|
|
3450
3835
|
if (shouldGroupAgain) {
|
|
3451
|
-
const groupResult =
|
|
3836
|
+
const groupResult = state.fullLazyLoad ? lazyGroup({
|
|
3837
|
+
groupBy,
|
|
3838
|
+
pivot: pivotBy,
|
|
3839
|
+
mappings: state.pivotMappings,
|
|
3840
|
+
reducers: state.aggregationReducers
|
|
3841
|
+
}, state.originalLazyGroupData) : group({
|
|
3452
3842
|
groupBy,
|
|
3453
3843
|
pivot: pivotBy,
|
|
3454
3844
|
reducers: state.aggregationReducers
|
|
3455
3845
|
}, dataArray);
|
|
3456
3846
|
const flattenResult = enhancedFlatten({
|
|
3457
3847
|
groupResult,
|
|
3848
|
+
reducers: state.aggregationReducers,
|
|
3458
3849
|
toPrimaryKey,
|
|
3459
3850
|
groupRowsState: state.groupRowsState,
|
|
3460
3851
|
generateGroupRows: state.generateGroupRows
|
|
3461
3852
|
});
|
|
3462
3853
|
rowInfoDataArray = flattenResult.data;
|
|
3463
3854
|
state.groupDeepMap = groupResult.deepMap;
|
|
3464
|
-
const pivotGroupsAndCols = pivotBy ? getPivotColumnsAndColumnGroups(
|
|
3855
|
+
const pivotGroupsAndCols = pivotBy ? getPivotColumnsAndColumnGroups({
|
|
3856
|
+
deepMap: groupResult.topLevelPivotColumns,
|
|
3857
|
+
pivotBy,
|
|
3858
|
+
pivotTotalColumnPosition: (_a = state.pivotTotalColumnPosition) != null ? _a : "end",
|
|
3859
|
+
reducers: state.aggregationReducers,
|
|
3860
|
+
showSeparatePivotColumnForSingleAggregation: state.showSeparatePivotColumnForSingleAggregation
|
|
3861
|
+
}) : void 0;
|
|
3465
3862
|
state.pivotColumns = pivotGroupsAndCols == null ? void 0 : pivotGroupsAndCols.columns;
|
|
3466
3863
|
state.pivotColumnGroups = pivotGroupsAndCols == null ? void 0 : pivotGroupsAndCols.columnGroups;
|
|
3467
3864
|
} else {
|
|
@@ -3509,6 +3906,7 @@ var DataSourceRoot = getComponentStateRoot({
|
|
|
3509
3906
|
forwardProps: forwardProps3,
|
|
3510
3907
|
concludeReducer,
|
|
3511
3908
|
mapPropsToState: mapPropsToState2,
|
|
3909
|
+
onPropChange,
|
|
3512
3910
|
interceptActions: getInterceptActions()
|
|
3513
3911
|
});
|
|
3514
3912
|
function DataSourceCmp({ children }) {
|
|
@@ -3540,57 +3938,63 @@ function DataSource(props) {
|
|
|
3540
3938
|
function useToggleGroupRow() {
|
|
3541
3939
|
const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
|
|
3542
3940
|
const toggleGroupRow = useCallback4((groupKeys) => {
|
|
3543
|
-
const
|
|
3941
|
+
const state = getDataSourceState();
|
|
3942
|
+
const newState = new GroupRowsState(state.groupRowsState);
|
|
3544
3943
|
newState.toggleGroupRow(groupKeys);
|
|
3545
3944
|
dataSourceActions.groupRowsState = newState;
|
|
3945
|
+
if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
3946
|
+
loadData(state.data, state, dataSourceActions, {
|
|
3947
|
+
groupKeys
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3546
3950
|
}, []);
|
|
3547
3951
|
return toggleGroupRow;
|
|
3548
3952
|
}
|
|
3549
3953
|
|
|
3550
3954
|
// src/components/InfiniteTable/hooks/useColumnsWhen.ts
|
|
3551
|
-
function
|
|
3552
|
-
const
|
|
3553
|
-
return
|
|
3554
|
-
acc.set(
|
|
3555
|
-
groupBy,
|
|
3955
|
+
function useGroupByMap(groupBy) {
|
|
3956
|
+
const groupByMap = useMemo4(() => {
|
|
3957
|
+
return groupBy.reduce((acc, groupBy2, index) => {
|
|
3958
|
+
acc.set(groupBy2.field, {
|
|
3959
|
+
groupBy: groupBy2,
|
|
3556
3960
|
groupIndex: index
|
|
3557
3961
|
});
|
|
3558
3962
|
return acc;
|
|
3559
3963
|
}, new Map());
|
|
3560
|
-
}, [
|
|
3561
|
-
return
|
|
3964
|
+
}, [groupBy]);
|
|
3965
|
+
return groupByMap;
|
|
3562
3966
|
}
|
|
3563
3967
|
function useColumnsWhen() {
|
|
3564
3968
|
const {
|
|
3565
|
-
componentState: {
|
|
3969
|
+
componentState: { groupBy },
|
|
3566
3970
|
componentActions: dataSourceActions
|
|
3567
3971
|
} = useDataSourceContextValue();
|
|
3568
3972
|
const {
|
|
3569
3973
|
componentState: { groupRenderStrategy, pivotTotalColumnPosition }
|
|
3570
3974
|
} = useComponentState();
|
|
3571
|
-
const
|
|
3572
|
-
|
|
3975
|
+
const groupByMap = useGroupByMap(groupBy);
|
|
3976
|
+
useEffect9(() => {
|
|
3573
3977
|
dataSourceActions.generateGroupRows = groupRenderStrategy !== "inline";
|
|
3574
3978
|
}, [groupRenderStrategy]);
|
|
3575
|
-
|
|
3979
|
+
useEffect9(() => {
|
|
3576
3980
|
dataSourceActions.pivotTotalColumnPosition = pivotTotalColumnPosition;
|
|
3577
3981
|
}, [pivotTotalColumnPosition]);
|
|
3578
|
-
useColumnsWhenInlineGroupRenderStrategy(
|
|
3982
|
+
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
3579
3983
|
useColumnsWhenPivoting();
|
|
3580
3984
|
useColumnsWhenGrouping();
|
|
3581
|
-
useHideEmptyGroupColumns(
|
|
3985
|
+
useHideEmptyGroupColumns(groupByMap);
|
|
3582
3986
|
}
|
|
3583
|
-
function useColumnsWhenInlineGroupRenderStrategy(
|
|
3987
|
+
function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
3584
3988
|
const toggleGroupRow = useToggleGroupRow();
|
|
3585
3989
|
const {
|
|
3586
3990
|
componentActions,
|
|
3587
3991
|
componentState: { columns, groupRenderStrategy }
|
|
3588
3992
|
} = useComponentState();
|
|
3589
|
-
function computeColumnsWhenInlineGroupRenderStrategy(columns2,
|
|
3993
|
+
function computeColumnsWhenInlineGroupRenderStrategy(columns2, groupByMap2, groupRenderStrategy2, toggleGroupRow2) {
|
|
3590
3994
|
const computedColumns = new Map();
|
|
3591
3995
|
columns2.forEach((column, id) => {
|
|
3592
3996
|
let base = {};
|
|
3593
|
-
const groupByForColumn =
|
|
3997
|
+
const groupByForColumn = groupByMap2.get(column.field);
|
|
3594
3998
|
if (groupByForColumn && groupRenderStrategy2 === "inline") {
|
|
3595
3999
|
const { groupIndex } = groupByForColumn;
|
|
3596
4000
|
const field = groupByForColumn.groupBy.field;
|
|
@@ -3635,9 +4039,9 @@ function useColumnsWhenInlineGroupRenderStrategy(groupRowsMap) {
|
|
|
3635
4039
|
});
|
|
3636
4040
|
return computedColumns.size === 0 ? void 0 : computedColumns;
|
|
3637
4041
|
}
|
|
3638
|
-
|
|
4042
|
+
useEffect9(() => {
|
|
3639
4043
|
const update = () => {
|
|
3640
|
-
componentActions.columnsWhenInlineGroupRenderStrategy = computeColumnsWhenInlineGroupRenderStrategy(columns,
|
|
4044
|
+
componentActions.columnsWhenInlineGroupRenderStrategy = computeColumnsWhenInlineGroupRenderStrategy(columns, groupByMap, groupRenderStrategy, toggleGroupRow);
|
|
3641
4045
|
};
|
|
3642
4046
|
update();
|
|
3643
4047
|
return interceptMap(columns, {
|
|
@@ -3645,11 +4049,11 @@ function useColumnsWhenInlineGroupRenderStrategy(groupRowsMap) {
|
|
|
3645
4049
|
delete: update,
|
|
3646
4050
|
clear: update
|
|
3647
4051
|
});
|
|
3648
|
-
}, [columns,
|
|
4052
|
+
}, [columns, groupByMap, groupRenderStrategy, toggleGroupRow]);
|
|
3649
4053
|
}
|
|
3650
4054
|
function useColumnsWhenPivoting() {
|
|
3651
4055
|
const {
|
|
3652
|
-
componentState: {
|
|
4056
|
+
componentState: { groupBy, pivotBy }
|
|
3653
4057
|
} = useDataSourceContextValue();
|
|
3654
4058
|
const {
|
|
3655
4059
|
componentActions,
|
|
@@ -3661,13 +4065,13 @@ function useColumnsWhenPivoting() {
|
|
|
3661
4065
|
}
|
|
3662
4066
|
} = useComponentState();
|
|
3663
4067
|
const toggleGroupRow = useToggleGroupRow();
|
|
3664
|
-
|
|
4068
|
+
useEffect9(() => {
|
|
3665
4069
|
const computedPivotColumns = getComputedPivotColumnsFromDataSourcePivotColumns(pivotColumns, {
|
|
3666
4070
|
pivotColumn,
|
|
3667
4071
|
pivotRowLabelsColumn,
|
|
3668
4072
|
pivotTotalColumnPosition,
|
|
3669
4073
|
pivotBy,
|
|
3670
|
-
|
|
4074
|
+
groupBy,
|
|
3671
4075
|
toggleGroupRow
|
|
3672
4076
|
});
|
|
3673
4077
|
componentActions.computedPivotColumns = computedPivotColumns;
|
|
@@ -3675,14 +4079,14 @@ function useColumnsWhenPivoting() {
|
|
|
3675
4079
|
}
|
|
3676
4080
|
function useColumnsWhenGrouping() {
|
|
3677
4081
|
const {
|
|
3678
|
-
componentState: {
|
|
4082
|
+
componentState: { groupBy }
|
|
3679
4083
|
} = useDataSourceContextValue();
|
|
3680
4084
|
const {
|
|
3681
4085
|
componentActions,
|
|
3682
4086
|
componentState: { columns, groupColumn, groupRenderStrategy, pivotColumns }
|
|
3683
4087
|
} = useComponentState();
|
|
3684
4088
|
const toggleGroupRow = useToggleGroupRow();
|
|
3685
|
-
|
|
4089
|
+
useEffect9(() => {
|
|
3686
4090
|
if (pivotColumns) {
|
|
3687
4091
|
return;
|
|
3688
4092
|
}
|
|
@@ -3691,7 +4095,7 @@ function useColumnsWhenGrouping() {
|
|
|
3691
4095
|
columns,
|
|
3692
4096
|
groupColumn,
|
|
3693
4097
|
groupRenderStrategy,
|
|
3694
|
-
|
|
4098
|
+
groupBy,
|
|
3695
4099
|
pivotColumns,
|
|
3696
4100
|
toggleGroupRow
|
|
3697
4101
|
});
|
|
@@ -3703,11 +4107,11 @@ function useColumnsWhenGrouping() {
|
|
|
3703
4107
|
delete: update,
|
|
3704
4108
|
clear: update
|
|
3705
4109
|
});
|
|
3706
|
-
}, [
|
|
4110
|
+
}, [columns, groupBy, groupColumn, groupRenderStrategy, pivotColumns]);
|
|
3707
4111
|
}
|
|
3708
4112
|
function useHideEmptyGroupColumns(groupRowsMap) {
|
|
3709
4113
|
const {
|
|
3710
|
-
componentState: {
|
|
4114
|
+
componentState: { groupBy, groupRowsState },
|
|
3711
4115
|
getState: getDataSourceState
|
|
3712
4116
|
} = useDataSourceContextValue();
|
|
3713
4117
|
const {
|
|
@@ -3719,11 +4123,11 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3719
4123
|
groupRenderStrategy
|
|
3720
4124
|
}
|
|
3721
4125
|
} = useComponentState();
|
|
3722
|
-
|
|
3723
|
-
if (groupRenderStrategy
|
|
4126
|
+
useEffect9(() => {
|
|
4127
|
+
if (groupRenderStrategy !== "multi-column") {
|
|
3724
4128
|
return;
|
|
3725
4129
|
}
|
|
3726
|
-
const groupsLength =
|
|
4130
|
+
const groupsLength = groupBy.length;
|
|
3727
4131
|
let expandedGroupsLevel = 0;
|
|
3728
4132
|
const { dataArray } = getDataSourceState();
|
|
3729
4133
|
const len = dataArray.length;
|
|
@@ -3737,20 +4141,20 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3737
4141
|
const currentState = getComponentState();
|
|
3738
4142
|
const { computedColumns } = currentState;
|
|
3739
4143
|
let updated = false;
|
|
3740
|
-
const columnVisibility =
|
|
4144
|
+
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
3741
4145
|
const cols = computedColumns;
|
|
3742
|
-
|
|
3743
|
-
const colId =
|
|
3744
|
-
|
|
4146
|
+
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
4147
|
+
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
4148
|
+
let col = cols.get(colId);
|
|
3745
4149
|
if (!col) {
|
|
3746
4150
|
return;
|
|
3747
4151
|
}
|
|
3748
|
-
const shouldBeHidden = index > expandedGroupsLevel;
|
|
4152
|
+
const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
|
|
3749
4153
|
updated = true;
|
|
3750
|
-
if (shouldBeHidden
|
|
3751
|
-
columnVisibility
|
|
4154
|
+
if (shouldBeHidden) {
|
|
4155
|
+
columnVisibility[colId] = false;
|
|
3752
4156
|
} else {
|
|
3753
|
-
columnVisibility
|
|
4157
|
+
delete columnVisibility[colId];
|
|
3754
4158
|
}
|
|
3755
4159
|
});
|
|
3756
4160
|
if (updated) {
|
|
@@ -3760,7 +4164,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3760
4164
|
getDataSourceState,
|
|
3761
4165
|
groupRenderStrategy,
|
|
3762
4166
|
generatedColumns,
|
|
3763
|
-
|
|
4167
|
+
groupBy,
|
|
3764
4168
|
groupRowsMap,
|
|
3765
4169
|
hideEmptyGroupColumns ? groupRowsState : null,
|
|
3766
4170
|
hideEmptyGroupColumns
|
|
@@ -3769,7 +4173,7 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
3769
4173
|
function getColumnsWhenGrouping(params) {
|
|
3770
4174
|
const {
|
|
3771
4175
|
pivotColumns,
|
|
3772
|
-
|
|
4176
|
+
groupBy,
|
|
3773
4177
|
groupColumn,
|
|
3774
4178
|
groupRenderStrategy,
|
|
3775
4179
|
toggleGroupRow,
|
|
@@ -3783,10 +4187,10 @@ function getColumnsWhenGrouping(params) {
|
|
|
3783
4187
|
}
|
|
3784
4188
|
const computedColumns = new Map();
|
|
3785
4189
|
if (groupRenderStrategy === "multi-column") {
|
|
3786
|
-
|
|
4190
|
+
groupBy.forEach((groupByForColumn, groupIndexForColumn, arr) => {
|
|
3787
4191
|
const generatedGroupColumn = getColumnForGroupBy({
|
|
3788
4192
|
groupByForColumn,
|
|
3789
|
-
|
|
4193
|
+
groupBy,
|
|
3790
4194
|
groupIndexForColumn,
|
|
3791
4195
|
groupCount: arr.length,
|
|
3792
4196
|
groupRenderStrategy
|
|
@@ -3795,8 +4199,8 @@ function getColumnsWhenGrouping(params) {
|
|
|
3795
4199
|
});
|
|
3796
4200
|
} else if (groupRenderStrategy === "single-column") {
|
|
3797
4201
|
const singleGroupColumn = getSingleGroupColumn({
|
|
3798
|
-
groupCount:
|
|
3799
|
-
|
|
4202
|
+
groupCount: groupBy.length,
|
|
4203
|
+
groupBy,
|
|
3800
4204
|
groupRenderStrategy
|
|
3801
4205
|
}, toggleGroupRow, groupColumn);
|
|
3802
4206
|
computedColumns.set(singleGroupColumn.id || "group-by", singleGroupColumn);
|
|
@@ -3813,7 +4217,8 @@ function useComputed() {
|
|
|
3813
4217
|
const { componentActions, componentState } = useComponentState();
|
|
3814
4218
|
const {
|
|
3815
4219
|
componentActions: dataSourceActions,
|
|
3816
|
-
componentState: dataSourceState
|
|
4220
|
+
componentState: dataSourceState,
|
|
4221
|
+
getState: getDataSourceState
|
|
3817
4222
|
} = useDataSourceContextValue();
|
|
3818
4223
|
const {
|
|
3819
4224
|
columnOrder,
|
|
@@ -3821,7 +4226,8 @@ function useComputed() {
|
|
|
3821
4226
|
columnPinning,
|
|
3822
4227
|
columnSizing,
|
|
3823
4228
|
columnTypes,
|
|
3824
|
-
bodySize
|
|
4229
|
+
bodySize,
|
|
4230
|
+
showSeparatePivotColumnForSingleAggregation
|
|
3825
4231
|
} = componentState;
|
|
3826
4232
|
useState5(() => {
|
|
3827
4233
|
componentState.onRowHeightCSSVarChange.onChange((rowHeight) => {
|
|
@@ -3835,7 +4241,9 @@ function useComputed() {
|
|
|
3835
4241
|
}
|
|
3836
4242
|
});
|
|
3837
4243
|
});
|
|
3838
|
-
|
|
4244
|
+
useEffect10(() => {
|
|
4245
|
+
dataSourceActions.showSeparatePivotColumnForSingleAggregation = showSeparatePivotColumnForSingleAggregation;
|
|
4246
|
+
}, [showSeparatePivotColumnForSingleAggregation]);
|
|
3839
4247
|
const { multiSort } = dataSourceState;
|
|
3840
4248
|
useColumnGroups();
|
|
3841
4249
|
useColumnsWhen();
|
|
@@ -3843,7 +4251,7 @@ function useComputed() {
|
|
|
3843
4251
|
var _a2;
|
|
3844
4252
|
const newSortInfo = multiSort ? sortInfo : (_a2 = sortInfo[0]) != null ? _a2 : null;
|
|
3845
4253
|
dataSourceActions.sortInfo = newSortInfo;
|
|
3846
|
-
}, []);
|
|
4254
|
+
}, [getDataSourceState]);
|
|
3847
4255
|
const columns = componentState.computedColumns;
|
|
3848
4256
|
const {
|
|
3849
4257
|
computedColumnOrder,
|
|
@@ -3994,11 +4402,11 @@ function VerticalScrollbarPlaceholderFn(props) {
|
|
|
3994
4402
|
var VerticalScrollbarPlaceholder = memo2(VerticalScrollbarPlaceholderFn);
|
|
3995
4403
|
|
|
3996
4404
|
// src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts
|
|
3997
|
-
var
|
|
4405
|
+
var import_createRuntimeFn3 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
3998
4406
|
var CellCls = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
|
|
3999
4407
|
var HeaderCellProxy = "_12zfob10";
|
|
4000
|
-
var HeaderCellRecipe = (0,
|
|
4001
|
-
var HeaderClsRecipe = (0,
|
|
4408
|
+
var HeaderCellRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob1c", variantClassNames: { dragging: { true: "_12zfob1d", false: "_12zfob1e" }, first: { true: "_12zfob1f", false: "_12zfob1g" }, last: { true: "_12zfob1h", false: "_12zfob1i" }, groupByField: { true: "_12zfob1j", false: "_12zfob1k" }, firstInCategory: { true: "_12zfob1l", false: "_12zfob1m" }, lastInCategory: { true: "_12zfob1n", false: "_12zfob1o" }, pinned: { start: "_12zfob1p", end: "_12zfob1q", false: "_12zfob1r" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_12zfob1s"], [{ pinned: "end", firstInCategory: true }, "_12zfob1t"], [{ pinned: false, lastInCategory: true }, "_12zfob1u"]] });
|
|
4409
|
+
var HeaderClsRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob12 _16lm1iw10", variantClassNames: { pinned: { start: "_12zfob13", end: "_12zfob14", false: "_12zfob15" }, virtualized: { true: "_12zfob16", false: "_12zfob17" }, overflow: { true: "_12zfob18", false: "_12zfob19" } }, defaultVariants: {}, compoundVariants: [[{ overflow: true, pinned: "start" }, "_12zfob1a"], [{ overflow: true, pinned: "end" }, "_12zfob1b"]] });
|
|
4002
4410
|
var HeaderGroupCls = "_16lm1iwz _16lm1iwj";
|
|
4003
4411
|
var HeaderGroup_Children = "_16lm1iwj _16lm1iw10 _16lm1iw12 _16lm1iwc";
|
|
4004
4412
|
var HeaderGroup_Header = "_12zfob1x _16lm1iwj _16lm1iw10 _16lm1iw11";
|
|
@@ -4026,18 +4434,18 @@ import {
|
|
|
4026
4434
|
} from "react";
|
|
4027
4435
|
|
|
4028
4436
|
// src/components/InfiniteTable/hooks/useInfiniteTableState.ts
|
|
4029
|
-
import { useContext as
|
|
4437
|
+
import { useContext as useContext4 } from "react";
|
|
4030
4438
|
var useInfiniteTableState = () => {
|
|
4031
4439
|
const TableContext2 = getInfiniteTableContext();
|
|
4032
|
-
const { componentState } =
|
|
4440
|
+
const { componentState } = useContext4(TableContext2);
|
|
4033
4441
|
return componentState;
|
|
4034
4442
|
};
|
|
4035
4443
|
|
|
4036
4444
|
// src/components/InfiniteTable/components/cell.css.ts
|
|
4037
|
-
var
|
|
4445
|
+
var import_createRuntimeFn4 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
4038
4446
|
var CellCls2 = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
|
|
4039
4447
|
var CellClsVariants = { shifting: "_1eexc2a3", dragging: "_1eexc2a4" };
|
|
4040
|
-
var ColumnCellRecipe = (0,
|
|
4448
|
+
var ColumnCellRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "_16lm1iw2 _16lm1iwo _16lm1iw7 _16lm1iwr", variantClassNames: { dragging: { false: "_1eexc2a7" }, first: { true: "_1eexc2a8", false: "_1eexc2a9" }, last: { true: "_1eexc2aa", false: "_1eexc2ab" }, groupByField: { true: "_1eexc2ac", false: "_1eexc2ad" }, firstInCategory: { true: "_1eexc2ae", false: "_1eexc2af" }, lastInCategory: { true: "_1eexc2ag", false: "_1eexc2ah" }, pinned: { start: "_1eexc2ai", end: "_1eexc2aj", false: "_1eexc2ak" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_1eexc2al"], [{ pinned: "end", firstInCategory: true }, "_1eexc2am"]] });
|
|
4041
4449
|
var columnAlignCellStyle = { center: "_1eexc2a0", start: "_1eexc2a1", end: "_1eexc2a2" };
|
|
4042
4450
|
|
|
4043
4451
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx
|
|
@@ -4097,7 +4505,7 @@ var InfiniteTableCell = memo3(InfiniteTableCellFn);
|
|
|
4097
4505
|
var import_binary_search = __toModule(require_binary_search());
|
|
4098
4506
|
import {
|
|
4099
4507
|
useCallback as useCallback6,
|
|
4100
|
-
useMemo as
|
|
4508
|
+
useMemo as useMemo5,
|
|
4101
4509
|
useRef as useRef7,
|
|
4102
4510
|
useState as useState6
|
|
4103
4511
|
} from "react";
|
|
@@ -4144,8 +4552,8 @@ var useColumnPointerEvents = ({
|
|
|
4144
4552
|
const dragging = draggingDiff != null;
|
|
4145
4553
|
const { componentActions, computed } = useInfiniteTable();
|
|
4146
4554
|
const { computedColumnOrder } = computed;
|
|
4147
|
-
const column =
|
|
4148
|
-
const { columnIndex, columnWidth, columnsArray } =
|
|
4555
|
+
const column = useMemo5(() => columns.get(columnId), [columnId, columns]);
|
|
4556
|
+
const { columnIndex, columnWidth, columnsArray } = useMemo5(() => {
|
|
4149
4557
|
const columnsArray2 = Array.from(columns.values());
|
|
4150
4558
|
return {
|
|
4151
4559
|
columnsArray: columnsArray2,
|
|
@@ -4468,10 +4876,10 @@ import {
|
|
|
4468
4876
|
createElement as createElement12,
|
|
4469
4877
|
memo as memo4
|
|
4470
4878
|
} from "react";
|
|
4471
|
-
import { useLayoutEffect as
|
|
4879
|
+
import { useLayoutEffect as useLayoutEffect3, useState as useState8 } from "react";
|
|
4472
4880
|
function AvoidReactDiffFn(props) {
|
|
4473
4881
|
const [children, setChildren] = useState8(props.updater.get());
|
|
4474
|
-
|
|
4882
|
+
useLayoutEffect3(() => {
|
|
4475
4883
|
const remove = props.updater.onChange((children2) => {
|
|
4476
4884
|
setChildren(children2);
|
|
4477
4885
|
});
|
|
@@ -4482,7 +4890,7 @@ function AvoidReactDiffFn(props) {
|
|
|
4482
4890
|
var AvoidReactDiff = memo4(AvoidReactDiffFn);
|
|
4483
4891
|
|
|
4484
4892
|
// src/components/RawList/useVirtualRenderer.ts
|
|
4485
|
-
import { useMemo as
|
|
4893
|
+
import { useMemo as useMemo6 } from "react";
|
|
4486
4894
|
|
|
4487
4895
|
// src/components/RawList/ReactVirtualRenderer.tsx
|
|
4488
4896
|
import {
|
|
@@ -4798,7 +5206,7 @@ function createRenderer(brain) {
|
|
|
4798
5206
|
function useVirtualRenderer({
|
|
4799
5207
|
brain
|
|
4800
5208
|
}) {
|
|
4801
|
-
return
|
|
5209
|
+
return useMemo6(() => {
|
|
4802
5210
|
return createRenderer(brain);
|
|
4803
5211
|
}, [brain]);
|
|
4804
5212
|
}
|
|
@@ -4890,7 +5298,7 @@ var InfiniteTableHeader = memo6(InfiniteTableHeaderFn);
|
|
|
4890
5298
|
import {
|
|
4891
5299
|
createElement as createElement18,
|
|
4892
5300
|
memo as memo7,
|
|
4893
|
-
useMemo as
|
|
5301
|
+
useMemo as useMemo7,
|
|
4894
5302
|
useRef as useRef10
|
|
4895
5303
|
} from "react";
|
|
4896
5304
|
|
|
@@ -5104,7 +5512,7 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
|
|
|
5104
5512
|
} = useInfiniteTable();
|
|
5105
5513
|
const domRef = useRef10(null);
|
|
5106
5514
|
const hasColumnGroups = computedColumnGroups.size > 0;
|
|
5107
|
-
const columnHeaderGroups =
|
|
5515
|
+
const columnHeaderGroups = useMemo7(() => {
|
|
5108
5516
|
return hasColumnGroups ? renderColumnHeaderGroups({
|
|
5109
5517
|
columnGroups: computedColumnGroups,
|
|
5110
5518
|
columnGroupsDepthsMap,
|
|
@@ -5189,6 +5597,9 @@ function TableHeaderWrapper(props) {
|
|
|
5189
5597
|
const hasPinnedStart = computedPinnedStartColumns.length > 0;
|
|
5190
5598
|
const hasPinnedEnd = computedPinnedEndColumns.length > 0;
|
|
5191
5599
|
const height = columnGroupsMaxDepth ? columnGroupsMaxDepth * headerHeight : headerHeight;
|
|
5600
|
+
const unvirtualizedStyle = !virtualizeHeader && computedPinnedStartColumnsWidth ? {
|
|
5601
|
+
left: computedPinnedStartWidth
|
|
5602
|
+
} : void 0;
|
|
5192
5603
|
const header = virtualizeHeader ? /* @__PURE__ */ createElement19(InfiniteTableHeader, {
|
|
5193
5604
|
columns: computedUnpinnedColumns,
|
|
5194
5605
|
repaintId: virtualizeHeader ? repaintId : void 0,
|
|
@@ -5203,6 +5614,7 @@ function TableHeaderWrapper(props) {
|
|
|
5203
5614
|
availableWidth: computedUnpinnedColumnsWidth,
|
|
5204
5615
|
totalWidth: computedUnpinnedColumnsWidth
|
|
5205
5616
|
}) : /* @__PURE__ */ createElement19(InfiniteTableHeaderUnvirtualized, {
|
|
5617
|
+
style: unvirtualizedStyle,
|
|
5206
5618
|
brain,
|
|
5207
5619
|
scrollable: true,
|
|
5208
5620
|
pinning: false,
|
|
@@ -5359,7 +5771,7 @@ import {
|
|
|
5359
5771
|
import { useRef as useRef12, useEffect as useEffect17, useState as useState9 } from "react";
|
|
5360
5772
|
|
|
5361
5773
|
// src/components/VirtualList/VirtualList.css.ts
|
|
5362
|
-
var VirtualListCls = "
|
|
5774
|
+
var VirtualListCls = "_16lm1iw1 _16lm1iw8 _16lm1iw0";
|
|
5363
5775
|
var VirtualListClsOrientation = { horizontal: "mlx2t1", vertical: "mlx2t2" };
|
|
5364
5776
|
var scrollTransformTargetCls = "mlx2t3";
|
|
5365
5777
|
|
|
@@ -5513,32 +5925,38 @@ function InfiniteTableColumnCellFn(props) {
|
|
|
5513
5925
|
const groupRowInfo = null;
|
|
5514
5926
|
let value = isGroupRow && groupBy && column.groupByField ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
|
|
5515
5927
|
if (column.valueGetter) {
|
|
5516
|
-
value = column.valueGetter({
|
|
5517
|
-
data,
|
|
5518
|
-
rowInfo
|
|
5519
|
-
|
|
5928
|
+
value = column.valueGetter(isGroupRow ? {
|
|
5929
|
+
data: rowInfo.data,
|
|
5930
|
+
rowInfo
|
|
5931
|
+
} : {
|
|
5932
|
+
data: rowInfo.data,
|
|
5933
|
+
rowInfo
|
|
5520
5934
|
});
|
|
5521
5935
|
}
|
|
5522
5936
|
const { componentState: computedDataSource } = useDataSourceContextValue();
|
|
5523
|
-
const
|
|
5524
|
-
value,
|
|
5525
|
-
column,
|
|
5937
|
+
const rest = rowInfo.isGroupRow ? {
|
|
5526
5938
|
rowInfo,
|
|
5527
|
-
data
|
|
5939
|
+
data: rowInfo.data
|
|
5940
|
+
} : {
|
|
5941
|
+
rowInfo,
|
|
5942
|
+
data: rowInfo.data
|
|
5528
5943
|
};
|
|
5944
|
+
const stylingRenderParam = __spreadValues({
|
|
5945
|
+
value,
|
|
5946
|
+
column
|
|
5947
|
+
}, rest);
|
|
5529
5948
|
let renderValue = value;
|
|
5530
5949
|
if (column.render || column.renderValue) {
|
|
5531
|
-
const renderParam = {
|
|
5950
|
+
const renderParam = __spreadProps(__spreadValues({
|
|
5532
5951
|
value,
|
|
5533
5952
|
column,
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
data,
|
|
5953
|
+
groupRowInfo
|
|
5954
|
+
}, rest), {
|
|
5537
5955
|
rowIndex,
|
|
5538
5956
|
toggleGroupRow,
|
|
5539
5957
|
toggleCurrentGroupRow: () => toggleGroupRow(rowInfo.groupKeys),
|
|
5540
|
-
|
|
5541
|
-
};
|
|
5958
|
+
groupBy: computedDataSource.groupBy
|
|
5959
|
+
});
|
|
5542
5960
|
if (column.render) {
|
|
5543
5961
|
renderValue = column.render(renderParam);
|
|
5544
5962
|
} else if (column.renderValue) {
|
|
@@ -5620,12 +6038,11 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
|
|
|
5620
6038
|
domRefFromProps(node);
|
|
5621
6039
|
domRef.current = node;
|
|
5622
6040
|
}, []);
|
|
5623
|
-
const
|
|
5624
|
-
|
|
5625
|
-
rowInfo,
|
|
6041
|
+
const rest = rowInfo.isGroupRow ? { data: rowInfo.data, rowInfo } : { data: rowInfo.data, rowInfo };
|
|
6042
|
+
const rowPropsAndStyleArgs = __spreadProps(__spreadValues({}, rest), {
|
|
5626
6043
|
rowIndex,
|
|
5627
|
-
|
|
5628
|
-
};
|
|
6044
|
+
groupBy: rowInfo.groupBy
|
|
6045
|
+
});
|
|
5629
6046
|
if (typeof rowProps === "function") {
|
|
5630
6047
|
rowProps = rowProps(rowPropsAndStyleArgs);
|
|
5631
6048
|
}
|
|
@@ -5894,17 +6311,16 @@ function useUnpinnedRendering(params) {
|
|
|
5894
6311
|
import { useCallback as useCallback13, useEffect as useEffect18, useRef as useRef15 } from "react";
|
|
5895
6312
|
|
|
5896
6313
|
// src/components/InfiniteTable/InfiniteCls.css.ts
|
|
5897
|
-
var
|
|
6314
|
+
var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
5898
6315
|
var FooterCls = "_16lm1iw1";
|
|
5899
6316
|
var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwj _16lm1iwz _16lm1iw0";
|
|
5900
|
-
var InfiniteClsRecipe = (0,
|
|
6317
|
+
var InfiniteClsRecipe = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { focused: { true: "_1yeub2v2", false: "_1yeub2v3" }, focusedWithin: { true: "_1yeub2v4", false: "_1yeub2v5" }, hasPinnedStart: { true: "_1yeub2v6", false: "_1yeub2v7" }, hasPinnedEnd: { true: "_1yeub2v8", false: "_1yeub2v9" }, hasPinnedStartOverflow: { true: "_1yeub2va", false: "_1yeub2vb" }, hasPinnedEndOverflow: { true: "_1yeub2vc", false: "_1yeub2vd" } }, defaultVariants: {}, compoundVariants: [] });
|
|
5901
6318
|
var InfiniteClsScrolling = "_1yeub2v1";
|
|
5902
6319
|
var InfiniteClsShiftingColumns = "_16lm1iwm";
|
|
5903
6320
|
var PinnedRowsClsVariants = { pinnedStart: "_1yeub2ve", pinnedEnd: "_1yeub2vf", overflow: "_1yeub2vg" };
|
|
5904
|
-
var PinnedRowsContainerClsVariants = (0,
|
|
6321
|
+
var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
|
|
5905
6322
|
|
|
5906
6323
|
// src/components/InfiniteTable/hooks/useOnContainerScroll.ts
|
|
5907
|
-
var DELAY = 200;
|
|
5908
6324
|
var TableClassName = internalProps.rootClassName;
|
|
5909
6325
|
var TableClassName__Scrolling = `${TableClassName}--scrolling`;
|
|
5910
6326
|
var SCROLL_BOTTOM_OFFSET = 1;
|
|
@@ -5915,15 +6331,25 @@ var useOnContainerScroll = ({
|
|
|
5915
6331
|
}) => {
|
|
5916
6332
|
const {
|
|
5917
6333
|
componentState: {
|
|
6334
|
+
scrollStopDelay,
|
|
5918
6335
|
scrollerDOMRef,
|
|
5919
6336
|
domRef,
|
|
5920
6337
|
scrollToBottomOffset,
|
|
5921
6338
|
onScrollToBottom,
|
|
5922
6339
|
onScrollToTop,
|
|
6340
|
+
onScrollStop: onScrollStopFromProps,
|
|
5923
6341
|
bodySize
|
|
5924
6342
|
}
|
|
5925
6343
|
} = useInfiniteTable();
|
|
5926
|
-
const {
|
|
6344
|
+
const {
|
|
6345
|
+
componentActions: dataSourceActions,
|
|
6346
|
+
getState: getDataSourceState,
|
|
6347
|
+
componentState: { notifyScrollStop }
|
|
6348
|
+
} = useDataSourceContextValue();
|
|
6349
|
+
const onScrollStop = useCallback13((param) => {
|
|
6350
|
+
onScrollStopFromProps == null ? void 0 : onScrollStopFromProps(param);
|
|
6351
|
+
notifyScrollStop(param);
|
|
6352
|
+
}, [onScrollStopFromProps, notifyScrollStop]);
|
|
5927
6353
|
const timeoutIdRef = useRef15(0);
|
|
5928
6354
|
const scrollingRef = useRef15(false);
|
|
5929
6355
|
const scrollTopMaxRef = useRef15(0);
|
|
@@ -5942,9 +6368,17 @@ var useOnContainerScroll = ({
|
|
|
5942
6368
|
timeoutIdRef.current = setTimeout(() => {
|
|
5943
6369
|
setScrolling(false);
|
|
5944
6370
|
timeoutIdRef.current = 0;
|
|
5945
|
-
},
|
|
6371
|
+
}, scrollStopDelay);
|
|
5946
6372
|
}
|
|
5947
6373
|
if (prevScrolling !== scrolling) {
|
|
6374
|
+
if (!scrolling) {
|
|
6375
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
6376
|
+
onScrollStop({
|
|
6377
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6378
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
6379
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
6380
|
+
});
|
|
6381
|
+
}
|
|
5948
6382
|
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
5949
6383
|
if (!classList) {
|
|
5950
6384
|
return;
|
|
@@ -5955,7 +6389,7 @@ var useOnContainerScroll = ({
|
|
|
5955
6389
|
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
5956
6390
|
}
|
|
5957
6391
|
}
|
|
5958
|
-
}, []);
|
|
6392
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
5959
6393
|
const onContainerScroll = useCallback13((scrollInfo) => {
|
|
5960
6394
|
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
5961
6395
|
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
@@ -5985,7 +6419,7 @@ var useOnContainerScroll = ({
|
|
|
5985
6419
|
if (isScrollBottom) {
|
|
5986
6420
|
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
5987
6421
|
if (getDataSourceState().livePagination) {
|
|
5988
|
-
dataSourceActions.
|
|
6422
|
+
dataSourceActions.cursorId = Date.now();
|
|
5989
6423
|
}
|
|
5990
6424
|
}
|
|
5991
6425
|
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
@@ -5998,7 +6432,7 @@ var useOnContainerScroll = ({
|
|
|
5998
6432
|
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
5999
6433
|
import {
|
|
6000
6434
|
createElement as createElement29,
|
|
6001
|
-
useMemo as
|
|
6435
|
+
useMemo as useMemo8
|
|
6002
6436
|
} from "react";
|
|
6003
6437
|
import { useCallback as useCallback15 } from "react";
|
|
6004
6438
|
|
|
@@ -6104,7 +6538,7 @@ function PinnedRowsContainer(props) {
|
|
|
6104
6538
|
brain,
|
|
6105
6539
|
renderRow
|
|
6106
6540
|
} = props;
|
|
6107
|
-
const style =
|
|
6541
|
+
const style = useMemo8(() => {
|
|
6108
6542
|
const result = pinning === "end" ? {
|
|
6109
6543
|
width: rowWidth,
|
|
6110
6544
|
height,
|
|
@@ -6277,6 +6711,15 @@ function usePinnedStartRendering(params) {
|
|
|
6277
6711
|
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6278
6712
|
import { useEffect as useEffect21 } from "react";
|
|
6279
6713
|
|
|
6714
|
+
// src/components/hooks/useOnce.ts
|
|
6715
|
+
import { useMemo as useMemo9 } from "react";
|
|
6716
|
+
function useOnce(fn) {
|
|
6717
|
+
const onceFn = useMemo9(() => {
|
|
6718
|
+
return once(fn);
|
|
6719
|
+
}, []);
|
|
6720
|
+
return onceFn();
|
|
6721
|
+
}
|
|
6722
|
+
|
|
6280
6723
|
// src/components/VirtualBrain/index.ts
|
|
6281
6724
|
var import_binary_search2 = __toModule(require_binary_search());
|
|
6282
6725
|
var initialScrollPosition2 = {
|
|
@@ -6866,7 +7309,6 @@ function useListRendering(param) {
|
|
|
6866
7309
|
setColumnVisibility: (columnVisibility) => {
|
|
6867
7310
|
componentActions.columnVisibility = columnVisibility;
|
|
6868
7311
|
},
|
|
6869
|
-
setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations,
|
|
6870
7312
|
getState,
|
|
6871
7313
|
getDataSourceState
|
|
6872
7314
|
};
|
|
@@ -7173,7 +7615,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7173
7615
|
const valid = useMemo11(() => {
|
|
7174
7616
|
let valid2 = isValidLicense(licenseKey, {
|
|
7175
7617
|
publishedAt: 1624970570587,
|
|
7176
|
-
version: "0.
|
|
7618
|
+
version: "0.1.3"
|
|
7177
7619
|
});
|
|
7178
7620
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7179
7621
|
return true;
|
|
@@ -7187,7 +7629,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7187
7629
|
import {
|
|
7188
7630
|
createElement as createElement31,
|
|
7189
7631
|
useCallback as useCallback19,
|
|
7190
|
-
useLayoutEffect as
|
|
7632
|
+
useLayoutEffect as useLayoutEffect4
|
|
7191
7633
|
} from "react";
|
|
7192
7634
|
import { useRef as useRef19 } from "react";
|
|
7193
7635
|
var error = err("CSSVariableWatch");
|
|
@@ -7210,7 +7652,7 @@ var useCSSVariableWatch = (params) => {
|
|
|
7210
7652
|
}
|
|
7211
7653
|
}, [params.onChange]);
|
|
7212
7654
|
useResizeObserver(params.ref, onResize, { earlyAttach: true });
|
|
7213
|
-
|
|
7655
|
+
useLayoutEffect4(() => {
|
|
7214
7656
|
const value = params.ref.current.getBoundingClientRect().height;
|
|
7215
7657
|
if (value) {
|
|
7216
7658
|
lastValueRef.current = value;
|
|
@@ -7412,7 +7854,7 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
|
|
|
7412
7854
|
const licenseValid = useLicense(licenseKey);
|
|
7413
7855
|
const domProps = useDOMProps(componentState.domProps);
|
|
7414
7856
|
const LoadMaskCmp = (_a = components == null ? void 0 : components.LoadMask) != null ? _a : LoadMask;
|
|
7415
|
-
|
|
7857
|
+
useLayoutEffect5(() => {
|
|
7416
7858
|
const dataSourceState = getDataSourceState();
|
|
7417
7859
|
const { onScrollbarsChange } = getInfiniteTableState();
|
|
7418
7860
|
const { notifyScrollbarsChange } = dataSourceState;
|
|
@@ -7518,5 +7960,6 @@ export {
|
|
|
7518
7960
|
interceptMap,
|
|
7519
7961
|
multisort,
|
|
7520
7962
|
useComponentState,
|
|
7521
|
-
useDataSource
|
|
7963
|
+
useDataSource,
|
|
7964
|
+
useEffectWithChanges
|
|
7522
7965
|
};
|