@pod-os/elements 0.26.1-rc.e49d800.0 → 0.27.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/dist/cjs/{BrokenFile-26f83028.js → BrokenFile-a5fc0832.js} +22 -6
- package/dist/cjs/BrokenFile-a5fc0832.js.map +1 -0
- package/dist/cjs/app-globals-97a7ec18.js +23 -0
- package/dist/cjs/app-globals-97a7ec18.js.map +1 -0
- package/dist/cjs/elements.cjs.js +2 -2
- package/dist/cjs/ion-badge_5.cjs.entry.js +1 -1
- package/dist/cjs/ion-icon_32.cjs.entry.js +9150 -0
- package/dist/cjs/ion-icon_32.cjs.entry.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/pos-app-generic.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-ldp-container.cjs.entry.js +1 -1
- package/dist/cjs/pos-app-rdf-document.cjs.entry.js +1 -1
- package/dist/cjs/pos-document.cjs.entry.js +1 -1
- package/dist/collection/apps/pos-app-browser/pos-app-browser.js +2 -1
- package/dist/collection/apps/pos-app-browser/pos-app-browser.js.map +1 -1
- package/dist/collection/apps/pos-app-dashboard/pos-app-dashboard.js +1 -1
- package/dist/collection/apps/pos-app-dashboard/pos-example-resources/pos-example-resources.js +1 -1
- package/dist/collection/apps/pos-app-dashboard/pos-getting-started/pos-getting-started.js +1 -1
- package/dist/collection/apps/pos-app-generic/pos-app-generic.js +1 -1
- package/dist/collection/apps/pos-app-ldp-container/pos-app-ldp-container.js +1 -1
- package/dist/collection/apps/pos-app-rdf-document/pos-app-rdf-document.js +1 -1
- package/dist/collection/apps/pos-app-settings/pos-app-settings.js +1 -1
- package/dist/collection/apps/pos-app-settings/pos-setting-offline-cache/pos-setting-offline-cache.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/pos-add-new-thing/pos-add-new-thing.js +1 -1
- package/dist/collection/components/pos-app/pos-app.js +1 -1
- package/dist/collection/components/pos-dialog/pos-dialog.js +15 -5
- package/dist/collection/components/pos-dialog/pos-dialog.js.map +1 -1
- package/dist/collection/components/pos-error-toast/pos-error-toast.js +1 -1
- package/dist/collection/components/pos-literals/pos-literals.js +1 -1
- package/dist/collection/components/pos-login/pos-login.js +21 -2
- package/dist/collection/components/pos-login/pos-login.js.map +1 -1
- package/dist/collection/components/pos-login-form/pos-login-form.js +1 -1
- package/dist/collection/components/pos-make-findable/pos-make-findable.css +2 -55
- package/dist/collection/components/pos-make-findable/pos-make-findable.js +15 -26
- package/dist/collection/components/pos-make-findable/pos-make-findable.js.map +1 -1
- package/dist/collection/components/pos-make-findable/shoelace.js +4 -0
- package/dist/collection/components/pos-make-findable/shoelace.js.map +1 -0
- package/dist/collection/components/pos-navigation/bar/pos-navigation-bar.js +1 -1
- package/dist/collection/components/pos-navigation/pos-navigation.js +1 -1
- package/dist/collection/components/pos-new-thing-form/pos-new-thing-form.js +1 -1
- package/dist/collection/components/pos-picture/pos-picture.js +1 -1
- package/dist/collection/components/pos-picture/pos-picture.js.map +1 -1
- package/dist/collection/components/pos-rich-link/pos-rich-link.js +2 -2
- package/dist/collection/components/pos-router/pos-router.js +1 -1
- package/dist/collection/components/pos-select-term/pos-select-term.js +1 -1
- package/dist/collection/components/pos-user-menu/pos-user-menu.css +23 -0
- package/dist/collection/components/pos-user-menu/pos-user-menu.js +102 -0
- package/dist/collection/components/pos-user-menu/pos-user-menu.js.map +1 -0
- package/dist/collection/components/pos-user-menu/shoelace.js +6 -0
- package/dist/collection/components/pos-user-menu/shoelace.js.map +1 -0
- package/dist/collection/global.js +6 -0
- package/dist/collection/global.js.map +1 -1
- package/dist/components/chunk.HVTXQL7M.js +4775 -0
- package/dist/components/chunk.HVTXQL7M.js.map +1 -0
- package/dist/components/index.js +7 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/index11.js +21 -5
- package/dist/components/index11.js.map +1 -1
- package/dist/components/pos-add-new-thing2.js +1 -1
- package/dist/components/pos-app-browser.js +68 -61
- package/dist/components/pos-app-browser.js.map +1 -1
- package/dist/components/pos-app-dashboard2.js +1 -1
- package/dist/components/pos-app-generic.js +1 -1
- package/dist/components/pos-app-ldp-container.js +1 -1
- package/dist/components/pos-app-rdf-document.js +1 -1
- package/dist/components/pos-app-settings2.js +1 -1
- package/dist/components/pos-app2.js +1 -1
- package/dist/components/pos-dialog2.js +3 -3
- package/dist/components/pos-dialog2.js.map +1 -1
- package/dist/components/pos-error-toast2.js +1 -1
- package/dist/components/pos-example-resources2.js +1 -1
- package/dist/components/pos-getting-started2.js +1 -1
- package/dist/components/pos-literals2.js +1 -1
- package/dist/components/pos-login-form2.js +1 -1
- package/dist/components/pos-login2.js +16 -3
- package/dist/components/pos-login2.js.map +1 -1
- package/dist/components/pos-make-findable2.js +16 -21
- package/dist/components/pos-make-findable2.js.map +1 -1
- package/dist/components/pos-navigation-bar2.js +1 -1
- package/dist/components/pos-navigation2.js +1 -1
- package/dist/components/pos-new-thing-form2.js +1 -1
- package/dist/components/pos-picture2.js +1 -1
- package/dist/components/pos-picture2.js.map +1 -1
- package/dist/components/pos-rich-link2.js +2 -2
- package/dist/components/pos-router2.js +1 -1
- package/dist/components/pos-select-term2.js +1 -1
- package/dist/components/pos-setting-offline-cache2.js +1 -1
- package/dist/components/pos-user-menu.d.ts +11 -0
- package/dist/components/pos-user-menu.js +8 -0
- package/dist/components/pos-user-menu.js.map +1 -0
- package/dist/components/pos-user-menu2.js +293 -0
- package/dist/components/pos-user-menu2.js.map +1 -0
- package/dist/elements/elements.css +8 -2
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/elements.esm.js.map +1 -1
- package/dist/elements/{p-650db824.entry.js → p-38edfa6d.entry.js} +2 -2
- package/dist/elements/p-61cd1259.js +2 -0
- package/dist/elements/p-61cd1259.js.map +1 -0
- package/dist/elements/p-74bdf05f.entry.js +652 -0
- package/dist/elements/p-74bdf05f.entry.js.map +1 -0
- package/dist/elements/p-93f5c8ec.js +2 -0
- package/dist/elements/p-93f5c8ec.js.map +1 -0
- package/dist/elements/p-b1de75a4.entry.js +2 -0
- package/dist/elements/{p-178b3852.entry.js → p-c466d5bf.entry.js} +2 -2
- package/dist/elements/{p-2cda3231.entry.js → p-dbb94429.entry.js} +2 -2
- package/dist/elements/p-ff684bff.entry.js +2 -0
- package/dist/esm/{BrokenFile-0b9882ef.js → BrokenFile-a47d9850.js} +22 -6
- package/dist/esm/BrokenFile-a47d9850.js.map +1 -0
- package/dist/esm/app-globals-fd9221d0.js +21 -0
- package/dist/esm/app-globals-fd9221d0.js.map +1 -0
- package/dist/esm/elements.js +2 -2
- package/dist/esm/ion-badge_5.entry.js +1 -1
- package/dist/esm/ion-icon_32.entry.js +9115 -0
- package/dist/esm/ion-icon_32.entry.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/pos-app-generic.entry.js +1 -1
- package/dist/esm/pos-app-ldp-container.entry.js +1 -1
- package/dist/esm/pos-app-rdf-document.entry.js +1 -1
- package/dist/esm/pos-document.entry.js +1 -1
- package/dist/types/components/pos-dialog/pos-dialog.d.ts +2 -2
- package/dist/types/components/pos-login/pos-login.d.ts +4 -0
- package/dist/types/components/pos-make-findable/pos-make-findable.d.ts +6 -3
- package/dist/types/components/pos-make-findable/shoelace.d.ts +3 -0
- package/dist/types/components/pos-user-menu/pos-user-menu.d.ts +13 -0
- package/dist/types/components/pos-user-menu/shoelace.d.ts +5 -0
- package/dist/types/components.d.ts +33 -0
- package/package.json +5 -4
- package/dist/cjs/BrokenFile-26f83028.js.map +0 -1
- package/dist/cjs/app-globals-1c06b5ae.js +0 -16
- package/dist/cjs/app-globals-1c06b5ae.js.map +0 -1
- package/dist/cjs/ion-icon_31.cjs.entry.js +0 -4144
- package/dist/cjs/ion-icon_31.cjs.entry.js.map +0 -1
- package/dist/elements/p-5e8a3893.js +0 -2
- package/dist/elements/p-5e8a3893.js.map +0 -1
- package/dist/elements/p-b80dbf24.entry.js +0 -20
- package/dist/elements/p-b80dbf24.entry.js.map +0 -1
- package/dist/elements/p-c27a94bc.entry.js +0 -2
- package/dist/elements/p-e1957ea1.entry.js +0 -2
- package/dist/elements/p-ec7a6c44.js +0 -2
- package/dist/elements/p-ec7a6c44.js.map +0 -1
- package/dist/esm/BrokenFile-0b9882ef.js.map +0 -1
- package/dist/esm/app-globals-31ecda4c.js +0 -14
- package/dist/esm/app-globals-31ecda4c.js.map +0 -1
- package/dist/esm/ion-icon_31.entry.js +0 -4110
- package/dist/esm/ion-icon_31.entry.js.map +0 -1
- /package/dist/elements/{p-650db824.entry.js.map → p-38edfa6d.entry.js.map} +0 -0
- /package/dist/elements/{p-e1957ea1.entry.js.map → p-b1de75a4.entry.js.map} +0 -0
- /package/dist/elements/{p-178b3852.entry.js.map → p-c466d5bf.entry.js.map} +0 -0
- /package/dist/elements/{p-2cda3231.entry.js.map → p-dbb94429.entry.js.map} +0 -0
- /package/dist/elements/{p-c27a94bc.entry.js.map → p-ff684bff.entry.js.map} +0 -0
|
@@ -0,0 +1,4775 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t$2=globalThis,e$8=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$3=Symbol(),o$7=new WeakMap;class n$5{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$3)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$8&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$7.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$7.set(s,t));}return t}toString(){return this.cssText}}const r$5=t=>new n$5("string"==typeof t?t:t+"",void 0,s$3),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$5(o,t,s$3)},S$1=(s,o)=>{if(e$8)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$3=e$8?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/const{is:i$3,defineProperty:e$7,getOwnPropertyDescriptor:h$3,getOwnPropertyNames:r$4,getOwnPropertySymbols:o$6,getPrototypeOf:n$4}=Object,a$1=globalThis,c$2=a$1.trustedTypes,l$1=c$2?c$2.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$3=(t,s)=>!i$3(t,s),b={attribute:!0,type:String,converter:u$1,reflect:!1,useDefault:!1,hasChanged:f$3};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;class y$1 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=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$7(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$3(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:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$4(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=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$4(t),...o$6(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$3(s));}else void 0!==s&&i.push(c$3(s));return i}static _$Eu(t,s){const i=s.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,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(!0),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&&!0===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$3)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);}!1===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]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&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,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];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=!1;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=!1,this._$EM(),s}t&&this._$AE(s);}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){}}y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const t$1=globalThis,i$2=t$1.trustedTypes,s$2=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$6="$lit$",h$2=`lit$${Math.random().toFixed(9).slice(2)}$`,o$5="?"+h$2,n$3=`<${o$5}>`,r$3=document,l=()=>r$3.createComment(""),c$1=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$2=/<(?:(!--|\/[^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,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$3.createTreeWalker(r$3,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$2?s$2.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f$2;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$2?"!--"===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$2,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$2:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f$2?s+n$3:d>=0?(o.push(a),s.slice(0,d)+e$6+s.slice(d)+h$2+x):s+h$2+(-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$6)){const i=v[a++],s=r.getAttribute(t).split(h$2),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$2)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h$2),s=t.length-1;if(s>0){r.textContent=i$2?i$2.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$5)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h$2,t+1));)d.push({type:7,index:c}),t+=h$2.length-1;}c++;}}static createElement(t,i){const s=r$3.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$1(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),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$3).importNode(i,!0);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$3,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??!0;}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$1(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$1(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.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?.(!1,!0,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=!1;if(void 0===h)t=S(this,t,i,0),o=!c$1(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$1(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$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const s$1=globalThis;class i$1 extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return T}}i$1._$litElement$=!0,i$1["finalized"]=!0,s$1.litElementHydrateSupport?.({LitElement:i$1});const o$4=s$1.litElementPolyfillSupport;o$4?.({LitElement:i$1});(s$1.litElementVersions??=[]).push("4.2.1");
|
|
26
|
+
|
|
27
|
+
// src/components/dropdown/dropdown.styles.ts
|
|
28
|
+
var dropdown_styles_default = i$4`
|
|
29
|
+
:host {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dropdown::part(popup) {
|
|
34
|
+
z-index: var(--sl-z-index-dropdown);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dropdown[data-current-placement^='top']::part(popup) {
|
|
38
|
+
transform-origin: bottom;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dropdown[data-current-placement^='bottom']::part(popup) {
|
|
42
|
+
transform-origin: top;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dropdown[data-current-placement^='left']::part(popup) {
|
|
46
|
+
transform-origin: right;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dropdown[data-current-placement^='right']::part(popup) {
|
|
50
|
+
transform-origin: left;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dropdown__trigger {
|
|
54
|
+
display: block;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.dropdown__panel {
|
|
58
|
+
font-family: var(--sl-font-sans);
|
|
59
|
+
font-size: var(--sl-font-size-medium);
|
|
60
|
+
font-weight: var(--sl-font-weight-normal);
|
|
61
|
+
box-shadow: var(--sl-shadow-large);
|
|
62
|
+
border-radius: var(--sl-border-radius-medium);
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.dropdown--open .dropdown__panel {
|
|
67
|
+
display: block;
|
|
68
|
+
pointer-events: all;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* When users slot a menu, make sure it conforms to the popup's auto-size */
|
|
72
|
+
::slotted(sl-menu) {
|
|
73
|
+
max-width: var(--auto-size-available-width) !important;
|
|
74
|
+
max-height: var(--auto-size-available-height) !important;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
var __defProp = Object.defineProperty;
|
|
79
|
+
var __defProps = Object.defineProperties;
|
|
80
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
81
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
82
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
83
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
84
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
85
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
86
|
+
var __typeError = (msg) => {
|
|
87
|
+
throw TypeError(msg);
|
|
88
|
+
};
|
|
89
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
90
|
+
var __spreadValues = (a, b) => {
|
|
91
|
+
for (var prop in b || (b = {}))
|
|
92
|
+
if (__hasOwnProp.call(b, prop))
|
|
93
|
+
__defNormalProp(a, prop, b[prop]);
|
|
94
|
+
if (__getOwnPropSymbols)
|
|
95
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
96
|
+
if (__propIsEnum.call(b, prop))
|
|
97
|
+
__defNormalProp(a, prop, b[prop]);
|
|
98
|
+
}
|
|
99
|
+
return a;
|
|
100
|
+
};
|
|
101
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
102
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
103
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
104
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
105
|
+
if (decorator = decorators[i])
|
|
106
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
107
|
+
if (kind && result) __defProp(target, key, result);
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
111
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
112
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
113
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
114
|
+
var __await = function(promise, isYieldStar) {
|
|
115
|
+
this[0] = promise;
|
|
116
|
+
this[1] = isYieldStar;
|
|
117
|
+
};
|
|
118
|
+
var __yieldStar = (value) => {
|
|
119
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
120
|
+
if (obj == null) {
|
|
121
|
+
obj = value[__knownSymbol("iterator")]();
|
|
122
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
123
|
+
} else {
|
|
124
|
+
obj = obj.call(value);
|
|
125
|
+
method = (k) => it[k] = (v) => {
|
|
126
|
+
if (isAwait) {
|
|
127
|
+
isAwait = false;
|
|
128
|
+
if (k === "throw") throw v;
|
|
129
|
+
return v;
|
|
130
|
+
}
|
|
131
|
+
isAwait = true;
|
|
132
|
+
return {
|
|
133
|
+
done: false,
|
|
134
|
+
value: new __await(new Promise((resolve) => {
|
|
135
|
+
var x = obj[k](v);
|
|
136
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
137
|
+
resolve(x);
|
|
138
|
+
}), 1)
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
143
|
+
throw x;
|
|
144
|
+
}, "return" in obj && method("return"), it;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/internal/active-elements.ts
|
|
148
|
+
function* activeElements(activeElement = document.activeElement) {
|
|
149
|
+
if (activeElement === null || activeElement === void 0) return;
|
|
150
|
+
yield activeElement;
|
|
151
|
+
if ("shadowRoot" in activeElement && activeElement.shadowRoot && activeElement.shadowRoot.mode !== "closed") {
|
|
152
|
+
yield* __yieldStar(activeElements(activeElement.shadowRoot.activeElement));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function getDeepestActiveElement() {
|
|
156
|
+
return [...activeElements()].pop();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/internal/tabbable.ts
|
|
160
|
+
var computedStyleMap = /* @__PURE__ */ new WeakMap();
|
|
161
|
+
function getCachedComputedStyle(el) {
|
|
162
|
+
let computedStyle = computedStyleMap.get(el);
|
|
163
|
+
if (!computedStyle) {
|
|
164
|
+
computedStyle = window.getComputedStyle(el, null);
|
|
165
|
+
computedStyleMap.set(el, computedStyle);
|
|
166
|
+
}
|
|
167
|
+
return computedStyle;
|
|
168
|
+
}
|
|
169
|
+
function isVisible(el) {
|
|
170
|
+
if (typeof el.checkVisibility === "function") {
|
|
171
|
+
return el.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
|
|
172
|
+
}
|
|
173
|
+
const computedStyle = getCachedComputedStyle(el);
|
|
174
|
+
return computedStyle.visibility !== "hidden" && computedStyle.display !== "none";
|
|
175
|
+
}
|
|
176
|
+
function isOverflowingAndTabbable(el) {
|
|
177
|
+
const computedStyle = getCachedComputedStyle(el);
|
|
178
|
+
const { overflowY, overflowX } = computedStyle;
|
|
179
|
+
if (overflowY === "scroll" || overflowX === "scroll") {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (overflowY !== "auto" || overflowX !== "auto") {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const isOverflowingY = el.scrollHeight > el.clientHeight;
|
|
186
|
+
if (isOverflowingY && overflowY === "auto") {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
const isOverflowingX = el.scrollWidth > el.clientWidth;
|
|
190
|
+
if (isOverflowingX && overflowX === "auto") {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
function isTabbable(el) {
|
|
196
|
+
const tag = el.tagName.toLowerCase();
|
|
197
|
+
const tabindex = Number(el.getAttribute("tabindex"));
|
|
198
|
+
const hasTabindex = el.hasAttribute("tabindex");
|
|
199
|
+
if (hasTabindex && (isNaN(tabindex) || tabindex <= -1)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
if (el.hasAttribute("disabled")) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (el.closest("[inert]")) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (tag === "input" && el.getAttribute("type") === "radio") {
|
|
209
|
+
const rootNode = el.getRootNode();
|
|
210
|
+
const findRadios = `input[type='radio'][name="${el.getAttribute("name")}"]`;
|
|
211
|
+
const firstChecked = rootNode.querySelector(`${findRadios}:checked`);
|
|
212
|
+
if (firstChecked) {
|
|
213
|
+
return firstChecked === el;
|
|
214
|
+
}
|
|
215
|
+
const firstRadio = rootNode.querySelector(findRadios);
|
|
216
|
+
return firstRadio === el;
|
|
217
|
+
}
|
|
218
|
+
if (!isVisible(el)) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
if ((tag === "audio" || tag === "video") && el.hasAttribute("controls")) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
if (el.hasAttribute("tabindex")) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
if (el.hasAttribute("contenteditable") && el.getAttribute("contenteditable") !== "false") {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
const isNativelyTabbable = [
|
|
231
|
+
"button",
|
|
232
|
+
"input",
|
|
233
|
+
"select",
|
|
234
|
+
"textarea",
|
|
235
|
+
"a",
|
|
236
|
+
"audio",
|
|
237
|
+
"video",
|
|
238
|
+
"summary",
|
|
239
|
+
"iframe"
|
|
240
|
+
].includes(tag);
|
|
241
|
+
if (isNativelyTabbable) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return isOverflowingAndTabbable(el);
|
|
245
|
+
}
|
|
246
|
+
function getTabbableBoundary(root) {
|
|
247
|
+
var _a, _b;
|
|
248
|
+
const tabbableElements = getTabbableElements(root);
|
|
249
|
+
const start = (_a = tabbableElements[0]) != null ? _a : null;
|
|
250
|
+
const end = (_b = tabbableElements[tabbableElements.length - 1]) != null ? _b : null;
|
|
251
|
+
return { start, end };
|
|
252
|
+
}
|
|
253
|
+
function getSlottedChildrenOutsideRootElement(slotElement, root) {
|
|
254
|
+
var _a;
|
|
255
|
+
return ((_a = slotElement.getRootNode({ composed: true })) == null ? void 0 : _a.host) !== root;
|
|
256
|
+
}
|
|
257
|
+
function getTabbableElements(root) {
|
|
258
|
+
const walkedEls = /* @__PURE__ */ new WeakMap();
|
|
259
|
+
const tabbableElements = [];
|
|
260
|
+
function walk(el) {
|
|
261
|
+
if (el instanceof Element) {
|
|
262
|
+
if (el.hasAttribute("inert") || el.closest("[inert]")) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (walkedEls.has(el)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
walkedEls.set(el, true);
|
|
269
|
+
if (!tabbableElements.includes(el) && isTabbable(el)) {
|
|
270
|
+
tabbableElements.push(el);
|
|
271
|
+
}
|
|
272
|
+
if (el instanceof HTMLSlotElement && getSlottedChildrenOutsideRootElement(el, root)) {
|
|
273
|
+
el.assignedElements({ flatten: true }).forEach((assignedEl) => {
|
|
274
|
+
walk(assignedEl);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (el.shadowRoot !== null && el.shadowRoot.mode === "open") {
|
|
278
|
+
walk(el.shadowRoot);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (const e of el.children) {
|
|
282
|
+
walk(e);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
walk(root);
|
|
286
|
+
return tabbableElements.sort((a, b) => {
|
|
287
|
+
const aTabindex = Number(a.getAttribute("tabindex")) || 0;
|
|
288
|
+
const bTabindex = Number(b.getAttribute("tabindex")) || 0;
|
|
289
|
+
return bTabindex - aTabindex;
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/components/popup/popup.styles.ts
|
|
294
|
+
var popup_styles_default = i$4`
|
|
295
|
+
:host {
|
|
296
|
+
--arrow-color: var(--sl-color-neutral-1000);
|
|
297
|
+
--arrow-size: 6px;
|
|
298
|
+
|
|
299
|
+
/*
|
|
300
|
+
* These properties are computed to account for the arrow's dimensions after being rotated 45º. The constant
|
|
301
|
+
* 0.7071 is derived from sin(45), which is the diagonal size of the arrow's container after rotating.
|
|
302
|
+
*/
|
|
303
|
+
--arrow-size-diagonal: calc(var(--arrow-size) * 0.7071);
|
|
304
|
+
--arrow-padding-offset: calc(var(--arrow-size-diagonal) - var(--arrow-size));
|
|
305
|
+
|
|
306
|
+
display: contents;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.popup {
|
|
310
|
+
position: absolute;
|
|
311
|
+
isolation: isolate;
|
|
312
|
+
max-width: var(--auto-size-available-width, none);
|
|
313
|
+
max-height: var(--auto-size-available-height, none);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.popup--fixed {
|
|
317
|
+
position: fixed;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.popup:not(.popup--active) {
|
|
321
|
+
display: none;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.popup__arrow {
|
|
325
|
+
position: absolute;
|
|
326
|
+
width: calc(var(--arrow-size-diagonal) * 2);
|
|
327
|
+
height: calc(var(--arrow-size-diagonal) * 2);
|
|
328
|
+
rotate: 45deg;
|
|
329
|
+
background: var(--arrow-color);
|
|
330
|
+
z-index: -1;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* Hover bridge */
|
|
334
|
+
.popup-hover-bridge:not(.popup-hover-bridge--visible) {
|
|
335
|
+
display: none;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.popup-hover-bridge {
|
|
339
|
+
position: fixed;
|
|
340
|
+
z-index: calc(var(--sl-z-index-dropdown) - 1);
|
|
341
|
+
top: 0;
|
|
342
|
+
right: 0;
|
|
343
|
+
bottom: 0;
|
|
344
|
+
left: 0;
|
|
345
|
+
clip-path: polygon(
|
|
346
|
+
var(--hover-bridge-top-left-x, 0) var(--hover-bridge-top-left-y, 0),
|
|
347
|
+
var(--hover-bridge-top-right-x, 0) var(--hover-bridge-top-right-y, 0),
|
|
348
|
+
var(--hover-bridge-bottom-right-x, 0) var(--hover-bridge-bottom-right-y, 0),
|
|
349
|
+
var(--hover-bridge-bottom-left-x, 0) var(--hover-bridge-bottom-left-y, 0)
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
`;
|
|
353
|
+
|
|
354
|
+
const connectedElements = new Set();
|
|
355
|
+
const translations = new Map();
|
|
356
|
+
let fallback;
|
|
357
|
+
let documentDirection = 'ltr';
|
|
358
|
+
let documentLanguage = 'en';
|
|
359
|
+
const isClient = (typeof MutationObserver !== "undefined" && typeof document !== "undefined" && typeof document.documentElement !== "undefined");
|
|
360
|
+
if (isClient) {
|
|
361
|
+
const documentElementObserver = new MutationObserver(update);
|
|
362
|
+
documentDirection = document.documentElement.dir || 'ltr';
|
|
363
|
+
documentLanguage = document.documentElement.lang || navigator.language;
|
|
364
|
+
documentElementObserver.observe(document.documentElement, {
|
|
365
|
+
attributes: true,
|
|
366
|
+
attributeFilter: ['dir', 'lang']
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function registerTranslation(...translation) {
|
|
370
|
+
translation.map(t => {
|
|
371
|
+
const code = t.$code.toLowerCase();
|
|
372
|
+
if (translations.has(code)) {
|
|
373
|
+
translations.set(code, Object.assign(Object.assign({}, translations.get(code)), t));
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
translations.set(code, t);
|
|
377
|
+
}
|
|
378
|
+
if (!fallback) {
|
|
379
|
+
fallback = t;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
update();
|
|
383
|
+
}
|
|
384
|
+
function update() {
|
|
385
|
+
if (isClient) {
|
|
386
|
+
documentDirection = document.documentElement.dir || 'ltr';
|
|
387
|
+
documentLanguage = document.documentElement.lang || navigator.language;
|
|
388
|
+
}
|
|
389
|
+
[...connectedElements.keys()].map((el) => {
|
|
390
|
+
if (typeof el.requestUpdate === 'function') {
|
|
391
|
+
el.requestUpdate();
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
class LocalizeController$1 {
|
|
396
|
+
constructor(host) {
|
|
397
|
+
this.host = host;
|
|
398
|
+
this.host.addController(this);
|
|
399
|
+
}
|
|
400
|
+
hostConnected() {
|
|
401
|
+
connectedElements.add(this.host);
|
|
402
|
+
}
|
|
403
|
+
hostDisconnected() {
|
|
404
|
+
connectedElements.delete(this.host);
|
|
405
|
+
}
|
|
406
|
+
dir() {
|
|
407
|
+
return `${this.host.dir || documentDirection}`.toLowerCase();
|
|
408
|
+
}
|
|
409
|
+
lang() {
|
|
410
|
+
return `${this.host.lang || documentLanguage}`.toLowerCase();
|
|
411
|
+
}
|
|
412
|
+
getTranslationData(lang) {
|
|
413
|
+
var _a, _b;
|
|
414
|
+
const locale = new Intl.Locale(lang.replace(/_/g, '-'));
|
|
415
|
+
const language = locale === null || locale === void 0 ? void 0 : locale.language.toLowerCase();
|
|
416
|
+
const region = (_b = (_a = locale === null || locale === void 0 ? void 0 : locale.region) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
417
|
+
const primary = translations.get(`${language}-${region}`);
|
|
418
|
+
const secondary = translations.get(language);
|
|
419
|
+
return { locale, language, region, primary, secondary };
|
|
420
|
+
}
|
|
421
|
+
exists(key, options) {
|
|
422
|
+
var _a;
|
|
423
|
+
const { primary, secondary } = this.getTranslationData((_a = options.lang) !== null && _a !== void 0 ? _a : this.lang());
|
|
424
|
+
options = Object.assign({ includeFallback: false }, options);
|
|
425
|
+
if ((primary && primary[key]) ||
|
|
426
|
+
(secondary && secondary[key]) ||
|
|
427
|
+
(options.includeFallback && fallback && fallback[key])) {
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
term(key, ...args) {
|
|
433
|
+
const { primary, secondary } = this.getTranslationData(this.lang());
|
|
434
|
+
let term;
|
|
435
|
+
if (primary && primary[key]) {
|
|
436
|
+
term = primary[key];
|
|
437
|
+
}
|
|
438
|
+
else if (secondary && secondary[key]) {
|
|
439
|
+
term = secondary[key];
|
|
440
|
+
}
|
|
441
|
+
else if (fallback && fallback[key]) {
|
|
442
|
+
term = fallback[key];
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
console.error(`No translation found for: ${String(key)}`);
|
|
446
|
+
return String(key);
|
|
447
|
+
}
|
|
448
|
+
if (typeof term === 'function') {
|
|
449
|
+
return term(...args);
|
|
450
|
+
}
|
|
451
|
+
return term;
|
|
452
|
+
}
|
|
453
|
+
date(dateToFormat, options) {
|
|
454
|
+
dateToFormat = new Date(dateToFormat);
|
|
455
|
+
return new Intl.DateTimeFormat(this.lang(), options).format(dateToFormat);
|
|
456
|
+
}
|
|
457
|
+
number(numberToFormat, options) {
|
|
458
|
+
numberToFormat = Number(numberToFormat);
|
|
459
|
+
return isNaN(numberToFormat) ? '' : new Intl.NumberFormat(this.lang(), options).format(numberToFormat);
|
|
460
|
+
}
|
|
461
|
+
relativeTime(value, unit, options) {
|
|
462
|
+
return new Intl.RelativeTimeFormat(this.lang(), options).format(value, unit);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/translations/en.ts
|
|
467
|
+
var translation = {
|
|
468
|
+
$code: "en",
|
|
469
|
+
$name: "English",
|
|
470
|
+
$dir: "ltr",
|
|
471
|
+
carousel: "Carousel",
|
|
472
|
+
clearEntry: "Clear entry",
|
|
473
|
+
close: "Close",
|
|
474
|
+
copied: "Copied",
|
|
475
|
+
copy: "Copy",
|
|
476
|
+
currentValue: "Current value",
|
|
477
|
+
error: "Error",
|
|
478
|
+
goToSlide: (slide, count) => `Go to slide ${slide} of ${count}`,
|
|
479
|
+
hidePassword: "Hide password",
|
|
480
|
+
loading: "Loading",
|
|
481
|
+
nextSlide: "Next slide",
|
|
482
|
+
numOptionsSelected: (num) => {
|
|
483
|
+
if (num === 0) return "No options selected";
|
|
484
|
+
if (num === 1) return "1 option selected";
|
|
485
|
+
return `${num} options selected`;
|
|
486
|
+
},
|
|
487
|
+
previousSlide: "Previous slide",
|
|
488
|
+
progress: "Progress",
|
|
489
|
+
remove: "Remove",
|
|
490
|
+
resize: "Resize",
|
|
491
|
+
scrollToEnd: "Scroll to end",
|
|
492
|
+
scrollToStart: "Scroll to start",
|
|
493
|
+
selectAColorFromTheScreen: "Select a color from the screen",
|
|
494
|
+
showPassword: "Show password",
|
|
495
|
+
slideNum: (slide) => `Slide ${slide}`,
|
|
496
|
+
toggleColorFormat: "Toggle color format"
|
|
497
|
+
};
|
|
498
|
+
registerTranslation(translation);
|
|
499
|
+
var en_default = translation;
|
|
500
|
+
|
|
501
|
+
var LocalizeController = class extends LocalizeController$1 {
|
|
502
|
+
};
|
|
503
|
+
registerTranslation(en_default);
|
|
504
|
+
|
|
505
|
+
// src/styles/component.styles.ts
|
|
506
|
+
var component_styles_default = i$4`
|
|
507
|
+
:host {
|
|
508
|
+
box-sizing: border-box;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
:host *,
|
|
512
|
+
:host *::before,
|
|
513
|
+
:host *::after {
|
|
514
|
+
box-sizing: inherit;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
[hidden] {
|
|
518
|
+
display: none !important;
|
|
519
|
+
}
|
|
520
|
+
`;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @license
|
|
524
|
+
* Copyright 2017 Google LLC
|
|
525
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
526
|
+
*/const o$3={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$3},r$2=(t=o$3,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=!0),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$2(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)}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* @license
|
|
530
|
+
* Copyright 2017 Google LLC
|
|
531
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
532
|
+
*/function r$1(r){return n$2({...r,state:!0,attribute:!1})}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* @license
|
|
536
|
+
* Copyright 2017 Google LLC
|
|
537
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
538
|
+
*/
|
|
539
|
+
const e$5=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* @license
|
|
543
|
+
* Copyright 2017 Google LLC
|
|
544
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
545
|
+
*/function e$4(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$5(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$5(n,s,{get(){return o(this)}})}}
|
|
546
|
+
|
|
547
|
+
var _hasRecordedInitialProperties;
|
|
548
|
+
var ShoelaceElement = class extends i$1 {
|
|
549
|
+
constructor() {
|
|
550
|
+
super();
|
|
551
|
+
__privateAdd(this, _hasRecordedInitialProperties, false);
|
|
552
|
+
// Store the constructor value of all `static properties = {}`
|
|
553
|
+
this.initialReflectedProperties = /* @__PURE__ */ new Map();
|
|
554
|
+
Object.entries(this.constructor.dependencies).forEach(([name, component]) => {
|
|
555
|
+
this.constructor.define(name, component);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
emit(name, options) {
|
|
559
|
+
const event = new CustomEvent(name, __spreadValues({
|
|
560
|
+
bubbles: true,
|
|
561
|
+
cancelable: false,
|
|
562
|
+
composed: true,
|
|
563
|
+
detail: {}
|
|
564
|
+
}, options));
|
|
565
|
+
this.dispatchEvent(event);
|
|
566
|
+
return event;
|
|
567
|
+
}
|
|
568
|
+
/* eslint-enable */
|
|
569
|
+
static define(name, elementConstructor = this, options = {}) {
|
|
570
|
+
const currentlyRegisteredConstructor = customElements.get(name);
|
|
571
|
+
if (!currentlyRegisteredConstructor) {
|
|
572
|
+
try {
|
|
573
|
+
customElements.define(name, elementConstructor, options);
|
|
574
|
+
} catch (_err) {
|
|
575
|
+
customElements.define(name, class extends elementConstructor {
|
|
576
|
+
}, options);
|
|
577
|
+
}
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
let newVersion = " (unknown version)";
|
|
581
|
+
let existingVersion = newVersion;
|
|
582
|
+
if ("version" in elementConstructor && elementConstructor.version) {
|
|
583
|
+
newVersion = " v" + elementConstructor.version;
|
|
584
|
+
}
|
|
585
|
+
if ("version" in currentlyRegisteredConstructor && currentlyRegisteredConstructor.version) {
|
|
586
|
+
existingVersion = " v" + currentlyRegisteredConstructor.version;
|
|
587
|
+
}
|
|
588
|
+
if (newVersion && existingVersion && newVersion === existingVersion) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
console.warn(
|
|
592
|
+
`Attempted to register <${name}>${newVersion}, but <${name}>${existingVersion} has already been registered.`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
596
|
+
if (!__privateGet(this, _hasRecordedInitialProperties)) {
|
|
597
|
+
this.constructor.elementProperties.forEach(
|
|
598
|
+
(obj, prop) => {
|
|
599
|
+
if (obj.reflect && this[prop] != null) {
|
|
600
|
+
this.initialReflectedProperties.set(prop, this[prop]);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
__privateSet(this, _hasRecordedInitialProperties, true);
|
|
605
|
+
}
|
|
606
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
607
|
+
}
|
|
608
|
+
willUpdate(changedProperties) {
|
|
609
|
+
super.willUpdate(changedProperties);
|
|
610
|
+
this.initialReflectedProperties.forEach((value, prop) => {
|
|
611
|
+
if (changedProperties.has(prop) && this[prop] == null) {
|
|
612
|
+
this[prop] = value;
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
_hasRecordedInitialProperties = new WeakMap();
|
|
618
|
+
/* eslint-disable */
|
|
619
|
+
// @ts-expect-error This is auto-injected at build time.
|
|
620
|
+
ShoelaceElement.version = "2.20.1";
|
|
621
|
+
ShoelaceElement.dependencies = {};
|
|
622
|
+
__decorateClass([
|
|
623
|
+
n$2()
|
|
624
|
+
], ShoelaceElement.prototype, "dir", 2);
|
|
625
|
+
__decorateClass([
|
|
626
|
+
n$2()
|
|
627
|
+
], ShoelaceElement.prototype, "lang", 2);
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Custom positioning reference element.
|
|
631
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
635
|
+
const alignments = ['start', 'end'];
|
|
636
|
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
637
|
+
const min = Math.min;
|
|
638
|
+
const max = Math.max;
|
|
639
|
+
const round = Math.round;
|
|
640
|
+
const floor = Math.floor;
|
|
641
|
+
const createCoords = v => ({
|
|
642
|
+
x: v,
|
|
643
|
+
y: v
|
|
644
|
+
});
|
|
645
|
+
const oppositeSideMap = {
|
|
646
|
+
left: 'right',
|
|
647
|
+
right: 'left',
|
|
648
|
+
bottom: 'top',
|
|
649
|
+
top: 'bottom'
|
|
650
|
+
};
|
|
651
|
+
const oppositeAlignmentMap = {
|
|
652
|
+
start: 'end',
|
|
653
|
+
end: 'start'
|
|
654
|
+
};
|
|
655
|
+
function clamp(start, value, end) {
|
|
656
|
+
return max(start, min(value, end));
|
|
657
|
+
}
|
|
658
|
+
function evaluate(value, param) {
|
|
659
|
+
return typeof value === 'function' ? value(param) : value;
|
|
660
|
+
}
|
|
661
|
+
function getSide(placement) {
|
|
662
|
+
return placement.split('-')[0];
|
|
663
|
+
}
|
|
664
|
+
function getAlignment(placement) {
|
|
665
|
+
return placement.split('-')[1];
|
|
666
|
+
}
|
|
667
|
+
function getOppositeAxis(axis) {
|
|
668
|
+
return axis === 'x' ? 'y' : 'x';
|
|
669
|
+
}
|
|
670
|
+
function getAxisLength(axis) {
|
|
671
|
+
return axis === 'y' ? 'height' : 'width';
|
|
672
|
+
}
|
|
673
|
+
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
|
674
|
+
function getSideAxis(placement) {
|
|
675
|
+
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
|
676
|
+
}
|
|
677
|
+
function getAlignmentAxis(placement) {
|
|
678
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
679
|
+
}
|
|
680
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
681
|
+
if (rtl === void 0) {
|
|
682
|
+
rtl = false;
|
|
683
|
+
}
|
|
684
|
+
const alignment = getAlignment(placement);
|
|
685
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
686
|
+
const length = getAxisLength(alignmentAxis);
|
|
687
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
688
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
689
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
690
|
+
}
|
|
691
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
692
|
+
}
|
|
693
|
+
function getExpandedPlacements(placement) {
|
|
694
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
695
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
696
|
+
}
|
|
697
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
698
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
699
|
+
}
|
|
700
|
+
const lrPlacement = ['left', 'right'];
|
|
701
|
+
const rlPlacement = ['right', 'left'];
|
|
702
|
+
const tbPlacement = ['top', 'bottom'];
|
|
703
|
+
const btPlacement = ['bottom', 'top'];
|
|
704
|
+
function getSideList(side, isStart, rtl) {
|
|
705
|
+
switch (side) {
|
|
706
|
+
case 'top':
|
|
707
|
+
case 'bottom':
|
|
708
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
709
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
710
|
+
case 'left':
|
|
711
|
+
case 'right':
|
|
712
|
+
return isStart ? tbPlacement : btPlacement;
|
|
713
|
+
default:
|
|
714
|
+
return [];
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
718
|
+
const alignment = getAlignment(placement);
|
|
719
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
720
|
+
if (alignment) {
|
|
721
|
+
list = list.map(side => side + "-" + alignment);
|
|
722
|
+
if (flipAlignment) {
|
|
723
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return list;
|
|
727
|
+
}
|
|
728
|
+
function getOppositePlacement(placement) {
|
|
729
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
730
|
+
}
|
|
731
|
+
function expandPaddingObject(padding) {
|
|
732
|
+
return {
|
|
733
|
+
top: 0,
|
|
734
|
+
right: 0,
|
|
735
|
+
bottom: 0,
|
|
736
|
+
left: 0,
|
|
737
|
+
...padding
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function getPaddingObject(padding) {
|
|
741
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
742
|
+
top: padding,
|
|
743
|
+
right: padding,
|
|
744
|
+
bottom: padding,
|
|
745
|
+
left: padding
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function rectToClientRect(rect) {
|
|
749
|
+
const {
|
|
750
|
+
x,
|
|
751
|
+
y,
|
|
752
|
+
width,
|
|
753
|
+
height
|
|
754
|
+
} = rect;
|
|
755
|
+
return {
|
|
756
|
+
width,
|
|
757
|
+
height,
|
|
758
|
+
top: y,
|
|
759
|
+
left: x,
|
|
760
|
+
right: x + width,
|
|
761
|
+
bottom: y + height,
|
|
762
|
+
x,
|
|
763
|
+
y
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
768
|
+
let {
|
|
769
|
+
reference,
|
|
770
|
+
floating
|
|
771
|
+
} = _ref;
|
|
772
|
+
const sideAxis = getSideAxis(placement);
|
|
773
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
774
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
775
|
+
const side = getSide(placement);
|
|
776
|
+
const isVertical = sideAxis === 'y';
|
|
777
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
778
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
779
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
780
|
+
let coords;
|
|
781
|
+
switch (side) {
|
|
782
|
+
case 'top':
|
|
783
|
+
coords = {
|
|
784
|
+
x: commonX,
|
|
785
|
+
y: reference.y - floating.height
|
|
786
|
+
};
|
|
787
|
+
break;
|
|
788
|
+
case 'bottom':
|
|
789
|
+
coords = {
|
|
790
|
+
x: commonX,
|
|
791
|
+
y: reference.y + reference.height
|
|
792
|
+
};
|
|
793
|
+
break;
|
|
794
|
+
case 'right':
|
|
795
|
+
coords = {
|
|
796
|
+
x: reference.x + reference.width,
|
|
797
|
+
y: commonY
|
|
798
|
+
};
|
|
799
|
+
break;
|
|
800
|
+
case 'left':
|
|
801
|
+
coords = {
|
|
802
|
+
x: reference.x - floating.width,
|
|
803
|
+
y: commonY
|
|
804
|
+
};
|
|
805
|
+
break;
|
|
806
|
+
default:
|
|
807
|
+
coords = {
|
|
808
|
+
x: reference.x,
|
|
809
|
+
y: reference.y
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
switch (getAlignment(placement)) {
|
|
813
|
+
case 'start':
|
|
814
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
815
|
+
break;
|
|
816
|
+
case 'end':
|
|
817
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
return coords;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
825
|
+
* next to a given reference element.
|
|
826
|
+
*
|
|
827
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
828
|
+
* write one for the platform you are using Floating UI with.
|
|
829
|
+
*/
|
|
830
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
831
|
+
const {
|
|
832
|
+
placement = 'bottom',
|
|
833
|
+
strategy = 'absolute',
|
|
834
|
+
middleware = [],
|
|
835
|
+
platform
|
|
836
|
+
} = config;
|
|
837
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
838
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
839
|
+
let rects = await platform.getElementRects({
|
|
840
|
+
reference,
|
|
841
|
+
floating,
|
|
842
|
+
strategy
|
|
843
|
+
});
|
|
844
|
+
let {
|
|
845
|
+
x,
|
|
846
|
+
y
|
|
847
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
848
|
+
let statefulPlacement = placement;
|
|
849
|
+
let middlewareData = {};
|
|
850
|
+
let resetCount = 0;
|
|
851
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
852
|
+
const {
|
|
853
|
+
name,
|
|
854
|
+
fn
|
|
855
|
+
} = validMiddleware[i];
|
|
856
|
+
const {
|
|
857
|
+
x: nextX,
|
|
858
|
+
y: nextY,
|
|
859
|
+
data,
|
|
860
|
+
reset
|
|
861
|
+
} = await fn({
|
|
862
|
+
x,
|
|
863
|
+
y,
|
|
864
|
+
initialPlacement: placement,
|
|
865
|
+
placement: statefulPlacement,
|
|
866
|
+
strategy,
|
|
867
|
+
middlewareData,
|
|
868
|
+
rects,
|
|
869
|
+
platform,
|
|
870
|
+
elements: {
|
|
871
|
+
reference,
|
|
872
|
+
floating
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
x = nextX != null ? nextX : x;
|
|
876
|
+
y = nextY != null ? nextY : y;
|
|
877
|
+
middlewareData = {
|
|
878
|
+
...middlewareData,
|
|
879
|
+
[name]: {
|
|
880
|
+
...middlewareData[name],
|
|
881
|
+
...data
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
if (reset && resetCount <= 50) {
|
|
885
|
+
resetCount++;
|
|
886
|
+
if (typeof reset === 'object') {
|
|
887
|
+
if (reset.placement) {
|
|
888
|
+
statefulPlacement = reset.placement;
|
|
889
|
+
}
|
|
890
|
+
if (reset.rects) {
|
|
891
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
892
|
+
reference,
|
|
893
|
+
floating,
|
|
894
|
+
strategy
|
|
895
|
+
}) : reset.rects;
|
|
896
|
+
}
|
|
897
|
+
({
|
|
898
|
+
x,
|
|
899
|
+
y
|
|
900
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
901
|
+
}
|
|
902
|
+
i = -1;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return {
|
|
906
|
+
x,
|
|
907
|
+
y,
|
|
908
|
+
placement: statefulPlacement,
|
|
909
|
+
strategy,
|
|
910
|
+
middlewareData
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
916
|
+
* element is overflowing a given clipping boundary on each side.
|
|
917
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
918
|
+
* - negative = how many pixels left before it will overflow
|
|
919
|
+
* - 0 = lies flush with the boundary
|
|
920
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
921
|
+
*/
|
|
922
|
+
async function detectOverflow(state, options) {
|
|
923
|
+
var _await$platform$isEle;
|
|
924
|
+
if (options === void 0) {
|
|
925
|
+
options = {};
|
|
926
|
+
}
|
|
927
|
+
const {
|
|
928
|
+
x,
|
|
929
|
+
y,
|
|
930
|
+
platform,
|
|
931
|
+
rects,
|
|
932
|
+
elements,
|
|
933
|
+
strategy
|
|
934
|
+
} = state;
|
|
935
|
+
const {
|
|
936
|
+
boundary = 'clippingAncestors',
|
|
937
|
+
rootBoundary = 'viewport',
|
|
938
|
+
elementContext = 'floating',
|
|
939
|
+
altBoundary = false,
|
|
940
|
+
padding = 0
|
|
941
|
+
} = evaluate(options, state);
|
|
942
|
+
const paddingObject = getPaddingObject(padding);
|
|
943
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
944
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
945
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
946
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
947
|
+
boundary,
|
|
948
|
+
rootBoundary,
|
|
949
|
+
strategy
|
|
950
|
+
}));
|
|
951
|
+
const rect = elementContext === 'floating' ? {
|
|
952
|
+
x,
|
|
953
|
+
y,
|
|
954
|
+
width: rects.floating.width,
|
|
955
|
+
height: rects.floating.height
|
|
956
|
+
} : rects.reference;
|
|
957
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
958
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
959
|
+
x: 1,
|
|
960
|
+
y: 1
|
|
961
|
+
} : {
|
|
962
|
+
x: 1,
|
|
963
|
+
y: 1
|
|
964
|
+
};
|
|
965
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
966
|
+
elements,
|
|
967
|
+
rect,
|
|
968
|
+
offsetParent,
|
|
969
|
+
strategy
|
|
970
|
+
}) : rect);
|
|
971
|
+
return {
|
|
972
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
973
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
974
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
975
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Provides data to position an inner element of the floating element so that it
|
|
981
|
+
* appears centered to the reference element.
|
|
982
|
+
* @see https://floating-ui.com/docs/arrow
|
|
983
|
+
*/
|
|
984
|
+
const arrow$1 = options => ({
|
|
985
|
+
name: 'arrow',
|
|
986
|
+
options,
|
|
987
|
+
async fn(state) {
|
|
988
|
+
const {
|
|
989
|
+
x,
|
|
990
|
+
y,
|
|
991
|
+
placement,
|
|
992
|
+
rects,
|
|
993
|
+
platform,
|
|
994
|
+
elements,
|
|
995
|
+
middlewareData
|
|
996
|
+
} = state;
|
|
997
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
998
|
+
const {
|
|
999
|
+
element,
|
|
1000
|
+
padding = 0
|
|
1001
|
+
} = evaluate(options, state) || {};
|
|
1002
|
+
if (element == null) {
|
|
1003
|
+
return {};
|
|
1004
|
+
}
|
|
1005
|
+
const paddingObject = getPaddingObject(padding);
|
|
1006
|
+
const coords = {
|
|
1007
|
+
x,
|
|
1008
|
+
y
|
|
1009
|
+
};
|
|
1010
|
+
const axis = getAlignmentAxis(placement);
|
|
1011
|
+
const length = getAxisLength(axis);
|
|
1012
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1013
|
+
const isYAxis = axis === 'y';
|
|
1014
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
1015
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
1016
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
1017
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1018
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1019
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1020
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1021
|
+
|
|
1022
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
1023
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
1024
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1025
|
+
}
|
|
1026
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1027
|
+
|
|
1028
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
1029
|
+
// centered, modify the padding so that it is centered.
|
|
1030
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1031
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
1032
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
1033
|
+
|
|
1034
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
1035
|
+
// point is outside the floating element's bounds.
|
|
1036
|
+
const min$1 = minPadding;
|
|
1037
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1038
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1039
|
+
const offset = clamp(min$1, center, max);
|
|
1040
|
+
|
|
1041
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
1042
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1043
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
1044
|
+
// a single reset is performed when this is true.
|
|
1045
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1046
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1047
|
+
return {
|
|
1048
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
1049
|
+
data: {
|
|
1050
|
+
[axis]: offset,
|
|
1051
|
+
centerOffset: center - offset - alignmentOffset,
|
|
1052
|
+
...(shouldAddOffset && {
|
|
1053
|
+
alignmentOffset
|
|
1054
|
+
})
|
|
1055
|
+
},
|
|
1056
|
+
reset: shouldAddOffset
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
1062
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
1063
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
1064
|
+
if (alignment) {
|
|
1065
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
1066
|
+
}
|
|
1067
|
+
return true;
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
1072
|
+
* that has the most space available automatically, without needing to specify a
|
|
1073
|
+
* preferred placement. Alternative to `flip`.
|
|
1074
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
1075
|
+
*/
|
|
1076
|
+
const autoPlacement = function (options) {
|
|
1077
|
+
if (options === void 0) {
|
|
1078
|
+
options = {};
|
|
1079
|
+
}
|
|
1080
|
+
return {
|
|
1081
|
+
name: 'autoPlacement',
|
|
1082
|
+
options,
|
|
1083
|
+
async fn(state) {
|
|
1084
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
1085
|
+
const {
|
|
1086
|
+
rects,
|
|
1087
|
+
middlewareData,
|
|
1088
|
+
placement,
|
|
1089
|
+
platform,
|
|
1090
|
+
elements
|
|
1091
|
+
} = state;
|
|
1092
|
+
const {
|
|
1093
|
+
crossAxis = false,
|
|
1094
|
+
alignment,
|
|
1095
|
+
allowedPlacements = placements,
|
|
1096
|
+
autoAlignment = true,
|
|
1097
|
+
...detectOverflowOptions
|
|
1098
|
+
} = evaluate(options, state);
|
|
1099
|
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
1100
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1101
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
1102
|
+
const currentPlacement = placements$1[currentIndex];
|
|
1103
|
+
if (currentPlacement == null) {
|
|
1104
|
+
return {};
|
|
1105
|
+
}
|
|
1106
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
1107
|
+
|
|
1108
|
+
// Make `computeCoords` start from the right place.
|
|
1109
|
+
if (placement !== currentPlacement) {
|
|
1110
|
+
return {
|
|
1111
|
+
reset: {
|
|
1112
|
+
placement: placements$1[0]
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
1117
|
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
|
1118
|
+
placement: currentPlacement,
|
|
1119
|
+
overflows: currentOverflows
|
|
1120
|
+
}];
|
|
1121
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
1122
|
+
|
|
1123
|
+
// There are more placements to check.
|
|
1124
|
+
if (nextPlacement) {
|
|
1125
|
+
return {
|
|
1126
|
+
data: {
|
|
1127
|
+
index: currentIndex + 1,
|
|
1128
|
+
overflows: allOverflows
|
|
1129
|
+
},
|
|
1130
|
+
reset: {
|
|
1131
|
+
placement: nextPlacement
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
|
1136
|
+
const alignment = getAlignment(d.placement);
|
|
1137
|
+
return [d.placement, alignment && crossAxis ?
|
|
1138
|
+
// Check along the mainAxis and main crossAxis side.
|
|
1139
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
|
1140
|
+
// Check only the mainAxis.
|
|
1141
|
+
d.overflows[0], d.overflows];
|
|
1142
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
1143
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
|
1144
|
+
// Aligned placements should not check their opposite crossAxis
|
|
1145
|
+
// side.
|
|
1146
|
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
|
1147
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
1148
|
+
if (resetPlacement !== placement) {
|
|
1149
|
+
return {
|
|
1150
|
+
data: {
|
|
1151
|
+
index: currentIndex + 1,
|
|
1152
|
+
overflows: allOverflows
|
|
1153
|
+
},
|
|
1154
|
+
reset: {
|
|
1155
|
+
placement: resetPlacement
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
return {};
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1166
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1167
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1168
|
+
* @see https://floating-ui.com/docs/flip
|
|
1169
|
+
*/
|
|
1170
|
+
const flip$1 = function (options) {
|
|
1171
|
+
if (options === void 0) {
|
|
1172
|
+
options = {};
|
|
1173
|
+
}
|
|
1174
|
+
return {
|
|
1175
|
+
name: 'flip',
|
|
1176
|
+
options,
|
|
1177
|
+
async fn(state) {
|
|
1178
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
1179
|
+
const {
|
|
1180
|
+
placement,
|
|
1181
|
+
middlewareData,
|
|
1182
|
+
rects,
|
|
1183
|
+
initialPlacement,
|
|
1184
|
+
platform,
|
|
1185
|
+
elements
|
|
1186
|
+
} = state;
|
|
1187
|
+
const {
|
|
1188
|
+
mainAxis: checkMainAxis = true,
|
|
1189
|
+
crossAxis: checkCrossAxis = true,
|
|
1190
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1191
|
+
fallbackStrategy = 'bestFit',
|
|
1192
|
+
fallbackAxisSideDirection = 'none',
|
|
1193
|
+
flipAlignment = true,
|
|
1194
|
+
...detectOverflowOptions
|
|
1195
|
+
} = evaluate(options, state);
|
|
1196
|
+
|
|
1197
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
1198
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
1199
|
+
// work.
|
|
1200
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
1201
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1202
|
+
return {};
|
|
1203
|
+
}
|
|
1204
|
+
const side = getSide(placement);
|
|
1205
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1206
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1207
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1208
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1209
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
1210
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1211
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1212
|
+
}
|
|
1213
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1214
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1215
|
+
const overflows = [];
|
|
1216
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1217
|
+
if (checkMainAxis) {
|
|
1218
|
+
overflows.push(overflow[side]);
|
|
1219
|
+
}
|
|
1220
|
+
if (checkCrossAxis) {
|
|
1221
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
1222
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
1223
|
+
}
|
|
1224
|
+
overflowsData = [...overflowsData, {
|
|
1225
|
+
placement,
|
|
1226
|
+
overflows
|
|
1227
|
+
}];
|
|
1228
|
+
|
|
1229
|
+
// One or more sides is overflowing.
|
|
1230
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1231
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1232
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1233
|
+
const nextPlacement = placements[nextIndex];
|
|
1234
|
+
if (nextPlacement) {
|
|
1235
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
1236
|
+
if (!ignoreCrossAxisOverflow ||
|
|
1237
|
+
// We leave the current main axis only if every placement on that axis
|
|
1238
|
+
// overflows the main axis.
|
|
1239
|
+
overflowsData.every(d => d.overflows[0] > 0 && getSideAxis(d.placement) === initialSideAxis)) {
|
|
1240
|
+
// Try next placement and re-run the lifecycle.
|
|
1241
|
+
return {
|
|
1242
|
+
data: {
|
|
1243
|
+
index: nextIndex,
|
|
1244
|
+
overflows: overflowsData
|
|
1245
|
+
},
|
|
1246
|
+
reset: {
|
|
1247
|
+
placement: nextPlacement
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
1254
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
1255
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1256
|
+
|
|
1257
|
+
// Otherwise fallback.
|
|
1258
|
+
if (!resetPlacement) {
|
|
1259
|
+
switch (fallbackStrategy) {
|
|
1260
|
+
case 'bestFit':
|
|
1261
|
+
{
|
|
1262
|
+
var _overflowsData$filter2;
|
|
1263
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
1264
|
+
if (hasFallbackAxisSideDirection) {
|
|
1265
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
1266
|
+
return currentSideAxis === initialSideAxis ||
|
|
1267
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
1268
|
+
// reading directions favoring greater width.
|
|
1269
|
+
currentSideAxis === 'y';
|
|
1270
|
+
}
|
|
1271
|
+
return true;
|
|
1272
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
1273
|
+
if (placement) {
|
|
1274
|
+
resetPlacement = placement;
|
|
1275
|
+
}
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
case 'initialPlacement':
|
|
1279
|
+
resetPlacement = initialPlacement;
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if (placement !== resetPlacement) {
|
|
1284
|
+
return {
|
|
1285
|
+
reset: {
|
|
1286
|
+
placement: resetPlacement
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return {};
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
function getSideOffsets(overflow, rect) {
|
|
1297
|
+
return {
|
|
1298
|
+
top: overflow.top - rect.height,
|
|
1299
|
+
right: overflow.right - rect.width,
|
|
1300
|
+
bottom: overflow.bottom - rect.height,
|
|
1301
|
+
left: overflow.left - rect.width
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function isAnySideFullyClipped(overflow) {
|
|
1305
|
+
return sides.some(side => overflow[side] >= 0);
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
1309
|
+
* when it is not in the same clipping context as the reference element.
|
|
1310
|
+
* @see https://floating-ui.com/docs/hide
|
|
1311
|
+
*/
|
|
1312
|
+
const hide = function (options) {
|
|
1313
|
+
if (options === void 0) {
|
|
1314
|
+
options = {};
|
|
1315
|
+
}
|
|
1316
|
+
return {
|
|
1317
|
+
name: 'hide',
|
|
1318
|
+
options,
|
|
1319
|
+
async fn(state) {
|
|
1320
|
+
const {
|
|
1321
|
+
rects
|
|
1322
|
+
} = state;
|
|
1323
|
+
const {
|
|
1324
|
+
strategy = 'referenceHidden',
|
|
1325
|
+
...detectOverflowOptions
|
|
1326
|
+
} = evaluate(options, state);
|
|
1327
|
+
switch (strategy) {
|
|
1328
|
+
case 'referenceHidden':
|
|
1329
|
+
{
|
|
1330
|
+
const overflow = await detectOverflow(state, {
|
|
1331
|
+
...detectOverflowOptions,
|
|
1332
|
+
elementContext: 'reference'
|
|
1333
|
+
});
|
|
1334
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
1335
|
+
return {
|
|
1336
|
+
data: {
|
|
1337
|
+
referenceHiddenOffsets: offsets,
|
|
1338
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
case 'escaped':
|
|
1343
|
+
{
|
|
1344
|
+
const overflow = await detectOverflow(state, {
|
|
1345
|
+
...detectOverflowOptions,
|
|
1346
|
+
altBoundary: true
|
|
1347
|
+
});
|
|
1348
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
1349
|
+
return {
|
|
1350
|
+
data: {
|
|
1351
|
+
escapedOffsets: offsets,
|
|
1352
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
default:
|
|
1357
|
+
{
|
|
1358
|
+
return {};
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
function getBoundingRect(rects) {
|
|
1366
|
+
const minX = min(...rects.map(rect => rect.left));
|
|
1367
|
+
const minY = min(...rects.map(rect => rect.top));
|
|
1368
|
+
const maxX = max(...rects.map(rect => rect.right));
|
|
1369
|
+
const maxY = max(...rects.map(rect => rect.bottom));
|
|
1370
|
+
return {
|
|
1371
|
+
x: minX,
|
|
1372
|
+
y: minY,
|
|
1373
|
+
width: maxX - minX,
|
|
1374
|
+
height: maxY - minY
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function getRectsByLine(rects) {
|
|
1378
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
1379
|
+
const groups = [];
|
|
1380
|
+
let prevRect = null;
|
|
1381
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
1382
|
+
const rect = sortedRects[i];
|
|
1383
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
1384
|
+
groups.push([rect]);
|
|
1385
|
+
} else {
|
|
1386
|
+
groups[groups.length - 1].push(rect);
|
|
1387
|
+
}
|
|
1388
|
+
prevRect = rect;
|
|
1389
|
+
}
|
|
1390
|
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Provides improved positioning for inline reference elements that can span
|
|
1394
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
1395
|
+
* @see https://floating-ui.com/docs/inline
|
|
1396
|
+
*/
|
|
1397
|
+
const inline = function (options) {
|
|
1398
|
+
if (options === void 0) {
|
|
1399
|
+
options = {};
|
|
1400
|
+
}
|
|
1401
|
+
return {
|
|
1402
|
+
name: 'inline',
|
|
1403
|
+
options,
|
|
1404
|
+
async fn(state) {
|
|
1405
|
+
const {
|
|
1406
|
+
placement,
|
|
1407
|
+
elements,
|
|
1408
|
+
rects,
|
|
1409
|
+
platform,
|
|
1410
|
+
strategy
|
|
1411
|
+
} = state;
|
|
1412
|
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
1413
|
+
// ClientRect's bounds, despite the event listener being triggered. A
|
|
1414
|
+
// padding of 2 seems to handle this issue.
|
|
1415
|
+
const {
|
|
1416
|
+
padding = 2,
|
|
1417
|
+
x,
|
|
1418
|
+
y
|
|
1419
|
+
} = evaluate(options, state);
|
|
1420
|
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
1421
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
1422
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
1423
|
+
const paddingObject = getPaddingObject(padding);
|
|
1424
|
+
function getBoundingClientRect() {
|
|
1425
|
+
// There are two rects and they are disjoined.
|
|
1426
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
1427
|
+
// Find the first rect in which the point is fully inside.
|
|
1428
|
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// There are 2 or more connected rects.
|
|
1432
|
+
if (clientRects.length >= 2) {
|
|
1433
|
+
if (getSideAxis(placement) === 'y') {
|
|
1434
|
+
const firstRect = clientRects[0];
|
|
1435
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
1436
|
+
const isTop = getSide(placement) === 'top';
|
|
1437
|
+
const top = firstRect.top;
|
|
1438
|
+
const bottom = lastRect.bottom;
|
|
1439
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
1440
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
1441
|
+
const width = right - left;
|
|
1442
|
+
const height = bottom - top;
|
|
1443
|
+
return {
|
|
1444
|
+
top,
|
|
1445
|
+
bottom,
|
|
1446
|
+
left,
|
|
1447
|
+
right,
|
|
1448
|
+
width,
|
|
1449
|
+
height,
|
|
1450
|
+
x: left,
|
|
1451
|
+
y: top
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
const isLeftSide = getSide(placement) === 'left';
|
|
1455
|
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
|
1456
|
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
|
1457
|
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
1458
|
+
const top = measureRects[0].top;
|
|
1459
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
1460
|
+
const left = minLeft;
|
|
1461
|
+
const right = maxRight;
|
|
1462
|
+
const width = right - left;
|
|
1463
|
+
const height = bottom - top;
|
|
1464
|
+
return {
|
|
1465
|
+
top,
|
|
1466
|
+
bottom,
|
|
1467
|
+
left,
|
|
1468
|
+
right,
|
|
1469
|
+
width,
|
|
1470
|
+
height,
|
|
1471
|
+
x: left,
|
|
1472
|
+
y: top
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
return fallback;
|
|
1476
|
+
}
|
|
1477
|
+
const resetRects = await platform.getElementRects({
|
|
1478
|
+
reference: {
|
|
1479
|
+
getBoundingClientRect
|
|
1480
|
+
},
|
|
1481
|
+
floating: elements.floating,
|
|
1482
|
+
strategy
|
|
1483
|
+
});
|
|
1484
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
1485
|
+
return {
|
|
1486
|
+
reset: {
|
|
1487
|
+
rects: resetRects
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
return {};
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
1497
|
+
|
|
1498
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
1499
|
+
// Derivable.
|
|
1500
|
+
|
|
1501
|
+
async function convertValueToCoords(state, options) {
|
|
1502
|
+
const {
|
|
1503
|
+
placement,
|
|
1504
|
+
platform,
|
|
1505
|
+
elements
|
|
1506
|
+
} = state;
|
|
1507
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1508
|
+
const side = getSide(placement);
|
|
1509
|
+
const alignment = getAlignment(placement);
|
|
1510
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
1511
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
1512
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1513
|
+
const rawValue = evaluate(options, state);
|
|
1514
|
+
|
|
1515
|
+
// eslint-disable-next-line prefer-const
|
|
1516
|
+
let {
|
|
1517
|
+
mainAxis,
|
|
1518
|
+
crossAxis,
|
|
1519
|
+
alignmentAxis
|
|
1520
|
+
} = typeof rawValue === 'number' ? {
|
|
1521
|
+
mainAxis: rawValue,
|
|
1522
|
+
crossAxis: 0,
|
|
1523
|
+
alignmentAxis: null
|
|
1524
|
+
} : {
|
|
1525
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1526
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1527
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1528
|
+
};
|
|
1529
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1530
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1531
|
+
}
|
|
1532
|
+
return isVertical ? {
|
|
1533
|
+
x: crossAxis * crossAxisMulti,
|
|
1534
|
+
y: mainAxis * mainAxisMulti
|
|
1535
|
+
} : {
|
|
1536
|
+
x: mainAxis * mainAxisMulti,
|
|
1537
|
+
y: crossAxis * crossAxisMulti
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Modifies the placement by translating the floating element along the
|
|
1543
|
+
* specified axes.
|
|
1544
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1545
|
+
* object may be passed.
|
|
1546
|
+
* @see https://floating-ui.com/docs/offset
|
|
1547
|
+
*/
|
|
1548
|
+
const offset$1 = function (options) {
|
|
1549
|
+
if (options === void 0) {
|
|
1550
|
+
options = 0;
|
|
1551
|
+
}
|
|
1552
|
+
return {
|
|
1553
|
+
name: 'offset',
|
|
1554
|
+
options,
|
|
1555
|
+
async fn(state) {
|
|
1556
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1557
|
+
const {
|
|
1558
|
+
x,
|
|
1559
|
+
y,
|
|
1560
|
+
placement,
|
|
1561
|
+
middlewareData
|
|
1562
|
+
} = state;
|
|
1563
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
1564
|
+
|
|
1565
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
1566
|
+
// then we don't need to change the positioning coordinates.
|
|
1567
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1568
|
+
return {};
|
|
1569
|
+
}
|
|
1570
|
+
return {
|
|
1571
|
+
x: x + diffCoords.x,
|
|
1572
|
+
y: y + diffCoords.y,
|
|
1573
|
+
data: {
|
|
1574
|
+
...diffCoords,
|
|
1575
|
+
placement
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1584
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1585
|
+
* @see https://floating-ui.com/docs/shift
|
|
1586
|
+
*/
|
|
1587
|
+
const shift$1 = function (options) {
|
|
1588
|
+
if (options === void 0) {
|
|
1589
|
+
options = {};
|
|
1590
|
+
}
|
|
1591
|
+
return {
|
|
1592
|
+
name: 'shift',
|
|
1593
|
+
options,
|
|
1594
|
+
async fn(state) {
|
|
1595
|
+
const {
|
|
1596
|
+
x,
|
|
1597
|
+
y,
|
|
1598
|
+
placement
|
|
1599
|
+
} = state;
|
|
1600
|
+
const {
|
|
1601
|
+
mainAxis: checkMainAxis = true,
|
|
1602
|
+
crossAxis: checkCrossAxis = false,
|
|
1603
|
+
limiter = {
|
|
1604
|
+
fn: _ref => {
|
|
1605
|
+
let {
|
|
1606
|
+
x,
|
|
1607
|
+
y
|
|
1608
|
+
} = _ref;
|
|
1609
|
+
return {
|
|
1610
|
+
x,
|
|
1611
|
+
y
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
...detectOverflowOptions
|
|
1616
|
+
} = evaluate(options, state);
|
|
1617
|
+
const coords = {
|
|
1618
|
+
x,
|
|
1619
|
+
y
|
|
1620
|
+
};
|
|
1621
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1622
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1623
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1624
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1625
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1626
|
+
if (checkMainAxis) {
|
|
1627
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1628
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1629
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1630
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1631
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
1632
|
+
}
|
|
1633
|
+
if (checkCrossAxis) {
|
|
1634
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1635
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1636
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1637
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1638
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
1639
|
+
}
|
|
1640
|
+
const limitedCoords = limiter.fn({
|
|
1641
|
+
...state,
|
|
1642
|
+
[mainAxis]: mainAxisCoord,
|
|
1643
|
+
[crossAxis]: crossAxisCoord
|
|
1644
|
+
});
|
|
1645
|
+
return {
|
|
1646
|
+
...limitedCoords,
|
|
1647
|
+
data: {
|
|
1648
|
+
x: limitedCoords.x - x,
|
|
1649
|
+
y: limitedCoords.y - y,
|
|
1650
|
+
enabled: {
|
|
1651
|
+
[mainAxis]: checkMainAxis,
|
|
1652
|
+
[crossAxis]: checkCrossAxis
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
/**
|
|
1660
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1661
|
+
*/
|
|
1662
|
+
const limitShift = function (options) {
|
|
1663
|
+
if (options === void 0) {
|
|
1664
|
+
options = {};
|
|
1665
|
+
}
|
|
1666
|
+
return {
|
|
1667
|
+
options,
|
|
1668
|
+
fn(state) {
|
|
1669
|
+
const {
|
|
1670
|
+
x,
|
|
1671
|
+
y,
|
|
1672
|
+
placement,
|
|
1673
|
+
rects,
|
|
1674
|
+
middlewareData
|
|
1675
|
+
} = state;
|
|
1676
|
+
const {
|
|
1677
|
+
offset = 0,
|
|
1678
|
+
mainAxis: checkMainAxis = true,
|
|
1679
|
+
crossAxis: checkCrossAxis = true
|
|
1680
|
+
} = evaluate(options, state);
|
|
1681
|
+
const coords = {
|
|
1682
|
+
x,
|
|
1683
|
+
y
|
|
1684
|
+
};
|
|
1685
|
+
const crossAxis = getSideAxis(placement);
|
|
1686
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1687
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1688
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1689
|
+
const rawOffset = evaluate(offset, state);
|
|
1690
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
|
1691
|
+
mainAxis: rawOffset,
|
|
1692
|
+
crossAxis: 0
|
|
1693
|
+
} : {
|
|
1694
|
+
mainAxis: 0,
|
|
1695
|
+
crossAxis: 0,
|
|
1696
|
+
...rawOffset
|
|
1697
|
+
};
|
|
1698
|
+
if (checkMainAxis) {
|
|
1699
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
1700
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
1701
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
1702
|
+
if (mainAxisCoord < limitMin) {
|
|
1703
|
+
mainAxisCoord = limitMin;
|
|
1704
|
+
} else if (mainAxisCoord > limitMax) {
|
|
1705
|
+
mainAxisCoord = limitMax;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
if (checkCrossAxis) {
|
|
1709
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
1710
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
1711
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
1712
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
1713
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
1714
|
+
if (crossAxisCoord < limitMin) {
|
|
1715
|
+
crossAxisCoord = limitMin;
|
|
1716
|
+
} else if (crossAxisCoord > limitMax) {
|
|
1717
|
+
crossAxisCoord = limitMax;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
[mainAxis]: mainAxisCoord,
|
|
1722
|
+
[crossAxis]: crossAxisCoord
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
/**
|
|
1729
|
+
* Provides data that allows you to change the size of the floating element —
|
|
1730
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1731
|
+
* width of the reference element.
|
|
1732
|
+
* @see https://floating-ui.com/docs/size
|
|
1733
|
+
*/
|
|
1734
|
+
const size$1 = function (options) {
|
|
1735
|
+
if (options === void 0) {
|
|
1736
|
+
options = {};
|
|
1737
|
+
}
|
|
1738
|
+
return {
|
|
1739
|
+
name: 'size',
|
|
1740
|
+
options,
|
|
1741
|
+
async fn(state) {
|
|
1742
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
1743
|
+
const {
|
|
1744
|
+
placement,
|
|
1745
|
+
rects,
|
|
1746
|
+
platform,
|
|
1747
|
+
elements
|
|
1748
|
+
} = state;
|
|
1749
|
+
const {
|
|
1750
|
+
apply = () => {},
|
|
1751
|
+
...detectOverflowOptions
|
|
1752
|
+
} = evaluate(options, state);
|
|
1753
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1754
|
+
const side = getSide(placement);
|
|
1755
|
+
const alignment = getAlignment(placement);
|
|
1756
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
1757
|
+
const {
|
|
1758
|
+
width,
|
|
1759
|
+
height
|
|
1760
|
+
} = rects.floating;
|
|
1761
|
+
let heightSide;
|
|
1762
|
+
let widthSide;
|
|
1763
|
+
if (side === 'top' || side === 'bottom') {
|
|
1764
|
+
heightSide = side;
|
|
1765
|
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
1766
|
+
} else {
|
|
1767
|
+
widthSide = side;
|
|
1768
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
1769
|
+
}
|
|
1770
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
1771
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
1772
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
1773
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
1774
|
+
const noShift = !state.middlewareData.shift;
|
|
1775
|
+
let availableHeight = overflowAvailableHeight;
|
|
1776
|
+
let availableWidth = overflowAvailableWidth;
|
|
1777
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
1778
|
+
availableWidth = maximumClippingWidth;
|
|
1779
|
+
}
|
|
1780
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
1781
|
+
availableHeight = maximumClippingHeight;
|
|
1782
|
+
}
|
|
1783
|
+
if (noShift && !alignment) {
|
|
1784
|
+
const xMin = max(overflow.left, 0);
|
|
1785
|
+
const xMax = max(overflow.right, 0);
|
|
1786
|
+
const yMin = max(overflow.top, 0);
|
|
1787
|
+
const yMax = max(overflow.bottom, 0);
|
|
1788
|
+
if (isYAxis) {
|
|
1789
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
1790
|
+
} else {
|
|
1791
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
await apply({
|
|
1795
|
+
...state,
|
|
1796
|
+
availableWidth,
|
|
1797
|
+
availableHeight
|
|
1798
|
+
});
|
|
1799
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
1800
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
1801
|
+
return {
|
|
1802
|
+
reset: {
|
|
1803
|
+
rects: true
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
return {};
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1812
|
+
function hasWindow() {
|
|
1813
|
+
return typeof window !== 'undefined';
|
|
1814
|
+
}
|
|
1815
|
+
function getNodeName(node) {
|
|
1816
|
+
if (isNode(node)) {
|
|
1817
|
+
return (node.nodeName || '').toLowerCase();
|
|
1818
|
+
}
|
|
1819
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
1820
|
+
// returning `#document` an infinite loop won't occur.
|
|
1821
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
1822
|
+
return '#document';
|
|
1823
|
+
}
|
|
1824
|
+
function getWindow(node) {
|
|
1825
|
+
var _node$ownerDocument;
|
|
1826
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1827
|
+
}
|
|
1828
|
+
function getDocumentElement(node) {
|
|
1829
|
+
var _ref;
|
|
1830
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1831
|
+
}
|
|
1832
|
+
function isNode(value) {
|
|
1833
|
+
if (!hasWindow()) {
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1836
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1837
|
+
}
|
|
1838
|
+
function isElement(value) {
|
|
1839
|
+
if (!hasWindow()) {
|
|
1840
|
+
return false;
|
|
1841
|
+
}
|
|
1842
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1843
|
+
}
|
|
1844
|
+
function isHTMLElement(value) {
|
|
1845
|
+
if (!hasWindow()) {
|
|
1846
|
+
return false;
|
|
1847
|
+
}
|
|
1848
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1849
|
+
}
|
|
1850
|
+
function isShadowRoot(value) {
|
|
1851
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
1852
|
+
return false;
|
|
1853
|
+
}
|
|
1854
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1855
|
+
}
|
|
1856
|
+
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
|
1857
|
+
function isOverflowElement(element) {
|
|
1858
|
+
const {
|
|
1859
|
+
overflow,
|
|
1860
|
+
overflowX,
|
|
1861
|
+
overflowY,
|
|
1862
|
+
display
|
|
1863
|
+
} = getComputedStyle$1(element);
|
|
1864
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
1865
|
+
}
|
|
1866
|
+
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
1867
|
+
function isTableElement(element) {
|
|
1868
|
+
return tableElements.has(getNodeName(element));
|
|
1869
|
+
}
|
|
1870
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
1871
|
+
function isTopLayer(element) {
|
|
1872
|
+
return topLayerSelectors.some(selector => {
|
|
1873
|
+
try {
|
|
1874
|
+
return element.matches(selector);
|
|
1875
|
+
} catch (_e) {
|
|
1876
|
+
return false;
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
|
1881
|
+
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
|
1882
|
+
const containValues = ['paint', 'layout', 'strict', 'content'];
|
|
1883
|
+
function isContainingBlock(elementOrCss) {
|
|
1884
|
+
const webkit = isWebKit();
|
|
1885
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1886
|
+
|
|
1887
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1888
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
1889
|
+
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
|
1890
|
+
}
|
|
1891
|
+
function getContainingBlock(element) {
|
|
1892
|
+
let currentNode = getParentNode(element);
|
|
1893
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1894
|
+
if (isContainingBlock(currentNode)) {
|
|
1895
|
+
return currentNode;
|
|
1896
|
+
} else if (isTopLayer(currentNode)) {
|
|
1897
|
+
return null;
|
|
1898
|
+
}
|
|
1899
|
+
currentNode = getParentNode(currentNode);
|
|
1900
|
+
}
|
|
1901
|
+
return null;
|
|
1902
|
+
}
|
|
1903
|
+
function isWebKit() {
|
|
1904
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
1905
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
1906
|
+
}
|
|
1907
|
+
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
|
1908
|
+
function isLastTraversableNode(node) {
|
|
1909
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
1910
|
+
}
|
|
1911
|
+
function getComputedStyle$1(element) {
|
|
1912
|
+
return getWindow(element).getComputedStyle(element);
|
|
1913
|
+
}
|
|
1914
|
+
function getNodeScroll(element) {
|
|
1915
|
+
if (isElement(element)) {
|
|
1916
|
+
return {
|
|
1917
|
+
scrollLeft: element.scrollLeft,
|
|
1918
|
+
scrollTop: element.scrollTop
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
return {
|
|
1922
|
+
scrollLeft: element.scrollX,
|
|
1923
|
+
scrollTop: element.scrollY
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function getParentNode(node) {
|
|
1927
|
+
if (getNodeName(node) === 'html') {
|
|
1928
|
+
return node;
|
|
1929
|
+
}
|
|
1930
|
+
const result =
|
|
1931
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1932
|
+
node.assignedSlot ||
|
|
1933
|
+
// DOM Element detected.
|
|
1934
|
+
node.parentNode ||
|
|
1935
|
+
// ShadowRoot detected.
|
|
1936
|
+
isShadowRoot(node) && node.host ||
|
|
1937
|
+
// Fallback.
|
|
1938
|
+
getDocumentElement(node);
|
|
1939
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1940
|
+
}
|
|
1941
|
+
function getNearestOverflowAncestor(node) {
|
|
1942
|
+
const parentNode = getParentNode(node);
|
|
1943
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1944
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1945
|
+
}
|
|
1946
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1947
|
+
return parentNode;
|
|
1948
|
+
}
|
|
1949
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1950
|
+
}
|
|
1951
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1952
|
+
var _node$ownerDocument2;
|
|
1953
|
+
if (list === void 0) {
|
|
1954
|
+
list = [];
|
|
1955
|
+
}
|
|
1956
|
+
if (traverseIframes === void 0) {
|
|
1957
|
+
traverseIframes = true;
|
|
1958
|
+
}
|
|
1959
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1960
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1961
|
+
const win = getWindow(scrollableAncestor);
|
|
1962
|
+
if (isBody) {
|
|
1963
|
+
const frameElement = getFrameElement(win);
|
|
1964
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1965
|
+
}
|
|
1966
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1967
|
+
}
|
|
1968
|
+
function getFrameElement(win) {
|
|
1969
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
function getCssDimensions(element) {
|
|
1973
|
+
const css = getComputedStyle$1(element);
|
|
1974
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
1975
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
1976
|
+
let width = parseFloat(css.width) || 0;
|
|
1977
|
+
let height = parseFloat(css.height) || 0;
|
|
1978
|
+
const hasOffset = isHTMLElement(element);
|
|
1979
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1980
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1981
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1982
|
+
if (shouldFallback) {
|
|
1983
|
+
width = offsetWidth;
|
|
1984
|
+
height = offsetHeight;
|
|
1985
|
+
}
|
|
1986
|
+
return {
|
|
1987
|
+
width,
|
|
1988
|
+
height,
|
|
1989
|
+
$: shouldFallback
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
function unwrapElement(element) {
|
|
1994
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
function getScale(element) {
|
|
1998
|
+
const domElement = unwrapElement(element);
|
|
1999
|
+
if (!isHTMLElement(domElement)) {
|
|
2000
|
+
return createCoords(1);
|
|
2001
|
+
}
|
|
2002
|
+
const rect = domElement.getBoundingClientRect();
|
|
2003
|
+
const {
|
|
2004
|
+
width,
|
|
2005
|
+
height,
|
|
2006
|
+
$
|
|
2007
|
+
} = getCssDimensions(domElement);
|
|
2008
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
2009
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
2010
|
+
|
|
2011
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
2012
|
+
|
|
2013
|
+
if (!x || !Number.isFinite(x)) {
|
|
2014
|
+
x = 1;
|
|
2015
|
+
}
|
|
2016
|
+
if (!y || !Number.isFinite(y)) {
|
|
2017
|
+
y = 1;
|
|
2018
|
+
}
|
|
2019
|
+
return {
|
|
2020
|
+
x,
|
|
2021
|
+
y
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
2026
|
+
function getVisualOffsets(element) {
|
|
2027
|
+
const win = getWindow(element);
|
|
2028
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
2029
|
+
return noOffsets;
|
|
2030
|
+
}
|
|
2031
|
+
return {
|
|
2032
|
+
x: win.visualViewport.offsetLeft,
|
|
2033
|
+
y: win.visualViewport.offsetTop
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
2037
|
+
if (isFixed === void 0) {
|
|
2038
|
+
isFixed = false;
|
|
2039
|
+
}
|
|
2040
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
2041
|
+
return false;
|
|
2042
|
+
}
|
|
2043
|
+
return isFixed;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
2047
|
+
if (includeScale === void 0) {
|
|
2048
|
+
includeScale = false;
|
|
2049
|
+
}
|
|
2050
|
+
if (isFixedStrategy === void 0) {
|
|
2051
|
+
isFixedStrategy = false;
|
|
2052
|
+
}
|
|
2053
|
+
const clientRect = element.getBoundingClientRect();
|
|
2054
|
+
const domElement = unwrapElement(element);
|
|
2055
|
+
let scale = createCoords(1);
|
|
2056
|
+
if (includeScale) {
|
|
2057
|
+
if (offsetParent) {
|
|
2058
|
+
if (isElement(offsetParent)) {
|
|
2059
|
+
scale = getScale(offsetParent);
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
scale = getScale(element);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
2066
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
2067
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
2068
|
+
let width = clientRect.width / scale.x;
|
|
2069
|
+
let height = clientRect.height / scale.y;
|
|
2070
|
+
if (domElement) {
|
|
2071
|
+
const win = getWindow(domElement);
|
|
2072
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
2073
|
+
let currentWin = win;
|
|
2074
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
2075
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
2076
|
+
const iframeScale = getScale(currentIFrame);
|
|
2077
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
2078
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
2079
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
2080
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
2081
|
+
x *= iframeScale.x;
|
|
2082
|
+
y *= iframeScale.y;
|
|
2083
|
+
width *= iframeScale.x;
|
|
2084
|
+
height *= iframeScale.y;
|
|
2085
|
+
x += left;
|
|
2086
|
+
y += top;
|
|
2087
|
+
currentWin = getWindow(currentIFrame);
|
|
2088
|
+
currentIFrame = getFrameElement(currentWin);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
return rectToClientRect({
|
|
2092
|
+
width,
|
|
2093
|
+
height,
|
|
2094
|
+
x,
|
|
2095
|
+
y
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2100
|
+
// incorrect for RTL.
|
|
2101
|
+
function getWindowScrollBarX(element, rect) {
|
|
2102
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
2103
|
+
if (!rect) {
|
|
2104
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
2105
|
+
}
|
|
2106
|
+
return rect.left + leftScroll;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
2110
|
+
if (ignoreScrollbarX === void 0) {
|
|
2111
|
+
ignoreScrollbarX = false;
|
|
2112
|
+
}
|
|
2113
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
2114
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
|
|
2115
|
+
// RTL <body> scrollbar.
|
|
2116
|
+
getWindowScrollBarX(documentElement, htmlRect));
|
|
2117
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
2118
|
+
return {
|
|
2119
|
+
x,
|
|
2120
|
+
y
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2125
|
+
let {
|
|
2126
|
+
elements,
|
|
2127
|
+
rect,
|
|
2128
|
+
offsetParent,
|
|
2129
|
+
strategy
|
|
2130
|
+
} = _ref;
|
|
2131
|
+
const isFixed = strategy === 'fixed';
|
|
2132
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2133
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
2134
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
2135
|
+
return rect;
|
|
2136
|
+
}
|
|
2137
|
+
let scroll = {
|
|
2138
|
+
scrollLeft: 0,
|
|
2139
|
+
scrollTop: 0
|
|
2140
|
+
};
|
|
2141
|
+
let scale = createCoords(1);
|
|
2142
|
+
const offsets = createCoords(0);
|
|
2143
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2144
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2145
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2146
|
+
scroll = getNodeScroll(offsetParent);
|
|
2147
|
+
}
|
|
2148
|
+
if (isHTMLElement(offsetParent)) {
|
|
2149
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2150
|
+
scale = getScale(offsetParent);
|
|
2151
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2152
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
2156
|
+
return {
|
|
2157
|
+
width: rect.width * scale.x,
|
|
2158
|
+
height: rect.height * scale.y,
|
|
2159
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
2160
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
2161
|
+
};
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
function getClientRects(element) {
|
|
2165
|
+
return Array.from(element.getClientRects());
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
2169
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2170
|
+
function getDocumentRect(element) {
|
|
2171
|
+
const html = getDocumentElement(element);
|
|
2172
|
+
const scroll = getNodeScroll(element);
|
|
2173
|
+
const body = element.ownerDocument.body;
|
|
2174
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2175
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2176
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2177
|
+
const y = -scroll.scrollTop;
|
|
2178
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
2179
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
2180
|
+
}
|
|
2181
|
+
return {
|
|
2182
|
+
width,
|
|
2183
|
+
height,
|
|
2184
|
+
x,
|
|
2185
|
+
y
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
function getViewportRect(element, strategy) {
|
|
2190
|
+
const win = getWindow(element);
|
|
2191
|
+
const html = getDocumentElement(element);
|
|
2192
|
+
const visualViewport = win.visualViewport;
|
|
2193
|
+
let width = html.clientWidth;
|
|
2194
|
+
let height = html.clientHeight;
|
|
2195
|
+
let x = 0;
|
|
2196
|
+
let y = 0;
|
|
2197
|
+
if (visualViewport) {
|
|
2198
|
+
width = visualViewport.width;
|
|
2199
|
+
height = visualViewport.height;
|
|
2200
|
+
const visualViewportBased = isWebKit();
|
|
2201
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
2202
|
+
x = visualViewport.offsetLeft;
|
|
2203
|
+
y = visualViewport.offsetTop;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
return {
|
|
2207
|
+
width,
|
|
2208
|
+
height,
|
|
2209
|
+
x,
|
|
2210
|
+
y
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
|
2215
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
2216
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2217
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
2218
|
+
const top = clientRect.top + element.clientTop;
|
|
2219
|
+
const left = clientRect.left + element.clientLeft;
|
|
2220
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
2221
|
+
const width = element.clientWidth * scale.x;
|
|
2222
|
+
const height = element.clientHeight * scale.y;
|
|
2223
|
+
const x = left * scale.x;
|
|
2224
|
+
const y = top * scale.y;
|
|
2225
|
+
return {
|
|
2226
|
+
width,
|
|
2227
|
+
height,
|
|
2228
|
+
x,
|
|
2229
|
+
y
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2233
|
+
let rect;
|
|
2234
|
+
if (clippingAncestor === 'viewport') {
|
|
2235
|
+
rect = getViewportRect(element, strategy);
|
|
2236
|
+
} else if (clippingAncestor === 'document') {
|
|
2237
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
2238
|
+
} else if (isElement(clippingAncestor)) {
|
|
2239
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
2240
|
+
} else {
|
|
2241
|
+
const visualOffsets = getVisualOffsets(element);
|
|
2242
|
+
rect = {
|
|
2243
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
2244
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
2245
|
+
width: clippingAncestor.width,
|
|
2246
|
+
height: clippingAncestor.height
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
return rectToClientRect(rect);
|
|
2250
|
+
}
|
|
2251
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
2252
|
+
const parentNode = getParentNode(element);
|
|
2253
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
2254
|
+
return false;
|
|
2255
|
+
}
|
|
2256
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
2260
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
2261
|
+
// of the given element up the tree.
|
|
2262
|
+
function getClippingElementAncestors(element, cache) {
|
|
2263
|
+
const cachedResult = cache.get(element);
|
|
2264
|
+
if (cachedResult) {
|
|
2265
|
+
return cachedResult;
|
|
2266
|
+
}
|
|
2267
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
2268
|
+
let currentContainingBlockComputedStyle = null;
|
|
2269
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
2270
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2271
|
+
|
|
2272
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2273
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2274
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
2275
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
2276
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
2277
|
+
currentContainingBlockComputedStyle = null;
|
|
2278
|
+
}
|
|
2279
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
2280
|
+
if (shouldDropCurrentNode) {
|
|
2281
|
+
// Drop non-containing blocks.
|
|
2282
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
2283
|
+
} else {
|
|
2284
|
+
// Record last containing block for next iteration.
|
|
2285
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
2286
|
+
}
|
|
2287
|
+
currentNode = getParentNode(currentNode);
|
|
2288
|
+
}
|
|
2289
|
+
cache.set(element, result);
|
|
2290
|
+
return result;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
2294
|
+
// clipping ancestors.
|
|
2295
|
+
function getClippingRect(_ref) {
|
|
2296
|
+
let {
|
|
2297
|
+
element,
|
|
2298
|
+
boundary,
|
|
2299
|
+
rootBoundary,
|
|
2300
|
+
strategy
|
|
2301
|
+
} = _ref;
|
|
2302
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2303
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2304
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
2305
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
2306
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
2307
|
+
accRect.top = max(rect.top, accRect.top);
|
|
2308
|
+
accRect.right = min(rect.right, accRect.right);
|
|
2309
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
2310
|
+
accRect.left = max(rect.left, accRect.left);
|
|
2311
|
+
return accRect;
|
|
2312
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
2313
|
+
return {
|
|
2314
|
+
width: clippingRect.right - clippingRect.left,
|
|
2315
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
2316
|
+
x: clippingRect.left,
|
|
2317
|
+
y: clippingRect.top
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
function getDimensions(element) {
|
|
2322
|
+
const {
|
|
2323
|
+
width,
|
|
2324
|
+
height
|
|
2325
|
+
} = getCssDimensions(element);
|
|
2326
|
+
return {
|
|
2327
|
+
width,
|
|
2328
|
+
height
|
|
2329
|
+
};
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
2333
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2334
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2335
|
+
const isFixed = strategy === 'fixed';
|
|
2336
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
2337
|
+
let scroll = {
|
|
2338
|
+
scrollLeft: 0,
|
|
2339
|
+
scrollTop: 0
|
|
2340
|
+
};
|
|
2341
|
+
const offsets = createCoords(0);
|
|
2342
|
+
|
|
2343
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
2344
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
2345
|
+
function setLeftRTLScrollbarOffset() {
|
|
2346
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
2347
|
+
}
|
|
2348
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2349
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2350
|
+
scroll = getNodeScroll(offsetParent);
|
|
2351
|
+
}
|
|
2352
|
+
if (isOffsetParentAnElement) {
|
|
2353
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
2354
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2355
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2356
|
+
} else if (documentElement) {
|
|
2357
|
+
setLeftRTLScrollbarOffset();
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
2361
|
+
setLeftRTLScrollbarOffset();
|
|
2362
|
+
}
|
|
2363
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2364
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
2365
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
2366
|
+
return {
|
|
2367
|
+
x,
|
|
2368
|
+
y,
|
|
2369
|
+
width: rect.width,
|
|
2370
|
+
height: rect.height
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
function isStaticPositioned(element) {
|
|
2375
|
+
return getComputedStyle$1(element).position === 'static';
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
2379
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
2380
|
+
return null;
|
|
2381
|
+
}
|
|
2382
|
+
if (polyfill) {
|
|
2383
|
+
return polyfill(element);
|
|
2384
|
+
}
|
|
2385
|
+
let rawOffsetParent = element.offsetParent;
|
|
2386
|
+
|
|
2387
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
2388
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
2389
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
2390
|
+
// non-static.
|
|
2391
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
2392
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
2393
|
+
}
|
|
2394
|
+
return rawOffsetParent;
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2398
|
+
// such as table ancestors and cross browser bugs.
|
|
2399
|
+
function getOffsetParent(element, polyfill) {
|
|
2400
|
+
const win = getWindow(element);
|
|
2401
|
+
if (isTopLayer(element)) {
|
|
2402
|
+
return win;
|
|
2403
|
+
}
|
|
2404
|
+
if (!isHTMLElement(element)) {
|
|
2405
|
+
let svgOffsetParent = getParentNode(element);
|
|
2406
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2407
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
2408
|
+
return svgOffsetParent;
|
|
2409
|
+
}
|
|
2410
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2411
|
+
}
|
|
2412
|
+
return win;
|
|
2413
|
+
}
|
|
2414
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2415
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
2416
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
2417
|
+
}
|
|
2418
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
2419
|
+
return win;
|
|
2420
|
+
}
|
|
2421
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
const getElementRects = async function (data) {
|
|
2425
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2426
|
+
const getDimensionsFn = this.getDimensions;
|
|
2427
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
2428
|
+
return {
|
|
2429
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
2430
|
+
floating: {
|
|
2431
|
+
x: 0,
|
|
2432
|
+
y: 0,
|
|
2433
|
+
width: floatingDimensions.width,
|
|
2434
|
+
height: floatingDimensions.height
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
};
|
|
2438
|
+
|
|
2439
|
+
function isRTL(element) {
|
|
2440
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
const platform = {
|
|
2444
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
2445
|
+
getDocumentElement,
|
|
2446
|
+
getClippingRect,
|
|
2447
|
+
getOffsetParent,
|
|
2448
|
+
getElementRects,
|
|
2449
|
+
getClientRects,
|
|
2450
|
+
getDimensions,
|
|
2451
|
+
getScale,
|
|
2452
|
+
isElement,
|
|
2453
|
+
isRTL
|
|
2454
|
+
};
|
|
2455
|
+
|
|
2456
|
+
function rectsAreEqual(a, b) {
|
|
2457
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
// https://samthor.au/2021/observing-dom/
|
|
2461
|
+
function observeMove(element, onMove) {
|
|
2462
|
+
let io = null;
|
|
2463
|
+
let timeoutId;
|
|
2464
|
+
const root = getDocumentElement(element);
|
|
2465
|
+
function cleanup() {
|
|
2466
|
+
var _io;
|
|
2467
|
+
clearTimeout(timeoutId);
|
|
2468
|
+
(_io = io) == null || _io.disconnect();
|
|
2469
|
+
io = null;
|
|
2470
|
+
}
|
|
2471
|
+
function refresh(skip, threshold) {
|
|
2472
|
+
if (skip === void 0) {
|
|
2473
|
+
skip = false;
|
|
2474
|
+
}
|
|
2475
|
+
if (threshold === void 0) {
|
|
2476
|
+
threshold = 1;
|
|
2477
|
+
}
|
|
2478
|
+
cleanup();
|
|
2479
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
2480
|
+
const {
|
|
2481
|
+
left,
|
|
2482
|
+
top,
|
|
2483
|
+
width,
|
|
2484
|
+
height
|
|
2485
|
+
} = elementRectForRootMargin;
|
|
2486
|
+
if (!skip) {
|
|
2487
|
+
onMove();
|
|
2488
|
+
}
|
|
2489
|
+
if (!width || !height) {
|
|
2490
|
+
return;
|
|
2491
|
+
}
|
|
2492
|
+
const insetTop = floor(top);
|
|
2493
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
2494
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
2495
|
+
const insetLeft = floor(left);
|
|
2496
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
2497
|
+
const options = {
|
|
2498
|
+
rootMargin,
|
|
2499
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
2500
|
+
};
|
|
2501
|
+
let isFirstUpdate = true;
|
|
2502
|
+
function handleObserve(entries) {
|
|
2503
|
+
const ratio = entries[0].intersectionRatio;
|
|
2504
|
+
if (ratio !== threshold) {
|
|
2505
|
+
if (!isFirstUpdate) {
|
|
2506
|
+
return refresh();
|
|
2507
|
+
}
|
|
2508
|
+
if (!ratio) {
|
|
2509
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
2510
|
+
// to prevent an infinite loop of updates.
|
|
2511
|
+
timeoutId = setTimeout(() => {
|
|
2512
|
+
refresh(false, 1e-7);
|
|
2513
|
+
}, 1000);
|
|
2514
|
+
} else {
|
|
2515
|
+
refresh(false, ratio);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
2519
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
2520
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
2521
|
+
// area anymore. This can happen under performance constraints. This may
|
|
2522
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
2523
|
+
// work around this, we compare the element's bounding rect now with
|
|
2524
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
2525
|
+
// are not equal then the element moved, so we refresh.
|
|
2526
|
+
refresh();
|
|
2527
|
+
}
|
|
2528
|
+
isFirstUpdate = false;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
2532
|
+
// error.
|
|
2533
|
+
try {
|
|
2534
|
+
io = new IntersectionObserver(handleObserve, {
|
|
2535
|
+
...options,
|
|
2536
|
+
// Handle <iframe>s
|
|
2537
|
+
root: root.ownerDocument
|
|
2538
|
+
});
|
|
2539
|
+
} catch (_e) {
|
|
2540
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
2541
|
+
}
|
|
2542
|
+
io.observe(element);
|
|
2543
|
+
}
|
|
2544
|
+
refresh(true);
|
|
2545
|
+
return cleanup;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
/**
|
|
2549
|
+
* Automatically updates the position of the floating element when necessary.
|
|
2550
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
2551
|
+
* visible on the screen.
|
|
2552
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
2553
|
+
* removed from the DOM or hidden from the screen.
|
|
2554
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
2555
|
+
*/
|
|
2556
|
+
function autoUpdate(reference, floating, update, options) {
|
|
2557
|
+
if (options === void 0) {
|
|
2558
|
+
options = {};
|
|
2559
|
+
}
|
|
2560
|
+
const {
|
|
2561
|
+
ancestorScroll = true,
|
|
2562
|
+
ancestorResize = true,
|
|
2563
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
2564
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
2565
|
+
animationFrame = false
|
|
2566
|
+
} = options;
|
|
2567
|
+
const referenceEl = unwrapElement(reference);
|
|
2568
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
2569
|
+
ancestors.forEach(ancestor => {
|
|
2570
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
2571
|
+
passive: true
|
|
2572
|
+
});
|
|
2573
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
2574
|
+
});
|
|
2575
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
2576
|
+
let reobserveFrame = -1;
|
|
2577
|
+
let resizeObserver = null;
|
|
2578
|
+
if (elementResize) {
|
|
2579
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
2580
|
+
let [firstEntry] = _ref;
|
|
2581
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
2582
|
+
// Prevent update loops when using the `size` middleware.
|
|
2583
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
2584
|
+
resizeObserver.unobserve(floating);
|
|
2585
|
+
cancelAnimationFrame(reobserveFrame);
|
|
2586
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
2587
|
+
var _resizeObserver;
|
|
2588
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
update();
|
|
2592
|
+
});
|
|
2593
|
+
if (referenceEl && !animationFrame) {
|
|
2594
|
+
resizeObserver.observe(referenceEl);
|
|
2595
|
+
}
|
|
2596
|
+
resizeObserver.observe(floating);
|
|
2597
|
+
}
|
|
2598
|
+
let frameId;
|
|
2599
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
2600
|
+
if (animationFrame) {
|
|
2601
|
+
frameLoop();
|
|
2602
|
+
}
|
|
2603
|
+
function frameLoop() {
|
|
2604
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
2605
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
2606
|
+
update();
|
|
2607
|
+
}
|
|
2608
|
+
prevRefRect = nextRefRect;
|
|
2609
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
2610
|
+
}
|
|
2611
|
+
update();
|
|
2612
|
+
return () => {
|
|
2613
|
+
var _resizeObserver2;
|
|
2614
|
+
ancestors.forEach(ancestor => {
|
|
2615
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
2616
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
2617
|
+
});
|
|
2618
|
+
cleanupIo == null || cleanupIo();
|
|
2619
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
2620
|
+
resizeObserver = null;
|
|
2621
|
+
if (animationFrame) {
|
|
2622
|
+
cancelAnimationFrame(frameId);
|
|
2623
|
+
}
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* Modifies the placement by translating the floating element along the
|
|
2629
|
+
* specified axes.
|
|
2630
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
2631
|
+
* object may be passed.
|
|
2632
|
+
* @see https://floating-ui.com/docs/offset
|
|
2633
|
+
*/
|
|
2634
|
+
const offset = offset$1;
|
|
2635
|
+
|
|
2636
|
+
/**
|
|
2637
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
2638
|
+
* that has the most space available automatically, without needing to specify a
|
|
2639
|
+
* preferred placement. Alternative to `flip`.
|
|
2640
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
2641
|
+
*/
|
|
2642
|
+
autoPlacement;
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
2646
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
2647
|
+
* @see https://floating-ui.com/docs/shift
|
|
2648
|
+
*/
|
|
2649
|
+
const shift = shift$1;
|
|
2650
|
+
|
|
2651
|
+
/**
|
|
2652
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2653
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2654
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2655
|
+
* @see https://floating-ui.com/docs/flip
|
|
2656
|
+
*/
|
|
2657
|
+
const flip = flip$1;
|
|
2658
|
+
|
|
2659
|
+
/**
|
|
2660
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2661
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2662
|
+
* width of the reference element.
|
|
2663
|
+
* @see https://floating-ui.com/docs/size
|
|
2664
|
+
*/
|
|
2665
|
+
const size = size$1;
|
|
2666
|
+
|
|
2667
|
+
/**
|
|
2668
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
2669
|
+
* when it is not in the same clipping context as the reference element.
|
|
2670
|
+
* @see https://floating-ui.com/docs/hide
|
|
2671
|
+
*/
|
|
2672
|
+
hide;
|
|
2673
|
+
|
|
2674
|
+
/**
|
|
2675
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2676
|
+
* appears centered to the reference element.
|
|
2677
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2678
|
+
*/
|
|
2679
|
+
const arrow = arrow$1;
|
|
2680
|
+
|
|
2681
|
+
/**
|
|
2682
|
+
* Provides improved positioning for inline reference elements that can span
|
|
2683
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
2684
|
+
* @see https://floating-ui.com/docs/inline
|
|
2685
|
+
*/
|
|
2686
|
+
inline;
|
|
2687
|
+
|
|
2688
|
+
/**
|
|
2689
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
2690
|
+
*/
|
|
2691
|
+
limitShift;
|
|
2692
|
+
|
|
2693
|
+
/**
|
|
2694
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2695
|
+
* next to a given reference element.
|
|
2696
|
+
*/
|
|
2697
|
+
const computePosition = (reference, floating, options) => {
|
|
2698
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
2699
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
2700
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
2701
|
+
const cache = new Map();
|
|
2702
|
+
const mergedOptions = {
|
|
2703
|
+
platform,
|
|
2704
|
+
...options
|
|
2705
|
+
};
|
|
2706
|
+
const platformWithCache = {
|
|
2707
|
+
...mergedOptions.platform,
|
|
2708
|
+
_c: cache
|
|
2709
|
+
};
|
|
2710
|
+
return computePosition$1(reference, floating, {
|
|
2711
|
+
...mergedOptions,
|
|
2712
|
+
platform: platformWithCache
|
|
2713
|
+
});
|
|
2714
|
+
};
|
|
2715
|
+
|
|
2716
|
+
/**
|
|
2717
|
+
* @license
|
|
2718
|
+
* Copyright 2017 Google LLC
|
|
2719
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2720
|
+
*/
|
|
2721
|
+
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$3=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
2722
|
+
|
|
2723
|
+
/**
|
|
2724
|
+
* @license
|
|
2725
|
+
* Copyright 2018 Google LLC
|
|
2726
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2727
|
+
*/const e$2=e$3(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
|
|
2728
|
+
|
|
2729
|
+
function offsetParent(element) {
|
|
2730
|
+
return offsetParentPolyfill(element);
|
|
2731
|
+
}
|
|
2732
|
+
function flatTreeParent(element) {
|
|
2733
|
+
if (element.assignedSlot) {
|
|
2734
|
+
return element.assignedSlot;
|
|
2735
|
+
}
|
|
2736
|
+
if (element.parentNode instanceof ShadowRoot) {
|
|
2737
|
+
return element.parentNode.host;
|
|
2738
|
+
}
|
|
2739
|
+
return element.parentNode;
|
|
2740
|
+
}
|
|
2741
|
+
function offsetParentPolyfill(element) {
|
|
2742
|
+
// Do an initial walk to check for display:none ancestors.
|
|
2743
|
+
for (let ancestor = element; ancestor; ancestor = flatTreeParent(ancestor)) {
|
|
2744
|
+
if (!(ancestor instanceof Element)) {
|
|
2745
|
+
continue;
|
|
2746
|
+
}
|
|
2747
|
+
if (getComputedStyle(ancestor).display === 'none') {
|
|
2748
|
+
return null;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
for (let ancestor = flatTreeParent(element); ancestor; ancestor = flatTreeParent(ancestor)) {
|
|
2752
|
+
if (!(ancestor instanceof Element)) {
|
|
2753
|
+
continue;
|
|
2754
|
+
}
|
|
2755
|
+
const style = getComputedStyle(ancestor);
|
|
2756
|
+
// Display:contents nodes aren't in the layout tree, so they should be skipped.
|
|
2757
|
+
if (style.display === 'contents') {
|
|
2758
|
+
continue;
|
|
2759
|
+
}
|
|
2760
|
+
if (style.position !== 'static' || isContainingBlock(style)) {
|
|
2761
|
+
return ancestor;
|
|
2762
|
+
}
|
|
2763
|
+
if (ancestor.tagName === 'BODY') {
|
|
2764
|
+
return ancestor;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
return null;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
function isVirtualElement(e) {
|
|
2771
|
+
return e !== null && typeof e === "object" && "getBoundingClientRect" in e && ("contextElement" in e ? e.contextElement instanceof Element : true);
|
|
2772
|
+
}
|
|
2773
|
+
var SlPopup = class extends ShoelaceElement {
|
|
2774
|
+
constructor() {
|
|
2775
|
+
super(...arguments);
|
|
2776
|
+
this.localize = new LocalizeController(this);
|
|
2777
|
+
this.active = false;
|
|
2778
|
+
this.placement = "top";
|
|
2779
|
+
this.strategy = "absolute";
|
|
2780
|
+
this.distance = 0;
|
|
2781
|
+
this.skidding = 0;
|
|
2782
|
+
this.arrow = false;
|
|
2783
|
+
this.arrowPlacement = "anchor";
|
|
2784
|
+
this.arrowPadding = 10;
|
|
2785
|
+
this.flip = false;
|
|
2786
|
+
this.flipFallbackPlacements = "";
|
|
2787
|
+
this.flipFallbackStrategy = "best-fit";
|
|
2788
|
+
this.flipPadding = 0;
|
|
2789
|
+
this.shift = false;
|
|
2790
|
+
this.shiftPadding = 0;
|
|
2791
|
+
this.autoSizePadding = 0;
|
|
2792
|
+
this.hoverBridge = false;
|
|
2793
|
+
this.updateHoverBridge = () => {
|
|
2794
|
+
if (this.hoverBridge && this.anchorEl) {
|
|
2795
|
+
const anchorRect = this.anchorEl.getBoundingClientRect();
|
|
2796
|
+
const popupRect = this.popup.getBoundingClientRect();
|
|
2797
|
+
const isVertical = this.placement.includes("top") || this.placement.includes("bottom");
|
|
2798
|
+
let topLeftX = 0;
|
|
2799
|
+
let topLeftY = 0;
|
|
2800
|
+
let topRightX = 0;
|
|
2801
|
+
let topRightY = 0;
|
|
2802
|
+
let bottomLeftX = 0;
|
|
2803
|
+
let bottomLeftY = 0;
|
|
2804
|
+
let bottomRightX = 0;
|
|
2805
|
+
let bottomRightY = 0;
|
|
2806
|
+
if (isVertical) {
|
|
2807
|
+
if (anchorRect.top < popupRect.top) {
|
|
2808
|
+
topLeftX = anchorRect.left;
|
|
2809
|
+
topLeftY = anchorRect.bottom;
|
|
2810
|
+
topRightX = anchorRect.right;
|
|
2811
|
+
topRightY = anchorRect.bottom;
|
|
2812
|
+
bottomLeftX = popupRect.left;
|
|
2813
|
+
bottomLeftY = popupRect.top;
|
|
2814
|
+
bottomRightX = popupRect.right;
|
|
2815
|
+
bottomRightY = popupRect.top;
|
|
2816
|
+
} else {
|
|
2817
|
+
topLeftX = popupRect.left;
|
|
2818
|
+
topLeftY = popupRect.bottom;
|
|
2819
|
+
topRightX = popupRect.right;
|
|
2820
|
+
topRightY = popupRect.bottom;
|
|
2821
|
+
bottomLeftX = anchorRect.left;
|
|
2822
|
+
bottomLeftY = anchorRect.top;
|
|
2823
|
+
bottomRightX = anchorRect.right;
|
|
2824
|
+
bottomRightY = anchorRect.top;
|
|
2825
|
+
}
|
|
2826
|
+
} else {
|
|
2827
|
+
if (anchorRect.left < popupRect.left) {
|
|
2828
|
+
topLeftX = anchorRect.right;
|
|
2829
|
+
topLeftY = anchorRect.top;
|
|
2830
|
+
topRightX = popupRect.left;
|
|
2831
|
+
topRightY = popupRect.top;
|
|
2832
|
+
bottomLeftX = anchorRect.right;
|
|
2833
|
+
bottomLeftY = anchorRect.bottom;
|
|
2834
|
+
bottomRightX = popupRect.left;
|
|
2835
|
+
bottomRightY = popupRect.bottom;
|
|
2836
|
+
} else {
|
|
2837
|
+
topLeftX = popupRect.right;
|
|
2838
|
+
topLeftY = popupRect.top;
|
|
2839
|
+
topRightX = anchorRect.left;
|
|
2840
|
+
topRightY = anchorRect.top;
|
|
2841
|
+
bottomLeftX = popupRect.right;
|
|
2842
|
+
bottomLeftY = popupRect.bottom;
|
|
2843
|
+
bottomRightX = anchorRect.left;
|
|
2844
|
+
bottomRightY = anchorRect.bottom;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
this.style.setProperty("--hover-bridge-top-left-x", `${topLeftX}px`);
|
|
2848
|
+
this.style.setProperty("--hover-bridge-top-left-y", `${topLeftY}px`);
|
|
2849
|
+
this.style.setProperty("--hover-bridge-top-right-x", `${topRightX}px`);
|
|
2850
|
+
this.style.setProperty("--hover-bridge-top-right-y", `${topRightY}px`);
|
|
2851
|
+
this.style.setProperty("--hover-bridge-bottom-left-x", `${bottomLeftX}px`);
|
|
2852
|
+
this.style.setProperty("--hover-bridge-bottom-left-y", `${bottomLeftY}px`);
|
|
2853
|
+
this.style.setProperty("--hover-bridge-bottom-right-x", `${bottomRightX}px`);
|
|
2854
|
+
this.style.setProperty("--hover-bridge-bottom-right-y", `${bottomRightY}px`);
|
|
2855
|
+
}
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
async connectedCallback() {
|
|
2859
|
+
super.connectedCallback();
|
|
2860
|
+
await this.updateComplete;
|
|
2861
|
+
this.start();
|
|
2862
|
+
}
|
|
2863
|
+
disconnectedCallback() {
|
|
2864
|
+
super.disconnectedCallback();
|
|
2865
|
+
this.stop();
|
|
2866
|
+
}
|
|
2867
|
+
async updated(changedProps) {
|
|
2868
|
+
super.updated(changedProps);
|
|
2869
|
+
if (changedProps.has("active")) {
|
|
2870
|
+
if (this.active) {
|
|
2871
|
+
this.start();
|
|
2872
|
+
} else {
|
|
2873
|
+
this.stop();
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
if (changedProps.has("anchor")) {
|
|
2877
|
+
this.handleAnchorChange();
|
|
2878
|
+
}
|
|
2879
|
+
if (this.active) {
|
|
2880
|
+
await this.updateComplete;
|
|
2881
|
+
this.reposition();
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
async handleAnchorChange() {
|
|
2885
|
+
await this.stop();
|
|
2886
|
+
if (this.anchor && typeof this.anchor === "string") {
|
|
2887
|
+
const root = this.getRootNode();
|
|
2888
|
+
this.anchorEl = root.getElementById(this.anchor);
|
|
2889
|
+
} else if (this.anchor instanceof Element || isVirtualElement(this.anchor)) {
|
|
2890
|
+
this.anchorEl = this.anchor;
|
|
2891
|
+
} else {
|
|
2892
|
+
this.anchorEl = this.querySelector('[slot="anchor"]');
|
|
2893
|
+
}
|
|
2894
|
+
if (this.anchorEl instanceof HTMLSlotElement) {
|
|
2895
|
+
this.anchorEl = this.anchorEl.assignedElements({ flatten: true })[0];
|
|
2896
|
+
}
|
|
2897
|
+
if (this.anchorEl && this.active) {
|
|
2898
|
+
this.start();
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
start() {
|
|
2902
|
+
if (!this.anchorEl || !this.active) {
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
this.cleanup = autoUpdate(this.anchorEl, this.popup, () => {
|
|
2906
|
+
this.reposition();
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
async stop() {
|
|
2910
|
+
return new Promise((resolve) => {
|
|
2911
|
+
if (this.cleanup) {
|
|
2912
|
+
this.cleanup();
|
|
2913
|
+
this.cleanup = void 0;
|
|
2914
|
+
this.removeAttribute("data-current-placement");
|
|
2915
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
2916
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
2917
|
+
requestAnimationFrame(() => resolve());
|
|
2918
|
+
} else {
|
|
2919
|
+
resolve();
|
|
2920
|
+
}
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
/** Forces the popup to recalculate and reposition itself. */
|
|
2924
|
+
reposition() {
|
|
2925
|
+
if (!this.active || !this.anchorEl) {
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
const middleware = [
|
|
2929
|
+
// The offset middleware goes first
|
|
2930
|
+
offset({ mainAxis: this.distance, crossAxis: this.skidding })
|
|
2931
|
+
];
|
|
2932
|
+
if (this.sync) {
|
|
2933
|
+
middleware.push(
|
|
2934
|
+
size({
|
|
2935
|
+
apply: ({ rects }) => {
|
|
2936
|
+
const syncWidth = this.sync === "width" || this.sync === "both";
|
|
2937
|
+
const syncHeight = this.sync === "height" || this.sync === "both";
|
|
2938
|
+
this.popup.style.width = syncWidth ? `${rects.reference.width}px` : "";
|
|
2939
|
+
this.popup.style.height = syncHeight ? `${rects.reference.height}px` : "";
|
|
2940
|
+
}
|
|
2941
|
+
})
|
|
2942
|
+
);
|
|
2943
|
+
} else {
|
|
2944
|
+
this.popup.style.width = "";
|
|
2945
|
+
this.popup.style.height = "";
|
|
2946
|
+
}
|
|
2947
|
+
if (this.flip) {
|
|
2948
|
+
middleware.push(
|
|
2949
|
+
flip({
|
|
2950
|
+
boundary: this.flipBoundary,
|
|
2951
|
+
// @ts-expect-error - We're converting a string attribute to an array here
|
|
2952
|
+
fallbackPlacements: this.flipFallbackPlacements,
|
|
2953
|
+
fallbackStrategy: this.flipFallbackStrategy === "best-fit" ? "bestFit" : "initialPlacement",
|
|
2954
|
+
padding: this.flipPadding
|
|
2955
|
+
})
|
|
2956
|
+
);
|
|
2957
|
+
}
|
|
2958
|
+
if (this.shift) {
|
|
2959
|
+
middleware.push(
|
|
2960
|
+
shift({
|
|
2961
|
+
boundary: this.shiftBoundary,
|
|
2962
|
+
padding: this.shiftPadding
|
|
2963
|
+
})
|
|
2964
|
+
);
|
|
2965
|
+
}
|
|
2966
|
+
if (this.autoSize) {
|
|
2967
|
+
middleware.push(
|
|
2968
|
+
size({
|
|
2969
|
+
boundary: this.autoSizeBoundary,
|
|
2970
|
+
padding: this.autoSizePadding,
|
|
2971
|
+
apply: ({ availableWidth, availableHeight }) => {
|
|
2972
|
+
if (this.autoSize === "vertical" || this.autoSize === "both") {
|
|
2973
|
+
this.style.setProperty("--auto-size-available-height", `${availableHeight}px`);
|
|
2974
|
+
} else {
|
|
2975
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
2976
|
+
}
|
|
2977
|
+
if (this.autoSize === "horizontal" || this.autoSize === "both") {
|
|
2978
|
+
this.style.setProperty("--auto-size-available-width", `${availableWidth}px`);
|
|
2979
|
+
} else {
|
|
2980
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
})
|
|
2984
|
+
);
|
|
2985
|
+
} else {
|
|
2986
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
2987
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
2988
|
+
}
|
|
2989
|
+
if (this.arrow) {
|
|
2990
|
+
middleware.push(
|
|
2991
|
+
arrow({
|
|
2992
|
+
element: this.arrowEl,
|
|
2993
|
+
padding: this.arrowPadding
|
|
2994
|
+
})
|
|
2995
|
+
);
|
|
2996
|
+
}
|
|
2997
|
+
const getOffsetParent = this.strategy === "absolute" ? (element) => platform.getOffsetParent(element, offsetParent) : platform.getOffsetParent;
|
|
2998
|
+
computePosition(this.anchorEl, this.popup, {
|
|
2999
|
+
placement: this.placement,
|
|
3000
|
+
middleware,
|
|
3001
|
+
strategy: this.strategy,
|
|
3002
|
+
platform: __spreadProps(__spreadValues({}, platform), {
|
|
3003
|
+
getOffsetParent
|
|
3004
|
+
})
|
|
3005
|
+
}).then(({ x, y, middlewareData, placement }) => {
|
|
3006
|
+
const isRtl = this.localize.dir() === "rtl";
|
|
3007
|
+
const staticSide = { top: "bottom", right: "left", bottom: "top", left: "right" }[placement.split("-")[0]];
|
|
3008
|
+
this.setAttribute("data-current-placement", placement);
|
|
3009
|
+
Object.assign(this.popup.style, {
|
|
3010
|
+
left: `${x}px`,
|
|
3011
|
+
top: `${y}px`
|
|
3012
|
+
});
|
|
3013
|
+
if (this.arrow) {
|
|
3014
|
+
const arrowX = middlewareData.arrow.x;
|
|
3015
|
+
const arrowY = middlewareData.arrow.y;
|
|
3016
|
+
let top = "";
|
|
3017
|
+
let right = "";
|
|
3018
|
+
let bottom = "";
|
|
3019
|
+
let left = "";
|
|
3020
|
+
if (this.arrowPlacement === "start") {
|
|
3021
|
+
const value = typeof arrowX === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
3022
|
+
top = typeof arrowY === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
3023
|
+
right = isRtl ? value : "";
|
|
3024
|
+
left = isRtl ? "" : value;
|
|
3025
|
+
} else if (this.arrowPlacement === "end") {
|
|
3026
|
+
const value = typeof arrowX === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
3027
|
+
right = isRtl ? "" : value;
|
|
3028
|
+
left = isRtl ? value : "";
|
|
3029
|
+
bottom = typeof arrowY === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
3030
|
+
} else if (this.arrowPlacement === "center") {
|
|
3031
|
+
left = typeof arrowX === "number" ? `calc(50% - var(--arrow-size-diagonal))` : "";
|
|
3032
|
+
top = typeof arrowY === "number" ? `calc(50% - var(--arrow-size-diagonal))` : "";
|
|
3033
|
+
} else {
|
|
3034
|
+
left = typeof arrowX === "number" ? `${arrowX}px` : "";
|
|
3035
|
+
top = typeof arrowY === "number" ? `${arrowY}px` : "";
|
|
3036
|
+
}
|
|
3037
|
+
Object.assign(this.arrowEl.style, {
|
|
3038
|
+
top,
|
|
3039
|
+
right,
|
|
3040
|
+
bottom,
|
|
3041
|
+
left,
|
|
3042
|
+
[staticSide]: "calc(var(--arrow-size-diagonal) * -1)"
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
});
|
|
3046
|
+
requestAnimationFrame(() => this.updateHoverBridge());
|
|
3047
|
+
this.emit("sl-reposition");
|
|
3048
|
+
}
|
|
3049
|
+
render() {
|
|
3050
|
+
return x`
|
|
3051
|
+
<slot name="anchor" @slotchange=${this.handleAnchorChange}></slot>
|
|
3052
|
+
|
|
3053
|
+
<span
|
|
3054
|
+
part="hover-bridge"
|
|
3055
|
+
class=${e$2({
|
|
3056
|
+
"popup-hover-bridge": true,
|
|
3057
|
+
"popup-hover-bridge--visible": this.hoverBridge && this.active
|
|
3058
|
+
})}
|
|
3059
|
+
></span>
|
|
3060
|
+
|
|
3061
|
+
<div
|
|
3062
|
+
part="popup"
|
|
3063
|
+
class=${e$2({
|
|
3064
|
+
popup: true,
|
|
3065
|
+
"popup--active": this.active,
|
|
3066
|
+
"popup--fixed": this.strategy === "fixed",
|
|
3067
|
+
"popup--has-arrow": this.arrow
|
|
3068
|
+
})}
|
|
3069
|
+
>
|
|
3070
|
+
<slot></slot>
|
|
3071
|
+
${this.arrow ? x`<div part="arrow" class="popup__arrow" role="presentation"></div>` : ""}
|
|
3072
|
+
</div>
|
|
3073
|
+
`;
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
SlPopup.styles = [component_styles_default, popup_styles_default];
|
|
3077
|
+
__decorateClass([
|
|
3078
|
+
e$4(".popup")
|
|
3079
|
+
], SlPopup.prototype, "popup", 2);
|
|
3080
|
+
__decorateClass([
|
|
3081
|
+
e$4(".popup__arrow")
|
|
3082
|
+
], SlPopup.prototype, "arrowEl", 2);
|
|
3083
|
+
__decorateClass([
|
|
3084
|
+
n$2()
|
|
3085
|
+
], SlPopup.prototype, "anchor", 2);
|
|
3086
|
+
__decorateClass([
|
|
3087
|
+
n$2({ type: Boolean, reflect: true })
|
|
3088
|
+
], SlPopup.prototype, "active", 2);
|
|
3089
|
+
__decorateClass([
|
|
3090
|
+
n$2({ reflect: true })
|
|
3091
|
+
], SlPopup.prototype, "placement", 2);
|
|
3092
|
+
__decorateClass([
|
|
3093
|
+
n$2({ reflect: true })
|
|
3094
|
+
], SlPopup.prototype, "strategy", 2);
|
|
3095
|
+
__decorateClass([
|
|
3096
|
+
n$2({ type: Number })
|
|
3097
|
+
], SlPopup.prototype, "distance", 2);
|
|
3098
|
+
__decorateClass([
|
|
3099
|
+
n$2({ type: Number })
|
|
3100
|
+
], SlPopup.prototype, "skidding", 2);
|
|
3101
|
+
__decorateClass([
|
|
3102
|
+
n$2({ type: Boolean })
|
|
3103
|
+
], SlPopup.prototype, "arrow", 2);
|
|
3104
|
+
__decorateClass([
|
|
3105
|
+
n$2({ attribute: "arrow-placement" })
|
|
3106
|
+
], SlPopup.prototype, "arrowPlacement", 2);
|
|
3107
|
+
__decorateClass([
|
|
3108
|
+
n$2({ attribute: "arrow-padding", type: Number })
|
|
3109
|
+
], SlPopup.prototype, "arrowPadding", 2);
|
|
3110
|
+
__decorateClass([
|
|
3111
|
+
n$2({ type: Boolean })
|
|
3112
|
+
], SlPopup.prototype, "flip", 2);
|
|
3113
|
+
__decorateClass([
|
|
3114
|
+
n$2({
|
|
3115
|
+
attribute: "flip-fallback-placements",
|
|
3116
|
+
converter: {
|
|
3117
|
+
fromAttribute: (value) => {
|
|
3118
|
+
return value.split(" ").map((p) => p.trim()).filter((p) => p !== "");
|
|
3119
|
+
},
|
|
3120
|
+
toAttribute: (value) => {
|
|
3121
|
+
return value.join(" ");
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
})
|
|
3125
|
+
], SlPopup.prototype, "flipFallbackPlacements", 2);
|
|
3126
|
+
__decorateClass([
|
|
3127
|
+
n$2({ attribute: "flip-fallback-strategy" })
|
|
3128
|
+
], SlPopup.prototype, "flipFallbackStrategy", 2);
|
|
3129
|
+
__decorateClass([
|
|
3130
|
+
n$2({ type: Object })
|
|
3131
|
+
], SlPopup.prototype, "flipBoundary", 2);
|
|
3132
|
+
__decorateClass([
|
|
3133
|
+
n$2({ attribute: "flip-padding", type: Number })
|
|
3134
|
+
], SlPopup.prototype, "flipPadding", 2);
|
|
3135
|
+
__decorateClass([
|
|
3136
|
+
n$2({ type: Boolean })
|
|
3137
|
+
], SlPopup.prototype, "shift", 2);
|
|
3138
|
+
__decorateClass([
|
|
3139
|
+
n$2({ type: Object })
|
|
3140
|
+
], SlPopup.prototype, "shiftBoundary", 2);
|
|
3141
|
+
__decorateClass([
|
|
3142
|
+
n$2({ attribute: "shift-padding", type: Number })
|
|
3143
|
+
], SlPopup.prototype, "shiftPadding", 2);
|
|
3144
|
+
__decorateClass([
|
|
3145
|
+
n$2({ attribute: "auto-size" })
|
|
3146
|
+
], SlPopup.prototype, "autoSize", 2);
|
|
3147
|
+
__decorateClass([
|
|
3148
|
+
n$2()
|
|
3149
|
+
], SlPopup.prototype, "sync", 2);
|
|
3150
|
+
__decorateClass([
|
|
3151
|
+
n$2({ type: Object })
|
|
3152
|
+
], SlPopup.prototype, "autoSizeBoundary", 2);
|
|
3153
|
+
__decorateClass([
|
|
3154
|
+
n$2({ attribute: "auto-size-padding", type: Number })
|
|
3155
|
+
], SlPopup.prototype, "autoSizePadding", 2);
|
|
3156
|
+
__decorateClass([
|
|
3157
|
+
n$2({ attribute: "hover-bridge", type: Boolean })
|
|
3158
|
+
], SlPopup.prototype, "hoverBridge", 2);
|
|
3159
|
+
|
|
3160
|
+
// src/utilities/animation-registry.ts
|
|
3161
|
+
var defaultAnimationRegistry = /* @__PURE__ */ new Map();
|
|
3162
|
+
var customAnimationRegistry = /* @__PURE__ */ new WeakMap();
|
|
3163
|
+
function ensureAnimation(animation) {
|
|
3164
|
+
return animation != null ? animation : { keyframes: [], options: { duration: 0 } };
|
|
3165
|
+
}
|
|
3166
|
+
function getLogicalAnimation(animation, dir) {
|
|
3167
|
+
if (dir.toLowerCase() === "rtl") {
|
|
3168
|
+
return {
|
|
3169
|
+
keyframes: animation.rtlKeyframes || animation.keyframes,
|
|
3170
|
+
options: animation.options
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
return animation;
|
|
3174
|
+
}
|
|
3175
|
+
function setDefaultAnimation(animationName, animation) {
|
|
3176
|
+
defaultAnimationRegistry.set(animationName, ensureAnimation(animation));
|
|
3177
|
+
}
|
|
3178
|
+
function getAnimation(el, animationName, options) {
|
|
3179
|
+
const customAnimation = customAnimationRegistry.get(el);
|
|
3180
|
+
if (customAnimation == null ? void 0 : customAnimation[animationName]) {
|
|
3181
|
+
return getLogicalAnimation(customAnimation[animationName], options.dir);
|
|
3182
|
+
}
|
|
3183
|
+
const defaultAnimation = defaultAnimationRegistry.get(animationName);
|
|
3184
|
+
if (defaultAnimation) {
|
|
3185
|
+
return getLogicalAnimation(defaultAnimation, options.dir);
|
|
3186
|
+
}
|
|
3187
|
+
return {
|
|
3188
|
+
keyframes: [],
|
|
3189
|
+
options: { duration: 0 }
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
// src/internal/event.ts
|
|
3194
|
+
function waitForEvent(el, eventName) {
|
|
3195
|
+
return new Promise((resolve) => {
|
|
3196
|
+
function done(event) {
|
|
3197
|
+
if (event.target === el) {
|
|
3198
|
+
el.removeEventListener(eventName, done);
|
|
3199
|
+
resolve();
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
el.addEventListener(eventName, done);
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
// src/internal/animate.ts
|
|
3207
|
+
function animateTo(el, keyframes, options) {
|
|
3208
|
+
return new Promise((resolve) => {
|
|
3209
|
+
if ((options == null ? void 0 : options.duration) === Infinity) {
|
|
3210
|
+
throw new Error("Promise-based animations must be finite.");
|
|
3211
|
+
}
|
|
3212
|
+
const animation = el.animate(keyframes, __spreadProps(__spreadValues({}, options), {
|
|
3213
|
+
duration: prefersReducedMotion() ? 0 : options.duration
|
|
3214
|
+
}));
|
|
3215
|
+
animation.addEventListener("cancel", resolve, { once: true });
|
|
3216
|
+
animation.addEventListener("finish", resolve, { once: true });
|
|
3217
|
+
});
|
|
3218
|
+
}
|
|
3219
|
+
function prefersReducedMotion() {
|
|
3220
|
+
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
3221
|
+
return query.matches;
|
|
3222
|
+
}
|
|
3223
|
+
function stopAnimations(el) {
|
|
3224
|
+
return Promise.all(
|
|
3225
|
+
el.getAnimations().map((animation) => {
|
|
3226
|
+
return new Promise((resolve) => {
|
|
3227
|
+
animation.cancel();
|
|
3228
|
+
requestAnimationFrame(resolve);
|
|
3229
|
+
});
|
|
3230
|
+
})
|
|
3231
|
+
);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
// src/internal/watch.ts
|
|
3235
|
+
function watch(propertyName, options) {
|
|
3236
|
+
const resolvedOptions = __spreadValues({
|
|
3237
|
+
waitUntilFirstUpdate: false
|
|
3238
|
+
}, options);
|
|
3239
|
+
return (proto, decoratedFnName) => {
|
|
3240
|
+
const { update } = proto;
|
|
3241
|
+
const watchedProperties = Array.isArray(propertyName) ? propertyName : [propertyName];
|
|
3242
|
+
proto.update = function(changedProps) {
|
|
3243
|
+
watchedProperties.forEach((property) => {
|
|
3244
|
+
const key = property;
|
|
3245
|
+
if (changedProps.has(key)) {
|
|
3246
|
+
const oldValue = changedProps.get(key);
|
|
3247
|
+
const newValue = this[key];
|
|
3248
|
+
if (oldValue !== newValue) {
|
|
3249
|
+
if (!resolvedOptions.waitUntilFirstUpdate || this.hasUpdated) {
|
|
3250
|
+
this[decoratedFnName](oldValue, newValue);
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
});
|
|
3255
|
+
update.call(this, changedProps);
|
|
3256
|
+
};
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* @license
|
|
3262
|
+
* Copyright 2018 Google LLC
|
|
3263
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3264
|
+
*/const o$2=o=>o??E;
|
|
3265
|
+
|
|
3266
|
+
var SlDropdown = class extends ShoelaceElement {
|
|
3267
|
+
constructor() {
|
|
3268
|
+
super(...arguments);
|
|
3269
|
+
this.localize = new LocalizeController(this);
|
|
3270
|
+
this.open = false;
|
|
3271
|
+
this.placement = "bottom-start";
|
|
3272
|
+
this.disabled = false;
|
|
3273
|
+
this.stayOpenOnSelect = false;
|
|
3274
|
+
this.distance = 0;
|
|
3275
|
+
this.skidding = 0;
|
|
3276
|
+
this.hoist = false;
|
|
3277
|
+
this.sync = void 0;
|
|
3278
|
+
this.handleKeyDown = (event) => {
|
|
3279
|
+
if (this.open && event.key === "Escape") {
|
|
3280
|
+
event.stopPropagation();
|
|
3281
|
+
this.hide();
|
|
3282
|
+
this.focusOnTrigger();
|
|
3283
|
+
}
|
|
3284
|
+
};
|
|
3285
|
+
this.handleDocumentKeyDown = (event) => {
|
|
3286
|
+
var _a;
|
|
3287
|
+
if (event.key === "Escape" && this.open && !this.closeWatcher) {
|
|
3288
|
+
event.stopPropagation();
|
|
3289
|
+
this.focusOnTrigger();
|
|
3290
|
+
this.hide();
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
if (event.key === "Tab") {
|
|
3294
|
+
if (this.open && ((_a = document.activeElement) == null ? void 0 : _a.tagName.toLowerCase()) === "sl-menu-item") {
|
|
3295
|
+
event.preventDefault();
|
|
3296
|
+
this.hide();
|
|
3297
|
+
this.focusOnTrigger();
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
const computeClosestContaining = (element, tagName) => {
|
|
3301
|
+
if (!element) return null;
|
|
3302
|
+
const closest = element.closest(tagName);
|
|
3303
|
+
if (closest) return closest;
|
|
3304
|
+
const rootNode = element.getRootNode();
|
|
3305
|
+
if (rootNode instanceof ShadowRoot) {
|
|
3306
|
+
return computeClosestContaining(rootNode.host, tagName);
|
|
3307
|
+
}
|
|
3308
|
+
return null;
|
|
3309
|
+
};
|
|
3310
|
+
setTimeout(() => {
|
|
3311
|
+
var _a2;
|
|
3312
|
+
const activeElement = ((_a2 = this.containingElement) == null ? void 0 : _a2.getRootNode()) instanceof ShadowRoot ? getDeepestActiveElement() : document.activeElement;
|
|
3313
|
+
if (!this.containingElement || computeClosestContaining(activeElement, this.containingElement.tagName.toLowerCase()) !== this.containingElement) {
|
|
3314
|
+
this.hide();
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
this.handleDocumentMouseDown = (event) => {
|
|
3320
|
+
const path = event.composedPath();
|
|
3321
|
+
if (this.containingElement && !path.includes(this.containingElement)) {
|
|
3322
|
+
this.hide();
|
|
3323
|
+
}
|
|
3324
|
+
};
|
|
3325
|
+
this.handlePanelSelect = (event) => {
|
|
3326
|
+
const target = event.target;
|
|
3327
|
+
if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === "sl-menu") {
|
|
3328
|
+
this.hide();
|
|
3329
|
+
this.focusOnTrigger();
|
|
3330
|
+
}
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
connectedCallback() {
|
|
3334
|
+
super.connectedCallback();
|
|
3335
|
+
if (!this.containingElement) {
|
|
3336
|
+
this.containingElement = this;
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
firstUpdated() {
|
|
3340
|
+
this.panel.hidden = !this.open;
|
|
3341
|
+
if (this.open) {
|
|
3342
|
+
this.addOpenListeners();
|
|
3343
|
+
this.popup.active = true;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
disconnectedCallback() {
|
|
3347
|
+
super.disconnectedCallback();
|
|
3348
|
+
this.removeOpenListeners();
|
|
3349
|
+
this.hide();
|
|
3350
|
+
}
|
|
3351
|
+
focusOnTrigger() {
|
|
3352
|
+
const trigger = this.trigger.assignedElements({ flatten: true })[0];
|
|
3353
|
+
if (typeof (trigger == null ? void 0 : trigger.focus) === "function") {
|
|
3354
|
+
trigger.focus();
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
getMenu() {
|
|
3358
|
+
return this.panel.assignedElements({ flatten: true }).find((el) => el.tagName.toLowerCase() === "sl-menu");
|
|
3359
|
+
}
|
|
3360
|
+
handleTriggerClick() {
|
|
3361
|
+
if (this.open) {
|
|
3362
|
+
this.hide();
|
|
3363
|
+
} else {
|
|
3364
|
+
this.show();
|
|
3365
|
+
this.focusOnTrigger();
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
async handleTriggerKeyDown(event) {
|
|
3369
|
+
if ([" ", "Enter"].includes(event.key)) {
|
|
3370
|
+
event.preventDefault();
|
|
3371
|
+
this.handleTriggerClick();
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
const menu = this.getMenu();
|
|
3375
|
+
if (menu) {
|
|
3376
|
+
const menuItems = menu.getAllItems();
|
|
3377
|
+
const firstMenuItem = menuItems[0];
|
|
3378
|
+
const lastMenuItem = menuItems[menuItems.length - 1];
|
|
3379
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
3380
|
+
event.preventDefault();
|
|
3381
|
+
if (!this.open) {
|
|
3382
|
+
this.show();
|
|
3383
|
+
await this.updateComplete;
|
|
3384
|
+
}
|
|
3385
|
+
if (menuItems.length > 0) {
|
|
3386
|
+
this.updateComplete.then(() => {
|
|
3387
|
+
if (event.key === "ArrowDown" || event.key === "Home") {
|
|
3388
|
+
menu.setCurrentItem(firstMenuItem);
|
|
3389
|
+
firstMenuItem.focus();
|
|
3390
|
+
}
|
|
3391
|
+
if (event.key === "ArrowUp" || event.key === "End") {
|
|
3392
|
+
menu.setCurrentItem(lastMenuItem);
|
|
3393
|
+
lastMenuItem.focus();
|
|
3394
|
+
}
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
handleTriggerKeyUp(event) {
|
|
3401
|
+
if (event.key === " ") {
|
|
3402
|
+
event.preventDefault();
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
handleTriggerSlotChange() {
|
|
3406
|
+
this.updateAccessibleTrigger();
|
|
3407
|
+
}
|
|
3408
|
+
//
|
|
3409
|
+
// Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and
|
|
3410
|
+
// `aria-expanded`. These must be applied to the "accessible trigger" (the tabbable portion of the trigger element
|
|
3411
|
+
// that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,
|
|
3412
|
+
// a child of the slotted element, or an element in the slotted element's shadow root.
|
|
3413
|
+
//
|
|
3414
|
+
// For example, the accessible trigger of an <sl-button> is a <button> located inside its shadow root.
|
|
3415
|
+
//
|
|
3416
|
+
// To determine this, we assume the first tabbable element in the trigger slot is the "accessible trigger."
|
|
3417
|
+
//
|
|
3418
|
+
updateAccessibleTrigger() {
|
|
3419
|
+
const assignedElements = this.trigger.assignedElements({ flatten: true });
|
|
3420
|
+
const accessibleTrigger = assignedElements.find((el) => getTabbableBoundary(el).start);
|
|
3421
|
+
let target;
|
|
3422
|
+
if (accessibleTrigger) {
|
|
3423
|
+
switch (accessibleTrigger.tagName.toLowerCase()) {
|
|
3424
|
+
// Shoelace buttons have to update the internal button so it's announced correctly by screen readers
|
|
3425
|
+
case "sl-button":
|
|
3426
|
+
case "sl-icon-button":
|
|
3427
|
+
target = accessibleTrigger.button;
|
|
3428
|
+
break;
|
|
3429
|
+
default:
|
|
3430
|
+
target = accessibleTrigger;
|
|
3431
|
+
}
|
|
3432
|
+
target.setAttribute("aria-haspopup", "true");
|
|
3433
|
+
target.setAttribute("aria-expanded", this.open ? "true" : "false");
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
/** Shows the dropdown panel. */
|
|
3437
|
+
async show() {
|
|
3438
|
+
if (this.open) {
|
|
3439
|
+
return void 0;
|
|
3440
|
+
}
|
|
3441
|
+
this.open = true;
|
|
3442
|
+
return waitForEvent(this, "sl-after-show");
|
|
3443
|
+
}
|
|
3444
|
+
/** Hides the dropdown panel */
|
|
3445
|
+
async hide() {
|
|
3446
|
+
if (!this.open) {
|
|
3447
|
+
return void 0;
|
|
3448
|
+
}
|
|
3449
|
+
this.open = false;
|
|
3450
|
+
return waitForEvent(this, "sl-after-hide");
|
|
3451
|
+
}
|
|
3452
|
+
/**
|
|
3453
|
+
* Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu
|
|
3454
|
+
* is activated.
|
|
3455
|
+
*/
|
|
3456
|
+
reposition() {
|
|
3457
|
+
this.popup.reposition();
|
|
3458
|
+
}
|
|
3459
|
+
addOpenListeners() {
|
|
3460
|
+
var _a;
|
|
3461
|
+
this.panel.addEventListener("sl-select", this.handlePanelSelect);
|
|
3462
|
+
if ("CloseWatcher" in window) {
|
|
3463
|
+
(_a = this.closeWatcher) == null ? void 0 : _a.destroy();
|
|
3464
|
+
this.closeWatcher = new CloseWatcher();
|
|
3465
|
+
this.closeWatcher.onclose = () => {
|
|
3466
|
+
this.hide();
|
|
3467
|
+
this.focusOnTrigger();
|
|
3468
|
+
};
|
|
3469
|
+
} else {
|
|
3470
|
+
this.panel.addEventListener("keydown", this.handleKeyDown);
|
|
3471
|
+
}
|
|
3472
|
+
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
3473
|
+
document.addEventListener("mousedown", this.handleDocumentMouseDown);
|
|
3474
|
+
}
|
|
3475
|
+
removeOpenListeners() {
|
|
3476
|
+
var _a;
|
|
3477
|
+
if (this.panel) {
|
|
3478
|
+
this.panel.removeEventListener("sl-select", this.handlePanelSelect);
|
|
3479
|
+
this.panel.removeEventListener("keydown", this.handleKeyDown);
|
|
3480
|
+
}
|
|
3481
|
+
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
3482
|
+
document.removeEventListener("mousedown", this.handleDocumentMouseDown);
|
|
3483
|
+
(_a = this.closeWatcher) == null ? void 0 : _a.destroy();
|
|
3484
|
+
}
|
|
3485
|
+
async handleOpenChange() {
|
|
3486
|
+
if (this.disabled) {
|
|
3487
|
+
this.open = false;
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
this.updateAccessibleTrigger();
|
|
3491
|
+
if (this.open) {
|
|
3492
|
+
this.emit("sl-show");
|
|
3493
|
+
this.addOpenListeners();
|
|
3494
|
+
await stopAnimations(this);
|
|
3495
|
+
this.panel.hidden = false;
|
|
3496
|
+
this.popup.active = true;
|
|
3497
|
+
const { keyframes, options } = getAnimation(this, "dropdown.show", { dir: this.localize.dir() });
|
|
3498
|
+
await animateTo(this.popup.popup, keyframes, options);
|
|
3499
|
+
this.emit("sl-after-show");
|
|
3500
|
+
} else {
|
|
3501
|
+
this.emit("sl-hide");
|
|
3502
|
+
this.removeOpenListeners();
|
|
3503
|
+
await stopAnimations(this);
|
|
3504
|
+
const { keyframes, options } = getAnimation(this, "dropdown.hide", { dir: this.localize.dir() });
|
|
3505
|
+
await animateTo(this.popup.popup, keyframes, options);
|
|
3506
|
+
this.panel.hidden = true;
|
|
3507
|
+
this.popup.active = false;
|
|
3508
|
+
this.emit("sl-after-hide");
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
render() {
|
|
3512
|
+
return x`
|
|
3513
|
+
<sl-popup
|
|
3514
|
+
part="base"
|
|
3515
|
+
exportparts="popup:base__popup"
|
|
3516
|
+
id="dropdown"
|
|
3517
|
+
placement=${this.placement}
|
|
3518
|
+
distance=${this.distance}
|
|
3519
|
+
skidding=${this.skidding}
|
|
3520
|
+
strategy=${this.hoist ? "fixed" : "absolute"}
|
|
3521
|
+
flip
|
|
3522
|
+
shift
|
|
3523
|
+
auto-size="vertical"
|
|
3524
|
+
auto-size-padding="10"
|
|
3525
|
+
sync=${o$2(this.sync ? this.sync : void 0)}
|
|
3526
|
+
class=${e$2({
|
|
3527
|
+
dropdown: true,
|
|
3528
|
+
"dropdown--open": this.open
|
|
3529
|
+
})}
|
|
3530
|
+
>
|
|
3531
|
+
<slot
|
|
3532
|
+
name="trigger"
|
|
3533
|
+
slot="anchor"
|
|
3534
|
+
part="trigger"
|
|
3535
|
+
class="dropdown__trigger"
|
|
3536
|
+
@click=${this.handleTriggerClick}
|
|
3537
|
+
@keydown=${this.handleTriggerKeyDown}
|
|
3538
|
+
@keyup=${this.handleTriggerKeyUp}
|
|
3539
|
+
@slotchange=${this.handleTriggerSlotChange}
|
|
3540
|
+
></slot>
|
|
3541
|
+
|
|
3542
|
+
<div aria-hidden=${this.open ? "false" : "true"} aria-labelledby="dropdown">
|
|
3543
|
+
<slot part="panel" class="dropdown__panel"></slot>
|
|
3544
|
+
</div>
|
|
3545
|
+
</sl-popup>
|
|
3546
|
+
`;
|
|
3547
|
+
}
|
|
3548
|
+
};
|
|
3549
|
+
SlDropdown.styles = [component_styles_default, dropdown_styles_default];
|
|
3550
|
+
SlDropdown.dependencies = { "sl-popup": SlPopup };
|
|
3551
|
+
__decorateClass([
|
|
3552
|
+
e$4(".dropdown")
|
|
3553
|
+
], SlDropdown.prototype, "popup", 2);
|
|
3554
|
+
__decorateClass([
|
|
3555
|
+
e$4(".dropdown__trigger")
|
|
3556
|
+
], SlDropdown.prototype, "trigger", 2);
|
|
3557
|
+
__decorateClass([
|
|
3558
|
+
e$4(".dropdown__panel")
|
|
3559
|
+
], SlDropdown.prototype, "panel", 2);
|
|
3560
|
+
__decorateClass([
|
|
3561
|
+
n$2({ type: Boolean, reflect: true })
|
|
3562
|
+
], SlDropdown.prototype, "open", 2);
|
|
3563
|
+
__decorateClass([
|
|
3564
|
+
n$2({ reflect: true })
|
|
3565
|
+
], SlDropdown.prototype, "placement", 2);
|
|
3566
|
+
__decorateClass([
|
|
3567
|
+
n$2({ type: Boolean, reflect: true })
|
|
3568
|
+
], SlDropdown.prototype, "disabled", 2);
|
|
3569
|
+
__decorateClass([
|
|
3570
|
+
n$2({ attribute: "stay-open-on-select", type: Boolean, reflect: true })
|
|
3571
|
+
], SlDropdown.prototype, "stayOpenOnSelect", 2);
|
|
3572
|
+
__decorateClass([
|
|
3573
|
+
n$2({ attribute: false })
|
|
3574
|
+
], SlDropdown.prototype, "containingElement", 2);
|
|
3575
|
+
__decorateClass([
|
|
3576
|
+
n$2({ type: Number })
|
|
3577
|
+
], SlDropdown.prototype, "distance", 2);
|
|
3578
|
+
__decorateClass([
|
|
3579
|
+
n$2({ type: Number })
|
|
3580
|
+
], SlDropdown.prototype, "skidding", 2);
|
|
3581
|
+
__decorateClass([
|
|
3582
|
+
n$2({ type: Boolean })
|
|
3583
|
+
], SlDropdown.prototype, "hoist", 2);
|
|
3584
|
+
__decorateClass([
|
|
3585
|
+
n$2({ reflect: true })
|
|
3586
|
+
], SlDropdown.prototype, "sync", 2);
|
|
3587
|
+
__decorateClass([
|
|
3588
|
+
watch("open", { waitUntilFirstUpdate: true })
|
|
3589
|
+
], SlDropdown.prototype, "handleOpenChange", 1);
|
|
3590
|
+
setDefaultAnimation("dropdown.show", {
|
|
3591
|
+
keyframes: [
|
|
3592
|
+
{ opacity: 0, scale: 0.9 },
|
|
3593
|
+
{ opacity: 1, scale: 1 }
|
|
3594
|
+
],
|
|
3595
|
+
options: { duration: 100, easing: "ease" }
|
|
3596
|
+
});
|
|
3597
|
+
setDefaultAnimation("dropdown.hide", {
|
|
3598
|
+
keyframes: [
|
|
3599
|
+
{ opacity: 1, scale: 1 },
|
|
3600
|
+
{ opacity: 0, scale: 0.9 }
|
|
3601
|
+
],
|
|
3602
|
+
options: { duration: 100, easing: "ease" }
|
|
3603
|
+
});
|
|
3604
|
+
|
|
3605
|
+
SlDropdown.define("sl-dropdown");
|
|
3606
|
+
|
|
3607
|
+
// src/components/menu/menu.styles.ts
|
|
3608
|
+
var menu_styles_default = i$4`
|
|
3609
|
+
:host {
|
|
3610
|
+
display: block;
|
|
3611
|
+
position: relative;
|
|
3612
|
+
background: var(--sl-panel-background-color);
|
|
3613
|
+
border: solid var(--sl-panel-border-width) var(--sl-panel-border-color);
|
|
3614
|
+
border-radius: var(--sl-border-radius-medium);
|
|
3615
|
+
padding: var(--sl-spacing-x-small) 0;
|
|
3616
|
+
overflow: auto;
|
|
3617
|
+
overscroll-behavior: none;
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
::slotted(sl-divider) {
|
|
3621
|
+
--spacing: var(--sl-spacing-x-small);
|
|
3622
|
+
}
|
|
3623
|
+
`;
|
|
3624
|
+
|
|
3625
|
+
var SlMenu = class extends ShoelaceElement {
|
|
3626
|
+
connectedCallback() {
|
|
3627
|
+
super.connectedCallback();
|
|
3628
|
+
this.setAttribute("role", "menu");
|
|
3629
|
+
}
|
|
3630
|
+
handleClick(event) {
|
|
3631
|
+
const menuItemTypes = ["menuitem", "menuitemcheckbox"];
|
|
3632
|
+
const composedPath = event.composedPath();
|
|
3633
|
+
const target = composedPath.find((el) => {
|
|
3634
|
+
var _a;
|
|
3635
|
+
return menuItemTypes.includes(((_a = el == null ? void 0 : el.getAttribute) == null ? void 0 : _a.call(el, "role")) || "");
|
|
3636
|
+
});
|
|
3637
|
+
if (!target) return;
|
|
3638
|
+
const closestMenu = composedPath.find((el) => {
|
|
3639
|
+
var _a;
|
|
3640
|
+
return ((_a = el == null ? void 0 : el.getAttribute) == null ? void 0 : _a.call(el, "role")) === "menu";
|
|
3641
|
+
});
|
|
3642
|
+
const clickHasSubmenu = closestMenu !== this;
|
|
3643
|
+
if (clickHasSubmenu) return;
|
|
3644
|
+
const item = target;
|
|
3645
|
+
if (item.type === "checkbox") {
|
|
3646
|
+
item.checked = !item.checked;
|
|
3647
|
+
}
|
|
3648
|
+
this.emit("sl-select", { detail: { item } });
|
|
3649
|
+
}
|
|
3650
|
+
handleKeyDown(event) {
|
|
3651
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3652
|
+
const item = this.getCurrentItem();
|
|
3653
|
+
event.preventDefault();
|
|
3654
|
+
event.stopPropagation();
|
|
3655
|
+
item == null ? void 0 : item.click();
|
|
3656
|
+
} else if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
3657
|
+
const items = this.getAllItems();
|
|
3658
|
+
const activeItem = this.getCurrentItem();
|
|
3659
|
+
let index = activeItem ? items.indexOf(activeItem) : 0;
|
|
3660
|
+
if (items.length > 0) {
|
|
3661
|
+
event.preventDefault();
|
|
3662
|
+
event.stopPropagation();
|
|
3663
|
+
if (event.key === "ArrowDown") {
|
|
3664
|
+
index++;
|
|
3665
|
+
} else if (event.key === "ArrowUp") {
|
|
3666
|
+
index--;
|
|
3667
|
+
} else if (event.key === "Home") {
|
|
3668
|
+
index = 0;
|
|
3669
|
+
} else if (event.key === "End") {
|
|
3670
|
+
index = items.length - 1;
|
|
3671
|
+
}
|
|
3672
|
+
if (index < 0) {
|
|
3673
|
+
index = items.length - 1;
|
|
3674
|
+
}
|
|
3675
|
+
if (index > items.length - 1) {
|
|
3676
|
+
index = 0;
|
|
3677
|
+
}
|
|
3678
|
+
this.setCurrentItem(items[index]);
|
|
3679
|
+
items[index].focus();
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
handleMouseDown(event) {
|
|
3684
|
+
const target = event.target;
|
|
3685
|
+
if (this.isMenuItem(target)) {
|
|
3686
|
+
this.setCurrentItem(target);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
handleSlotChange() {
|
|
3690
|
+
const items = this.getAllItems();
|
|
3691
|
+
if (items.length > 0) {
|
|
3692
|
+
this.setCurrentItem(items[0]);
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
isMenuItem(item) {
|
|
3696
|
+
var _a;
|
|
3697
|
+
return item.tagName.toLowerCase() === "sl-menu-item" || ["menuitem", "menuitemcheckbox", "menuitemradio"].includes((_a = item.getAttribute("role")) != null ? _a : "");
|
|
3698
|
+
}
|
|
3699
|
+
/** @internal Gets all slotted menu items, ignoring dividers, headers, and other elements. */
|
|
3700
|
+
getAllItems() {
|
|
3701
|
+
return [...this.defaultSlot.assignedElements({ flatten: true })].filter((el) => {
|
|
3702
|
+
if (el.inert || !this.isMenuItem(el)) {
|
|
3703
|
+
return false;
|
|
3704
|
+
}
|
|
3705
|
+
return true;
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* @internal Gets the current menu item, which is the menu item that has `tabindex="0"` within the roving tab index.
|
|
3710
|
+
* The menu item may or may not have focus, but for keyboard interaction purposes it's considered the "active" item.
|
|
3711
|
+
*/
|
|
3712
|
+
getCurrentItem() {
|
|
3713
|
+
return this.getAllItems().find((i) => i.getAttribute("tabindex") === "0");
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* @internal Sets the current menu item to the specified element. This sets `tabindex="0"` on the target element and
|
|
3717
|
+
* `tabindex="-1"` to all other items. This method must be called prior to setting focus on a menu item.
|
|
3718
|
+
*/
|
|
3719
|
+
setCurrentItem(item) {
|
|
3720
|
+
const items = this.getAllItems();
|
|
3721
|
+
items.forEach((i) => {
|
|
3722
|
+
i.setAttribute("tabindex", i === item ? "0" : "-1");
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
render() {
|
|
3726
|
+
return x`
|
|
3727
|
+
<slot
|
|
3728
|
+
@slotchange=${this.handleSlotChange}
|
|
3729
|
+
@click=${this.handleClick}
|
|
3730
|
+
@keydown=${this.handleKeyDown}
|
|
3731
|
+
@mousedown=${this.handleMouseDown}
|
|
3732
|
+
></slot>
|
|
3733
|
+
`;
|
|
3734
|
+
}
|
|
3735
|
+
};
|
|
3736
|
+
SlMenu.styles = [component_styles_default, menu_styles_default];
|
|
3737
|
+
__decorateClass([
|
|
3738
|
+
e$4("slot")
|
|
3739
|
+
], SlMenu.prototype, "defaultSlot", 2);
|
|
3740
|
+
|
|
3741
|
+
SlMenu.define("sl-menu");
|
|
3742
|
+
|
|
3743
|
+
// src/components/menu-item/menu-item.styles.ts
|
|
3744
|
+
var menu_item_styles_default = i$4`
|
|
3745
|
+
:host {
|
|
3746
|
+
--submenu-offset: -2px;
|
|
3747
|
+
|
|
3748
|
+
display: block;
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
:host([inert]) {
|
|
3752
|
+
display: none;
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
.menu-item {
|
|
3756
|
+
position: relative;
|
|
3757
|
+
display: flex;
|
|
3758
|
+
align-items: stretch;
|
|
3759
|
+
font-family: var(--sl-font-sans);
|
|
3760
|
+
font-size: var(--sl-font-size-medium);
|
|
3761
|
+
font-weight: var(--sl-font-weight-normal);
|
|
3762
|
+
line-height: var(--sl-line-height-normal);
|
|
3763
|
+
letter-spacing: var(--sl-letter-spacing-normal);
|
|
3764
|
+
color: var(--sl-color-neutral-700);
|
|
3765
|
+
padding: var(--sl-spacing-2x-small) var(--sl-spacing-2x-small);
|
|
3766
|
+
transition: var(--sl-transition-fast) fill;
|
|
3767
|
+
user-select: none;
|
|
3768
|
+
-webkit-user-select: none;
|
|
3769
|
+
white-space: nowrap;
|
|
3770
|
+
cursor: pointer;
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
.menu-item.menu-item--disabled {
|
|
3774
|
+
outline: none;
|
|
3775
|
+
opacity: 0.5;
|
|
3776
|
+
cursor: not-allowed;
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
.menu-item.menu-item--loading {
|
|
3780
|
+
outline: none;
|
|
3781
|
+
cursor: wait;
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
.menu-item.menu-item--loading *:not(sl-spinner) {
|
|
3785
|
+
opacity: 0.5;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
.menu-item--loading sl-spinner {
|
|
3789
|
+
--indicator-color: currentColor;
|
|
3790
|
+
--track-width: 1px;
|
|
3791
|
+
position: absolute;
|
|
3792
|
+
font-size: 0.75em;
|
|
3793
|
+
top: calc(50% - 0.5em);
|
|
3794
|
+
left: 0.65rem;
|
|
3795
|
+
opacity: 1;
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
.menu-item .menu-item__label {
|
|
3799
|
+
flex: 1 1 auto;
|
|
3800
|
+
display: inline-block;
|
|
3801
|
+
text-overflow: ellipsis;
|
|
3802
|
+
overflow: hidden;
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
.menu-item .menu-item__prefix {
|
|
3806
|
+
flex: 0 0 auto;
|
|
3807
|
+
display: flex;
|
|
3808
|
+
align-items: center;
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
.menu-item .menu-item__prefix::slotted(*) {
|
|
3812
|
+
margin-inline-end: var(--sl-spacing-x-small);
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
.menu-item .menu-item__suffix {
|
|
3816
|
+
flex: 0 0 auto;
|
|
3817
|
+
display: flex;
|
|
3818
|
+
align-items: center;
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
.menu-item .menu-item__suffix::slotted(*) {
|
|
3822
|
+
margin-inline-start: var(--sl-spacing-x-small);
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3825
|
+
/* Safe triangle */
|
|
3826
|
+
.menu-item--submenu-expanded::after {
|
|
3827
|
+
content: '';
|
|
3828
|
+
position: fixed;
|
|
3829
|
+
z-index: calc(var(--sl-z-index-dropdown) - 1);
|
|
3830
|
+
top: 0;
|
|
3831
|
+
right: 0;
|
|
3832
|
+
bottom: 0;
|
|
3833
|
+
left: 0;
|
|
3834
|
+
clip-path: polygon(
|
|
3835
|
+
var(--safe-triangle-cursor-x, 0) var(--safe-triangle-cursor-y, 0),
|
|
3836
|
+
var(--safe-triangle-submenu-start-x, 0) var(--safe-triangle-submenu-start-y, 0),
|
|
3837
|
+
var(--safe-triangle-submenu-end-x, 0) var(--safe-triangle-submenu-end-y, 0)
|
|
3838
|
+
);
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
:host(:focus-visible) {
|
|
3842
|
+
outline: none;
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
:host(:hover:not([aria-disabled='true'], :focus-visible)) .menu-item,
|
|
3846
|
+
.menu-item--submenu-expanded {
|
|
3847
|
+
background-color: var(--sl-color-neutral-100);
|
|
3848
|
+
color: var(--sl-color-neutral-1000);
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3851
|
+
:host(:focus-visible) .menu-item {
|
|
3852
|
+
outline: none;
|
|
3853
|
+
background-color: var(--sl-color-primary-600);
|
|
3854
|
+
color: var(--sl-color-neutral-0);
|
|
3855
|
+
opacity: 1;
|
|
3856
|
+
}
|
|
3857
|
+
|
|
3858
|
+
.menu-item .menu-item__check,
|
|
3859
|
+
.menu-item .menu-item__chevron {
|
|
3860
|
+
flex: 0 0 auto;
|
|
3861
|
+
display: flex;
|
|
3862
|
+
align-items: center;
|
|
3863
|
+
justify-content: center;
|
|
3864
|
+
width: 1.5em;
|
|
3865
|
+
visibility: hidden;
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
.menu-item--checked .menu-item__check,
|
|
3869
|
+
.menu-item--has-submenu .menu-item__chevron {
|
|
3870
|
+
visibility: visible;
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
/* Add elevation and z-index to submenus */
|
|
3874
|
+
sl-popup::part(popup) {
|
|
3875
|
+
box-shadow: var(--sl-shadow-large);
|
|
3876
|
+
z-index: var(--sl-z-index-dropdown);
|
|
3877
|
+
margin-left: var(--submenu-offset);
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
.menu-item--rtl sl-popup::part(popup) {
|
|
3881
|
+
margin-left: calc(-1 * var(--submenu-offset));
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
@media (forced-colors: active) {
|
|
3885
|
+
:host(:hover:not([aria-disabled='true'])) .menu-item,
|
|
3886
|
+
:host(:focus-visible) .menu-item {
|
|
3887
|
+
outline: dashed 1px SelectedItem;
|
|
3888
|
+
outline-offset: -1px;
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
::slotted(sl-menu) {
|
|
3893
|
+
max-width: var(--auto-size-available-width) !important;
|
|
3894
|
+
max-height: var(--auto-size-available-height) !important;
|
|
3895
|
+
}
|
|
3896
|
+
`;
|
|
3897
|
+
|
|
3898
|
+
/**
|
|
3899
|
+
* @license
|
|
3900
|
+
* Copyright 2020 Google LLC
|
|
3901
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3902
|
+
*/const e$1=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,f$1=o=>void 0===o.strings;
|
|
3903
|
+
|
|
3904
|
+
/**
|
|
3905
|
+
* @license
|
|
3906
|
+
* Copyright 2017 Google LLC
|
|
3907
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3908
|
+
*/const s=(i,t)=>{const e=i._$AN;if(void 0===e)return !1;for(const i of e)i._$AO?.(t,!1),s(i,t);return !0},o$1=i=>{let t,e;do{if(void 0===(t=i._$AM))break;e=t._$AN,e.delete(i),i=t;}while(0===e?.size)},r=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(void 0===e)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),c(t);}};function h$1(i){void 0!==this._$AN?(o$1(this),this._$AM=i,r(this)):this._$AM=i;}function n$1(i,t=!1,e=0){const r=this._$AH,h=this._$AN;if(void 0!==h&&0!==h.size)if(t)if(Array.isArray(r))for(let i=e;i<r.length;i++)s(r[i],!1),o$1(r[i]);else null!=r&&(s(r,!1),o$1(r));else s(this,i);}const c=i=>{i.type==t.CHILD&&(i._$AP??=n$1,i._$AQ??=h$1);};class f extends i{constructor(){super(...arguments),this._$AN=void 0;}_$AT(i,t,e){super._$AT(i,t,e),r(this),this.isConnected=i._$AU;}_$AO(i,t=!0){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),t&&(s(this,i),o$1(this));}setValue(t){if(f$1(this._$Ct))this._$Ct._$AI(t,this);else {const i=[...this._$Ct._$AH];i[this._$Ci]=t,this._$Ct._$AI(i,this,0);}}disconnected(){}reconnected(){}}
|
|
3909
|
+
|
|
3910
|
+
/**
|
|
3911
|
+
* @license
|
|
3912
|
+
* Copyright 2020 Google LLC
|
|
3913
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3914
|
+
*/const e=()=>new h;class h{}const o=new WeakMap,n=e$3(class extends f{render(i){return E}update(i,[s]){const e=s!==this.G;return e&&void 0!==this.G&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=s,this.ht=i.options?.host,this.rt(this.ct=i.element)),E}rt(t){if(this.isConnected||(t=void 0),"function"==typeof this.G){const i=this.ht??globalThis;let s=o.get(i);void 0===s&&(s=new WeakMap,o.set(i,s)),void 0!==s.get(this.G)&&this.G.call(this.ht,void 0),s.set(this.G,t),void 0!==t&&this.G.call(this.ht,t);}else this.G.value=t;}get lt(){return "function"==typeof this.G?o.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0);}reconnected(){this.rt(this.ct);}});
|
|
3915
|
+
|
|
3916
|
+
// src/components/menu-item/submenu-controller.ts
|
|
3917
|
+
var SubmenuController = class {
|
|
3918
|
+
constructor(host, hasSlotController) {
|
|
3919
|
+
this.popupRef = e();
|
|
3920
|
+
this.enableSubmenuTimer = -1;
|
|
3921
|
+
this.isConnected = false;
|
|
3922
|
+
this.isPopupConnected = false;
|
|
3923
|
+
this.skidding = 0;
|
|
3924
|
+
this.submenuOpenDelay = 100;
|
|
3925
|
+
// Set the safe triangle cursor position
|
|
3926
|
+
this.handleMouseMove = (event) => {
|
|
3927
|
+
this.host.style.setProperty("--safe-triangle-cursor-x", `${event.clientX}px`);
|
|
3928
|
+
this.host.style.setProperty("--safe-triangle-cursor-y", `${event.clientY}px`);
|
|
3929
|
+
};
|
|
3930
|
+
this.handleMouseOver = () => {
|
|
3931
|
+
if (this.hasSlotController.test("submenu")) {
|
|
3932
|
+
this.enableSubmenu();
|
|
3933
|
+
}
|
|
3934
|
+
};
|
|
3935
|
+
// Focus on the first menu-item of a submenu.
|
|
3936
|
+
this.handleKeyDown = (event) => {
|
|
3937
|
+
switch (event.key) {
|
|
3938
|
+
case "Escape":
|
|
3939
|
+
case "Tab":
|
|
3940
|
+
this.disableSubmenu();
|
|
3941
|
+
break;
|
|
3942
|
+
case "ArrowLeft":
|
|
3943
|
+
if (event.target !== this.host) {
|
|
3944
|
+
event.preventDefault();
|
|
3945
|
+
event.stopPropagation();
|
|
3946
|
+
this.host.focus();
|
|
3947
|
+
this.disableSubmenu();
|
|
3948
|
+
}
|
|
3949
|
+
break;
|
|
3950
|
+
case "ArrowRight":
|
|
3951
|
+
case "Enter":
|
|
3952
|
+
case " ":
|
|
3953
|
+
this.handleSubmenuEntry(event);
|
|
3954
|
+
break;
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3957
|
+
this.handleClick = (event) => {
|
|
3958
|
+
var _a;
|
|
3959
|
+
if (event.target === this.host) {
|
|
3960
|
+
event.preventDefault();
|
|
3961
|
+
event.stopPropagation();
|
|
3962
|
+
} else if (event.target instanceof Element && (event.target.tagName === "sl-menu-item" || ((_a = event.target.role) == null ? void 0 : _a.startsWith("menuitem")))) {
|
|
3963
|
+
this.disableSubmenu();
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
// Close this submenu on focus outside of the parent or any descendants.
|
|
3967
|
+
this.handleFocusOut = (event) => {
|
|
3968
|
+
if (event.relatedTarget && event.relatedTarget instanceof Element && this.host.contains(event.relatedTarget)) {
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
3971
|
+
this.disableSubmenu();
|
|
3972
|
+
};
|
|
3973
|
+
// Prevent the parent menu-item from getting focus on mouse movement on the submenu
|
|
3974
|
+
this.handlePopupMouseover = (event) => {
|
|
3975
|
+
event.stopPropagation();
|
|
3976
|
+
};
|
|
3977
|
+
// Set the safe triangle values for the submenu when the position changes
|
|
3978
|
+
this.handlePopupReposition = () => {
|
|
3979
|
+
const submenuSlot = this.host.renderRoot.querySelector("slot[name='submenu']");
|
|
3980
|
+
const menu = submenuSlot == null ? void 0 : submenuSlot.assignedElements({ flatten: true }).filter((el) => el.localName === "sl-menu")[0];
|
|
3981
|
+
const isRtl = getComputedStyle(this.host).direction === "rtl";
|
|
3982
|
+
if (!menu) {
|
|
3983
|
+
return;
|
|
3984
|
+
}
|
|
3985
|
+
const { left, top, width, height } = menu.getBoundingClientRect();
|
|
3986
|
+
this.host.style.setProperty("--safe-triangle-submenu-start-x", `${isRtl ? left + width : left}px`);
|
|
3987
|
+
this.host.style.setProperty("--safe-triangle-submenu-start-y", `${top}px`);
|
|
3988
|
+
this.host.style.setProperty("--safe-triangle-submenu-end-x", `${isRtl ? left + width : left}px`);
|
|
3989
|
+
this.host.style.setProperty("--safe-triangle-submenu-end-y", `${top + height}px`);
|
|
3990
|
+
};
|
|
3991
|
+
(this.host = host).addController(this);
|
|
3992
|
+
this.hasSlotController = hasSlotController;
|
|
3993
|
+
}
|
|
3994
|
+
hostConnected() {
|
|
3995
|
+
if (this.hasSlotController.test("submenu") && !this.host.disabled) {
|
|
3996
|
+
this.addListeners();
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
hostDisconnected() {
|
|
4000
|
+
this.removeListeners();
|
|
4001
|
+
}
|
|
4002
|
+
hostUpdated() {
|
|
4003
|
+
if (this.hasSlotController.test("submenu") && !this.host.disabled) {
|
|
4004
|
+
this.addListeners();
|
|
4005
|
+
this.updateSkidding();
|
|
4006
|
+
} else {
|
|
4007
|
+
this.removeListeners();
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
addListeners() {
|
|
4011
|
+
if (!this.isConnected) {
|
|
4012
|
+
this.host.addEventListener("mousemove", this.handleMouseMove);
|
|
4013
|
+
this.host.addEventListener("mouseover", this.handleMouseOver);
|
|
4014
|
+
this.host.addEventListener("keydown", this.handleKeyDown);
|
|
4015
|
+
this.host.addEventListener("click", this.handleClick);
|
|
4016
|
+
this.host.addEventListener("focusout", this.handleFocusOut);
|
|
4017
|
+
this.isConnected = true;
|
|
4018
|
+
}
|
|
4019
|
+
if (!this.isPopupConnected) {
|
|
4020
|
+
if (this.popupRef.value) {
|
|
4021
|
+
this.popupRef.value.addEventListener("mouseover", this.handlePopupMouseover);
|
|
4022
|
+
this.popupRef.value.addEventListener("sl-reposition", this.handlePopupReposition);
|
|
4023
|
+
this.isPopupConnected = true;
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
removeListeners() {
|
|
4028
|
+
if (this.isConnected) {
|
|
4029
|
+
this.host.removeEventListener("mousemove", this.handleMouseMove);
|
|
4030
|
+
this.host.removeEventListener("mouseover", this.handleMouseOver);
|
|
4031
|
+
this.host.removeEventListener("keydown", this.handleKeyDown);
|
|
4032
|
+
this.host.removeEventListener("click", this.handleClick);
|
|
4033
|
+
this.host.removeEventListener("focusout", this.handleFocusOut);
|
|
4034
|
+
this.isConnected = false;
|
|
4035
|
+
}
|
|
4036
|
+
if (this.isPopupConnected) {
|
|
4037
|
+
if (this.popupRef.value) {
|
|
4038
|
+
this.popupRef.value.removeEventListener("mouseover", this.handlePopupMouseover);
|
|
4039
|
+
this.popupRef.value.removeEventListener("sl-reposition", this.handlePopupReposition);
|
|
4040
|
+
this.isPopupConnected = false;
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
handleSubmenuEntry(event) {
|
|
4045
|
+
const submenuSlot = this.host.renderRoot.querySelector("slot[name='submenu']");
|
|
4046
|
+
if (!submenuSlot) {
|
|
4047
|
+
console.error("Cannot activate a submenu if no corresponding menuitem can be found.", this);
|
|
4048
|
+
return;
|
|
4049
|
+
}
|
|
4050
|
+
let menuItems = null;
|
|
4051
|
+
for (const elt of submenuSlot.assignedElements()) {
|
|
4052
|
+
menuItems = elt.querySelectorAll("sl-menu-item, [role^='menuitem']");
|
|
4053
|
+
if (menuItems.length !== 0) {
|
|
4054
|
+
break;
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
if (!menuItems || menuItems.length === 0) {
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
menuItems[0].setAttribute("tabindex", "0");
|
|
4061
|
+
for (let i = 1; i !== menuItems.length; ++i) {
|
|
4062
|
+
menuItems[i].setAttribute("tabindex", "-1");
|
|
4063
|
+
}
|
|
4064
|
+
if (this.popupRef.value) {
|
|
4065
|
+
event.preventDefault();
|
|
4066
|
+
event.stopPropagation();
|
|
4067
|
+
if (this.popupRef.value.active) {
|
|
4068
|
+
if (menuItems[0] instanceof HTMLElement) {
|
|
4069
|
+
menuItems[0].focus();
|
|
4070
|
+
}
|
|
4071
|
+
} else {
|
|
4072
|
+
this.enableSubmenu(false);
|
|
4073
|
+
this.host.updateComplete.then(() => {
|
|
4074
|
+
if (menuItems[0] instanceof HTMLElement) {
|
|
4075
|
+
menuItems[0].focus();
|
|
4076
|
+
}
|
|
4077
|
+
});
|
|
4078
|
+
this.host.requestUpdate();
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
setSubmenuState(state) {
|
|
4083
|
+
if (this.popupRef.value) {
|
|
4084
|
+
if (this.popupRef.value.active !== state) {
|
|
4085
|
+
this.popupRef.value.active = state;
|
|
4086
|
+
this.host.requestUpdate();
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
// Shows the submenu. Supports disabling the opening delay, e.g. for keyboard events that want to set the focus to the
|
|
4091
|
+
// newly opened menu.
|
|
4092
|
+
enableSubmenu(delay = true) {
|
|
4093
|
+
if (delay) {
|
|
4094
|
+
window.clearTimeout(this.enableSubmenuTimer);
|
|
4095
|
+
this.enableSubmenuTimer = window.setTimeout(() => {
|
|
4096
|
+
this.setSubmenuState(true);
|
|
4097
|
+
}, this.submenuOpenDelay);
|
|
4098
|
+
} else {
|
|
4099
|
+
this.setSubmenuState(true);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
disableSubmenu() {
|
|
4103
|
+
window.clearTimeout(this.enableSubmenuTimer);
|
|
4104
|
+
this.setSubmenuState(false);
|
|
4105
|
+
}
|
|
4106
|
+
// Calculate the space the top of a menu takes-up, for aligning the popup menu-item with the activating element.
|
|
4107
|
+
updateSkidding() {
|
|
4108
|
+
var _a;
|
|
4109
|
+
if (!((_a = this.host.parentElement) == null ? void 0 : _a.computedStyleMap)) {
|
|
4110
|
+
return;
|
|
4111
|
+
}
|
|
4112
|
+
const styleMap = this.host.parentElement.computedStyleMap();
|
|
4113
|
+
const attrs = ["padding-top", "border-top-width", "margin-top"];
|
|
4114
|
+
const skidding = attrs.reduce((accumulator, attr) => {
|
|
4115
|
+
var _a2;
|
|
4116
|
+
const styleValue = (_a2 = styleMap.get(attr)) != null ? _a2 : new CSSUnitValue(0, "px");
|
|
4117
|
+
const unitValue = styleValue instanceof CSSUnitValue ? styleValue : new CSSUnitValue(0, "px");
|
|
4118
|
+
const pxValue = unitValue.to("px");
|
|
4119
|
+
return accumulator - pxValue.value;
|
|
4120
|
+
}, 0);
|
|
4121
|
+
this.skidding = skidding;
|
|
4122
|
+
}
|
|
4123
|
+
isExpanded() {
|
|
4124
|
+
return this.popupRef.value ? this.popupRef.value.active : false;
|
|
4125
|
+
}
|
|
4126
|
+
renderSubmenu() {
|
|
4127
|
+
const isRtl = getComputedStyle(this.host).direction === "rtl";
|
|
4128
|
+
if (!this.isConnected) {
|
|
4129
|
+
return x` <slot name="submenu" hidden></slot> `;
|
|
4130
|
+
}
|
|
4131
|
+
return x`
|
|
4132
|
+
<sl-popup
|
|
4133
|
+
${n(this.popupRef)}
|
|
4134
|
+
placement=${isRtl ? "left-start" : "right-start"}
|
|
4135
|
+
anchor="anchor"
|
|
4136
|
+
flip
|
|
4137
|
+
flip-fallback-strategy="best-fit"
|
|
4138
|
+
skidding="${this.skidding}"
|
|
4139
|
+
strategy="fixed"
|
|
4140
|
+
auto-size="vertical"
|
|
4141
|
+
auto-size-padding="10"
|
|
4142
|
+
>
|
|
4143
|
+
<slot name="submenu"></slot>
|
|
4144
|
+
</sl-popup>
|
|
4145
|
+
`;
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
|
|
4149
|
+
// src/components/spinner/spinner.styles.ts
|
|
4150
|
+
var spinner_styles_default = i$4`
|
|
4151
|
+
:host {
|
|
4152
|
+
--track-width: 2px;
|
|
4153
|
+
--track-color: rgb(128 128 128 / 25%);
|
|
4154
|
+
--indicator-color: var(--sl-color-primary-600);
|
|
4155
|
+
--speed: 2s;
|
|
4156
|
+
|
|
4157
|
+
display: inline-flex;
|
|
4158
|
+
width: 1em;
|
|
4159
|
+
height: 1em;
|
|
4160
|
+
flex: none;
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
.spinner {
|
|
4164
|
+
flex: 1 1 auto;
|
|
4165
|
+
height: 100%;
|
|
4166
|
+
width: 100%;
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
.spinner__track,
|
|
4170
|
+
.spinner__indicator {
|
|
4171
|
+
fill: none;
|
|
4172
|
+
stroke-width: var(--track-width);
|
|
4173
|
+
r: calc(0.5em - var(--track-width) / 2);
|
|
4174
|
+
cx: 0.5em;
|
|
4175
|
+
cy: 0.5em;
|
|
4176
|
+
transform-origin: 50% 50%;
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4179
|
+
.spinner__track {
|
|
4180
|
+
stroke: var(--track-color);
|
|
4181
|
+
transform-origin: 0% 0%;
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
.spinner__indicator {
|
|
4185
|
+
stroke: var(--indicator-color);
|
|
4186
|
+
stroke-linecap: round;
|
|
4187
|
+
stroke-dasharray: 150% 75%;
|
|
4188
|
+
animation: spin var(--speed) linear infinite;
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4191
|
+
@keyframes spin {
|
|
4192
|
+
0% {
|
|
4193
|
+
transform: rotate(0deg);
|
|
4194
|
+
stroke-dasharray: 0.05em, 3em;
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4197
|
+
50% {
|
|
4198
|
+
transform: rotate(450deg);
|
|
4199
|
+
stroke-dasharray: 1.375em, 1.375em;
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
100% {
|
|
4203
|
+
transform: rotate(1080deg);
|
|
4204
|
+
stroke-dasharray: 0.05em, 3em;
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
`;
|
|
4208
|
+
|
|
4209
|
+
var SlSpinner = class extends ShoelaceElement {
|
|
4210
|
+
constructor() {
|
|
4211
|
+
super(...arguments);
|
|
4212
|
+
this.localize = new LocalizeController(this);
|
|
4213
|
+
}
|
|
4214
|
+
render() {
|
|
4215
|
+
return x`
|
|
4216
|
+
<svg part="base" class="spinner" role="progressbar" aria-label=${this.localize.term("loading")}>
|
|
4217
|
+
<circle class="spinner__track"></circle>
|
|
4218
|
+
<circle class="spinner__indicator"></circle>
|
|
4219
|
+
</svg>
|
|
4220
|
+
`;
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
SlSpinner.styles = [component_styles_default, spinner_styles_default];
|
|
4224
|
+
|
|
4225
|
+
// src/internal/slot.ts
|
|
4226
|
+
var HasSlotController = class {
|
|
4227
|
+
constructor(host, ...slotNames) {
|
|
4228
|
+
this.slotNames = [];
|
|
4229
|
+
this.handleSlotChange = (event) => {
|
|
4230
|
+
const slot = event.target;
|
|
4231
|
+
if (this.slotNames.includes("[default]") && !slot.name || slot.name && this.slotNames.includes(slot.name)) {
|
|
4232
|
+
this.host.requestUpdate();
|
|
4233
|
+
}
|
|
4234
|
+
};
|
|
4235
|
+
(this.host = host).addController(this);
|
|
4236
|
+
this.slotNames = slotNames;
|
|
4237
|
+
}
|
|
4238
|
+
hasDefaultSlot() {
|
|
4239
|
+
return [...this.host.childNodes].some((node) => {
|
|
4240
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
4241
|
+
return true;
|
|
4242
|
+
}
|
|
4243
|
+
if (node.nodeType === node.ELEMENT_NODE) {
|
|
4244
|
+
const el = node;
|
|
4245
|
+
const tagName = el.tagName.toLowerCase();
|
|
4246
|
+
if (tagName === "sl-visually-hidden") {
|
|
4247
|
+
return false;
|
|
4248
|
+
}
|
|
4249
|
+
if (!el.hasAttribute("slot")) {
|
|
4250
|
+
return true;
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
return false;
|
|
4254
|
+
});
|
|
4255
|
+
}
|
|
4256
|
+
hasNamedSlot(name) {
|
|
4257
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
4258
|
+
}
|
|
4259
|
+
test(slotName) {
|
|
4260
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
4261
|
+
}
|
|
4262
|
+
hostConnected() {
|
|
4263
|
+
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
|
|
4264
|
+
}
|
|
4265
|
+
hostDisconnected() {
|
|
4266
|
+
this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
function getTextContent(slot) {
|
|
4270
|
+
if (!slot) {
|
|
4271
|
+
return "";
|
|
4272
|
+
}
|
|
4273
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
|
4274
|
+
let text = "";
|
|
4275
|
+
[...nodes].forEach((node) => {
|
|
4276
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
4277
|
+
text += node.textContent;
|
|
4278
|
+
}
|
|
4279
|
+
});
|
|
4280
|
+
return text;
|
|
4281
|
+
}
|
|
4282
|
+
|
|
4283
|
+
// src/utilities/base-path.ts
|
|
4284
|
+
var basePath = "";
|
|
4285
|
+
function setBasePath(path) {
|
|
4286
|
+
basePath = path;
|
|
4287
|
+
}
|
|
4288
|
+
function getBasePath(subpath = "") {
|
|
4289
|
+
if (!basePath) {
|
|
4290
|
+
const scripts = [...document.getElementsByTagName("script")];
|
|
4291
|
+
const configScript = scripts.find((script) => script.hasAttribute("data-shoelace"));
|
|
4292
|
+
if (configScript) {
|
|
4293
|
+
setBasePath(configScript.getAttribute("data-shoelace"));
|
|
4294
|
+
} else {
|
|
4295
|
+
const fallbackScript = scripts.find((s) => {
|
|
4296
|
+
return /shoelace(\.min)?\.js($|\?)/.test(s.src) || /shoelace-autoloader(\.min)?\.js($|\?)/.test(s.src);
|
|
4297
|
+
});
|
|
4298
|
+
let path = "";
|
|
4299
|
+
if (fallbackScript) {
|
|
4300
|
+
path = fallbackScript.getAttribute("src");
|
|
4301
|
+
}
|
|
4302
|
+
setBasePath(path.split("/").slice(0, -1).join("/"));
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
return basePath.replace(/\/$/, "") + (subpath ? `/${subpath.replace(/^\//, "")}` : ``);
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
// src/components/icon/library.default.ts
|
|
4309
|
+
var library = {
|
|
4310
|
+
name: "default",
|
|
4311
|
+
resolver: (name) => getBasePath(`assets/icons/${name}.svg`)
|
|
4312
|
+
};
|
|
4313
|
+
var library_default_default = library;
|
|
4314
|
+
|
|
4315
|
+
// src/components/icon/library.system.ts
|
|
4316
|
+
var icons = {
|
|
4317
|
+
caret: `
|
|
4318
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
4319
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
4320
|
+
</svg>
|
|
4321
|
+
`,
|
|
4322
|
+
check: `
|
|
4323
|
+
<svg part="checked-icon" class="checkbox__icon" viewBox="0 0 16 16">
|
|
4324
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
|
|
4325
|
+
<g stroke="currentColor">
|
|
4326
|
+
<g transform="translate(3.428571, 3.428571)">
|
|
4327
|
+
<path d="M0,5.71428571 L3.42857143,9.14285714"></path>
|
|
4328
|
+
<path d="M9.14285714,0 L3.42857143,9.14285714"></path>
|
|
4329
|
+
</g>
|
|
4330
|
+
</g>
|
|
4331
|
+
</g>
|
|
4332
|
+
</svg>
|
|
4333
|
+
`,
|
|
4334
|
+
"chevron-down": `
|
|
4335
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">
|
|
4336
|
+
<path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>
|
|
4337
|
+
</svg>
|
|
4338
|
+
`,
|
|
4339
|
+
"chevron-left": `
|
|
4340
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16">
|
|
4341
|
+
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
|
|
4342
|
+
</svg>
|
|
4343
|
+
`,
|
|
4344
|
+
"chevron-right": `
|
|
4345
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-right" viewBox="0 0 16 16">
|
|
4346
|
+
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
|
|
4347
|
+
</svg>
|
|
4348
|
+
`,
|
|
4349
|
+
copy: `
|
|
4350
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-copy" viewBox="0 0 16 16">
|
|
4351
|
+
<path fill-rule="evenodd" d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V2Zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H6ZM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1H2Z"/>
|
|
4352
|
+
</svg>
|
|
4353
|
+
`,
|
|
4354
|
+
eye: `
|
|
4355
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
|
|
4356
|
+
<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
|
|
4357
|
+
<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
|
|
4358
|
+
</svg>
|
|
4359
|
+
`,
|
|
4360
|
+
"eye-slash": `
|
|
4361
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-slash" viewBox="0 0 16 16">
|
|
4362
|
+
<path d="M13.359 11.238C15.06 9.72 16 8 16 8s-3-5.5-8-5.5a7.028 7.028 0 0 0-2.79.588l.77.771A5.944 5.944 0 0 1 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.134 13.134 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755-.165.165-.337.328-.517.486l.708.709z"/>
|
|
4363
|
+
<path d="M11.297 9.176a3.5 3.5 0 0 0-4.474-4.474l.823.823a2.5 2.5 0 0 1 2.829 2.829l.822.822zm-2.943 1.299.822.822a3.5 3.5 0 0 1-4.474-4.474l.823.823a2.5 2.5 0 0 0 2.829 2.829z"/>
|
|
4364
|
+
<path d="M3.35 5.47c-.18.16-.353.322-.518.487A13.134 13.134 0 0 0 1.172 8l.195.288c.335.48.83 1.12 1.465 1.755C4.121 11.332 5.881 12.5 8 12.5c.716 0 1.39-.133 2.02-.36l.77.772A7.029 7.029 0 0 1 8 13.5C3 13.5 0 8 0 8s.939-1.721 2.641-3.238l.708.709zm10.296 8.884-12-12 .708-.708 12 12-.708.708z"/>
|
|
4365
|
+
</svg>
|
|
4366
|
+
`,
|
|
4367
|
+
eyedropper: `
|
|
4368
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eyedropper" viewBox="0 0 16 16">
|
|
4369
|
+
<path d="M13.354.646a1.207 1.207 0 0 0-1.708 0L8.5 3.793l-.646-.647a.5.5 0 1 0-.708.708L8.293 5l-7.147 7.146A.5.5 0 0 0 1 12.5v1.793l-.854.853a.5.5 0 1 0 .708.707L1.707 15H3.5a.5.5 0 0 0 .354-.146L11 7.707l1.146 1.147a.5.5 0 0 0 .708-.708l-.647-.646 3.147-3.146a1.207 1.207 0 0 0 0-1.708l-2-2zM2 12.707l7-7L10.293 7l-7 7H2v-1.293z"></path>
|
|
4370
|
+
</svg>
|
|
4371
|
+
`,
|
|
4372
|
+
"grip-vertical": `
|
|
4373
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-grip-vertical" viewBox="0 0 16 16">
|
|
4374
|
+
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"></path>
|
|
4375
|
+
</svg>
|
|
4376
|
+
`,
|
|
4377
|
+
indeterminate: `
|
|
4378
|
+
<svg part="indeterminate-icon" class="checkbox__icon" viewBox="0 0 16 16">
|
|
4379
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
|
|
4380
|
+
<g stroke="currentColor" stroke-width="2">
|
|
4381
|
+
<g transform="translate(2.285714, 6.857143)">
|
|
4382
|
+
<path d="M10.2857143,1.14285714 L1.14285714,1.14285714"></path>
|
|
4383
|
+
</g>
|
|
4384
|
+
</g>
|
|
4385
|
+
</g>
|
|
4386
|
+
</svg>
|
|
4387
|
+
`,
|
|
4388
|
+
"person-fill": `
|
|
4389
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-fill" viewBox="0 0 16 16">
|
|
4390
|
+
<path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
|
|
4391
|
+
</svg>
|
|
4392
|
+
`,
|
|
4393
|
+
"play-fill": `
|
|
4394
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-fill" viewBox="0 0 16 16">
|
|
4395
|
+
<path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"></path>
|
|
4396
|
+
</svg>
|
|
4397
|
+
`,
|
|
4398
|
+
"pause-fill": `
|
|
4399
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pause-fill" viewBox="0 0 16 16">
|
|
4400
|
+
<path d="M5.5 3.5A1.5 1.5 0 0 1 7 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5zm5 0A1.5 1.5 0 0 1 12 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5z"></path>
|
|
4401
|
+
</svg>
|
|
4402
|
+
`,
|
|
4403
|
+
radio: `
|
|
4404
|
+
<svg part="checked-icon" class="radio__icon" viewBox="0 0 16 16">
|
|
4405
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
4406
|
+
<g fill="currentColor">
|
|
4407
|
+
<circle cx="8" cy="8" r="3.42857143"></circle>
|
|
4408
|
+
</g>
|
|
4409
|
+
</g>
|
|
4410
|
+
</svg>
|
|
4411
|
+
`,
|
|
4412
|
+
"star-fill": `
|
|
4413
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
|
|
4414
|
+
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
|
|
4415
|
+
</svg>
|
|
4416
|
+
`,
|
|
4417
|
+
"x-lg": `
|
|
4418
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
|
|
4419
|
+
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>
|
|
4420
|
+
</svg>
|
|
4421
|
+
`,
|
|
4422
|
+
"x-circle-fill": `
|
|
4423
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle-fill" viewBox="0 0 16 16">
|
|
4424
|
+
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"></path>
|
|
4425
|
+
</svg>
|
|
4426
|
+
`
|
|
4427
|
+
};
|
|
4428
|
+
var systemLibrary = {
|
|
4429
|
+
name: "system",
|
|
4430
|
+
resolver: (name) => {
|
|
4431
|
+
if (name in icons) {
|
|
4432
|
+
return `data:image/svg+xml,${encodeURIComponent(icons[name])}`;
|
|
4433
|
+
}
|
|
4434
|
+
return "";
|
|
4435
|
+
}
|
|
4436
|
+
};
|
|
4437
|
+
var library_system_default = systemLibrary;
|
|
4438
|
+
|
|
4439
|
+
// src/components/icon/library.ts
|
|
4440
|
+
var registry = [library_default_default, library_system_default];
|
|
4441
|
+
var watchedIcons = [];
|
|
4442
|
+
function watchIcon(icon) {
|
|
4443
|
+
watchedIcons.push(icon);
|
|
4444
|
+
}
|
|
4445
|
+
function unwatchIcon(icon) {
|
|
4446
|
+
watchedIcons = watchedIcons.filter((el) => el !== icon);
|
|
4447
|
+
}
|
|
4448
|
+
function getIconLibrary(name) {
|
|
4449
|
+
return registry.find((lib) => lib.name === name);
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
// src/components/icon/icon.styles.ts
|
|
4453
|
+
var icon_styles_default = i$4`
|
|
4454
|
+
:host {
|
|
4455
|
+
display: inline-block;
|
|
4456
|
+
width: 1em;
|
|
4457
|
+
height: 1em;
|
|
4458
|
+
box-sizing: content-box !important;
|
|
4459
|
+
}
|
|
4460
|
+
|
|
4461
|
+
svg {
|
|
4462
|
+
display: block;
|
|
4463
|
+
height: 100%;
|
|
4464
|
+
width: 100%;
|
|
4465
|
+
}
|
|
4466
|
+
`;
|
|
4467
|
+
|
|
4468
|
+
var CACHEABLE_ERROR = Symbol();
|
|
4469
|
+
var RETRYABLE_ERROR = Symbol();
|
|
4470
|
+
var parser;
|
|
4471
|
+
var iconCache = /* @__PURE__ */ new Map();
|
|
4472
|
+
var SlIcon = class extends ShoelaceElement {
|
|
4473
|
+
constructor() {
|
|
4474
|
+
super(...arguments);
|
|
4475
|
+
this.initialRender = false;
|
|
4476
|
+
this.svg = null;
|
|
4477
|
+
this.label = "";
|
|
4478
|
+
this.library = "default";
|
|
4479
|
+
}
|
|
4480
|
+
/** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */
|
|
4481
|
+
async resolveIcon(url, library) {
|
|
4482
|
+
var _a;
|
|
4483
|
+
let fileData;
|
|
4484
|
+
if (library == null ? void 0 : library.spriteSheet) {
|
|
4485
|
+
this.svg = x`<svg part="svg">
|
|
4486
|
+
<use part="use" href="${url}"></use>
|
|
4487
|
+
</svg>`;
|
|
4488
|
+
return this.svg;
|
|
4489
|
+
}
|
|
4490
|
+
try {
|
|
4491
|
+
fileData = await fetch(url, { mode: "cors" });
|
|
4492
|
+
if (!fileData.ok) return fileData.status === 410 ? CACHEABLE_ERROR : RETRYABLE_ERROR;
|
|
4493
|
+
} catch (e) {
|
|
4494
|
+
return RETRYABLE_ERROR;
|
|
4495
|
+
}
|
|
4496
|
+
try {
|
|
4497
|
+
const div = document.createElement("div");
|
|
4498
|
+
div.innerHTML = await fileData.text();
|
|
4499
|
+
const svg = div.firstElementChild;
|
|
4500
|
+
if (((_a = svg == null ? void 0 : svg.tagName) == null ? void 0 : _a.toLowerCase()) !== "svg") return CACHEABLE_ERROR;
|
|
4501
|
+
if (!parser) parser = new DOMParser();
|
|
4502
|
+
const doc = parser.parseFromString(svg.outerHTML, "text/html");
|
|
4503
|
+
const svgEl = doc.body.querySelector("svg");
|
|
4504
|
+
if (!svgEl) return CACHEABLE_ERROR;
|
|
4505
|
+
svgEl.part.add("svg");
|
|
4506
|
+
return document.adoptNode(svgEl);
|
|
4507
|
+
} catch (e) {
|
|
4508
|
+
return CACHEABLE_ERROR;
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
connectedCallback() {
|
|
4512
|
+
super.connectedCallback();
|
|
4513
|
+
watchIcon(this);
|
|
4514
|
+
}
|
|
4515
|
+
firstUpdated() {
|
|
4516
|
+
this.initialRender = true;
|
|
4517
|
+
this.setIcon();
|
|
4518
|
+
}
|
|
4519
|
+
disconnectedCallback() {
|
|
4520
|
+
super.disconnectedCallback();
|
|
4521
|
+
unwatchIcon(this);
|
|
4522
|
+
}
|
|
4523
|
+
getIconSource() {
|
|
4524
|
+
const library = getIconLibrary(this.library);
|
|
4525
|
+
if (this.name && library) {
|
|
4526
|
+
return {
|
|
4527
|
+
url: library.resolver(this.name),
|
|
4528
|
+
fromLibrary: true
|
|
4529
|
+
};
|
|
4530
|
+
}
|
|
4531
|
+
return {
|
|
4532
|
+
url: this.src,
|
|
4533
|
+
fromLibrary: false
|
|
4534
|
+
};
|
|
4535
|
+
}
|
|
4536
|
+
handleLabelChange() {
|
|
4537
|
+
const hasLabel = typeof this.label === "string" && this.label.length > 0;
|
|
4538
|
+
if (hasLabel) {
|
|
4539
|
+
this.setAttribute("role", "img");
|
|
4540
|
+
this.setAttribute("aria-label", this.label);
|
|
4541
|
+
this.removeAttribute("aria-hidden");
|
|
4542
|
+
} else {
|
|
4543
|
+
this.removeAttribute("role");
|
|
4544
|
+
this.removeAttribute("aria-label");
|
|
4545
|
+
this.setAttribute("aria-hidden", "true");
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
async setIcon() {
|
|
4549
|
+
var _a;
|
|
4550
|
+
const { url, fromLibrary } = this.getIconSource();
|
|
4551
|
+
const library = fromLibrary ? getIconLibrary(this.library) : void 0;
|
|
4552
|
+
if (!url) {
|
|
4553
|
+
this.svg = null;
|
|
4554
|
+
return;
|
|
4555
|
+
}
|
|
4556
|
+
let iconResolver = iconCache.get(url);
|
|
4557
|
+
if (!iconResolver) {
|
|
4558
|
+
iconResolver = this.resolveIcon(url, library);
|
|
4559
|
+
iconCache.set(url, iconResolver);
|
|
4560
|
+
}
|
|
4561
|
+
if (!this.initialRender) {
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4564
|
+
const svg = await iconResolver;
|
|
4565
|
+
if (svg === RETRYABLE_ERROR) {
|
|
4566
|
+
iconCache.delete(url);
|
|
4567
|
+
}
|
|
4568
|
+
if (url !== this.getIconSource().url) {
|
|
4569
|
+
return;
|
|
4570
|
+
}
|
|
4571
|
+
if (e$1(svg)) {
|
|
4572
|
+
this.svg = svg;
|
|
4573
|
+
if (library) {
|
|
4574
|
+
await this.updateComplete;
|
|
4575
|
+
const shadowSVG = this.shadowRoot.querySelector("[part='svg']");
|
|
4576
|
+
if (typeof library.mutator === "function" && shadowSVG) {
|
|
4577
|
+
library.mutator(shadowSVG);
|
|
4578
|
+
}
|
|
4579
|
+
}
|
|
4580
|
+
return;
|
|
4581
|
+
}
|
|
4582
|
+
switch (svg) {
|
|
4583
|
+
case RETRYABLE_ERROR:
|
|
4584
|
+
case CACHEABLE_ERROR:
|
|
4585
|
+
this.svg = null;
|
|
4586
|
+
this.emit("sl-error");
|
|
4587
|
+
break;
|
|
4588
|
+
default:
|
|
4589
|
+
this.svg = svg.cloneNode(true);
|
|
4590
|
+
(_a = library == null ? void 0 : library.mutator) == null ? void 0 : _a.call(library, this.svg);
|
|
4591
|
+
this.emit("sl-load");
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
render() {
|
|
4595
|
+
return this.svg;
|
|
4596
|
+
}
|
|
4597
|
+
};
|
|
4598
|
+
SlIcon.styles = [component_styles_default, icon_styles_default];
|
|
4599
|
+
__decorateClass([
|
|
4600
|
+
r$1()
|
|
4601
|
+
], SlIcon.prototype, "svg", 2);
|
|
4602
|
+
__decorateClass([
|
|
4603
|
+
n$2({ reflect: true })
|
|
4604
|
+
], SlIcon.prototype, "name", 2);
|
|
4605
|
+
__decorateClass([
|
|
4606
|
+
n$2()
|
|
4607
|
+
], SlIcon.prototype, "src", 2);
|
|
4608
|
+
__decorateClass([
|
|
4609
|
+
n$2()
|
|
4610
|
+
], SlIcon.prototype, "label", 2);
|
|
4611
|
+
__decorateClass([
|
|
4612
|
+
n$2({ reflect: true })
|
|
4613
|
+
], SlIcon.prototype, "library", 2);
|
|
4614
|
+
__decorateClass([
|
|
4615
|
+
watch("label")
|
|
4616
|
+
], SlIcon.prototype, "handleLabelChange", 1);
|
|
4617
|
+
__decorateClass([
|
|
4618
|
+
watch(["name", "src", "library"])
|
|
4619
|
+
], SlIcon.prototype, "setIcon", 1);
|
|
4620
|
+
|
|
4621
|
+
var SlMenuItem = class extends ShoelaceElement {
|
|
4622
|
+
constructor() {
|
|
4623
|
+
super(...arguments);
|
|
4624
|
+
this.localize = new LocalizeController(this);
|
|
4625
|
+
this.type = "normal";
|
|
4626
|
+
this.checked = false;
|
|
4627
|
+
this.value = "";
|
|
4628
|
+
this.loading = false;
|
|
4629
|
+
this.disabled = false;
|
|
4630
|
+
this.hasSlotController = new HasSlotController(this, "submenu");
|
|
4631
|
+
this.submenuController = new SubmenuController(this, this.hasSlotController);
|
|
4632
|
+
this.handleHostClick = (event) => {
|
|
4633
|
+
if (this.disabled) {
|
|
4634
|
+
event.preventDefault();
|
|
4635
|
+
event.stopImmediatePropagation();
|
|
4636
|
+
}
|
|
4637
|
+
};
|
|
4638
|
+
this.handleMouseOver = (event) => {
|
|
4639
|
+
this.focus();
|
|
4640
|
+
event.stopPropagation();
|
|
4641
|
+
};
|
|
4642
|
+
}
|
|
4643
|
+
connectedCallback() {
|
|
4644
|
+
super.connectedCallback();
|
|
4645
|
+
this.addEventListener("click", this.handleHostClick);
|
|
4646
|
+
this.addEventListener("mouseover", this.handleMouseOver);
|
|
4647
|
+
}
|
|
4648
|
+
disconnectedCallback() {
|
|
4649
|
+
super.disconnectedCallback();
|
|
4650
|
+
this.removeEventListener("click", this.handleHostClick);
|
|
4651
|
+
this.removeEventListener("mouseover", this.handleMouseOver);
|
|
4652
|
+
}
|
|
4653
|
+
handleDefaultSlotChange() {
|
|
4654
|
+
const textLabel = this.getTextLabel();
|
|
4655
|
+
if (typeof this.cachedTextLabel === "undefined") {
|
|
4656
|
+
this.cachedTextLabel = textLabel;
|
|
4657
|
+
return;
|
|
4658
|
+
}
|
|
4659
|
+
if (textLabel !== this.cachedTextLabel) {
|
|
4660
|
+
this.cachedTextLabel = textLabel;
|
|
4661
|
+
this.emit("slotchange", { bubbles: true, composed: false, cancelable: false });
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
handleCheckedChange() {
|
|
4665
|
+
if (this.checked && this.type !== "checkbox") {
|
|
4666
|
+
this.checked = false;
|
|
4667
|
+
console.error('The checked attribute can only be used on menu items with type="checkbox"', this);
|
|
4668
|
+
return;
|
|
4669
|
+
}
|
|
4670
|
+
if (this.type === "checkbox") {
|
|
4671
|
+
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
4672
|
+
} else {
|
|
4673
|
+
this.removeAttribute("aria-checked");
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
handleDisabledChange() {
|
|
4677
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
4678
|
+
}
|
|
4679
|
+
handleTypeChange() {
|
|
4680
|
+
if (this.type === "checkbox") {
|
|
4681
|
+
this.setAttribute("role", "menuitemcheckbox");
|
|
4682
|
+
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
4683
|
+
} else {
|
|
4684
|
+
this.setAttribute("role", "menuitem");
|
|
4685
|
+
this.removeAttribute("aria-checked");
|
|
4686
|
+
}
|
|
4687
|
+
}
|
|
4688
|
+
/** Returns a text label based on the contents of the menu item's default slot. */
|
|
4689
|
+
getTextLabel() {
|
|
4690
|
+
return getTextContent(this.defaultSlot);
|
|
4691
|
+
}
|
|
4692
|
+
isSubmenu() {
|
|
4693
|
+
return this.hasSlotController.test("submenu");
|
|
4694
|
+
}
|
|
4695
|
+
render() {
|
|
4696
|
+
const isRtl = this.localize.dir() === "rtl";
|
|
4697
|
+
const isSubmenuExpanded = this.submenuController.isExpanded();
|
|
4698
|
+
return x`
|
|
4699
|
+
<div
|
|
4700
|
+
id="anchor"
|
|
4701
|
+
part="base"
|
|
4702
|
+
class=${e$2({
|
|
4703
|
+
"menu-item": true,
|
|
4704
|
+
"menu-item--rtl": isRtl,
|
|
4705
|
+
"menu-item--checked": this.checked,
|
|
4706
|
+
"menu-item--disabled": this.disabled,
|
|
4707
|
+
"menu-item--loading": this.loading,
|
|
4708
|
+
"menu-item--has-submenu": this.isSubmenu(),
|
|
4709
|
+
"menu-item--submenu-expanded": isSubmenuExpanded
|
|
4710
|
+
})}
|
|
4711
|
+
?aria-haspopup="${this.isSubmenu()}"
|
|
4712
|
+
?aria-expanded="${isSubmenuExpanded ? true : false}"
|
|
4713
|
+
>
|
|
4714
|
+
<span part="checked-icon" class="menu-item__check">
|
|
4715
|
+
<sl-icon name="check" library="system" aria-hidden="true"></sl-icon>
|
|
4716
|
+
</span>
|
|
4717
|
+
|
|
4718
|
+
<slot name="prefix" part="prefix" class="menu-item__prefix"></slot>
|
|
4719
|
+
|
|
4720
|
+
<slot part="label" class="menu-item__label" @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
4721
|
+
|
|
4722
|
+
<slot name="suffix" part="suffix" class="menu-item__suffix"></slot>
|
|
4723
|
+
|
|
4724
|
+
<span part="submenu-icon" class="menu-item__chevron">
|
|
4725
|
+
<sl-icon name=${isRtl ? "chevron-left" : "chevron-right"} library="system" aria-hidden="true"></sl-icon>
|
|
4726
|
+
</span>
|
|
4727
|
+
|
|
4728
|
+
${this.submenuController.renderSubmenu()}
|
|
4729
|
+
${this.loading ? x` <sl-spinner part="spinner" exportparts="base:spinner__base"></sl-spinner> ` : ""}
|
|
4730
|
+
</div>
|
|
4731
|
+
`;
|
|
4732
|
+
}
|
|
4733
|
+
};
|
|
4734
|
+
SlMenuItem.styles = [component_styles_default, menu_item_styles_default];
|
|
4735
|
+
SlMenuItem.dependencies = {
|
|
4736
|
+
"sl-icon": SlIcon,
|
|
4737
|
+
"sl-popup": SlPopup,
|
|
4738
|
+
"sl-spinner": SlSpinner
|
|
4739
|
+
};
|
|
4740
|
+
__decorateClass([
|
|
4741
|
+
e$4("slot:not([name])")
|
|
4742
|
+
], SlMenuItem.prototype, "defaultSlot", 2);
|
|
4743
|
+
__decorateClass([
|
|
4744
|
+
e$4(".menu-item")
|
|
4745
|
+
], SlMenuItem.prototype, "menuItem", 2);
|
|
4746
|
+
__decorateClass([
|
|
4747
|
+
n$2()
|
|
4748
|
+
], SlMenuItem.prototype, "type", 2);
|
|
4749
|
+
__decorateClass([
|
|
4750
|
+
n$2({ type: Boolean, reflect: true })
|
|
4751
|
+
], SlMenuItem.prototype, "checked", 2);
|
|
4752
|
+
__decorateClass([
|
|
4753
|
+
n$2()
|
|
4754
|
+
], SlMenuItem.prototype, "value", 2);
|
|
4755
|
+
__decorateClass([
|
|
4756
|
+
n$2({ type: Boolean, reflect: true })
|
|
4757
|
+
], SlMenuItem.prototype, "loading", 2);
|
|
4758
|
+
__decorateClass([
|
|
4759
|
+
n$2({ type: Boolean, reflect: true })
|
|
4760
|
+
], SlMenuItem.prototype, "disabled", 2);
|
|
4761
|
+
__decorateClass([
|
|
4762
|
+
watch("checked")
|
|
4763
|
+
], SlMenuItem.prototype, "handleCheckedChange", 1);
|
|
4764
|
+
__decorateClass([
|
|
4765
|
+
watch("disabled")
|
|
4766
|
+
], SlMenuItem.prototype, "handleDisabledChange", 1);
|
|
4767
|
+
__decorateClass([
|
|
4768
|
+
watch("type")
|
|
4769
|
+
], SlMenuItem.prototype, "handleTypeChange", 1);
|
|
4770
|
+
|
|
4771
|
+
SlMenuItem.define("sl-menu-item");
|
|
4772
|
+
|
|
4773
|
+
export { SlIcon as S, __decorateClass as _, ShoelaceElement as a, component_styles_default as c, e$2 as e, i$4 as i, n$2 as n, r$1 as r, watch as w, x };
|
|
4774
|
+
|
|
4775
|
+
//# sourceMappingURL=chunk.HVTXQL7M.js.map
|