MCPcopy Create free account
hub / github.com/angular/components / ToolbarWidgetPattern

Class ToolbarWidgetPattern

src/aria/private/toolbar/toolbar-widget.ts:33–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33export class ToolbarWidgetPattern implements ListFocusItem, ListNavigationItem {
34 /** A unique identifier for the widget. */
35 readonly id = () => this.inputs.id();
36
37 /** The html element that should receive focus. */
38 readonly element = () => this.inputs.element();
39
40 /** Whether the widget is disabled. */
41 readonly disabled = () => this.inputs.disabled() || this.group()?.disabled() || false;
42
43 /** A reference to the parent toolbar. */
44 readonly group = () => this.inputs.group();
45
46 /** A reference to the toolbar containing the widget. */
47 readonly toolbar = () => this.inputs.toolbar();
48
49 /** The tabindex of the widget. */
50 readonly tabIndex = computed(() => this.toolbar().focusManager.getItemTabIndex(this));
51
52 /** The position of the widget within the toolbar. */
53 readonly index = computed(() => this.toolbar().inputs.items().indexOf(this) ?? -1);
54
55 /** Whether the widget is currently the active one (focused). */
56 readonly active: SignalLike<boolean> = computed(() => this.toolbar().activeItem() === this);
57
58 constructor(readonly inputs: ToolbarWidgetInputs) {}
59}

Callers

nothing calls this directly

Calls 6

computedFunction · 0.90
getItemTabIndexMethod · 0.80
activeItemMethod · 0.80
idMethod · 0.45
elementMethod · 0.45
disabledMethod · 0.45

Tested by

no test coverage detected