@angular/aria 21.0.0-rc.1 → 21.0.0-rc.3
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/_adev_assets/aria-accordion.json +429 -59
- package/_adev_assets/aria-combobox.json +261 -41
- package/_adev_assets/aria-grid.json +339 -85
- package/_adev_assets/aria-listbox.json +99 -70
- package/_adev_assets/aria-menu.json +355 -158
- package/_adev_assets/aria-tabs.json +198 -305
- package/_adev_assets/aria-toolbar.json +70 -221
- package/_adev_assets/aria-tree.json +153 -363
- package/fesm2022/_widget-chunk.mjs +388 -57
- package/fesm2022/_widget-chunk.mjs.map +1 -1
- package/fesm2022/accordion.mjs +125 -72
- package/fesm2022/accordion.mjs.map +1 -1
- package/fesm2022/aria.mjs +1 -1
- package/fesm2022/aria.mjs.map +1 -1
- package/fesm2022/combobox.mjs +129 -24
- package/fesm2022/combobox.mjs.map +1 -1
- package/fesm2022/grid.mjs +203 -65
- package/fesm2022/grid.mjs.map +1 -1
- package/fesm2022/listbox.mjs +50 -39
- package/fesm2022/listbox.mjs.map +1 -1
- package/fesm2022/menu.mjs +179 -71
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/private.mjs +418 -440
- package/fesm2022/private.mjs.map +1 -1
- package/fesm2022/tabs.mjs +105 -73
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +52 -44
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tree.mjs +106 -63
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/types/_grid-chunk.d.ts +216 -35
- package/types/accordion.d.ts +134 -35
- package/types/combobox.d.ts +141 -12
- package/types/grid.d.ts +150 -32
- package/types/listbox.d.ts +60 -28
- package/types/menu.d.ts +133 -49
- package/types/private.d.ts +210 -250
- package/types/tabs.d.ts +124 -44
- package/types/toolbar.d.ts +58 -36
- package/types/tree.d.ts +121 -49
package/fesm2022/listbox.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { input, inject, ElementRef, contentChildren, computed, booleanAttribute, model, signal, afterRenderEffect, untracked, Directive } from '@angular/core';
|
|
3
3
|
import { ComboboxListboxPattern, ListboxPattern, OptionPattern } from '@angular/aria/private';
|
|
4
4
|
import { Directionality } from '@angular/cdk/bidi';
|
|
5
5
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -7,14 +7,14 @@ import { _IdGenerator } from '@angular/cdk/a11y';
|
|
|
7
7
|
import { ComboboxPopup } from './combobox.mjs';
|
|
8
8
|
|
|
9
9
|
class Listbox {
|
|
10
|
-
|
|
11
|
-
id = computed(() => this._generatedId, ...(ngDevMode ? [{
|
|
10
|
+
id = input(inject(_IdGenerator).getId('ng-listbox-', true), ...(ngDevMode ? [{
|
|
12
11
|
debugName: "id"
|
|
13
12
|
}] : []));
|
|
14
13
|
_popup = inject(ComboboxPopup, {
|
|
15
14
|
optional: true
|
|
16
15
|
});
|
|
17
16
|
_elementRef = inject(ElementRef);
|
|
17
|
+
element = this._elementRef.nativeElement;
|
|
18
18
|
_directionality = inject(Directionality);
|
|
19
19
|
_options = contentChildren(Option, ...(ngDevMode ? [{
|
|
20
20
|
debugName: "_options",
|
|
@@ -55,7 +55,7 @@ class Listbox {
|
|
|
55
55
|
selectionMode = input('follow', ...(ngDevMode ? [{
|
|
56
56
|
debugName: "selectionMode"
|
|
57
57
|
}] : []));
|
|
58
|
-
typeaheadDelay = input(
|
|
58
|
+
typeaheadDelay = input(500, ...(ngDevMode ? [{
|
|
59
59
|
debugName: "typeaheadDelay"
|
|
60
60
|
}] : []));
|
|
61
61
|
disabled = input(false, ...(ngDevMode ? [{
|
|
@@ -70,8 +70,8 @@ class Listbox {
|
|
|
70
70
|
}] : [{
|
|
71
71
|
transform: booleanAttribute
|
|
72
72
|
}]));
|
|
73
|
-
|
|
74
|
-
debugName: "
|
|
73
|
+
values = model([], ...(ngDevMode ? [{
|
|
74
|
+
debugName: "values"
|
|
75
75
|
}] : []));
|
|
76
76
|
_pattern;
|
|
77
77
|
_hasFocused = signal(false, ...(ngDevMode ? [{
|
|
@@ -89,7 +89,7 @@ class Listbox {
|
|
|
89
89
|
};
|
|
90
90
|
this._pattern = this._popup?.combobox ? new ComboboxListboxPattern(inputs) : new ListboxPattern(inputs);
|
|
91
91
|
if (this._popup) {
|
|
92
|
-
this._popup.
|
|
92
|
+
this._popup._controls.set(this._pattern);
|
|
93
93
|
}
|
|
94
94
|
afterRenderEffect(() => {
|
|
95
95
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
@@ -113,13 +113,13 @@ class Listbox {
|
|
|
113
113
|
});
|
|
114
114
|
afterRenderEffect(() => {
|
|
115
115
|
const items = inputs.items();
|
|
116
|
-
const
|
|
117
|
-
if (items &&
|
|
118
|
-
this.
|
|
116
|
+
const values = untracked(() => this.values());
|
|
117
|
+
if (items && values.some(v => !items.some(i => i.value() === v))) {
|
|
118
|
+
this.values.set(values.filter(v => items.some(i => i.value() === v)));
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
_onFocus() {
|
|
123
123
|
this._hasFocused.set(true);
|
|
124
124
|
}
|
|
125
125
|
scrollActiveItemIntoView(options = {
|
|
@@ -127,6 +127,9 @@ class Listbox {
|
|
|
127
127
|
}) {
|
|
128
128
|
this._pattern.inputs.activeItem()?.element()?.scrollIntoView(options);
|
|
129
129
|
}
|
|
130
|
+
gotoFirst() {
|
|
131
|
+
this._pattern.listBehavior.first();
|
|
132
|
+
}
|
|
130
133
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
131
134
|
minVersion: "12.0.0",
|
|
132
135
|
version: "20.2.0-next.2",
|
|
@@ -142,6 +145,13 @@ class Listbox {
|
|
|
142
145
|
isStandalone: true,
|
|
143
146
|
selector: "[ngListbox]",
|
|
144
147
|
inputs: {
|
|
148
|
+
id: {
|
|
149
|
+
classPropertyName: "id",
|
|
150
|
+
publicName: "id",
|
|
151
|
+
isSignal: true,
|
|
152
|
+
isRequired: false,
|
|
153
|
+
transformFunction: null
|
|
154
|
+
},
|
|
145
155
|
orientation: {
|
|
146
156
|
classPropertyName: "orientation",
|
|
147
157
|
publicName: "orientation",
|
|
@@ -205,16 +215,16 @@ class Listbox {
|
|
|
205
215
|
isRequired: false,
|
|
206
216
|
transformFunction: null
|
|
207
217
|
},
|
|
208
|
-
|
|
209
|
-
classPropertyName: "
|
|
210
|
-
publicName: "
|
|
218
|
+
values: {
|
|
219
|
+
classPropertyName: "values",
|
|
220
|
+
publicName: "values",
|
|
211
221
|
isSignal: true,
|
|
212
222
|
isRequired: false,
|
|
213
223
|
transformFunction: null
|
|
214
224
|
}
|
|
215
225
|
},
|
|
216
226
|
outputs: {
|
|
217
|
-
|
|
227
|
+
values: "valuesChange"
|
|
218
228
|
},
|
|
219
229
|
host: {
|
|
220
230
|
attributes: {
|
|
@@ -223,7 +233,7 @@ class Listbox {
|
|
|
223
233
|
listeners: {
|
|
224
234
|
"keydown": "_pattern.onKeydown($event)",
|
|
225
235
|
"pointerdown": "_pattern.onPointerdown($event)",
|
|
226
|
-
"focusin": "
|
|
236
|
+
"focusin": "_onFocus()"
|
|
227
237
|
},
|
|
228
238
|
properties: {
|
|
229
239
|
"attr.id": "id()",
|
|
@@ -233,8 +243,7 @@ class Listbox {
|
|
|
233
243
|
"attr.aria-orientation": "_pattern.orientation()",
|
|
234
244
|
"attr.aria-multiselectable": "_pattern.multi()",
|
|
235
245
|
"attr.aria-activedescendant": "_pattern.activeDescendant()"
|
|
236
|
-
}
|
|
237
|
-
classAttribute: "ng-listbox"
|
|
246
|
+
}
|
|
238
247
|
},
|
|
239
248
|
queries: [{
|
|
240
249
|
propertyName: "_options",
|
|
@@ -261,7 +270,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
261
270
|
exportAs: 'ngListbox',
|
|
262
271
|
host: {
|
|
263
272
|
'role': 'listbox',
|
|
264
|
-
'class': 'ng-listbox',
|
|
265
273
|
'[attr.id]': 'id()',
|
|
266
274
|
'[attr.tabindex]': '_pattern.tabIndex()',
|
|
267
275
|
'[attr.aria-readonly]': '_pattern.readonly()',
|
|
@@ -271,30 +279,28 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
271
279
|
'[attr.aria-activedescendant]': '_pattern.activeDescendant()',
|
|
272
280
|
'(keydown)': '_pattern.onKeydown($event)',
|
|
273
281
|
'(pointerdown)': '_pattern.onPointerdown($event)',
|
|
274
|
-
'(focusin)': '
|
|
282
|
+
'(focusin)': '_onFocus()'
|
|
275
283
|
},
|
|
276
|
-
hostDirectives: [
|
|
277
|
-
directive: ComboboxPopup
|
|
278
|
-
}]
|
|
284
|
+
hostDirectives: [ComboboxPopup]
|
|
279
285
|
}]
|
|
280
286
|
}],
|
|
281
287
|
ctorParameters: () => []
|
|
282
288
|
});
|
|
283
289
|
class Option {
|
|
284
290
|
_elementRef = inject(ElementRef);
|
|
291
|
+
element = this._elementRef.nativeElement;
|
|
292
|
+
active = computed(() => this._pattern.active(), ...(ngDevMode ? [{
|
|
293
|
+
debugName: "active"
|
|
294
|
+
}] : []));
|
|
285
295
|
_listbox = inject(Listbox);
|
|
286
|
-
|
|
287
|
-
id = computed(() => this._generatedId, ...(ngDevMode ? [{
|
|
296
|
+
id = input(inject(_IdGenerator).getId('ng-option-', true), ...(ngDevMode ? [{
|
|
288
297
|
debugName: "id"
|
|
289
298
|
}] : []));
|
|
290
|
-
searchTerm = computed(() => this.label() ?? this.element
|
|
299
|
+
searchTerm = computed(() => this.label() ?? this.element.textContent, ...(ngDevMode ? [{
|
|
291
300
|
debugName: "searchTerm"
|
|
292
301
|
}] : []));
|
|
293
|
-
|
|
294
|
-
debugName: "
|
|
295
|
-
}] : []));
|
|
296
|
-
element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{
|
|
297
|
-
debugName: "element"
|
|
302
|
+
_listboxPattern = computed(() => this._listbox._pattern, ...(ngDevMode ? [{
|
|
303
|
+
debugName: "_listboxPattern"
|
|
298
304
|
}] : []));
|
|
299
305
|
value = input.required(...(ngDevMode ? [{
|
|
300
306
|
debugName: "value"
|
|
@@ -315,9 +321,9 @@ class Option {
|
|
|
315
321
|
...this,
|
|
316
322
|
id: this.id,
|
|
317
323
|
value: this.value,
|
|
318
|
-
listbox: this.
|
|
319
|
-
element: this.element,
|
|
320
|
-
searchTerm: this.searchTerm
|
|
324
|
+
listbox: this._listboxPattern,
|
|
325
|
+
element: () => this.element,
|
|
326
|
+
searchTerm: () => this.searchTerm() ?? ''
|
|
321
327
|
});
|
|
322
328
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
323
329
|
minVersion: "12.0.0",
|
|
@@ -334,6 +340,13 @@ class Option {
|
|
|
334
340
|
isStandalone: true,
|
|
335
341
|
selector: "[ngOption]",
|
|
336
342
|
inputs: {
|
|
343
|
+
id: {
|
|
344
|
+
classPropertyName: "id",
|
|
345
|
+
publicName: "id",
|
|
346
|
+
isSignal: true,
|
|
347
|
+
isRequired: false,
|
|
348
|
+
transformFunction: null
|
|
349
|
+
},
|
|
337
350
|
value: {
|
|
338
351
|
classPropertyName: "value",
|
|
339
352
|
publicName: "value",
|
|
@@ -361,13 +374,12 @@ class Option {
|
|
|
361
374
|
"role": "option"
|
|
362
375
|
},
|
|
363
376
|
properties: {
|
|
364
|
-
"attr.data-active": "
|
|
377
|
+
"attr.data-active": "active()",
|
|
365
378
|
"attr.id": "_pattern.id()",
|
|
366
379
|
"attr.tabindex": "_pattern.tabIndex()",
|
|
367
380
|
"attr.aria-selected": "_pattern.selected()",
|
|
368
381
|
"attr.aria-disabled": "_pattern.disabled()"
|
|
369
|
-
}
|
|
370
|
-
classAttribute: "ng-option"
|
|
382
|
+
}
|
|
371
383
|
},
|
|
372
384
|
exportAs: ["ngOption"],
|
|
373
385
|
ngImport: i0
|
|
@@ -385,8 +397,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
385
397
|
exportAs: 'ngOption',
|
|
386
398
|
host: {
|
|
387
399
|
'role': 'option',
|
|
388
|
-
'
|
|
389
|
-
'[attr.data-active]': '_pattern.active()',
|
|
400
|
+
'[attr.data-active]': 'active()',
|
|
390
401
|
'[attr.id]': '_pattern.id()',
|
|
391
402
|
'[attr.tabindex]': '_pattern.tabIndex()',
|
|
392
403
|
'[attr.aria-selected]': '_pattern.selected()',
|
package/fesm2022/listbox.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/listbox/listbox.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n contentChildren,\n Directive,\n ElementRef,\n inject,\n input,\n model,\n signal,\n untracked,\n} from '@angular/core';\nimport {ComboboxListboxPattern, ListboxPattern, OptionPattern} from '@angular/aria/private';\nimport {Directionality} from '@angular/cdk/bidi';\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {_IdGenerator} from '@angular/cdk/a11y';\nimport {ComboboxPopup} from '../combobox';\n\n/**\n * A listbox container.\n *\n * Listboxes are used to display a list of items for a user to select from. The Listbox is meant\n * to be used in conjunction with Option as follows:\n *\n * ```html\n * <ul ngListbox>\n * <li [value]=\"1\" ngOption>Item 1</li>\n * <li [value]=\"2\" ngOption>Item 2</li>\n * <li [value]=\"3\" ngOption>Item 3</li>\n * </ul>\n * ```\n */\n@Directive({\n selector: '[ngListbox]',\n exportAs: 'ngListbox',\n host: {\n 'role': 'listbox',\n 'class': 'ng-listbox',\n '[attr.id]': 'id()',\n '[attr.tabindex]': '_pattern.tabIndex()',\n '[attr.aria-readonly]': '_pattern.readonly()',\n '[attr.aria-disabled]': '_pattern.disabled()',\n '[attr.aria-orientation]': '_pattern.orientation()',\n '[attr.aria-multiselectable]': '_pattern.multi()',\n '[attr.aria-activedescendant]': '_pattern.activeDescendant()',\n '(keydown)': '_pattern.onKeydown($event)',\n '(pointerdown)': '_pattern.onPointerdown($event)',\n '(focusin)': 'onFocus()',\n },\n hostDirectives: [{directive: ComboboxPopup}],\n})\nexport class Listbox<V> {\n /** A unique identifier for the listbox. */\n private readonly _generatedId = inject(_IdGenerator).getId('ng-listbox-', true);\n\n // TODO(wagnermaciel): https://github.com/angular/components/pull/30495#discussion_r1972601144.\n /** A unique identifier for the listbox. */\n protected id = computed(() => this._generatedId);\n\n /** A reference to the parent combobox popup, if one exists. */\n private readonly _popup = inject<ComboboxPopup<V>>(ComboboxPopup, {\n optional: true,\n });\n\n /** A reference to the listbox element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The directionality (LTR / RTL) context for the application (or a subtree of it). */\n private readonly _directionality = inject(Directionality);\n\n /** The Options nested inside of the Listbox. */\n private readonly _options = contentChildren(Option, {descendants: true});\n\n /** A signal wrapper for directionality. */\n protected textDirection = toSignal(this._directionality.change, {\n initialValue: this._directionality.value,\n });\n\n /** The Option UIPatterns of the child Options. */\n protected items = computed(() => this._options().map(option => option._pattern));\n\n /** Whether the list is vertically or horizontally oriented. */\n orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Whether multiple items in the list can be selected at once. */\n multi = input(false, {transform: booleanAttribute});\n\n /** Whether focus should wrap when navigating. */\n wrap = input(true, {transform: booleanAttribute});\n\n /** Whether to allow disabled items in the list to receive focus. */\n softDisabled = input(true, {transform: booleanAttribute});\n\n /** The focus strategy used by the list. */\n focusMode = input<'roving' | 'activedescendant'>('roving');\n\n /** The selection strategy used by the list. */\n selectionMode = input<'follow' | 'explicit'>('follow');\n\n /** The amount of time before the typeahead search is reset. */\n typeaheadDelay = input<number>(0.5); // Picked arbitrarily.\n\n /** Whether the listbox is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** Whether the listbox is readonly. */\n readonly = input(false, {transform: booleanAttribute});\n\n /** The values of the current selected items. */\n value = model<V[]>([]);\n\n /** The Listbox UIPattern. */\n readonly _pattern: ListboxPattern<V>;\n\n /** Whether the listbox has received focus yet. */\n private _hasFocused = signal(false);\n\n constructor() {\n const inputs = {\n ...this,\n id: this.id,\n items: this.items,\n activeItem: signal(undefined),\n textDirection: this.textDirection,\n element: () => this._elementRef.nativeElement,\n combobox: () => this._popup?.combobox?._pattern,\n };\n\n this._pattern = this._popup?.combobox\n ? new ComboboxListboxPattern<V>(inputs)\n : new ListboxPattern<V>(inputs);\n\n if (this._popup) {\n this._popup.controls.set(this._pattern as ComboboxListboxPattern<V>);\n }\n\n afterRenderEffect(() => {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const violations = this._pattern.validate();\n for (const violation of violations) {\n console.error(violation);\n }\n }\n });\n\n afterRenderEffect(() => {\n if (!this._hasFocused()) {\n this._pattern.setDefaultState();\n }\n });\n\n // Ensure that if the active item is removed from\n // the list, the listbox updates it's focus state.\n afterRenderEffect(() => {\n const items = inputs.items();\n const activeItem = untracked(() => inputs.activeItem());\n\n if (!items.some(i => i === activeItem) && activeItem) {\n this._pattern.listBehavior.unfocus();\n }\n });\n\n // Ensure that the value is always in sync with the available options.\n afterRenderEffect(() => {\n const items = inputs.items();\n const value = untracked(() => this.value());\n\n if (items && value.some(v => !items.some(i => i.value() === v))) {\n this.value.set(value.filter(v => items.some(i => i.value() === v)));\n }\n });\n }\n\n onFocus() {\n this._hasFocused.set(true);\n }\n\n scrollActiveItemIntoView(options: ScrollIntoViewOptions = {block: 'nearest'}) {\n this._pattern.inputs.activeItem()?.element()?.scrollIntoView(options);\n }\n}\n\n/** A selectable option in a Listbox. */\n@Directive({\n selector: '[ngOption]',\n exportAs: 'ngOption',\n host: {\n 'role': 'option',\n 'class': 'ng-option',\n '[attr.data-active]': '_pattern.active()',\n '[attr.id]': '_pattern.id()',\n '[attr.tabindex]': '_pattern.tabIndex()',\n '[attr.aria-selected]': '_pattern.selected()',\n '[attr.aria-disabled]': '_pattern.disabled()',\n },\n})\nexport class Option<V> {\n /** A reference to the option element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The parent Listbox. */\n private readonly _listbox = inject(Listbox);\n\n /** A unique identifier for the option. */\n private readonly _generatedId = inject(_IdGenerator).getId('ng-option-', true);\n\n // TODO(wagnermaciel): https://github.com/angular/components/pull/30495#discussion_r1972601144.\n /** A unique identifier for the option. */\n protected id = computed(() => this._generatedId);\n\n // TODO(wagnermaciel): See if we want to change how we handle this since textContent is not\n // reactive. See https://github.com/angular/components/pull/30495#discussion_r1961260216.\n /** The text used by the typeahead search. */\n protected searchTerm = computed(() => this.label() ?? this.element().textContent);\n\n /** The parent Listbox UIPattern. */\n protected listbox = computed(() => this._listbox._pattern);\n\n /** A reference to the option element to be focused on navigation. */\n protected element = computed(() => this._elementRef.nativeElement);\n\n /** The value of the option. */\n value = input.required<V>();\n\n /** Whether an item is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** The text used by the typeahead search. */\n label = input<string>();\n\n /** Whether the option is selected. */\n readonly selected = computed(() => this._pattern.selected());\n\n /** The Option UIPattern. */\n readonly _pattern = new OptionPattern<V>({\n ...this,\n id: this.id,\n value: this.value,\n listbox: this.listbox,\n element: this.element,\n searchTerm: this.searchTerm,\n });\n}\n"],"names":["Listbox","_generatedId","inject","_IdGenerator","getId","id","computed","ngDevMode","debugName","_popup","ComboboxPopup","optional","_elementRef","ElementRef","_directionality","Directionality","_options","contentChildren","Option","descendants","textDirection","toSignal","change","initialValue","value","items","map","option","_pattern","orientation","input","multi","transform","booleanAttribute","wrap","softDisabled","focusMode","selectionMode","typeaheadDelay","disabled","readonly","model","_hasFocused","signal","constructor","inputs","activeItem","undefined","element","nativeElement","combobox","ComboboxListboxPattern","ListboxPattern","controls","set","afterRenderEffect","violations","validate","violation","console","error","setDefaultState","untracked","some","i","listBehavior","unfocus","v","filter","onFocus","scrollActiveItemIntoView","options","block","scrollIntoView","deps","target","i0","ɵɵFactoryTarget","Directive","ɵdir","ɵɵngDeclareDirective","minVersion","version","type","isSignal","exportAs","hostDirectives","directive","i1","ngImport","decorators","args","selector","host","_listbox","searchTerm","label","textContent","listbox","required","selected","OptionPattern","isStandalone","classPropertyName","publicName","isRequired","transformFunction","attributes","properties","classAttribute"],"mappings":";;;;;;;;MA4DaA,OAAO,CAAA;EAEDC,YAAY,GAAGC,MAAM,CAACC,YAAY,CAAC,CAACC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC;EAIrEC,EAAE,GAAGC,QAAQ,CAAC,MAAM,IAAI,CAACL,YAAY,EAAA,IAAAM,SAAA,GAAA,CAAA;AAAAC,IAAAA,SAAA,EAAA;AAAA,GAAA,CAAA,GAAA,EAAA,CAAA,CAAC;AAG/BC,EAAAA,MAAM,GAAGP,MAAM,CAAmBQ,aAAa,EAAE;AAChEC,IAAAA,QAAQ,EAAE;AACX,GAAA,CAAC;AAGeC,EAAAA,WAAW,GAAGV,MAAM,CAACW,UAAU,CAAC;AAGhCC,EAAAA,eAAe,GAAGZ,MAAM,CAACa,cAAc,CAAC;EAGxCC,QAAQ,GAAGC,eAAe,CAACC,MAAM;;AAAGC,IAAAA,WAAW,EAAE;GAAI,CAAA,GAAA,CAAlB;AAACA,IAAAA,WAAW,EAAE;GAAK,GAAC;EAG9DC,aAAa,GAAGC,QAAQ,CAAC,IAAI,CAACP,eAAe,CAACQ,MAAM,EAAE;AAC9DC,IAAAA,YAAY,EAAE,IAAI,CAACT,eAAe,CAACU;AACpC,GAAA,CAAC;EAGQC,KAAK,GAAGnB,QAAQ,CAAC,MAAM,IAAI,CAACU,QAAQ,EAAE,CAACU,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,QAAQ,CAAC,EAAA,IAAArB,SAAA,GAAA,CAAA;AAAAC,IAAAA,SAAA,EAAA;AAAA,GAAA,CAAA,GAAA,EAAA,CAAA,CAAC;EAGhFqB,WAAW,GAAGC,KAAK,CAA4B,UAAU;;WAAC;EAG1DC,KAAK,G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KAAA;IAAAxB,QAAA,EAAA,CAAA,UAAA,CAAA;AAAAI,IAAAA,QAAA,EAAAb;AAAA,GAAA,CAAA;;;;;;QAAN1D,MAAM;AAAAwE,EAAAA,UAAA,EAAA,CAAA;UAblBZ,SAAS;AAACa,IAAAA,IAAA,EAAA,CAAA;AACTC,MAAAA,QAAQ,EAAE,YAAY;AACtBP,MAAAA,QAAQ,EAAE,UAAU;AACpBQ,MAAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,QAAQ;AAChB,QAAA,OAAO,EAAE,WAAW;AACpB,QAAA,oBAAoB,EAAE,mBAAmB;AACzC,QAAA,WAAW,EAAE,eAAe;AAC5B,QAAA,iBAAiB,EAAE,qBAAqB;AACxC,QAAA,sBAAsB,EAAE,qBAAqB;AAC7C,QAAA,sBAAsB,EAAE;AACzB;KACF;;;;;;"}
|
|
1
|
+
{"version":3,"file":"listbox.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/listbox/listbox.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n contentChildren,\n Directive,\n ElementRef,\n inject,\n input,\n model,\n signal,\n untracked,\n} from '@angular/core';\nimport {ComboboxListboxPattern, ListboxPattern, OptionPattern} from '@angular/aria/private';\nimport {Directionality} from '@angular/cdk/bidi';\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {_IdGenerator} from '@angular/cdk/a11y';\nimport {ComboboxPopup} from '../combobox';\n\n/**\n * Represents a container used to display a list of items for a user to select from.\n *\n * The `ngListbox` is meant to be used in conjunction with `ngOption` directives to create a\n * selectable list. It supports single and multiple selection modes, as well as various focus and\n * orientation strategies.\n *\n * ```html\n * <ul ngListbox [(value)]=\"selectedItems\" [multi]=\"true\" orientation=\"vertical\">\n * @for (item of items; track item.id) {\n * <li ngOption [value]=\"item.id\" [label]=\"item.name\" [disabled]=\"item.disabled\">\n * {{item.name}}\n * </li>\n * }\n * </ul>\n * ```\n *\n * @developerPreview 21.0\n */\n@Directive({\n selector: '[ngListbox]',\n exportAs: 'ngListbox',\n host: {\n 'role': 'listbox',\n '[attr.id]': 'id()',\n '[attr.tabindex]': '_pattern.tabIndex()',\n '[attr.aria-readonly]': '_pattern.readonly()',\n '[attr.aria-disabled]': '_pattern.disabled()',\n '[attr.aria-orientation]': '_pattern.orientation()',\n '[attr.aria-multiselectable]': '_pattern.multi()',\n '[attr.aria-activedescendant]': '_pattern.activeDescendant()',\n '(keydown)': '_pattern.onKeydown($event)',\n '(pointerdown)': '_pattern.onPointerdown($event)',\n '(focusin)': '_onFocus()',\n },\n hostDirectives: [ComboboxPopup],\n})\nexport class Listbox<V> {\n /** A unique identifier for the listbox. */\n readonly id = input(inject(_IdGenerator).getId('ng-listbox-', true));\n\n /** A reference to the parent combobox popup, if one exists. */\n private readonly _popup = inject<ComboboxPopup<V>>(ComboboxPopup, {\n optional: true,\n });\n\n /** A reference to the host element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** A reference to the host element. */\n readonly element = this._elementRef.nativeElement as HTMLElement;\n\n /** The directionality (LTR / RTL) context for the application (or a subtree of it). */\n private readonly _directionality = inject(Directionality);\n\n /** The Options nested inside of the Listbox. */\n private readonly _options = contentChildren(Option, {descendants: true});\n\n /** A signal wrapper for directionality. */\n protected textDirection = toSignal(this._directionality.change, {\n initialValue: this._directionality.value,\n });\n\n /** The Option UIPatterns of the child Options. */\n protected items = computed(() => this._options().map(option => option._pattern));\n\n /** Whether the list is vertically or horizontally oriented. */\n orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Whether multiple items in the list can be selected at once. */\n multi = input(false, {transform: booleanAttribute});\n\n /** Whether focus should wrap when navigating. */\n wrap = input(true, {transform: booleanAttribute});\n\n /**\n * Whether to allow disabled items to receive focus. When `true`, disabled items are\n * focusable but not interactive. When `false`, disabled items are skipped during navigation.\n */\n softDisabled = input(true, {transform: booleanAttribute});\n\n /**\n * The focus strategy used by the list.\n * - `roving`: Focus is moved to the active item using `tabindex`.\n * - `activedescendant`: Focus remains on the listbox container, and `aria-activedescendant` is used to indicate the active item.\n */\n focusMode = input<'roving' | 'activedescendant'>('roving');\n\n /**\n * The selection strategy used by the list.\n * - `follow`: The focused item is automatically selected.\n * - `explicit`: Items are selected explicitly by the user (e.g., via click or spacebar).\n */\n selectionMode = input<'follow' | 'explicit'>('follow');\n\n /** The amount of time before the typeahead search is reset. */\n typeaheadDelay = input<number>(500); // Picked arbitrarily.\n\n /** Whether the listbox is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** Whether the listbox is readonly. */\n readonly = input(false, {transform: booleanAttribute});\n\n /** The values of the currently selected items. */\n values = model<V[]>([]);\n\n /** The Listbox UIPattern. */\n readonly _pattern: ListboxPattern<V>;\n\n /** Whether the listbox has received focus yet. */\n private _hasFocused = signal(false);\n\n constructor() {\n const inputs = {\n ...this,\n id: this.id,\n items: this.items,\n activeItem: signal(undefined),\n textDirection: this.textDirection,\n element: () => this._elementRef.nativeElement,\n combobox: () => this._popup?.combobox?._pattern,\n };\n\n this._pattern = this._popup?.combobox\n ? new ComboboxListboxPattern<V>(inputs)\n : new ListboxPattern<V>(inputs);\n\n if (this._popup) {\n this._popup._controls.set(this._pattern as ComboboxListboxPattern<V>);\n }\n\n afterRenderEffect(() => {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const violations = this._pattern.validate();\n for (const violation of violations) {\n console.error(violation);\n }\n }\n });\n\n afterRenderEffect(() => {\n if (!this._hasFocused()) {\n this._pattern.setDefaultState();\n }\n });\n\n // Ensure that if the active item is removed from\n // the list, the listbox updates it's focus state.\n afterRenderEffect(() => {\n const items = inputs.items();\n const activeItem = untracked(() => inputs.activeItem());\n\n if (!items.some(i => i === activeItem) && activeItem) {\n this._pattern.listBehavior.unfocus();\n }\n });\n\n // Ensure that the values are always in sync with the available options.\n afterRenderEffect(() => {\n const items = inputs.items();\n const values = untracked(() => this.values());\n\n if (items && values.some(v => !items.some(i => i.value() === v))) {\n this.values.set(values.filter(v => items.some(i => i.value() === v)));\n }\n });\n }\n\n _onFocus() {\n this._hasFocused.set(true);\n }\n\n scrollActiveItemIntoView(options: ScrollIntoViewOptions = {block: 'nearest'}) {\n this._pattern.inputs.activeItem()?.element()?.scrollIntoView(options);\n }\n\n /** Navigates to the first item in the listbox. */\n gotoFirst() {\n this._pattern.listBehavior.first();\n }\n}\n\n/**\n * A selectable option in an `ngListbox`.\n *\n * This directive should be applied to an element (e.g., `<li>`, `<div>`) within an\n * `ngListbox`. The `value` input is used to identify the option, and the `label` input provides\n * the accessible name for the option.\n *\n * ```html\n * <li ngOption value=\"item-id\" label=\"Item Name\">\n * Item Name\n * </li>\n * ```\n *\n * @developerPreview 21.0\n */\n@Directive({\n selector: '[ngOption]',\n exportAs: 'ngOption',\n host: {\n 'role': 'option',\n '[attr.data-active]': 'active()',\n '[attr.id]': '_pattern.id()',\n '[attr.tabindex]': '_pattern.tabIndex()',\n '[attr.aria-selected]': '_pattern.selected()',\n '[attr.aria-disabled]': '_pattern.disabled()',\n },\n})\nexport class Option<V> {\n /** A reference to the host element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** A reference to the host element. */\n readonly element = this._elementRef.nativeElement as HTMLElement;\n\n /** Whether the option is currently active (focused). */\n active = computed(() => this._pattern.active());\n\n /** The parent Listbox. */\n private readonly _listbox = inject(Listbox);\n\n /** A unique identifier for the option. */\n readonly id = input(inject(_IdGenerator).getId('ng-option-', true));\n\n // TODO(wagnermaciel): See if we want to change how we handle this since textContent is not\n // reactive. See https://github.com/angular/components/pull/30495#discussion_r1961260216.\n /** The text used by the typeahead search. */\n protected searchTerm = computed(() => this.label() ?? this.element.textContent);\n\n /** The parent Listbox UIPattern. */\n private readonly _listboxPattern = computed(() => this._listbox._pattern);\n\n /** The value of the option. */\n value = input.required<V>();\n\n /** Whether an item is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** The text used by the typeahead search. */\n label = input<string>();\n\n /** Whether the option is selected. */\n readonly selected = computed(() => this._pattern.selected());\n\n /** The Option UIPattern. */\n readonly _pattern = new OptionPattern<V>({\n ...this,\n id: this.id,\n value: this.value,\n listbox: this._listboxPattern,\n element: () => this.element,\n searchTerm: () => this.searchTerm() ?? '',\n });\n}\n"],"names":["Listbox","id","input","inject","_IdGenerator","getId","_popup","ComboboxPopup","optional","_elementRef","ElementRef","element","nativeElement","_directionality","Directionality","_options","contentChildren","Option","descendants","textDirection","toSignal","change","initialValue","value","items","computed","map","option","_pattern","ngDevMode","debugName","orientation","multi","transform","booleanAttribute","wrap","softDisabled","focusMode","selectionMode","typeaheadDelay","disabled","readonly","values","model","_hasFocused","signal","constructor","inputs","activeItem","undefined","combobox","ComboboxListboxPattern","ListboxPattern","_controls","set","afterRenderEffect","violations","validate","violation","console","error","setDefaultState","untracked","some","i","listBehavior","unfocus","v","filter","_onFocus","scrollActiveItemIntoView","options","block","scrollIntoView","gotoFirst","first","deps","target","i0","ɵɵFactoryTarget","Directive","ɵdir","ɵɵngDeclareDirective","minVersion","version","type","isSignal","exportAs","hostDirectives","directive","i1","ngImport","decorators","args","selector","host","active","_listbox","searchTerm","label","textContent","_listboxPattern","required","selected","OptionPattern","listbox","isStandalone","classPropertyName","publicName","isRequired","transformFunction","attributes","properties"],"mappings":";;;;;;;;MAgEaA,OAAO,CAAA;AAETC,EAAAA,EAAE,GAAGC,KAAK,CAACC,MAAM,CAACC,YAAY,CAAC,CAACC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC;;WAAC;AAGnDC,EAAAA,MAAM,GAAGH,MAAM,CAAmBI,aAAa,EAAE;AAChEC,IAAAA,QAAQ,EAAE;AACX,GAAA,CAAC;AAGeC,EAAAA,WAAW,GAAGN,MAAM,CAACO,UAAU,CAAC;AAGxCC,EAAAA,OAAO,GAAG,IAAI,CAACF,WAAW,CAACG,aAA4B;AAG/CC,EAA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