pixel-virtual-tree 1.0.13 → 1.0.15
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/lib/components/Button/Button.js +4 -2
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Button/types.d.ts +4 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js +3 -33
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.js +4 -4
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js +10 -144
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.d.ts +3 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js +54 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.d.ts +2 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.js +34 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/util.js.map +1 -1
- package/lib/components/Icon/iconList.js +8 -0
- package/lib/components/Icon/iconList.js.map +1 -1
- package/lib/components/StatusButton/StatusButton.js +1 -1
- package/lib/components/StatusButton/StatusButton.js.map +1 -1
- package/lib/components/StepsLandingTable/Components/StepTableMainRow.js +1 -1
- package/lib/components/StepsLandingTable/Components/StepTableMainRow.js.map +1 -1
- package/lib/components/Table/Table.js +7 -4
- package/lib/components/Table/Table.js.map +1 -1
- package/lib/components/Table/Types.d.ts +10 -0
- package/lib/components/Table/components/SortableRow.d.ts +1 -1
- package/lib/components/Table/components/SortableRow.js +4 -2
- package/lib/components/Table/components/SortableRow.js.map +1 -1
- package/lib/components/Table/components/VirtualizedRows.d.ts +1 -1
- package/lib/components/Table/components/VirtualizedRows.js +3 -2
- package/lib/components/Table/components/VirtualizedRows.js.map +1 -1
- package/lib/components/TableTreeFn/Components/TableRow.js +1 -1
- package/lib/components/TableTreeFn/Components/TableRow.js.map +1 -1
- package/lib/components/TableTreeFn/TableTreeFn.d.ts +2 -1
- package/lib/components/TableTreeFn/index.d.ts +1 -2
- package/lib/components/TableTreeFn/index.js +1 -5
- package/lib/components/TableTreeFn/index.js.map +1 -1
- package/lib/components/TableTreeFn/tree-v2/TreeTableController.d.ts +1 -0
- package/lib/components/TableTreeFn/tree-v2/TreeTableController.js +58 -0
- package/lib/components/TableTreeFn/tree-v2/TreeTableController.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/compat/callbackBridge.d.ts +1 -0
- package/lib/components/TableTreeFn/tree-v2/compat/callbackBridge.js +7 -0
- package/lib/components/TableTreeFn/tree-v2/compat/callbackBridge.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/interactions/useTreeEvents.d.ts +1 -0
- package/lib/components/TableTreeFn/tree-v2/interactions/useTreeEvents.js +45 -0
- package/lib/components/TableTreeFn/tree-v2/interactions/useTreeEvents.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/legacyAdapter.d.ts +11 -0
- package/lib/components/TableTreeFn/tree-v2/legacyAdapter.js +38 -0
- package/lib/components/TableTreeFn/tree-v2/legacyAdapter.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeCell.d.ts +3 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeCell.js +9 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeCell.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeIndent.d.ts +3 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeIndent.js +5 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeIndent.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeRow.d.ts +9 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeRow.js +18 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeRow.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeViewportRenderer.d.ts +11 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeViewportRenderer.js +11 -0
- package/lib/components/TableTreeFn/tree-v2/render/TreeViewportRenderer.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/useRowHeight.d.ts +1 -0
- package/lib/components/TableTreeFn/tree-v2/render/useRowHeight.js +17 -0
- package/lib/components/TableTreeFn/tree-v2/render/useRowHeight.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/types.d.ts +31 -0
- package/lib/components/TableTreeFn/tree-v2/types.js +2 -0
- package/lib/components/TableTreeFn/tree-v2/types.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/HeightIndex.d.ts +11 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/HeightIndex.js +59 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/HeightIndex.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/calcViewport.d.ts +7 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/calcViewport.js +19 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/calcViewport.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/types.d.ts +16 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/types.js +2 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/types.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/useVirtualViewport.d.ts +7 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/useVirtualViewport.js +42 -0
- package/lib/components/TableTreeFn/tree-v2/virtualization/useVirtualViewport.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/addNode.d.ts +19 -0
- package/lib/components/TableTreeFn/tree-v2/worker/addNode.js +46 -0
- package/lib/components/TableTreeFn/tree-v2/worker/addNode.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/collapse.d.ts +5 -0
- package/lib/components/TableTreeFn/tree-v2/worker/collapse.js +24 -0
- package/lib/components/TableTreeFn/tree-v2/worker/collapse.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/expand.d.ts +5 -0
- package/lib/components/TableTreeFn/tree-v2/worker/expand.js +29 -0
- package/lib/components/TableTreeFn/tree-v2/worker/expand.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/flatten.d.ts +6 -0
- package/lib/components/TableTreeFn/tree-v2/worker/flatten.js +22 -0
- package/lib/components/TableTreeFn/tree-v2/worker/flatten.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/heights.d.ts +7 -0
- package/lib/components/TableTreeFn/tree-v2/worker/heights.js +13 -0
- package/lib/components/TableTreeFn/tree-v2/worker/heights.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/protocol.d.ts +77 -0
- package/lib/components/TableTreeFn/tree-v2/worker/protocol.js +2 -0
- package/lib/components/TableTreeFn/tree-v2/worker/protocol.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/selection.d.ts +6 -0
- package/lib/components/TableTreeFn/tree-v2/worker/selection.js +60 -0
- package/lib/components/TableTreeFn/tree-v2/worker/selection.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/state.d.ts +20 -0
- package/lib/components/TableTreeFn/tree-v2/worker/state.js +20 -0
- package/lib/components/TableTreeFn/tree-v2/worker/state.js.map +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/tree.worker.d.ts +1 -0
- package/lib/components/TableTreeFn/tree-v2/worker/tree.worker.js +83 -0
- package/lib/components/TableTreeFn/tree-v2/worker/tree.worker.js.map +1 -0
- package/lib/components/TableTreeFn/types.d.ts +14 -17
- package/lib/index.d.ts +53 -117
- package/lib/index.js +16 -8
- package/lib/index.js.map +1 -1
- package/lib/styles.css +1 -1
- package/lib/styles.css.map +1 -1
- package/lib/treeWorker.js +2 -0
- package/lib/treeWorker.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/getEncryptedData/getEncryptedData.d.ts +1 -1
- package/lib/utils/getEncryptedData/getEncryptedData.js +28 -16
- package/lib/utils/getEncryptedData/getEncryptedData.js.map +1 -1
- package/package.json +1 -1
- package/lib/components/TableTreeFn/DataGrid.d.ts +0 -5
- package/lib/components/TableTreeFn/DataGrid.js +0 -314
- package/lib/components/TableTreeFn/DataGrid.js.map +0 -1
- package/lib/components/TableTreeFn/Icons.d.ts +0 -3
- package/lib/components/TableTreeFn/Icons.js +0 -12
- package/lib/components/TableTreeFn/Icons.js.map +0 -1
- package/lib/components/TableTreeFn/hooks/useVirtualization.d.ts +0 -16
- package/lib/components/TableTreeFn/hooks/useVirtualization.js +0 -37
- package/lib/components/TableTreeFn/hooks/useVirtualization.js.map +0 -1
- package/lib/components/TableTreeFn/worker/gridWorker.d.ts +0 -1
- package/lib/components/TableTreeFn/worker/gridWorker.js +0 -50
- package/lib/components/TableTreeFn/worker/gridWorker.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export class HeightIndex {
|
|
2
|
+
heights;
|
|
3
|
+
prefix;
|
|
4
|
+
constructor(size, defaultHeight) {
|
|
5
|
+
this.heights = new Float64Array(size);
|
|
6
|
+
this.heights.fill(defaultHeight);
|
|
7
|
+
this.prefix = new Float64Array(size + 1);
|
|
8
|
+
this.recompute();
|
|
9
|
+
}
|
|
10
|
+
recompute() {
|
|
11
|
+
let acc = 0;
|
|
12
|
+
this.prefix[0] = 0;
|
|
13
|
+
for (let i = 0; i < this.heights.length; i++) {
|
|
14
|
+
acc += this.heights[i];
|
|
15
|
+
this.prefix[i + 1] = acc;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
update(index, height) {
|
|
19
|
+
const prev = this.heights[index];
|
|
20
|
+
if (prev === undefined)
|
|
21
|
+
return;
|
|
22
|
+
const delta = height - prev;
|
|
23
|
+
if (delta === 0)
|
|
24
|
+
return;
|
|
25
|
+
this.heights[index] = height;
|
|
26
|
+
for (let i = index + 1; i < this.prefix.length; i++) {
|
|
27
|
+
this.prefix[i] = this.prefix[i] + delta;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
totalHeight() {
|
|
31
|
+
return this.prefix[this.prefix.length - 1];
|
|
32
|
+
}
|
|
33
|
+
findIndex(scrollTop) {
|
|
34
|
+
let low = 0;
|
|
35
|
+
let high = this.prefix.length - 1;
|
|
36
|
+
while (low < high) {
|
|
37
|
+
const mid = (low + high) >>> 1;
|
|
38
|
+
if (this.prefix[mid] <= scrollTop) {
|
|
39
|
+
low = mid + 1;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
high = mid;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Math.max(0, low - 1);
|
|
46
|
+
}
|
|
47
|
+
offsetAt(index) {
|
|
48
|
+
return this.prefix[index];
|
|
49
|
+
}
|
|
50
|
+
resize(newSize, defaultHeight) {
|
|
51
|
+
const next = new Float64Array(newSize);
|
|
52
|
+
next.fill(defaultHeight);
|
|
53
|
+
next.set(this.heights.subarray(0, Math.min(this.heights.length, newSize)));
|
|
54
|
+
this.heights = next;
|
|
55
|
+
this.prefix = new Float64Array(newSize + 1);
|
|
56
|
+
this.recompute();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=HeightIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeightIndex.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/virtualization/HeightIndex.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IACZ,OAAO,CAAe;IACtB,MAAM,CAAe;IAE7B,YAAY,IAAY,EAAE,aAAqB;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;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Z,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAElC,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAE,IAAI,SAAS,EAAE,CAAC;gBACjC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACJ,IAAI,GAAG,GAAG,CAAC;YACf,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,OAAe,EAAE,aAAqB;QACzC,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VirtualViewport, VirtualizationConfig } from './types';
|
|
2
|
+
import { HeightIndex } from './HeightIndex';
|
|
3
|
+
/**
|
|
4
|
+
* Computes the visible window for a given scroll position.
|
|
5
|
+
* Pure function — safe to call inside RAF.
|
|
6
|
+
*/
|
|
7
|
+
export declare function calculateViewport(scrollTop: number, viewportHeight: number, rowCount: number, heightIndex: HeightIndex, config: VirtualizationConfig): VirtualViewport;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the visible window for a given scroll position.
|
|
3
|
+
* Pure function — safe to call inside RAF.
|
|
4
|
+
*/
|
|
5
|
+
export function calculateViewport(scrollTop, viewportHeight, rowCount, heightIndex, config) {
|
|
6
|
+
if (rowCount === 0) {
|
|
7
|
+
return { startIndex: 0, endIndex: 0, offsetTop: 0 };
|
|
8
|
+
}
|
|
9
|
+
const firstVisible = heightIndex.findIndex(scrollTop);
|
|
10
|
+
const lastVisible = heightIndex.findIndex(scrollTop + viewportHeight);
|
|
11
|
+
const startIndex = Math.max(0, firstVisible - config.overscan);
|
|
12
|
+
const endIndex = Math.min(rowCount - 1, lastVisible + config.overscan);
|
|
13
|
+
return {
|
|
14
|
+
startIndex,
|
|
15
|
+
endIndex,
|
|
16
|
+
offsetTop: heightIndex.offsetAt(startIndex),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=calcViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calcViewport.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/virtualization/calcViewport.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC7B,SAAiB,EACjB,cAAsB,EACtB,QAAgB,EAChB,WAAwB,EACxB,MAA4B;IAE5B,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC;IAEtE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEvE,OAAO;QACH,UAAU;QACV,QAAQ;QACR,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;KAC9C,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculated viewport window.
|
|
3
|
+
* Only rows within [startIndex, endIndex] should be rendered.
|
|
4
|
+
*/
|
|
5
|
+
export interface VirtualViewport {
|
|
6
|
+
startIndex: number;
|
|
7
|
+
endIndex: number;
|
|
8
|
+
offsetTop: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for virtualization.
|
|
12
|
+
*/
|
|
13
|
+
export interface VirtualizationConfig {
|
|
14
|
+
overscan: number;
|
|
15
|
+
estimatedRowHeight: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/virtualization/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VirtualViewport, VirtualizationConfig } from './types';
|
|
2
|
+
import { HeightIndex } from './HeightIndex';
|
|
3
|
+
/**
|
|
4
|
+
* Hook that tracks scroll position and computes
|
|
5
|
+
* the current virtual viewport window.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useVirtualViewport(containerRef: React.RefObject<HTMLElement>, rowCount: number, heightIndex: HeightIndex | null, config: VirtualizationConfig): VirtualViewport;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { calculateViewport } from './calcViewport';
|
|
3
|
+
/**
|
|
4
|
+
* Hook that tracks scroll position and computes
|
|
5
|
+
* the current virtual viewport window.
|
|
6
|
+
*/
|
|
7
|
+
export function useVirtualViewport(containerRef, rowCount, heightIndex, config) {
|
|
8
|
+
const [viewport, setViewport] = useState({
|
|
9
|
+
startIndex: 0,
|
|
10
|
+
endIndex: 0,
|
|
11
|
+
offsetTop: 0,
|
|
12
|
+
});
|
|
13
|
+
const rafIdRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const container = containerRef.current;
|
|
16
|
+
if (!container || !heightIndex)
|
|
17
|
+
return;
|
|
18
|
+
const onScroll = () => {
|
|
19
|
+
if (rafIdRef.current !== null)
|
|
20
|
+
return;
|
|
21
|
+
rafIdRef.current = requestAnimationFrame(() => {
|
|
22
|
+
rafIdRef.current = null;
|
|
23
|
+
const next = calculateViewport(container.scrollTop, container.clientHeight, rowCount, heightIndex, config);
|
|
24
|
+
setViewport((prev) => prev.startIndex === next.startIndex &&
|
|
25
|
+
prev.endIndex === next.endIndex
|
|
26
|
+
? prev
|
|
27
|
+
: next);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
container.addEventListener('scroll', onScroll, { passive: true });
|
|
31
|
+
// Initial calculation
|
|
32
|
+
onScroll();
|
|
33
|
+
return () => {
|
|
34
|
+
container.removeEventListener('scroll', onScroll);
|
|
35
|
+
if (rafIdRef.current !== null) {
|
|
36
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [containerRef, rowCount, heightIndex, config]);
|
|
40
|
+
return viewport;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=useVirtualViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVirtualViewport.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/virtualization/useVirtualViewport.ts"],"names":[],"m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E,CAAC,CAAC;QAElE,sBAAsB;QACtB,QAAQ,EAAE,CAAC;QAEX,OAAO,GAAG,EAAE;YACR,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAClD,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC5B,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAElD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NodeId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Inserts a temporary node into visibleOrder
|
|
4
|
+
* without mutating the real tree.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addTempNode(params: {
|
|
7
|
+
tempId: NodeId;
|
|
8
|
+
parentId?: NodeId;
|
|
9
|
+
position: 'above' | 'below' | 'child';
|
|
10
|
+
initialValue?: unknown;
|
|
11
|
+
}): void;
|
|
12
|
+
/**
|
|
13
|
+
* Commits a temporary node into the real tree.
|
|
14
|
+
*/
|
|
15
|
+
export declare function commitTempNode(tempId: NodeId, finalNode: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* Cancels and removes a temporary node.
|
|
18
|
+
*/
|
|
19
|
+
export declare function cancelTempNode(tempId: NodeId): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
/**
|
|
3
|
+
* Inserts a temporary node into visibleOrder
|
|
4
|
+
* without mutating the real tree.
|
|
5
|
+
*/
|
|
6
|
+
export function addTempNode(params) {
|
|
7
|
+
const { tempId, parentId, position, initialValue } = params;
|
|
8
|
+
let anchorIndex = 0;
|
|
9
|
+
if (parentId) {
|
|
10
|
+
const idx = treeState.visibleOrder.indexOf(parentId);
|
|
11
|
+
if (idx !== -1) {
|
|
12
|
+
anchorIndex = idx;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const insertIndex = position === 'below'
|
|
16
|
+
? anchorIndex + 1
|
|
17
|
+
: position === 'above'
|
|
18
|
+
? anchorIndex
|
|
19
|
+
: anchorIndex + 1;
|
|
20
|
+
treeState.tempNodes.set(tempId, {
|
|
21
|
+
id: tempId,
|
|
22
|
+
isTemp: true,
|
|
23
|
+
value: initialValue,
|
|
24
|
+
parentId,
|
|
25
|
+
});
|
|
26
|
+
treeState.visibleOrder.splice(insertIndex, 0, tempId);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Commits a temporary node into the real tree.
|
|
30
|
+
*/
|
|
31
|
+
export function commitTempNode(tempId, finalNode) {
|
|
32
|
+
treeState.tempNodes.delete(tempId);
|
|
33
|
+
treeState.nodes.set(finalNode.id, finalNode);
|
|
34
|
+
const idx = treeState.visibleOrder.indexOf(tempId);
|
|
35
|
+
if (idx !== -1) {
|
|
36
|
+
treeState.visibleOrder[idx] = finalNode.id;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Cancels and removes a temporary node.
|
|
41
|
+
*/
|
|
42
|
+
export function cancelTempNode(tempId) {
|
|
43
|
+
treeState.tempNodes.delete(tempId);
|
|
44
|
+
treeState.visibleOrder = treeState.visibleOrder.filter((id) => id !== tempId);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=addNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addNode.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/addNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAK3B;IACG,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAE5D,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GAAG,SAAS,CAAC,YAAY,CAAC,MAAM,CAClD,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CACxB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
/**
|
|
3
|
+
* Collapses a node and removes its entire visible subtree.
|
|
4
|
+
*/
|
|
5
|
+
export function collapseNode(nodeId) {
|
|
6
|
+
const node = treeState.nodes.get(nodeId);
|
|
7
|
+
if (!node || node.expanded !== true)
|
|
8
|
+
return;
|
|
9
|
+
node.expanded = false;
|
|
10
|
+
treeState.expandedSet.delete(nodeId);
|
|
11
|
+
const toRemove = new Set();
|
|
12
|
+
function collect(id) {
|
|
13
|
+
const n = treeState.nodes.get(id);
|
|
14
|
+
if (!n)
|
|
15
|
+
return;
|
|
16
|
+
for (const child of n.children) {
|
|
17
|
+
toRemove.add(child);
|
|
18
|
+
collect(child);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
collect(nodeId);
|
|
22
|
+
treeState.visibleOrder = treeState.visibleOrder.filter((id) => !toRemove.has(id));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=collapse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/collapse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACvC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO;IAE5C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACtB,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,SAAS,OAAO,CAAC,EAAU;QACvB,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC;YAAE,OAAO;QAEf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC7B,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhB,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC,MAAM,CAClD,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAC5B,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
/**
|
|
3
|
+
* Expands a node and incrementally inserts its visible subtree.
|
|
4
|
+
*/
|
|
5
|
+
export function expandNode(nodeId) {
|
|
6
|
+
const node = treeState.nodes.get(nodeId);
|
|
7
|
+
if (!node || node.expanded !== false)
|
|
8
|
+
return;
|
|
9
|
+
node.expanded = true;
|
|
10
|
+
treeState.expandedSet.add(nodeId);
|
|
11
|
+
const anchorIndex = treeState.visibleOrder.indexOf(nodeId);
|
|
12
|
+
if (anchorIndex === -1)
|
|
13
|
+
return;
|
|
14
|
+
const toInsert = [];
|
|
15
|
+
function dfs(id) {
|
|
16
|
+
toInsert.push(id);
|
|
17
|
+
const n = treeState.nodes.get(id);
|
|
18
|
+
if (!n || !n.expanded)
|
|
19
|
+
return;
|
|
20
|
+
for (const child of n.children) {
|
|
21
|
+
dfs(child);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (const childId of node.children) {
|
|
25
|
+
dfs(childId);
|
|
26
|
+
}
|
|
27
|
+
treeState.visibleOrder.splice(anchorIndex + 1, 0, ...toInsert);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=expand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/expand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACrC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK;QAAE,OAAO;IAE7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACrB,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAElC,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,WAAW,KAAK,CAAC,CAAC;QAAE,OAAO;IAE/B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,SAAS,GAAG,CAAC,EAAU;QACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;YAAE,OAAO;QAC9B,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,CAAC;IACL,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
/**
|
|
3
|
+
* Fully flattens the tree from roots.
|
|
4
|
+
* Used only during INIT or rare full rebuilds.
|
|
5
|
+
*/
|
|
6
|
+
export function flattenTree(rootIds) {
|
|
7
|
+
const result = [];
|
|
8
|
+
function dfs(id) {
|
|
9
|
+
result.push(id);
|
|
10
|
+
const node = treeState.nodes.get(id);
|
|
11
|
+
if (!node || !node.expanded)
|
|
12
|
+
return;
|
|
13
|
+
for (const childId of node.children) {
|
|
14
|
+
dfs(childId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (const rootId of rootIds) {
|
|
18
|
+
dfs(rootId);
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAiB;IACzC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,SAAS,GAAG,CAAC,EAAU;QACnB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhB,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEpC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC;IACL,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,GAAG,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NodeId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Updates cached row height.
|
|
4
|
+
* Used for accurate scroll restoration & virtualization.
|
|
5
|
+
*/
|
|
6
|
+
export declare function setRowHeight(nodeId: NodeId, height: number): void;
|
|
7
|
+
export declare function getRowHeight(nodeId: NodeId): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
const DEFAULT_ROW_HEIGHT = 32;
|
|
3
|
+
/**
|
|
4
|
+
* Updates cached row height.
|
|
5
|
+
* Used for accurate scroll restoration & virtualization.
|
|
6
|
+
*/
|
|
7
|
+
export function setRowHeight(nodeId, height) {
|
|
8
|
+
treeState.rowHeights.set(nodeId, height);
|
|
9
|
+
}
|
|
10
|
+
export function getRowHeight(nodeId) {
|
|
11
|
+
return treeState.rowHeights.get(nodeId) ?? DEFAULT_ROW_HEIGHT;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=heights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heights.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/heights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,YAAY,CACxB,MAAc,EACd,MAAc;IAEd,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACvC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { NodeId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Messages FROM main thread TO worker
|
|
4
|
+
*/
|
|
5
|
+
export type WorkerInitMessage = {
|
|
6
|
+
type: 'INIT';
|
|
7
|
+
payload: {
|
|
8
|
+
nodes: Array<[NodeId, any]>;
|
|
9
|
+
rootIds: NodeId[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type WorkerExpandMessage = {
|
|
13
|
+
type: 'EXPAND';
|
|
14
|
+
payload: {
|
|
15
|
+
nodeId: NodeId;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type WorkerCollapseMessage = {
|
|
19
|
+
type: 'COLLAPSE';
|
|
20
|
+
payload: {
|
|
21
|
+
nodeId: NodeId;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type WorkerSelectMessage = {
|
|
25
|
+
type: 'SELECT';
|
|
26
|
+
payload: {
|
|
27
|
+
nodeId: NodeId;
|
|
28
|
+
selected: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type WorkerRowHeightMessage = {
|
|
32
|
+
type: 'ROW_HEIGHT';
|
|
33
|
+
payload: {
|
|
34
|
+
nodeId: NodeId;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type WorkerAddNodeMessage = {
|
|
39
|
+
type: 'ADD_NODE';
|
|
40
|
+
payload: {
|
|
41
|
+
tempId: NodeId;
|
|
42
|
+
parentId?: NodeId;
|
|
43
|
+
position: 'above' | 'below' | 'child';
|
|
44
|
+
initialValue?: unknown;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type WorkerCommitNodeMessage = {
|
|
48
|
+
type: 'COMMIT_NODE';
|
|
49
|
+
payload: {
|
|
50
|
+
tempId: NodeId;
|
|
51
|
+
finalNode: any;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type WorkerCancelNodeMessage = {
|
|
55
|
+
type: 'CANCEL_NODE';
|
|
56
|
+
payload: {
|
|
57
|
+
tempId: NodeId;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type WorkerMessage = WorkerInitMessage | WorkerExpandMessage | WorkerCollapseMessage | WorkerSelectMessage | WorkerRowHeightMessage | WorkerAddNodeMessage | WorkerCommitNodeMessage | WorkerCancelNodeMessage;
|
|
61
|
+
/**
|
|
62
|
+
* Messages FROM worker TO main thread
|
|
63
|
+
*/
|
|
64
|
+
export type WorkerVisibleOrderResponse = {
|
|
65
|
+
type: 'VISIBLE_ORDER';
|
|
66
|
+
payload: {
|
|
67
|
+
order: NodeId[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type WorkerSelectionResponse = {
|
|
71
|
+
type: 'SELECTION_UPDATE';
|
|
72
|
+
payload: {
|
|
73
|
+
selected: NodeId[];
|
|
74
|
+
partial: NodeId[];
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type WorkerResponse = WorkerVisibleOrderResponse | WorkerSelectionResponse;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/protocol.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { treeState } from './state';
|
|
2
|
+
/**
|
|
3
|
+
* Toggles selection and propagates state
|
|
4
|
+
* to children and parents.
|
|
5
|
+
*/
|
|
6
|
+
export function toggleSelection(nodeId, selected) {
|
|
7
|
+
const node = treeState.nodes.get(nodeId);
|
|
8
|
+
if (!node || node.selectable === false)
|
|
9
|
+
return;
|
|
10
|
+
function selectSubtree(id) {
|
|
11
|
+
if (selected) {
|
|
12
|
+
treeState.selectedSet.add(id);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
treeState.selectedSet.delete(id);
|
|
16
|
+
}
|
|
17
|
+
treeState.partialSet.delete(id);
|
|
18
|
+
const n = treeState.nodes.get(id);
|
|
19
|
+
if (!n)
|
|
20
|
+
return;
|
|
21
|
+
for (const child of n.children) {
|
|
22
|
+
selectSubtree(child);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function updateParents(parentId) {
|
|
26
|
+
if (!parentId)
|
|
27
|
+
return;
|
|
28
|
+
const parent = treeState.nodes.get(parentId);
|
|
29
|
+
if (!parent)
|
|
30
|
+
return;
|
|
31
|
+
let selectedCount = 0;
|
|
32
|
+
for (const childId of parent.children) {
|
|
33
|
+
if (treeState.partialSet.has(childId)) {
|
|
34
|
+
treeState.partialSet.add(parentId);
|
|
35
|
+
treeState.selectedSet.delete(parentId);
|
|
36
|
+
updateParents(parent.parentId);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (treeState.selectedSet.has(childId)) {
|
|
40
|
+
selectedCount++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (selectedCount === parent.children.length) {
|
|
44
|
+
treeState.selectedSet.add(parentId);
|
|
45
|
+
treeState.partialSet.delete(parentId);
|
|
46
|
+
}
|
|
47
|
+
else if (selectedCount === 0) {
|
|
48
|
+
treeState.selectedSet.delete(parentId);
|
|
49
|
+
treeState.partialSet.delete(parentId);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
treeState.partialSet.add(parentId);
|
|
53
|
+
treeState.selectedSet.delete(parentId);
|
|
54
|
+
}
|
|
55
|
+
updateParents(parent.parentId);
|
|
56
|
+
}
|
|
57
|
+
selectSubtree(nodeId);
|
|
58
|
+
updateParents(node.parentId);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;GAGG;AACH,MAAM,U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AC;gBAC/B,OAAO;YACX,CAAC;YACD,IAAI,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrC,aAAa,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;QAED,IAAI,aAAa,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC3C,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACpC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YAC7B,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACJ,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACnC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC;QAED,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NodeId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal mutable state for the worker.
|
|
4
|
+
* Never exposed directly.
|
|
5
|
+
*/
|
|
6
|
+
export declare const treeState: {
|
|
7
|
+
/** Canonical nodes (real nodes only) */
|
|
8
|
+
nodes: Map<string, any>;
|
|
9
|
+
/** Ordered list of currently visible node ids */
|
|
10
|
+
visibleOrder: NodeId[];
|
|
11
|
+
/** Expanded nodes */
|
|
12
|
+
expandedSet: Set<string>;
|
|
13
|
+
/** Selection state */
|
|
14
|
+
selectedSet: Set<string>;
|
|
15
|
+
partialSet: Set<string>;
|
|
16
|
+
/** Row height cache (px) */
|
|
17
|
+
rowHeights: Map<string, number>;
|
|
18
|
+
/** Temporary (ephemeral) nodes for add/edit */
|
|
19
|
+
tempNodes: Map<string, any>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal mutable state for the worker.
|
|
3
|
+
* Never exposed directly.
|
|
4
|
+
*/
|
|
5
|
+
export const treeState = {
|
|
6
|
+
/** Canonical nodes (real nodes only) */
|
|
7
|
+
nodes: new Map(),
|
|
8
|
+
/** Ordered list of currently visible node ids */
|
|
9
|
+
visibleOrder: [],
|
|
10
|
+
/** Expanded nodes */
|
|
11
|
+
expandedSet: new Set(),
|
|
12
|
+
/** Selection state */
|
|
13
|
+
selectedSet: new Set(),
|
|
14
|
+
partialSet: new Set(),
|
|
15
|
+
/** Row height cache (px) */
|
|
16
|
+
rowHeights: new Map(),
|
|
17
|
+
/** Temporary (ephemeral) nodes for add/edit */
|
|
18
|
+
tempNodes: new Map(),
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/components/TableTreeFn/tree-v2/worker/state.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,wCAAwC;IACxC,KAAK,EAAE,IAAI,GAAG,EAAe;IAE7B,iDAAiD;IACjD,YAAY,EAAE,EAAc;IAE5B,qBAAqB;IACrB,WAAW,EAAE,IAAI,GAAG,EAAU;IAE9B,sBAAsB;IACtB,WAAW,EAAE,IAAI,GAAG,EAAU;IAC9B,UAAU,EAAE,IAAI,GAAG,EAAU;IAE7B,4BAA4B;IAC5B,UAAU,EAAE,IAAI,GAAG,EAAkB;IAErC,+CAA+C;IAC/C,SAAS,EAAE,IAAI,GAAG,EAAe;CACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|