Skip to content

Commit 610baa4

Browse files
committed
docs(aria/toolbar): expose selected values model (angular#32356)
* docs(aria/toolbar): expose selected values model * fixup! docs(aria/toolbar): expose selected values model * fixup! docs(aria/toolbar): expose selected values model (cherry picked from commit 84f9e0b)
1 parent bac171d commit 610baa4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/aria/private/toolbar/toolbar.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function getToolbarPattern(
7575
element,
7676
items,
7777
activeItem,
78+
values: signal([]),
7879
wrap: signal(inputs.wrap ?? true),
7980
disabled: signal(inputs.disabled ?? false),
8081
softDisabled: signal(inputs.softDisabled ?? true),

src/aria/private/toolbar/toolbar.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {computed, signal} from '@angular/core';
9+
import {computed} from '@angular/core';
1010
import {SignalLike} from '../behaviors/signal-like/signal-like';
1111
import {KeyboardEventManager} from '../behaviors/event-manager';
1212
import {List, ListInputs} from '../behaviors/list/list';
@@ -15,7 +15,7 @@ import {ToolbarWidgetPattern} from './toolbar-widget';
1515
/** Represents the required inputs for a toolbar. */
1616
export type ToolbarInputs<V> = Omit<
1717
ListInputs<ToolbarWidgetPattern<V>, V>,
18-
'multi' | 'typeaheadDelay' | 'values' | 'selectionMode' | 'focusMode'
18+
'multi' | 'typeaheadDelay' | 'selectionMode' | 'focusMode'
1919
> & {
2020
/** A function that returns the toolbar item associated with a given element. */
2121
getItem: (e: Element) => ToolbarWidgetPattern<V> | undefined;
@@ -160,7 +160,6 @@ export class ToolbarPattern<V> {
160160
multi: () => true,
161161
focusMode: () => 'roving',
162162
selectionMode: () => 'explicit',
163-
values: signal([] as V[]),
164163
typeaheadDelay: () => 0, // Toolbar widgets do not support typeahead.
165164
});
166165
}

src/aria/toolbar/toolbar.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
OnInit,
1919
OnDestroy,
2020
contentChildren,
21+
model,
2122
} from '@angular/core';
2223
import {
2324
ToolbarPattern,
@@ -108,6 +109,9 @@ export class Toolbar<V> {
108109
/** Whether focus should wrap when navigating. */
109110
readonly wrap = input(true, {transform: booleanAttribute});
110111

112+
/** The values of the selected widgets within the toolbar. */
113+
readonly values = model<V[]>([]);
114+
111115
/** The toolbar UIPattern. */
112116
readonly _pattern: ToolbarPattern<V> = new ToolbarPattern<V>({
113117
...this,
@@ -116,6 +120,7 @@ export class Toolbar<V> {
116120
textDirection: this.textDirection,
117121
element: () => this._elementRef.nativeElement,
118122
getItem: e => this._getItem(e),
123+
values: this.values,
119124
});
120125

121126
/** Whether the toolbar has received focus yet. */

0 commit comments

Comments
 (0)