| 127 | } |
| 128 | |
| 129 | ngOnInit() { |
| 130 | if (this.parent() instanceof TreeItemGroup) { |
| 131 | (this.parent() as TreeItemGroup<V>)._register(this); |
| 132 | } |
| 133 | this.tree()._collection.register(this); |
| 134 | |
| 135 | const treePattern = computed(() => this.tree()._pattern); |
| 136 | const parentPattern = computed(() => { |
| 137 | if (this.parent() instanceof Tree) { |
| 138 | return treePattern(); |
| 139 | } |
| 140 | return (this.parent() as TreeItemGroup<V>).ownedBy()._pattern; |
| 141 | }); |
| 142 | this._pattern = new TreeItemPattern<V>({ |
| 143 | ...this, |
| 144 | tree: treePattern, |
| 145 | parent: parentPattern, |
| 146 | children: computed(() => this._group()?._childPatterns()), |
| 147 | hasChildren: computed(() => !!this._group()), |
| 148 | element: () => this.element, |
| 149 | searchTerm: () => this.searchTerm() ?? '', |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | ngOnDestroy() { |
| 154 | if (this.parent() instanceof TreeItemGroup) { |