@molecule/app-top-nav-layout-angular 0.0.0-stage → 0.0.1-stage
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 +202 -0
- package/README.md +337 -2
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/top-nav-layout.component.d.ts +109 -0
- package/dist/top-nav-layout.component.d.ts.map +1 -0
- package/dist/top-nav-layout.component.js +255 -0
- package/dist/top-nav-layout.component.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +70 -4
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,338 @@
|
|
|
1
|
-
|
|
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-15T09:13:45.799Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-top-nav-layout-angular
|
|
10
|
+
|
|
11
|
+
Angular top navigation app shell layout — the counterpart of
|
|
12
|
+
`@molecule/app-top-nav-layout-react`: the same props and the same DOM for
|
|
13
|
+
the same input.
|
|
14
|
+
|
|
15
|
+
Exports `<TopNavLayout>` — sticky header with brand link + horizontal router
|
|
16
|
+
links + a user-menu slot, plus the `<main>` holding the routed page body
|
|
17
|
+
(React renders its router's `<Outlet />` there) — and the `TopNavItem` /
|
|
18
|
+
`TopNavLayoutProps` types.
|
|
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 { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-angular'
|
|
29
|
+
|
|
30
|
+
const NAV: TopNavItem[] = [
|
|
31
|
+
{ key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
|
|
32
|
+
{ key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'app-shell',
|
|
37
|
+
standalone: true,
|
|
38
|
+
imports: [TopNavLayout],
|
|
39
|
+
template: `
|
|
40
|
+
<div mol-top-nav-layout appName="Acme" [navItems]="nav">
|
|
41
|
+
<button type="button" slot="userMenu">Account</button>
|
|
42
|
+
<router-outlet />
|
|
43
|
+
</div>
|
|
44
|
+
`,
|
|
45
|
+
})
|
|
46
|
+
export class Shell {
|
|
47
|
+
nav = NAV
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Type
|
|
52
|
+
|
|
53
|
+
`feature`
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install @molecule/app-top-nav-layout-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
### Interfaces
|
|
64
|
+
|
|
65
|
+
#### `TopNavItem`
|
|
66
|
+
|
|
67
|
+
A single navigation item rendered in the top nav bar.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
interface TopNavItem {
|
|
71
|
+
/** Route path the link goes to. */
|
|
72
|
+
to: string
|
|
73
|
+
/** Stable key — tracks the rendered link and is the i18n key suffix in apps. */
|
|
74
|
+
key: string
|
|
75
|
+
/** Material symbol icon name (or any glyph) shown next to the label. */
|
|
76
|
+
icon?: string
|
|
77
|
+
/** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
|
|
78
|
+
label: string
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `TopNavLayoutProps`
|
|
83
|
+
|
|
84
|
+
Props accepted by {@link TopNavLayout} — the same props
|
|
85
|
+
`@molecule/app-top-nav-layout-react` accepts. Node props (`userMenu`, the
|
|
86
|
+
routed page body) are projected content in Angular (an input cannot carry a
|
|
87
|
+
node), so they are typed `unknown`: pass them in the host template, not as
|
|
88
|
+
values.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
interface TopNavLayoutProps {
|
|
92
|
+
/** Brand text shown in the top-left link (typically the app name). */
|
|
93
|
+
appName: string
|
|
94
|
+
/** Path the brand link navigates to. Defaults to `'/'`. */
|
|
95
|
+
logoTo?: string
|
|
96
|
+
/** Horizontal nav items rendered in the header. */
|
|
97
|
+
navItems: ReadonlyArray<TopNavItem>
|
|
98
|
+
/** User menu, projected as `[slot=userMenu]` content. */
|
|
99
|
+
userMenu?: unknown
|
|
100
|
+
/** Aria-label for the primary `<nav>`. Defaults to `'Primary navigation'`. */
|
|
101
|
+
navAriaLabel?: string
|
|
102
|
+
/** Extra classes on the outer wrapper. */
|
|
103
|
+
className?: string
|
|
104
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
105
|
+
dataMolId?: string
|
|
106
|
+
/**
|
|
107
|
+
* The routed page body, projected as the element's default content. React
|
|
108
|
+
* renders its router's `<Outlet />` in the `<main>`.
|
|
109
|
+
*/
|
|
110
|
+
children?: unknown
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Classes
|
|
115
|
+
|
|
116
|
+
#### `TopNavLayout`
|
|
117
|
+
|
|
118
|
+
TopNavLayout component.
|
|
119
|
+
|
|
120
|
+
Sticky top-nav shell with brand + horizontal nav + user-menu slot. The host
|
|
121
|
+
IS the outer `<div>` (`div[mol-top-nav-layout]`), matching React's root
|
|
122
|
+
exactly. The page body is projected as the element's default content (React
|
|
123
|
+
renders its router's `<Outlet />` in the `<main>`), and the user menu is
|
|
124
|
+
projected as `[slot=userMenu]` content. Nav labels are hidden below the `md`
|
|
125
|
+
breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
126
|
+
render as Material Symbols ligatures and need the Material Symbols font
|
|
127
|
+
loaded by the host app. Styling comes from the bonded ClassMap. `label` is
|
|
128
|
+
rendered as-is: pass an already-translated string.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
@Component({
|
|
132
|
+
selector: 'div[mol-top-nav-layout]',
|
|
133
|
+
standalone: true,
|
|
134
|
+
imports: [Link],
|
|
135
|
+
inputs: ['appName', 'logoTo', 'navItems', 'navAriaLabel', 'className', 'dataMolId'],
|
|
136
|
+
host: {
|
|
137
|
+
'[class]': 'classes()',
|
|
138
|
+
'[attr.data-mol-id]': 'dataMolId ?? null',
|
|
139
|
+
},
|
|
140
|
+
template: `<header [class]="headerClasses()">
|
|
141
|
+
<div [class]="barClasses()">
|
|
142
|
+
<a [molLink]="logoPath()" [class]="brandClasses()">{{ appName }}</a>
|
|
143
|
+
<nav [class]="navClasses()" [attr.aria-label]="navLabel()">
|
|
144
|
+
@for (item of navItems; track item.key) {
|
|
145
|
+
<a
|
|
146
|
+
[molLink]="item.to"
|
|
147
|
+
[attr.aria-label]="item.label"
|
|
148
|
+
[attr.aria-current]="isActive(item) ? 'page' : null"
|
|
149
|
+
[class]="itemClasses(item)"
|
|
150
|
+
>
|
|
151
|
+
@if (item.icon) {
|
|
152
|
+
<span [class]="iconClasses()" aria-hidden="true">{{ item.icon }}</span>
|
|
153
|
+
}
|
|
154
|
+
<span [class]="labelClasses()">{{ item.label }}</span>
|
|
155
|
+
</a>
|
|
156
|
+
}
|
|
157
|
+
</nav>
|
|
158
|
+
<ng-content select="[slot=userMenu]"></ng-content>
|
|
159
|
+
</div>
|
|
160
|
+
</header>
|
|
161
|
+
<main><ng-content></ng-content></main>`,
|
|
162
|
+
})
|
|
163
|
+
export class TopNavLayout implements OnDestroy {
|
|
164
|
+
/** Brand text shown in the top-left link (typically the app name). */
|
|
165
|
+
appName = ''
|
|
166
|
+
/** Path the brand link navigates to (defaults to `'/'` at read time). */
|
|
167
|
+
logoTo?: string
|
|
168
|
+
/** Horizontal nav items rendered in the header. */
|
|
169
|
+
navItems: ReadonlyArray<TopNavItem> = []
|
|
170
|
+
/** Aria-label for the primary `<nav>` (defaults to `'Primary navigation'` at read time). */
|
|
171
|
+
navAriaLabel?: string
|
|
172
|
+
/** Extra classes on the outer wrapper. */
|
|
173
|
+
className?: string
|
|
174
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
175
|
+
dataMolId?: string
|
|
176
|
+
|
|
177
|
+
private readonly router = useRouterInstance()
|
|
178
|
+
|
|
179
|
+
/** The current location, kept current so active items follow navigation. */
|
|
180
|
+
private readonly location = signal(this.router.getLocation())
|
|
181
|
+
|
|
182
|
+
private readonly stop = this.router.subscribe(() => this.location.set(this.router.getLocation()))
|
|
183
|
+
|
|
184
|
+
/** Stops listening to the router when the component goes away. */
|
|
185
|
+
ngOnDestroy(): void {
|
|
186
|
+
this.stop()
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The current class map.
|
|
191
|
+
* @returns The UIClassMap.
|
|
192
|
+
*/
|
|
193
|
+
cm(): UIClassMap {
|
|
194
|
+
return getClassMap()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Computes the wrapper class list.
|
|
199
|
+
* @returns The class string.
|
|
200
|
+
*/
|
|
201
|
+
classes(): string {
|
|
202
|
+
return this.cm().cn(this.cm().minH('screen'), this.cm().topNavLayoutRoot, this.className)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Computes the header class list.
|
|
207
|
+
* @returns The class string.
|
|
208
|
+
*/
|
|
209
|
+
headerClasses(): string {
|
|
210
|
+
return this.cm().cn(this.cm().topNavLayoutHeader)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Computes the class list of the inner header bar.
|
|
215
|
+
* @returns The class string.
|
|
216
|
+
*/
|
|
217
|
+
barClasses(): string {
|
|
218
|
+
const cm = this.cm()
|
|
219
|
+
return cm.cn(
|
|
220
|
+
cm.maxW('7xl'),
|
|
221
|
+
cm.mxAuto,
|
|
222
|
+
cm.sp('px', 6),
|
|
223
|
+
cm.sp('py', 3),
|
|
224
|
+
cm.flex({ align: 'center', justify: 'between', gap: 'lg' }),
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Computes the brand link class list.
|
|
230
|
+
* @returns The class string.
|
|
231
|
+
*/
|
|
232
|
+
brandClasses(): string {
|
|
233
|
+
return this.cm().cn(this.cm().textSize('2xl'), this.cm().fontWeight('bold'))
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Computes the nav class list.
|
|
238
|
+
* @returns The class string.
|
|
239
|
+
*/
|
|
240
|
+
navClasses(): string {
|
|
241
|
+
return this.cm().flex({ align: 'center', gap: 'md' })
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Computes the icon span class list.
|
|
246
|
+
* @returns The class string.
|
|
247
|
+
*/
|
|
248
|
+
iconClasses(): string {
|
|
249
|
+
return this.cm().iconGlyphFont
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Computes the label span class list.
|
|
254
|
+
* @returns The class string.
|
|
255
|
+
*/
|
|
256
|
+
labelClasses(): string {
|
|
257
|
+
return this.cm().topNavLayoutNavItemLabel
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The brand link destination (React's default parameter: a later-bound write
|
|
262
|
+
* of `undefined` must not erase the `'/'` default).
|
|
263
|
+
* @returns The path.
|
|
264
|
+
*/
|
|
265
|
+
logoPath(): string {
|
|
266
|
+
return this.logoTo ?? '/'
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The nav region's aria-label (React's default parameter).
|
|
271
|
+
* @returns The aria-label.
|
|
272
|
+
*/
|
|
273
|
+
navLabel(): string {
|
|
274
|
+
return this.navAriaLabel ?? 'Primary navigation'
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Whether one nav item's link is active at the current location.
|
|
279
|
+
* @param item - The nav item.
|
|
280
|
+
* @returns True when the link renders in its active state.
|
|
281
|
+
*/
|
|
282
|
+
isActive(item: TopNavItem): boolean {
|
|
283
|
+
return navItemActive(this.location().pathname, item.to)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Computes the class list of one nav link: the shared nav-item treatment
|
|
288
|
+
* plus the active or idle variant.
|
|
289
|
+
* @param item - The nav item.
|
|
290
|
+
* @returns The class string.
|
|
291
|
+
*/
|
|
292
|
+
itemClasses(item: TopNavItem): string {
|
|
293
|
+
const cm = this.cm()
|
|
294
|
+
return cm.cn(
|
|
295
|
+
cm.flex({ align: 'center', gap: 'xs' }),
|
|
296
|
+
cm.sp('px', 3),
|
|
297
|
+
cm.sp('py', 2),
|
|
298
|
+
cm.textSize('sm'),
|
|
299
|
+
cm.fontWeight('medium'),
|
|
300
|
+
cm.topNavLayoutNavItem,
|
|
301
|
+
this.isActive(item)
|
|
302
|
+
? cm.cn(cm.bgPrimaryContainer, cm.textPrimary)
|
|
303
|
+
: cm.cn(cm.textMuted, cm.topNavLayoutNavItemIdle),
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Injection Notes
|
|
310
|
+
|
|
311
|
+
### Requirements
|
|
312
|
+
|
|
313
|
+
Peer dependencies:
|
|
314
|
+
|
|
315
|
+
- `@angular/common` ^22.0.0
|
|
316
|
+
- `@angular/core` ^22.0.0
|
|
317
|
+
- `@angular/platform-browser` ^22.0.0
|
|
318
|
+
- `@molecule/app-angular` ^3.6.0
|
|
319
|
+
- `@molecule/app-ui` ^1.0.1
|
|
320
|
+
- `@molecule/app-ui-angular` ^1.1.0
|
|
321
|
+
|
|
322
|
+
### Runtime Dependencies
|
|
323
|
+
|
|
324
|
+
- `@angular/common`
|
|
325
|
+
- `@angular/core`
|
|
326
|
+
- `@angular/platform-browser`
|
|
327
|
+
- `@molecule/app-angular`
|
|
328
|
+
- `@molecule/app-ui`
|
|
329
|
+
- `@molecule/app-ui-angular`
|
|
330
|
+
|
|
331
|
+
Use it as a LAYOUT component and project the routed page as the element's
|
|
332
|
+
default content (Angular's own `<router-outlet />`); the user menu is
|
|
333
|
+
projected as `[slot=userMenu]`. Nav labels are hidden below the `md`
|
|
334
|
+
breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
335
|
+
render as Material Symbols ligatures and need the Material Symbols font
|
|
336
|
+
loaded by the host app. Styling comes from the bonded ClassMap, so a
|
|
337
|
+
theme/ClassMap bond is a prerequisite. `label` is rendered as-is: pass an
|
|
338
|
+
already-translated string.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular top navigation app shell layout — the counterpart of
|
|
3
|
+
* `@molecule/app-top-nav-layout-react`: the same props and the same DOM for
|
|
4
|
+
* the same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports `<TopNavLayout>` — sticky header with brand link + horizontal router
|
|
7
|
+
* links + a user-menu slot, plus the `<main>` holding the routed page body
|
|
8
|
+
* (React renders its router's `<Outlet />` there) — and the `TopNavItem` /
|
|
9
|
+
* `TopNavLayoutProps` types.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { Component } from '@angular/core'
|
|
14
|
+
* import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-angular'
|
|
15
|
+
*
|
|
16
|
+
* const NAV: TopNavItem[] = [
|
|
17
|
+
* { key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
|
|
18
|
+
* { key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
|
|
19
|
+
* ]
|
|
20
|
+
*
|
|
21
|
+
* @Component({
|
|
22
|
+
* selector: 'app-shell',
|
|
23
|
+
* standalone: true,
|
|
24
|
+
* imports: [TopNavLayout],
|
|
25
|
+
* template: `
|
|
26
|
+
* <div
|
|
27
|
+
* mol-top-nav-layout
|
|
28
|
+
* appName="Acme"
|
|
29
|
+
* [navItems]="nav"
|
|
30
|
+
* >
|
|
31
|
+
* <button type="button" slot="userMenu">Account</button>
|
|
32
|
+
* <router-outlet />
|
|
33
|
+
* </div>
|
|
34
|
+
* `,
|
|
35
|
+
* })
|
|
36
|
+
* export class Shell {
|
|
37
|
+
* nav = NAV
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Use it as a LAYOUT component and project the routed page as the element's
|
|
43
|
+
* default content (Angular's own `<router-outlet />`); the user menu is
|
|
44
|
+
* projected as `[slot=userMenu]`. Nav labels are hidden below the `md`
|
|
45
|
+
* breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
46
|
+
* render as Material Symbols ligatures and need the Material Symbols font
|
|
47
|
+
* loaded by the host app. Styling comes from the bonded ClassMap, so a
|
|
48
|
+
* theme/ClassMap bond is a prerequisite. `label` is rendered as-is: pass an
|
|
49
|
+
* already-translated string.
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
53
|
+
export * from './top-nav-layout.component.js';
|
|
54
|
+
export * from './types.js';
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular top navigation app shell layout — the counterpart of
|
|
3
|
+
* `@molecule/app-top-nav-layout-react`: the same props and the same DOM for
|
|
4
|
+
* the same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports `<TopNavLayout>` — sticky header with brand link + horizontal router
|
|
7
|
+
* links + a user-menu slot, plus the `<main>` holding the routed page body
|
|
8
|
+
* (React renders its router's `<Outlet />` there) — and the `TopNavItem` /
|
|
9
|
+
* `TopNavLayoutProps` types.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { Component } from '@angular/core'
|
|
14
|
+
* import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-angular'
|
|
15
|
+
*
|
|
16
|
+
* const NAV: TopNavItem[] = [
|
|
17
|
+
* { key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
|
|
18
|
+
* { key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
|
|
19
|
+
* ]
|
|
20
|
+
*
|
|
21
|
+
* @Component({
|
|
22
|
+
* selector: 'app-shell',
|
|
23
|
+
* standalone: true,
|
|
24
|
+
* imports: [TopNavLayout],
|
|
25
|
+
* template: `
|
|
26
|
+
* <div
|
|
27
|
+
* mol-top-nav-layout
|
|
28
|
+
* appName="Acme"
|
|
29
|
+
* [navItems]="nav"
|
|
30
|
+
* >
|
|
31
|
+
* <button type="button" slot="userMenu">Account</button>
|
|
32
|
+
* <router-outlet />
|
|
33
|
+
* </div>
|
|
34
|
+
* `,
|
|
35
|
+
* })
|
|
36
|
+
* export class Shell {
|
|
37
|
+
* nav = NAV
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Use it as a LAYOUT component and project the routed page as the element's
|
|
43
|
+
* default content (Angular's own `<router-outlet />`); the user menu is
|
|
44
|
+
* projected as `[slot=userMenu]`. Nav labels are hidden below the `md`
|
|
45
|
+
* breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
46
|
+
* render as Material Symbols ligatures and need the Material Symbols font
|
|
47
|
+
* loaded by the host app. Styling comes from the bonded ClassMap, so a
|
|
48
|
+
* theme/ClassMap bond is a prerequisite. `label` is rendered as-is: pass an
|
|
49
|
+
* already-translated string.
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
53
|
+
export * from './top-nav-layout.component.js';
|
|
54
|
+
export * from './types.js';
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TopNavLayout component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type OnDestroy } from '@angular/core';
|
|
7
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
8
|
+
import type { TopNavItem } from './types.js';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/**
|
|
11
|
+
* TopNavLayout component.
|
|
12
|
+
*
|
|
13
|
+
* Sticky top-nav shell with brand + horizontal nav + user-menu slot. The host
|
|
14
|
+
* IS the outer `<div>` (`div[mol-top-nav-layout]`), matching React's root
|
|
15
|
+
* exactly. The page body is projected as the element's default content (React
|
|
16
|
+
* renders its router's `<Outlet />` in the `<main>`), and the user menu is
|
|
17
|
+
* projected as `[slot=userMenu]` content. Nav labels are hidden below the `md`
|
|
18
|
+
* breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
19
|
+
* render as Material Symbols ligatures and need the Material Symbols font
|
|
20
|
+
* loaded by the host app. Styling comes from the bonded ClassMap. `label` is
|
|
21
|
+
* rendered as-is: pass an already-translated string.
|
|
22
|
+
*/
|
|
23
|
+
export declare class TopNavLayout implements OnDestroy {
|
|
24
|
+
/** Brand text shown in the top-left link (typically the app name). */
|
|
25
|
+
appName: string;
|
|
26
|
+
/** Path the brand link navigates to (defaults to `'/'` at read time). */
|
|
27
|
+
logoTo?: string;
|
|
28
|
+
/** Horizontal nav items rendered in the header. */
|
|
29
|
+
navItems: ReadonlyArray<TopNavItem>;
|
|
30
|
+
/** Aria-label for the primary `<nav>` (defaults to `'Primary navigation'` at read time). */
|
|
31
|
+
navAriaLabel?: string;
|
|
32
|
+
/** Extra classes on the outer wrapper. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
35
|
+
dataMolId?: string;
|
|
36
|
+
private readonly router;
|
|
37
|
+
/** The current location, kept current so active items follow navigation. */
|
|
38
|
+
private readonly location;
|
|
39
|
+
private readonly stop;
|
|
40
|
+
/** Stops listening to the router when the component goes away. */
|
|
41
|
+
ngOnDestroy(): void;
|
|
42
|
+
/**
|
|
43
|
+
* The current class map.
|
|
44
|
+
* @returns The UIClassMap.
|
|
45
|
+
*/
|
|
46
|
+
cm(): UIClassMap;
|
|
47
|
+
/**
|
|
48
|
+
* Computes the wrapper class list.
|
|
49
|
+
* @returns The class string.
|
|
50
|
+
*/
|
|
51
|
+
classes(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Computes the header class list.
|
|
54
|
+
* @returns The class string.
|
|
55
|
+
*/
|
|
56
|
+
headerClasses(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Computes the class list of the inner header bar.
|
|
59
|
+
* @returns The class string.
|
|
60
|
+
*/
|
|
61
|
+
barClasses(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Computes the brand link class list.
|
|
64
|
+
* @returns The class string.
|
|
65
|
+
*/
|
|
66
|
+
brandClasses(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Computes the nav class list.
|
|
69
|
+
* @returns The class string.
|
|
70
|
+
*/
|
|
71
|
+
navClasses(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Computes the icon span class list.
|
|
74
|
+
* @returns The class string.
|
|
75
|
+
*/
|
|
76
|
+
iconClasses(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Computes the label span class list.
|
|
79
|
+
* @returns The class string.
|
|
80
|
+
*/
|
|
81
|
+
labelClasses(): string;
|
|
82
|
+
/**
|
|
83
|
+
* The brand link destination (React's default parameter: a later-bound write
|
|
84
|
+
* of `undefined` must not erase the `'/'` default).
|
|
85
|
+
* @returns The path.
|
|
86
|
+
*/
|
|
87
|
+
logoPath(): string;
|
|
88
|
+
/**
|
|
89
|
+
* The nav region's aria-label (React's default parameter).
|
|
90
|
+
* @returns The aria-label.
|
|
91
|
+
*/
|
|
92
|
+
navLabel(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether one nav item's link is active at the current location.
|
|
95
|
+
* @param item - The nav item.
|
|
96
|
+
* @returns True when the link renders in its active state.
|
|
97
|
+
*/
|
|
98
|
+
isActive(item: TopNavItem): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Computes the class list of one nav link: the shared nav-item treatment
|
|
101
|
+
* plus the active or idle variant.
|
|
102
|
+
* @param item - The nav item.
|
|
103
|
+
* @returns The class string.
|
|
104
|
+
*/
|
|
105
|
+
itemClasses(item: TopNavItem): string;
|
|
106
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TopNavLayout, never>;
|
|
107
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TopNavLayout, "div[mol-top-nav-layout]", never, { "appName": { "alias": "appName"; "required": false; }; "logoTo": { "alias": "logoTo"; "required": false; }; "navItems": { "alias": "navItems"; "required": false; }; "navAriaLabel": { "alias": "navAriaLabel"; "required": false; }; "className": { "alias": "className"; "required": false; }; "dataMolId": { "alias": "dataMolId"; "required": false; }; }, {}, never, ["[slot=userMenu]", "*"], true, never>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=top-nav-layout.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-nav-layout.component.d.ts","sourceRoot":"","sources":["../src/top-nav-layout.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAU,MAAM,eAAe,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;;AAmB5C;;;;;;;;;;;;GAYG;AACH,qBAgCa,YAAa,YAAW,SAAS;IAC5C,sEAAsE;IACtE,OAAO,SAAK;IACZ,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAK;IACxC,4FAA4F;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAE7D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4E;IAEjG,kEAAkE;IAClE,WAAW,IAAI,IAAI;IAInB;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,UAAU,IAAI,MAAM;IAWpB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,WAAW,IAAI,MAAM;IAIrB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAInC;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;yCAjI1B,YAAY;2CAAZ,YAAY;CA+IxB"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TopNavLayout component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, signal } from '@angular/core';
|
|
7
|
+
import { Link, useRouterInstance } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
const _c0 = [[["", "slot", "usermenu"]], "*"];
|
|
11
|
+
const _c1 = ["[slot=userMenu]", "*"];
|
|
12
|
+
const _forTrack0 = ($index, $item) => $item.key;
|
|
13
|
+
function TopNavLayout_For_6_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
14
|
+
i0.ɵɵelementStart(0, "span", 3);
|
|
15
|
+
i0.ɵɵtext(1);
|
|
16
|
+
i0.ɵɵelementEnd();
|
|
17
|
+
} if (rf & 2) {
|
|
18
|
+
const item_r1 = i0.ɵɵnextContext().$implicit;
|
|
19
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
20
|
+
i0.ɵɵclassMap(ctx_r1.iconClasses());
|
|
21
|
+
i0.ɵɵadvance();
|
|
22
|
+
i0.ɵɵtextInterpolate(item_r1.icon);
|
|
23
|
+
} }
|
|
24
|
+
function TopNavLayout_For_6_Template(rf, ctx) { if (rf & 1) {
|
|
25
|
+
i0.ɵɵelementStart(0, "a", 0);
|
|
26
|
+
i0.ɵɵconditionalCreate(1, TopNavLayout_For_6_Conditional_1_Template, 2, 3, "span", 2);
|
|
27
|
+
i0.ɵɵelementStart(2, "span");
|
|
28
|
+
i0.ɵɵtext(3);
|
|
29
|
+
i0.ɵɵelementEnd()();
|
|
30
|
+
} if (rf & 2) {
|
|
31
|
+
const item_r1 = ctx.$implicit;
|
|
32
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
33
|
+
i0.ɵɵclassMap(ctx_r1.itemClasses(item_r1));
|
|
34
|
+
i0.ɵɵproperty("molLink", item_r1.to);
|
|
35
|
+
i0.ɵɵattribute("aria-label", item_r1.label)("aria-current", ctx_r1.isActive(item_r1) ? "page" : null);
|
|
36
|
+
i0.ɵɵadvance();
|
|
37
|
+
i0.ɵɵconditional(item_r1.icon ? 1 : -1);
|
|
38
|
+
i0.ɵɵadvance();
|
|
39
|
+
i0.ɵɵclassMap(ctx_r1.labelClasses());
|
|
40
|
+
i0.ɵɵadvance();
|
|
41
|
+
i0.ɵɵtextInterpolate(item_r1.label);
|
|
42
|
+
} }
|
|
43
|
+
/**
|
|
44
|
+
* Whether react-router's `<NavLink>` would mark `to` active at `pathname`: the
|
|
45
|
+
* pathnames are equal, or the location continues beyond `to` on a segment
|
|
46
|
+
* boundary (`/dashboard` is active at `/dashboard/settings`, but not at
|
|
47
|
+
* `/dashboard-archive`), compared case-insensitively.
|
|
48
|
+
*
|
|
49
|
+
* @param pathname - The current location's pathname.
|
|
50
|
+
* @param to - The link's destination.
|
|
51
|
+
* @returns Whether the link renders in its active state.
|
|
52
|
+
*/
|
|
53
|
+
const navItemActive = (pathname, to) => {
|
|
54
|
+
const location = pathname.toLowerCase();
|
|
55
|
+
const target = to.toLowerCase();
|
|
56
|
+
const endSlash = target !== '/' && target.endsWith('/') ? target.length - 1 : target.length;
|
|
57
|
+
return location === target || (location.startsWith(target) && location.charAt(endSlash) === '/');
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* TopNavLayout component.
|
|
61
|
+
*
|
|
62
|
+
* Sticky top-nav shell with brand + horizontal nav + user-menu slot. The host
|
|
63
|
+
* IS the outer `<div>` (`div[mol-top-nav-layout]`), matching React's root
|
|
64
|
+
* exactly. The page body is projected as the element's default content (React
|
|
65
|
+
* renders its router's `<Outlet />` in the `<main>`), and the user menu is
|
|
66
|
+
* projected as `[slot=userMenu]` content. Nav labels are hidden below the `md`
|
|
67
|
+
* breakpoint (icon-only mobile nav), so always provide `icon` names; they
|
|
68
|
+
* render as Material Symbols ligatures and need the Material Symbols font
|
|
69
|
+
* loaded by the host app. Styling comes from the bonded ClassMap. `label` is
|
|
70
|
+
* rendered as-is: pass an already-translated string.
|
|
71
|
+
*/
|
|
72
|
+
export class TopNavLayout {
|
|
73
|
+
/** Brand text shown in the top-left link (typically the app name). */
|
|
74
|
+
appName = '';
|
|
75
|
+
/** Path the brand link navigates to (defaults to `'/'` at read time). */
|
|
76
|
+
logoTo;
|
|
77
|
+
/** Horizontal nav items rendered in the header. */
|
|
78
|
+
navItems = [];
|
|
79
|
+
/** Aria-label for the primary `<nav>` (defaults to `'Primary navigation'` at read time). */
|
|
80
|
+
navAriaLabel;
|
|
81
|
+
/** Extra classes on the outer wrapper. */
|
|
82
|
+
className;
|
|
83
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
84
|
+
dataMolId;
|
|
85
|
+
router = useRouterInstance();
|
|
86
|
+
/** The current location, kept current so active items follow navigation. */
|
|
87
|
+
location = signal(this.router.getLocation(), /* @ts-ignore */
|
|
88
|
+
...(ngDevMode ? [{ debugName: "location" }] : /* istanbul ignore next */ []));
|
|
89
|
+
stop = this.router.subscribe(() => this.location.set(this.router.getLocation()));
|
|
90
|
+
/** Stops listening to the router when the component goes away. */
|
|
91
|
+
ngOnDestroy() {
|
|
92
|
+
this.stop();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The current class map.
|
|
96
|
+
* @returns The UIClassMap.
|
|
97
|
+
*/
|
|
98
|
+
cm() {
|
|
99
|
+
return getClassMap();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Computes the wrapper class list.
|
|
103
|
+
* @returns The class string.
|
|
104
|
+
*/
|
|
105
|
+
classes() {
|
|
106
|
+
return this.cm().cn(this.cm().minH('screen'), this.cm().topNavLayoutRoot, this.className);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Computes the header class list.
|
|
110
|
+
* @returns The class string.
|
|
111
|
+
*/
|
|
112
|
+
headerClasses() {
|
|
113
|
+
return this.cm().cn(this.cm().topNavLayoutHeader);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Computes the class list of the inner header bar.
|
|
117
|
+
* @returns The class string.
|
|
118
|
+
*/
|
|
119
|
+
barClasses() {
|
|
120
|
+
const cm = this.cm();
|
|
121
|
+
return cm.cn(cm.maxW('7xl'), cm.mxAuto, cm.sp('px', 6), cm.sp('py', 3), cm.flex({ align: 'center', justify: 'between', gap: 'lg' }));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Computes the brand link class list.
|
|
125
|
+
* @returns The class string.
|
|
126
|
+
*/
|
|
127
|
+
brandClasses() {
|
|
128
|
+
return this.cm().cn(this.cm().textSize('2xl'), this.cm().fontWeight('bold'));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Computes the nav class list.
|
|
132
|
+
* @returns The class string.
|
|
133
|
+
*/
|
|
134
|
+
navClasses() {
|
|
135
|
+
return this.cm().flex({ align: 'center', gap: 'md' });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Computes the icon span class list.
|
|
139
|
+
* @returns The class string.
|
|
140
|
+
*/
|
|
141
|
+
iconClasses() {
|
|
142
|
+
return this.cm().iconGlyphFont;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Computes the label span class list.
|
|
146
|
+
* @returns The class string.
|
|
147
|
+
*/
|
|
148
|
+
labelClasses() {
|
|
149
|
+
return this.cm().topNavLayoutNavItemLabel;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The brand link destination (React's default parameter: a later-bound write
|
|
153
|
+
* of `undefined` must not erase the `'/'` default).
|
|
154
|
+
* @returns The path.
|
|
155
|
+
*/
|
|
156
|
+
logoPath() {
|
|
157
|
+
return this.logoTo ?? '/';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The nav region's aria-label (React's default parameter).
|
|
161
|
+
* @returns The aria-label.
|
|
162
|
+
*/
|
|
163
|
+
navLabel() {
|
|
164
|
+
return this.navAriaLabel ?? 'Primary navigation';
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Whether one nav item's link is active at the current location.
|
|
168
|
+
* @param item - The nav item.
|
|
169
|
+
* @returns True when the link renders in its active state.
|
|
170
|
+
*/
|
|
171
|
+
isActive(item) {
|
|
172
|
+
return navItemActive(this.location().pathname, item.to);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Computes the class list of one nav link: the shared nav-item treatment
|
|
176
|
+
* plus the active or idle variant.
|
|
177
|
+
* @param item - The nav item.
|
|
178
|
+
* @returns The class string.
|
|
179
|
+
*/
|
|
180
|
+
itemClasses(item) {
|
|
181
|
+
const cm = this.cm();
|
|
182
|
+
return cm.cn(cm.flex({ align: 'center', gap: 'xs' }), cm.sp('px', 3), cm.sp('py', 2), cm.textSize('sm'), cm.fontWeight('medium'), cm.topNavLayoutNavItem, this.isActive(item)
|
|
183
|
+
? cm.cn(cm.bgPrimaryContainer, cm.textPrimary)
|
|
184
|
+
: cm.cn(cm.textMuted, cm.topNavLayoutNavItemIdle));
|
|
185
|
+
}
|
|
186
|
+
static ɵfac = function TopNavLayout_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TopNavLayout)(); };
|
|
187
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TopNavLayout, selectors: [["div", "mol-top-nav-layout", ""]], hostVars: 3, hostBindings: function TopNavLayout_HostBindings(rf, ctx) { if (rf & 2) {
|
|
188
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId ?? null);
|
|
189
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
190
|
+
} }, inputs: { appName: "appName", logoTo: "logoTo", navItems: "navItems", navAriaLabel: "navAriaLabel", className: "className", dataMolId: "dataMolId" }, ngContentSelectors: _c1, decls: 10, vars: 11, consts: [[3, "molLink"], [3, "molLink", "class"], ["aria-hidden", "true", 3, "class"], ["aria-hidden", "true"]], template: function TopNavLayout_Template(rf, ctx) { if (rf & 1) {
|
|
191
|
+
i0.ɵɵprojectionDef(_c0);
|
|
192
|
+
i0.ɵɵelementStart(0, "header")(1, "div")(2, "a", 0);
|
|
193
|
+
i0.ɵɵtext(3);
|
|
194
|
+
i0.ɵɵelementEnd();
|
|
195
|
+
i0.ɵɵelementStart(4, "nav");
|
|
196
|
+
i0.ɵɵrepeaterCreate(5, TopNavLayout_For_6_Template, 4, 9, "a", 1, _forTrack0);
|
|
197
|
+
i0.ɵɵelementEnd();
|
|
198
|
+
i0.ɵɵprojection(7);
|
|
199
|
+
i0.ɵɵelementEnd()();
|
|
200
|
+
i0.ɵɵelementStart(8, "main");
|
|
201
|
+
i0.ɵɵprojection(9, 1);
|
|
202
|
+
i0.ɵɵelementEnd();
|
|
203
|
+
} if (rf & 2) {
|
|
204
|
+
i0.ɵɵclassMap(ctx.headerClasses());
|
|
205
|
+
i0.ɵɵadvance();
|
|
206
|
+
i0.ɵɵclassMap(ctx.barClasses());
|
|
207
|
+
i0.ɵɵadvance();
|
|
208
|
+
i0.ɵɵclassMap(ctx.brandClasses());
|
|
209
|
+
i0.ɵɵproperty("molLink", ctx.logoPath());
|
|
210
|
+
i0.ɵɵadvance();
|
|
211
|
+
i0.ɵɵtextInterpolate(ctx.appName);
|
|
212
|
+
i0.ɵɵadvance();
|
|
213
|
+
i0.ɵɵclassMap(ctx.navClasses());
|
|
214
|
+
i0.ɵɵattribute("aria-label", ctx.navLabel());
|
|
215
|
+
i0.ɵɵadvance();
|
|
216
|
+
i0.ɵɵrepeater(ctx.navItems);
|
|
217
|
+
} }, dependencies: [Link], encapsulation: 2 });
|
|
218
|
+
}
|
|
219
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TopNavLayout, [{
|
|
220
|
+
type: Component,
|
|
221
|
+
args: [{
|
|
222
|
+
selector: 'div[mol-top-nav-layout]',
|
|
223
|
+
standalone: true,
|
|
224
|
+
imports: [Link],
|
|
225
|
+
inputs: ['appName', 'logoTo', 'navItems', 'navAriaLabel', 'className', 'dataMolId'],
|
|
226
|
+
host: {
|
|
227
|
+
'[class]': 'classes()',
|
|
228
|
+
'[attr.data-mol-id]': 'dataMolId ?? null',
|
|
229
|
+
},
|
|
230
|
+
template: `<header [class]="headerClasses()">
|
|
231
|
+
<div [class]="barClasses()">
|
|
232
|
+
<a [molLink]="logoPath()" [class]="brandClasses()">{{ appName }}</a>
|
|
233
|
+
<nav [class]="navClasses()" [attr.aria-label]="navLabel()">
|
|
234
|
+
@for (item of navItems; track item.key) {
|
|
235
|
+
<a
|
|
236
|
+
[molLink]="item.to"
|
|
237
|
+
[attr.aria-label]="item.label"
|
|
238
|
+
[attr.aria-current]="isActive(item) ? 'page' : null"
|
|
239
|
+
[class]="itemClasses(item)"
|
|
240
|
+
>
|
|
241
|
+
@if (item.icon) {
|
|
242
|
+
<span [class]="iconClasses()" aria-hidden="true">{{ item.icon }}</span>
|
|
243
|
+
}
|
|
244
|
+
<span [class]="labelClasses()">{{ item.label }}</span>
|
|
245
|
+
</a>
|
|
246
|
+
}
|
|
247
|
+
</nav>
|
|
248
|
+
<ng-content select="[slot=userMenu]"></ng-content>
|
|
249
|
+
</div>
|
|
250
|
+
</header>
|
|
251
|
+
<main><ng-content></ng-content></main>`,
|
|
252
|
+
}]
|
|
253
|
+
}], null, null); })();
|
|
254
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TopNavLayout, { className: "TopNavLayout", filePath: "top-nav-layout.component.ts", lineNumber: 77 }); })();
|
|
255
|
+
//# sourceMappingURL=top-nav-layout.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-nav-layout.component.js","sourceRoot":"","sources":["../src/top-nav-layout.component.ts"],"names":[],"mappings":"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"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of `@molecule/app-top-nav-layout-angular` — the Angular counterpart
|
|
3
|
+
* of `@molecule/app-top-nav-layout-react`, same props and DOM.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** A single navigation item rendered in the top nav bar. */
|
|
8
|
+
export interface TopNavItem {
|
|
9
|
+
/** Route path the link goes to. */
|
|
10
|
+
to: string;
|
|
11
|
+
/** Stable key — tracks the rendered link and is the i18n key suffix in apps. */
|
|
12
|
+
key: string;
|
|
13
|
+
/** Material symbol icon name (or any glyph) shown next to the label. */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Props accepted by {@link TopNavLayout} — the same props
|
|
20
|
+
* `@molecule/app-top-nav-layout-react` accepts. Node props (`userMenu`, the
|
|
21
|
+
* routed page body) are projected content in Angular (an input cannot carry a
|
|
22
|
+
* node), so they are typed `unknown`: pass them in the host template, not as
|
|
23
|
+
* values.
|
|
24
|
+
*/
|
|
25
|
+
export interface TopNavLayoutProps {
|
|
26
|
+
/** Brand text shown in the top-left link (typically the app name). */
|
|
27
|
+
appName: string;
|
|
28
|
+
/** Path the brand link navigates to. Defaults to `'/'`. */
|
|
29
|
+
logoTo?: string;
|
|
30
|
+
/** Horizontal nav items rendered in the header. */
|
|
31
|
+
navItems: ReadonlyArray<TopNavItem>;
|
|
32
|
+
/** User menu, projected as `[slot=userMenu]` content. */
|
|
33
|
+
userMenu?: unknown;
|
|
34
|
+
/** Aria-label for the primary `<nav>`. Defaults to `'Primary navigation'`. */
|
|
35
|
+
navAriaLabel?: string;
|
|
36
|
+
/** Extra classes on the outer wrapper. */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
39
|
+
dataMolId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The routed page body, projected as the element's default content. React
|
|
42
|
+
* renders its router's `<Outlet />` in the `<main>`.
|
|
43
|
+
*/
|
|
44
|
+
children?: unknown;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAA;IACX,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACnC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-top-nav-layout-angular",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "Top navigation app shell: brand link + horizontal NavLinks + UserMenu slot, with a router outlet for nested routes",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-top-nav-layout-angular",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "ngc",
|
|
21
|
+
"dev": "ngc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"layout",
|
|
28
|
+
"top-nav",
|
|
29
|
+
"angular"
|
|
30
|
+
],
|
|
31
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
36
|
+
"directory": "packages/app/features/top-nav-layout-angular"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@angular/common": "^22.0.0",
|
|
47
|
+
"@angular/core": "^22.0.0",
|
|
48
|
+
"@angular/platform-browser": "^22.0.0",
|
|
49
|
+
"@molecule/app-angular": "^3.6.0",
|
|
50
|
+
"@molecule/app-ui": "^1.0.1",
|
|
51
|
+
"@molecule/app-ui-angular": "^1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@angular/common": "22.2.3",
|
|
55
|
+
"@angular/compiler": "22.2.3",
|
|
56
|
+
"@angular/compiler-cli": "22.2.3",
|
|
57
|
+
"@angular/core": "22.2.3",
|
|
58
|
+
"@angular/platform-browser": "22.2.3",
|
|
59
|
+
"@molecule/app-angular": "3.6.0",
|
|
60
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
61
|
+
"@molecule/app-i18n": "1.2.1",
|
|
62
|
+
"@molecule/app-icons": "1.0.4",
|
|
63
|
+
"@molecule/app-ui": "1.3.11",
|
|
64
|
+
"@molecule/app-ui-angular": "1.1.2",
|
|
65
|
+
"@types/node": "26.6.5",
|
|
66
|
+
"jsdom": "30.1.3",
|
|
67
|
+
"rxjs": "7.8.2",
|
|
68
|
+
"typescript": "6.0.3",
|
|
69
|
+
"vitest": "4.1.12",
|
|
70
|
+
"zone.js": "0.16.3"
|
|
71
|
+
}
|
|
72
|
+
}
|