@dugararchit/cdk 0.0.0-dugararchit

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/_index.scss +8 -0
  2. package/a11y/_index.import.scss +2 -0
  3. package/a11y/_index.scss +102 -0
  4. package/a11y/a11y-prebuilt.scss +3 -0
  5. package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
  6. package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
  7. package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
  8. package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
  9. package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
  10. package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
  11. package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
  12. package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
  13. package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
  14. package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
  15. package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
  16. package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
  17. package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
  18. package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
  19. package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
  20. package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
  21. package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
  22. package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
  23. package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
  24. package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
  25. package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
  26. package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
  27. package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
  28. package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
  29. package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
  30. package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
  31. package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
  32. package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
  33. package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
  34. package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
  35. package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
  36. package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
  37. package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
  38. package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
  39. package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
  40. package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
  41. package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
  42. package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
  43. package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
  44. package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
  45. package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
  46. package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
  47. package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
  48. package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
  49. package/fesm2022/stagefright5-cdk.mjs +26 -0
  50. package/fesm2022/stagefright5-cdk.mjs.map +1 -0
  51. package/overlay/_index-deprecated.scss +13 -0
  52. package/overlay/_index.import.scss +13 -0
  53. package/overlay/_index.scss +148 -0
  54. package/overlay/overlay-prebuilt.scss +3 -0
  55. package/package.json +159 -0
  56. package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
  57. package/schematics/schematics/BUILD.bazel +104 -0
  58. package/schematics/schematics/README.md +4 -0
  59. package/schematics/schematics/collection.json +18 -0
  60. package/schematics/schematics/index.ts +22 -0
  61. package/schematics/schematics/migration.json +50 -0
  62. package/schematics/schematics/ng-add/index.spec.ts +50 -0
  63. package/schematics/schematics/ng-add/index.ts +39 -0
  64. package/schematics/schematics/ng-add/package-config.ts +62 -0
  65. package/schematics/schematics/ng-add/schema.json +16 -0
  66. package/schematics/schematics/ng-add/schema.ts +12 -0
  67. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
  68. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
  69. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
  70. package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
  71. package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
  72. package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
  73. package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
  74. package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
  75. package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
  76. package/schematics/schematics/ng-update/data/class-names.ts +50 -0
  77. package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
  78. package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
  79. package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
  80. package/schematics/schematics/ng-update/data/index.ts +18 -0
  81. package/schematics/schematics/ng-update/data/input-names.ts +118 -0
  82. package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
  83. package/schematics/schematics/ng-update/data/output-names.ts +42 -0
  84. package/schematics/schematics/ng-update/data/property-names.ts +151 -0
  85. package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
  86. package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
  87. package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
  88. package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
  89. package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
  90. package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
  91. package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
  92. package/schematics/schematics/ng-update/index.ts +113 -0
  93. package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
  94. package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
  95. package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
  96. package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
  97. package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
  98. package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
  99. package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
  100. package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
  101. package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
  102. package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
  103. package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
  104. package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
  105. package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
  106. package/schematics/schematics/ng-update/public-api.ts +18 -0
  107. package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
  108. package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
  109. package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
  110. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
  111. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
  112. package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
  113. package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
  114. package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
  115. package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
  116. package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
  117. package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
  118. package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
  119. package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
  120. package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
  121. package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
  122. package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
  123. package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
  124. package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
  125. package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
  126. package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
  127. package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
  128. package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
  129. package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
  130. package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
  131. package/schematics/schematics/ng-update/update-schematic.md +209 -0
  132. package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
  133. package/schematics/schematics/paths.ts +15 -0
  134. package/schematics/schematics/testing/BUILD.bazel +27 -0
  135. package/schematics/schematics/testing/file-content.ts +20 -0
  136. package/schematics/schematics/testing/index.ts +14 -0
  137. package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
  138. package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
  139. package/schematics/schematics/testing/test-app.ts +21 -0
  140. package/schematics/schematics/testing/test-case-setup.ts +236 -0
  141. package/schematics/schematics/testing/test-library.ts +21 -0
  142. package/schematics/schematics/testing/test-project.ts +40 -0
  143. package/schematics/schematics/testing/tsconfig.json +7 -0
  144. package/schematics/schematics/tsconfig.json +28 -0
  145. package/schematics/schematics/update-tool/BUILD.bazel +19 -0
  146. package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
  147. package/schematics/schematics/update-tool/file-system.ts +78 -0
  148. package/schematics/schematics/update-tool/index.ts +191 -0
  149. package/schematics/schematics/update-tool/logger.ts +23 -0
  150. package/schematics/schematics/update-tool/migration.ts +88 -0
  151. package/schematics/schematics/update-tool/public-api.ts +16 -0
  152. package/schematics/schematics/update-tool/target-version.ts +31 -0
  153. package/schematics/schematics/update-tool/tsconfig.json +7 -0
  154. package/schematics/schematics/update-tool/update-recorder.ts +14 -0
  155. package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
  156. package/schematics/schematics/update-tool/utils/functions.ts +18 -0
  157. package/schematics/schematics/update-tool/utils/imports.ts +128 -0
  158. package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
  159. package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
  160. package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
  161. package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
  162. package/schematics/schematics/update-tool/version-changes.ts +49 -0
  163. package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
  164. package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
  165. package/schematics/schematics/utils/ast.ts +88 -0
  166. package/schematics/schematics/utils/build-component.ts +252 -0
  167. package/schematics/schematics/utils/get-project.ts +27 -0
  168. package/schematics/schematics/utils/html-manipulation.ts +105 -0
  169. package/schematics/schematics/utils/index.ts +19 -0
  170. package/schematics/schematics/utils/parse5-element.ts +34 -0
  171. package/schematics/schematics/utils/project-index-file.ts +21 -0
  172. package/schematics/schematics/utils/project-main-file.ts +26 -0
  173. package/schematics/schematics/utils/project-style-file.ts +53 -0
  174. package/schematics/schematics/utils/project-targets.ts +43 -0
  175. package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
  176. package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
  177. package/schematics/schematics/utils/schematic-options.ts +65 -0
  178. package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
  179. package/scrolling/virtual-scroll-viewport.scss +87 -0
  180. package/table/table.scss +3 -0
  181. package/text-field/_index.import.scss +2 -0
  182. package/text-field/_index.scss +89 -0
  183. package/text-field/text-field-prebuilt.scss +4 -0
  184. package/types/stagefright5-cdk-a11y.d.ts +1160 -0
  185. package/types/stagefright5-cdk-accordion.d.ts +95 -0
  186. package/types/stagefright5-cdk-bidi.d.ts +95 -0
  187. package/types/stagefright5-cdk-clipboard.d.ts +116 -0
  188. package/types/stagefright5-cdk-coercion.d.ts +101 -0
  189. package/types/stagefright5-cdk-collections.d.ts +405 -0
  190. package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
  191. package/types/stagefright5-cdk-keycodes.d.ts +142 -0
  192. package/types/stagefright5-cdk-layout.d.ts +96 -0
  193. package/types/stagefright5-cdk-observers.d.ts +91 -0
  194. package/types/stagefright5-cdk-overlay.d.ts +1258 -0
  195. package/types/stagefright5-cdk-platform.d.ts +130 -0
  196. package/types/stagefright5-cdk-portal.d.ts +327 -0
  197. package/types/stagefright5-cdk-scrolling.d.ts +631 -0
  198. package/types/stagefright5-cdk-stepper.d.ts +302 -0
  199. package/types/stagefright5-cdk-table.d.ts +1128 -0
  200. package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
  201. package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
  202. package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
  203. package/types/stagefright5-cdk-testing.d.ts +735 -0
  204. package/types/stagefright5-cdk-text-field.d.ts +171 -0
  205. package/types/stagefright5-cdk-tree.d.ts +522 -0
  206. package/types/stagefright5-cdk.d.ts +14 -0
@@ -0,0 +1,945 @@
1
+ import { SelectionModel, isDataSource } from '@dugararchit/cdk/collections';
2
+ import { isObservable, Subject, BehaviorSubject, of } from 'rxjs';
3
+ import { take, filter, takeUntil } from 'rxjs/operators';
4
+ import * as i0 from '@angular/core';
5
+ import { InjectionToken, Inject, Optional, Directive, ContentChildren, ViewChild, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
6
+ import { coerceNumberProperty, coerceBooleanProperty } from '@dugararchit/cdk/coercion';
7
+ import * as i2 from '@dugararchit/cdk/bidi';
8
+
9
+ /**
10
+ * @license
11
+ * Copyright Google LLC All Rights Reserved.
12
+ *
13
+ * Use of this source code is governed by an MIT-style license that can be
14
+ * found in the LICENSE file at https://angular.io/license
15
+ */
16
+ /** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
17
+ class BaseTreeControl {
18
+ constructor() {
19
+ /** A selection model with multi-selection to track expansion status. */
20
+ this.expansionModel = new SelectionModel(true);
21
+ }
22
+ /** Toggles one single data node's expanded/collapsed state. */
23
+ toggle(dataNode) {
24
+ this.expansionModel.toggle(this._trackByValue(dataNode));
25
+ }
26
+ /** Expands one single data node. */
27
+ expand(dataNode) {
28
+ this.expansionModel.select(this._trackByValue(dataNode));
29
+ }
30
+ /** Collapses one single data node. */
31
+ collapse(dataNode) {
32
+ this.expansionModel.deselect(this._trackByValue(dataNode));
33
+ }
34
+ /** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
35
+ isExpanded(dataNode) {
36
+ return this.expansionModel.isSelected(this._trackByValue(dataNode));
37
+ }
38
+ /** Toggles a subtree rooted at `node` recursively. */
39
+ toggleDescendants(dataNode) {
40
+ this.expansionModel.isSelected(this._trackByValue(dataNode))
41
+ ? this.collapseDescendants(dataNode)
42
+ : this.expandDescendants(dataNode);
43
+ }
44
+ /** Collapse all dataNodes in the tree. */
45
+ collapseAll() {
46
+ this.expansionModel.clear();
47
+ }
48
+ /** Expands a subtree rooted at given data node recursively. */
49
+ expandDescendants(dataNode) {
50
+ let toBeProcessed = [dataNode];
51
+ toBeProcessed.push(...this.getDescendants(dataNode));
52
+ this.expansionModel.select(...toBeProcessed.map(value => this._trackByValue(value)));
53
+ }
54
+ /** Collapses a subtree rooted at given data node recursively. */
55
+ collapseDescendants(dataNode) {
56
+ let toBeProcessed = [dataNode];
57
+ toBeProcessed.push(...this.getDescendants(dataNode));
58
+ this.expansionModel.deselect(...toBeProcessed.map(value => this._trackByValue(value)));
59
+ }
60
+ _trackByValue(value) {
61
+ return this.trackBy ? this.trackBy(value) : value;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @license
67
+ * Copyright Google LLC All Rights Reserved.
68
+ *
69
+ * Use of this source code is governed by an MIT-style license that can be
70
+ * found in the LICENSE file at https://angular.io/license
71
+ */
72
+ /** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */
73
+ class FlatTreeControl extends BaseTreeControl {
74
+ /** Construct with flat tree data node functions getLevel and isExpandable. */
75
+ constructor(getLevel, isExpandable, options) {
76
+ super();
77
+ this.getLevel = getLevel;
78
+ this.isExpandable = isExpandable;
79
+ this.options = options;
80
+ if (this.options) {
81
+ this.trackBy = this.options.trackBy;
82
+ }
83
+ }
84
+ /**
85
+ * Gets a list of the data node's subtree of descendent data nodes.
86
+ *
87
+ * To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
88
+ * with correct levels.
89
+ */
90
+ getDescendants(dataNode) {
91
+ const startIndex = this.dataNodes.indexOf(dataNode);
92
+ const results = [];
93
+ // Goes through flattened tree nodes in the `dataNodes` array, and get all descendants.
94
+ // The level of descendants of a tree node must be greater than the level of the given
95
+ // tree node.
96
+ // If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
97
+ // If we reach a node whose level is greater than the level of the tree node, we hit a
98
+ // sibling of an ancestor.
99
+ for (let i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
100
+ results.push(this.dataNodes[i]);
101
+ }
102
+ return results;
103
+ }
104
+ /**
105
+ * Expands all data nodes in the tree.
106
+ *
107
+ * To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
108
+ * data nodes of the tree.
109
+ */
110
+ expandAll() {
111
+ this.expansionModel.select(...this.dataNodes.map(node => this._trackByValue(node)));
112
+ }
113
+ }
114
+
115
+ /**
116
+ * @license
117
+ * Copyright Google LLC All Rights Reserved.
118
+ *
119
+ * Use of this source code is governed by an MIT-style license that can be
120
+ * found in the LICENSE file at https://angular.io/license
121
+ */
122
+ /** Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type. */
123
+ class NestedTreeControl extends BaseTreeControl {
124
+ /** Construct with nested tree function getChildren. */
125
+ constructor(getChildren, options) {
126
+ super();
127
+ this.getChildren = getChildren;
128
+ this.options = options;
129
+ if (this.options) {
130
+ this.trackBy = this.options.trackBy;
131
+ }
132
+ }
133
+ /**
134
+ * Expands all dataNodes in the tree.
135
+ *
136
+ * To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
137
+ * data nodes of the tree.
138
+ */
139
+ expandAll() {
140
+ this.expansionModel.clear();
141
+ const allNodes = this.dataNodes.reduce((accumulator, dataNode) => [...accumulator, ...this.getDescendants(dataNode), dataNode], []);
142
+ this.expansionModel.select(...allNodes.map(node => this._trackByValue(node)));
143
+ }
144
+ /** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
145
+ getDescendants(dataNode) {
146
+ const descendants = [];
147
+ this._getDescendants(descendants, dataNode);
148
+ // Remove the node itself
149
+ return descendants.splice(1);
150
+ }
151
+ /** A helper function to get descendants recursively. */
152
+ _getDescendants(descendants, dataNode) {
153
+ descendants.push(dataNode);
154
+ const childrenNodes = this.getChildren(dataNode);
155
+ if (Array.isArray(childrenNodes)) {
156
+ childrenNodes.forEach((child) => this._getDescendants(descendants, child));
157
+ }
158
+ else if (isObservable(childrenNodes)) {
159
+ // TypeScript as of version 3.5 doesn't seem to treat `Boolean` like a function that
160
+ // returns a `boolean` specifically in the context of `filter`, so we manually clarify that.
161
+ childrenNodes.pipe(take(1), filter(Boolean)).subscribe(children => {
162
+ for (const child of children) {
163
+ this._getDescendants(descendants, child);
164
+ }
165
+ });
166
+ }
167
+ }
168
+ }
169
+
170
+ /**
171
+ * @license
172
+ * Copyright Google LLC All Rights Reserved.
173
+ *
174
+ * Use of this source code is governed by an MIT-style license that can be
175
+ * found in the LICENSE file at https://angular.io/license
176
+ */
177
+ /**
178
+ * Injection token used to provide a `CdkTreeNode` to its outlet.
179
+ * Used primarily to avoid circular imports.
180
+ * @docs-private
181
+ */
182
+ const CDK_TREE_NODE_OUTLET_NODE = new InjectionToken('CDK_TREE_NODE_OUTLET_NODE');
183
+ /**
184
+ * Outlet for nested CdkNode. Put `[cdkTreeNodeOutlet]` on a tag to place children dataNodes
185
+ * inside the outlet.
186
+ */
187
+ class CdkTreeNodeOutlet {
188
+ constructor(viewContainer, _node) {
189
+ this.viewContainer = viewContainer;
190
+ this._node = _node;
191
+ }
192
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeOutlet, deps: [{ token: i0.ViewContainerRef }, { token: CDK_TREE_NODE_OUTLET_NODE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
193
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkTreeNodeOutlet, isStandalone: false, selector: "[cdkTreeNodeOutlet]", ngImport: i0 }); }
194
+ }
195
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeOutlet, decorators: [{
196
+ type: Directive,
197
+ args: [{
198
+ standalone: false,
199
+ selector: '[cdkTreeNodeOutlet]',
200
+ }]
201
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: undefined, decorators: [{
202
+ type: Inject,
203
+ args: [CDK_TREE_NODE_OUTLET_NODE]
204
+ }, {
205
+ type: Optional
206
+ }] }] });
207
+
208
+ /**
209
+ * @license
210
+ * Copyright Google LLC All Rights Reserved.
211
+ *
212
+ * Use of this source code is governed by an MIT-style license that can be
213
+ * found in the LICENSE file at https://angular.io/license
214
+ */
215
+ /** Context provided to the tree node component. */
216
+ class CdkTreeNodeOutletContext {
217
+ constructor(data) {
218
+ this.$implicit = data;
219
+ }
220
+ }
221
+ /**
222
+ * Data node definition for the CdkTree.
223
+ * Captures the node's template and a when predicate that describes when this node should be used.
224
+ */
225
+ class CdkTreeNodeDef {
226
+ /** @docs-private */
227
+ constructor(template) {
228
+ this.template = template;
229
+ }
230
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeDef, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
231
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkTreeNodeDef, isStandalone: false, selector: "[cdkTreeNodeDef]", inputs: { when: ["cdkTreeNodeDefWhen", "when"] }, ngImport: i0 }); }
232
+ }
233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeDef, decorators: [{
234
+ type: Directive,
235
+ args: [{
236
+ standalone: false,
237
+ selector: '[cdkTreeNodeDef]',
238
+ inputs: ['when: cdkTreeNodeDefWhen'],
239
+ }]
240
+ }], ctorParameters: () => [{ type: i0.TemplateRef }] });
241
+
242
+ /**
243
+ * @license
244
+ * Copyright Google LLC All Rights Reserved.
245
+ *
246
+ * Use of this source code is governed by an MIT-style license that can be
247
+ * found in the LICENSE file at https://angular.io/license
248
+ */
249
+ /**
250
+ * Returns an error to be thrown when there is no usable data.
251
+ * @docs-private
252
+ */
253
+ function getTreeNoValidDataSourceError() {
254
+ return Error(`A valid data source must be provided.`);
255
+ }
256
+ /**
257
+ * Returns an error to be thrown when there are multiple nodes that are missing a when function.
258
+ * @docs-private
259
+ */
260
+ function getTreeMultipleDefaultNodeDefsError() {
261
+ return Error(`There can only be one default row without a when predicate function.`);
262
+ }
263
+ /**
264
+ * Returns an error to be thrown when there are no matching node defs for a particular set of data.
265
+ * @docs-private
266
+ */
267
+ function getTreeMissingMatchingNodeDefError() {
268
+ return Error(`Could not find a matching node definition for the provided node data.`);
269
+ }
270
+ /**
271
+ * Returns an error to be thrown when there are tree control.
272
+ * @docs-private
273
+ */
274
+ function getTreeControlMissingError() {
275
+ return Error(`Could not find a tree control for the tree.`);
276
+ }
277
+ /**
278
+ * Returns an error to be thrown when tree control did not implement functions for flat/nested node.
279
+ * @docs-private
280
+ */
281
+ function getTreeControlFunctionsMissingError() {
282
+ return Error(`Could not find functions for nested/flat tree in tree control.`);
283
+ }
284
+
285
+ /**
286
+ * CDK tree component that connects with a data source to retrieve data of type `T` and renders
287
+ * dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
288
+ */
289
+ class CdkTree {
290
+ /**
291
+ * Provides a stream containing the latest data array to render. Influenced by the tree's
292
+ * stream of view window (what dataNodes are currently on screen).
293
+ * Data source can be an observable of data array, or a data array to render.
294
+ */
295
+ get dataSource() {
296
+ return this._dataSource;
297
+ }
298
+ set dataSource(dataSource) {
299
+ if (this._dataSource !== dataSource) {
300
+ this._switchDataSource(dataSource);
301
+ }
302
+ }
303
+ constructor(_differs, _changeDetectorRef) {
304
+ this._differs = _differs;
305
+ this._changeDetectorRef = _changeDetectorRef;
306
+ /** Subject that emits when the component has been destroyed. */
307
+ this._onDestroy = new Subject();
308
+ /** Level of nodes */
309
+ this._levels = new Map();
310
+ // TODO(tinayuangao): Setup a listener for scrolling, emit the calculated view to viewChange.
311
+ // Remove the MAX_VALUE in viewChange
312
+ /**
313
+ * Stream containing the latest information on what rows are being displayed on screen.
314
+ * Can be used by the data source to as a heuristic of what data should be provided.
315
+ */
316
+ this.viewChange = new BehaviorSubject({
317
+ start: 0,
318
+ end: Number.MAX_VALUE,
319
+ });
320
+ }
321
+ ngOnInit() {
322
+ this._dataDiffer = this._differs.find([]).create(this.trackBy);
323
+ if (!this.treeControl && (typeof ngDevMode === 'undefined' || ngDevMode)) {
324
+ throw getTreeControlMissingError();
325
+ }
326
+ }
327
+ ngOnDestroy() {
328
+ this._nodeOutlet.viewContainer.clear();
329
+ this.viewChange.complete();
330
+ this._onDestroy.next();
331
+ this._onDestroy.complete();
332
+ if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
333
+ this.dataSource.disconnect(this);
334
+ }
335
+ if (this._dataSubscription) {
336
+ this._dataSubscription.unsubscribe();
337
+ this._dataSubscription = null;
338
+ }
339
+ }
340
+ ngAfterContentChecked() {
341
+ const defaultNodeDefs = this._nodeDefs.filter(def => !def.when);
342
+ if (defaultNodeDefs.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
343
+ throw getTreeMultipleDefaultNodeDefsError();
344
+ }
345
+ this._defaultNodeDef = defaultNodeDefs[0];
346
+ if (this.dataSource && this._nodeDefs && !this._dataSubscription) {
347
+ this._observeRenderChanges();
348
+ }
349
+ }
350
+ // TODO(tinayuangao): Work on keyboard traversal and actions, make sure it's working for RTL
351
+ // and nested trees.
352
+ /**
353
+ * Switch to the provided data source by resetting the data and unsubscribing from the current
354
+ * render change subscription if one exists. If the data source is null, interpret this by
355
+ * clearing the node outlet. Otherwise start listening for new data.
356
+ */
357
+ _switchDataSource(dataSource) {
358
+ if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
359
+ this.dataSource.disconnect(this);
360
+ }
361
+ if (this._dataSubscription) {
362
+ this._dataSubscription.unsubscribe();
363
+ this._dataSubscription = null;
364
+ }
365
+ // Remove the all dataNodes if there is now no data source
366
+ if (!dataSource) {
367
+ this._nodeOutlet.viewContainer.clear();
368
+ }
369
+ this._dataSource = dataSource;
370
+ if (this._nodeDefs) {
371
+ this._observeRenderChanges();
372
+ }
373
+ }
374
+ /** Set up a subscription for the data provided by the data source. */
375
+ _observeRenderChanges() {
376
+ let dataStream;
377
+ if (isDataSource(this._dataSource)) {
378
+ dataStream = this._dataSource.connect(this);
379
+ }
380
+ else if (isObservable(this._dataSource)) {
381
+ dataStream = this._dataSource;
382
+ }
383
+ else if (Array.isArray(this._dataSource)) {
384
+ dataStream = of(this._dataSource);
385
+ }
386
+ if (dataStream) {
387
+ this._dataSubscription = dataStream
388
+ .pipe(takeUntil(this._onDestroy))
389
+ .subscribe(data => this.renderNodeChanges(data));
390
+ }
391
+ else if (typeof ngDevMode === 'undefined' || ngDevMode) {
392
+ throw getTreeNoValidDataSourceError();
393
+ }
394
+ }
395
+ /** Check for changes made in the data and render each change (node added/removed/moved). */
396
+ renderNodeChanges(data, dataDiffer = this._dataDiffer, viewContainer = this._nodeOutlet.viewContainer, parentData) {
397
+ const changes = dataDiffer.diff(data);
398
+ if (!changes) {
399
+ return;
400
+ }
401
+ changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
402
+ if (item.previousIndex == null) {
403
+ this.insertNode(data[currentIndex], currentIndex, viewContainer, parentData);
404
+ }
405
+ else if (currentIndex == null) {
406
+ viewContainer.remove(adjustedPreviousIndex);
407
+ this._levels.delete(item.item);
408
+ }
409
+ else {
410
+ const view = viewContainer.get(adjustedPreviousIndex);
411
+ viewContainer.move(view, currentIndex);
412
+ }
413
+ });
414
+ this._changeDetectorRef.detectChanges();
415
+ }
416
+ /**
417
+ * Finds the matching node definition that should be used for this node data. If there is only
418
+ * one node definition, it is returned. Otherwise, find the node definition that has a when
419
+ * predicate that returns true with the data. If none return true, return the default node
420
+ * definition.
421
+ */
422
+ _getNodeDef(data, i) {
423
+ if (this._nodeDefs.length === 1) {
424
+ return this._nodeDefs.first;
425
+ }
426
+ const nodeDef = this._nodeDefs.find(def => def.when && def.when(i, data)) || this._defaultNodeDef;
427
+ if (!nodeDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
428
+ throw getTreeMissingMatchingNodeDefError();
429
+ }
430
+ return nodeDef;
431
+ }
432
+ /**
433
+ * Create the embedded view for the data node template and place it in the correct index location
434
+ * within the data node view container.
435
+ */
436
+ insertNode(nodeData, index, viewContainer, parentData) {
437
+ const node = this._getNodeDef(nodeData, index);
438
+ // Node context that will be provided to created embedded view
439
+ const context = new CdkTreeNodeOutletContext(nodeData);
440
+ // If the tree is flat tree, then use the `getLevel` function in flat tree control
441
+ // Otherwise, use the level of parent node.
442
+ if (this.treeControl.getLevel) {
443
+ context.level = this.treeControl.getLevel(nodeData);
444
+ }
445
+ else if (typeof parentData !== 'undefined' && this._levels.has(parentData)) {
446
+ context.level = this._levels.get(parentData) + 1;
447
+ }
448
+ else {
449
+ context.level = 0;
450
+ }
451
+ this._levels.set(nodeData, context.level);
452
+ // Use default tree nodeOutlet, or nested node's nodeOutlet
453
+ const container = viewContainer ? viewContainer : this._nodeOutlet.viewContainer;
454
+ container.createEmbeddedView(node.template, context, index);
455
+ // Set the data to just created `CdkTreeNode`.
456
+ // The `CdkTreeNode` created from `createEmbeddedView` will be saved in static variable
457
+ // `mostRecentTreeNode`. We get it from static variable and pass the node data to it.
458
+ if (CdkTreeNode.mostRecentTreeNode) {
459
+ CdkTreeNode.mostRecentTreeNode.data = nodeData;
460
+ }
461
+ }
462
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTree, deps: [{ token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
463
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.11", type: CdkTree, isStandalone: false, selector: "cdk-tree", inputs: { dataSource: "dataSource", treeControl: "treeControl", trackBy: "trackBy" }, host: { attributes: { "role": "tree" }, classAttribute: "cdk-tree" }, queries: [{ propertyName: "_nodeDefs", predicate: CdkTreeNodeDef, descendants: true }], viewQueries: [{ propertyName: "_nodeOutlet", first: true, predicate: CdkTreeNodeOutlet, descendants: true, static: true }], exportAs: ["cdkTree"], ngImport: i0, template: `<ng-container cdkTreeNodeOutlet></ng-container>`, isInline: true, dependencies: [{ kind: "directive", type: CdkTreeNodeOutlet, selector: "[cdkTreeNodeOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Eager, encapsulation: i0.ViewEncapsulation.None }); }
464
+ }
465
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTree, decorators: [{
466
+ type: Component,
467
+ args: [{
468
+ standalone: false,
469
+ selector: 'cdk-tree',
470
+ exportAs: 'cdkTree',
471
+ template: `<ng-container cdkTreeNodeOutlet></ng-container>`,
472
+ host: {
473
+ 'class': 'cdk-tree',
474
+ 'role': 'tree',
475
+ },
476
+ encapsulation: ViewEncapsulation.None,
477
+ // The "OnPush" status for the `CdkTree` component is effectively a noop, so we are removing it.
478
+ // The view for `CdkTree` consists entirely of templates declared in other views. As they are
479
+ // declared elsewhere, they are checked when their declaration points are checked.
480
+ // tslint:disable-next-line:validate-decorators
481
+ changeDetection: ChangeDetectionStrategy.Default,
482
+ }]
483
+ }], ctorParameters: () => [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }], propDecorators: { dataSource: [{
484
+ type: Input
485
+ }], treeControl: [{
486
+ type: Input
487
+ }], trackBy: [{
488
+ type: Input
489
+ }], _nodeOutlet: [{
490
+ type: ViewChild,
491
+ args: [CdkTreeNodeOutlet, { static: true }]
492
+ }], _nodeDefs: [{
493
+ type: ContentChildren,
494
+ args: [CdkTreeNodeDef, {
495
+ // We need to use `descendants: true`, because Ivy will no longer match
496
+ // indirect descendants if it's left as false.
497
+ descendants: true,
498
+ }]
499
+ }] } });
500
+ /**
501
+ * Tree node for CdkTree. It contains the data in the tree node.
502
+ */
503
+ class CdkTreeNode {
504
+ /**
505
+ * The role of the tree node.
506
+ * @deprecated The correct role is 'treeitem', 'group' should not be used. This input will be
507
+ * removed in a future version.
508
+ * @breaking-change 12.0.0 Remove this input
509
+ */
510
+ get role() {
511
+ return 'treeitem';
512
+ }
513
+ set role(_role) {
514
+ // TODO: move to host after View Engine deprecation
515
+ this._elementRef.nativeElement.setAttribute('role', _role);
516
+ }
517
+ /**
518
+ * The most recently created `CdkTreeNode`. We save it in static variable so we can retrieve it
519
+ * in `CdkTree` and set the data to it.
520
+ */
521
+ static { this.mostRecentTreeNode = null; }
522
+ /** The tree node's data. */
523
+ get data() {
524
+ return this._data;
525
+ }
526
+ set data(value) {
527
+ if (value !== this._data) {
528
+ this._data = value;
529
+ this._setRoleFromData();
530
+ this._dataChanges.next();
531
+ }
532
+ }
533
+ get isExpanded() {
534
+ return this._tree.treeControl.isExpanded(this._data);
535
+ }
536
+ get level() {
537
+ // If the treeControl has a getLevel method, use it to get the level. Otherwise read the
538
+ // aria-level off the parent node and use it as the level for this node (note aria-level is
539
+ // 1-indexed, while this property is 0-indexed, so we don't need to increment).
540
+ return this._tree.treeControl.getLevel
541
+ ? this._tree.treeControl.getLevel(this._data)
542
+ : this._parentNodeAriaLevel;
543
+ }
544
+ constructor(_elementRef, _tree) {
545
+ this._elementRef = _elementRef;
546
+ this._tree = _tree;
547
+ /** Subject that emits when the component has been destroyed. */
548
+ this._destroyed = new Subject();
549
+ /** Emits when the node's data has changed. */
550
+ this._dataChanges = new Subject();
551
+ CdkTreeNode.mostRecentTreeNode = this;
552
+ this.role = 'treeitem';
553
+ }
554
+ ngOnInit() {
555
+ this._parentNodeAriaLevel = getParentNodeAriaLevel(this._elementRef.nativeElement);
556
+ this._elementRef.nativeElement.setAttribute('aria-level', `${this.level + 1}`);
557
+ }
558
+ ngOnDestroy() {
559
+ // If this is the last tree node being destroyed,
560
+ // clear out the reference to avoid leaking memory.
561
+ if (CdkTreeNode.mostRecentTreeNode === this) {
562
+ CdkTreeNode.mostRecentTreeNode = null;
563
+ }
564
+ this._dataChanges.complete();
565
+ this._destroyed.next();
566
+ this._destroyed.complete();
567
+ }
568
+ /** Focuses the menu item. Implements for FocusableOption. */
569
+ focus() {
570
+ this._elementRef.nativeElement.focus();
571
+ }
572
+ // TODO: role should eventually just be set in the component host
573
+ _setRoleFromData() {
574
+ if (!this._tree.treeControl.isExpandable &&
575
+ !this._tree.treeControl.getChildren &&
576
+ (typeof ngDevMode === 'undefined' || ngDevMode)) {
577
+ throw getTreeControlFunctionsMissingError();
578
+ }
579
+ this.role = 'treeitem';
580
+ }
581
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNode, deps: [{ token: i0.ElementRef }, { token: CdkTree }], target: i0.ɵɵFactoryTarget.Directive }); }
582
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkTreeNode, isStandalone: false, selector: "cdk-tree-node", inputs: { role: "role" }, host: { properties: { "attr.aria-expanded": "isExpanded" }, classAttribute: "cdk-tree-node" }, exportAs: ["cdkTreeNode"], ngImport: i0 }); }
583
+ }
584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNode, decorators: [{
585
+ type: Directive,
586
+ args: [{
587
+ standalone: false,
588
+ selector: 'cdk-tree-node',
589
+ exportAs: 'cdkTreeNode',
590
+ host: {
591
+ 'class': 'cdk-tree-node',
592
+ '[attr.aria-expanded]': 'isExpanded',
593
+ },
594
+ }]
595
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: CdkTree }], propDecorators: { role: [{
596
+ type: Input
597
+ }] } });
598
+ function getParentNodeAriaLevel(nodeElement) {
599
+ let parent = nodeElement.parentElement;
600
+ while (parent && !isNodeElement(parent)) {
601
+ parent = parent.parentElement;
602
+ }
603
+ if (!parent) {
604
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
605
+ throw Error('Incorrect tree structure containing detached node.');
606
+ }
607
+ else {
608
+ return -1;
609
+ }
610
+ }
611
+ else if (parent.classList.contains('cdk-nested-tree-node')) {
612
+ return coerceNumberProperty(parent.getAttribute('aria-level'));
613
+ }
614
+ else {
615
+ // The ancestor element is the cdk-tree itself
616
+ return 0;
617
+ }
618
+ }
619
+ function isNodeElement(element) {
620
+ const classList = element.classList;
621
+ return !!(classList?.contains('cdk-nested-tree-node') || classList?.contains('cdk-tree'));
622
+ }
623
+
624
+ /**
625
+ * @license
626
+ * Copyright Google LLC All Rights Reserved.
627
+ *
628
+ * Use of this source code is governed by an MIT-style license that can be
629
+ * found in the LICENSE file at https://angular.io/license
630
+ */
631
+ /**
632
+ * Nested node is a child of `<cdk-tree>`. It works with nested tree.
633
+ * By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
634
+ * be added in the `cdkTreeNodeOutlet` in tree node template.
635
+ * The children of node will be automatically added to `cdkTreeNodeOutlet`.
636
+ */
637
+ class CdkNestedTreeNode extends CdkTreeNode {
638
+ constructor(elementRef, tree, _differs) {
639
+ super(elementRef, tree);
640
+ this._differs = _differs;
641
+ }
642
+ ngAfterContentInit() {
643
+ this._dataDiffer = this._differs.find([]).create(this._tree.trackBy);
644
+ if (!this._tree.treeControl.getChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) {
645
+ throw getTreeControlFunctionsMissingError();
646
+ }
647
+ const childrenNodes = this._tree.treeControl.getChildren(this.data);
648
+ if (Array.isArray(childrenNodes)) {
649
+ this.updateChildrenNodes(childrenNodes);
650
+ }
651
+ else if (isObservable(childrenNodes)) {
652
+ childrenNodes
653
+ .pipe(takeUntil(this._destroyed))
654
+ .subscribe(result => this.updateChildrenNodes(result));
655
+ }
656
+ this.nodeOutlet.changes
657
+ .pipe(takeUntil(this._destroyed))
658
+ .subscribe(() => this.updateChildrenNodes());
659
+ }
660
+ // This is a workaround for https://github.com/angular/angular/issues/23091
661
+ // In aot mode, the lifecycle hooks from parent class are not called.
662
+ ngOnInit() {
663
+ super.ngOnInit();
664
+ }
665
+ ngOnDestroy() {
666
+ this._clear();
667
+ super.ngOnDestroy();
668
+ }
669
+ /** Add children dataNodes to the NodeOutlet */
670
+ updateChildrenNodes(children) {
671
+ const outlet = this._getNodeOutlet();
672
+ if (children) {
673
+ this._children = children;
674
+ }
675
+ if (outlet && this._children) {
676
+ const viewContainer = outlet.viewContainer;
677
+ this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
678
+ }
679
+ else {
680
+ // Reset the data differ if there's no children nodes displayed
681
+ this._dataDiffer.diff([]);
682
+ }
683
+ }
684
+ /** Clear the children dataNodes. */
685
+ _clear() {
686
+ const outlet = this._getNodeOutlet();
687
+ if (outlet) {
688
+ outlet.viewContainer.clear();
689
+ this._dataDiffer.diff([]);
690
+ }
691
+ }
692
+ /** Gets the outlet for the current node. */
693
+ _getNodeOutlet() {
694
+ const outlets = this.nodeOutlet;
695
+ // Note that since we use `descendants: true` on the query, we have to ensure
696
+ // that we don't pick up the outlet of a child node by accident.
697
+ return outlets && outlets.find(outlet => !outlet._node || outlet._node === this);
698
+ }
699
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkNestedTreeNode, deps: [{ token: i0.ElementRef }, { token: CdkTree }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
700
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkNestedTreeNode, isStandalone: false, selector: "cdk-nested-tree-node", inputs: { role: "role", disabled: "disabled", tabIndex: "tabIndex" }, host: { classAttribute: "cdk-nested-tree-node" }, providers: [
701
+ { provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
702
+ { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode },
703
+ ], queries: [{ propertyName: "nodeOutlet", predicate: CdkTreeNodeOutlet, descendants: true }], exportAs: ["cdkNestedTreeNode"], usesInheritance: true, ngImport: i0 }); }
704
+ }
705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkNestedTreeNode, decorators: [{
706
+ type: Directive,
707
+ args: [{
708
+ standalone: false,
709
+ selector: 'cdk-nested-tree-node',
710
+ exportAs: 'cdkNestedTreeNode',
711
+ inputs: ['role', 'disabled', 'tabIndex'],
712
+ providers: [
713
+ { provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
714
+ { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode },
715
+ ],
716
+ host: {
717
+ 'class': 'cdk-nested-tree-node',
718
+ },
719
+ }]
720
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: CdkTree }, { type: i0.IterableDiffers }], propDecorators: { nodeOutlet: [{
721
+ type: ContentChildren,
722
+ args: [CdkTreeNodeOutlet, {
723
+ // We need to use `descendants: true`, because Ivy will no longer match
724
+ // indirect descendants if it's left as false.
725
+ descendants: true,
726
+ }]
727
+ }] } });
728
+
729
+ /** Regex used to split a string on its CSS units. */
730
+ const cssUnitPattern = /([A-Za-z%]+)$/;
731
+ /**
732
+ * Indent for the children tree dataNodes.
733
+ * This directive will add left-padding to the node to show hierarchy.
734
+ */
735
+ class CdkTreeNodePadding {
736
+ /** The level of depth of the tree node. The padding will be `level * indent` pixels. */
737
+ get level() {
738
+ return this._level;
739
+ }
740
+ set level(value) {
741
+ this._setLevelInput(value);
742
+ }
743
+ /**
744
+ * The indent for each level. Can be a number or a CSS string.
745
+ * Default number 40px from material design menu sub-menu spec.
746
+ */
747
+ get indent() {
748
+ return this._indent;
749
+ }
750
+ set indent(indent) {
751
+ this._setIndentInput(indent);
752
+ }
753
+ constructor(_treeNode, _tree, _element, _dir) {
754
+ this._treeNode = _treeNode;
755
+ this._tree = _tree;
756
+ this._element = _element;
757
+ this._dir = _dir;
758
+ /** Subject that emits when the component has been destroyed. */
759
+ this._destroyed = new Subject();
760
+ /** CSS units used for the indentation value. */
761
+ this.indentUnits = 'px';
762
+ this._indent = 40;
763
+ this._setPadding();
764
+ if (_dir) {
765
+ _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadding(true));
766
+ }
767
+ // In Ivy the indentation binding might be set before the tree node's data has been added,
768
+ // which means that we'll miss the first render. We have to subscribe to changes in the
769
+ // data to ensure that everything is up to date.
770
+ _treeNode._dataChanges.subscribe(() => this._setPadding());
771
+ }
772
+ ngOnDestroy() {
773
+ this._destroyed.next();
774
+ this._destroyed.complete();
775
+ }
776
+ /** The padding indent value for the tree node. Returns a string with px numbers if not null. */
777
+ _paddingIndent() {
778
+ const nodeLevel = this._treeNode.data && this._tree.treeControl.getLevel
779
+ ? this._tree.treeControl.getLevel(this._treeNode.data)
780
+ : null;
781
+ const level = this._level == null ? nodeLevel : this._level;
782
+ return typeof level === 'number' ? `${level * this._indent}${this.indentUnits}` : null;
783
+ }
784
+ _setPadding(forceChange = false) {
785
+ const padding = this._paddingIndent();
786
+ if (padding !== this._currentPadding || forceChange) {
787
+ const element = this._element.nativeElement;
788
+ const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
789
+ const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingLeft';
790
+ element.style[paddingProp] = padding || '';
791
+ element.style[resetProp] = '';
792
+ this._currentPadding = padding;
793
+ }
794
+ }
795
+ /**
796
+ * This has been extracted to a util because of TS 4 and VE.
797
+ * View Engine doesn't support property rename inheritance.
798
+ * TS 4.0 doesn't allow properties to override accessors or vice-versa.
799
+ * @docs-private
800
+ */
801
+ _setLevelInput(value) {
802
+ // Set to null as the fallback value so that _setPadding can fall back to the node level if the
803
+ // consumer set the directive as `cdkTreeNodePadding=""`. We still want to take this value if
804
+ // they set 0 explicitly.
805
+ this._level = coerceNumberProperty(value, null);
806
+ this._setPadding();
807
+ }
808
+ /**
809
+ * This has been extracted to a util because of TS 4 and VE.
810
+ * View Engine doesn't support property rename inheritance.
811
+ * TS 4.0 doesn't allow properties to override accessors or vice-versa.
812
+ * @docs-private
813
+ */
814
+ _setIndentInput(indent) {
815
+ let value = indent;
816
+ let units = 'px';
817
+ if (typeof indent === 'string') {
818
+ const parts = indent.split(cssUnitPattern);
819
+ value = parts[0];
820
+ units = parts[1] || units;
821
+ }
822
+ this.indentUnits = units;
823
+ this._indent = coerceNumberProperty(value);
824
+ this._setPadding();
825
+ }
826
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodePadding, deps: [{ token: CdkTreeNode }, { token: CdkTree }, { token: i0.ElementRef }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
827
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkTreeNodePadding, isStandalone: false, selector: "[cdkTreeNodePadding]", inputs: { level: ["cdkTreeNodePadding", "level"], indent: ["cdkTreeNodePaddingIndent", "indent"] }, ngImport: i0 }); }
828
+ }
829
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodePadding, decorators: [{
830
+ type: Directive,
831
+ args: [{
832
+ standalone: false,
833
+ selector: '[cdkTreeNodePadding]',
834
+ }]
835
+ }], ctorParameters: () => [{ type: CdkTreeNode }, { type: CdkTree }, { type: i0.ElementRef }, { type: i2.Directionality, decorators: [{
836
+ type: Optional
837
+ }] }], propDecorators: { level: [{
838
+ type: Input,
839
+ args: ['cdkTreeNodePadding']
840
+ }], indent: [{
841
+ type: Input,
842
+ args: ['cdkTreeNodePaddingIndent']
843
+ }] } });
844
+
845
+ /**
846
+ * @license
847
+ * Copyright Google LLC All Rights Reserved.
848
+ *
849
+ * Use of this source code is governed by an MIT-style license that can be
850
+ * found in the LICENSE file at https://angular.io/license
851
+ */
852
+ /**
853
+ * Node toggle to expand/collapse the node.
854
+ */
855
+ class CdkTreeNodeToggle {
856
+ /** Whether expand/collapse the node recursively. */
857
+ get recursive() {
858
+ return this._recursive;
859
+ }
860
+ set recursive(value) {
861
+ this._recursive = coerceBooleanProperty(value);
862
+ }
863
+ constructor(_tree, _treeNode) {
864
+ this._tree = _tree;
865
+ this._treeNode = _treeNode;
866
+ this._recursive = false;
867
+ }
868
+ _toggle(event) {
869
+ this.recursive
870
+ ? this._tree.treeControl.toggleDescendants(this._treeNode.data)
871
+ : this._tree.treeControl.toggle(this._treeNode.data);
872
+ event.stopPropagation();
873
+ }
874
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeToggle, deps: [{ token: CdkTree }, { token: CdkTreeNode }], target: i0.ɵɵFactoryTarget.Directive }); }
875
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: CdkTreeNodeToggle, isStandalone: false, selector: "[cdkTreeNodeToggle]", inputs: { recursive: ["cdkTreeNodeToggleRecursive", "recursive"] }, host: { listeners: { "click": "_toggle($event)" } }, ngImport: i0 }); }
876
+ }
877
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeNodeToggle, decorators: [{
878
+ type: Directive,
879
+ args: [{
880
+ standalone: false,
881
+ selector: '[cdkTreeNodeToggle]',
882
+ host: {
883
+ '(click)': '_toggle($event)',
884
+ },
885
+ }]
886
+ }], ctorParameters: () => [{ type: CdkTree }, { type: CdkTreeNode }], propDecorators: { recursive: [{
887
+ type: Input,
888
+ args: ['cdkTreeNodeToggleRecursive']
889
+ }] } });
890
+
891
+ /**
892
+ * @license
893
+ * Copyright Google LLC All Rights Reserved.
894
+ *
895
+ * Use of this source code is governed by an MIT-style license that can be
896
+ * found in the LICENSE file at https://angular.io/license
897
+ */
898
+ const EXPORTED_DECLARATIONS = [
899
+ CdkNestedTreeNode,
900
+ CdkTreeNodeDef,
901
+ CdkTreeNodePadding,
902
+ CdkTreeNodeToggle,
903
+ CdkTree,
904
+ CdkTreeNode,
905
+ CdkTreeNodeOutlet,
906
+ ];
907
+ class CdkTreeModule {
908
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
909
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeModule, declarations: [CdkNestedTreeNode,
910
+ CdkTreeNodeDef,
911
+ CdkTreeNodePadding,
912
+ CdkTreeNodeToggle,
913
+ CdkTree,
914
+ CdkTreeNode,
915
+ CdkTreeNodeOutlet], exports: [CdkNestedTreeNode,
916
+ CdkTreeNodeDef,
917
+ CdkTreeNodePadding,
918
+ CdkTreeNodeToggle,
919
+ CdkTree,
920
+ CdkTreeNode,
921
+ CdkTreeNodeOutlet] }); }
922
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeModule }); }
923
+ }
924
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: CdkTreeModule, decorators: [{
925
+ type: NgModule,
926
+ args: [{
927
+ exports: EXPORTED_DECLARATIONS,
928
+ declarations: EXPORTED_DECLARATIONS,
929
+ }]
930
+ }] });
931
+
932
+ /**
933
+ * @license
934
+ * Copyright Google LLC All Rights Reserved.
935
+ *
936
+ * Use of this source code is governed by an MIT-style license that can be
937
+ * found in the LICENSE file at https://angular.io/license
938
+ */
939
+
940
+ /**
941
+ * Generated bundle index. Do not edit.
942
+ */
943
+
944
+ export { BaseTreeControl, CDK_TREE_NODE_OUTLET_NODE, CdkNestedTreeNode, CdkTree, CdkTreeModule, CdkTreeNode, CdkTreeNodeDef, CdkTreeNodeOutlet, CdkTreeNodeOutletContext, CdkTreeNodePadding, CdkTreeNodeToggle, FlatTreeControl, NestedTreeControl, getTreeControlFunctionsMissingError, getTreeControlMissingError, getTreeMissingMatchingNodeDefError, getTreeMultipleDefaultNodeDefsError, getTreeNoValidDataSourceError };
945
+ //# sourceMappingURL=stagefright5-cdk-tree.mjs.map