Skip to content

Commit 2173ee8

Browse files
committed
refactor(aria/toolbar): underscore pattern props only for internal usage
1 parent 481a204 commit 2173ee8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/aria/toolbar/toolbar.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class Toolbar<V> {
8989
readonly textDirection = inject(Directionality).valueSignal;
9090

9191
/** Sorted UIPatterns of the child widgets */
92-
readonly items = computed(() =>
92+
readonly _itemPatterns = computed(() =>
9393
[...this._widgets()].sort(sortDirectives).map(widget => widget._pattern),
9494
);
9595

@@ -111,6 +111,7 @@ export class Toolbar<V> {
111111
/** The toolbar UIPattern. */
112112
readonly _pattern: ToolbarPattern<V> = new ToolbarPattern<V>({
113113
...this,
114+
items: this._itemPatterns,
114115
activeItem: signal(undefined),
115116
textDirection: this.textDirection,
116117
element: () => this._elementRef.nativeElement,
@@ -159,7 +160,7 @@ export class Toolbar<V> {
159160
/** Finds the toolbar item associated with a given element. */
160161
private _getItem(element: Element) {
161162
const widgetTarget = element.closest('[ngToolbarWidget]');
162-
return this.items().find(widget => widget.element() === widgetTarget);
163+
return this._itemPatterns().find(widget => widget.element() === widgetTarget);
163164
}
164165
}
165166

@@ -204,7 +205,7 @@ export class ToolbarWidget<V> implements OnInit, OnDestroy {
204205
readonly id = input(inject(_IdGenerator).getId('ng-toolbar-widget-', true));
205206

206207
/** The parent Toolbar UIPattern. */
207-
readonly toolbar = computed(() => this._toolbar._pattern);
208+
readonly _toolbarPattern = computed(() => this._toolbar._pattern);
208209

209210
/** Whether the widget is disabled. */
210211
readonly disabled = input(false, {transform: booleanAttribute});
@@ -224,12 +225,15 @@ export class ToolbarWidget<V> implements OnInit, OnDestroy {
224225
/** Whether the widget is selected (only relevant in a selection group). */
225226
readonly selected = () => this._pattern.selected();
226227

227-
readonly group: SignalLike<ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V> | undefined> =
228-
() => this._group?._pattern;
228+
private readonly _groupPattern: SignalLike<
229+
ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V> | undefined
230+
> = () => this._group?._pattern;
229231

230232
/** The ToolbarWidget UIPattern. */
231233
readonly _pattern = new ToolbarWidgetPattern<V>({
232234
...this,
235+
group: this._groupPattern,
236+
toolbar: this._toolbarPattern,
233237
id: this.id,
234238
value: this.value,
235239
element: () => this.element,
@@ -268,17 +272,21 @@ export class ToolbarWidgetGroup<V> {
268272
private readonly _widgets = contentChildren(ToolbarWidget<V>, {descendants: true});
269273

270274
/** The parent Toolbar UIPattern. */
271-
readonly toolbar = computed(() => this._toolbar?._pattern);
275+
private readonly _toolbarPattern = computed(() => this._toolbar?._pattern);
272276

273277
/** Whether the widget group is disabled. */
274278
readonly disabled = input(false, {transform: booleanAttribute});
275279

276280
/** The list of toolbar items within the group. */
277-
readonly items = () => this._widgets().map(w => w._pattern);
281+
private readonly _itemPatterns = () => this._widgets().map(w => w._pattern);
278282

279283
/** Whether the group allows multiple widgets to be selected. */
280284
readonly multi = input(false, {transform: booleanAttribute});
281285

282286
/** The ToolbarWidgetGroup UIPattern. */
283-
readonly _pattern = new ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V>(this);
287+
readonly _pattern = new ToolbarWidgetGroupPattern<ToolbarWidgetPattern<V>, V>({
288+
...this,
289+
items: this._itemPatterns,
290+
toolbar: this._toolbarPattern,
291+
});
284292
}

0 commit comments

Comments
 (0)