@m3e/dialog 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,143 @@
1
+ # @m3e/dialog
2
+
3
+ The `m3e-dialog` component presents important prompts, alerts, and actions in user flows. Designed according to Material 3 principles, it supports custom header, content, and close icon slots, ARIA accessibility, focus management, and theming via CSS custom properties.
4
+
5
+ ## ๐Ÿ“ฆ Installation
6
+
7
+ ```bash
8
+ npm install @m3e/dialog
9
+ ```
10
+
11
+ ## ๐Ÿ’ป Editor Integration
12
+
13
+ This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
14
+
15
+ ### Visual Studio Code
16
+
17
+ To enable autocomplete and hover documentation for `@m3e/dialog`, 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.
18
+
19
+ Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
20
+
21
+ ```json
22
+ {
23
+ "html.customData": ["./node_modules/@m3e/dialog/dist/html-custom-data.json"],
24
+ "css.customData": ["./node_modules/@m3e/dialog/dist/css-custom-data.json"]
25
+ }
26
+ ```
27
+
28
+ ## ๐Ÿš€ Browser Usage
29
+
30
+ 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.
31
+
32
+ ```html
33
+ <script type="module" src="/node_modules/@m3e/dialog/dist/index.js"></script>
34
+ ```
35
+
36
+ You also need a module script for `@m3e/icon-button` due to it being a dependency.
37
+
38
+ ```html
39
+ <script type="module" src="/node_modules/@m3e/icon-button/dist/index.js"></script>
40
+ ```
41
+
42
+ 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.
43
+
44
+ ```html
45
+ <script type="importmap">
46
+ {
47
+ "imports": {
48
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
49
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js",
50
+ "@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js"
51
+ }
52
+ }
53
+ </script>
54
+ ```
55
+
56
+ > For production, use index.min.js and a11y.min.js for faster load times.
57
+
58
+ ## ๐Ÿ—‚๏ธ Elements
59
+
60
+ - `m3e-dialog` โ€” A Material 3 Expressive dialog for prompts, alerts, and actions.
61
+ - `m3e-dialog-trigger` โ€” An element for opening dialogs by reference (via the `for` attribute).
62
+
63
+ ## ๐Ÿงช Examples
64
+
65
+ The following example illustrates a dialog with a header, content, and actions:
66
+
67
+ ```html
68
+ <m3e-button variant="filled">
69
+ <m3e-dialog-trigger for="dlg">Open Dialog</m3e-dialog-trigger>
70
+ </m3e-button>
71
+ <m3e-dialog id="dlg" dismissible onclosed="console.log(this.returnValue)">
72
+ <span slot="header">Dialog Title</span>
73
+ Dialog content goes here.
74
+ <div slot="actions" end>
75
+ <m3e-button autofocus><m3e-dialog-action return-value="ok">Close</m3e-dialog-action></m3e-button>
76
+ </div>
77
+ </m3e-dialog>
78
+ ```
79
+
80
+ ## ๐Ÿ“– API Reference
81
+
82
+ This section details the attributes, slots, events, and CSS custom properties available for the `m3e-dialog` component.
83
+
84
+ ### โš™๏ธ Attributes
85
+
86
+ | Attribute | Type | Default | Description |
87
+ | --------------- | --------- | --------- | ------------------------------------------------------------------------------------------- |
88
+ | `alert` | `boolean` | `false` | Whether the dialog is an alert. |
89
+ | `close-label` | `string` | `"Close"` | The accessible label given to the button used to dismiss the dialog. |
90
+ | `disable-close` | `boolean` | `false` | Whether users cannot click the backdrop or press ESC to dismiss the dialog. |
91
+ | `dismissible` | `boolean` | `false` | Whether a button is presented that can be used to close the dialog. |
92
+ | `no-focus-trap` | `boolean` | `false` | Whether to disable focus trapping, which keeps keyboard `Tab` navigation within the dialog. |
93
+ | `open` | `boolean` | `false` | Whether the dialog is open. |
94
+
95
+ ### ๐Ÿงฉ Slots
96
+
97
+ | Slot | Description |
98
+ | ------------ | ---------------------------------------- |
99
+ | _(default)_ | Renders the content of the dialog. |
100
+ | `header` | Renders the header of the dialog. |
101
+ | `close-icon` | Renders the icon of the button to close. |
102
+ | `actions` | Renders action buttons for the dialog. |
103
+
104
+ ### ๐Ÿ”” Events
105
+
106
+ | Event | Description |
107
+ | --------- | ---------------------------------------- |
108
+ | `opening` | Emitted when the dialog begins to open. |
109
+ | `opened` | Emitted when the dialog has opened. |
110
+ | `cancel` | Emitted when the dialog is cancelled. |
111
+ | `closing` | Emitted when the dialog begins to close. |
112
+ | `closed` | Emitted when the dialog has closed. |
113
+
114
+ ### ๐ŸŽ›๏ธ CSS Custom Properties
115
+
116
+ | Property | Description |
117
+ | ------------------------------------- | ----------------------------------------- |
118
+ | `--m3e-dialog-shape` | Border radius of the dialog container. |
119
+ | `--m3e-dialog-min-width` | Minimum width of the dialog. |
120
+ | `--m3e-dialog-max-width` | Maximum width of the dialog. |
121
+ | `--m3e-dialog-color` | Foreground color of the dialog. |
122
+ | `--m3e-dialog-container-color` | Background color of the dialog container. |
123
+ | `--m3e-dialog-scrim-color` | Color of the scrim (backdrop overlay). |
124
+ | `--m3e-dialog-scrim-opacity` | Opacity of the scrim when open. |
125
+ | `--m3e-dialog-header-container-color` | Background color of the dialog header. |
126
+ | `--m3e-dialog-header-color` | Foreground color of the dialog header. |
127
+ | `--m3e-dialog-header-font-size` | Font size for the dialog header. |
128
+ | `--m3e-dialog-header-font-weight` | Font weight for the dialog header. |
129
+ | `--m3e-dialog-header-line-height` | Line height for the dialog header. |
130
+ | `--m3e-dialog-header-tracking` | Letter spacing for the dialog header. |
131
+ | `--m3e-dialog-content-color` | Foreground color of the dialog content. |
132
+ | `--m3e-dialog-content-font-size` | Font size for the dialog content. |
133
+ | `--m3e-dialog-content-font-weight` | Font weight for the dialog content. |
134
+ | `--m3e-dialog-content-line-height` | Line height for the dialog content. |
135
+ | `--m3e-dialog-content-tracking` | Letter spacing for the dialog content. |
136
+
137
+ ## ๐Ÿค Contributing
138
+
139
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
140
+
141
+ ## ๐Ÿ“„ License
142
+
143
+ 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>Dialog for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Dialog 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="../../button/dist/index.min.js"></script>
31
+ <script type="module" src="../../icon-button/dist/index.min.js"></script>
32
+ <script type="module" src="../dist/index.min.js"></script>
33
+ <style>
34
+ body {
35
+ font-family: "Roboto";
36
+ }
37
+ *:not(:defined) {
38
+ display: none;
39
+ }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <m3e-theme strong-focus>
44
+ <m3e-button variant="filled">
45
+ <m3e-dialog-trigger for="dlg">Open Dialog</m3e-dialog-trigger>
46
+ </m3e-button>
47
+ <m3e-dialog id="dlg" dismissible onclosed="console.log(this.returnValue)">
48
+ <span slot="header">Lorem ipsum dolor sit amet</span>
49
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
50
+ magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
51
+ consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
52
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
53
+ laborum.
54
+ <div slot="actions" end>
55
+ <m3e-button autofocus><m3e-dialog-action return-value="ok">Close</m3e-dialog-action></m3e-button>
56
+ </div>
57
+ </m3e-dialog>
58
+ </m3e-theme>
59
+ </body>
60
+ </html>
@@ -0,0 +1,97 @@
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-dialog-shape",
7
+ "description": "Border radius of the dialog container.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-dialog-min-width",
12
+ "description": "Minimum width of the dialog.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-dialog-max-width",
17
+ "description": "Maximum width of the dialog.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-dialog-color",
22
+ "description": "Foreground color of the dialog.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-dialog-container-color",
27
+ "description": "Background color of the dialog container.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-dialog-scrim-color",
32
+ "description": "Color of the scrim (backdrop overlay).",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-dialog-scrim-opacity",
37
+ "description": "Opacity of the scrim when open.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-dialog-header-container-color",
42
+ "description": "Background color of the dialog header.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-dialog-header-color",
47
+ "description": "Foreground color of the dialog header.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-dialog-header-font-size",
52
+ "description": "Font size for the dialog header.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-dialog-header-font-weight",
57
+ "description": "Font weight for the dialog header.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-dialog-header-line-height",
62
+ "description": "Line height for the dialog header.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-dialog-header-tracking",
67
+ "description": "Letter spacing for the dialog header.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-dialog-content-color",
72
+ "description": "Foreground color of the dialog content.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-dialog-content-font-size",
77
+ "description": "Font size for the dialog content.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-dialog-content-font-weight",
82
+ "description": "Font weight for the dialog content.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-dialog-content-line-height",
87
+ "description": "Line height for the dialog content.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-dialog-content-tracking",
92
+ "description": "Letter spacing for the dialog content.",
93
+ "values": []
94
+ }
95
+ ],
96
+ "pseudoElements": []
97
+ }