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

Class ToolbarWidgetGroup

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

Source from the content-addressed store, hash-verified

33 providers: [{provide: TOOLBAR_WIDGET_GROUP, useExisting: ToolbarWidgetGroup}],
34})
35export class ToolbarWidgetGroup {
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>(Toolbar, {optional: true});
44
45 /** The list of child widgets within the group. */
46 private readonly _widgets = contentChildren<ToolbarWidget>(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 /** The ToolbarWidgetGroup UIPattern. */
58 readonly _pattern = new ToolbarWidgetGroupPattern({
59 ...this,
60 items: this._itemPatterns,
61 toolbar: this._toolbarPattern,
62 });
63
64 constructor() {
65 // Check for any violations after the DOM has been updated.
66 if (typeof ngDevMode === 'undefined' || ngDevMode) {
67 afterRenderEffect({
68 read: () => {
69 const violations: string[] = [];
70 if (!this._toolbar) {
71 violations.push('ngToolbarWidgetGroup must be placed inside an ngToolbar container.');
72 }
73 reportViolations(violations, this.element);
74 },
75 });
76 }
77 }
78}

Callers

nothing calls this directly

Calls 2

computedFunction · 0.85
inputFunction · 0.85

Tested by

no test coverage detected