@clr/angular
Version:
Angular components for Clarity
1 lines • 76.8 kB
Source Map (JSON)
{"version":3,"file":"clr-angular-data-tree-view.mjs","sources":["../../../projects/angular/data/tree-view/models/selected-state.enum.ts","../../../projects/angular/data/tree-view/tree-features.service.ts","../../../projects/angular/data/tree-view/tree-focus-manager.service.ts","../../../projects/angular/data/tree-view/models/tree-node.model.ts","../../../projects/angular/data/tree-view/models/declarative-tree-node.model.ts","../../../projects/angular/data/tree-view/tree-node-link.ts","../../../projects/angular/data/tree-view/recursive-children.ts","../../../projects/angular/data/tree-view/tree-node.ts","../../../projects/angular/data/tree-view/tree-node.html","../../../projects/angular/data/tree-view/tree.ts","../../../projects/angular/data/tree-view/models/async-array.ts","../../../projects/angular/data/tree-view/models/recursive-tree-node.model.ts","../../../projects/angular/data/tree-view/recursive-for-of.ts","../../../projects/angular/data/tree-view/tree-view.module.ts","../../../projects/angular/data/tree-view/index.ts","../../../projects/angular/data/tree-view/clr-angular-data-tree-view.ts"],"sourcesContent":["/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\n// TODO: I'd like this to be a CheckedState enum for the checkboxes in the future.\nexport enum ClrSelectedState {\n // WARNING! Unselected has the value 0,\n // so it's actually the only one that will evaluate to false if cast to a boolean.\n // Don't mess with the order!\n UNSELECTED = 0,\n SELECTED,\n INDETERMINATE,\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { Injectable, Optional, SkipSelf, TemplateRef } from '@angular/core';\nimport { Subject } from 'rxjs';\n\nimport { RecursiveTreeNodeModel } from './models/recursive-tree-node.model';\nimport { ClrRecursiveForOfContext } from './recursive-for-of';\n\n@Injectable()\nexport class TreeFeaturesService<T> {\n selectable = false;\n eager = true;\n recursion: {\n template: TemplateRef<ClrRecursiveForOfContext<T>>;\n root: RecursiveTreeNodeModel<T>[];\n };\n childrenFetched = new Subject<void>();\n}\n\nexport function treeFeaturesFactory<T>(existing: TreeFeaturesService<T>) {\n return existing || new TreeFeaturesService();\n}\n\nexport const TREE_FEATURES_PROVIDER = {\n provide: TreeFeaturesService,\n useFactory: treeFeaturesFactory,\n /*\n * The Optional + SkipSelf pattern ensures that in case of nested components, only the root one will\n * instantiate a new service and all its children will reuse the root's instance.\n * If there are several roots (in this case, several independent trees on a page), each root will instantiate\n * its own service so they won't interfere with one another.\n *\n * TL;DR - Optional + SkipSelf = 1 instance of TreeFeaturesService per tree.\n */\n deps: [[new Optional(), new SkipSelf(), TreeFeaturesService]],\n};\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { Injectable } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport { TreeNodeModel } from './models/tree-node.model';\n\n@Injectable()\nexport class TreeFocusManagerService<T> {\n rootNodeModels: TreeNodeModel<T>[];\n\n private focusedNodeId: string;\n private _focusRequest = new Subject<string>();\n private _focusChange = new Subject<string>();\n\n get focusRequest(): Observable<string> {\n return this._focusRequest.asObservable();\n }\n\n get focusChange(): Observable<string> {\n return this._focusChange.asObservable();\n }\n\n focusNode(model: TreeNodeModel<T>): void {\n if (model) {\n this._focusRequest.next(model.nodeId);\n }\n }\n\n broadcastFocusedNode(nodeId: string): void {\n if (this.focusedNodeId !== nodeId) {\n this.focusedNodeId = nodeId;\n this._focusChange.next(nodeId);\n }\n }\n\n focusParent(model: TreeNodeModel<T>): void {\n if (model) {\n this.focusNode(model.parent);\n }\n }\n\n focusFirstVisibleNode(): void {\n const focusModel = this.rootNodeModels && this.rootNodeModels[0];\n this.focusNode(focusModel);\n }\n\n focusLastVisibleNode(): void {\n this.focusNode(this.findLastVisibleInTree());\n }\n\n focusNodeAbove(model: TreeNodeModel<T>): void {\n this.focusNode(this.findNodeAbove(model));\n }\n\n focusNodeBelow(model: TreeNodeModel<T>): void {\n this.focusNode(this.findNodeBelow(model));\n }\n\n focusNodeStartsWith(searchString: string, model: TreeNodeModel<T>): void {\n this.focusNode(this.findClosestNodeStartsWith(searchString, model));\n }\n\n private findSiblings(model: TreeNodeModel<T>): TreeNodeModel<T>[] {\n // the method will return not only sibling models but also itself among them\n if (model.parent) {\n return model.parent.children;\n } else {\n return this.rootNodeModels;\n }\n }\n\n private findLastVisibleInNode(model: TreeNodeModel<T>): TreeNodeModel<T> {\n // the method will traverse through until it finds the last visible node from the given node\n if (!model) {\n return null;\n }\n if (model.expanded && model.children.length > 0) {\n const children = model.children;\n const lastChild = children[children.length - 1];\n return this.findLastVisibleInNode(lastChild);\n } else {\n return model;\n }\n }\n\n private findNextFocusable(model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (!model) {\n return null;\n }\n\n const siblings = this.findSiblings(model);\n const selfIndex = siblings.indexOf(model);\n\n if (selfIndex < siblings.length - 1) {\n return siblings[selfIndex + 1];\n } else if (selfIndex === siblings.length - 1) {\n return this.findNextFocusable(model.parent);\n }\n return null;\n }\n\n private findLastVisibleInTree(): TreeNodeModel<T> {\n const lastRootNode =\n this.rootNodeModels && this.rootNodeModels.length && this.rootNodeModels[this.rootNodeModels.length - 1];\n return this.findLastVisibleInNode(lastRootNode);\n }\n\n private findNodeAbove(model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (!model) {\n return null;\n }\n\n const siblings = this.findSiblings(model);\n const selfIndex = siblings.indexOf(model);\n\n if (selfIndex === 0) {\n return model.parent;\n } else if (selfIndex > 0) {\n return this.findLastVisibleInNode(siblings[selfIndex - 1]);\n }\n return null;\n }\n\n private findNodeBelow(model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (!model) {\n return null;\n }\n\n if (model.expanded && model.children.length > 0) {\n return model.children[0];\n } else {\n return this.findNextFocusable(model);\n }\n }\n\n private findDescendentNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (model.expanded && model.children.length > 0) {\n for (const childModel of model.children) {\n const found = this.findNodeStartsWith(searchString, childModel);\n if (found) {\n return found;\n }\n }\n }\n return null;\n }\n\n private findSiblingNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {\n const siblings = this.findSiblings(model);\n const selfIndex = siblings.indexOf(model);\n\n // Look from sibling nodes\n for (let i = selfIndex + 1; i < siblings.length; i++) {\n const siblingModel = siblings[i];\n const found = this.findNodeStartsWith(searchString, siblingModel);\n if (found) {\n return found;\n }\n }\n return null;\n }\n\n private findRootNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {\n for (const rootModel of this.rootNodeModels) {\n // Don't look from a parent yet\n if (model.parent && model.parent === rootModel) {\n continue;\n }\n\n const found = this.findNodeStartsWith(searchString, rootModel);\n if (found) {\n return found;\n }\n }\n return null;\n }\n\n private findNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (!model) {\n return null;\n }\n\n if (model.textContent.startsWith(searchString)) {\n return model;\n }\n\n return this.findDescendentNodeStartsWith(searchString, model);\n }\n\n private findClosestNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {\n if (!model) {\n return null;\n }\n\n const foundFromDescendents = this.findDescendentNodeStartsWith(searchString, model);\n\n if (foundFromDescendents) {\n return foundFromDescendents;\n }\n\n const foundFromSiblings = this.findSiblingNodeStartsWith(searchString, model);\n\n if (foundFromSiblings) {\n return foundFromSiblings;\n }\n\n const foundFromRootNodes = this.findRootNodeStartsWith(searchString, model);\n\n if (foundFromRootNodes) {\n return foundFromRootNodes;\n }\n // Now look from its own direct parent\n return this.findNodeStartsWith(searchString, model.parent);\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { BehaviorSubject } from 'rxjs';\n\nimport { ClrSelectedState } from './selected-state.enum';\n\nexport abstract class TreeNodeModel<T> {\n nodeId: string;\n expanded: boolean;\n model: T | null;\n textContent: string;\n loading$ = new BehaviorSubject(false);\n selected = new BehaviorSubject(ClrSelectedState.UNSELECTED);\n\n /*\n * Being able to push this down to the RecursiveTreeNodeModel would require too much work on the angular components\n * right now for them to know which kind of model they are using. So I'm lifting the public properties to this\n * abstract parent class for now and we can revisit it later, when we're not facing such a close deadline.\n */\n private _loading = false;\n private _disabled: boolean;\n\n /*\n * Ideally, I would like to use a polymorphic this type here to ensure homogeneity of the tree, something like:\n * abstract parent: this<T> | null;\n * abstract children: this<T>[];\n * But I'm hitting limitations on typescript not allowing that type in constructors or static methods.\n * So I'm resorting to forcing override with more precise types by marking these abstract.\n */\n abstract parent: TreeNodeModel<T> | null;\n abstract children: TreeNodeModel<T>[];\n\n get loading() {\n return this._loading;\n }\n set loading(isLoading: boolean) {\n this._loading = isLoading;\n this.loading$.next(isLoading);\n }\n\n get disabled() {\n // when both parameters are undefined, double negative is needed to cast to false, otherwise will return undefined.\n return !!(this._disabled || this.parent?.disabled);\n }\n set disabled(value: boolean) {\n this._disabled = value;\n }\n\n destroy() {\n // Just to be safe\n this.selected.complete();\n }\n\n // Propagate by default when eager, don't propagate in the lazy-loaded tree.\n setSelected(state: ClrSelectedState, propagateUp: boolean, propagateDown: boolean) {\n if (state === this.selected.value) {\n return;\n }\n this.selected.next(state);\n if (propagateDown && state !== ClrSelectedState.INDETERMINATE && this.children) {\n this.children.forEach(child => {\n if (!child.disabled) {\n child.setSelected(state, false, true);\n }\n });\n }\n if (propagateUp && this.parent) {\n this.parent._updateSelectionFromChildren();\n }\n }\n\n toggleSelection(propagate: boolean) {\n if (this.disabled) {\n return;\n }\n\n // Both unselected and indeterminate toggle to selected\n const newState =\n this.selected.value === ClrSelectedState.SELECTED ? ClrSelectedState.UNSELECTED : ClrSelectedState.SELECTED;\n // NOTE: we always propagate selection up in this method because it is only called when the user takes an action.\n // It should never be called from lifecycle hooks or app-provided inputs.\n this.setSelected(newState, true, propagate);\n }\n\n /*\n * Internal, but needs to be called by other nodes\n */\n _updateSelectionFromChildren() {\n const newState = this.computeSelectionStateFromChildren();\n if (newState === this.selected.value) {\n return;\n }\n this.selected.next(newState);\n if (this.parent) {\n this.parent._updateSelectionFromChildren();\n }\n }\n\n private computeSelectionStateFromChildren() {\n let oneSelected = false;\n let oneUnselected = false;\n // Using a good old for loop to exit as soon as we can tell, for better performance on large trees.\n for (const child of this.children) {\n switch (child.selected.value) {\n case ClrSelectedState.INDETERMINATE:\n if (child.disabled) {\n continue;\n }\n return ClrSelectedState.INDETERMINATE;\n case ClrSelectedState.SELECTED:\n oneSelected = true;\n if (oneUnselected) {\n return ClrSelectedState.INDETERMINATE;\n }\n break;\n case ClrSelectedState.UNSELECTED:\n default:\n // Default is the same as unselected, in case an undefined somehow made it all the way here.\n oneUnselected = true;\n if (oneSelected) {\n return ClrSelectedState.INDETERMINATE;\n }\n break;\n }\n }\n if (!oneSelected) {\n return ClrSelectedState.UNSELECTED;\n } else if (!oneUnselected) {\n return ClrSelectedState.SELECTED;\n } else {\n return ClrSelectedState.UNSELECTED;\n }\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { TreeNodeModel } from './tree-node.model';\n\n/*\n * A declarative model is built by traversing the Angular component tree.\n * Declarative = Tree node components dictate the model\n */\nexport class DeclarativeTreeNodeModel<T> extends TreeNodeModel<T> {\n // Override for a more precise type\n parent: DeclarativeTreeNodeModel<T> | null;\n children: DeclarativeTreeNodeModel<T>[];\n\n constructor(parent: DeclarativeTreeNodeModel<T> | null) {\n super();\n this.parent = parent;\n if (parent) {\n parent._addChild(this);\n }\n this.children = [];\n }\n\n override destroy() {\n if (this.parent) {\n this.parent._removeChild(this);\n }\n super.destroy();\n }\n\n _addChild(child: DeclarativeTreeNodeModel<T>) {\n this.children.push(child);\n }\n\n _removeChild(child: DeclarativeTreeNodeModel<T>) {\n const index = this.children.indexOf(child);\n if (index > -1) {\n this.children.splice(index, 1);\n }\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { Directive, ElementRef } from '@angular/core';\n\n@Directive({\n selector: '.clr-treenode-link',\n standalone: false,\n})\nexport class ClrTreeNodeLink {\n constructor(private el: ElementRef<HTMLElement>) {}\n\n get active() {\n return this.el.nativeElement.classList.contains('active');\n }\n\n activate() {\n if (this.el.nativeElement && this.el.nativeElement.click) {\n this.el.nativeElement.click();\n }\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { Component, Input, Optional } from '@angular/core';\nimport { IfExpandService } from '@clr/angular/utils';\nimport { Subscription } from 'rxjs';\n\nimport { RecursiveTreeNodeModel } from './models/recursive-tree-node.model';\nimport { TreeNodeModel } from './models/tree-node.model';\nimport { ClrRecursiveForOfContext } from './recursive-for-of';\nimport { TreeFeaturesService } from './tree-features.service';\n\n@Component({\n selector: 'clr-recursive-children',\n template: `\n @if (shouldRender()) {\n @for (child of parent?.children || children; track child) {\n <ng-container *ngTemplateOutlet=\"featuresService.recursion.template; context: getContext(child)\"></ng-container>\n }\n }\n `,\n host: {\n '[attr.role]': 'role', // Safari + VO needs direct relationship between treeitem and group; no element should exist between them\n },\n standalone: false,\n})\n/**\n * Internal component, do not export!\n * This is part of the hack to get around https://github.com/angular/angular/issues/15998\n */\nexport class RecursiveChildren<T> {\n // Offering the option to either give the parent node to recurse potentially lazily,\n // or directly the list of children to display.\n @Input('parent') parent: TreeNodeModel<T>;\n @Input('children') children: TreeNodeModel<T>[];\n\n subscription: Subscription;\n role: string;\n\n constructor(\n public featuresService: TreeFeaturesService<T>,\n @Optional() private expandService: IfExpandService\n ) {\n if (expandService) {\n this.subscription = expandService.expandChange.subscribe(value => {\n if (!value && this.parent && !featuresService.eager && featuresService.recursion) {\n // In the case of lazy-loading recursive trees, we clear the children on collapse.\n // This is better in case they change between two user interaction, and that way\n // the app itself can decide whether to cache them or not.\n (this.parent as RecursiveTreeNodeModel<T>).clearChildren();\n }\n });\n }\n }\n\n ngAfterContentInit() {\n this.setAriaRoles();\n }\n\n shouldRender() {\n return (\n this.featuresService.recursion &&\n // In the smart case, we eagerly render all the recursive children\n // to make sure two-way bindings for selection are available.\n // They will be hidden with CSS by the parent.\n (this.featuresService.eager || !this.expandService || this.expandService.expanded)\n );\n }\n\n getContext(node: TreeNodeModel<T>): ClrRecursiveForOfContext<T> {\n return {\n $implicit: node.model,\n clrModel: node,\n };\n }\n\n ngOnDestroy() {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n\n private setAriaRoles() {\n this.role = this.parent ? 'group' : null;\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { animate, state, style, transition, trigger } from '@angular/animations';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n AfterContentInit,\n AfterViewInit,\n Component,\n ContentChildren,\n ElementRef,\n EventEmitter,\n Inject,\n Injector,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n Output,\n PLATFORM_ID,\n QueryList,\n SkipSelf,\n ViewChild,\n} from '@angular/core';\nimport {\n ClrCommonStringsService,\n IfExpandService,\n isKeyEitherLetterOrNumber,\n Keys,\n LoadingListener,\n preventArrowKeyScroll,\n uniqueIdFactory,\n} from '@clr/angular/utils';\nimport { Subject, Subscription } from 'rxjs';\nimport { debounceTime, filter } from 'rxjs/operators';\n\nimport { DeclarativeTreeNodeModel } from './models/declarative-tree-node.model';\nimport { ClrSelectedState } from './models/selected-state.enum';\nimport { TreeNodeModel } from './models/tree-node.model';\nimport { TREE_FEATURES_PROVIDER, TreeFeaturesService } from './tree-features.service';\nimport { TreeFocusManagerService } from './tree-focus-manager.service';\nimport { ClrTreeNodeLink } from './tree-node-link';\n\nconst LVIEW_CONTEXT_INDEX = 8;\n\n// If the user types multiple keys without allowing 200ms to pass between them,\n// then those keys are sent together in one request.\nconst TREE_TYPE_AHEAD_TIMEOUT = 200;\n\n@Component({\n selector: 'clr-tree-node',\n templateUrl: './tree-node.html',\n providers: [TREE_FEATURES_PROVIDER, IfExpandService, { provide: LoadingListener, useExisting: IfExpandService }],\n animations: [\n trigger('toggleChildrenAnim', [\n transition('collapsed => expanded', [style({ height: 0 }), animate(200, style({ height: '*' }))]),\n transition('expanded => collapsed', [style({ height: '*' }), animate(200, style({ height: 0 }))]),\n state('expanded', style({ height: '*', 'overflow-y': 'visible' })),\n state('collapsed', style({ height: 0 })),\n ]),\n ],\n host: {\n '[class.clr-tree-node]': 'true',\n '[class.disabled]': 'this._model.disabled',\n },\n standalone: false,\n})\nexport class ClrTreeNode<T> implements OnInit, AfterContentInit, AfterViewInit, OnDestroy {\n // Allows the consumer to override our logic deciding if a node is expandable.\n // Useful for recursive trees that don't want to pre-load one level ahead just to know which nodes are expandable.\n @Input('clrExpandable') expandable: boolean | undefined;\n\n @Output('clrSelectedChange') selectedChange = new EventEmitter<ClrSelectedState>(false);\n @Output('clrExpandedChange') expandedChange = new EventEmitter<boolean>();\n\n STATES = ClrSelectedState;\n isModelLoading = false;\n nodeId = uniqueIdFactory();\n contentContainerTabindex = -1;\n _model: TreeNodeModel<T>;\n\n private skipEmitChange = false;\n private typeAheadKeyBuffer = '';\n private typeAheadKeyEvent = new Subject<string>();\n private subscriptions: Subscription[] = [];\n\n @ViewChild('contentContainer', { read: ElementRef, static: true }) private contentContainer: ElementRef<HTMLElement>;\n\n // @ContentChild would have been more succinct\n // but it doesn't offer a way to query only an immediate child\n @ContentChildren(ClrTreeNodeLink, { descendants: false }) private treeNodeLinkList: QueryList<ClrTreeNodeLink>;\n\n constructor(\n @Inject(PLATFORM_ID) private platformId: any,\n @Optional()\n @SkipSelf()\n parent: ClrTreeNode<T>,\n public featuresService: TreeFeaturesService<T>,\n public expandService: IfExpandService,\n public commonStrings: ClrCommonStringsService,\n private focusManager: TreeFocusManagerService<T>,\n private elementRef: ElementRef<HTMLElement>,\n injector: Injector\n ) {\n if (featuresService.recursion) {\n // I'm completely stuck, we have to hack into private properties until either\n // https://github.com/angular/angular/issues/14935 or https://github.com/angular/angular/issues/15998\n // are fixed\n // This is for non-ivy implementations\n if ((injector as any).view) {\n this._model = (injector as any).view.context.clrModel;\n } else {\n // Ivy puts this on a specific index of a _lView property\n this._model = (injector as any)._lView[LVIEW_CONTEXT_INDEX].clrModel;\n }\n } else {\n // Force cast for now, not sure how to tie the correct type here to featuresService.recursion\n this._model = new DeclarativeTreeNodeModel(parent ? (parent._model as DeclarativeTreeNodeModel<T>) : null);\n }\n this._model.nodeId = this.nodeId;\n }\n\n @Input('clrDisabled')\n get disabled(): boolean {\n return this._model.disabled;\n }\n set disabled(value: boolean) {\n this._model.disabled = value;\n }\n\n @Input('clrSelected')\n get selected(): ClrSelectedState | boolean {\n return this._model.selected.value;\n }\n set selected(value: ClrSelectedState | boolean) {\n this.featuresService.selectable = true;\n // Gracefully handle falsy states like null or undefined because it's just easier than answering questions.\n // This shouldn't happen with strict typing on the app's side, but it's not up to us.\n if (value === null || typeof value === 'undefined') {\n value = ClrSelectedState.UNSELECTED;\n }\n // We match booleans to the corresponding ClrSelectedState\n if (typeof value === 'boolean') {\n value = value ? ClrSelectedState.SELECTED : ClrSelectedState.UNSELECTED;\n }\n // We propagate only if the tree is in smart mode, and skip emitting the output when we set the input\n // See https://github.com/vmware/clarity/issues/3073\n this.skipEmitChange = true;\n this._model.setSelected(value, this.featuresService.eager, this.featuresService.eager);\n this.skipEmitChange = false;\n }\n\n // I'm caving on this, for tree nodes I think we can tolerate having a two-way binding on the component\n // rather than enforce the clrIfExpanded structural directive for dynamic cases. Mostly because for the smart\n // case, you can't use a structural directive, it would need to go on an ng-container.\n @Input('clrExpanded')\n get expanded(): boolean {\n return this.expandService.expanded;\n }\n set expanded(value: boolean) {\n this.expandService.expanded = value;\n }\n\n @Input('clrForTypeAhead')\n set clrForTypeAhead(value: string) {\n this._model.textContent = trimAndLowerCase(value || this.elementRef.nativeElement.textContent);\n }\n\n get ariaSelected(): boolean {\n if (this.isSelectable()) {\n return this._model.selected.value === ClrSelectedState.SELECTED;\n } else if (this.treeNodeLink?.active) {\n return true;\n } else {\n return null;\n }\n }\n\n get treeNodeLink() {\n return this.treeNodeLinkList && this.treeNodeLinkList.first;\n }\n\n private get isParent() {\n return this._model.children && this._model.children.length > 0;\n }\n\n ngOnInit() {\n this._model.expanded = this.expanded;\n this._model.disabled = this.disabled;\n this.subscriptions.push(\n this._model.selected.pipe(filter(() => !this.skipEmitChange)).subscribe(value => {\n this.selectedChange.emit(value);\n })\n );\n this.subscriptions.push(\n this.expandService.expandChange.subscribe(value => {\n this.expandedChange.emit(value);\n this._model.expanded = value;\n })\n );\n this.subscriptions.push(\n this.focusManager.focusRequest.subscribe(nodeId => {\n if (this.nodeId === nodeId) {\n this.focusTreeNode();\n }\n }),\n this.focusManager.focusChange.subscribe(nodeId => {\n this.checkTabIndex(nodeId);\n })\n );\n\n this.subscriptions.push(\n this._model.loading$.pipe(debounceTime(0)).subscribe(isLoading => (this.isModelLoading = isLoading))\n );\n }\n\n ngAfterContentInit() {\n this.subscriptions.push(\n this.typeAheadKeyEvent.pipe(debounceTime(TREE_TYPE_AHEAD_TIMEOUT)).subscribe((bufferedKeys: string) => {\n this.focusManager.focusNodeStartsWith(bufferedKeys, this._model);\n // reset once bufferedKeys are used\n this.typeAheadKeyBuffer = '';\n })\n );\n }\n\n ngAfterViewInit() {\n if (!this._model.textContent) {\n this._model.textContent = trimAndLowerCase(this.elementRef.nativeElement.textContent);\n }\n }\n\n ngOnDestroy() {\n this._model.destroy();\n this.subscriptions.forEach(sub => sub.unsubscribe());\n }\n\n isExpandable() {\n if (typeof this.expandable !== 'undefined') {\n return this.expandable;\n }\n return !!this.expandService.expandable || this.isParent;\n }\n\n isSelectable() {\n return this.featuresService.selectable;\n }\n\n focusTreeNode(): void {\n const containerEl = this.contentContainer.nativeElement;\n if (isPlatformBrowser(this.platformId) && document.activeElement !== containerEl) {\n this.setTabIndex(0);\n containerEl.focus();\n containerEl.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n }\n\n broadcastFocusOnContainer() {\n this.focusManager.broadcastFocusedNode(this.nodeId);\n }\n\n onKeyDown(event: KeyboardEvent) {\n // Two reasons to prevent default behavior:\n // 1. to prevent scrolling on arrow keys\n // 2. Assistive Technology focus differs from Keyboard focus behavior.\n // By default, pressing arrow key makes AT focus go into the nested content of the item.\n preventArrowKeyScroll(event);\n\n // https://www.w3.org/TR/wai-aria-practices-1.1/#keyboard-interaction-22\n switch (event.key) {\n case Keys.ArrowUp:\n this.focusManager.focusNodeAbove(this._model);\n break;\n case Keys.ArrowDown:\n this.focusManager.focusNodeBelow(this._model);\n break;\n case Keys.ArrowRight:\n this.expandOrFocusFirstChild();\n break;\n case Keys.ArrowLeft:\n this.collapseOrFocusParent();\n break;\n case Keys.Home:\n event.preventDefault();\n this.focusManager.focusFirstVisibleNode();\n break;\n case Keys.End:\n event.preventDefault();\n this.focusManager.focusLastVisibleNode();\n break;\n case Keys.Enter:\n this.toggleExpandOrTriggerDefault();\n break;\n case Keys.Space:\n case Keys.Spacebar:\n // to prevent scrolling on space key in this specific case\n event.preventDefault();\n this.toggleExpandOrTriggerDefault();\n break;\n default:\n if (this._model.textContent && isKeyEitherLetterOrNumber(event)) {\n this.typeAheadKeyBuffer += event.key;\n this.typeAheadKeyEvent.next(this.typeAheadKeyBuffer);\n return;\n }\n break;\n }\n\n // if non-letter keys are pressed, do reset.\n this.typeAheadKeyBuffer = '';\n }\n\n private setTabIndex(value: number) {\n this.contentContainerTabindex = value;\n this.contentContainer.nativeElement.setAttribute('tabindex', value.toString());\n }\n\n private checkTabIndex(nodeId: string): void {\n if (isPlatformBrowser(this.platformId) && this.nodeId !== nodeId && this.contentContainerTabindex !== -1) {\n this.setTabIndex(-1);\n }\n }\n\n private toggleExpandOrTriggerDefault() {\n if (this.disabled) {\n return;\n }\n\n if (this.isExpandable() && !this.isSelectable()) {\n this.expandService.expanded = !this.expanded;\n } else {\n this.triggerDefaultAction();\n }\n }\n\n private expandOrFocusFirstChild() {\n if (this.disabled) {\n return;\n }\n\n if (this.expanded) {\n // if the node is already expanded and has children, focus its very first child\n if (this.isParent) {\n this.focusManager.focusNodeBelow(this._model);\n }\n } else {\n // we must check if the node is expandable, in order to set .expanded to true from false\n // because we shouldn't set .expanded to true if it's not expandable node\n if (this.isExpandable()) {\n this.expandService.expanded = true;\n }\n }\n }\n\n private collapseOrFocusParent() {\n if (this.disabled) {\n return;\n }\n\n if (this.expanded) {\n this.expandService.expanded = false;\n } else {\n this.focusManager.focusParent(this._model);\n }\n }\n\n private triggerDefaultAction() {\n if (this.treeNodeLink) {\n this.treeNodeLink.activate();\n } else {\n if (this.isSelectable()) {\n this._model.toggleSelection(this.featuresService.eager);\n }\n }\n }\n}\n\nfunction trimAndLowerCase(value: string) {\n return value.toLocaleLowerCase().trim();\n}\n","<!--\n ~ Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n ~ The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n ~ This software is released under MIT license.\n ~ The full license information can be found in LICENSE in the root directory of this project.\n -->\n\n<div\n #contentContainer\n role=\"treeitem\"\n class=\"clr-tree-node-content-container\"\n tabindex=\"-1\"\n [class.clr-form-control-disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled\"\n [attr.aria-expanded]=\"isExpandable() ? expanded : null\"\n [attr.aria-selected]=\"ariaSelected\"\n (keydown)=\"onKeyDown($event)\"\n (focus)=\"broadcastFocusOnContainer()\"\n>\n @if (isExpandable() && !isModelLoading && !expandService.loading) {\n <button\n aria-hidden=\"true\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"clr-treenode-caret\"\n (click)=\"expandService.toggle();\"\n (focus)=\"focusTreeNode()\"\n [disabled]=\"disabled\"\n >\n <cds-icon\n class=\"clr-treenode-caret-icon\"\n shape=\"angle\"\n [direction]=\"expandService.expanded ? 'down' : 'right'\"\n ></cds-icon>\n </button>\n } @if (expandService.loading || isModelLoading) {\n <div class=\"clr-treenode-spinner-container\">\n <span class=\"clr-treenode-spinner spinner\"></span>\n </div>\n } @if (featuresService.selectable) {\n <div class=\"clr-checkbox-wrapper clr-treenode-checkbox\">\n <input\n aria-hidden=\"true\"\n type=\"checkbox\"\n [id]=\"nodeId + '-check'\"\n class=\"clr-checkbox\"\n [disabled]=\"disabled\"\n [checked]=\"_model.selected.value === STATES.SELECTED\"\n [indeterminate]=\"_model.selected.value === STATES.INDETERMINATE\"\n (change)=\"_model.toggleSelection(featuresService.eager)\"\n (focus)=\"focusTreeNode()\"\n tabindex=\"-1\"\n />\n <label [for]=\"nodeId + '-check'\" class=\"clr-control-label\">\n <ng-container [ngTemplateOutlet]=\"treenodeContent\"></ng-container>\n </label>\n </div>\n } @if (!featuresService.selectable) {\n <div class=\"clr-treenode-content\" (mouseup)=\"focusTreeNode()\">\n <ng-container [ngTemplateOutlet]=\"treenodeContent\"></ng-container>\n </div>\n }\n\n <ng-template #treenodeContent>\n <ng-content></ng-content>\n @if (featuresService.selectable || ariaSelected) {\n <div class=\"clr-sr-only\">\n <span> {{ariaSelected ? commonStrings.keys.selectedTreeNode : commonStrings.keys.unselectedTreeNode}}</span>\n </div>\n }\n </ng-template>\n</div>\n<div\n class=\"clr-treenode-children\"\n [@toggleChildrenAnim]=\"expandService.expanded ? 'expanded' : 'collapsed'\"\n [attr.role]=\"isExpandable() && !featuresService.recursion ? 'group' : null\"\n>\n <ng-content select=\"clr-tree-node\"></ng-content>\n <ng-content select=\"[clrIfExpanded]\"></ng-content>\n <clr-recursive-children [parent]=\"_model\"></clr-recursive-children>\n</div>\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport {\n AfterContentInit,\n Component,\n ContentChildren,\n ElementRef,\n Input,\n NgZone,\n OnDestroy,\n QueryList,\n Renderer2,\n} from '@angular/core';\nimport { fromEvent, Subscription } from 'rxjs';\n\nimport { TREE_FEATURES_PROVIDER, TreeFeaturesService } from './tree-features.service';\nimport { TreeFocusManagerService } from './tree-focus-manager.service';\nimport { ClrTreeNode } from './tree-node';\n\n@Component({\n selector: 'clr-tree',\n template: `\n <ng-content></ng-content>\n @if (featuresService.recursion) {\n <clr-recursive-children [children]=\"featuresService.recursion.root\"></clr-recursive-children>\n }\n `,\n providers: [TREE_FEATURES_PROVIDER, TreeFocusManagerService],\n host: {\n tabindex: '0',\n '[attr.role]': '\"tree\"',\n },\n standalone: false,\n})\nexport class ClrTree<T> implements AfterContentInit, OnDestroy {\n @ContentChildren(ClrTreeNode) private rootNodes: QueryList<ClrTreeNode<T>>;\n\n private subscriptions: Subscription[] = [];\n private _isMultiSelectable = false;\n\n constructor(\n public featuresService: TreeFeaturesService<T>,\n private focusManagerService: TreeFocusManagerService<T>,\n private renderer: Renderer2,\n private el: ElementRef<HTMLElement>,\n ngZone: NgZone\n ) {\n const subscription = ngZone.runOutsideAngular(() =>\n fromEvent(el.nativeElement, 'focusin').subscribe((event: FocusEvent) => {\n if (event.target === el.nativeElement) {\n // After discussing with the team, I've made it so that when the tree receives focus, the first visible node will be focused.\n // This will prevent from the page scrolling abruptly to the first selected node if it exist in a deeply nested tree.\n focusManagerService.focusFirstVisibleNode();\n // when the first child gets focus,\n // tree should no longer have tabindex of 0.\n renderer.removeAttribute(el.nativeElement, 'tabindex');\n }\n })\n );\n\n this.subscriptions.push(subscription);\n }\n\n @Input('clrLazy')\n set lazy(value: boolean) {\n this.featuresService.eager = !value;\n }\n\n get isMultiSelectable() {\n return this._isMultiSelectable;\n }\n\n ngAfterContentInit() {\n this.setRootNodes();\n this.subscriptions.push(\n this.rootNodes.changes.subscribe(() => {\n this.setMultiSelectable();\n\n this.setRootNodes();\n })\n );\n }\n\n ngOnDestroy() {\n this.subscriptions.forEach(sub => sub.unsubscribe());\n }\n\n private setMultiSelectable() {\n if (this.featuresService.selectable && this.rootNodes.length > 0) {\n this._isMultiSelectable = true;\n this.renderer.setAttribute(this.el.nativeElement, 'aria-multiselectable', 'true');\n } else {\n this._isMultiSelectable = false;\n this.renderer.removeAttribute(this.el.nativeElement, 'aria-multiselectable');\n }\n }\n\n private setRootNodes(): void {\n // if node has no parent, it's a root node\n // for recursive tree, this.rootNodes registers also nested children\n // so we have to use filter to extract the ones that are truly root nodes\n this.focusManagerService.rootNodeModels = this.rootNodes.map(node => node._model).filter(node => !node.parent);\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\n// We need to make sure people can give us null or undefined children even if they run strict type checking.\nimport { Observable } from 'rxjs';\n\nexport type AsyncArray<T> =\n | T[]\n | null\n | undefined\n | Promise<T[] | null | undefined>\n | Observable<T[] | null | undefined>;\n\nexport function isPromise<T>(o: AsyncArray<T>): o is Promise<T[]> {\n // Shamelessly copied from every open-source project out there.\n return o && typeof (o as any).then === 'function';\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { isObservable, Subscription } from 'rxjs';\n\nimport { TreeFeaturesService } from '../tree-features.service';\nimport { AsyncArray, isPromise } from './async-array';\nimport { TreeNodeModel } from './tree-node.model';\n\n/*\n * A recursive model is built received from the app and traversed to create the corresponding components.\n * Recursive = Model dictates the tree node components\n */\nexport class RecursiveTreeNodeModel<T> extends TreeNodeModel<T> {\n parent: RecursiveTreeNodeModel<T> | null;\n\n private subscription: Subscription;\n private childrenFetched = false;\n private _children: RecursiveTreeNodeModel<T>[] = [];\n\n constructor(\n model: T,\n parent: RecursiveTreeNodeModel<T> | null,\n private getChildren: (node: T) => AsyncArray<T> | undefined,\n private featuresService: TreeFeaturesService<T> | undefined\n ) {\n super();\n this.model = model;\n this.parent = parent;\n }\n\n get children(): RecursiveTreeNodeModel<T>[] {\n this.fetchChildren();\n return this._children;\n }\n set children(value: RecursiveTreeNodeModel<T>[]) {\n this._children = value;\n }\n\n override destroy() {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n super.destroy();\n }\n\n clearChildren() {\n this._children.forEach(child => child.destroy());\n delete this._children;\n this.childrenFetched = false;\n }\n\n fetchChildren() {\n if (this.childrenFetched) {\n return;\n }\n\n const asyncChildren = this.getChildren(this.model);\n if (isPromise(asyncChildren)) {\n this.loading = true;\n asyncChildren.then(raw => {\n this._children = this.wrapChildren(raw);\n this.loading = false;\n });\n } else if (isObservable(asyncChildren)) {\n this.loading = true;\n this.subscription = asyncChildren.subscribe(raw => {\n this._children = this.wrapChildren(raw);\n this.loading = false;\n });\n } else if (asyncChildren) {\n // Synchronous case\n this._children = this.wrapChildren(asyncChildren);\n } else {\n this._children = [];\n }\n this.childrenFetched = true;\n if (this.featuresService) {\n this.featuresService.childrenFetched.next();\n }\n }\n\n private wrapChildren(rawModels: T[]) {\n return rawModels.map(m => new RecursiveTreeNodeModel(m, this, this.getChildren, this.featuresService));\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { ChangeDetectorRef, Directive, Input, OnChanges, OnDestroy, TemplateRef } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\n\nimport { AsyncArray } from './models/async-array';\nimport { RecursiveTreeNodeModel } from './models/recursive-tree-node.model';\nimport { TreeNodeModel } from './models/tree-node.model';\nimport { TreeFeaturesService } from './tree-features.service';\n\nexport interface ClrRecursiveForOfContext<T> {\n $implicit: T;\n clrModel: TreeNodeModel<T>;\n}\n\n@Directive({\n selector: '[clrRecursiveFor][clrRecursiveForOf]',\n standalone: false,\n})\nexport class ClrRecursiveForOf<T> implements OnChanges, OnDestroy {\n // TODO: accept NgIterable<T>\n @Input('clrRecursiveForOf') nodes: T | T[];\n\n // TODO: accept NgIterable<T> return type\n @Input('clrRecursiveForGetChildren') getChildren: (node: T) => AsyncArray<T>;\n\n private childrenFetchSubscription: Subscription;\n\n constructor(\n private template: TemplateRef<ClrRecursiveForOfContext<T>>,\n private featuresService: TreeFeaturesService<T>,\n private cdr: ChangeDetectorRef\n ) {}\n\n // I'm using OnChanges instead of OnInit to easily keep up to date with dynamic trees. Maybe optimizable later.\n ngOnChanges() {\n let wrapped: RecursiveTreeNodeModel<T>[];\n if (Array.isArray(this.nodes)) {\n wrapped = this.nodes.map(node => new RecursiveTreeNodeModel(node, null, this.getChildren, this.featuresService));\n } else {\n wrapped = [new RecursiveTreeNodeModel(this.nodes, null, this.getChildren, this.featuresService)];\n }\n if (!this.childrenFetchSubscription) {\n this.childrenFetchSubscription = this.featuresService.childrenFetched.pipe(debounceTime(0)).subscribe(() => {\n this.cdr.detectChanges();\n });\n }\n\n this.featuresService.recursion = {\n template: this.template,\n root: wrapped,\n };\n }\n\n ngOnDestroy() {\n if (this.childrenFetchSubscription) {\n this.childrenFetchSubscription.unsubscribe();\n }\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nimport { CommonModule } from '@angular/common';\nimport { NgModule, Type } from '@angular/core';\nimport { angleIcon, ClarityIcons, ClrIcon } from '@clr/angular/icon';\nimport { ClrLoadingModule } from '@clr/angular/utils';\n\nimport { RecursiveChildren } from './recursive-children';\nimport { ClrRecursiveForOf } from './recursive-for-of';\nimport { ClrTree } from './tree';\nimport { ClrTreeNode } from './tree-node';\nimport { ClrTreeNodeLink } from './tree-node-link';\n\nexport const CLR_TREE_VIEW_DIRECTIVES: Type<any>[] = [ClrTree, ClrTreeNode, ClrRecursiveForOf, ClrTreeNodeLink];\n\n@NgModule({\n imports: [CommonModule, ClrIcon, ClrLoadingModule],\n declarations: [CLR_TREE_VIEW_DIRECTIVES, RecursiveChildren],\n exports: [CLR_TREE_VIEW_DIRECTIVES],\n})\nexport class ClrTreeViewModule {\n constructor() {\n ClarityIcons.addIcons(angleIcon);\n }\n}\n","/*\n * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.\n * The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n * This software is released under MIT license.\n * The full license information can be found in LICENSE in the root directory of this project.\n */\n\nexport * from './models/selected-state.enum';\nexport * from './tree';\nexport * from './tree-node';\nexport * from './recursive-for-of';\nexport * from './tree-view.module';\nexport * from './tree-node-link';\nexport * from './models/tree-node.model';\nexport * from './models/declarative-tree-node.model';\nexport * from './models/recursive-tree-node.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.TreeFeaturesService","i3.TreeFocusManagerService","i4","i6.RecursiveChildren","i2.TreeFocusManagerService","i3.RecursiveChildren"],"mappings":";;;;;;;;;;;;AAAA;;;;;AAKG;AAEH;IAC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