ng-hub-ui-nav 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Carlos Morcillo Fernández
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # ng-hub-ui-nav
2
+
3
+ [![npm version](https://img.shields.io/npm/v/ng-hub-ui-nav.svg)](https://www.npmjs.com/package/ng-hub-ui-nav)
4
+ [![license](https://img.shields.io/npm/l/ng-hub-ui-nav.svg)](https://github.com/carlos-morcillo/ng-hub-ui-nav/blob/main/LICENSE)
5
+
6
+ A flexible, accessible, and highly customizable navigation component for Angular 21+. It supports horizontal menus, vertical sidebars, mobile collapse modes, stacked drill-down panels, projected start/end slots, and scroll-spy integration.
7
+
8
+ > [!IMPORTANT]
9
+ > Version `21.1.0` targets Angular 21 and follows the signal-first architecture used across `ng-hub-ui`.
10
+
11
+ ## Library Family `ng-hub-ui`
12
+
13
+ This library is part of the **ng-hub-ui** ecosystem:
14
+
15
+ - [**ng-hub-ui-accordion**](https://www.npmjs.com/package/ng-hub-ui-accordion)
16
+ - [**ng-hub-ui-avatar**](https://www.npmjs.com/package/ng-hub-ui-avatar)
17
+ - [**ng-hub-ui-board**](https://www.npmjs.com/package/ng-hub-ui-board)
18
+ - [**ng-hub-ui-breadcrumbs**](https://www.npmjs.com/package/ng-hub-ui-breadcrumbs)
19
+ - [**ng-hub-ui-calendar**](https://www.npmjs.com/package/ng-hub-ui-calendar)
20
+ - [**ng-hub-ui-modal**](https://www.npmjs.com/package/ng-hub-ui-modal)
21
+ - [**ng-hub-ui-nav**](https://www.npmjs.com/package/ng-hub-ui-nav)
22
+ - [**ng-hub-ui-paginable**](https://www.npmjs.com/package/ng-hub-ui-paginable)
23
+ - [**ng-hub-ui-portal**](https://www.npmjs.com/package/ng-hub-ui-portal)
24
+ - [**ng-hub-ui-stepper**](https://www.npmjs.com/package/ng-hub-ui-stepper)
25
+ - [**ng-hub-ui-utils**](https://www.npmjs.com/package/ng-hub-ui-utils)
26
+
27
+ ## Table of Contents
28
+
29
+ - [Features](#features)
30
+ - [Installation](#installation)
31
+ - [Quick Start](#quick-start)
32
+ - [Examples](#examples)
33
+ - [API Reference](#api-reference)
34
+ - [Styling](#styling)
35
+ - [Changelog](#changelog)
36
+ - [Contribution](#contribution)
37
+ - [Support](#support)
38
+ - [Contributors](#contributors)
39
+ - [License](#license)
40
+
41
+ ## Features
42
+
43
+ - Horizontal and vertical navigation layouts.
44
+ - Responsive collapse modes: `offcanvas`, `dropdown`, and `fullscreen`.
45
+ - Vertical child expansion modes: `accordion`, `flyout`, and `panel`.
46
+ - Stacked panel drill-down navigation with configurable visible panel count.
47
+ - Projected `hubNavStart` and `hubNavEnd` slots.
48
+ - Custom item rendering with `hubNavItemTemplate`.
49
+ - Router-aware active states with fragment and query param support.
50
+ - Scroll-spy helpers for documentation pages and one-page layouts.
51
+ - Sticky vertical navigation support.
52
+ - Full CSS variable theming via `--hub-nav-*` tokens.
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ npm install ng-hub-ui-nav
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```typescript
63
+ import { Component } from '@angular/core';
64
+ import { HubNavComponent, HubNavItem } from 'ng-hub-ui-nav';
65
+
66
+ @Component({
67
+ standalone: true,
68
+ imports: [HubNavComponent],
69
+ template: `
70
+ <hub-nav
71
+ [items]="items"
72
+ [config]="{
73
+ orientation: 'horizontal',
74
+ dropdownTrigger: 'click'
75
+ }"
76
+ />
77
+ `
78
+ })
79
+ export class ExampleComponent {
80
+ readonly items: HubNavItem[] = [
81
+ { id: 'home', label: 'Home', type: 'link', route: '/' },
82
+ {
83
+ id: 'components',
84
+ label: 'Components',
85
+ type: 'dropdown',
86
+ children: [
87
+ { id: 'accordion', label: 'Accordion', type: 'link', route: '/accordion' },
88
+ { id: 'calendar', label: 'Calendar', type: 'link', route: '/calendar' }
89
+ ]
90
+ }
91
+ ];
92
+ }
93
+ ```
94
+
95
+ ## Examples
96
+
97
+ ### Vertical Sidebar with Panels
98
+
99
+ ```html
100
+ <hub-nav
101
+ [items]="items"
102
+ [config]="{
103
+ orientation: 'vertical',
104
+ verticalExpandMode: 'panel',
105
+ panelMaxVisible: 2,
106
+ panelWidth: '18rem',
107
+ position: 'sticky',
108
+ stickyTop: '1rem'
109
+ }"
110
+ />
111
+ ```
112
+
113
+ ### Start and End Slots
114
+
115
+ ```html
116
+ <hub-nav [items]="items" [config]="{ orientation: 'horizontal' }">
117
+ <ng-template hubNavStart let-collapsed="collapsed">
118
+ <strong>My App</strong>
119
+ </ng-template>
120
+
121
+ <ng-template hubNavEnd>
122
+ <button type="button">Profile</button>
123
+ </ng-template>
124
+ </hub-nav>
125
+ ```
126
+
127
+ ### Scroll Spy
128
+
129
+ ```html
130
+ <section
131
+ hubNavScrollSpy
132
+ (activeSectionChange)="activeSection = $event"
133
+ >
134
+ <section id="overview" hubNavScrollSpySection>...</section>
135
+ <section id="api" hubNavScrollSpySection>...</section>
136
+ </section>
137
+ ```
138
+
139
+ ## API Reference
140
+
141
+ ### `HubNavComponent`
142
+
143
+ #### Inputs
144
+
145
+ | Input | Type | Default | Description |
146
+ |---|---|---|---|
147
+ | `items` | `HubNavItem[]` | required | Navigation tree to render. |
148
+ | `config` | `Partial<HubNavConfig>` | `{}` | Per-instance config merged with global defaults. |
149
+ | `navClass` | `string` | `''` | Additional class applied to the internal `<nav>`. |
150
+ | `itemTemplate` | `TemplateRef<unknown> \| null` | `null` | Optional custom item template. |
151
+ | `autoOpenFromRoute` | `boolean` | `false` | Opens matching dropdowns/panels from the current route. |
152
+
153
+ #### Outputs
154
+
155
+ | Output | Type | Description |
156
+ |---|---|---|
157
+ | `itemClick` | `OutputEmitterRef<HubNavItem>` | Emitted when a link item is activated. |
158
+ | `dropdownOpen` | `OutputEmitterRef<HubNavItem>` | Emitted when a dropdown opens. |
159
+ | `dropdownClose` | `OutputEmitterRef<HubNavItem>` | Emitted when a dropdown closes. |
160
+ | `mobileToggle` | `OutputEmitterRef<boolean>` | Emitted when the responsive mobile panel opens or closes. |
161
+ | `panelChange` | `OutputEmitterRef<HubNavPanelEvent>` | Emitted when a panel opens, closes, drills down, or drills back. |
162
+
163
+ ### `HubNavConfig`
164
+
165
+ ```typescript
166
+ interface HubNavConfig {
167
+ orientation: 'horizontal' | 'vertical';
168
+ verticalExpandMode: 'accordion' | 'flyout' | 'panel';
169
+ dropdownTrigger: 'hover' | 'click' | 'both';
170
+ position: 'static' | 'sticky' | 'fixed';
171
+ stickyTop: string;
172
+ collapseMode: 'offcanvas' | 'dropdown' | 'fullscreen';
173
+ collapseBreakpoint: number;
174
+ offcanvasPosition: 'start' | 'end' | 'top' | 'bottom';
175
+ ariaLabel: string;
176
+ panelMaxVisible: number;
177
+ sidebarSide: 'left' | 'right';
178
+ panelWidth: string;
179
+ }
180
+ ```
181
+
182
+ ### `HubNavItem`
183
+
184
+ ```typescript
185
+ interface HubNavItem {
186
+ id: string;
187
+ label: string;
188
+ type: 'link' | 'dropdown' | 'header' | 'separator' | 'custom';
189
+ icon?: string;
190
+ route?: string | string[];
191
+ queryParams?: Record<string, string>;
192
+ fragment?: string;
193
+ routerLinkActiveOptions?: { exact: boolean };
194
+ children?: HubNavItem[];
195
+ badge?: string;
196
+ badgeClass?: string;
197
+ disabled?: boolean;
198
+ cssClass?: string;
199
+ data?: unknown;
200
+ expandMode?: 'accordion' | 'flyout' | 'panel';
201
+ }
202
+ ```
203
+
204
+ ### Directives
205
+
206
+ - `hubNavStart`: projects content into the start slot.
207
+ - `hubNavEnd`: projects content into the end slot.
208
+ - `hubNavItemTemplate`: overrides item rendering.
209
+ - `hubNavScrollSpy`: tracks visible sections in a scroll container.
210
+ - `hubNavScrollSpySection`: marks a section as spy-trackable.
211
+
212
+ ## Styling
213
+
214
+ The component exposes a complete set of `--hub-nav-*` tokens. See the full reference in:
215
+
216
+ - [CSS Variables Reference](docs/css-variables-reference.md)
217
+
218
+ Example:
219
+
220
+ ```css
221
+ .my-sidebar {
222
+ --hub-nav-panel-width: 18rem;
223
+ --hub-nav-item-active-bg: #0d6efd;
224
+ --hub-nav-item-active-color: #ffffff;
225
+ --hub-nav-dropdown-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.16);
226
+ }
227
+ ```
228
+
229
+ ## Changelog
230
+
231
+ See the full release history in [CHANGELOG.md](CHANGELOG.md).
232
+
233
+ If you are upgrading across versions, also review [BREAKING_CHANGES.md](BREAKING_CHANGES.md).
234
+
235
+ ## Contribution
236
+
237
+ Issues, discussions, and pull requests are welcome.
238
+
239
+ If you want to contribute:
240
+
241
+ 1. Fork the repository.
242
+ 2. Create a feature branch.
243
+ 3. Keep API changes documented in the README and changelog.
244
+ 4. Open a pull request with a clear description of the change.
245
+
246
+ ## Support
247
+
248
+ If this library helps your projects, you can support its maintenance here:
249
+
250
+ - [Buy Me a Coffee](https://buymeacoffee.com/carlosmorcillo)
251
+
252
+ ## Contributors
253
+
254
+ Created and maintained by [Carlos Morcillo](https://github.com/carlos-morcillo).
255
+
256
+ ## License
257
+
258
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.