@infinite-table/infinite-react 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +5 -5
- package/index.d.ts +99 -3
- package/index.esm.css +5 -5
- package/index.esm.js +6496 -6349
- package/index.js +1870 -1727
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -54,6 +54,40 @@ var __toModule = (module2) => {
|
|
|
54
54
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
// node_modules/binary-search/index.js
|
|
58
|
+
var require_binary_search = __commonJS({
|
|
59
|
+
"node_modules/binary-search/index.js"(exports, module2) {
|
|
60
|
+
module2.exports = function(haystack, needle, comparator, low, high) {
|
|
61
|
+
var mid, cmp;
|
|
62
|
+
if (low === void 0)
|
|
63
|
+
low = 0;
|
|
64
|
+
else {
|
|
65
|
+
low = low | 0;
|
|
66
|
+
if (low < 0 || low >= haystack.length)
|
|
67
|
+
throw new RangeError("invalid lower bound");
|
|
68
|
+
}
|
|
69
|
+
if (high === void 0)
|
|
70
|
+
high = haystack.length - 1;
|
|
71
|
+
else {
|
|
72
|
+
high = high | 0;
|
|
73
|
+
if (high < low || high >= haystack.length)
|
|
74
|
+
throw new RangeError("invalid upper bound");
|
|
75
|
+
}
|
|
76
|
+
while (low <= high) {
|
|
77
|
+
mid = low + (high - low >>> 1);
|
|
78
|
+
cmp = +comparator(haystack[mid], needle, mid, haystack);
|
|
79
|
+
if (cmp < 0)
|
|
80
|
+
low = mid + 1;
|
|
81
|
+
else if (cmp > 0)
|
|
82
|
+
high = mid - 1;
|
|
83
|
+
else
|
|
84
|
+
return mid;
|
|
85
|
+
}
|
|
86
|
+
return ~low;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
57
91
|
// node_modules/ms/index.js
|
|
58
92
|
var require_ms = __commonJS({
|
|
59
93
|
"node_modules/ms/index.js"(exports, module2) {
|
|
@@ -587,40 +621,6 @@ var require_vanilla_extract_recipes_createRuntimeFn_cjs = __commonJS({
|
|
|
587
621
|
}
|
|
588
622
|
});
|
|
589
623
|
|
|
590
|
-
// node_modules/binary-search/index.js
|
|
591
|
-
var require_binary_search = __commonJS({
|
|
592
|
-
"node_modules/binary-search/index.js"(exports, module2) {
|
|
593
|
-
module2.exports = function(haystack, needle, comparator, low, high) {
|
|
594
|
-
var mid, cmp;
|
|
595
|
-
if (low === void 0)
|
|
596
|
-
low = 0;
|
|
597
|
-
else {
|
|
598
|
-
low = low | 0;
|
|
599
|
-
if (low < 0 || low >= haystack.length)
|
|
600
|
-
throw new RangeError("invalid lower bound");
|
|
601
|
-
}
|
|
602
|
-
if (high === void 0)
|
|
603
|
-
high = haystack.length - 1;
|
|
604
|
-
else {
|
|
605
|
-
high = high | 0;
|
|
606
|
-
if (high < low || high >= haystack.length)
|
|
607
|
-
throw new RangeError("invalid upper bound");
|
|
608
|
-
}
|
|
609
|
-
while (low <= high) {
|
|
610
|
-
mid = low + (high - low >>> 1);
|
|
611
|
-
cmp = +comparator(haystack[mid], needle, mid, haystack);
|
|
612
|
-
if (cmp < 0)
|
|
613
|
-
low = mid + 1;
|
|
614
|
-
else if (cmp > 0)
|
|
615
|
-
high = mid - 1;
|
|
616
|
-
else
|
|
617
|
-
return mid;
|
|
618
|
-
}
|
|
619
|
-
return ~low;
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
|
|
624
624
|
// src/index.tsx
|
|
625
625
|
__export(exports, {
|
|
626
626
|
DataSource: () => DataSource,
|
|
@@ -685,15 +685,124 @@ function buildSubscriptionCallback() {
|
|
|
685
685
|
return updater;
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
// src/components/VirtualBrain/
|
|
688
|
+
// src/components/VirtualBrain/index.ts
|
|
689
|
+
var import_binary_search = __toModule(require_binary_search());
|
|
690
|
+
|
|
691
|
+
// src/utils/debug.ts
|
|
692
|
+
var debug = require_browser();
|
|
693
|
+
var debugTable = debug(`InfiniteTable`);
|
|
694
|
+
var dbg = (channelName) => {
|
|
695
|
+
const result = debugTable.extend(channelName);
|
|
696
|
+
result.log = console.log.bind(console);
|
|
697
|
+
return result;
|
|
698
|
+
};
|
|
699
|
+
var err = (channelName) => {
|
|
700
|
+
const result = debugTable.extend(`${channelName}:error`);
|
|
701
|
+
result.log = console.error.bind(console);
|
|
702
|
+
return result;
|
|
703
|
+
};
|
|
704
|
+
var emptyLogFn = () => emptyLogFn;
|
|
705
|
+
emptyLogFn.extend = () => emptyLogFn;
|
|
706
|
+
var Logger = class {
|
|
707
|
+
constructor(channelName) {
|
|
708
|
+
this.debug = emptyLogFn;
|
|
709
|
+
this.error = emptyLogFn;
|
|
710
|
+
if (true) {
|
|
711
|
+
this.debug = dbg(channelName);
|
|
712
|
+
this.error = err(channelName);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// src/components/VirtualBrain/index.ts
|
|
689
718
|
var initialScrollPosition = {
|
|
690
719
|
scrollLeft: 0,
|
|
691
720
|
scrollTop: 0
|
|
692
721
|
};
|
|
693
|
-
var
|
|
694
|
-
|
|
722
|
+
var raf = typeof window !== "undefined" ? requestAnimationFrame : (fn) => setTimeout(fn, 0);
|
|
723
|
+
var ItemIndexBag = Object.seal({ itemIndex: 0 });
|
|
724
|
+
var SORT_ASC = (a, b) => a - b;
|
|
725
|
+
var VirtualBrain = class extends Logger {
|
|
726
|
+
constructor(options) {
|
|
727
|
+
super(`VirtualBrain:${options.mainAxis}`);
|
|
695
728
|
this.scrollPosition = initialScrollPosition;
|
|
729
|
+
this.scrollPositionOnMainAxis = 0;
|
|
730
|
+
this.destroyed = false;
|
|
731
|
+
this.totalSize = 0;
|
|
696
732
|
this.onScrollFns = [];
|
|
733
|
+
this.onTotalSizeChangeFns = [];
|
|
734
|
+
this.onRenderCountChangeFns = [];
|
|
735
|
+
this.onRenderRangeChangeFns = [];
|
|
736
|
+
this.onDestroyFns = [];
|
|
737
|
+
this.renderCount = 0;
|
|
738
|
+
this.renderRange = {
|
|
739
|
+
renderStartIndex: -1,
|
|
740
|
+
renderEndIndex: -1
|
|
741
|
+
};
|
|
742
|
+
this.availableSize = { width: 0, height: 0 };
|
|
743
|
+
this.setAvailableSize = (size) => {
|
|
744
|
+
this.availableSize = size;
|
|
745
|
+
if (true) {
|
|
746
|
+
this.debug("New available size %d", size[this.options.mainAxis === "vertical" ? "height" : "width"]);
|
|
747
|
+
}
|
|
748
|
+
this.updateRenderCount();
|
|
749
|
+
};
|
|
750
|
+
this.computeRenderCount = ({
|
|
751
|
+
itemSize,
|
|
752
|
+
count,
|
|
753
|
+
size
|
|
754
|
+
}) => {
|
|
755
|
+
let renderCount = 0;
|
|
756
|
+
if (typeof itemSize === "function") {
|
|
757
|
+
const sizes = [];
|
|
758
|
+
for (let i = 0; i < count; i++) {
|
|
759
|
+
sizes.push(this.getItemSize(i));
|
|
760
|
+
}
|
|
761
|
+
sizes.sort(SORT_ASC);
|
|
762
|
+
let sum = 0;
|
|
763
|
+
for (let i = 0; i < count; i++) {
|
|
764
|
+
sum += sizes[i];
|
|
765
|
+
renderCount++;
|
|
766
|
+
if (sum > size) {
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
renderCount += 1;
|
|
771
|
+
} else {
|
|
772
|
+
renderCount = Math.ceil(size / itemSize) + 1;
|
|
773
|
+
}
|
|
774
|
+
renderCount = Math.min(count, renderCount);
|
|
775
|
+
return renderCount;
|
|
776
|
+
};
|
|
777
|
+
this.setRenderCount = (renderCount) => {
|
|
778
|
+
if (renderCount === this.renderCount) {
|
|
779
|
+
this.notifyTotalSizeChange();
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (true) {
|
|
783
|
+
this.debug("set renderCount to %d", renderCount);
|
|
784
|
+
}
|
|
785
|
+
this.renderCount = renderCount;
|
|
786
|
+
this.updateRenderRange();
|
|
787
|
+
this.notifyRenderCountChange();
|
|
788
|
+
this.notifyTotalSizeChange();
|
|
789
|
+
};
|
|
790
|
+
this.getRenderCount = () => {
|
|
791
|
+
var _a;
|
|
792
|
+
return (_a = this.renderCount) != null ? _a : 0;
|
|
793
|
+
};
|
|
794
|
+
this.setScrollPosition = (scrollPosition) => {
|
|
795
|
+
this.scrollPosition = scrollPosition;
|
|
796
|
+
const oldScrollPosOnMainAxis = this.scrollPositionOnMainAxis;
|
|
797
|
+
this.scrollPositionOnMainAxis = this.scrollPosition[this.options.mainAxis === "vertical" ? "scrollTop" : "scrollLeft"];
|
|
798
|
+
if (this.scrollPositionOnMainAxis !== oldScrollPosOnMainAxis) {
|
|
799
|
+
this.updateRenderRange();
|
|
800
|
+
}
|
|
801
|
+
this.notifyScrollChange();
|
|
802
|
+
};
|
|
803
|
+
this.getRenderRange = () => {
|
|
804
|
+
return this.renderRange;
|
|
805
|
+
};
|
|
697
806
|
this.getScrollPosition = () => {
|
|
698
807
|
return this.scrollPosition;
|
|
699
808
|
};
|
|
@@ -703,937 +812,1292 @@ var ScrollListener = class {
|
|
|
703
812
|
this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
|
|
704
813
|
};
|
|
705
814
|
};
|
|
706
|
-
this.
|
|
707
|
-
this.
|
|
708
|
-
|
|
815
|
+
this.onTotalSizeChange = (fn) => {
|
|
816
|
+
this.onTotalSizeChangeFns.push(fn);
|
|
817
|
+
return () => {
|
|
818
|
+
this.onTotalSizeChangeFns = this.onTotalSizeChangeFns.filter((f) => f !== fn);
|
|
819
|
+
};
|
|
709
820
|
};
|
|
710
|
-
this.
|
|
711
|
-
this.
|
|
821
|
+
this.onRenderCountChange = (fn) => {
|
|
822
|
+
this.onRenderCountChangeFns.push(fn);
|
|
823
|
+
return () => {
|
|
824
|
+
this.onRenderCountChangeFns = this.onRenderCountChangeFns.filter((f) => f !== fn);
|
|
825
|
+
};
|
|
712
826
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
742
|
-
function computeColumnGroupsDepths(columnGroups) {
|
|
743
|
-
const map2 = new Map();
|
|
744
|
-
columnGroups.forEach((colGroup, colGroupId) => {
|
|
745
|
-
let parentGroupId = colGroup.columnGroup;
|
|
746
|
-
let depth = 0;
|
|
747
|
-
while (parentGroupId) {
|
|
748
|
-
const parent = columnGroups.get(parentGroupId);
|
|
749
|
-
if (!parent) {
|
|
750
|
-
if (true) {
|
|
751
|
-
console.warn(`Cannot find column group ${parentGroupId}`);
|
|
752
|
-
}
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
depth++;
|
|
756
|
-
parentGroupId = parent.columnGroup;
|
|
757
|
-
}
|
|
758
|
-
map2.set(colGroupId, depth);
|
|
759
|
-
});
|
|
760
|
-
return map2;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
// src/components/InfiniteTable/state/getInitialState.ts
|
|
764
|
-
function initSetupState() {
|
|
765
|
-
const columnsGeneratedForGrouping = new Map();
|
|
766
|
-
return {
|
|
767
|
-
propsCache: new Map([]),
|
|
768
|
-
columnShifts: null,
|
|
769
|
-
domRef: (0, import_react2.createRef)(),
|
|
770
|
-
scrollerDOMRef: (0, import_react2.createRef)(),
|
|
771
|
-
portalDOMRef: (0, import_react2.createRef)(),
|
|
772
|
-
onRowHeightCSSVarChange: buildSubscriptionCallback(),
|
|
773
|
-
onHeaderHeightCSSVarChange: buildSubscriptionCallback(),
|
|
774
|
-
bodySize: {
|
|
775
|
-
width: 0,
|
|
776
|
-
height: 0
|
|
777
|
-
},
|
|
778
|
-
scrollPosition: {
|
|
779
|
-
scrollTop: 0,
|
|
780
|
-
scrollLeft: 0
|
|
781
|
-
},
|
|
782
|
-
focused: false,
|
|
783
|
-
focusedWithin: false,
|
|
784
|
-
columnsWhenGrouping: columnsGeneratedForGrouping,
|
|
785
|
-
draggingColumnId: null,
|
|
786
|
-
pinnedStartScrollListener: new ScrollListener(),
|
|
787
|
-
pinnedEndScrollListener: new ScrollListener(),
|
|
788
|
-
columnsWhenInlineGroupRenderStrategy: void 0
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
var forwardProps = (setupState) => {
|
|
792
|
-
return {
|
|
793
|
-
scrollTopId: 1,
|
|
794
|
-
components: 1,
|
|
795
|
-
loadingText: 1,
|
|
796
|
-
pivotColumns: 1,
|
|
797
|
-
groupColumn: 1,
|
|
798
|
-
onReady: 1,
|
|
799
|
-
domProps: 1,
|
|
800
|
-
focusedClassName: 1,
|
|
801
|
-
focusedWithinClassName: 1,
|
|
802
|
-
focusedStyle: 1,
|
|
803
|
-
focusedWithinStyle: 1,
|
|
804
|
-
onSelfFocus: 1,
|
|
805
|
-
onFocusWithin: 1,
|
|
806
|
-
onSelfBlur: 1,
|
|
807
|
-
onBlurWithin: 1,
|
|
808
|
-
onScrollToTop: 1,
|
|
809
|
-
onScrollToBottom: 1,
|
|
810
|
-
onScrollStop: 1,
|
|
811
|
-
scrollToBottomOffset: 1,
|
|
812
|
-
rowStyle: 1,
|
|
813
|
-
rowProps: 1,
|
|
814
|
-
rowClassName: 1,
|
|
815
|
-
pinnedStartMaxWidth: 1,
|
|
816
|
-
pinnedEndMaxWidth: 1,
|
|
817
|
-
pivotColumn: 1,
|
|
818
|
-
pivotColumnGroups: 1,
|
|
819
|
-
onScrollbarsChange: 1,
|
|
820
|
-
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
821
|
-
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
822
|
-
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
823
|
-
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
824
|
-
columnMaxWidth: (columnMaxWidth) => columnMaxWidth != null ? columnMaxWidth : 2e3,
|
|
825
|
-
columnDefaultWidth: (columnDefaultWidth) => columnDefaultWidth != null ? columnDefaultWidth : 200,
|
|
826
|
-
draggableColumns: (draggableColumns) => draggableColumns != null ? draggableColumns : true,
|
|
827
|
-
showSeparatePivotColumnForSingleAggregation: (showSeparatePivotColumnForSingleAggregation) => showSeparatePivotColumnForSingleAggregation != null ? showSeparatePivotColumnForSingleAggregation : false,
|
|
828
|
-
sortable: (sortable) => sortable != null ? sortable : true,
|
|
829
|
-
hideEmptyGroupColumns: (hideEmptyGroupColumns) => hideEmptyGroupColumns != null ? hideEmptyGroupColumns : false,
|
|
830
|
-
pivotTotalColumnPosition: (pivotTotalColumnPosition) => pivotTotalColumnPosition != null ? pivotTotalColumnPosition : "end",
|
|
831
|
-
licenseKey: (licenseKey) => licenseKey || "",
|
|
832
|
-
columnOrder: (columnOrder) => columnOrder != null ? columnOrder : true,
|
|
833
|
-
header: (header) => header != null ? header : true,
|
|
834
|
-
showZebraRows: (showZebraRows) => showZebraRows != null ? showZebraRows : true,
|
|
835
|
-
showHoverRows: (showHoverRows) => showHoverRows != null ? showHoverRows : true,
|
|
836
|
-
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
837
|
-
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
838
|
-
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
839
|
-
columns: (columns) => toMap(columns, setupState.propsCache.get("columns")),
|
|
840
|
-
columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
|
|
841
|
-
columnPinning: (columnPinning) => toMap(columnPinning, setupState.propsCache.get("columnPinning")),
|
|
842
|
-
columnSizing: (columnSizing) => columnSizing || {},
|
|
843
|
-
columnTypes: (columnTypes) => columnTypes || {},
|
|
844
|
-
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
845
|
-
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
846
|
-
};
|
|
847
|
-
};
|
|
848
|
-
function getGroupRenderStrategy(options) {
|
|
849
|
-
const { groupBy, groupColumn, groupRenderStrategy } = options;
|
|
850
|
-
if (groupRenderStrategy) {
|
|
851
|
-
return groupRenderStrategy;
|
|
852
|
-
}
|
|
853
|
-
if (groupColumn != null && typeof groupColumn === "object") {
|
|
854
|
-
return "single-column";
|
|
855
|
-
}
|
|
856
|
-
const columnsInGroupBy = groupBy.filter((g) => g.column);
|
|
857
|
-
if (columnsInGroupBy.length) {
|
|
858
|
-
return "multi-column";
|
|
859
|
-
}
|
|
860
|
-
return "multi-column";
|
|
861
|
-
}
|
|
862
|
-
var mapPropsToState = (params) => {
|
|
863
|
-
const { props, state, oldState, parentState } = params;
|
|
864
|
-
const { virtualizeColumns, header } = state;
|
|
865
|
-
const computedColumnGroups = state.pivotColumnGroups || state.columnGroups;
|
|
866
|
-
const virtualizeHeader = header && virtualizeColumns && (!computedColumnGroups || (computedColumnGroups == null ? void 0 : computedColumnGroups.size) === 0);
|
|
867
|
-
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;
|
|
868
|
-
const groupBy = parentState == null ? void 0 : parentState.groupBy;
|
|
869
|
-
const groupRenderStrategy = getGroupRenderStrategy({
|
|
870
|
-
groupRenderStrategy: props.groupRenderStrategy,
|
|
871
|
-
groupBy,
|
|
872
|
-
groupColumn: props.groupColumn
|
|
873
|
-
});
|
|
874
|
-
const computedColumns = state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
|
|
875
|
-
return {
|
|
876
|
-
controlledColumnVisibility: !!props.columnVisibility,
|
|
877
|
-
groupRenderStrategy,
|
|
878
|
-
groupBy,
|
|
879
|
-
computedColumns,
|
|
880
|
-
virtualizeHeader,
|
|
881
|
-
columnGroupsDepthsMap,
|
|
882
|
-
columnGroupsMaxDepth: columnGroupsDepthsMap != state.columnGroupsDepthsMap ? Math.max(...columnGroupsDepthsMap.values(), 0) : state.columnGroupsMaxDepth,
|
|
883
|
-
computedColumnGroups,
|
|
884
|
-
rowHeightCSSVar: typeof props.rowHeight === "string" ? props.rowHeight : "",
|
|
885
|
-
headerHeightCSSVar: typeof props.headerHeight === "string" ? props.headerHeight || "--ITableHeader__height" : ""
|
|
886
|
-
};
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
// src/components/ResizeObserver/index.tsx
|
|
890
|
-
var React = __toModule(require("react"));
|
|
891
|
-
var import_react3 = __toModule(require("react"));
|
|
892
|
-
var setupResizeObserver = (node, callback) => {
|
|
893
|
-
const RO = window.ResizeObserver;
|
|
894
|
-
const observer = new RO((entries) => {
|
|
895
|
-
var _a;
|
|
896
|
-
const entry = entries[0];
|
|
897
|
-
let { width, height } = entry.contentRect;
|
|
898
|
-
if ((_a = entry.borderBoxSize) == null ? void 0 : _a[0]) {
|
|
899
|
-
height = entry.borderBoxSize[0].blockSize;
|
|
900
|
-
width = entry.borderBoxSize[0].inlineSize;
|
|
901
|
-
} else {
|
|
902
|
-
const rect = node.getBoundingClientRect();
|
|
903
|
-
height = rect.height;
|
|
904
|
-
width = rect.width;
|
|
905
|
-
}
|
|
906
|
-
callback({ width, height });
|
|
907
|
-
});
|
|
908
|
-
observer.observe(node);
|
|
909
|
-
return () => {
|
|
910
|
-
observer.disconnect();
|
|
911
|
-
};
|
|
912
|
-
};
|
|
913
|
-
var useResizeObserver = (ref, callback, config = { earlyAttach: false }) => {
|
|
914
|
-
const sizeRef = (0, import_react3.useRef)({
|
|
915
|
-
width: 0,
|
|
916
|
-
height: 0
|
|
917
|
-
});
|
|
918
|
-
const effectFn = (callback2) => {
|
|
919
|
-
let disconnect;
|
|
920
|
-
if (ref.current) {
|
|
921
|
-
disconnect = setupResizeObserver(ref.current, (size) => {
|
|
922
|
-
size = {
|
|
923
|
-
width: Math.round(size.width),
|
|
924
|
-
height: Math.round(size.height)
|
|
925
|
-
};
|
|
926
|
-
const prevSize = sizeRef.current;
|
|
927
|
-
if (prevSize.width !== size.width || prevSize.height !== size.height) {
|
|
928
|
-
sizeRef.current = size;
|
|
929
|
-
callback2(size);
|
|
930
|
-
}
|
|
827
|
+
this.onRenderRangeChange = (fn) => {
|
|
828
|
+
this.onRenderRangeChangeFns.push(fn);
|
|
829
|
+
return () => {
|
|
830
|
+
this.onRenderRangeChangeFns = this.onRenderRangeChangeFns.filter((f) => f !== fn);
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
this.onDestroy = (fn) => {
|
|
834
|
+
this.onDestroyFns.push(fn);
|
|
835
|
+
return () => {
|
|
836
|
+
this.onDestroyFns = this.onDestroyFns.filter((f) => f !== fn);
|
|
837
|
+
};
|
|
838
|
+
};
|
|
839
|
+
this.update = (newCount, newItemSize, newItemSpan) => {
|
|
840
|
+
const { itemSize, count, itemSpan } = this.options;
|
|
841
|
+
const countChange = count !== newCount;
|
|
842
|
+
const itemSizeChange = itemSize !== newItemSize;
|
|
843
|
+
const itemSpanChange = itemSpan !== newItemSpan;
|
|
844
|
+
if (!countChange && !itemSizeChange && !itemSpanChange) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
this.options.count = newCount;
|
|
848
|
+
this.options.itemSize = newItemSize;
|
|
849
|
+
this.options.itemSpan = newItemSpan;
|
|
850
|
+
const size = this.availableSize[this.options.mainAxis === "vertical" ? "height" : "width"];
|
|
851
|
+
const newRenderCount = this.computeRenderCount({
|
|
852
|
+
itemSize: newItemSize,
|
|
853
|
+
count: newCount,
|
|
854
|
+
size
|
|
931
855
|
});
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
856
|
+
if (!itemSizeChange && !itemSpanChange && countChange && newCount > count) {
|
|
857
|
+
const currentRenderCount = this.getRenderCount();
|
|
858
|
+
if (currentRenderCount > newRenderCount) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
936
861
|
}
|
|
862
|
+
if (true) {
|
|
863
|
+
if (itemSizeChange && countChange) {
|
|
864
|
+
this.debug(`Reset brain: reason itemSize changed and count changed (old ${count}, new ${newCount})`, {
|
|
865
|
+
oldItemSize: itemSize,
|
|
866
|
+
newItemSize
|
|
867
|
+
});
|
|
868
|
+
} else if (itemSizeChange) {
|
|
869
|
+
this.debug(`Reset brain: reason itemSize changed`, {
|
|
870
|
+
oldItemSize: itemSize,
|
|
871
|
+
newItemSize
|
|
872
|
+
});
|
|
873
|
+
} else if (countChange) {
|
|
874
|
+
this.debug(`Reset brain: reason count changed (old ${count}, new ${newCount})`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
this.reset();
|
|
878
|
+
this.updateRenderCount(newRenderCount);
|
|
937
879
|
};
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
}, [ref.current, callback, config.earlyAttach]);
|
|
946
|
-
(0, import_react3.useLayoutEffect)(() => {
|
|
947
|
-
if (config.earlyAttach) {
|
|
948
|
-
return effectFn(callback);
|
|
949
|
-
}
|
|
950
|
-
return () => {
|
|
880
|
+
this.reset = () => {
|
|
881
|
+
this.itemSpanParent = [];
|
|
882
|
+
this.itemSpanValue = [];
|
|
883
|
+
this.itemSizeCache = [];
|
|
884
|
+
this.itemOffsetCache = [0];
|
|
885
|
+
this.renderCount = -1;
|
|
886
|
+
this.totalSize = 0;
|
|
951
887
|
};
|
|
952
|
-
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
position: "absolute",
|
|
957
|
-
top: 0,
|
|
958
|
-
left: 0,
|
|
959
|
-
width: "100%",
|
|
960
|
-
height: "100%",
|
|
961
|
-
boxSizing: "border-box"
|
|
962
|
-
}), []);
|
|
963
|
-
const { notifyOnMount, earlyAttach } = props;
|
|
964
|
-
const firstTime = (0, import_react3.useRef)(true);
|
|
965
|
-
const ref = (0, import_react3.useRef)(null);
|
|
966
|
-
const onResize = (0, import_react3.useCallback)((size) => {
|
|
967
|
-
if (firstTime.current && !notifyOnMount) {
|
|
968
|
-
firstTime.current = false;
|
|
969
|
-
return;
|
|
970
|
-
}
|
|
971
|
-
props.onResize(size);
|
|
972
|
-
}, [props.onResize]);
|
|
973
|
-
useResizeObserver(ref, onResize, { earlyAttach: earlyAttach || false });
|
|
974
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
975
|
-
ref,
|
|
976
|
-
style
|
|
977
|
-
});
|
|
978
|
-
};
|
|
979
|
-
ReactResizeObserver.defaultProps = {
|
|
980
|
-
notifyOnMount: true,
|
|
981
|
-
earlyAttach: false
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// src/components/InfiniteTable/hooks/useInfiniteTable.ts
|
|
985
|
-
var import_react4 = __toModule(require("react"));
|
|
986
|
-
var useInfiniteTable = () => {
|
|
987
|
-
const TableContext2 = getInfiniteTableContext();
|
|
988
|
-
return (0, import_react4.useContext)(TableContext2);
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
992
|
-
var import_react8 = __toModule(require("react"));
|
|
993
|
-
|
|
994
|
-
// src/components/flexbox/index.tsx
|
|
995
|
-
var computeFlex = (params) => {
|
|
996
|
-
const {
|
|
997
|
-
availableSize,
|
|
998
|
-
items,
|
|
999
|
-
minSize: defaultMinSize,
|
|
1000
|
-
maxSize: defaultMaxSize
|
|
1001
|
-
} = params;
|
|
1002
|
-
if (availableSize < 0) {
|
|
1003
|
-
throw "The provided availableSize cannot be negative!";
|
|
1004
|
-
}
|
|
1005
|
-
let totalFixedSize = 0;
|
|
1006
|
-
let totalFlex = 0;
|
|
1007
|
-
let totalFlexCount = 0;
|
|
1008
|
-
items.forEach((item, i) => {
|
|
1009
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1010
|
-
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1011
|
-
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1012
|
-
if (item.size != null) {
|
|
1013
|
-
if (maxSize != null && item.size > maxSize) {
|
|
1014
|
-
item.size = maxSize;
|
|
1015
|
-
}
|
|
1016
|
-
if (minSize != null && item.size < minSize) {
|
|
1017
|
-
item.size = minSize;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
if (item.size == null && item.flex == null) {
|
|
1021
|
-
throw `Items must specify either a size or a flex property. Item at index ${i} doesn't have either of those.`;
|
|
1022
|
-
}
|
|
1023
|
-
if (item.flex != null) {
|
|
1024
|
-
totalFlexCount += 1;
|
|
1025
|
-
}
|
|
1026
|
-
totalFlex += (_e = item.flex) != null ? _e : 0;
|
|
1027
|
-
totalFixedSize += (_f = item.size) != null ? _f : 0;
|
|
1028
|
-
});
|
|
1029
|
-
let availableSizeForFlex = Math.max(availableSize - totalFixedSize, 0);
|
|
1030
|
-
let sizePerFlex = availableSizeForFlex / totalFlex;
|
|
1031
|
-
let maxxedFlexItems = {};
|
|
1032
|
-
let minnedFlexItems = {};
|
|
1033
|
-
let constrainedCount = 0;
|
|
1034
|
-
items.forEach((item, index) => {
|
|
1035
|
-
var _a, _b, _c, _d;
|
|
1036
|
-
if (item.flex != null) {
|
|
1037
|
-
const approxFlexSize = sizePerFlex * item.flex;
|
|
1038
|
-
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1039
|
-
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1040
|
-
let constrained = false;
|
|
1041
|
-
let substractSize = 0;
|
|
1042
|
-
if (maxSize != null && approxFlexSize > maxSize) {
|
|
1043
|
-
maxxedFlexItems[index] = true;
|
|
1044
|
-
constrained = true;
|
|
1045
|
-
substractSize = maxSize;
|
|
888
|
+
this.computeItemSpanUpTo = (itemIndex) => {
|
|
889
|
+
const { count, itemSpan } = this.options;
|
|
890
|
+
if (!itemSpan) {
|
|
891
|
+
return;
|
|
1046
892
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
893
|
+
const cache = this.itemSpanParent;
|
|
894
|
+
const spanResultArr = this.itemSpanValue;
|
|
895
|
+
if (cache[itemIndex] === void 0) {
|
|
896
|
+
let i = cache.length;
|
|
897
|
+
let lastIndex = Math.min(itemIndex, count - 1);
|
|
898
|
+
for (; i <= lastIndex; i++) {
|
|
899
|
+
if (cache[i] === void 0) {
|
|
900
|
+
ItemIndexBag.itemIndex = i;
|
|
901
|
+
let spanValue = itemSpan(ItemIndexBag);
|
|
902
|
+
if (spanValue < 1) {
|
|
903
|
+
this.debug("itemSpan cannot be less than 1 - got %d for index %d", spanValue, i);
|
|
904
|
+
}
|
|
905
|
+
cache[i] = i;
|
|
906
|
+
spanResultArr[i] = spanValue;
|
|
907
|
+
let spannedItemIndex = i;
|
|
908
|
+
while (spanValue > 1) {
|
|
909
|
+
spannedItemIndex += 1;
|
|
910
|
+
cache[spannedItemIndex] = i;
|
|
911
|
+
spanResultArr[spannedItemIndex] = 0;
|
|
912
|
+
spanValue -= 1;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
1051
916
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
availableSizeForFlex -= substractSize;
|
|
917
|
+
};
|
|
918
|
+
this.computeCacheFor = (itemIndex) => {
|
|
919
|
+
if (typeof this.options.itemSize !== "function") {
|
|
920
|
+
return;
|
|
1057
921
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
let remainingSizeForFlex = availableSizeForFlex;
|
|
1066
|
-
let remainingFlex = totalFlex;
|
|
1067
|
-
let totalTakenSize = 0;
|
|
1068
|
-
let flexSizeSum = 0;
|
|
1069
|
-
const computedSizes = [];
|
|
1070
|
-
const resultItems = items.map((item, index) => {
|
|
1071
|
-
var _a, _b, _c, _d, _e;
|
|
1072
|
-
const sizedItem = __spreadValues({}, item);
|
|
1073
|
-
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1074
|
-
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1075
|
-
let flexSize = 0;
|
|
1076
|
-
const maxxed = maxxedFlexItems[index];
|
|
1077
|
-
const minned = minnedFlexItems[index];
|
|
1078
|
-
const constrained = maxxed || minned;
|
|
1079
|
-
let computedSize = (_e = item.size) != null ? _e : 0;
|
|
1080
|
-
if (item.flex != null) {
|
|
1081
|
-
if (constrained) {
|
|
1082
|
-
if (minned) {
|
|
1083
|
-
flexSize = minSize;
|
|
922
|
+
const itemSize = this.options.itemSize(itemIndex);
|
|
923
|
+
this.itemSizeCache[itemIndex] = itemSize;
|
|
924
|
+
if (itemIndex > 0) {
|
|
925
|
+
const prevOffset = this.itemOffsetCache[itemIndex - 1];
|
|
926
|
+
const prevSize = this.itemSizeCache[itemIndex - 1];
|
|
927
|
+
if (prevOffset == null) {
|
|
928
|
+
console.error(`Offset was not available for item ${itemIndex - 1}`);
|
|
1084
929
|
}
|
|
1085
|
-
if (
|
|
1086
|
-
|
|
930
|
+
if (prevSize == null) {
|
|
931
|
+
console.error(`Size was not available for item ${itemIndex - 1}`);
|
|
1087
932
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
933
|
+
const offset = prevOffset + prevSize;
|
|
934
|
+
this.itemOffsetCache[itemIndex] = offset;
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
this.getItemSpan = (itemIndex) => {
|
|
938
|
+
if (!this.options.itemSpan) {
|
|
939
|
+
return 1;
|
|
940
|
+
}
|
|
941
|
+
if (this.itemSpanValue[itemIndex] === void 0) {
|
|
942
|
+
this.computeItemSpanUpTo(itemIndex);
|
|
943
|
+
}
|
|
944
|
+
return this.itemSpanValue[itemIndex] || 1;
|
|
945
|
+
};
|
|
946
|
+
this.getItemSpanParent = (itemIndex) => {
|
|
947
|
+
if (!this.options.itemSpan) {
|
|
948
|
+
return itemIndex;
|
|
949
|
+
}
|
|
950
|
+
if (this.itemSpanParent[itemIndex] === void 0) {
|
|
951
|
+
this.computeItemSpanUpTo(itemIndex);
|
|
952
|
+
}
|
|
953
|
+
return this.itemSpanParent[itemIndex];
|
|
954
|
+
};
|
|
955
|
+
this.getItemSizeWithSpan = (itemIndex, itemSpan) => {
|
|
956
|
+
let itemSize = this.getItemSize(itemIndex);
|
|
957
|
+
while (itemSpan > 1) {
|
|
958
|
+
itemIndex += 1;
|
|
959
|
+
itemSpan -= 1;
|
|
960
|
+
itemSize += this.getItemSize(itemIndex);
|
|
961
|
+
}
|
|
962
|
+
return itemSize;
|
|
963
|
+
};
|
|
964
|
+
this.getItemSize = (itemIndex) => {
|
|
965
|
+
const { itemSize, count } = this.options;
|
|
966
|
+
if (typeof itemSize !== "function") {
|
|
967
|
+
return itemSize;
|
|
968
|
+
}
|
|
969
|
+
let cachedSize = this.getItemSizeCacheFor(itemIndex);
|
|
970
|
+
if (cachedSize === void 0) {
|
|
971
|
+
let i = this.itemSizeCache.length;
|
|
972
|
+
let lastIndex = Math.min(itemIndex, count - 1);
|
|
973
|
+
for (; i <= lastIndex; i++) {
|
|
974
|
+
this.computeCacheFor(i);
|
|
1107
975
|
}
|
|
976
|
+
cachedSize = this.getItemSizeCacheFor(itemIndex);
|
|
1108
977
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
totalTakenSize += computedSize;
|
|
1116
|
-
return sizedItem;
|
|
1117
|
-
});
|
|
1118
|
-
return {
|
|
1119
|
-
items: resultItems,
|
|
1120
|
-
flexSizes,
|
|
1121
|
-
computedSizes,
|
|
1122
|
-
remainingSize: Math.round(availableSize - totalTakenSize)
|
|
1123
|
-
};
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
// src/components/InfiniteTable/utils/adjustColumnOrderForPinning.ts
|
|
1127
|
-
var order = ["start", void 0, "end"];
|
|
1128
|
-
var adjustColumnOrderForPinning = (columnOrder, columnPinning) => {
|
|
1129
|
-
if (columnPinning.size > 0) {
|
|
1130
|
-
columnOrder.sort((colId1, colId2) => {
|
|
1131
|
-
let p1 = columnPinning.get(colId1);
|
|
1132
|
-
let p2 = columnPinning.get(colId2);
|
|
1133
|
-
if (p1 === true) {
|
|
1134
|
-
p1 = "start";
|
|
978
|
+
return cachedSize;
|
|
979
|
+
};
|
|
980
|
+
this.getTotalSize = () => {
|
|
981
|
+
const { count, itemSize } = this.options;
|
|
982
|
+
if (typeof itemSize !== "function") {
|
|
983
|
+
return itemSize * count;
|
|
1135
984
|
}
|
|
1136
|
-
if (
|
|
1137
|
-
|
|
985
|
+
if (this.totalSize !== 0) {
|
|
986
|
+
return this.totalSize;
|
|
1138
987
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
988
|
+
const lastItemSize = this.getItemSize(count - 1);
|
|
989
|
+
const lastItemOffset = this.itemOffsetCache[count - 1];
|
|
990
|
+
return this.totalSize = lastItemSize + lastItemOffset;
|
|
991
|
+
};
|
|
992
|
+
this.getItemAt = (scrollPos) => {
|
|
993
|
+
const { itemSize, count } = this.options;
|
|
994
|
+
if (typeof itemSize !== "function") {
|
|
995
|
+
return Math.min(Math.max(0, Math.floor(scrollPos / itemSize)), count - 1);
|
|
1141
996
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
997
|
+
let lastOffsetIndex = this.itemOffsetCache.length - 1;
|
|
998
|
+
let lastSizeIndex = this.itemSizeCache.length - 1;
|
|
999
|
+
let lastOffset = this.itemOffsetCache[lastOffsetIndex];
|
|
1000
|
+
let _prev;
|
|
1001
|
+
while (lastOffset < scrollPos) {
|
|
1002
|
+
if (lastOffsetIndex >= count) {
|
|
1003
|
+
return count - 1;
|
|
1004
|
+
}
|
|
1005
|
+
lastSizeIndex += 1;
|
|
1006
|
+
this.computeCacheFor(lastSizeIndex);
|
|
1007
|
+
_prev = lastOffset;
|
|
1008
|
+
lastOffset = this.itemOffsetCache[lastSizeIndex];
|
|
1009
|
+
if (_prev === lastOffset && _prev != 0) {
|
|
1010
|
+
return count - 1;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
const searchResult = (0, import_binary_search.default)(this.itemOffsetCache, scrollPos, SORT_ASC);
|
|
1014
|
+
if (searchResult >= 0) {
|
|
1015
|
+
return searchResult;
|
|
1016
|
+
}
|
|
1017
|
+
return ~searchResult - 1;
|
|
1018
|
+
};
|
|
1019
|
+
this.getItemOffsetFor = (itemIndex) => {
|
|
1020
|
+
if (typeof this.options.itemSize !== "function") {
|
|
1021
|
+
return itemIndex * this.options.itemSize;
|
|
1022
|
+
}
|
|
1023
|
+
let result = this.itemOffsetCache[itemIndex];
|
|
1024
|
+
if (result == null) {
|
|
1025
|
+
let lastSizeIndex = this.itemSizeCache.length - 1;
|
|
1026
|
+
while (lastSizeIndex < itemIndex) {
|
|
1027
|
+
lastSizeIndex += 1;
|
|
1028
|
+
this.computeCacheFor(lastSizeIndex);
|
|
1029
|
+
}
|
|
1030
|
+
result = this.itemOffsetCache[itemIndex];
|
|
1031
|
+
}
|
|
1032
|
+
return result;
|
|
1033
|
+
};
|
|
1034
|
+
this.destroy = () => {
|
|
1035
|
+
if (this.destroyed) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
this.notifyDestroy();
|
|
1039
|
+
this.reset();
|
|
1040
|
+
this.destroyed = true;
|
|
1041
|
+
this.onDestroyFns = [];
|
|
1042
|
+
this.onScrollFns = [];
|
|
1043
|
+
this.onTotalSizeChangeFns = [];
|
|
1044
|
+
this.onRenderCountChangeFns = [];
|
|
1045
|
+
this.onRenderRangeChangeFns = [];
|
|
1046
|
+
};
|
|
1047
|
+
this.options = options;
|
|
1048
|
+
this.reset();
|
|
1049
|
+
this.renderCount = 0;
|
|
1050
|
+
this.debug(`Init ${options.mainAxis}`);
|
|
1051
|
+
}
|
|
1052
|
+
getOptions() {
|
|
1053
|
+
return this.options;
|
|
1054
|
+
}
|
|
1055
|
+
updateRenderCount(renderCount) {
|
|
1056
|
+
const { itemSize, mainAxis, count } = this.options;
|
|
1057
|
+
const size = this.availableSize[mainAxis === "vertical" ? "height" : "width"];
|
|
1058
|
+
if (!size) {
|
|
1059
|
+
this.setRenderCount(0);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
this.setRenderCount(renderCount != null ? renderCount : this.computeRenderCount({ itemSize, count, size }));
|
|
1063
|
+
}
|
|
1064
|
+
updateRenderRange() {
|
|
1065
|
+
this.setRenderRange(this.computeRenderRange());
|
|
1066
|
+
}
|
|
1067
|
+
getRenderStartIndex() {
|
|
1068
|
+
return this.renderRange.renderStartIndex;
|
|
1069
|
+
}
|
|
1070
|
+
notifyScrollChange() {
|
|
1071
|
+
const { scrollPosition } = this;
|
|
1072
|
+
const fns = this.onScrollFns;
|
|
1073
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1074
|
+
fns[i](scrollPosition);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
notifyDestroy() {
|
|
1078
|
+
const fns = this.onDestroyFns;
|
|
1079
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1080
|
+
fns[i]();
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
notifyTotalSizeChange() {
|
|
1084
|
+
const totalSize = this.getTotalSize();
|
|
1085
|
+
const fns = this.onTotalSizeChangeFns;
|
|
1086
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1087
|
+
raf(() => {
|
|
1088
|
+
fns[i](totalSize);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
notifyRenderCountChange() {
|
|
1093
|
+
const { renderCount } = this;
|
|
1094
|
+
const fns = this.onRenderCountChangeFns;
|
|
1095
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1096
|
+
raf(() => {
|
|
1097
|
+
fns[i](renderCount);
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
notifyRenderRangeChange() {
|
|
1102
|
+
const { renderRange } = this;
|
|
1103
|
+
const fns = this.onRenderRangeChangeFns;
|
|
1104
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1105
|
+
raf(() => {
|
|
1106
|
+
fns[i](renderRange);
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
setRenderRange(renderRange) {
|
|
1111
|
+
const { renderStartIndex, renderEndIndex } = this.renderRange;
|
|
1112
|
+
if (renderEndIndex !== renderRange.renderEndIndex || renderStartIndex !== renderRange.renderStartIndex) {
|
|
1113
|
+
this.renderRange = renderRange;
|
|
1114
|
+
if (true) {
|
|
1115
|
+
this.debug("Set renderRange to %d-%d", renderRange.renderStartIndex, renderRange.renderEndIndex);
|
|
1116
|
+
}
|
|
1117
|
+
this.notifyRenderRangeChange();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
computeRenderRange() {
|
|
1121
|
+
const count = this.getOptions().count;
|
|
1122
|
+
let renderCount = this.getRenderCount();
|
|
1123
|
+
if (renderCount === 0) {
|
|
1124
|
+
return {
|
|
1125
|
+
renderStartIndex: -1,
|
|
1126
|
+
renderEndIndex: -1
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
let renderStartIndex = this.getItemAt(this.scrollPositionOnMainAxis);
|
|
1130
|
+
let renderEndIndex = renderStartIndex + this.renderCount - 1;
|
|
1131
|
+
if (renderEndIndex >= count) {
|
|
1132
|
+
renderEndIndex = count - 1;
|
|
1133
|
+
renderStartIndex = renderEndIndex - renderCount + 1;
|
|
1134
|
+
}
|
|
1135
|
+
if (this.options.itemSpan) {
|
|
1136
|
+
this.computeItemSpanUpTo(renderStartIndex);
|
|
1137
|
+
while (this.itemSpanParent[renderStartIndex] != renderStartIndex) {
|
|
1138
|
+
renderStartIndex--;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
renderStartIndex,
|
|
1143
|
+
renderEndIndex
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
getItemSizeCacheFor(itemIndex) {
|
|
1147
|
+
return this.itemSizeCache[itemIndex];
|
|
1144
1148
|
}
|
|
1145
|
-
return columnOrder;
|
|
1146
1149
|
};
|
|
1147
1150
|
|
|
1148
|
-
// src/
|
|
1149
|
-
var
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const result = debugTable.extend(channelName);
|
|
1153
|
-
result.log = console.log.bind(console);
|
|
1154
|
-
return result;
|
|
1155
|
-
};
|
|
1156
|
-
var err = (channelName) => {
|
|
1157
|
-
const result = debugTable.extend(`${channelName}:error`);
|
|
1158
|
-
result.log = console.error.bind(console);
|
|
1159
|
-
return result;
|
|
1151
|
+
// src/components/VirtualBrain/ScrollListener.ts
|
|
1152
|
+
var initialScrollPosition2 = {
|
|
1153
|
+
scrollLeft: 0,
|
|
1154
|
+
scrollTop: 0
|
|
1160
1155
|
};
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
this.
|
|
1156
|
+
var ScrollListener = class {
|
|
1157
|
+
constructor() {
|
|
1158
|
+
this.scrollPosition = initialScrollPosition2;
|
|
1159
|
+
this.onScrollFns = [];
|
|
1160
|
+
this.getScrollPosition = () => {
|
|
1161
|
+
return this.scrollPosition;
|
|
1162
|
+
};
|
|
1163
|
+
this.onScroll = (fn) => {
|
|
1164
|
+
this.onScrollFns.push(fn);
|
|
1165
|
+
return () => {
|
|
1166
|
+
this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
|
|
1167
|
+
};
|
|
1168
|
+
};
|
|
1169
|
+
this.setScrollPosition = (scrollPosition) => {
|
|
1170
|
+
this.scrollPosition = scrollPosition;
|
|
1171
|
+
this.notifyScrollChange();
|
|
1172
|
+
};
|
|
1173
|
+
this.destroy = () => {
|
|
1174
|
+
this.onScrollFns = [];
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
notifyScrollChange() {
|
|
1178
|
+
const { scrollPosition } = this;
|
|
1179
|
+
const fns = this.onScrollFns;
|
|
1180
|
+
for (let i = 0, len = fns.length; i < len; i++) {
|
|
1181
|
+
fns[i](scrollPosition);
|
|
1170
1182
|
}
|
|
1171
1183
|
}
|
|
1172
1184
|
};
|
|
1173
1185
|
|
|
1174
|
-
// src/utils/
|
|
1175
|
-
function
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
// src/components/utils/getScrollbarWidth.ts
|
|
1180
|
-
var scrollbarWidth;
|
|
1181
|
-
function getScrollbarWidth() {
|
|
1182
|
-
var _a, _b;
|
|
1183
|
-
if (scrollbarWidth != null) {
|
|
1184
|
-
return scrollbarWidth;
|
|
1185
|
-
}
|
|
1186
|
-
const doc = (_a = getGlobal().document) != null ? _a : null;
|
|
1187
|
-
if (!doc) {
|
|
1188
|
-
return 0;
|
|
1186
|
+
// src/components/InfiniteTable/utils/toMap.ts
|
|
1187
|
+
function toMap(mapOrObject, weakMapCache) {
|
|
1188
|
+
if (!mapOrObject) {
|
|
1189
|
+
return new Map();
|
|
1189
1190
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
outer.style.overflow = "scroll";
|
|
1193
|
-
doc.body.appendChild(outer);
|
|
1194
|
-
const inner = doc.createElement("div");
|
|
1195
|
-
outer.appendChild(inner);
|
|
1196
|
-
scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
|
1197
|
-
(_b = outer.parentNode) == null ? void 0 : _b.removeChild(outer);
|
|
1198
|
-
return scrollbarWidth;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
1202
|
-
var emptyType = Object.freeze({});
|
|
1203
|
-
function getColumnComputedType(column, columnTypes) {
|
|
1204
|
-
const defaultType = columnTypes["default"] || emptyType;
|
|
1205
|
-
if (column.type === void 0) {
|
|
1206
|
-
return defaultType;
|
|
1191
|
+
if (mapOrObject instanceof Map) {
|
|
1192
|
+
return mapOrObject;
|
|
1207
1193
|
}
|
|
1208
|
-
if (
|
|
1209
|
-
return
|
|
1194
|
+
if (weakMapCache && weakMapCache.has(mapOrObject)) {
|
|
1195
|
+
return weakMapCache.get(mapOrObject);
|
|
1210
1196
|
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1197
|
+
const result = new Map(Object.entries(mapOrObject));
|
|
1198
|
+
if (weakMapCache) {
|
|
1199
|
+
weakMapCache.set(mapOrObject, result);
|
|
1214
1200
|
}
|
|
1215
|
-
return
|
|
1201
|
+
return result;
|
|
1216
1202
|
}
|
|
1217
1203
|
|
|
1218
|
-
// src/components/InfiniteTable/
|
|
1219
|
-
function
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1204
|
+
// src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
|
|
1205
|
+
function computeColumnGroupsDepths(columnGroups) {
|
|
1206
|
+
const map2 = new Map();
|
|
1207
|
+
columnGroups.forEach((colGroup, colGroupId) => {
|
|
1208
|
+
let parentGroupId = colGroup.columnGroup;
|
|
1209
|
+
let depth = 0;
|
|
1210
|
+
while (parentGroupId) {
|
|
1211
|
+
const parent = columnGroups.get(parentGroupId);
|
|
1212
|
+
if (!parent) {
|
|
1213
|
+
if (true) {
|
|
1214
|
+
console.warn(`Cannot find column group ${parentGroupId}`);
|
|
1215
|
+
}
|
|
1216
|
+
break;
|
|
1225
1217
|
}
|
|
1218
|
+
depth++;
|
|
1219
|
+
parentGroupId = parent.columnGroup;
|
|
1226
1220
|
}
|
|
1221
|
+
map2.set(colGroupId, depth);
|
|
1227
1222
|
});
|
|
1228
|
-
return
|
|
1229
|
-
}
|
|
1230
|
-
function assignNonNull(target, ...rest) {
|
|
1231
|
-
return assignFiltered((value) => value != null, target, ...rest);
|
|
1223
|
+
return map2;
|
|
1232
1224
|
}
|
|
1233
1225
|
|
|
1234
|
-
// src/components/InfiniteTable/
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
return
|
|
1226
|
+
// src/components/InfiniteTable/state/getInitialState.ts
|
|
1227
|
+
function initSetupState() {
|
|
1228
|
+
const columnsGeneratedForGrouping = new Map();
|
|
1229
|
+
return {
|
|
1230
|
+
propsCache: new Map([]),
|
|
1231
|
+
horizontalVirtualBrain: new VirtualBrain({
|
|
1232
|
+
count: 0,
|
|
1233
|
+
itemSize: 100,
|
|
1234
|
+
mainAxis: "horizontal"
|
|
1235
|
+
}),
|
|
1236
|
+
verticalVirtualBrain: new VirtualBrain({
|
|
1237
|
+
count: 0,
|
|
1238
|
+
itemSize: 10,
|
|
1239
|
+
mainAxis: "vertical"
|
|
1240
|
+
}),
|
|
1241
|
+
columnShifts: null,
|
|
1242
|
+
domRef: (0, import_react2.createRef)(),
|
|
1243
|
+
scrollerDOMRef: (0, import_react2.createRef)(),
|
|
1244
|
+
portalDOMRef: (0, import_react2.createRef)(),
|
|
1245
|
+
onRowHeightCSSVarChange: buildSubscriptionCallback(),
|
|
1246
|
+
onHeaderHeightCSSVarChange: buildSubscriptionCallback(),
|
|
1247
|
+
bodySize: {
|
|
1248
|
+
width: 0,
|
|
1249
|
+
height: 0
|
|
1250
|
+
},
|
|
1251
|
+
scrollPosition: {
|
|
1252
|
+
scrollTop: 0,
|
|
1253
|
+
scrollLeft: 0
|
|
1254
|
+
},
|
|
1255
|
+
ready: false,
|
|
1256
|
+
focused: false,
|
|
1257
|
+
focusedWithin: false,
|
|
1258
|
+
columnsWhenGrouping: columnsGeneratedForGrouping,
|
|
1259
|
+
draggingColumnId: null,
|
|
1260
|
+
pinnedStartScrollListener: new ScrollListener(),
|
|
1261
|
+
pinnedEndScrollListener: new ScrollListener(),
|
|
1262
|
+
columnsWhenInlineGroupRenderStrategy: void 0
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
var forwardProps = (setupState) => {
|
|
1266
|
+
return {
|
|
1267
|
+
scrollTopKey: 1,
|
|
1268
|
+
components: 1,
|
|
1269
|
+
loadingText: 1,
|
|
1270
|
+
pivotColumns: 1,
|
|
1271
|
+
groupColumn: 1,
|
|
1272
|
+
onReady: 1,
|
|
1273
|
+
domProps: 1,
|
|
1274
|
+
focusedClassName: 1,
|
|
1275
|
+
focusedWithinClassName: 1,
|
|
1276
|
+
focusedStyle: 1,
|
|
1277
|
+
focusedWithinStyle: 1,
|
|
1278
|
+
onSelfFocus: 1,
|
|
1279
|
+
onFocusWithin: 1,
|
|
1280
|
+
onSelfBlur: 1,
|
|
1281
|
+
onBlurWithin: 1,
|
|
1282
|
+
onScrollToTop: 1,
|
|
1283
|
+
onScrollToBottom: 1,
|
|
1284
|
+
onScrollStop: 1,
|
|
1285
|
+
scrollToBottomOffset: 1,
|
|
1286
|
+
rowStyle: 1,
|
|
1287
|
+
rowProps: 1,
|
|
1288
|
+
rowClassName: 1,
|
|
1289
|
+
pinnedStartMaxWidth: 1,
|
|
1290
|
+
pinnedEndMaxWidth: 1,
|
|
1291
|
+
pivotColumn: 1,
|
|
1292
|
+
pivotColumnGroups: 1,
|
|
1293
|
+
onScrollbarsChange: 1,
|
|
1294
|
+
autoSizeColumnsKey: 1,
|
|
1295
|
+
scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 100,
|
|
1296
|
+
viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
|
|
1297
|
+
activeIndex: (activeIndex) => activeIndex != null ? activeIndex : 0,
|
|
1298
|
+
columnMinWidth: (columnMinWidth) => columnMinWidth != null ? columnMinWidth : 30,
|
|
1299
|
+
columnMaxWidth: (columnMaxWidth) => columnMaxWidth != null ? columnMaxWidth : 2e3,
|
|
1300
|
+
columnDefaultWidth: (columnDefaultWidth) => columnDefaultWidth != null ? columnDefaultWidth : 200,
|
|
1301
|
+
columnCssEllipsis: (columnCssEllipsis) => columnCssEllipsis != null ? columnCssEllipsis : true,
|
|
1302
|
+
draggableColumns: (draggableColumns) => draggableColumns != null ? draggableColumns : true,
|
|
1303
|
+
showSeparatePivotColumnForSingleAggregation: (showSeparatePivotColumnForSingleAggregation) => showSeparatePivotColumnForSingleAggregation != null ? showSeparatePivotColumnForSingleAggregation : false,
|
|
1304
|
+
sortable: (sortable) => sortable != null ? sortable : true,
|
|
1305
|
+
hideEmptyGroupColumns: (hideEmptyGroupColumns) => hideEmptyGroupColumns != null ? hideEmptyGroupColumns : false,
|
|
1306
|
+
pivotTotalColumnPosition: (pivotTotalColumnPosition) => pivotTotalColumnPosition != null ? pivotTotalColumnPosition : "end",
|
|
1307
|
+
licenseKey: (licenseKey) => licenseKey || "",
|
|
1308
|
+
columnOrder: (columnOrder) => columnOrder != null ? columnOrder : true,
|
|
1309
|
+
header: (header) => header != null ? header : true,
|
|
1310
|
+
showZebraRows: (showZebraRows) => showZebraRows != null ? showZebraRows : true,
|
|
1311
|
+
showHoverRows: (showHoverRows) => showHoverRows != null ? showHoverRows : true,
|
|
1312
|
+
virtualizeColumns: (virtualizeColumns) => virtualizeColumns != null ? virtualizeColumns : true,
|
|
1313
|
+
rowHeight: (rowHeight) => typeof rowHeight === "number" ? rowHeight : 0,
|
|
1314
|
+
headerHeight: (headerHeight) => typeof headerHeight === "number" ? headerHeight : 0,
|
|
1315
|
+
columns: (columns) => toMap(columns, setupState.propsCache.get("columns")),
|
|
1316
|
+
columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
|
|
1317
|
+
columnPinning: (columnPinning) => toMap(columnPinning, setupState.propsCache.get("columnPinning")),
|
|
1318
|
+
columnSizing: (columnSizing) => columnSizing || {},
|
|
1319
|
+
columnTypes: (columnTypes) => columnTypes || {},
|
|
1320
|
+
collapsedColumnGroups: (collapsedColumnGroups) => collapsedColumnGroups != null ? collapsedColumnGroups : new Map(),
|
|
1321
|
+
columnGroups: (columnGroups) => toMap(columnGroups, setupState.propsCache.get("columnGroups"))
|
|
1322
|
+
};
|
|
1238
1323
|
};
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1324
|
+
function getGroupRenderStrategy(options) {
|
|
1325
|
+
const { groupBy, groupColumn, groupRenderStrategy } = options;
|
|
1326
|
+
if (groupRenderStrategy) {
|
|
1327
|
+
return groupRenderStrategy;
|
|
1328
|
+
}
|
|
1329
|
+
if (groupColumn != null && typeof groupColumn === "object") {
|
|
1330
|
+
return "single-column";
|
|
1331
|
+
}
|
|
1332
|
+
const columnsInGroupBy = groupBy.filter((g) => g.column);
|
|
1333
|
+
if (columnsInGroupBy.length) {
|
|
1334
|
+
return "multi-column";
|
|
1335
|
+
}
|
|
1336
|
+
return "multi-column";
|
|
1337
|
+
}
|
|
1338
|
+
var mapPropsToState = (params) => {
|
|
1339
|
+
var _a, _b;
|
|
1340
|
+
const { props, state, oldState, parentState } = params;
|
|
1341
|
+
const { virtualizeColumns, header } = state;
|
|
1342
|
+
const computedColumnGroups = state.pivotColumnGroups || state.columnGroups;
|
|
1343
|
+
const virtualizeHeader = header && virtualizeColumns && (!computedColumnGroups || (computedColumnGroups == null ? void 0 : computedColumnGroups.size) === 0);
|
|
1344
|
+
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;
|
|
1345
|
+
const groupBy = parentState == null ? void 0 : parentState.groupBy;
|
|
1346
|
+
const groupRenderStrategy = getGroupRenderStrategy({
|
|
1347
|
+
groupRenderStrategy: props.groupRenderStrategy,
|
|
1348
|
+
groupBy,
|
|
1349
|
+
groupColumn: props.groupColumn
|
|
1350
|
+
});
|
|
1351
|
+
const computedColumns = state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
|
|
1352
|
+
return {
|
|
1353
|
+
controlledColumnVisibility: !!props.columnVisibility,
|
|
1354
|
+
groupRenderStrategy,
|
|
1355
|
+
groupBy,
|
|
1356
|
+
computedColumns,
|
|
1357
|
+
virtualizeHeader,
|
|
1358
|
+
columnHeaderCssEllipsis: (_b = (_a = props.columnHeaderCssEllipsis) != null ? _a : props.columnCssEllipsis) != null ? _b : true,
|
|
1359
|
+
columnGroupsDepthsMap,
|
|
1360
|
+
columnGroupsMaxDepth: columnGroupsDepthsMap != state.columnGroupsDepthsMap ? Math.max(...columnGroupsDepthsMap.values(), 0) : state.columnGroupsMaxDepth,
|
|
1361
|
+
computedColumnGroups,
|
|
1362
|
+
rowHeightCSSVar: typeof props.rowHeight === "string" ? props.rowHeight : "",
|
|
1363
|
+
headerHeightCSSVar: typeof props.headerHeight === "string" ? props.headerHeight || "--ITableHeader__height" : ""
|
|
1364
|
+
};
|
|
1243
1365
|
};
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
columnTypes,
|
|
1262
|
-
columnVisibility,
|
|
1263
|
-
columnVisibilityAssumeVisible
|
|
1264
|
-
}) => {
|
|
1265
|
-
let computedOffset = 0;
|
|
1266
|
-
const normalizedColumnOrder = adjustColumnOrderForPinning(columnOrder === true ? [...columns.keys()] : columnOrder, columnPinning);
|
|
1267
|
-
const visibleColumnOrder = normalizedColumnOrder.filter((colId) => {
|
|
1268
|
-
let col = columns.get(colId);
|
|
1269
|
-
if (!col) {
|
|
1270
|
-
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1271
|
-
return false;
|
|
1366
|
+
|
|
1367
|
+
// src/components/ResizeObserver/index.tsx
|
|
1368
|
+
var React = __toModule(require("react"));
|
|
1369
|
+
var import_react3 = __toModule(require("react"));
|
|
1370
|
+
var setupResizeObserver = (node, callback) => {
|
|
1371
|
+
const RO = window.ResizeObserver;
|
|
1372
|
+
const observer = new RO((entries) => {
|
|
1373
|
+
var _a;
|
|
1374
|
+
const entry = entries[0];
|
|
1375
|
+
let { width, height } = entry.contentRect;
|
|
1376
|
+
if ((_a = entry.borderBoxSize) == null ? void 0 : _a[0]) {
|
|
1377
|
+
height = entry.borderBoxSize[0].blockSize;
|
|
1378
|
+
width = entry.borderBoxSize[0].inlineSize;
|
|
1379
|
+
} else {
|
|
1380
|
+
const rect = node.getBoundingClientRect();
|
|
1381
|
+
height = rect.height;
|
|
1382
|
+
width = rect.width;
|
|
1272
1383
|
}
|
|
1273
|
-
|
|
1274
|
-
return result2;
|
|
1384
|
+
callback({ width, height });
|
|
1275
1385
|
});
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1386
|
+
observer.observe(node);
|
|
1387
|
+
return () => {
|
|
1388
|
+
observer.disconnect();
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
var useResizeObserver = (ref, callback, config = { earlyAttach: false }) => {
|
|
1392
|
+
const sizeRef = (0, import_react3.useRef)({
|
|
1393
|
+
width: 0,
|
|
1394
|
+
height: 0
|
|
1395
|
+
});
|
|
1396
|
+
const effectFn = (callback2) => {
|
|
1397
|
+
let disconnect;
|
|
1398
|
+
if (ref.current) {
|
|
1399
|
+
disconnect = setupResizeObserver(ref.current, (size) => {
|
|
1400
|
+
size = {
|
|
1401
|
+
width: Math.round(size.width),
|
|
1402
|
+
height: Math.round(size.height)
|
|
1403
|
+
};
|
|
1404
|
+
const prevSize = sizeRef.current;
|
|
1405
|
+
if (prevSize.width !== size.width || prevSize.height !== size.height) {
|
|
1406
|
+
sizeRef.current = size;
|
|
1407
|
+
callback2(size);
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1280
1410
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1411
|
+
return () => {
|
|
1412
|
+
if (disconnect) {
|
|
1413
|
+
disconnect();
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1417
|
+
(0, import_react3.useEffect)(() => {
|
|
1418
|
+
if (!config.earlyAttach) {
|
|
1419
|
+
return effectFn(callback);
|
|
1286
1420
|
}
|
|
1287
|
-
return
|
|
1288
|
-
}, {});
|
|
1289
|
-
const flexResult = computeFlex({
|
|
1290
|
-
availableSize: Math.max(bodySize.width - (viewportReservedWidth != null ? viewportReservedWidth : 0) - getScrollbarWidth(), 0),
|
|
1291
|
-
maxSize: columnMaxWidth,
|
|
1292
|
-
minSize: columnMinWidth,
|
|
1293
|
-
items: visibleColumnOrder.map((colId) => {
|
|
1294
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1295
|
-
const column = columns.get(colId);
|
|
1296
|
-
const colType = getColumnComputedType(column, columnTypes);
|
|
1297
|
-
const colTypeSizing = {
|
|
1298
|
-
minWidth: colType == null ? void 0 : colType.minWidth,
|
|
1299
|
-
maxWidth: colType == null ? void 0 : colType.maxWidth,
|
|
1300
|
-
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1301
|
-
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1302
|
-
};
|
|
1303
|
-
let colSizing = assignNonNull({
|
|
1304
|
-
width: column == null ? void 0 : column.defaultWidth,
|
|
1305
|
-
flex: column == null ? void 0 : column.defaultFlex,
|
|
1306
|
-
minWidth: column == null ? void 0 : column.minWidth,
|
|
1307
|
-
maxWidth: column == null ? void 0 : column.maxWidth
|
|
1308
|
-
}, columnSizing[colId]);
|
|
1309
|
-
if (colSizing.width != null) {
|
|
1310
|
-
delete colTypeSizing.flex;
|
|
1311
|
-
}
|
|
1312
|
-
if (colSizing.flex != null) {
|
|
1313
|
-
delete colTypeSizing.width;
|
|
1314
|
-
}
|
|
1315
|
-
colSizing = assignNonNull(colTypeSizing, colSizing);
|
|
1316
|
-
let colFlex = (_a = colSizing.flex) != null ? _a : void 0;
|
|
1317
|
-
const colMinWidth = (_c = (_b = colSizing.minWidth) != null ? _b : column == null ? void 0 : column.minWidth) != null ? _c : columnMinWidth;
|
|
1318
|
-
const colMaxWidth = (_e = (_d = colSizing.maxWidth) != null ? _d : column == null ? void 0 : column.maxWidth) != null ? _e : columnMaxWidth;
|
|
1319
|
-
let size = colFlex != void 0 ? void 0 : (_f = colSizing.width) != null ? _f : columnDefaultWidth;
|
|
1320
|
-
if (!size && colFlex == void 0) {
|
|
1321
|
-
size = colMinWidth;
|
|
1322
|
-
}
|
|
1323
|
-
return {
|
|
1324
|
-
size,
|
|
1325
|
-
flex: colFlex,
|
|
1326
|
-
minSize: colMinWidth,
|
|
1327
|
-
maxSize: colMaxWidth
|
|
1328
|
-
};
|
|
1329
|
-
})
|
|
1330
|
-
});
|
|
1331
|
-
const { computedSizes } = flexResult;
|
|
1332
|
-
const computedPinnedStartColumns = [];
|
|
1333
|
-
const computedPinnedEndColumns = [];
|
|
1334
|
-
const computedUnpinnedColumns = [];
|
|
1335
|
-
const computedVisibleColumns = [];
|
|
1336
|
-
const computedVisibleColumnsMap = new Map();
|
|
1337
|
-
let computedUnpinnedColumnsWidth = 0;
|
|
1338
|
-
let computedPinnedStartColumnsWidth = 0;
|
|
1339
|
-
let computedPinnedEndColumnsWidth = 0;
|
|
1340
|
-
let prevPinned = null;
|
|
1341
|
-
const computedPinnedArray = [];
|
|
1342
|
-
let totalPinnedStartWidth = 0;
|
|
1343
|
-
let totalUnpinnedWidth = 0;
|
|
1344
|
-
let totalPinnedEndWidth = 0;
|
|
1345
|
-
columnsArray.forEach((_c, i) => {
|
|
1346
|
-
const id = visibleColumnOrder[i];
|
|
1347
|
-
const computedWidth = computedSizes[i];
|
|
1348
|
-
const pinned = computedPinnedArray[i] = getComputedPinned(id, columnPinning);
|
|
1349
|
-
if (pinned === "start") {
|
|
1350
|
-
totalPinnedStartWidth += computedWidth;
|
|
1351
|
-
} else if (pinned === "end") {
|
|
1352
|
-
totalPinnedEndWidth += computedWidth;
|
|
1353
|
-
} else {
|
|
1354
|
-
totalUnpinnedWidth += computedWidth;
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
|
|
1358
|
-
columnsArray.forEach((c, i) => {
|
|
1359
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1360
|
-
const id = visibleColumnOrder[i];
|
|
1361
|
-
const nextColumnId = visibleColumnOrder[i + 1];
|
|
1362
|
-
const colType = getColumnComputedType(c, columnTypes);
|
|
1363
|
-
const sortingInfo = sortedMap[id] ? sortedMap[id] : c.field ? (_a = sortedMap[c.field]) != null ? _a : null : null;
|
|
1364
|
-
const computedSortInfo = (_b = sortingInfo == null ? void 0 : sortingInfo.sortInfo) != null ? _b : null;
|
|
1365
|
-
const computedSorted = !!computedSortInfo;
|
|
1366
|
-
const computedSortedAsc = computedSorted && computedSortInfo.dir === 1;
|
|
1367
|
-
const computedSortedDesc = computedSorted && !computedSortedAsc;
|
|
1368
|
-
const computedSortIndex = (_c = sortingInfo == null ? void 0 : sortingInfo.index) != null ? _c : -1;
|
|
1369
|
-
const computedWidth = computedSizes[i];
|
|
1370
|
-
const toggleSort = () => {
|
|
1371
|
-
let currentSortInfo = computedSortInfo;
|
|
1372
|
-
let newColumnSortInfo;
|
|
1373
|
-
if (!currentSortInfo) {
|
|
1374
|
-
newColumnSortInfo = {
|
|
1375
|
-
dir: 1,
|
|
1376
|
-
id,
|
|
1377
|
-
field: c.field,
|
|
1378
|
-
type: c.type
|
|
1379
|
-
};
|
|
1380
|
-
} else {
|
|
1381
|
-
if (computedSortedDesc) {
|
|
1382
|
-
newColumnSortInfo = null;
|
|
1383
|
-
} else {
|
|
1384
|
-
newColumnSortInfo = __spreadProps(__spreadValues({}, computedSortInfo), {
|
|
1385
|
-
dir: -1
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
if (c.field && newColumnSortInfo && !newColumnSortInfo.field) {
|
|
1390
|
-
newColumnSortInfo.field = c.field;
|
|
1391
|
-
}
|
|
1392
|
-
let finalSortInfo = sortInfo ? [...sortInfo] : [];
|
|
1393
|
-
if (multiSort) {
|
|
1394
|
-
if (computedSortIndex === -1) {
|
|
1395
|
-
if (newColumnSortInfo) {
|
|
1396
|
-
finalSortInfo.push(newColumnSortInfo);
|
|
1397
|
-
}
|
|
1398
|
-
} else {
|
|
1399
|
-
finalSortInfo = finalSortInfo.map((info, index) => {
|
|
1400
|
-
if (index === computedSortIndex) {
|
|
1401
|
-
return newColumnSortInfo;
|
|
1402
|
-
}
|
|
1403
|
-
return info;
|
|
1404
|
-
}).filter((x) => x != null);
|
|
1405
|
-
}
|
|
1406
|
-
} else {
|
|
1407
|
-
finalSortInfo = newColumnSortInfo ? [newColumnSortInfo] : [];
|
|
1408
|
-
}
|
|
1409
|
-
setSortInfo(finalSortInfo);
|
|
1421
|
+
return () => {
|
|
1410
1422
|
};
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
const computedFirstInCategory = computedPinned !== prevPinned;
|
|
1416
|
-
const computedLastInCategory = computedLast || computedPinned !== getComputedPinned(nextColumnId, columnPinning);
|
|
1417
|
-
const result2 = __spreadProps(__spreadValues({
|
|
1418
|
-
align: colType.align,
|
|
1419
|
-
verticalAlign: colType.verticalAlign,
|
|
1420
|
-
defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
|
|
1421
|
-
valueGetter: colType.valueGetter,
|
|
1422
|
-
renderValue: colType.renderValue,
|
|
1423
|
-
render: colType.render
|
|
1424
|
-
}, c), {
|
|
1425
|
-
computedWidth,
|
|
1426
|
-
computedAbsoluteOffset,
|
|
1427
|
-
computedPinningOffset,
|
|
1428
|
-
computedOffset,
|
|
1429
|
-
computedSortable: (_f = (_e = (_d = c.sortable) != null ? _d : colType.sortable) != null ? _e : sortable) != null ? _f : true,
|
|
1430
|
-
computedSortInfo,
|
|
1431
|
-
computedSortIndex,
|
|
1432
|
-
computedMultiSort: multiSort,
|
|
1433
|
-
computedSorted,
|
|
1434
|
-
computedSortedAsc,
|
|
1435
|
-
computedSortedDesc,
|
|
1436
|
-
computedVisibleIndex: i,
|
|
1437
|
-
computedPinned,
|
|
1438
|
-
computedDraggable: (_h = (_g = c.draggable) != null ? _g : draggableColumns) != null ? _h : true,
|
|
1439
|
-
computedFirstInCategory,
|
|
1440
|
-
computedLastInCategory,
|
|
1441
|
-
computedFirst: i === 0,
|
|
1442
|
-
computedLast,
|
|
1443
|
-
toggleSort,
|
|
1444
|
-
id,
|
|
1445
|
-
header: (_k = (_j = (_i = c.header) != null ? _i : colType.header) != null ? _j : c.name) != null ? _k : c.field
|
|
1446
|
-
});
|
|
1447
|
-
computedOffset += computedWidth;
|
|
1448
|
-
computedVisibleColumnsMap.set(result2.id, result2);
|
|
1449
|
-
computedVisibleColumns.push(result2);
|
|
1450
|
-
if (computedPinned === "start") {
|
|
1451
|
-
computedPinnedStartColumns.push(result2);
|
|
1452
|
-
computedPinnedStartColumnsWidth += result2.computedWidth;
|
|
1453
|
-
}
|
|
1454
|
-
if (computedPinned === "end") {
|
|
1455
|
-
computedPinnedEndColumns.push(result2);
|
|
1456
|
-
computedPinnedEndColumnsWidth += result2.computedWidth;
|
|
1423
|
+
}, [ref.current, callback, config.earlyAttach]);
|
|
1424
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
1425
|
+
if (config.earlyAttach) {
|
|
1426
|
+
return effectFn(callback);
|
|
1457
1427
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1428
|
+
return () => {
|
|
1429
|
+
};
|
|
1430
|
+
}, [ref.current, callback, config.earlyAttach]);
|
|
1431
|
+
};
|
|
1432
|
+
var ReactResizeObserver = (props) => {
|
|
1433
|
+
const style = (0, import_react3.useMemo)(() => ({
|
|
1434
|
+
position: "absolute",
|
|
1435
|
+
top: 0,
|
|
1436
|
+
left: 0,
|
|
1437
|
+
width: "100%",
|
|
1438
|
+
height: "100%",
|
|
1439
|
+
boxSizing: "border-box"
|
|
1440
|
+
}), []);
|
|
1441
|
+
const { notifyOnMount, earlyAttach } = props;
|
|
1442
|
+
const firstTime = (0, import_react3.useRef)(true);
|
|
1443
|
+
const ref = (0, import_react3.useRef)(null);
|
|
1444
|
+
const onResize = (0, import_react3.useCallback)((size) => {
|
|
1445
|
+
if (firstTime.current && !notifyOnMount) {
|
|
1446
|
+
firstTime.current = false;
|
|
1447
|
+
return;
|
|
1461
1448
|
}
|
|
1462
|
-
|
|
1449
|
+
props.onResize(size);
|
|
1450
|
+
}, [props.onResize]);
|
|
1451
|
+
useResizeObserver(ref, onResize, { earlyAttach: earlyAttach || false });
|
|
1452
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1453
|
+
ref,
|
|
1454
|
+
style
|
|
1463
1455
|
});
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
computedPinnedStartColumnsWidth,
|
|
1469
|
-
computedPinnedEndColumnsWidth,
|
|
1470
|
-
computedUnpinnedColumnsWidth,
|
|
1471
|
-
computedColumnOrder: normalizedColumnOrder,
|
|
1472
|
-
computedPinnedStartColumns,
|
|
1473
|
-
computedPinnedEndColumns,
|
|
1474
|
-
computedUnpinnedOffset: computedPinnedStartColumnsWidth,
|
|
1475
|
-
computedPinnedEndOffset: computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
|
|
1476
|
-
computedUnpinnedColumns,
|
|
1477
|
-
computedVisibleColumns,
|
|
1478
|
-
computedVisibleColumnsMap,
|
|
1479
|
-
computedPinnedEndWidth,
|
|
1480
|
-
computedPinnedStartWidth
|
|
1481
|
-
};
|
|
1482
|
-
return result;
|
|
1456
|
+
};
|
|
1457
|
+
ReactResizeObserver.defaultProps = {
|
|
1458
|
+
notifyOnMount: true,
|
|
1459
|
+
earlyAttach: false
|
|
1483
1460
|
};
|
|
1484
1461
|
|
|
1485
|
-
// src/components/InfiniteTable/hooks/
|
|
1486
|
-
var
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
var useRerender = () => {
|
|
1491
|
-
const [state, setState] = (0, import_react5.useState)(0);
|
|
1492
|
-
return [
|
|
1493
|
-
state,
|
|
1494
|
-
(0, import_react5.useCallback)(() => {
|
|
1495
|
-
setState((state2) => state2 + 1);
|
|
1496
|
-
}, [setState])
|
|
1497
|
-
];
|
|
1462
|
+
// src/components/InfiniteTable/hooks/useInfiniteTable.ts
|
|
1463
|
+
var import_react4 = __toModule(require("react"));
|
|
1464
|
+
var useInfiniteTable = () => {
|
|
1465
|
+
const TableContext2 = getInfiniteTableContext();
|
|
1466
|
+
return (0, import_react4.useContext)(TableContext2);
|
|
1498
1467
|
};
|
|
1499
1468
|
|
|
1500
|
-
// src/components/hooks/
|
|
1501
|
-
var
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1469
|
+
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
1470
|
+
var import_react8 = __toModule(require("react"));
|
|
1471
|
+
|
|
1472
|
+
// src/components/flexbox/index.tsx
|
|
1473
|
+
var computeFlex = (params) => {
|
|
1474
|
+
const {
|
|
1475
|
+
availableSize,
|
|
1476
|
+
items,
|
|
1477
|
+
minSize: defaultMinSize,
|
|
1478
|
+
maxSize: defaultMaxSize
|
|
1479
|
+
} = params;
|
|
1480
|
+
if (availableSize < 0) {
|
|
1481
|
+
throw "The provided availableSize cannot be negative!";
|
|
1510
1482
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
fns.beforeClear(map2);
|
|
1483
|
+
let totalFixedSize = 0;
|
|
1484
|
+
let totalFlex = 0;
|
|
1485
|
+
let totalFlexCount = 0;
|
|
1486
|
+
items.forEach((item, i) => {
|
|
1487
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1488
|
+
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1489
|
+
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1490
|
+
if (item.size != null) {
|
|
1491
|
+
if (maxSize != null && item.size > maxSize) {
|
|
1492
|
+
item.size = maxSize;
|
|
1522
1493
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
fns.clear();
|
|
1494
|
+
if (minSize != null && item.size < minSize) {
|
|
1495
|
+
item.size = minSize;
|
|
1526
1496
|
}
|
|
1527
|
-
return result;
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
return () => {
|
|
1531
|
-
if (set) {
|
|
1532
|
-
map2.set = set;
|
|
1533
1497
|
}
|
|
1534
|
-
if (
|
|
1535
|
-
|
|
1498
|
+
if (item.size == null && item.flex == null) {
|
|
1499
|
+
throw `Items must specify either a size or a flex property. Item at index ${i} doesn't have either of those.`;
|
|
1536
1500
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
|
|
1501
|
+
if (item.flex != null) {
|
|
1502
|
+
totalFlexCount += 1;
|
|
1539
1503
|
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
let
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1504
|
+
totalFlex += (_e = item.flex) != null ? _e : 0;
|
|
1505
|
+
totalFixedSize += (_f = item.size) != null ? _f : 0;
|
|
1506
|
+
});
|
|
1507
|
+
let availableSizeForFlex = Math.max(availableSize - totalFixedSize, 0);
|
|
1508
|
+
let sizePerFlex = availableSizeForFlex / totalFlex;
|
|
1509
|
+
let maxxedFlexItems = {};
|
|
1510
|
+
let minnedFlexItems = {};
|
|
1511
|
+
let constrainedCount = 0;
|
|
1512
|
+
items.forEach((item, index) => {
|
|
1513
|
+
var _a, _b, _c, _d;
|
|
1514
|
+
if (item.flex != null) {
|
|
1515
|
+
const approxFlexSize = sizePerFlex * item.flex;
|
|
1516
|
+
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1517
|
+
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1518
|
+
let constrained = false;
|
|
1519
|
+
let substractSize = 0;
|
|
1520
|
+
if (maxSize != null && approxFlexSize > maxSize) {
|
|
1521
|
+
maxxedFlexItems[index] = true;
|
|
1522
|
+
constrained = true;
|
|
1523
|
+
substractSize = maxSize;
|
|
1524
|
+
}
|
|
1525
|
+
if (minSize != null && approxFlexSize < minSize) {
|
|
1526
|
+
minnedFlexItems[index] = true;
|
|
1527
|
+
constrained = true;
|
|
1528
|
+
substractSize = minSize;
|
|
1529
|
+
}
|
|
1530
|
+
if (constrained) {
|
|
1531
|
+
constrainedCount += 1;
|
|
1532
|
+
totalFlexCount -= 1;
|
|
1533
|
+
totalFlex -= item.flex;
|
|
1534
|
+
availableSizeForFlex -= substractSize;
|
|
1535
|
+
}
|
|
1549
1536
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1537
|
+
});
|
|
1538
|
+
if (constrainedCount) {
|
|
1539
|
+
sizePerFlex = availableSizeForFlex / totalFlex;
|
|
1540
|
+
}
|
|
1541
|
+
let flexSizes = [];
|
|
1542
|
+
let currentFlexCount = 0;
|
|
1543
|
+
let remainingSizeForFlex = availableSizeForFlex;
|
|
1544
|
+
let remainingFlex = totalFlex;
|
|
1545
|
+
let totalTakenSize = 0;
|
|
1546
|
+
let flexSizeSum = 0;
|
|
1547
|
+
const computedSizes = [];
|
|
1548
|
+
const resultItems = items.map((item, index) => {
|
|
1549
|
+
var _a, _b, _c, _d, _e;
|
|
1550
|
+
const sizedItem = __spreadValues({}, item);
|
|
1551
|
+
let maxSize = (_b = (_a = item.maxSize) != null ? _a : defaultMaxSize) != null ? _b : void 0;
|
|
1552
|
+
let minSize = (_d = (_c = item.minSize) != null ? _c : defaultMinSize) != null ? _d : void 0;
|
|
1553
|
+
let flexSize = 0;
|
|
1554
|
+
const maxxed = maxxedFlexItems[index];
|
|
1555
|
+
const minned = minnedFlexItems[index];
|
|
1556
|
+
const constrained = maxxed || minned;
|
|
1557
|
+
let computedSize = (_e = item.size) != null ? _e : 0;
|
|
1558
|
+
if (item.flex != null) {
|
|
1559
|
+
if (constrained) {
|
|
1560
|
+
if (minned) {
|
|
1561
|
+
flexSize = minSize;
|
|
1562
|
+
}
|
|
1563
|
+
if (maxxed) {
|
|
1564
|
+
flexSize = maxSize;
|
|
1565
|
+
}
|
|
1566
|
+
} else {
|
|
1567
|
+
currentFlexCount += 1;
|
|
1568
|
+
const constrain = (size) => {
|
|
1569
|
+
if (maxSize != null && size > maxSize) {
|
|
1570
|
+
size = maxSize;
|
|
1571
|
+
}
|
|
1572
|
+
if (minSize != null && size < minSize) {
|
|
1573
|
+
size = minSize;
|
|
1574
|
+
}
|
|
1575
|
+
return size;
|
|
1576
|
+
};
|
|
1577
|
+
if (currentFlexCount === totalFlexCount) {
|
|
1578
|
+
flexSize = constrain(remainingSizeForFlex);
|
|
1579
|
+
} else {
|
|
1580
|
+
flexSize = constrain(Math.round(item.flex * sizePerFlex));
|
|
1581
|
+
flexSizeSum += flexSize;
|
|
1582
|
+
remainingSizeForFlex = availableSizeForFlex - flexSizeSum;
|
|
1583
|
+
remainingFlex -= item.flex;
|
|
1584
|
+
sizePerFlex = remainingSizeForFlex / remainingFlex;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
computedSize = flexSize;
|
|
1588
|
+
sizedItem.flexSize = flexSize;
|
|
1589
|
+
}
|
|
1590
|
+
flexSizes.push(flexSize);
|
|
1591
|
+
computedSizes.push(computedSize);
|
|
1592
|
+
sizedItem.computedSize = computedSize;
|
|
1593
|
+
totalTakenSize += computedSize;
|
|
1594
|
+
return sizedItem;
|
|
1595
|
+
});
|
|
1596
|
+
return {
|
|
1597
|
+
items: resultItems,
|
|
1598
|
+
flexSizes,
|
|
1599
|
+
computedSizes,
|
|
1600
|
+
remainingSize: Math.round(availableSize - totalTakenSize)
|
|
1554
1601
|
};
|
|
1555
1602
|
};
|
|
1556
1603
|
|
|
1557
|
-
// src/components/InfiniteTable/
|
|
1558
|
-
var
|
|
1559
|
-
|
|
1560
|
-
(0
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1604
|
+
// src/components/InfiniteTable/utils/adjustColumnOrderForPinning.ts
|
|
1605
|
+
var order = ["start", void 0, "end"];
|
|
1606
|
+
var adjustColumnOrderForPinning = (columnOrder, columnPinning) => {
|
|
1607
|
+
if (columnPinning.size > 0) {
|
|
1608
|
+
columnOrder.sort((colId1, colId2) => {
|
|
1609
|
+
let p1 = columnPinning.get(colId1);
|
|
1610
|
+
let p2 = columnPinning.get(colId2);
|
|
1611
|
+
if (p1 === true) {
|
|
1612
|
+
p1 = "start";
|
|
1613
|
+
}
|
|
1614
|
+
if (p2 === true) {
|
|
1615
|
+
p2 = "start";
|
|
1616
|
+
}
|
|
1617
|
+
if (p1 == p2) {
|
|
1618
|
+
return 0;
|
|
1619
|
+
}
|
|
1620
|
+
return order.indexOf(p1) - order.indexOf(p2);
|
|
1566
1621
|
});
|
|
1567
|
-
}
|
|
1568
|
-
return
|
|
1622
|
+
}
|
|
1623
|
+
return columnOrder;
|
|
1569
1624
|
};
|
|
1570
1625
|
|
|
1571
|
-
// src/
|
|
1572
|
-
|
|
1626
|
+
// src/utils/getGlobal.ts
|
|
1627
|
+
function getGlobal() {
|
|
1628
|
+
return globalThis;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
// src/components/utils/getScrollbarWidth.ts
|
|
1632
|
+
var scrollbarWidth;
|
|
1633
|
+
function getScrollbarWidth() {
|
|
1634
|
+
var _a, _b;
|
|
1635
|
+
if (scrollbarWidth != null) {
|
|
1636
|
+
return scrollbarWidth;
|
|
1637
|
+
}
|
|
1638
|
+
const doc = (_a = getGlobal().document) != null ? _a : null;
|
|
1639
|
+
if (!doc) {
|
|
1640
|
+
return 0;
|
|
1641
|
+
}
|
|
1642
|
+
const outer = doc.createElement("div");
|
|
1643
|
+
outer.style.visibility = "hidden";
|
|
1644
|
+
outer.style.overflow = "scroll";
|
|
1645
|
+
doc.body.appendChild(outer);
|
|
1646
|
+
const inner = doc.createElement("div");
|
|
1647
|
+
outer.appendChild(inner);
|
|
1648
|
+
scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
|
1649
|
+
(_b = outer.parentNode) == null ? void 0 : _b.removeChild(outer);
|
|
1650
|
+
return scrollbarWidth;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
1654
|
+
var emptyType = Object.freeze({});
|
|
1655
|
+
function getColumnComputedType(column, columnTypes) {
|
|
1656
|
+
const defaultType = columnTypes["default"] || emptyType;
|
|
1657
|
+
if (column.type === void 0) {
|
|
1658
|
+
return defaultType;
|
|
1659
|
+
}
|
|
1660
|
+
if (column.type === null) {
|
|
1661
|
+
return emptyType;
|
|
1662
|
+
}
|
|
1663
|
+
if (typeof column.type === "string") {
|
|
1664
|
+
const type = columnTypes[column.type] || emptyType;
|
|
1665
|
+
return type;
|
|
1666
|
+
}
|
|
1667
|
+
return column.type.reduce((acc, columnType) => Object.assign(acc, columnTypes[columnType]), {});
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// src/components/InfiniteTable/utils/assignFiltered.ts
|
|
1671
|
+
function assignFiltered(filterFn, target, ...rest) {
|
|
1672
|
+
let result = target;
|
|
1673
|
+
rest.forEach((obj) => {
|
|
1674
|
+
for (const key in obj) {
|
|
1675
|
+
if (obj.hasOwnProperty(key) && filterFn(obj[key], key)) {
|
|
1676
|
+
result[key] = obj[key];
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
return result;
|
|
1681
|
+
}
|
|
1682
|
+
function assignNonNull(target, ...rest) {
|
|
1683
|
+
return assignFiltered((value) => value != null, target, ...rest);
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
|
|
1687
|
+
var logError = err("getComputedVisibleColumns");
|
|
1688
|
+
var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
|
|
1689
|
+
return columnVisibility[colId] !== false;
|
|
1690
|
+
};
|
|
1691
|
+
var getComputedPinned = (colId, columnPinning) => {
|
|
1692
|
+
const pinned = columnPinning.get(colId);
|
|
1693
|
+
const computedPinned = pinned === "start" ? "start" : pinned === "end" ? "end" : false;
|
|
1694
|
+
return computedPinned;
|
|
1695
|
+
};
|
|
1696
|
+
var getComputedVisibleColumns = ({
|
|
1573
1697
|
columns,
|
|
1574
1698
|
bodySize,
|
|
1575
1699
|
columnMinWidth,
|
|
1576
1700
|
columnMaxWidth,
|
|
1577
1701
|
columnDefaultWidth,
|
|
1702
|
+
columnCssEllipsis,
|
|
1703
|
+
columnHeaderCssEllipsis,
|
|
1704
|
+
pinnedStartMaxWidth,
|
|
1705
|
+
pinnedEndMaxWidth,
|
|
1578
1706
|
sortable,
|
|
1579
|
-
draggableColumns,
|
|
1580
1707
|
sortInfo,
|
|
1581
|
-
multiSort,
|
|
1582
1708
|
setSortInfo,
|
|
1583
|
-
|
|
1709
|
+
multiSort,
|
|
1710
|
+
viewportReservedWidth,
|
|
1711
|
+
draggableColumns,
|
|
1712
|
+
columnOrder,
|
|
1584
1713
|
columnPinning,
|
|
1714
|
+
columnSizing,
|
|
1585
1715
|
columnTypes,
|
|
1586
|
-
pinnedEndMaxWidth,
|
|
1587
|
-
pinnedStartMaxWidth,
|
|
1588
|
-
viewportReservedWidth,
|
|
1589
1716
|
columnVisibility,
|
|
1590
|
-
columnVisibilityAssumeVisible
|
|
1591
|
-
columnSizing
|
|
1717
|
+
columnVisibilityAssumeVisible
|
|
1592
1718
|
}) => {
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
const {
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1719
|
+
let computedOffset = 0;
|
|
1720
|
+
const normalizedColumnOrder = adjustColumnOrderForPinning(columnOrder === true ? [...columns.keys()] : columnOrder, columnPinning);
|
|
1721
|
+
const visibleColumnOrder = normalizedColumnOrder.filter((colId) => {
|
|
1722
|
+
let col = columns.get(colId);
|
|
1723
|
+
if (!col) {
|
|
1724
|
+
logError(`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`);
|
|
1725
|
+
return false;
|
|
1726
|
+
}
|
|
1727
|
+
const result2 = isColumnVisible(columnVisibility, columnVisibilityAssumeVisible, colId);
|
|
1728
|
+
return result2;
|
|
1729
|
+
});
|
|
1730
|
+
const columnsArray = visibleColumnOrder.map((columnId) => columns.get(columnId)).filter(Boolean);
|
|
1731
|
+
const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
|
|
1732
|
+
if (info.id) {
|
|
1733
|
+
acc[info.id] = { sortInfo: info, index };
|
|
1734
|
+
}
|
|
1735
|
+
if (info.field) {
|
|
1736
|
+
acc[info.field] = {
|
|
1737
|
+
sortInfo: info,
|
|
1738
|
+
index
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
return acc;
|
|
1742
|
+
}, {});
|
|
1743
|
+
console.log(columnSizing, "columnSizing");
|
|
1744
|
+
const flexResult = computeFlex({
|
|
1745
|
+
availableSize: Math.max(bodySize.width - (viewportReservedWidth != null ? viewportReservedWidth : 0) - getScrollbarWidth(), 0),
|
|
1746
|
+
maxSize: columnMaxWidth,
|
|
1747
|
+
minSize: columnMinWidth,
|
|
1748
|
+
items: visibleColumnOrder.map((colId) => {
|
|
1749
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1750
|
+
const column = columns.get(colId);
|
|
1751
|
+
const colType = getColumnComputedType(column, columnTypes);
|
|
1752
|
+
const colTypeSizing = {
|
|
1753
|
+
minWidth: colType == null ? void 0 : colType.minWidth,
|
|
1754
|
+
maxWidth: colType == null ? void 0 : colType.maxWidth,
|
|
1755
|
+
width: colType == null ? void 0 : colType.defaultWidth,
|
|
1756
|
+
flex: colType == null ? void 0 : colType.defaultFlex
|
|
1757
|
+
};
|
|
1758
|
+
let colSizing = assignNonNull({
|
|
1759
|
+
width: column == null ? void 0 : column.defaultWidth,
|
|
1760
|
+
flex: column == null ? void 0 : column.defaultFlex,
|
|
1761
|
+
minWidth: column == null ? void 0 : column.minWidth,
|
|
1762
|
+
maxWidth: column == null ? void 0 : column.maxWidth
|
|
1763
|
+
}, columnSizing[colId]);
|
|
1764
|
+
if (colSizing.width != null) {
|
|
1765
|
+
delete colTypeSizing.flex;
|
|
1766
|
+
}
|
|
1767
|
+
if (colSizing.flex != null) {
|
|
1768
|
+
delete colTypeSizing.width;
|
|
1769
|
+
}
|
|
1770
|
+
colSizing = assignNonNull(colTypeSizing, colSizing);
|
|
1771
|
+
let colFlex = (_a = colSizing.flex) != null ? _a : void 0;
|
|
1772
|
+
const colMinWidth = (_c = (_b = colSizing.minWidth) != null ? _b : column == null ? void 0 : column.minWidth) != null ? _c : columnMinWidth;
|
|
1773
|
+
const colMaxWidth = (_e = (_d = colSizing.maxWidth) != null ? _d : column == null ? void 0 : column.maxWidth) != null ? _e : columnMaxWidth;
|
|
1774
|
+
let size = colFlex != void 0 ? void 0 : (_f = colSizing.width) != null ? _f : columnDefaultWidth;
|
|
1775
|
+
if (!size && colFlex == void 0) {
|
|
1776
|
+
size = colMinWidth;
|
|
1777
|
+
}
|
|
1778
|
+
return {
|
|
1779
|
+
size,
|
|
1780
|
+
flex: colFlex,
|
|
1781
|
+
minSize: colMinWidth,
|
|
1782
|
+
maxSize: colMaxWidth
|
|
1783
|
+
};
|
|
1784
|
+
})
|
|
1785
|
+
});
|
|
1786
|
+
const { computedSizes } = flexResult;
|
|
1787
|
+
const computedPinnedStartColumns = [];
|
|
1788
|
+
const computedPinnedEndColumns = [];
|
|
1789
|
+
const computedUnpinnedColumns = [];
|
|
1790
|
+
const computedVisibleColumns = [];
|
|
1791
|
+
const computedVisibleColumnsMap = new Map();
|
|
1792
|
+
let computedUnpinnedColumnsWidth = 0;
|
|
1793
|
+
let computedPinnedStartColumnsWidth = 0;
|
|
1794
|
+
let computedPinnedEndColumnsWidth = 0;
|
|
1795
|
+
let prevPinned = null;
|
|
1796
|
+
const computedPinnedArray = [];
|
|
1797
|
+
let totalPinnedStartWidth = 0;
|
|
1798
|
+
let totalUnpinnedWidth = 0;
|
|
1799
|
+
let totalPinnedEndWidth = 0;
|
|
1800
|
+
columnsArray.forEach((_c, i) => {
|
|
1801
|
+
const id = visibleColumnOrder[i];
|
|
1802
|
+
const computedWidth = computedSizes[i];
|
|
1803
|
+
const pinned = computedPinnedArray[i] = getComputedPinned(id, columnPinning);
|
|
1804
|
+
if (pinned === "start") {
|
|
1805
|
+
totalPinnedStartWidth += computedWidth;
|
|
1806
|
+
} else if (pinned === "end") {
|
|
1807
|
+
totalPinnedEndWidth += computedWidth;
|
|
1808
|
+
} else {
|
|
1809
|
+
totalUnpinnedWidth += computedWidth;
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
|
|
1813
|
+
columnsArray.forEach((c, i) => {
|
|
1814
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1815
|
+
const id = visibleColumnOrder[i];
|
|
1816
|
+
const nextColumnId = visibleColumnOrder[i + 1];
|
|
1817
|
+
const colType = getColumnComputedType(c, columnTypes);
|
|
1818
|
+
const sortingInfo = sortedMap[id] ? sortedMap[id] : c.field ? (_a = sortedMap[c.field]) != null ? _a : null : null;
|
|
1819
|
+
const computedSortInfo = (_b = sortingInfo == null ? void 0 : sortingInfo.sortInfo) != null ? _b : null;
|
|
1820
|
+
const computedSorted = !!computedSortInfo;
|
|
1821
|
+
const computedSortedAsc = computedSorted && computedSortInfo.dir === 1;
|
|
1822
|
+
const computedSortedDesc = computedSorted && !computedSortedAsc;
|
|
1823
|
+
const computedSortIndex = (_c = sortingInfo == null ? void 0 : sortingInfo.index) != null ? _c : -1;
|
|
1824
|
+
const computedWidth = computedSizes[i];
|
|
1825
|
+
const toggleSort = () => {
|
|
1826
|
+
let currentSortInfo = computedSortInfo;
|
|
1827
|
+
let newColumnSortInfo;
|
|
1828
|
+
if (!currentSortInfo) {
|
|
1829
|
+
newColumnSortInfo = {
|
|
1830
|
+
dir: 1,
|
|
1831
|
+
id,
|
|
1832
|
+
field: c.field,
|
|
1833
|
+
type: c.type
|
|
1834
|
+
};
|
|
1835
|
+
} else {
|
|
1836
|
+
if (computedSortedDesc) {
|
|
1837
|
+
newColumnSortInfo = null;
|
|
1838
|
+
} else {
|
|
1839
|
+
newColumnSortInfo = __spreadProps(__spreadValues({}, computedSortInfo), {
|
|
1840
|
+
dir: -1
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
if (c.field && newColumnSortInfo && !newColumnSortInfo.field) {
|
|
1845
|
+
newColumnSortInfo.field = c.field;
|
|
1846
|
+
}
|
|
1847
|
+
let finalSortInfo = sortInfo ? [...sortInfo] : [];
|
|
1848
|
+
if (multiSort) {
|
|
1849
|
+
if (computedSortIndex === -1) {
|
|
1850
|
+
if (newColumnSortInfo) {
|
|
1851
|
+
finalSortInfo.push(newColumnSortInfo);
|
|
1852
|
+
}
|
|
1853
|
+
} else {
|
|
1854
|
+
finalSortInfo = finalSortInfo.map((info, index) => {
|
|
1855
|
+
if (index === computedSortIndex) {
|
|
1856
|
+
return newColumnSortInfo;
|
|
1857
|
+
}
|
|
1858
|
+
return info;
|
|
1859
|
+
}).filter((x) => x != null);
|
|
1860
|
+
}
|
|
1861
|
+
} else {
|
|
1862
|
+
finalSortInfo = newColumnSortInfo ? [newColumnSortInfo] : [];
|
|
1863
|
+
}
|
|
1864
|
+
setSortInfo(finalSortInfo);
|
|
1865
|
+
};
|
|
1866
|
+
const computedPinned = getComputedPinned(id, columnPinning);
|
|
1867
|
+
const computedLast = i === visibleColumnOrder.length - 1;
|
|
1868
|
+
const computedPinningOffset = computedPinned === "start" ? computedPinnedStartColumnsWidth : computedPinned === "end" ? computedPinnedEndColumnsWidth : computedOffset - computedPinnedStartColumnsWidth;
|
|
1869
|
+
const computedAbsoluteOffset = computedPinned === "start" || computedPinned === false ? computedOffset : firstPinnedEndAbsoluteOffset + computedPinnedEndColumnsWidth;
|
|
1870
|
+
const computedFirstInCategory = computedPinned !== prevPinned;
|
|
1871
|
+
const computedLastInCategory = computedLast || computedPinned !== getComputedPinned(nextColumnId, columnPinning);
|
|
1872
|
+
const cssEllipsis = (_e = (_d = c.cssEllipsis) != null ? _d : colType.cssEllipsis) != null ? _e : columnCssEllipsis;
|
|
1873
|
+
const headerCssEllipsis = (_j = (_i = (_h = (_g = (_f = c.headerCssEllipsis) != null ? _f : colType.cssEllipsis) != null ? _g : c.cssEllipsis) != null ? _h : colType.headerCssEllipsis) != null ? _i : columnHeaderCssEllipsis) != null ? _j : cssEllipsis;
|
|
1874
|
+
const result2 = __spreadProps(__spreadValues({
|
|
1875
|
+
align: colType.align,
|
|
1876
|
+
verticalAlign: colType.verticalAlign,
|
|
1877
|
+
defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
|
|
1878
|
+
valueGetter: colType.valueGetter,
|
|
1879
|
+
renderValue: colType.renderValue,
|
|
1880
|
+
render: colType.render,
|
|
1881
|
+
style: colType.style
|
|
1882
|
+
}, c), {
|
|
1883
|
+
cssEllipsis,
|
|
1884
|
+
headerCssEllipsis,
|
|
1885
|
+
computedWidth,
|
|
1886
|
+
computedAbsoluteOffset,
|
|
1887
|
+
computedPinningOffset,
|
|
1888
|
+
computedOffset,
|
|
1889
|
+
computedSortable: (_m = (_l = (_k = c.sortable) != null ? _k : colType.sortable) != null ? _l : sortable) != null ? _m : true,
|
|
1890
|
+
computedSortInfo,
|
|
1891
|
+
computedSortIndex,
|
|
1892
|
+
computedMultiSort: multiSort,
|
|
1893
|
+
computedSorted,
|
|
1894
|
+
computedSortedAsc,
|
|
1895
|
+
computedSortedDesc,
|
|
1896
|
+
computedVisibleIndex: i,
|
|
1897
|
+
computedPinned,
|
|
1898
|
+
computedDraggable: (_o = (_n = c.draggable) != null ? _n : draggableColumns) != null ? _o : true,
|
|
1899
|
+
computedFirstInCategory,
|
|
1900
|
+
computedLastInCategory,
|
|
1901
|
+
computedFirst: i === 0,
|
|
1902
|
+
computedLast,
|
|
1903
|
+
toggleSort,
|
|
1904
|
+
id,
|
|
1905
|
+
header: (_r = (_q = (_p = c.header) != null ? _p : colType.header) != null ? _q : c.name) != null ? _r : c.field
|
|
1906
|
+
});
|
|
1907
|
+
computedOffset += computedWidth;
|
|
1908
|
+
computedVisibleColumnsMap.set(result2.id, result2);
|
|
1909
|
+
computedVisibleColumns.push(result2);
|
|
1910
|
+
if (computedPinned === "start") {
|
|
1911
|
+
computedPinnedStartColumns.push(result2);
|
|
1912
|
+
computedPinnedStartColumnsWidth += result2.computedWidth;
|
|
1913
|
+
}
|
|
1914
|
+
if (computedPinned === "end") {
|
|
1915
|
+
computedPinnedEndColumns.push(result2);
|
|
1916
|
+
computedPinnedEndColumnsWidth += result2.computedWidth;
|
|
1917
|
+
}
|
|
1918
|
+
if (!computedPinned) {
|
|
1919
|
+
computedUnpinnedColumns.push(result2);
|
|
1920
|
+
computedUnpinnedColumnsWidth += result2.computedWidth;
|
|
1921
|
+
}
|
|
1922
|
+
prevPinned = computedPinned;
|
|
1923
|
+
});
|
|
1924
|
+
const computedPinnedStartWidth = pinnedStartMaxWidth != null ? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth) : computedPinnedStartColumnsWidth;
|
|
1925
|
+
const computedPinnedEndWidth = pinnedEndMaxWidth != null ? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth) : computedPinnedEndColumnsWidth;
|
|
1926
|
+
const result = {
|
|
1927
|
+
computedRemainingSpace: bodySize.width - (totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
|
|
1603
1928
|
computedPinnedStartColumnsWidth,
|
|
1604
1929
|
computedPinnedEndColumnsWidth,
|
|
1605
1930
|
computedUnpinnedColumnsWidth,
|
|
1606
|
-
|
|
1607
|
-
|
|
1931
|
+
computedColumnOrder: normalizedColumnOrder,
|
|
1932
|
+
computedPinnedStartColumns,
|
|
1933
|
+
computedPinnedEndColumns,
|
|
1934
|
+
computedUnpinnedOffset: computedPinnedStartColumnsWidth,
|
|
1935
|
+
computedPinnedEndOffset: computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
|
|
1936
|
+
computedUnpinnedColumns,
|
|
1937
|
+
computedVisibleColumns,
|
|
1938
|
+
computedVisibleColumnsMap,
|
|
1608
1939
|
computedPinnedEndWidth,
|
|
1609
1940
|
computedPinnedStartWidth
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1941
|
+
};
|
|
1942
|
+
return result;
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1945
|
+
// src/components/InfiniteTable/hooks/useRerenderOnKeyChange.ts
|
|
1946
|
+
var import_react7 = __toModule(require("react"));
|
|
1947
|
+
|
|
1948
|
+
// src/components/hooks/useRerender.ts
|
|
1949
|
+
var import_react5 = __toModule(require("react"));
|
|
1950
|
+
var useRerender = () => {
|
|
1951
|
+
const [state, setState] = (0, import_react5.useState)(0);
|
|
1952
|
+
return [
|
|
1953
|
+
state,
|
|
1954
|
+
(0, import_react5.useCallback)(() => {
|
|
1955
|
+
setState((state2) => state2 + 1);
|
|
1956
|
+
}, [setState])
|
|
1957
|
+
];
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
// src/components/hooks/useInterceptedMap.ts
|
|
1961
|
+
var import_react6 = __toModule(require("react"));
|
|
1962
|
+
function interceptMap(map2, fns) {
|
|
1963
|
+
const { set, delete: deleteKey, clear } = map2;
|
|
1964
|
+
if (fns.set) {
|
|
1965
|
+
map2.set = (key, value) => {
|
|
1966
|
+
set.call(map2, key, value);
|
|
1967
|
+
fns.set(key, value);
|
|
1968
|
+
return map2;
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
if (fns.delete) {
|
|
1972
|
+
map2.delete = (key) => {
|
|
1973
|
+
const removed = deleteKey.call(map2, key);
|
|
1974
|
+
fns.delete(key);
|
|
1975
|
+
return removed;
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
if (fns.clear || fns.beforeClear) {
|
|
1979
|
+
map2.clear = () => {
|
|
1980
|
+
if (fns.beforeClear) {
|
|
1981
|
+
fns.beforeClear(map2);
|
|
1982
|
+
}
|
|
1983
|
+
const result = clear.call(map2);
|
|
1984
|
+
if (fns.clear) {
|
|
1985
|
+
fns.clear();
|
|
1986
|
+
}
|
|
1987
|
+
return result;
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
return () => {
|
|
1991
|
+
if (set) {
|
|
1992
|
+
map2.set = set;
|
|
1993
|
+
}
|
|
1994
|
+
if (deleteKey) {
|
|
1995
|
+
map2.delete = deleteKey;
|
|
1996
|
+
}
|
|
1997
|
+
if (clear) {
|
|
1998
|
+
map2.clear = clear;
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
// src/components/InfiniteTable/utils/rafFn.ts
|
|
2004
|
+
var rafFn = (fn) => {
|
|
2005
|
+
let rafId = 0;
|
|
2006
|
+
return (...args) => {
|
|
2007
|
+
if (rafId) {
|
|
2008
|
+
cancelAnimationFrame(rafId);
|
|
2009
|
+
}
|
|
2010
|
+
rafId = requestAnimationFrame(() => {
|
|
2011
|
+
rafId = 0;
|
|
2012
|
+
fn(...args);
|
|
2013
|
+
});
|
|
2014
|
+
};
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
// src/components/InfiniteTable/hooks/useRerenderOnKeyChange.ts
|
|
2018
|
+
var useRerenderOnKeyChange = (map2) => {
|
|
2019
|
+
const [renderId, rerender] = useRerender();
|
|
2020
|
+
(0, import_react7.useEffect)(() => {
|
|
2021
|
+
const update = rafFn(rerender);
|
|
2022
|
+
return interceptMap(map2, {
|
|
2023
|
+
set: update,
|
|
2024
|
+
clear: update,
|
|
2025
|
+
delete: update
|
|
2026
|
+
});
|
|
2027
|
+
}, [map2]);
|
|
2028
|
+
return renderId;
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
2032
|
+
var useComputedVisibleColumns = ({
|
|
2033
|
+
columns,
|
|
2034
|
+
bodySize,
|
|
2035
|
+
columnMinWidth,
|
|
2036
|
+
columnMaxWidth,
|
|
2037
|
+
columnDefaultWidth,
|
|
2038
|
+
sortable,
|
|
2039
|
+
columnCssEllipsis,
|
|
2040
|
+
columnHeaderCssEllipsis,
|
|
2041
|
+
draggableColumns,
|
|
2042
|
+
sortInfo,
|
|
2043
|
+
multiSort,
|
|
2044
|
+
setSortInfo,
|
|
2045
|
+
columnOrder,
|
|
2046
|
+
columnPinning,
|
|
2047
|
+
columnTypes,
|
|
2048
|
+
pinnedEndMaxWidth,
|
|
2049
|
+
pinnedStartMaxWidth,
|
|
2050
|
+
viewportReservedWidth,
|
|
2051
|
+
columnVisibility,
|
|
2052
|
+
columnVisibilityAssumeVisible,
|
|
2053
|
+
columnSizing
|
|
2054
|
+
}) => {
|
|
2055
|
+
const columnsRenderId = useRerenderOnKeyChange(columns);
|
|
2056
|
+
const pinningRenderId = useRerenderOnKeyChange(columnPinning);
|
|
2057
|
+
const {
|
|
2058
|
+
computedRemainingSpace,
|
|
2059
|
+
computedColumnOrder,
|
|
2060
|
+
computedVisibleColumns,
|
|
2061
|
+
computedVisibleColumnsMap,
|
|
2062
|
+
computedPinnedStartColumns,
|
|
2063
|
+
computedPinnedEndColumns,
|
|
2064
|
+
computedUnpinnedColumns,
|
|
2065
|
+
computedPinnedStartColumnsWidth,
|
|
2066
|
+
computedPinnedEndColumnsWidth,
|
|
2067
|
+
computedUnpinnedColumnsWidth,
|
|
2068
|
+
computedUnpinnedOffset,
|
|
2069
|
+
computedPinnedEndOffset,
|
|
2070
|
+
computedPinnedEndWidth,
|
|
2071
|
+
computedPinnedStartWidth
|
|
2072
|
+
} = (0, import_react8.useMemo)(() => {
|
|
2073
|
+
return getComputedVisibleColumns({
|
|
2074
|
+
columns,
|
|
2075
|
+
bodySize,
|
|
2076
|
+
columnMinWidth,
|
|
2077
|
+
columnMaxWidth,
|
|
2078
|
+
columnDefaultWidth,
|
|
2079
|
+
columnCssEllipsis,
|
|
2080
|
+
columnHeaderCssEllipsis,
|
|
2081
|
+
viewportReservedWidth,
|
|
2082
|
+
sortable,
|
|
2083
|
+
sortInfo,
|
|
2084
|
+
setSortInfo,
|
|
2085
|
+
multiSort,
|
|
2086
|
+
pinnedEndMaxWidth,
|
|
2087
|
+
pinnedStartMaxWidth,
|
|
2088
|
+
draggableColumns,
|
|
2089
|
+
columnOrder,
|
|
2090
|
+
columnPinning,
|
|
2091
|
+
columnSizing,
|
|
2092
|
+
columnTypes,
|
|
2093
|
+
columnVisibility,
|
|
2094
|
+
columnVisibilityAssumeVisible: columnVisibilityAssumeVisible != null ? columnVisibilityAssumeVisible : true
|
|
2095
|
+
});
|
|
2096
|
+
}, [
|
|
2097
|
+
columns,
|
|
2098
|
+
bodySize.width,
|
|
2099
|
+
columnMinWidth,
|
|
2100
|
+
columnMaxWidth,
|
|
1637
2101
|
columnDefaultWidth,
|
|
1638
2102
|
sortable,
|
|
1639
2103
|
sortInfo,
|
|
@@ -1644,6 +2108,7 @@ var useComputedVisibleColumns = ({
|
|
|
1644
2108
|
columnVisibilityAssumeVisible,
|
|
1645
2109
|
pinnedEndMaxWidth,
|
|
1646
2110
|
pinnedStartMaxWidth,
|
|
2111
|
+
columnSizing,
|
|
1647
2112
|
columnPinning,
|
|
1648
2113
|
columnsRenderId,
|
|
1649
2114
|
pinningRenderId
|
|
@@ -2121,6 +2586,7 @@ var flex = { "1": "_16lm1iwc", none: "_16lm1iwd" };
|
|
|
2121
2586
|
var flexFlow = { column: "_16lm1iwz", row: "_16lm1iw10" };
|
|
2122
2587
|
var justifyContent = { center: "_16lm1iw13", start: "_16lm1iw14", end: "_16lm1iw15" };
|
|
2123
2588
|
var left = { "0": "_16lm1iwt", "100%": "_16lm1iwu" };
|
|
2589
|
+
var overflow = { hidden: "_16lm1iw16", auto: "_16lm1iw17", visible: "_16lm1iw18" };
|
|
2124
2590
|
var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
|
|
2125
2591
|
var top = { "0": "_16lm1iwr", "100%": "_16lm1iws" };
|
|
2126
2592
|
var transform = { translateZero: "_16lm1iw9", rotate90: "_16lm1iwa" };
|
|
@@ -4471,6 +4937,8 @@ function useComputed() {
|
|
|
4471
4937
|
computedPinnedEndWidth
|
|
4472
4938
|
} = useComputedVisibleColumns({
|
|
4473
4939
|
columns,
|
|
4940
|
+
columnCssEllipsis: componentState.columnCssEllipsis,
|
|
4941
|
+
columnHeaderCssEllipsis: componentState.columnHeaderCssEllipsis,
|
|
4474
4942
|
columnMinWidth: componentState.columnMinWidth,
|
|
4475
4943
|
columnMaxWidth: componentState.columnMaxWidth,
|
|
4476
4944
|
columnDefaultWidth: componentState.columnDefaultWidth,
|
|
@@ -4654,14 +5122,15 @@ var useInfiniteTableState = () => {
|
|
|
4654
5122
|
|
|
4655
5123
|
// src/components/InfiniteTable/components/cell.css.ts
|
|
4656
5124
|
var import_createRuntimeFn4 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
|
|
4657
|
-
var CellCls2 = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
|
|
4658
5125
|
var CellClsVariants = { shifting: "_1eexc2a3", dragging: "_1eexc2a4" };
|
|
4659
|
-
var
|
|
5126
|
+
var ColumnCellCls = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
|
|
5127
|
+
var ColumnCellRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "_16lm1iw2 _16lm1iwo _16lm1iw7 _16lm1iwr", variantClassNames: { dragging: { false: "_1eexc2a8" }, first: { true: "_1eexc2a9", false: "_1eexc2aa" }, last: { true: "_1eexc2ab", false: "_1eexc2ac" }, groupByField: { true: "_1eexc2ad", false: "_1eexc2ae" }, firstInCategory: { true: "_1eexc2af", false: "_1eexc2ag" }, lastInCategory: { true: "_1eexc2ah", false: "_1eexc2ai" }, pinned: { start: "_1eexc2aj", end: "_1eexc2ak", false: "_1eexc2al" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_1eexc2am"], [{ pinned: "end", firstInCategory: true }, "_1eexc2an"]] });
|
|
4660
5128
|
var columnAlignCellStyle = { center: "_1eexc2a0", start: "_1eexc2a1", end: "_1eexc2a2" };
|
|
4661
5129
|
|
|
4662
5130
|
// src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx
|
|
4663
5131
|
var { rootClassName: rootClassName2 } = internalProps;
|
|
4664
5132
|
var InfiniteTableCellClassName = `${rootClassName2}Cell`;
|
|
5133
|
+
var InfiniteTableCellContentClassName = `${rootClassName2}Cell_content`;
|
|
4665
5134
|
function InfiniteTableCellFn(props) {
|
|
4666
5135
|
var _b, _c;
|
|
4667
5136
|
const _a = props, {
|
|
@@ -4705,15 +5174,15 @@ function InfiniteTableCellFn(props) {
|
|
|
4705
5174
|
ref: domRef,
|
|
4706
5175
|
style,
|
|
4707
5176
|
"data-name": `Cell`,
|
|
4708
|
-
className: join(domProps.className, columnAlignCellStyle[(_b = column.align) != null ? _b : "start"], justifyContent[(_c = column.align) != null ? _c : "start"], InfiniteTableCellClassName,
|
|
4709
|
-
}), beforeChildren,
|
|
4710
|
-
className: `${
|
|
4711
|
-
}, children)
|
|
5177
|
+
className: join(domProps.className, columnAlignCellStyle[(_b = column.align) != null ? _b : "start"], justifyContent[(_c = column.align) != null ? _c : "start"], InfiniteTableCellClassName, ColumnCellCls, shifting ? `${InfiniteTableCellClassName}--shifting ${CellClsVariants.shifting}` : "")
|
|
5178
|
+
}), beforeChildren, /* @__PURE__ */ React10.createElement("div", {
|
|
5179
|
+
className: `${InfiniteTableCellContentClassName} ${cssEllipsis ? cssEllipsisClassName : overflow.hidden}`
|
|
5180
|
+
}, children), afterChildren);
|
|
4712
5181
|
}
|
|
4713
5182
|
var InfiniteTableCell = React10.memo(InfiniteTableCellFn);
|
|
4714
5183
|
|
|
4715
5184
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
4716
|
-
var
|
|
5185
|
+
var import_binary_search2 = __toModule(require_binary_search());
|
|
4717
5186
|
var import_react20 = __toModule(require("react"));
|
|
4718
5187
|
|
|
4719
5188
|
// src/components/InfiniteTable/utils/moveXatY.ts
|
|
@@ -4794,7 +5263,7 @@ var useColumnPointerEvents = ({
|
|
|
4794
5263
|
const columnPinned = column.computedPinned;
|
|
4795
5264
|
let currentPos = dir === -1 ? column.computedAbsoluteOffset + diffX : column.computedAbsoluteOffset + column.computedWidth + diffX;
|
|
4796
5265
|
const breakpoints = breakpointsRef.current;
|
|
4797
|
-
let index = (0,
|
|
5266
|
+
let index = (0, import_binary_search2.default)(breakpoints, currentPos, ({ breakpoint }, value) => {
|
|
4798
5267
|
return breakpoint < value ? -1 : breakpoint > value ? 1 : 0;
|
|
4799
5268
|
});
|
|
4800
5269
|
if (index < 0) {
|
|
@@ -4912,6 +5381,7 @@ var defaultLineStyle = {
|
|
|
4912
5381
|
marginBottom: 2,
|
|
4913
5382
|
transition: `width 0.25s, opacity 0.25s`
|
|
4914
5383
|
};
|
|
5384
|
+
var InfiniteTableIconClassName = "InfiniteTableIcon";
|
|
4915
5385
|
function SortIcon(props) {
|
|
4916
5386
|
var _a;
|
|
4917
5387
|
const [rendered, setRendered] = (0, import_react21.useState)(true);
|
|
@@ -4961,7 +5431,7 @@ function SortIcon(props) {
|
|
|
4961
5431
|
}
|
|
4962
5432
|
return /* @__PURE__ */ React11.createElement("div", {
|
|
4963
5433
|
style: __spreadProps(__spreadValues({}, style), { width: size }),
|
|
4964
|
-
className: join(className,
|
|
5434
|
+
className: join(className, InfiniteTableIconClassName, `${InfiniteTableIconClassName}-sort`)
|
|
4965
5435
|
}, showIndex ? /* @__PURE__ */ React11.createElement("div", {
|
|
4966
5436
|
"data-name": "index",
|
|
4967
5437
|
style: indexStyle
|
|
@@ -4981,7 +5451,7 @@ var defaultStyle = {
|
|
|
4981
5451
|
top: 0
|
|
4982
5452
|
};
|
|
4983
5453
|
var { rootClassName: rootClassName3 } = internalProps;
|
|
4984
|
-
var
|
|
5454
|
+
var InfiniteTableHeaderCellClassName = `${rootClassName3}HeaderCell`;
|
|
4985
5455
|
function InfiniteTableHeaderCell(props) {
|
|
4986
5456
|
var _a, _b, _c, _d;
|
|
4987
5457
|
const column = props.column;
|
|
@@ -5003,7 +5473,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
5003
5473
|
header = header != null ? header : column.name;
|
|
5004
5474
|
const sortTool = /* @__PURE__ */ React12.createElement(SortIcon, {
|
|
5005
5475
|
index: column.computedMultiSort ? column.computedSortIndex + 1 : void 0,
|
|
5006
|
-
className: `${
|
|
5476
|
+
className: `${InfiniteTableHeaderCellClassName}__sort-icon ${HeaderSortIconCls}`,
|
|
5007
5477
|
direction: column.computedSorted ? column.computedSortedAsc ? 1 : -1 : 0
|
|
5008
5478
|
});
|
|
5009
5479
|
const domRef = (0, import_react22.useRef)(null);
|
|
@@ -5040,7 +5510,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
5040
5510
|
let draggingProxy = null;
|
|
5041
5511
|
if (dragging) {
|
|
5042
5512
|
draggingProxy = /* @__PURE__ */ React12.createElement("div", {
|
|
5043
|
-
className: `${
|
|
5513
|
+
className: `${InfiniteTableHeaderCellClassName}Proxy ${HeaderCellProxy}`,
|
|
5044
5514
|
style: {
|
|
5045
5515
|
position: "absolute",
|
|
5046
5516
|
height: headerHeight,
|
|
@@ -5061,7 +5531,7 @@ function InfiniteTableHeaderCell(props) {
|
|
|
5061
5531
|
offset,
|
|
5062
5532
|
onPointerDown,
|
|
5063
5533
|
onPointerUp,
|
|
5064
|
-
className: join(
|
|
5534
|
+
className: join(InfiniteTableHeaderCellClassName, userSelect.none, column.computedSortable ? cursor.pointer : "", useCellClassName(column, [InfiniteTableHeaderCellClassName, InfiniteTableCellClassName], HeaderCellRecipe, { dragging }), CellCls),
|
|
5065
5535
|
cssEllipsis: (_d = (_c = column.headerCssEllipsis) != null ? _c : column.cssEllipsis) != null ? _d : true,
|
|
5066
5536
|
afterChildren: sortTool
|
|
5067
5537
|
}, header), draggingProxy);
|
|
@@ -5933,7 +6403,7 @@ function SpacePlaceholderFn(props) {
|
|
|
5933
6403
|
var SpacePlaceholder = React22.memo(SpacePlaceholderFn);
|
|
5934
6404
|
|
|
5935
6405
|
// src/components/InfiniteTable/hooks/useListRendering.tsx
|
|
5936
|
-
var
|
|
6406
|
+
var import_react40 = __toModule(require("react"));
|
|
5937
6407
|
|
|
5938
6408
|
// src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
|
|
5939
6409
|
var React28 = __toModule(require("react"));
|
|
@@ -6530,801 +7000,357 @@ var useOnContainerScroll = ({
|
|
|
6530
7000
|
scrollingRef.current = scrolling;
|
|
6531
7001
|
if (scrolling) {
|
|
6532
7002
|
if (timeoutIdRef.current) {
|
|
6533
|
-
clearTimeout(timeoutIdRef.current);
|
|
6534
|
-
}
|
|
6535
|
-
timeoutIdRef.current = setTimeout(() => {
|
|
6536
|
-
setScrolling(false);
|
|
6537
|
-
timeoutIdRef.current = 0;
|
|
6538
|
-
}, scrollStopDelay);
|
|
6539
|
-
}
|
|
6540
|
-
if (prevScrolling !== scrolling) {
|
|
6541
|
-
if (!scrolling) {
|
|
6542
|
-
const range = verticalVirtualBrain.getRenderRange();
|
|
6543
|
-
onScrollStop({
|
|
6544
|
-
scrollTop: scrollPositionRef.current.scrollTop,
|
|
6545
|
-
firstVisibleRowIndex: range.renderStartIndex,
|
|
6546
|
-
lastVisibleRowIndex: range.renderEndIndex
|
|
6547
|
-
});
|
|
6548
|
-
}
|
|
6549
|
-
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
6550
|
-
if (!classList) {
|
|
6551
|
-
return;
|
|
6552
|
-
}
|
|
6553
|
-
if (scrolling) {
|
|
6554
|
-
classList.add(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
6555
|
-
} else {
|
|
6556
|
-
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
6557
|
-
}
|
|
6558
|
-
}
|
|
6559
|
-
}, [scrollStopDelay, onScrollStop]);
|
|
6560
|
-
const onContainerScroll = (0, import_react34.useCallback)((scrollInfo) => {
|
|
6561
|
-
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6562
|
-
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
6563
|
-
setScrolling(true);
|
|
6564
|
-
}, [
|
|
6565
|
-
horizontalVirtualBrain,
|
|
6566
|
-
verticalVirtualBrain,
|
|
6567
|
-
domRef.current,
|
|
6568
|
-
setScrolling
|
|
6569
|
-
]);
|
|
6570
|
-
const scrollPositionRef = (0, import_react34.useRef)({
|
|
6571
|
-
scrollLeft: 0,
|
|
6572
|
-
scrollTop: 0
|
|
6573
|
-
});
|
|
6574
|
-
const applyScrollHorizontal = (0, import_react34.useCallback)(({ scrollLeft }) => {
|
|
6575
|
-
scrollPositionRef.current.scrollLeft = scrollLeft;
|
|
6576
|
-
onContainerScroll(scrollPositionRef.current);
|
|
6577
|
-
}, [onContainerScroll]);
|
|
6578
|
-
const applyScrollVertical = (0, import_react34.useCallback)(({ scrollTop }) => {
|
|
6579
|
-
scrollPositionRef.current.scrollTop = scrollTop;
|
|
6580
|
-
onContainerScroll(scrollPositionRef.current);
|
|
6581
|
-
if (scrollTop === 0) {
|
|
6582
|
-
onScrollToTop == null ? void 0 : onScrollToTop();
|
|
6583
|
-
}
|
|
6584
|
-
const offset = scrollToBottomOffset != null ? scrollToBottomOffset : SCROLL_BOTTOM_OFFSET;
|
|
6585
|
-
const isScrollBottom = scrollTop + offset >= scrollTopMaxRef.current;
|
|
6586
|
-
if (isScrollBottom) {
|
|
6587
|
-
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
6588
|
-
if (getDataSourceState().livePagination) {
|
|
6589
|
-
dataSourceActions.cursorId = Date.now();
|
|
6590
|
-
}
|
|
6591
|
-
}
|
|
6592
|
-
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
6593
|
-
return {
|
|
6594
|
-
applyScrollHorizontal,
|
|
6595
|
-
applyScrollVertical
|
|
6596
|
-
};
|
|
6597
|
-
};
|
|
6598
|
-
|
|
6599
|
-
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6600
|
-
var React30 = __toModule(require("react"));
|
|
6601
|
-
var import_react37 = __toModule(require("react"));
|
|
6602
|
-
|
|
6603
|
-
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
6604
|
-
var React29 = __toModule(require("react"));
|
|
6605
|
-
var import_react36 = __toModule(require("react"));
|
|
6606
|
-
|
|
6607
|
-
// src/components/hooks/useOnMount.ts
|
|
6608
|
-
var import_react35 = __toModule(require("react"));
|
|
6609
|
-
function useOnMount(domRef, props) {
|
|
6610
|
-
(0, import_react35.useEffect)(() => {
|
|
6611
|
-
const { onMount, onUnmount } = props;
|
|
6612
|
-
const node = domRef == null ? void 0 : domRef.current;
|
|
6613
|
-
onMount == null ? void 0 : onMount(node);
|
|
6614
|
-
return () => {
|
|
6615
|
-
onUnmount == null ? void 0 : onUnmount(node);
|
|
6616
|
-
};
|
|
6617
|
-
}, []);
|
|
6618
|
-
}
|
|
6619
|
-
|
|
6620
|
-
// src/components/VirtualList/InfiniteListRootClassName.ts
|
|
6621
|
-
var InfiniteListRootClassName = "InfiniteList";
|
|
6622
|
-
|
|
6623
|
-
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
6624
|
-
var rootClassName10 = InfiniteListRootClassName;
|
|
6625
|
-
var defaultClasses = [
|
|
6626
|
-
willChange.transform,
|
|
6627
|
-
position.relative,
|
|
6628
|
-
transform.translateZero
|
|
6629
|
-
];
|
|
6630
|
-
var RowListWithExternalScrolling = (props) => {
|
|
6631
|
-
const {
|
|
6632
|
-
renderRow,
|
|
6633
|
-
repaintId,
|
|
6634
|
-
brain,
|
|
6635
|
-
updateScroll,
|
|
6636
|
-
style,
|
|
6637
|
-
className,
|
|
6638
|
-
onMount,
|
|
6639
|
-
onUnmount
|
|
6640
|
-
} = props;
|
|
6641
|
-
const domRef = (0, import_react36.useRef)(null);
|
|
6642
|
-
const renderItem = (0, import_react36.useCallback)((renderProps) => renderRow({
|
|
6643
|
-
domRef: renderProps.domRef,
|
|
6644
|
-
rowHeight: renderProps.itemSize,
|
|
6645
|
-
rowIndex: renderProps.itemIndex
|
|
6646
|
-
}), [renderRow]);
|
|
6647
|
-
useOnMount(domRef, {
|
|
6648
|
-
onMount,
|
|
6649
|
-
onUnmount
|
|
6650
|
-
});
|
|
6651
|
-
(0, import_react36.useEffect)(() => {
|
|
6652
|
-
const onScroll = (scrollPosition) => {
|
|
6653
|
-
const node = domRef.current;
|
|
6654
|
-
if (node) {
|
|
6655
|
-
if (true) {
|
|
6656
|
-
const { renderStartIndex, renderEndIndex } = brain.getRenderRange();
|
|
6657
|
-
node.dataset.renderStartIndex = renderStartIndex;
|
|
6658
|
-
node.dataset.renderEndIndex = renderEndIndex;
|
|
6659
|
-
}
|
|
6660
|
-
if (updateScroll) {
|
|
6661
|
-
updateScroll(node, scrollPosition);
|
|
6662
|
-
} else {
|
|
6663
|
-
node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, ${-scrollPosition.scrollTop}px, 0px)`;
|
|
6664
|
-
}
|
|
6665
|
-
}
|
|
6666
|
-
};
|
|
6667
|
-
const removeOnScroll = brain.onScroll(onScroll);
|
|
6668
|
-
return () => {
|
|
6669
|
-
removeOnScroll();
|
|
6670
|
-
};
|
|
6671
|
-
}, [brain]);
|
|
6672
|
-
const domProps = {
|
|
6673
|
-
ref: domRef,
|
|
6674
|
-
style,
|
|
6675
|
-
className: join(className, rootClassName10, `${rootClassName10}--vertical`, VirtualListCls, VirtualListClsOrientation.vertical, ...defaultClasses)
|
|
6676
|
-
};
|
|
6677
|
-
if (true) {
|
|
6678
|
-
domProps["data-cmp-name"] = "RowListWithExternalScrolling";
|
|
6679
|
-
}
|
|
6680
|
-
return /* @__PURE__ */ React29.createElement("div", __spreadValues({}, domProps), /* @__PURE__ */ React29.createElement(RawList, {
|
|
6681
|
-
brain,
|
|
6682
|
-
renderItem,
|
|
6683
|
-
repaintId
|
|
6684
|
-
}));
|
|
6685
|
-
};
|
|
6686
|
-
|
|
6687
|
-
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
6688
|
-
var UPDATE_SCROLL3 = (node, brainScrollPosition, horizontalPinnedScrollPosition) => {
|
|
6689
|
-
node.style.transform = `translate3d(${horizontalPinnedScrollPosition ? -horizontalPinnedScrollPosition.scrollLeft : 0}px, ${-brainScrollPosition.scrollTop}px, 0px)`;
|
|
6690
|
-
};
|
|
6691
|
-
var PinnedRowsContainerClassName = `InfinitePinnedRows`;
|
|
6692
|
-
function PinnedRowsContainer(props) {
|
|
6693
|
-
const {
|
|
6694
|
-
maxWidth,
|
|
6695
|
-
pinning,
|
|
6696
|
-
rowWidth,
|
|
6697
|
-
height,
|
|
6698
|
-
pinnedScrollListener,
|
|
6699
|
-
hasOverflow,
|
|
6700
|
-
brain,
|
|
6701
|
-
renderRow
|
|
6702
|
-
} = props;
|
|
6703
|
-
const style = React30.useMemo(() => {
|
|
6704
|
-
const result = pinning === "end" ? {
|
|
6705
|
-
width: rowWidth,
|
|
6706
|
-
height,
|
|
6707
|
-
right: 0
|
|
6708
|
-
} : {};
|
|
6709
|
-
if (!hasOverflow && pinning === "end") {
|
|
6710
|
-
result.position = "absolute";
|
|
6711
|
-
}
|
|
6712
|
-
if (hasOverflow) {
|
|
6713
|
-
result.height = getScrollbarWidth();
|
|
6714
|
-
result.width = getScrollbarWidth();
|
|
6715
|
-
}
|
|
6716
|
-
return result;
|
|
6717
|
-
}, [height, rowWidth, pinning, hasOverflow]);
|
|
6718
|
-
const updateScroll = (0, import_react37.useCallback)((node, scrollPosition) => {
|
|
6719
|
-
UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
|
|
6720
|
-
}, [hasOverflow, pinnedScrollListener]);
|
|
6721
|
-
const rowListProps = {
|
|
6722
|
-
style,
|
|
6723
|
-
brain,
|
|
6724
|
-
renderRow,
|
|
6725
|
-
updateScroll,
|
|
6726
|
-
className: join(`${PinnedRowsContainerClassName}`, PinnedRowsClsVariants[pinning === "start" ? "pinnedStart" : "pinnedEnd"], `${PinnedRowsContainerClassName}--pinned-${pinning}`, `${PinnedRowsContainerClassName}--overflow`, PinnedRowsClsVariants.overflow)
|
|
6727
|
-
};
|
|
6728
|
-
if (hasOverflow) {
|
|
6729
|
-
return /* @__PURE__ */ React30.createElement(VirtualScrollContainer, {
|
|
6730
|
-
scrollable: {
|
|
6731
|
-
horizontal: true,
|
|
6732
|
-
vertical: false
|
|
6733
|
-
},
|
|
6734
|
-
style: {
|
|
6735
|
-
width: maxWidth,
|
|
6736
|
-
height,
|
|
6737
|
-
position: "absolute",
|
|
6738
|
-
[pinning === "start" ? "left" : "right"]: 0,
|
|
6739
|
-
[pinning === "start" ? "right" : "left"]: "unset"
|
|
6740
|
-
},
|
|
6741
|
-
onContainerScroll: pinnedScrollListener == null ? void 0 : pinnedScrollListener.setScrollPosition,
|
|
6742
|
-
className: join(PinnedRowsContainerClsVariants({
|
|
6743
|
-
pinned: pinning
|
|
6744
|
-
}), `${PinnedRowsContainerClassName}Container`, `${PinnedRowsContainerClassName}Container--pinned-${pinning}`)
|
|
6745
|
-
}, /* @__PURE__ */ React30.createElement(RowListWithExternalScrolling, __spreadProps(__spreadValues({}, rowListProps), {
|
|
6746
|
-
onMount: (node) => {
|
|
6747
|
-
pinnedScrollListener == null ? void 0 : pinnedScrollListener.onScroll((scrollPosition) => {
|
|
6748
|
-
updateScroll(node, brain.getScrollPosition(), scrollPosition);
|
|
6749
|
-
});
|
|
6750
|
-
}
|
|
6751
|
-
})), /* @__PURE__ */ React30.createElement(SpacePlaceholder, {
|
|
6752
|
-
width: rowWidth,
|
|
6753
|
-
height: 1
|
|
6754
|
-
}));
|
|
6755
|
-
}
|
|
6756
|
-
return /* @__PURE__ */ React30.createElement(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
|
|
6757
|
-
}
|
|
6758
|
-
function useRenderPinnedRow(params) {
|
|
6759
|
-
const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
|
|
6760
|
-
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
6761
|
-
const dataArray = getData();
|
|
6762
|
-
const rowInfo = dataArray[rowParams.rowIndex];
|
|
6763
|
-
const { showZebraRows, showHoverRows } = getState();
|
|
6764
|
-
const rowProps = __spreadValues({
|
|
6765
|
-
rowInfo,
|
|
6766
|
-
getData,
|
|
6767
|
-
showZebraRows,
|
|
6768
|
-
showHoverRows,
|
|
6769
|
-
toggleGroupRow: params.toggleGroupRow,
|
|
6770
|
-
virtualizeColumns: false,
|
|
6771
|
-
verticalBrain,
|
|
6772
|
-
brain: null,
|
|
6773
|
-
rowSpan,
|
|
6774
|
-
rowWidth: columnsWidth,
|
|
6775
|
-
columns
|
|
6776
|
-
}, rowParams);
|
|
6777
|
-
return /* @__PURE__ */ React30.createElement(TableRowUnvirtualized, __spreadValues({}, rowProps));
|
|
6778
|
-
}, [columnsWidth, columns, verticalBrain]);
|
|
6779
|
-
return renderPinnedRow;
|
|
6780
|
-
}
|
|
6781
|
-
function usePinnedRenderingForSide(side, params) {
|
|
6782
|
-
const {
|
|
6783
|
-
getState,
|
|
6784
|
-
getData,
|
|
6785
|
-
rowHeight,
|
|
6786
|
-
bodySize,
|
|
6787
|
-
computedPinnedEndColumns,
|
|
6788
|
-
computedPinnedEndColumnsWidth,
|
|
6789
|
-
computedPinnedStartColumns,
|
|
6790
|
-
computedPinnedStartColumnsWidth,
|
|
6791
|
-
verticalVirtualBrain,
|
|
6792
|
-
computedPinnedEndWidth,
|
|
6793
|
-
computedPinnedEndOverflow,
|
|
6794
|
-
computedPinnedStartWidth,
|
|
6795
|
-
computedPinnedStartOverflow,
|
|
6796
|
-
pinnedStartScrollListener,
|
|
6797
|
-
pinnedEndScrollListener,
|
|
6798
|
-
rowSpan,
|
|
6799
|
-
repaintId,
|
|
6800
|
-
toggleGroupRow,
|
|
6801
|
-
scrollbars: {
|
|
6802
|
-
vertical: hasVerticalScrollbar,
|
|
6803
|
-
horizontal: hasHorizontalScrollbar
|
|
6804
|
-
}
|
|
6805
|
-
} = params;
|
|
6806
|
-
const count = getData().length;
|
|
6807
|
-
const rowWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
|
|
6808
|
-
const columns = side === "start" ? computedPinnedStartColumns : computedPinnedEndColumns;
|
|
6809
|
-
const columnsWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
|
|
6810
|
-
const maxWidth = side === "start" ? computedPinnedStartWidth : computedPinnedEndWidth;
|
|
6811
|
-
const hasOverflow = side === "start" ? computedPinnedStartOverflow : computedPinnedEndOverflow;
|
|
6812
|
-
const pinnedScrollListener = side === "start" ? pinnedStartScrollListener : pinnedEndScrollListener;
|
|
6813
|
-
const renderRowPinned = useRenderPinnedRow({
|
|
6814
|
-
getData,
|
|
6815
|
-
getState,
|
|
6816
|
-
toggleGroupRow,
|
|
6817
|
-
rowSpan,
|
|
6818
|
-
verticalBrain: verticalVirtualBrain,
|
|
6819
|
-
columns,
|
|
6820
|
-
columnsWidth
|
|
6821
|
-
});
|
|
6822
|
-
const pinnedList = columns.length && rowHeight !== 0 ? /* @__PURE__ */ React30.createElement(PinnedRowsContainer, {
|
|
6823
|
-
pinning: side,
|
|
6824
|
-
pinnedScrollListener,
|
|
6825
|
-
hasOverflow,
|
|
6826
|
-
rowHeight,
|
|
6827
|
-
rowWidth,
|
|
6828
|
-
maxWidth,
|
|
6829
|
-
height: bodySize.height,
|
|
6830
|
-
count,
|
|
6831
|
-
repaintId: `${repaintId}-pin-${side}-${rowHeight}`,
|
|
6832
|
-
brain: verticalVirtualBrain,
|
|
6833
|
-
renderRow: renderRowPinned
|
|
6834
|
-
}) : null;
|
|
6835
|
-
const pinnedScrollbarPlaceholder = pinnedList && hasHorizontalScrollbar && !hasOverflow ? /* @__PURE__ */ React30.createElement(HorizontalScrollbarPlaceholder, {
|
|
6836
|
-
style: side === "end" ? {
|
|
6837
|
-
width: columnsWidth,
|
|
6838
|
-
right: hasVerticalScrollbar ? getScrollbarWidth() : 0
|
|
6839
|
-
} : {
|
|
6840
|
-
width: columnsWidth,
|
|
6841
|
-
left: 0
|
|
6842
|
-
}
|
|
6843
|
-
}) : null;
|
|
6844
|
-
return {
|
|
6845
|
-
renderRowPinned,
|
|
6846
|
-
pinnedList,
|
|
6847
|
-
pinnedScrollbarPlaceholder
|
|
6848
|
-
};
|
|
6849
|
-
}
|
|
6850
|
-
function usePinnedEndRendering(params) {
|
|
6851
|
-
const {
|
|
6852
|
-
renderRowPinned: renderRowPinnedEnd,
|
|
6853
|
-
pinnedList: pinnedEndList,
|
|
6854
|
-
pinnedScrollbarPlaceholder: pinnedEndScrollbarPlaceholder
|
|
6855
|
-
} = usePinnedRenderingForSide("end", params);
|
|
6856
|
-
return {
|
|
6857
|
-
renderRowPinnedEnd,
|
|
6858
|
-
pinnedEndList,
|
|
6859
|
-
pinnedEndScrollbarPlaceholder
|
|
6860
|
-
};
|
|
6861
|
-
}
|
|
6862
|
-
function usePinnedStartRendering(params) {
|
|
6863
|
-
const {
|
|
6864
|
-
renderRowPinned: renderRowPinnedStart,
|
|
6865
|
-
pinnedList: pinnedStartList,
|
|
6866
|
-
pinnedScrollbarPlaceholder: pinnedStartScrollbarPlaceholder
|
|
6867
|
-
} = usePinnedRenderingForSide("start", params);
|
|
6868
|
-
const result = {
|
|
6869
|
-
renderRowPinnedStart,
|
|
6870
|
-
pinnedStartList,
|
|
6871
|
-
pinnedStartScrollbarPlaceholder
|
|
6872
|
-
};
|
|
6873
|
-
return result;
|
|
6874
|
-
}
|
|
6875
|
-
|
|
6876
|
-
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
6877
|
-
var import_react40 = __toModule(require("react"));
|
|
6878
|
-
|
|
6879
|
-
// src/components/hooks/useOnce.ts
|
|
6880
|
-
var import_react38 = __toModule(require("react"));
|
|
6881
|
-
function useOnce(fn) {
|
|
6882
|
-
const onceFn = (0, import_react38.useMemo)(() => {
|
|
6883
|
-
return once(fn);
|
|
6884
|
-
}, []);
|
|
6885
|
-
return onceFn();
|
|
6886
|
-
}
|
|
6887
|
-
|
|
6888
|
-
// src/components/VirtualBrain/index.ts
|
|
6889
|
-
var import_binary_search2 = __toModule(require_binary_search());
|
|
6890
|
-
var initialScrollPosition2 = {
|
|
6891
|
-
scrollLeft: 0,
|
|
6892
|
-
scrollTop: 0
|
|
6893
|
-
};
|
|
6894
|
-
var raf = typeof window !== "undefined" ? requestAnimationFrame : (fn) => setTimeout(fn, 0);
|
|
6895
|
-
var ItemIndexBag = Object.seal({ itemIndex: 0 });
|
|
6896
|
-
var SORT_ASC = (a, b) => a - b;
|
|
6897
|
-
var VirtualBrain = class extends Logger {
|
|
6898
|
-
constructor(options) {
|
|
6899
|
-
super(`VirtualBrain:${options.mainAxis}`);
|
|
6900
|
-
this.scrollPosition = initialScrollPosition2;
|
|
6901
|
-
this.scrollPositionOnMainAxis = 0;
|
|
6902
|
-
this.destroyed = false;
|
|
6903
|
-
this.totalSize = 0;
|
|
6904
|
-
this.onScrollFns = [];
|
|
6905
|
-
this.onTotalSizeChangeFns = [];
|
|
6906
|
-
this.onRenderCountChangeFns = [];
|
|
6907
|
-
this.onRenderRangeChangeFns = [];
|
|
6908
|
-
this.onDestroyFns = [];
|
|
6909
|
-
this.renderCount = 0;
|
|
6910
|
-
this.renderRange = {
|
|
6911
|
-
renderStartIndex: -1,
|
|
6912
|
-
renderEndIndex: -1
|
|
6913
|
-
};
|
|
6914
|
-
this.availableSize = { width: 0, height: 0 };
|
|
6915
|
-
this.setAvailableSize = (size) => {
|
|
6916
|
-
this.availableSize = size;
|
|
6917
|
-
if (true) {
|
|
6918
|
-
this.debug("New available size %d", size[this.options.mainAxis === "vertical" ? "height" : "width"]);
|
|
6919
|
-
}
|
|
6920
|
-
this.updateRenderCount();
|
|
6921
|
-
};
|
|
6922
|
-
this.computeRenderCount = ({
|
|
6923
|
-
itemSize,
|
|
6924
|
-
count,
|
|
6925
|
-
size
|
|
6926
|
-
}) => {
|
|
6927
|
-
let renderCount = 0;
|
|
6928
|
-
if (typeof itemSize === "function") {
|
|
6929
|
-
const sizes = [];
|
|
6930
|
-
for (let i = 0; i < count; i++) {
|
|
6931
|
-
sizes.push(this.getItemSize(i));
|
|
6932
|
-
}
|
|
6933
|
-
sizes.sort(SORT_ASC);
|
|
6934
|
-
let sum = 0;
|
|
6935
|
-
for (let i = 0; i < count; i++) {
|
|
6936
|
-
sum += sizes[i];
|
|
6937
|
-
renderCount++;
|
|
6938
|
-
if (sum > size) {
|
|
6939
|
-
break;
|
|
6940
|
-
}
|
|
6941
|
-
}
|
|
6942
|
-
renderCount += 1;
|
|
6943
|
-
} else {
|
|
6944
|
-
renderCount = Math.ceil(size / itemSize) + 1;
|
|
6945
|
-
}
|
|
6946
|
-
renderCount = Math.min(count, renderCount);
|
|
6947
|
-
return renderCount;
|
|
6948
|
-
};
|
|
6949
|
-
this.setRenderCount = (renderCount) => {
|
|
6950
|
-
if (renderCount === this.renderCount) {
|
|
6951
|
-
this.notifyTotalSizeChange();
|
|
6952
|
-
return;
|
|
6953
|
-
}
|
|
6954
|
-
if (true) {
|
|
6955
|
-
this.debug("set renderCount to %d", renderCount);
|
|
6956
|
-
}
|
|
6957
|
-
this.renderCount = renderCount;
|
|
6958
|
-
this.updateRenderRange();
|
|
6959
|
-
this.notifyRenderCountChange();
|
|
6960
|
-
this.notifyTotalSizeChange();
|
|
6961
|
-
};
|
|
6962
|
-
this.getRenderCount = () => {
|
|
6963
|
-
var _a;
|
|
6964
|
-
return (_a = this.renderCount) != null ? _a : 0;
|
|
6965
|
-
};
|
|
6966
|
-
this.setScrollPosition = (scrollPosition) => {
|
|
6967
|
-
this.scrollPosition = scrollPosition;
|
|
6968
|
-
const oldScrollPosOnMainAxis = this.scrollPositionOnMainAxis;
|
|
6969
|
-
this.scrollPositionOnMainAxis = this.scrollPosition[this.options.mainAxis === "vertical" ? "scrollTop" : "scrollLeft"];
|
|
6970
|
-
if (this.scrollPositionOnMainAxis !== oldScrollPosOnMainAxis) {
|
|
6971
|
-
this.updateRenderRange();
|
|
6972
|
-
}
|
|
6973
|
-
this.notifyScrollChange();
|
|
6974
|
-
};
|
|
6975
|
-
this.getRenderRange = () => {
|
|
6976
|
-
return this.renderRange;
|
|
6977
|
-
};
|
|
6978
|
-
this.getScrollPosition = () => {
|
|
6979
|
-
return this.scrollPosition;
|
|
6980
|
-
};
|
|
6981
|
-
this.onScroll = (fn) => {
|
|
6982
|
-
this.onScrollFns.push(fn);
|
|
6983
|
-
return () => {
|
|
6984
|
-
this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
|
|
6985
|
-
};
|
|
6986
|
-
};
|
|
6987
|
-
this.onTotalSizeChange = (fn) => {
|
|
6988
|
-
this.onTotalSizeChangeFns.push(fn);
|
|
6989
|
-
return () => {
|
|
6990
|
-
this.onTotalSizeChangeFns = this.onTotalSizeChangeFns.filter((f) => f !== fn);
|
|
6991
|
-
};
|
|
6992
|
-
};
|
|
6993
|
-
this.onRenderCountChange = (fn) => {
|
|
6994
|
-
this.onRenderCountChangeFns.push(fn);
|
|
6995
|
-
return () => {
|
|
6996
|
-
this.onRenderCountChangeFns = this.onRenderCountChangeFns.filter((f) => f !== fn);
|
|
6997
|
-
};
|
|
6998
|
-
};
|
|
6999
|
-
this.onRenderRangeChange = (fn) => {
|
|
7000
|
-
this.onRenderRangeChangeFns.push(fn);
|
|
7001
|
-
return () => {
|
|
7002
|
-
this.onRenderRangeChangeFns = this.onRenderRangeChangeFns.filter((f) => f !== fn);
|
|
7003
|
-
};
|
|
7004
|
-
};
|
|
7005
|
-
this.onDestroy = (fn) => {
|
|
7006
|
-
this.onDestroyFns.push(fn);
|
|
7007
|
-
return () => {
|
|
7008
|
-
this.onDestroyFns = this.onDestroyFns.filter((f) => f !== fn);
|
|
7009
|
-
};
|
|
7010
|
-
};
|
|
7011
|
-
this.update = (newCount, newItemSize, newItemSpan) => {
|
|
7012
|
-
const { itemSize, count, itemSpan } = this.options;
|
|
7013
|
-
const countChange = count !== newCount;
|
|
7014
|
-
const itemSizeChange = itemSize !== newItemSize;
|
|
7015
|
-
const itemSpanChange = itemSpan !== newItemSpan;
|
|
7016
|
-
if (!countChange && !itemSizeChange && !itemSpanChange) {
|
|
7017
|
-
return;
|
|
7018
|
-
}
|
|
7019
|
-
this.options.count = newCount;
|
|
7020
|
-
this.options.itemSize = newItemSize;
|
|
7021
|
-
this.options.itemSpan = newItemSpan;
|
|
7022
|
-
const size = this.availableSize[this.options.mainAxis === "vertical" ? "height" : "width"];
|
|
7023
|
-
const newRenderCount = this.computeRenderCount({
|
|
7024
|
-
itemSize: newItemSize,
|
|
7025
|
-
count: newCount,
|
|
7026
|
-
size
|
|
7027
|
-
});
|
|
7028
|
-
if (!itemSizeChange && !itemSpanChange && countChange && newCount > count) {
|
|
7029
|
-
const currentRenderCount = this.getRenderCount();
|
|
7030
|
-
if (currentRenderCount > newRenderCount) {
|
|
7031
|
-
return;
|
|
7032
|
-
}
|
|
7033
|
-
}
|
|
7034
|
-
if (true) {
|
|
7035
|
-
if (itemSizeChange && countChange) {
|
|
7036
|
-
this.debug(`Reset brain: reason itemSize changed and count changed (old ${count}, new ${newCount})`, {
|
|
7037
|
-
oldItemSize: itemSize,
|
|
7038
|
-
newItemSize
|
|
7039
|
-
});
|
|
7040
|
-
} else if (itemSizeChange) {
|
|
7041
|
-
this.debug(`Reset brain: reason itemSize changed`, {
|
|
7042
|
-
oldItemSize: itemSize,
|
|
7043
|
-
newItemSize
|
|
7044
|
-
});
|
|
7045
|
-
} else if (countChange) {
|
|
7046
|
-
this.debug(`Reset brain: reason count changed (old ${count}, new ${newCount})`);
|
|
7047
|
-
}
|
|
7048
|
-
}
|
|
7049
|
-
this.reset();
|
|
7050
|
-
this.updateRenderCount(newRenderCount);
|
|
7051
|
-
};
|
|
7052
|
-
this.reset = () => {
|
|
7053
|
-
this.itemSpanParent = [];
|
|
7054
|
-
this.itemSpanValue = [];
|
|
7055
|
-
this.itemSizeCache = [];
|
|
7056
|
-
this.itemOffsetCache = [0];
|
|
7057
|
-
this.renderCount = -1;
|
|
7058
|
-
this.totalSize = 0;
|
|
7059
|
-
};
|
|
7060
|
-
this.computeItemSpanUpTo = (itemIndex) => {
|
|
7061
|
-
const { count, itemSpan } = this.options;
|
|
7062
|
-
if (!itemSpan) {
|
|
7063
|
-
return;
|
|
7064
|
-
}
|
|
7065
|
-
const cache = this.itemSpanParent;
|
|
7066
|
-
const spanResultArr = this.itemSpanValue;
|
|
7067
|
-
if (cache[itemIndex] === void 0) {
|
|
7068
|
-
let i = cache.length;
|
|
7069
|
-
let lastIndex = Math.min(itemIndex, count - 1);
|
|
7070
|
-
for (; i <= lastIndex; i++) {
|
|
7071
|
-
if (cache[i] === void 0) {
|
|
7072
|
-
ItemIndexBag.itemIndex = i;
|
|
7073
|
-
let spanValue = itemSpan(ItemIndexBag);
|
|
7074
|
-
if (spanValue < 1) {
|
|
7075
|
-
this.debug("itemSpan cannot be less than 1 - got %d for index %d", spanValue, i);
|
|
7076
|
-
}
|
|
7077
|
-
cache[i] = i;
|
|
7078
|
-
spanResultArr[i] = spanValue;
|
|
7079
|
-
let spannedItemIndex = i;
|
|
7080
|
-
while (spanValue > 1) {
|
|
7081
|
-
spannedItemIndex += 1;
|
|
7082
|
-
cache[spannedItemIndex] = i;
|
|
7083
|
-
spanResultArr[spannedItemIndex] = 0;
|
|
7084
|
-
spanValue -= 1;
|
|
7085
|
-
}
|
|
7086
|
-
}
|
|
7087
|
-
}
|
|
7088
|
-
}
|
|
7089
|
-
};
|
|
7090
|
-
this.computeCacheFor = (itemIndex) => {
|
|
7091
|
-
if (typeof this.options.itemSize !== "function") {
|
|
7092
|
-
return;
|
|
7093
|
-
}
|
|
7094
|
-
const itemSize = this.options.itemSize(itemIndex);
|
|
7095
|
-
this.itemSizeCache[itemIndex] = itemSize;
|
|
7096
|
-
if (itemIndex > 0) {
|
|
7097
|
-
const prevOffset = this.itemOffsetCache[itemIndex - 1];
|
|
7098
|
-
const prevSize = this.itemSizeCache[itemIndex - 1];
|
|
7099
|
-
if (prevOffset == null) {
|
|
7100
|
-
console.error(`Offset was not available for item ${itemIndex - 1}`);
|
|
7101
|
-
}
|
|
7102
|
-
if (prevSize == null) {
|
|
7103
|
-
console.error(`Size was not available for item ${itemIndex - 1}`);
|
|
7104
|
-
}
|
|
7105
|
-
const offset = prevOffset + prevSize;
|
|
7106
|
-
this.itemOffsetCache[itemIndex] = offset;
|
|
7107
|
-
}
|
|
7108
|
-
};
|
|
7109
|
-
this.getItemSpan = (itemIndex) => {
|
|
7110
|
-
if (!this.options.itemSpan) {
|
|
7111
|
-
return 1;
|
|
7112
|
-
}
|
|
7113
|
-
if (this.itemSpanValue[itemIndex] === void 0) {
|
|
7114
|
-
this.computeItemSpanUpTo(itemIndex);
|
|
7115
|
-
}
|
|
7116
|
-
return this.itemSpanValue[itemIndex] || 1;
|
|
7117
|
-
};
|
|
7118
|
-
this.getItemSpanParent = (itemIndex) => {
|
|
7119
|
-
if (!this.options.itemSpan) {
|
|
7120
|
-
return itemIndex;
|
|
7121
|
-
}
|
|
7122
|
-
if (this.itemSpanParent[itemIndex] === void 0) {
|
|
7123
|
-
this.computeItemSpanUpTo(itemIndex);
|
|
7124
|
-
}
|
|
7125
|
-
return this.itemSpanParent[itemIndex];
|
|
7126
|
-
};
|
|
7127
|
-
this.getItemSizeWithSpan = (itemIndex, itemSpan) => {
|
|
7128
|
-
let itemSize = this.getItemSize(itemIndex);
|
|
7129
|
-
while (itemSpan > 1) {
|
|
7130
|
-
itemIndex += 1;
|
|
7131
|
-
itemSpan -= 1;
|
|
7132
|
-
itemSize += this.getItemSize(itemIndex);
|
|
7133
|
-
}
|
|
7134
|
-
return itemSize;
|
|
7135
|
-
};
|
|
7136
|
-
this.getItemSize = (itemIndex) => {
|
|
7137
|
-
const { itemSize, count } = this.options;
|
|
7138
|
-
if (typeof itemSize !== "function") {
|
|
7139
|
-
return itemSize;
|
|
7140
|
-
}
|
|
7141
|
-
let cachedSize = this.getItemSizeCacheFor(itemIndex);
|
|
7142
|
-
if (cachedSize === void 0) {
|
|
7143
|
-
let i = this.itemSizeCache.length;
|
|
7144
|
-
let lastIndex = Math.min(itemIndex, count - 1);
|
|
7145
|
-
for (; i <= lastIndex; i++) {
|
|
7146
|
-
this.computeCacheFor(i);
|
|
7147
|
-
}
|
|
7148
|
-
cachedSize = this.getItemSizeCacheFor(itemIndex);
|
|
7149
|
-
}
|
|
7150
|
-
return cachedSize;
|
|
7151
|
-
};
|
|
7152
|
-
this.getTotalSize = () => {
|
|
7153
|
-
const { count, itemSize } = this.options;
|
|
7154
|
-
if (typeof itemSize !== "function") {
|
|
7155
|
-
return itemSize * count;
|
|
7156
|
-
}
|
|
7157
|
-
if (this.totalSize !== 0) {
|
|
7158
|
-
return this.totalSize;
|
|
7159
|
-
}
|
|
7160
|
-
const lastItemSize = this.getItemSize(count - 1);
|
|
7161
|
-
const lastItemOffset = this.itemOffsetCache[count - 1];
|
|
7162
|
-
return this.totalSize = lastItemSize + lastItemOffset;
|
|
7163
|
-
};
|
|
7164
|
-
this.getItemAt = (scrollPos) => {
|
|
7165
|
-
const { itemSize, count } = this.options;
|
|
7166
|
-
if (typeof itemSize !== "function") {
|
|
7167
|
-
return Math.min(Math.max(0, Math.floor(scrollPos / itemSize)), count - 1);
|
|
7168
|
-
}
|
|
7169
|
-
let lastOffsetIndex = this.itemOffsetCache.length - 1;
|
|
7170
|
-
let lastSizeIndex = this.itemSizeCache.length - 1;
|
|
7171
|
-
let lastOffset = this.itemOffsetCache[lastOffsetIndex];
|
|
7172
|
-
let _prev;
|
|
7173
|
-
while (lastOffset < scrollPos) {
|
|
7174
|
-
if (lastOffsetIndex >= count) {
|
|
7175
|
-
return count - 1;
|
|
7176
|
-
}
|
|
7177
|
-
lastSizeIndex += 1;
|
|
7178
|
-
this.computeCacheFor(lastSizeIndex);
|
|
7179
|
-
_prev = lastOffset;
|
|
7180
|
-
lastOffset = this.itemOffsetCache[lastSizeIndex];
|
|
7181
|
-
if (_prev === lastOffset && _prev != 0) {
|
|
7182
|
-
return count - 1;
|
|
7183
|
-
}
|
|
7184
|
-
}
|
|
7185
|
-
const searchResult = (0, import_binary_search2.default)(this.itemOffsetCache, scrollPos, SORT_ASC);
|
|
7186
|
-
if (searchResult >= 0) {
|
|
7187
|
-
return searchResult;
|
|
7188
|
-
}
|
|
7189
|
-
return ~searchResult - 1;
|
|
7190
|
-
};
|
|
7191
|
-
this.getItemOffsetFor = (itemIndex) => {
|
|
7192
|
-
if (typeof this.options.itemSize !== "function") {
|
|
7193
|
-
return itemIndex * this.options.itemSize;
|
|
7194
|
-
}
|
|
7195
|
-
let result = this.itemOffsetCache[itemIndex];
|
|
7196
|
-
if (result == null) {
|
|
7197
|
-
let lastSizeIndex = this.itemSizeCache.length - 1;
|
|
7198
|
-
while (lastSizeIndex < itemIndex) {
|
|
7199
|
-
lastSizeIndex += 1;
|
|
7200
|
-
this.computeCacheFor(lastSizeIndex);
|
|
7201
|
-
}
|
|
7202
|
-
result = this.itemOffsetCache[itemIndex];
|
|
7003
|
+
clearTimeout(timeoutIdRef.current);
|
|
7203
7004
|
}
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7005
|
+
timeoutIdRef.current = setTimeout(() => {
|
|
7006
|
+
setScrolling(false);
|
|
7007
|
+
timeoutIdRef.current = 0;
|
|
7008
|
+
}, scrollStopDelay);
|
|
7009
|
+
}
|
|
7010
|
+
if (prevScrolling !== scrolling) {
|
|
7011
|
+
if (!scrolling) {
|
|
7012
|
+
const range = verticalVirtualBrain.getRenderRange();
|
|
7013
|
+
onScrollStop({
|
|
7014
|
+
scrollTop: scrollPositionRef.current.scrollTop,
|
|
7015
|
+
firstVisibleRowIndex: range.renderStartIndex,
|
|
7016
|
+
lastVisibleRowIndex: range.renderEndIndex
|
|
7017
|
+
});
|
|
7018
|
+
}
|
|
7019
|
+
const classList = (_a = domRef.current) == null ? void 0 : _a.classList;
|
|
7020
|
+
if (!classList) {
|
|
7208
7021
|
return;
|
|
7209
7022
|
}
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
this.onTotalSizeChangeFns = [];
|
|
7216
|
-
this.onRenderCountChangeFns = [];
|
|
7217
|
-
this.onRenderRangeChangeFns = [];
|
|
7218
|
-
};
|
|
7219
|
-
this.options = options;
|
|
7220
|
-
this.reset();
|
|
7221
|
-
this.renderCount = 0;
|
|
7222
|
-
this.debug(`Init ${options.mainAxis}`);
|
|
7223
|
-
}
|
|
7224
|
-
getOptions() {
|
|
7225
|
-
return this.options;
|
|
7226
|
-
}
|
|
7227
|
-
updateRenderCount(renderCount) {
|
|
7228
|
-
const { itemSize, mainAxis, count } = this.options;
|
|
7229
|
-
const size = this.availableSize[mainAxis === "vertical" ? "height" : "width"];
|
|
7230
|
-
if (!size) {
|
|
7231
|
-
this.setRenderCount(0);
|
|
7232
|
-
return;
|
|
7233
|
-
}
|
|
7234
|
-
this.setRenderCount(renderCount != null ? renderCount : this.computeRenderCount({ itemSize, count, size }));
|
|
7235
|
-
}
|
|
7236
|
-
updateRenderRange() {
|
|
7237
|
-
this.setRenderRange(this.computeRenderRange());
|
|
7238
|
-
}
|
|
7239
|
-
getRenderStartIndex() {
|
|
7240
|
-
return this.renderRange.renderStartIndex;
|
|
7241
|
-
}
|
|
7242
|
-
notifyScrollChange() {
|
|
7243
|
-
const { scrollPosition } = this;
|
|
7244
|
-
const fns = this.onScrollFns;
|
|
7245
|
-
for (let i = 0, len = fns.length; i < len; i++) {
|
|
7246
|
-
fns[i](scrollPosition);
|
|
7247
|
-
}
|
|
7248
|
-
}
|
|
7249
|
-
notifyDestroy() {
|
|
7250
|
-
const fns = this.onDestroyFns;
|
|
7251
|
-
for (let i = 0, len = fns.length; i < len; i++) {
|
|
7252
|
-
fns[i]();
|
|
7253
|
-
}
|
|
7254
|
-
}
|
|
7255
|
-
notifyTotalSizeChange() {
|
|
7256
|
-
const totalSize = this.getTotalSize();
|
|
7257
|
-
const fns = this.onTotalSizeChangeFns;
|
|
7258
|
-
for (let i = 0, len = fns.length; i < len; i++) {
|
|
7259
|
-
raf(() => {
|
|
7260
|
-
fns[i](totalSize);
|
|
7261
|
-
});
|
|
7262
|
-
}
|
|
7263
|
-
}
|
|
7264
|
-
notifyRenderCountChange() {
|
|
7265
|
-
const { renderCount } = this;
|
|
7266
|
-
const fns = this.onRenderCountChangeFns;
|
|
7267
|
-
for (let i = 0, len = fns.length; i < len; i++) {
|
|
7268
|
-
raf(() => {
|
|
7269
|
-
fns[i](renderCount);
|
|
7270
|
-
});
|
|
7023
|
+
if (scrolling) {
|
|
7024
|
+
classList.add(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
7025
|
+
} else {
|
|
7026
|
+
classList.remove(InfiniteClsScrolling, TableClassName__Scrolling);
|
|
7027
|
+
}
|
|
7271
7028
|
}
|
|
7272
|
-
}
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7029
|
+
}, [scrollStopDelay, onScrollStop]);
|
|
7030
|
+
const onContainerScroll = (0, import_react34.useCallback)((scrollInfo) => {
|
|
7031
|
+
verticalVirtualBrain.setScrollPosition(scrollInfo);
|
|
7032
|
+
horizontalVirtualBrain.setScrollPosition(scrollInfo);
|
|
7033
|
+
setScrolling(true);
|
|
7034
|
+
}, [
|
|
7035
|
+
horizontalVirtualBrain,
|
|
7036
|
+
verticalVirtualBrain,
|
|
7037
|
+
domRef.current,
|
|
7038
|
+
setScrolling
|
|
7039
|
+
]);
|
|
7040
|
+
const scrollPositionRef = (0, import_react34.useRef)({
|
|
7041
|
+
scrollLeft: 0,
|
|
7042
|
+
scrollTop: 0
|
|
7043
|
+
});
|
|
7044
|
+
const applyScrollHorizontal = (0, import_react34.useCallback)(({ scrollLeft }) => {
|
|
7045
|
+
scrollPositionRef.current.scrollLeft = scrollLeft;
|
|
7046
|
+
onContainerScroll(scrollPositionRef.current);
|
|
7047
|
+
}, [onContainerScroll]);
|
|
7048
|
+
const applyScrollVertical = (0, import_react34.useCallback)(({ scrollTop }) => {
|
|
7049
|
+
scrollPositionRef.current.scrollTop = scrollTop;
|
|
7050
|
+
onContainerScroll(scrollPositionRef.current);
|
|
7051
|
+
if (scrollTop === 0) {
|
|
7052
|
+
onScrollToTop == null ? void 0 : onScrollToTop();
|
|
7280
7053
|
}
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
this.debug("Set renderRange to %d-%d", renderRange.renderStartIndex, renderRange.renderEndIndex);
|
|
7054
|
+
const offset = scrollToBottomOffset != null ? scrollToBottomOffset : SCROLL_BOTTOM_OFFSET;
|
|
7055
|
+
const isScrollBottom = scrollTop + offset >= scrollTopMaxRef.current;
|
|
7056
|
+
if (isScrollBottom) {
|
|
7057
|
+
onScrollToBottom == null ? void 0 : onScrollToBottom();
|
|
7058
|
+
if (getDataSourceState().livePagination) {
|
|
7059
|
+
dataSourceActions.cursorId = Date.now();
|
|
7288
7060
|
}
|
|
7289
|
-
this.notifyRenderRangeChange();
|
|
7290
7061
|
}
|
|
7062
|
+
}, [onContainerScroll, scrollToBottomOffset, onScrollToBottom, onScrollToTop]);
|
|
7063
|
+
return {
|
|
7064
|
+
applyScrollHorizontal,
|
|
7065
|
+
applyScrollVertical
|
|
7066
|
+
};
|
|
7067
|
+
};
|
|
7068
|
+
|
|
7069
|
+
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
7070
|
+
var React30 = __toModule(require("react"));
|
|
7071
|
+
var import_react37 = __toModule(require("react"));
|
|
7072
|
+
|
|
7073
|
+
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
7074
|
+
var React29 = __toModule(require("react"));
|
|
7075
|
+
var import_react36 = __toModule(require("react"));
|
|
7076
|
+
|
|
7077
|
+
// src/components/hooks/useOnMount.ts
|
|
7078
|
+
var import_react35 = __toModule(require("react"));
|
|
7079
|
+
function useOnMount(domRef, props) {
|
|
7080
|
+
(0, import_react35.useEffect)(() => {
|
|
7081
|
+
const { onMount, onUnmount } = props;
|
|
7082
|
+
const node = domRef == null ? void 0 : domRef.current;
|
|
7083
|
+
onMount == null ? void 0 : onMount(node);
|
|
7084
|
+
return () => {
|
|
7085
|
+
onUnmount == null ? void 0 : onUnmount(node);
|
|
7086
|
+
};
|
|
7087
|
+
}, []);
|
|
7088
|
+
}
|
|
7089
|
+
|
|
7090
|
+
// src/components/VirtualList/InfiniteListRootClassName.ts
|
|
7091
|
+
var InfiniteListRootClassName = "InfiniteList";
|
|
7092
|
+
|
|
7093
|
+
// src/components/VirtualList/RowListWithExternalScrolling.tsx
|
|
7094
|
+
var rootClassName10 = InfiniteListRootClassName;
|
|
7095
|
+
var defaultClasses = [
|
|
7096
|
+
willChange.transform,
|
|
7097
|
+
position.relative,
|
|
7098
|
+
transform.translateZero
|
|
7099
|
+
];
|
|
7100
|
+
var RowListWithExternalScrolling = (props) => {
|
|
7101
|
+
const {
|
|
7102
|
+
renderRow,
|
|
7103
|
+
repaintId,
|
|
7104
|
+
brain,
|
|
7105
|
+
updateScroll,
|
|
7106
|
+
style,
|
|
7107
|
+
className,
|
|
7108
|
+
onMount,
|
|
7109
|
+
onUnmount
|
|
7110
|
+
} = props;
|
|
7111
|
+
const domRef = (0, import_react36.useRef)(null);
|
|
7112
|
+
const renderItem = (0, import_react36.useCallback)((renderProps) => renderRow({
|
|
7113
|
+
domRef: renderProps.domRef,
|
|
7114
|
+
rowHeight: renderProps.itemSize,
|
|
7115
|
+
rowIndex: renderProps.itemIndex
|
|
7116
|
+
}), [renderRow]);
|
|
7117
|
+
useOnMount(domRef, {
|
|
7118
|
+
onMount,
|
|
7119
|
+
onUnmount
|
|
7120
|
+
});
|
|
7121
|
+
(0, import_react36.useEffect)(() => {
|
|
7122
|
+
const onScroll = (scrollPosition) => {
|
|
7123
|
+
const node = domRef.current;
|
|
7124
|
+
if (node) {
|
|
7125
|
+
if (true) {
|
|
7126
|
+
const { renderStartIndex, renderEndIndex } = brain.getRenderRange();
|
|
7127
|
+
node.dataset.renderStartIndex = renderStartIndex;
|
|
7128
|
+
node.dataset.renderEndIndex = renderEndIndex;
|
|
7129
|
+
}
|
|
7130
|
+
if (updateScroll) {
|
|
7131
|
+
updateScroll(node, scrollPosition);
|
|
7132
|
+
} else {
|
|
7133
|
+
node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, ${-scrollPosition.scrollTop}px, 0px)`;
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
};
|
|
7137
|
+
const removeOnScroll = brain.onScroll(onScroll);
|
|
7138
|
+
return () => {
|
|
7139
|
+
removeOnScroll();
|
|
7140
|
+
};
|
|
7141
|
+
}, [brain]);
|
|
7142
|
+
const domProps = {
|
|
7143
|
+
ref: domRef,
|
|
7144
|
+
style,
|
|
7145
|
+
className: join(className, rootClassName10, `${rootClassName10}--vertical`, VirtualListCls, VirtualListClsOrientation.vertical, ...defaultClasses)
|
|
7146
|
+
};
|
|
7147
|
+
if (true) {
|
|
7148
|
+
domProps["data-cmp-name"] = "RowListWithExternalScrolling";
|
|
7291
7149
|
}
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7150
|
+
return /* @__PURE__ */ React29.createElement("div", __spreadValues({}, domProps), /* @__PURE__ */ React29.createElement(RawList, {
|
|
7151
|
+
brain,
|
|
7152
|
+
renderItem,
|
|
7153
|
+
repaintId
|
|
7154
|
+
}));
|
|
7155
|
+
};
|
|
7156
|
+
|
|
7157
|
+
// src/components/InfiniteTable/hooks/usePinnedRendering.tsx
|
|
7158
|
+
var UPDATE_SCROLL3 = (node, brainScrollPosition, horizontalPinnedScrollPosition) => {
|
|
7159
|
+
node.style.transform = `translate3d(${horizontalPinnedScrollPosition ? -horizontalPinnedScrollPosition.scrollLeft : 0}px, ${-brainScrollPosition.scrollTop}px, 0px)`;
|
|
7160
|
+
};
|
|
7161
|
+
var PinnedRowsContainerClassName = `InfinitePinnedRows`;
|
|
7162
|
+
function PinnedRowsContainer(props) {
|
|
7163
|
+
const {
|
|
7164
|
+
maxWidth,
|
|
7165
|
+
pinning,
|
|
7166
|
+
rowWidth,
|
|
7167
|
+
height,
|
|
7168
|
+
pinnedScrollListener,
|
|
7169
|
+
hasOverflow,
|
|
7170
|
+
brain,
|
|
7171
|
+
renderRow
|
|
7172
|
+
} = props;
|
|
7173
|
+
const style = React30.useMemo(() => {
|
|
7174
|
+
const result = pinning === "end" ? {
|
|
7175
|
+
width: rowWidth,
|
|
7176
|
+
height,
|
|
7177
|
+
right: 0
|
|
7178
|
+
} : {};
|
|
7179
|
+
if (!hasOverflow && pinning === "end") {
|
|
7180
|
+
result.position = "absolute";
|
|
7300
7181
|
}
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
renderEndIndex = count - 1;
|
|
7305
|
-
renderStartIndex = renderEndIndex - renderCount + 1;
|
|
7182
|
+
if (hasOverflow) {
|
|
7183
|
+
result.height = getScrollbarWidth();
|
|
7184
|
+
result.width = getScrollbarWidth();
|
|
7306
7185
|
}
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7186
|
+
return result;
|
|
7187
|
+
}, [height, rowWidth, pinning, hasOverflow]);
|
|
7188
|
+
const updateScroll = (0, import_react37.useCallback)((node, scrollPosition) => {
|
|
7189
|
+
UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
|
|
7190
|
+
}, [hasOverflow, pinnedScrollListener]);
|
|
7191
|
+
const rowListProps = {
|
|
7192
|
+
style,
|
|
7193
|
+
brain,
|
|
7194
|
+
renderRow,
|
|
7195
|
+
updateScroll,
|
|
7196
|
+
className: join(`${PinnedRowsContainerClassName}`, PinnedRowsClsVariants[pinning === "start" ? "pinnedStart" : "pinnedEnd"], `${PinnedRowsContainerClassName}--pinned-${pinning}`, `${PinnedRowsContainerClassName}--overflow`, PinnedRowsClsVariants.overflow)
|
|
7197
|
+
};
|
|
7198
|
+
if (hasOverflow) {
|
|
7199
|
+
return /* @__PURE__ */ React30.createElement(VirtualScrollContainer, {
|
|
7200
|
+
scrollable: {
|
|
7201
|
+
horizontal: true,
|
|
7202
|
+
vertical: false
|
|
7203
|
+
},
|
|
7204
|
+
style: {
|
|
7205
|
+
width: maxWidth,
|
|
7206
|
+
height,
|
|
7207
|
+
position: "absolute",
|
|
7208
|
+
[pinning === "start" ? "left" : "right"]: 0,
|
|
7209
|
+
[pinning === "start" ? "right" : "left"]: "unset"
|
|
7210
|
+
},
|
|
7211
|
+
onContainerScroll: pinnedScrollListener == null ? void 0 : pinnedScrollListener.setScrollPosition,
|
|
7212
|
+
className: join(PinnedRowsContainerClsVariants({
|
|
7213
|
+
pinned: pinning
|
|
7214
|
+
}), `${PinnedRowsContainerClassName}Container`, `${PinnedRowsContainerClassName}Container--pinned-${pinning}`)
|
|
7215
|
+
}, /* @__PURE__ */ React30.createElement(RowListWithExternalScrolling, __spreadProps(__spreadValues({}, rowListProps), {
|
|
7216
|
+
onMount: (node) => {
|
|
7217
|
+
pinnedScrollListener == null ? void 0 : pinnedScrollListener.onScroll((scrollPosition) => {
|
|
7218
|
+
updateScroll(node, brain.getScrollPosition(), scrollPosition);
|
|
7219
|
+
});
|
|
7311
7220
|
}
|
|
7312
|
-
}
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
};
|
|
7317
|
-
}
|
|
7318
|
-
getItemSizeCacheFor(itemIndex) {
|
|
7319
|
-
return this.itemSizeCache[itemIndex];
|
|
7221
|
+
})), /* @__PURE__ */ React30.createElement(SpacePlaceholder, {
|
|
7222
|
+
width: rowWidth,
|
|
7223
|
+
height: 1
|
|
7224
|
+
}));
|
|
7320
7225
|
}
|
|
7321
|
-
};
|
|
7226
|
+
return /* @__PURE__ */ React30.createElement(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
|
|
7227
|
+
}
|
|
7228
|
+
function useRenderPinnedRow(params) {
|
|
7229
|
+
const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
|
|
7230
|
+
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
7231
|
+
const dataArray = getData();
|
|
7232
|
+
const rowInfo = dataArray[rowParams.rowIndex];
|
|
7233
|
+
const { showZebraRows, showHoverRows } = getState();
|
|
7234
|
+
const rowProps = __spreadValues({
|
|
7235
|
+
rowInfo,
|
|
7236
|
+
getData,
|
|
7237
|
+
showZebraRows,
|
|
7238
|
+
showHoverRows,
|
|
7239
|
+
toggleGroupRow: params.toggleGroupRow,
|
|
7240
|
+
virtualizeColumns: false,
|
|
7241
|
+
verticalBrain,
|
|
7242
|
+
brain: null,
|
|
7243
|
+
rowSpan,
|
|
7244
|
+
rowWidth: columnsWidth,
|
|
7245
|
+
columns
|
|
7246
|
+
}, rowParams);
|
|
7247
|
+
return /* @__PURE__ */ React30.createElement(TableRowUnvirtualized, __spreadValues({}, rowProps));
|
|
7248
|
+
}, [columnsWidth, columns, verticalBrain]);
|
|
7249
|
+
return renderPinnedRow;
|
|
7250
|
+
}
|
|
7251
|
+
function usePinnedRenderingForSide(side, params) {
|
|
7252
|
+
const {
|
|
7253
|
+
getState,
|
|
7254
|
+
getData,
|
|
7255
|
+
rowHeight,
|
|
7256
|
+
bodySize,
|
|
7257
|
+
computedPinnedEndColumns,
|
|
7258
|
+
computedPinnedEndColumnsWidth,
|
|
7259
|
+
computedPinnedStartColumns,
|
|
7260
|
+
computedPinnedStartColumnsWidth,
|
|
7261
|
+
verticalVirtualBrain,
|
|
7262
|
+
computedPinnedEndWidth,
|
|
7263
|
+
computedPinnedEndOverflow,
|
|
7264
|
+
computedPinnedStartWidth,
|
|
7265
|
+
computedPinnedStartOverflow,
|
|
7266
|
+
pinnedStartScrollListener,
|
|
7267
|
+
pinnedEndScrollListener,
|
|
7268
|
+
rowSpan,
|
|
7269
|
+
repaintId,
|
|
7270
|
+
toggleGroupRow,
|
|
7271
|
+
scrollbars: {
|
|
7272
|
+
vertical: hasVerticalScrollbar,
|
|
7273
|
+
horizontal: hasHorizontalScrollbar
|
|
7274
|
+
}
|
|
7275
|
+
} = params;
|
|
7276
|
+
const count = getData().length;
|
|
7277
|
+
const rowWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
|
|
7278
|
+
const columns = side === "start" ? computedPinnedStartColumns : computedPinnedEndColumns;
|
|
7279
|
+
const columnsWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
|
|
7280
|
+
const maxWidth = side === "start" ? computedPinnedStartWidth : computedPinnedEndWidth;
|
|
7281
|
+
const hasOverflow = side === "start" ? computedPinnedStartOverflow : computedPinnedEndOverflow;
|
|
7282
|
+
const pinnedScrollListener = side === "start" ? pinnedStartScrollListener : pinnedEndScrollListener;
|
|
7283
|
+
const renderRowPinned = useRenderPinnedRow({
|
|
7284
|
+
getData,
|
|
7285
|
+
getState,
|
|
7286
|
+
toggleGroupRow,
|
|
7287
|
+
rowSpan,
|
|
7288
|
+
verticalBrain: verticalVirtualBrain,
|
|
7289
|
+
columns,
|
|
7290
|
+
columnsWidth
|
|
7291
|
+
});
|
|
7292
|
+
const pinnedList = columns.length && rowHeight !== 0 ? /* @__PURE__ */ React30.createElement(PinnedRowsContainer, {
|
|
7293
|
+
pinning: side,
|
|
7294
|
+
pinnedScrollListener,
|
|
7295
|
+
hasOverflow,
|
|
7296
|
+
rowHeight,
|
|
7297
|
+
rowWidth,
|
|
7298
|
+
maxWidth,
|
|
7299
|
+
height: bodySize.height,
|
|
7300
|
+
count,
|
|
7301
|
+
repaintId: `${repaintId}-pin-${side}-${rowHeight}`,
|
|
7302
|
+
brain: verticalVirtualBrain,
|
|
7303
|
+
renderRow: renderRowPinned
|
|
7304
|
+
}) : null;
|
|
7305
|
+
const pinnedScrollbarPlaceholder = pinnedList && hasHorizontalScrollbar && !hasOverflow ? /* @__PURE__ */ React30.createElement(HorizontalScrollbarPlaceholder, {
|
|
7306
|
+
style: side === "end" ? {
|
|
7307
|
+
width: columnsWidth,
|
|
7308
|
+
right: hasVerticalScrollbar ? getScrollbarWidth() : 0
|
|
7309
|
+
} : {
|
|
7310
|
+
width: columnsWidth,
|
|
7311
|
+
left: 0
|
|
7312
|
+
}
|
|
7313
|
+
}) : null;
|
|
7314
|
+
return {
|
|
7315
|
+
renderRowPinned,
|
|
7316
|
+
pinnedList,
|
|
7317
|
+
pinnedScrollbarPlaceholder
|
|
7318
|
+
};
|
|
7319
|
+
}
|
|
7320
|
+
function usePinnedEndRendering(params) {
|
|
7321
|
+
const {
|
|
7322
|
+
renderRowPinned: renderRowPinnedEnd,
|
|
7323
|
+
pinnedList: pinnedEndList,
|
|
7324
|
+
pinnedScrollbarPlaceholder: pinnedEndScrollbarPlaceholder
|
|
7325
|
+
} = usePinnedRenderingForSide("end", params);
|
|
7326
|
+
return {
|
|
7327
|
+
renderRowPinnedEnd,
|
|
7328
|
+
pinnedEndList,
|
|
7329
|
+
pinnedEndScrollbarPlaceholder
|
|
7330
|
+
};
|
|
7331
|
+
}
|
|
7332
|
+
function usePinnedStartRendering(params) {
|
|
7333
|
+
const {
|
|
7334
|
+
renderRowPinned: renderRowPinnedStart,
|
|
7335
|
+
pinnedList: pinnedStartList,
|
|
7336
|
+
pinnedScrollbarPlaceholder: pinnedStartScrollbarPlaceholder
|
|
7337
|
+
} = usePinnedRenderingForSide("start", params);
|
|
7338
|
+
const result = {
|
|
7339
|
+
renderRowPinnedStart,
|
|
7340
|
+
pinnedStartList,
|
|
7341
|
+
pinnedStartScrollbarPlaceholder
|
|
7342
|
+
};
|
|
7343
|
+
return result;
|
|
7344
|
+
}
|
|
7322
7345
|
|
|
7323
|
-
// src/components/InfiniteTable/hooks/
|
|
7346
|
+
// src/components/InfiniteTable/hooks/useYourBrain.ts
|
|
7324
7347
|
var import_react39 = __toModule(require("react"));
|
|
7348
|
+
|
|
7349
|
+
// src/components/InfiniteTable/hooks/useColumnSizeFn.ts
|
|
7350
|
+
var import_react38 = __toModule(require("react"));
|
|
7325
7351
|
var debug5 = dbg("useColumnSizeFn");
|
|
7326
7352
|
function useColumnSizeFn(computedUnpinnedColumns) {
|
|
7327
|
-
const columnSize = (0,
|
|
7353
|
+
const columnSize = (0, import_react38.useCallback)((index) => {
|
|
7328
7354
|
const column = computedUnpinnedColumns[index];
|
|
7329
7355
|
if (!column) {
|
|
7330
7356
|
debug5("cannot find column at index", index, computedUnpinnedColumns);
|
|
@@ -7338,6 +7364,8 @@ function useColumnSizeFn(computedUnpinnedColumns) {
|
|
|
7338
7364
|
function useYourBrain(param) {
|
|
7339
7365
|
const {
|
|
7340
7366
|
dataArray,
|
|
7367
|
+
horizontalVirtualBrain,
|
|
7368
|
+
verticalVirtualBrain,
|
|
7341
7369
|
computedUnpinnedColumns,
|
|
7342
7370
|
computedPinnedStartWidth,
|
|
7343
7371
|
computedPinnedEndWidth,
|
|
@@ -7346,42 +7374,19 @@ function useYourBrain(param) {
|
|
|
7346
7374
|
rowSpan
|
|
7347
7375
|
} = param;
|
|
7348
7376
|
const columnSize = useColumnSizeFn(computedUnpinnedColumns);
|
|
7349
|
-
const horizontalVirtualBrain = useOnce(() => {
|
|
7350
|
-
const brain = new VirtualBrain({
|
|
7351
|
-
count: computedUnpinnedColumns.length,
|
|
7352
|
-
itemSize: columnSize,
|
|
7353
|
-
mainAxis: "horizontal"
|
|
7354
|
-
});
|
|
7355
|
-
return brain;
|
|
7356
|
-
});
|
|
7357
|
-
const verticalVirtualBrain = useOnce(() => {
|
|
7358
|
-
const brain = new VirtualBrain({
|
|
7359
|
-
count: dataArray.length,
|
|
7360
|
-
itemSize: rowHeight,
|
|
7361
|
-
mainAxis: "vertical",
|
|
7362
|
-
itemSpan: rowSpan
|
|
7363
|
-
});
|
|
7364
|
-
return brain;
|
|
7365
|
-
});
|
|
7366
|
-
(0, import_react40.useEffect)(() => {
|
|
7367
|
-
return () => {
|
|
7368
|
-
horizontalVirtualBrain.destroy();
|
|
7369
|
-
verticalVirtualBrain.destroy();
|
|
7370
|
-
};
|
|
7371
|
-
}, []);
|
|
7372
7377
|
horizontalVirtualBrain.update(computedUnpinnedColumns.length, columnSize);
|
|
7373
7378
|
verticalVirtualBrain.update(dataArray.length, rowHeight, rowSpan);
|
|
7374
7379
|
if (true) {
|
|
7375
7380
|
globalThis.verticalVirtualBrain = verticalVirtualBrain;
|
|
7376
7381
|
globalThis.horizontalVirtualBrain = horizontalVirtualBrain;
|
|
7377
7382
|
}
|
|
7378
|
-
(0,
|
|
7383
|
+
(0, import_react39.useEffect)(() => {
|
|
7379
7384
|
verticalVirtualBrain.setAvailableSize({
|
|
7380
7385
|
height: bodySize.height,
|
|
7381
7386
|
width: 0
|
|
7382
7387
|
});
|
|
7383
7388
|
}, [bodySize, verticalVirtualBrain]);
|
|
7384
|
-
(0,
|
|
7389
|
+
(0, import_react39.useEffect)(() => {
|
|
7385
7390
|
horizontalVirtualBrain.setAvailableSize({
|
|
7386
7391
|
height: 0,
|
|
7387
7392
|
width: Math.max(bodySize.width - computedPinnedStartWidth - computedPinnedEndWidth, 0)
|
|
@@ -7417,15 +7422,19 @@ function useListRendering(param) {
|
|
|
7417
7422
|
pinnedStartMaxWidth,
|
|
7418
7423
|
pinnedEndMaxWidth,
|
|
7419
7424
|
pinnedStartScrollListener,
|
|
7420
|
-
pinnedEndScrollListener
|
|
7425
|
+
pinnedEndScrollListener,
|
|
7426
|
+
verticalVirtualBrain,
|
|
7427
|
+
horizontalVirtualBrain
|
|
7421
7428
|
} = componentState;
|
|
7422
7429
|
const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
|
|
7423
|
-
const repaintIdRef = (0,
|
|
7430
|
+
const repaintIdRef = (0, import_react40.useRef)(0);
|
|
7424
7431
|
if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
|
|
7425
7432
|
repaintIdRef.current++;
|
|
7426
7433
|
}
|
|
7427
7434
|
const repaintId = repaintIdRef.current;
|
|
7428
|
-
|
|
7435
|
+
useYourBrain({
|
|
7436
|
+
horizontalVirtualBrain,
|
|
7437
|
+
verticalVirtualBrain,
|
|
7429
7438
|
computedPinnedStartWidth: computed.computedPinnedStartWidth,
|
|
7430
7439
|
computedPinnedEndWidth: computed.computedPinnedEndWidth,
|
|
7431
7440
|
computedUnpinnedColumns: computed.computedUnpinnedColumns,
|
|
@@ -7437,15 +7446,16 @@ function useListRendering(param) {
|
|
|
7437
7446
|
const hasHorizontalScrollbar = computedUnpinnedColumnsWidth > bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth;
|
|
7438
7447
|
const reservedContentHeight = verticalVirtualBrain.getTotalSize() + (hasHorizontalScrollbar ? getScrollbarWidth() : 0);
|
|
7439
7448
|
const hasVerticalScrollbar = bodySize.height > 0 && bodySize.height < reservedContentHeight;
|
|
7440
|
-
const scrollbars = (0,
|
|
7449
|
+
const scrollbars = (0, import_react40.useMemo)(() => ({
|
|
7441
7450
|
vertical: hasVerticalScrollbar,
|
|
7442
7451
|
horizontal: hasHorizontalScrollbar
|
|
7443
7452
|
}), [hasVerticalScrollbar, hasHorizontalScrollbar]);
|
|
7444
|
-
(0,
|
|
7453
|
+
(0, import_react40.useEffect)(() => {
|
|
7445
7454
|
if (!bodySize.height) {
|
|
7446
7455
|
return;
|
|
7447
7456
|
}
|
|
7448
7457
|
const { onReady } = getState();
|
|
7458
|
+
componentActions.ready = true;
|
|
7449
7459
|
if (onReady) {
|
|
7450
7460
|
const imperativeApi = {
|
|
7451
7461
|
setColumnOrder: (columnOrder) => {
|
|
@@ -7496,7 +7506,7 @@ function useListRendering(param) {
|
|
|
7496
7506
|
computedUnpinnedColumns
|
|
7497
7507
|
});
|
|
7498
7508
|
const [, rerender] = useRerender();
|
|
7499
|
-
(0,
|
|
7509
|
+
(0, import_react40.useEffect)(() => {
|
|
7500
7510
|
rerender();
|
|
7501
7511
|
}, [dataSourceState]);
|
|
7502
7512
|
const { pinnedStartList, pinnedStartScrollbarPlaceholder } = usePinnedStartRendering(pinnedRenderingParams);
|
|
@@ -7520,7 +7530,7 @@ function useListRendering(param) {
|
|
|
7520
7530
|
|
|
7521
7531
|
// src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx
|
|
7522
7532
|
var React31 = __toModule(require("react"));
|
|
7523
|
-
var
|
|
7533
|
+
var import_react41 = __toModule(require("react"));
|
|
7524
7534
|
|
|
7525
7535
|
// src/components/utils/decamelize.ts
|
|
7526
7536
|
function decamelize(str, options) {
|
|
@@ -7569,7 +7579,7 @@ var InfiniteTableLicenseFooter = React31.forwardRef(function InfiniteTableLicens
|
|
|
7569
7579
|
ref.current = node;
|
|
7570
7580
|
}
|
|
7571
7581
|
}, []);
|
|
7572
|
-
(0,
|
|
7582
|
+
(0, import_react41.useEffect)(() => {
|
|
7573
7583
|
const forceStyle = () => {
|
|
7574
7584
|
requestAnimationFrame(() => {
|
|
7575
7585
|
var _a;
|
|
@@ -7597,7 +7607,7 @@ var InfiniteTableLicenseFooter = React31.forwardRef(function InfiniteTableLicens
|
|
|
7597
7607
|
});
|
|
7598
7608
|
|
|
7599
7609
|
// src/components/InfiniteTable/hooks/useLicense/useLicense.ts
|
|
7600
|
-
var
|
|
7610
|
+
var import_react42 = __toModule(require("react"));
|
|
7601
7611
|
|
|
7602
7612
|
// src/components/InfiniteTable/hooks/useLicense/crc32.ts
|
|
7603
7613
|
var DEFAULT_ReversedPolynomial = 3988292384;
|
|
@@ -7755,10 +7765,10 @@ var isInsideSandbox = () => {
|
|
|
7755
7765
|
};
|
|
7756
7766
|
var isInsidePlayground = isInsideSandbox() || isInsideSandpack();
|
|
7757
7767
|
var useLicense = (licenseKey = "") => {
|
|
7758
|
-
const valid = (0,
|
|
7768
|
+
const valid = (0, import_react42.useMemo)(() => {
|
|
7759
7769
|
let valid2 = isValidLicense(licenseKey, {
|
|
7760
7770
|
publishedAt: 1624970570587,
|
|
7761
|
-
version: "0.2.
|
|
7771
|
+
version: "0.2.11"
|
|
7762
7772
|
});
|
|
7763
7773
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
7764
7774
|
return true;
|
|
@@ -7770,7 +7780,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7770
7780
|
|
|
7771
7781
|
// src/components/CSSVariableWatch.tsx
|
|
7772
7782
|
var React32 = __toModule(require("react"));
|
|
7773
|
-
var
|
|
7783
|
+
var import_react43 = __toModule(require("react"));
|
|
7774
7784
|
var error = err("CSSVariableWatch");
|
|
7775
7785
|
var debug6 = dbg("CSSVariableWatch");
|
|
7776
7786
|
var WRAPPER_STYLE = {
|
|
@@ -7783,7 +7793,7 @@ var WRAPPER_STYLE = {
|
|
|
7783
7793
|
overflow: "hidden"
|
|
7784
7794
|
};
|
|
7785
7795
|
var useCSSVariableWatch = (params) => {
|
|
7786
|
-
const lastValueRef = (0,
|
|
7796
|
+
const lastValueRef = (0, import_react43.useRef)(0);
|
|
7787
7797
|
const onResize = React32.useCallback(({ height }) => {
|
|
7788
7798
|
if (height && height !== lastValueRef.current) {
|
|
7789
7799
|
lastValueRef.current = height;
|
|
@@ -7803,7 +7813,7 @@ var useCSSVariableWatch = (params) => {
|
|
|
7803
7813
|
}, []);
|
|
7804
7814
|
};
|
|
7805
7815
|
var CSSVariableWatch = (props) => {
|
|
7806
|
-
const domRef = (0,
|
|
7816
|
+
const domRef = (0, import_react43.useRef)(null);
|
|
7807
7817
|
useCSSVariableWatch(__spreadProps(__spreadValues({}, props), {
|
|
7808
7818
|
ref: domRef
|
|
7809
7819
|
}));
|
|
@@ -7913,19 +7923,151 @@ var LoadMaskTextCls = "qy58ya4";
|
|
|
7913
7923
|
|
|
7914
7924
|
// src/components/InfiniteTable/components/LoadMask.tsx
|
|
7915
7925
|
var { rootClassName: rootClassName11 } = internalProps;
|
|
7916
|
-
var
|
|
7926
|
+
var baseCls = `${rootClassName11}-LoadMask`;
|
|
7917
7927
|
function LoadMaskFn(props) {
|
|
7918
7928
|
const { visible, children = "Loading" } = props;
|
|
7919
7929
|
return /* @__PURE__ */ React33.createElement("div", {
|
|
7920
|
-
className: `${LoadMaskCls[visible ? "visible" : "hidden"]} ${
|
|
7930
|
+
className: `${LoadMaskCls[visible ? "visible" : "hidden"]} ${baseCls}`
|
|
7921
7931
|
}, /* @__PURE__ */ React33.createElement("div", {
|
|
7922
|
-
className: `${LoadMaskOverlayCls} ${
|
|
7932
|
+
className: `${LoadMaskOverlayCls} ${baseCls}-Overlay`
|
|
7923
7933
|
}), /* @__PURE__ */ React33.createElement("div", {
|
|
7924
|
-
className: `${LoadMaskTextCls} ${
|
|
7934
|
+
className: `${LoadMaskTextCls} ${baseCls}-Text`
|
|
7925
7935
|
}, children));
|
|
7926
7936
|
}
|
|
7927
7937
|
var LoadMask = React33.memo(LoadMaskFn);
|
|
7928
7938
|
|
|
7939
|
+
// src/components/InfiniteTable/hooks/useAutoSizeColumns.ts
|
|
7940
|
+
var import_react44 = __toModule(require("react"));
|
|
7941
|
+
var OFFSET = 10;
|
|
7942
|
+
function getColumnContentMaxWidths(domRef, options) {
|
|
7943
|
+
var _a;
|
|
7944
|
+
const { includeHeader, columnsToResize, columnsToSkip } = options;
|
|
7945
|
+
const query = `.${InfiniteTableCellClassName} > .${InfiniteTableCellContentClassName}`;
|
|
7946
|
+
let match = (_a = domRef.current) == null ? void 0 : _a.querySelectorAll(query);
|
|
7947
|
+
const measuredMaxWidths = {};
|
|
7948
|
+
const computedPaddingsForColumns = {};
|
|
7949
|
+
if (match && match.length) {
|
|
7950
|
+
match.forEach((content) => {
|
|
7951
|
+
const cell = content.parentElement;
|
|
7952
|
+
const isHeader = cell.matches(`.${InfiniteTableHeaderCellClassName}`);
|
|
7953
|
+
if (includeHeader === false && isHeader) {
|
|
7954
|
+
return;
|
|
7955
|
+
}
|
|
7956
|
+
const colId = cell.getAttribute("data-column-id");
|
|
7957
|
+
const contentClone = content.cloneNode(true);
|
|
7958
|
+
contentClone.style.visibility = "hidden";
|
|
7959
|
+
contentClone.style.pointerEvents = "none";
|
|
7960
|
+
contentClone.classList.remove(...cssEllipsisClassName.split(" "));
|
|
7961
|
+
contentClone.style.position = "absolute";
|
|
7962
|
+
cell.appendChild(contentClone);
|
|
7963
|
+
let measuredWidth = contentClone.offsetWidth;
|
|
7964
|
+
cell.removeChild(contentClone);
|
|
7965
|
+
if (!computedPaddingsForColumns[colId]) {
|
|
7966
|
+
const cellComputedStyle = getGlobal().getComputedStyle(cell);
|
|
7967
|
+
computedPaddingsForColumns[colId] = parseInt(cellComputedStyle.paddingLeft, 10) + parseInt(cellComputedStyle.paddingRight, 10) + parseInt(cellComputedStyle.borderLeftWidth, 10) + parseInt(cellComputedStyle.borderRightWidth, 10) + OFFSET;
|
|
7968
|
+
}
|
|
7969
|
+
measuredWidth += computedPaddingsForColumns[colId];
|
|
7970
|
+
if (isHeader) {
|
|
7971
|
+
let otherElementsLength = 0;
|
|
7972
|
+
cell.childNodes.forEach((child) => {
|
|
7973
|
+
if (child !== content) {
|
|
7974
|
+
const el = child;
|
|
7975
|
+
otherElementsLength += Math.max(el.offsetWidth, parseInt(el.style.width, 10));
|
|
7976
|
+
const style = getGlobal().getComputedStyle(el);
|
|
7977
|
+
otherElementsLength += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
|
|
7978
|
+
}
|
|
7979
|
+
});
|
|
7980
|
+
measuredWidth += otherElementsLength;
|
|
7981
|
+
}
|
|
7982
|
+
if (columnsToSkip && columnsToSkip.has(colId)) {
|
|
7983
|
+
return;
|
|
7984
|
+
}
|
|
7985
|
+
if (columnsToResize && !columnsToResize.has(colId)) {
|
|
7986
|
+
return;
|
|
7987
|
+
}
|
|
7988
|
+
measuredMaxWidths[colId] = Math.max(measuredWidth, measuredMaxWidths[colId] || 0);
|
|
7989
|
+
});
|
|
7990
|
+
}
|
|
7991
|
+
return measuredMaxWidths;
|
|
7992
|
+
}
|
|
7993
|
+
function useAutoSizeColumns() {
|
|
7994
|
+
const {
|
|
7995
|
+
getComponentState,
|
|
7996
|
+
componentActions,
|
|
7997
|
+
componentState: {
|
|
7998
|
+
domRef,
|
|
7999
|
+
ready,
|
|
8000
|
+
autoSizeColumnsKey,
|
|
8001
|
+
verticalVirtualBrain,
|
|
8002
|
+
horizontalVirtualBrain
|
|
8003
|
+
}
|
|
8004
|
+
} = useComponentState();
|
|
8005
|
+
const [refreshId, setRefreshId] = (0, import_react44.useState)(0);
|
|
8006
|
+
const theKey = typeof autoSizeColumnsKey === "object" ? autoSizeColumnsKey.key : autoSizeColumnsKey;
|
|
8007
|
+
const getTheKey = useLatest(theKey);
|
|
8008
|
+
const lastExecutedIdentifierRef = (0, import_react44.useRef)(null);
|
|
8009
|
+
(0, import_react44.useEffect)(() => {
|
|
8010
|
+
const key = getTheKey();
|
|
8011
|
+
if (key == null) {
|
|
8012
|
+
return;
|
|
8013
|
+
}
|
|
8014
|
+
const { current } = lastExecutedIdentifierRef;
|
|
8015
|
+
const onChange = () => {
|
|
8016
|
+
if (autoSizeColumnsKey !== current) {
|
|
8017
|
+
setRefreshId(refreshId + 1);
|
|
8018
|
+
}
|
|
8019
|
+
};
|
|
8020
|
+
const removeVertical = verticalVirtualBrain.onRenderRangeChange(onChange);
|
|
8021
|
+
const removeHorizontal = horizontalVirtualBrain.onRenderRangeChange(onChange);
|
|
8022
|
+
return () => {
|
|
8023
|
+
removeVertical();
|
|
8024
|
+
removeHorizontal();
|
|
8025
|
+
};
|
|
8026
|
+
}, [verticalVirtualBrain, horizontalVirtualBrain]);
|
|
8027
|
+
(0, import_react44.useEffect)(() => {
|
|
8028
|
+
var _a;
|
|
8029
|
+
if (theKey == null) {
|
|
8030
|
+
return;
|
|
8031
|
+
}
|
|
8032
|
+
const { autoSizeColumnsKey: autoSizeColumnsKey2 } = getComponentState();
|
|
8033
|
+
let columnsToResize;
|
|
8034
|
+
let columnsToSkip;
|
|
8035
|
+
let includeHeader = true;
|
|
8036
|
+
if (typeof autoSizeColumnsKey2 === "object") {
|
|
8037
|
+
if (autoSizeColumnsKey2.columnsToResize) {
|
|
8038
|
+
columnsToResize = new Set(autoSizeColumnsKey2.columnsToResize);
|
|
8039
|
+
}
|
|
8040
|
+
if (autoSizeColumnsKey2.columnsToSkip) {
|
|
8041
|
+
columnsToSkip = new Set(autoSizeColumnsKey2.columnsToSkip);
|
|
8042
|
+
}
|
|
8043
|
+
includeHeader = (_a = autoSizeColumnsKey2.includeHeader) != null ? _a : includeHeader;
|
|
8044
|
+
}
|
|
8045
|
+
lastExecutedIdentifierRef.current = theKey;
|
|
8046
|
+
const measuredMaxWidths = getColumnContentMaxWidths(domRef, {
|
|
8047
|
+
includeHeader,
|
|
8048
|
+
columnsToResize,
|
|
8049
|
+
columnsToSkip
|
|
8050
|
+
});
|
|
8051
|
+
const colIds = Object.keys(measuredMaxWidths);
|
|
8052
|
+
if (!colIds.length) {
|
|
8053
|
+
return;
|
|
8054
|
+
}
|
|
8055
|
+
const columnSizing = getComponentState().columnSizing;
|
|
8056
|
+
const newColumnSizing = __spreadValues({}, columnSizing);
|
|
8057
|
+
let changed = false;
|
|
8058
|
+
colIds.forEach((colId) => {
|
|
8059
|
+
var _a2;
|
|
8060
|
+
newColumnSizing[colId] = {
|
|
8061
|
+
width: measuredMaxWidths[colId]
|
|
8062
|
+
};
|
|
8063
|
+
changed = changed || newColumnSizing[colId].width !== ((_a2 = columnSizing[colId]) == null ? void 0 : _a2.width);
|
|
8064
|
+
});
|
|
8065
|
+
if (changed) {
|
|
8066
|
+
componentActions.columnSizing = newColumnSizing;
|
|
8067
|
+
}
|
|
8068
|
+
}, [theKey, ready, refreshId]);
|
|
8069
|
+
}
|
|
8070
|
+
|
|
7929
8071
|
// src/components/InfiniteTable/index.tsx
|
|
7930
8072
|
var InfiniteTableClassName = internalProps.rootClassName;
|
|
7931
8073
|
var ONLY_VERTICAL_SCROLLBAR = {
|
|
@@ -8012,6 +8154,7 @@ var InfiniteTableComponent = React34.memo(function InfiniteTableComponent2() {
|
|
|
8012
8154
|
React34.useEffect(() => {
|
|
8013
8155
|
dataSourceActions.scrollStopDelayUpdatedByTable = scrollStopDelay;
|
|
8014
8156
|
}, [scrollStopDelay]);
|
|
8157
|
+
useAutoSizeColumns();
|
|
8015
8158
|
return /* @__PURE__ */ React34.createElement("div", __spreadValues({
|
|
8016
8159
|
ref: domRef
|
|
8017
8160
|
}, domProps), header ? /* @__PURE__ */ React34.createElement(TableHeaderWrapper, {
|
|
@@ -8043,7 +8186,7 @@ var InfiniteTableComponent = React34.memo(function InfiniteTableComponent2() {
|
|
|
8043
8186
|
});
|
|
8044
8187
|
function InfiniteTableContextProvider() {
|
|
8045
8188
|
const { componentActions, componentState } = useComponentState();
|
|
8046
|
-
const { scrollerDOMRef,
|
|
8189
|
+
const { scrollerDOMRef, scrollTopKey } = componentState;
|
|
8047
8190
|
const computed = useComputed();
|
|
8048
8191
|
const getComputed = useLatest(computed);
|
|
8049
8192
|
const getState = useLatest(componentState);
|
|
@@ -8082,7 +8225,7 @@ function InfiniteTableContextProvider() {
|
|
|
8082
8225
|
if (scrollerDOMRef.current) {
|
|
8083
8226
|
scrollerDOMRef.current.scrollTop = 0;
|
|
8084
8227
|
}
|
|
8085
|
-
}, [
|
|
8228
|
+
}, [scrollTopKey, scrollerDOMRef]);
|
|
8086
8229
|
const TableContext2 = getInfiniteTableContext();
|
|
8087
8230
|
return /* @__PURE__ */ React34.createElement(TableContext2.Provider, {
|
|
8088
8231
|
value: contextValue
|