@angular/cdk-experimental 21.0.0-next.5 → 21.0.0-next.8

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 (65) hide show
  1. package/fesm2022/{polyfill.mjs → _polyfill-chunk.mjs} +1 -1
  2. package/fesm2022/_polyfill-chunk.mjs.map +1 -0
  3. package/fesm2022/cdk-experimental.mjs +1 -1
  4. package/fesm2022/cdk-experimental.mjs.map +1 -1
  5. package/fesm2022/column-resize.mjs +1 -1
  6. package/fesm2022/popover-edit.mjs +1 -1
  7. package/package.json +10 -45
  8. package/{column-resize/index.d.ts → types/column-resize.d.ts} +37 -37
  9. package/{popover-edit/index.d.ts → types/popover-edit.d.ts} +30 -30
  10. package/{scrolling/index.d.ts → types/scrolling.d.ts} +6 -6
  11. package/{selection/index.d.ts → types/selection.d.ts} +14 -14
  12. package/{table-scroll-container/index.d.ts → types/table-scroll-container.d.ts} +6 -6
  13. package/accordion/index.d.ts +0 -94
  14. package/accordion.d.d.ts +0 -89
  15. package/combobox/index.d.ts +0 -94
  16. package/deferred-content/index.d.ts +0 -37
  17. package/expansion.d.d.ts +0 -71
  18. package/fesm2022/accordion.mjs +0 -194
  19. package/fesm2022/accordion.mjs.map +0 -1
  20. package/fesm2022/accordion2.mjs +0 -152
  21. package/fesm2022/accordion2.mjs.map +0 -1
  22. package/fesm2022/combobox.mjs +0 -340
  23. package/fesm2022/combobox.mjs.map +0 -1
  24. package/fesm2022/deferred-content.mjs +0 -59
  25. package/fesm2022/deferred-content.mjs.map +0 -1
  26. package/fesm2022/expansion.mjs +0 -87
  27. package/fesm2022/expansion.mjs.map +0 -1
  28. package/fesm2022/list-navigation.mjs +0 -261
  29. package/fesm2022/list-navigation.mjs.map +0 -1
  30. package/fesm2022/list.mjs +0 -370
  31. package/fesm2022/list.mjs.map +0 -1
  32. package/fesm2022/listbox.mjs +0 -163
  33. package/fesm2022/listbox.mjs.map +0 -1
  34. package/fesm2022/option.mjs +0 -231
  35. package/fesm2022/option.mjs.map +0 -1
  36. package/fesm2022/polyfill.mjs.map +0 -1
  37. package/fesm2022/radio-group.mjs +0 -205
  38. package/fesm2022/radio-group.mjs.map +0 -1
  39. package/fesm2022/radio-group2.mjs +0 -143
  40. package/fesm2022/radio-group2.mjs.map +0 -1
  41. package/fesm2022/tabs.mjs +0 -302
  42. package/fesm2022/tabs.mjs.map +0 -1
  43. package/fesm2022/tabs2.mjs +0 -211
  44. package/fesm2022/tabs2.mjs.map +0 -1
  45. package/fesm2022/toolbar.mjs +0 -171
  46. package/fesm2022/toolbar.mjs.map +0 -1
  47. package/fesm2022/toolbar2.mjs +0 -224
  48. package/fesm2022/toolbar2.mjs.map +0 -1
  49. package/fesm2022/tree.mjs +0 -620
  50. package/fesm2022/tree.mjs.map +0 -1
  51. package/fesm2022/ui-patterns.mjs +0 -21
  52. package/fesm2022/ui-patterns.mjs.map +0 -1
  53. package/list.d.d.ts +0 -207
  54. package/listbox/index.d.ts +0 -89
  55. package/listbox.d.d.ts +0 -101
  56. package/pointer-event-manager.d.d.ts +0 -190
  57. package/radio-group/index.d.ts +0 -87
  58. package/radio-group.d.d.ts +0 -80
  59. package/tabs/index.d.ts +0 -159
  60. package/tabs.d.d.ts +0 -137
  61. package/toolbar/index.d.ts +0 -91
  62. package/toolbar.d.d.ts +0 -136
  63. package/tree/index.d.ts +0 -275
  64. package/ui-patterns/index.d.ts +0 -9
  65. /package/{index.d.ts → types/cdk-experimental.d.ts} +0 -0
package/fesm2022/tree.mjs DELETED
@@ -1,620 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { computed, signal, inject, ElementRef, input, booleanAttribute, model, afterRenderEffect, Directive } from '@angular/core';
3
- import { _IdGenerator } from '@angular/cdk/a11y';
4
- import { Directionality } from '@angular/cdk/bidi';
5
- import * as i1 from '@angular/cdk-experimental/deferred-content';
6
- import { DeferredContentAware, DeferredContent } from '@angular/cdk-experimental/deferred-content';
7
- import { List } from './list.mjs';
8
- import { ExpansionControl, ListExpansion } from './expansion.mjs';
9
- import { Modifier, KeyboardEventManager, PointerEventManager } from './list-navigation.mjs';
10
-
11
- /**
12
- * Represents an item in a Tree.
13
- */
14
- class TreeItemPattern {
15
- inputs;
16
- /** The position of this item among its siblings. */
17
- index = computed(() => this.tree().visibleItems().indexOf(this));
18
- /** The unique identifier used by the expansion behavior. */
19
- expansionId;
20
- /** Controls expansion for child items. */
21
- expansionManager;
22
- /** Controls expansion for this item. */
23
- expansion;
24
- /** Whether the item is expandable. It's expandable if children item exist. */
25
- expandable;
26
- /** The level of the current item in a tree. */
27
- level = computed(() => this.parent().level() + 1);
28
- /** Whether this item is currently expanded. */
29
- expanded = computed(() => this.expansion.isExpanded());
30
- /** Whether this item is visible. */
31
- visible = computed(() => this.parent().expanded());
32
- /** The number of items under the same parent at the same level. */
33
- setsize = computed(() => this.parent().children().length);
34
- /** The position of this item among its siblings (1-based). */
35
- posinset = computed(() => this.parent().children().indexOf(this) + 1);
36
- /** Whether the item is active. */
37
- active = computed(() => this.tree().activeItem() === this);
38
- /** The tabindex of the item. */
39
- tabindex = computed(() => this.tree().listBehavior.getItemTabindex(this));
40
- /** Whether the item is selected. */
41
- selected = computed(() => {
42
- if (this.tree().nav()) {
43
- return undefined;
44
- }
45
- return this.tree().value().includes(this.value());
46
- });
47
- /** The current type of this item. */
48
- current = computed(() => {
49
- if (!this.tree().nav()) {
50
- return undefined;
51
- }
52
- return this.tree().value().includes(this.value()) ? this.tree().currentType() : undefined;
53
- });
54
- constructor(inputs) {
55
- this.inputs = inputs;
56
- this.id = inputs.id;
57
- this.value = inputs.value;
58
- this.element = inputs.element;
59
- this.disabled = inputs.disabled;
60
- this.searchTerm = inputs.searchTerm;
61
- this.expansionId = inputs.id;
62
- this.tree = inputs.tree;
63
- this.parent = inputs.parent;
64
- this.children = inputs.children;
65
- this.expandable = inputs.hasChildren;
66
- this.expansion = new ExpansionControl({
67
- ...inputs,
68
- expandable: this.expandable,
69
- expansionId: this.expansionId,
70
- expansionManager: this.parent().expansionManager,
71
- });
72
- this.expansionManager = new ListExpansion({
73
- ...inputs,
74
- multiExpandable: () => true,
75
- // TODO(ok7sai): allow pre-expanded tree items.
76
- expandedIds: signal([]),
77
- items: this.children,
78
- disabled: computed(() => this.tree()?.disabled() ?? false),
79
- });
80
- }
81
- }
82
- /** Controls the state and interactions of a tree view. */
83
- class TreePattern {
84
- inputs;
85
- /** The list behavior for the tree. */
86
- listBehavior;
87
- /** Controls expansion for direct children of the tree root (top-level items). */
88
- expansionManager;
89
- /** The root level is 0. */
90
- level = () => 0;
91
- /** The root is always expanded. */
92
- expanded = () => true;
93
- /** The tabindex of the tree. */
94
- tabindex = computed(() => this.listBehavior.tabindex());
95
- /** The id of the current active item. */
96
- activedescendant = computed(() => this.listBehavior.activedescendant());
97
- /** The direct children of the root (top-level tree items). */
98
- children = computed(() => this.inputs.allItems().filter(item => item.level() === this.level() + 1));
99
- /** All currently visible tree items. An item is visible if their parent is expanded. */
100
- visibleItems = computed(() => this.inputs.allItems().filter(item => item.visible()));
101
- /** Whether the tree selection follows focus. */
102
- followFocus = computed(() => this.inputs.selectionMode() === 'follow');
103
- /** The key for navigating to the previous item. */
104
- prevKey = computed(() => {
105
- if (this.inputs.orientation() === 'vertical') {
106
- return 'ArrowUp';
107
- }
108
- return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
109
- });
110
- /** The key for navigating to the next item. */
111
- nextKey = computed(() => {
112
- if (this.inputs.orientation() === 'vertical') {
113
- return 'ArrowDown';
114
- }
115
- return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
116
- });
117
- /** The key for collapsing an item or moving to its parent. */
118
- collapseKey = computed(() => {
119
- if (this.inputs.orientation() === 'horizontal') {
120
- return 'ArrowUp';
121
- }
122
- return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
123
- });
124
- /** The key for expanding an item or moving to its first child. */
125
- expandKey = computed(() => {
126
- if (this.inputs.orientation() === 'horizontal') {
127
- return 'ArrowDown';
128
- }
129
- return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
130
- });
131
- /** Represents the space key. Does nothing when the user is actively using typeahead. */
132
- dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));
133
- /** Regular expression to match characters for typeahead. */
134
- typeaheadRegexp = /^.$/;
135
- /** The keydown event manager for the tree. */
136
- keydown = computed(() => {
137
- const manager = new KeyboardEventManager();
138
- const list = this.listBehavior;
139
- manager
140
- .on(this.prevKey, () => list.prev({ selectOne: this.followFocus() }))
141
- .on(this.nextKey, () => list.next({ selectOne: this.followFocus() }))
142
- .on('Home', () => list.first({ selectOne: this.followFocus() }))
143
- .on('End', () => list.last({ selectOne: this.followFocus() }))
144
- .on(this.typeaheadRegexp, e => list.search(e.key, { selectOne: this.followFocus() }))
145
- .on(this.expandKey, () => this.expand({ selectOne: this.followFocus() }))
146
- .on(this.collapseKey, () => this.collapse({ selectOne: this.followFocus() }))
147
- .on(Modifier.Shift, '*', () => this.expandSiblings());
148
- if (this.inputs.multi()) {
149
- manager
150
- // TODO: Tracking the anchor by index can break if the
151
- // tree is expanded or collapsed causing the index to change.
152
- .on(Modifier.Any, 'Shift', () => list.anchor(this.listBehavior.activeIndex()))
153
- .on(Modifier.Shift, this.prevKey, () => list.prev({ selectRange: true }))
154
- .on(Modifier.Shift, this.nextKey, () => list.next({ selectRange: true }))
155
- .on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'Home', () => list.first({ selectRange: true, anchor: false }))
156
- .on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'End', () => list.last({ selectRange: true, anchor: false }))
157
- .on(Modifier.Shift, 'Enter', () => list.updateSelection({ selectRange: true, anchor: false }))
158
- .on(Modifier.Shift, this.dynamicSpaceKey, () => list.updateSelection({ selectRange: true, anchor: false }));
159
- }
160
- if (!this.followFocus() && this.inputs.multi()) {
161
- manager
162
- .on(this.dynamicSpaceKey, () => list.toggle())
163
- .on('Enter', () => list.toggle())
164
- .on([Modifier.Ctrl, Modifier.Meta], 'A', () => list.toggleAll());
165
- }
166
- if (!this.followFocus() && !this.inputs.multi()) {
167
- manager.on(this.dynamicSpaceKey, () => list.selectOne());
168
- manager.on('Enter', () => list.selectOne());
169
- }
170
- if (this.inputs.multi() && this.followFocus()) {
171
- manager
172
- .on([Modifier.Ctrl, Modifier.Meta], this.prevKey, () => list.prev())
173
- .on([Modifier.Ctrl, Modifier.Meta], this.nextKey, () => list.next())
174
- .on([Modifier.Ctrl, Modifier.Meta], this.expandKey, () => this.expand())
175
- .on([Modifier.Ctrl, Modifier.Meta], this.collapseKey, () => this.collapse())
176
- .on([Modifier.Ctrl, Modifier.Meta], ' ', () => list.toggle())
177
- .on([Modifier.Ctrl, Modifier.Meta], 'Enter', () => list.toggle())
178
- .on([Modifier.Ctrl, Modifier.Meta], 'Home', () => list.first())
179
- .on([Modifier.Ctrl, Modifier.Meta], 'End', () => list.last())
180
- .on([Modifier.Ctrl, Modifier.Meta], 'A', () => {
181
- list.toggleAll();
182
- list.select(); // Ensure the currect item remains selected.
183
- });
184
- }
185
- return manager;
186
- });
187
- /** The pointerdown event manager for the tree. */
188
- pointerdown = computed(() => {
189
- const manager = new PointerEventManager();
190
- if (this.multi()) {
191
- manager.on(Modifier.Shift, e => this.goto(e, { selectRange: true }));
192
- }
193
- if (!this.multi()) {
194
- return manager.on(e => this.goto(e, { selectOne: true }));
195
- }
196
- if (this.multi() && this.followFocus()) {
197
- return manager
198
- .on(e => this.goto(e, { selectOne: true }))
199
- .on(Modifier.Ctrl, e => this.goto(e, { toggle: true }));
200
- }
201
- if (this.multi() && !this.followFocus()) {
202
- return manager.on(e => this.goto(e, { toggle: true }));
203
- }
204
- return manager;
205
- });
206
- constructor(inputs) {
207
- this.inputs = inputs;
208
- this.nav = inputs.nav;
209
- this.currentType = inputs.currentType;
210
- this.allItems = inputs.allItems;
211
- this.focusMode = inputs.focusMode;
212
- this.disabled = inputs.disabled;
213
- this.activeItem = inputs.activeItem;
214
- this.skipDisabled = inputs.skipDisabled;
215
- this.wrap = inputs.wrap;
216
- this.orientation = inputs.orientation;
217
- this.textDirection = inputs.textDirection;
218
- this.multi = computed(() => (this.nav() ? false : this.inputs.multi()));
219
- this.selectionMode = inputs.selectionMode;
220
- this.typeaheadDelay = inputs.typeaheadDelay;
221
- this.value = inputs.value;
222
- this.listBehavior = new List({
223
- ...inputs,
224
- items: this.visibleItems,
225
- multi: this.multi,
226
- });
227
- this.expansionManager = new ListExpansion({
228
- multiExpandable: () => true,
229
- // TODO(ok7sai): allow pre-expanded tree items.
230
- expandedIds: signal([]),
231
- items: this.children,
232
- disabled: this.disabled,
233
- });
234
- }
235
- /**
236
- * Sets the tree to it's default initial state.
237
- *
238
- * Sets the active index of the tree to the first focusable selected tree item if one exists.
239
- * Otherwise, sets focus to the first focusable tree item.
240
- */
241
- setDefaultState() {
242
- let firstItem;
243
- for (const item of this.allItems()) {
244
- if (!item.visible())
245
- continue;
246
- if (!this.listBehavior.isFocusable(item))
247
- continue;
248
- if (firstItem === undefined) {
249
- firstItem = item;
250
- }
251
- if (item.selected()) {
252
- this.activeItem.set(item);
253
- return;
254
- }
255
- }
256
- if (firstItem !== undefined) {
257
- this.activeItem.set(firstItem);
258
- }
259
- }
260
- /** Handles keydown events on the tree. */
261
- onKeydown(event) {
262
- if (!this.disabled()) {
263
- this.keydown().handle(event);
264
- }
265
- }
266
- /** Handles pointerdown events on the tree. */
267
- onPointerdown(event) {
268
- if (!this.disabled()) {
269
- this.pointerdown().handle(event);
270
- }
271
- }
272
- /** Navigates to the given tree item in the tree. */
273
- goto(e, opts) {
274
- const item = this._getItem(e);
275
- if (!item)
276
- return;
277
- this.listBehavior.goto(item, opts);
278
- this.toggleExpansion(item);
279
- }
280
- /** Toggles to expand or collapse a tree item. */
281
- toggleExpansion(item) {
282
- item ??= this.activeItem();
283
- if (!item || !this.listBehavior.isFocusable(item))
284
- return;
285
- if (!item.expandable())
286
- return;
287
- if (item.expanded()) {
288
- this.collapse();
289
- }
290
- else {
291
- item.expansion.open();
292
- }
293
- }
294
- /** Expands a tree item. */
295
- expand(opts) {
296
- const item = this.activeItem();
297
- if (!item || !this.listBehavior.isFocusable(item))
298
- return;
299
- if (item.expandable() && !item.expanded()) {
300
- item.expansion.open();
301
- }
302
- else if (item.expanded() &&
303
- item.children().some(item => this.listBehavior.isFocusable(item))) {
304
- this.listBehavior.next(opts);
305
- }
306
- }
307
- /** Expands all sibling tree items including itself. */
308
- expandSiblings(item) {
309
- item ??= this.activeItem();
310
- const siblings = item?.parent()?.children();
311
- siblings?.forEach(item => item.expansion.open());
312
- }
313
- /** Collapses a tree item. */
314
- collapse(opts) {
315
- const item = this.activeItem();
316
- if (!item || !this.listBehavior.isFocusable(item))
317
- return;
318
- if (item.expandable() && item.expanded()) {
319
- item.expansion.close();
320
- }
321
- else if (item.parent() && item.parent() !== this) {
322
- const parentItem = item.parent();
323
- if (parentItem instanceof TreeItemPattern && this.listBehavior.isFocusable(parentItem)) {
324
- this.listBehavior.goto(parentItem, opts);
325
- }
326
- }
327
- }
328
- /** Retrieves the TreeItemPattern associated with a DOM event, if any. */
329
- _getItem(event) {
330
- if (!(event.target instanceof HTMLElement)) {
331
- return;
332
- }
333
- const element = event.target.closest('[role="treeitem"]');
334
- return this.inputs.allItems().find(i => i.element() === element);
335
- }
336
- }
337
-
338
- /**
339
- * Sort directives by their document order.
340
- */
341
- function sortDirectives(a, b) {
342
- return (a.element().compareDocumentPosition(b.element()) & Node.DOCUMENT_POSITION_PRECEDING) > 0
343
- ? 1
344
- : -1;
345
- }
346
- /**
347
- * A Tree container.
348
- *
349
- * Transforms nested lists into an accessible, ARIA-compliant tree structure.
350
- *
351
- * ```html
352
- * <ul cdkTree [(value)]="selectedItems" [multi]="true">
353
- * <li cdkTreeItem [value]="'leaf1'">Leaf Item 1</li>
354
- * <li cdkTreeItem [value]="'parent1'">
355
- * Parent Item 1
356
- * <ul cdkTreeItemGroup [value]="'parent1'">
357
- * <ng-template cdkTreeItemGroupContent>
358
- * <li cdkTreeItem [value]="'child1.1'">Child Item 1.1</li>
359
- * <li cdkTreeItem [value]="'child1.2'">Child Item 1.2</li>
360
- * </ng-template>
361
- * </ul>
362
- * </li>
363
- * <li cdkTreeItem [value]="'leaf2'" [disabled]="true">Disabled Leaf Item 2</li>
364
- * </ul>
365
- * ```
366
- */
367
- class CdkTree {
368
- /** A reference to the tree element. */
369
- _elementRef = inject(ElementRef);
370
- /** All CdkTreeItem instances within this tree. */
371
- _unorderedItems = signal(new Set(), ...(ngDevMode ? [{ debugName: "_unorderedItems" }] : []));
372
- /** Orientation of the tree. */
373
- orientation = input('vertical', ...(ngDevMode ? [{ debugName: "orientation" }] : []));
374
- /** Whether multi-selection is allowed. */
375
- multi = input(false, ...(ngDevMode ? [{ debugName: "multi", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
376
- /** Whether the tree is disabled. */
377
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
378
- /** The selection strategy used by the tree. */
379
- selectionMode = input('explicit', ...(ngDevMode ? [{ debugName: "selectionMode" }] : []));
380
- /** The focus strategy used by the tree. */
381
- focusMode = input('roving', ...(ngDevMode ? [{ debugName: "focusMode" }] : []));
382
- /** Whether navigation wraps. */
383
- wrap = input(true, ...(ngDevMode ? [{ debugName: "wrap", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
384
- /** Whether to skip disabled items during navigation. */
385
- skipDisabled = input(true, ...(ngDevMode ? [{ debugName: "skipDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
386
- /** Typeahead delay. */
387
- typeaheadDelay = input(0.5, ...(ngDevMode ? [{ debugName: "typeaheadDelay" }] : []));
388
- /** Selected item values. */
389
- value = model([], ...(ngDevMode ? [{ debugName: "value" }] : []));
390
- /** Text direction. */
391
- textDirection = inject(Directionality).valueSignal;
392
- /** Whether the tree is in navigation mode. */
393
- nav = input(false, ...(ngDevMode ? [{ debugName: "nav" }] : []));
394
- /** The aria-current type. */
395
- currentType = input('page', ...(ngDevMode ? [{ debugName: "currentType" }] : []));
396
- /** The UI pattern for the tree. */
397
- pattern = new TreePattern({
398
- ...this,
399
- allItems: computed(() => [...this._unorderedItems()].sort(sortDirectives).map(item => item.pattern)),
400
- activeItem: signal(undefined),
401
- element: () => this._elementRef.nativeElement,
402
- });
403
- /** Whether the tree has received focus yet. */
404
- _hasFocused = signal(false, ...(ngDevMode ? [{ debugName: "_hasFocused" }] : []));
405
- constructor() {
406
- afterRenderEffect(() => {
407
- if (!this._hasFocused()) {
408
- this.pattern.setDefaultState();
409
- }
410
- });
411
- }
412
- onFocus() {
413
- this._hasFocused.set(true);
414
- }
415
- register(child) {
416
- this._unorderedItems().add(child);
417
- this._unorderedItems.set(new Set(this._unorderedItems()));
418
- }
419
- unregister(child) {
420
- this._unorderedItems().delete(child);
421
- this._unorderedItems.set(new Set(this._unorderedItems()));
422
- }
423
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTree, deps: [], target: i0.ɵɵFactoryTarget.Directive });
424
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: CdkTree, isStandalone: true, selector: "[cdkTree]", 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.aria-orientation": "pattern.orientation()", "attr.aria-multiselectable": "pattern.multi()", "attr.aria-disabled": "pattern.disabled()", "attr.aria-activedescendant": "pattern.activedescendant()", "tabindex": "pattern.tabindex()" }, classAttribute: "cdk-tree" }, exportAs: ["cdkTree"], ngImport: i0 });
425
- }
426
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTree, decorators: [{
427
- type: Directive,
428
- args: [{
429
- selector: '[cdkTree]',
430
- exportAs: 'cdkTree',
431
- host: {
432
- 'class': 'cdk-tree',
433
- 'role': 'tree',
434
- '[attr.aria-orientation]': 'pattern.orientation()',
435
- '[attr.aria-multiselectable]': 'pattern.multi()',
436
- '[attr.aria-disabled]': 'pattern.disabled()',
437
- '[attr.aria-activedescendant]': 'pattern.activedescendant()',
438
- '[tabindex]': 'pattern.tabindex()',
439
- '(keydown)': 'pattern.onKeydown($event)',
440
- '(pointerdown)': 'pattern.onPointerdown($event)',
441
- '(focusin)': 'onFocus()',
442
- },
443
- }]
444
- }], ctorParameters: () => [] });
445
- /**
446
- * A selectable and expandable Tree Item in a Tree.
447
- */
448
- class CdkTreeItem {
449
- /** A reference to the tree item element. */
450
- _elementRef = inject(ElementRef);
451
- /** A unique identifier for the tree item. */
452
- _id = inject(_IdGenerator).getId('cdk-tree-item-');
453
- /** The owned tree item group. */
454
- _group = signal(undefined, ...(ngDevMode ? [{ debugName: "_group" }] : []));
455
- /** The id of the owned group. */
456
- ownsId = computed(() => this._group()?.id, ...(ngDevMode ? [{ debugName: "ownsId" }] : []));
457
- /** The host native element. */
458
- element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{ debugName: "element" }] : []));
459
- /** The value of the tree item. */
460
- value = input.required(...(ngDevMode ? [{ debugName: "value" }] : []));
461
- /** The parent tree root or tree item group. */
462
- parent = input.required(...(ngDevMode ? [{ debugName: "parent" }] : []));
463
- /** Whether the tree item is disabled. */
464
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
465
- /** Optional label for typeahead. Defaults to the element's textContent. */
466
- label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
467
- /** Search term for typeahead. */
468
- searchTerm = computed(() => this.label() ?? this.element().textContent, ...(ngDevMode ? [{ debugName: "searchTerm" }] : []));
469
- /** The tree root. */
470
- tree = computed(() => {
471
- if (this.parent() instanceof CdkTree) {
472
- return this.parent();
473
- }
474
- return this.parent().ownedBy().tree();
475
- }, ...(ngDevMode ? [{ debugName: "tree" }] : []));
476
- /** The UI pattern for this item. */
477
- pattern;
478
- constructor() {
479
- // Updates the visibility of the owned group.
480
- afterRenderEffect(() => {
481
- this._group()?.visible.set(this.pattern.expanded());
482
- });
483
- }
484
- ngOnInit() {
485
- this.parent().register(this);
486
- this.tree().register(this);
487
- const treePattern = computed(() => this.tree().pattern, ...(ngDevMode ? [{ debugName: "treePattern" }] : []));
488
- const parentPattern = computed(() => {
489
- if (this.parent() instanceof CdkTree) {
490
- return treePattern();
491
- }
492
- return this.parent().ownedBy().pattern;
493
- }, ...(ngDevMode ? [{ debugName: "parentPattern" }] : []));
494
- this.pattern = new TreeItemPattern({
495
- ...this,
496
- id: () => this._id,
497
- tree: treePattern,
498
- parent: parentPattern,
499
- children: computed(() => this._group()
500
- ?.children()
501
- .map(item => item.pattern) ?? []),
502
- hasChildren: computed(() => !!this._group()),
503
- });
504
- }
505
- ngOnDestroy() {
506
- this.parent().unregister(this);
507
- this.tree().unregister(this);
508
- }
509
- register(group) {
510
- this._group.set(group);
511
- }
512
- unregister() {
513
- this._group.set(undefined);
514
- }
515
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
516
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: CdkTreeItem, isStandalone: true, selector: "[cdkTreeItem]", 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: { "class.cdk-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()", "attr.inert": "pattern.visible() ? null : true" }, classAttribute: "cdk-treeitem" }, exportAs: ["cdkTreeItem"], ngImport: i0 });
517
- }
518
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItem, decorators: [{
519
- type: Directive,
520
- args: [{
521
- selector: '[cdkTreeItem]',
522
- exportAs: 'cdkTreeItem',
523
- host: {
524
- 'class': 'cdk-treeitem',
525
- '[class.cdk-active]': 'pattern.active()',
526
- 'role': 'treeitem',
527
- '[id]': 'pattern.id()',
528
- '[attr.aria-expanded]': 'pattern.expandable() ? pattern.expanded() : null',
529
- '[attr.aria-selected]': 'pattern.selected()',
530
- '[attr.aria-current]': 'pattern.current()',
531
- '[attr.aria-disabled]': 'pattern.disabled()',
532
- '[attr.aria-level]': 'pattern.level()',
533
- '[attr.aria-owns]': 'ownsId()',
534
- '[attr.aria-setsize]': 'pattern.setsize()',
535
- '[attr.aria-posinset]': 'pattern.posinset()',
536
- '[attr.tabindex]': 'pattern.tabindex()',
537
- '[attr.inert]': 'pattern.visible() ? null : true',
538
- },
539
- }]
540
- }], ctorParameters: () => [] });
541
- /**
542
- * Container that designates content as a group.
543
- */
544
- class CdkTreeItemGroup {
545
- /** A reference to the group element. */
546
- _elementRef = inject(ElementRef);
547
- /** The DeferredContentAware host directive. */
548
- _deferredContentAware = inject(DeferredContentAware);
549
- /** All groupable items that are descendants of the group. */
550
- _unorderedItems = signal(new Set(), ...(ngDevMode ? [{ debugName: "_unorderedItems" }] : []));
551
- /** The host native element. */
552
- element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{ debugName: "element" }] : []));
553
- /** Unique ID for the group. */
554
- id = inject(_IdGenerator).getId('cdk-tree-group-');
555
- /** Whether the group is visible. */
556
- visible = signal(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
557
- /** Child items within this group. */
558
- children = computed(() => [...this._unorderedItems()].sort(sortDirectives), ...(ngDevMode ? [{ debugName: "children" }] : []));
559
- /** Tree item that owns the group. */
560
- ownedBy = input.required(...(ngDevMode ? [{ debugName: "ownedBy" }] : []));
561
- constructor() {
562
- // Connect the group's hidden state to the DeferredContentAware's visibility.
563
- afterRenderEffect(() => {
564
- this._deferredContentAware.contentVisible.set(this.visible());
565
- });
566
- }
567
- ngOnInit() {
568
- this.ownedBy().register(this);
569
- }
570
- ngOnDestroy() {
571
- this.ownedBy().unregister();
572
- }
573
- register(child) {
574
- this._unorderedItems().add(child);
575
- this._unorderedItems.set(new Set(this._unorderedItems()));
576
- }
577
- unregister(child) {
578
- this._unorderedItems().delete(child);
579
- this._unorderedItems.set(new Set(this._unorderedItems()));
580
- }
581
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItemGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
582
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: CdkTreeItemGroup, isStandalone: true, selector: "[cdkTreeItemGroup]", 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: "cdk-treeitem-group" }, exportAs: ["cdkTreeItemGroup"], hostDirectives: [{ directive: i1.DeferredContentAware, inputs: ["preserveContent", "preserveContent"] }], ngImport: i0 });
583
- }
584
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItemGroup, decorators: [{
585
- type: Directive,
586
- args: [{
587
- selector: '[cdkTreeItemGroup]',
588
- exportAs: 'cdkTreeItemGroup',
589
- hostDirectives: [
590
- {
591
- directive: DeferredContentAware,
592
- inputs: ['preserveContent'],
593
- },
594
- ],
595
- host: {
596
- 'class': 'cdk-treeitem-group',
597
- 'role': 'group',
598
- '[id]': 'id',
599
- '[attr.inert]': 'visible() ? null : true',
600
- },
601
- }]
602
- }], ctorParameters: () => [] });
603
- /**
604
- * A structural directive that marks the `ng-template` to be used as the content
605
- * for a `CdkTreeItemGroup`. This content can be lazily loaded.
606
- */
607
- class CdkTreeItemGroupContent {
608
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItemGroupContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
609
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.0-next.2", type: CdkTreeItemGroupContent, isStandalone: true, selector: "ng-template[cdkTreeItemGroupContent]", hostDirectives: [{ directive: i1.DeferredContent }], ngImport: i0 });
610
- }
611
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeItemGroupContent, decorators: [{
612
- type: Directive,
613
- args: [{
614
- selector: 'ng-template[cdkTreeItemGroupContent]',
615
- hostDirectives: [DeferredContent],
616
- }]
617
- }] });
618
-
619
- export { CdkTree, CdkTreeItem, CdkTreeItemGroup, CdkTreeItemGroupContent };
620
- //# sourceMappingURL=tree.mjs.map