@mozaic-ds/angular 2.0.52 → 2.0.53
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.
|
@@ -17330,6 +17330,12 @@ class TreeStateService {
|
|
|
17330
17330
|
loadingIds = signal(new Set(), ...(ngDevMode ? [{ debugName: "loadingIds" }] : /* istanbul ignore next */ []));
|
|
17331
17331
|
internalNodes = signal([], ...(ngDevMode ? [{ debugName: "internalNodes" }] : /* istanbul ignore next */ []));
|
|
17332
17332
|
loadChildrenFn = signal(null, ...(ngDevMode ? [{ debugName: "loadChildrenFn" }] : /* istanbul ignore next */ []));
|
|
17333
|
+
/**
|
|
17334
|
+
* Parent IDs for which children have been patched in (via lazy-load).
|
|
17335
|
+
* Grows monotonically — consumers diff against their own "processed" set.
|
|
17336
|
+
* Not emitted for statically-populated children present at init.
|
|
17337
|
+
*/
|
|
17338
|
+
loadedParentIds = signal(new Set(), ...(ngDevMode ? [{ debugName: "loadedParentIds" }] : /* istanbul ignore next */ []));
|
|
17333
17339
|
flatVisibleNodes = computed(() => {
|
|
17334
17340
|
const result = [];
|
|
17335
17341
|
this._flatten(this.internalNodes(), result, 0, null);
|
|
@@ -17393,6 +17399,11 @@ class TreeStateService {
|
|
|
17393
17399
|
}
|
|
17394
17400
|
patchChildren(nodeId, children) {
|
|
17395
17401
|
this.internalNodes.update((nodes) => this._patchNode(nodes, nodeId, children));
|
|
17402
|
+
this.loadedParentIds.update((set) => {
|
|
17403
|
+
const next = new Set(set);
|
|
17404
|
+
next.add(nodeId);
|
|
17405
|
+
return next;
|
|
17406
|
+
});
|
|
17396
17407
|
}
|
|
17397
17408
|
_patchNode(nodes, targetId, children) {
|
|
17398
17409
|
return nodes.map((n) => {
|
|
@@ -17945,30 +17956,18 @@ class MozTreeComponent {
|
|
|
17945
17956
|
effect(() => {
|
|
17946
17957
|
this.stateService.loadChildrenFn.set(this.loadChildren());
|
|
17947
17958
|
});
|
|
17948
|
-
//
|
|
17949
|
-
//
|
|
17950
|
-
|
|
17959
|
+
// React to genuine lazy-load events emitted by patchChildren. Static
|
|
17960
|
+
// initial children never go through patchChildren, so pre-selected
|
|
17961
|
+
// descendants of statically-populated parents are left untouched.
|
|
17962
|
+
const processed = new Set();
|
|
17951
17963
|
effect(() => {
|
|
17952
|
-
const
|
|
17964
|
+
const loaded = this.stateService.loadedParentIds();
|
|
17953
17965
|
if (this.selectionService.selectionMode() !== 'checkbox')
|
|
17954
17966
|
return;
|
|
17955
|
-
const
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
const hadChildren = prevChildMap.get(n.id) ?? false;
|
|
17960
|
-
const hasChildrenNow = !!(n.children && n.children.length > 0);
|
|
17961
|
-
newChildMap.set(n.id, hasChildrenNow);
|
|
17962
|
-
if (!hadChildren && hasChildrenNow) {
|
|
17963
|
-
newlyLoadedParentIds.push(n.id);
|
|
17964
|
-
}
|
|
17965
|
-
if (n.children)
|
|
17966
|
-
visit(n.children);
|
|
17967
|
-
}
|
|
17968
|
-
};
|
|
17969
|
-
visit(nodes);
|
|
17970
|
-
prevChildMap = newChildMap;
|
|
17971
|
-
for (const parentId of newlyLoadedParentIds) {
|
|
17967
|
+
for (const parentId of loaded) {
|
|
17968
|
+
if (processed.has(parentId))
|
|
17969
|
+
continue;
|
|
17970
|
+
processed.add(parentId);
|
|
17972
17971
|
this.selectionService.propagateOnChildrenLoaded(parentId);
|
|
17973
17972
|
}
|
|
17974
17973
|
});
|