MCPcopy Index your code
hub / github.com/angular/components / ToolbarPattern

Class ToolbarPattern

src/aria/private/toolbar/toolbar.ts:24–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23/** Controls the state of a toolbar. */
24export class ToolbarPattern<V> {
25 /** The list behavior for the toolbar. */
26 readonly listBehavior: List<ToolbarWidgetPattern<V>, V>;
27
28 /** Whether the toolbar has been interacted with. */
29 readonly hasBeenInteracted = signal(false);
30
31 /** Whether the tablist is vertically or horizontally oriented. */
32 readonly orientation: SignalLike<'vertical' | 'horizontal'>;
33
34 /** Whether disabled items in the group should be focusable. */
35 readonly softDisabled: SignalLike<boolean>;
36
37 /** Whether the toolbar is disabled. */
38 readonly disabled = computed(() => this.listBehavior.disabled());
39
40 /** The tab index of the toolbar (if using activedescendant). */
41 readonly tabIndex = computed(() => this.listBehavior.tabIndex());
42
43 /** The id of the current active widget (if using activedescendant). */
44 readonly activeDescendant = computed(() => this.listBehavior.activeDescendant());
45
46 /** The currently active item in the toolbar. */
47 readonly activeItem = () => this.listBehavior.inputs.activeItem();
48
49 /** The key used to navigate to the previous widget. */
50 private readonly _prevKey = computed(() => {
51 if (this.inputs.orientation() === 'vertical') {
52 return 'ArrowUp';
53 }
54 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
55 });
56
57 /** The key used to navigate to the next widget. */
58 private readonly _nextKey = computed(() => {
59 if (this.inputs.orientation() === 'vertical') {
60 return 'ArrowDown';
61 }
62 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
63 });
64
65 /** The alternate key used to navigate to the previous widget. */
66 private readonly _altPrevKey = computed(() => {
67 if (this.inputs.orientation() === 'vertical') {
68 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
69 }
70 return 'ArrowUp';
71 });
72
73 /** The alternate key used to navigate to the next widget. */
74 private readonly _altNextKey = computed(() => {
75 if (this.inputs.orientation() === 'vertical') {
76 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
77 }
78 return 'ArrowDown';
79 });
80
81 /** The keydown event manager for the toolbar. */

Callers

nothing calls this directly

Calls 14

_groupNextMethod · 0.95
_groupPrevMethod · 0.95
selectMethod · 0.95
signalFunction · 0.90
computedFunction · 0.90
activeItemMethod · 0.80
disabledMethod · 0.45
tabIndexMethod · 0.45
orientationMethod · 0.45
onMethod · 0.45
nextMethod · 0.45
prevMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…