@m3e/expansion-panel 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.
Files changed (48) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +175 -0
  3. package/cem.config.mjs +16 -0
  4. package/demo/index.html +60 -0
  5. package/dist/css-custom-data.json +172 -0
  6. package/dist/custom-elements.json +787 -0
  7. package/dist/html-custom-data.json +72 -0
  8. package/dist/index.js +690 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.min.js +248 -0
  11. package/dist/index.min.js.map +1 -0
  12. package/dist/src/AccordionElement.d.ts +56 -0
  13. package/dist/src/AccordionElement.d.ts.map +1 -0
  14. package/dist/src/ExpansionHeaderElement.d.ts +60 -0
  15. package/dist/src/ExpansionHeaderElement.d.ts.map +1 -0
  16. package/dist/src/ExpansionPanelElement.d.ts +121 -0
  17. package/dist/src/ExpansionPanelElement.d.ts.map +1 -0
  18. package/dist/src/ExpansionToggleDirection.d.ts +3 -0
  19. package/dist/src/ExpansionToggleDirection.d.ts.map +1 -0
  20. package/dist/src/ExpansionTogglePosition.d.ts +3 -0
  21. package/dist/src/ExpansionTogglePosition.d.ts.map +1 -0
  22. package/dist/src/index.d.ts +6 -0
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/styles/ExpansionHeaderStyle.d.ts +6 -0
  25. package/dist/src/styles/ExpansionHeaderStyle.d.ts.map +1 -0
  26. package/dist/src/styles/ExpansionHeaderToken.d.ts +17 -0
  27. package/dist/src/styles/ExpansionHeaderToken.d.ts.map +1 -0
  28. package/dist/src/styles/ExpansionPanelStyle.d.ts +6 -0
  29. package/dist/src/styles/ExpansionPanelStyle.d.ts.map +1 -0
  30. package/dist/src/styles/ExpansionPanelToken.d.ts +21 -0
  31. package/dist/src/styles/ExpansionPanelToken.d.ts.map +1 -0
  32. package/dist/src/styles/index.d.ts +3 -0
  33. package/dist/src/styles/index.d.ts.map +1 -0
  34. package/eslint.config.mjs +13 -0
  35. package/package.json +49 -0
  36. package/rollup.config.js +32 -0
  37. package/src/AccordionElement.ts +115 -0
  38. package/src/ExpansionHeaderElement.ts +99 -0
  39. package/src/ExpansionPanelElement.ts +260 -0
  40. package/src/ExpansionToggleDirection.ts +2 -0
  41. package/src/ExpansionTogglePosition.ts +2 -0
  42. package/src/index.ts +5 -0
  43. package/src/styles/ExpansionHeaderStyle.ts +85 -0
  44. package/src/styles/ExpansionHeaderToken.ts +24 -0
  45. package/src/styles/ExpansionPanelStyle.ts +85 -0
  46. package/src/styles/ExpansionPanelToken.ts +28 -0
  47. package/src/styles/index.ts +2 -0
  48. package/tsconfig.json +9 -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,175 @@
1
+ # @m3e/expansion-panel
2
+
3
+ The `@m3e/expansion-panel` package provides expressive, accessible components for organizing content in collapsible sections and coordinated groups. It includes:
4
+
5
+ - **`m3e-expansion-panel`** — An accessible, animated details-summary view for organizing content in collapsible sections. Supports custom header, content, actions, and toggle icon slots, configurable toggle position and direction, open/close states, lifecycle events, and rich theming via CSS custom properties for elevation, shape, spacing, and color.
6
+
7
+ - **`m3e-accordion`** — Organizes multiple expansion panels into a coordinated, accessible group. Supports single or multiple open panels via the `multi` attribute, expressive theming and shape control for grouped layouts, and manages open/close state across child panels for interactive disclosure patterns.
8
+
9
+ > **Part of the [M3E](../../README.md) monorepo**
10
+ > This package is maintained within the unified M3E repository, which provides a suite of Material 3 web components.
11
+
12
+ ## 📦 Installation
13
+
14
+ ```bash
15
+ npm install @m3e/expansion-panel
16
+ ```
17
+
18
+ ## 💻 Editor Integration
19
+
20
+ This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
21
+
22
+ ### Visual Studio Code
23
+
24
+ To enable autocomplete and hover documentation for `@m3e/expansion-panel`, 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.
25
+
26
+ Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
27
+
28
+ ```json
29
+ {
30
+ "html.customData": ["./node_modules/@m3e/expansion-panel/dist/html-custom-data.json"],
31
+ "css.customData": ["./node_modules/@m3e/expansion-panel/dist/css-custom-data.json"]
32
+ }
33
+ ```
34
+
35
+ ## 🚀 Browser Usage
36
+
37
+ 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.
38
+
39
+ ```html
40
+ <script type="module" src="/node_modules/@m3e/expansion-panel/dist/index.js"></script>
41
+ ```
42
+
43
+ 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.
44
+
45
+ ```html
46
+ <script type="importmap">
47
+ {
48
+ "imports": {
49
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
50
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js"
51
+ }
52
+ }
53
+ </script>
54
+ ```
55
+
56
+ > For production, use index.min.js for faster load times.
57
+
58
+ ## 🗂️ Elements
59
+
60
+ - `m3e-expansion-panel` — An expandable details-summary view.
61
+ - `m3e-accordion` — Combines multiple expansion panels in to an accordion.
62
+
63
+ ## 🧪 Examples
64
+
65
+ The following example illustrates the basic use of the `m3e-accordion` and `m3e-expansion-panel` components.
66
+
67
+ ```html
68
+ <m3e-accordion>
69
+ <m3e-expansion-panel>
70
+ <span slot="header">Panel 1</span>
71
+ I am content for the first expansion panel
72
+ </m3e-expansion-panel>
73
+ <m3e-expansion-panel>
74
+ <span slot="header">Panel 2</span>
75
+ I am content for the second expansion panel
76
+ </m3e-expansion-panel>
77
+ </m3e-accordion>
78
+ ```
79
+
80
+ ## 📖 API Reference
81
+
82
+ ### 🗂️ Accordion
83
+
84
+ This section details the attributes, slots and CSS custom properties available for the `m3e-accordion` component.
85
+
86
+ #### ⚙️ Attributes
87
+
88
+ | Attribute | Type | Default | Description |
89
+ | --------- | --------- | ------- | --------------------------------------------------------------- |
90
+ | `multi` | `boolean` | `false` | Whether multiple expansion panels can be open at the same time. |
91
+
92
+ #### 🧩 Slots
93
+
94
+ | Slot | Description |
95
+ | ----------- | ------------------------------------ |
96
+ | _(default)_ | Renders the panels of the accordion. |
97
+
98
+ #### 🎛️ CSS Custom Properties (applies to slotted panels)
99
+
100
+ | Property | Description |
101
+ | --------------------------------------- | ------------------------------------ |
102
+ | `--m3e-expansion-panel-container-color` | Background color for grouped panels. |
103
+ | `--m3e-expansion-panel-elevation` | Elevation for grouped panels. |
104
+ | `--m3e-expansion-panel-open-shape` | Shape for open grouped panels. |
105
+ | `--m3e-expansion-panel-shape` | Shape for closed grouped panels. |
106
+
107
+ ---
108
+
109
+ ### 🗂️ Expansion Panel
110
+
111
+ This section details the attributes, events, slots and CSS custom properties available for the `m3e-expansion-panel` component.
112
+
113
+ #### 🏷️ Attributes
114
+
115
+ | Attribute | Type | Default | Description |
116
+ | ------------------ | ------------------ | ------- | -------------------------------------- |
117
+ | `disabled` | `boolean` | `false` | Whether the element is disabled. |
118
+ | `hide-toggle` | `boolean` | `false` | Whether to hide the expansion toggle. |
119
+ | `open` | `boolean` | `false` | Whether the panel is expanded. |
120
+ | `toggle-direction` | `"start" \| "end"` | `"end"` | The direction of the expansion toggle. |
121
+ | `toggle-position` | `"start" \| "end"` | `"end"` | The position of the expansion toggle. |
122
+
123
+ #### 🔔 Events
124
+
125
+ | Event Name | Description |
126
+ | ---------- | ------------------------------------------------- |
127
+ | `opening` | Emitted when the expansion panel begins to open. |
128
+ | `opened` | Emitted when the expansion panel has opened. |
129
+ | `closing` | Emitted when the expansion panel begins to close. |
130
+ | `closed` | Emitted when the expansion panel has closed. |
131
+
132
+ #### 🧩 Slots
133
+
134
+ | Slot | Description |
135
+ | ------------- | ------------------------------------- |
136
+ | _(default)_ | Renders the detail of the panel. |
137
+ | `header` | Renders the header content. |
138
+ | `actions` | Renders the actions bar of the panel. |
139
+ | `toggle-icon` | Renders the expansion toggle icon. |
140
+
141
+ #### 🎛️ CSS Custom Properties
142
+
143
+ | Property | Description |
144
+ | ------------------------------------------------- | --------------------------------------------------- |
145
+ | `--m3e-expansion-header-collapsed-height` | Height of the header when collapsed. |
146
+ | `--m3e-expansion-header-expanded-height` | Height of the header when expanded. |
147
+ | `--m3e-expansion-header-padding-left` | Left padding inside the header. |
148
+ | `--m3e-expansion-header-padding-right` | Right padding inside the header. |
149
+ | `--m3e-expansion-header-spacing` | Spacing between header elements. |
150
+ | `--m3e-expansion-header-toggle-icon-size` | Size of the toggle icon. |
151
+ | `--m3e-expansion-header-font-size` | Font size of the header text. |
152
+ | `--m3e-expansion-header-font-weight` | Font weight of the header text. |
153
+ | `--m3e-expansion-header-line-height` | Line height of the header text. |
154
+ | `--m3e-expansion-header-tracking` | Letter spacing of the header text. |
155
+ | `--m3e-expansion-panel-text-color` | Color of the panel's text content. |
156
+ | `--m3e-expansion-panel-disabled-text-color` | Color of the panel's text content, when disabled. |
157
+ | `--m3e-expansion-panel-disabled-text-opacity` | Opacity of the panel's text content, when disabled. |
158
+ | `--m3e-expansion-panel-container-color` | Background color of the panel container. |
159
+ | `--m3e-expansion-panel-elevation` | Elevation level when collapsed. |
160
+ | `--m3e-expansion-panel-shape` | Shape (e.g. border radius) when collapsed. |
161
+ | `--m3e-expansion-panel-open-elevation` | Elevation level when expanded. |
162
+ | `--m3e-expansion-panel-open-shape` | Shape (e.g. border radius) when expanded. |
163
+ | `--m3e-expansion-panel-content-padding` | Padding around the content area. |
164
+ | `--m3e-expansion-panel-actions-spacing` | Spacing between action buttons/elements. |
165
+ | `--m3e-expansion-panel-actions-padding` | Padding around the actions section. |
166
+ | `--m3e-expansion-panel-actions-divider-thickness` | Thickness of the divider above actions. |
167
+ | `--m3e-expansion-panel-actions-divider-color` | Color of the divider above actions. |
168
+
169
+ ## 🤝 Contributing
170
+
171
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
172
+
173
+ ## 📄 License
174
+
175
+ 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>Expansion Panel for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Expansion Panel 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="../../button/dist/index.min.js"></script>
28
+ <script type="module" src="../../theme/dist/index.min.js"></script>
29
+ <script type="module" src="../dist/index.min.js"></script>
30
+ <style>
31
+ body {
32
+ font-family: "Roboto";
33
+ }
34
+ *:not(:defined) {
35
+ display: none;
36
+ }
37
+ </style>
38
+ </head>
39
+ <body>
40
+ <m3e-theme strong-focus>
41
+ <m3e-accordion>
42
+ <m3e-expansion-panel>
43
+ <span slot="header">Expansion panel 1 title</span>
44
+ <div>I am content for the first expansion panel</div>
45
+ </m3e-expansion-panel>
46
+ <m3e-expansion-panel disabled>
47
+ <span slot="header">Expansion panel 2 title</span>
48
+ <div>I am content for the second expansion panel</div>
49
+ </m3e-expansion-panel>
50
+ <m3e-expansion-panel>
51
+ <span slot="header">Expansion panel 2 title</span>
52
+ <div>I am content for the third expansion panel</div>
53
+ <div slot="actions">
54
+ <m3e-button>Action</m3e-button>
55
+ </div>
56
+ </m3e-expansion-panel>
57
+ </m3e-accordion>
58
+ </m3e-theme>
59
+ </body>
60
+ </html>
@@ -0,0 +1,172 @@
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-expansion-header-collapsed-height",
7
+ "description": "Height of the header when the panel is collapsed.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-expansion-header-expanded-height",
12
+ "description": "Height of the header when the panel is expanded.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-expansion-header-padding-left",
17
+ "description": "Left padding inside the header.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-expansion-header-padding-right",
22
+ "description": "Right padding inside the header.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-expansion-header-spacing",
27
+ "description": "Spacing between header elements.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-expansion-header-toggle-icon-size",
32
+ "description": "Size of the toggle icon (e.g. chevron).",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-expansion-header-font-size",
37
+ "description": "The font size of the header text.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-expansion-header-font-weight",
42
+ "description": "The font weight of the header text.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-expansion-header-line-height",
47
+ "description": "The line height of the header text.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-expansion-header-tracking",
52
+ "description": "Letter spacing (tracking) of the header text.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-expansion-header-collapsed-height",
57
+ "description": "Height of the header when the panel is collapsed.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-expansion-header-expanded-height",
62
+ "description": "Height of the header when the panel is expanded.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-expansion-header-padding-left",
67
+ "description": "Left padding inside the header.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-expansion-header-padding-right",
72
+ "description": "Right padding inside the header.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-expansion-header-spacing",
77
+ "description": "Spacing between header elements.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-expansion-header-toggle-icon-size",
82
+ "description": "Size of the toggle icon (e.g. chevron).",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-expansion-header-font-size",
87
+ "description": "The font size of the header text.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-expansion-header-font-weight",
92
+ "description": "The font weight of the header text.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-expansion-header-line-height",
97
+ "description": "The line height of the header text.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-expansion-header-tracking",
102
+ "description": "Letter spacing (tracking) of the header text.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-expansion-panel-text-color",
107
+ "description": "Color of the panel's text content.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-expansion-panel-disabled-text-color",
112
+ "description": "Color of the panel's text content, when disabled.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-expansion-panel-disabled-text-opacity",
117
+ "description": "Opacity of the panel's text content, when disabled.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-expansion-panel-container-color",
122
+ "description": "Background color of the panel container.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-expansion-panel-elevation",
127
+ "description": "Elevation level when the panel is collapsed.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-expansion-panel-shape",
132
+ "description": "Shape (e.g. border radius) of the panel when collapsed.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-expansion-panel-open-elevation",
137
+ "description": "Elevation level when the panel is expanded.",
138
+ "values": []
139
+ },
140
+ {
141
+ "name": "--m3e-expansion-panel-open-shape",
142
+ "description": "Shape (e.g. border radius) of the panel when expanded.",
143
+ "values": []
144
+ },
145
+ {
146
+ "name": "--m3e-expansion-panel-content-padding",
147
+ "description": "Padding around the panel's content area.",
148
+ "values": []
149
+ },
150
+ {
151
+ "name": "--m3e-expansion-panel-actions-spacing",
152
+ "description": "Spacing between action buttons or elements.",
153
+ "values": []
154
+ },
155
+ {
156
+ "name": "--m3e-expansion-panel-actions-padding",
157
+ "description": "Padding around the actions section.",
158
+ "values": []
159
+ },
160
+ {
161
+ "name": "--m3e-expansion-panel-actions-divider-thickness",
162
+ "description": "Thickness of the divider above actions.",
163
+ "values": []
164
+ },
165
+ {
166
+ "name": "--m3e-expansion-panel-actions-divider-color",
167
+ "description": "Color of the divider above actions.",
168
+ "values": []
169
+ }
170
+ ],
171
+ "pseudoElements": []
172
+ }