@m3e/fab-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,172 @@
1
+ # @m3e/fab-menu
2
+
3
+ The `m3e-fab-menu` component presents a dynamic menu of related actions, elegantly revealed from a floating action button (FAB). Designed using expressive, adaptive surfaces, it enables seamless access to contextual actions in modern, visually rich interfaces.
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/fab-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/fab-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/fab-menu/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/fab-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/fab-menu/dist/index.js"></script>
37
+ ```
38
+
39
+ You also need a module script for `@m3e/fab` due to it being a dependency.
40
+
41
+ ```html
42
+ <script type="module" src="/node_modules/@m3e/fab/dist/index.js"></script>
43
+ ```
44
+
45
+ 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.
46
+
47
+ ```html
48
+ <script type="importmap">
49
+ {
50
+ "imports": {
51
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
52
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js",
53
+ "@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js",
54
+ "@m3e/core/anchoring": "/node_modules/@m3e/core/dist/anchoring.js",
55
+ "@m3e/core/bidi": "/node_modules/@m3e/core/dist/bidi.js"
56
+ }
57
+ }
58
+ </script>
59
+ ```
60
+
61
+ > For production, use index.min.js, a11y.min.js, anchoring.min.js, and bidi.min.js for faster load times.
62
+
63
+ ## 🗂️ Elements
64
+
65
+ - `m3e-fab-menu` — A menu, opened from a floating action button (FAB), used to display multiple related actions.
66
+ - `m3e-fab-menu-item` — An item of a floating action button (FAB) menu.
67
+
68
+ - `m3e-fab-menu-trigger` — An element used to trigger the opening of a `m3e-fab-menu` from a FAB.
69
+
70
+ ## 🧪 Examples
71
+
72
+ The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`:
73
+
74
+ ```html
75
+ <m3e-fab variant="primary" size="large">
76
+ <m3e-fab-menu-trigger for="fabmenu">
77
+ <m3e-icon name="edit"></m3e-icon>
78
+ </m3e-fab-menu-trigger>
79
+ </m3e-fab>
80
+ <m3e-fab-menu id="fabmenu" variant="secondary">
81
+ <m3e-fab-menu-item>First</m3e-fab-menu-item>
82
+ <m3e-fab-menu-item>Second</m3e-fab-menu-item>
83
+ <m3e-fab-menu-item>Third</m3e-fab-menu-item>
84
+ <m3e-fab-menu-item>Forth</m3e-fab-menu-item>
85
+ <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>
86
+ <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>
87
+ </m3e-fab-menu>
88
+ ```
89
+
90
+ ## 📖 API Reference
91
+
92
+ ### 🗂️ `m3e-fab-menu`
93
+
94
+ This section details the attributes, slots and CSS custom properties available for the `m3e-fab-menu` component.
95
+
96
+ #### ⚙️ Attributes
97
+
98
+ | Attribute | Type | Default | Description |
99
+ | --------- | ---------------------------------------- | ----------- | ----------------------------------- |
100
+ | `variant` | `"primary" \| "secondary" \| "tertiary"` | `"primary"` | The appearance variant of the menu. |
101
+
102
+ #### 🧩 Slots
103
+
104
+ | Slot | Description |
105
+ | ----------- | --------------------------------- |
106
+ | _(default)_ | Renders the contents of the menu. |
107
+
108
+ ### 🎛️ CSS Custom Properties
109
+
110
+ | Property | Description |
111
+ | ------------------------------------- | --------------------------------------------------- |
112
+ | `--m3e-fab-menu-spacing` | Vertical gap between menu items. |
113
+ | `--m3e-fab-menu-max-width` | Maximum width of the menu. |
114
+ | `--m3e-primary-fab-color` | Foreground color for primary variant items. |
115
+ | `--m3e-primary-fab-container-color` | Container color for primary variant items. |
116
+ | `--m3e-primary-fab-hover-color` | Hover background color for primary variant items. |
117
+ | `--m3e-primary-fab-focus-color` | Focus background color for primary variant items. |
118
+ | `--m3e-primary-fab-ripple-color` | Ripple color for primary variant items. |
119
+ | `--m3e-secondary-fab-color` | Foreground color for secondary variant items. |
120
+ | `--m3e-secondary-fab-container-color` | Container color for secondary variant items. |
121
+ | `--m3e-secondary-fab-hover-color` | Hover background color for secondary variant items. |
122
+ | `--m3e-secondary-fab-focus-color` | Focus background color for secondary variant items. |
123
+ | `--m3e-secondary-fab-ripple-color` | Ripple color for secondary variant items. |
124
+ | `--m3e-tertiary-fab-color` | Foreground color for tertiary variant items. |
125
+ | `--m3e-tertiary-fab-container-color` | Container color for tertiary variant items. |
126
+ | `--m3e-tertiary-fab-hover-color` | Hover background color for tertiary variant items. |
127
+ | `--m3e-tertiary-fab-focus-color` | Focus background color for tertiary variant items. |
128
+ | `--m3e-tertiary-fab-ripple-color` | Ripple color for tertiary variant items. |
129
+
130
+ ### 🗂️ `m3e-fab-menu-item`
131
+
132
+ This section details the attributes, slots and CSS custom properties available for the `m3e-fab-menu-item` component.
133
+
134
+ #### ⚙️ Attributes
135
+
136
+ | Attribute | Type | Default | Description |
137
+ | ---------- | --------- | ------- | ----------------------------------------------------- |
138
+ | `disabled` | `boolean` | `false` | Whether the element is disabled. |
139
+ | `download` | `string` | | Download target for the link button. |
140
+ | `href` | `string` | | The URL to which the link button points. |
141
+ | `rel` | `string` | | The relationship between the target and the document. |
142
+ | `target` | `string` | | The target of the link button. |
143
+
144
+ #### 🧩 Slots
145
+
146
+ | Slot | Description |
147
+ | ----------- | ---------------------------------------- |
148
+ | _(default)_ | Renders the label of the item. |
149
+ | `icon` | Renders an icon before the item's label. |
150
+
151
+ ### 🎛️ CSS Custom Properties
152
+
153
+ | Property | Description |
154
+ | ------------------------------------ | -------------------------------------- |
155
+ | `--m3e-fab-menu-item-height` | Height of the menu item. |
156
+ | `--m3e-fab-menu-item-font-size` | Font size of the menu item label. |
157
+ | `--m3e-fab-menu-item-font-weight` | Font weight of the menu item label. |
158
+ | `--m3e-fab-menu-item-line-height` | Line height of the menu item label. |
159
+ | `--m3e-fab-menu-item-tracking` | Letter spacing of the menu item label. |
160
+ | `--m3e-fab-menu-item-shape` | Border radius of the menu item. |
161
+ | `--m3e-fab-menu-item-leading-space` | Padding at the start of the menu item. |
162
+ | `--m3e-fab-menu-item-trailing-space` | Padding at the end of the menu item. |
163
+ | `--m3e-fab-menu-item-spacing` | Gap between icon and label. |
164
+ | `--m3e-fab-menu-item-icon-size` | Size of the icon in the menu item. |
165
+
166
+ ## 🤝 Contributing
167
+
168
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
169
+
170
+ ## 📄 License
171
+
172
+ 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,60 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Floating Action Button 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="Floating Action Button 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
+ "@m3e/core/bidi": "../../core/dist/bidi.min.js",
26
+ "@m3e/core/anchoring": "../../core/dist/anchoring.min.js"
27
+ }
28
+ }
29
+ </script>
30
+ <script type="module" src="../../icon/dist/index.min.js"></script>
31
+ <script type="module" src="../../fab/dist/index.min.js"></script>
32
+ <script type="module" src="../../theme/dist/index.min.js"></script>
33
+ <script type="module" src="../dist/index.min.js"></script>
34
+ <style>
35
+ body {
36
+ font-family: "Roboto";
37
+ }
38
+ *:not(:defined) {
39
+ display: none;
40
+ }
41
+ </style>
42
+ </head>
43
+ <body>
44
+ <m3e-theme strong-focus>
45
+ <m3e-fab variant="primary" size="large" style="position: absolute; right: 1rem; bottom: 1rem">
46
+ <m3e-fab-menu-trigger for="fabmenu">
47
+ <m3e-icon name="edit"></m3e-icon>
48
+ </m3e-fab-menu-trigger>
49
+ </m3e-fab>
50
+ <m3e-fab-menu id="fabmenu" variant="secondary">
51
+ <m3e-fab-menu-item>First</m3e-fab-menu-item>
52
+ <m3e-fab-menu-item disabled>Second</m3e-fab-menu-item>
53
+ <m3e-fab-menu-item>Third</m3e-fab-menu-item>
54
+ <m3e-fab-menu-item>Forth</m3e-fab-menu-item>
55
+ <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>
56
+ <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>
57
+ </m3e-fab-menu>
58
+ </m3e-theme>
59
+ </body>
60
+ </html>
@@ -0,0 +1,142 @@
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-fab-menu-spacing",
7
+ "description": "Vertical gap between menu items.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-fab-menu-max-width",
12
+ "description": "Maximum width of the menu.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-primary-fab-color",
17
+ "description": "Foreground color for primary variant items.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-primary-fab-container-color",
22
+ "description": "Container color for primary variant items.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-primary-fab-hover-color",
27
+ "description": "Hover background color for primary variant items.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-primary-fab-focus-color",
32
+ "description": "Focus background color for primary variant items.",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-primary-fab-ripple-color",
37
+ "description": "Ripple color for primary variant items.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-secondary-fab-color",
42
+ "description": "Foreground color for secondary variant items.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-secondary-fab-container-color",
47
+ "description": "Container color for secondary variant items.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-secondary-fab-hover-color",
52
+ "description": "Hover background color for secondary variant items.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-secondary-fab-focus-color",
57
+ "description": "Focus background color for secondary variant items.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-secondary-fab-ripple-color",
62
+ "description": "Ripple color for secondary variant items.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-tertiary-fab-color",
67
+ "description": "Foreground color for tertiary variant items.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-tertiary-fab-container-color",
72
+ "description": "Container color for tertiary variant items.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-tertiary-fab-hover-color",
77
+ "description": "Hover background color for tertiary variant items.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-tertiary-fab-focus-color",
82
+ "description": "Focus background color for tertiary variant items.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-tertiary-fab-ripple-color",
87
+ "description": "Ripple color for tertiary variant items.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-fab-menu-item-height",
92
+ "description": "Height of the menu item.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-fab-menu-item-font-size",
97
+ "description": "Font size of the menu item label.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-fab-menu-item-font-weight",
102
+ "description": "Font weight of the menu item label.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-fab-menu-item-line-height",
107
+ "description": "Line height of the menu item label.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-fab-menu-item-tracking",
112
+ "description": "Letter spacing of the menu item label.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-fab-menu-item-shape",
117
+ "description": "Border radius of the menu item.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-fab-menu-item-leading-space",
122
+ "description": "Padding at the start of the menu item.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-fab-menu-item-trailing-space",
127
+ "description": "Padding at the end of the menu item.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-fab-menu-item-spacing",
132
+ "description": "Gap between icon and label.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-fab-menu-item-icon-size",
137
+ "description": "Size of the icon in the menu item.",
138
+ "values": []
139
+ }
140
+ ],
141
+ "pseudoElements": []
142
+ }