@lit-material/navigation 0.0.1

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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +5 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/navigation-drawer-item-styles.d.ts +2 -0
  8. package/dist/navigation-drawer-item-styles.d.ts.map +1 -0
  9. package/dist/navigation-drawer-item-styles.js +108 -0
  10. package/dist/navigation-drawer-item-styles.js.map +1 -0
  11. package/dist/navigation-drawer-item.d.ts +44 -0
  12. package/dist/navigation-drawer-item.d.ts.map +1 -0
  13. package/dist/navigation-drawer-item.js +124 -0
  14. package/dist/navigation-drawer-item.js.map +1 -0
  15. package/dist/navigation-drawer-styles.d.ts +2 -0
  16. package/dist/navigation-drawer-styles.d.ts.map +1 -0
  17. package/dist/navigation-drawer-styles.js +75 -0
  18. package/dist/navigation-drawer-styles.js.map +1 -0
  19. package/dist/navigation-drawer.d.ts +68 -0
  20. package/dist/navigation-drawer.d.ts.map +1 -0
  21. package/dist/navigation-drawer.js +187 -0
  22. package/dist/navigation-drawer.js.map +1 -0
  23. package/dist/navigation-rail-item-styles.d.ts +2 -0
  24. package/dist/navigation-rail-item-styles.d.ts.map +1 -0
  25. package/dist/navigation-rail-item-styles.js +122 -0
  26. package/dist/navigation-rail-item-styles.js.map +1 -0
  27. package/dist/navigation-rail-item.d.ts +46 -0
  28. package/dist/navigation-rail-item.d.ts.map +1 -0
  29. package/dist/navigation-rail-item.js +128 -0
  30. package/dist/navigation-rail-item.js.map +1 -0
  31. package/dist/navigation-rail-styles.d.ts +2 -0
  32. package/dist/navigation-rail-styles.d.ts.map +1 -0
  33. package/dist/navigation-rail-styles.js +51 -0
  34. package/dist/navigation-rail-styles.js.map +1 -0
  35. package/dist/navigation-rail.d.ts +44 -0
  36. package/dist/navigation-rail.d.ts.map +1 -0
  37. package/dist/navigation-rail.js +93 -0
  38. package/dist/navigation-rail.js.map +1 -0
  39. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bohdaq
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,127 @@
1
+ # @lit-material/navigation
2
+
3
+ Material Design 3 navigation drawer and navigation rail web components built with
4
+ [Lit](https://lit.dev/). Part of [lit-material](https://github.com/bohdaq/lit-material).
5
+
6
+ ![lit-material navigation drawer (standard, with a modal-drawer trigger button) and navigation rail, both showing their first destination selected](./screenshot.png)
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install @lit-material/navigation @lit-material/tokens
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```html
17
+ <link rel="stylesheet" href="node_modules/@lit-material/tokens/css/index.css" />
18
+ <script type="module">
19
+ import "@lit-material/navigation";
20
+ </script>
21
+
22
+ <!-- Navigation drawer: a vertical panel of destinations. -->
23
+ <lit-material-navigation-drawer selected="0">
24
+ <lit-material-navigation-drawer-item>
25
+ <svg slot="icon">…</svg>
26
+ Inbox
27
+ </lit-material-navigation-drawer-item>
28
+ <lit-material-navigation-drawer-item>
29
+ <svg slot="icon">…</svg>
30
+ Sent
31
+ </lit-material-navigation-drawer-item>
32
+ </lit-material-navigation-drawer>
33
+
34
+ <!-- Navigation rail: a narrow always-visible bar, typically docked to an edge. -->
35
+ <lit-material-navigation-rail selected="0">
36
+ <lit-material-navigation-rail-item>
37
+ <svg slot="icon">…</svg>
38
+ Music
39
+ </lit-material-navigation-rail-item>
40
+ <lit-material-navigation-rail-item>
41
+ <svg slot="icon">…</svg>
42
+ Videos
43
+ </lit-material-navigation-rail-item>
44
+ </lit-material-navigation-rail>
45
+ ```
46
+
47
+ Listen for `change` to react to the selection:
48
+
49
+ ```js
50
+ document.querySelector("lit-material-navigation-drawer").addEventListener("change", (event) => {
51
+ console.log(event.target.selected); // the selected index
52
+ });
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### `lit-material-navigation-drawer`
58
+
59
+ | Property | Attribute | Type | Default |
60
+ | ----------------------- | ------------------------ | ------------------------ | ------------ |
61
+ | `variant` | `variant` | `"standard" \| "modal"` | `"standard"` |
62
+ | `position` | `position` | `"start" \| "end"` | `"start"` |
63
+ | `selected` | `selected` | `number` | `-1` |
64
+ | `open` | `open` | `boolean` | `false` |
65
+ | `disableBackdropClose` | `disable-backdrop-close` | `boolean` | `false` |
66
+
67
+ `standard` renders as a plain, always-in-flow `<nav>` — a persistent side panel you place in your
68
+ own layout. `modal` wraps the same content in a native `<dialog>` (the same foundation
69
+ [`@lit-material/dialog`](https://github.com/bohdaq/lit-material/tree/main/packages/dialog) uses),
70
+ so the scrim, Escape-to-close, and focus trap all come from the browser; `position` picks which
71
+ edge it slides in from. Call `show()`/`close()` (or set `.open`) to control a `modal` drawer.
72
+ Fires `cancel`/`close`, re-dispatched from the native `<dialog>` events, for the `modal` variant.
73
+
74
+ Slots: default (`lit-material-navigation-drawer-item` elements), `header` (a title, a close
75
+ button…).
76
+
77
+ ### `lit-material-navigation-drawer-item`
78
+
79
+ | Property | Attribute | Type | Default |
80
+ | ---------- | ---------- | --------- | ------- |
81
+ | `selected` | `selected` | `boolean` | `false` |
82
+ | `disabled` | `disabled` | `boolean` | `false` |
83
+ | `href` | `href` | `string` | `""` |
84
+ | `target` | `target` | `string` | `""` |
85
+
86
+ Slots: default (label text), `icon` (leading icon), `badge` (a trailing count or dot).
87
+ `selected` is normally managed by the parent drawer, not set directly.
88
+
89
+ ### `lit-material-navigation-rail`
90
+
91
+ | Property | Attribute | Type | Default |
92
+ | ------------ | ----------- | -------------------------------- | ------- |
93
+ | `alignment` | `alignment` | `"top" \| "center" \| "bottom"` | `"top"` |
94
+ | `selected` | `selected` | `number` | `-1` |
95
+
96
+ Slots: default (`lit-material-navigation-rail-item` elements), `fab` (an optional FAB shown above
97
+ the items).
98
+
99
+ ### `lit-material-navigation-rail-item`
100
+
101
+ | Property | Attribute | Type | Default |
102
+ | ---------- | ---------- | --------- | ------- |
103
+ | `selected` | `selected` | `boolean` | `false` |
104
+ | `disabled` | `disabled` | `boolean` | `false` |
105
+ | `href` | `href` | `string` | `""` |
106
+ | `target` | `target` | `string` | `""` |
107
+
108
+ Slots: default (label text, shown below the icon), `icon`, `badge` (positioned over the icon's
109
+ top-right corner). The ripple/focus-ring are scoped to the icon's pill-shaped active indicator,
110
+ not the whole item, matching the MD3 spec.
111
+
112
+ ## Behavior
113
+
114
+ Both `lit-material-navigation-drawer` and `lit-material-navigation-rail` manage selection the
115
+ same way `lit-material-tabs` does: set `selected` (an index) to reflect your current route or
116
+ section, and each item's own `selected` is kept in sync automatically. Clicking an item updates
117
+ `selected` and fires `change` — items don't manage selection themselves, so binding `selected` to
118
+ your router state (rather than reading it back out) is the expected integration point for SPA
119
+ navigation.
120
+
121
+ Fully out of scope for this first pass: responsive breakpoint switching (automatically swapping
122
+ between rail/drawer/bottom-navigation based on window size) — that's an app-level layout decision
123
+ this library doesn't make on your behalf.
124
+
125
+ ## License
126
+
127
+ MIT
@@ -0,0 +1,7 @@
1
+ export { LitMaterialNavigationDrawer } from "./navigation-drawer.js";
2
+ export type { NavigationDrawerVariant, NavigationDrawerPosition } from "./navigation-drawer.js";
3
+ export { LitMaterialNavigationDrawerItem } from "./navigation-drawer-item.js";
4
+ export { LitMaterialNavigationRail } from "./navigation-rail.js";
5
+ export type { NavigationRailAlignment } from "./navigation-rail.js";
6
+ export { LitMaterialNavigationRailItem } from "./navigation-rail-item.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { LitMaterialNavigationDrawer } from "./navigation-drawer.js";
2
+ export { LitMaterialNavigationDrawerItem } from "./navigation-drawer-item.js";
3
+ export { LitMaterialNavigationRail } from "./navigation-rail.js";
4
+ export { LitMaterialNavigationRailItem } from "./navigation-rail-item.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=navigation-drawer-item-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-item-styles.d.ts","sourceRoot":"","sources":["../src/navigation-drawer-item-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAyGlB,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { css } from "lit";
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ outline: none;
6
+ -webkit-tap-highlight-color: transparent;
7
+ }
8
+
9
+ :host([disabled]) {
10
+ pointer-events: none;
11
+ }
12
+
13
+ .item {
14
+ position: relative;
15
+ display: flex;
16
+ align-items: center;
17
+ gap: 12px;
18
+ box-sizing: border-box;
19
+ width: 100%;
20
+ min-height: 56px;
21
+ padding-inline: 16px;
22
+ border: none;
23
+ border-radius: var(--md-sys-shape-corner-full, 28px);
24
+ margin: 0;
25
+ background-color: transparent;
26
+ color: var(--md-sys-color-on-surface-variant, #49454f);
27
+ cursor: pointer;
28
+ text-align: start;
29
+ text-decoration: none;
30
+ font-family: var(--md-sys-typescale-label-large-font, Roboto, system-ui, sans-serif);
31
+ font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
32
+ font-weight: var(--md-sys-typescale-label-large-weight, 500);
33
+ -webkit-appearance: none;
34
+ appearance: none;
35
+ transition: background-color 150ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
36
+ }
37
+
38
+ .item:disabled,
39
+ .item[aria-disabled="true"] {
40
+ cursor: default;
41
+ }
42
+
43
+ :host([selected]) .item {
44
+ background-color: var(--md-sys-color-secondary-container, #e8def8);
45
+ color: var(--md-sys-color-on-secondary-container, #1d192b);
46
+ }
47
+
48
+ .icon ::slotted(*) {
49
+ display: block;
50
+ width: 24px;
51
+ height: 24px;
52
+ }
53
+
54
+ .label {
55
+ flex: 1;
56
+ min-width: 0;
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ white-space: nowrap;
60
+ }
61
+
62
+ .badge ::slotted(*) {
63
+ display: block;
64
+ }
65
+
66
+ .state-layer {
67
+ position: absolute;
68
+ inset: 0;
69
+ border-radius: inherit;
70
+ background-color: currentColor;
71
+ opacity: 0;
72
+ pointer-events: none;
73
+ transition: opacity 100ms linear;
74
+ }
75
+
76
+ .item:hover .state-layer {
77
+ opacity: var(--md-sys-state-hover-state-layer-opacity, 0.08);
78
+ }
79
+
80
+ .state-layer[data-pressed] {
81
+ opacity: var(--md-sys-state-pressed-state-layer-opacity, 0.1);
82
+ }
83
+
84
+ .focus-ring {
85
+ position: absolute;
86
+ inset: -2px;
87
+ border-radius: inherit;
88
+ outline: 3px solid var(--md-sys-color-secondary, #625b71);
89
+ outline-offset: 2px;
90
+ pointer-events: none;
91
+ }
92
+
93
+ .focus-ring[hidden] {
94
+ display: none;
95
+ }
96
+
97
+ :host([disabled]) .item {
98
+ color: color-mix(in srgb, var(--md-sys-color-on-surface, #1c1b1f) 38%, transparent);
99
+ }
100
+
101
+ @media (prefers-reduced-motion: reduce) {
102
+ .item,
103
+ .state-layer {
104
+ transition: none;
105
+ }
106
+ }
107
+ `;
108
+ //# sourceMappingURL=navigation-drawer-item-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-item-styles.js","sourceRoot":"","sources":["../src/navigation-drawer-item-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyGxB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { LitElement } from "lit";
2
+ /**
3
+ * A single destination inside a `lit-material-navigation-drawer` — a
4
+ * pill-shaped row with a leading icon and a label, following the MD3
5
+ * navigation drawer item spec.
6
+ *
7
+ * Renders as a real `<button>` by default, or an `<a>` when `href` is set —
8
+ * both get the same ripple/focus-ring treatment as `lit-material-list-item`.
9
+ * `selected` is normally managed by the parent drawer (see its docs), not
10
+ * set directly.
11
+ *
12
+ * @element lit-material-navigation-drawer-item
13
+ *
14
+ * @slot - The label text.
15
+ * @slot icon - The leading icon.
16
+ * @slot badge - Optional trailing content (a count or dot).
17
+ *
18
+ * @csspart item - The `<button>` or `<a>` row (background/shape).
19
+ * @csspart ripple - The state-layer element the hover/press feedback is drawn on.
20
+ * @csspart focus-ring - The focus indicator element.
21
+ */
22
+ export declare class LitMaterialNavigationDrawerItem extends LitElement {
23
+ static styles: import("lit").CSSResult;
24
+ static shadowRootOptions: ShadowRootInit;
25
+ selected: boolean;
26
+ disabled: boolean;
27
+ /** If set, renders the item as a link (`<a>`) instead of a `<button>`. */
28
+ href: string;
29
+ target: string;
30
+ private readonly stateLayerElement?;
31
+ private readonly ripple;
32
+ private readonly focusRing;
33
+ protected updated(): void;
34
+ private get content();
35
+ render(): import("lit").TemplateResult<1>;
36
+ private handleClick;
37
+ private handleLinkClick;
38
+ }
39
+ declare global {
40
+ interface HTMLElementTagNameMap {
41
+ "lit-material-navigation-drawer-item": LitMaterialNavigationDrawerItem;
42
+ }
43
+ }
44
+ //# sourceMappingURL=navigation-drawer-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-item.d.ts","sourceRoot":"","sources":["../src/navigation-drawer-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAKhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,+BAAgC,SAAQ,UAAU;IAC7D,OAAgB,MAAM,0BAAU;IAEhC,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAE0C,QAAQ,UAAS;IACjB,QAAQ,UAAS;IAE7D,0EAA0E;IAC9D,IAAI,SAAM;IACV,MAAM,SAAM;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAc;IAExE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;cAExC,OAAO,IAAI,IAAI;IAIlC,OAAO,KAAK,OAAO,GAQlB;IAEQ,MAAM;IAmCf,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,eAAe;CAMxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qCAAqC,EAAE,+BAA+B,CAAC;KACxE;CACF"}
@@ -0,0 +1,124 @@
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, LitElement, nothing } from "lit";
8
+ import { customElement, property, query } from "lit/decorators.js";
9
+ import { FocusRingController, RippleController } from "@lit-material/core";
10
+ import { styles } from "./navigation-drawer-item-styles.js";
11
+ /**
12
+ * A single destination inside a `lit-material-navigation-drawer` — a
13
+ * pill-shaped row with a leading icon and a label, following the MD3
14
+ * navigation drawer item spec.
15
+ *
16
+ * Renders as a real `<button>` by default, or an `<a>` when `href` is set —
17
+ * both get the same ripple/focus-ring treatment as `lit-material-list-item`.
18
+ * `selected` is normally managed by the parent drawer (see its docs), not
19
+ * set directly.
20
+ *
21
+ * @element lit-material-navigation-drawer-item
22
+ *
23
+ * @slot - The label text.
24
+ * @slot icon - The leading icon.
25
+ * @slot badge - Optional trailing content (a count or dot).
26
+ *
27
+ * @csspart item - The `<button>` or `<a>` row (background/shape).
28
+ * @csspart ripple - The state-layer element the hover/press feedback is drawn on.
29
+ * @csspart focus-ring - The focus indicator element.
30
+ */
31
+ let LitMaterialNavigationDrawerItem = class LitMaterialNavigationDrawerItem extends LitElement {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.selected = false;
35
+ this.disabled = false;
36
+ /** If set, renders the item as a link (`<a>`) instead of a `<button>`. */
37
+ this.href = "";
38
+ this.target = "";
39
+ this.ripple = new RippleController(this);
40
+ this.focusRing = new FocusRingController(this);
41
+ }
42
+ static { this.styles = styles; }
43
+ static { this.shadowRootOptions = {
44
+ ...LitElement.shadowRootOptions,
45
+ delegatesFocus: true,
46
+ }; }
47
+ updated() {
48
+ if (this.stateLayerElement)
49
+ this.ripple.attach(this.stateLayerElement);
50
+ }
51
+ get content() {
52
+ return html `
53
+ <div class="focus-ring" part="focus-ring" ?hidden=${!this.focusRing.visible}></div>
54
+ <div class="state-layer" part="ripple"></div>
55
+ <slot name="icon" class="icon"></slot>
56
+ <span class="label"><slot></slot></span>
57
+ <slot name="badge" class="badge"></slot>
58
+ `;
59
+ }
60
+ render() {
61
+ const ariaCurrent = this.selected ? "page" : nothing;
62
+ if (this.href) {
63
+ return html `
64
+ <a
65
+ class="item"
66
+ part="item"
67
+ href=${this.disabled ? nothing : this.href}
68
+ target=${this.target || nothing}
69
+ rel=${this.target === "_blank" ? "noopener noreferrer" : nothing}
70
+ aria-current=${ariaCurrent}
71
+ aria-disabled=${this.disabled ? "true" : nothing}
72
+ tabindex=${this.disabled ? "-1" : "0"}
73
+ @click=${this.handleLinkClick}
74
+ >
75
+ ${this.content}
76
+ </a>
77
+ `;
78
+ }
79
+ return html `
80
+ <button
81
+ class="item"
82
+ part="item"
83
+ type="button"
84
+ ?disabled=${this.disabled}
85
+ aria-current=${ariaCurrent}
86
+ @click=${this.handleClick}
87
+ >
88
+ ${this.content}
89
+ </button>
90
+ `;
91
+ }
92
+ handleClick(event) {
93
+ if (this.disabled) {
94
+ event.preventDefault();
95
+ event.stopImmediatePropagation();
96
+ }
97
+ }
98
+ handleLinkClick(event) {
99
+ if (this.disabled) {
100
+ event.preventDefault();
101
+ event.stopImmediatePropagation();
102
+ }
103
+ }
104
+ };
105
+ __decorate([
106
+ property({ type: Boolean, reflect: true })
107
+ ], LitMaterialNavigationDrawerItem.prototype, "selected", void 0);
108
+ __decorate([
109
+ property({ type: Boolean, reflect: true })
110
+ ], LitMaterialNavigationDrawerItem.prototype, "disabled", void 0);
111
+ __decorate([
112
+ property()
113
+ ], LitMaterialNavigationDrawerItem.prototype, "href", void 0);
114
+ __decorate([
115
+ property()
116
+ ], LitMaterialNavigationDrawerItem.prototype, "target", void 0);
117
+ __decorate([
118
+ query(".state-layer")
119
+ ], LitMaterialNavigationDrawerItem.prototype, "stateLayerElement", void 0);
120
+ LitMaterialNavigationDrawerItem = __decorate([
121
+ customElement("lit-material-navigation-drawer-item")
122
+ ], LitMaterialNavigationDrawerItem);
123
+ export { LitMaterialNavigationDrawerItem };
124
+ //# sourceMappingURL=navigation-drawer-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-item.js","sourceRoot":"","sources":["../src/navigation-drawer-item.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=navigation-drawer-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-styles.d.ts","sourceRoot":"","sources":["../src/navigation-drawer-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAwElB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { css } from "lit";
2
+ export const styles = css `
3
+ :host {
4
+ display: contents;
5
+ }
6
+
7
+ .drawer {
8
+ display: flex;
9
+ flex-direction: column;
10
+ box-sizing: border-box;
11
+ gap: 4px;
12
+ width: 360px;
13
+ max-width: 100%;
14
+ height: 100%;
15
+ padding: 12px;
16
+ background-color: var(--md-sys-color-surface, #fffbfe);
17
+ color: var(--md-sys-color-on-surface, #1c1b1f);
18
+ /* Not part of the tab order for "modal" (see the component for why it's
19
+ the default showModal() focus target) — no visible focus indicator
20
+ of its own. */
21
+ outline: none;
22
+ }
23
+
24
+ .header {
25
+ padding: 16px 16px 8px;
26
+ }
27
+
28
+ .header:empty {
29
+ display: none;
30
+ }
31
+
32
+ .content {
33
+ display: flex;
34
+ flex-direction: column;
35
+ gap: 4px;
36
+ min-height: 0;
37
+ overflow-y: auto;
38
+ }
39
+
40
+ /* Modal variant: same .drawer content, wrapped in a native <dialog> so the
41
+ scrim, Escape-to-close, and focus trap all come from the browser. */
42
+ .dialog {
43
+ margin: 0;
44
+ padding: 0;
45
+ border: none;
46
+ inset: 0;
47
+ width: 100%;
48
+ height: 100%;
49
+ max-width: 100%;
50
+ max-height: 100%;
51
+ background: transparent;
52
+ color: inherit;
53
+ }
54
+
55
+ .dialog[open] {
56
+ display: flex;
57
+ justify-content: flex-start;
58
+ }
59
+
60
+ :host([position="end"]) .dialog[open] {
61
+ justify-content: flex-end;
62
+ }
63
+
64
+ .dialog::backdrop {
65
+ background-color: rgba(0, 0, 0, 0.32);
66
+ }
67
+
68
+ .dialog .drawer {
69
+ box-shadow: var(
70
+ --md-sys-elevation-level1,
71
+ 0 1px 2px rgba(0, 0, 0, 0.3)
72
+ );
73
+ }
74
+ `;
75
+ //# sourceMappingURL=navigation-drawer-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer-styles.js","sourceRoot":"","sources":["../src/navigation-drawer-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwExB,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { LitElement } from "lit";
2
+ export type NavigationDrawerVariant = "standard" | "modal";
3
+ export type NavigationDrawerPosition = "start" | "end";
4
+ /**
5
+ * Material Design 3 navigation drawer — a vertical panel of primary
6
+ * destinations (`lit-material-navigation-drawer-item` elements).
7
+ *
8
+ * `standard` renders as a plain, always-in-flow `<nav>` (a persistent side
9
+ * panel you place in your own layout). `modal` wraps the same content in a
10
+ * native `<dialog>`, the same foundation `lit-material-dialog` uses — so the
11
+ * scrim, Escape-to-close, and focus trap all come from the browser. `position`
12
+ * picks which edge a `modal` drawer slides in from.
13
+ *
14
+ * Selection is index-based and managed here (like `lit-material-tabs`): set
15
+ * `selected` to reflect your current route/section, and each item's own
16
+ * `selected` is kept in sync automatically. Clicking an item updates
17
+ * `selected` and fires `change` — items themselves don't manage selection.
18
+ *
19
+ * @element lit-material-navigation-drawer
20
+ *
21
+ * @slot - `lit-material-navigation-drawer-item` elements.
22
+ * @slot header - Optional header content (a title, a close button…).
23
+ *
24
+ * @csspart dialog - The native `<dialog>` element. Only rendered for `modal`.
25
+ * @csspart drawer - The visible panel (background, width, padding).
26
+ * @csspart header - The header slot's container.
27
+ * @csspart content - The items slot's container.
28
+ *
29
+ * @fires change - Fires when `selected` changes via an item click.
30
+ * @fires cancel - `modal` only: re-dispatched from the native `cancel` event.
31
+ * Cancelable: calling `preventDefault()` stops the drawer from closing.
32
+ * @fires close - `modal` only: re-dispatched from the native `close` event.
33
+ */
34
+ export declare class LitMaterialNavigationDrawer extends LitElement {
35
+ static styles: import("lit").CSSResult;
36
+ variant: NavigationDrawerVariant;
37
+ position: NavigationDrawerPosition;
38
+ /** Index of the selected item. `-1` means no selection. */
39
+ selected: number;
40
+ /** Whether a `modal` drawer is open. Ignored for `standard`. */
41
+ open: boolean;
42
+ /** If set, clicking the backdrop does not close a `modal` drawer. */
43
+ disableBackdropClose: boolean;
44
+ private readonly dialogElement?;
45
+ private reopenOnClose;
46
+ constructor();
47
+ connectedCallback(): void;
48
+ protected updated(changed: Map<string, unknown>): void;
49
+ /** Opens a `modal` drawer. Equivalent to setting `.open = true`. */
50
+ show(): void;
51
+ /** Closes a `modal` drawer. Equivalent to setting `.open = false`. */
52
+ close(): void;
53
+ private get items();
54
+ private syncSelected;
55
+ private readonly handleSlotChange;
56
+ private readonly handleClick;
57
+ private renderNav;
58
+ render(): import("lit").TemplateResult<1>;
59
+ private handleClose;
60
+ private handleCancel;
61
+ private handleBackdropClick;
62
+ }
63
+ declare global {
64
+ interface HTMLElementTagNameMap {
65
+ "lit-material-navigation-drawer": LitMaterialNavigationDrawer;
66
+ }
67
+ }
68
+ //# sourceMappingURL=navigation-drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-drawer.d.ts","sourceRoot":"","sources":["../src/navigation-drawer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAKhD,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,OAAO,CAAC;AAC3D,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBACa,2BAA4B,SAAQ,UAAU;IACzD,OAAgB,MAAM,0BAAU;IAEpB,OAAO,EAAE,uBAAuB,CAAc;IAC7B,QAAQ,EAAE,wBAAwB,CAAW;IAE1E,2DAA2D;IAC/B,QAAQ,SAAM;IAE1C,gEAAgE;IACpB,IAAI,UAAS;IAEzD,qEAAqE;IACH,oBAAoB,UAAS;IAE9E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;IACpE,OAAO,CAAC,aAAa,CAAS;;IAOrB,iBAAiB,IAAI,IAAI;cAKf,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAW/D,oEAAoE;IACpE,IAAI,IAAI,IAAI;IAIZ,sEAAsE;IACtE,KAAK,IAAI,IAAI;IAIb,OAAO,KAAK,KAAK,GAMhB;IAED,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmC;IAEpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAS1B;IAEF,OAAO,CAAC,SAAS;IAqBR,MAAM;IAgBf,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,mBAAmB;CAK5B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gCAAgC,EAAE,2BAA2B,CAAC;KAC/D;CACF"}