@loomidev/bottom-nav 0.2.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 @@
1
+ {"version":3,"file":"styles.css.js","sourceRoot":"","sources":["../../src/generated/styles.css.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC,yyIAAyyI,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { LoomiBottomNav, LoomiBottomNavItem, type LoomiBottomNavActiveStyle, type LoomiBottomNavVariant, type LoomiBottomNavChangeDetail, } from "./loomi-bottom-nav.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { LoomiBottomNav, LoomiBottomNavItem, } from "./loomi-bottom-nav.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,GAInB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { type PropertyValues, type TemplateResult } from "lit";
2
+ import { LoomiElement, type LoomiColor } from "@loomidev/core";
3
+ import type { LoomiIconSource } from "@loomidev/icons";
4
+ import "@loomidev/icon/loomi-icon.js";
5
+ export type LoomiBottomNavActiveStyle = "pill" | "underline" | "top-line" | "background" | "icon-only" | "dot" | "border" | "minimal";
6
+ export type LoomiBottomNavVariant = "fixed" | "floating";
7
+ /**
8
+ * `<loomi-bottom-nav-item>` — a single destination inside a `<loomi-bottom-nav>`.
9
+ *
10
+ * Set `href` to render a real anchor (native links, Laravel routes, full page nav).
11
+ * Omit it and set `value` (or rely on `name`) to render a `<button>` instead — the item
12
+ * then behaves as a pure emitter for client-side routers. Either way, clicking always
13
+ * fires `loomi-change`, so React Router / Vue Router / SvelteKit / Astro can intercept
14
+ * navigation by calling `event.preventDefault()` on that event (or by setting the static
15
+ * `prevent-default` attribute). `target="_blank"` always keeps native new-tab behavior.
16
+ *
17
+ * @slot - The item's label text (used when the `label` attribute is absent).
18
+ * @csspart link - The underlying `<a>`/`<button>`.
19
+ * @csspart icon - The `<loomi-icon>` element.
20
+ * @csspart label - The label wrapper.
21
+ * @csspart badge - The badge/count pill (only rendered when `badge` is set).
22
+ * @csspart active-indicator - The underline/top-line/dot marker (only visible for those `active-style`s).
23
+ * @fires loomi-change - Bubbles + composed, cancelable. `detail: { item, value, name, href }`.
24
+ */
25
+ export declare class LoomiBottomNavItem extends LoomiElement {
26
+ static styles: import("lit").CSSResultGroup[];
27
+ /** Label text. Falls back to slot text if empty. */
28
+ label: string;
29
+ /** Built-in icon name (same registry as `<loomi-icon>`). */
30
+ icon: string;
31
+ /** Icon set override for just this item. Empty = inherit from the parent `icon-source`. */
32
+ iconSource: LoomiIconSource | "";
33
+ /** Badge content — a count or short string (e.g. `"3"`, `"9+"`). Empty = no badge. */
34
+ badge: string;
35
+ /** Disable this item: no navigation, no click/keyboard activation. */
36
+ disabled: boolean;
37
+ /** Identifier matched against the parent's `active` attribute. Falls back to `name`, then slot text. */
38
+ value: string;
39
+ /** Renders an `<a>` instead of a `<button>` and enables native/SPA-router navigation. */
40
+ href: string;
41
+ /** Anchor `target`. `_blank` always keeps native new-tab behavior, even with `prevent-default`. */
42
+ target: string;
43
+ /** Anchor `rel`. Defaults to `noopener noreferrer` when `target="_blank"` and `rel` is unset. */
44
+ rel: string;
45
+ /** Always call `event.preventDefault()` on click, even for a real `href` — for apps that
46
+ * want every navigation to go through the `loomi-change` event instead of a real link. */
47
+ preventDefaultNav: boolean;
48
+ /** Whether this is the active item. Normally set by the parent — set directly only when
49
+ * using this element outside a `<loomi-bottom-nav>`. */
50
+ active: boolean;
51
+ /** Active visual treatment. Normally pushed down by the parent's `active-style`. */
52
+ activeStyle: LoomiBottomNavActiveStyle;
53
+ /** Fallback icon source inherited from the parent. Set internally — not a public API. */
54
+ hostIconSource: LoomiIconSource;
55
+ private linkEl?;
56
+ /** Delegates focus to the internal `<a>`/`<button>` — the host itself holds no focus. */
57
+ focus(options?: FocusOptions): void;
58
+ /** The identifier compared against the parent's `active` attribute. */
59
+ get itemValue(): string;
60
+ private get effectiveIconSource();
61
+ private get effectiveRel();
62
+ private onClick;
63
+ private renderBadge;
64
+ private renderInner;
65
+ render(): TemplateResult;
66
+ }
67
+ /**
68
+ * `<loomi-bottom-nav>` — a mobile bottom navigation bar. Fixed to the viewport bottom by
69
+ * default (safe-area aware); set `variant="floating"` for a detached, rounded, elevated
70
+ * island instead. Set `mobile-only` to hide it at tablet width and up.
71
+ *
72
+ * `active` is a controlled identifier — set it to a child's `value`/`name` (or update it
73
+ * from a router) and every `<loomi-bottom-nav-item>` recomputes its own active state.
74
+ * Clicking an (enabled) item also updates `active` locally for immediate feedback, and
75
+ * always fires `loomi-change` so a router can take over.
76
+ *
77
+ * @slot - `<loomi-bottom-nav-item>` children (3–5 recommended).
78
+ * @csspart nav - The internal `<nav>` element.
79
+ * @fires loomi-change - Re-fired (bubbled through) from the clicked item — see
80
+ * `<loomi-bottom-nav-item>`. `detail: { item, value, name, href }`.
81
+ */
82
+ export declare class LoomiBottomNav extends LoomiElement {
83
+ static styles: import("lit").CSSResultGroup[];
84
+ /** The active item's `value`/`name`. Set this from your router to control which item is highlighted. */
85
+ active: string;
86
+ /** Visual treatment for the active item. */
87
+ activeStyle: LoomiBottomNavActiveStyle;
88
+ /** `fixed` docks edge-to-edge at the viewport bottom (default); `floating` detaches into a rounded, elevated island. */
89
+ variant: LoomiBottomNavVariant;
90
+ /** Accent used for the active item's color/background/border/dot. */
91
+ color: LoomiColor;
92
+ /** Default icon set for every item — overridable per-item via `<loomi-bottom-nav-item icon-source>`. */
93
+ iconSource: LoomiIconSource;
94
+ /** Accessible label for the `<nav>` landmark. */
95
+ label: string;
96
+ /** Hide this bar at tablet width (768px) and up — bottom navs are typically mobile-only. */
97
+ mobileOnly: boolean;
98
+ private get items();
99
+ private syncItems;
100
+ willUpdate(changed: PropertyValues<this>): void;
101
+ private onSlotchange;
102
+ private onItemChange;
103
+ /** Arrow/Home/End roving focus across items (manual activation — Enter/Space/click still
104
+ * do the actual navigating, per the WAI-ARIA APG toolbar pattern). */
105
+ private onKeydown;
106
+ render(): TemplateResult;
107
+ }
108
+ export interface LoomiBottomNavChangeDetail {
109
+ item: LoomiBottomNavItem;
110
+ value: string;
111
+ name: string;
112
+ href: string | undefined;
113
+ }
114
+ declare global {
115
+ interface HTMLElementTagNameMap {
116
+ "loomi-bottom-nav": LoomiBottomNav;
117
+ "loomi-bottom-nav-item": LoomiBottomNavItem;
118
+ }
119
+ interface HTMLElementEventMap {
120
+ "loomi-change": CustomEvent<LoomiBottomNavChangeDetail>;
121
+ }
122
+ }
123
+ //# sourceMappingURL=loomi-bottom-nav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loomi-bottom-nav.d.ts","sourceRoot":"","sources":["../src/loomi-bottom-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9E,OAAO,EAAE,YAAY,EAA2B,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,8BAA8B,CAAC;AAGtC,MAAM,MAAM,yBAAyB,GACnC,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG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BAAqB,CAAW;IAEtE,qEAAqE;IACzD,KAAK,EAAE,UAAU,CAA2B;IAExD,wGAAwG;IAChE,UAAU,EAAE,eAAe,CAAe;IAElF,iDAAiD;IACrC,KAAK,SAAa;IAE9B,4FAA4F;IACtB,UAAU,UAAS;IAEzF,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,SAAS;IAWR,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAMxD,OAAO,CAAC,YAAY,CAGlB;IAEF,OAAO,CAAC,YAAY,CAIlB;IAEF;0EACsE;IACtE,OAAO,CAAC,SAAS,CAgCf;IAEO,MAAM,IAAI,cAAc;CAclC;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;QACnC,uBAAuB,EAAE,kBAAkB,CAAC;KAC7C;IAED,UAAU,mBAAmB;QAC3B,cAAc,EAAE,WAAW,CAAC,0BAA0B,CAAC,CAAC;KACzD;CACF"}
@@ -0,0 +1,339 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing } from "lit";
8
+ import { customElement, property, query } from "lit/decorators.js";
9
+ import { ifDefined } from "lit/directives/if-defined.js";
10
+ import { LoomiElement, loomiStyles, accentVars } from "@loomidev/core";
11
+ import "@loomidev/icon/loomi-icon.js";
12
+ import { componentStyles } from "./generated/styles.css.js";
13
+ /**
14
+ * `<loomi-bottom-nav-item>` — a single destination inside a `<loomi-bottom-nav>`.
15
+ *
16
+ * Set `href` to render a real anchor (native links, Laravel routes, full page nav).
17
+ * Omit it and set `value` (or rely on `name`) to render a `<button>` instead — the item
18
+ * then behaves as a pure emitter for client-side routers. Either way, clicking always
19
+ * fires `loomi-change`, so React Router / Vue Router / SvelteKit / Astro can intercept
20
+ * navigation by calling `event.preventDefault()` on that event (or by setting the static
21
+ * `prevent-default` attribute). `target="_blank"` always keeps native new-tab behavior.
22
+ *
23
+ * @slot - The item's label text (used when the `label` attribute is absent).
24
+ * @csspart link - The underlying `<a>`/`<button>`.
25
+ * @csspart icon - The `<loomi-icon>` element.
26
+ * @csspart label - The label wrapper.
27
+ * @csspart badge - The badge/count pill (only rendered when `badge` is set).
28
+ * @csspart active-indicator - The underline/top-line/dot marker (only visible for those `active-style`s).
29
+ * @fires loomi-change - Bubbles + composed, cancelable. `detail: { item, value, name, href }`.
30
+ */
31
+ let LoomiBottomNavItem = class LoomiBottomNavItem extends LoomiElement {
32
+ constructor() {
33
+ super(...arguments);
34
+ /** Label text. Falls back to slot text if empty. */
35
+ this.label = "";
36
+ /** Built-in icon name (same registry as `<loomi-icon>`). */
37
+ this.icon = "";
38
+ /** Icon set override for just this item. Empty = inherit from the parent `icon-source`. */
39
+ this.iconSource = "";
40
+ /** Badge content — a count or short string (e.g. `"3"`, `"9+"`). Empty = no badge. */
41
+ this.badge = "";
42
+ /** Disable this item: no navigation, no click/keyboard activation. */
43
+ this.disabled = false;
44
+ /** Identifier matched against the parent's `active` attribute. Falls back to `name`, then slot text. */
45
+ this.value = "";
46
+ /** Renders an `<a>` instead of a `<button>` and enables native/SPA-router navigation. */
47
+ this.href = "";
48
+ /** Anchor `target`. `_blank` always keeps native new-tab behavior, even with `prevent-default`. */
49
+ this.target = "";
50
+ /** Anchor `rel`. Defaults to `noopener noreferrer` when `target="_blank"` and `rel` is unset. */
51
+ this.rel = "";
52
+ /** Always call `event.preventDefault()` on click, even for a real `href` — for apps that
53
+ * want every navigation to go through the `loomi-change` event instead of a real link. */
54
+ this.preventDefaultNav = false;
55
+ /** Whether this is the active item. Normally set by the parent — set directly only when
56
+ * using this element outside a `<loomi-bottom-nav>`. */
57
+ this.active = false;
58
+ /** Active visual treatment. Normally pushed down by the parent's `active-style`. */
59
+ this.activeStyle = "pill";
60
+ /** Fallback icon source inherited from the parent. Set internally — not a public API. */
61
+ this.hostIconSource = "heroicons";
62
+ this.onClick = (event) => {
63
+ if (this.disabled) {
64
+ event.preventDefault();
65
+ event.stopImmediatePropagation();
66
+ return;
67
+ }
68
+ const changeEvent = new CustomEvent("loomi-change", {
69
+ bubbles: true,
70
+ composed: true,
71
+ cancelable: true,
72
+ detail: {
73
+ item: this,
74
+ value: this.itemValue,
75
+ name: this.itemValue,
76
+ href: this.href || undefined,
77
+ },
78
+ });
79
+ const notCanceled = this.dispatchEvent(changeEvent);
80
+ // Real anchor: let native navigation happen unless the consumer opted out (statically
81
+ // via `prevent-default`, or dynamically by canceling the `loomi-change` event above) —
82
+ // `target="_blank"` always wins, since intercepting a new-tab open makes no sense.
83
+ if (this.href && this.target !== "_blank" && (this.preventDefaultNav || !notCanceled)) {
84
+ event.preventDefault();
85
+ }
86
+ };
87
+ }
88
+ static { this.styles = loomiStyles(componentStyles); }
89
+ /** Delegates focus to the internal `<a>`/`<button>` — the host itself holds no focus. */
90
+ focus(options) {
91
+ this.linkEl?.focus(options);
92
+ }
93
+ /** The identifier compared against the parent's `active` attribute. */
94
+ get itemValue() {
95
+ return this.value || this.name || this.textContent?.trim() || "";
96
+ }
97
+ get effectiveIconSource() {
98
+ return (this.iconSource || this.hostIconSource || "heroicons");
99
+ }
100
+ get effectiveRel() {
101
+ if (this.rel)
102
+ return this.rel;
103
+ return this.target === "_blank" ? "noopener noreferrer" : undefined;
104
+ }
105
+ renderBadge() {
106
+ if (!this.badge)
107
+ return nothing;
108
+ return html `<span class="loomi-bnavi-badge" part="badge">${this.badge}</span>`;
109
+ }
110
+ renderInner() {
111
+ return html `
112
+ <span class="loomi-bnavi-icon-wrap">
113
+ ${this.icon
114
+ ? html `<loomi-icon
115
+ class="loomi-bnavi-icon"
116
+ part="icon"
117
+ name=${this.icon}
118
+ source=${this.effectiveIconSource}
119
+ size="1.4rem"
120
+ ></loomi-icon>`
121
+ : nothing}
122
+ ${this.renderBadge()}
123
+ </span>
124
+ <span class="loomi-bnavi-label" part="label"><slot>${this.label}</slot></span>
125
+ <span class="loomi-bnavi-indicator" part="active-indicator" aria-hidden="true"></span>
126
+ `;
127
+ }
128
+ render() {
129
+ if (this.href) {
130
+ return html `<a
131
+ class="loomi-bnavi-link"
132
+ part="link"
133
+ href=${ifDefined(this.disabled ? undefined : this.href)}
134
+ target=${ifDefined(this.target || undefined)}
135
+ rel=${ifDefined(this.effectiveRel)}
136
+ aria-current=${this.active ? "page" : nothing}
137
+ aria-disabled=${this.disabled ? "true" : nothing}
138
+ tabindex=${this.disabled ? "-1" : "0"}
139
+ @click=${this.onClick}
140
+ >${this.renderInner()}</a
141
+ >`;
142
+ }
143
+ return html `<button
144
+ class="loomi-bnavi-link"
145
+ part="link"
146
+ type="button"
147
+ ?disabled=${this.disabled}
148
+ aria-current=${this.active ? "page" : nothing}
149
+ @click=${this.onClick}
150
+ >
151
+ ${this.renderInner()}
152
+ </button>`;
153
+ }
154
+ };
155
+ __decorate([
156
+ property()
157
+ ], LoomiBottomNavItem.prototype, "label", void 0);
158
+ __decorate([
159
+ property()
160
+ ], LoomiBottomNavItem.prototype, "icon", void 0);
161
+ __decorate([
162
+ property({ attribute: "icon-source" })
163
+ ], LoomiBottomNavItem.prototype, "iconSource", void 0);
164
+ __decorate([
165
+ property()
166
+ ], LoomiBottomNavItem.prototype, "badge", void 0);
167
+ __decorate([
168
+ property({ type: Boolean, reflect: true })
169
+ ], LoomiBottomNavItem.prototype, "disabled", void 0);
170
+ __decorate([
171
+ property()
172
+ ], LoomiBottomNavItem.prototype, "value", void 0);
173
+ __decorate([
174
+ property()
175
+ ], LoomiBottomNavItem.prototype, "href", void 0);
176
+ __decorate([
177
+ property()
178
+ ], LoomiBottomNavItem.prototype, "target", void 0);
179
+ __decorate([
180
+ property()
181
+ ], LoomiBottomNavItem.prototype, "rel", void 0);
182
+ __decorate([
183
+ property({ type: Boolean, attribute: "prevent-default" })
184
+ ], LoomiBottomNavItem.prototype, "preventDefaultNav", void 0);
185
+ __decorate([
186
+ property({ type: Boolean, reflect: true })
187
+ ], LoomiBottomNavItem.prototype, "active", void 0);
188
+ __decorate([
189
+ property({ attribute: "active-style", reflect: true })
190
+ ], LoomiBottomNavItem.prototype, "activeStyle", void 0);
191
+ __decorate([
192
+ property({ attribute: false })
193
+ ], LoomiBottomNavItem.prototype, "hostIconSource", void 0);
194
+ __decorate([
195
+ query(".loomi-bnavi-link")
196
+ ], LoomiBottomNavItem.prototype, "linkEl", void 0);
197
+ LoomiBottomNavItem = __decorate([
198
+ customElement("loomi-bottom-nav-item")
199
+ ], LoomiBottomNavItem);
200
+ export { LoomiBottomNavItem };
201
+ /**
202
+ * `<loomi-bottom-nav>` — a mobile bottom navigation bar. Fixed to the viewport bottom by
203
+ * default (safe-area aware); set `variant="floating"` for a detached, rounded, elevated
204
+ * island instead. Set `mobile-only` to hide it at tablet width and up.
205
+ *
206
+ * `active` is a controlled identifier — set it to a child's `value`/`name` (or update it
207
+ * from a router) and every `<loomi-bottom-nav-item>` recomputes its own active state.
208
+ * Clicking an (enabled) item also updates `active` locally for immediate feedback, and
209
+ * always fires `loomi-change` so a router can take over.
210
+ *
211
+ * @slot - `<loomi-bottom-nav-item>` children (3–5 recommended).
212
+ * @csspart nav - The internal `<nav>` element.
213
+ * @fires loomi-change - Re-fired (bubbled through) from the clicked item — see
214
+ * `<loomi-bottom-nav-item>`. `detail: { item, value, name, href }`.
215
+ */
216
+ let LoomiBottomNav = class LoomiBottomNav extends LoomiElement {
217
+ constructor() {
218
+ super(...arguments);
219
+ /** The active item's `value`/`name`. Set this from your router to control which item is highlighted. */
220
+ this.active = "";
221
+ /** Visual treatment for the active item. */
222
+ this.activeStyle = "pill";
223
+ /** `fixed` docks edge-to-edge at the viewport bottom (default); `floating` detaches into a rounded, elevated island. */
224
+ this.variant = "fixed";
225
+ /** Accent used for the active item's color/background/border/dot. */
226
+ this.color = "primary";
227
+ /** Default icon set for every item — overridable per-item via `<loomi-bottom-nav-item icon-source>`. */
228
+ this.iconSource = "heroicons";
229
+ /** Accessible label for the `<nav>` landmark. */
230
+ this.label = "Primary";
231
+ /** Hide this bar at tablet width (768px) and up — bottom navs are typically mobile-only. */
232
+ this.mobileOnly = false;
233
+ this.onSlotchange = () => {
234
+ this.syncItems();
235
+ this.requestUpdate();
236
+ };
237
+ this.onItemChange = (event) => {
238
+ const detail = event.detail;
239
+ if (!detail?.item || detail.item.disabled)
240
+ return;
241
+ this.active = detail.value ?? this.active;
242
+ };
243
+ /** Arrow/Home/End roving focus across items (manual activation — Enter/Space/click still
244
+ * do the actual navigating, per the WAI-ARIA APG toolbar pattern). */
245
+ this.onKeydown = (event) => {
246
+ const enabled = this.items.filter((item) => !item.disabled);
247
+ if (!enabled.length)
248
+ return;
249
+ const current = event
250
+ .composedPath()
251
+ .find((el) => el instanceof LoomiBottomNavItem);
252
+ const currentIndex = current ? enabled.indexOf(current) : -1;
253
+ let next;
254
+ switch (event.key) {
255
+ case "ArrowRight":
256
+ case "ArrowDown":
257
+ if (currentIndex === -1)
258
+ return;
259
+ next = enabled[(currentIndex + 1) % enabled.length];
260
+ break;
261
+ case "ArrowLeft":
262
+ case "ArrowUp":
263
+ if (currentIndex === -1)
264
+ return;
265
+ next = enabled[(currentIndex - 1 + enabled.length) % enabled.length];
266
+ break;
267
+ case "Home":
268
+ next = enabled[0];
269
+ break;
270
+ case "End":
271
+ next = enabled[enabled.length - 1];
272
+ break;
273
+ default:
274
+ return;
275
+ }
276
+ event.preventDefault();
277
+ next?.focus();
278
+ };
279
+ }
280
+ static { this.styles = loomiStyles(componentStyles); }
281
+ get items() {
282
+ return Array.from(this.querySelectorAll("loomi-bottom-nav-item"));
283
+ }
284
+ syncItems() {
285
+ for (const item of this.items) {
286
+ item.active = !!this.active && item.itemValue === this.active;
287
+ item.activeStyle = this.activeStyle;
288
+ item.hostIconSource = this.iconSource;
289
+ }
290
+ }
291
+ // Runs before every render (including the first — light DOM children are already parsed
292
+ // by the time Lit's first render fires, unlike connectedCallback) so items always reflect
293
+ // the current `active`/`active-style`/`icon-source` before paint.
294
+ willUpdate(changed) {
295
+ if (changed.has("active") || changed.has("activeStyle") || changed.has("iconSource")) {
296
+ this.syncItems();
297
+ }
298
+ }
299
+ render() {
300
+ return html `
301
+ <nav
302
+ class="loomi-bnav"
303
+ part="nav"
304
+ style=${accentVars(this.color)}
305
+ aria-label=${this.label}
306
+ @keydown=${this.onKeydown}
307
+ @loomi-change=${this.onItemChange}
308
+ >
309
+ <slot @slotchange=${this.onSlotchange}></slot>
310
+ </nav>
311
+ `;
312
+ }
313
+ };
314
+ __decorate([
315
+ property({ reflect: true })
316
+ ], LoomiBottomNav.prototype, "active", void 0);
317
+ __decorate([
318
+ property({ attribute: "active-style", reflect: true })
319
+ ], LoomiBottomNav.prototype, "activeStyle", void 0);
320
+ __decorate([
321
+ property({ reflect: true })
322
+ ], LoomiBottomNav.prototype, "variant", void 0);
323
+ __decorate([
324
+ property()
325
+ ], LoomiBottomNav.prototype, "color", void 0);
326
+ __decorate([
327
+ property({ attribute: "icon-source" })
328
+ ], LoomiBottomNav.prototype, "iconSource", void 0);
329
+ __decorate([
330
+ property()
331
+ ], LoomiBottomNav.prototype, "label", void 0);
332
+ __decorate([
333
+ property({ type: Boolean, attribute: "mobile-only", reflect: true })
334
+ ], LoomiBottomNav.prototype, "mobileOnly", void 0);
335
+ LoomiBottomNav = __decorate([
336
+ customElement("loomi-bottom-nav")
337
+ ], LoomiBottomNav);
338
+ export { LoomiBottomNav };
339
+ //# sourceMappingURL=loomi-bottom-nav.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loomi-bottom-nav.js","sourceRoot":"","sources":["../src/loomi-bottom-nav.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAmB,MAAM,gBAAgB,CAAC;AAExF,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,YAAY;IAA7C;;QAGL,oDAAoD;QACxC,UAAK,GAAG,EAAE,CAAC;QAEvB,4DAA4D;QAChD,SAAI,GAAG,EAAE,CAAC;QAEtB,2FAA2F;QACnD,eAAU,GAAyB,EAAE,CAAC;QAE9E,sFAAsF;QAC1E,UAAK,GAAG,EAAE,CAAC;QAEvB,sEAAsE;QAC1B,aAAQ,GAAG,KAAK,CAAC;QAE7D,wGAAwG;QAC5F,UAAK,GAAG,EAAE,CAAC;QAEvB,yFAAyF;QAC7E,SAAI,GAAG,EAAE,CAAC;QAEtB,mGAAmG;QACvF,WAAM,GAAG,EAAE,CAAC;QAExB,iGAAiG;QACrF,QAAG,GAAG,EAAE,CAAC;QAErB;kGAC0F;QAC/B,sBAAiB,GAAG,KAAK,CAAC;QAErF;gEACwD;QACZ,WAAM,GAAG,KAAK,CAAC;QAE3D,oFAAoF;QAC5B,gBAAW,GACjE,MAAM,CAAC;QAET,yFAAyF;QACzD,mBAAc,GAAoB,WAAW,CAAC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AC;QACxC,CAAC;IACH,CAAC;IAED,wFAAwF;IACxF,0FAA0F;IAC1F,kEAAkE;IACzD,UAAU,CAAC,OAA6B;QAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YACrF,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAiDQ,MAAM;QACb,OAAO,IAAI,CAAA;;;;gBAIC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;qBACjB,IAAI,CAAC,KAAK;mBACZ,IAAI,CAAC,SAAS;wBACT,IAAI,CAAC,YAAY;;4BAEb,IAAI,CAAC,YAAY;;KAExC,CAAC;IACJ,CAAC;;AAtG4B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAa;AAGe;IAAvD,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAC9C;AAGoB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAA0C;AAG1D;IAAX,QAAQ,EAAE;6CAA6C;AAGhB;IAAvC,QAAQ,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;kDAA2C;AAGtE;IAAX,QAAQ,EAAE;6CAAmB;AAGwC;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAoB;AAvB9E,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA2G1B"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@loomidev/bottom-nav",
3
+ "version": "0.2.0",
4
+ "description": "<loomi-bottom-nav>/<loomi-bottom-nav-item> — a mobile bottom navigation bar with badges, active-state styles, and framework-agnostic routing.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/loomidev/loomiui.git",
8
+ "directory": "packages/bottom-nav"
9
+ },
10
+ "license": "MIT",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "files": [
19
+ "dist",
20
+ "custom-elements.json"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js"
26
+ },
27
+ "./loomi-bottom-nav.js": {
28
+ "types": "./dist/loomi-bottom-nav.d.ts",
29
+ "import": "./dist/loomi-bottom-nav.js"
30
+ }
31
+ },
32
+ "dependencies": {
33
+ "@loomidev/core": "^0.2.0",
34
+ "@loomidev/icons": "^0.2.0",
35
+ "@loomidev/icon": "^0.2.0"
36
+ },
37
+ "peerDependencies": {
38
+ "lit": "^3.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@tailwindcss/cli": "^4.0.0",
42
+ "lit": "^3.3.3",
43
+ "tailwindcss": "^4.0.0",
44
+ "typescript": "^5.6.3",
45
+ "@loomidev/theme": "^0.2.0"
46
+ },
47
+ "keywords": [
48
+ "web-components",
49
+ "lit",
50
+ "loomiui",
51
+ "bottom-nav",
52
+ "navigation",
53
+ "mobile",
54
+ "tab-bar"
55
+ ],
56
+ "customElements": "custom-elements.json",
57
+ "scripts": {
58
+ "build": "node scripts/build-styles.mjs && tsc -p tsconfig.json",
59
+ "dev": "node scripts/build-styles.mjs && tsc -p tsconfig.json --watch",
60
+ "typecheck": "tsc -p tsconfig.json --noEmit"
61
+ }
62
+ }