@m3e/nav-menu 1.0.0-rc.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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 matraic
4
+ Contact: matraic@yahoo.com
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # @m3e/nav-menu
2
+
3
+ The `m3e-nav-menu` and `m3e-nav-menu-item` components provide a hierarchical, accessible navigation menu. Designed for sidebars, navigation drawers, and complex menu structures, they support nested expandable items, keyboard navigation, selection, and extensive theming via CSS custom properties.
4
+
5
+ > **Part of the [M3E](../../README.md) monorepo**
6
+ > This package is maintained within the unified M3E repository, which provides a suite of Material 3 web components.
7
+
8
+ ## ๐Ÿ“ฆ Installation
9
+
10
+ ```bash
11
+ npm install @m3e/nav-menu
12
+ ```
13
+
14
+ ## ๐Ÿ’ป Editor Integration
15
+
16
+ This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
17
+
18
+ ### Visual Studio Code
19
+
20
+ To enable autocomplete and hover documentation for `@m3e/nav-menu`, install the [Custom Elements Manifest Language Server](https://marketplace.visualstudio.com/items?itemName=pwrs.cem-language-server-vscode) extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.
21
+
22
+ Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
23
+
24
+ ```json
25
+ {
26
+ "html.customData": ["./node_modules/@m3e/nav-menu/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/nav-menu/dist/css-custom-data.json"]
28
+ }
29
+ ```
30
+
31
+ ## ๐Ÿš€ Browser Usage
32
+
33
+ This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
34
+
35
+ ```html
36
+ <script type="module" src="/node_modules/@m3e/nav-menu/dist/index.js"></script>
37
+ ```
38
+
39
+ In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include dependencies.
40
+
41
+ ```html
42
+ <script type="importmap">
43
+ {
44
+ "imports": {
45
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
46
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js",
47
+ "@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js"
48
+ }
49
+ }
50
+ </script>
51
+ ```
52
+
53
+ > For production, use index.min.js and a11y.min.js for faster load times.
54
+
55
+ ## ๐Ÿ—‚๏ธ Elements
56
+
57
+ - `m3e-nav-menu` โ€” Presents a hierarchical menu.
58
+ - `m3e-nav-menu-item` โ€” An expandable item in a navigation menu.
59
+
60
+ ## ๐Ÿงช Example
61
+
62
+ ```html
63
+ <m3e-nav-menu>
64
+ <m3e-nav-menu-item open>
65
+ <m3e-icon slot="icon" name="rocket_launch"></m3e-icon>
66
+ <span slot="label">Getting Started</span>
67
+ <m3e-nav-menu-item>
68
+ <m3e-icon slot="icon" name="widgets"></m3e-icon>
69
+ <span slot="label">Overview</span>
70
+ </m3e-nav-menu-item>
71
+ <m3e-nav-menu-item>
72
+ <m3e-icon slot="icon" name="package_2"></m3e-icon>
73
+ <span slot="label">Installation</span>
74
+ </m3e-nav-menu-item>
75
+ </m3e-nav-menu-item>
76
+ <m3e-nav-menu-item>
77
+ <span slot="label">Actions</span>
78
+ <m3e-nav-menu-item><span slot="label">Button</span></m3e-nav-menu-item>
79
+ <m3e-nav-menu-item><span slot="label">Icon</span></m3e-nav-menu-item>
80
+ <m3e-nav-menu-item><span slot="label">Icon Button</span></m3e-nav-menu-item>
81
+ </m3e-nav-menu-item>
82
+ </m3e-nav-menu>
83
+ ```
84
+
85
+ ## ๐Ÿ“– API Reference
86
+
87
+ ### ๐Ÿ—‚๏ธ m3e-nav-menu
88
+
89
+ This section details the slots and CSS custom properties available for the `m3e-nav-menu` component.
90
+
91
+ #### ๐Ÿงฉ Slots
92
+
93
+ | Slot | Description |
94
+ | ----------- | ------------------------------ |
95
+ | _(default)_ | Renders the items of the menu. |
96
+
97
+ #### ๐ŸŽ›๏ธ CSS Custom Properties
98
+
99
+ | Property | Description |
100
+ | -------------------------------- | ---------------------------------------- |
101
+ | `--m3e-nav-menu-padding-top` | Top padding for the menu. |
102
+ | `--m3e-nav-menu-padding-bottom` | Bottom padding for the menu. |
103
+ | `--m3e-nav-menu-padding-left` | Left padding for the menu. |
104
+ | `--m3e-nav-menu-padding-right` | Right padding for the menu. |
105
+ | `--m3e-nav-menu-divider-margin` | Margin for divider elements in the menu. |
106
+ | `--m3e-nav-menu-scrollbar-width` | Width of the menu scrollbar. |
107
+ | `--m3e-nav-menu-scrollbar-color` | Color of the menu scrollbar. |
108
+
109
+ ### ๐Ÿ—‚๏ธ m3e-nav-menu-item
110
+
111
+ This section details the attributes, slots, events, and CSS custom properties available for the `m3e-nav-menu-item` component.
112
+
113
+ #### โš™๏ธ Attributes
114
+
115
+ | Attribute | Type | Default | Description |
116
+ | --------------- | --------- | ------- | ----------------------------------------------------------- |
117
+ | `disabled` | `boolean` | `false` | Whether the item is disabled. |
118
+ | `indeterminate` | `boolean` | `false` | Whether the item's selected/checked state is indeterminate. |
119
+ | `open` | `boolean` | `false` | Whether the item is expanded. |
120
+ | `selected` | `boolean` | `false` | Whether the item is selected. |
121
+
122
+ #### ๐Ÿ”” Events
123
+
124
+ | Event | Description |
125
+ | --------- | -------------------------------------- |
126
+ | `opening` | Emitted when the item begins to open. |
127
+ | `opened` | Emitted when the item has opened. |
128
+ | `closing` | Emitted when the item begins to close. |
129
+ | `closed` | Emitted when the item has closed. |
130
+
131
+ #### ๐Ÿงฉ Slots
132
+
133
+ | Slot | Description |
134
+ | --------------- | ------------------------------------------- |
135
+ | _(default)_ | Renders the nested child items. |
136
+ | `label` | Renders the label of the item. |
137
+ | `icon` | Renders the icon of the item. |
138
+ | `selected-icon` | Renders the icon of the item when selected. |
139
+ | `toggle-icon` | Renders the toggle icon. |
140
+ | `badge` | Renders a badge for the item. |
141
+
142
+ #### ๐ŸŽ›๏ธ CSS Custom Properties
143
+
144
+ | Property | Description |
145
+ | ------------------------------------------------------ | --------------------------------------------- |
146
+ | `--m3e-nav-menu-item-font-size` | Font size for the item label. |
147
+ | `--m3e-nav-menu-item-font-weight` | Font weight for the item label. |
148
+ | `--m3e-nav-menu-item-line-height` | Line height for the item label. |
149
+ | `--m3e-nav-menu-item-tracking` | Letter spacing for the item label. |
150
+ | `--m3e-nav-menu-item-padding` | Inline padding for the item. |
151
+ | `--m3e-nav-menu-item-height` | Height of the item. |
152
+ | `--m3e-nav-menu-item-spacing` | Spacing between icon and label. |
153
+ | `--m3e-nav-menu-item-shape` | Border radius of the item and focus ring. |
154
+ | `--m3e-nav-menu-item-icon-size` | Size of the icon. |
155
+ | `--m3e-nav-menu-item-inset` | Indentation for nested items. |
156
+ | `--m3e-nav-menu-item-label-color` | Text color for the item label. |
157
+ | `--m3e-nav-menu-item-selected-label-color` | Text color for selected item label. |
158
+ | `--m3e-nav-menu-item-selected-container-color` | Background color for selected item. |
159
+ | `--m3e-nav-menu-item-selected-container-focus-color` | Focus color for selected item container. |
160
+ | `--m3e-nav-menu-item-selected-container-hover-color` | Hover color for selected item container. |
161
+ | `--m3e-nav-menu-item-selected-ripple-color` | Ripple color for selected item. |
162
+ | `--m3e-nav-menu-item-unselected-container-focus-color` | Focus color for unselected item container. |
163
+ | `--m3e-nav-menu-item-unselected-container-hover-color` | Hover color for unselected item container. |
164
+ | `--m3e-nav-menu-item-unselected-ripple-color` | Ripple color for unselected item. |
165
+ | `--m3e-nav-menu-item-open-container-color` | Background color for open item with children. |
166
+ | `--m3e-nav-menu-item-open-container-focus-color` | Focus color for open item container. |
167
+ | `--m3e-nav-menu-item-open-container-hover-color` | Hover color for open item container. |
168
+ | `--m3e-nav-menu-item-open-ripple-color` | Ripple color for open item. |
169
+ | `--m3e-nav-menu-item-disabled-color` | Text color for disabled item. |
170
+ | `--m3e-nav-menu-item-disabled-color-opacity` | Opacity for disabled item text color. |
171
+ | `--m3e-nav-menu-item-badge-font-size` | Font size for badge slot. |
172
+ | `--m3e-nav-menu-item-badge-font-weight` | Font weight for badge slot. |
173
+ | `--m3e-nav-menu-item-badge-line-height` | Line height for badge slot. |
174
+ | `--m3e-nav-menu-badge-item-tracking` | Letter spacing for badge slot. |
175
+ | `--m3e-nav-menu-divider-margin` | Margin for divider elements. |
176
+ | `--m3e-nav-menu-item-vertical-inset` | Vertical margin for first/last child items. |
177
+
178
+ ## ๐Ÿค Contributing
179
+
180
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
181
+
182
+ ## ๐Ÿ“„ License
183
+
184
+ This package is licensed under the MIT License.
package/cem.config.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { customElementVsCodePlugin } from "custom-element-vs-code-integration";
2
+
3
+ export default {
4
+ globs: ["src/**/*.ts"],
5
+ exclude: ["src/**/*.spec.ts"],
6
+ packagejson: true,
7
+ outdir: "dist",
8
+ litelement: true,
9
+ plugins: [
10
+ customElementVsCodePlugin({
11
+ outdir: "dist",
12
+ htmlFileName: "html-custom-data.json",
13
+ cssFileName: "css-custom-data.json",
14
+ }),
15
+ ],
16
+ };
@@ -0,0 +1,64 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Navigation Menu for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Navigation Menu for M3E" />
8
+ <base href="./" />
9
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11
+ <link
12
+ href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap"
13
+ rel="stylesheet"
14
+ />
15
+ <link
16
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0"
17
+ rel="stylesheet"
18
+ />
19
+ <script type="importmap">
20
+ {
21
+ "imports": {
22
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
23
+ "@m3e/core": "../../core/dist/index.min.js",
24
+ "@m3e/core/a11y": "../../core/dist/a11y.min.js"
25
+ }
26
+ }
27
+ </script>
28
+ <script type="module" src="../../icon/dist/index.min.js"></script>
29
+ <script type="module" src="../../theme/dist/index.min.js"></script>
30
+ <script type="module" src="../dist/index.min.js"></script>
31
+ <style>
32
+ body {
33
+ font-family: "Roboto";
34
+ }
35
+ *:not(:defined) {
36
+ display: none;
37
+ }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <m3e-theme strong-focus>
42
+ <m3e-nav-menu style="max-width: 300px">
43
+ <m3e-nav-menu-item open>
44
+ <m3e-icon slot="icon" name="rocket_launch"></m3e-icon>
45
+ <span slot="label">Getting Started</span>
46
+ <m3e-nav-menu-item disabled>
47
+ <m3e-icon slot="icon" name="widgets"></m3e-icon>
48
+ <span slot="label">Overview</span>
49
+ </m3e-nav-menu-item>
50
+ <m3e-nav-menu-item>
51
+ <m3e-icon slot="icon" name="package_2"></m3e-icon>
52
+ <span slot="label">Installation</span>
53
+ </m3e-nav-menu-item>
54
+ </m3e-nav-menu-item>
55
+ <m3e-nav-menu-item>
56
+ <span slot="label">Actions</span>
57
+ <m3e-nav-menu-item><span slot="label">Button</span></m3e-nav-menu-item>
58
+ <m3e-nav-menu-item><span slot="label">Icon</span></m3e-nav-menu-item>
59
+ <m3e-nav-menu-item><span slot="label">Icon Button</span></m3e-nav-menu-item>
60
+ </m3e-nav-menu-item>
61
+ </m3e-nav-menu>
62
+ </m3e-theme>
63
+ </body>
64
+ </html>
@@ -0,0 +1,197 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [
5
+ {
6
+ "name": "--m3e-nav-menu-padding-top",
7
+ "description": "Top padding for the menu.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-nav-menu-padding-bottom",
12
+ "description": "Bottom padding for the menu.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-nav-menu-padding-left",
17
+ "description": "Left padding for the menu.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-nav-menu-padding-right",
22
+ "description": "Right padding for the menu.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-nav-menu-divider-margin",
27
+ "description": "Margin for divider elements in the menu.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-nav-menu-scrollbar-width",
32
+ "description": "Width of the menu scrollbar.",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-nav-menu-scrollbar-color",
37
+ "description": "Color of the menu scrollbar.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-nav-menu-item-font-size",
42
+ "description": "Font size for the item label.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-nav-menu-item-font-weight",
47
+ "description": "Font weight for the item label.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-nav-menu-item-line-height",
52
+ "description": "Line height for the item label.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-nav-menu-item-tracking",
57
+ "description": "Letter spacing for the item label.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-nav-menu-item-padding",
62
+ "description": "Inline padding for the item.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-nav-menu-item-height",
67
+ "description": "Height of the item.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-nav-menu-item-spacing",
72
+ "description": "Spacing between icon and label.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-nav-menu-item-shape",
77
+ "description": "Border radius of the item and focus ring.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-nav-menu-item-icon-size",
82
+ "description": "Size of the icon.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-nav-menu-item-inset",
87
+ "description": "Indentation for nested items.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-nav-menu-item-label-color",
92
+ "description": "Text color for the item label.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-nav-menu-item-selected-label-color",
97
+ "description": "Text color for selected item label.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-nav-menu-item-selected-container-color",
102
+ "description": "Background color for selected item.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-nav-menu-item-selected-container-focus-color",
107
+ "description": "Focus color for selected item container.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-nav-menu-item-selected-container-hover-color",
112
+ "description": "Hover color for selected item container.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-nav-menu-item-selected-ripple-color",
117
+ "description": "Ripple color for selected item.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-nav-menu-item-unselected-container-focus-color",
122
+ "description": "Focus color for unselected item container.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-nav-menu-item-unselected-container-hover-color",
127
+ "description": "Hover color for unselected item container.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-nav-menu-item-unselected-ripple-color",
132
+ "description": "Ripple color for unselected item.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-nav-menu-item-open-container-color",
137
+ "description": "Background color for open item with children.",
138
+ "values": []
139
+ },
140
+ {
141
+ "name": "--m3e-nav-menu-item-open-container-focus-color",
142
+ "description": "Focus color for open item container.",
143
+ "values": []
144
+ },
145
+ {
146
+ "name": "--m3e-nav-menu-item-open-container-hover-color",
147
+ "description": "Hover color for open item container.",
148
+ "values": []
149
+ },
150
+ {
151
+ "name": "--m3e-nav-menu-item-open-ripple-color",
152
+ "description": "Ripple color for open item.",
153
+ "values": []
154
+ },
155
+ {
156
+ "name": "--m3e-nav-menu-item-disabled-color",
157
+ "description": "Text color for disabled item.",
158
+ "values": []
159
+ },
160
+ {
161
+ "name": "--m3e-nav-menu-item-disabled-color-opacity",
162
+ "description": "Opacity for disabled item text color.",
163
+ "values": []
164
+ },
165
+ {
166
+ "name": "--m3e-nav-menu-item-badge-font-size",
167
+ "description": "Font size for badge slot.",
168
+ "values": []
169
+ },
170
+ {
171
+ "name": "--m3e-nav-menu-item-badge-font-weight",
172
+ "description": "Font weight for badge slot.",
173
+ "values": []
174
+ },
175
+ {
176
+ "name": "--m3e-nav-menu-item-badge-line-height",
177
+ "description": "Line height for badge slot.",
178
+ "values": []
179
+ },
180
+ {
181
+ "name": "--m3e-nav-menu-badge-item-tracking",
182
+ "description": "Letter spacing for badge slot.",
183
+ "values": []
184
+ },
185
+ {
186
+ "name": "--m3e-nav-menu-divider-margin",
187
+ "description": "Margin for divider elements.",
188
+ "values": []
189
+ },
190
+ {
191
+ "name": "--m3e-nav-menu-item-vertical-inset",
192
+ "description": "Vertical margin for first/last child items.",
193
+ "values": []
194
+ }
195
+ ],
196
+ "pseudoElements": []
197
+ }