@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 +202 -0
- package/README.md +440 -2
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/sidebar-layout.component.d.ts +179 -0
- package/dist/sidebar-layout.component.d.ts.map +1 -0
- package/dist/sidebar-layout.component.js +399 -0
- package/dist/sidebar-layout.component.js.map +1 -0
- package/dist/slot-dom.d.ts +46 -0
- package/dist/slot-dom.d.ts.map +1 -0
- package/dist/slot-dom.js +84 -0
- package/dist/slot-dom.js.map +1 -0
- package/dist/types.d.ts +73 -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
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SidebarLayout component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, inject, Renderer2, signal, ViewChild, } from '@angular/core';
|
|
7
|
+
import { Link, useRouterInstance, useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { hasNodes, SlotGuard } from './slot-dom.js';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
const _c0 = ["bottom"];
|
|
12
|
+
const _c1 = ["placeholder"];
|
|
13
|
+
const _c2 = ["userSlot"];
|
|
14
|
+
const _c3 = ["themeSlot"];
|
|
15
|
+
const _c4 = [[["", "slot", "usermenu"]], [["", "slot", "themetoggle"]], "*"];
|
|
16
|
+
const _c5 = ["[slot=userMenu]", "[slot=themeToggle]", "*"];
|
|
17
|
+
const _forTrack0 = ($index, $item) => $item.key;
|
|
18
|
+
function SidebarLayout_For_5_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
19
|
+
i0.ɵɵelementStart(0, "span", 6);
|
|
20
|
+
i0.ɵɵtext(1);
|
|
21
|
+
i0.ɵɵelementEnd();
|
|
22
|
+
} if (rf & 2) {
|
|
23
|
+
const item_r1 = i0.ɵɵnextContext().$implicit;
|
|
24
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
25
|
+
i0.ɵɵclassMap(ctx_r1.iconClasses());
|
|
26
|
+
i0.ɵɵadvance();
|
|
27
|
+
i0.ɵɵtextInterpolate(item_r1.icon);
|
|
28
|
+
} }
|
|
29
|
+
function SidebarLayout_For_5_Template(rf, ctx) { if (rf & 1) {
|
|
30
|
+
i0.ɵɵelementStart(0, "a", 4);
|
|
31
|
+
i0.ɵɵconditionalCreate(1, SidebarLayout_For_5_Conditional_1_Template, 2, 3, "span", 8);
|
|
32
|
+
i0.ɵɵelementStart(2, "span");
|
|
33
|
+
i0.ɵɵtext(3);
|
|
34
|
+
i0.ɵɵelementEnd()();
|
|
35
|
+
} if (rf & 2) {
|
|
36
|
+
const item_r1 = ctx.$implicit;
|
|
37
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
38
|
+
i0.ɵɵclassMap(ctx_r1.itemClasses(item_r1));
|
|
39
|
+
i0.ɵɵproperty("molLink", ctx_r1.itemPath(item_r1));
|
|
40
|
+
i0.ɵɵattribute("data-mol-id", "nav-" + item_r1.key)("aria-current", ctx_r1.isActive(item_r1) ? "page" : null);
|
|
41
|
+
i0.ɵɵadvance();
|
|
42
|
+
i0.ɵɵconditional(item_r1.icon ? 1 : -1);
|
|
43
|
+
i0.ɵɵadvance(2);
|
|
44
|
+
i0.ɵɵtextInterpolate(item_r1.label);
|
|
45
|
+
} }
|
|
46
|
+
/** Pixel widths for the `sm` / `md` / `lg` presets. */
|
|
47
|
+
const SIDEBAR_WIDTH_PX = {
|
|
48
|
+
sm: 208,
|
|
49
|
+
md: 240,
|
|
50
|
+
lg: 256,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the effective sidebar pixel width from the stack-agnostic
|
|
54
|
+
* `sidebarWidth` prop, falling back to the deprecated `sidebarWidthClass`
|
|
55
|
+
* (a `w-<n>` Tailwind utility) for backward compatibility. The legacy class is
|
|
56
|
+
* PARSED to pixels — never re-emitted as a class.
|
|
57
|
+
*
|
|
58
|
+
* @param width - The stack-agnostic width preset or explicit pixel number.
|
|
59
|
+
* @param legacyWidthClass - Deprecated Tailwind width utility (e.g. `'w-64'`).
|
|
60
|
+
* @returns The sidebar width in pixels.
|
|
61
|
+
*/
|
|
62
|
+
const resolveSidebarWidthPx = (width, legacyWidthClass) => {
|
|
63
|
+
if (typeof width === 'number')
|
|
64
|
+
return width;
|
|
65
|
+
if (width === 'sm' || width === 'md' || width === 'lg')
|
|
66
|
+
return SIDEBAR_WIDTH_PX[width];
|
|
67
|
+
if (legacyWidthClass) {
|
|
68
|
+
// Tailwind spacing scale: `w-<n>` === n × 0.25rem === n × 4px at a 16px root.
|
|
69
|
+
const match = /^w-(\d+(?:\.\d+)?)$/.exec(legacyWidthClass.trim());
|
|
70
|
+
if (match)
|
|
71
|
+
return Number(match[1]) * 4;
|
|
72
|
+
}
|
|
73
|
+
return SIDEBAR_WIDTH_PX.md;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* SidebarLayout component.
|
|
77
|
+
*
|
|
78
|
+
* Fixed-width left sidebar with brand link + vertical router links + bottom
|
|
79
|
+
* user-menu / theme-toggle slots, and the `<main>` holding the routed page
|
|
80
|
+
* body. The host IS the outer `<div>` (`div[mol-sidebar-layout]`), matching
|
|
81
|
+
* React's root exactly. The page body is projected as the element's default
|
|
82
|
+
* content (React renders its router's `<Outlet />` in the `<main>`); the bottom
|
|
83
|
+
* slots are projected as `[slot=userMenu]` / `[slot=themeToggle]` content.
|
|
84
|
+
*
|
|
85
|
+
* The sidebar WIDTH is the one value a styling-agnostic ClassMap can't express,
|
|
86
|
+
* so it is applied via inline style from `sidebarWidth`; active-nav
|
|
87
|
+
* highlighting picks the longest prefix-match of the current path, and
|
|
88
|
+
* same-path links get a `#top` fragment appended. `label` is rendered as-is:
|
|
89
|
+
* pass an already-translated string.
|
|
90
|
+
*/
|
|
91
|
+
export class SidebarLayout {
|
|
92
|
+
/** Brand text shown at the top of the sidebar (typically the app name). */
|
|
93
|
+
appName = '';
|
|
94
|
+
/** Path the brand link navigates to (defaults to `'/'` at read time). */
|
|
95
|
+
logoTo;
|
|
96
|
+
/** Vertical nav items rendered in the sidebar. */
|
|
97
|
+
navItems = [];
|
|
98
|
+
/**
|
|
99
|
+
* Aria-label for the primary `<nav>`. Overrides the translated default
|
|
100
|
+
* (`sidebarLayout.aria.primaryNavigation`, English `'Primary navigation'`);
|
|
101
|
+
* prop > `t()` > default.
|
|
102
|
+
*/
|
|
103
|
+
navAriaLabel;
|
|
104
|
+
/** Sidebar width preset or explicit pixel number (defaults to `'md'` at read time). */
|
|
105
|
+
sidebarWidth;
|
|
106
|
+
/** Deprecated Tailwind width utility, parsed to pixels (never emitted as a class). */
|
|
107
|
+
sidebarWidthClass;
|
|
108
|
+
/** Extra classes on the outer wrapper. */
|
|
109
|
+
className;
|
|
110
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
111
|
+
dataMolId;
|
|
112
|
+
/** The projected bottom-slot container (detached when both slots are absent). */
|
|
113
|
+
bottom;
|
|
114
|
+
/** The placeholder `<span>` React renders while the user menu is absent. */
|
|
115
|
+
placeholder;
|
|
116
|
+
/** The `[slot=userMenu]` projection capture point. */
|
|
117
|
+
userSlot;
|
|
118
|
+
/** The `[slot=themeToggle]` projection capture point. */
|
|
119
|
+
themeSlot;
|
|
120
|
+
router = useRouterInstance();
|
|
121
|
+
i18n = useTranslation();
|
|
122
|
+
/** The current location, kept current so active items follow navigation. */
|
|
123
|
+
location = signal(this.router.getLocation(), /* @ts-ignore */
|
|
124
|
+
...(ngDevMode ? [{ debugName: "location" }] : /* istanbul ignore next */ []));
|
|
125
|
+
stop = this.router.subscribe(() => this.location.set(this.router.getLocation()));
|
|
126
|
+
guard = new SlotGuard(inject(Renderer2));
|
|
127
|
+
/** Stops listening to the router when the component goes away. */
|
|
128
|
+
ngOnDestroy() {
|
|
129
|
+
this.stop();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The current class map.
|
|
133
|
+
* @returns The UIClassMap.
|
|
134
|
+
*/
|
|
135
|
+
cm() {
|
|
136
|
+
return getClassMap();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Computes the wrapper class list.
|
|
140
|
+
* @returns The class string.
|
|
141
|
+
*/
|
|
142
|
+
classes() {
|
|
143
|
+
return this.cm().cn(this.cm().pageShell, this.cm().page, this.className);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Computes the sidebar's class list.
|
|
147
|
+
* @returns The class string.
|
|
148
|
+
*/
|
|
149
|
+
asideClasses() {
|
|
150
|
+
const cm = this.cm();
|
|
151
|
+
return cm.cn(cm.sp('p', 4), cm.shrink0, cm.flex({ direction: 'col' }), cm.surface, cm.borderR);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The inline sidebar width, in pixels.
|
|
155
|
+
* @returns The width in pixels.
|
|
156
|
+
*/
|
|
157
|
+
widthPx() {
|
|
158
|
+
return resolveSidebarWidthPx(this.sidebarWidth, this.sidebarWidthClass);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Computes the brand link class list.
|
|
162
|
+
* @returns The class string.
|
|
163
|
+
*/
|
|
164
|
+
brandClasses() {
|
|
165
|
+
const cm = this.cm();
|
|
166
|
+
return cm.cn(cm.textSize('xl'), cm.fontWeight('bold'), cm.sp('mb', 6), cm.displayBlock);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Computes the nav class list.
|
|
170
|
+
* @returns The class string.
|
|
171
|
+
*/
|
|
172
|
+
navClasses() {
|
|
173
|
+
return this.cm().cn(this.cm().flex1, this.cm().stack(1));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The nav region's accessible name: an explicit `navAriaLabel` wins,
|
|
177
|
+
* otherwise the translated default (the inline English keeps the DOM
|
|
178
|
+
* identical until a locale bond supplies the key).
|
|
179
|
+
*
|
|
180
|
+
* @returns The aria-label.
|
|
181
|
+
*/
|
|
182
|
+
navLabel() {
|
|
183
|
+
return (this.navAriaLabel ??
|
|
184
|
+
this.i18n.t('sidebarLayout.aria.primaryNavigation', undefined, {
|
|
185
|
+
defaultValue: 'Primary navigation',
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The brand link destination (React's default parameter).
|
|
190
|
+
* @returns The link target.
|
|
191
|
+
*/
|
|
192
|
+
logoPath() {
|
|
193
|
+
return this.samePathTarget(this.logoTo ?? '/');
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* One nav item's link destination.
|
|
197
|
+
* @param item - The nav item.
|
|
198
|
+
* @returns The link target.
|
|
199
|
+
*/
|
|
200
|
+
itemPath(item) {
|
|
201
|
+
return this.samePathTarget(item.to);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Computes the icon span class list.
|
|
205
|
+
* @returns The class string.
|
|
206
|
+
*/
|
|
207
|
+
iconClasses() {
|
|
208
|
+
return this.cm().cn(this.cm().iconGlyphFont);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Computes the bottom-slot container class list.
|
|
212
|
+
* @returns The class string.
|
|
213
|
+
*/
|
|
214
|
+
bottomClasses() {
|
|
215
|
+
const cm = this.cm();
|
|
216
|
+
return cm.cn(cm.sp('pt', 4), cm.flex({ align: 'center', justify: 'between', gap: 'sm' }), cm.borderT);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Computes the main content area class list.
|
|
220
|
+
* @returns The class string.
|
|
221
|
+
*/
|
|
222
|
+
mainClasses() {
|
|
223
|
+
return this.cm().cn(this.cm().pageShellContent);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The key of the nav item whose `to` is the longest prefix-match of the
|
|
227
|
+
* current pathname.
|
|
228
|
+
*
|
|
229
|
+
* @returns The active item's key, or null when nothing matches.
|
|
230
|
+
*/
|
|
231
|
+
activeKey() {
|
|
232
|
+
const pathname = this.location().pathname;
|
|
233
|
+
return this.navItems.reduce((bestKey, item) => {
|
|
234
|
+
const isMatch = pathname === item.to || pathname.startsWith(`${item.to}/`);
|
|
235
|
+
if (!isMatch)
|
|
236
|
+
return bestKey;
|
|
237
|
+
if (bestKey === null)
|
|
238
|
+
return item.key;
|
|
239
|
+
const best = this.navItems.find((i) => i.key === bestKey);
|
|
240
|
+
return best && item.to.length > best.to.length ? item.key : bestKey;
|
|
241
|
+
}, null);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Whether one nav item is the active one at the current location.
|
|
245
|
+
* @param item - The nav item.
|
|
246
|
+
* @returns True when the item renders in its active state.
|
|
247
|
+
*/
|
|
248
|
+
isActive(item) {
|
|
249
|
+
return item.key === this.activeKey();
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Computes the class list of one nav link: the shared nav-item treatment
|
|
253
|
+
* plus the active or idle variant.
|
|
254
|
+
* @param item - The nav item.
|
|
255
|
+
* @returns The class string.
|
|
256
|
+
*/
|
|
257
|
+
itemClasses(item) {
|
|
258
|
+
const cm = this.cm();
|
|
259
|
+
return cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.sp('px', 3), cm.sp('py', 2), cm.textSize('sm'), cm.fontWeight('medium'), cm.roundedFull, this.isActive(item)
|
|
260
|
+
? cm.cn(cm.bgPrimaryContainer, cm.textOnPrimaryContainer)
|
|
261
|
+
: cm.cn(cm.textMuted, cm.link));
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Appends `#top` when `to` is the current path, so a same-route click still
|
|
265
|
+
* produces an observable URL change. React passes the bare `#top` and
|
|
266
|
+
* react-router resolves it against the location (`/#top` on the home route);
|
|
267
|
+
* this binding's `Link` renders `to` verbatim, so the root case is spelled
|
|
268
|
+
* out here.
|
|
269
|
+
*
|
|
270
|
+
* @param to - The link's destination.
|
|
271
|
+
* @returns The link target.
|
|
272
|
+
*/
|
|
273
|
+
samePathTarget(to) {
|
|
274
|
+
const pathname = this.location().pathname;
|
|
275
|
+
const samePath = pathname === to || pathname + '/' === to;
|
|
276
|
+
if (!samePath)
|
|
277
|
+
return to;
|
|
278
|
+
return `${to.replace(/\/$/, '') || '/'}#top`;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Reconciles the projected bottom slots against React's branch once the view
|
|
282
|
+
* queries resolve.
|
|
283
|
+
*/
|
|
284
|
+
ngAfterViewInit() {
|
|
285
|
+
this.reconcile();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Re-reconciles on later passes, so a change to the projected content swaps
|
|
289
|
+
* the branch the way React does.
|
|
290
|
+
*/
|
|
291
|
+
ngDoCheck() {
|
|
292
|
+
this.reconcile();
|
|
293
|
+
}
|
|
294
|
+
/** Re-reconciles after each view update. */
|
|
295
|
+
ngAfterViewChecked() {
|
|
296
|
+
this.reconcile();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Applies React's condition: the bottom container renders only when a slot
|
|
300
|
+
* exists, and the placeholder `<span>` renders only while the user menu is
|
|
301
|
+
* absent and the theme toggle is present.
|
|
302
|
+
*/
|
|
303
|
+
reconcile() {
|
|
304
|
+
const user = this.userSlot?.nativeElement;
|
|
305
|
+
const theme = this.themeSlot?.nativeElement;
|
|
306
|
+
const hasUser = hasNodes(user);
|
|
307
|
+
const hasTheme = hasNodes(theme);
|
|
308
|
+
this.guard.toggle(this.bottom?.nativeElement, hasUser || hasTheme);
|
|
309
|
+
this.guard.toggle(this.placeholder?.nativeElement, !hasUser && hasTheme);
|
|
310
|
+
}
|
|
311
|
+
static ɵfac = function SidebarLayout_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SidebarLayout)(); };
|
|
312
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SidebarLayout, selectors: [["div", "mol-sidebar-layout", ""]], viewQuery: function SidebarLayout_Query(rf, ctx) { if (rf & 1) {
|
|
313
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5)(_c3, 5);
|
|
314
|
+
} if (rf & 2) {
|
|
315
|
+
let _t;
|
|
316
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.bottom = _t.first);
|
|
317
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.placeholder = _t.first);
|
|
318
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.userSlot = _t.first);
|
|
319
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.themeSlot = _t.first);
|
|
320
|
+
} }, hostVars: 3, hostBindings: function SidebarLayout_HostBindings(rf, ctx) { if (rf & 2) {
|
|
321
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId ?? null);
|
|
322
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
323
|
+
} }, inputs: { appName: "appName", logoTo: "logoTo", navItems: "navItems", navAriaLabel: "navAriaLabel", sidebarWidth: "sidebarWidth", sidebarWidthClass: "sidebarWidthClass", className: "className", dataMolId: "dataMolId" }, ngContentSelectors: _c5, decls: 18, vars: 17, consts: [["bottom", ""], ["placeholder", ""], ["userSlot", ""], ["themeSlot", ""], [3, "molLink"], [3, "molLink", "class"], ["aria-hidden", "true"], ["data-parity-unwrap", "", 2, "display", "contents"], ["aria-hidden", "true", 3, "class"]], template: function SidebarLayout_Template(rf, ctx) { if (rf & 1) {
|
|
324
|
+
i0.ɵɵprojectionDef(_c4);
|
|
325
|
+
i0.ɵɵelementStart(0, "aside")(1, "a", 4);
|
|
326
|
+
i0.ɵɵtext(2);
|
|
327
|
+
i0.ɵɵelementEnd();
|
|
328
|
+
i0.ɵɵelementStart(3, "nav");
|
|
329
|
+
i0.ɵɵrepeaterCreate(4, SidebarLayout_For_5_Template, 4, 7, "a", 5, _forTrack0);
|
|
330
|
+
i0.ɵɵelementEnd();
|
|
331
|
+
i0.ɵɵelementStart(6, "div", null, 0);
|
|
332
|
+
i0.ɵɵelement(8, "span", 6, 1);
|
|
333
|
+
i0.ɵɵelementStart(10, "span", 7, 2);
|
|
334
|
+
i0.ɵɵprojection(12);
|
|
335
|
+
i0.ɵɵelementEnd();
|
|
336
|
+
i0.ɵɵelementStart(13, "span", 7, 3);
|
|
337
|
+
i0.ɵɵprojection(15, 1);
|
|
338
|
+
i0.ɵɵelementEnd()()();
|
|
339
|
+
i0.ɵɵelementStart(16, "main");
|
|
340
|
+
i0.ɵɵprojection(17, 2);
|
|
341
|
+
i0.ɵɵelementEnd();
|
|
342
|
+
} if (rf & 2) {
|
|
343
|
+
i0.ɵɵclassMap(ctx.asideClasses());
|
|
344
|
+
i0.ɵɵstyleProp("width", ctx.widthPx(), "px");
|
|
345
|
+
i0.ɵɵadvance();
|
|
346
|
+
i0.ɵɵclassMap(ctx.brandClasses());
|
|
347
|
+
i0.ɵɵproperty("molLink", ctx.logoPath());
|
|
348
|
+
i0.ɵɵadvance();
|
|
349
|
+
i0.ɵɵtextInterpolate(ctx.appName);
|
|
350
|
+
i0.ɵɵadvance();
|
|
351
|
+
i0.ɵɵclassMap(ctx.navClasses());
|
|
352
|
+
i0.ɵɵattribute("aria-label", ctx.navLabel());
|
|
353
|
+
i0.ɵɵadvance();
|
|
354
|
+
i0.ɵɵrepeater(ctx.navItems);
|
|
355
|
+
i0.ɵɵadvance(2);
|
|
356
|
+
i0.ɵɵclassMap(ctx.bottomClasses());
|
|
357
|
+
i0.ɵɵadvance(10);
|
|
358
|
+
i0.ɵɵclassMap(ctx.mainClasses());
|
|
359
|
+
i0.ɵɵstyleProp("min-width", 0, "px");
|
|
360
|
+
} }, dependencies: [Link], encapsulation: 2 });
|
|
361
|
+
}
|
|
362
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarLayout, [{
|
|
363
|
+
type: Component,
|
|
364
|
+
args: [{
|
|
365
|
+
selector: 'div[mol-sidebar-layout]',
|
|
366
|
+
standalone: true,
|
|
367
|
+
imports: [Link],
|
|
368
|
+
inputs: [
|
|
369
|
+
'appName',
|
|
370
|
+
'logoTo',
|
|
371
|
+
'navItems',
|
|
372
|
+
'navAriaLabel',
|
|
373
|
+
'sidebarWidth',
|
|
374
|
+
'sidebarWidthClass',
|
|
375
|
+
'className',
|
|
376
|
+
'dataMolId',
|
|
377
|
+
],
|
|
378
|
+
host: {
|
|
379
|
+
'[class]': 'classes()',
|
|
380
|
+
'[attr.data-mol-id]': 'dataMolId ?? null',
|
|
381
|
+
},
|
|
382
|
+
// prettier-ignore
|
|
383
|
+
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>`,
|
|
384
|
+
}]
|
|
385
|
+
}], null, { bottom: [{
|
|
386
|
+
type: ViewChild,
|
|
387
|
+
args: ['bottom']
|
|
388
|
+
}], placeholder: [{
|
|
389
|
+
type: ViewChild,
|
|
390
|
+
args: ['placeholder']
|
|
391
|
+
}], userSlot: [{
|
|
392
|
+
type: ViewChild,
|
|
393
|
+
args: ['userSlot']
|
|
394
|
+
}], themeSlot: [{
|
|
395
|
+
type: ViewChild,
|
|
396
|
+
args: ['themeSlot']
|
|
397
|
+
}] }); })();
|
|
398
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SidebarLayout, { className: "SidebarLayout", filePath: "sidebar-layout.component.ts", lineNumber: 92 }); })();
|
|
399
|
+
//# sourceMappingURL=sidebar-layout.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-layout.component.js","sourceRoot":"","sources":["../src/sidebar-layout.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,SAAS,EAGT,MAAM,EAEN,SAAS,EACT,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;;;;;;;;;;IAkEsW,+BAAiD;IAAA,YAAe;IAAA,iBAAO;;;;IAAjE,mCAAuB;IAAoB,cAAe;IAAf,kCAAe;;;IAAvO,4BAAsJ;IAAA,sFAAiB;IAAwE,4BAAM;IAAA,YAAgB;IAAO,AAAP,iBAAO,EAAI;;;;IAAtJ,0CAA2B;IAAlJ,kDAA0B;;IAAyH,cAAyF;IAAzF,uCAAyF;IAAM,eAAgB;IAAhB,mCAAgB;;AA/Dvf,uDAAuD;AACvD,MAAM,gBAAgB,GAAuC;IAC3D,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;CACR,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,qBAAqB,GAAG,CAAC,KAAuB,EAAE,gBAAyB,EAAU,EAAE;IAC3F,IAAI,OAAO,KAAK,KAAK,QAAQ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C,WAAW;;kFA7BX,aAAa"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM helpers for the projected capture points of {@link SidebarLayout}.
|
|
3
|
+
*
|
|
4
|
+
* React renders the bottom slot container only when a slot exists, and renders
|
|
5
|
+
* a bare placeholder `<span>` while the user menu is absent but the theme
|
|
6
|
+
* toggle is present. Angular projection needs an always-mounted `<ng-content>`
|
|
7
|
+
* capture point, so the container lives in the template unconditionally and
|
|
8
|
+
* these helpers reconcile it against React's DOM: the capture points are marked
|
|
9
|
+
* `data-parity-unwrap` (the conformance snapshot expands them, so they look like
|
|
10
|
+
* React's bare slot) and the container / placeholder are detached when React
|
|
11
|
+
* would not render them, re-attached from where they were removed.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { Renderer2 } from '@angular/core';
|
|
16
|
+
/**
|
|
17
|
+
* Whether an ng-content wrapper captured any element or text node.
|
|
18
|
+
*
|
|
19
|
+
* @param el - The wrapper element.
|
|
20
|
+
* @returns True when at least one projected node exists.
|
|
21
|
+
*/
|
|
22
|
+
export declare const hasNodes: (el: Element | undefined | null) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Attaches or detaches one template element against what React renders,
|
|
25
|
+
* remembering the parent it came from so it returns to the same place (the
|
|
26
|
+
* slot container's parent is the `<aside>`, not the component host).
|
|
27
|
+
*/
|
|
28
|
+
export declare class SlotGuard {
|
|
29
|
+
private readonly renderer;
|
|
30
|
+
private readonly parents;
|
|
31
|
+
private readonly anchors;
|
|
32
|
+
/**
|
|
33
|
+
* Creates the guard.
|
|
34
|
+
*
|
|
35
|
+
* @param renderer - The DOM renderer.
|
|
36
|
+
*/
|
|
37
|
+
constructor(renderer: Renderer2);
|
|
38
|
+
/**
|
|
39
|
+
* Attaches or detaches the element (contents move with it).
|
|
40
|
+
*
|
|
41
|
+
* @param el - The element to reconcile.
|
|
42
|
+
* @param shouldAttach - Whether it should be in the DOM.
|
|
43
|
+
*/
|
|
44
|
+
toggle(el: Element | undefined | null, shouldAttach: boolean): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=slot-dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-dom.d.ts","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,OAAO,GAAG,SAAS,GAAG,IAAI,KAAG,OAOzD,CAAA;AAED;;;;GAIG;AACH,qBAAa,SAAS;IASR,OAAO,CAAC,QAAQ,CAAC,QAAQ;IARrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD;;;;OAIG;gBAC0B,QAAQ,EAAE,SAAS;IAEhD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI;CAwBpE"}
|
package/dist/slot-dom.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM helpers for the projected capture points of {@link SidebarLayout}.
|
|
3
|
+
*
|
|
4
|
+
* React renders the bottom slot container only when a slot exists, and renders
|
|
5
|
+
* a bare placeholder `<span>` while the user menu is absent but the theme
|
|
6
|
+
* toggle is present. Angular projection needs an always-mounted `<ng-content>`
|
|
7
|
+
* capture point, so the container lives in the template unconditionally and
|
|
8
|
+
* these helpers reconcile it against React's DOM: the capture points are marked
|
|
9
|
+
* `data-parity-unwrap` (the conformance snapshot expands them, so they look like
|
|
10
|
+
* React's bare slot) and the container / placeholder are detached when React
|
|
11
|
+
* would not render them, re-attached from where they were removed.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Whether an ng-content wrapper captured any element or text node.
|
|
17
|
+
*
|
|
18
|
+
* @param el - The wrapper element.
|
|
19
|
+
* @returns True when at least one projected node exists.
|
|
20
|
+
*/
|
|
21
|
+
export const hasNodes = (el) => {
|
|
22
|
+
if (!el)
|
|
23
|
+
return false;
|
|
24
|
+
for (const node of Array.from(el.childNodes)) {
|
|
25
|
+
if (node.nodeType === 1)
|
|
26
|
+
return true;
|
|
27
|
+
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Attaches or detaches one template element against what React renders,
|
|
34
|
+
* remembering the parent it came from so it returns to the same place (the
|
|
35
|
+
* slot container's parent is the `<aside>`, not the component host).
|
|
36
|
+
*/
|
|
37
|
+
export class SlotGuard {
|
|
38
|
+
renderer;
|
|
39
|
+
parents = new Map();
|
|
40
|
+
anchors = new Map();
|
|
41
|
+
/**
|
|
42
|
+
* Creates the guard.
|
|
43
|
+
*
|
|
44
|
+
* @param renderer - The DOM renderer.
|
|
45
|
+
*/
|
|
46
|
+
constructor(renderer) {
|
|
47
|
+
this.renderer = renderer;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Attaches or detaches the element (contents move with it).
|
|
51
|
+
*
|
|
52
|
+
* @param el - The element to reconcile.
|
|
53
|
+
* @param shouldAttach - Whether it should be in the DOM.
|
|
54
|
+
*/
|
|
55
|
+
toggle(el, shouldAttach) {
|
|
56
|
+
if (!el)
|
|
57
|
+
return;
|
|
58
|
+
if (shouldAttach) {
|
|
59
|
+
const parent = this.parents.get(el);
|
|
60
|
+
if (!parent || el.isConnected)
|
|
61
|
+
return;
|
|
62
|
+
const anchor = this.anchors.get(el);
|
|
63
|
+
if (anchor?.isConnected) {
|
|
64
|
+
parent.insertBefore(el, anchor);
|
|
65
|
+
this.renderer.removeChild(parent, anchor);
|
|
66
|
+
this.anchors.delete(el);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
parent.appendChild(el);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (el.isConnected && el.parentNode) {
|
|
73
|
+
const parent = el.parentNode;
|
|
74
|
+
this.parents.set(el, parent);
|
|
75
|
+
// A placeholder comment keeps the re-insertion position stable; the
|
|
76
|
+
// conformance normalizer strips comment nodes, so it never shows.
|
|
77
|
+
const anchor = this.renderer.createComment('slot');
|
|
78
|
+
parent.insertBefore(anchor, el);
|
|
79
|
+
this.anchors.set(el, anchor);
|
|
80
|
+
this.renderer.removeChild(parent, el);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=slot-dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-dom.js","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAW,EAAE;IAClE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAA;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACpC,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;YAAE,OAAO,IAAI,CAAA;IACzE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,SAAS;IASS;IARZ,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAA;IAClC,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAA;IAEtD;;;;OAIG;IACH,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AAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of `@molecule/app-sidebar-layout-angular` — the Angular counterpart of
|
|
3
|
+
* `@molecule/app-sidebar-layout-react`, same props and DOM.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** Describes a single item in the sidebar's vertical navigation list. */
|
|
8
|
+
export interface SidebarNavItem {
|
|
9
|
+
/** Route path the link goes to. */
|
|
10
|
+
to: string;
|
|
11
|
+
/** Stable key — used for list tracking and i18n key suffix. */
|
|
12
|
+
key: string;
|
|
13
|
+
/** Material symbol icon name. */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Semantic sidebar width. Mapped to a fixed pixel width internally and applied
|
|
20
|
+
* via inline style (a width is one of the "specific values" a styling-agnostic
|
|
21
|
+
* ClassMap cannot express as a swappable token) so the sidebar renders the same
|
|
22
|
+
* regardless of which ClassMap bond is active — no Tailwind width utility leaks
|
|
23
|
+
* into consumer code.
|
|
24
|
+
*
|
|
25
|
+
* - `sm` → 208px, `md` → 240px (default), `lg` → 256px.
|
|
26
|
+
* - Pass a raw `number` for an exact pixel width.
|
|
27
|
+
*/
|
|
28
|
+
export type SidebarWidth = 'sm' | 'md' | 'lg' | number;
|
|
29
|
+
/**
|
|
30
|
+
* Props accepted by {@link SidebarLayout} — the same props
|
|
31
|
+
* `@molecule/app-sidebar-layout-react` accepts. Node props (`userMenu`,
|
|
32
|
+
* `themeToggle`, `children`) are projected content in Angular (an input cannot
|
|
33
|
+
* carry a node), so they are typed `unknown`: pass them in the host template,
|
|
34
|
+
* not as values.
|
|
35
|
+
*/
|
|
36
|
+
export interface SidebarLayoutProps {
|
|
37
|
+
/** Brand text shown at the top of the sidebar (typically the app name). */
|
|
38
|
+
appName: string;
|
|
39
|
+
/** Path the brand link navigates to. Defaults to `'/'`. */
|
|
40
|
+
logoTo?: string;
|
|
41
|
+
/** Vertical nav items rendered in the sidebar. */
|
|
42
|
+
navItems: ReadonlyArray<SidebarNavItem>;
|
|
43
|
+
/** Bottom slot (typically a user menu), projected as `[slot=userMenu]` content. */
|
|
44
|
+
userMenu?: unknown;
|
|
45
|
+
/** Optional slot next to the user menu, projected as `[slot=themeToggle]` content. */
|
|
46
|
+
themeToggle?: unknown;
|
|
47
|
+
/**
|
|
48
|
+
* Aria-label for the primary `<nav>`. Overrides the translated default
|
|
49
|
+
* (`sidebarLayout.aria.primaryNavigation`, English `'Primary navigation'`);
|
|
50
|
+
* prop > `t()` > default.
|
|
51
|
+
*/
|
|
52
|
+
navAriaLabel?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Sidebar width — a stack-agnostic preset (`'sm'` | `'md'` | `'lg'`) or an
|
|
55
|
+
* exact pixel `number`. Applied via inline style. Defaults to `'md'` (240px).
|
|
56
|
+
*/
|
|
57
|
+
sidebarWidth?: SidebarWidth;
|
|
58
|
+
/**
|
|
59
|
+
* Legacy sidebar-width prop retained only for backward compatibility: a
|
|
60
|
+
* `w-<n>` value is PARSED to a pixel width and applied via inline style
|
|
61
|
+
* (never re-emitted as a class). `sidebarWidth` takes precedence.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Use {@link SidebarLayoutProps.sidebarWidth} instead.
|
|
64
|
+
*/
|
|
65
|
+
sidebarWidthClass?: string;
|
|
66
|
+
/** Extra classes on the outer wrapper. */
|
|
67
|
+
className?: string;
|
|
68
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
69
|
+
dataMolId?: string;
|
|
70
|
+
/** The routed page body, projected as the element's default content. */
|
|
71
|
+
children?: unknown;
|
|
72
|
+
}
|
|
73
|
+
//# 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,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAA;IACX,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAA;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACvC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sFAAsF;IACtF,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wEAAwE;IACxE,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"}
|