material-tree.umd.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/tree'), require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/coercion'), require('@angular/common'), require('@angular/cdk/collections'), require('rxjs'), require('rxjs/operators')) :
  10. typeof define === 'function' && define.amd ? define('@angular/material/tree', ['exports', '@angular/cdk/tree', '@angular/core', '@angular/material/core', '@angular/cdk/coercion', '@angular/common', '@angular/cdk/collections', 'rxjs', 'rxjs/operators'], factory) :
  11. (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.tree = {}),global.ng.cdk.tree,global.ng.core,global.ng.material.core,global.ng.cdk.coercion,global.ng.common,global.ng.cdk.collections,global.rxjs,global.rxjs.operators));
  12. }(this, (function (exports,tree,core,core$1,coercion,common,collections,rxjs,operators) { 'use strict';
  13. /*! *****************************************************************************
  14. Copyright (c) Microsoft Corporation. All rights reserved.
  15. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  16. this file except in compliance with the License. You may obtain a copy of the
  17. License at http://www.apache.org/licenses/LICENSE-2.0
  18. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  20. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  21. MERCHANTABLITY OR NON-INFRINGEMENT.
  22. See the Apache Version 2.0 License for specific language governing permissions
  23. and limitations under the License.
  24. ***************************************************************************** */
  25. /* global Reflect, Promise */
  26. var extendStatics = function(d, b) {
  27. extendStatics = Object.setPrototypeOf ||
  28. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30. return extendStatics(d, b);
  31. };
  32. function __extends(d, b) {
  33. extendStatics(d, b);
  34. function __() { this.constructor = d; }
  35. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36. }
  37. /**
  38. * @fileoverview added by tsickle
  39. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  40. */
  41. /** @type {?} */
  42. var _MatTreeNodeMixinBase = core$1.mixinTabIndex(core$1.mixinDisabled(tree.CdkTreeNode));
  43. /**
  44. * Wrapper for the CdkTree node with Material design styles.
  45. * @template T
  46. */
  47. var MatTreeNode = /** @class */ (function (_super) {
  48. __extends(MatTreeNode, _super);
  49. function MatTreeNode(_elementRef, _tree, tabIndex) {
  50. var _this = _super.call(this, _elementRef, _tree) || this;
  51. _this._elementRef = _elementRef;
  52. _this._tree = _tree;
  53. _this.role = 'treeitem';
  54. _this.tabIndex = Number(tabIndex) || 0;
  55. return _this;
  56. }
  57. MatTreeNode.decorators = [
  58. { type: core.Directive, args: [{
  59. selector: 'mat-tree-node',
  60. exportAs: 'matTreeNode',
  61. inputs: ['disabled', 'tabIndex'],
  62. host: {
  63. '[attr.aria-expanded]': 'isExpanded',
  64. '[attr.aria-level]': 'role === "treeitem" ? level : null',
  65. '[attr.role]': 'role',
  66. 'class': 'mat-tree-node'
  67. },
  68. providers: [{ provide: tree.CdkTreeNode, useExisting: MatTreeNode }]
  69. },] },
  70. ];
  71. /** @nocollapse */
  72. MatTreeNode.ctorParameters = function () { return [
  73. { type: core.ElementRef },
  74. { type: tree.CdkTree },
  75. { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] }
  76. ]; };
  77. MatTreeNode.propDecorators = {
  78. role: [{ type: core.Input }]
  79. };
  80. return MatTreeNode;
  81. }(_MatTreeNodeMixinBase));
  82. /**
  83. * Wrapper for the CdkTree node definition with Material design styles.
  84. * @template T
  85. */
  86. var MatTreeNodeDef = /** @class */ (function (_super) {
  87. __extends(MatTreeNodeDef, _super);
  88. function MatTreeNodeDef() {
  89. return _super !== null && _super.apply(this, arguments) || this;
  90. }
  91. MatTreeNodeDef.decorators = [
  92. { type: core.Directive, args: [{
  93. selector: '[matTreeNodeDef]',
  94. inputs: [
  95. 'when: matTreeNodeDefWhen'
  96. ],
  97. providers: [{ provide: tree.CdkTreeNodeDef, useExisting: MatTreeNodeDef }]
  98. },] },
  99. ];
  100. MatTreeNodeDef.propDecorators = {
  101. data: [{ type: core.Input, args: ['matTreeNode',] }]
  102. };
  103. return MatTreeNodeDef;
  104. }(tree.CdkTreeNodeDef));
  105. /**
  106. * Wrapper for the CdkTree nested node with Material design styles.
  107. * @template T
  108. */
  109. var MatNestedTreeNode = /** @class */ (function (_super) {
  110. __extends(MatNestedTreeNode, _super);
  111. function MatNestedTreeNode(_elementRef, _tree, _differs, tabIndex) {
  112. var _this = _super.call(this, _elementRef, _tree, _differs) || this;
  113. _this._elementRef = _elementRef;
  114. _this._tree = _tree;
  115. _this._differs = _differs;
  116. _this._disabled = false;
  117. _this.tabIndex = Number(tabIndex) || 0;
  118. return _this;
  119. }
  120. Object.defineProperty(MatNestedTreeNode.prototype, "disabled", {
  121. /** Whether the node is disabled. */
  122. get: /**
  123. * Whether the node is disabled.
  124. * @return {?}
  125. */
  126. function () { return this._disabled; },
  127. set: /**
  128. * @param {?} value
  129. * @return {?}
  130. */
  131. function (value) { this._disabled = coercion.coerceBooleanProperty(value); },
  132. enumerable: true,
  133. configurable: true
  134. });
  135. Object.defineProperty(MatNestedTreeNode.prototype, "tabIndex", {
  136. /** Tabindex for the node. */
  137. get: /**
  138. * Tabindex for the node.
  139. * @return {?}
  140. */
  141. function () { return this.disabled ? -1 : this._tabIndex; },
  142. set: /**
  143. * @param {?} value
  144. * @return {?}
  145. */
  146. function (value) {
  147. // If the specified tabIndex value is null or undefined, fall back to the default value.
  148. this._tabIndex = value != null ? value : 0;
  149. },
  150. enumerable: true,
  151. configurable: true
  152. });
  153. // This is a workaround for https://github.com/angular/angular/issues/23091
  154. // In aot mode, the lifecycle hooks from parent class are not called.
  155. // TODO(tinayuangao): Remove when the angular issue #23091 is fixed
  156. // This is a workaround for https://github.com/angular/angular/issues/23091
  157. // In aot mode, the lifecycle hooks from parent class are not called.
  158. // TODO(tinayuangao): Remove when the angular issue #23091 is fixed
  159. /**
  160. * @return {?}
  161. */
  162. MatNestedTreeNode.prototype.ngAfterContentInit =
  163. // This is a workaround for https://github.com/angular/angular/issues/23091
  164. // In aot mode, the lifecycle hooks from parent class are not called.
  165. // TODO(tinayuangao): Remove when the angular issue #23091 is fixed
  166. /**
  167. * @return {?}
  168. */
  169. function () {
  170. _super.prototype.ngAfterContentInit.call(this);
  171. };
  172. /**
  173. * @return {?}
  174. */
  175. MatNestedTreeNode.prototype.ngOnDestroy = /**
  176. * @return {?}
  177. */
  178. function () {
  179. _super.prototype.ngOnDestroy.call(this);
  180. };
  181. MatNestedTreeNode.decorators = [
  182. { type: core.Directive, args: [{
  183. selector: 'mat-nested-tree-node',
  184. exportAs: 'matNestedTreeNode',
  185. host: {
  186. '[attr.aria-expanded]': 'isExpanded',
  187. '[attr.role]': 'role',
  188. 'class': 'mat-nested-tree-node',
  189. },
  190. providers: [
  191. { provide: tree.CdkNestedTreeNode, useExisting: MatNestedTreeNode },
  192. { provide: tree.CdkTreeNode, useExisting: MatNestedTreeNode },
  193. { provide: tree.CDK_TREE_NODE_OUTLET_NODE, useExisting: MatNestedTreeNode }
  194. ]
  195. },] },
  196. ];
  197. /** @nocollapse */
  198. MatNestedTreeNode.ctorParameters = function () { return [
  199. { type: core.ElementRef },
  200. { type: tree.CdkTree },
  201. { type: core.IterableDiffers },
  202. { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] }
  203. ]; };
  204. MatNestedTreeNode.propDecorators = {
  205. node: [{ type: core.Input, args: ['matNestedTreeNode',] }],
  206. disabled: [{ type: core.Input }],
  207. tabIndex: [{ type: core.Input }]
  208. };
  209. return MatNestedTreeNode;
  210. }(tree.CdkNestedTreeNode));
  211. /**
  212. * @fileoverview added by tsickle
  213. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  214. */
  215. /**
  216. * Wrapper for the CdkTree padding with Material design styles.
  217. * @template T
  218. */
  219. var MatTreeNodePadding = /** @class */ (function (_super) {
  220. __extends(MatTreeNodePadding, _super);
  221. function MatTreeNodePadding() {
  222. return _super !== null && _super.apply(this, arguments) || this;
  223. }
  224. MatTreeNodePadding.decorators = [
  225. { type: core.Directive, args: [{
  226. selector: '[matTreeNodePadding]',
  227. providers: [{ provide: tree.CdkTreeNodePadding, useExisting: MatTreeNodePadding }]
  228. },] },
  229. ];
  230. MatTreeNodePadding.propDecorators = {
  231. level: [{ type: core.Input, args: ['matTreeNodePadding',] }],
  232. indent: [{ type: core.Input, args: ['matTreeNodePaddingIndent',] }]
  233. };
  234. return MatTreeNodePadding;
  235. }(tree.CdkTreeNodePadding));
  236. /**
  237. * @fileoverview added by tsickle
  238. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  239. */
  240. /**
  241. * Outlet for nested CdkNode. Put `[matTreeNodeOutlet]` on a tag to place children dataNodes
  242. * inside the outlet.
  243. */
  244. var MatTreeNodeOutlet = /** @class */ (function () {
  245. function MatTreeNodeOutlet(viewContainer, _node) {
  246. this.viewContainer = viewContainer;
  247. this._node = _node;
  248. }
  249. MatTreeNodeOutlet.decorators = [
  250. { type: core.Directive, args: [{
  251. selector: '[matTreeNodeOutlet]',
  252. providers: [{
  253. provide: tree.CdkTreeNodeOutlet,
  254. useExisting: MatTreeNodeOutlet
  255. }]
  256. },] },
  257. ];
  258. /** @nocollapse */
  259. MatTreeNodeOutlet.ctorParameters = function () { return [
  260. { type: core.ViewContainerRef },
  261. { type: undefined, decorators: [{ type: core.Inject, args: [tree.CDK_TREE_NODE_OUTLET_NODE,] }, { type: core.Optional }] }
  262. ]; };
  263. return MatTreeNodeOutlet;
  264. }());
  265. /**
  266. * @fileoverview added by tsickle
  267. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  268. */
  269. /**
  270. * Wrapper for the CdkTable with Material design styles.
  271. * @template T
  272. */
  273. var MatTree = /** @class */ (function (_super) {
  274. __extends(MatTree, _super);
  275. function MatTree() {
  276. return _super !== null && _super.apply(this, arguments) || this;
  277. }
  278. MatTree.decorators = [
  279. { type: core.Component, args: [{selector: 'mat-tree',
  280. exportAs: 'matTree',
  281. template: "<ng-container matTreeNodeOutlet></ng-container>",
  282. host: {
  283. 'class': 'mat-tree',
  284. 'role': 'tree',
  285. },
  286. styles: [".mat-tree{display:block}.mat-tree-node{display:flex;align-items:center;min-height:48px;flex:1;overflow:hidden;word-wrap:break-word}.mat-nested-tree-ndoe{border-bottom-width:0}"],
  287. encapsulation: core.ViewEncapsulation.None,
  288. // See note on CdkTree for explanation on why this uses the default change detection strategy.
  289. // tslint:disable-next-line:validate-decorators
  290. changeDetection: core.ChangeDetectionStrategy.Default,
  291. providers: [{ provide: tree.CdkTree, useExisting: MatTree }]
  292. },] },
  293. ];
  294. MatTree.propDecorators = {
  295. _nodeOutlet: [{ type: core.ViewChild, args: [MatTreeNodeOutlet, { static: true },] }]
  296. };
  297. return MatTree;
  298. }(tree.CdkTree));
  299. /**
  300. * @fileoverview added by tsickle
  301. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  302. */
  303. /**
  304. * Wrapper for the CdkTree's toggle with Material design styles.
  305. * @template T
  306. */
  307. var MatTreeNodeToggle = /** @class */ (function (_super) {
  308. __extends(MatTreeNodeToggle, _super);
  309. function MatTreeNodeToggle() {
  310. var _this = _super !== null && _super.apply(this, arguments) || this;
  311. _this.recursive = false;
  312. return _this;
  313. }
  314. MatTreeNodeToggle.decorators = [
  315. { type: core.Directive, args: [{
  316. selector: '[matTreeNodeToggle]',
  317. providers: [{ provide: tree.CdkTreeNodeToggle, useExisting: MatTreeNodeToggle }]
  318. },] },
  319. ];
  320. MatTreeNodeToggle.propDecorators = {
  321. recursive: [{ type: core.Input, args: ['matTreeNodeToggleRecursive',] }]
  322. };
  323. return MatTreeNodeToggle;
  324. }(tree.CdkTreeNodeToggle));
  325. /**
  326. * @fileoverview added by tsickle
  327. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  328. */
  329. /** @type {?} */
  330. var MAT_TREE_DIRECTIVES = [
  331. MatNestedTreeNode,
  332. MatTreeNodeDef,
  333. MatTreeNodePadding,
  334. MatTreeNodeToggle,
  335. MatTree,
  336. MatTreeNode,
  337. MatTreeNodeOutlet
  338. ];
  339. var MatTreeModule = /** @class */ (function () {
  340. function MatTreeModule() {
  341. }
  342. MatTreeModule.decorators = [
  343. { type: core.NgModule, args: [{
  344. imports: [tree.CdkTreeModule, common.CommonModule, core$1.MatCommonModule],
  345. exports: MAT_TREE_DIRECTIVES,
  346. declarations: MAT_TREE_DIRECTIVES,
  347. },] },
  348. ];
  349. return MatTreeModule;
  350. }());
  351. /**
  352. * @fileoverview added by tsickle
  353. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  354. */
  355. /**
  356. * Tree flattener to convert a normal type of node to node with children & level information.
  357. * Transform nested nodes of type `T` to flattened nodes of type `F`.
  358. *
  359. * For example, the input data of type `T` is nested, and contains its children data:
  360. * SomeNode: {
  361. * key: 'Fruits',
  362. * children: [
  363. * NodeOne: {
  364. * key: 'Apple',
  365. * },
  366. * NodeTwo: {
  367. * key: 'Pear',
  368. * }
  369. * ]
  370. * }
  371. * After flattener flatten the tree, the structure will become
  372. * SomeNode: {
  373. * key: 'Fruits',
  374. * expandable: true,
  375. * level: 1
  376. * },
  377. * NodeOne: {
  378. * key: 'Apple',
  379. * expandable: false,
  380. * level: 2
  381. * },
  382. * NodeTwo: {
  383. * key: 'Pear',
  384. * expandable: false,
  385. * level: 2
  386. * }
  387. * and the output flattened type is `F` with additional information.
  388. * @template T, F
  389. */
  390. var /**
  391. * Tree flattener to convert a normal type of node to node with children & level information.
  392. * Transform nested nodes of type `T` to flattened nodes of type `F`.
  393. *
  394. * For example, the input data of type `T` is nested, and contains its children data:
  395. * SomeNode: {
  396. * key: 'Fruits',
  397. * children: [
  398. * NodeOne: {
  399. * key: 'Apple',
  400. * },
  401. * NodeTwo: {
  402. * key: 'Pear',
  403. * }
  404. * ]
  405. * }
  406. * After flattener flatten the tree, the structure will become
  407. * SomeNode: {
  408. * key: 'Fruits',
  409. * expandable: true,
  410. * level: 1
  411. * },
  412. * NodeOne: {
  413. * key: 'Apple',
  414. * expandable: false,
  415. * level: 2
  416. * },
  417. * NodeTwo: {
  418. * key: 'Pear',
  419. * expandable: false,
  420. * level: 2
  421. * }
  422. * and the output flattened type is `F` with additional information.
  423. * @template T, F
  424. */
  425. MatTreeFlattener = /** @class */ (function () {
  426. function MatTreeFlattener(transformFunction, getLevel, isExpandable, getChildren) {
  427. this.transformFunction = transformFunction;
  428. this.getLevel = getLevel;
  429. this.isExpandable = isExpandable;
  430. this.getChildren = getChildren;
  431. }
  432. /**
  433. * @param {?} node
  434. * @param {?} level
  435. * @param {?} resultNodes
  436. * @param {?} parentMap
  437. * @return {?}
  438. */
  439. MatTreeFlattener.prototype._flattenNode = /**
  440. * @param {?} node
  441. * @param {?} level
  442. * @param {?} resultNodes
  443. * @param {?} parentMap
  444. * @return {?}
  445. */
  446. function (node, level, resultNodes, parentMap) {
  447. var _this = this;
  448. /** @type {?} */
  449. var flatNode = this.transformFunction(node, level);
  450. resultNodes.push(flatNode);
  451. if (this.isExpandable(flatNode)) {
  452. /** @type {?} */
  453. var childrenNodes = this.getChildren(node);
  454. if (childrenNodes) {
  455. if (Array.isArray(childrenNodes)) {
  456. this._flattenChildren(childrenNodes, level, resultNodes, parentMap);
  457. }
  458. else {
  459. childrenNodes.pipe(operators.take(1)).subscribe((/**
  460. * @param {?} children
  461. * @return {?}
  462. */
  463. function (children) {
  464. _this._flattenChildren(children, level, resultNodes, parentMap);
  465. }));
  466. }
  467. }
  468. }
  469. return resultNodes;
  470. };
  471. /**
  472. * @param {?} children
  473. * @param {?} level
  474. * @param {?} resultNodes
  475. * @param {?} parentMap
  476. * @return {?}
  477. */
  478. MatTreeFlattener.prototype._flattenChildren = /**
  479. * @param {?} children
  480. * @param {?} level
  481. * @param {?} resultNodes
  482. * @param {?} parentMap
  483. * @return {?}
  484. */
  485. function (children, level, resultNodes, parentMap) {
  486. var _this = this;
  487. children.forEach((/**
  488. * @param {?} child
  489. * @param {?} index
  490. * @return {?}
  491. */
  492. function (child, index) {
  493. /** @type {?} */
  494. var childParentMap = parentMap.slice();
  495. childParentMap.push(index != children.length - 1);
  496. _this._flattenNode(child, level + 1, resultNodes, childParentMap);
  497. }));
  498. };
  499. /**
  500. * Flatten a list of node type T to flattened version of node F.
  501. * Please note that type T may be nested, and the length of `structuredData` may be different
  502. * from that of returned list `F[]`.
  503. */
  504. /**
  505. * Flatten a list of node type T to flattened version of node F.
  506. * Please note that type T may be nested, and the length of `structuredData` may be different
  507. * from that of returned list `F[]`.
  508. * @param {?} structuredData
  509. * @return {?}
  510. */
  511. MatTreeFlattener.prototype.flattenNodes = /**
  512. * Flatten a list of node type T to flattened version of node F.
  513. * Please note that type T may be nested, and the length of `structuredData` may be different
  514. * from that of returned list `F[]`.
  515. * @param {?} structuredData
  516. * @return {?}
  517. */
  518. function (structuredData) {
  519. var _this = this;
  520. /** @type {?} */
  521. var resultNodes = [];
  522. structuredData.forEach((/**
  523. * @param {?} node
  524. * @return {?}
  525. */
  526. function (node) { return _this._flattenNode(node, 0, resultNodes, []); }));
  527. return resultNodes;
  528. };
  529. /**
  530. * Expand flattened node with current expansion status.
  531. * The returned list may have different length.
  532. */
  533. /**
  534. * Expand flattened node with current expansion status.
  535. * The returned list may have different length.
  536. * @param {?} nodes
  537. * @param {?} treeControl
  538. * @return {?}
  539. */
  540. MatTreeFlattener.prototype.expandFlattenedNodes = /**
  541. * Expand flattened node with current expansion status.
  542. * The returned list may have different length.
  543. * @param {?} nodes
  544. * @param {?} treeControl
  545. * @return {?}
  546. */
  547. function (nodes, treeControl) {
  548. var _this = this;
  549. /** @type {?} */
  550. var results = [];
  551. /** @type {?} */
  552. var currentExpand = [];
  553. currentExpand[0] = true;
  554. nodes.forEach((/**
  555. * @param {?} node
  556. * @return {?}
  557. */
  558. function (node) {
  559. /** @type {?} */
  560. var expand = true;
  561. for (var i = 0; i <= _this.getLevel(node); i++) {
  562. expand = expand && currentExpand[i];
  563. }
  564. if (expand) {
  565. results.push(node);
  566. }
  567. if (_this.isExpandable(node)) {
  568. currentExpand[_this.getLevel(node) + 1] = treeControl.isExpanded(node);
  569. }
  570. }));
  571. return results;
  572. };
  573. return MatTreeFlattener;
  574. }());
  575. /**
  576. * Data source for flat tree.
  577. * The data source need to handle expansion/collapsion of the tree node and change the data feed
  578. * to `MatTree`.
  579. * The nested tree nodes of type `T` are flattened through `MatTreeFlattener`, and converted
  580. * to type `F` for `MatTree` to consume.
  581. * @template T, F
  582. */
  583. var /**
  584. * Data source for flat tree.
  585. * The data source need to handle expansion/collapsion of the tree node and change the data feed
  586. * to `MatTree`.
  587. * The nested tree nodes of type `T` are flattened through `MatTreeFlattener`, and converted
  588. * to type `F` for `MatTree` to consume.
  589. * @template T, F
  590. */
  591. MatTreeFlatDataSource = /** @class */ (function (_super) {
  592. __extends(MatTreeFlatDataSource, _super);
  593. function MatTreeFlatDataSource(_treeControl, _treeFlattener, initialData) {
  594. if (initialData === void 0) { initialData = []; }
  595. var _this = _super.call(this) || this;
  596. _this._treeControl = _treeControl;
  597. _this._treeFlattener = _treeFlattener;
  598. _this._flattenedData = new rxjs.BehaviorSubject([]);
  599. _this._expandedData = new rxjs.BehaviorSubject([]);
  600. _this._data = new rxjs.BehaviorSubject(initialData);
  601. return _this;
  602. }
  603. Object.defineProperty(MatTreeFlatDataSource.prototype, "data", {
  604. get: /**
  605. * @return {?}
  606. */
  607. function () { return this._data.value; },
  608. set: /**
  609. * @param {?} value
  610. * @return {?}
  611. */
  612. function (value) {
  613. this._data.next(value);
  614. this._flattenedData.next(this._treeFlattener.flattenNodes(this.data));
  615. this._treeControl.dataNodes = this._flattenedData.value;
  616. },
  617. enumerable: true,
  618. configurable: true
  619. });
  620. /**
  621. * @param {?} collectionViewer
  622. * @return {?}
  623. */
  624. MatTreeFlatDataSource.prototype.connect = /**
  625. * @param {?} collectionViewer
  626. * @return {?}
  627. */
  628. function (collectionViewer) {
  629. var _this = this;
  630. /** @type {?} */
  631. var changes = [
  632. collectionViewer.viewChange,
  633. this._treeControl.expansionModel.onChange,
  634. this._flattenedData
  635. ];
  636. return rxjs.merge.apply(void 0, changes).pipe(operators.map((/**
  637. * @return {?}
  638. */
  639. function () {
  640. _this._expandedData.next(_this._treeFlattener.expandFlattenedNodes(_this._flattenedData.value, _this._treeControl));
  641. return _this._expandedData.value;
  642. })));
  643. };
  644. /**
  645. * @return {?}
  646. */
  647. MatTreeFlatDataSource.prototype.disconnect = /**
  648. * @return {?}
  649. */
  650. function () {
  651. // no op
  652. };
  653. return MatTreeFlatDataSource;
  654. }(collections.DataSource));
  655. /**
  656. * @fileoverview added by tsickle
  657. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  658. */
  659. /**
  660. * Data source for nested tree.
  661. *
  662. * The data source for nested tree doesn't have to consider node flattener, or the way to expand
  663. * or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
  664. * @template T
  665. */
  666. var /**
  667. * Data source for nested tree.
  668. *
  669. * The data source for nested tree doesn't have to consider node flattener, or the way to expand
  670. * or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
  671. * @template T
  672. */
  673. MatTreeNestedDataSource = /** @class */ (function (_super) {
  674. __extends(MatTreeNestedDataSource, _super);
  675. function MatTreeNestedDataSource() {
  676. var _this = _super !== null && _super.apply(this, arguments) || this;
  677. _this._data = new rxjs.BehaviorSubject([]);
  678. return _this;
  679. }
  680. Object.defineProperty(MatTreeNestedDataSource.prototype, "data", {
  681. /**
  682. * Data for the nested tree
  683. */
  684. get: /**
  685. * Data for the nested tree
  686. * @return {?}
  687. */
  688. function () { return this._data.value; },
  689. set: /**
  690. * @param {?} value
  691. * @return {?}
  692. */
  693. function (value) { this._data.next(value); },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. /**
  698. * @param {?} collectionViewer
  699. * @return {?}
  700. */
  701. MatTreeNestedDataSource.prototype.connect = /**
  702. * @param {?} collectionViewer
  703. * @return {?}
  704. */
  705. function (collectionViewer) {
  706. var _this = this;
  707. return rxjs.merge.apply(void 0, [collectionViewer.viewChange, this._data]).pipe(operators.map((/**
  708. * @return {?}
  709. */
  710. function () {
  711. return _this.data;
  712. })));
  713. };
  714. /**
  715. * @return {?}
  716. */
  717. MatTreeNestedDataSource.prototype.disconnect = /**
  718. * @return {?}
  719. */
  720. function () {
  721. // no op
  722. };
  723. return MatTreeNestedDataSource;
  724. }(collections.DataSource));
  725. exports.MatTreeNode = MatTreeNode;
  726. exports.MatTreeNodeDef = MatTreeNodeDef;
  727. exports.MatNestedTreeNode = MatNestedTreeNode;
  728. exports.MatTreeNodePadding = MatTreeNodePadding;
  729. exports.MatTree = MatTree;
  730. exports.MatTreeModule = MatTreeModule;
  731. exports.MatTreeNodeToggle = MatTreeNodeToggle;
  732. exports.MatTreeNodeOutlet = MatTreeNodeOutlet;
  733. exports.MatTreeFlattener = MatTreeFlattener;
  734. exports.MatTreeFlatDataSource = MatTreeFlatDataSource;
  735. exports.MatTreeNestedDataSource = MatTreeNestedDataSource;
  736. Object.defineProperty(exports, '__esModule', { value: true });
  737. })));
  738. //# sourceMappingURL=material-tree.umd.js.map