@basis-ng/primitives 0.0.1-alpha.134 → 0.0.1-alpha.136
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.
|
@@ -3519,7 +3519,11 @@ class TreeNode {
|
|
|
3519
3519
|
/**
|
|
3520
3520
|
* Whether this node is expanded to show nested content.
|
|
3521
3521
|
*/
|
|
3522
|
-
|
|
3522
|
+
expanded = model(false, ...(ngDevMode ? [{ debugName: "expanded" }] : []));
|
|
3523
|
+
/**
|
|
3524
|
+
* Whether drag-and-drop is only enabled when this node is collapsed.
|
|
3525
|
+
*/
|
|
3526
|
+
dragOnlyWhenCollapsed = input(false, ...(ngDevMode ? [{ debugName: "dragOnlyWhenCollapsed" }] : []));
|
|
3523
3527
|
/**
|
|
3524
3528
|
* Injected CDK drag instance for this node.
|
|
3525
3529
|
*/
|
|
@@ -3541,11 +3545,21 @@ class TreeNode {
|
|
|
3541
3545
|
*/
|
|
3542
3546
|
closeEmitter = output();
|
|
3543
3547
|
constructor() {
|
|
3544
|
-
//
|
|
3548
|
+
// Track expanded state changes for close events
|
|
3549
|
+
let previousExpanded = this.expanded();
|
|
3545
3550
|
effect(() => {
|
|
3546
|
-
|
|
3551
|
+
const currentExpanded = this.expanded();
|
|
3552
|
+
// Emit close event when collapsing
|
|
3553
|
+
if (previousExpanded && !currentExpanded && this.nestedTree()) {
|
|
3547
3554
|
this.closeEmitter.emit();
|
|
3548
3555
|
}
|
|
3556
|
+
previousExpanded = currentExpanded;
|
|
3557
|
+
});
|
|
3558
|
+
// Control drag based on expanded state and dragOnlyWhenCollapsed
|
|
3559
|
+
effect(() => {
|
|
3560
|
+
if (this.dragOnlyWhenCollapsed() && this.hasNestedTree()) {
|
|
3561
|
+
this.node.disabled = this.expanded();
|
|
3562
|
+
}
|
|
3549
3563
|
});
|
|
3550
3564
|
}
|
|
3551
3565
|
ngOnInit() {
|
|
@@ -3559,25 +3573,14 @@ class TreeNode {
|
|
|
3559
3573
|
handleNodeDisability(disabled) {
|
|
3560
3574
|
this.node.disabled = disabled;
|
|
3561
3575
|
}
|
|
3562
|
-
/**
|
|
3563
|
-
* Set initial expansion state for the node.
|
|
3564
|
-
* @param expanded - Whether the node should be initially expanded.
|
|
3565
|
-
*/
|
|
3566
|
-
setInitialExpansion(expanded) {
|
|
3567
|
-
if (this.hasNestedTree()) {
|
|
3568
|
-
this.extended.set(expanded);
|
|
3569
|
-
// Propagate to nested tree if it exists
|
|
3570
|
-
this.nestedTree()?.setNodesExpansion(expanded);
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
3576
|
/**
|
|
3574
3577
|
* Toggle the node expansion.
|
|
3575
3578
|
*/
|
|
3576
3579
|
toggleExtension() {
|
|
3577
|
-
this.
|
|
3580
|
+
this.expanded.update((current) => !current);
|
|
3578
3581
|
}
|
|
3579
3582
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: TreeNode, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3580
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: TreeNode, isStandalone: true, selector: "b-tree-node", inputs: {
|
|
3583
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: TreeNode, isStandalone: true, selector: "b-tree-node", inputs: { expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null }, dragOnlyWhenCollapsed: { classPropertyName: "dragOnlyWhenCollapsed", publicName: "dragOnlyWhenCollapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange", closeEmitter: "closeEmitter" }, providers: [
|
|
3581
3584
|
provideIcons({
|
|
3582
3585
|
lucideGripVertical,
|
|
3583
3586
|
}),
|
|
@@ -3612,7 +3615,7 @@ class TreeNode {
|
|
|
3612
3615
|
</svg>
|
|
3613
3616
|
}
|
|
3614
3617
|
</section>
|
|
3615
|
-
@if (hasNestedTree() &&
|
|
3618
|
+
@if (hasNestedTree() && expanded()) {
|
|
3616
3619
|
<div class="nested">
|
|
3617
3620
|
<ng-content select="b-tree" />
|
|
3618
3621
|
</div>
|
|
@@ -3655,7 +3658,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
3655
3658
|
</svg>
|
|
3656
3659
|
}
|
|
3657
3660
|
</section>
|
|
3658
|
-
@if (hasNestedTree() &&
|
|
3661
|
+
@if (hasNestedTree() && expanded()) {
|
|
3659
3662
|
<div class="nested">
|
|
3660
3663
|
<ng-content select="b-tree" />
|
|
3661
3664
|
</div>
|
|
@@ -3673,7 +3676,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
3673
3676
|
}),
|
|
3674
3677
|
],
|
|
3675
3678
|
}]
|
|
3676
|
-
}], ctorParameters: () => [], propDecorators: {
|
|
3679
|
+
}], ctorParameters: () => [], propDecorators: { expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }], dragOnlyWhenCollapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragOnlyWhenCollapsed", required: false }] }], nestedTree: [{ type: i0.ContentChild, args: [i0.forwardRef(() => Tree), { isSignal: true }] }], closeEmitter: [{ type: i0.Output, args: ["closeEmitter"] }] } });
|
|
3677
3680
|
|
|
3678
3681
|
/**
|
|
3679
3682
|
* Root container for a tree structure, enabling drag-and-drop and nested nodes.
|
|
@@ -3696,9 +3699,9 @@ class Tree {
|
|
|
3696
3699
|
*/
|
|
3697
3700
|
closeRecursively = input(false, ...(ngDevMode ? [{ debugName: "closeRecursively" }] : []));
|
|
3698
3701
|
/**
|
|
3699
|
-
* Whether
|
|
3702
|
+
* Whether drag-and-drop is only enabled when nodes are collapsed.
|
|
3700
3703
|
*/
|
|
3701
|
-
|
|
3704
|
+
dragOnlyWhenCollapsed = input(false, ...(ngDevMode ? [{ debugName: "dragOnlyWhenCollapsed" }] : []));
|
|
3702
3705
|
/**
|
|
3703
3706
|
* Computed signal indicating if the tree is disabled (inverse of draggable).
|
|
3704
3707
|
*/
|
|
@@ -3716,13 +3719,6 @@ class Tree {
|
|
|
3716
3719
|
node.handleNodeDisability(disabled);
|
|
3717
3720
|
});
|
|
3718
3721
|
});
|
|
3719
|
-
// Reactively expand nodes - needs to react to defaultExpanded changes
|
|
3720
|
-
effect(() => {
|
|
3721
|
-
const shouldExpand = this.defaultExpanded();
|
|
3722
|
-
this.nestedNodes().forEach((node) => {
|
|
3723
|
-
node.setInitialExpansion(shouldExpand);
|
|
3724
|
-
});
|
|
3725
|
-
});
|
|
3726
3722
|
}
|
|
3727
3723
|
ngOnInit() {
|
|
3728
3724
|
// Setup recursive close only once based on initial input value
|
|
@@ -3745,21 +3741,12 @@ class Tree {
|
|
|
3745
3741
|
*/
|
|
3746
3742
|
closeNestedNodes() {
|
|
3747
3743
|
this.nestedNodes().forEach((node) => {
|
|
3748
|
-
node.
|
|
3744
|
+
node.expanded.set(false);
|
|
3749
3745
|
node.nestedTree()?.closeNestedNodes();
|
|
3750
3746
|
});
|
|
3751
3747
|
}
|
|
3752
|
-
/**
|
|
3753
|
-
* Set expansion state for all nodes recursively.
|
|
3754
|
-
* @param expanded - Whether nodes should be expanded.
|
|
3755
|
-
*/
|
|
3756
|
-
setNodesExpansion(expanded) {
|
|
3757
|
-
this.nestedNodes().forEach((node) => {
|
|
3758
|
-
node.setInitialExpansion(expanded);
|
|
3759
|
-
});
|
|
3760
|
-
}
|
|
3761
3748
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: Tree, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3762
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.0.0", type: Tree, isStandalone: true, selector: "b-tree", inputs: { draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, closeRecursively: { classPropertyName: "closeRecursively", publicName: "closeRecursively", isSignal: true, isRequired: false, transformFunction: null },
|
|
3749
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.0.0", type: Tree, isStandalone: true, selector: "b-tree", inputs: { draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, closeRecursively: { classPropertyName: "closeRecursively", publicName: "closeRecursively", isSignal: true, isRequired: false, transformFunction: null }, dragOnlyWhenCollapsed: { classPropertyName: "dragOnlyWhenCollapsed", publicName: "dragOnlyWhenCollapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dropEmitter: "dropEmitter" }, host: { listeners: { "cdkDropListDropped": "dropEmitter.emit($event)" } }, queries: [{ propertyName: "nestedNodes", predicate: TreeNode, isSignal: true }], hostDirectives: [{ directive: i1$3.CdkDropList, inputs: ["id", "id", "cdkDropListConnectedTo", "connectedTo"], outputs: ["cdkDropListDropped", "cdkDropListDropped"] }, { directive: i1$3.CdkDropListGroup }], ngImport: i0, template: ` <ng-content /> `, isInline: true });
|
|
3763
3750
|
}
|
|
3764
3751
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: Tree, decorators: [{
|
|
3765
3752
|
type: Component,
|
|
@@ -3778,7 +3765,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
3778
3765
|
CdkDropListGroup,
|
|
3779
3766
|
],
|
|
3780
3767
|
}]
|
|
3781
|
-
}], ctorParameters: () => [], propDecorators: { draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], nestedNodes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => TreeNode), { isSignal: true }] }], closeRecursively: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeRecursively", required: false }] }],
|
|
3768
|
+
}], ctorParameters: () => [], propDecorators: { draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], nestedNodes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => TreeNode), { isSignal: true }] }], closeRecursively: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeRecursively", required: false }] }], dragOnlyWhenCollapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "dragOnlyWhenCollapsed", required: false }] }], dropEmitter: [{ type: i0.Output, args: ["dropEmitter"] }] } });
|
|
3782
3769
|
|
|
3783
3770
|
/**
|
|
3784
3771
|
* Directive that registers and controls a dialog template instance.
|