@m3e/form-field 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/NOTICE.md ADDED
@@ -0,0 +1,8 @@
1
+ # NOTICE
2
+
3
+ This package includes code adapted from third-party sources under the MIT license:
4
+
5
+ - Angular Material Form Field
6
+ Source: https://github.com/angular/components
7
+ License: MIT
8
+ Copyright (c) Google LLC
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # @m3e/form-field
2
+
3
+ The `m3e-form-field` component is a semantic, expressive container for form controls that anchors label behavior, subscript messaging, and variant-specific layout. Designed according to Material Design 3 guidelines, it supports two visual variants—`outlined` and `filled`—each with dynamic elevation, shape transitions, and adaptive color theming. The component responds to control state changes (focus, hover, press, disabled, invalid) with smooth motion and semantic clarity, ensuring visual hierarchy and emotional resonance.
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/form-field
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/form-field`, 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/form-field/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/form-field/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/form-field/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-form-field` — A container for form controls that applies Material Design styling and behavior.
58
+
59
+ ## 🧪 Examples
60
+
61
+ The following example illustrates a basic usage of the `m3e-form-field`.
62
+
63
+ ```html
64
+ <m3e-form-field>
65
+ <label slot="label" for="field">Text field</label>
66
+ <input id="field" />
67
+ </m3e-form-field>
68
+ ```
69
+
70
+ ## 📖 API Reference
71
+
72
+ This section details the attributes, slots and CSS custom properties available for the `m3e-form-field` component.
73
+
74
+ ### ⚙️ Attributes
75
+
76
+ | Attribute | Type | Default | Description |
77
+ | ---------------------- | ----------------------------------- | ------------ | ----------------------------------------------------------------------- |
78
+ | `variant` | `"filled"` \| `"outlined"` | `"outlined"` | The appearance variant of the field. |
79
+ | `hide-required-marker` | `boolean` | `false` | Whether the required marker should be hidden. |
80
+ | `hide-subscript` | `"always"` \| `"auto"` \| `"never"` | `"auto"` | Whether subscript content is hidden. |
81
+ | `float-label` | `"always"` \| `"auto"` | `"auto"` | Specifies whether the label should float always or only when necessary. |
82
+
83
+ ### 🧩 Slots
84
+
85
+ | Slot | Description |
86
+ | ------------- | --------------------------------------------------------------------------- |
87
+ | _(default)_ | Renders the form control (e.g. `<input>`, `<select>`, or custom control). |
88
+ | `prefix` | Renders visual content before the control (e.g. icons, avatars, tokens). |
89
+ | `prefix-text` | Renders plain text before the control, aligned with the input baseline. |
90
+ | `suffix` | Renders visual content after the control (e.g. icons, buttons, indicators). |
91
+ | `suffix-text` | Renders plain text after the control, aligned with the input baseline. |
92
+ | `hint` | Renders hint text in the subscript area when the control is valid. |
93
+ | `error` | Renders error text in the subscript area when the control is invalid. |
94
+
95
+ #### 🧠 Notes
96
+
97
+ - Only one control should be slotted at a time.
98
+ - `hint` and `error` slots are mutually exclusive based on control validity.
99
+ - Prefix/suffix slots support both decorative and interactive content.
100
+ - Floating label behavior is automatically coordinated with control state and value.
101
+
102
+ ### 🎛️ CSS Custom Properties
103
+
104
+ | Property | Description |
105
+ | --------------------------------------------- | ------------------------------------------------- |
106
+ | `--m3e-form-field-font-size` | Font size for the form field container text. |
107
+ | `--m3e-form-field-font-weight` | Font weight for the form field container text. |
108
+ | `--m3e-form-field-line-height` | Line height for the form field container text. |
109
+ | `--m3e-form-field-tracking` | Letter spacing for the form field container text. |
110
+ | `--m3e-form-field-label-font-size` | Font size for the floating label. |
111
+ | `--m3e-form-field-label-font-weight` | Font weight for the floating label. |
112
+ | `--m3e-form-field-label-line-height` | Line height for the floating label. |
113
+ | `--m3e-form-field-label-tracking` | Letter spacing for the floating label. |
114
+ | `--m3e-form-field-subscript-font-size` | Font size for hint and error text. |
115
+ | `--m3e-form-field-subscript-font-weight` | Font weight for hint and error text. |
116
+ | `--m3e-form-field-subscript-line-height` | Line height for hint and error text. |
117
+ | `--m3e-form-field-subscript-tracking` | Letter spacing for hint and error text. |
118
+ | `--m3e-form-field-color` | Text color for the form field container. |
119
+ | `--m3e-form-field-subscript-color` | Color for hint and error text. |
120
+ | `--m3e-form-field-invalid-color` | Color used when the control is invalid. |
121
+ | `--m3e-form-field-focused-outline-color` | Outline color when focused. |
122
+ | `--m3e-form-field-focused-color` | Label color when focused. |
123
+ | `--m3e-form-field-outline-color` | Outline color in outlined variant. |
124
+ | `--m3e-form-field-container-color` | Background color in filled variant. |
125
+ | `--m3e-form-field-hover-container-color` | Hover background color in filled variant. |
126
+ | `--m3e-form-field-width` | Width of the form field container. |
127
+ | `--m3e-form-field-icon-size` | Size of prefix and suffix icons. |
128
+ | `--m3e-outlined-form-field-container-shape` | Corner radius for outlined container. |
129
+ | `--m3e-form-field-container-shape` | Corner radius for filled container. |
130
+ | `--m3e-form-field-hover-container-opacity` | Opacity for hover background in filled variant. |
131
+ | `--m3e-form-field-disabled-opacity` | Opacity for disabled text. |
132
+ | `--m3e-form-field-disabled-container-opacity` | Opacity for disabled container background. |
133
+
134
+ ## 🤝 Contributing
135
+
136
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
137
+
138
+ ## 📄 License
139
+
140
+ 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,116 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Form Field for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Form Field 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-form-field variant="outlined">
43
+ <label slot="label" for="fld1">Outlined Field</label>
44
+ <input autocomplete="off" id="fld1" />
45
+ </m3e-form-field>
46
+ <br />
47
+ <m3e-form-field variant="filled">
48
+ <label slot="label" for="fld2">Filled Field</label>
49
+ <input autocomplete="off" id="fld2" />
50
+ </m3e-form-field>
51
+ <br />
52
+ <m3e-form-field float-label="always">
53
+ <label slot="label" for="fld3">Always float label</label>
54
+ <input autocomplete="off" id="fld3" />
55
+ </m3e-form-field>
56
+ <br />
57
+ <m3e-form-field>
58
+ <label slot="label" for="fld4">With hint text (auto)</label>
59
+ <input autocomplete="off" id="fld4" />
60
+ <span slot="hint">Hint text</span>
61
+ </m3e-form-field>
62
+ <br />
63
+ <m3e-form-field>
64
+ <label slot="label" for="fld5">Hide subscript auto</label>
65
+ <input autocomplete="off" id="fld5" />
66
+ <span slot="hint">Hint text</span>
67
+ </m3e-form-field>
68
+ <br />
69
+ <m3e-form-field hide-subscript="never">
70
+ <label slot="label" for="fld6">Hide subscript never</label>
71
+ <input autocomplete="off" id="fld6" />
72
+ <span slot="hint">Hint text</span>
73
+ </m3e-form-field>
74
+ <br /><br />
75
+ <m3e-form-field hide-subscript="always">
76
+ <label slot="label" for="fld7">Hide subscript always</label>
77
+ <input autocomplete="off" id="fld7" />
78
+ <span slot="hint">Hint text</span>
79
+ </m3e-form-field>
80
+ <br /><br />
81
+ <m3e-form-field style="--md-sys-density-scale: -1">
82
+ <label slot="label" for="fld8">Outlined comfortable density</label>
83
+ <input autocomplete="off" id="fld8" />
84
+ <span slot="hint">Hint text</span>
85
+ </m3e-form-field>
86
+ <m3e-form-field variant="filled" style="--md-sys-density-scale: -1">
87
+ <label slot="label" for="fld9">Filled comfortable density</label>
88
+ <input autocomplete="off" id="fld9" />
89
+ <span slot="hint">Hint text</span>
90
+ </m3e-form-field>
91
+ <br />
92
+ <m3e-form-field style="--md-sys-density-scale: -2">
93
+ <label slot="label" for="fld10">Outlined compact density</label>
94
+ <input autocomplete="off" id="fld10" />
95
+ <span slot="hint">Hint text</span>
96
+ </m3e-form-field>
97
+ <m3e-form-field variant="filled" style="--md-sys-density-scale: -2">
98
+ <label slot="label" for="fld11">Filled compact density</label>
99
+ <input autocomplete="off" id="fld11" />
100
+ <span slot="hint">Hint text</span>
101
+ </m3e-form-field>
102
+ <br /><br />
103
+ <m3e-form-field>
104
+ <label slot="label" for="fld12">Required field</label>
105
+ <input required autocomplete="off" id="fld12" />
106
+ <span slot="hint">Required</span>
107
+ </m3e-form-field>
108
+ <br /><br />
109
+ <m3e-form-field>
110
+ <label slot="label" for="fld13">Disabled field</label>
111
+ <input disabled autocomplete="off" id="fld13" value="Sample value" />
112
+ <span slot="hint">Disabled</span>
113
+ </m3e-form-field>
114
+ </m3e-theme>
115
+ </body>
116
+ </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-form-field-font-size",
7
+ "description": "Font size for the form field container text.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-form-field-font-weight",
12
+ "description": "Font weight for the form field container text.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-form-field-line-height",
17
+ "description": "Line height for the form field container text.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-form-field-tracking",
22
+ "description": "Letter spacing for the form field container text.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-form-field-label-font-size",
27
+ "description": "Font size for the floating label.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-form-field-label-font-weight",
32
+ "description": "Font weight for the floating label.",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-form-field-label-line-height",
37
+ "description": "Line height for the floating label.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-form-field-label-tracking",
42
+ "description": "Letter spacing for the floating label.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-form-field-subscript-font-size",
47
+ "description": "Font size for hint and error text.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-form-field-subscript-font-weight",
52
+ "description": "Font weight for hint and error text.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-form-field-subscript-line-height",
57
+ "description": "Line height for hint and error text.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-form-field-subscript-tracking",
62
+ "description": "Letter spacing for hint and error text.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-form-field-color",
67
+ "description": "Text color for the form field container.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-form-field-subscript-color",
72
+ "description": "Color for hint and error text.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-form-field-invalid-color",
77
+ "description": "Color used when the control is invalid.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-form-field-focused-outline-color",
82
+ "description": "Outline color when focused.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-form-field-focused-color",
87
+ "description": "Label color when focused.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-form-field-outline-color",
92
+ "description": "Outline color in outlined variant.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-form-field-container-color",
97
+ "description": "Background color in filled variant.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-form-field-hover-container-color",
102
+ "description": "Hover background color in filled variant.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-form-field-width",
107
+ "description": "Width of the form field container.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-form-field-icon-size",
112
+ "description": "Size of prefix and suffix icons.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-outlined-form-field-container-shape",
117
+ "description": "Corner radius for outlined container.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-form-field-container-shape",
122
+ "description": "Corner radius for filled container.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-form-field-hover-container-opacity",
127
+ "description": "Opacity for hover background in filled variant.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-form-field-disabled-opacity",
132
+ "description": "Opacity for disabled text.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-form-field-disabled-container-opacity",
137
+ "description": "Opacity for disabled container background.",
138
+ "values": []
139
+ }
140
+ ],
141
+ "pseudoElements": []
142
+ }