@m3e/option 1.0.6
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 +22 -0
- package/README.md +181 -0
- package/dist/css-custom-data.json +207 -0
- package/dist/custom-elements.json +3368 -0
- package/dist/html-custom-data.json +52 -0
- package/dist/index.js +615 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +233 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/OptGroupElement.d.ts +42 -0
- package/dist/src/OptGroupElement.d.ts.map +1 -0
- package/dist/src/OptionElement.d.ts +74 -0
- package/dist/src/OptionElement.d.ts.map +1 -0
- package/dist/src/OptionPanelElement.d.ts +77 -0
- package/dist/src/OptionPanelElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +50 -0
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,181 @@
|
|
|
1
|
+
# @m3e/option
|
|
2
|
+
|
|
3
|
+
The `m3e-option`, `m3e-option-panel`, and `m3e-optgroup` components provide a complete solution for displaying selectable options in menus and lists. They follow Material Design 3 principles with comprehensive support for single and multiple selection, dynamic positioning, keyboard navigation, and extensive theming via CSS custom properties.
|
|
4
|
+
|
|
5
|
+
> **This package is part of [M3E](https://github.com/matraic/m3e) monorepo**, a unified suite of Material 3 web components. [Explore the docs](https://matraic.github.io/m3e) to see them in action.
|
|
6
|
+
|
|
7
|
+
## ๐ฆ Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @m3e/option
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## ๐ป Editor Integration
|
|
14
|
+
|
|
15
|
+
This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
|
|
16
|
+
|
|
17
|
+
### Visual Studio Code
|
|
18
|
+
|
|
19
|
+
To enable autocomplete and hover documentation for `@m3e/option`, 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.
|
|
20
|
+
|
|
21
|
+
Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"html.customData": ["./node_modules/@m3e/option/dist/html-custom-data.json"],
|
|
26
|
+
"css.customData": ["./node_modules/@m3e/option/dist/css-custom-data.json"]
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## ๐ Native Module Support
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<script type="module" src="/node_modules/@m3e/option/dist/index.js"></script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script type="importmap">
|
|
42
|
+
{
|
|
43
|
+
"imports": {
|
|
44
|
+
"lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
|
|
45
|
+
"@m3e/core": "/node_modules/@m3e/core/dist/index.js",
|
|
46
|
+
"@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js",
|
|
47
|
+
"@m3e/core/anchoring": "/node_modules/@m3e/core/dist/anchoring.js"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> For production, use index.min.js, a11y.min.js, and anchoring.min.js for faster load times.
|
|
54
|
+
|
|
55
|
+
## ๐๏ธ Elements
|
|
56
|
+
|
|
57
|
+
- `m3e-option` โ A selectable item within a menu or list, providing visual feedback and selection state management.
|
|
58
|
+
- `m3e-option-panel` โ A temporary surface that presents a scrollable list of options anchored to a trigger element.
|
|
59
|
+
- `m3e-optgroup` โ A container that groups related options under a customizable label with semantic structure.
|
|
60
|
+
|
|
61
|
+
## ๐งช Example
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<m3e-option-panel>
|
|
65
|
+
<m3e-option value="apple">Apple</m3e-option>
|
|
66
|
+
<m3e-option value="banana">Banana</m3e-option>
|
|
67
|
+
<m3e-optgroup>
|
|
68
|
+
<span slot="label">Citrus</span>
|
|
69
|
+
<m3e-option value="lemon">Lemon</m3e-option>
|
|
70
|
+
<m3e-option value="orange">Orange</m3e-option>
|
|
71
|
+
</m3e-optgroup>
|
|
72
|
+
</m3e-option-panel>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## ๐ API Reference
|
|
76
|
+
|
|
77
|
+
### ๐๏ธ m3e-option
|
|
78
|
+
|
|
79
|
+
This section details the attributes, slots, events and CSS custom properties available for the `m3e-option` component.
|
|
80
|
+
|
|
81
|
+
#### โ๏ธ Attributes
|
|
82
|
+
|
|
83
|
+
| Attribute | Type | Default | Description |
|
|
84
|
+
| ---------- | --------- | ------- | ---------------------------------------------- |
|
|
85
|
+
| `disabled` | `boolean` | `false` | Whether the element is disabled. |
|
|
86
|
+
| `selected` | `boolean` | `false` | Whether the element is selected. |
|
|
87
|
+
| `value` | `string` | | A string representing the value of the option. |
|
|
88
|
+
|
|
89
|
+
#### ๐งฉ Slots
|
|
90
|
+
|
|
91
|
+
| Slot | Description |
|
|
92
|
+
| ----------- | -------------------------------- |
|
|
93
|
+
| _(default)_ | Renders the label of the option. |
|
|
94
|
+
|
|
95
|
+
#### ๐๏ธ CSS Custom Properties
|
|
96
|
+
|
|
97
|
+
| Property | Description |
|
|
98
|
+
| --------------------------------------------- | ------------------------------------------------- |
|
|
99
|
+
| `--m3e-option-container-height` | The height of the option container. |
|
|
100
|
+
| `--m3e-option-color` | The text color of the option. |
|
|
101
|
+
| `--m3e-option-container-hover-color` | The color for the hover state layer. |
|
|
102
|
+
| `--m3e-option-container-focus-color` | The color for the focus state layer. |
|
|
103
|
+
| `--m3e-option-ripple-color` | The color of the ripple effect. |
|
|
104
|
+
| `--m3e-option-selected-color` | The text color when the option is selected. |
|
|
105
|
+
| `--m3e-option-selected-container-color` | The background color when the option is selected. |
|
|
106
|
+
| `--m3e-option-selected-container-hover-color` | The hover color for the selected state layer. |
|
|
107
|
+
| `--m3e-option-selected-container-focus-color` | The focus color for the selected state layer. |
|
|
108
|
+
| `--m3e-option-selected-ripple-color` | The ripple color when the option is selected. |
|
|
109
|
+
| `--m3e-option-disabled-color` | The text color when the option is disabled. |
|
|
110
|
+
| `--m3e-option-disabled-opacity` | The opacity level applied to the disabled text. |
|
|
111
|
+
| `--m3e-option-icon-label-space` | The spacing between the icon and label. |
|
|
112
|
+
| `--m3e-option-padding-start` | The left padding of the option content. |
|
|
113
|
+
| `--m3e-option-padding-end` | The right padding of the option content. |
|
|
114
|
+
| `--m3e-option-label-text-font-size` | The font size of the option label. |
|
|
115
|
+
| `--m3e-option-label-text-font-weight` | The font weight of the option label. |
|
|
116
|
+
| `--m3e-option-label-text-line-height` | The line height of the option label. |
|
|
117
|
+
| `--m3e-option-label-text-tracking` | The letter spacing of the option label. |
|
|
118
|
+
| `--m3e-option-focus-ring-shape` | The corner radius of the focus ring. |
|
|
119
|
+
| `--m3e-option-icon-size` | The size of the option icons. |
|
|
120
|
+
|
|
121
|
+
### ๐๏ธ m3e-option-panel
|
|
122
|
+
|
|
123
|
+
This section details the attributes, slots, events and CSS custom properties available for the `m3e-option-panel` component.
|
|
124
|
+
|
|
125
|
+
#### ๐ Events
|
|
126
|
+
|
|
127
|
+
| Event | Description |
|
|
128
|
+
| -------------- | ---------------------------------------------- |
|
|
129
|
+
| `beforetoggle` | Dispatched before the toggle state changes. |
|
|
130
|
+
| `toggle` | Dispatched after the toggle state has changed. |
|
|
131
|
+
|
|
132
|
+
#### ๐งฉ Slots
|
|
133
|
+
|
|
134
|
+
| Slot | Description |
|
|
135
|
+
| ----------- | --------------------------------- |
|
|
136
|
+
| _(default)_ | Renders the contents of the list. |
|
|
137
|
+
|
|
138
|
+
#### ๐๏ธ CSS Custom Properties
|
|
139
|
+
|
|
140
|
+
| Property | Description |
|
|
141
|
+
| -------------------------------------------- | ------------------------------------------------------- |
|
|
142
|
+
| `--m3e-option-panel-container-shape` | Controls the corner radius of the menu container. |
|
|
143
|
+
| `--m3e-option-panel-container-min-width` | Minimum width of the menu container. |
|
|
144
|
+
| `--m3e-option-panel-container-max-width` | Maximum width of the menu container. |
|
|
145
|
+
| `--m3e-option-panel-container-max-height` | Maximum height of the menu container. |
|
|
146
|
+
| `--m3e-option-panel-container-padding-block` | Vertical padding inside the menu container. |
|
|
147
|
+
| `--m3e-option-panel-container-color` | Background color of the menu container. |
|
|
148
|
+
| `--m3e-option-panel-container-elevation` | Box shadow elevation of the menu container. |
|
|
149
|
+
| `--m3e-option-panel-divider-spacing` | Vertical spacing around slotted `m3e-divider` elements. |
|
|
150
|
+
|
|
151
|
+
### ๐๏ธ m3e-optgroup
|
|
152
|
+
|
|
153
|
+
This section details the attributes, slots, and CSS custom properties available for the `m3e-optgroup` component.
|
|
154
|
+
|
|
155
|
+
#### ๐งฉ Slots
|
|
156
|
+
|
|
157
|
+
| Slot | Description |
|
|
158
|
+
| ----------- | --------------------------------- |
|
|
159
|
+
| _(default)_ | Renders the options of the group. |
|
|
160
|
+
| `label` | Renders the label of the group. |
|
|
161
|
+
|
|
162
|
+
#### ๐๏ธ CSS Custom Properties
|
|
163
|
+
|
|
164
|
+
| Property | Description |
|
|
165
|
+
| ---------------------------- | ---------------------------------------- |
|
|
166
|
+
| `--m3e-option-height` | The height of the group label container. |
|
|
167
|
+
| `--m3e-option-font-size` | The font size of the group label. |
|
|
168
|
+
| `--m3e-option-font-weight` | The font weight of the group label. |
|
|
169
|
+
| `--m3e-option-line-height` | The line height of the group label. |
|
|
170
|
+
| `--m3e-option-tracking` | The letter spacing of the group label. |
|
|
171
|
+
| `--m3e-option-padding-end` | The right padding of the label. |
|
|
172
|
+
| `--m3e-option-padding-start` | The left padding of the label. |
|
|
173
|
+
| `--m3e-option-color` | The text color of the group label. |
|
|
174
|
+
|
|
175
|
+
## ๐ค Contributing
|
|
176
|
+
|
|
177
|
+
See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
|
|
178
|
+
|
|
179
|
+
## ๐ License
|
|
180
|
+
|
|
181
|
+
This package is licensed under the MIT License.
|
|
@@ -0,0 +1,207 @@
|
|
|
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-option-height",
|
|
7
|
+
"description": "The height of the group label container.",
|
|
8
|
+
"values": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "--m3e-option-font-size",
|
|
12
|
+
"description": "The font size of the group label.",
|
|
13
|
+
"values": []
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "--m3e-option-font-weight",
|
|
17
|
+
"description": "The font weight of the group label.",
|
|
18
|
+
"values": []
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "--m3e-option-line-height",
|
|
22
|
+
"description": "The line height of the group label.",
|
|
23
|
+
"values": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "--m3e-option-tracking",
|
|
27
|
+
"description": "The letter spacing of the group label.",
|
|
28
|
+
"values": []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "--m3e-option-padding-end",
|
|
32
|
+
"description": "The right padding of the label.",
|
|
33
|
+
"values": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "--m3e-option-padding-start",
|
|
37
|
+
"description": "The left padding of the label.",
|
|
38
|
+
"values": []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "--m3e-option-color",
|
|
42
|
+
"description": "The text color of the group label.",
|
|
43
|
+
"values": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "--m3e-option-container-height",
|
|
47
|
+
"description": "The height of the option container.",
|
|
48
|
+
"values": []
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "--m3e-option-color",
|
|
52
|
+
"description": "The text color of the option.",
|
|
53
|
+
"values": []
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "--m3e-option-container-hover-color",
|
|
57
|
+
"description": "The color for the hover state layer.",
|
|
58
|
+
"values": []
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "--m3e-option-container-focus-color",
|
|
62
|
+
"description": "The color for the focus state layer.",
|
|
63
|
+
"values": []
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "--m3e-option-ripple-color",
|
|
67
|
+
"description": "The color of the ripple effect.",
|
|
68
|
+
"values": []
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "--m3e-option-selected-color",
|
|
72
|
+
"description": "The text color when the option is selected.",
|
|
73
|
+
"values": []
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "--m3e-option-selected-container-color",
|
|
77
|
+
"description": "The background color when the option is selected.",
|
|
78
|
+
"values": []
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "--m3e-option-selected-container-hover-color",
|
|
82
|
+
"description": "The hover color for the selected state layer.",
|
|
83
|
+
"values": []
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "--m3e-option-selected-container-focus-color",
|
|
87
|
+
"description": "The focus color for the selected state layer.",
|
|
88
|
+
"values": []
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "--m3e-option-selected-ripple-color",
|
|
92
|
+
"description": "The ripple color when the option is selected.",
|
|
93
|
+
"values": []
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "--m3e-option-disabled-color",
|
|
97
|
+
"description": "The text color when the option is disabled.",
|
|
98
|
+
"values": []
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "--m3e-option-disabled-opacity",
|
|
102
|
+
"description": "The opacity level applied to the disabled text color.",
|
|
103
|
+
"values": []
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "--m3e-option-icon-label-space",
|
|
107
|
+
"description": "The spacing between the icon and label.",
|
|
108
|
+
"values": []
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "--m3e-option-padding-start",
|
|
112
|
+
"description": "The left padding of the option content.",
|
|
113
|
+
"values": []
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "--m3e-option-padding-end",
|
|
117
|
+
"description": "The right padding of the option content.",
|
|
118
|
+
"values": []
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "--m3e-option-label-text-font-size",
|
|
122
|
+
"description": "The font size of the option label.",
|
|
123
|
+
"values": []
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "--m3e-option-label-text-font-weight",
|
|
127
|
+
"description": "The font weight of the option label.",
|
|
128
|
+
"values": []
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "--m3e-option-label-text-line-height",
|
|
132
|
+
"description": "The line height of the option label.",
|
|
133
|
+
"values": []
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "--m3e-option-label-text-tracking",
|
|
137
|
+
"description": "The letter spacing of the option label.",
|
|
138
|
+
"values": []
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "--m3e-option-focus-ring-shape",
|
|
142
|
+
"description": "The corner radius of the focus ring.",
|
|
143
|
+
"values": []
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "--m3e-option-icon-size",
|
|
147
|
+
"description": "The size of the option icons.",
|
|
148
|
+
"values": []
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "--m3e-option-panel-container-shape",
|
|
152
|
+
"description": "Controls the corner radius of the menu container.",
|
|
153
|
+
"values": []
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "--m3e-option-panel-container-min-width",
|
|
157
|
+
"description": "Minimum width of the menu container.",
|
|
158
|
+
"values": []
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "--m3e-option-panel-container-max-width",
|
|
162
|
+
"description": "Maximum width of the menu container.",
|
|
163
|
+
"values": []
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "--m3e-option-panel-container-max-height",
|
|
167
|
+
"description": "Maximum height of the menu container.",
|
|
168
|
+
"values": []
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "--m3e-option-panel-container-padding-block",
|
|
172
|
+
"description": "Vertical padding inside the menu container.",
|
|
173
|
+
"values": []
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "--m3e-option-panel-container-color",
|
|
177
|
+
"description": "Background color of the menu container.",
|
|
178
|
+
"values": []
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "--m3e-option-panel-container-elevation",
|
|
182
|
+
"description": "Box shadow elevation of the menu container.",
|
|
183
|
+
"values": []
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "--m3e-option-panel-divider-spacing",
|
|
187
|
+
"description": "Vertical spacing around slotted `m3e-divider` elements.",
|
|
188
|
+
"values": []
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "--m3e-nav-bar-height",
|
|
192
|
+
"description": "Height of the navigation bar.",
|
|
193
|
+
"values": []
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"name": "--m3e-nav-bar-container-color",
|
|
197
|
+
"description": "Background color of the navigation bar container.",
|
|
198
|
+
"values": []
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "--m3e-nav-bar-vertical-item-width",
|
|
202
|
+
"description": "Minimum width of vertical nav items.",
|
|
203
|
+
"values": []
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"pseudoElements": []
|
|
207
|
+
}
|