Skip to content

Commit 711747b

Browse files
committed
refactor(aria/toolbar): Add accessors for pattern properties
1 parent 0a7e982 commit 711747b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/aria/toolbar/toolbar.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ export class Toolbar<V> {
169169
exportAs: 'ngToolbarWidget',
170170
host: {
171171
'class': 'ng-toolbar-widget',
172-
'[attr.data-active]': '_pattern.active()',
173-
'[attr.tabindex]': '_pattern.tabindex()',
172+
'[attr.data-active]': 'active()',
173+
'[attr.tabindex]': '_pattern.tabIndex()',
174174
'[attr.inert]': 'hardDisabled() ? true : null',
175175
'[attr.disabled]': 'hardDisabled() ? true : null',
176176
'[attr.aria-disabled]': '_pattern.disabled()',
@@ -202,6 +202,21 @@ export class ToolbarWidget<V> implements OnInit, OnDestroy {
202202
/** Whether the widget is 'hard' disabled, which is different from `aria-disabled`. A hard disabled widget cannot receive focus. */
203203
readonly hardDisabled = computed(() => this._pattern.disabled() && !this._toolbar.softDisabled());
204204

205+
/** The optional ToolbarWidgetGroup this widget belongs to. */
206+
readonly _group = inject(ToolbarWidgetGroup, {optional: true});
207+
208+
/** The value associated with the widget. */
209+
readonly value = input.required<V>();
210+
211+
/** Whether the widget is currently the active one (focused). */
212+
readonly active = computed(() => this._pattern.active());
213+
214+
/** Whether the widget is selected (only relevant in a selection group). */
215+
readonly selected = () => this._pattern.selected();
216+
217+
readonly group: SignalLike<ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V> | undefined> =
218+
() => this._group?._pattern;
219+
205220
/** The ToolbarWidget UIPattern. */
206221
readonly _pattern = new ToolbarWidgetPattern<V>({
207222
...this,

0 commit comments

Comments
 (0)