@angular/aria 21.0.0-next.8 → 21.0.0-rc.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 (50) hide show
  1. package/_adev_assets/aria-accordion.json +373 -0
  2. package/_adev_assets/aria-combobox.json +383 -0
  3. package/_adev_assets/aria-grid.json +578 -0
  4. package/_adev_assets/aria-listbox.json +511 -0
  5. package/_adev_assets/aria-menu.json +752 -0
  6. package/_adev_assets/aria-radio-group.json +389 -0
  7. package/_adev_assets/aria-tabs.json +987 -0
  8. package/_adev_assets/aria-toolbar.json +717 -0
  9. package/_adev_assets/aria-tree.json +1067 -0
  10. package/fesm2022/_widget-chunk.mjs +827 -0
  11. package/fesm2022/_widget-chunk.mjs.map +1 -0
  12. package/fesm2022/accordion.mjs +371 -172
  13. package/fesm2022/accordion.mjs.map +1 -1
  14. package/fesm2022/aria.mjs +1 -2
  15. package/fesm2022/aria.mjs.map +1 -1
  16. package/fesm2022/combobox.mjs +304 -114
  17. package/fesm2022/combobox.mjs.map +1 -1
  18. package/fesm2022/deferred-content.mjs +89 -49
  19. package/fesm2022/deferred-content.mjs.map +1 -1
  20. package/fesm2022/grid.mjs +517 -0
  21. package/fesm2022/grid.mjs.map +1 -0
  22. package/fesm2022/listbox.mjs +384 -183
  23. package/fesm2022/listbox.mjs.map +1 -1
  24. package/fesm2022/menu.mjs +535 -0
  25. package/fesm2022/menu.mjs.map +1 -0
  26. package/fesm2022/private.mjs +2347 -0
  27. package/fesm2022/private.mjs.map +1 -0
  28. package/fesm2022/radio-group.mjs +320 -179
  29. package/fesm2022/radio-group.mjs.map +1 -1
  30. package/fesm2022/tabs.mjs +483 -274
  31. package/fesm2022/tabs.mjs.map +1 -1
  32. package/fesm2022/toolbar.mjs +330 -199
  33. package/fesm2022/toolbar.mjs.map +1 -1
  34. package/fesm2022/tree.mjs +511 -309
  35. package/fesm2022/tree.mjs.map +1 -1
  36. package/package.json +14 -6
  37. package/types/_grid-chunk.d.ts +546 -0
  38. package/types/accordion.d.ts +4 -4
  39. package/types/combobox.d.ts +18 -5
  40. package/types/deferred-content.d.ts +1 -0
  41. package/types/grid.d.ts +111 -0
  42. package/types/listbox.d.ts +6 -3
  43. package/types/menu.d.ts +158 -0
  44. package/types/{ui-patterns.d.ts → private.d.ts} +333 -133
  45. package/types/radio-group.d.ts +5 -3
  46. package/types/tabs.d.ts +4 -4
  47. package/types/toolbar.d.ts +4 -4
  48. package/types/tree.d.ts +17 -32
  49. package/fesm2022/ui-patterns.mjs +0 -2504
  50. package/fesm2022/ui-patterns.mjs.map +0 -1
package/fesm2022/tree.mjs CHANGED
@@ -4,325 +4,527 @@ import { _IdGenerator } from '@angular/cdk/a11y';
4
4
  import { Directionality } from '@angular/cdk/bidi';
5
5
  import * as i1 from '@angular/aria/deferred-content';
6
6
  import { DeferredContentAware, DeferredContent } from '@angular/aria/deferred-content';
7
- import { ComboboxTreePattern, TreePattern, TreeItemPattern } from '@angular/aria/ui-patterns';
7
+ import { ComboboxTreePattern, TreePattern, TreeItemPattern } from '@angular/aria/private';
8
8
  import { ComboboxPopup } from './combobox.mjs';
9
+ import '@angular/core/rxjs-interop';
9
10
 
10
- /**
11
- * Sort directives by their document order.
12
- */
13
11
  function sortDirectives(a, b) {
14
- return (a.element().compareDocumentPosition(b.element()) & Node.DOCUMENT_POSITION_PRECEDING) > 0
15
- ? 1
16
- : -1;
12
+ return (a.element().compareDocumentPosition(b.element()) & Node.DOCUMENT_POSITION_PRECEDING) > 0 ? 1 : -1;
17
13
  }
18
- /**
19
- * A Tree container.
20
- *
21
- * Transforms nested lists into an accessible, ARIA-compliant tree structure.
22
- *
23
- * ```html
24
- * <ul ngTree [(value)]="selectedItems" [multi]="true">
25
- * <li ngTreeItem [value]="'leaf1'">Leaf Item 1</li>
26
- * <li ngTreeItem [value]="'parent1'">
27
- * Parent Item 1
28
- * <ul ngTreeItemGroup [value]="'parent1'">
29
- * <ng-template ngTreeItemGroupContent>
30
- * <li ngTreeItem [value]="'child1.1'">Child Item 1.1</li>
31
- * <li ngTreeItem [value]="'child1.2'">Child Item 1.2</li>
32
- * </ng-template>
33
- * </ul>
34
- * </li>
35
- * <li ngTreeItem [value]="'leaf2'" [disabled]="true">Disabled Leaf Item 2</li>
36
- * </ul>
37
- * ```
38
- */
39
14
  class Tree {
40
- /** A unique identifier for the tree. */
41
- _generatedId = inject(_IdGenerator).getId('ng-tree-');
42
- // TODO(wagnermaciel): https://github.com/angular/components/pull/30495#discussion_r1972601144.
43
- /** A unique identifier for the tree. */
44
- id = computed(() => this._generatedId, ...(ngDevMode ? [{ debugName: "id" }] : []));
45
- /** A reference to the parent combobox popup, if one exists. */
46
- _popup = inject(ComboboxPopup, {
47
- optional: true,
48
- });
49
- /** A reference to the tree element. */
50
- _elementRef = inject(ElementRef);
51
- /** All TreeItem instances within this tree. */
52
- _unorderedItems = signal(new Set(), ...(ngDevMode ? [{ debugName: "_unorderedItems" }] : []));
53
- /** Orientation of the tree. */
54
- orientation = input('vertical', ...(ngDevMode ? [{ debugName: "orientation" }] : []));
55
- /** Whether multi-selection is allowed. */
56
- multi = input(false, ...(ngDevMode ? [{ debugName: "multi", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
57
- /** Whether the tree is disabled. */
58
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
59
- /** The selection strategy used by the tree. */
60
- selectionMode = input('explicit', ...(ngDevMode ? [{ debugName: "selectionMode" }] : []));
61
- /** The focus strategy used by the tree. */
62
- focusMode = input('roving', ...(ngDevMode ? [{ debugName: "focusMode" }] : []));
63
- /** Whether navigation wraps. */
64
- wrap = input(true, ...(ngDevMode ? [{ debugName: "wrap", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
65
- /** Whether to skip disabled items during navigation. */
66
- skipDisabled = input(true, ...(ngDevMode ? [{ debugName: "skipDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
67
- /** Typeahead delay. */
68
- typeaheadDelay = input(0.5, ...(ngDevMode ? [{ debugName: "typeaheadDelay" }] : []));
69
- /** Selected item values. */
70
- value = model([], ...(ngDevMode ? [{ debugName: "value" }] : []));
71
- /** Text direction. */
72
- textDirection = inject(Directionality).valueSignal;
73
- /** Whether the tree is in navigation mode. */
74
- nav = input(false, ...(ngDevMode ? [{ debugName: "nav" }] : []));
75
- /** The aria-current type. */
76
- currentType = input('page', ...(ngDevMode ? [{ debugName: "currentType" }] : []));
77
- /** The UI pattern for the tree. */
78
- pattern;
79
- /** Whether the tree has received focus yet. */
80
- _hasFocused = signal(false, ...(ngDevMode ? [{ debugName: "_hasFocused" }] : []));
81
- constructor() {
82
- const inputs = {
83
- ...this,
84
- id: this.id,
85
- allItems: computed(() => [...this._unorderedItems()].sort(sortDirectives).map(item => item.pattern)),
86
- activeItem: signal(undefined),
87
- element: () => this._elementRef.nativeElement,
88
- combobox: () => this._popup?.combobox?.pattern,
89
- };
90
- this.pattern = this._popup?.combobox
91
- ? new ComboboxTreePattern(inputs)
92
- : new TreePattern(inputs);
93
- if (this._popup?.combobox) {
94
- this._popup?.controls?.set(this.pattern);
95
- }
96
- afterRenderEffect(() => {
97
- if (!this._hasFocused()) {
98
- this.pattern.setDefaultState();
99
- }
100
- });
101
- afterRenderEffect(() => {
102
- const items = inputs.allItems();
103
- const activeItem = untracked(() => inputs.activeItem());
104
- if (!items.some(i => i === activeItem) && activeItem) {
105
- this.pattern.listBehavior.unfocus();
106
- }
107
- });
108
- afterRenderEffect(() => {
109
- const items = inputs.allItems();
110
- const value = untracked(() => this.value());
111
- if (items && value.some(v => !items.some(i => i.value() === v))) {
112
- this.value.set(value.filter(v => items.some(i => i.value() === v)));
113
- }
114
- });
115
- }
116
- onFocus() {
117
- this._hasFocused.set(true);
118
- }
119
- register(child) {
120
- this._unorderedItems().add(child);
121
- this._unorderedItems.set(new Set(this._unorderedItems()));
15
+ _generatedId = inject(_IdGenerator).getId('ng-tree-');
16
+ id = computed(() => this._generatedId, ...(ngDevMode ? [{
17
+ debugName: "id"
18
+ }] : []));
19
+ _popup = inject(ComboboxPopup, {
20
+ optional: true
21
+ });
22
+ _elementRef = inject(ElementRef);
23
+ _unorderedItems = signal(new Set(), ...(ngDevMode ? [{
24
+ debugName: "_unorderedItems"
25
+ }] : []));
26
+ orientation = input('vertical', ...(ngDevMode ? [{
27
+ debugName: "orientation"
28
+ }] : []));
29
+ multi = input(false, ...(ngDevMode ? [{
30
+ debugName: "multi",
31
+ transform: booleanAttribute
32
+ }] : [{
33
+ transform: booleanAttribute
34
+ }]));
35
+ disabled = input(false, ...(ngDevMode ? [{
36
+ debugName: "disabled",
37
+ transform: booleanAttribute
38
+ }] : [{
39
+ transform: booleanAttribute
40
+ }]));
41
+ selectionMode = input('explicit', ...(ngDevMode ? [{
42
+ debugName: "selectionMode"
43
+ }] : []));
44
+ focusMode = input('roving', ...(ngDevMode ? [{
45
+ debugName: "focusMode"
46
+ }] : []));
47
+ wrap = input(true, ...(ngDevMode ? [{
48
+ debugName: "wrap",
49
+ transform: booleanAttribute
50
+ }] : [{
51
+ transform: booleanAttribute
52
+ }]));
53
+ skipDisabled = input(true, ...(ngDevMode ? [{
54
+ debugName: "skipDisabled",
55
+ transform: booleanAttribute
56
+ }] : [{
57
+ transform: booleanAttribute
58
+ }]));
59
+ typeaheadDelay = input(0.5, ...(ngDevMode ? [{
60
+ debugName: "typeaheadDelay"
61
+ }] : []));
62
+ value = model([], ...(ngDevMode ? [{
63
+ debugName: "value"
64
+ }] : []));
65
+ textDirection = inject(Directionality).valueSignal;
66
+ nav = input(false, ...(ngDevMode ? [{
67
+ debugName: "nav"
68
+ }] : []));
69
+ currentType = input('page', ...(ngDevMode ? [{
70
+ debugName: "currentType"
71
+ }] : []));
72
+ _pattern;
73
+ _hasFocused = signal(false, ...(ngDevMode ? [{
74
+ debugName: "_hasFocused"
75
+ }] : []));
76
+ constructor() {
77
+ const inputs = {
78
+ ...this,
79
+ id: this.id,
80
+ allItems: computed(() => [...this._unorderedItems()].sort(sortDirectives).map(item => item._pattern)),
81
+ activeItem: signal(undefined),
82
+ element: () => this._elementRef.nativeElement,
83
+ combobox: () => this._popup?.combobox?._pattern
84
+ };
85
+ this._pattern = this._popup?.combobox ? new ComboboxTreePattern(inputs) : new TreePattern(inputs);
86
+ if (this._popup?.combobox) {
87
+ this._popup?.controls?.set(this._pattern);
122
88
  }
123
- unregister(child) {
124
- this._unorderedItems().delete(child);
125
- this._unorderedItems.set(new Set(this._unorderedItems()));
126
- }
127
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: Tree, deps: [], target: i0.ɵɵFactoryTarget.Directive });
128
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: Tree, isStandalone: true, selector: "[ngTree]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, multi: { classPropertyName: "multi", publicName: "multi", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, selectionMode: { classPropertyName: "selectionMode", publicName: "selectionMode", isSignal: true, isRequired: false, transformFunction: null }, focusMode: { classPropertyName: "focusMode", publicName: "focusMode", isSignal: true, isRequired: false, transformFunction: null }, wrap: { classPropertyName: "wrap", publicName: "wrap", isSignal: true, isRequired: false, transformFunction: null }, skipDisabled: { classPropertyName: "skipDisabled", publicName: "skipDisabled", isSignal: true, isRequired: false, transformFunction: null }, typeaheadDelay: { classPropertyName: "typeaheadDelay", publicName: "typeaheadDelay", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, nav: { classPropertyName: "nav", publicName: "nav", isSignal: true, isRequired: false, transformFunction: null }, currentType: { classPropertyName: "currentType", publicName: "currentType", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { attributes: { "role": "tree" }, listeners: { "keydown": "pattern.onKeydown($event)", "pointerdown": "pattern.onPointerdown($event)", "focusin": "onFocus()" }, properties: { "attr.id": "id()", "attr.aria-orientation": "pattern.orientation()", "attr.aria-multiselectable": "pattern.multi()", "attr.aria-disabled": "pattern.disabled()", "attr.aria-activedescendant": "pattern.activedescendant()", "tabindex": "pattern.tabindex()" }, classAttribute: "ng-tree" }, exportAs: ["ngTree"], hostDirectives: [{ directive: ComboboxPopup }], ngImport: i0 });
89
+ afterRenderEffect(() => {
90
+ if (!this._hasFocused()) {
91
+ this._pattern.setDefaultState();
92
+ }
93
+ });
94
+ afterRenderEffect(() => {
95
+ const items = inputs.allItems();
96
+ const activeItem = untracked(() => inputs.activeItem());
97
+ if (!items.some(i => i === activeItem) && activeItem) {
98
+ this._pattern.listBehavior.unfocus();
99
+ }
100
+ });
101
+ afterRenderEffect(() => {
102
+ const items = inputs.allItems();
103
+ const value = untracked(() => this.value());
104
+ if (items && value.some(v => !items.some(i => i.value() === v))) {
105
+ this.value.set(value.filter(v => items.some(i => i.value() === v)));
106
+ }
107
+ });
108
+ }
109
+ onFocus() {
110
+ this._hasFocused.set(true);
111
+ }
112
+ register(child) {
113
+ this._unorderedItems().add(child);
114
+ this._unorderedItems.set(new Set(this._unorderedItems()));
115
+ }
116
+ unregister(child) {
117
+ this._unorderedItems().delete(child);
118
+ this._unorderedItems.set(new Set(this._unorderedItems()));
119
+ }
120
+ scrollActiveItemIntoView(options = {
121
+ block: 'nearest'
122
+ }) {
123
+ this._pattern.inputs.activeItem()?.element().scrollIntoView(options);
124
+ }
125
+ static ɵfac = i0.ɵɵngDeclareFactory({
126
+ minVersion: "12.0.0",
127
+ version: "20.2.0-next.2",
128
+ ngImport: i0,
129
+ type: Tree,
130
+ deps: [],
131
+ target: i0.ɵɵFactoryTarget.Directive
132
+ });
133
+ static ɵdir = i0.ɵɵngDeclareDirective({
134
+ minVersion: "17.1.0",
135
+ version: "20.2.0-next.2",
136
+ type: Tree,
137
+ isStandalone: true,
138
+ selector: "[ngTree]",
139
+ inputs: {
140
+ orientation: {
141
+ classPropertyName: "orientation",
142
+ publicName: "orientation",
143
+ isSignal: true,
144
+ isRequired: false,
145
+ transformFunction: null
146
+ },
147
+ multi: {
148
+ classPropertyName: "multi",
149
+ publicName: "multi",
150
+ isSignal: true,
151
+ isRequired: false,
152
+ transformFunction: null
153
+ },
154
+ disabled: {
155
+ classPropertyName: "disabled",
156
+ publicName: "disabled",
157
+ isSignal: true,
158
+ isRequired: false,
159
+ transformFunction: null
160
+ },
161
+ selectionMode: {
162
+ classPropertyName: "selectionMode",
163
+ publicName: "selectionMode",
164
+ isSignal: true,
165
+ isRequired: false,
166
+ transformFunction: null
167
+ },
168
+ focusMode: {
169
+ classPropertyName: "focusMode",
170
+ publicName: "focusMode",
171
+ isSignal: true,
172
+ isRequired: false,
173
+ transformFunction: null
174
+ },
175
+ wrap: {
176
+ classPropertyName: "wrap",
177
+ publicName: "wrap",
178
+ isSignal: true,
179
+ isRequired: false,
180
+ transformFunction: null
181
+ },
182
+ skipDisabled: {
183
+ classPropertyName: "skipDisabled",
184
+ publicName: "skipDisabled",
185
+ isSignal: true,
186
+ isRequired: false,
187
+ transformFunction: null
188
+ },
189
+ typeaheadDelay: {
190
+ classPropertyName: "typeaheadDelay",
191
+ publicName: "typeaheadDelay",
192
+ isSignal: true,
193
+ isRequired: false,
194
+ transformFunction: null
195
+ },
196
+ value: {
197
+ classPropertyName: "value",
198
+ publicName: "value",
199
+ isSignal: true,
200
+ isRequired: false,
201
+ transformFunction: null
202
+ },
203
+ nav: {
204
+ classPropertyName: "nav",
205
+ publicName: "nav",
206
+ isSignal: true,
207
+ isRequired: false,
208
+ transformFunction: null
209
+ },
210
+ currentType: {
211
+ classPropertyName: "currentType",
212
+ publicName: "currentType",
213
+ isSignal: true,
214
+ isRequired: false,
215
+ transformFunction: null
216
+ }
217
+ },
218
+ outputs: {
219
+ value: "valueChange"
220
+ },
221
+ host: {
222
+ attributes: {
223
+ "role": "tree"
224
+ },
225
+ listeners: {
226
+ "keydown": "_pattern.onKeydown($event)",
227
+ "pointerdown": "_pattern.onPointerdown($event)",
228
+ "focusin": "onFocus()"
229
+ },
230
+ properties: {
231
+ "attr.id": "id()",
232
+ "attr.aria-orientation": "_pattern.orientation()",
233
+ "attr.aria-multiselectable": "_pattern.multi()",
234
+ "attr.aria-disabled": "_pattern.disabled()",
235
+ "attr.aria-activedescendant": "_pattern.activedescendant()",
236
+ "tabindex": "_pattern.tabindex()"
237
+ },
238
+ classAttribute: "ng-tree"
239
+ },
240
+ exportAs: ["ngTree"],
241
+ hostDirectives: [{
242
+ directive: ComboboxPopup
243
+ }],
244
+ ngImport: i0
245
+ });
129
246
  }
130
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: Tree, decorators: [{
131
- type: Directive,
132
- args: [{
133
- selector: '[ngTree]',
134
- exportAs: 'ngTree',
135
- host: {
136
- 'class': 'ng-tree',
137
- 'role': 'tree',
138
- '[attr.id]': 'id()',
139
- '[attr.aria-orientation]': 'pattern.orientation()',
140
- '[attr.aria-multiselectable]': 'pattern.multi()',
141
- '[attr.aria-disabled]': 'pattern.disabled()',
142
- '[attr.aria-activedescendant]': 'pattern.activedescendant()',
143
- '[tabindex]': 'pattern.tabindex()',
144
- '(keydown)': 'pattern.onKeydown($event)',
145
- '(pointerdown)': 'pattern.onPointerdown($event)',
146
- '(focusin)': 'onFocus()',
147
- },
148
- hostDirectives: [{ directive: ComboboxPopup }],
149
- }]
150
- }], ctorParameters: () => [] });
151
- /**
152
- * A selectable and expandable Tree Item in a Tree.
153
- */
154
- class TreeItem {
155
- /** A reference to the tree item element. */
156
- _elementRef = inject(ElementRef);
157
- /** A unique identifier for the tree item. */
158
- _id = inject(_IdGenerator).getId('ng-tree-item-');
159
- /** The owned tree item group. */
160
- _group = signal(undefined, ...(ngDevMode ? [{ debugName: "_group" }] : []));
161
- /** The id of the owned group. */
162
- ownsId = computed(() => this._group()?.id, ...(ngDevMode ? [{ debugName: "ownsId" }] : []));
163
- /** The host native element. */
164
- element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{ debugName: "element" }] : []));
165
- /** The value of the tree item. */
166
- value = input.required(...(ngDevMode ? [{ debugName: "value" }] : []));
167
- /** The parent tree root or tree item group. */
168
- parent = input.required(...(ngDevMode ? [{ debugName: "parent" }] : []));
169
- /** Whether the tree item is disabled. */
170
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
171
- /** Optional label for typeahead. Defaults to the element's textContent. */
172
- label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
173
- /** Search term for typeahead. */
174
- searchTerm = computed(() => this.label() ?? this.element().textContent, ...(ngDevMode ? [{ debugName: "searchTerm" }] : []));
175
- /** The tree root. */
176
- tree = computed(() => {
177
- if (this.parent() instanceof Tree) {
178
- return this.parent();
179
- }
180
- return this.parent().ownedBy().tree();
181
- }, ...(ngDevMode ? [{ debugName: "tree" }] : []));
182
- /** The UI pattern for this item. */
183
- pattern;
184
- constructor() {
185
- // Updates the visibility of the owned group.
186
- afterRenderEffect(() => {
187
- this._group()?.visible.set(this.pattern.expanded());
188
- });
189
- }
190
- ngOnInit() {
191
- this.parent().register(this);
192
- this.tree().register(this);
193
- const treePattern = computed(() => this.tree().pattern, ...(ngDevMode ? [{ debugName: "treePattern" }] : []));
194
- const parentPattern = computed(() => {
195
- if (this.parent() instanceof Tree) {
196
- return treePattern();
197
- }
198
- return this.parent().ownedBy().pattern;
199
- }, ...(ngDevMode ? [{ debugName: "parentPattern" }] : []));
200
- this.pattern = new TreeItemPattern({
201
- ...this,
202
- id: () => this._id,
203
- tree: treePattern,
204
- parent: parentPattern,
205
- children: computed(() => this._group()
206
- ?.children()
207
- .map(item => item.pattern) ?? []),
208
- hasChildren: computed(() => !!this._group()),
209
- });
210
- }
211
- ngOnDestroy() {
212
- this.parent().unregister(this);
213
- this.tree().unregister(this);
214
- }
215
- register(group) {
216
- this._group.set(group);
247
+ i0.ɵɵngDeclareClassMetadata({
248
+ minVersion: "12.0.0",
249
+ version: "20.2.0-next.2",
250
+ ngImport: i0,
251
+ type: Tree,
252
+ decorators: [{
253
+ type: Directive,
254
+ args: [{
255
+ selector: '[ngTree]',
256
+ exportAs: 'ngTree',
257
+ host: {
258
+ 'class': 'ng-tree',
259
+ 'role': 'tree',
260
+ '[attr.id]': 'id()',
261
+ '[attr.aria-orientation]': '_pattern.orientation()',
262
+ '[attr.aria-multiselectable]': '_pattern.multi()',
263
+ '[attr.aria-disabled]': '_pattern.disabled()',
264
+ '[attr.aria-activedescendant]': '_pattern.activedescendant()',
265
+ '[tabindex]': '_pattern.tabindex()',
266
+ '(keydown)': '_pattern.onKeydown($event)',
267
+ '(pointerdown)': '_pattern.onPointerdown($event)',
268
+ '(focusin)': 'onFocus()'
269
+ },
270
+ hostDirectives: [{
271
+ directive: ComboboxPopup
272
+ }]
273
+ }]
274
+ }],
275
+ ctorParameters: () => []
276
+ });
277
+ class TreeItem extends DeferredContentAware {
278
+ _elementRef = inject(ElementRef);
279
+ _id = inject(_IdGenerator).getId('ng-tree-item-');
280
+ _group = signal(undefined, ...(ngDevMode ? [{
281
+ debugName: "_group"
282
+ }] : []));
283
+ element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{
284
+ debugName: "element"
285
+ }] : []));
286
+ value = input.required(...(ngDevMode ? [{
287
+ debugName: "value"
288
+ }] : []));
289
+ parent = input.required(...(ngDevMode ? [{
290
+ debugName: "parent"
291
+ }] : []));
292
+ disabled = input(false, ...(ngDevMode ? [{
293
+ debugName: "disabled",
294
+ transform: booleanAttribute
295
+ }] : [{
296
+ transform: booleanAttribute
297
+ }]));
298
+ selectable = input(true, ...(ngDevMode ? [{
299
+ debugName: "selectable"
300
+ }] : []));
301
+ label = input(...(ngDevMode ? [undefined, {
302
+ debugName: "label"
303
+ }] : []));
304
+ searchTerm = computed(() => this.label() ?? this.element().textContent, ...(ngDevMode ? [{
305
+ debugName: "searchTerm"
306
+ }] : []));
307
+ tree = computed(() => {
308
+ if (this.parent() instanceof Tree) {
309
+ return this.parent();
217
310
  }
218
- unregister() {
219
- this._group.set(undefined);
220
- }
221
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
222
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: TreeItem, isStandalone: true, selector: "[ngTreeItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, parent: { classPropertyName: "parent", publicName: "parent", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "treeitem" }, properties: { "attr.data-active": "pattern.active()", "id": "pattern.id()", "attr.aria-expanded": "pattern.expandable() ? pattern.expanded() : null", "attr.aria-selected": "pattern.selected()", "attr.aria-current": "pattern.current()", "attr.aria-disabled": "pattern.disabled()", "attr.aria-level": "pattern.level()", "attr.aria-owns": "ownsId()", "attr.aria-setsize": "pattern.setsize()", "attr.aria-posinset": "pattern.posinset()", "attr.tabindex": "pattern.tabindex()" }, classAttribute: "ng-treeitem" }, exportAs: ["ngTreeItem"], ngImport: i0 });
311
+ return this.parent().ownedBy().tree();
312
+ }, ...(ngDevMode ? [{
313
+ debugName: "tree"
314
+ }] : []));
315
+ _pattern;
316
+ constructor() {
317
+ super();
318
+ this.preserveContent.set(true);
319
+ afterRenderEffect(() => {
320
+ this.tree()._pattern instanceof ComboboxTreePattern ? this.contentVisible.set(true) : this.contentVisible.set(this._pattern.expanded());
321
+ });
322
+ }
323
+ ngOnInit() {
324
+ this.parent().register(this);
325
+ this.tree().register(this);
326
+ const treePattern = computed(() => this.tree()._pattern, ...(ngDevMode ? [{
327
+ debugName: "treePattern"
328
+ }] : []));
329
+ const parentPattern = computed(() => {
330
+ if (this.parent() instanceof Tree) {
331
+ return treePattern();
332
+ }
333
+ return this.parent().ownedBy()._pattern;
334
+ }, ...(ngDevMode ? [{
335
+ debugName: "parentPattern"
336
+ }] : []));
337
+ this._pattern = new TreeItemPattern({
338
+ ...this,
339
+ id: () => this._id,
340
+ tree: treePattern,
341
+ parent: parentPattern,
342
+ children: computed(() => this._group()?.children() ?? []),
343
+ hasChildren: computed(() => !!this._group())
344
+ });
345
+ }
346
+ ngOnDestroy() {
347
+ this.parent().unregister(this);
348
+ this.tree().unregister(this);
349
+ }
350
+ register(group) {
351
+ this._group.set(group);
352
+ }
353
+ unregister() {
354
+ this._group.set(undefined);
355
+ }
356
+ static ɵfac = i0.ɵɵngDeclareFactory({
357
+ minVersion: "12.0.0",
358
+ version: "20.2.0-next.2",
359
+ ngImport: i0,
360
+ type: TreeItem,
361
+ deps: [],
362
+ target: i0.ɵɵFactoryTarget.Directive
363
+ });
364
+ static ɵdir = i0.ɵɵngDeclareDirective({
365
+ minVersion: "17.1.0",
366
+ version: "20.2.0-next.2",
367
+ type: TreeItem,
368
+ isStandalone: true,
369
+ selector: "[ngTreeItem]",
370
+ inputs: {
371
+ value: {
372
+ classPropertyName: "value",
373
+ publicName: "value",
374
+ isSignal: true,
375
+ isRequired: true,
376
+ transformFunction: null
377
+ },
378
+ parent: {
379
+ classPropertyName: "parent",
380
+ publicName: "parent",
381
+ isSignal: true,
382
+ isRequired: true,
383
+ transformFunction: null
384
+ },
385
+ disabled: {
386
+ classPropertyName: "disabled",
387
+ publicName: "disabled",
388
+ isSignal: true,
389
+ isRequired: false,
390
+ transformFunction: null
391
+ },
392
+ selectable: {
393
+ classPropertyName: "selectable",
394
+ publicName: "selectable",
395
+ isSignal: true,
396
+ isRequired: false,
397
+ transformFunction: null
398
+ },
399
+ label: {
400
+ classPropertyName: "label",
401
+ publicName: "label",
402
+ isSignal: true,
403
+ isRequired: false,
404
+ transformFunction: null
405
+ }
406
+ },
407
+ host: {
408
+ attributes: {
409
+ "role": "treeitem"
410
+ },
411
+ properties: {
412
+ "attr.data-active": "_pattern.active()",
413
+ "id": "_pattern.id()",
414
+ "attr.aria-expanded": "_pattern.expandable() ? _pattern.expanded() : null",
415
+ "attr.aria-selected": "_pattern.selected()",
416
+ "attr.aria-current": "_pattern.current()",
417
+ "attr.aria-disabled": "_pattern.disabled()",
418
+ "attr.aria-level": "_pattern.level()",
419
+ "attr.aria-setsize": "_pattern.setsize()",
420
+ "attr.aria-posinset": "_pattern.posinset()",
421
+ "attr.tabindex": "_pattern.tabindex()"
422
+ },
423
+ classAttribute: "ng-treeitem"
424
+ },
425
+ exportAs: ["ngTreeItem"],
426
+ usesInheritance: true,
427
+ ngImport: i0
428
+ });
223
429
  }
224
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItem, decorators: [{
225
- type: Directive,
226
- args: [{
227
- selector: '[ngTreeItem]',
228
- exportAs: 'ngTreeItem',
229
- host: {
230
- 'class': 'ng-treeitem',
231
- '[attr.data-active]': 'pattern.active()',
232
- 'role': 'treeitem',
233
- '[id]': 'pattern.id()',
234
- '[attr.aria-expanded]': 'pattern.expandable() ? pattern.expanded() : null',
235
- '[attr.aria-selected]': 'pattern.selected()',
236
- '[attr.aria-current]': 'pattern.current()',
237
- '[attr.aria-disabled]': 'pattern.disabled()',
238
- '[attr.aria-level]': 'pattern.level()',
239
- '[attr.aria-owns]': 'ownsId()',
240
- '[attr.aria-setsize]': 'pattern.setsize()',
241
- '[attr.aria-posinset]': 'pattern.posinset()',
242
- '[attr.tabindex]': 'pattern.tabindex()',
243
- },
244
- }]
245
- }], ctorParameters: () => [] });
246
- /**
247
- * Container that designates content as a group.
248
- */
430
+ i0.ɵɵngDeclareClassMetadata({
431
+ minVersion: "12.0.0",
432
+ version: "20.2.0-next.2",
433
+ ngImport: i0,
434
+ type: TreeItem,
435
+ decorators: [{
436
+ type: Directive,
437
+ args: [{
438
+ selector: '[ngTreeItem]',
439
+ exportAs: 'ngTreeItem',
440
+ host: {
441
+ 'class': 'ng-treeitem',
442
+ '[attr.data-active]': '_pattern.active()',
443
+ 'role': 'treeitem',
444
+ '[id]': '_pattern.id()',
445
+ '[attr.aria-expanded]': '_pattern.expandable() ? _pattern.expanded() : null',
446
+ '[attr.aria-selected]': '_pattern.selected()',
447
+ '[attr.aria-current]': '_pattern.current()',
448
+ '[attr.aria-disabled]': '_pattern.disabled()',
449
+ '[attr.aria-level]': '_pattern.level()',
450
+ '[attr.aria-setsize]': '_pattern.setsize()',
451
+ '[attr.aria-posinset]': '_pattern.posinset()',
452
+ '[attr.tabindex]': '_pattern.tabindex()'
453
+ }
454
+ }]
455
+ }],
456
+ ctorParameters: () => []
457
+ });
249
458
  class TreeItemGroup {
250
- /** A reference to the group element. */
251
- _elementRef = inject(ElementRef);
252
- /** The DeferredContentAware host directive. */
253
- _deferredContentAware = inject(DeferredContentAware);
254
- /** All groupable items that are descendants of the group. */
255
- _unorderedItems = signal(new Set(), ...(ngDevMode ? [{ debugName: "_unorderedItems" }] : []));
256
- /** The host native element. */
257
- element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{ debugName: "element" }] : []));
258
- /** Unique ID for the group. */
259
- id = inject(_IdGenerator).getId('ng-tree-group-');
260
- /** Whether the group is visible. */
261
- visible = signal(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
262
- /** Child items within this group. */
263
- children = computed(() => [...this._unorderedItems()].sort(sortDirectives), ...(ngDevMode ? [{ debugName: "children" }] : []));
264
- /** Tree item that owns the group. */
265
- ownedBy = input.required(...(ngDevMode ? [{ debugName: "ownedBy" }] : []));
266
- constructor() {
267
- this._deferredContentAware.preserveContent.set(true);
268
- // Connect the group's hidden state to the DeferredContentAware's visibility.
269
- afterRenderEffect(() => {
270
- this.ownedBy().tree().pattern instanceof ComboboxTreePattern
271
- ? this._deferredContentAware.contentVisible.set(true)
272
- : this._deferredContentAware.contentVisible.set(this.visible());
273
- });
274
- }
275
- ngOnInit() {
276
- this.ownedBy().register(this);
277
- }
278
- ngOnDestroy() {
279
- this.ownedBy().unregister();
280
- }
281
- register(child) {
282
- this._unorderedItems().add(child);
283
- this._unorderedItems.set(new Set(this._unorderedItems()));
284
- }
285
- unregister(child) {
286
- this._unorderedItems().delete(child);
287
- this._unorderedItems.set(new Set(this._unorderedItems()));
288
- }
289
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItemGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
290
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: TreeItemGroup, isStandalone: true, selector: "[ngTreeItemGroup]", inputs: { ownedBy: { classPropertyName: "ownedBy", publicName: "ownedBy", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "id": "id", "attr.inert": "visible() ? null : true" }, classAttribute: "ng-treeitem-group" }, exportAs: ["ngTreeItemGroup"], hostDirectives: [{ directive: i1.DeferredContentAware, inputs: ["preserveContent", "preserveContent"] }], ngImport: i0 });
291
- }
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItemGroup, decorators: [{
293
- type: Directive,
294
- args: [{
295
- selector: '[ngTreeItemGroup]',
296
- exportAs: 'ngTreeItemGroup',
297
- hostDirectives: [
298
- {
299
- directive: DeferredContentAware,
300
- inputs: ['preserveContent'],
301
- },
302
- ],
303
- host: {
304
- 'class': 'ng-treeitem-group',
305
- 'role': 'group',
306
- '[id]': 'id',
307
- '[attr.inert]': 'visible() ? null : true',
308
- },
309
- }]
310
- }], ctorParameters: () => [] });
311
- /**
312
- * A structural directive that marks the `ng-template` to be used as the content
313
- * for a `TreeItemGroup`. This content can be lazily loaded.
314
- */
315
- class TreeItemGroupContent {
316
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItemGroupContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
317
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.0-next.2", type: TreeItemGroupContent, isStandalone: true, selector: "ng-template[ngTreeItemGroupContent]", hostDirectives: [{ directive: i1.DeferredContent }], ngImport: i0 });
459
+ _deferredContent = inject(DeferredContent);
460
+ _unorderedItems = signal(new Set(), ...(ngDevMode ? [{
461
+ debugName: "_unorderedItems"
462
+ }] : []));
463
+ children = computed(() => [...this._unorderedItems()].sort(sortDirectives).map(c => c._pattern), ...(ngDevMode ? [{
464
+ debugName: "children"
465
+ }] : []));
466
+ ownedBy = input.required(...(ngDevMode ? [{
467
+ debugName: "ownedBy"
468
+ }] : []));
469
+ ngOnInit() {
470
+ this._deferredContent.deferredContentAware.set(this.ownedBy());
471
+ this.ownedBy().register(this);
472
+ }
473
+ ngOnDestroy() {
474
+ this.ownedBy().unregister();
475
+ }
476
+ register(child) {
477
+ this._unorderedItems().add(child);
478
+ this._unorderedItems.set(new Set(this._unorderedItems()));
479
+ }
480
+ unregister(child) {
481
+ this._unorderedItems().delete(child);
482
+ this._unorderedItems.set(new Set(this._unorderedItems()));
483
+ }
484
+ static ɵfac = i0.ɵɵngDeclareFactory({
485
+ minVersion: "12.0.0",
486
+ version: "20.2.0-next.2",
487
+ ngImport: i0,
488
+ type: TreeItemGroup,
489
+ deps: [],
490
+ target: i0.ɵɵFactoryTarget.Directive
491
+ });
492
+ static ɵdir = i0.ɵɵngDeclareDirective({
493
+ minVersion: "17.1.0",
494
+ version: "20.2.0-next.2",
495
+ type: TreeItemGroup,
496
+ isStandalone: true,
497
+ selector: "ng-template[ngTreeItemGroup]",
498
+ inputs: {
499
+ ownedBy: {
500
+ classPropertyName: "ownedBy",
501
+ publicName: "ownedBy",
502
+ isSignal: true,
503
+ isRequired: true,
504
+ transformFunction: null
505
+ }
506
+ },
507
+ exportAs: ["ngTreeItemGroup"],
508
+ hostDirectives: [{
509
+ directive: i1.DeferredContent
510
+ }],
511
+ ngImport: i0
512
+ });
318
513
  }
319
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: TreeItemGroupContent, decorators: [{
320
- type: Directive,
321
- args: [{
322
- selector: 'ng-template[ngTreeItemGroupContent]',
323
- hostDirectives: [DeferredContent],
324
- }]
325
- }] });
514
+ i0.ɵɵngDeclareClassMetadata({
515
+ minVersion: "12.0.0",
516
+ version: "20.2.0-next.2",
517
+ ngImport: i0,
518
+ type: TreeItemGroup,
519
+ decorators: [{
520
+ type: Directive,
521
+ args: [{
522
+ selector: 'ng-template[ngTreeItemGroup]',
523
+ exportAs: 'ngTreeItemGroup',
524
+ hostDirectives: [DeferredContent]
525
+ }]
526
+ }]
527
+ });
326
528
 
327
- export { Tree, TreeItem, TreeItemGroup, TreeItemGroupContent };
529
+ export { Tree, TreeItem, TreeItemGroup };
328
530
  //# sourceMappingURL=tree.mjs.map