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

Class ToolbarWidgetGroup

src/aria/toolbar/toolbar-widget-group.ts:35–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 providers: [{provide: TOOLBAR_WIDGET_GROUP, useExisting: ToolbarWidgetGroup}],
34})
35export class ToolbarWidgetGroup<V> {
36 /** A reference to the host element. */
37 private readonly _elementRef = inject(ElementRef);
38
39 /** A reference to the host element. */
40 readonly element = this._elementRef.nativeElement as HTMLElement;
41
42 /** The parent Toolbar. */
43 private readonly _toolbar = inject<Toolbar<V>>(Toolbar, {optional: true});
44
45 /** The list of child widgets within the group. */
46 private readonly _widgets = contentChildren(ToolbarWidget, {descendants: true});
47
48 /** The parent Toolbar UIPattern. */
49 private readonly _toolbarPattern = computed(() => this._toolbar?._pattern);
50
51 /** Whether the widget group is disabled. */
52 readonly disabled = input(false, {transform: booleanAttribute});
53
54 /** The list of toolbar items within the group. */
55 private readonly _itemPatterns = () => this._widgets().map(w => w._pattern);
56
57 /** Whether the group allows multiple widgets to be selected. */
58 readonly multi = input(false, {transform: booleanAttribute});
59
60 /** The ToolbarWidgetGroup UIPattern. */
61 readonly _pattern = new ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V>({
62 ...this,
63 items: this._itemPatterns,
64 toolbar: this._toolbarPattern,
65 });
66
67 constructor() {
68 // Check for any violations after the DOM has been updated.
69 if (typeof ngDevMode === 'undefined' || ngDevMode) {
70 afterRenderEffect({
71 read: () => {
72 const violations: string[] = [];
73 if (!this._toolbar) {
74 violations.push('ngToolbarWidgetGroup must be placed inside an ngToolbar container.');
75 }
76 reportViolations(violations, this.element);
77 },
78 });
79 }
80 }
81}

Callers

nothing calls this directly

Calls 2

computedFunction · 0.85
inputFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…