@m3e/autocomplete 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 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,115 @@
1
+ # @m3e/autocomplete
2
+
3
+ The `m3e-autocomplete` component enhances a text input field with a dynamically positioned menu of filterable suggestions. Following Material Design 3 principles, it provides real-time filtering, keyboard navigation, automatic option activation, and text highlighting to guide user selection.
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/autocomplete
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/autocomplete`, 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/autocomplete/dist/html-custom-data.json"],
26
+ "css.customData": ["./node_modules/@m3e/autocomplete/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/autocomplete/dist/index.js"></script>
36
+ ```
37
+
38
+ You also need a module script for `@m3e/option` due to it being a dependency.
39
+
40
+ ```html
41
+ <script type="module" src="/node_modules/@m3e/option/dist/index.js"></script>
42
+ ```
43
+
44
+ In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include additional dependencies.
45
+
46
+ ```html
47
+ <script type="importmap">
48
+ {
49
+ "imports": {
50
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
51
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js",
52
+ "@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js",
53
+ "@m3e/core/anchoring": "/node_modules/@m3e/core/dist/anchoring.js"
54
+ }
55
+ }
56
+ </script>
57
+ ```
58
+
59
+ > For production, use index.min.js, a11y.min.js, and anchoring.min.js for faster load times.
60
+
61
+ ## ๐Ÿ—‚๏ธ Elements
62
+
63
+ - `m3e-autocomplete` โ€” An input enhancement that displays a filtered menu of suggestions, providing real-time filtering and keyboard navigation.
64
+
65
+ ## ๐Ÿงช Example
66
+
67
+ ```html
68
+ <m3e-form-field>
69
+ <label slot="label" for="fruit">Choose your favorite fruit</label>
70
+ <input id="fruit" />
71
+ </m3e-form-field>
72
+ <m3e-autocomplete for="fruit">
73
+ <m3e-option>Apples</m3e-option>
74
+ <m3e-option>Oranges</m3e-option>
75
+ <m3e-option>Bananas</m3e-option>
76
+ <m3e-option>Grapes</m3e-option>
77
+ </m3e-autocomplete>
78
+ ```
79
+
80
+ With auto-activation and required selection:
81
+
82
+ ```html
83
+ <m3e-autocomplete for="fruit" auto-activate required>
84
+ <m3e-option>Apples</m3e-option>
85
+ <m3e-option>Oranges</m3e-option>
86
+ <m3e-option>Bananas</m3e-option>
87
+ <m3e-option>Grapes</m3e-option>
88
+ </m3e-autocomplete>
89
+ ```
90
+
91
+ ## ๐Ÿ“– API Reference
92
+
93
+ This section details the attributes and slots available for the `m3e-autocomplete` component.
94
+
95
+ ### โš™๏ธ Attributes
96
+
97
+ | Attribute | Type | Default | Description |
98
+ | -------------------------- | --------- | ------- | ---------------------------------------------------------------------------------------- |
99
+ | `auto-activate` | `boolean` | `false` | Whether the first option should be automatically activated. |
100
+ | `hide-selection-indicator` | `boolean` | `false` | Whether to hide the selection indicator for options. |
101
+ | `required` | `boolean` | `false` | Whether the user is required to make a selection when interacting with the autocomplete. |
102
+
103
+ ### ๐Ÿงฉ Slots
104
+
105
+ | Slot | Description |
106
+ | ----------- | ------------------------------ |
107
+ | _(default)_ | Renders the options available. |
108
+
109
+ ## ๐Ÿค Contributing
110
+
111
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
112
+
113
+ ## ๐Ÿ“„ License
114
+
115
+ This package is licensed under the MIT License.
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [],
5
+ "pseudoElements": []
6
+ }