@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.
- package/LICENSE +22 -0
- package/README.md +139 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +88 -0
- package/dist/css-custom-data.json +57 -0
- package/dist/custom-elements.json +569 -0
- package/dist/html-custom-data.json +49 -0
- package/dist/index.js +620 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +209 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/DrawerContainerElement.d.ts +105 -0
- package/dist/src/DrawerContainerElement.d.ts.map +1 -0
- package/dist/src/DrawerMode.d.ts +3 -0
- package/dist/src/DrawerMode.d.ts.map +1 -0
- package/dist/src/DrawerPosition.d.ts +3 -0
- package/dist/src/DrawerPosition.d.ts.map +1 -0
- package/dist/src/DrawerToggleElement.d.ts +48 -0
- package/dist/src/DrawerToggleElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/styles/DrawerContainerStyle.d.ts +7 -0
- package/dist/src/styles/DrawerContainerStyle.d.ts.map +1 -0
- package/dist/src/styles/DrawerContainerToken.d.ts +16 -0
- package/dist/src/styles/DrawerContainerToken.d.ts.map +1 -0
- package/dist/src/styles/index.d.ts +2 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +49 -0
- package/rollup.config.js +32 -0
- package/src/DrawerContainerElement.ts +244 -0
- package/src/DrawerMode.ts +2 -0
- package/src/DrawerPosition.ts +2 -0
- package/src/DrawerToggleElement.ts +123 -0
- package/src/index.ts +4 -0
- package/src/styles/DrawerContainerStyle.ts +178 -0
- package/src/styles/DrawerContainerToken.ts +19 -0
- package/src/styles/index.ts +1 -0
- package/tsconfig.json +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { unsafeCSS, css, LitElement, html } from 'lit';
|
|
7
|
+
import { DesignToken, Role, hasAssignedNodes, HtmlFor } from '@m3e/core';
|
|
8
|
+
import { M3eBreakpointObserver, Breakpoint } from '@m3e/core/layout';
|
|
9
|
+
|
|
10
|
+
/******************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function __decorate(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
35
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
36
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
37
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
41
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
42
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
43
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
44
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
48
|
+
var e = new Error(message);
|
|
49
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2017 Google LLC
|
|
55
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
+
*/
|
|
57
|
+
const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @license
|
|
61
|
+
* Copyright 2019 Google LLC
|
|
62
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
63
|
+
*/
|
|
64
|
+
const t=globalThis,e$1=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o$2=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$1&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$1)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$1=e$1?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @license
|
|
68
|
+
* Copyright 2017 Google LLC
|
|
69
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
70
|
+
*/const{is:i,defineProperty:e,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$2,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f=(t,s)=>!i(t,s),b={attribute:true,type:String,converter:u,reflect:false,useDefault:false,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r$2(t),...o$1(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$1(s));}else void 0!==s&&i.push(c$1(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.1");
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2017 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r$1=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @license
|
|
80
|
+
* Copyright 2017 Google LLC
|
|
81
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
82
|
+
*/function r(r){return n({...r,state:true,attribute:false})}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Component design tokens that control `M3eDrawerContainerElement`.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
const DrawerContainerToken = {
|
|
89
|
+
containerColor: unsafeCSS(`var(--m3e-drawer-container-color, ${DesignToken.color.surface})`),
|
|
90
|
+
containerElevation: unsafeCSS(`var(--m3e-drawer-container-elevation, ${DesignToken.elevation.level0})`),
|
|
91
|
+
containerWidth: unsafeCSS(`var(--m3e-drawer-container-width, 22.5rem)`),
|
|
92
|
+
scrimOpacity: unsafeCSS("var(--m3e-drawer-container-scrim-opacity, 32%)"),
|
|
93
|
+
cornerShape: unsafeCSS(`var(--m3e-modal-drawer-corner-shape, ${DesignToken.shape.corner.large})`),
|
|
94
|
+
modalContainerColor: unsafeCSS(`var(--m3e-modal-drawer-container-color, ${DesignToken.color.surfaceContainerLow})`),
|
|
95
|
+
modalContainerElevation: unsafeCSS(`var(--m3e-modal-drawer-elevation, ${DesignToken.elevation.level1})`),
|
|
96
|
+
dividerColor: unsafeCSS(`var(--m3e-drawer-divider-color, ${DesignToken.color.outline})`),
|
|
97
|
+
dividerThickness: unsafeCSS("var(--m3e-drawer-divider-thickness, 1px)"),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Styles for `M3eDrawerContainerElement`.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
const DrawerContainerStyle = css `
|
|
105
|
+
:host {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: row;
|
|
108
|
+
position: relative;
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
flex: 1 1 auto;
|
|
111
|
+
}
|
|
112
|
+
.content {
|
|
113
|
+
height: 100%;
|
|
114
|
+
}
|
|
115
|
+
::slotted([slot="start"]),
|
|
116
|
+
::slotted([slot="end"]) {
|
|
117
|
+
display: block;
|
|
118
|
+
height: 100%;
|
|
119
|
+
z-index: 3;
|
|
120
|
+
outline: none;
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
flex: none;
|
|
123
|
+
width: ${DrawerContainerToken.containerWidth};
|
|
124
|
+
background-color: ${DrawerContainerToken.containerColor};
|
|
125
|
+
box-shadow: ${DrawerContainerToken.containerElevation};
|
|
126
|
+
transition: ${unsafeCSS(`margin ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard},
|
|
127
|
+
visibility ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
128
|
+
background-color ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard},
|
|
129
|
+
box-shadow ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard}`)};
|
|
130
|
+
}
|
|
131
|
+
:host(.-start-over) ::slotted([slot="start"]) {
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 0;
|
|
134
|
+
left: 0;
|
|
135
|
+
}
|
|
136
|
+
:host(.-end-over) ::slotted([slot="end"]) {
|
|
137
|
+
position: absolute;
|
|
138
|
+
top: 0;
|
|
139
|
+
right: 0;
|
|
140
|
+
}
|
|
141
|
+
:host(:not([start])) ::slotted([slot="start"]) {
|
|
142
|
+
visibility: hidden;
|
|
143
|
+
margin-inline-start: calc(0px - ${DrawerContainerToken.containerWidth});
|
|
144
|
+
}
|
|
145
|
+
:host([start]) ::slotted([slot="start"]) {
|
|
146
|
+
visibility: visible;
|
|
147
|
+
margin-inline-start: 0;
|
|
148
|
+
}
|
|
149
|
+
:host(:not([end])) ::slotted([slot="end"]) {
|
|
150
|
+
visibility: hidden;
|
|
151
|
+
margin-inline-end: calc(0px - ${DrawerContainerToken.containerWidth});
|
|
152
|
+
}
|
|
153
|
+
:host([end]) ::slotted([slot="end"]) {
|
|
154
|
+
margin-inline-end: 0;
|
|
155
|
+
visibility: visible;
|
|
156
|
+
}
|
|
157
|
+
.content {
|
|
158
|
+
flex: 1 1 auto;
|
|
159
|
+
position: relative;
|
|
160
|
+
height: 100%;
|
|
161
|
+
}
|
|
162
|
+
.scrim {
|
|
163
|
+
display: block;
|
|
164
|
+
position: absolute;
|
|
165
|
+
left: 0;
|
|
166
|
+
right: 0;
|
|
167
|
+
top: 0;
|
|
168
|
+
bottom: 0;
|
|
169
|
+
z-index: 1;
|
|
170
|
+
background-color: ${DesignToken.color.scrim};
|
|
171
|
+
opacity: 0;
|
|
172
|
+
visibility: hidden;
|
|
173
|
+
transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard},
|
|
174
|
+
visibility ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard} allow-discrete`)};
|
|
175
|
+
}
|
|
176
|
+
@starting-style {
|
|
177
|
+
.scrim {
|
|
178
|
+
opacity: 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
:host(.-start-push[start]) .scrim,
|
|
182
|
+
:host(.-end-push[end]) .scrim,
|
|
183
|
+
:host(.-start-over[start]) .scrim,
|
|
184
|
+
:host(.-end-over[end]) .scrim {
|
|
185
|
+
visibility: visible;
|
|
186
|
+
opacity: ${DrawerContainerToken.scrimOpacity};
|
|
187
|
+
}
|
|
188
|
+
:host(.-start-push) ::slotted([slot="start"]),
|
|
189
|
+
:host(.-start-over) ::slotted([slot="start"]) {
|
|
190
|
+
border-start-end-radius: ${DrawerContainerToken.cornerShape};
|
|
191
|
+
border-end-end-radius: ${DrawerContainerToken.cornerShape};
|
|
192
|
+
}
|
|
193
|
+
:host(.-end-push) ::slotted([slot="end"]),
|
|
194
|
+
:host(.-end-over) ::slotted([slot="end"]) {
|
|
195
|
+
border-start-start-radius: ${DrawerContainerToken.cornerShape};
|
|
196
|
+
border-end-start-radius: ${DrawerContainerToken.cornerShape};
|
|
197
|
+
}
|
|
198
|
+
:host(.-start-push) ::slotted([slot="start"]),
|
|
199
|
+
:host(.-end-push) ::slotted([slot="end"]),
|
|
200
|
+
:host(.-start-over) ::slotted([slot="start"]),
|
|
201
|
+
:host(.-end-over) ::slotted([slot="end"]) {
|
|
202
|
+
background-color: ${DrawerContainerToken.modalContainerColor};
|
|
203
|
+
box-shadow: ${DrawerContainerToken.modalContainerElevation};
|
|
204
|
+
}
|
|
205
|
+
:host([start-divider]) ::slotted([slot="start"]) {
|
|
206
|
+
border-inline-end-color: transparent;
|
|
207
|
+
border-inline-end-width: ${DrawerContainerToken.dividerThickness};
|
|
208
|
+
border-inline-end-style: solid;
|
|
209
|
+
box-sizing: border-box;
|
|
210
|
+
}
|
|
211
|
+
:host([start-divider].-start-side[start]:not(.-end-push[end]):not(.-end-over[end])) ::slotted([slot="start"]) {
|
|
212
|
+
border-inline-end-color: ${DrawerContainerToken.dividerColor};
|
|
213
|
+
}
|
|
214
|
+
:host([end-divider]) ::slotted([slot="end"]) {
|
|
215
|
+
border-inline-start-color: transparent;
|
|
216
|
+
border-inline-start-width: ${DrawerContainerToken.dividerThickness};
|
|
217
|
+
border-inline-start-style: solid;
|
|
218
|
+
box-sizing: border-box;
|
|
219
|
+
}
|
|
220
|
+
:host([end-divider].-end-side[end]:not(.-start-push[start]):not(.-start-over[start])) ::slotted([slot="end"]) {
|
|
221
|
+
border-inline-start-color: ${DrawerContainerToken.dividerColor};
|
|
222
|
+
}
|
|
223
|
+
@media (forced-colors: active) {
|
|
224
|
+
::slotted([slot="start"]),
|
|
225
|
+
::slotted([slot="end"]) {
|
|
226
|
+
background-color: Canvas;
|
|
227
|
+
box-shadow: unset;
|
|
228
|
+
transition: ${unsafeCSS(`margin ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard},
|
|
229
|
+
visibility ${DesignToken.motion.duration.medium4} ${DesignToken.motion.easing.standard} allow-discrete`)};
|
|
230
|
+
}
|
|
231
|
+
:host(.-start-push) ::slotted([slot="start"]),
|
|
232
|
+
:host(.-end-push) ::slotted([slot="end"]),
|
|
233
|
+
:host(.-start-over) ::slotted([slot="start"]),
|
|
234
|
+
:host(.-end-over) ::slotted([slot="end"]) {
|
|
235
|
+
background-color: Canvas;
|
|
236
|
+
box-shadow: unset;
|
|
237
|
+
border-color: CanvasText;
|
|
238
|
+
}
|
|
239
|
+
::slotted([slot="start"]),
|
|
240
|
+
::slotted([slot="end"]) {
|
|
241
|
+
border-style: solid;
|
|
242
|
+
border-color: Canvas;
|
|
243
|
+
border-width: 1px;
|
|
244
|
+
}
|
|
245
|
+
::slotted([slot="start"]) {
|
|
246
|
+
border-inline-start-style: none;
|
|
247
|
+
}
|
|
248
|
+
::slotted([slot="end"]) {
|
|
249
|
+
border-inline-end-style: none;
|
|
250
|
+
}
|
|
251
|
+
:host([start-divider].-start-side[start]:not(.-end-push[end]):not(.-end-over[end])) ::slotted([slot="start"]) {
|
|
252
|
+
border-inline-end-color: GrayText;
|
|
253
|
+
}
|
|
254
|
+
:host([end-divider].-end-side[end]:not(.-start-push[start]):not(.-start-over[start])) ::slotted([slot="end"]) {
|
|
255
|
+
border-inline-start-color: GrayText;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
@media (prefers-reduced-motion) {
|
|
259
|
+
::slotted([slot="start"]),
|
|
260
|
+
::slotted([slot="end"]),
|
|
261
|
+
.scrim {
|
|
262
|
+
transition: none;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
|
|
267
|
+
var _M3eDrawerContainerElement_instances, _M3eDrawerContainerElement_breakpointUnobserve, _M3eDrawerContainerElement_disableStartFocusTrap, _M3eDrawerContainerElement_disableEndFocusTrap, _M3eDrawerContainerElement_initialized, _M3eDrawerContainerElement_handleScrimClick, _M3eDrawerContainerElement_handleStartSlotChange, _M3eDrawerContainerElement_handleEndSlotChange, _M3eDrawerContainerElement_clearMode, _M3eDrawerContainerElement_updateMode;
|
|
268
|
+
/**
|
|
269
|
+
* @summary
|
|
270
|
+
* A container for one or two sliding drawers.
|
|
271
|
+
*
|
|
272
|
+
* @description
|
|
273
|
+
* A responsive layout container that manages left and right drawers alongside main content.
|
|
274
|
+
* Supports `over`, `push`, `side`, and `auto` modes, adapting drawer behavior based on breakpoint size.
|
|
275
|
+
* Encodes spatial hierarchy, motion transitions, and accessibility semantics for modal, dismissible,
|
|
276
|
+
* and permanent navigation.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* The following example illustrates a typical drawer layout.
|
|
280
|
+
* ```html
|
|
281
|
+
* <m3e-drawer-container>
|
|
282
|
+
* <nav slot="start">
|
|
283
|
+
* <!-- Start drawer content -->
|
|
284
|
+
* </nav>
|
|
285
|
+
* <main>
|
|
286
|
+
* <!-- Main content -->
|
|
287
|
+
* </main>
|
|
288
|
+
* <aside slot="end">
|
|
289
|
+
* <!-- End drawer content -->
|
|
290
|
+
* </aside>
|
|
291
|
+
* <m3e-drawer-container>
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @tag m3e-drawer-container
|
|
295
|
+
*
|
|
296
|
+
* @slot - Renders the main content.
|
|
297
|
+
* @slot start - Renders the start drawer.
|
|
298
|
+
* @slot end - Renders the end drawer.
|
|
299
|
+
*
|
|
300
|
+
* @attr end - Whether the end drawer is open.
|
|
301
|
+
* @attr end-mode - The behavior mode of the end drawer.
|
|
302
|
+
* @attr end-divider - Whether to show a divider between the end drawer and content for `side` mode.
|
|
303
|
+
* @attr start - Whether the start drawer is open.
|
|
304
|
+
* @attr start-mode - The behavior mode of the start drawer.
|
|
305
|
+
* @attr start-divider - Whether to show a divider between the start drawer and content for `side` mode.
|
|
306
|
+
*
|
|
307
|
+
* @fires change - Emitted when the state of the start or end drawers change.
|
|
308
|
+
*
|
|
309
|
+
* @cssprop --m3e-drawer-container-color - The background color of the drawer container.
|
|
310
|
+
* @cssprop --m3e-drawer-container-elevation - The elevation level of the drawer container.
|
|
311
|
+
* @cssprop --m3e-drawer-container-width - The width of the drawer container.
|
|
312
|
+
* @cssprop --m3e-drawer-container-scrim-opacity - The opacity of the scrim behind the drawer.
|
|
313
|
+
* @cssprop --m3e-modal-drawer-start-shape - The shape of the drawer’s start edge (typically left in LTR).
|
|
314
|
+
* @cssprop --m3e-modal-drawer-end-shape - The shape of the drawer’s end edge (typically right in LTR).
|
|
315
|
+
* @cssprop --m3e-modal-drawer-container-color - The background color of the modal drawer container.
|
|
316
|
+
* @cssprop --m3e-modal-drawer-elevation - The elevation level of the modal drawer container.
|
|
317
|
+
* @cssprop --m3e-drawer-divider-color - The color of the divider between drawer sections.
|
|
318
|
+
* @cssprop --m3e-drawer-divider-thickness - The thickness of the divider line.
|
|
319
|
+
*/
|
|
320
|
+
let M3eDrawerContainerElement = class M3eDrawerContainerElement extends Role(LitElement, "none") {
|
|
321
|
+
constructor() {
|
|
322
|
+
super(...arguments);
|
|
323
|
+
_M3eDrawerContainerElement_instances.add(this);
|
|
324
|
+
/** @private */ this._startMode = "side";
|
|
325
|
+
/** @private */ this._endMode = "side";
|
|
326
|
+
/** @private */ _M3eDrawerContainerElement_breakpointUnobserve.set(this, void 0);
|
|
327
|
+
/** @private */ _M3eDrawerContainerElement_disableStartFocusTrap.set(this, false);
|
|
328
|
+
/** @private */ _M3eDrawerContainerElement_disableEndFocusTrap.set(this, false);
|
|
329
|
+
/** @private */ _M3eDrawerContainerElement_initialized.set(this, false);
|
|
330
|
+
/**
|
|
331
|
+
* Whether the start drawer is open.
|
|
332
|
+
* @default false
|
|
333
|
+
*/
|
|
334
|
+
this.start = false;
|
|
335
|
+
/**
|
|
336
|
+
* The behavior mode of the start drawer.
|
|
337
|
+
* @default "side"
|
|
338
|
+
*/
|
|
339
|
+
this.startMode = "side";
|
|
340
|
+
/**
|
|
341
|
+
* Whether to show a divider between the start drawer and content for `side` mode.
|
|
342
|
+
* @default "side"
|
|
343
|
+
*/
|
|
344
|
+
this.startDivider = false;
|
|
345
|
+
/**
|
|
346
|
+
* Whether the end drawer is open.
|
|
347
|
+
* @default false
|
|
348
|
+
*/
|
|
349
|
+
this.end = false;
|
|
350
|
+
/**
|
|
351
|
+
* The behavior mode of the end drawer.
|
|
352
|
+
* @default "side"
|
|
353
|
+
*/
|
|
354
|
+
this.endMode = "side";
|
|
355
|
+
/**
|
|
356
|
+
* Whether to show a divider between the end drawer and content for `side` mode.
|
|
357
|
+
* @default "side"
|
|
358
|
+
*/
|
|
359
|
+
this.endDivider = false;
|
|
360
|
+
}
|
|
361
|
+
/** @inheritdoc */
|
|
362
|
+
disconnectedCallback() {
|
|
363
|
+
super.disconnectedCallback();
|
|
364
|
+
__classPrivateFieldGet(this, _M3eDrawerContainerElement_breakpointUnobserve, "f")?.call(this);
|
|
365
|
+
__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_clearMode).call(this);
|
|
366
|
+
}
|
|
367
|
+
/** @inheritdoc */
|
|
368
|
+
update(changedProperties) {
|
|
369
|
+
super.update(changedProperties);
|
|
370
|
+
if (changedProperties.has("startMode") || changedProperties.has("endMode")) {
|
|
371
|
+
__classPrivateFieldGet(this, _M3eDrawerContainerElement_breakpointUnobserve, "f")?.call(this);
|
|
372
|
+
if (this.startMode === "auto" || this.endMode === "auto") {
|
|
373
|
+
__classPrivateFieldSet(this, _M3eDrawerContainerElement_breakpointUnobserve, M3eBreakpointObserver.observe([Breakpoint.XSmall, Breakpoint.Small], (matches) => __classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_updateMode).call(this, matches, __classPrivateFieldGet(this, _M3eDrawerContainerElement_initialized, "f"))), "f");
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_updateMode).call(this);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
__classPrivateFieldSet(this, _M3eDrawerContainerElement_initialized, true, "f");
|
|
380
|
+
}
|
|
381
|
+
/** @inheritdoc */
|
|
382
|
+
render() {
|
|
383
|
+
return html `<m3e-focus-trap ?disabled="${!this.start || this._startMode === "side" || __classPrivateFieldGet(this, _M3eDrawerContainerElement_disableStartFocusTrap, "f")}">
|
|
384
|
+
<slot name="start" @slotchange="${__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_handleStartSlotChange)}"></slot>
|
|
385
|
+
</m3e-focus-trap>
|
|
386
|
+
<div
|
|
387
|
+
class="content"
|
|
388
|
+
.inert="${(this._startMode !== "side" || this._endMode !== "side") && (this.start || this.end)}"
|
|
389
|
+
>
|
|
390
|
+
<slot></slot>
|
|
391
|
+
</div>
|
|
392
|
+
<div class="scrim" @click="${__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_handleScrimClick)}"></div>
|
|
393
|
+
<m3e-focus-trap ?disabled="${!this.end || this._endMode === "side" || __classPrivateFieldGet(this, _M3eDrawerContainerElement_disableEndFocusTrap, "f")}">
|
|
394
|
+
<slot name="end" @slotchange="${__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_handleEndSlotChange)}"></slot>
|
|
395
|
+
</m3e-focus-trap>`;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
_M3eDrawerContainerElement_breakpointUnobserve = new WeakMap();
|
|
399
|
+
_M3eDrawerContainerElement_disableStartFocusTrap = new WeakMap();
|
|
400
|
+
_M3eDrawerContainerElement_disableEndFocusTrap = new WeakMap();
|
|
401
|
+
_M3eDrawerContainerElement_initialized = new WeakMap();
|
|
402
|
+
_M3eDrawerContainerElement_instances = new WeakSet();
|
|
403
|
+
_M3eDrawerContainerElement_handleScrimClick = function _M3eDrawerContainerElement_handleScrimClick() {
|
|
404
|
+
if (this._startMode !== "side") {
|
|
405
|
+
this.start = false;
|
|
406
|
+
}
|
|
407
|
+
if (this._endMode !== "side") {
|
|
408
|
+
this.end = false;
|
|
409
|
+
}
|
|
410
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
411
|
+
};
|
|
412
|
+
_M3eDrawerContainerElement_handleStartSlotChange = function _M3eDrawerContainerElement_handleStartSlotChange(e) {
|
|
413
|
+
__classPrivateFieldSet(this, _M3eDrawerContainerElement_disableStartFocusTrap, !hasAssignedNodes(e.target), "f");
|
|
414
|
+
};
|
|
415
|
+
_M3eDrawerContainerElement_handleEndSlotChange = function _M3eDrawerContainerElement_handleEndSlotChange(e) {
|
|
416
|
+
__classPrivateFieldSet(this, _M3eDrawerContainerElement_disableEndFocusTrap, !hasAssignedNodes(e.target), "f");
|
|
417
|
+
};
|
|
418
|
+
_M3eDrawerContainerElement_clearMode = function _M3eDrawerContainerElement_clearMode() {
|
|
419
|
+
this.classList.remove("-start-over");
|
|
420
|
+
this.classList.remove("-start-push");
|
|
421
|
+
this.classList.remove("-start-side");
|
|
422
|
+
this.classList.remove("-end-over");
|
|
423
|
+
this.classList.remove("-end-push");
|
|
424
|
+
this.classList.remove("-end-side");
|
|
425
|
+
};
|
|
426
|
+
_M3eDrawerContainerElement_updateMode = function _M3eDrawerContainerElement_updateMode(breakpoints, autoClose = false) {
|
|
427
|
+
let autoCloseStart = false, autoCloseEnd = false;
|
|
428
|
+
if (this.startMode === "auto") {
|
|
429
|
+
if (breakpoints?.get(Breakpoint.Medium)) {
|
|
430
|
+
this._startMode = "side";
|
|
431
|
+
}
|
|
432
|
+
else if (breakpoints?.get(Breakpoint.Small)) {
|
|
433
|
+
autoCloseStart = this._startMode === "side" && this.start;
|
|
434
|
+
this._startMode = "push";
|
|
435
|
+
}
|
|
436
|
+
else if (breakpoints?.get(Breakpoint.XSmall)) {
|
|
437
|
+
autoCloseStart = this._startMode !== "over" && this.start;
|
|
438
|
+
this._startMode = "over";
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
this._startMode = "side";
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
this._startMode = this.startMode;
|
|
446
|
+
}
|
|
447
|
+
if (this.endMode === "auto") {
|
|
448
|
+
if (breakpoints?.get(Breakpoint.Medium)) {
|
|
449
|
+
this._endMode = "side";
|
|
450
|
+
}
|
|
451
|
+
else if (breakpoints?.get(Breakpoint.Small)) {
|
|
452
|
+
autoCloseEnd = this._endMode === "side" && this.end;
|
|
453
|
+
this._endMode = "push";
|
|
454
|
+
}
|
|
455
|
+
else if (breakpoints?.get(Breakpoint.XSmall)) {
|
|
456
|
+
autoCloseEnd = this._endMode !== "over" && this.end;
|
|
457
|
+
this._endMode = "over";
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
this._endMode = "side";
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
this._endMode = this.endMode;
|
|
465
|
+
}
|
|
466
|
+
__classPrivateFieldGet(this, _M3eDrawerContainerElement_instances, "m", _M3eDrawerContainerElement_clearMode).call(this);
|
|
467
|
+
this.classList.add(`-start-${this._startMode}`);
|
|
468
|
+
this.classList.add(`-end-${this._endMode}`);
|
|
469
|
+
if (autoClose && (autoCloseStart || autoCloseEnd)) {
|
|
470
|
+
if (autoCloseStart) {
|
|
471
|
+
this.start = false;
|
|
472
|
+
}
|
|
473
|
+
if (autoCloseEnd) {
|
|
474
|
+
this.end = false;
|
|
475
|
+
}
|
|
476
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
/** The styles of the element. */
|
|
480
|
+
M3eDrawerContainerElement.styles = DrawerContainerStyle;
|
|
481
|
+
__decorate([
|
|
482
|
+
r()
|
|
483
|
+
], M3eDrawerContainerElement.prototype, "_startMode", void 0);
|
|
484
|
+
__decorate([
|
|
485
|
+
r()
|
|
486
|
+
], M3eDrawerContainerElement.prototype, "_endMode", void 0);
|
|
487
|
+
__decorate([
|
|
488
|
+
n({ type: Boolean, reflect: true })
|
|
489
|
+
], M3eDrawerContainerElement.prototype, "start", void 0);
|
|
490
|
+
__decorate([
|
|
491
|
+
n({ attribute: "start-mode", reflect: true })
|
|
492
|
+
], M3eDrawerContainerElement.prototype, "startMode", void 0);
|
|
493
|
+
__decorate([
|
|
494
|
+
n({ attribute: "start-divider", type: Boolean, reflect: true })
|
|
495
|
+
], M3eDrawerContainerElement.prototype, "startDivider", void 0);
|
|
496
|
+
__decorate([
|
|
497
|
+
n({ type: Boolean, reflect: true })
|
|
498
|
+
], M3eDrawerContainerElement.prototype, "end", void 0);
|
|
499
|
+
__decorate([
|
|
500
|
+
n({ attribute: "end-mode", reflect: true })
|
|
501
|
+
], M3eDrawerContainerElement.prototype, "endMode", void 0);
|
|
502
|
+
__decorate([
|
|
503
|
+
n({ attribute: "end-divider", type: Boolean, reflect: true })
|
|
504
|
+
], M3eDrawerContainerElement.prototype, "endDivider", void 0);
|
|
505
|
+
M3eDrawerContainerElement = __decorate([
|
|
506
|
+
t$1("m3e-drawer-container")
|
|
507
|
+
], M3eDrawerContainerElement);
|
|
508
|
+
|
|
509
|
+
var _M3eDrawerToggleElement_instances, _M3eDrawerToggleElement_clickHandler, _M3eDrawerToggleElement_drawerContainerChangeHandler, _M3eDrawerToggleElement_handleClick, _M3eDrawerToggleElement_handleDrawerContainerChange, _M3eDrawerToggleElement_updateToggle;
|
|
510
|
+
/**
|
|
511
|
+
* An element, nested within a clickable element, used to toggle the opened state of a drawer.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* The following example illustrates the use of a `m3e-drawer-toggle`, nested inside a `m3e-icon-button` component,
|
|
515
|
+
* which toggles the open state of the start drawer.
|
|
516
|
+
*
|
|
517
|
+
* ```html
|
|
518
|
+
* <m3e-icon-button slot="leading-icon" aria-label="Menu" toggle selected>
|
|
519
|
+
* <m3e-drawer-toggle for="startDrawer"></m3e-drawer-toggle>
|
|
520
|
+
* <m3e-icon name="menu"></m3e-icon>
|
|
521
|
+
* <m3e-icon slot="selected" name="menu_open"></m3e-icon>
|
|
522
|
+
* </m3e-icon-button>
|
|
523
|
+
*
|
|
524
|
+
* <m3e-drawer-container start>
|
|
525
|
+
* <nav slot="start" id="startDrawer" aria-label="Navigation">
|
|
526
|
+
* <!-- Start drawer content -->
|
|
527
|
+
* </nav>
|
|
528
|
+
* <!-- Container content -->
|
|
529
|
+
* </m3e-drawer-container>
|
|
530
|
+
* ```
|
|
531
|
+
*
|
|
532
|
+
* @tag m3e-drawer-toggle
|
|
533
|
+
*/
|
|
534
|
+
let M3eDrawerToggleElement = class M3eDrawerToggleElement extends HtmlFor(Role(LitElement, "none")) {
|
|
535
|
+
constructor() {
|
|
536
|
+
super(...arguments);
|
|
537
|
+
_M3eDrawerToggleElement_instances.add(this);
|
|
538
|
+
/** @private */ _M3eDrawerToggleElement_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eDrawerToggleElement_instances, "m", _M3eDrawerToggleElement_handleClick).call(this, e));
|
|
539
|
+
/** @private */ _M3eDrawerToggleElement_drawerContainerChangeHandler.set(this, () => __classPrivateFieldGet(this, _M3eDrawerToggleElement_instances, "m", _M3eDrawerToggleElement_handleDrawerContainerChange).call(this));
|
|
540
|
+
}
|
|
541
|
+
/** @inheritdoc */
|
|
542
|
+
connectedCallback() {
|
|
543
|
+
super.connectedCallback();
|
|
544
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _M3eDrawerToggleElement_clickHandler, "f"));
|
|
545
|
+
}
|
|
546
|
+
/** @inheritdoc */
|
|
547
|
+
disconnectedCallback() {
|
|
548
|
+
super.disconnectedCallback();
|
|
549
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _M3eDrawerToggleElement_clickHandler, "f"));
|
|
550
|
+
}
|
|
551
|
+
/** @inheritdoc */
|
|
552
|
+
attach(control) {
|
|
553
|
+
const container = control.closest("m3e-drawer-container");
|
|
554
|
+
if (container) {
|
|
555
|
+
container.addEventListener("change", __classPrivateFieldGet(this, _M3eDrawerToggleElement_drawerContainerChangeHandler, "f"));
|
|
556
|
+
__classPrivateFieldGet(this, _M3eDrawerToggleElement_instances, "m", _M3eDrawerToggleElement_updateToggle).call(this, container, control);
|
|
557
|
+
}
|
|
558
|
+
super.attach(control);
|
|
559
|
+
}
|
|
560
|
+
/** @inheritdoc */
|
|
561
|
+
detach() {
|
|
562
|
+
this.control?.closest("m3e-drawer-container")?.removeEventListener("change", __classPrivateFieldGet(this, _M3eDrawerToggleElement_drawerContainerChangeHandler, "f"));
|
|
563
|
+
super.detach();
|
|
564
|
+
}
|
|
565
|
+
/** @inheritdoc */
|
|
566
|
+
render() {
|
|
567
|
+
return html `<slot></slot>`;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
_M3eDrawerToggleElement_clickHandler = new WeakMap();
|
|
571
|
+
_M3eDrawerToggleElement_drawerContainerChangeHandler = new WeakMap();
|
|
572
|
+
_M3eDrawerToggleElement_instances = new WeakSet();
|
|
573
|
+
_M3eDrawerToggleElement_handleClick = function _M3eDrawerToggleElement_handleClick(e) {
|
|
574
|
+
if (!e.defaultPrevented && this.control && this.parentElement) {
|
|
575
|
+
const container = this.control.closest("m3e-drawer-container");
|
|
576
|
+
if (container) {
|
|
577
|
+
if (this.control.slot === "start") {
|
|
578
|
+
container.start = !container.start;
|
|
579
|
+
}
|
|
580
|
+
else if (this.control.slot === "end") {
|
|
581
|
+
container.end = !container.end;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
_M3eDrawerToggleElement_handleDrawerContainerChange = function _M3eDrawerToggleElement_handleDrawerContainerChange() {
|
|
587
|
+
if (this.control) {
|
|
588
|
+
const container = this.control.closest("m3e-drawer-container");
|
|
589
|
+
if (container) {
|
|
590
|
+
__classPrivateFieldGet(this, _M3eDrawerToggleElement_instances, "m", _M3eDrawerToggleElement_updateToggle).call(this, container, this.control);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
_M3eDrawerToggleElement_updateToggle = function _M3eDrawerToggleElement_updateToggle(container, control) {
|
|
595
|
+
if (control.slot === "start") {
|
|
596
|
+
if (this.parentElement?.hasAttribute("toggle")) {
|
|
597
|
+
this.parentElement.toggleAttribute("selected", container.start);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
else if (control.slot === "end") {
|
|
601
|
+
if (this.parentElement?.hasAttribute("toggle")) {
|
|
602
|
+
this.parentElement.toggleAttribute("selected", container.end);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
/** The styles of the element. */
|
|
607
|
+
M3eDrawerToggleElement.styles = css `
|
|
608
|
+
:host {
|
|
609
|
+
display: contents;
|
|
610
|
+
}
|
|
611
|
+
::slotted(.material-icons) {
|
|
612
|
+
font-size: inherit !important;
|
|
613
|
+
}
|
|
614
|
+
`;
|
|
615
|
+
M3eDrawerToggleElement = __decorate([
|
|
616
|
+
t$1("m3e-drawer-toggle")
|
|
617
|
+
], M3eDrawerToggleElement);
|
|
618
|
+
|
|
619
|
+
export { M3eDrawerContainerElement, M3eDrawerToggleElement };
|
|
620
|
+
//# sourceMappingURL=index.js.map
|