@m3e/drawer-container 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 (39) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +139 -0
  3. package/cem.config.mjs +16 -0
  4. package/demo/index.html +88 -0
  5. package/dist/css-custom-data.json +57 -0
  6. package/dist/custom-elements.json +569 -0
  7. package/dist/html-custom-data.json +49 -0
  8. package/dist/index.js +620 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.min.js +209 -0
  11. package/dist/index.min.js.map +1 -0
  12. package/dist/src/DrawerContainerElement.d.ts +105 -0
  13. package/dist/src/DrawerContainerElement.d.ts.map +1 -0
  14. package/dist/src/DrawerMode.d.ts +3 -0
  15. package/dist/src/DrawerMode.d.ts.map +1 -0
  16. package/dist/src/DrawerPosition.d.ts +3 -0
  17. package/dist/src/DrawerPosition.d.ts.map +1 -0
  18. package/dist/src/DrawerToggleElement.d.ts +48 -0
  19. package/dist/src/DrawerToggleElement.d.ts.map +1 -0
  20. package/dist/src/index.d.ts +5 -0
  21. package/dist/src/index.d.ts.map +1 -0
  22. package/dist/src/styles/DrawerContainerStyle.d.ts +7 -0
  23. package/dist/src/styles/DrawerContainerStyle.d.ts.map +1 -0
  24. package/dist/src/styles/DrawerContainerToken.d.ts +16 -0
  25. package/dist/src/styles/DrawerContainerToken.d.ts.map +1 -0
  26. package/dist/src/styles/index.d.ts +2 -0
  27. package/dist/src/styles/index.d.ts.map +1 -0
  28. package/eslint.config.mjs +13 -0
  29. package/package.json +49 -0
  30. package/rollup.config.js +32 -0
  31. package/src/DrawerContainerElement.ts +244 -0
  32. package/src/DrawerMode.ts +2 -0
  33. package/src/DrawerPosition.ts +2 -0
  34. package/src/DrawerToggleElement.ts +123 -0
  35. package/src/index.ts +4 -0
  36. package/src/styles/DrawerContainerStyle.ts +178 -0
  37. package/src/styles/DrawerContainerToken.ts +19 -0
  38. package/src/styles/index.ts +1 -0
  39. 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,139 @@
1
+ # @m3e/drawer-container
2
+
3
+ The `m3e-drawer-container` component provides a responsive layout container for managing one or two sliding drawers alongside main content. It supports multiple drawer modes (`over`, `push`, `side`, and `auto`), adapts to breakpoint size, and encodes spatial hierarchy, motion transitions, and accessibility semantics for modal, dismissible, and permanent navigation.
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/drawer-container
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/drawer-container`, 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/drawer-container/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/drawer-container/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/drawer-container/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/layout": "/node_modules/@m3e/core/dist/layout.js"
48
+ }
49
+ }
50
+ </script>
51
+ ```
52
+
53
+ > For production, use index.min.js and layout.min.js for faster load times.
54
+
55
+ ## 🗂️ Elements
56
+
57
+ - `m3e-drawer-container` — A container for one or two sliding drawers.
58
+ - `m3e-drawer-toggle` — An element, nested within a clickable element, used to toggle the opened state of a drawer.
59
+
60
+ ## 🧪 Examples
61
+
62
+ The following example illustrates a typical drawer layout.
63
+
64
+ ```html
65
+ <m3e-drawer-container>
66
+ <nav slot="start">
67
+ <!-- Start drawer content -->
68
+ </nav>
69
+ <main>
70
+ <!-- Main content -->
71
+ </main>
72
+ <aside slot="end">
73
+ <!-- End drawer content -->
74
+ </aside>
75
+ </m3e-drawer-container>
76
+ ```
77
+
78
+ The next example illustrates the use of a `m3e-drawer-toggle`, nested inside a `m3e-icon-button` component, which toggles the open state of the start drawer.
79
+
80
+ ```html
81
+ <m3e-icon-button slot="leading-icon" aria-label="Menu" toggle selected>
82
+ <m3e-drawer-toggle for="startDrawer"></m3e-drawer-toggle>
83
+ <m3e-icon name="menu"></m3e-icon>
84
+ <m3e-icon slot="selected" name="menu_open"></m3e-icon>
85
+ </m3e-icon-button>
86
+
87
+ <m3e-drawer-container start>
88
+ <nav slot="start" id="startDrawer" aria-label="Navigation">
89
+ <!-- Start drawer content -->
90
+ </nav>
91
+ <!-- Container content -->
92
+ </m3e-drawer-container>
93
+ ```
94
+
95
+ ## 📖 API Reference
96
+
97
+ This section details the attributes and CSS custom properties available for the `m3e-drawer-container` component.
98
+
99
+ ### ⚙️ Attributes
100
+
101
+ | Attribute | Type | Default | Description |
102
+ | --------------- | -------------------------------------- | -------- | ----------------------------------------------------------------------------------------- |
103
+ | `start` | `boolean` | `false` | Whether the start drawer is open. |
104
+ | `start-mode` | `"over" \| "push" \| "side" \| "auto"` | `"side"` | The behavior mode of the start drawer. Supports `over`, `push`, `side`, and `auto` modes. |
105
+ | `start-divider` | `boolean` | `false` | Whether to show a divider between the start drawer and content for `side` mode. |
106
+ | `end` | `boolean` | `false` | Whether the end drawer is open. |
107
+ | `end-mode` | `"over" \| "push" \| "side" \| "auto"` | `"side"` | The behavior mode of the end drawer. Supports `over`, `push`, `side`, and `auto` modes. |
108
+ | `end-divider` | `boolean` | `false` | Whether to show a divider between the end drawer and content for `side` mode. |
109
+
110
+ ### 🧩 Slots
111
+
112
+ | Slot | Description |
113
+ | ----------- | ------------------------- |
114
+ | _(default)_ | Renders the main content. |
115
+ | `start` | Renders the start drawer. |
116
+ | `end` | Renders the end drawer. |
117
+
118
+ ### 🎛️ CSS Custom Properties
119
+
120
+ | Property | Description |
121
+ | -------------------------------------- | ------------------------------------------------------------- |
122
+ | `--m3e-drawer-container-color` | The background color of the drawer container. |
123
+ | `--m3e-drawer-container-elevation` | The elevation level of the drawer container. |
124
+ | `--m3e-drawer-container-width` | The width of the drawer container. |
125
+ | `--m3e-drawer-container-scrim-opacity` | The opacity of the scrim behind the drawer. |
126
+ | `--m3e-modal-drawer-start-shape` | The shape of the drawer’s start edge (typically left in LTR). |
127
+ | `--m3e-modal-drawer-end-shape` | The shape of the drawer’s end edge (typically right in LTR). |
128
+ | `--m3e-modal-drawer-container-color` | The background color of the modal drawer container. |
129
+ | `--m3e-modal-drawer-elevation` | The elevation level of the modal drawer container. |
130
+ | `--m3e-drawer-divider-color` | The color of the divider between drawer sections. |
131
+ | `--m3e-drawer-divider-thickness` | The thickness of the divider line. |
132
+
133
+ ## 🤝 Contributing
134
+
135
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
136
+
137
+ ## 📄 License
138
+
139
+ 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,88 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Drawer Container for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Drawer Container 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
+ "@m3e/core/layout": "../../core/dist/layout.min.js"
26
+ }
27
+ }
28
+ </script>
29
+ <script type="module" src="../../app-bar/dist/index.min.js"></script>
30
+ <script type="module" src="../../icon-button/dist/index.min.js"></script>
31
+ <script type="module" src="../../icon/dist/index.min.js"></script>
32
+ <script type="module" src="../../nav-menu/dist/index.min.js"></script>
33
+ <script type="module" src="../../theme/dist/index.min.js"></script>
34
+ <script type="module" src="../dist/index.min.js"></script>
35
+ <style>
36
+ body {
37
+ margin: unset;
38
+ font-family: "Roboto";
39
+ display: flex;
40
+ flex-direction: column;
41
+ height: 100vh;
42
+ overflow: hidden;
43
+ }
44
+ m3e-app-bar {
45
+ flex: none;
46
+ }
47
+ m3e-drawer-container {
48
+ flex: 1 1 auto;
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <m3e-theme strong-focus>
54
+ <m3e-app-bar>
55
+ <m3e-icon-button slot="leading-icon" aria-label="Menu" toggle>
56
+ <m3e-icon name="menu"></m3e-icon>
57
+ <m3e-icon slot="selected" name="menu_open"></m3e-icon>
58
+ <m3e-drawer-toggle for="startDrawer"></m3e-drawer-toggle>
59
+ </m3e-icon-button>
60
+ <span slot="title">App title</span>
61
+ </m3e-app-bar>
62
+ <m3e-drawer-container start end start-mode="auto" end-mode="auto" end-divider>
63
+ <m3e-nav-menu id="startDrawer" slot="start">
64
+ <m3e-nav-menu-item open>
65
+ <m3e-icon slot="icon" name="rocket_launch"></m3e-icon>
66
+ <span slot="label">Getting Started</span>
67
+ <m3e-nav-menu-item>
68
+ <m3e-icon slot="icon" name="widgets"></m3e-icon>
69
+ <span slot="label">Overview</span>
70
+ </m3e-nav-menu-item>
71
+ <m3e-nav-menu-item>
72
+ <m3e-icon slot="icon" name="package_2"></m3e-icon>
73
+ <span slot="label">Installation</span>
74
+ </m3e-nav-menu-item>
75
+ </m3e-nav-menu-item>
76
+ <m3e-nav-menu-item>
77
+ <span slot="label">Actions</span>
78
+ <m3e-nav-menu-item><span slot="label">Button</span></m3e-nav-menu-item>
79
+ <m3e-nav-menu-item><span slot="label">Icon</span></m3e-nav-menu-item>
80
+ <m3e-nav-menu-item><span slot="label">Icon Button</span></m3e-nav-menu-item>
81
+ </m3e-nav-menu-item>
82
+ </m3e-nav-menu>
83
+ <aside slot="end">Right-side content</aside>
84
+ <div>Main content</div>
85
+ </m3e-drawer-container>
86
+ </m3e-theme>
87
+ </body>
88
+ </html>
@@ -0,0 +1,57 @@
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-drawer-container-color",
7
+ "description": "The background color of the drawer container.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-drawer-container-elevation",
12
+ "description": "The elevation level of the drawer container.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-drawer-container-width",
17
+ "description": "The width of the drawer container.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-drawer-container-scrim-opacity",
22
+ "description": "The opacity of the scrim behind the drawer.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-modal-drawer-start-shape",
27
+ "description": "The shape of the drawer’s start edge (typically left in LTR).",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-modal-drawer-end-shape",
32
+ "description": "The shape of the drawer’s end edge (typically right in LTR).",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-modal-drawer-container-color",
37
+ "description": "The background color of the modal drawer container.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-modal-drawer-elevation",
42
+ "description": "The elevation level of the modal drawer container.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-drawer-divider-color",
47
+ "description": "The color of the divider between drawer sections.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-drawer-divider-thickness",
52
+ "description": "The thickness of the divider line.",
53
+ "values": []
54
+ }
55
+ ],
56
+ "pseudoElements": []
57
+ }