@m3e/checkbox 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,135 @@
1
+ # @m3e/checkbox
2
+
3
+ The `m3e-checkbox` component enables users to select one or more options from a set. It supports selected, unselected, and indeterminate states, and communicates selection through visual cues and accessible semantics. This component reflects user intent, form participation, and validation feedback, adapting to disabled and required contexts. It emits `input` and `change` events to signal state transitions and integrates with form submission via `name` and `value`.
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/checkbox
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/checkbox`, 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/checkbox/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/checkbox/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/checkbox/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
+ }
48
+ }
49
+ </script>
50
+ ```
51
+
52
+ > For production, use index.min.js for faster load times.
53
+
54
+ ## ๐Ÿ—‚๏ธ Elements
55
+
56
+ - `m3e-checkbox` โ€” A checkbox that allows a user to select one or more options from a limited number of choices.
57
+
58
+ ## ๐Ÿงช Examples
59
+
60
+ The following example illustrates wrapping a `m3e-checkbox` within a `label`.
61
+
62
+ ```html
63
+ <label>
64
+ <m3e-checkbox></m3e-checkbox>
65
+ Checkbox label
66
+ </label>
67
+ ```
68
+
69
+ The next example illustrates use of the `for` attribute to label a checkbox.
70
+
71
+ ```html
72
+ <m3e-checkbox id="chk"></m3e-checkbox><label for="chk">Checkbox label </label>
73
+ ```
74
+
75
+ ## ๐Ÿ“– API Reference
76
+
77
+ This section details the attributes, events and CSS custom properties available for the `m3e-checkbox` component.
78
+
79
+ ### โš™๏ธ Attributes
80
+
81
+ | Attribute | Type | Default | Description |
82
+ | --------------- | --------- | ------- | ------------------------------------------------------------------------- |
83
+ | `checked` | `boolean` | `false` | Whether the element is checked. |
84
+ | `disabled` | `boolean` | `false` | Whether the element is disabled. |
85
+ | `indeterminate` | `boolean` | `false` | Whether the element's checked state is indeterminate. |
86
+ | `name` | `string` | | The name that identifies the element when submitting the associated form. |
87
+ | `required` | `boolean` | `false` | Whether the element is required. |
88
+ | `value` | `string` | `"on"` | A string representing the value of the checkbox. |
89
+
90
+ #### ๐Ÿ”” Events
91
+
92
+ | Event | Description |
93
+ | -------- | --------------------------------------- |
94
+ | `input` | Emitted when the checked state changes. |
95
+ | `change` | Emitted when the checked state changes. |
96
+
97
+ ### ๐ŸŽ›๏ธ CSS Custom Properties
98
+
99
+ | Property | Description |
100
+ | ---------------------------------------------------- | ------------------------------------------------ |
101
+ | `--m3e-checkbox-icon-size` | Size of the checkbox icon inside the container. |
102
+ | `--m3e-checkbox-container-size` | Base size of the checkbox container. |
103
+ | `--m3e-checkbox-container-shape` | Border radius of the icon container. |
104
+ | `--m3e-checkbox-unselected-outline-thickness` | Border thickness for unselected state. |
105
+ | `--m3e-checkbox-unselected-outline-color` | Border color for unselected state. |
106
+ | `--m3e-checkbox-unselected-hover-outline-color` | Border color on hover when unselected. |
107
+ | `--m3e-checkbox-unselected-disabled-outline-color` | Base color for disabled unselected outline. |
108
+ | `--m3e-checkbox-unselected-disabled-outline-opacity` | Opacity for disabled unselected outline. |
109
+ | `--m3e-checkbox-unselected-error-outline-color` | Border color for invalid unselected state. |
110
+ | `--m3e-checkbox-selected-container-color` | Background color for selected container. |
111
+ | `--m3e-checkbox-selected-icon-color` | Icon color for selected state. |
112
+ | `--m3e-checkbox-selected-disabled-container-color` | Base color for disabled selected container. |
113
+ | `--m3e-checkbox-selected-disabled-container-opacity` | Opacity for disabled selected container. |
114
+ | `--m3e-checkbox-selected-disabled-icon-color` | Base color for disabled selected icon. |
115
+ | `--m3e-checkbox-selected-disabled-icon-opacity` | Opacity for disabled selected icon. |
116
+ | `--m3e-checkbox-unselected-hover-color` | Ripple hover color for unselected state. |
117
+ | `--m3e-checkbox-unselected-focus-color` | Ripple focus color for unselected state. |
118
+ | `--m3e-checkbox-unselected-ripple-color` | Ripple base color for unselected state. |
119
+ | `--m3e-checkbox-selected-hover-color` | Ripple hover color for selected state. |
120
+ | `--m3e-checkbox-selected-focus-color` | Ripple focus color for selected state. |
121
+ | `--m3e-checkbox-selected-ripple-color` | Ripple base color for selected state. |
122
+ | `--m3e-checkbox-unselected-error-hover-color` | Ripple hover color for invalid unselected state. |
123
+ | `--m3e-checkbox-unselected-error-focus-color` | Ripple focus color for invalid unselected state. |
124
+ | `--m3e-checkbox-unselected-error-ripple-color` | Ripple base color for invalid unselected state. |
125
+ | `--m3e-checkbox-selected-error-hover-color` | Ripple hover color for invalid selected state. |
126
+ | `--m3e-checkbox-selected-error-focus-color` | Ripple focus color for invalid selected state. |
127
+ | `--m3e-checkbox-selected-error-ripple-color` | Ripple base color for invalid selected state. |
128
+
129
+ ## ๐Ÿค Contributing
130
+
131
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
132
+
133
+ ## ๐Ÿ“„ License
134
+
135
+ 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,74 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Checkbox for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Checkbox 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
+ }
25
+ }
26
+ </script>
27
+ <script type="module" src="../../theme/dist/index.min.js"></script>
28
+ <script type="module" src="../dist/index.min.js"></script>
29
+ <style>
30
+ body {
31
+ font-family: "Roboto";
32
+ }
33
+ *:not(:defined) {
34
+ display: none;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <m3e-theme strong-focus>
40
+ <label>
41
+ <m3e-checkbox></m3e-checkbox>
42
+ Checkbox label
43
+ </label>
44
+ <br />
45
+ <m3e-checkbox id="chk"></m3e-checkbox>
46
+ <label for="chk">Checkbox label </label>
47
+ <br />
48
+ <label>
49
+ <m3e-checkbox indeterminate></m3e-checkbox>
50
+ Indeterminate checkbox
51
+ </label>
52
+ <br />
53
+ <label>
54
+ <m3e-checkbox required></m3e-checkbox>
55
+ Required checkbox
56
+ </label>
57
+ <br />
58
+ <label>
59
+ <m3e-checkbox disabled></m3e-checkbox>
60
+ Disabled checkbox
61
+ </label>
62
+ <br />
63
+ <label>
64
+ <m3e-checkbox disabled checked></m3e-checkbox>
65
+ Disabled checked checkbox
66
+ </label>
67
+ <br />
68
+ <label>
69
+ <m3e-checkbox disabled indeterminate></m3e-checkbox>
70
+ Disabled indeterminate checkbox
71
+ </label>
72
+ </m3e-theme>
73
+ </body>
74
+ </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-checkbox-icon-size",
7
+ "description": "Size of the checkbox icon inside the container.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-checkbox-container-size",
12
+ "description": "Base size of the checkbox container.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-checkbox-container-shape",
17
+ "description": "Border radius of the icon container.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-checkbox-unselected-outline-thickness",
22
+ "description": "Border thickness for unselected state.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-checkbox-unselected-outline-color",
27
+ "description": "Border color for unselected state.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-checkbox-unselected-hover-outline-color",
32
+ "description": "Border color on hover when unselected.",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-checkbox-unselected-disabled-outline-color",
37
+ "description": "Base color for disabled unselected outline.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-checkbox-unselected-disabled-outline-opacity",
42
+ "description": "Opacity for disabled unselected outline.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-checkbox-unselected-error-outline-color",
47
+ "description": "Border color for invalid unselected state.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-checkbox-selected-container-color",
52
+ "description": "Background color for selected container.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-checkbox-selected-icon-color",
57
+ "description": "Icon color for selected state.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-checkbox-selected-disabled-container-color",
62
+ "description": "Base color for disabled selected container.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-checkbox-selected-disabled-container-opacity",
67
+ "description": "Opacity for disabled selected container.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-checkbox-selected-disabled-icon-color",
72
+ "description": "Base color for disabled selected icon.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-checkbox-selected-disabled-icon-opacity",
77
+ "description": "Opacity for disabled selected icon.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-checkbox-unselected-hover-color",
82
+ "description": "Ripple hover color for unselected state.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-checkbox-unselected-focus-color",
87
+ "description": "Ripple focus color for unselected state.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-checkbox-unselected-ripple-color",
92
+ "description": "Ripple base color for unselected state.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-checkbox-selected-hover-color",
97
+ "description": "Ripple hover color for selected state.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-checkbox-selected-focus-color",
102
+ "description": "Ripple focus color for selected state.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-checkbox-selected-ripple-color",
107
+ "description": "Ripple base color for selected state.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-checkbox-unselected-error-hover-color",
112
+ "description": "Ripple hover color for invalid unselected state.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-checkbox-unselected-error-focus-color",
117
+ "description": "Ripple focus color for invalid unselected state.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-checkbox-unselected-error-ripple-color",
122
+ "description": "Ripple base color for invalid unselected state.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-checkbox-selected-error-hover-color",
127
+ "description": "Ripple hover color for invalid selected state.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-checkbox-selected-error-focus-color",
132
+ "description": "Ripple focus color for invalid selected state.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-checkbox-selected-error-ripple-color",
137
+ "description": "Ripple base color for invalid selected state.",
138
+ "values": []
139
+ }
140
+ ],
141
+ "pseudoElements": []
142
+ }