blob: 1f2cee345f5ed03115c112db14d369e608259bf8 [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/collections"),require("rxjs"),require("rxjs/operators"),require("@angular/core"),require("@angular/cdk/coercion"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@angular/cdk/tree",["exports","@angular/cdk/collections","rxjs","rxjs/operators","@angular/core","@angular/cdk/coercion","@angular/cdk/bidi"],t):t(((e=e||self).ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.tree={}),e.ng.cdk.collections,e.rxjs,e.rxjs.operators,e.ng.core,e.ng.cdk.coercion,e.ng.cdk.bidi)}(this,(function(e,t,n,r,o,i,s){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function u(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(c(arguments[t]));return e}var l,p=function(){function e(){this.expansionModel=new t.SelectionModel(!0)}return e.prototype.toggle=function(e){this.expansionModel.toggle(this._trackByValue(e))},e.prototype.expand=function(e){this.expansionModel.select(this._trackByValue(e))},e.prototype.collapse=function(e){this.expansionModel.deselect(this._trackByValue(e))},e.prototype.isExpanded=function(e){return this.expansionModel.isSelected(this._trackByValue(e))},e.prototype.toggleDescendants=function(e){this.expansionModel.isSelected(this._trackByValue(e))?this.collapseDescendants(e):this.expandDescendants(e)},e.prototype.collapseAll=function(){this.expansionModel.clear()},e.prototype.expandDescendants=function(e){var t,n=this,r=[e];r.push.apply(r,u(this.getDescendants(e))),(t=this.expansionModel).select.apply(t,u(r.map((function(e){return n._trackByValue(e)}))))},e.prototype.collapseDescendants=function(e){var t,n=this,r=[e];r.push.apply(r,u(this.getDescendants(e))),(t=this.expansionModel).deselect.apply(t,u(r.map((function(e){return n._trackByValue(e)}))))},e.prototype._trackByValue=function(e){return this.trackBy?this.trackBy(e):e},e}(),h=function(e){function t(t,n,r){var o=e.call(this)||this;return o.getLevel=t,o.isExpandable=n,o.options=r,o.options&&(o.trackBy=o.options.trackBy),o}return d(t,e),t.prototype.getDescendants=function(e){for(var t=[],n=this.dataNodes.indexOf(e)+1;n<this.dataNodes.length&&this.getLevel(e)<this.getLevel(this.dataNodes[n]);n++)t.push(this.dataNodes[n]);return t},t.prototype.expandAll=function(){var e,t=this;(e=this.expansionModel).select.apply(e,u(this.dataNodes.map((function(e){return t._trackByValue(e)}))))},t}(p),f=function(e){function t(t,n){var r=e.call(this)||this;return r.getChildren=t,r.options=n,r.options&&(r.trackBy=r.options.trackBy),r}return d(t,e),t.prototype.expandAll=function(){var e,t=this;this.expansionModel.clear();var n=this.dataNodes.reduce((function(e,n){return u(e,t.getDescendants(n),[n])}),[]);(e=this.expansionModel).select.apply(e,u(n.map((function(e){return t._trackByValue(e)}))))},t.prototype.getDescendants=function(e){var t=[];return this._getDescendants(t,e),t.splice(1)},t.prototype._getDescendants=function(e,t){var o=this;e.push(t);var i=this.getChildren(t);Array.isArray(i)?i.forEach((function(t){return o._getDescendants(e,t)})):n.isObservable(i)&&i.pipe(r.take(1),r.filter(Boolean)).subscribe((function(t){var n,r;try{for(var i=function s(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),a=i.next();!a.done;a=i.next())o._getDescendants(e,a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}))},t}(p),_=new o.InjectionToken("CDK_TREE_NODE_OUTLET_NODE");(l=function l(e,t){this.viewContainer=e,this._node=t}).decorators=[{type:o.Directive,args:[{selector:"[cdkTreeNodeOutlet]"}]}],l.ctorParameters=function(){return[{type:o.ViewContainerRef},{type:void 0,decorators:[{type:o.Inject,args:[_]},{type:o.Optional}]}]};
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var y,g=function g(e){this.$implicit=e};(y=function y(e){this.template=e}).decorators=[{type:o.Directive,args:[{selector:"[cdkTreeNodeDef]",inputs:["when: cdkTreeNodeDefWhen"]}]}],y.ctorParameters=function(){return[{type:o.TemplateRef}]};var v=function(){function e(e,t){this._differs=e,this._changeDetectorRef=t,this._onDestroy=new n.Subject,this._levels=new Map,this.viewChange=new n.BehaviorSubject({start:0,end:Number.MAX_VALUE})}return Object.defineProperty(e.prototype,"dataSource",{get:function(){return this._dataSource},set:function(e){this._dataSource!==e&&this._switchDataSource(e)},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){this._dataDiffer=this._differs.find([]).create(this.trackBy)},e.prototype.ngOnDestroy=function(){this._nodeOutlet.viewContainer.clear(),this.viewChange.complete(),this._onDestroy.next(),this._onDestroy.complete(),this._dataSource&&"function"==typeof this._dataSource.disconnect&&this.dataSource.disconnect(this),this._dataSubscription&&(this._dataSubscription.unsubscribe(),this._dataSubscription=null)},e.prototype.ngAfterContentChecked=function(){var e=this._nodeDefs.filter((function(e){return!e.when}));this._defaultNodeDef=e[0],this.dataSource&&this._nodeDefs&&!this._dataSubscription&&this._observeRenderChanges()},e.prototype._switchDataSource=function(e){this._dataSource&&"function"==typeof this._dataSource.disconnect&&this.dataSource.disconnect(this),this._dataSubscription&&(this._dataSubscription.unsubscribe(),this._dataSubscription=null),e||this._nodeOutlet.viewContainer.clear(),this._dataSource=e,this._nodeDefs&&this._observeRenderChanges()},e.prototype._observeRenderChanges=function(){var e,o=this;t.isDataSource(this._dataSource)?e=this._dataSource.connect(this):n.isObservable(this._dataSource)?e=this._dataSource:Array.isArray(this._dataSource)&&(e=n.of(this._dataSource)),e&&(this._dataSubscription=e.pipe(r.takeUntil(this._onDestroy)).subscribe((function(e){return o.renderNodeChanges(e)})))},e.prototype.renderNodeChanges=function(e,t,n,r){var o=this;void 0===t&&(t=this._dataDiffer),void 0===n&&(n=this._nodeOutlet.viewContainer);var i=t.diff(e);i&&(i.forEachOperation((function(t,i,s){if(null==t.previousIndex)o.insertNode(e[s],s,n,r);else if(null==s)n.remove(i),o._levels.delete(t.item);else{var a=n.get(i);n.move(a,s)}})),this._changeDetectorRef.detectChanges())},e.prototype._getNodeDef=function(e,t){return 1===this._nodeDefs.length?this._nodeDefs.first:this._nodeDefs.find((function(n){return n.when&&n.when(t,e)}))||this._defaultNodeDef},e.prototype.insertNode=function(e,t,n,r){var o=this._getNodeDef(e,t),i=new g(e);i.level=this.treeControl.getLevel?this.treeControl.getLevel(e):void 0!==r&&this._levels.has(r)?this._levels.get(r)+1:0,this._levels.set(e,i.level),(n||this._nodeOutlet.viewContainer).createEmbeddedView(o.template,i,t),b.mostRecentTreeNode&&(b.mostRecentTreeNode.data=e)},e}();v.decorators=[{type:o.Component,args:[{selector:"cdk-tree",exportAs:"cdkTree",template:"<ng-container cdkTreeNodeOutlet></ng-container>",host:{class:"cdk-tree",role:"tree"},encapsulation:o.ViewEncapsulation.None,changeDetection:o.ChangeDetectionStrategy.Default}]}],v.ctorParameters=function(){return[{type:o.IterableDiffers},{type:o.ChangeDetectorRef}]},v.propDecorators={dataSource:[{type:o.Input}],treeControl:[{type:o.Input}],trackBy:[{type:o.Input}],_nodeOutlet:[{type:o.ViewChild,args:[l,{static:!0}]}],_nodeDefs:[{type:o.ContentChildren,args:[y,{descendants:!0}]}]};var b=function(){function e(t,r){this._elementRef=t,this._tree=r,this._destroyed=new n.Subject,this._dataChanges=new n.Subject,e.mostRecentTreeNode=this,this._elementRef.nativeElement.classList.add("cdk-tree-node"),this.role="treeitem"}return Object.defineProperty(e.prototype,"role",{get:function(){return"treeitem"},set:function(e){this._elementRef.nativeElement.setAttribute("role",e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this._data},set:function(e){e!==this._data&&(this._data=e,this._setRoleFromData(),this._dataChanges.next())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isExpanded",{get:function(){return this._tree.treeControl.isExpanded(this._data)},enumerable:!1,configurable:!0}),e.prototype._setExpanded=function(e){this._isAriaExpanded=e,this._elementRef.nativeElement.setAttribute("aria-expanded",""+e)},Object.defineProperty(e.prototype,"level",{get:function(){return this._tree.treeControl.getLevel?this._tree.treeControl.getLevel(this._data):this._parentNodeAriaLevel},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){this._parentNodeAriaLevel=function e(t){for(var n,r=t.parentElement;r&&(n=void 0,!(null==(n=r.classList)?void 0:n.contains("cdk-nested-tree-node"))&&!(null==n?void 0:n.contains("cdk-tree")));)r=r.parentElement;return r?r.classList.contains("cdk-nested-tree-node")?i.coerceNumberProperty(r.getAttribute("aria-level")):0:-1}(this._elementRef.nativeElement),this._elementRef.nativeElement.setAttribute("aria-level",""+(this.level+1))},e.prototype.ngDoCheck=function(){this.isExpanded!=this._isAriaExpanded&&this._setExpanded(this.isExpanded)},e.prototype.ngOnDestroy=function(){e.mostRecentTreeNode===this&&(e.mostRecentTreeNode=null),this._dataChanges.complete(),this._destroyed.next(),this._destroyed.complete()},e.prototype.focus=function(){this._elementRef.nativeElement.focus()},e.prototype._setRoleFromData=function(){this.role="treeitem"},e}();b.mostRecentTreeNode=null,b.decorators=[{type:o.Directive,args:[{selector:"cdk-tree-node",exportAs:"cdkTreeNode"}]}],b.ctorParameters=function(){return[{type:o.ElementRef},{type:v}]},b.propDecorators={role:[{type:o.Input}]};var m=function(e){function t(t,n,r){var o=e.call(this,t,n)||this;return o._elementRef=t,o._tree=n,o._differs=r,o._elementRef.nativeElement.classList.add("cdk-nested-tree-node"),o}return d(t,e),t.prototype.ngAfterContentInit=function(){var e=this;this._dataDiffer=this._differs.find([]).create(this._tree.trackBy);var t=this._tree.treeControl.getChildren(this.data);Array.isArray(t)?this.updateChildrenNodes(t):n.isObservable(t)&&t.pipe(r.takeUntil(this._destroyed)).subscribe((function(t){return e.updateChildrenNodes(t)})),this.nodeOutlet.changes.pipe(r.takeUntil(this._destroyed)).subscribe((function(){return e.updateChildrenNodes()}))},t.prototype.ngOnInit=function(){e.prototype.ngOnInit.call(this)},t.prototype.ngDoCheck=function(){e.prototype.ngDoCheck.call(this)},t.prototype.ngOnDestroy=function(){this._clear(),e.prototype.ngOnDestroy.call(this)},t.prototype.updateChildrenNodes=function(e){var t=this._getNodeOutlet();e&&(this._children=e),t&&this._children?this._tree.renderNodeChanges(this._children,this._dataDiffer,t.viewContainer,this._data):this._dataDiffer.diff([])},t.prototype._clear=function(){var e=this._getNodeOutlet();e&&(e.viewContainer.clear(),this._dataDiffer.diff([]))},t.prototype._getNodeOutlet=function(){var e=this,t=this.nodeOutlet;return t&&t.find((function(t){return!t._node||t._node===e}))},t}(b);m.decorators=[{type:o.Directive,args:[{selector:"cdk-nested-tree-node",exportAs:"cdkNestedTreeNode",inputs:["role","disabled","tabIndex"],providers:[{provide:b,useExisting:m},{provide:_,useExisting:m}]}]}],m.ctorParameters=function(){return[{type:o.ElementRef},{type:v},{type:o.IterableDiffers}]},m.propDecorators={nodeOutlet:[{type:o.ContentChildren,args:[l,{descendants:!0}]}]};
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var D=/([A-Za-z%]+)$/,C=function(){function e(e,t,o,i){var s=this;this._treeNode=e,this._tree=t,this._element=o,this._dir=i,this._destroyed=new n.Subject,this.indentUnits="px",this._indent=40,this._setPadding(),i&&i.change.pipe(r.takeUntil(this._destroyed)).subscribe((function(){return s._setPadding(!0)})),e._dataChanges.subscribe((function(){return s._setPadding()}))}return Object.defineProperty(e.prototype,"level",{get:function(){return this._level},set:function(e){this._setLevelInput(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indent",{get:function(){return this._indent},set:function(e){this._setIndentInput(e)},enumerable:!1,configurable:!0}),e.prototype.ngOnDestroy=function(){this._destroyed.next(),this._destroyed.complete()},e.prototype._paddingIndent=function(){var e=this._treeNode.data&&this._tree.treeControl.getLevel?this._tree.treeControl.getLevel(this._treeNode.data):null,t=null==this._level?e:this._level;return"number"==typeof t?""+t*this._indent+this.indentUnits:null},e.prototype._setPadding=function(e){void 0===e&&(e=!1);var t=this._paddingIndent();if(t!==this._currentPadding||e){var n=this._element.nativeElement,r=this._dir&&"rtl"===this._dir.value?"paddingRight":"paddingLeft",o="paddingLeft"===r?"paddingRight":"paddingLeft";n.style[r]=t||"",n.style[o]="",this._currentPadding=t}},e.prototype._setLevelInput=function(e){this._level=i.coerceNumberProperty(e,null),this._setPadding()},e.prototype._setIndentInput=function(e){var t=e,n="px";if("string"==typeof e){var r=e.split(D);t=r[0],n=r[1]||n}this.indentUnits=n,this._indent=i.coerceNumberProperty(t),this._setPadding()},e}();C.decorators=[{type:o.Directive,args:[{selector:"[cdkTreeNodePadding]"}]}],C.ctorParameters=function(){return[{type:b},{type:v},{type:o.ElementRef},{type:s.Directionality,decorators:[{type:o.Optional}]}]},C.propDecorators={level:[{type:o.Input,args:["cdkTreeNodePadding"]}],indent:[{type:o.Input,args:["cdkTreeNodePaddingIndent"]}]};
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var k=function(){function e(e,t){this._tree=e,this._treeNode=t,this._recursive=!1}return Object.defineProperty(e.prototype,"recursive",{get:function(){return this._recursive},set:function(e){this._recursive=i.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),e.prototype._toggle=function(e){this.recursive?this._tree.treeControl.toggleDescendants(this._treeNode.data):this._tree.treeControl.toggle(this._treeNode.data),e.stopPropagation()},e}();k.decorators=[{type:o.Directive,args:[{selector:"[cdkTreeNodeToggle]"}]}],k.ctorParameters=function(){return[{type:v},{type:b}]},k.propDecorators={recursive:[{type:o.Input,args:["cdkTreeNodeToggleRecursive"]}],_toggle:[{type:o.HostListener,args:["click",["$event"]]}]};
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var N,x=[m,y,C,k,v,b,l];(N=function N(){}).decorators=[{type:o.NgModule,args:[{exports:x,declarations:x}]}],
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
e.BaseTreeControl=p,e.CDK_TREE_NODE_OUTLET_NODE=_,e.CdkNestedTreeNode=m,e.CdkTree=v,e.CdkTreeModule=N,e.CdkTreeNode=b,e.CdkTreeNodeDef=y,e.CdkTreeNodeOutlet=l,e.CdkTreeNodeOutletContext=g,e.CdkTreeNodePadding=C,e.CdkTreeNodeToggle=k,e.FlatTreeControl=h,e.NestedTreeControl=f,e.getTreeControlFunctionsMissingError=function E(){return Error("Could not find functions for nested/flat tree in tree control.")},e.getTreeControlMissingError=function O(){return Error("Could not find a tree control for the tree.")},e.getTreeMissingMatchingNodeDefError=function T(){return Error("Could not find a matching node definition for the provided node data.")},e.getTreeMultipleDefaultNodeDefsError=function S(){return Error("There can only be one default row without a when predicate function.")},e.getTreeNoValidDataSourceError=
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function w(){return Error("A valid data source must be provided.")},Object.defineProperty(e,"__esModule",{value:!0})}));