@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.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Angular vertical sidebar app shell layout — the counterpart of
3
+ * `@molecule/app-sidebar-layout-react`: the same props and the same DOM for the
4
+ * same input.
5
+ *
6
+ * Exports `<SidebarLayout>` plus the `SidebarLayoutProps` and `SidebarNavItem`
7
+ * types — fixed-width left sidebar with brand link, vertical nav links, and
8
+ * bottom user-menu / theme-toggle slots; the main area on the right scrolls and
9
+ * renders the routed page.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { Component } from '@angular/core'
14
+ * import { SidebarLayout } from '@molecule/app-sidebar-layout-angular'
15
+ *
16
+ * const NAV = [
17
+ * { key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
18
+ * { key: 'projects', to: '/projects', icon: 'folder', label: 'Projects' },
19
+ * { key: 'settings', to: '/settings', icon: 'settings', label: 'Settings' },
20
+ * ]
21
+ *
22
+ * @Component({
23
+ * selector: 'app-shell',
24
+ * standalone: true,
25
+ * imports: [SidebarLayout],
26
+ * template: `
27
+ * <div mol-sidebar-layout [appName]="'Acme App'" [navItems]="NAV">
28
+ * <app-user-menu slot="userMenu" />
29
+ * <router-outlet />
30
+ * </div>
31
+ * `,
32
+ * })
33
+ * export class Shell {
34
+ * readonly NAV = NAV
35
+ * }
36
+ * ```
37
+ *
38
+ * @remarks
39
+ * - Router required: reads the current location and renders router links, so
40
+ * it must be mounted inside the molecule router provider (the app shell
41
+ * does that at startup).
42
+ * - Node props are projected content: the bottom slots are selected by
43
+ * `[slot=userMenu]` / `[slot=themeToggle]`, everything else lands in the main
44
+ * container as the default projection (React's `<Outlet />`).
45
+ * - Fully ClassMap-driven: every layout/surface/border/text/state class is
46
+ * resolved through `getClassMap()` (`cm.pageShell`, `cm.page`, `cm.surface`,
47
+ * `cm.borderR`, …), so swapping the ClassMap bond restyles the whole shell.
48
+ * The sidebar WIDTH is applied via inline style from `sidebarWidth`
49
+ * (`'sm'`|`'md'`|`'lg'`|pixel `number`); the old `sidebarWidthClass` prop is
50
+ * `@deprecated` — parsed to pixels, never re-emitted as a class.
51
+ * - `icon` values are Material Symbols ligature names rendered with the
52
+ * `material-symbols-outlined` font class — the one documented icon-font
53
+ * exception. Without the font loaded, the raw icon name shows as text.
54
+ * - Active-nav highlighting picks the longest prefix-match of the current
55
+ * path; same-path links get a `#top` fragment appended.
56
+ * - `navAriaLabel` overrides the translated nav region name; without it the
57
+ * label comes from `t('sidebarLayout.aria.primaryNavigation')` (English
58
+ * default `'Primary navigation'`), so it follows a locale switch through its
59
+ * companion locale bond (`@molecule/app-locales-sidebar-layout`). Nav item
60
+ * `label`s stay plain caller strings — translate them upstream.
61
+ * - Requires a bonded ClassMap. Sibling: `@molecule/app-shell-layout-angular`
62
+ * is the top header/footer shell (router-free).
63
+ *
64
+ * @module
65
+ */
66
+ export * from './sidebar-layout.component.js';
67
+ export * from './types.js';
68
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Angular vertical sidebar app shell layout — the counterpart of
3
+ * `@molecule/app-sidebar-layout-react`: the same props and the same DOM for the
4
+ * same input.
5
+ *
6
+ * Exports `<SidebarLayout>` plus the `SidebarLayoutProps` and `SidebarNavItem`
7
+ * types — fixed-width left sidebar with brand link, vertical nav links, and
8
+ * bottom user-menu / theme-toggle slots; the main area on the right scrolls and
9
+ * renders the routed page.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { Component } from '@angular/core'
14
+ * import { SidebarLayout } from '@molecule/app-sidebar-layout-angular'
15
+ *
16
+ * const NAV = [
17
+ * { key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
18
+ * { key: 'projects', to: '/projects', icon: 'folder', label: 'Projects' },
19
+ * { key: 'settings', to: '/settings', icon: 'settings', label: 'Settings' },
20
+ * ]
21
+ *
22
+ * @Component({
23
+ * selector: 'app-shell',
24
+ * standalone: true,
25
+ * imports: [SidebarLayout],
26
+ * template: `
27
+ * <div mol-sidebar-layout [appName]="'Acme App'" [navItems]="NAV">
28
+ * <app-user-menu slot="userMenu" />
29
+ * <router-outlet />
30
+ * </div>
31
+ * `,
32
+ * })
33
+ * export class Shell {
34
+ * readonly NAV = NAV
35
+ * }
36
+ * ```
37
+ *
38
+ * @remarks
39
+ * - Router required: reads the current location and renders router links, so
40
+ * it must be mounted inside the molecule router provider (the app shell
41
+ * does that at startup).
42
+ * - Node props are projected content: the bottom slots are selected by
43
+ * `[slot=userMenu]` / `[slot=themeToggle]`, everything else lands in the main
44
+ * container as the default projection (React's `<Outlet />`).
45
+ * - Fully ClassMap-driven: every layout/surface/border/text/state class is
46
+ * resolved through `getClassMap()` (`cm.pageShell`, `cm.page`, `cm.surface`,
47
+ * `cm.borderR`, …), so swapping the ClassMap bond restyles the whole shell.
48
+ * The sidebar WIDTH is applied via inline style from `sidebarWidth`
49
+ * (`'sm'`|`'md'`|`'lg'`|pixel `number`); the old `sidebarWidthClass` prop is
50
+ * `@deprecated` — parsed to pixels, never re-emitted as a class.
51
+ * - `icon` values are Material Symbols ligature names rendered with the
52
+ * `material-symbols-outlined` font class — the one documented icon-font
53
+ * exception. Without the font loaded, the raw icon name shows as text.
54
+ * - Active-nav highlighting picks the longest prefix-match of the current
55
+ * path; same-path links get a `#top` fragment appended.
56
+ * - `navAriaLabel` overrides the translated nav region name; without it the
57
+ * label comes from `t('sidebarLayout.aria.primaryNavigation')` (English
58
+ * default `'Primary navigation'`), so it follows a locale switch through its
59
+ * companion locale bond (`@molecule/app-locales-sidebar-layout`). Nav item
60
+ * `label`s stay plain caller strings — translate them upstream.
61
+ * - Requires a bonded ClassMap. Sibling: `@molecule/app-shell-layout-angular`
62
+ * is the top header/footer shell (router-free).
63
+ *
64
+ * @module
65
+ */
66
+ export * from './sidebar-layout.component.js';
67
+ export * from './types.js';
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * SidebarLayout component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { type AfterViewChecked, type AfterViewInit, type DoCheck, type OnDestroy } from '@angular/core';
7
+ import type { UIClassMap } from '@molecule/app-ui';
8
+ import type { SidebarNavItem } from './types.js';
9
+ import * as i0 from "@angular/core";
10
+ /**
11
+ * SidebarLayout component.
12
+ *
13
+ * Fixed-width left sidebar with brand link + vertical router links + bottom
14
+ * user-menu / theme-toggle slots, and the `<main>` holding the routed page
15
+ * body. The host IS the outer `<div>` (`div[mol-sidebar-layout]`), matching
16
+ * React's root exactly. The page body is projected as the element's default
17
+ * content (React renders its router's `<Outlet />` in the `<main>`); the bottom
18
+ * slots are projected as `[slot=userMenu]` / `[slot=themeToggle]` content.
19
+ *
20
+ * The sidebar WIDTH is the one value a styling-agnostic ClassMap can't express,
21
+ * so it is applied via inline style from `sidebarWidth`; active-nav
22
+ * highlighting picks the longest prefix-match of the current path, and
23
+ * same-path links get a `#top` fragment appended. `label` is rendered as-is:
24
+ * pass an already-translated string.
25
+ */
26
+ export declare class SidebarLayout implements AfterViewInit, AfterViewChecked, DoCheck, OnDestroy {
27
+ /** Brand text shown at the top of the sidebar (typically the app name). */
28
+ appName: string;
29
+ /** Path the brand link navigates to (defaults to `'/'` at read time). */
30
+ logoTo?: string;
31
+ /** Vertical nav items rendered in the sidebar. */
32
+ navItems: ReadonlyArray<SidebarNavItem>;
33
+ /**
34
+ * Aria-label for the primary `<nav>`. Overrides the translated default
35
+ * (`sidebarLayout.aria.primaryNavigation`, English `'Primary navigation'`);
36
+ * prop > `t()` > default.
37
+ */
38
+ navAriaLabel?: string;
39
+ /** Sidebar width preset or explicit pixel number (defaults to `'md'` at read time). */
40
+ sidebarWidth?: string | number;
41
+ /** Deprecated Tailwind width utility, parsed to pixels (never emitted as a class). */
42
+ sidebarWidthClass?: string;
43
+ /** Extra classes on the outer wrapper. */
44
+ className?: string;
45
+ /** `data-mol-id` for AI-agent selectors. */
46
+ dataMolId?: string;
47
+ /** The projected bottom-slot container (detached when both slots are absent). */
48
+ private bottom?;
49
+ /** The placeholder `<span>` React renders while the user menu is absent. */
50
+ private placeholder?;
51
+ /** The `[slot=userMenu]` projection capture point. */
52
+ private userSlot?;
53
+ /** The `[slot=themeToggle]` projection capture point. */
54
+ private themeSlot?;
55
+ private readonly router;
56
+ private readonly i18n;
57
+ /** The current location, kept current so active items follow navigation. */
58
+ private readonly location;
59
+ private readonly stop;
60
+ private readonly guard;
61
+ /** Stops listening to the router when the component goes away. */
62
+ ngOnDestroy(): void;
63
+ /**
64
+ * The current class map.
65
+ * @returns The UIClassMap.
66
+ */
67
+ cm(): UIClassMap;
68
+ /**
69
+ * Computes the wrapper class list.
70
+ * @returns The class string.
71
+ */
72
+ classes(): string;
73
+ /**
74
+ * Computes the sidebar's class list.
75
+ * @returns The class string.
76
+ */
77
+ asideClasses(): string;
78
+ /**
79
+ * The inline sidebar width, in pixels.
80
+ * @returns The width in pixels.
81
+ */
82
+ widthPx(): number;
83
+ /**
84
+ * Computes the brand link class list.
85
+ * @returns The class string.
86
+ */
87
+ brandClasses(): string;
88
+ /**
89
+ * Computes the nav class list.
90
+ * @returns The class string.
91
+ */
92
+ navClasses(): string;
93
+ /**
94
+ * The nav region's accessible name: an explicit `navAriaLabel` wins,
95
+ * otherwise the translated default (the inline English keeps the DOM
96
+ * identical until a locale bond supplies the key).
97
+ *
98
+ * @returns The aria-label.
99
+ */
100
+ navLabel(): string;
101
+ /**
102
+ * The brand link destination (React's default parameter).
103
+ * @returns The link target.
104
+ */
105
+ logoPath(): string;
106
+ /**
107
+ * One nav item's link destination.
108
+ * @param item - The nav item.
109
+ * @returns The link target.
110
+ */
111
+ itemPath(item: SidebarNavItem): string;
112
+ /**
113
+ * Computes the icon span class list.
114
+ * @returns The class string.
115
+ */
116
+ iconClasses(): string;
117
+ /**
118
+ * Computes the bottom-slot container class list.
119
+ * @returns The class string.
120
+ */
121
+ bottomClasses(): string;
122
+ /**
123
+ * Computes the main content area class list.
124
+ * @returns The class string.
125
+ */
126
+ mainClasses(): string;
127
+ /**
128
+ * The key of the nav item whose `to` is the longest prefix-match of the
129
+ * current pathname.
130
+ *
131
+ * @returns The active item's key, or null when nothing matches.
132
+ */
133
+ activeKey(): string | null;
134
+ /**
135
+ * Whether one nav item is the active one at the current location.
136
+ * @param item - The nav item.
137
+ * @returns True when the item renders in its active state.
138
+ */
139
+ isActive(item: SidebarNavItem): boolean;
140
+ /**
141
+ * Computes the class list of one nav link: the shared nav-item treatment
142
+ * plus the active or idle variant.
143
+ * @param item - The nav item.
144
+ * @returns The class string.
145
+ */
146
+ itemClasses(item: SidebarNavItem): string;
147
+ /**
148
+ * Appends `#top` when `to` is the current path, so a same-route click still
149
+ * produces an observable URL change. React passes the bare `#top` and
150
+ * react-router resolves it against the location (`/#top` on the home route);
151
+ * this binding's `Link` renders `to` verbatim, so the root case is spelled
152
+ * out here.
153
+ *
154
+ * @param to - The link's destination.
155
+ * @returns The link target.
156
+ */
157
+ private samePathTarget;
158
+ /**
159
+ * Reconciles the projected bottom slots against React's branch once the view
160
+ * queries resolve.
161
+ */
162
+ ngAfterViewInit(): void;
163
+ /**
164
+ * Re-reconciles on later passes, so a change to the projected content swaps
165
+ * the branch the way React does.
166
+ */
167
+ ngDoCheck(): void;
168
+ /** Re-reconciles after each view update. */
169
+ ngAfterViewChecked(): void;
170
+ /**
171
+ * Applies React's condition: the bottom container renders only when a slot
172
+ * exists, and the placeholder `<span>` renders only while the user menu is
173
+ * absent and the theme toggle is present.
174
+ */
175
+ private reconcile;
176
+ static ɵfac: i0.ɵɵFactoryDeclaration<SidebarLayout, never>;
177
+ static ɵcmp: i0.ɵɵComponentDeclaration<SidebarLayout, "div[mol-sidebar-layout]", never, { "appName": { "alias": "appName"; "required": false; }; "logoTo": { "alias": "logoTo"; "required": false; }; "navItems": { "alias": "navItems"; "required": false; }; "navAriaLabel": { "alias": "navAriaLabel"; "required": false; }; "sidebarWidth": { "alias": "sidebarWidth"; "required": false; }; "sidebarWidthClass": { "alias": "sidebarWidthClass"; "required": false; }; "className": { "alias": "className"; "required": false; }; "dataMolId": { "alias": "dataMolId"; "required": false; }; }, {}, never, ["[slot=userMenu]", "[slot=themeToggle]", "*"], true, never>;
178
+ }
179
+ //# sourceMappingURL=sidebar-layout.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar-layout.component.d.ts","sourceRoot":"","sources":["../src/sidebar-layout.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,KAAK,OAAO,EAGZ,KAAK,SAAS,EAIf,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;;AA8BhD;;;;;;;;;;;;;;;GAeG;AACH,qBAqBa,aAAc,YAAW,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS;IACvF,2EAA2E;IAC3E,OAAO,SAAK;IACZ,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAA;I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