@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.
- package/LICENSE +22 -0
- package/README.md +175 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +60 -0
- package/dist/css-custom-data.json +172 -0
- package/dist/custom-elements.json +787 -0
- package/dist/html-custom-data.json +72 -0
- package/dist/index.js +690 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +248 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/AccordionElement.d.ts +56 -0
- package/dist/src/AccordionElement.d.ts.map +1 -0
- package/dist/src/ExpansionHeaderElement.d.ts +60 -0
- package/dist/src/ExpansionHeaderElement.d.ts.map +1 -0
- package/dist/src/ExpansionPanelElement.d.ts +121 -0
- package/dist/src/ExpansionPanelElement.d.ts.map +1 -0
- package/dist/src/ExpansionToggleDirection.d.ts +3 -0
- package/dist/src/ExpansionToggleDirection.d.ts.map +1 -0
- package/dist/src/ExpansionTogglePosition.d.ts +3 -0
- package/dist/src/ExpansionTogglePosition.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/styles/ExpansionHeaderStyle.d.ts +6 -0
- package/dist/src/styles/ExpansionHeaderStyle.d.ts.map +1 -0
- package/dist/src/styles/ExpansionHeaderToken.d.ts +17 -0
- package/dist/src/styles/ExpansionHeaderToken.d.ts.map +1 -0
- package/dist/src/styles/ExpansionPanelStyle.d.ts +6 -0
- package/dist/src/styles/ExpansionPanelStyle.d.ts.map +1 -0
- package/dist/src/styles/ExpansionPanelToken.d.ts +21 -0
- package/dist/src/styles/ExpansionPanelToken.d.ts.map +1 -0
- package/dist/src/styles/index.d.ts +3 -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/AccordionElement.ts +115 -0
- package/src/ExpansionHeaderElement.ts +99 -0
- package/src/ExpansionPanelElement.ts +260 -0
- package/src/ExpansionToggleDirection.ts +2 -0
- package/src/ExpansionTogglePosition.ts +2 -0
- package/src/index.ts +5 -0
- package/src/styles/ExpansionHeaderStyle.ts +85 -0
- package/src/styles/ExpansionHeaderToken.ts +24 -0
- package/src/styles/ExpansionPanelStyle.ts +85 -0
- package/src/styles/ExpansionPanelToken.ts +28 -0
- package/src/styles/index.ts +2 -0
- package/tsconfig.json +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement, html, css, unsafeCSS, nothing } from 'lit';
|
|
7
|
+
import { Role, DesignToken, KeyboardClick, Focusable, Disabled, AttachInternals, EventAttribute } from '@m3e/core';
|
|
8
|
+
|
|
9
|
+
/******************************************************************************
|
|
10
|
+
Copyright (c) Microsoft Corporation.
|
|
11
|
+
|
|
12
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
+
purpose with or without fee is hereby granted.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
+
***************************************************************************** */
|
|
23
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function __decorate(decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
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;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
34
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
35
|
+
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");
|
|
36
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
40
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
41
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
42
|
+
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");
|
|
43
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
47
|
+
var e = new Error(message);
|
|
48
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @license
|
|
53
|
+
* Copyright 2017 Google LLC
|
|
54
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
55
|
+
*/
|
|
56
|
+
const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @license
|
|
60
|
+
* Copyright 2019 Google LLC
|
|
61
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
62
|
+
*/
|
|
63
|
+
const t=globalThis,e$3=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$3&&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$2=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$3)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$3?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @license
|
|
67
|
+
* Copyright 2017 Google LLC
|
|
68
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
69
|
+
*/const{is:i,defineProperty:e$2,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$1,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$2(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$1(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");
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @license
|
|
73
|
+
* Copyright 2017 Google LLC
|
|
74
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
75
|
+
*/const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r=(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(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)}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @license
|
|
79
|
+
* Copyright 2017 Google LLC
|
|
80
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
81
|
+
*/
|
|
82
|
+
const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @license
|
|
86
|
+
* Copyright 2017 Google LLC
|
|
87
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
88
|
+
*/function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$1(n,s,{get(){return o(this)}})}}
|
|
89
|
+
|
|
90
|
+
var _M3eAccordionElement_instances, _M3eAccordionElement_panels, _M3eAccordionElement_handleSlotChange, _M3eAccordionElement_handleOpening;
|
|
91
|
+
/**
|
|
92
|
+
* @summary
|
|
93
|
+
* Combines multiple expansion panels in to an accordion.
|
|
94
|
+
*
|
|
95
|
+
* @description
|
|
96
|
+
* The `m3e-accordion` component organizes multiple expansion panels into a coordinated, accessible group.
|
|
97
|
+
* It supports single or multiple open panels via the `multi` attribute, and provides expressive theming
|
|
98
|
+
* and shape control for grouped layouts. The accordion manages open/close state across its child panels,
|
|
99
|
+
* enabling interactive disclosure patterns for complex content.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* The following example illustrates the basic use of the `m3e-accordion` and `m3e-expansion-panel` components.
|
|
103
|
+
*
|
|
104
|
+
* ```html
|
|
105
|
+
* <m3e-accordion>
|
|
106
|
+
* <m3e-expansion-panel>
|
|
107
|
+
* <span slot="header">Panel 1</span>
|
|
108
|
+
* I am content for the first expansion panel
|
|
109
|
+
* </m3e-expansion-panel>
|
|
110
|
+
* <m3e-expansion-panel>
|
|
111
|
+
* <span slot="header">Panel 2</span>
|
|
112
|
+
* I am content for the second expansion panel
|
|
113
|
+
* </m3e-expansion-panel>
|
|
114
|
+
* </m3e-accordion>
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @tag m3e-accordion
|
|
118
|
+
*
|
|
119
|
+
* @slot - Renders the panels of the accordion.
|
|
120
|
+
*
|
|
121
|
+
* @attr multi - Whether multiple expansion panels can be open at the same time.
|
|
122
|
+
*/
|
|
123
|
+
let M3eAccordionElement = class M3eAccordionElement extends Role(LitElement, "none") {
|
|
124
|
+
constructor() {
|
|
125
|
+
super(...arguments);
|
|
126
|
+
_M3eAccordionElement_instances.add(this);
|
|
127
|
+
/** @private */ _M3eAccordionElement_panels.set(this, []);
|
|
128
|
+
/**
|
|
129
|
+
* Whether multiple expansion panels can be open at the same time.
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
this.multi = false;
|
|
133
|
+
}
|
|
134
|
+
/** The panels of the accordion. */
|
|
135
|
+
get panels() {
|
|
136
|
+
return __classPrivateFieldGet(this, _M3eAccordionElement_panels, "f");
|
|
137
|
+
}
|
|
138
|
+
/** @inheritdoc */
|
|
139
|
+
render() {
|
|
140
|
+
return html `<slot @slotchange="${__classPrivateFieldGet(this, _M3eAccordionElement_instances, "m", _M3eAccordionElement_handleSlotChange)}" @opening="${__classPrivateFieldGet(this, _M3eAccordionElement_instances, "m", _M3eAccordionElement_handleOpening)}"></slot>`;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
_M3eAccordionElement_panels = new WeakMap();
|
|
144
|
+
_M3eAccordionElement_instances = new WeakSet();
|
|
145
|
+
_M3eAccordionElement_handleSlotChange = function _M3eAccordionElement_handleSlotChange() {
|
|
146
|
+
__classPrivateFieldSet(this, _M3eAccordionElement_panels, [...this.querySelectorAll("m3e-expansion-panel")], "f");
|
|
147
|
+
if (this.multi) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let alreadyOpen = false;
|
|
151
|
+
for (const panel of __classPrivateFieldGet(this, _M3eAccordionElement_panels, "f").filter((x) => !x.open)) {
|
|
152
|
+
if (alreadyOpen) {
|
|
153
|
+
panel.open = false;
|
|
154
|
+
}
|
|
155
|
+
alreadyOpen = true;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
_M3eAccordionElement_handleOpening = function _M3eAccordionElement_handleOpening(e) {
|
|
159
|
+
if (!this.multi) {
|
|
160
|
+
for (const panel of __classPrivateFieldGet(this, _M3eAccordionElement_panels, "f").filter((x) => x !== e.target && x.open)) {
|
|
161
|
+
panel.open = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/** The styles of the element. */
|
|
166
|
+
M3eAccordionElement.styles = css `
|
|
167
|
+
:host {
|
|
168
|
+
display: block;
|
|
169
|
+
}
|
|
170
|
+
::slotted(m3e-expansion-panel) {
|
|
171
|
+
--m3e-expansion-panel-container-color: ${DesignToken.color.surfaceContainerLow};
|
|
172
|
+
--m3e-expansion-panel-elevation: ${DesignToken.elevation.level2};
|
|
173
|
+
--m3e-expansion-panel-open-shape: ${DesignToken.shape.corner.medium};
|
|
174
|
+
--_expansion-panel-open-spacing: 1rem;
|
|
175
|
+
}
|
|
176
|
+
::slotted(m3e-expansion-panel:first-of-type:last-of-type) {
|
|
177
|
+
--m3e-expansion-panel-shape: ${DesignToken.shape.corner.medium};
|
|
178
|
+
}
|
|
179
|
+
::slotted(m3e-expansion-panel:first-of-type:not(:last-of-type)) {
|
|
180
|
+
--m3e-expansion-panel-shape: ${DesignToken.shape.corner.value.medium} ${DesignToken.shape.corner.value.medium}
|
|
181
|
+
${DesignToken.shape.corner.value.none} ${DesignToken.shape.corner.value.none};
|
|
182
|
+
}
|
|
183
|
+
::slotted(m3e-expansion-panel:last-of-type:not(:first-of-type)) {
|
|
184
|
+
--m3e-expansion-panel-shape: ${DesignToken.shape.corner.value.none} ${DesignToken.shape.corner.value.none}
|
|
185
|
+
${DesignToken.shape.corner.value.medium} ${DesignToken.shape.corner.value.medium};
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
__decorate([
|
|
189
|
+
n({ type: Boolean })
|
|
190
|
+
], M3eAccordionElement.prototype, "multi", void 0);
|
|
191
|
+
M3eAccordionElement = __decorate([
|
|
192
|
+
t$1("m3e-accordion")
|
|
193
|
+
], M3eAccordionElement);
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Component design tokens for `M3eExpansionHeaderElement`.
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
const ExpansionHeaderToken = {
|
|
200
|
+
collapsedHeight: unsafeCSS("var(--m3e-expansion-header-collapsed-height, 3rem)"),
|
|
201
|
+
expandedHeight: unsafeCSS("var(--m3e-expansion-header-expanded-height, 4rem)"),
|
|
202
|
+
paddingLeft: unsafeCSS("var(--m3e-expansion-header-padding-left, 1.5rem)"),
|
|
203
|
+
paddingRight: unsafeCSS("var(--m3e-expansion-header-padding-right, 1.5rem)"),
|
|
204
|
+
spacing: unsafeCSS("var(--m3e-expansion-header-spacing, 0.5rem)"),
|
|
205
|
+
toggleIconSize: unsafeCSS("var(--m3e-expansion-header-toggle-icon-size, 1.5rem)"),
|
|
206
|
+
fontSize: unsafeCSS(`var(--m3e-expansion-header-font-size, ${DesignToken.typescale.standard.title.medium.fontSize})`),
|
|
207
|
+
fontWeight: unsafeCSS(`var(--m3e-expansion-header-font-weight, ${DesignToken.typescale.standard.title.medium.fontWeight})`),
|
|
208
|
+
lineHeight: unsafeCSS(`var(--m3e-expansion-header-line-height, ${DesignToken.typescale.standard.title.medium.lineHeight})`),
|
|
209
|
+
tracking: unsafeCSS(`var(--m3e-expansion-header-tracking, ${DesignToken.typescale.standard.title.medium.tracking})`),
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Styles for `M3eExpansionHeaderElement`.
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
const ExpansionHeaderStyle = css `
|
|
217
|
+
:host {
|
|
218
|
+
display: flex;
|
|
219
|
+
border-radius: inherit;
|
|
220
|
+
outline: none;
|
|
221
|
+
position: relative;
|
|
222
|
+
height: ${ExpansionHeaderToken.collapsedHeight};
|
|
223
|
+
padding-inline-start: ${ExpansionHeaderToken.paddingLeft};
|
|
224
|
+
padding-inline-end: ${ExpansionHeaderToken.paddingRight};
|
|
225
|
+
font-size: ${ExpansionHeaderToken.fontSize};
|
|
226
|
+
font-weight: ${ExpansionHeaderToken.fontWeight};
|
|
227
|
+
line-height: ${ExpansionHeaderToken.lineHeight};
|
|
228
|
+
letter-spacing: ${ExpansionHeaderToken.tracking};
|
|
229
|
+
transition: ${unsafeCSS(`height var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
230
|
+
${DesignToken.motion.easing.standard}`)};
|
|
231
|
+
|
|
232
|
+
column-gap: ${ExpansionHeaderToken.spacing};
|
|
233
|
+
}
|
|
234
|
+
:host(:not(:disabled)) {
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
}
|
|
237
|
+
:host([aria-expanded="true"]) {
|
|
238
|
+
height: ${ExpansionHeaderToken.expandedHeight};
|
|
239
|
+
}
|
|
240
|
+
:host(:not(:focus-visible)) .state-layer {
|
|
241
|
+
--m3e-state-layer-focus-color: transparent;
|
|
242
|
+
}
|
|
243
|
+
:host([aria-expanded="true"]) .state-layer {
|
|
244
|
+
--m3e-state-layer-hover-color: transparent;
|
|
245
|
+
}
|
|
246
|
+
:host([aria-expanded="true"]) [part="background"],
|
|
247
|
+
.content {
|
|
248
|
+
flex: 1 1 auto;
|
|
249
|
+
display: flex;
|
|
250
|
+
align-items: center;
|
|
251
|
+
}
|
|
252
|
+
.toggle {
|
|
253
|
+
display: flex;
|
|
254
|
+
align-items: center;
|
|
255
|
+
justify-content: center;
|
|
256
|
+
vertical-align: middle;
|
|
257
|
+
font-size: ${ExpansionHeaderToken.toggleIconSize};
|
|
258
|
+
transition: ${unsafeCSS(`transform var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
259
|
+
${DesignToken.motion.easing.standard}`)};
|
|
260
|
+
}
|
|
261
|
+
:host([toggle-direction="vertical"][aria-expanded="true"]) .toggle {
|
|
262
|
+
transform: rotate(180deg);
|
|
263
|
+
}
|
|
264
|
+
:host([toggle-direction="horizontal"][aria-expanded="true"]) .toggle {
|
|
265
|
+
transform: rotate(90deg);
|
|
266
|
+
}
|
|
267
|
+
:host([toggle-position="before"]) .toggle {
|
|
268
|
+
margin-inline-start: calc(0px - ${ExpansionHeaderToken.spacing});
|
|
269
|
+
}
|
|
270
|
+
:host([toggle-position="after"]) .toggle {
|
|
271
|
+
margin-inline-end: calc(0px - ${ExpansionHeaderToken.spacing});
|
|
272
|
+
}
|
|
273
|
+
:host([hide-toggle]) .toggle {
|
|
274
|
+
display: none;
|
|
275
|
+
}
|
|
276
|
+
::slotted([slot="toggle-icon"]) {
|
|
277
|
+
font-size: inherit !important;
|
|
278
|
+
flex: none;
|
|
279
|
+
}
|
|
280
|
+
::slotted(svg[slot="toggle-icon"]) {
|
|
281
|
+
width: 1em;
|
|
282
|
+
height: 1em;
|
|
283
|
+
}
|
|
284
|
+
@media (prefers-reduced-motion) {
|
|
285
|
+
:host,
|
|
286
|
+
.toggle {
|
|
287
|
+
transition: none;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
`;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Component design tokens for `M3eExpansionPanelElement`.
|
|
294
|
+
* @internal
|
|
295
|
+
*/
|
|
296
|
+
const ExpansionPanelToken = {
|
|
297
|
+
textColor: unsafeCSS(`var(--m3e-expansion-panel-text-color, ${DesignToken.color.onSurface})`),
|
|
298
|
+
disabledTextColor: unsafeCSS(`var(--m3e-expansion-panel-disabled-text-color, ${DesignToken.color.onSurface})`),
|
|
299
|
+
disabledTextOpacity: unsafeCSS(`var(--m3e-expansion-panel-disabled-text-opacity, 38%)`),
|
|
300
|
+
containerColor: unsafeCSS("var(--m3e-expansion-panel-container-color)"),
|
|
301
|
+
collapsedElevation: unsafeCSS("var(--m3e-expansion-panel-elevation)"),
|
|
302
|
+
collapsedShape: unsafeCSS("var(--m3e-expansion-panel-shape)"),
|
|
303
|
+
expandedElevation: unsafeCSS("var(--m3e-expansion-panel-open-elevation, var(--m3e-expansion-panel-elevation))"),
|
|
304
|
+
expandedShape: unsafeCSS("var(--m3e-expansion-panel-open-shape, var(--m3e-expansion-panel-shape))"),
|
|
305
|
+
expandedSpace: unsafeCSS("var(--_expansion-panel-open-spacing)"),
|
|
306
|
+
contentPadding: unsafeCSS("var(--m3e-expansion-panel-content-padding, 0 1.5rem 1rem 1.5rem)"),
|
|
307
|
+
actionsSpacing: unsafeCSS("var(--m3e-expansion-panel-actions-spacing, 0.5rem)"),
|
|
308
|
+
actionsPadding: unsafeCSS("var(--m3e-expansion-panel-actions-padding, 1rem 1.5rem 1rem 1.5rem)"),
|
|
309
|
+
actionsDividerThickness: unsafeCSS("var(--m3e-expansion-panel-actions-divider-thickness, var(--m3e-divider-thickness, 1px))"),
|
|
310
|
+
actionsDividerColor: unsafeCSS(`var(--m3e-expansion-panel-actions-divider-color, var(--m3e-divider-color, ${DesignToken.color.outlineVariant}))`),
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Styles for `M3eExpansionPanelElement`.
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
const ExpansionPanelStyle = css `
|
|
318
|
+
:host {
|
|
319
|
+
display: block;
|
|
320
|
+
background-color: ${ExpansionPanelToken.containerColor};
|
|
321
|
+
transition: ${unsafeCSS(`box-shadow var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
322
|
+
${DesignToken.motion.easing.standard}`)};
|
|
323
|
+
}
|
|
324
|
+
:host(:not(:disabled)) {
|
|
325
|
+
color: ${ExpansionPanelToken.textColor};
|
|
326
|
+
}
|
|
327
|
+
:host(:disabled) {
|
|
328
|
+
color: color-mix(
|
|
329
|
+
in srgb,
|
|
330
|
+
${ExpansionPanelToken.disabledTextColor} ${ExpansionPanelToken.disabledTextOpacity},
|
|
331
|
+
transparent
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
:host(:not([open])) {
|
|
335
|
+
box-shadow: ${ExpansionPanelToken.collapsedElevation};
|
|
336
|
+
border-radius: ${ExpansionPanelToken.collapsedShape};
|
|
337
|
+
}
|
|
338
|
+
:host([open]) {
|
|
339
|
+
box-shadow: ${ExpansionPanelToken.expandedElevation};
|
|
340
|
+
border-radius: ${ExpansionPanelToken.expandedShape};
|
|
341
|
+
margin-block: ${ExpansionPanelToken.expandedSpace};
|
|
342
|
+
}
|
|
343
|
+
.toggle {
|
|
344
|
+
display: flex;
|
|
345
|
+
align-items: center;
|
|
346
|
+
justify-content: center;
|
|
347
|
+
font-size: ${ExpansionHeaderToken.toggleIconSize};
|
|
348
|
+
}
|
|
349
|
+
::slotted([slot="toggle-icon"]) {
|
|
350
|
+
font-size: inherit !important;
|
|
351
|
+
flex: none;
|
|
352
|
+
}
|
|
353
|
+
.toggle svg,
|
|
354
|
+
::slotted(svg[slot="toggle-icon"]) {
|
|
355
|
+
width: 1em;
|
|
356
|
+
height: 1em;
|
|
357
|
+
}
|
|
358
|
+
.content {
|
|
359
|
+
padding: ${ExpansionPanelToken.contentPadding};
|
|
360
|
+
}
|
|
361
|
+
::slotted([slot="actions"]) {
|
|
362
|
+
flex: none;
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
column-gap: ${ExpansionPanelToken.actionsSpacing};
|
|
366
|
+
padding: ${ExpansionPanelToken.actionsPadding};
|
|
367
|
+
border-top-style: solid;
|
|
368
|
+
border-top-width: ${ExpansionPanelToken.actionsDividerThickness};
|
|
369
|
+
border-top-color: ${ExpansionPanelToken.actionsDividerColor};
|
|
370
|
+
}
|
|
371
|
+
::slotted([slot="actions"][end]) {
|
|
372
|
+
justify-content: flex-end;
|
|
373
|
+
}
|
|
374
|
+
@media (prefers-reduced-motion) {
|
|
375
|
+
:host {
|
|
376
|
+
transition: none;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
@media (forced-colors: active) {
|
|
380
|
+
:host {
|
|
381
|
+
border: 1px solid CanvasText;
|
|
382
|
+
}
|
|
383
|
+
:host(:disabled) {
|
|
384
|
+
color: GrayText;
|
|
385
|
+
}
|
|
386
|
+
::slotted([slot="actions"]) {
|
|
387
|
+
border-top-color: GrayText;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
`;
|
|
391
|
+
|
|
392
|
+
var _M3eExpansionHeaderElement_instances, _M3eExpansionHeaderElement_renderToggle;
|
|
393
|
+
/**
|
|
394
|
+
* A button used to toggle the expanded state of an expansion panel.
|
|
395
|
+
*
|
|
396
|
+
* @tag m3e-expansion-header
|
|
397
|
+
*
|
|
398
|
+
* @slot - Renders the content of the header.
|
|
399
|
+
* @slot toggle-icon - Renders the icon of the expansion toggle.
|
|
400
|
+
*
|
|
401
|
+
* @attr hide-toggle - Whether to hide the expansion toggle.
|
|
402
|
+
* @attr toggle-direction - The direction of the expansion toggle.
|
|
403
|
+
* @attr toggle-position - The position of the expansion toggle.
|
|
404
|
+
*
|
|
405
|
+
* @cssprop --m3e-expansion-header-collapsed-height - Height of the header when the panel is collapsed.
|
|
406
|
+
* @cssprop --m3e-expansion-header-expanded-height - Height of the header when the panel is expanded.
|
|
407
|
+
* @cssprop --m3e-expansion-header-padding-left - Left padding inside the header.
|
|
408
|
+
* @cssprop --m3e-expansion-header-padding-right - Right padding inside the header.
|
|
409
|
+
* @cssprop --m3e-expansion-header-spacing - Spacing between header elements.
|
|
410
|
+
* @cssprop --m3e-expansion-header-toggle-icon-size - Size of the toggle icon (e.g. chevron).
|
|
411
|
+
* @cssprop --m3e-expansion-header-font-size - The font size of the header text.
|
|
412
|
+
* @cssprop --m3e-expansion-header-font-weight - The font weight of the header text.
|
|
413
|
+
* @cssprop --m3e-expansion-header-line-height - The line height of the header text.
|
|
414
|
+
* @cssprop --m3e-expansion-header-tracking - Letter spacing (tracking) of the header text.
|
|
415
|
+
*/
|
|
416
|
+
let M3eExpansionHeaderElement = class M3eExpansionHeaderElement extends KeyboardClick(Focusable(Disabled(AttachInternals(Role(LitElement, "button"), true)))) {
|
|
417
|
+
constructor() {
|
|
418
|
+
super(...arguments);
|
|
419
|
+
_M3eExpansionHeaderElement_instances.add(this);
|
|
420
|
+
/**
|
|
421
|
+
* The direction of the expansion toggle.
|
|
422
|
+
* @default "vertical"
|
|
423
|
+
*/
|
|
424
|
+
this.toggleDirection = "vertical";
|
|
425
|
+
/**
|
|
426
|
+
* The position of the expansion toggle.
|
|
427
|
+
* @default "after"
|
|
428
|
+
*/
|
|
429
|
+
this.togglePosition = "after";
|
|
430
|
+
/**
|
|
431
|
+
* Whether to hide the expansion toggle.
|
|
432
|
+
* @default false
|
|
433
|
+
*/
|
|
434
|
+
this.hideToggle = false;
|
|
435
|
+
}
|
|
436
|
+
/** @inheritdoc */
|
|
437
|
+
firstUpdated(_changedProperties) {
|
|
438
|
+
super.firstUpdated(_changedProperties);
|
|
439
|
+
[this._focusRing, this._stateLayer].forEach((x) => x?.attach(this));
|
|
440
|
+
}
|
|
441
|
+
/** @inheritdoc */
|
|
442
|
+
render() {
|
|
443
|
+
return html `<m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
444
|
+
<m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
|
|
445
|
+
${this.togglePosition === "before" ? __classPrivateFieldGet(this, _M3eExpansionHeaderElement_instances, "m", _M3eExpansionHeaderElement_renderToggle).call(this) : nothing}
|
|
446
|
+
<div class="content">
|
|
447
|
+
<slot></slot>
|
|
448
|
+
</div>
|
|
449
|
+
${this.togglePosition === "after" ? __classPrivateFieldGet(this, _M3eExpansionHeaderElement_instances, "m", _M3eExpansionHeaderElement_renderToggle).call(this) : nothing}`;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
_M3eExpansionHeaderElement_instances = new WeakSet();
|
|
453
|
+
_M3eExpansionHeaderElement_renderToggle = function _M3eExpansionHeaderElement_renderToggle() {
|
|
454
|
+
return html `<div class="toggle" aria-hidden="true">
|
|
455
|
+
<slot name="toggle-icon"></slot>
|
|
456
|
+
</div>`;
|
|
457
|
+
};
|
|
458
|
+
/** The styles of the element. */
|
|
459
|
+
M3eExpansionHeaderElement.styles = ExpansionHeaderStyle;
|
|
460
|
+
__decorate([
|
|
461
|
+
e(".focus-ring")
|
|
462
|
+
], M3eExpansionHeaderElement.prototype, "_focusRing", void 0);
|
|
463
|
+
__decorate([
|
|
464
|
+
e(".state-layer")
|
|
465
|
+
], M3eExpansionHeaderElement.prototype, "_stateLayer", void 0);
|
|
466
|
+
__decorate([
|
|
467
|
+
n({ attribute: "toggle-direction", reflect: true })
|
|
468
|
+
], M3eExpansionHeaderElement.prototype, "toggleDirection", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
n({ attribute: "toggle-position", reflect: true })
|
|
471
|
+
], M3eExpansionHeaderElement.prototype, "togglePosition", void 0);
|
|
472
|
+
__decorate([
|
|
473
|
+
n({ attribute: "hide-toggle", type: Boolean, reflect: true })
|
|
474
|
+
], M3eExpansionHeaderElement.prototype, "hideToggle", void 0);
|
|
475
|
+
M3eExpansionHeaderElement = __decorate([
|
|
476
|
+
t$1("m3e-expansion-header")
|
|
477
|
+
], M3eExpansionHeaderElement);
|
|
478
|
+
|
|
479
|
+
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
480
|
+
var _M3eExpansionPanelElement_instances, _M3eExpansionPanelElement_id, _M3eExpansionPanelElement_contentId, _M3eExpansionPanelElement_headerId, _M3eExpansionPanelElement_renderToggleIcon, _M3eExpansionPanelElement_handleHeaderClick, _M3eExpansionPanelElement_handleKeyDown, _M3eExpansionPanelElement_handleCollapsibleEvent;
|
|
481
|
+
var M3eExpansionPanelElement_1;
|
|
482
|
+
/**
|
|
483
|
+
* @summary
|
|
484
|
+
* An expandable details-summary view.
|
|
485
|
+
*
|
|
486
|
+
* @description
|
|
487
|
+
* The `m3e-expansion-panel` component provides an accessible, animated details-summary view for
|
|
488
|
+
* organizing content in collapsible sections. It supports custom header, content, actions, and
|
|
489
|
+
* toggle icon slots, and offers configurable toggle position and direction. The panel responds to
|
|
490
|
+
* open/close states, emits lifecycle events, and supports rich theming via CSS custom properties
|
|
491
|
+
* for elevation, shape, spacing, and color.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* The following example illustrates the basic use of the `m3e-accordion` and `m3e-expansion-panel` components.
|
|
495
|
+
*
|
|
496
|
+
* ```html
|
|
497
|
+
* <m3e-accordion>
|
|
498
|
+
* <m3e-expansion-panel>
|
|
499
|
+
* <span slot="header">Panel 1</span>
|
|
500
|
+
* I am content for the first expansion panel
|
|
501
|
+
* </m3e-expansion-panel>
|
|
502
|
+
* <m3e-expansion-panel>
|
|
503
|
+
* <span slot="header">Panel 2</span>
|
|
504
|
+
* I am content for the second expansion panel
|
|
505
|
+
* </m3e-expansion-panel>
|
|
506
|
+
* </m3e-accordion>
|
|
507
|
+
* ```
|
|
508
|
+
*
|
|
509
|
+
* @tag m3e-expansion-panel
|
|
510
|
+
*
|
|
511
|
+
* @slot - Renders the detail of the panel.
|
|
512
|
+
* @slot actions- Renders the actions bar of the panel.
|
|
513
|
+
* @slot header - Renders the header content.
|
|
514
|
+
* @slot toggle-icon - Renders the expansion toggle icon.
|
|
515
|
+
*
|
|
516
|
+
* @attr disabled - Whether the element is disabled.
|
|
517
|
+
* @attr hide-toggle - Whether to hide the expansion toggle.
|
|
518
|
+
* @attr open - Whether the panel is expanded.
|
|
519
|
+
* @attr toggle-direction - The direction of the expansion toggle.
|
|
520
|
+
* @attr toggle-position - The position of the expansion toggle.
|
|
521
|
+
*
|
|
522
|
+
* @fires opening - Emitted when the expansion panel begins to open.
|
|
523
|
+
* @fires opened - Emitted when the expansion panel has opened.
|
|
524
|
+
* @fires closing - Emitted when the expansion panel begins to close.
|
|
525
|
+
* @fires closed - Emitted when the expansion panel has closed.
|
|
526
|
+
*
|
|
527
|
+
* @cssprop --m3e-expansion-header-collapsed-height - Height of the header when the panel is collapsed.
|
|
528
|
+
* @cssprop --m3e-expansion-header-expanded-height - Height of the header when the panel is expanded.
|
|
529
|
+
* @cssprop --m3e-expansion-header-padding-left - Left padding inside the header.
|
|
530
|
+
* @cssprop --m3e-expansion-header-padding-right - Right padding inside the header.
|
|
531
|
+
* @cssprop --m3e-expansion-header-spacing - Spacing between header elements.
|
|
532
|
+
* @cssprop --m3e-expansion-header-toggle-icon-size - Size of the toggle icon (e.g. chevron).
|
|
533
|
+
* @cssprop --m3e-expansion-header-font-size - The font size of the header text.
|
|
534
|
+
* @cssprop --m3e-expansion-header-font-weight - The font weight of the header text.
|
|
535
|
+
* @cssprop --m3e-expansion-header-line-height - The line height of the header text.
|
|
536
|
+
* @cssprop --m3e-expansion-header-tracking - Letter spacing (tracking) of the header text.
|
|
537
|
+
* @cssprop --m3e-expansion-panel-text-color - Color of the panel's text content.
|
|
538
|
+
* @cssprop --m3e-expansion-panel-disabled-text-color - Color of the panel's text content, when disabled.
|
|
539
|
+
* @cssprop --m3e-expansion-panel-disabled-text-opacity - Opacity of the panel's text content, when disabled.
|
|
540
|
+
* @cssprop --m3e-expansion-panel-container-color - Background color of the panel container.
|
|
541
|
+
* @cssprop --m3e-expansion-panel-elevation - Elevation level when the panel is collapsed.
|
|
542
|
+
* @cssprop --m3e-expansion-panel-shape - Shape (e.g. border radius) of the panel when collapsed.
|
|
543
|
+
* @cssprop --m3e-expansion-panel-open-elevation - Elevation level when the panel is expanded.
|
|
544
|
+
* @cssprop --m3e-expansion-panel-open-shape - Shape (e.g. border radius) of the panel when expanded.
|
|
545
|
+
* @cssprop --m3e-expansion-panel-content-padding - Padding around the panel's content area.
|
|
546
|
+
* @cssprop --m3e-expansion-panel-actions-spacing - Spacing between action buttons or elements.
|
|
547
|
+
* @cssprop --m3e-expansion-panel-actions-padding - Padding around the actions section.
|
|
548
|
+
* @cssprop --m3e-expansion-panel-actions-divider-thickness - Thickness of the divider above actions.
|
|
549
|
+
* @cssprop --m3e-expansion-panel-actions-divider-color - Color of the divider above actions.
|
|
550
|
+
*/
|
|
551
|
+
let M3eExpansionPanelElement = M3eExpansionPanelElement_1 = class M3eExpansionPanelElement extends EventAttribute(Disabled(AttachInternals(Role(LitElement, "none"), true)), "opening", "opened", "closing", "closed") {
|
|
552
|
+
constructor() {
|
|
553
|
+
super(...arguments);
|
|
554
|
+
_M3eExpansionPanelElement_instances.add(this);
|
|
555
|
+
/** @private */ _M3eExpansionPanelElement_id.set(this, M3eExpansionPanelElement_1.__nextId++);
|
|
556
|
+
/** @private */ _M3eExpansionPanelElement_contentId.set(this, `m3e-expansion-panel-${__classPrivateFieldGet(this, _M3eExpansionPanelElement_id, "f")}-content`);
|
|
557
|
+
/** @private */ _M3eExpansionPanelElement_headerId.set(this, `m3e-expansion-panel-${__classPrivateFieldGet(this, _M3eExpansionPanelElement_id, "f")}-header`);
|
|
558
|
+
/**
|
|
559
|
+
* Whether the panel is expanded.
|
|
560
|
+
* @default false
|
|
561
|
+
*/
|
|
562
|
+
this.open = false;
|
|
563
|
+
/**
|
|
564
|
+
* The direction of the expansion toggle.
|
|
565
|
+
* @default "vertical"
|
|
566
|
+
*/
|
|
567
|
+
this.toggleDirection = "vertical";
|
|
568
|
+
/**
|
|
569
|
+
* The position of the expansion toggle.
|
|
570
|
+
* @default "after"
|
|
571
|
+
*/
|
|
572
|
+
this.togglePosition = "after";
|
|
573
|
+
/**
|
|
574
|
+
* Whether to hide the expansion toggle.
|
|
575
|
+
* @default false
|
|
576
|
+
*/
|
|
577
|
+
this.hideToggle = false;
|
|
578
|
+
}
|
|
579
|
+
/** @inheritdoc */
|
|
580
|
+
render() {
|
|
581
|
+
return html ` <m3e-expansion-header
|
|
582
|
+
id="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_headerId, "f")}"
|
|
583
|
+
toggle-direction="${this.toggleDirection}"
|
|
584
|
+
toggle-position="${this.togglePosition}"
|
|
585
|
+
?hide-toggle="${this.hideToggle}"
|
|
586
|
+
?disabled="${this.disabled}"
|
|
587
|
+
aria-expanded="${this.open}"
|
|
588
|
+
aria-controls="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_contentId, "f")}"
|
|
589
|
+
@click="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleHeaderClick)}"
|
|
590
|
+
@keydown="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleKeyDown)}"
|
|
591
|
+
>
|
|
592
|
+
<div slot="toggle-icon" class="toggle">
|
|
593
|
+
<slot name="toggle-icon">${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_renderToggleIcon).call(this)}</slot>
|
|
594
|
+
</div>
|
|
595
|
+
<slot name="header"></slot>
|
|
596
|
+
</m3e-expansion-header>
|
|
597
|
+
<m3e-collapsible
|
|
598
|
+
id="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_contentId, "f")}"
|
|
599
|
+
role="region"
|
|
600
|
+
aria-labelledby="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_headerId, "f")}"
|
|
601
|
+
aria-hidden="${!this.open}"
|
|
602
|
+
?open="${this.open}"
|
|
603
|
+
@opening="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleCollapsibleEvent)}"
|
|
604
|
+
@opened="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleCollapsibleEvent)}"
|
|
605
|
+
@closing="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleCollapsibleEvent)}"
|
|
606
|
+
@closed="${__classPrivateFieldGet(this, _M3eExpansionPanelElement_instances, "m", _M3eExpansionPanelElement_handleCollapsibleEvent)}"
|
|
607
|
+
>
|
|
608
|
+
<div class="content">
|
|
609
|
+
<slot></slot>
|
|
610
|
+
</div>
|
|
611
|
+
<slot name="actions"></slot>
|
|
612
|
+
</m3e-collapsible>`;
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
_M3eExpansionPanelElement_id = new WeakMap();
|
|
616
|
+
_M3eExpansionPanelElement_contentId = new WeakMap();
|
|
617
|
+
_M3eExpansionPanelElement_headerId = new WeakMap();
|
|
618
|
+
_M3eExpansionPanelElement_instances = new WeakSet();
|
|
619
|
+
_M3eExpansionPanelElement_renderToggleIcon = function _M3eExpansionPanelElement_renderToggleIcon() {
|
|
620
|
+
return this.toggleDirection === "vertical"
|
|
621
|
+
? html `<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
622
|
+
<path d="M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z" />
|
|
623
|
+
</svg>`
|
|
624
|
+
: html `<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
625
|
+
<path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z" />
|
|
626
|
+
</svg>`;
|
|
627
|
+
};
|
|
628
|
+
_M3eExpansionPanelElement_handleHeaderClick = function _M3eExpansionPanelElement_handleHeaderClick() {
|
|
629
|
+
this.open = !this.open;
|
|
630
|
+
};
|
|
631
|
+
_M3eExpansionPanelElement_handleKeyDown = function _M3eExpansionPanelElement_handleKeyDown(e) {
|
|
632
|
+
switch (e.key) {
|
|
633
|
+
case "ArrowUp":
|
|
634
|
+
{
|
|
635
|
+
e.preventDefault();
|
|
636
|
+
const accordion = this.closest("m3e-accordion");
|
|
637
|
+
if (accordion) {
|
|
638
|
+
const panels = [...accordion.panels].reverse();
|
|
639
|
+
const index = panels.indexOf(this);
|
|
640
|
+
(panels.find((x, i) => !x.disabled && i > index) ?? panels.find((x, i) => !x.disabled && i < index))?._header?.focus();
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
this.open = false;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
break;
|
|
647
|
+
case "ArrowDown":
|
|
648
|
+
{
|
|
649
|
+
e.preventDefault();
|
|
650
|
+
const accordion = this.closest("m3e-accordion");
|
|
651
|
+
if (accordion) {
|
|
652
|
+
const index = accordion.panels.indexOf(this);
|
|
653
|
+
(accordion.panels.find((x, i) => !x.disabled && i > index) ??
|
|
654
|
+
accordion.panels.find((x, i) => !x.disabled && i < index))?._header?.focus();
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
this.open = true;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
_M3eExpansionPanelElement_handleCollapsibleEvent = function _M3eExpansionPanelElement_handleCollapsibleEvent(e) {
|
|
664
|
+
e.stopPropagation();
|
|
665
|
+
this.dispatchEvent(new Event(e.type, { bubbles: true }));
|
|
666
|
+
};
|
|
667
|
+
/** The styles of the element. */
|
|
668
|
+
M3eExpansionPanelElement.styles = ExpansionPanelStyle;
|
|
669
|
+
/** @private */ M3eExpansionPanelElement.__nextId = 0;
|
|
670
|
+
__decorate([
|
|
671
|
+
e("m3e-expansion-header")
|
|
672
|
+
], M3eExpansionPanelElement.prototype, "_header", void 0);
|
|
673
|
+
__decorate([
|
|
674
|
+
n({ type: Boolean, reflect: true })
|
|
675
|
+
], M3eExpansionPanelElement.prototype, "open", void 0);
|
|
676
|
+
__decorate([
|
|
677
|
+
n({ attribute: "toggle-direction", reflect: true })
|
|
678
|
+
], M3eExpansionPanelElement.prototype, "toggleDirection", void 0);
|
|
679
|
+
__decorate([
|
|
680
|
+
n({ attribute: "toggle-position", reflect: true })
|
|
681
|
+
], M3eExpansionPanelElement.prototype, "togglePosition", void 0);
|
|
682
|
+
__decorate([
|
|
683
|
+
n({ attribute: "hide-toggle", type: Boolean, reflect: true })
|
|
684
|
+
], M3eExpansionPanelElement.prototype, "hideToggle", void 0);
|
|
685
|
+
M3eExpansionPanelElement = M3eExpansionPanelElement_1 = __decorate([
|
|
686
|
+
t$1("m3e-expansion-panel")
|
|
687
|
+
], M3eExpansionPanelElement);
|
|
688
|
+
|
|
689
|
+
export { M3eAccordionElement, M3eExpansionHeaderElement, M3eExpansionPanelElement };
|
|
690
|
+
//# sourceMappingURL=index.js.map
|