source: trip-planner-front/node_modules/@angular/cdk/bundles/cdk-tree.umd.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 59.4 KB
Line 
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/collections'), require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/cdk/coercion'), require('@angular/cdk/bidi')) :
3 typeof define === 'function' && define.amd ? define('@angular/cdk/tree', ['exports', '@angular/cdk/collections', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/cdk/coercion', '@angular/cdk/bidi'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.tree = {}), global.ng.cdk.collections, global.rxjs, global.rxjs.operators, global.ng.core, global.ng.cdk.coercion, global.ng.cdk.bidi));
5}(this, (function (exports, collections, rxjs, operators, core, coercion, bidi) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation.
9
10 Permission to use, copy, modify, and/or distribute this software for any
11 purpose with or without fee is hereby granted.
12
13 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22 var extendStatics = function (d, b) {
23 extendStatics = Object.setPrototypeOf ||
24 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25 function (d, b) { for (var p in b)
26 if (Object.prototype.hasOwnProperty.call(b, p))
27 d[p] = b[p]; };
28 return extendStatics(d, b);
29 };
30 function __extends(d, b) {
31 if (typeof b !== "function" && b !== null)
32 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33 extendStatics(d, b);
34 function __() { this.constructor = d; }
35 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36 }
37 var __assign = function () {
38 __assign = Object.assign || function __assign(t) {
39 for (var s, i = 1, n = arguments.length; i < n; i++) {
40 s = arguments[i];
41 for (var p in s)
42 if (Object.prototype.hasOwnProperty.call(s, p))
43 t[p] = s[p];
44 }
45 return t;
46 };
47 return __assign.apply(this, arguments);
48 };
49 function __rest(s, e) {
50 var t = {};
51 for (var p in s)
52 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53 t[p] = s[p];
54 if (s != null && typeof Object.getOwnPropertySymbols === "function")
55 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57 t[p[i]] = s[p[i]];
58 }
59 return t;
60 }
61 function __decorate(decorators, target, key, desc) {
62 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64 r = Reflect.decorate(decorators, target, key, desc);
65 else
66 for (var i = decorators.length - 1; i >= 0; i--)
67 if (d = decorators[i])
68 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71 function __param(paramIndex, decorator) {
72 return function (target, key) { decorator(target, key, paramIndex); };
73 }
74 function __metadata(metadataKey, metadataValue) {
75 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76 return Reflect.metadata(metadataKey, metadataValue);
77 }
78 function __awaiter(thisArg, _arguments, P, generator) {
79 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80 return new (P || (P = Promise))(function (resolve, reject) {
81 function fulfilled(value) { try {
82 step(generator.next(value));
83 }
84 catch (e) {
85 reject(e);
86 } }
87 function rejected(value) { try {
88 step(generator["throw"](value));
89 }
90 catch (e) {
91 reject(e);
92 } }
93 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94 step((generator = generator.apply(thisArg, _arguments || [])).next());
95 });
96 }
97 function __generator(thisArg, body) {
98 var _ = { label: 0, sent: function () { if (t[0] & 1)
99 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
100 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
101 function verb(n) { return function (v) { return step([n, v]); }; }
102 function step(op) {
103 if (f)
104 throw new TypeError("Generator is already executing.");
105 while (_)
106 try {
107 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
108 return t;
109 if (y = 0, t)
110 op = [op[0] & 2, t.value];
111 switch (op[0]) {
112 case 0:
113 case 1:
114 t = op;
115 break;
116 case 4:
117 _.label++;
118 return { value: op[1], done: false };
119 case 5:
120 _.label++;
121 y = op[1];
122 op = [0];
123 continue;
124 case 7:
125 op = _.ops.pop();
126 _.trys.pop();
127 continue;
128 default:
129 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130 _ = 0;
131 continue;
132 }
133 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
134 _.label = op[1];
135 break;
136 }
137 if (op[0] === 6 && _.label < t[1]) {
138 _.label = t[1];
139 t = op;
140 break;
141 }
142 if (t && _.label < t[2]) {
143 _.label = t[2];
144 _.ops.push(op);
145 break;
146 }
147 if (t[2])
148 _.ops.pop();
149 _.trys.pop();
150 continue;
151 }
152 op = body.call(thisArg, _);
153 }
154 catch (e) {
155 op = [6, e];
156 y = 0;
157 }
158 finally {
159 f = t = 0;
160 }
161 if (op[0] & 5)
162 throw op[1];
163 return { value: op[0] ? op[1] : void 0, done: true };
164 }
165 }
166 var __createBinding = Object.create ? (function (o, m, k, k2) {
167 if (k2 === undefined)
168 k2 = k;
169 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
170 }) : (function (o, m, k, k2) {
171 if (k2 === undefined)
172 k2 = k;
173 o[k2] = m[k];
174 });
175 function __exportStar(m, o) {
176 for (var p in m)
177 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
178 __createBinding(o, m, p);
179 }
180 function __values(o) {
181 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
182 if (m)
183 return m.call(o);
184 if (o && typeof o.length === "number")
185 return {
186 next: function () {
187 if (o && i >= o.length)
188 o = void 0;
189 return { value: o && o[i++], done: !o };
190 }
191 };
192 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
193 }
194 function __read(o, n) {
195 var m = typeof Symbol === "function" && o[Symbol.iterator];
196 if (!m)
197 return o;
198 var i = m.call(o), r, ar = [], e;
199 try {
200 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
201 ar.push(r.value);
202 }
203 catch (error) {
204 e = { error: error };
205 }
206 finally {
207 try {
208 if (r && !r.done && (m = i["return"]))
209 m.call(i);
210 }
211 finally {
212 if (e)
213 throw e.error;
214 }
215 }
216 return ar;
217 }
218 /** @deprecated */
219 function __spread() {
220 for (var ar = [], i = 0; i < arguments.length; i++)
221 ar = ar.concat(__read(arguments[i]));
222 return ar;
223 }
224 /** @deprecated */
225 function __spreadArrays() {
226 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
227 s += arguments[i].length;
228 for (var r = Array(s), k = 0, i = 0; i < il; i++)
229 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
230 r[k] = a[j];
231 return r;
232 }
233 function __spreadArray(to, from, pack) {
234 if (pack || arguments.length === 2)
235 for (var i = 0, l = from.length, ar; i < l; i++) {
236 if (ar || !(i in from)) {
237 if (!ar)
238 ar = Array.prototype.slice.call(from, 0, i);
239 ar[i] = from[i];
240 }
241 }
242 return to.concat(ar || from);
243 }
244 function __await(v) {
245 return this instanceof __await ? (this.v = v, this) : new __await(v);
246 }
247 function __asyncGenerator(thisArg, _arguments, generator) {
248 if (!Symbol.asyncIterator)
249 throw new TypeError("Symbol.asyncIterator is not defined.");
250 var g = generator.apply(thisArg, _arguments || []), i, q = [];
251 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
252 function verb(n) { if (g[n])
253 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
254 function resume(n, v) { try {
255 step(g[n](v));
256 }
257 catch (e) {
258 settle(q[0][3], e);
259 } }
260 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
261 function fulfill(value) { resume("next", value); }
262 function reject(value) { resume("throw", value); }
263 function settle(f, v) { if (f(v), q.shift(), q.length)
264 resume(q[0][0], q[0][1]); }
265 }
266 function __asyncDelegator(o) {
267 var i, p;
268 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
269 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
270 }
271 function __asyncValues(o) {
272 if (!Symbol.asyncIterator)
273 throw new TypeError("Symbol.asyncIterator is not defined.");
274 var m = o[Symbol.asyncIterator], i;
275 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
276 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
277 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
278 }
279 function __makeTemplateObject(cooked, raw) {
280 if (Object.defineProperty) {
281 Object.defineProperty(cooked, "raw", { value: raw });
282 }
283 else {
284 cooked.raw = raw;
285 }
286 return cooked;
287 }
288 ;
289 var __setModuleDefault = Object.create ? (function (o, v) {
290 Object.defineProperty(o, "default", { enumerable: true, value: v });
291 }) : function (o, v) {
292 o["default"] = v;
293 };
294 function __importStar(mod) {
295 if (mod && mod.__esModule)
296 return mod;
297 var result = {};
298 if (mod != null)
299 for (var k in mod)
300 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
301 __createBinding(result, mod, k);
302 __setModuleDefault(result, mod);
303 return result;
304 }
305 function __importDefault(mod) {
306 return (mod && mod.__esModule) ? mod : { default: mod };
307 }
308 function __classPrivateFieldGet(receiver, state, kind, f) {
309 if (kind === "a" && !f)
310 throw new TypeError("Private accessor was defined without a getter");
311 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
312 throw new TypeError("Cannot read private member from an object whose class did not declare it");
313 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
314 }
315 function __classPrivateFieldSet(receiver, state, value, kind, f) {
316 if (kind === "m")
317 throw new TypeError("Private method is not writable");
318 if (kind === "a" && !f)
319 throw new TypeError("Private accessor was defined without a setter");
320 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
321 throw new TypeError("Cannot write private member to an object whose class did not declare it");
322 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
323 }
324
325 /** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
326 var BaseTreeControl = /** @class */ (function () {
327 function BaseTreeControl() {
328 /** A selection model with multi-selection to track expansion status. */
329 this.expansionModel = new collections.SelectionModel(true);
330 }
331 /** Toggles one single data node's expanded/collapsed state. */
332 BaseTreeControl.prototype.toggle = function (dataNode) {
333 this.expansionModel.toggle(this._trackByValue(dataNode));
334 };
335 /** Expands one single data node. */
336 BaseTreeControl.prototype.expand = function (dataNode) {
337 this.expansionModel.select(this._trackByValue(dataNode));
338 };
339 /** Collapses one single data node. */
340 BaseTreeControl.prototype.collapse = function (dataNode) {
341 this.expansionModel.deselect(this._trackByValue(dataNode));
342 };
343 /** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
344 BaseTreeControl.prototype.isExpanded = function (dataNode) {
345 return this.expansionModel.isSelected(this._trackByValue(dataNode));
346 };
347 /** Toggles a subtree rooted at `node` recursively. */
348 BaseTreeControl.prototype.toggleDescendants = function (dataNode) {
349 this.expansionModel.isSelected(this._trackByValue(dataNode)) ?
350 this.collapseDescendants(dataNode) :
351 this.expandDescendants(dataNode);
352 };
353 /** Collapse all dataNodes in the tree. */
354 BaseTreeControl.prototype.collapseAll = function () {
355 this.expansionModel.clear();
356 };
357 /** Expands a subtree rooted at given data node recursively. */
358 BaseTreeControl.prototype.expandDescendants = function (dataNode) {
359 var _a;
360 var _this = this;
361 var toBeProcessed = [dataNode];
362 toBeProcessed.push.apply(toBeProcessed, __spreadArray([], __read(this.getDescendants(dataNode))));
363 (_a = this.expansionModel).select.apply(_a, __spreadArray([], __read(toBeProcessed.map(function (value) { return _this._trackByValue(value); }))));
364 };
365 /** Collapses a subtree rooted at given data node recursively. */
366 BaseTreeControl.prototype.collapseDescendants = function (dataNode) {
367 var _a;
368 var _this = this;
369 var toBeProcessed = [dataNode];
370 toBeProcessed.push.apply(toBeProcessed, __spreadArray([], __read(this.getDescendants(dataNode))));
371 (_a = this.expansionModel).deselect.apply(_a, __spreadArray([], __read(toBeProcessed.map(function (value) { return _this._trackByValue(value); }))));
372 };
373 BaseTreeControl.prototype._trackByValue = function (value) {
374 return this.trackBy ? this.trackBy(value) : value;
375 };
376 return BaseTreeControl;
377 }());
378
379 /** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */
380 var FlatTreeControl = /** @class */ (function (_super) {
381 __extends(FlatTreeControl, _super);
382 /** Construct with flat tree data node functions getLevel and isExpandable. */
383 function FlatTreeControl(getLevel, isExpandable, options) {
384 var _this = _super.call(this) || this;
385 _this.getLevel = getLevel;
386 _this.isExpandable = isExpandable;
387 _this.options = options;
388 if (_this.options) {
389 _this.trackBy = _this.options.trackBy;
390 }
391 return _this;
392 }
393 /**
394 * Gets a list of the data node's subtree of descendent data nodes.
395 *
396 * To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
397 * with correct levels.
398 */
399 FlatTreeControl.prototype.getDescendants = function (dataNode) {
400 var startIndex = this.dataNodes.indexOf(dataNode);
401 var results = [];
402 // Goes through flattened tree nodes in the `dataNodes` array, and get all descendants.
403 // The level of descendants of a tree node must be greater than the level of the given
404 // tree node.
405 // If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
406 // If we reach a node whose level is greater than the level of the tree node, we hit a
407 // sibling of an ancestor.
408 for (var i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
409 results.push(this.dataNodes[i]);
410 }
411 return results;
412 };
413 /**
414 * Expands all data nodes in the tree.
415 *
416 * To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
417 * data nodes of the tree.
418 */
419 FlatTreeControl.prototype.expandAll = function () {
420 var _a;
421 var _this = this;
422 (_a = this.expansionModel).select.apply(_a, __spreadArray([], __read(this.dataNodes.map(function (node) { return _this._trackByValue(node); }))));
423 };
424 return FlatTreeControl;
425 }(BaseTreeControl));
426
427 /** Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type. */
428 var NestedTreeControl = /** @class */ (function (_super) {
429 __extends(NestedTreeControl, _super);
430 /** Construct with nested tree function getChildren. */
431 function NestedTreeControl(getChildren, options) {
432 var _this = _super.call(this) || this;
433 _this.getChildren = getChildren;
434 _this.options = options;
435 if (_this.options) {
436 _this.trackBy = _this.options.trackBy;
437 }
438 return _this;
439 }
440 /**
441 * Expands all dataNodes in the tree.
442 *
443 * To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
444 * data nodes of the tree.
445 */
446 NestedTreeControl.prototype.expandAll = function () {
447 var _a;
448 var _this = this;
449 this.expansionModel.clear();
450 var allNodes = this.dataNodes.reduce(function (accumulator, dataNode) { return __spreadArray(__spreadArray(__spreadArray([], __read(accumulator)), __read(_this.getDescendants(dataNode))), [dataNode]); }, []);
451 (_a = this.expansionModel).select.apply(_a, __spreadArray([], __read(allNodes.map(function (node) { return _this._trackByValue(node); }))));
452 };
453 /** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
454 NestedTreeControl.prototype.getDescendants = function (dataNode) {
455 var descendants = [];
456 this._getDescendants(descendants, dataNode);
457 // Remove the node itself
458 return descendants.splice(1);
459 };
460 /** A helper function to get descendants recursively. */
461 NestedTreeControl.prototype._getDescendants = function (descendants, dataNode) {
462 var _this = this;
463 descendants.push(dataNode);
464 var childrenNodes = this.getChildren(dataNode);
465 if (Array.isArray(childrenNodes)) {
466 childrenNodes.forEach(function (child) { return _this._getDescendants(descendants, child); });
467 }
468 else if (rxjs.isObservable(childrenNodes)) {
469 // TypeScript as of version 3.5 doesn't seem to treat `Boolean` like a function that
470 // returns a `boolean` specifically in the context of `filter`, so we manually clarify that.
471 childrenNodes.pipe(operators.take(1), operators.filter(Boolean))
472 .subscribe(function (children) {
473 var e_1, _a;
474 try {
475 for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
476 var child = children_1_1.value;
477 _this._getDescendants(descendants, child);
478 }
479 }
480 catch (e_1_1) { e_1 = { error: e_1_1 }; }
481 finally {
482 try {
483 if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
484 }
485 finally { if (e_1) throw e_1.error; }
486 }
487 });
488 }
489 };
490 return NestedTreeControl;
491 }(BaseTreeControl));
492
493 /**
494 * @license
495 * Copyright Google LLC All Rights Reserved.
496 *
497 * Use of this source code is governed by an MIT-style license that can be
498 * found in the LICENSE file at https://angular.io/license
499 */
500 /**
501 * Injection token used to provide a `CdkTreeNode` to its outlet.
502 * Used primarily to avoid circular imports.
503 * @docs-private
504 */
505 var CDK_TREE_NODE_OUTLET_NODE = new core.InjectionToken('CDK_TREE_NODE_OUTLET_NODE');
506 /**
507 * Outlet for nested CdkNode. Put `[cdkTreeNodeOutlet]` on a tag to place children dataNodes
508 * inside the outlet.
509 */
510 var CdkTreeNodeOutlet = /** @class */ (function () {
511 function CdkTreeNodeOutlet(viewContainer, _node) {
512 this.viewContainer = viewContainer;
513 this._node = _node;
514 }
515 return CdkTreeNodeOutlet;
516 }());
517 CdkTreeNodeOutlet.decorators = [
518 { type: core.Directive, args: [{
519 selector: '[cdkTreeNodeOutlet]'
520 },] }
521 ];
522 CdkTreeNodeOutlet.ctorParameters = function () { return [
523 { type: core.ViewContainerRef },
524 { type: undefined, decorators: [{ type: core.Inject, args: [CDK_TREE_NODE_OUTLET_NODE,] }, { type: core.Optional }] }
525 ]; };
526
527 /**
528 * @license
529 * Copyright Google LLC All Rights Reserved.
530 *
531 * Use of this source code is governed by an MIT-style license that can be
532 * found in the LICENSE file at https://angular.io/license
533 */
534 /** Context provided to the tree node component. */
535 var CdkTreeNodeOutletContext = /** @class */ (function () {
536 function CdkTreeNodeOutletContext(data) {
537 this.$implicit = data;
538 }
539 return CdkTreeNodeOutletContext;
540 }());
541 /**
542 * Data node definition for the CdkTree.
543 * Captures the node's template and a when predicate that describes when this node should be used.
544 */
545 var CdkTreeNodeDef = /** @class */ (function () {
546 /** @docs-private */
547 function CdkTreeNodeDef(template) {
548 this.template = template;
549 }
550 return CdkTreeNodeDef;
551 }());
552 CdkTreeNodeDef.decorators = [
553 { type: core.Directive, args: [{
554 selector: '[cdkTreeNodeDef]',
555 inputs: [
556 'when: cdkTreeNodeDefWhen'
557 ],
558 },] }
559 ];
560 CdkTreeNodeDef.ctorParameters = function () { return [
561 { type: core.TemplateRef }
562 ]; };
563
564 /**
565 * @license
566 * Copyright Google LLC All Rights Reserved.
567 *
568 * Use of this source code is governed by an MIT-style license that can be
569 * found in the LICENSE file at https://angular.io/license
570 */
571 /**
572 * Returns an error to be thrown when there is no usable data.
573 * @docs-private
574 */
575 function getTreeNoValidDataSourceError() {
576 return Error("A valid data source must be provided.");
577 }
578 /**
579 * Returns an error to be thrown when there are multiple nodes that are missing a when function.
580 * @docs-private
581 */
582 function getTreeMultipleDefaultNodeDefsError() {
583 return Error("There can only be one default row without a when predicate function.");
584 }
585 /**
586 * Returns an error to be thrown when there are no matching node defs for a particular set of data.
587 * @docs-private
588 */
589 function getTreeMissingMatchingNodeDefError() {
590 return Error("Could not find a matching node definition for the provided node data.");
591 }
592 /**
593 * Returns an error to be thrown when there are tree control.
594 * @docs-private
595 */
596 function getTreeControlMissingError() {
597 return Error("Could not find a tree control for the tree.");
598 }
599 /**
600 * Returns an error to be thrown when tree control did not implement functions for flat/nested node.
601 * @docs-private
602 */
603 function getTreeControlFunctionsMissingError() {
604 return Error("Could not find functions for nested/flat tree in tree control.");
605 }
606
607 /**
608 * CDK tree component that connects with a data source to retrieve data of type `T` and renders
609 * dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
610 */
611 var CdkTree = /** @class */ (function () {
612 function CdkTree(_differs, _changeDetectorRef) {
613 this._differs = _differs;
614 this._changeDetectorRef = _changeDetectorRef;
615 /** Subject that emits when the component has been destroyed. */
616 this._onDestroy = new rxjs.Subject();
617 /** Level of nodes */
618 this._levels = new Map();
619 // TODO(tinayuangao): Setup a listener for scrolling, emit the calculated view to viewChange.
620 // Remove the MAX_VALUE in viewChange
621 /**
622 * Stream containing the latest information on what rows are being displayed on screen.
623 * Can be used by the data source to as a heuristic of what data should be provided.
624 */
625 this.viewChange = new rxjs.BehaviorSubject({ start: 0, end: Number.MAX_VALUE });
626 }
627 Object.defineProperty(CdkTree.prototype, "dataSource", {
628 /**
629 * Provides a stream containing the latest data array to render. Influenced by the tree's
630 * stream of view window (what dataNodes are currently on screen).
631 * Data source can be an observable of data array, or a data array to render.
632 */
633 get: function () { return this._dataSource; },
634 set: function (dataSource) {
635 if (this._dataSource !== dataSource) {
636 this._switchDataSource(dataSource);
637 }
638 },
639 enumerable: false,
640 configurable: true
641 });
642 CdkTree.prototype.ngOnInit = function () {
643 this._dataDiffer = this._differs.find([]).create(this.trackBy);
644 if (!this.treeControl && (typeof ngDevMode === 'undefined' || ngDevMode)) {
645 throw getTreeControlMissingError();
646 }
647 };
648 CdkTree.prototype.ngOnDestroy = function () {
649 this._nodeOutlet.viewContainer.clear();
650 this.viewChange.complete();
651 this._onDestroy.next();
652 this._onDestroy.complete();
653 if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
654 this.dataSource.disconnect(this);
655 }
656 if (this._dataSubscription) {
657 this._dataSubscription.unsubscribe();
658 this._dataSubscription = null;
659 }
660 };
661 CdkTree.prototype.ngAfterContentChecked = function () {
662 var defaultNodeDefs = this._nodeDefs.filter(function (def) { return !def.when; });
663 if (defaultNodeDefs.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
664 throw getTreeMultipleDefaultNodeDefsError();
665 }
666 this._defaultNodeDef = defaultNodeDefs[0];
667 if (this.dataSource && this._nodeDefs && !this._dataSubscription) {
668 this._observeRenderChanges();
669 }
670 };
671 // TODO(tinayuangao): Work on keyboard traversal and actions, make sure it's working for RTL
672 // and nested trees.
673 /**
674 * Switch to the provided data source by resetting the data and unsubscribing from the current
675 * render change subscription if one exists. If the data source is null, interpret this by
676 * clearing the node outlet. Otherwise start listening for new data.
677 */
678 CdkTree.prototype._switchDataSource = function (dataSource) {
679 if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
680 this.dataSource.disconnect(this);
681 }
682 if (this._dataSubscription) {
683 this._dataSubscription.unsubscribe();
684 this._dataSubscription = null;
685 }
686 // Remove the all dataNodes if there is now no data source
687 if (!dataSource) {
688 this._nodeOutlet.viewContainer.clear();
689 }
690 this._dataSource = dataSource;
691 if (this._nodeDefs) {
692 this._observeRenderChanges();
693 }
694 };
695 /** Set up a subscription for the data provided by the data source. */
696 CdkTree.prototype._observeRenderChanges = function () {
697 var _this = this;
698 var dataStream;
699 if (collections.isDataSource(this._dataSource)) {
700 dataStream = this._dataSource.connect(this);
701 }
702 else if (rxjs.isObservable(this._dataSource)) {
703 dataStream = this._dataSource;
704 }
705 else if (Array.isArray(this._dataSource)) {
706 dataStream = rxjs.of(this._dataSource);
707 }
708 if (dataStream) {
709 this._dataSubscription = dataStream.pipe(operators.takeUntil(this._onDestroy))
710 .subscribe(function (data) { return _this.renderNodeChanges(data); });
711 }
712 else if (typeof ngDevMode === 'undefined' || ngDevMode) {
713 throw getTreeNoValidDataSourceError();
714 }
715 };
716 /** Check for changes made in the data and render each change (node added/removed/moved). */
717 CdkTree.prototype.renderNodeChanges = function (data, dataDiffer, viewContainer, parentData) {
718 var _this = this;
719 if (dataDiffer === void 0) { dataDiffer = this._dataDiffer; }
720 if (viewContainer === void 0) { viewContainer = this._nodeOutlet.viewContainer; }
721 var changes = dataDiffer.diff(data);
722 if (!changes) {
723 return;
724 }
725 changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
726 if (item.previousIndex == null) {
727 _this.insertNode(data[currentIndex], currentIndex, viewContainer, parentData);
728 }
729 else if (currentIndex == null) {
730 viewContainer.remove(adjustedPreviousIndex);
731 _this._levels.delete(item.item);
732 }
733 else {
734 var view = viewContainer.get(adjustedPreviousIndex);
735 viewContainer.move(view, currentIndex);
736 }
737 });
738 this._changeDetectorRef.detectChanges();
739 };
740 /**
741 * Finds the matching node definition that should be used for this node data. If there is only
742 * one node definition, it is returned. Otherwise, find the node definition that has a when
743 * predicate that returns true with the data. If none return true, return the default node
744 * definition.
745 */
746 CdkTree.prototype._getNodeDef = function (data, i) {
747 if (this._nodeDefs.length === 1) {
748 return this._nodeDefs.first;
749 }
750 var nodeDef = this._nodeDefs.find(function (def) { return def.when && def.when(i, data); }) || this._defaultNodeDef;
751 if (!nodeDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
752 throw getTreeMissingMatchingNodeDefError();
753 }
754 return nodeDef;
755 };
756 /**
757 * Create the embedded view for the data node template and place it in the correct index location
758 * within the data node view container.
759 */
760 CdkTree.prototype.insertNode = function (nodeData, index, viewContainer, parentData) {
761 var node = this._getNodeDef(nodeData, index);
762 // Node context that will be provided to created embedded view
763 var context = new CdkTreeNodeOutletContext(nodeData);
764 // If the tree is flat tree, then use the `getLevel` function in flat tree control
765 // Otherwise, use the level of parent node.
766 if (this.treeControl.getLevel) {
767 context.level = this.treeControl.getLevel(nodeData);
768 }
769 else if (typeof parentData !== 'undefined' && this._levels.has(parentData)) {
770 context.level = this._levels.get(parentData) + 1;
771 }
772 else {
773 context.level = 0;
774 }
775 this._levels.set(nodeData, context.level);
776 // Use default tree nodeOutlet, or nested node's nodeOutlet
777 var container = viewContainer ? viewContainer : this._nodeOutlet.viewContainer;
778 container.createEmbeddedView(node.template, context, index);
779 // Set the data to just created `CdkTreeNode`.
780 // The `CdkTreeNode` created from `createEmbeddedView` will be saved in static variable
781 // `mostRecentTreeNode`. We get it from static variable and pass the node data to it.
782 if (CdkTreeNode.mostRecentTreeNode) {
783 CdkTreeNode.mostRecentTreeNode.data = nodeData;
784 }
785 };
786 return CdkTree;
787 }());
788 CdkTree.decorators = [
789 { type: core.Component, args: [{
790 selector: 'cdk-tree',
791 exportAs: 'cdkTree',
792 template: "<ng-container cdkTreeNodeOutlet></ng-container>",
793 host: {
794 'class': 'cdk-tree',
795 'role': 'tree',
796 },
797 encapsulation: core.ViewEncapsulation.None,
798 // The "OnPush" status for the `CdkTree` component is effectively a noop, so we are removing it.
799 // The view for `CdkTree` consists entirely of templates declared in other views. As they are
800 // declared elsewhere, they are checked when their declaration points are checked.
801 // tslint:disable-next-line:validate-decorators
802 changeDetection: core.ChangeDetectionStrategy.Default
803 },] }
804 ];
805 CdkTree.ctorParameters = function () { return [
806 { type: core.IterableDiffers },
807 { type: core.ChangeDetectorRef }
808 ]; };
809 CdkTree.propDecorators = {
810 dataSource: [{ type: core.Input }],
811 treeControl: [{ type: core.Input }],
812 trackBy: [{ type: core.Input }],
813 _nodeOutlet: [{ type: core.ViewChild, args: [CdkTreeNodeOutlet, { static: true },] }],
814 _nodeDefs: [{ type: core.ContentChildren, args: [CdkTreeNodeDef, {
815 // We need to use `descendants: true`, because Ivy will no longer match
816 // indirect descendants if it's left as false.
817 descendants: true
818 },] }]
819 };
820 /**
821 * Tree node for CdkTree. It contains the data in the tree node.
822 */
823 var CdkTreeNode = /** @class */ (function () {
824 function CdkTreeNode(_elementRef, _tree) {
825 this._elementRef = _elementRef;
826 this._tree = _tree;
827 /** Subject that emits when the component has been destroyed. */
828 this._destroyed = new rxjs.Subject();
829 /** Emits when the node's data has changed. */
830 this._dataChanges = new rxjs.Subject();
831 CdkTreeNode.mostRecentTreeNode = this;
832 // The classes are directly added here instead of in the host property because classes on
833 // the host property are not inherited with View Engine. It is not set as a @HostBinding because
834 // it is not set by the time it's children nodes try to read the class from it.
835 // TODO: move to host after View Engine deprecation
836 this._elementRef.nativeElement.classList.add('cdk-tree-node');
837 this.role = 'treeitem';
838 }
839 Object.defineProperty(CdkTreeNode.prototype, "role", {
840 /**
841 * The role of the tree node.
842 * @deprecated The correct role is 'treeitem', 'group' should not be used. This input will be
843 * removed in a future version.
844 * @breaking-change 12.0.0 Remove this input
845 */
846 get: function () { return 'treeitem'; },
847 set: function (_role) {
848 // TODO: move to host after View Engine deprecation
849 this._elementRef.nativeElement.setAttribute('role', _role);
850 },
851 enumerable: false,
852 configurable: true
853 });
854 Object.defineProperty(CdkTreeNode.prototype, "data", {
855 /** The tree node's data. */
856 get: function () { return this._data; },
857 set: function (value) {
858 if (value !== this._data) {
859 this._data = value;
860 this._setRoleFromData();
861 this._dataChanges.next();
862 }
863 },
864 enumerable: false,
865 configurable: true
866 });
867 Object.defineProperty(CdkTreeNode.prototype, "isExpanded", {
868 get: function () {
869 return this._tree.treeControl.isExpanded(this._data);
870 },
871 enumerable: false,
872 configurable: true
873 });
874 CdkTreeNode.prototype._setExpanded = function (_expanded) {
875 this._isAriaExpanded = _expanded;
876 this._elementRef.nativeElement.setAttribute('aria-expanded', "" + _expanded);
877 };
878 Object.defineProperty(CdkTreeNode.prototype, "level", {
879 get: function () {
880 // If the treeControl has a getLevel method, use it to get the level. Otherwise read the
881 // aria-level off the parent node and use it as the level for this node (note aria-level is
882 // 1-indexed, while this property is 0-indexed, so we don't need to increment).
883 return this._tree.treeControl.getLevel ?
884 this._tree.treeControl.getLevel(this._data) : this._parentNodeAriaLevel;
885 },
886 enumerable: false,
887 configurable: true
888 });
889 CdkTreeNode.prototype.ngOnInit = function () {
890 this._parentNodeAriaLevel = getParentNodeAriaLevel(this._elementRef.nativeElement);
891 this._elementRef.nativeElement.setAttribute('aria-level', "" + (this.level + 1));
892 };
893 CdkTreeNode.prototype.ngDoCheck = function () {
894 // aria-expanded is be set here because the expanded state is stored in the tree control and
895 // the node isn't aware when the state is changed.
896 // It is not set using a @HostBinding because they sometimes get lost with Mixin based classes.
897 // TODO: move to host after View Engine deprecation
898 if (this.isExpanded != this._isAriaExpanded) {
899 this._setExpanded(this.isExpanded);
900 }
901 };
902 CdkTreeNode.prototype.ngOnDestroy = function () {
903 // If this is the last tree node being destroyed,
904 // clear out the reference to avoid leaking memory.
905 if (CdkTreeNode.mostRecentTreeNode === this) {
906 CdkTreeNode.mostRecentTreeNode = null;
907 }
908 this._dataChanges.complete();
909 this._destroyed.next();
910 this._destroyed.complete();
911 };
912 /** Focuses the menu item. Implements for FocusableOption. */
913 CdkTreeNode.prototype.focus = function () {
914 this._elementRef.nativeElement.focus();
915 };
916 // TODO: role should eventually just be set in the component host
917 CdkTreeNode.prototype._setRoleFromData = function () {
918 if (!this._tree.treeControl.isExpandable && !this._tree.treeControl.getChildren &&
919 (typeof ngDevMode === 'undefined' || ngDevMode)) {
920 throw getTreeControlFunctionsMissingError();
921 }
922 this.role = 'treeitem';
923 };
924 return CdkTreeNode;
925 }());
926 /**
927 * The most recently created `CdkTreeNode`. We save it in static variable so we can retrieve it
928 * in `CdkTree` and set the data to it.
929 */
930 CdkTreeNode.mostRecentTreeNode = null;
931 CdkTreeNode.decorators = [
932 { type: core.Directive, args: [{
933 selector: 'cdk-tree-node',
934 exportAs: 'cdkTreeNode',
935 },] }
936 ];
937 CdkTreeNode.ctorParameters = function () { return [
938 { type: core.ElementRef },
939 { type: CdkTree }
940 ]; };
941 CdkTreeNode.propDecorators = {
942 role: [{ type: core.Input }]
943 };
944 function getParentNodeAriaLevel(nodeElement) {
945 var parent = nodeElement.parentElement;
946 while (parent && !isNodeElement(parent)) {
947 parent = parent.parentElement;
948 }
949 if (!parent) {
950 if (typeof ngDevMode === 'undefined' || ngDevMode) {
951 throw Error('Incorrect tree structure containing detached node.');
952 }
953 else {
954 return -1;
955 }
956 }
957 else if (parent.classList.contains('cdk-nested-tree-node')) {
958 return coercion.coerceNumberProperty(parent.getAttribute('aria-level'));
959 }
960 else {
961 // The ancestor element is the cdk-tree itself
962 return 0;
963 }
964 }
965 function isNodeElement(element) {
966 var classList = element.classList;
967 return !!((classList === null || classList === void 0 ? void 0 : classList.contains('cdk-nested-tree-node')) || (classList === null || classList === void 0 ? void 0 : classList.contains('cdk-tree')));
968 }
969
970 /**
971 * Nested node is a child of `<cdk-tree>`. It works with nested tree.
972 * By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
973 * be added in the `cdkTreeNodeOutlet` in tree node template.
974 * The children of node will be automatically added to `cdkTreeNodeOutlet`.
975 */
976 var CdkNestedTreeNode = /** @class */ (function (_super) {
977 __extends(CdkNestedTreeNode, _super);
978 function CdkNestedTreeNode(elementRef, tree, _differs) {
979 var _this = _super.call(this, elementRef, tree) || this;
980 _this._differs = _differs;
981 // The classes are directly added here instead of in the host property because classes on
982 // the host property are not inherited with View Engine. It is not set as a @HostBinding because
983 // it is not set by the time it's children nodes try to read the class from it.
984 // TODO: move to host after View Engine deprecation
985 elementRef.nativeElement.classList.add('cdk-nested-tree-node');
986 return _this;
987 }
988 CdkNestedTreeNode.prototype.ngAfterContentInit = function () {
989 var _this = this;
990 this._dataDiffer = this._differs.find([]).create(this._tree.trackBy);
991 if (!this._tree.treeControl.getChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) {
992 throw getTreeControlFunctionsMissingError();
993 }
994 var childrenNodes = this._tree.treeControl.getChildren(this.data);
995 if (Array.isArray(childrenNodes)) {
996 this.updateChildrenNodes(childrenNodes);
997 }
998 else if (rxjs.isObservable(childrenNodes)) {
999 childrenNodes.pipe(operators.takeUntil(this._destroyed))
1000 .subscribe(function (result) { return _this.updateChildrenNodes(result); });
1001 }
1002 this.nodeOutlet.changes.pipe(operators.takeUntil(this._destroyed))
1003 .subscribe(function () { return _this.updateChildrenNodes(); });
1004 };
1005 // This is a workaround for https://github.com/angular/angular/issues/23091
1006 // In aot mode, the lifecycle hooks from parent class are not called.
1007 CdkNestedTreeNode.prototype.ngOnInit = function () {
1008 _super.prototype.ngOnInit.call(this);
1009 };
1010 CdkNestedTreeNode.prototype.ngDoCheck = function () {
1011 _super.prototype.ngDoCheck.call(this);
1012 };
1013 CdkNestedTreeNode.prototype.ngOnDestroy = function () {
1014 this._clear();
1015 _super.prototype.ngOnDestroy.call(this);
1016 };
1017 /** Add children dataNodes to the NodeOutlet */
1018 CdkNestedTreeNode.prototype.updateChildrenNodes = function (children) {
1019 var outlet = this._getNodeOutlet();
1020 if (children) {
1021 this._children = children;
1022 }
1023 if (outlet && this._children) {
1024 var viewContainer = outlet.viewContainer;
1025 this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
1026 }
1027 else {
1028 // Reset the data differ if there's no children nodes displayed
1029 this._dataDiffer.diff([]);
1030 }
1031 };
1032 /** Clear the children dataNodes. */
1033 CdkNestedTreeNode.prototype._clear = function () {
1034 var outlet = this._getNodeOutlet();
1035 if (outlet) {
1036 outlet.viewContainer.clear();
1037 this._dataDiffer.diff([]);
1038 }
1039 };
1040 /** Gets the outlet for the current node. */
1041 CdkNestedTreeNode.prototype._getNodeOutlet = function () {
1042 var _this = this;
1043 var outlets = this.nodeOutlet;
1044 // Note that since we use `descendants: true` on the query, we have to ensure
1045 // that we don't pick up the outlet of a child node by accident.
1046 return outlets && outlets.find(function (outlet) { return !outlet._node || outlet._node === _this; });
1047 };
1048 return CdkNestedTreeNode;
1049 }(CdkTreeNode));
1050 CdkNestedTreeNode.decorators = [
1051 { type: core.Directive, args: [{
1052 selector: 'cdk-nested-tree-node',
1053 exportAs: 'cdkNestedTreeNode',
1054 inputs: ['role', 'disabled', 'tabIndex'],
1055 providers: [
1056 { provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
1057 { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode }
1058 ]
1059 },] }
1060 ];
1061 CdkNestedTreeNode.ctorParameters = function () { return [
1062 { type: core.ElementRef },
1063 { type: CdkTree },
1064 { type: core.IterableDiffers }
1065 ]; };
1066 CdkNestedTreeNode.propDecorators = {
1067 nodeOutlet: [{ type: core.ContentChildren, args: [CdkTreeNodeOutlet, {
1068 // We need to use `descendants: true`, because Ivy will no longer match
1069 // indirect descendants if it's left as false.
1070 descendants: true
1071 },] }]
1072 };
1073
1074 /**
1075 * @license
1076 * Copyright Google LLC All Rights Reserved.
1077 *
1078 * Use of this source code is governed by an MIT-style license that can be
1079 * found in the LICENSE file at https://angular.io/license
1080 */
1081 /** Regex used to split a string on its CSS units. */
1082 var cssUnitPattern = /([A-Za-z%]+)$/;
1083 /**
1084 * Indent for the children tree dataNodes.
1085 * This directive will add left-padding to the node to show hierarchy.
1086 */
1087 var CdkTreeNodePadding = /** @class */ (function () {
1088 function CdkTreeNodePadding(_treeNode, _tree, _element, _dir) {
1089 var _this = this;
1090 this._treeNode = _treeNode;
1091 this._tree = _tree;
1092 this._element = _element;
1093 this._dir = _dir;
1094 /** Subject that emits when the component has been destroyed. */
1095 this._destroyed = new rxjs.Subject();
1096 /** CSS units used for the indentation value. */
1097 this.indentUnits = 'px';
1098 this._indent = 40;
1099 this._setPadding();
1100 if (_dir) {
1101 _dir.change.pipe(operators.takeUntil(this._destroyed)).subscribe(function () { return _this._setPadding(true); });
1102 }
1103 // In Ivy the indentation binding might be set before the tree node's data has been added,
1104 // which means that we'll miss the first render. We have to subscribe to changes in the
1105 // data to ensure that everything is up to date.
1106 _treeNode._dataChanges.subscribe(function () { return _this._setPadding(); });
1107 }
1108 Object.defineProperty(CdkTreeNodePadding.prototype, "level", {
1109 /** The level of depth of the tree node. The padding will be `level * indent` pixels. */
1110 get: function () { return this._level; },
1111 set: function (value) { this._setLevelInput(value); },
1112 enumerable: false,
1113 configurable: true
1114 });
1115 Object.defineProperty(CdkTreeNodePadding.prototype, "indent", {
1116 /**
1117 * The indent for each level. Can be a number or a CSS string.
1118 * Default number 40px from material design menu sub-menu spec.
1119 */
1120 get: function () { return this._indent; },
1121 set: function (indent) { this._setIndentInput(indent); },
1122 enumerable: false,
1123 configurable: true
1124 });
1125 CdkTreeNodePadding.prototype.ngOnDestroy = function () {
1126 this._destroyed.next();
1127 this._destroyed.complete();
1128 };
1129 /** The padding indent value for the tree node. Returns a string with px numbers if not null. */
1130 CdkTreeNodePadding.prototype._paddingIndent = function () {
1131 var nodeLevel = (this._treeNode.data && this._tree.treeControl.getLevel)
1132 ? this._tree.treeControl.getLevel(this._treeNode.data)
1133 : null;
1134 var level = this._level == null ? nodeLevel : this._level;
1135 return typeof level === 'number' ? "" + level * this._indent + this.indentUnits : null;
1136 };
1137 CdkTreeNodePadding.prototype._setPadding = function (forceChange) {
1138 if (forceChange === void 0) { forceChange = false; }
1139 var padding = this._paddingIndent();
1140 if (padding !== this._currentPadding || forceChange) {
1141 var element = this._element.nativeElement;
1142 var paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
1143 var resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingLeft';
1144 element.style[paddingProp] = padding || '';
1145 element.style[resetProp] = '';
1146 this._currentPadding = padding;
1147 }
1148 };
1149 /**
1150 * This has been extracted to a util because of TS 4 and VE.
1151 * View Engine doesn't support property rename inheritance.
1152 * TS 4.0 doesn't allow properties to override accessors or vice-versa.
1153 * @docs-private
1154 */
1155 CdkTreeNodePadding.prototype._setLevelInput = function (value) {
1156 // Set to null as the fallback value so that _setPadding can fall back to the node level if the
1157 // consumer set the directive as `cdkTreeNodePadding=""`. We still want to take this value if
1158 // they set 0 explicitly.
1159 this._level = coercion.coerceNumberProperty(value, null);
1160 this._setPadding();
1161 };
1162 /**
1163 * This has been extracted to a util because of TS 4 and VE.
1164 * View Engine doesn't support property rename inheritance.
1165 * TS 4.0 doesn't allow properties to override accessors or vice-versa.
1166 * @docs-private
1167 */
1168 CdkTreeNodePadding.prototype._setIndentInput = function (indent) {
1169 var value = indent;
1170 var units = 'px';
1171 if (typeof indent === 'string') {
1172 var parts = indent.split(cssUnitPattern);
1173 value = parts[0];
1174 units = parts[1] || units;
1175 }
1176 this.indentUnits = units;
1177 this._indent = coercion.coerceNumberProperty(value);
1178 this._setPadding();
1179 };
1180 return CdkTreeNodePadding;
1181 }());
1182 CdkTreeNodePadding.decorators = [
1183 { type: core.Directive, args: [{
1184 selector: '[cdkTreeNodePadding]',
1185 },] }
1186 ];
1187 CdkTreeNodePadding.ctorParameters = function () { return [
1188 { type: CdkTreeNode },
1189 { type: CdkTree },
1190 { type: core.ElementRef },
1191 { type: bidi.Directionality, decorators: [{ type: core.Optional }] }
1192 ]; };
1193 CdkTreeNodePadding.propDecorators = {
1194 level: [{ type: core.Input, args: ['cdkTreeNodePadding',] }],
1195 indent: [{ type: core.Input, args: ['cdkTreeNodePaddingIndent',] }]
1196 };
1197
1198 /**
1199 * @license
1200 * Copyright Google LLC All Rights Reserved.
1201 *
1202 * Use of this source code is governed by an MIT-style license that can be
1203 * found in the LICENSE file at https://angular.io/license
1204 */
1205 /**
1206 * Node toggle to expand/collapse the node.
1207 */
1208 var CdkTreeNodeToggle = /** @class */ (function () {
1209 function CdkTreeNodeToggle(_tree, _treeNode) {
1210 this._tree = _tree;
1211 this._treeNode = _treeNode;
1212 this._recursive = false;
1213 }
1214 Object.defineProperty(CdkTreeNodeToggle.prototype, "recursive", {
1215 /** Whether expand/collapse the node recursively. */
1216 get: function () { return this._recursive; },
1217 set: function (value) { this._recursive = coercion.coerceBooleanProperty(value); },
1218 enumerable: false,
1219 configurable: true
1220 });
1221 // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
1222 // In Ivy the `host` bindings will be merged when this class is extended, whereas in
1223 // ViewEngine they're overwritten.
1224 // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
1225 // tslint:disable-next-line:no-host-decorator-in-concrete
1226 CdkTreeNodeToggle.prototype._toggle = function (event) {
1227 this.recursive
1228 ? this._tree.treeControl.toggleDescendants(this._treeNode.data)
1229 : this._tree.treeControl.toggle(this._treeNode.data);
1230 event.stopPropagation();
1231 };
1232 return CdkTreeNodeToggle;
1233 }());
1234 CdkTreeNodeToggle.decorators = [
1235 { type: core.Directive, args: [{ selector: '[cdkTreeNodeToggle]' },] }
1236 ];
1237 CdkTreeNodeToggle.ctorParameters = function () { return [
1238 { type: CdkTree },
1239 { type: CdkTreeNode }
1240 ]; };
1241 CdkTreeNodeToggle.propDecorators = {
1242 recursive: [{ type: core.Input, args: ['cdkTreeNodeToggleRecursive',] }],
1243 _toggle: [{ type: core.HostListener, args: ['click', ['$event'],] }]
1244 };
1245
1246 /**
1247 * @license
1248 * Copyright Google LLC All Rights Reserved.
1249 *
1250 * Use of this source code is governed by an MIT-style license that can be
1251 * found in the LICENSE file at https://angular.io/license
1252 */
1253 var EXPORTED_DECLARATIONS = [
1254 CdkNestedTreeNode,
1255 CdkTreeNodeDef,
1256 CdkTreeNodePadding,
1257 CdkTreeNodeToggle,
1258 CdkTree,
1259 CdkTreeNode,
1260 CdkTreeNodeOutlet,
1261 ];
1262 var CdkTreeModule = /** @class */ (function () {
1263 function CdkTreeModule() {
1264 }
1265 return CdkTreeModule;
1266 }());
1267 CdkTreeModule.decorators = [
1268 { type: core.NgModule, args: [{
1269 exports: EXPORTED_DECLARATIONS,
1270 declarations: EXPORTED_DECLARATIONS,
1271 },] }
1272 ];
1273
1274 /**
1275 * @license
1276 * Copyright Google LLC All Rights Reserved.
1277 *
1278 * Use of this source code is governed by an MIT-style license that can be
1279 * found in the LICENSE file at https://angular.io/license
1280 */
1281
1282 /**
1283 * Generated bundle index. Do not edit.
1284 */
1285
1286 exports.BaseTreeControl = BaseTreeControl;
1287 exports.CDK_TREE_NODE_OUTLET_NODE = CDK_TREE_NODE_OUTLET_NODE;
1288 exports.CdkNestedTreeNode = CdkNestedTreeNode;
1289 exports.CdkTree = CdkTree;
1290 exports.CdkTreeModule = CdkTreeModule;
1291 exports.CdkTreeNode = CdkTreeNode;
1292 exports.CdkTreeNodeDef = CdkTreeNodeDef;
1293 exports.CdkTreeNodeOutlet = CdkTreeNodeOutlet;
1294 exports.CdkTreeNodeOutletContext = CdkTreeNodeOutletContext;
1295 exports.CdkTreeNodePadding = CdkTreeNodePadding;
1296 exports.CdkTreeNodeToggle = CdkTreeNodeToggle;
1297 exports.FlatTreeControl = FlatTreeControl;
1298 exports.NestedTreeControl = NestedTreeControl;
1299 exports.getTreeControlFunctionsMissingError = getTreeControlFunctionsMissingError;
1300 exports.getTreeControlMissingError = getTreeControlMissingError;
1301 exports.getTreeMissingMatchingNodeDefError = getTreeMissingMatchingNodeDefError;
1302 exports.getTreeMultipleDefaultNodeDefsError = getTreeMultipleDefaultNodeDefsError;
1303 exports.getTreeNoValidDataSourceError = getTreeNoValidDataSourceError;
1304
1305 Object.defineProperty(exports, '__esModule', { value: true });
1306
1307})));
1308//# sourceMappingURL=cdk-tree.umd.js.map
Note: See TracBrowser for help on using the repository browser.