MCPcopy
hub / github.com/angular/components / ToolbarWidgetPattern

Class ToolbarWidgetPattern

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

Source from the content-addressed store, hash-verified

24}
25
26export class ToolbarWidgetPattern<V> implements ListItem<V> {
27 /** A unique identifier for the widget. */
28 readonly id = () => this.inputs.id();
29
30 /** The html element that should receive focus. */
31 readonly element = () => this.inputs.element();
32
33 /** Whether the widget is disabled. */
34 readonly disabled = () => this.inputs.disabled() || this.group()?.disabled() || false;
35
36 /** A reference to the parent toolbar. */
37 readonly group = () => this.inputs.group();
38
39 /** A reference to the toolbar containing the widget. */
40 readonly toolbar = () => this.inputs.toolbar();
41
42 /** The tabindex of the widget. */
43 readonly tabIndex = computed(() => this.toolbar().listBehavior.getItemTabindex(this));
44
45 /** The text used by the typeahead search. */
46 readonly searchTerm = () => ''; // Unused because toolbar does not support typeahead.
47
48 /** The value associated with the widget. */
49 readonly value = () => this.inputs.value();
50
51 /** Whether the widget is selectable. */
52 readonly selectable = () => true; // Unused because toolbar does not support selection.
53
54 /** The position of the widget within the toolbar. */
55 readonly index = computed(() => this.toolbar().inputs.items().indexOf(this) ?? -1);
56
57 /** Whether the widget is selected (only relevant in a selection group). */
58 readonly selected = computed(() =>
59 this.toolbar().listBehavior.inputs.value().includes(this.value()),
60 );
61
62 /** Whether the widget is currently the active one (focused). */
63 readonly active: SignalLike<boolean> = computed(() => this.toolbar().activeItem() === this);
64
65 constructor(readonly inputs: ToolbarWidgetInputs<V>) {}
66}

Callers

nothing calls this directly

Calls 7

computedFunction · 0.90
activeItemMethod · 0.80
idMethod · 0.45
elementMethod · 0.45
disabledMethod · 0.45
getItemTabindexMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…