@daffodil/design 0.94.1-rc.0 → 0.95.0

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 (170) hide show
  1. package/README.md +1 -2
  2. package/accordion/src/accordion-theme.scss +4 -4
  3. package/article/README.md +4 -27
  4. package/article/src/article-theme.scss +14 -14
  5. package/badge/src/badge-theme.scss +0 -6
  6. package/button/README.md +0 -4
  7. package/button/src/button/basic/button-theme.scss +17 -42
  8. package/button/src/button/button-base.scss +12 -3
  9. package/button/src/button/flat/flat-theme.scss +14 -12
  10. package/button/src/button/icon/icon-theme.scss +19 -40
  11. package/button/src/button/stroked/stroked-theme.scss +22 -36
  12. package/card/src/card/stroked/stroked-theme.scss +1 -1
  13. package/card/src/card-base.scss +0 -1
  14. package/fesm2022/daffodil-design-accordion.mjs +285 -188
  15. package/fesm2022/daffodil-design-accordion.mjs.map +1 -1
  16. package/fesm2022/daffodil-design-article.mjs +578 -340
  17. package/fesm2022/daffodil-design-article.mjs.map +1 -1
  18. package/fesm2022/daffodil-design-badge.mjs +166 -84
  19. package/fesm2022/daffodil-design-badge.mjs.map +1 -1
  20. package/fesm2022/daffodil-design-beacon.mjs +109 -47
  21. package/fesm2022/daffodil-design-beacon.mjs.map +1 -1
  22. package/fesm2022/daffodil-design-breadcrumb.mjs +384 -277
  23. package/fesm2022/daffodil-design-breadcrumb.mjs.map +1 -1
  24. package/fesm2022/daffodil-design-button.mjs +541 -408
  25. package/fesm2022/daffodil-design-button.mjs.map +1 -1
  26. package/fesm2022/daffodil-design-callout.mjs +349 -224
  27. package/fesm2022/daffodil-design-callout.mjs.map +1 -1
  28. package/fesm2022/daffodil-design-card.mjs +496 -327
  29. package/fesm2022/daffodil-design-card.mjs.map +1 -1
  30. package/fesm2022/daffodil-design-checkbox.mjs +373 -313
  31. package/fesm2022/daffodil-design-checkbox.mjs.map +1 -1
  32. package/fesm2022/daffodil-design-container.mjs +103 -60
  33. package/fesm2022/daffodil-design-container.mjs.map +1 -1
  34. package/fesm2022/daffodil-design-form-field.mjs +441 -352
  35. package/fesm2022/daffodil-design-form-field.mjs.map +1 -1
  36. package/fesm2022/daffodil-design-form.mjs +155 -57
  37. package/fesm2022/daffodil-design-form.mjs.map +1 -1
  38. package/fesm2022/daffodil-design-hero.mjs +349 -234
  39. package/fesm2022/daffodil-design-hero.mjs.map +1 -1
  40. package/fesm2022/daffodil-design-image-lite.mjs +60 -0
  41. package/fesm2022/daffodil-design-image-lite.mjs.map +1 -0
  42. package/fesm2022/daffodil-design-image.mjs +245 -107
  43. package/fesm2022/daffodil-design-image.mjs.map +1 -1
  44. package/fesm2022/daffodil-design-input.mjs +217 -164
  45. package/fesm2022/daffodil-design-input.mjs.map +1 -1
  46. package/fesm2022/daffodil-design-list.mjs +308 -170
  47. package/fesm2022/daffodil-design-list.mjs.map +1 -1
  48. package/fesm2022/daffodil-design-media-gallery.mjs +351 -278
  49. package/fesm2022/daffodil-design-media-gallery.mjs.map +1 -1
  50. package/fesm2022/daffodil-design-menu.mjs +525 -417
  51. package/fesm2022/daffodil-design-menu.mjs.map +1 -1
  52. package/fesm2022/daffodil-design-modal.mjs +680 -450
  53. package/fesm2022/daffodil-design-modal.mjs.map +1 -1
  54. package/fesm2022/daffodil-design-native-select.mjs +175 -166
  55. package/fesm2022/daffodil-design-native-select.mjs.map +1 -1
  56. package/fesm2022/daffodil-design-navbar.mjs +145 -68
  57. package/fesm2022/daffodil-design-navbar.mjs.map +1 -1
  58. package/fesm2022/daffodil-design-notification.mjs +376 -226
  59. package/fesm2022/daffodil-design-notification.mjs.map +1 -1
  60. package/fesm2022/daffodil-design-paginator.mjs +296 -192
  61. package/fesm2022/daffodil-design-paginator.mjs.map +1 -1
  62. package/fesm2022/daffodil-design-progress-bar.mjs +243 -157
  63. package/fesm2022/daffodil-design-progress-bar.mjs.map +1 -1
  64. package/fesm2022/daffodil-design-radio.mjs +382 -300
  65. package/fesm2022/daffodil-design-radio.mjs.map +1 -1
  66. package/fesm2022/daffodil-design-select.mjs +424 -364
  67. package/fesm2022/daffodil-design-select.mjs.map +1 -1
  68. package/fesm2022/daffodil-design-sidebar.mjs +874 -887
  69. package/fesm2022/daffodil-design-sidebar.mjs.map +1 -1
  70. package/fesm2022/daffodil-design-spinner.mjs +156 -99
  71. package/fesm2022/daffodil-design-spinner.mjs.map +1 -1
  72. package/fesm2022/daffodil-design-switch.mjs +176 -106
  73. package/fesm2022/daffodil-design-switch.mjs.map +1 -1
  74. package/fesm2022/daffodil-design-tabs.mjs +685 -427
  75. package/fesm2022/daffodil-design-tabs.mjs.map +1 -1
  76. package/fesm2022/daffodil-design-tag.mjs +251 -133
  77. package/fesm2022/daffodil-design-tag.mjs.map +1 -1
  78. package/fesm2022/daffodil-design-testing.mjs +4 -16
  79. package/fesm2022/daffodil-design-testing.mjs.map +1 -1
  80. package/fesm2022/daffodil-design-text-snippet.mjs +140 -54
  81. package/fesm2022/daffodil-design-text-snippet.mjs.map +1 -1
  82. package/fesm2022/daffodil-design-textarea.mjs +170 -150
  83. package/fesm2022/daffodil-design-textarea.mjs.map +1 -1
  84. package/fesm2022/daffodil-design-toast.mjs +658 -481
  85. package/fesm2022/daffodil-design-toast.mjs.map +1 -1
  86. package/fesm2022/daffodil-design-tree.mjs +456 -469
  87. package/fesm2022/daffodil-design-tree.mjs.map +1 -1
  88. package/fesm2022/daffodil-design-youtube-player.mjs +168 -115
  89. package/fesm2022/daffodil-design-youtube-player.mjs.map +1 -1
  90. package/fesm2022/daffodil-design.mjs +1628 -1650
  91. package/fesm2022/daffodil-design.mjs.map +1 -1
  92. package/form-field/README.md +0 -4
  93. package/form-field/src/form-field-theme.scss +12 -4
  94. package/image/README.md +4 -0
  95. package/image-lite/README.md +58 -0
  96. package/image-lite/src/image-theme.scss +18 -0
  97. package/list/src/list-base.scss +3 -4
  98. package/list/src/list-theme.scss +6 -5
  99. package/media-gallery/README.md +1 -1
  100. package/media-gallery/src/media-gallery-theme.scss +3 -3
  101. package/menu/src/menu-theme.scss +6 -2
  102. package/notification/src/notification-theme.scss +10 -10
  103. package/package.json +1 -1
  104. package/scss/global.scss +17 -11
  105. package/scss/theme.scss +2 -18
  106. package/scss/theming/_get-palette.scss +0 -3
  107. package/scss/theming/_index.scss +0 -1
  108. package/scss/theming/_light-dark.scss +2 -2
  109. package/scss/theming/_theme-css-variables.scss +1 -1
  110. package/scss/theming/create-theme/_create-theme.scss +2 -2
  111. package/scss/theming/get-font-colors/_get-font-colors.scss +7 -25
  112. package/scss/theming/get-font-colors/_get-font-colors.spec.scss +0 -12
  113. package/scss/typography/_classes.scss +0 -6
  114. package/scss/typography/_index.scss +0 -1
  115. package/scss/typography/mixins/_sizes.scss +0 -1
  116. package/scss/typography/utilities/_variables.scss +3 -0
  117. package/select/src/select-theme.scss +10 -14
  118. package/switch/src/switch-theme.scss +2 -2
  119. package/tabs/src/tabs-theme.scss +4 -4
  120. package/types/daffodil-design-accordion.d.ts +92 -67
  121. package/types/daffodil-design-article.d.ts +49 -56
  122. package/types/daffodil-design-badge.d.ts +56 -33
  123. package/types/daffodil-design-beacon.d.ts +35 -14
  124. package/types/daffodil-design-breadcrumb.d.ts +89 -85
  125. package/types/daffodil-design-button.d.ts +128 -146
  126. package/types/daffodil-design-callout.d.ts +55 -39
  127. package/types/daffodil-design-card.d.ts +66 -56
  128. package/types/daffodil-design-checkbox.d.ts +211 -167
  129. package/types/daffodil-design-container.d.ts +17 -16
  130. package/types/daffodil-design-form-field.d.ts +273 -240
  131. package/types/daffodil-design-form.d.ts +21 -21
  132. package/types/daffodil-design-hero.d.ts +55 -39
  133. package/types/daffodil-design-image-lite.d.ts +17 -0
  134. package/types/daffodil-design-image.d.ts +89 -55
  135. package/types/daffodil-design-input.d.ts +86 -72
  136. package/types/daffodil-design-list.d.ts +49 -43
  137. package/types/daffodil-design-media-gallery.d.ts +176 -148
  138. package/types/daffodil-design-menu.d.ts +177 -169
  139. package/types/daffodil-design-modal.d.ts +205 -205
  140. package/types/daffodil-design-native-select.d.ts +94 -84
  141. package/types/daffodil-design-navbar.d.ts +34 -24
  142. package/types/daffodil-design-notification.d.ts +82 -67
  143. package/types/daffodil-design-paginator.d.ts +140 -118
  144. package/types/daffodil-design-progress-bar.d.ts +92 -74
  145. package/types/daffodil-design-radio.d.ts +183 -144
  146. package/types/daffodil-design-select.d.ts +207 -178
  147. package/types/daffodil-design-sidebar.d.ts +270 -253
  148. package/types/daffodil-design-spinner.d.ts +49 -36
  149. package/types/daffodil-design-switch.d.ts +77 -46
  150. package/types/daffodil-design-tabs.d.ts +248 -198
  151. package/types/daffodil-design-tag.d.ts +91 -56
  152. package/types/daffodil-design-testing.d.ts +1 -3
  153. package/types/daffodil-design-text-snippet.d.ts +48 -37
  154. package/types/daffodil-design-textarea.d.ts +88 -79
  155. package/types/daffodil-design-toast.d.ts +175 -183
  156. package/types/daffodil-design-tree.d.ts +186 -169
  157. package/types/daffodil-design-youtube-player.d.ts +56 -52
  158. package/types/daffodil-design.d.ts +614 -695
  159. package/button/src/button/raised/raised-theme.scss +0 -92
  160. package/button/src/button/underline/underline-theme.scss +0 -141
  161. package/fesm2022/daffodil-design-link-set.mjs +0 -160
  162. package/fesm2022/daffodil-design-link-set.mjs.map +0 -1
  163. package/fesm2022/daffodil-design-quantity-field.mjs +0 -364
  164. package/fesm2022/daffodil-design-quantity-field.mjs.map +0 -1
  165. package/link-set/README.md +0 -86
  166. package/quantity-field/README.md +0 -63
  167. package/scss/theming/_configure-theme.scss +0 -120
  168. package/scss/typography/mixins/_font-weight.scss +0 -14
  169. package/types/daffodil-design-link-set.d.ts +0 -72
  170. package/types/daffodil-design-quantity-field.d.ts +0 -171
@@ -1,487 +1,474 @@
1
- import { NgTemplateOutlet, DOCUMENT, CommonModule } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { Inject, inject, input, computed, signal, contentChild, ChangeDetectionStrategy, ViewEncapsulation, Component, effect, untracked, Directive, NgModule } from '@angular/core';
4
- import * as i1 from '@daffodil/design';
5
- import { DaffArticleEncapsulatedDirective } from '@daffodil/design';
6
- import { __decorate } from 'tslib';
7
- import { BehaviorSubject } from 'rxjs';
8
- import { collect } from '@daffodil/core';
9
-
10
- /**
11
- * This service is used by tree items to notify their parent
12
- * that the tree has to be recomputed.
13
- *
14
- * This service is a multiton associated with each tree instance.
15
- * It follows the same lifecycle as the tree it is associated with.
16
- */
1
+ import { CommonModule, DOCUMENT, NgTemplateOutlet } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, Directive, Inject, NgModule, ViewEncapsulation, computed, contentChild, effect, inject, input, signal, untracked } from "@angular/core";
4
+ import * as i1 from "@daffodil/design";
5
+ import { DaffArticleEncapsulatedDirective } from "@daffodil/design";
6
+ import { __decorate } from "tslib";
7
+ import { BehaviorSubject } from "rxjs";
8
+ import { collect } from "@daffodil/core";
17
9
  let DaffTreeNotifierService = class DaffTreeNotifierService {
18
- constructor() {
19
- /**
20
- * @docs-private
21
- */
22
- this._notice = new BehaviorSubject(true);
23
- /**
24
- * An observable that emits when the tree needs to be re-computed.
25
- */
26
- this.notice$ = this._notice.asObservable();
27
- }
28
- /**
29
- * `notify` can be called to trigger a re-computation of the tree
30
- * if data has changed unexpectedly and a re-render did not occur.
31
- *
32
- * This should be used sparingly. Instead, prefer updating `data` on the tree
33
- * itself for performance reasons.
34
- */
35
- notify() {
36
- this._notice.next(true);
37
- }
38
- /**
39
- * Cleanup when the tree is destroyed.
40
- *
41
- * @docs-private
42
- */
43
- ngOnDestroy() {
44
- this._notice.complete();
45
- }
10
+ constructor() {
11
+ this._notice = new BehaviorSubject(true);
12
+ this.notice$ = this._notice.asObservable();
13
+ }
14
+ notify() {
15
+ this._notice.next(true);
16
+ }
17
+ ngOnDestroy() {
18
+ this._notice.complete();
19
+ }
46
20
  };
47
- DaffTreeNotifierService = __decorate([
48
- Inject({})
49
- ], DaffTreeNotifierService);
50
-
51
- /**
52
- * Flatten a DaffTreeUi<unknown> into an array, removing elements from the array
53
- * below nodes in the tree that are not open.
54
- */
21
+ DaffTreeNotifierService = __decorate([Inject({})], DaffTreeNotifierService);
55
22
  const flattenTree = (daffUiTree, removeNodes = false) => {
56
- const tree = [];
57
- if (!daffUiTree) {
58
- return [];
59
- }
60
- let items = [
61
- {
62
- ...daffUiTree,
63
- level: 0,
64
- data: undefined,
65
- open: true,
66
- _treeRef: daffUiTree,
67
- },
68
- ];
69
- while (items) {
70
- const el = items.pop();
71
- if (!el) {
72
- break;
73
- }
74
- items = [
75
- ...items,
76
- ...el.items.map((i) => ({
77
- ...i,
78
- level: el.level + 1,
79
- _treeRef: i,
80
- })).reverse(),
81
- ];
82
- const hasClosedAncestor = el._treeRef.parent
83
- ? collect(el._treeRef.parent, (node) => node.parent ? [node.parent] : [], el.level).reduce((acc, parent) => acc || !parent.open, false)
84
- : false;
85
- if (!removeNodes && el._treeRef.parent) {
86
- tree.push({
87
- id: el.id,
88
- title: el.title,
89
- level: el.level,
90
- url: el.url,
91
- visible: !hasClosedAncestor,
92
- hasChildren: el.items.length > 0,
93
- data: undefined,
94
- _treeRef: el._treeRef,
95
- });
96
- }
97
- else if (removeNodes && el._treeRef.parent?.open) {
98
- tree.push({
99
- id: el.id,
100
- title: el.title,
101
- level: el.level,
102
- url: el.url,
103
- visible: !hasClosedAncestor,
104
- hasChildren: el.items.length > 0,
105
- data: undefined,
106
- _treeRef: el._treeRef,
107
- });
108
- }
109
- }
110
- return tree;
23
+ const tree = [];
24
+ if (!daffUiTree) return [];
25
+ let items = [{
26
+ ...daffUiTree,
27
+ level: 0,
28
+ data: void 0,
29
+ open: true,
30
+ _treeRef: daffUiTree
31
+ }];
32
+ while (items) {
33
+ const el = items.pop();
34
+ if (!el) break;
35
+ items = [...items, ...el.items.map((i) => ({
36
+ ...i,
37
+ level: el.level + 1,
38
+ _treeRef: i
39
+ })).reverse()];
40
+ const hasClosedAncestor = el._treeRef.parent ? collect(el._treeRef.parent, (node) => node.parent ? [node.parent] : [], el.level).reduce((acc, parent) => acc || !parent.open, false) : false;
41
+ if (!removeNodes && el._treeRef.parent) tree.push({
42
+ id: el.id,
43
+ title: el.title,
44
+ level: el.level,
45
+ url: el.url,
46
+ visible: !hasClosedAncestor,
47
+ hasChildren: el.items.length > 0,
48
+ data: el.data,
49
+ _treeRef: el._treeRef
50
+ });
51
+ else if (removeNodes && el._treeRef.parent?.open) tree.push({
52
+ id: el.id,
53
+ title: el.title,
54
+ level: el.level,
55
+ url: el.url,
56
+ visible: !hasClosedAncestor,
57
+ hasChildren: el.items.length > 0,
58
+ data: el.data,
59
+ _treeRef: el._treeRef
60
+ });
61
+ }
62
+ return tree;
111
63
  };
112
-
113
- /**
114
- * Traverse the tree, pre-order, right-to-left
115
- */
116
64
  const traverse = (tree, visit, key) => {
117
- let stack = [
118
- tree,
119
- ];
120
- while (stack) {
121
- const el = stack.pop();
122
- if (!el) {
123
- break;
124
- }
125
- visit(el);
126
- stack = [
127
- ...stack,
128
- ...el[key],
129
- ];
130
- }
131
- return tree;
65
+ let stack = [tree];
66
+ while (stack) {
67
+ const el = stack.pop();
68
+ if (!el) break;
69
+ visit(el);
70
+ stack = [...stack, ...el[key]];
71
+ }
72
+ return tree;
132
73
  };
133
-
134
74
  const daffDataTreeToUiTree = (data, parent, open = false) => ({
135
- id: parent ? `${parent.id}.${data.id ?? data.title}` : (data.id ?? data.title),
136
- title: data.title,
137
- url: data.url,
138
- data: data.data,
139
- open,
140
- parent,
141
- items: [],
75
+ id: parent ? `${parent.id}.${data.id ?? data.title}` : data.id ?? data.title,
76
+ title: data.title,
77
+ url: data.url,
78
+ data: data.data,
79
+ open,
80
+ parent,
81
+ items: []
142
82
  });
143
- /**
144
- * This function translates the original data given to us by the client
145
- * to the internal representation of the tree used by the {@link DaffTreeComponent}
146
- */
147
83
  const hydrateTree = (data, treeId) => {
148
- const root = {
149
- id: treeId ?? (data.id ?? data.title),
150
- title: data.title,
151
- url: data.url,
152
- data: data.data,
153
- open: true,
154
- parent: undefined,
155
- items: [],
156
- };
157
- let treeStack = [
158
- root,
159
- ];
160
- traverse(data, (el) => {
161
- const treeEl = treeStack.pop();
162
- treeEl.items = el.items.map((i) => daffDataTreeToUiTree(i, treeEl, false));
163
- treeStack = [
164
- ...treeStack,
165
- ...treeEl.items,
166
- ];
167
- return el;
168
- }, 'items');
169
- return root;
84
+ const root = {
85
+ id: treeId ?? data.id ?? data.title,
86
+ title: data.title,
87
+ url: data.url,
88
+ data: data.data,
89
+ open: true,
90
+ parent: void 0,
91
+ items: []
92
+ };
93
+ let treeStack = [root];
94
+ traverse(data, (el) => {
95
+ const treeEl = treeStack.pop();
96
+ treeEl.items = el.items.map((i) => daffDataTreeToUiTree(i, treeEl, false));
97
+ treeStack = [...treeStack, ...treeEl.items];
98
+ return el;
99
+ }, "items");
100
+ return root;
170
101
  };
171
-
172
- /* eslint-disable quote-props */
173
102
  let daffTreeId = 0;
174
- /**
175
- * The `DaffTreeComponent` allows you to render tree structures as interactable UI.
176
- *
177
- * @example Basic use of the tree component
178
- * ```html
179
- * <ul daff-tree [tree]="tree">
180
- * <ng-template #daffTreeItemWithChildrenTpl let-node>
181
- * <button daffTreeItem [node]="node">{{ node.title }} </button>
182
- * </ng-template>
183
- *
184
- * <ng-template #daffTreeItemTpl let-node>
185
- * <a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a>
186
- * </ng-template>
187
- * </ul>
188
- * ```
189
- *
190
- * where `tree` is a {@link DaffTreeData}.
191
- *
192
- */
193
- class DaffTreeComponent {
194
- constructor() {
195
- this.notifier = inject(DaffTreeNotifierService);
196
- /**
197
- * The rendering mode for nodes in the tree.
198
- *
199
- * Default value is `in-dom`, which means nodes are present in the DOM.
200
- *
201
- * Generally, `not-in-dom` is faster as there are less DOM elements to render,
202
- * but there may be use-cases (like SEO) where having the tree in the DOM
203
- * is relevant.
204
- */
205
- this.renderMode = input('in-dom', ...(ngDevMode ? [{ debugName: "renderMode" }] : /* istanbul ignore next */ []));
206
- /**
207
- * A unique identifier for the tree instance.
208
- * Used as a prefix for all node IDs in the tree.
209
- * If not provided, an auto-incrementing number is used.
210
- */
211
- this.id = input(`${daffTreeId++}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
212
- /**
213
- * The tree data you would like to render.
214
- */
215
- this.tree = input(...(ngDevMode ? [undefined, { debugName: "tree" }] : /* istanbul ignore next */ []));
216
- /**
217
- * The internal tree element.
218
- */
219
- this._tree = computed(() => {
220
- const tree = this.tree();
221
- return tree ? hydrateTree(tree, this.id()) : undefined;
222
- }, ...(ngDevMode ? [{ debugName: "_tree" }] : /* istanbul ignore next */ []));
223
- /**
224
- * A revision counter incremented by notifications from tree items.
225
- * Used to trigger re-flattening when tree item state changes.
226
- */
227
- this._revision = signal(0, ...(ngDevMode ? [{ debugName: "_revision" }] : /* istanbul ignore next */ []));
228
- /**
229
- * @docs-private
230
- *
231
- * The flattened tree data. For debugging purposes, you can iterate through this if you want to inspect
232
- * the resulting array structure we computed to render the tree.
233
- */
234
- this.flatTree = computed(() => {
235
- this._revision();
236
- const tree = this._tree();
237
- return tree ? flattenTree(tree, this.renderMode() === 'not-in-dom') : [];
238
- }, ...(ngDevMode ? [{ debugName: "flatTree" }] : /* istanbul ignore next */ []));
239
- /**
240
- * The template used to render tree-nodes that themselves have children.
241
- *
242
- * @docs-private
243
- */
244
- this.withChildrenTemplate = contentChild('daffTreeItemWithChildrenTpl', ...(ngDevMode ? [{ debugName: "withChildrenTemplate" }] : /* istanbul ignore next */ []));
245
- /**
246
- * The template used to render tree-nodes that have no children.
247
- *
248
- * @docs-private
249
- */
250
- this.treeItemTemplate = contentChild('daffTreeItemTpl', ...(ngDevMode ? [{ debugName: "treeItemTemplate" }] : /* istanbul ignore next */ []));
251
- this.notifier.notice$.subscribe(() => {
252
- this._revision.update((r) => r + 1);
253
- });
254
- }
255
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
256
- /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: DaffTreeComponent, isStandalone: true, selector: "ul[daff-tree]", inputs: { renderMode: { classPropertyName: "renderMode", publicName: "renderMode", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, tree: { classPropertyName: "tree", publicName: "tree", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "daff-tree" }, providers: [
257
- DaffTreeNotifierService,
258
- ], queries: [{ propertyName: "withChildrenTemplate", first: true, predicate: ["daffTreeItemWithChildrenTpl"], descendants: true, isSignal: true }, { propertyName: "treeItemTemplate", first: true, predicate: ["daffTreeItemTpl"], descendants: true, isSignal: true }], hostDirectives: [{ directive: i1.DaffArticleEncapsulatedDirective }], ngImport: i0, template: "@for (node of flatTree(); track node.id) {\n\t<li [attr.aria-level]=\"node.level\" [class.hidden]=\"!node.visible\">\n\t\t<ng-container\n\t\t\t*ngTemplateOutlet=\"node.hasChildren ? withChildrenTemplate() : treeItemTemplate(); context: { $implicit: node }\">\n\t\t</ng-container>\n\t</li>\n}", styles: [".daff-tree{margin:0;padding:0;list-style:none;--tree-padding: 1rem}.daff-tree li.hidden{display:none}.daff-tree-item{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;position:relative;background:none;border:0;padding:.5rem 1rem .5rem 0;line-height:1.5rem;font-weight:400;text-align:left;text-decoration:none;width:100%;padding-left:calc(var(--tree-padding) * (var(--depth)))}.daff-tree-item:before{content:\"\";position:absolute;top:0;bottom:0;left:0;width:.25rem}.daff-tree-item:focus,.daff-tree-item:focus-visible{z-index:1}.daff-tree-item.selected{font-weight:500}.daff-tree-item.parent{position:relative;padding-right:2.5rem}.daff-tree-item.parent:after{content:\"\";position:absolute;top:48%;right:1rem;display:inline-block;border-right:2px solid currentColor;border-bottom:2px solid currentColor;width:.5rem;height:.5rem;transform:translateY(-50%) rotate(45deg);transition:transform .15s}.daff-tree-item.parent.open:after{top:56%;transform:translateY(-50%) rotate(225deg)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
259
- }
260
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeComponent, decorators: [{
261
- type: Component,
262
- args: [{ selector: 'ul[daff-tree]', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
263
- DaffTreeNotifierService,
264
- ], hostDirectives: [{
265
- directive: DaffArticleEncapsulatedDirective,
266
- }], host: {
267
- 'class': 'daff-tree',
268
- }, imports: [
269
- NgTemplateOutlet,
270
- ], template: "@for (node of flatTree(); track node.id) {\n\t<li [attr.aria-level]=\"node.level\" [class.hidden]=\"!node.visible\">\n\t\t<ng-container\n\t\t\t*ngTemplateOutlet=\"node.hasChildren ? withChildrenTemplate() : treeItemTemplate(); context: { $implicit: node }\">\n\t\t</ng-container>\n\t</li>\n}", styles: [".daff-tree{margin:0;padding:0;list-style:none;--tree-padding: 1rem}.daff-tree li.hidden{display:none}.daff-tree-item{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;position:relative;background:none;border:0;padding:.5rem 1rem .5rem 0;line-height:1.5rem;font-weight:400;text-align:left;text-decoration:none;width:100%;padding-left:calc(var(--tree-padding) * (var(--depth)))}.daff-tree-item:before{content:\"\";position:absolute;top:0;bottom:0;left:0;width:.25rem}.daff-tree-item:focus,.daff-tree-item:focus-visible{z-index:1}.daff-tree-item.selected{font-weight:500}.daff-tree-item.parent{position:relative;padding-right:2.5rem}.daff-tree-item.parent:after{content:\"\";position:absolute;top:48%;right:1rem;display:inline-block;border-right:2px solid currentColor;border-bottom:2px solid currentColor;width:.5rem;height:.5rem;transform:translateY(-50%) rotate(45deg);transition:transform .15s}.daff-tree-item.parent.open:after{top:56%;transform:translateY(-50%) rotate(225deg)}\n"] }]
271
- }], ctorParameters: () => [], propDecorators: { renderMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "renderMode", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], tree: [{ type: i0.Input, args: [{ isSignal: true, alias: "tree", required: false }] }], withChildrenTemplate: [{ type: i0.ContentChild, args: ['daffTreeItemWithChildrenTpl', { isSignal: true }] }], treeItemTemplate: [{ type: i0.ContentChild, args: ['daffTreeItemTpl', { isSignal: true }] }] } });
272
-
273
- /**
274
- * Walk up the tree from a leaf to the root applying the
275
- * visit function at each node along the way.
276
- */
103
+ var DaffTreeComponent = class DaffTreeComponent {
104
+ constructor() {
105
+ this.notifier = inject(DaffTreeNotifierService);
106
+ this.renderMode = input("in-dom", ...ngDevMode ? [{ debugName: "renderMode" }] : /* istanbul ignore next */ []);
107
+ this.id = input(`${daffTreeId++}`, ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
108
+ this.tree = input(...ngDevMode ? [void 0, { debugName: "tree" }] : /* istanbul ignore next */ []);
109
+ this._tree = computed(() => {
110
+ const tree = this.tree();
111
+ return tree ? hydrateTree(tree, this.id()) : void 0;
112
+ }, ...ngDevMode ? [{ debugName: "_tree" }] : /* istanbul ignore next */ []);
113
+ this._revision = signal(0, ...ngDevMode ? [{ debugName: "_revision" }] : /* istanbul ignore next */ []);
114
+ this.flatTree = computed(() => {
115
+ this._revision();
116
+ const tree = this._tree();
117
+ return tree ? flattenTree(tree, this.renderMode() === "not-in-dom") : [];
118
+ }, ...ngDevMode ? [{ debugName: "flatTree" }] : /* istanbul ignore next */ []);
119
+ this.withChildrenTemplate = contentChild("daffTreeItemWithChildrenTpl", ...ngDevMode ? [{ debugName: "withChildrenTemplate" }] : /* istanbul ignore next */ []);
120
+ this.treeItemTemplate = contentChild("daffTreeItemTpl", ...ngDevMode ? [{ debugName: "treeItemTemplate" }] : /* istanbul ignore next */ []);
121
+ this.notifier.notice$.subscribe(() => {
122
+ this._revision.update((r) => r + 1);
123
+ });
124
+ }
125
+ static {
126
+ this.ɵfac = i0.ɵɵngDeclareFactory({
127
+ minVersion: "12.0.0",
128
+ version: "22.2.4",
129
+ ngImport: i0,
130
+ type: DaffTreeComponent,
131
+ deps: [],
132
+ target: i0.ɵɵFactoryTarget.Component
133
+ });
134
+ }
135
+ static {
136
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
137
+ minVersion: "17.0.0",
138
+ version: "22.2.4",
139
+ type: DaffTreeComponent,
140
+ isStandalone: true,
141
+ selector: "ul[daff-tree]",
142
+ inputs: {
143
+ renderMode: {
144
+ classPropertyName: "renderMode",
145
+ publicName: "renderMode",
146
+ isSignal: true,
147
+ isRequired: false,
148
+ transformFunction: null
149
+ },
150
+ id: {
151
+ classPropertyName: "id",
152
+ publicName: "id",
153
+ isSignal: true,
154
+ isRequired: false,
155
+ transformFunction: null
156
+ },
157
+ tree: {
158
+ classPropertyName: "tree",
159
+ publicName: "tree",
160
+ isSignal: true,
161
+ isRequired: false,
162
+ transformFunction: null
163
+ }
164
+ },
165
+ host: { classAttribute: "daff-tree" },
166
+ providers: [DaffTreeNotifierService],
167
+ queries: [{
168
+ propertyName: "withChildrenTemplate",
169
+ first: true,
170
+ predicate: ["daffTreeItemWithChildrenTpl"],
171
+ descendants: true,
172
+ isSignal: true
173
+ }, {
174
+ propertyName: "treeItemTemplate",
175
+ first: true,
176
+ predicate: ["daffTreeItemTpl"],
177
+ descendants: true,
178
+ isSignal: true
179
+ }],
180
+ hostDirectives: [{ directive: i1.DaffArticleEncapsulatedDirective }],
181
+ ngImport: i0,
182
+ template: "@for (node of flatTree(); track node.id) {\n <li [attr.aria-level]=\"node.level\" [class.hidden]=\"!node.visible\">\n <ng-container\n *ngTemplateOutlet=\"node.hasChildren ? withChildrenTemplate() : treeItemTemplate(); context: { $implicit: node }\">\n </ng-container>\n </li>\n}",
183
+ styles: [".daff-tree{margin:0;padding:0;list-style:none;--tree-padding: 1rem}.daff-tree li.hidden{display:none}.daff-tree-item{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;position:relative;background:none;border:0;padding:.5rem 1rem .5rem 0;line-height:1.5rem;font-weight:400;text-align:left;text-decoration:none;width:100%;padding-left:calc(var(--tree-padding) * (var(--depth)))}.daff-tree-item:before{content:\"\";position:absolute;top:0;bottom:0;left:0;width:.25rem}.daff-tree-item:focus,.daff-tree-item:focus-visible{z-index:1}.daff-tree-item.selected{font-weight:500}.daff-tree-item.parent{position:relative;padding-right:2.5rem}.daff-tree-item.parent:after{content:\"\";position:absolute;top:48%;right:1rem;display:inline-block;border-right:.125rem solid currentColor;border-bottom:.125rem solid currentColor;width:.5rem;height:.5rem;transform:translateY(-50%) rotate(45deg);transition:transform .15s}.daff-tree-item.parent.open:after{top:56%;transform:translateY(-50%) rotate(225deg)}\n"],
184
+ dependencies: [{
185
+ kind: "directive",
186
+ type: NgTemplateOutlet,
187
+ selector: "[ngTemplateOutlet]",
188
+ inputs: [
189
+ "ngTemplateOutletContext",
190
+ "ngTemplateOutlet",
191
+ "ngTemplateOutletInjector"
192
+ ]
193
+ }],
194
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
195
+ encapsulation: i0.ViewEncapsulation.None
196
+ });
197
+ }
198
+ };
199
+ i0.ɵɵngDeclareClassMetadata({
200
+ minVersion: "12.0.0",
201
+ version: "22.2.4",
202
+ ngImport: i0,
203
+ type: DaffTreeComponent,
204
+ decorators: [{
205
+ type: Component,
206
+ args: [{
207
+ selector: "ul[daff-tree]",
208
+ encapsulation: ViewEncapsulation.None,
209
+ changeDetection: ChangeDetectionStrategy.OnPush,
210
+ providers: [DaffTreeNotifierService],
211
+ hostDirectives: [{ directive: DaffArticleEncapsulatedDirective }],
212
+ host: { "class": "daff-tree" },
213
+ imports: [NgTemplateOutlet],
214
+ template: "@for (node of flatTree(); track node.id) {\n <li [attr.aria-level]=\"node.level\" [class.hidden]=\"!node.visible\">\n <ng-container\n *ngTemplateOutlet=\"node.hasChildren ? withChildrenTemplate() : treeItemTemplate(); context: { $implicit: node }\">\n </ng-container>\n </li>\n}",
215
+ styles: [".daff-tree{margin:0;padding:0;list-style:none;--tree-padding: 1rem}.daff-tree li.hidden{display:none}.daff-tree-item{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;position:relative;background:none;border:0;padding:.5rem 1rem .5rem 0;line-height:1.5rem;font-weight:400;text-align:left;text-decoration:none;width:100%;padding-left:calc(var(--tree-padding) * (var(--depth)))}.daff-tree-item:before{content:\"\";position:absolute;top:0;bottom:0;left:0;width:.25rem}.daff-tree-item:focus,.daff-tree-item:focus-visible{z-index:1}.daff-tree-item.selected{font-weight:500}.daff-tree-item.parent{position:relative;padding-right:2.5rem}.daff-tree-item.parent:after{content:\"\";position:absolute;top:48%;right:1rem;display:inline-block;border-right:.125rem solid currentColor;border-bottom:.125rem solid currentColor;width:.5rem;height:.5rem;transform:translateY(-50%) rotate(45deg);transition:transform .15s}.daff-tree-item.parent.open:after{top:56%;transform:translateY(-50%) rotate(225deg)}\n"]
216
+ }]
217
+ }],
218
+ ctorParameters: () => [],
219
+ propDecorators: {
220
+ renderMode: [{
221
+ type: i0.Input,
222
+ args: [{
223
+ isSignal: true,
224
+ alias: "renderMode",
225
+ required: false
226
+ }]
227
+ }],
228
+ id: [{
229
+ type: i0.Input,
230
+ args: [{
231
+ isSignal: true,
232
+ alias: "id",
233
+ required: false
234
+ }]
235
+ }],
236
+ tree: [{
237
+ type: i0.Input,
238
+ args: [{
239
+ isSignal: true,
240
+ alias: "tree",
241
+ required: false
242
+ }]
243
+ }],
244
+ withChildrenTemplate: [{
245
+ type: i0.ContentChild,
246
+ args: ["daffTreeItemWithChildrenTpl", { isSignal: true }]
247
+ }],
248
+ treeItemTemplate: [{
249
+ type: i0.ContentChild,
250
+ args: ["daffTreeItemTpl", { isSignal: true }]
251
+ }]
252
+ }
253
+ });
277
254
  const walkUp = (tree, visit) => {
278
- while (tree.parent) {
279
- visit(tree);
280
- tree = tree.parent;
281
- }
282
- return tree;
255
+ while (tree.parent) {
256
+ visit(tree);
257
+ tree = tree.parent;
258
+ }
259
+ return tree;
283
260
  };
284
-
285
- /**
286
- * Open all ancestor nodes of the given node so that it becomes visible in the tree.
287
- */
288
261
  const daffTreeOpenAncestors = (node) => {
289
- walkUp(node, (ancestor) => {
290
- ancestor.open = true;
291
- return ancestor;
292
- });
262
+ walkUp(node, (ancestor) => {
263
+ ancestor.open = true;
264
+ return ancestor;
265
+ });
293
266
  };
294
-
295
- /* eslint-disable quote-props */
296
- /**
297
- * The `DaffTreeItemDirective` marks elements as tree child nodes that interact with the parent tree structure.
298
- *
299
- * @example Using a `[daffTreeItem]`
300
- *
301
- * `[tree]` is a {@link DaffTreeData} and `[daff-tree]` is a {@link DaffTreeComponent}.
302
- *
303
- * ```html
304
- * <ul daff-tree [tree]="tree">
305
- * <ng-template #daffTreeItemWithChildrenTpl let-node>
306
- * <button daffTreeItem [node]="node">{{ node.title }} </button>
307
- * </ng-template>
308
- *
309
- * <ng-template #daffTreeItemTpl let-node>
310
- * <a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a>
311
- * </ng-template>
312
- * </ul>
313
- * ```
314
- *
315
- */
316
- class DaffTreeItemDirective {
317
- constructor() {
318
- this.document = inject(DOCUMENT);
319
- this.treeNotifier = inject(DaffTreeNotifierService);
320
- /**
321
- * The {@link DaffTreeFlatNode} associated with this specific tree item.
322
- */
323
- this.node = input.required(...(ngDevMode ? [{ debugName: "node" }] : /* istanbul ignore next */ []));
324
- /**
325
- * Whether or not the tree item is the currently active item.
326
- * Note that there is no requirement that there only be one active item at a time.
327
- *
328
- * When a tree item becomes selected, all of its ancestor nodes
329
- * will be automatically opened so that the selected item is visible.
330
- */
331
- this.selected = input(false, ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
332
- /**
333
- * The html `id` of the tree item. This is derived from the {@link DaffTreeData}.
334
- */
335
- this.id = computed(() => 'tree-' + this.node().id, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
336
- /**
337
- * A property indicating the depth of the tree.
338
- */
339
- this.depth = computed(() => this.node().level, ...(ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []));
340
- /**
341
- * Whether or not this node has children.
342
- */
343
- this.isParent = computed(() => this.node().hasChildren, ...(ngDevMode ? [{ debugName: "isParent" }] : /* istanbul ignore next */ []));
344
- /**
345
- * Indicates whether or not the tree is `open`.
346
- */
347
- this.open = computed(() => this.node()._treeRef.open, ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
348
- /**
349
- * Accessibility property, notifying users about whether
350
- * or not the tree item is open.
351
- *
352
- * @docs-private
353
- */
354
- this.ariaExpanded = computed(() => {
355
- const node = this.node();
356
- return node.hasChildren ? (node._treeRef.open ? 'true' : 'false') : undefined;
357
- }, ...(ngDevMode ? [{ debugName: "ariaExpanded" }] : /* istanbul ignore next */ []));
358
- effect(() => {
359
- if (this.selected()) {
360
- const node = untracked(this.node);
361
- daffTreeOpenAncestors(node._treeRef);
362
- this.treeNotifier.notify();
363
- }
364
- });
365
- }
366
- /**
367
- * @docs-private
368
- */
369
- onEscape() {
370
- this.toggleParent(this.node());
371
- }
372
- /**
373
- * @docs-private
374
- */
375
- onClick() {
376
- if (this.node().hasChildren) {
377
- this.toggleTree(this.node());
378
- }
379
- this.treeNotifier.notify();
380
- }
381
- /**
382
- * Toggle the open state of the tree's parent.
383
- */
384
- toggleParent(node) {
385
- if (node._treeRef?.parent.parent === undefined) {
386
- return;
387
- }
388
- node._treeRef.parent.open = !node._treeRef.parent.open;
389
- this.document.getElementById('tree-' + node._treeRef.parent.id).focus();
390
- }
391
- /**
392
- * Toggle the open state of this specific subtree tree.
393
- */
394
- toggleTree(node) {
395
- if (node._treeRef.open === false) {
396
- node._treeRef.open = true;
397
- }
398
- else {
399
- node._treeRef.open = false;
400
- }
401
- }
402
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
403
- /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: DaffTreeItemDirective, isStandalone: true, selector: "[daffTreeItem]", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown.escape": "onEscape()", "click": "onClick()" }, properties: { "class.selected": "selected()", "class.parent": "isParent()", "class.open": "open()", "attr.id": "id()", "attr.aria-expanded": "ariaExpanded()", "style.--depth": "depth()" }, classAttribute: "daff-tree-item" }, ngImport: i0 }); }
404
- }
405
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeItemDirective, decorators: [{
406
- type: Directive,
407
- args: [{
408
- selector: '[daffTreeItem]',
409
- host: {
410
- 'class': 'daff-tree-item',
411
- '[class.selected]': 'selected()',
412
- '[class.parent]': 'isParent()',
413
- '[class.open]': 'open()',
414
- '[attr.id]': 'id()',
415
- '[attr.aria-expanded]': 'ariaExpanded()',
416
- '[style.--depth]': 'depth()',
417
- '(keydown.escape)': 'onEscape()',
418
- '(click)': 'onClick()',
419
- },
420
- }]
421
- }], ctorParameters: () => [], propDecorators: { node: [{ type: i0.Input, args: [{ isSignal: true, alias: "node", required: true }] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }] } });
422
-
423
- /**
424
- * @deprecated in favor of {@link DAFF_TREE_COMPONENTS}. Deprecated in version 0.78.0. Will be removed in version 1.0.0.
425
- */
426
- class DaffTreeModule {
427
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
428
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeModule, imports: [CommonModule,
429
- DaffTreeComponent,
430
- DaffTreeItemDirective], exports: [DaffTreeComponent,
431
- DaffTreeItemDirective] }); }
432
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeModule, imports: [CommonModule] }); }
433
- }
434
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffTreeModule, decorators: [{
435
- type: NgModule,
436
- args: [{
437
- imports: [
438
- CommonModule,
439
- DaffTreeComponent,
440
- DaffTreeItemDirective,
441
- ],
442
- exports: [
443
- DaffTreeComponent,
444
- DaffTreeItemDirective,
445
- ],
446
- }]
447
- }] });
448
-
449
- /**
450
- * Transform a tree-like structure into a {@link DaffTreeData}.
451
- *
452
- * @param tree - The data structure representing tree-like data.
453
- * @param transformFn - A user-supplied function that will transform the user
454
- * type into a {@link DaffTreeData}
455
- * @param key - The property of the your tree that indicates which
456
- * key contains the "children" of your tree structure.
457
- *
458
- */
267
+ var DaffTreeItemDirective = class DaffTreeItemDirective {
268
+ constructor() {
269
+ this.document = inject(DOCUMENT);
270
+ this.treeNotifier = inject(DaffTreeNotifierService);
271
+ this.node = input.required(...ngDevMode ? [{ debugName: "node" }] : /* istanbul ignore next */ []);
272
+ this.selected = input(false, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
273
+ this.id = computed(() => "tree-" + this.node().id, ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
274
+ this.depth = computed(() => this.node().level, ...ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []);
275
+ this.isParent = computed(() => this.node().hasChildren, ...ngDevMode ? [{ debugName: "isParent" }] : /* istanbul ignore next */ []);
276
+ this.open = computed(() => this.node()._treeRef.open, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
277
+ this.ariaExpanded = computed(() => {
278
+ const node = this.node();
279
+ return node.hasChildren ? node._treeRef.open ? "true" : "false" : void 0;
280
+ }, ...ngDevMode ? [{ debugName: "ariaExpanded" }] : /* istanbul ignore next */ []);
281
+ effect(() => {
282
+ if (this.selected()) {
283
+ const node = untracked(this.node);
284
+ daffTreeOpenAncestors(node._treeRef);
285
+ this.treeNotifier.notify();
286
+ }
287
+ });
288
+ }
289
+ onEscape() {
290
+ this.toggleParent(this.node());
291
+ }
292
+ onClick() {
293
+ if (this.node().hasChildren) this.toggleTree(this.node());
294
+ this.treeNotifier.notify();
295
+ }
296
+ toggleParent(node) {
297
+ if (node._treeRef?.parent.parent === void 0) return;
298
+ node._treeRef.parent.open = !node._treeRef.parent.open;
299
+ this.document.getElementById("tree-" + node._treeRef.parent.id).focus();
300
+ }
301
+ toggleTree(node) {
302
+ if (node._treeRef.open === false) node._treeRef.open = true;
303
+ else node._treeRef.open = false;
304
+ }
305
+ static {
306
+ this.ɵfac = i0.ɵɵngDeclareFactory({
307
+ minVersion: "12.0.0",
308
+ version: "22.2.4",
309
+ ngImport: i0,
310
+ type: DaffTreeItemDirective,
311
+ deps: [],
312
+ target: i0.ɵɵFactoryTarget.Directive
313
+ });
314
+ }
315
+ static {
316
+ this.ɵdir = i0.ɵɵngDeclareDirective({
317
+ minVersion: "17.1.0",
318
+ version: "22.2.4",
319
+ type: DaffTreeItemDirective,
320
+ isStandalone: true,
321
+ selector: "[daffTreeItem]",
322
+ inputs: {
323
+ node: {
324
+ classPropertyName: "node",
325
+ publicName: "node",
326
+ isSignal: true,
327
+ isRequired: true,
328
+ transformFunction: null
329
+ },
330
+ selected: {
331
+ classPropertyName: "selected",
332
+ publicName: "selected",
333
+ isSignal: true,
334
+ isRequired: false,
335
+ transformFunction: null
336
+ }
337
+ },
338
+ host: {
339
+ listeners: {
340
+ "keydown.escape": "onEscape()",
341
+ "click": "onClick()"
342
+ },
343
+ properties: {
344
+ "class.selected": "selected()",
345
+ "class.parent": "isParent()",
346
+ "class.open": "open()",
347
+ "attr.id": "id()",
348
+ "attr.aria-expanded": "ariaExpanded()",
349
+ "style.--depth": "depth()"
350
+ },
351
+ classAttribute: "daff-tree-item"
352
+ },
353
+ ngImport: i0
354
+ });
355
+ }
356
+ };
357
+ i0.ɵɵngDeclareClassMetadata({
358
+ minVersion: "12.0.0",
359
+ version: "22.2.4",
360
+ ngImport: i0,
361
+ type: DaffTreeItemDirective,
362
+ decorators: [{
363
+ type: Directive,
364
+ args: [{
365
+ selector: "[daffTreeItem]",
366
+ host: {
367
+ "class": "daff-tree-item",
368
+ "[class.selected]": "selected()",
369
+ "[class.parent]": "isParent()",
370
+ "[class.open]": "open()",
371
+ "[attr.id]": "id()",
372
+ "[attr.aria-expanded]": "ariaExpanded()",
373
+ "[style.--depth]": "depth()",
374
+ "(keydown.escape)": "onEscape()",
375
+ "(click)": "onClick()"
376
+ }
377
+ }]
378
+ }],
379
+ ctorParameters: () => [],
380
+ propDecorators: {
381
+ node: [{
382
+ type: i0.Input,
383
+ args: [{
384
+ isSignal: true,
385
+ alias: "node",
386
+ required: true
387
+ }]
388
+ }],
389
+ selected: [{
390
+ type: i0.Input,
391
+ args: [{
392
+ isSignal: true,
393
+ alias: "selected",
394
+ required: false
395
+ }]
396
+ }]
397
+ }
398
+ });
399
+ var DaffTreeModule = class DaffTreeModule {
400
+ static {
401
+ this.ɵfac = i0.ɵɵngDeclareFactory({
402
+ minVersion: "12.0.0",
403
+ version: "22.2.4",
404
+ ngImport: i0,
405
+ type: DaffTreeModule,
406
+ deps: [],
407
+ target: i0.ɵɵFactoryTarget.NgModule
408
+ });
409
+ }
410
+ static {
411
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
412
+ minVersion: "14.0.0",
413
+ version: "22.2.4",
414
+ ngImport: i0,
415
+ type: DaffTreeModule,
416
+ imports: [
417
+ CommonModule,
418
+ DaffTreeComponent,
419
+ DaffTreeItemDirective
420
+ ],
421
+ exports: [DaffTreeComponent, DaffTreeItemDirective]
422
+ });
423
+ }
424
+ static {
425
+ this.ɵinj = i0.ɵɵngDeclareInjector({
426
+ minVersion: "12.0.0",
427
+ version: "22.2.4",
428
+ ngImport: i0,
429
+ type: DaffTreeModule,
430
+ imports: [CommonModule]
431
+ });
432
+ }
433
+ };
434
+ i0.ɵɵngDeclareClassMetadata({
435
+ minVersion: "12.0.0",
436
+ version: "22.2.4",
437
+ ngImport: i0,
438
+ type: DaffTreeModule,
439
+ decorators: [{
440
+ type: NgModule,
441
+ args: [{
442
+ imports: [
443
+ CommonModule,
444
+ DaffTreeComponent,
445
+ DaffTreeItemDirective
446
+ ],
447
+ exports: [DaffTreeComponent, DaffTreeItemDirective]
448
+ }]
449
+ }]
450
+ });
459
451
  const daffTransformTree = (tree, transformFn, key) => {
460
- const transformedTree = transformFn(tree);
461
- const queue = [{ node: tree, parent: transformedTree }];
462
- while (queue.length > 0) {
463
- const { node, parent } = queue.shift();
464
- const childItems = node[key];
465
- for (const child of childItems) {
466
- const transformedChild = transformFn(child);
467
- parent.items.push(transformedChild);
468
- queue.push({ node: child, parent: transformedChild });
469
- }
470
- }
471
- return transformedTree;
452
+ const transformedTree = transformFn(tree);
453
+ const queue = [{
454
+ node: tree,
455
+ parent: transformedTree
456
+ }];
457
+ while (queue.length > 0) {
458
+ const { node, parent } = queue.shift();
459
+ const childItems = node[key];
460
+ for (const child of childItems) {
461
+ const transformedChild = transformFn(child);
462
+ parent.items.push(transformedChild);
463
+ queue.push({
464
+ node: child,
465
+ parent: transformedChild
466
+ });
467
+ }
468
+ }
469
+ return transformedTree;
472
470
  };
473
-
474
- /**
475
- * @docs-private
476
- */
477
- const DAFF_TREE_COMPONENTS = [
478
- DaffTreeComponent,
479
- DaffTreeItemDirective,
480
- ];
481
-
482
- /**
483
- * Generated bundle index. Do not edit.
484
- */
485
-
471
+ const DAFF_TREE_COMPONENTS = [DaffTreeComponent, DaffTreeItemDirective];
486
472
  export { DAFF_TREE_COMPONENTS, DaffTreeComponent, DaffTreeItemDirective, DaffTreeModule, daffTransformTree };
487
- //# sourceMappingURL=daffodil-design-tree.mjs.map
473
+
474
+ //# sourceMappingURL=daffodil-design-tree.mjs.map