@molecule/app-sidebar-layout-angular 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,441 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-11-21T12:47:19.070Z
7
+ -->
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ # @molecule/app-sidebar-layout-angular
10
+
11
+ Angular vertical sidebar app shell layout — the counterpart of
12
+ `@molecule/app-sidebar-layout-react`: the same props and the same DOM for the
13
+ same input.
14
+
15
+ Exports `<SidebarLayout>` plus the `SidebarLayoutProps` and `SidebarNavItem`
16
+ types — fixed-width left sidebar with brand link, vertical nav links, and
17
+ bottom user-menu / theme-toggle slots; the main area on the right scrolls and
18
+ renders the routed page.
19
+
20
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
21
+ > It is written to be read by coding agents as much as by people, and is generated from this
22
+ > package's source — edit `src/index.ts` JSDoc, not this file.
23
+
24
+ ## Quick Start
25
+
26
+ ```ts
27
+ import { Component } from '@angular/core'
28
+ import { SidebarLayout } from '@molecule/app-sidebar-layout-angular'
29
+
30
+ const NAV = [
31
+ { key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
32
+ { key: 'projects', to: '/projects', icon: 'folder', label: 'Projects' },
33
+ { key: 'settings', to: '/settings', icon: 'settings', label: 'Settings' },
34
+ ]
35
+
36
+ @Component({
37
+ selector: 'app-shell',
38
+ standalone: true,
39
+ imports: [SidebarLayout],
40
+ template: `
41
+ <div mol-sidebar-layout [appName]="'Acme App'" [navItems]="NAV">
42
+ <app-user-menu slot="userMenu" />
43
+ <router-outlet />
44
+ </div>
45
+ `,
46
+ })
47
+ export class Shell {
48
+ readonly NAV = NAV
49
+ }
50
+ ```
51
+
52
+ ## Type
53
+
54
+ `feature`
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ npm install @molecule/app-sidebar-layout-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
60
+ ```
61
+
62
+ ## API
63
+
64
+ ### Interfaces
65
+
66
+ #### `SidebarNavItem`
67
+
68
+ Describes a single item in the sidebar's vertical navigation list.
69
+
70
+ ```typescript
71
+ interface SidebarNavItem {
72
+ /** Route path the link goes to. */
73
+ to: string
74
+ /** Stable key — used for list tracking and i18n key suffix. */
75
+ key: string
76
+ /** Material symbol icon name. */
77
+ icon?: string
78
+ /** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
79
+ label: string
80
+ }
81
+ ```
82
+
83
+ #### `SidebarLayoutProps`
84
+
85
+ Props accepted by {@link SidebarLayout} — the same props
86
+ `@molecule/app-sidebar-layout-react` accepts. Node props (`userMenu`,
87
+ `themeToggle`, `children`) are projected content in Angular (an input cannot
88
+ carry a node), so they are typed `unknown`: pass them in the host template,
89
+ not as values.
90
+
91
+ ```typescript
92
+ interface SidebarLayoutProps {
93
+ /** Brand text shown at the top of the sidebar (typically the app name). */
94
+ appName: string
95
+ /** Path the brand link navigates to. Defaults to `'/'`. */
96
+ logoTo?: string
97
+ /** Vertical nav items rendered in the sidebar. */
98
+ navItems: ReadonlyArray<SidebarNavItem>
99
+ /** Bottom slot (typically a user menu), projected as `[slot=userMenu]` content. */
100
+ userMenu?: unknown
101
+ /** Optional slot next to the user menu, projected as `[slot=themeToggle]` content. */
102
+ themeToggle?: unknown
103
+ /**
104
+ * Aria-label for the primary `<nav>`. Overrides the translated default
105
+ * (`sidebarLayout.aria.primaryNavigation`, English `'Primary navigation'`);
106
+ * prop > `t()` > default.
107
+ */
108
+ navAriaLabel?: string
109
+ /**
110
+ * Sidebar width — a stack-agnostic preset (`'sm'` | `'md'` | `'lg'`) or an
111
+ * exact pixel `number`. Applied via inline style. Defaults to `'md'` (240px).
112
+ */
113
+ sidebarWidth?: SidebarWidth
114
+ /**
115
+ * Legacy sidebar-width prop retained only for backward compatibility: a
116
+ * `w-<n>` value is PARSED to a pixel width and applied via inline style
117
+ * (never re-emitted as a class). `sidebarWidth` takes precedence.
118
+ *
119
+ * @deprecated Use {@link SidebarLayoutProps.sidebarWidth} instead.
120
+ */
121
+ sidebarWidthClass?: string
122
+ /** Extra classes on the outer wrapper. */
123
+ className?: string
124
+ /** `data-mol-id` for AI-agent selectors. */
125
+ dataMolId?: string
126
+ /** The routed page body, projected as the element's default content. */
127
+ children?: unknown
128
+ }
129
+ ```
130
+
131
+ ### Types
132
+
133
+ #### `SidebarWidth`
134
+
135
+ Semantic sidebar width. Mapped to a fixed pixel width internally and applied
136
+ via inline style (a width is one of the "specific values" a styling-agnostic
137
+ ClassMap cannot express as a swappable token) so the sidebar renders the same
138
+ regardless of which ClassMap bond is active — no Tailwind width utility leaks
139
+ into consumer code.
140
+
141
+ - `sm` → 208px, `md` → 240px (default), `lg` → 256px.
142
+ - Pass a raw `number` for an exact pixel width.
143
+
144
+ ```typescript
145
+ type SidebarWidth = 'sm' | 'md' | 'lg' | number
146
+ ```
147
+
148
+ ### Classes
149
+
150
+ #### `SidebarLayout`
151
+
152
+ SidebarLayout component.
153
+
154
+ Fixed-width left sidebar with brand link + vertical router links + bottom
155
+ user-menu / theme-toggle slots, and the `<main>` holding the routed page
156
+ body. The host IS the outer `<div>` (`div[mol-sidebar-layout]`), matching
157
+ React's root exactly. The page body is projected as the element's default
158
+ content (React renders its router's `<Outlet />` in the `<main>`); the bottom
159
+ slots are projected as `[slot=userMenu]` / `[slot=themeToggle]` content.
160
+
161
+ The sidebar WIDTH is the one value a styling-agnostic ClassMap can't express,
162
+ so it is applied via inline style from `sidebarWidth`; active-nav
163
+ highlighting picks the longest prefix-match of the current path, and
164
+ same-path links get a `#top` fragment appended. `label` is rendered as-is:
165
+ pass an already-translated string.
166
+
167
+ ```typescript
168
+ @Component({
169
+ selector: 'div[mol-sidebar-layout]',
170
+ standalone: true,
171
+ imports: [Link],
172
+ inputs: [
173
+ 'appName',
174
+ 'logoTo',
175
+ 'navItems',
176
+ 'navAriaLabel',
177
+ 'sidebarWidth',
178
+ 'sidebarWidthClass',
179
+ 'className',
180
+ 'dataMolId',
181
+ ],
182
+ host: {
183
+ '[class]': 'classes()',
184
+ '[attr.data-mol-id]': 'dataMolId ?? null',
185
+ },
186
+ // prettier-ignore
187
+ template: `<aside [class]="asideClasses()" [style.width.px]="widthPx()"><a [molLink]="logoPath()" [class]="brandClasses()">{{ appName }}</a><nav [class]="navClasses()" [attr.aria-label]="navLabel()">@for (item of navItems; track item.key) {<a [molLink]="itemPath(item)" [attr.data-mol-id]="'nav-' + item.key" [attr.aria-current]="isActive(item) ? 'page' : null" [class]="itemClasses(item)">@if (item.icon) {<span [class]="iconClasses()" aria-hidden="true">{{ item.icon }}</span>}<span>{{ item.label }}</span></a>}</nav><div #bottom [class]="bottomClasses()"><span #placeholder aria-hidden="true"></span><span #userSlot data-parity-unwrap style="display: contents"><ng-content select="[slot=userMenu]"></ng-content></span><span #themeSlot data-parity-unwrap style="display: contents"><ng-content select="[slot=themeToggle]"></ng-content></span></div></aside><main [class]="mainClasses()" [style.min-width.px]="0"><ng-content></ng-content></main>`,
188
+ })
189
+ export class SidebarLayout implements AfterViewInit, AfterViewChecked, DoCheck, OnDestroy {
190
+ /** Brand text shown at the top of the sidebar (typically the app name). */
191
+ appName = ''
192
+ /** Path the brand link navigates to (defaults to `'/'` at read time). */
193
+ logoTo?: string
194
+ /** Vertical nav items rendered in the sidebar. */
195
+ navItems: ReadonlyArray<SidebarNavItem> = []
196
+ /** Aria-label for the primary `<nav>`. */
197
+ navAriaLabel?: string
198
+ /** Sidebar width preset or explicit pixel number (defaults to `'md'` at read time). */
199
+ sidebarWidth?: string | number
200
+ /** Deprecated Tailwind width utility, parsed to pixels (never emitted as a class). */
201
+ sidebarWidthClass?: string
202
+ /** Extra classes on the outer wrapper. */
203
+ className?: string
204
+ /** `data-mol-id` for AI-agent selectors. */
205
+ dataMolId?: string
206
+
207
+ /** The projected bottom-slot container (detached when both slots are absent). */
208
+ @ViewChild('bottom') private bottom?: ElementRef<HTMLElement>
209
+ /** The placeholder `<span>` React renders while the user menu is absent. */
210
+ @ViewChild('placeholder') private placeholder?: ElementRef<HTMLElement>
211
+ /** The `[slot=userMenu]` projection capture point. */
212
+ @ViewChild('userSlot') private userSlot?: ElementRef<HTMLElement>
213
+ /** The `[slot=themeToggle]` projection capture point. */
214
+ @ViewChild('themeSlot') private themeSlot?: ElementRef<HTMLElement>
215
+
216
+ private readonly router = useRouterInstance()
217
+
218
+ private readonly i18n = useTranslation()
219
+
220
+ /** The current location, kept current so active items follow navigation. */
221
+ private readonly location = signal(this.router.getLocation())
222
+
223
+ private readonly stop = this.router.subscribe(() => this.location.set(this.router.getLocation()))
224
+
225
+ private readonly guard = new SlotGuard(inject(Renderer2))
226
+
227
+ /** Stops listening to the router when the component goes away. */
228
+ ngOnDestroy(): void {
229
+ this.stop()
230
+ }
231
+
232
+ /**
233
+ * The current class map.
234
+ * @returns The UIClassMap.
235
+ */
236
+ cm(): UIClassMap {
237
+ return getClassMap()
238
+ }
239
+
240
+ /** Computes the wrapper class list. */
241
+ classes(): string {
242
+ return this.cm().cn(this.cm().pageShell, this.cm().page, this.className)
243
+ }
244
+
245
+ /** Computes the sidebar's class list. */
246
+ asideClasses(): string {
247
+ const cm = this.cm()
248
+ return cm.cn(cm.sp('p', 4), cm.shrink0, cm.flex({ direction: 'col' }), cm.surface, cm.borderR)
249
+ }
250
+
251
+ /** The inline sidebar width, in pixels. */
252
+ widthPx(): number {
253
+ return resolveSidebarWidthPx(this.sidebarWidth, this.sidebarWidthClass)
254
+ }
255
+
256
+ /** Computes the brand link class list. */
257
+ brandClasses(): string {
258
+ const cm = this.cm()
259
+ return cm.cn(cm.textSize('xl'), cm.fontWeight('bold'), cm.sp('mb', 6), cm.displayBlock)
260
+ }
261
+
262
+ /** Computes the nav class list. */
263
+ navClasses(): string {
264
+ return this.cm().cn(this.cm().flex1, this.cm().stack(1))
265
+ }
266
+
267
+ /** The nav region's accessible name: an explicit `navAriaLabel` wins, otherwise the translated default (the inline English keeps the DOM identical until a locale… */
268
+ navLabel(): string {
269
+ return (
270
+ this.navAriaLabel ??
271
+ this.i18n.t('sidebarLayout.aria.primaryNavigation', undefined, {
272
+ defaultValue: 'Primary navigation',
273
+ })
274
+ )
275
+ }
276
+
277
+ /**
278
+ * The brand link destination (React's default parameter).
279
+ * @returns The link target.
280
+ */
281
+ logoPath(): string {
282
+ return this.samePathTarget(this.logoTo ?? '/')
283
+ }
284
+
285
+ /** One nav item's link destination. */
286
+ itemPath(item: SidebarNavItem): string {
287
+ return this.samePathTarget(item.to)
288
+ }
289
+
290
+ /** Computes the icon span class list. */
291
+ iconClasses(): string {
292
+ return this.cm().cn(this.cm().iconGlyphFont)
293
+ }
294
+
295
+ /**
296
+ * Computes the bottom-slot container class list.
297
+ * @returns The class string.
298
+ */
299
+ bottomClasses(): string {
300
+ const cm = this.cm()
301
+ return cm.cn(
302
+ cm.sp('pt', 4),
303
+ cm.flex({ align: 'center', justify: 'between', gap: 'sm' }),
304
+ cm.borderT,
305
+ )
306
+ }
307
+
308
+ /**
309
+ * Computes the main content area class list.
310
+ * @returns The class string.
311
+ */
312
+ mainClasses(): string {
313
+ return this.cm().cn(this.cm().pageShellContent)
314
+ }
315
+
316
+ /** The key of the nav item whose `to` is the longest prefix-match of the current pathname. */
317
+ activeKey(): string | null {
318
+ const pathname = this.location().pathname
319
+ return this.navItems.reduce<string | null>((bestKey, item) => {
320
+ const isMatch = pathname === item.to || pathname.startsWith(`${item.to}/`)
321
+ if (!isMatch) return bestKey
322
+ if (bestKey === null) return item.key
323
+ const best = this.navItems.find((i) => i.key === bestKey)
324
+ return best && item.to.length > best.to.length ? item.key : bestKey
325
+ }, null)
326
+ }
327
+
328
+ /** Whether one nav item is the active one at the current location. */
329
+ isActive(item: SidebarNavItem): boolean {
330
+ return item.key === this.activeKey()
331
+ }
332
+
333
+ /** Computes the class list of one nav link: the shared nav-item treatment plus the active or idle variant. */
334
+ itemClasses(item: SidebarNavItem): string {
335
+ const cm = this.cm()
336
+ return cm.cn(
337
+ cm.flex({ align: 'center', gap: 'sm' }),
338
+ cm.sp('px', 3),
339
+ cm.sp('py', 2),
340
+ cm.textSize('sm'),
341
+ cm.fontWeight('medium'),
342
+ cm.roundedFull,
343
+ this.isActive(item)
344
+ ? cm.cn(cm.bgPrimaryContainer, cm.textOnPrimaryContainer)
345
+ : cm.cn(cm.textMuted, cm.link),
346
+ )
347
+ }
348
+
349
+ /** Appends `#top` when `to` is the current path, so a same-route click still produces an observable URL change. */
350
+ private samePathTarget(to: string): string {
351
+ const pathname = this.location().pathname
352
+ const samePath = pathname === to || pathname + '/' === to
353
+ if (!samePath) return to
354
+ return `${to.replace(/\/$/, '') || '/'}#top`
355
+ }
356
+
357
+ /**
358
+ * Reconciles the projected bottom slots against React's branch once the view
359
+ * queries resolve.
360
+ */
361
+ ngAfterViewInit(): void {
362
+ this.reconcile()
363
+ }
364
+
365
+ /**
366
+ * Re-reconciles on later passes, so a change to the projected content swaps
367
+ * the branch the way React does.
368
+ */
369
+ ngDoCheck(): void {
370
+ this.reconcile()
371
+ }
372
+
373
+ /** Re-reconciles after each view update. */
374
+ ngAfterViewChecked(): void {
375
+ this.reconcile()
376
+ }
377
+
378
+ /** Applies React's condition: the bottom container renders only when a slot exists, and the placeholder `<span>` renders only while the user menu is absent and th… */
379
+ private reconcile(): void {
380
+ const user = this.userSlot?.nativeElement
381
+ const theme = this.themeSlot?.nativeElement
382
+ const hasUser = hasNodes(user)
383
+ const hasTheme = hasNodes(theme)
384
+ this.guard.toggle(this.bottom?.nativeElement, hasUser || hasTheme)
385
+ this.guard.toggle(this.placeholder?.nativeElement, !hasUser && hasTheme)
386
+ }
387
+ }
388
+ ```
389
+
390
+ _(The 14 longest member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-sidebar-layout-angular/dist/sidebar-layout.component.d.ts`.)_
391
+
392
+ ## Injection Notes
393
+
394
+ ### Requirements
395
+
396
+ Peer dependencies:
397
+
398
+ - `@angular/common` ^22.0.0
399
+ - `@angular/core` ^22.0.0
400
+ - `@angular/platform-browser` ^22.0.0
401
+ - `@molecule/app-angular` ^3.6.0
402
+ - `@molecule/app-ui` ^1.3.11
403
+ - `@molecule/app-ui-angular` ^1.1.0
404
+
405
+ ### Runtime Dependencies
406
+
407
+ - `@angular/common`
408
+ - `@angular/core`
409
+ - `@angular/platform-browser`
410
+ - `@molecule/app-angular`
411
+ - `@molecule/app-ui`
412
+ - `@molecule/app-ui-angular`
413
+
414
+ - Router required: reads the current location and renders router links, so
415
+ it must be mounted inside the molecule router provider (the app shell
416
+ does that at startup).
417
+ - Node props are projected content: the bottom slots are selected by
418
+ `[slot=userMenu]` / `[slot=themeToggle]`, everything else lands in the main
419
+ container as the default projection (React's `<Outlet />`).
420
+ - Fully ClassMap-driven: every layout/surface/border/text/state class is
421
+ resolved through `getClassMap()` (`cm.pageShell`, `cm.page`, `cm.surface`,
422
+ `cm.borderR`, …), so swapping the ClassMap bond restyles the whole shell.
423
+ The sidebar WIDTH is applied via inline style from `sidebarWidth`
424
+ (`'sm'`|`'md'`|`'lg'`|pixel `number`); the old `sidebarWidthClass` prop is
425
+ `@deprecated` — parsed to pixels, never re-emitted as a class.
426
+ - `icon` values are Material Symbols ligature names rendered with the
427
+ `material-symbols-outlined` font class — the one documented icon-font
428
+ exception. Without the font loaded, the raw icon name shows as text.
429
+ - Active-nav highlighting picks the longest prefix-match of the current
430
+ path; same-path links get a `#top` fragment appended.
431
+ - `navAriaLabel` overrides the translated nav region name; without it the
432
+ label comes from `t('sidebarLayout.aria.primaryNavigation')` (English
433
+ default `'Primary navigation'`), so it follows a locale switch through its
434
+ companion locale bond (`@molecule/app-locales-sidebar-layout`). Nav item
435
+ `label`s stay plain caller strings — translate them upstream.
436
+ - Requires a bonded ClassMap. Sibling: `@molecule/app-shell-layout-angular`
437
+ is the top header/footer shell (router-free).
438
+
439
+ ## Translations
440
+
441
+ Translation strings are provided by `@molecule/app-locales-sidebar-layout`.