@angular/aria 21.0.5 → 21.0.6
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.
- package/LICENSE +1 -1
- package/fesm2022/_combobox-tree-chunk.mjs +274 -107
- package/fesm2022/_combobox-tree-chunk.mjs.map +1 -1
- package/fesm2022/_list-chunk.mjs +2 -168
- package/fesm2022/_list-chunk.mjs.map +1 -1
- package/fesm2022/_list-navigation-chunk.mjs +15 -12
- package/fesm2022/_list-navigation-chunk.mjs.map +1 -1
- package/fesm2022/_list-typeahead-chunk.mjs +170 -0
- package/fesm2022/_list-typeahead-chunk.mjs.map +1 -0
- package/fesm2022/_toolbar-widget-group-chunk.mjs +9 -3
- package/fesm2022/_toolbar-widget-group-chunk.mjs.map +1 -1
- package/fesm2022/accordion.mjs +1 -1
- package/fesm2022/aria.mjs +1 -1
- package/fesm2022/aria.mjs.map +1 -1
- package/fesm2022/listbox.mjs +1 -0
- package/fesm2022/listbox.mjs.map +1 -1
- package/fesm2022/menu.mjs +3 -2
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/private.mjs +1 -0
- package/fesm2022/private.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +1 -0
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tree.mjs +7 -7
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/types/_list-chunk.d.ts +9 -8
- package/types/_list-navigation-chunk.d.ts +23 -19
- package/types/_tree-chunk.d.ts +119 -28
- package/types/accordion.d.ts +1 -1
- package/types/menu.d.ts +1 -1
- package/types/private.d.ts +4 -2
- package/types/tree.d.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,205 @@
|
|
|
1
|
-
import { computed, Modifier, KeyboardEventManager } from './_signal-like-chunk.mjs';
|
|
2
|
-
import { List } from './_list-chunk.mjs';
|
|
1
|
+
import { computed, signal, Modifier, KeyboardEventManager } from './_signal-like-chunk.mjs';
|
|
3
2
|
import { ListExpansion } from './_expansion-chunk.mjs';
|
|
3
|
+
import { ListNavigation, ListFocus } from './_list-navigation-chunk.mjs';
|
|
4
|
+
import { ListSelection, ListTypeahead } from './_list-typeahead-chunk.mjs';
|
|
4
5
|
import { PointerEventManager } from './_pointer-event-manager-chunk.mjs';
|
|
5
6
|
|
|
7
|
+
class TreeListFocus extends ListFocus {
|
|
8
|
+
isFocusable(item) {
|
|
9
|
+
return super.isFocusable(item) && item.visible();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class Tree {
|
|
13
|
+
inputs;
|
|
14
|
+
navigationBehavior;
|
|
15
|
+
selectionBehavior;
|
|
16
|
+
typeaheadBehavior;
|
|
17
|
+
focusBehavior;
|
|
18
|
+
expansionBehavior;
|
|
19
|
+
disabled = computed(() => this.focusBehavior.isListDisabled());
|
|
20
|
+
activeDescendant = computed(() => this.focusBehavior.getActiveDescendant());
|
|
21
|
+
tabIndex = computed(() => this.focusBehavior.getListTabIndex());
|
|
22
|
+
activeIndex = computed(() => this.focusBehavior.activeIndex());
|
|
23
|
+
_anchorIndex = signal(0);
|
|
24
|
+
_wrap = signal(true);
|
|
25
|
+
constructor(inputs) {
|
|
26
|
+
this.inputs = inputs;
|
|
27
|
+
this.focusBehavior = new TreeListFocus(inputs);
|
|
28
|
+
this.selectionBehavior = new ListSelection({
|
|
29
|
+
...inputs,
|
|
30
|
+
focusManager: this.focusBehavior
|
|
31
|
+
});
|
|
32
|
+
this.typeaheadBehavior = new ListTypeahead({
|
|
33
|
+
...inputs,
|
|
34
|
+
focusManager: this.focusBehavior
|
|
35
|
+
});
|
|
36
|
+
this.expansionBehavior = new ListExpansion(inputs);
|
|
37
|
+
this.navigationBehavior = new ListNavigation({
|
|
38
|
+
...inputs,
|
|
39
|
+
focusManager: this.focusBehavior,
|
|
40
|
+
wrap: computed(() => this._wrap() && this.inputs.wrap())
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getItemTabindex(item) {
|
|
44
|
+
return this.focusBehavior.getItemTabIndex(item);
|
|
45
|
+
}
|
|
46
|
+
first(opts) {
|
|
47
|
+
this._navigate(opts, () => this.navigationBehavior.first(opts));
|
|
48
|
+
}
|
|
49
|
+
last(opts) {
|
|
50
|
+
this._navigate(opts, () => this.navigationBehavior.last(opts));
|
|
51
|
+
}
|
|
52
|
+
next(opts) {
|
|
53
|
+
this._navigate(opts, () => this.navigationBehavior.next(opts));
|
|
54
|
+
}
|
|
55
|
+
prev(opts) {
|
|
56
|
+
this._navigate(opts, () => this.navigationBehavior.prev(opts));
|
|
57
|
+
}
|
|
58
|
+
firstChild(opts) {
|
|
59
|
+
this._navigate(opts, () => {
|
|
60
|
+
const item = this.inputs.activeItem();
|
|
61
|
+
const items = item?.children?.() ?? [];
|
|
62
|
+
return this.navigationBehavior.first({
|
|
63
|
+
items,
|
|
64
|
+
...opts
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
lastChild(opts) {
|
|
69
|
+
this._navigate(opts, () => {
|
|
70
|
+
const item = this.inputs.activeItem();
|
|
71
|
+
const items = item?.children?.() ?? [];
|
|
72
|
+
return this.navigationBehavior.last({
|
|
73
|
+
items,
|
|
74
|
+
...opts
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
nextSibling(opts) {
|
|
79
|
+
this._navigate(opts, () => {
|
|
80
|
+
const item = this.inputs.activeItem();
|
|
81
|
+
const items = item?.parent?.()?.children?.() ?? [];
|
|
82
|
+
return this.navigationBehavior.next({
|
|
83
|
+
items,
|
|
84
|
+
...opts
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
prevSibling(opts) {
|
|
89
|
+
this._navigate(opts, () => {
|
|
90
|
+
const item = this.inputs.activeItem();
|
|
91
|
+
const items = item?.parent?.()?.children?.() ?? [];
|
|
92
|
+
return this.navigationBehavior.prev({
|
|
93
|
+
items,
|
|
94
|
+
...opts
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
parent(opts) {
|
|
99
|
+
this._navigate(opts, () => this.navigationBehavior.goto(this.inputs.activeItem()?.parent?.(), opts));
|
|
100
|
+
}
|
|
101
|
+
goto(item, opts) {
|
|
102
|
+
this._navigate(opts, () => this.navigationBehavior.goto(item, opts));
|
|
103
|
+
}
|
|
104
|
+
unfocus() {
|
|
105
|
+
this.inputs.activeItem.set(undefined);
|
|
106
|
+
}
|
|
107
|
+
anchor(index) {
|
|
108
|
+
this._anchorIndex.set(index);
|
|
109
|
+
}
|
|
110
|
+
search(char, opts) {
|
|
111
|
+
this._navigate(opts, () => this.typeaheadBehavior.search(char));
|
|
112
|
+
}
|
|
113
|
+
isTyping() {
|
|
114
|
+
return this.typeaheadBehavior.isTyping();
|
|
115
|
+
}
|
|
116
|
+
select(item) {
|
|
117
|
+
this.selectionBehavior.select(item);
|
|
118
|
+
}
|
|
119
|
+
selectOne() {
|
|
120
|
+
this.selectionBehavior.selectOne();
|
|
121
|
+
}
|
|
122
|
+
deselect(item) {
|
|
123
|
+
this.selectionBehavior.deselect(item);
|
|
124
|
+
}
|
|
125
|
+
deselectAll() {
|
|
126
|
+
this.selectionBehavior.deselectAll();
|
|
127
|
+
}
|
|
128
|
+
toggle(item) {
|
|
129
|
+
this.selectionBehavior.toggle(item);
|
|
130
|
+
}
|
|
131
|
+
toggleOne() {
|
|
132
|
+
this.selectionBehavior.toggleOne();
|
|
133
|
+
}
|
|
134
|
+
toggleAll() {
|
|
135
|
+
this.selectionBehavior.toggleAll();
|
|
136
|
+
}
|
|
137
|
+
toggleExpansion(item) {
|
|
138
|
+
item ??= this.inputs.activeItem();
|
|
139
|
+
if (!item || !this.isFocusable(item)) return;
|
|
140
|
+
if (this.isExpandable(item)) {
|
|
141
|
+
this.expansionBehavior.toggle(item);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
expand(item) {
|
|
145
|
+
if (this.isExpandable(item)) {
|
|
146
|
+
this.expansionBehavior.open(item);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
collapse(item) {
|
|
150
|
+
this.expansionBehavior.close(item);
|
|
151
|
+
}
|
|
152
|
+
expandSiblings(item) {
|
|
153
|
+
item ??= this.inputs.activeItem();
|
|
154
|
+
if (!item) return;
|
|
155
|
+
const parent = item.parent?.();
|
|
156
|
+
const siblings = parent ? parent.children?.() : this.inputs.items().filter(i => !i.parent?.());
|
|
157
|
+
siblings?.forEach(s => this.expand(s));
|
|
158
|
+
}
|
|
159
|
+
expandAll() {
|
|
160
|
+
this.expansionBehavior.openAll();
|
|
161
|
+
}
|
|
162
|
+
collapseAll() {
|
|
163
|
+
this.expansionBehavior.closeAll();
|
|
164
|
+
}
|
|
165
|
+
isFocusable(item) {
|
|
166
|
+
return this.focusBehavior.isFocusable(item);
|
|
167
|
+
}
|
|
168
|
+
isExpandable(item) {
|
|
169
|
+
return this.expansionBehavior.isExpandable(item);
|
|
170
|
+
}
|
|
171
|
+
updateSelection(opts = {
|
|
172
|
+
anchor: true
|
|
173
|
+
}) {
|
|
174
|
+
if (opts.toggle) {
|
|
175
|
+
this.selectionBehavior.toggle();
|
|
176
|
+
}
|
|
177
|
+
if (opts.select) {
|
|
178
|
+
this.selectionBehavior.select();
|
|
179
|
+
}
|
|
180
|
+
if (opts.selectOne) {
|
|
181
|
+
this.selectionBehavior.selectOne();
|
|
182
|
+
}
|
|
183
|
+
if (opts.selectRange) {
|
|
184
|
+
this.selectionBehavior.selectRange();
|
|
185
|
+
}
|
|
186
|
+
if (!opts.anchor) {
|
|
187
|
+
this.anchor(this.selectionBehavior.rangeStartIndex());
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
_navigate(opts = {}, operation) {
|
|
191
|
+
if (opts?.selectRange) {
|
|
192
|
+
this._wrap.set(false);
|
|
193
|
+
this.selectionBehavior.rangeStartIndex.set(this._anchorIndex());
|
|
194
|
+
}
|
|
195
|
+
const moved = operation();
|
|
196
|
+
if (moved) {
|
|
197
|
+
this.updateSelection(opts);
|
|
198
|
+
}
|
|
199
|
+
this._wrap.set(true);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
6
203
|
class TreeItemPattern {
|
|
7
204
|
inputs;
|
|
8
205
|
id = () => this.inputs.id();
|
|
@@ -11,19 +208,21 @@ class TreeItemPattern {
|
|
|
11
208
|
disabled = () => this.inputs.disabled();
|
|
12
209
|
searchTerm = () => this.inputs.searchTerm();
|
|
13
210
|
tree = () => this.inputs.tree();
|
|
14
|
-
parent = () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
211
|
+
parent = computed(() => {
|
|
212
|
+
const parent = this.inputs.parent();
|
|
213
|
+
return parent instanceof TreeItemPattern ? parent : undefined;
|
|
214
|
+
});
|
|
215
|
+
children = () => this.inputs.children() ?? [];
|
|
216
|
+
index = computed(() => this.tree().inputs.items().indexOf(this));
|
|
18
217
|
expandable = () => this.inputs.hasChildren();
|
|
19
218
|
selectable = () => this.inputs.selectable();
|
|
20
219
|
expanded;
|
|
21
|
-
level = computed(() => this.parent().level() + 1);
|
|
22
|
-
visible = computed(() => this.parent().expanded() && this.parent().visible());
|
|
23
|
-
setsize = computed(() => this.parent().children().length);
|
|
24
|
-
posinset = computed(() => this.parent().children().indexOf(this) + 1);
|
|
220
|
+
level = computed(() => this.inputs.parent().level() + 1);
|
|
221
|
+
visible = computed(() => this.inputs.parent().expanded() && this.inputs.parent().visible());
|
|
222
|
+
setsize = computed(() => this.inputs.parent().children().length);
|
|
223
|
+
posinset = computed(() => this.inputs.parent().children().indexOf(this) + 1);
|
|
25
224
|
active = computed(() => this.tree().activeItem() === this);
|
|
26
|
-
tabIndex = computed(() => this.tree().
|
|
225
|
+
tabIndex = computed(() => this.tree().treeBehavior.getItemTabindex(this));
|
|
27
226
|
selected = computed(() => {
|
|
28
227
|
if (this.tree().nav()) {
|
|
29
228
|
return undefined;
|
|
@@ -45,25 +244,17 @@ class TreeItemPattern {
|
|
|
45
244
|
constructor(inputs) {
|
|
46
245
|
this.inputs = inputs;
|
|
47
246
|
this.expanded = inputs.expanded;
|
|
48
|
-
this.expansionBehavior = new ListExpansion({
|
|
49
|
-
...inputs,
|
|
50
|
-
multiExpandable: () => true,
|
|
51
|
-
items: this.children,
|
|
52
|
-
disabled: computed(() => this.tree()?.disabled() ?? false)
|
|
53
|
-
});
|
|
54
247
|
}
|
|
55
248
|
}
|
|
56
249
|
class TreePattern {
|
|
57
250
|
inputs;
|
|
58
|
-
|
|
59
|
-
expansionBehavior;
|
|
251
|
+
treeBehavior;
|
|
60
252
|
level = () => 0;
|
|
61
253
|
expanded = () => true;
|
|
62
254
|
visible = () => true;
|
|
63
|
-
tabIndex = computed(() => this.
|
|
64
|
-
activeDescendant = computed(() => this.
|
|
65
|
-
children = computed(() => this.inputs.
|
|
66
|
-
visibleItems = computed(() => this.inputs.allItems().filter(item => item.visible()));
|
|
255
|
+
tabIndex = computed(() => this.treeBehavior.tabIndex());
|
|
256
|
+
activeDescendant = computed(() => this.treeBehavior.activeDescendant());
|
|
257
|
+
children = computed(() => this.inputs.items().filter(item => item.level() === this.level() + 1));
|
|
67
258
|
followFocus = computed(() => this.inputs.selectionMode() === 'follow');
|
|
68
259
|
isRtl = computed(() => this.inputs.textDirection() === 'rtl');
|
|
69
260
|
prevKey = computed(() => {
|
|
@@ -90,60 +281,60 @@ class TreePattern {
|
|
|
90
281
|
}
|
|
91
282
|
return this.isRtl() ? 'ArrowLeft' : 'ArrowRight';
|
|
92
283
|
});
|
|
93
|
-
dynamicSpaceKey = computed(() => this.
|
|
284
|
+
dynamicSpaceKey = computed(() => this.treeBehavior.isTyping() ? '' : ' ');
|
|
94
285
|
typeaheadRegexp = /^.$/;
|
|
95
286
|
keydown = computed(() => {
|
|
96
287
|
const manager = new KeyboardEventManager();
|
|
97
|
-
const
|
|
98
|
-
manager.on(this.prevKey, () =>
|
|
288
|
+
const tree = this.treeBehavior;
|
|
289
|
+
manager.on(this.prevKey, () => tree.prev({
|
|
99
290
|
selectOne: this.followFocus()
|
|
100
|
-
})).on(this.nextKey, () =>
|
|
291
|
+
})).on(this.nextKey, () => tree.next({
|
|
101
292
|
selectOne: this.followFocus()
|
|
102
|
-
})).on('Home', () =>
|
|
293
|
+
})).on('Home', () => tree.first({
|
|
103
294
|
selectOne: this.followFocus()
|
|
104
|
-
})).on('End', () =>
|
|
295
|
+
})).on('End', () => tree.last({
|
|
105
296
|
selectOne: this.followFocus()
|
|
106
|
-
})).on(this.typeaheadRegexp, e =>
|
|
297
|
+
})).on(this.typeaheadRegexp, e => tree.search(e.key, {
|
|
107
298
|
selectOne: this.followFocus()
|
|
108
|
-
})).on(this.expandKey, () => this.
|
|
299
|
+
})).on(Modifier.Shift, '*', () => tree.expandSiblings()).on(this.expandKey, () => this._expandOrFirstChild({
|
|
109
300
|
selectOne: this.followFocus()
|
|
110
|
-
})).on(this.collapseKey, () => this.
|
|
301
|
+
})).on(this.collapseKey, () => this._collapseOrParent({
|
|
111
302
|
selectOne: this.followFocus()
|
|
112
|
-
}))
|
|
303
|
+
}));
|
|
113
304
|
if (this.inputs.multi()) {
|
|
114
|
-
manager.on(Modifier.Any, 'Shift', () =>
|
|
305
|
+
manager.on(Modifier.Any, 'Shift', () => tree.anchor(this.treeBehavior.activeIndex())).on(Modifier.Shift, this.prevKey, () => tree.prev({
|
|
115
306
|
selectRange: true
|
|
116
|
-
})).on(Modifier.Shift, this.nextKey, () =>
|
|
307
|
+
})).on(Modifier.Shift, this.nextKey, () => tree.next({
|
|
117
308
|
selectRange: true
|
|
118
|
-
})).on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'Home', () =>
|
|
309
|
+
})).on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'Home', () => tree.first({
|
|
119
310
|
selectRange: true,
|
|
120
311
|
anchor: false
|
|
121
|
-
})).on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'End', () =>
|
|
312
|
+
})).on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'End', () => tree.last({
|
|
122
313
|
selectRange: true,
|
|
123
314
|
anchor: false
|
|
124
|
-
})).on(Modifier.Shift, 'Enter', () =>
|
|
315
|
+
})).on(Modifier.Shift, 'Enter', () => tree.updateSelection({
|
|
125
316
|
selectRange: true,
|
|
126
317
|
anchor: false
|
|
127
|
-
})).on(Modifier.Shift, this.dynamicSpaceKey, () =>
|
|
318
|
+
})).on(Modifier.Shift, this.dynamicSpaceKey, () => tree.updateSelection({
|
|
128
319
|
selectRange: true,
|
|
129
320
|
anchor: false
|
|
130
321
|
}));
|
|
131
322
|
}
|
|
132
323
|
if (!this.followFocus() && this.inputs.multi()) {
|
|
133
|
-
manager.on(this.dynamicSpaceKey, () =>
|
|
324
|
+
manager.on(this.dynamicSpaceKey, () => tree.toggle()).on('Enter', () => tree.toggle(), {
|
|
134
325
|
preventDefault: !this.nav()
|
|
135
|
-
}).on([Modifier.Ctrl, Modifier.Meta], 'A', () =>
|
|
326
|
+
}).on([Modifier.Ctrl, Modifier.Meta], 'A', () => tree.toggleAll());
|
|
136
327
|
}
|
|
137
328
|
if (!this.followFocus() && !this.inputs.multi()) {
|
|
138
|
-
manager.on(this.dynamicSpaceKey, () =>
|
|
139
|
-
manager.on('Enter', () =>
|
|
329
|
+
manager.on(this.dynamicSpaceKey, () => tree.selectOne());
|
|
330
|
+
manager.on('Enter', () => tree.selectOne(), {
|
|
140
331
|
preventDefault: !this.nav()
|
|
141
332
|
});
|
|
142
333
|
}
|
|
143
334
|
if (this.inputs.multi() && this.followFocus()) {
|
|
144
|
-
manager.on([Modifier.Ctrl, Modifier.Meta], this.prevKey, () =>
|
|
145
|
-
|
|
146
|
-
|
|
335
|
+
manager.on([Modifier.Ctrl, Modifier.Meta], this.prevKey, () => tree.prev()).on([Modifier.Ctrl, Modifier.Meta], this.nextKey, () => tree.next()).on([Modifier.Ctrl, Modifier.Meta], this.expandKey, () => this._expandOrFirstChild()).on([Modifier.Ctrl, Modifier.Meta], this.collapseKey, () => this._collapseOrParent()).on([Modifier.Ctrl, Modifier.Meta], ' ', () => tree.toggle()).on([Modifier.Ctrl, Modifier.Meta], 'Enter', () => tree.toggle()).on([Modifier.Ctrl, Modifier.Meta], 'Home', () => tree.first()).on([Modifier.Ctrl, Modifier.Meta], 'End', () => tree.last()).on([Modifier.Ctrl, Modifier.Meta], 'A', () => {
|
|
336
|
+
tree.toggleAll();
|
|
337
|
+
tree.select();
|
|
147
338
|
});
|
|
148
339
|
}
|
|
149
340
|
return manager;
|
|
@@ -178,7 +369,7 @@ class TreePattern {
|
|
|
178
369
|
element = () => this.inputs.element();
|
|
179
370
|
nav = () => this.inputs.nav();
|
|
180
371
|
currentType = () => this.inputs.currentType();
|
|
181
|
-
|
|
372
|
+
items = () => this.inputs.items();
|
|
182
373
|
focusMode = () => this.inputs.focusMode();
|
|
183
374
|
disabled = () => this.inputs.disabled();
|
|
184
375
|
activeItem;
|
|
@@ -194,22 +385,17 @@ class TreePattern {
|
|
|
194
385
|
this.inputs = inputs;
|
|
195
386
|
this.activeItem = inputs.activeItem;
|
|
196
387
|
this.values = inputs.values;
|
|
197
|
-
this.
|
|
388
|
+
this.treeBehavior = new Tree({
|
|
198
389
|
...inputs,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
202
|
-
this.expansionBehavior = new ListExpansion({
|
|
203
|
-
multiExpandable: () => true,
|
|
204
|
-
items: this.children,
|
|
205
|
-
disabled: this.disabled
|
|
390
|
+
multi: this.multi,
|
|
391
|
+
multiExpandable: () => true
|
|
206
392
|
});
|
|
207
393
|
}
|
|
208
394
|
setDefaultState() {
|
|
209
395
|
let firstItem;
|
|
210
|
-
for (const item of this.
|
|
396
|
+
for (const item of this.inputs.items()) {
|
|
211
397
|
if (!item.visible()) continue;
|
|
212
|
-
if (!this.
|
|
398
|
+
if (!this.treeBehavior.isFocusable(item)) continue;
|
|
213
399
|
if (firstItem === undefined) {
|
|
214
400
|
firstItem = item;
|
|
215
401
|
}
|
|
@@ -235,43 +421,23 @@ class TreePattern {
|
|
|
235
421
|
goto(e, opts) {
|
|
236
422
|
const item = this._getItem(e);
|
|
237
423
|
if (!item) return;
|
|
238
|
-
this.
|
|
239
|
-
this.toggleExpansion(item);
|
|
424
|
+
this.treeBehavior.goto(item, opts);
|
|
425
|
+
this.treeBehavior.toggleExpansion(item);
|
|
240
426
|
}
|
|
241
|
-
|
|
242
|
-
item
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
if (item.expanded()) {
|
|
246
|
-
this.collapse();
|
|
427
|
+
_expandOrFirstChild(opts) {
|
|
428
|
+
const item = this.treeBehavior.inputs.activeItem();
|
|
429
|
+
if (item && this.treeBehavior.isExpandable(item) && !item.expanded()) {
|
|
430
|
+
this.treeBehavior.expand(item);
|
|
247
431
|
} else {
|
|
248
|
-
this.
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
expand(opts) {
|
|
252
|
-
const item = this.activeItem();
|
|
253
|
-
if (!item || !this.listBehavior.isFocusable(item)) return;
|
|
254
|
-
if (item.expandable() && !item.expanded()) {
|
|
255
|
-
this.expansionBehavior.open(item);
|
|
256
|
-
} else if (item.expanded() && item.children().some(item => this.listBehavior.isFocusable(item))) {
|
|
257
|
-
this.listBehavior.next(opts);
|
|
432
|
+
this.treeBehavior.firstChild(opts);
|
|
258
433
|
}
|
|
259
434
|
}
|
|
260
|
-
|
|
261
|
-
item
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const item = this.activeItem();
|
|
267
|
-
if (!item || !this.listBehavior.isFocusable(item)) return;
|
|
268
|
-
if (item.expandable() && item.expanded()) {
|
|
269
|
-
this.expansionBehavior.close(item);
|
|
270
|
-
} else if (item.parent() && item.parent() !== this) {
|
|
271
|
-
const parentItem = item.parent();
|
|
272
|
-
if (parentItem instanceof TreeItemPattern && this.listBehavior.isFocusable(parentItem)) {
|
|
273
|
-
this.listBehavior.goto(parentItem, opts);
|
|
274
|
-
}
|
|
435
|
+
_collapseOrParent(opts) {
|
|
436
|
+
const item = this.treeBehavior.inputs.activeItem();
|
|
437
|
+
if (item && this.treeBehavior.isExpandable(item) && item.expanded()) {
|
|
438
|
+
this.treeBehavior.collapse(item);
|
|
439
|
+
} else {
|
|
440
|
+
this.treeBehavior.parent(opts);
|
|
275
441
|
}
|
|
276
442
|
}
|
|
277
443
|
_getItem(event) {
|
|
@@ -279,17 +445,18 @@ class TreePattern {
|
|
|
279
445
|
return;
|
|
280
446
|
}
|
|
281
447
|
const element = event.target.closest('[role="treeitem"]');
|
|
282
|
-
return this.inputs.
|
|
448
|
+
return this.inputs.items().find(i => i.element() === element);
|
|
283
449
|
}
|
|
284
450
|
}
|
|
285
451
|
|
|
286
452
|
class ComboboxTreePattern extends TreePattern {
|
|
287
453
|
inputs;
|
|
454
|
+
toggleExpansion = item => this.treeBehavior.toggleExpansion(item);
|
|
288
455
|
isItemCollapsible = () => this.inputs.activeItem()?.parent() instanceof TreeItemPattern;
|
|
289
456
|
role = () => 'tree';
|
|
290
|
-
activeId = computed(() => this.
|
|
457
|
+
activeId = computed(() => this.treeBehavior.activeDescendant());
|
|
291
458
|
getActiveItem = () => this.inputs.activeItem();
|
|
292
|
-
items = computed(() => this.inputs.
|
|
459
|
+
items = computed(() => this.inputs.items());
|
|
293
460
|
tabIndex = () => -1;
|
|
294
461
|
constructor(inputs) {
|
|
295
462
|
if (inputs.combobox()) {
|
|
@@ -303,25 +470,25 @@ class ComboboxTreePattern extends TreePattern {
|
|
|
303
470
|
onKeydown(_) {}
|
|
304
471
|
onPointerdown(_) {}
|
|
305
472
|
setDefaultState() {}
|
|
306
|
-
focus = item => this.
|
|
307
|
-
next = () => this.
|
|
308
|
-
prev = () => this.
|
|
309
|
-
last = () => this.
|
|
310
|
-
first = () => this.
|
|
311
|
-
unfocus = () => this.
|
|
312
|
-
select = item => this.
|
|
313
|
-
toggle = item => this.
|
|
314
|
-
clearSelection = () => this.
|
|
473
|
+
focus = item => this.treeBehavior.goto(item);
|
|
474
|
+
next = () => this.treeBehavior.next();
|
|
475
|
+
prev = () => this.treeBehavior.prev();
|
|
476
|
+
last = () => this.treeBehavior.last();
|
|
477
|
+
first = () => this.treeBehavior.first();
|
|
478
|
+
unfocus = () => this.treeBehavior.unfocus();
|
|
479
|
+
select = item => this.treeBehavior.select(item);
|
|
480
|
+
toggle = item => this.treeBehavior.toggle(item);
|
|
481
|
+
clearSelection = () => this.treeBehavior.deselectAll();
|
|
315
482
|
getItem = e => this._getItem(e);
|
|
316
|
-
getSelectedItems = () => this.inputs.
|
|
483
|
+
getSelectedItems = () => this.inputs.items().filter(item => item.selected());
|
|
317
484
|
setValue = value => this.inputs.values.set(value ? [value] : []);
|
|
318
|
-
expandItem = () => this.
|
|
319
|
-
collapseItem = () => this.
|
|
485
|
+
expandItem = () => this._expandOrFirstChild();
|
|
486
|
+
collapseItem = () => this._collapseOrParent();
|
|
320
487
|
isItemExpandable(item = this.inputs.activeItem()) {
|
|
321
488
|
return item ? item.expandable() : false;
|
|
322
489
|
}
|
|
323
|
-
expandAll = () => this.
|
|
324
|
-
collapseAll = () => this.
|
|
490
|
+
expandAll = () => this.treeBehavior.expandAll();
|
|
491
|
+
collapseAll = () => this.treeBehavior.collapseAll();
|
|
325
492
|
isItemSelectable = (item = this.inputs.activeItem()) => {
|
|
326
493
|
return item ? item.selectable() : false;
|
|
327
494
|
};
|