tree.es5.js 24 KB

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