@m3e/tooltip 1.1.10 → 1.2.0
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/README.md +79 -11
- package/dist/css-custom-data.json +100 -0
- package/dist/custom-elements.json +1495 -186
- package/dist/html-custom-data.json +49 -0
- package/dist/index.js +871 -206
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +24 -7
- package/dist/index.min.js.map +1 -1
- package/dist/src/RichTooltipActionElement.d.ts +21 -0
- package/dist/src/RichTooltipActionElement.d.ts.map +1 -0
- package/dist/src/RichTooltipElement.d.ts +116 -0
- package/dist/src/RichTooltipElement.d.ts.map +1 -0
- package/dist/src/RichTooltipPosition.d.ts +3 -0
- package/dist/src/RichTooltipPosition.d.ts.map +1 -0
- package/dist/src/TooltipElement.d.ts +8 -38
- package/dist/src/TooltipElement.d.ts.map +1 -1
- package/dist/src/TooltipElementBase.d.ts +69 -0
- package/dist/src/TooltipElementBase.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.min.js
CHANGED
|
@@ -3,38 +3,55 @@
|
|
|
3
3
|
* Copyright (c) 2025 matraic
|
|
4
4
|
* See LICENSE file in the project root for full license text.
|
|
5
5
|
*/
|
|
6
|
-
import{
|
|
6
|
+
import{ActionElementBase as t,HtmlFor as e,HoverController as i,LongPressController as s,isDisabledMixin as o,DesignToken as r,hasAssignedNodes as n,getTextContent as a}from"@m3e/core";import{LitElement as h,unsafeCSS as l,css as c,html as d}from"lit";import{M3eInteractivityChecker as p,M3eAriaDescriber as u}from"@m3e/core/a11y";import{M3eDirectionality as f}from"@m3e/core/bidi";import{M3ePlatform as m}from"@m3e/core/platform";import{positionAnchor as g}from"@m3e/core/anchoring";function b(t,e,i,s){var o,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(r<3?o(n):r>3?o(e,i,n):o(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}function v(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function $(t,e,i,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(t,i):o?o.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
11
|
*/
|
|
12
|
-
const
|
|
12
|
+
const _=t=>(e,i)=>{void 0!==i?i.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},y=globalThis,w=y.ShadowRoot&&(void 0===y.ShadyCSS||y.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,A=Symbol(),S=new WeakMap;
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2019 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/let
|
|
17
|
+
*/let E=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==A)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(w&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=S.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&S.set(e,t))}return t}toString(){return this.cssText}};const x=w?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new E("string"==typeof t?t:t+"",void 0,A))(e)})(t):t,{is:P,defineProperty:k,getOwnPropertyDescriptor:C,getOwnPropertyNames:T,getOwnPropertySymbols:M,getPrototypeOf:U}=Object,O=globalThis,H=O.trustedTypes,N=H?H.emptyScript:"",R=O.reactiveElementPolyfillSupport,W=(t,e)=>t,D={toAttribute(t,e){switch(e){case Boolean:t=t?N:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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}},z=(t,e)=>!P(t,e),j={attribute:!0,type:String,converter:D,reflect:!1,useDefault:!1,hasChanged:z};
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/Symbol.metadata??=Symbol("metadata"),
|
|
22
|
+
*/Symbol.metadata??=Symbol("metadata"),O.litPropertyMetadata??=new WeakMap;class I 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,e=j){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);void 0!==s&&k(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=C(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:s,set(e){const r=s?.call(this);o?.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??j}static _$Ei(){if(this.hasOwnProperty(W("elementProperties")))return;const t=U(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(W("properties"))){const t=this.properties,e=[...T(t),...M(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(x(t))}else void 0!==t&&e.push(x(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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,e=this.constructor.elementProperties;for(const i of e.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((t,e)=>{if(w)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),s=y.litNonce;void 0!==s&&e.setAttribute("nonce",s),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(void 0!==s&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:D).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,s=i._$Eh.get(t);if(void 0!==s&&this._$Em!==s){const t=i.getPropertyOptions(s),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:D;this._$Em=s;const r=o.fromAttribute(e,t.type);this[s]=r??this._$Ej?.get(s)??r,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const s=this.constructor,o=this[t];if(i??=s.getPropertyOptions(t),!((i.hasChanged??z)(o,e)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:s,wrapped:o},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==o||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===s&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,s=this[e];!0!==t||this._$AL.has(e)||void 0===s||this.C(e,void 0,i,s)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[W("elementProperties")]=new Map,I[W("finalized")]=new Map,R?.({ReactiveElement:I}),(O.reactiveElementVersions??=[]).push("2.1.1");
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
27
|
*/
|
|
28
|
-
const L={attribute:!0,type:String,converter:
|
|
28
|
+
const L={attribute:!0,type:String,converter:D,reflect:!1,hasChanged:z},q=(t=L,e,i)=>{const{kind:s,metadata:o}=i;let r=globalThis.litPropertyMetadata.get(o);if(void 0===r&&globalThis.litPropertyMetadata.set(o,r=new Map),"setter"===s&&((t=Object.create(t)).wrapped=!0),r.set(i.name,t),"accessor"===s){const{name:s}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(s,o,t)},init(e){return void 0!==e&&this.C(s,void 0,t,e),e}}}if("setter"===s){const{name:s}=i;return function(i){const o=this[s];e.call(this,i),this.requestUpdate(s,o,t)}}throw Error("Unsupported decorator location: "+s)};function B(t){return(e,i)=>"object"==typeof i?q(t,e,i):((t,e,i)=>{const s=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),s?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/
|
|
33
|
+
*/function V(t){return B({...t,state:!0,attribute:!1})}
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2017 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
+
*/let F=class extends t{constructor(){super(...arguments),this.disableRestoreFocus=!1}_onClick(){this.closest("m3e-rich-tooltip")?.hide(!this.disableRestoreFocus)}};b([B({attribute:"disable-restore-focus",type:Boolean})],F.prototype,"disableRestoreFocus",void 0),F=b([_("m3e-rich-tooltip-action")],F);
|
|
39
|
+
/**
|
|
40
|
+
* @license
|
|
41
|
+
* Copyright 2017 Google LLC
|
|
42
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
+
*/
|
|
44
|
+
const G=globalThis,K=G.trustedTypes,J=K?K.createPolicy("lit-html",{createHTML:t=>t}):void 0,Z="$lit$",X=`lit$${Math.random().toFixed(9).slice(2)}$`,Q="?"+X,Y=`<${Q}>`,tt=document,et=()=>tt.createComment(""),it=t=>null===t||"object"!=typeof t&&"function"!=typeof t,st=Array.isArray,ot="[ \t\n\f\r]",rt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nt=/-->/g,at=/>/g,ht=RegExp(`>|${ot}(?:([^\\s"'>=/]+)(${ot}*=${ot}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),lt=/'/g,ct=/"/g,dt=/^(?:script|style|textarea|title)$/i,pt=Symbol.for("lit-noChange"),ut=Symbol.for("lit-nothing"),ft=new WeakMap,mt=tt.createTreeWalker(tt,129);function gt(t,e){if(!st(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==J?J.createHTML(e):e}const bt=(t,e)=>{const i=t.length-1,s=[];let o,r=2===e?"<svg>":3===e?"<math>":"",n=rt;for(let e=0;e<i;e++){const i=t[e];let a,h,l=-1,c=0;for(;c<i.length&&(n.lastIndex=c,h=n.exec(i),null!==h);)c=n.lastIndex,n===rt?"!--"===h[1]?n=nt:void 0!==h[1]?n=at:void 0!==h[2]?(dt.test(h[2])&&(o=RegExp("</"+h[2],"g")),n=ht):void 0!==h[3]&&(n=ht):n===ht?">"===h[0]?(n=o??rt,l=-1):void 0===h[1]?l=-2:(l=n.lastIndex-h[2].length,a=h[1],n=void 0===h[3]?ht:'"'===h[3]?ct:lt):n===ct||n===lt?n=ht:n===nt||n===at?n=rt:(n=ht,o=void 0);const d=n===ht&&t[e+1].startsWith("/>")?" ":"";r+=n===rt?i+Y:l>=0?(s.push(a),i.slice(0,l)+Z+i.slice(l)+X+d):i+X+(-2===l?e:d)}return[gt(t,r+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]};class vt{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,r=0;const n=t.length-1,a=this.parts,[h,l]=bt(t,e);if(this.el=vt.createElement(h,i),mt.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=mt.nextNode())&&a.length<n;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(Z)){const e=l[r++],i=s.getAttribute(t).split(X),n=/([.?@])?(.*)/.exec(e);a.push({type:1,index:o,name:n[2],strings:i,ctor:"."===n[1]?At:"?"===n[1]?St:"@"===n[1]?Et:wt}),s.removeAttribute(t)}else t.startsWith(X)&&(a.push({type:6,index:o}),s.removeAttribute(t));if(dt.test(s.tagName)){const t=s.textContent.split(X),e=t.length-1;if(e>0){s.textContent=K?K.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],et()),mt.nextNode(),a.push({type:2,index:++o});s.append(t[e],et())}}}else if(8===s.nodeType)if(s.data===Q)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=s.data.indexOf(X,t+1));)a.push({type:7,index:o}),t+=X.length-1}o++}}static createElement(t,e){const i=tt.createElement("template");return i.innerHTML=t,i}}function $t(t,e,i=t,s){if(e===pt)return e;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const r=it(e)?void 0:e._$litDirective$;return o?.constructor!==r&&(o?._$AO?.(!1),void 0===r?o=void 0:(o=new r(t),o._$AT(t,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(e=$t(t,o._$AS(t,e.values),o,s)),e}class _t{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=(t?.creationScope??tt).importNode(e,!0);mt.currentNode=s;let o=mt.nextNode(),r=0,n=0,a=i[0];for(;void 0!==a;){if(r===a.index){let e;2===a.type?e=new yt(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new xt(o,this,t)),this._$AV.push(e),a=i[++n]}r!==a?.index&&(o=mt.nextNode(),r++)}return mt.currentNode=tt,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class yt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=ut,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=$t(this,t,e),it(t)?t===ut||null==t||""===t?(this._$AH!==ut&&this._$AR(),this._$AH=ut):t!==this._$AH&&t!==pt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>st(t)||"function"==typeof t?.[Symbol.iterator])(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!==ut&&it(this._$AH)?this._$AA.nextSibling.data=t:this.T(tt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,s="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=vt.createElement(gt(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new _t(s,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=ft.get(t.strings);return void 0===e&&ft.set(t.strings,e=new vt(t)),e}k(t){st(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new yt(this.O(et()),this.O(et()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class wt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=ut,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ut}_$AI(t,e=this,i,s){const o=this.strings;let r=!1;if(void 0===o)t=$t(this,t,e,0),r=!it(t)||t!==this._$AH&&t!==pt,r&&(this._$AH=t);else{const s=t;let n,a;for(t=o[0],n=0;n<o.length-1;n++)a=$t(this,s[i+n],e,n),a===pt&&(a=this._$AH[n]),r||=!it(a)||a!==this._$AH[n],a===ut?t=ut:t!==ut&&(t+=(a??"")+o[n+1]),this._$AH[n]=a}r&&!s&&this.j(t)}j(t){t===ut?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class At extends wt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ut?void 0:t}}class St extends wt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==ut)}}class Et extends wt{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=$t(this,t,e,0)??ut)===pt)return;const i=this._$AH,s=t===ut&&i!==ut||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==ut&&(i===ut||s);s&&this.element.removeEventListener(this.name,this,i),o&&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 xt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){$t(this,t)}}const Pt=G.litHtmlPolyfillSupport;Pt?.(vt,yt),(G.litHtmlVersions??=[]).push("3.3.1");
|
|
45
|
+
/**
|
|
46
|
+
* @license
|
|
47
|
+
* Copyright 2018 Google LLC
|
|
48
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
49
|
+
*/
|
|
50
|
+
const kt=t=>t??ut;var Ct,Tt,Mt,Ut,Ot,Ht,Nt,Rt,Wt,Dt;class zt extends(e(h)){constructor(){super(...arguments),Ct.add(this),Mt.set(this,null),Ut.set(this,void 0),Ot.set(this,!1),Ht.set(this,()=>v(this,Ct,"m",Wt).call(this)),Nt.set(this,new i(this,{target:null,endDelay:200,callback:(t,e)=>{if(!this._isInteractive)if(t){if(e===this._base)return void $(this,Ot,!0,"f");this.show()}else v(this,Ot,"f")&&e!==this._base||($(this,Ot,!1,"f"),this.hide())}})),Rt.set(this,new s(this,{target:null,callback:t=>{this._isInteractive||(t?this.show():this.hide())}})),this.disabled=!1,this.touchGestures="auto"}get showDelay(){return v(this,Nt,"f").startDelay}set showDelay(t){v(this,Nt,"f").startDelay=t}get hideDelay(){return v(this,Nt,"f").endDelay}set hideDelay(t){v(this,Nt,"f").endDelay=t}get isOpen(){return Tt.__openTooltips.includes(this)}get _isInteractive(){return!1}attach(t){super.attach(t),m.iOS||m.Android?(v(this,Rt,"f").observe(t),v(this,Ct,"m",Dt).call(this)):v(this,Nt,"f").observe(t),t.addEventListener("click",v(this,Ht,"f"))}detach(){this.control&&(v(this,Nt,"f").unobserve(this.control),v(this,Rt,"f").observe(this.control),this.control.removeEventListener("click",v(this,Ht,"f")),this.hide()),super.detach()}update(t){super.update(t),t.has("disabled")&&this.disabled&&this.hide()}firstUpdated(t){super.firstUpdated(t),this._base&&v(this,Nt,"f").observe(this._base)}async show(){!this.control||this.disabled||o(this.control)&&this.control.disabled||(Tt.__openTooltips.filter(t=>t!==this).forEach(t=>t.hide()),this._base.showPopover(),$(this,Ut,await g(this._base,this.control,{position:this._anchorPosition,inline:!0,flip:!0,shift:!0,offset:4},(t,e)=>this._updatePosition(this._base,t,e)),"f"),Tt.__openTooltips.includes(this)||Tt.__openTooltips.push(this))}hide(){this._base.hidePopover(),v(this,Ut,"f")?.call(this),$(this,Ut,void 0,"f"),v(this,Nt,"f").clearDelays(),Tt.__openTooltips.includes(this)&&(Tt.__openTooltips=Tt.__openTooltips.filter(t=>t!==this))}}var jt,It,Lt,qt,Bt,Vt,Ft,Gt,Kt,Jt,Zt,Xt,Qt,Yt,te,ee;Tt=zt,Mt=new WeakMap,Ut=new WeakMap,Ot=new WeakMap,Ht=new WeakMap,Nt=new WeakMap,Rt=new WeakMap,Ct=new WeakSet,Wt=function(){this._isInteractive?Tt.__openTooltips.includes(this)?this.hide():this.show():this.hide()},Dt=function(){if("off"!==this.touchGestures&&v(this,Mt,"f")){const t=v(this,Mt,"f").style;("on"===this.touchGestures||"INPUT"!==v(this,Mt,"f").nodeName&&"TEXTAREA"!==v(this,Mt,"f").nodeName)&&(t.userSelect=t.msUserSelect=t.webkitUserSelect=t.MozUserSelect="none"),"on"!==this.touchGestures&&v(this,Mt,"f").draggable||(t.webkitUserDrag="none"),t.touchAction="none",t.webkitTapHighlightColor="transparent"}},zt.__openTooltips=new Array,b([
|
|
34
51
|
/**
|
|
35
52
|
* @license
|
|
36
53
|
* Copyright 2017 Google LLC
|
|
37
54
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
55
|
*/
|
|
39
|
-
function(t){return(e,s,i)=>((t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,s),s))(e,s,{get(){return(e=>e.renderRoot?.querySelector(t)??null)(this)}})}(".base")],Z.prototype,"_base",void 0),f([q({type:Boolean,reflect:!0})],Z.prototype,"disabled",void 0),f([q()],Z.prototype,"position",void 0),f([q({attribute:"show-delay",type:Number})],Z.prototype,"showDelay",null),f([q({attribute:"hide-delay",type:Number})],Z.prototype,"hideDelay",null),f([q({attribute:"touch-gestures"})],Z.prototype,"touchGestures",void 0),Z=Y=f([(t=>(e,s)=>{void 0!==s?s.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})("m3e-tooltip")],Z);export{Z as M3eTooltipElement};
|
|
56
|
+
function(t){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i))(e,i,{get(){return(e=>e.renderRoot?.querySelector(t)??null)(this)}})}(".base")],zt.prototype,"_base",void 0),b([B({type:Boolean,reflect:!0})],zt.prototype,"disabled",void 0),b([B({attribute:"show-delay",type:Number})],zt.prototype,"showDelay",null),b([B({attribute:"hide-delay",type:Number})],zt.prototype,"hideDelay",null),b([B({attribute:"touch-gestures"})],zt.prototype,"touchGestures",void 0);let ie=ee=class extends zt{constructor(){super(...arguments),jt.add(this),It.set(this,ee.__nextId++),Lt.set(this,""),qt.set(this,""),Bt.set(this,""),Vt.set(this,!1),this._hasSubhead=!1,this._interactive=!1,Ft.set(this,t=>v(this,jt,"m",Jt).call(this,t)),this.position="below-after"}get _isInteractive(){return this._interactive}get _anchorPosition(){switch(this.position){case"above":return"top";case"above-after":return"rtl"===f.current?"top-start":"top-end";case"above-before":return"rtl"===f.current?"top-end":"top-start";case"after":return"rtl"===f.current?"left":"right";case"before":return"rtl"===f.current?"right":"left";case"below":return"bottom";case"below-after":return"rtl"===f.current?"bottom-start":"bottom-end";case"below-before":return"rtl"===f.current?"bottom-end":"bottom-start"}}render(){const t=this._interactive&&this._hasSubhead?`m3e-rich-tooltip-${v(this,It,"f")}-subhead`:void 0;return d`<div class="base" popover="manual" role="${kt(this._interactive?"dialog":void 0)}" aria-labelledby="${kt(t)}" @keydown="${v(this,jt,"m",Zt)}" @beforetoggle="${v(this,jt,"m",Gt)}" @toggle="${v(this,jt,"m",Kt)}"><m3e-elevation level="3"></m3e-elevation><div class="subhead" id="${kt(t)}"><slot name="subhead" @slotchange="${v(this,jt,"m",Xt)}"></slot></div><div class="content"><slot @slotchange="${v(this,jt,"m",Qt)}"></slot></div><div class="actions"><slot name="actions" @slotchange="${v(this,jt,"m",Yt)}"></slot></div></div>`}show(){return this._interactive&&document.addEventListener("click",v(this,Ft,"f")),super.show()}hide(t=!0){this._interactive&&document.removeEventListener("click",v(this,Ft,"f")),super.hide(),t&&this._interactive&&this.control&&p.isFocusable(this.control)&&this.control.focus()}attach(t){super.attach(t),v(this,jt,"m",te).call(this),this._interactive&&(t.ariaHasPopup="dialog")}update(t){super.update(t),t.has("_interactive")&&(this.ariaHidden=this._interactive?null:"true",v(this,jt,"m",te).call(this),this.control&&this._interactive&&(this.control.ariaHasPopup="dialog"))}_updatePosition(t,e,i){this.position.includes("before")&&"before"!==this.position&&("rtl"===f.current?e+=this.control?.clientWidth??0:e-=this.control?.clientWidth??0),this.position.includes("after")&&"after"!==this.position&&("rtl"===f.current?e-=this.control?.clientWidth??0:e+=this.control?.clientWidth??0),"rtl"===f.current?(t.style.right=window.innerWidth-e-t.clientWidth+"px",t.style.left=""):(t.style.left=`${e}px`,t.style.right=""),t.style.top=`${i}px`}};var se,oe,re,ne;It=new WeakMap,Lt=new WeakMap,qt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Ft=new WeakMap,jt=new WeakSet,Gt=function(t){const e=new ToggleEvent("beforetoggle",{oldState:t.oldState,newState:t.newState,bubbles:!0,composed:!0,cancelable:t.cancelable});this.dispatchEvent(e)||(t.preventDefault(),this.hide())},Kt=function(t){const e=new ToggleEvent("toggle",{oldState:t.oldState,newState:t.newState,bubbles:!0,composed:!0});this.dispatchEvent(e)},Jt=function(t){t.composedPath().some(t=>t instanceof ee||t===this.control)||this.hide()},Zt=function(t){"Escape"!==t.key||t.shiftKey||t.ctrlKey||(t.preventDefault(),this.hide())},Xt=function(t){this._hasSubhead=n(t.target),this.shadowRoot?.querySelector(".base")?.classList.toggle("has-subhead",this._hasSubhead),$(this,Lt,this._hasSubhead?a(t.target,!0):"","f"),v(this,jt,"m",te).call(this)},Qt=function(t){this._interactive=p.findInteractiveElements(this).length>0,$(this,qt,a(t.target,!0),"f"),v(this,jt,"m",te).call(this)},Yt=function(t){this.shadowRoot?.querySelector(".base")?.classList.toggle("has-actions",n(t.target)),this._interactive=p.findInteractiveElements(this).length>0,v(this,jt,"m",te).call(this)},te=function(){const t=v(this,Lt,"f")?`${v(this,Lt,"f")}/n${v(this,qt,"f")}`:v(this,qt,"f");this.isConnected&&this.control&&(v(this,Bt,"f")&&v(this,Vt,"f")&&(u.removeDescription(this.control,v(this,Bt,"f")),$(this,Vt,!1,"f")),$(this,Bt,t,"f"),v(this,Bt,"f")&&!this._interactive&&(u.describe(this.control,v(this,Bt,"f")),$(this,Vt,!0,"f")))},ie.styles=c`:host { display: contents; } .base { display: flex; flex-direction: column; position: absolute; padding: unset; margin: unset; border: unset; padding-block-start: var(--m3e-rich-tooltip-padding-top, 0.75rem); padding-inline: var(--m3e-rich-tooltip-padding-inline, 1rem); max-width: var(--m3e-rich-tooltip-max-width, 20rem); box-sizing: border-box; overflow: visible; border-radius: var(--m3e-rich-tooltip-shape, ${r.shape.corner.medium}); background-color: var(--m3e-rich-tooltip-container-color, ${r.color.surfaceContainer}); visibility: hidden; opacity: 0; transform: scale(0.8); transition: ${l(`opacity ${r.motion.duration.short3} ${r.motion.easing.standard}, \n transform ${r.motion.duration.short3} ${r.motion.easing.standard},\n overlay ${r.motion.duration.short3} ${r.motion.easing.standard} allow-discrete,\n visibility ${r.motion.duration.short3} ${r.motion.easing.standard} allow-discrete`)}; } .base:not(.has-actions) { padding-block-end: var(--m3e-rich-tooltip-padding-bottom, 0.75rem); } .base::backdrop { background-color: transparent; } .base:not(:popover-open) { visibility: hidden; opacity: 0; transform: scale(0.8); } .base:popover-open { visibility: visible; opacity: 1; transform: scale(1); } .base:not(.has-subhead) .subhead, .base:not(.has-actions) .actions { display: none; } .subhead { color: var(--m3e-rich-tooltip-subhead-color, ${r.color.onSurfaceVariant}); font-size: var(--m3e-rich-tooltip-subhead-font-size, ${r.typescale.standard.title.small.fontSize}); font-weight: var( --m3e-rich-tooltip-subhead-font-weight, ${r.typescale.standard.title.small.fontWeight} ); line-height: var( --m3e-rich-tooltip-subhead-line-height, ${r.typescale.standard.title.small.lineHeight} ); letter-spacing: var(--m3e-rich-tooltip-subhead-tracking, ${r.typescale.standard.title.small.tracking}); padding-block-end: var(--m3e-rich-tooltip-subhead-bottom-space, 0.25rem); } .content { color: var(--m3e-rich-tooltip-supporting-text-color, ${r.color.onSurfaceVariant}); font-size: var( --m3e-rich-tooltip-supporting-text-font-size, ${r.typescale.standard.body.medium.fontSize} ); font-weight: var( --m3e-rich-tooltip-supporting-text-font-weight, ${r.typescale.standard.body.medium.fontWeight} ); line-height: var( --m3e-rich-tooltip-supporting-text-line-height, ${r.typescale.standard.body.medium.lineHeight} ); letter-spacing: var( --m3e-rich-tooltip-supporting-text-tracking, ${r.typescale.standard.body.medium.tracking} ); } .actions { margin-inline: calc( 0px - calc( var(--m3e-rich-tooltip-padding-inline, 1rem) - var(--m3e-rich-tooltip-actions-padding-inline, 0.25rem) ) ); padding-block-start: var(--m3e-rich-tooltip-actions-top-space, 0.75rem); padding-block-end: var(--m3e-rich-tooltip-actions-bottom-space, 0.5rem); } ::slotted([slot="actions"]) { flex: none; display: flex; align-items: center; min-height: 1.5rem; column-gap: 0.5rem; } ::slotted([slot="actions"][end]) { justify-content: flex-end; } @starting-style { .base:popover-open { opacity: 0; transform: scale(0.8); } } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { background-color: Canvas; color: CanvasText; box-sizing: border-box; border: 1px solid CanvasText; } }`,ie.__nextId=0,b([V()],ie.prototype,"_hasSubhead",void 0),b([V()],ie.prototype,"_interactive",void 0),b([B()],ie.prototype,"position",void 0),ie=ee=b([_("m3e-rich-tooltip")],ie);let ae=class extends zt{constructor(){super(...arguments),se.add(this),oe.set(this,void 0),this.position="below"}get _anchorPosition(){return"above"===this.position?"top":"below"===this.position?"bottom":"before"===this.position?"ltr"===f.current?"left":"right":"ltr"===f.current?"right":"left"}attach(t){super.attach(t),v(this,oe,"f")&&u.describe(t,v(this,oe,"f"))}detach(){this.control&&v(this,oe,"f")&&u.removeDescription(this.control,v(this,oe,"f")),super.detach()}connectedCallback(){super.connectedCallback(),this.ariaHidden="true"}render(){return d`<div class="base" popover="manual" @toggle="${v(this,se,"m",ne)}"><slot @slotchange="${v(this,se,"m",re)}"></slot></div>`}_updatePosition(t,e,i){"rtl"===f.current?(t.style.right=window.innerWidth-e-t.clientWidth+"px",t.style.left=""):(t.style.left=`${e}px`,t.style.right=""),t.style.top=`${i}px`}};oe=new WeakMap,se=new WeakSet,re=function(t){const e=a(t.target,!0);this.isConnected&&this.control?(v(this,oe,"f")&&u.removeDescription(this.control,v(this,oe,"f")),$(this,oe,e,"f"),v(this,oe,"f")&&u.describe(this.control,v(this,oe,"f"))):$(this,oe,e,"f")},ne=function(t){if("open"===t.newState){const t=this._base.getBoundingClientRect().height>parseFloat(getComputedStyle(this._base).minHeight);this.classList.toggle("-multiline",t)}},ae.styles=c`:host { display: contents; } .base { position: absolute; pointer-events: none; margin: unset; border: unset; word-break: normal; overflow-wrap: anywhere; padding: var(--m3e-tooltip-padding, 0.25rem 0.5rem); min-width: var(--m3e-tooltip-min-width, 2.5rem); max-width: var(--m3e-tooltip-max-width, 12.5rem); min-height: var(--m3e-tooltip-min-height, 1.5rem); max-height: var(--m3e-tooltip-max-height, 40vh); box-sizing: border-box; overflow: hidden; text-align: center; border-radius: var(--m3e-tooltip-shape, ${r.shape.corner.extraSmall}); background-color: var(--m3e-tooltip-container-color, ${r.color.inverseSurface}); color: var(--m3e-tooltip-supporting-text-color, ${r.color.inverseOnSurface}); font-size: var(--m3e-tooltip-supporting-text-font-size, ${r.typescale.standard.body.small.fontSize}); font-weight: var( --m3e-tooltip-supporting-text-font-weight, ${r.typescale.standard.body.small.fontWeight} ); line-height: var( --m3e-tooltip-supporting-text-line-height, ${r.typescale.standard.body.small.lineHeight} ); letter-spacing: var( --m3e-tooltip-supporting-text-tracking, ${r.typescale.standard.body.small.tracking} ); visibility: hidden; opacity: 0; transform: scale(0.8); transition: ${l(`opacity ${r.motion.duration.short3} ${r.motion.easing.standard}, \n transform ${r.motion.duration.short3} ${r.motion.easing.standard},\n overlay ${r.motion.duration.short3} ${r.motion.easing.standard} allow-discrete,\n visibility ${r.motion.duration.short3} ${r.motion.easing.standard} allow-discrete`)}; } :host(.-multiline) .base { text-align: start; } .base::backdrop { background-color: transparent; } .base:not(:popover-open) { visibility: hidden; opacity: 0; transform: scale(0.8); } .base:popover-open { visibility: visible; opacity: 1; transform: scale(1); } @starting-style { .base:popover-open { opacity: 0; transform: scale(0.8); } } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { background-color: Canvas; color: CanvasText; box-sizing: border-box; border: 1px solid CanvasText; } }`,b([B()],ae.prototype,"position",void 0),ae=b([_("m3e-tooltip")],ae);export{F as M3eRichTooltipActionElement,ie as M3eRichTooltipElement,ae as M3eTooltipElement,zt as TooltipElementBase};
|
|
40
57
|
//# sourceMappingURL=index.min.js.map
|