@m3e/dialog 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +143 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +60 -0
- package/dist/css-custom-data.json +97 -0
- package/dist/custom-elements.json +639 -0
- package/dist/html-custom-data.json +61 -0
- package/dist/index.js +619 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +212 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/DialogActionElement.d.ts +31 -0
- package/dist/src/DialogActionElement.d.ts.map +1 -0
- package/dist/src/DialogElement.d.ts +141 -0
- package/dist/src/DialogElement.d.ts.map +1 -0
- package/dist/src/DialogTriggerElement.d.ts +24 -0
- package/dist/src/DialogTriggerElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/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/DialogActionElement.ts +56 -0
- package/src/DialogElement.ts +472 -0
- package/src/DialogTriggerElement.ts +50 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
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, nothing, unsafeCSS } from 'lit';
|
|
7
|
+
import { AttachInternals, Role, EventAttribute, prefersReducedMotion, DesignToken, HtmlFor } 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$2=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$1=globalThis,e$4=t$1.ShadowRoot&&(void 0===t$1.ShadyCSS||t$1.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$4=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$1)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$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$1.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @license
|
|
67
|
+
* Copyright 2017 Google LLC
|
|
68
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
69
|
+
*/const{is:i$1,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$3,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1: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$1=(t,s)=>!i$1(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.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$3(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(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$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$3(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$2(s));}else void 0!==s&&i.push(c$2(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$1(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$1).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$1;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$1)(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$1("elementProperties")]=new Map,y[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @license
|
|
73
|
+
* Copyright 2017 Google LLC
|
|
74
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
75
|
+
*/const o$2={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$2=(t=o$2,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$1(t){return (e,o)=>"object"==typeof o?r$2(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
|
+
*/function r$1(r){return n$1({...r,state:true,attribute:false})}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @license
|
|
85
|
+
* Copyright 2017 Google LLC
|
|
86
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
87
|
+
*/
|
|
88
|
+
const e$2=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @license
|
|
92
|
+
* Copyright 2017 Google LLC
|
|
93
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
94
|
+
*/function e$1(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$2(n,s,{get(){return o(this)}})}}
|
|
95
|
+
|
|
96
|
+
var _M3eDialogActionElement_clickHandler;
|
|
97
|
+
/**
|
|
98
|
+
* An element, nested within a clickable element, used to close a parenting dialog.
|
|
99
|
+
* @tag m3e-dialog-action
|
|
100
|
+
*
|
|
101
|
+
* @attr return-value - The value to return from the dialog.
|
|
102
|
+
*/
|
|
103
|
+
let M3eDialogActionElement = class M3eDialogActionElement extends AttachInternals(Role(LitElement, "none")) {
|
|
104
|
+
constructor() {
|
|
105
|
+
super(...arguments);
|
|
106
|
+
/**
|
|
107
|
+
* The value to return from the dialog.
|
|
108
|
+
* @default ""
|
|
109
|
+
*/
|
|
110
|
+
this.returnValue = "";
|
|
111
|
+
/** @private */
|
|
112
|
+
_M3eDialogActionElement_clickHandler.set(this, (e) => {
|
|
113
|
+
if (!e.defaultPrevented) {
|
|
114
|
+
this.closest("m3e-dialog")?.hide(this.returnValue);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** @inheritdoc */
|
|
119
|
+
connectedCallback() {
|
|
120
|
+
super.connectedCallback();
|
|
121
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _M3eDialogActionElement_clickHandler, "f"));
|
|
122
|
+
}
|
|
123
|
+
/** @inheritdoc */
|
|
124
|
+
disconnectedCallback() {
|
|
125
|
+
super.disconnectedCallback();
|
|
126
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _M3eDialogActionElement_clickHandler, "f"));
|
|
127
|
+
}
|
|
128
|
+
/** @inheritdoc */
|
|
129
|
+
render() {
|
|
130
|
+
return html `<slot></slot>`;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
_M3eDialogActionElement_clickHandler = new WeakMap();
|
|
134
|
+
/** The styles of the element. */
|
|
135
|
+
M3eDialogActionElement.styles = css `
|
|
136
|
+
:host {
|
|
137
|
+
display: contents;
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
__decorate([
|
|
141
|
+
n$1({ attribute: "return-value" })
|
|
142
|
+
], M3eDialogActionElement.prototype, "returnValue", void 0);
|
|
143
|
+
M3eDialogActionElement = __decorate([
|
|
144
|
+
t$2("m3e-dialog-action")
|
|
145
|
+
], M3eDialogActionElement);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @license
|
|
149
|
+
* Copyright 2017 Google LLC
|
|
150
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
151
|
+
*/
|
|
152
|
+
const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$1="?"+h,n=`<${o$1}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @license
|
|
156
|
+
* Copyright 2018 Google LLC
|
|
157
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
158
|
+
*/const o=o=>o??E;
|
|
159
|
+
|
|
160
|
+
var _M3eDialogElement_instances, _M3eDialogElement_id, _M3eDialogElement_open, _M3eDialogElement_escapePressedWithoutCancel, _M3eDialogElement_renderCloseButton, _M3eDialogElement_handleClose, _M3eDialogElement_handleCancel, _M3eDialogElement_handleClick, _M3eDialogElement_handleKeyDown, _M3eDialogElement_handleActionsSlotChange;
|
|
161
|
+
var M3eDialogElement_1;
|
|
162
|
+
/**
|
|
163
|
+
* @summary
|
|
164
|
+
* A dialog that provides important prompts in a user flow.
|
|
165
|
+
*
|
|
166
|
+
* @description
|
|
167
|
+
* The `m3e-dialog` component presents important prompts, alerts, and actions in user flows.
|
|
168
|
+
* Designed according to Material 3 principles, it supports custom header, content, and
|
|
169
|
+
* close icon slots, ARIA accessibility, focus management, and theming via CSS custom properties.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```html
|
|
173
|
+
* <m3e-button variant="filled">
|
|
174
|
+
* <m3e-dialog-trigger for="dlg">Open Dialog</m3e-dialog-trigger>
|
|
175
|
+
* </m3e-button>
|
|
176
|
+
* <m3e-dialog id="dlg" dismissible onclosed="console.log(this.returnValue)">
|
|
177
|
+
* <span slot="header">Dialog Title</span>
|
|
178
|
+
* Dialog content goes here.
|
|
179
|
+
* <div slot="actions" end>
|
|
180
|
+
* <m3e-button autofocus><m3e-dialog-action return-value="ok">Close</m3e-dialog-action></m3e-button>
|
|
181
|
+
* </div>
|
|
182
|
+
* </m3e-dialog>
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @tag m3e-dialog
|
|
186
|
+
*
|
|
187
|
+
* @slot - Renders the content of the dialog.
|
|
188
|
+
* @slot header - Renders the header of the dialog.
|
|
189
|
+
* @slot close-icon - Renders the icon of the button used to close the dialog.
|
|
190
|
+
*
|
|
191
|
+
* @attr alert - Whether the dialog is an alert.
|
|
192
|
+
* @attr close-label - The accessible label given to the button used to dismiss the dialog.
|
|
193
|
+
* @attr disable-close -Whether users cannot click the backdrop or press escape to dismiss the dialog.
|
|
194
|
+
* @attr dismissible - Whether a button is presented that can be used to close the dialog.
|
|
195
|
+
* @attr no-focus-trap - Whether to disable focus trapping, which keeps keyboard `Tab` navigation within the dialog.
|
|
196
|
+
* @attr open - Whether the dialog is open.
|
|
197
|
+
*
|
|
198
|
+
* @fires opening - Emitted when the dialog begins to open.
|
|
199
|
+
* @fires opened - Emitted when the dialog has opened.
|
|
200
|
+
* @fires cancel - Emitted when the dialog is cancelled.
|
|
201
|
+
* @fires closing - Emitted when the dialog begins to close.
|
|
202
|
+
* @fires closed - Emitted when the dialog has closed.
|
|
203
|
+
*
|
|
204
|
+
* @cssprop --m3e-dialog-shape - Border radius of the dialog container.
|
|
205
|
+
* @cssprop --m3e-dialog-min-width - Minimum width of the dialog.
|
|
206
|
+
* @cssprop --m3e-dialog-max-width - Maximum width of the dialog.
|
|
207
|
+
* @cssprop --m3e-dialog-color - Foreground color of the dialog.
|
|
208
|
+
* @cssprop --m3e-dialog-container-color - Background color of the dialog container.
|
|
209
|
+
* @cssprop --m3e-dialog-scrim-color - Color of the scrim (backdrop overlay).
|
|
210
|
+
* @cssprop --m3e-dialog-scrim-opacity - Opacity of the scrim when open.
|
|
211
|
+
* @cssprop --m3e-dialog-header-container-color - Background color of the dialog header.
|
|
212
|
+
* @cssprop --m3e-dialog-header-color - Foreground color of the dialog header.
|
|
213
|
+
* @cssprop --m3e-dialog-header-font-size - Font size for the dialog header.
|
|
214
|
+
* @cssprop --m3e-dialog-header-font-weight - Font weight for the dialog header.
|
|
215
|
+
* @cssprop --m3e-dialog-header-line-height - Line height for the dialog header.
|
|
216
|
+
* @cssprop --m3e-dialog-header-tracking - Letter spacing for the dialog header.
|
|
217
|
+
* @cssprop --m3e-dialog-content-color - Foreground color of the dialog content.
|
|
218
|
+
* @cssprop --m3e-dialog-content-font-size - Font size for the dialog content.
|
|
219
|
+
* @cssprop --m3e-dialog-content-font-weight - Font weight for the dialog content.
|
|
220
|
+
* @cssprop --m3e-dialog-content-line-height - Line height for the dialog content.
|
|
221
|
+
* @cssprop --m3e-dialog-content-tracking - Letter spacing for the dialog content.
|
|
222
|
+
*/
|
|
223
|
+
let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends EventAttribute(Role(LitElement, "none"), "opening", "opened", "cancel", "closing", "closed") {
|
|
224
|
+
constructor() {
|
|
225
|
+
super(...arguments);
|
|
226
|
+
_M3eDialogElement_instances.add(this);
|
|
227
|
+
/** @private */ _M3eDialogElement_id.set(this, M3eDialogElement_1.__nextId++);
|
|
228
|
+
/** @private */ _M3eDialogElement_open.set(this, false);
|
|
229
|
+
/** @private */ _M3eDialogElement_escapePressedWithoutCancel.set(this, false);
|
|
230
|
+
/** @private */ this._hasActions = false;
|
|
231
|
+
/**
|
|
232
|
+
* Whether the dialog is an alert.
|
|
233
|
+
* @default false
|
|
234
|
+
*/
|
|
235
|
+
this.alert = false;
|
|
236
|
+
/**
|
|
237
|
+
* Whether a button is presented that can be used to close the dialog.
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
|
+
this.dismissible = false;
|
|
241
|
+
/**
|
|
242
|
+
* Whether users cannot click the backdrop or press ESC to dismiss the dialog.
|
|
243
|
+
* @default false
|
|
244
|
+
*/
|
|
245
|
+
this.disableClose = false;
|
|
246
|
+
/**
|
|
247
|
+
* Whether to disable focus trapping, which keeps keyboard `Tab` navigation within the dialog.
|
|
248
|
+
* @default false
|
|
249
|
+
*/
|
|
250
|
+
this.noFocusTrap = false;
|
|
251
|
+
/**
|
|
252
|
+
* The accessible label given to the button used to dismiss the dialog.
|
|
253
|
+
* @default "Close"
|
|
254
|
+
*/
|
|
255
|
+
this.closeLabel = "Close";
|
|
256
|
+
/**
|
|
257
|
+
* The return value of the dialog.
|
|
258
|
+
* @default ""
|
|
259
|
+
*/
|
|
260
|
+
this.returnValue = "";
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Whether the dialog is open.
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
get open() {
|
|
267
|
+
return __classPrivateFieldGet(this, _M3eDialogElement_open, "f");
|
|
268
|
+
}
|
|
269
|
+
set open(value) {
|
|
270
|
+
if (value === __classPrivateFieldGet(this, _M3eDialogElement_open, "f"))
|
|
271
|
+
return;
|
|
272
|
+
__classPrivateFieldSet(this, _M3eDialogElement_open, value, "f");
|
|
273
|
+
if (__classPrivateFieldGet(this, _M3eDialogElement_open, "f")) {
|
|
274
|
+
this.show();
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.hide();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Asynchronously opens the dialog.
|
|
282
|
+
* @returns {Promise<void>} A `Promise` that resolves when the dialog is open.
|
|
283
|
+
*/
|
|
284
|
+
async show() {
|
|
285
|
+
await this.updateComplete;
|
|
286
|
+
if (this._base.open) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (!this.dispatchEvent(new Event("opening", { cancelable: true }))) {
|
|
290
|
+
this.open = false;
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
this._base.showModal();
|
|
294
|
+
this._content.scrollTop = 0;
|
|
295
|
+
const focusable = this.querySelector("[autofocus]");
|
|
296
|
+
if (focusable) {
|
|
297
|
+
if (!prefersReducedMotion()) {
|
|
298
|
+
this._base.addEventListener("transitionend", () => focusable.focus(), {
|
|
299
|
+
once: true,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
focusable.focus();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
this.dispatchEvent(new Event("opened"));
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Asynchronously closes the dialog.
|
|
310
|
+
* @param {string} returnValue The value to return.
|
|
311
|
+
* @returns {Promise<void>} A `Promise` that resolves when the dialog is closed.
|
|
312
|
+
*/
|
|
313
|
+
async hide(returnValue = this.returnValue) {
|
|
314
|
+
if (!this.isConnected) {
|
|
315
|
+
this.open = false;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
await this.updateComplete;
|
|
319
|
+
if (!this._base.open) {
|
|
320
|
+
this.open = false;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const prevReturnValue = this.returnValue;
|
|
324
|
+
this.returnValue = returnValue;
|
|
325
|
+
if (!this.dispatchEvent(new Event("closing", { cancelable: true }))) {
|
|
326
|
+
this.returnValue = prevReturnValue;
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
this.open = false;
|
|
330
|
+
this._base.close(returnValue);
|
|
331
|
+
this.dispatchEvent(new Event("closed"));
|
|
332
|
+
}
|
|
333
|
+
/** @inheritdoc */
|
|
334
|
+
render() {
|
|
335
|
+
return html `<dialog
|
|
336
|
+
class="base"
|
|
337
|
+
role="${o(this.alert ? "alertdialog" : undefined)}"
|
|
338
|
+
aria-labelledby="m3e-dialog-${__classPrivateFieldGet(this, _M3eDialogElement_id, "f")}-header"
|
|
339
|
+
.returnValue="${this.returnValue}"
|
|
340
|
+
@close="${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_handleClose)}"
|
|
341
|
+
@cancel="${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_handleCancel)}"
|
|
342
|
+
@click="${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_handleClick)}"
|
|
343
|
+
@keydown="${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_handleKeyDown)}"
|
|
344
|
+
>
|
|
345
|
+
<m3e-elevation level="3"></m3e-elevation>
|
|
346
|
+
<m3e-focus-trap ?disabled="${this.noFocusTrap}">
|
|
347
|
+
<div class="header">
|
|
348
|
+
<slot name="header" id="m3e-dialog-${__classPrivateFieldGet(this, _M3eDialogElement_id, "f")}-header"></slot>
|
|
349
|
+
${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_renderCloseButton).call(this)}
|
|
350
|
+
</div>
|
|
351
|
+
<m3e-scroll-container class="content" dividers="${this._hasActions ? "above-below" : "above"}">
|
|
352
|
+
<slot></slot>
|
|
353
|
+
</m3e-scroll-container>
|
|
354
|
+
<slot name="actions" @slotchange="${__classPrivateFieldGet(this, _M3eDialogElement_instances, "m", _M3eDialogElement_handleActionsSlotChange)}"></slot>
|
|
355
|
+
</m3e-focus-trap>
|
|
356
|
+
</dialog>`;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
_M3eDialogElement_id = new WeakMap();
|
|
360
|
+
_M3eDialogElement_open = new WeakMap();
|
|
361
|
+
_M3eDialogElement_escapePressedWithoutCancel = new WeakMap();
|
|
362
|
+
_M3eDialogElement_instances = new WeakSet();
|
|
363
|
+
_M3eDialogElement_renderCloseButton = function _M3eDialogElement_renderCloseButton() {
|
|
364
|
+
return !this.dismissible
|
|
365
|
+
? nothing
|
|
366
|
+
: html `<m3e-icon-button aria-label="${this.closeLabel}" class="close" @click="${this.hide}">
|
|
367
|
+
<slot name="close-icon">
|
|
368
|
+
<svg class="close-icon" viewBox="0 -960 960 960" fill="currentColor">
|
|
369
|
+
<path
|
|
370
|
+
d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"
|
|
371
|
+
/>
|
|
372
|
+
</svg>
|
|
373
|
+
</slot>
|
|
374
|
+
</m3e-icon-button>`;
|
|
375
|
+
};
|
|
376
|
+
_M3eDialogElement_handleClose = function _M3eDialogElement_handleClose() {
|
|
377
|
+
if (!__classPrivateFieldGet(this, _M3eDialogElement_escapePressedWithoutCancel, "f")) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
__classPrivateFieldSet(this, _M3eDialogElement_escapePressedWithoutCancel, true, "f");
|
|
381
|
+
this._base?.dispatchEvent(new Event("cancel", { cancelable: true }));
|
|
382
|
+
};
|
|
383
|
+
_M3eDialogElement_handleCancel = function _M3eDialogElement_handleCancel(e) {
|
|
384
|
+
if (e.target !== this._base)
|
|
385
|
+
return;
|
|
386
|
+
__classPrivateFieldSet(this, _M3eDialogElement_escapePressedWithoutCancel, false, "f");
|
|
387
|
+
e.preventDefault();
|
|
388
|
+
if (!this.dispatchEvent(new Event("cancel", { cancelable: true }))) {
|
|
389
|
+
this.hide();
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
_M3eDialogElement_handleClick = function _M3eDialogElement_handleClick(e) {
|
|
393
|
+
if (!this.disableClose && e.target === this._base) {
|
|
394
|
+
this.hide();
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
_M3eDialogElement_handleKeyDown = function _M3eDialogElement_handleKeyDown(e) {
|
|
398
|
+
if (e.key === "Escape" && !e.shiftKey && !e.ctrlKey) {
|
|
399
|
+
e.preventDefault();
|
|
400
|
+
if (!this.disableClose) {
|
|
401
|
+
this.hide();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
_M3eDialogElement_handleActionsSlotChange = function _M3eDialogElement_handleActionsSlotChange(e) {
|
|
406
|
+
this._hasActions = e.target.assignedNodes({ flatten: true }).length > 0;
|
|
407
|
+
this.classList.toggle("-has-actions", this._hasActions);
|
|
408
|
+
};
|
|
409
|
+
/** The styles of the element. */
|
|
410
|
+
M3eDialogElement.styles = css `
|
|
411
|
+
:host {
|
|
412
|
+
display: contents;
|
|
413
|
+
}
|
|
414
|
+
.base {
|
|
415
|
+
font: inherit;
|
|
416
|
+
border: unset;
|
|
417
|
+
outline: unset;
|
|
418
|
+
padding: unset;
|
|
419
|
+
display: flex;
|
|
420
|
+
flex-direction: column;
|
|
421
|
+
position: fixed;
|
|
422
|
+
overflow: visible;
|
|
423
|
+
border-radius: var(--m3e-dialog-shape, ${DesignToken.shape.corner.extraLarge});
|
|
424
|
+
min-width: var(--m3e-dialog-min-width, 17.5rem);
|
|
425
|
+
max-width: var(--m3e-dialog-max-width, 35rem);
|
|
426
|
+
color: var(--m3e-dialog-color, ${DesignToken.color.onSurface});
|
|
427
|
+
background-color: var(--m3e-dialog-container-color, ${DesignToken.color.surfaceContainerHigh});
|
|
428
|
+
visibility: hidden;
|
|
429
|
+
opacity: 0;
|
|
430
|
+
transform-origin: top;
|
|
431
|
+
transform: translateY(-3.125rem) scaleY(0.8);
|
|
432
|
+
}
|
|
433
|
+
.base::backdrop {
|
|
434
|
+
background-color: color-mix(in srgb, var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) 0%, transparent);
|
|
435
|
+
margin-right: -20px;
|
|
436
|
+
}
|
|
437
|
+
.base:not([open]) {
|
|
438
|
+
visibility: hidden;
|
|
439
|
+
opacity: 0;
|
|
440
|
+
transform: translateY(-3.125rem) scaleY(0.8);
|
|
441
|
+
transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.emphasized},
|
|
442
|
+
transform ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.emphasized},
|
|
443
|
+
overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.emphasized} allow-discrete,
|
|
444
|
+
visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.emphasized} allow-discrete`)};
|
|
445
|
+
}
|
|
446
|
+
.base[open] {
|
|
447
|
+
visibility: visible;
|
|
448
|
+
opacity: 1;
|
|
449
|
+
transform: translateY(0) scaleY(1);
|
|
450
|
+
transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.emphasized},
|
|
451
|
+
transform ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.emphasized},
|
|
452
|
+
overlay ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.emphasized} allow-discrete,
|
|
453
|
+
visibility ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.emphasized} allow-discrete`)};
|
|
454
|
+
}
|
|
455
|
+
.base:not([open])::backdrop {
|
|
456
|
+
transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
|
|
457
|
+
overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
458
|
+
visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)};
|
|
459
|
+
}
|
|
460
|
+
.base[open]::backdrop {
|
|
461
|
+
background-color: color-mix(
|
|
462
|
+
in srgb,
|
|
463
|
+
var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) var(--m3e-dialog-scrim-opacity, 32%),
|
|
464
|
+
transparent
|
|
465
|
+
);
|
|
466
|
+
transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard},
|
|
467
|
+
overlay ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
468
|
+
visibility ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete`)};
|
|
469
|
+
}
|
|
470
|
+
@starting-style {
|
|
471
|
+
.base[open] {
|
|
472
|
+
opacity: 0;
|
|
473
|
+
transform: translateY(-3.125rem) scaleY(0.8);
|
|
474
|
+
}
|
|
475
|
+
.base[open]::backdrop {
|
|
476
|
+
background-color: color-mix(in srgb, var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) 0%, transparent);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
.header {
|
|
480
|
+
flex: none;
|
|
481
|
+
display: flex;
|
|
482
|
+
align-items: center;
|
|
483
|
+
padding: 1.5rem 1.5rem 1rem 1.5rem;
|
|
484
|
+
background-color: var(--m3e-dialog-header-container-color, transparent);
|
|
485
|
+
}
|
|
486
|
+
::slotted([slot="header"]) {
|
|
487
|
+
margin: unset;
|
|
488
|
+
flex: 1 1 auto;
|
|
489
|
+
color: var(--m3e-dialog-header-color, inherit);
|
|
490
|
+
font-size: var(--m3e-dialog-header-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});
|
|
491
|
+
font-weight: var(--m3e-dialog-header-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});
|
|
492
|
+
line-height: var(--m3e-dialog-header-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});
|
|
493
|
+
letter-spacing: var(--m3e-dialog-header-tracking, ${DesignToken.typescale.standard.headline.small.tracking});
|
|
494
|
+
}
|
|
495
|
+
.content {
|
|
496
|
+
padding-inline: 1.5rem;
|
|
497
|
+
color: var(--m3e-dialog-content-color, ${DesignToken.color.onSurfaceVariant});
|
|
498
|
+
font-size: var(--m3e-dialog-content-font-size, ${DesignToken.typescale.standard.body.medium.fontSize});
|
|
499
|
+
font-weight: var(--m3e-dialog-content-font-weight, ${DesignToken.typescale.standard.body.medium.fontWeight});
|
|
500
|
+
line-height: var(--m3e-dialog-content-line-height, ${DesignToken.typescale.standard.body.medium.lineHeight});
|
|
501
|
+
letter-spacing: var(--m3e-dialog-content-tracking, ${DesignToken.typescale.standard.body.medium.tracking});
|
|
502
|
+
}
|
|
503
|
+
::slotted([slot="actions"]) {
|
|
504
|
+
flex: none;
|
|
505
|
+
display: flex;
|
|
506
|
+
align-items: center;
|
|
507
|
+
min-height: 1.5rem;
|
|
508
|
+
padding: 1.5rem;
|
|
509
|
+
column-gap: 0.5rem;
|
|
510
|
+
}
|
|
511
|
+
::slotted([slot="actions"][end]) {
|
|
512
|
+
justify-content: flex-end;
|
|
513
|
+
}
|
|
514
|
+
:host(:not(.-has-actions)) .content {
|
|
515
|
+
margin-bottom: 1.5rem;
|
|
516
|
+
}
|
|
517
|
+
.close {
|
|
518
|
+
margin-left: 0.5rem;
|
|
519
|
+
}
|
|
520
|
+
::slotted([slot="close-icon"]),
|
|
521
|
+
.close-icon {
|
|
522
|
+
width: 1em;
|
|
523
|
+
font-size: var(--m3e-icon-button-icon-size, 1.5rem) !important;
|
|
524
|
+
}
|
|
525
|
+
@media (forced-colors: active) {
|
|
526
|
+
.base:not([open])::backdrop,
|
|
527
|
+
.base[open]::backdrop {
|
|
528
|
+
transition: none;
|
|
529
|
+
}
|
|
530
|
+
.base {
|
|
531
|
+
border-style: solid;
|
|
532
|
+
border-width: 1px;
|
|
533
|
+
border-color: CanvasText;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
@media (prefers-reduced-motion) {
|
|
537
|
+
.base:not([open]),
|
|
538
|
+
.base[open],
|
|
539
|
+
.base:not([open])::backdrop,
|
|
540
|
+
.base[open]::backdrop {
|
|
541
|
+
transition: none;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
`;
|
|
545
|
+
/** @private */ M3eDialogElement.__nextId = 0;
|
|
546
|
+
__decorate([
|
|
547
|
+
r$1()
|
|
548
|
+
], M3eDialogElement.prototype, "_hasActions", void 0);
|
|
549
|
+
__decorate([
|
|
550
|
+
e$1(".base")
|
|
551
|
+
], M3eDialogElement.prototype, "_base", void 0);
|
|
552
|
+
__decorate([
|
|
553
|
+
e$1(".content")
|
|
554
|
+
], M3eDialogElement.prototype, "_content", void 0);
|
|
555
|
+
__decorate([
|
|
556
|
+
n$1({ type: Boolean })
|
|
557
|
+
], M3eDialogElement.prototype, "alert", void 0);
|
|
558
|
+
__decorate([
|
|
559
|
+
n$1({ type: Boolean, reflect: true })
|
|
560
|
+
], M3eDialogElement.prototype, "open", null);
|
|
561
|
+
__decorate([
|
|
562
|
+
n$1({ type: Boolean })
|
|
563
|
+
], M3eDialogElement.prototype, "dismissible", void 0);
|
|
564
|
+
__decorate([
|
|
565
|
+
n$1({ attribute: "disable-close", type: Boolean })
|
|
566
|
+
], M3eDialogElement.prototype, "disableClose", void 0);
|
|
567
|
+
__decorate([
|
|
568
|
+
n$1({ attribute: "no-focus-trap", type: Boolean })
|
|
569
|
+
], M3eDialogElement.prototype, "noFocusTrap", void 0);
|
|
570
|
+
__decorate([
|
|
571
|
+
n$1({ attribute: "close-label" })
|
|
572
|
+
], M3eDialogElement.prototype, "closeLabel", void 0);
|
|
573
|
+
M3eDialogElement = M3eDialogElement_1 = __decorate([
|
|
574
|
+
t$2("m3e-dialog")
|
|
575
|
+
], M3eDialogElement);
|
|
576
|
+
|
|
577
|
+
var _M3eDialogTriggerElement_clickHandler;
|
|
578
|
+
/**
|
|
579
|
+
* An element, nested within a clickable element, used to open a dialog.
|
|
580
|
+
* @tag m3e-dialog-trigger
|
|
581
|
+
*/
|
|
582
|
+
let M3eDialogTriggerElement = class M3eDialogTriggerElement extends HtmlFor(AttachInternals(LitElement)) {
|
|
583
|
+
constructor() {
|
|
584
|
+
super(...arguments);
|
|
585
|
+
/** @private */
|
|
586
|
+
_M3eDialogTriggerElement_clickHandler.set(this, (e) => {
|
|
587
|
+
if (!e.defaultPrevented && this.control instanceof M3eDialogElement) {
|
|
588
|
+
this.control.show();
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
/** @inheritdoc */
|
|
593
|
+
connectedCallback() {
|
|
594
|
+
super.connectedCallback();
|
|
595
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _M3eDialogTriggerElement_clickHandler, "f"));
|
|
596
|
+
}
|
|
597
|
+
/** @inheritdoc */
|
|
598
|
+
disconnectedCallback() {
|
|
599
|
+
super.disconnectedCallback();
|
|
600
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _M3eDialogTriggerElement_clickHandler, "f"));
|
|
601
|
+
}
|
|
602
|
+
/** @inheritdoc */
|
|
603
|
+
render() {
|
|
604
|
+
return html `<slot></slot>`;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
_M3eDialogTriggerElement_clickHandler = new WeakMap();
|
|
608
|
+
/** The styles of the element. */
|
|
609
|
+
M3eDialogTriggerElement.styles = css `
|
|
610
|
+
:host {
|
|
611
|
+
display: contents;
|
|
612
|
+
}
|
|
613
|
+
`;
|
|
614
|
+
M3eDialogTriggerElement = __decorate([
|
|
615
|
+
t$2("m3e-dialog-trigger")
|
|
616
|
+
], M3eDialogTriggerElement);
|
|
617
|
+
|
|
618
|
+
export { M3eDialogActionElement, M3eDialogElement, M3eDialogTriggerElement };
|
|
619
|
+
//# sourceMappingURL=index.js.map
|