@aurodesignsystem-dev/auro-popover 0.0.0-pr102.3 → 0.0.0-pr106.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +418 -0
- package/NOTICE +2 -0
- package/README.md +25 -59
- package/demo/api.html +63 -0
- package/demo/api.js +19 -0
- package/demo/api.md +63 -2
- package/demo/api.min.js +19 -383
- package/demo/auro-popover.min.js +2177 -0
- package/demo/index.html +57 -0
- package/demo/index.js +4 -0
- package/demo/index.md +1 -1
- package/demo/index.min.js +2 -386
- package/dist/auro-popover-CqCc1tbB.js +13 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1 -0
- package/dist/registered.js +1 -0
- package/package.json +41 -129
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/dist/auro-popover.d.ts +0 -80
- package/dist/auro-popover.d.ts.map +0 -1
- package/dist/auro-popover__bundled.js +0 -385
- package/dist/color-css.d.ts +0 -3
- package/dist/color-css.d.ts.map +0 -1
- package/dist/layoverVersion.d.ts +0 -3
- package/dist/layoverVersion.d.ts.map +0 -1
- package/dist/style-css.d.ts +0 -3
- package/dist/style-css.d.ts.map +0 -1
- package/dist/tokens-css.d.ts +0 -3
- package/dist/tokens-css.d.ts.map +0 -1
- package/index.js +0 -3
- package/packageScripts/postinstall.mjs +0 -28
- package/src/auro-popover.js +0 -165
- package/src/color-css.js +0 -2
- package/src/layoverVersion.js +0 -1
- package/src/style-css.js +0 -2
- package/src/tokens-css.js +0 -2
|
@@ -0,0 +1,2177 @@
|
|
|
1
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
7
|
+
|
|
8
|
+
class AuroLibraryRuntimeUtils {
|
|
9
|
+
|
|
10
|
+
/* eslint-disable jsdoc/require-param */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This will register a new custom element with the browser.
|
|
14
|
+
* @param {String} name - The name of the custom element.
|
|
15
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
registerComponent(name, componentClass) {
|
|
19
|
+
if (!customElements.get(name)) {
|
|
20
|
+
customElements.define(name, class extends componentClass {});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
closestElement(
|
|
29
|
+
selector, // selector like in .closest()
|
|
30
|
+
base = this, // extra functionality to skip a parent
|
|
31
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
32
|
+
!el || el === document || el === window
|
|
33
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
34
|
+
: found
|
|
35
|
+
? found // found a selector INside this element
|
|
36
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
37
|
+
) {
|
|
38
|
+
return __Closest(base);
|
|
39
|
+
}
|
|
40
|
+
/* eslint-enable jsdoc/require-param */
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
44
|
+
* @param {Object} elem - The element to check.
|
|
45
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
handleComponentTagRename(elem, tagName) {
|
|
49
|
+
const tag = tagName.toLowerCase();
|
|
50
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
51
|
+
|
|
52
|
+
if (elemTag !== tag) {
|
|
53
|
+
elem.setAttribute(tag, true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Validates if an element is a specific Auro component.
|
|
59
|
+
* @param {Object} elem - The element to validate.
|
|
60
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
61
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
62
|
+
*/
|
|
63
|
+
elementMatch(elem, tagName) {
|
|
64
|
+
const tag = tagName.toLowerCase();
|
|
65
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
66
|
+
|
|
67
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @license
|
|
73
|
+
* Copyright 2019 Google LLC
|
|
74
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
75
|
+
*/
|
|
76
|
+
const t$1=globalThis,e$2=t$1.ShadowRoot&&(void 0===t$1.ShadyCSS||t$1.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$3=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$2)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$2&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$3.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$3.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$2("string"==typeof t?t:t+"",void 0,s$2),i$3=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(true===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$2(o,t,s$2)},S$1=(s,o)=>{if(e$2)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$1.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$2?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @license
|
|
80
|
+
* Copyright 2017 Google LLC
|
|
81
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
82
|
+
*/const{is:i$2,defineProperty:e$1,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$2,getPrototypeOf:n$1}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$2(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$1(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$1(t),...o$2(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$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");
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @license
|
|
86
|
+
* Copyright 2017 Google LLC
|
|
87
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
88
|
+
*/
|
|
89
|
+
const t=globalThis,i$1=t.trustedTypes,s$1=i$1?i$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$1="?"+h,n=`<${o$1}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,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.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$1?i$1.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");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};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @license
|
|
93
|
+
* Copyright 2017 Google LLC
|
|
94
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
95
|
+
*/const s=globalThis;class i 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(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}}i._$litElement$=true,i["finalized"]=true,s.litElementHydrateSupport?.({LitElement:i});const o=s.litElementPolyfillSupport;o?.({LitElement:i});(s.litElementVersions??=[]).push("4.2.1");
|
|
96
|
+
|
|
97
|
+
var top = 'top';
|
|
98
|
+
var bottom = 'bottom';
|
|
99
|
+
var right = 'right';
|
|
100
|
+
var left = 'left';
|
|
101
|
+
var auto = 'auto';
|
|
102
|
+
var basePlacements = [top, bottom, right, left];
|
|
103
|
+
var start = 'start';
|
|
104
|
+
var end = 'end';
|
|
105
|
+
var clippingParents = 'clippingParents';
|
|
106
|
+
var viewport = 'viewport';
|
|
107
|
+
var popper = 'popper';
|
|
108
|
+
var reference = 'reference';
|
|
109
|
+
var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
|
|
110
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|
111
|
+
}, []);
|
|
112
|
+
var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
|
113
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
114
|
+
}, []); // modifiers that need to read the DOM
|
|
115
|
+
|
|
116
|
+
var beforeRead = 'beforeRead';
|
|
117
|
+
var read = 'read';
|
|
118
|
+
var afterRead = 'afterRead'; // pure-logic modifiers
|
|
119
|
+
|
|
120
|
+
var beforeMain = 'beforeMain';
|
|
121
|
+
var main = 'main';
|
|
122
|
+
var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
|
123
|
+
|
|
124
|
+
var beforeWrite = 'beforeWrite';
|
|
125
|
+
var write = 'write';
|
|
126
|
+
var afterWrite = 'afterWrite';
|
|
127
|
+
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
128
|
+
|
|
129
|
+
function getNodeName(element) {
|
|
130
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getWindow(node) {
|
|
134
|
+
if (node == null) {
|
|
135
|
+
return window;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (node.toString() !== '[object Window]') {
|
|
139
|
+
var ownerDocument = node.ownerDocument;
|
|
140
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return node;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function isElement(node) {
|
|
147
|
+
var OwnElement = getWindow(node).Element;
|
|
148
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function isHTMLElement(node) {
|
|
152
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
153
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isShadowRoot(node) {
|
|
157
|
+
// IE 11 has no ShadowRoot
|
|
158
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
163
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// and applies them to the HTMLElements such as popper and arrow
|
|
167
|
+
|
|
168
|
+
function applyStyles(_ref) {
|
|
169
|
+
var state = _ref.state;
|
|
170
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
171
|
+
var style = state.styles[name] || {};
|
|
172
|
+
var attributes = state.attributes[name] || {};
|
|
173
|
+
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
174
|
+
|
|
175
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
176
|
+
return;
|
|
177
|
+
} // Flow doesn't support to extend this property, but it's the most
|
|
178
|
+
// effective way to apply styles to an HTMLElement
|
|
179
|
+
// $FlowFixMe[cannot-write]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
Object.assign(element.style, style);
|
|
183
|
+
Object.keys(attributes).forEach(function (name) {
|
|
184
|
+
var value = attributes[name];
|
|
185
|
+
|
|
186
|
+
if (value === false) {
|
|
187
|
+
element.removeAttribute(name);
|
|
188
|
+
} else {
|
|
189
|
+
element.setAttribute(name, value === true ? '' : value);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function effect$2(_ref2) {
|
|
196
|
+
var state = _ref2.state;
|
|
197
|
+
var initialStyles = {
|
|
198
|
+
popper: {
|
|
199
|
+
position: state.options.strategy,
|
|
200
|
+
left: '0',
|
|
201
|
+
top: '0',
|
|
202
|
+
margin: '0'
|
|
203
|
+
},
|
|
204
|
+
arrow: {
|
|
205
|
+
position: 'absolute'
|
|
206
|
+
},
|
|
207
|
+
reference: {}
|
|
208
|
+
};
|
|
209
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
210
|
+
state.styles = initialStyles;
|
|
211
|
+
|
|
212
|
+
if (state.elements.arrow) {
|
|
213
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return function () {
|
|
217
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
218
|
+
var element = state.elements[name];
|
|
219
|
+
var attributes = state.attributes[name] || {};
|
|
220
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
|
221
|
+
|
|
222
|
+
var style = styleProperties.reduce(function (style, property) {
|
|
223
|
+
style[property] = '';
|
|
224
|
+
return style;
|
|
225
|
+
}, {}); // arrow is optional + virtual elements
|
|
226
|
+
|
|
227
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
Object.assign(element.style, style);
|
|
232
|
+
Object.keys(attributes).forEach(function (attribute) {
|
|
233
|
+
element.removeAttribute(attribute);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
var applyStyles$1 = {
|
|
241
|
+
name: 'applyStyles',
|
|
242
|
+
enabled: true,
|
|
243
|
+
phase: 'write',
|
|
244
|
+
fn: applyStyles,
|
|
245
|
+
effect: effect$2,
|
|
246
|
+
requires: ['computeStyles']
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
function getBasePlacement(placement) {
|
|
250
|
+
return placement.split('-')[0];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var max = Math.max;
|
|
254
|
+
var min = Math.min;
|
|
255
|
+
var round = Math.round;
|
|
256
|
+
|
|
257
|
+
function getUAString() {
|
|
258
|
+
var uaData = navigator.userAgentData;
|
|
259
|
+
|
|
260
|
+
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
|
261
|
+
return uaData.brands.map(function (item) {
|
|
262
|
+
return item.brand + "/" + item.version;
|
|
263
|
+
}).join(' ');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return navigator.userAgent;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function isLayoutViewport() {
|
|
270
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
274
|
+
if (includeScale === void 0) {
|
|
275
|
+
includeScale = false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (isFixedStrategy === void 0) {
|
|
279
|
+
isFixedStrategy = false;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
var clientRect = element.getBoundingClientRect();
|
|
283
|
+
var scaleX = 1;
|
|
284
|
+
var scaleY = 1;
|
|
285
|
+
|
|
286
|
+
if (includeScale && isHTMLElement(element)) {
|
|
287
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
288
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
292
|
+
visualViewport = _ref.visualViewport;
|
|
293
|
+
|
|
294
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
295
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
296
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
297
|
+
var width = clientRect.width / scaleX;
|
|
298
|
+
var height = clientRect.height / scaleY;
|
|
299
|
+
return {
|
|
300
|
+
width: width,
|
|
301
|
+
height: height,
|
|
302
|
+
top: y,
|
|
303
|
+
right: x + width,
|
|
304
|
+
bottom: y + height,
|
|
305
|
+
left: x,
|
|
306
|
+
x: x,
|
|
307
|
+
y: y
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// means it doesn't take into account transforms.
|
|
312
|
+
|
|
313
|
+
function getLayoutRect(element) {
|
|
314
|
+
var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
|
|
315
|
+
// Fixes https://github.com/popperjs/popper-core/issues/1223
|
|
316
|
+
|
|
317
|
+
var width = element.offsetWidth;
|
|
318
|
+
var height = element.offsetHeight;
|
|
319
|
+
|
|
320
|
+
if (Math.abs(clientRect.width - width) <= 1) {
|
|
321
|
+
width = clientRect.width;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (Math.abs(clientRect.height - height) <= 1) {
|
|
325
|
+
height = clientRect.height;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
x: element.offsetLeft,
|
|
330
|
+
y: element.offsetTop,
|
|
331
|
+
width: width,
|
|
332
|
+
height: height
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function contains(parent, child) {
|
|
337
|
+
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
|
338
|
+
|
|
339
|
+
if (parent.contains(child)) {
|
|
340
|
+
return true;
|
|
341
|
+
} // then fallback to custom implementation with Shadow DOM support
|
|
342
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
|
343
|
+
var next = child;
|
|
344
|
+
|
|
345
|
+
do {
|
|
346
|
+
if (next && parent.isSameNode(next)) {
|
|
347
|
+
return true;
|
|
348
|
+
} // $FlowFixMe[prop-missing]: need a better way to handle this...
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
next = next.parentNode || next.host;
|
|
352
|
+
} while (next);
|
|
353
|
+
} // Give up, the result is false
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function getComputedStyle(element) {
|
|
360
|
+
return getWindow(element).getComputedStyle(element);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function isTableElement(element) {
|
|
364
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function getDocumentElement(element) {
|
|
368
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
369
|
+
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
|
|
370
|
+
element.document) || window.document).documentElement;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function getParentNode(element) {
|
|
374
|
+
if (getNodeName(element) === 'html') {
|
|
375
|
+
return element;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
379
|
+
// $FlowFixMe[incompatible-return]
|
|
380
|
+
// $FlowFixMe[prop-missing]
|
|
381
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
382
|
+
element.parentNode || ( // DOM Element detected
|
|
383
|
+
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|
384
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|
385
|
+
getDocumentElement(element) // fallback
|
|
386
|
+
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function getTrueOffsetParent(element) {
|
|
391
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
392
|
+
getComputedStyle(element).position === 'fixed') {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return element.offsetParent;
|
|
397
|
+
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
|
398
|
+
// return the containing block
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
function getContainingBlock(element) {
|
|
402
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
403
|
+
var isIE = /Trident/i.test(getUAString());
|
|
404
|
+
|
|
405
|
+
if (isIE && isHTMLElement(element)) {
|
|
406
|
+
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
407
|
+
var elementCss = getComputedStyle(element);
|
|
408
|
+
|
|
409
|
+
if (elementCss.position === 'fixed') {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
var currentNode = getParentNode(element);
|
|
415
|
+
|
|
416
|
+
if (isShadowRoot(currentNode)) {
|
|
417
|
+
currentNode = currentNode.host;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
421
|
+
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
422
|
+
// create a containing block.
|
|
423
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
424
|
+
|
|
425
|
+
if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
|
|
426
|
+
return currentNode;
|
|
427
|
+
} else {
|
|
428
|
+
currentNode = currentNode.parentNode;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return null;
|
|
433
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
434
|
+
// such as table ancestors and cross browser bugs.
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
function getOffsetParent(element) {
|
|
438
|
+
var window = getWindow(element);
|
|
439
|
+
var offsetParent = getTrueOffsetParent(element);
|
|
440
|
+
|
|
441
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
442
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
|
446
|
+
return window;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function getMainAxisFromPlacement(placement) {
|
|
453
|
+
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function within(min$1, value, max$1) {
|
|
457
|
+
return max(min$1, min(value, max$1));
|
|
458
|
+
}
|
|
459
|
+
function withinMaxClamp(min, value, max) {
|
|
460
|
+
var v = within(min, value, max);
|
|
461
|
+
return v > max ? max : v;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function getFreshSideObject() {
|
|
465
|
+
return {
|
|
466
|
+
top: 0,
|
|
467
|
+
right: 0,
|
|
468
|
+
bottom: 0,
|
|
469
|
+
left: 0
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function mergePaddingObject(paddingObject) {
|
|
474
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function expandToHashMap(value, keys) {
|
|
478
|
+
return keys.reduce(function (hashMap, key) {
|
|
479
|
+
hashMap[key] = value;
|
|
480
|
+
return hashMap;
|
|
481
|
+
}, {});
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
var toPaddingObject = function toPaddingObject(padding, state) {
|
|
485
|
+
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
|
486
|
+
placement: state.placement
|
|
487
|
+
})) : padding;
|
|
488
|
+
return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
function arrow(_ref) {
|
|
492
|
+
var _state$modifiersData$;
|
|
493
|
+
|
|
494
|
+
var state = _ref.state,
|
|
495
|
+
name = _ref.name,
|
|
496
|
+
options = _ref.options;
|
|
497
|
+
var arrowElement = state.elements.arrow;
|
|
498
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
499
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
500
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
|
501
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
502
|
+
var len = isVertical ? 'height' : 'width';
|
|
503
|
+
|
|
504
|
+
if (!arrowElement || !popperOffsets) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
|
509
|
+
var arrowRect = getLayoutRect(arrowElement);
|
|
510
|
+
var minProp = axis === 'y' ? top : left;
|
|
511
|
+
var maxProp = axis === 'y' ? bottom : right;
|
|
512
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
|
513
|
+
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
|
514
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
515
|
+
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
516
|
+
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
|
517
|
+
// outside of the popper bounds
|
|
518
|
+
|
|
519
|
+
var min = paddingObject[minProp];
|
|
520
|
+
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
521
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
522
|
+
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
|
523
|
+
|
|
524
|
+
var axisProp = axis;
|
|
525
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function effect$1(_ref2) {
|
|
529
|
+
var state = _ref2.state,
|
|
530
|
+
options = _ref2.options;
|
|
531
|
+
var _options$element = options.element,
|
|
532
|
+
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
|
533
|
+
|
|
534
|
+
if (arrowElement == null) {
|
|
535
|
+
return;
|
|
536
|
+
} // CSS selector
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
if (typeof arrowElement === 'string') {
|
|
540
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
541
|
+
|
|
542
|
+
if (!arrowElement) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
state.elements.arrow = arrowElement;
|
|
552
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
var arrow$1 = {
|
|
556
|
+
name: 'arrow',
|
|
557
|
+
enabled: true,
|
|
558
|
+
phase: 'main',
|
|
559
|
+
fn: arrow,
|
|
560
|
+
effect: effect$1,
|
|
561
|
+
requires: ['popperOffsets'],
|
|
562
|
+
requiresIfExists: ['preventOverflow']
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
function getVariation(placement) {
|
|
566
|
+
return placement.split('-')[1];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
var unsetSides = {
|
|
570
|
+
top: 'auto',
|
|
571
|
+
right: 'auto',
|
|
572
|
+
bottom: 'auto',
|
|
573
|
+
left: 'auto'
|
|
574
|
+
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
|
575
|
+
// Zooming can change the DPR, but it seems to report a value that will
|
|
576
|
+
// cleanly divide the values into the appropriate subpixels.
|
|
577
|
+
|
|
578
|
+
function roundOffsetsByDPR(_ref, win) {
|
|
579
|
+
var x = _ref.x,
|
|
580
|
+
y = _ref.y;
|
|
581
|
+
var dpr = win.devicePixelRatio || 1;
|
|
582
|
+
return {
|
|
583
|
+
x: round(x * dpr) / dpr || 0,
|
|
584
|
+
y: round(y * dpr) / dpr || 0
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function mapToStyles(_ref2) {
|
|
589
|
+
var _Object$assign2;
|
|
590
|
+
|
|
591
|
+
var popper = _ref2.popper,
|
|
592
|
+
popperRect = _ref2.popperRect,
|
|
593
|
+
placement = _ref2.placement,
|
|
594
|
+
variation = _ref2.variation,
|
|
595
|
+
offsets = _ref2.offsets,
|
|
596
|
+
position = _ref2.position,
|
|
597
|
+
gpuAcceleration = _ref2.gpuAcceleration,
|
|
598
|
+
adaptive = _ref2.adaptive,
|
|
599
|
+
roundOffsets = _ref2.roundOffsets,
|
|
600
|
+
isFixed = _ref2.isFixed;
|
|
601
|
+
var _offsets$x = offsets.x,
|
|
602
|
+
x = _offsets$x === void 0 ? 0 : _offsets$x,
|
|
603
|
+
_offsets$y = offsets.y,
|
|
604
|
+
y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
605
|
+
|
|
606
|
+
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
|
607
|
+
x: x,
|
|
608
|
+
y: y
|
|
609
|
+
}) : {
|
|
610
|
+
x: x,
|
|
611
|
+
y: y
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
x = _ref3.x;
|
|
615
|
+
y = _ref3.y;
|
|
616
|
+
var hasX = offsets.hasOwnProperty('x');
|
|
617
|
+
var hasY = offsets.hasOwnProperty('y');
|
|
618
|
+
var sideX = left;
|
|
619
|
+
var sideY = top;
|
|
620
|
+
var win = window;
|
|
621
|
+
|
|
622
|
+
if (adaptive) {
|
|
623
|
+
var offsetParent = getOffsetParent(popper);
|
|
624
|
+
var heightProp = 'clientHeight';
|
|
625
|
+
var widthProp = 'clientWidth';
|
|
626
|
+
|
|
627
|
+
if (offsetParent === getWindow(popper)) {
|
|
628
|
+
offsetParent = getDocumentElement(popper);
|
|
629
|
+
|
|
630
|
+
if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
|
|
631
|
+
heightProp = 'scrollHeight';
|
|
632
|
+
widthProp = 'scrollWidth';
|
|
633
|
+
}
|
|
634
|
+
} // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
offsetParent = offsetParent;
|
|
638
|
+
|
|
639
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
640
|
+
sideY = bottom;
|
|
641
|
+
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
|
|
642
|
+
offsetParent[heightProp];
|
|
643
|
+
y -= offsetY - popperRect.height;
|
|
644
|
+
y *= gpuAcceleration ? 1 : -1;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
648
|
+
sideX = right;
|
|
649
|
+
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
|
|
650
|
+
offsetParent[widthProp];
|
|
651
|
+
x -= offsetX - popperRect.width;
|
|
652
|
+
x *= gpuAcceleration ? 1 : -1;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
var commonStyles = Object.assign({
|
|
657
|
+
position: position
|
|
658
|
+
}, adaptive && unsetSides);
|
|
659
|
+
|
|
660
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
661
|
+
x: x,
|
|
662
|
+
y: y
|
|
663
|
+
}, getWindow(popper)) : {
|
|
664
|
+
x: x,
|
|
665
|
+
y: y
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
x = _ref4.x;
|
|
669
|
+
y = _ref4.y;
|
|
670
|
+
|
|
671
|
+
if (gpuAcceleration) {
|
|
672
|
+
var _Object$assign;
|
|
673
|
+
|
|
674
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function computeStyles(_ref5) {
|
|
681
|
+
var state = _ref5.state,
|
|
682
|
+
options = _ref5.options;
|
|
683
|
+
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
684
|
+
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
685
|
+
_options$adaptive = options.adaptive,
|
|
686
|
+
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
|
687
|
+
_options$roundOffsets = options.roundOffsets,
|
|
688
|
+
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
689
|
+
var commonStyles = {
|
|
690
|
+
placement: getBasePlacement(state.placement),
|
|
691
|
+
variation: getVariation(state.placement),
|
|
692
|
+
popper: state.elements.popper,
|
|
693
|
+
popperRect: state.rects.popper,
|
|
694
|
+
gpuAcceleration: gpuAcceleration,
|
|
695
|
+
isFixed: state.options.strategy === 'fixed'
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
699
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|
700
|
+
offsets: state.modifiersData.popperOffsets,
|
|
701
|
+
position: state.options.strategy,
|
|
702
|
+
adaptive: adaptive,
|
|
703
|
+
roundOffsets: roundOffsets
|
|
704
|
+
})));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (state.modifiersData.arrow != null) {
|
|
708
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|
709
|
+
offsets: state.modifiersData.arrow,
|
|
710
|
+
position: 'absolute',
|
|
711
|
+
adaptive: false,
|
|
712
|
+
roundOffsets: roundOffsets
|
|
713
|
+
})));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
717
|
+
'data-popper-placement': state.placement
|
|
718
|
+
});
|
|
719
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
var computeStyles$1 = {
|
|
723
|
+
name: 'computeStyles',
|
|
724
|
+
enabled: true,
|
|
725
|
+
phase: 'beforeWrite',
|
|
726
|
+
fn: computeStyles,
|
|
727
|
+
data: {}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
var passive = {
|
|
731
|
+
passive: true
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
function effect(_ref) {
|
|
735
|
+
var state = _ref.state,
|
|
736
|
+
instance = _ref.instance,
|
|
737
|
+
options = _ref.options;
|
|
738
|
+
var _options$scroll = options.scroll,
|
|
739
|
+
scroll = _options$scroll === void 0 ? true : _options$scroll,
|
|
740
|
+
_options$resize = options.resize,
|
|
741
|
+
resize = _options$resize === void 0 ? true : _options$resize;
|
|
742
|
+
var window = getWindow(state.elements.popper);
|
|
743
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
744
|
+
|
|
745
|
+
if (scroll) {
|
|
746
|
+
scrollParents.forEach(function (scrollParent) {
|
|
747
|
+
scrollParent.addEventListener('scroll', instance.update, passive);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (resize) {
|
|
752
|
+
window.addEventListener('resize', instance.update, passive);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return function () {
|
|
756
|
+
if (scroll) {
|
|
757
|
+
scrollParents.forEach(function (scrollParent) {
|
|
758
|
+
scrollParent.removeEventListener('scroll', instance.update, passive);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (resize) {
|
|
763
|
+
window.removeEventListener('resize', instance.update, passive);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
var eventListeners = {
|
|
770
|
+
name: 'eventListeners',
|
|
771
|
+
enabled: true,
|
|
772
|
+
phase: 'write',
|
|
773
|
+
fn: function fn() {},
|
|
774
|
+
effect: effect,
|
|
775
|
+
data: {}
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
var hash$1 = {
|
|
779
|
+
left: 'right',
|
|
780
|
+
right: 'left',
|
|
781
|
+
bottom: 'top',
|
|
782
|
+
top: 'bottom'
|
|
783
|
+
};
|
|
784
|
+
function getOppositePlacement(placement) {
|
|
785
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
786
|
+
return hash$1[matched];
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
var hash = {
|
|
791
|
+
start: 'end',
|
|
792
|
+
end: 'start'
|
|
793
|
+
};
|
|
794
|
+
function getOppositeVariationPlacement(placement) {
|
|
795
|
+
return placement.replace(/start|end/g, function (matched) {
|
|
796
|
+
return hash[matched];
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function getWindowScroll(node) {
|
|
801
|
+
var win = getWindow(node);
|
|
802
|
+
var scrollLeft = win.pageXOffset;
|
|
803
|
+
var scrollTop = win.pageYOffset;
|
|
804
|
+
return {
|
|
805
|
+
scrollLeft: scrollLeft,
|
|
806
|
+
scrollTop: scrollTop
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function getWindowScrollBarX(element) {
|
|
811
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
812
|
+
// incorrect for RTL.
|
|
813
|
+
// Popper 1 is broken in this case and never had a bug report so let's assume
|
|
814
|
+
// it's not an issue. I don't think anyone ever specifies width on <html>
|
|
815
|
+
// anyway.
|
|
816
|
+
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
|
817
|
+
// this (e.g. Edge 2019, IE11, Safari)
|
|
818
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function getViewportRect(element, strategy) {
|
|
822
|
+
var win = getWindow(element);
|
|
823
|
+
var html = getDocumentElement(element);
|
|
824
|
+
var visualViewport = win.visualViewport;
|
|
825
|
+
var width = html.clientWidth;
|
|
826
|
+
var height = html.clientHeight;
|
|
827
|
+
var x = 0;
|
|
828
|
+
var y = 0;
|
|
829
|
+
|
|
830
|
+
if (visualViewport) {
|
|
831
|
+
width = visualViewport.width;
|
|
832
|
+
height = visualViewport.height;
|
|
833
|
+
var layoutViewport = isLayoutViewport();
|
|
834
|
+
|
|
835
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
836
|
+
x = visualViewport.offsetLeft;
|
|
837
|
+
y = visualViewport.offsetTop;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return {
|
|
842
|
+
width: width,
|
|
843
|
+
height: height,
|
|
844
|
+
x: x + getWindowScrollBarX(element),
|
|
845
|
+
y: y
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
850
|
+
|
|
851
|
+
function getDocumentRect(element) {
|
|
852
|
+
var _element$ownerDocumen;
|
|
853
|
+
|
|
854
|
+
var html = getDocumentElement(element);
|
|
855
|
+
var winScroll = getWindowScroll(element);
|
|
856
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
857
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
858
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
859
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
860
|
+
var y = -winScroll.scrollTop;
|
|
861
|
+
|
|
862
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
863
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
return {
|
|
867
|
+
width: width,
|
|
868
|
+
height: height,
|
|
869
|
+
x: x,
|
|
870
|
+
y: y
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function isScrollParent(element) {
|
|
875
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
876
|
+
var _getComputedStyle = getComputedStyle(element),
|
|
877
|
+
overflow = _getComputedStyle.overflow,
|
|
878
|
+
overflowX = _getComputedStyle.overflowX,
|
|
879
|
+
overflowY = _getComputedStyle.overflowY;
|
|
880
|
+
|
|
881
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function getScrollParent(node) {
|
|
885
|
+
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
|
886
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
887
|
+
return node.ownerDocument.body;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
891
|
+
return node;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return getScrollParent(getParentNode(node));
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
899
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
|
900
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
901
|
+
reference element's position.
|
|
902
|
+
*/
|
|
903
|
+
|
|
904
|
+
function listScrollParents(element, list) {
|
|
905
|
+
var _element$ownerDocumen;
|
|
906
|
+
|
|
907
|
+
if (list === void 0) {
|
|
908
|
+
list = [];
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
var scrollParent = getScrollParent(element);
|
|
912
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
913
|
+
var win = getWindow(scrollParent);
|
|
914
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
915
|
+
var updatedList = list.concat(target);
|
|
916
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
917
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function rectToClientRect(rect) {
|
|
921
|
+
return Object.assign({}, rect, {
|
|
922
|
+
left: rect.x,
|
|
923
|
+
top: rect.y,
|
|
924
|
+
right: rect.x + rect.width,
|
|
925
|
+
bottom: rect.y + rect.height
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
930
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
931
|
+
rect.top = rect.top + element.clientTop;
|
|
932
|
+
rect.left = rect.left + element.clientLeft;
|
|
933
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
934
|
+
rect.right = rect.left + element.clientWidth;
|
|
935
|
+
rect.width = element.clientWidth;
|
|
936
|
+
rect.height = element.clientHeight;
|
|
937
|
+
rect.x = rect.left;
|
|
938
|
+
rect.y = rect.top;
|
|
939
|
+
return rect;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
943
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
944
|
+
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
945
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
946
|
+
// `initial`
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
function getClippingParents(element) {
|
|
950
|
+
var clippingParents = listScrollParents(getParentNode(element));
|
|
951
|
+
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
952
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
953
|
+
|
|
954
|
+
if (!isElement(clipperElement)) {
|
|
955
|
+
return [];
|
|
956
|
+
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
return clippingParents.filter(function (clippingParent) {
|
|
960
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
|
961
|
+
});
|
|
962
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
|
963
|
+
// clipping parents
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
967
|
+
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
968
|
+
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
969
|
+
var firstClippingParent = clippingParents[0];
|
|
970
|
+
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
971
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
972
|
+
accRect.top = max(rect.top, accRect.top);
|
|
973
|
+
accRect.right = min(rect.right, accRect.right);
|
|
974
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
975
|
+
accRect.left = max(rect.left, accRect.left);
|
|
976
|
+
return accRect;
|
|
977
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
978
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
979
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
980
|
+
clippingRect.x = clippingRect.left;
|
|
981
|
+
clippingRect.y = clippingRect.top;
|
|
982
|
+
return clippingRect;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function computeOffsets(_ref) {
|
|
986
|
+
var reference = _ref.reference,
|
|
987
|
+
element = _ref.element,
|
|
988
|
+
placement = _ref.placement;
|
|
989
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|
990
|
+
var variation = placement ? getVariation(placement) : null;
|
|
991
|
+
var commonX = reference.x + reference.width / 2 - element.width / 2;
|
|
992
|
+
var commonY = reference.y + reference.height / 2 - element.height / 2;
|
|
993
|
+
var offsets;
|
|
994
|
+
|
|
995
|
+
switch (basePlacement) {
|
|
996
|
+
case top:
|
|
997
|
+
offsets = {
|
|
998
|
+
x: commonX,
|
|
999
|
+
y: reference.y - element.height
|
|
1000
|
+
};
|
|
1001
|
+
break;
|
|
1002
|
+
|
|
1003
|
+
case bottom:
|
|
1004
|
+
offsets = {
|
|
1005
|
+
x: commonX,
|
|
1006
|
+
y: reference.y + reference.height
|
|
1007
|
+
};
|
|
1008
|
+
break;
|
|
1009
|
+
|
|
1010
|
+
case right:
|
|
1011
|
+
offsets = {
|
|
1012
|
+
x: reference.x + reference.width,
|
|
1013
|
+
y: commonY
|
|
1014
|
+
};
|
|
1015
|
+
break;
|
|
1016
|
+
|
|
1017
|
+
case left:
|
|
1018
|
+
offsets = {
|
|
1019
|
+
x: reference.x - element.width,
|
|
1020
|
+
y: commonY
|
|
1021
|
+
};
|
|
1022
|
+
break;
|
|
1023
|
+
|
|
1024
|
+
default:
|
|
1025
|
+
offsets = {
|
|
1026
|
+
x: reference.x,
|
|
1027
|
+
y: reference.y
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|
1032
|
+
|
|
1033
|
+
if (mainAxis != null) {
|
|
1034
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
1035
|
+
|
|
1036
|
+
switch (variation) {
|
|
1037
|
+
case start:
|
|
1038
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
|
1039
|
+
break;
|
|
1040
|
+
|
|
1041
|
+
case end:
|
|
1042
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
return offsets;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function detectOverflow(state, options) {
|
|
1051
|
+
if (options === void 0) {
|
|
1052
|
+
options = {};
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
var _options = options,
|
|
1056
|
+
_options$placement = _options.placement,
|
|
1057
|
+
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
1058
|
+
_options$strategy = _options.strategy,
|
|
1059
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
1060
|
+
_options$boundary = _options.boundary,
|
|
1061
|
+
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
1062
|
+
_options$rootBoundary = _options.rootBoundary,
|
|
1063
|
+
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
|
1064
|
+
_options$elementConte = _options.elementContext,
|
|
1065
|
+
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
|
1066
|
+
_options$altBoundary = _options.altBoundary,
|
|
1067
|
+
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
|
1068
|
+
_options$padding = _options.padding,
|
|
1069
|
+
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
1070
|
+
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
1071
|
+
var altContext = elementContext === popper ? reference : popper;
|
|
1072
|
+
var popperRect = state.rects.popper;
|
|
1073
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
1074
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
1075
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
1076
|
+
var popperOffsets = computeOffsets({
|
|
1077
|
+
reference: referenceClientRect,
|
|
1078
|
+
element: popperRect,
|
|
1079
|
+
placement: placement
|
|
1080
|
+
});
|
|
1081
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
|
1082
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
|
1083
|
+
// 0 or negative = within the clipping rect
|
|
1084
|
+
|
|
1085
|
+
var overflowOffsets = {
|
|
1086
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
1087
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
1088
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
1089
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
1090
|
+
};
|
|
1091
|
+
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
|
1092
|
+
|
|
1093
|
+
if (elementContext === popper && offsetData) {
|
|
1094
|
+
var offset = offsetData[placement];
|
|
1095
|
+
Object.keys(overflowOffsets).forEach(function (key) {
|
|
1096
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
1097
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
|
1098
|
+
overflowOffsets[key] += offset[axis] * multiply;
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
return overflowOffsets;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
function computeAutoPlacement(state, options) {
|
|
1106
|
+
if (options === void 0) {
|
|
1107
|
+
options = {};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
var _options = options,
|
|
1111
|
+
placement = _options.placement,
|
|
1112
|
+
boundary = _options.boundary,
|
|
1113
|
+
rootBoundary = _options.rootBoundary,
|
|
1114
|
+
padding = _options.padding,
|
|
1115
|
+
flipVariations = _options.flipVariations,
|
|
1116
|
+
_options$allowedAutoP = _options.allowedAutoPlacements,
|
|
1117
|
+
allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
|
1118
|
+
var variation = getVariation(placement);
|
|
1119
|
+
var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
|
1120
|
+
return getVariation(placement) === variation;
|
|
1121
|
+
}) : basePlacements;
|
|
1122
|
+
var allowedPlacements = placements$1.filter(function (placement) {
|
|
1123
|
+
return allowedAutoPlacements.indexOf(placement) >= 0;
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
if (allowedPlacements.length === 0) {
|
|
1127
|
+
allowedPlacements = placements$1;
|
|
1128
|
+
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
var overflows = allowedPlacements.reduce(function (acc, placement) {
|
|
1132
|
+
acc[placement] = detectOverflow(state, {
|
|
1133
|
+
placement: placement,
|
|
1134
|
+
boundary: boundary,
|
|
1135
|
+
rootBoundary: rootBoundary,
|
|
1136
|
+
padding: padding
|
|
1137
|
+
})[getBasePlacement(placement)];
|
|
1138
|
+
return acc;
|
|
1139
|
+
}, {});
|
|
1140
|
+
return Object.keys(overflows).sort(function (a, b) {
|
|
1141
|
+
return overflows[a] - overflows[b];
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function getExpandedFallbackPlacements(placement) {
|
|
1146
|
+
if (getBasePlacement(placement) === auto) {
|
|
1147
|
+
return [];
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
1151
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
function flip(_ref) {
|
|
1155
|
+
var state = _ref.state,
|
|
1156
|
+
options = _ref.options,
|
|
1157
|
+
name = _ref.name;
|
|
1158
|
+
|
|
1159
|
+
if (state.modifiersData[name]._skip) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
var _options$mainAxis = options.mainAxis,
|
|
1164
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
1165
|
+
_options$altAxis = options.altAxis,
|
|
1166
|
+
checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
|
1167
|
+
specifiedFallbackPlacements = options.fallbackPlacements,
|
|
1168
|
+
padding = options.padding,
|
|
1169
|
+
boundary = options.boundary,
|
|
1170
|
+
rootBoundary = options.rootBoundary,
|
|
1171
|
+
altBoundary = options.altBoundary,
|
|
1172
|
+
_options$flipVariatio = options.flipVariations,
|
|
1173
|
+
flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
|
1174
|
+
allowedAutoPlacements = options.allowedAutoPlacements;
|
|
1175
|
+
var preferredPlacement = state.options.placement;
|
|
1176
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
|
1177
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
|
1178
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|
1179
|
+
var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
|
1180
|
+
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
|
1181
|
+
placement: placement,
|
|
1182
|
+
boundary: boundary,
|
|
1183
|
+
rootBoundary: rootBoundary,
|
|
1184
|
+
padding: padding,
|
|
1185
|
+
flipVariations: flipVariations,
|
|
1186
|
+
allowedAutoPlacements: allowedAutoPlacements
|
|
1187
|
+
}) : placement);
|
|
1188
|
+
}, []);
|
|
1189
|
+
var referenceRect = state.rects.reference;
|
|
1190
|
+
var popperRect = state.rects.popper;
|
|
1191
|
+
var checksMap = new Map();
|
|
1192
|
+
var makeFallbackChecks = true;
|
|
1193
|
+
var firstFittingPlacement = placements[0];
|
|
1194
|
+
|
|
1195
|
+
for (var i = 0; i < placements.length; i++) {
|
|
1196
|
+
var placement = placements[i];
|
|
1197
|
+
|
|
1198
|
+
var _basePlacement = getBasePlacement(placement);
|
|
1199
|
+
|
|
1200
|
+
var isStartVariation = getVariation(placement) === start;
|
|
1201
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
1202
|
+
var len = isVertical ? 'width' : 'height';
|
|
1203
|
+
var overflow = detectOverflow(state, {
|
|
1204
|
+
placement: placement,
|
|
1205
|
+
boundary: boundary,
|
|
1206
|
+
rootBoundary: rootBoundary,
|
|
1207
|
+
altBoundary: altBoundary,
|
|
1208
|
+
padding: padding
|
|
1209
|
+
});
|
|
1210
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
1211
|
+
|
|
1212
|
+
if (referenceRect[len] > popperRect[len]) {
|
|
1213
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
1217
|
+
var checks = [];
|
|
1218
|
+
|
|
1219
|
+
if (checkMainAxis) {
|
|
1220
|
+
checks.push(overflow[_basePlacement] <= 0);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
if (checkAltAxis) {
|
|
1224
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
if (checks.every(function (check) {
|
|
1228
|
+
return check;
|
|
1229
|
+
})) {
|
|
1230
|
+
firstFittingPlacement = placement;
|
|
1231
|
+
makeFallbackChecks = false;
|
|
1232
|
+
break;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
checksMap.set(placement, checks);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
if (makeFallbackChecks) {
|
|
1239
|
+
// `2` may be desired in some cases – research later
|
|
1240
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
|
1241
|
+
|
|
1242
|
+
var _loop = function _loop(_i) {
|
|
1243
|
+
var fittingPlacement = placements.find(function (placement) {
|
|
1244
|
+
var checks = checksMap.get(placement);
|
|
1245
|
+
|
|
1246
|
+
if (checks) {
|
|
1247
|
+
return checks.slice(0, _i).every(function (check) {
|
|
1248
|
+
return check;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
if (fittingPlacement) {
|
|
1254
|
+
firstFittingPlacement = fittingPlacement;
|
|
1255
|
+
return "break";
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
1260
|
+
var _ret = _loop(_i);
|
|
1261
|
+
|
|
1262
|
+
if (_ret === "break") break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
if (state.placement !== firstFittingPlacement) {
|
|
1267
|
+
state.modifiersData[name]._skip = true;
|
|
1268
|
+
state.placement = firstFittingPlacement;
|
|
1269
|
+
state.reset = true;
|
|
1270
|
+
}
|
|
1271
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
var flip$1 = {
|
|
1275
|
+
name: 'flip',
|
|
1276
|
+
enabled: true,
|
|
1277
|
+
phase: 'main',
|
|
1278
|
+
fn: flip,
|
|
1279
|
+
requiresIfExists: ['offset'],
|
|
1280
|
+
data: {
|
|
1281
|
+
_skip: false
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1285
|
+
function getSideOffsets(overflow, rect, preventedOffsets) {
|
|
1286
|
+
if (preventedOffsets === void 0) {
|
|
1287
|
+
preventedOffsets = {
|
|
1288
|
+
x: 0,
|
|
1289
|
+
y: 0
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
return {
|
|
1294
|
+
top: overflow.top - rect.height - preventedOffsets.y,
|
|
1295
|
+
right: overflow.right - rect.width + preventedOffsets.x,
|
|
1296
|
+
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|
1297
|
+
left: overflow.left - rect.width - preventedOffsets.x
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
function isAnySideFullyClipped(overflow) {
|
|
1302
|
+
return [top, right, bottom, left].some(function (side) {
|
|
1303
|
+
return overflow[side] >= 0;
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
function hide(_ref) {
|
|
1308
|
+
var state = _ref.state,
|
|
1309
|
+
name = _ref.name;
|
|
1310
|
+
var referenceRect = state.rects.reference;
|
|
1311
|
+
var popperRect = state.rects.popper;
|
|
1312
|
+
var preventedOffsets = state.modifiersData.preventOverflow;
|
|
1313
|
+
var referenceOverflow = detectOverflow(state, {
|
|
1314
|
+
elementContext: 'reference'
|
|
1315
|
+
});
|
|
1316
|
+
var popperAltOverflow = detectOverflow(state, {
|
|
1317
|
+
altBoundary: true
|
|
1318
|
+
});
|
|
1319
|
+
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|
1320
|
+
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|
1321
|
+
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|
1322
|
+
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|
1323
|
+
state.modifiersData[name] = {
|
|
1324
|
+
referenceClippingOffsets: referenceClippingOffsets,
|
|
1325
|
+
popperEscapeOffsets: popperEscapeOffsets,
|
|
1326
|
+
isReferenceHidden: isReferenceHidden,
|
|
1327
|
+
hasPopperEscaped: hasPopperEscaped
|
|
1328
|
+
};
|
|
1329
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
1330
|
+
'data-popper-reference-hidden': isReferenceHidden,
|
|
1331
|
+
'data-popper-escaped': hasPopperEscaped
|
|
1332
|
+
});
|
|
1333
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
var hide$1 = {
|
|
1337
|
+
name: 'hide',
|
|
1338
|
+
enabled: true,
|
|
1339
|
+
phase: 'main',
|
|
1340
|
+
requiresIfExists: ['preventOverflow'],
|
|
1341
|
+
fn: hide
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
function distanceAndSkiddingToXY(placement, rects, offset) {
|
|
1345
|
+
var basePlacement = getBasePlacement(placement);
|
|
1346
|
+
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
|
1347
|
+
|
|
1348
|
+
var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
|
1349
|
+
placement: placement
|
|
1350
|
+
})) : offset,
|
|
1351
|
+
skidding = _ref[0],
|
|
1352
|
+
distance = _ref[1];
|
|
1353
|
+
|
|
1354
|
+
skidding = skidding || 0;
|
|
1355
|
+
distance = (distance || 0) * invertDistance;
|
|
1356
|
+
return [left, right].indexOf(basePlacement) >= 0 ? {
|
|
1357
|
+
x: distance,
|
|
1358
|
+
y: skidding
|
|
1359
|
+
} : {
|
|
1360
|
+
x: skidding,
|
|
1361
|
+
y: distance
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
function offset(_ref2) {
|
|
1366
|
+
var state = _ref2.state,
|
|
1367
|
+
options = _ref2.options,
|
|
1368
|
+
name = _ref2.name;
|
|
1369
|
+
var _options$offset = options.offset,
|
|
1370
|
+
offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
|
1371
|
+
var data = placements.reduce(function (acc, placement) {
|
|
1372
|
+
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
|
1373
|
+
return acc;
|
|
1374
|
+
}, {});
|
|
1375
|
+
var _data$state$placement = data[state.placement],
|
|
1376
|
+
x = _data$state$placement.x,
|
|
1377
|
+
y = _data$state$placement.y;
|
|
1378
|
+
|
|
1379
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
1380
|
+
state.modifiersData.popperOffsets.x += x;
|
|
1381
|
+
state.modifiersData.popperOffsets.y += y;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
state.modifiersData[name] = data;
|
|
1385
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
var offset$1 = {
|
|
1389
|
+
name: 'offset',
|
|
1390
|
+
enabled: true,
|
|
1391
|
+
phase: 'main',
|
|
1392
|
+
requires: ['popperOffsets'],
|
|
1393
|
+
fn: offset
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
function popperOffsets(_ref) {
|
|
1397
|
+
var state = _ref.state,
|
|
1398
|
+
name = _ref.name;
|
|
1399
|
+
// Offsets are the actual position the popper needs to have to be
|
|
1400
|
+
// properly positioned near its reference element
|
|
1401
|
+
// This is the most basic placement, and will be adjusted by
|
|
1402
|
+
// the modifiers in the next step
|
|
1403
|
+
state.modifiersData[name] = computeOffsets({
|
|
1404
|
+
reference: state.rects.reference,
|
|
1405
|
+
element: state.rects.popper,
|
|
1406
|
+
placement: state.placement
|
|
1407
|
+
});
|
|
1408
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
var popperOffsets$1 = {
|
|
1412
|
+
name: 'popperOffsets',
|
|
1413
|
+
enabled: true,
|
|
1414
|
+
phase: 'read',
|
|
1415
|
+
fn: popperOffsets,
|
|
1416
|
+
data: {}
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
function getAltAxis(axis) {
|
|
1420
|
+
return axis === 'x' ? 'y' : 'x';
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
function preventOverflow(_ref) {
|
|
1424
|
+
var state = _ref.state,
|
|
1425
|
+
options = _ref.options,
|
|
1426
|
+
name = _ref.name;
|
|
1427
|
+
var _options$mainAxis = options.mainAxis,
|
|
1428
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
1429
|
+
_options$altAxis = options.altAxis,
|
|
1430
|
+
checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
|
1431
|
+
boundary = options.boundary,
|
|
1432
|
+
rootBoundary = options.rootBoundary,
|
|
1433
|
+
altBoundary = options.altBoundary,
|
|
1434
|
+
padding = options.padding,
|
|
1435
|
+
_options$tether = options.tether,
|
|
1436
|
+
tether = _options$tether === void 0 ? true : _options$tether,
|
|
1437
|
+
_options$tetherOffset = options.tetherOffset,
|
|
1438
|
+
tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|
1439
|
+
var overflow = detectOverflow(state, {
|
|
1440
|
+
boundary: boundary,
|
|
1441
|
+
rootBoundary: rootBoundary,
|
|
1442
|
+
padding: padding,
|
|
1443
|
+
altBoundary: altBoundary
|
|
1444
|
+
});
|
|
1445
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
1446
|
+
var variation = getVariation(state.placement);
|
|
1447
|
+
var isBasePlacement = !variation;
|
|
1448
|
+
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|
1449
|
+
var altAxis = getAltAxis(mainAxis);
|
|
1450
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
1451
|
+
var referenceRect = state.rects.reference;
|
|
1452
|
+
var popperRect = state.rects.popper;
|
|
1453
|
+
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
|
1454
|
+
placement: state.placement
|
|
1455
|
+
})) : tetherOffset;
|
|
1456
|
+
var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
|
1457
|
+
mainAxis: tetherOffsetValue,
|
|
1458
|
+
altAxis: tetherOffsetValue
|
|
1459
|
+
} : Object.assign({
|
|
1460
|
+
mainAxis: 0,
|
|
1461
|
+
altAxis: 0
|
|
1462
|
+
}, tetherOffsetValue);
|
|
1463
|
+
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|
1464
|
+
var data = {
|
|
1465
|
+
x: 0,
|
|
1466
|
+
y: 0
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
if (!popperOffsets) {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
if (checkMainAxis) {
|
|
1474
|
+
var _offsetModifierState$;
|
|
1475
|
+
|
|
1476
|
+
var mainSide = mainAxis === 'y' ? top : left;
|
|
1477
|
+
var altSide = mainAxis === 'y' ? bottom : right;
|
|
1478
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
1479
|
+
var offset = popperOffsets[mainAxis];
|
|
1480
|
+
var min$1 = offset + overflow[mainSide];
|
|
1481
|
+
var max$1 = offset - overflow[altSide];
|
|
1482
|
+
var additive = tether ? -popperRect[len] / 2 : 0;
|
|
1483
|
+
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|
1484
|
+
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
|
1485
|
+
// outside the reference bounds
|
|
1486
|
+
|
|
1487
|
+
var arrowElement = state.elements.arrow;
|
|
1488
|
+
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|
1489
|
+
width: 0,
|
|
1490
|
+
height: 0
|
|
1491
|
+
};
|
|
1492
|
+
var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
|
1493
|
+
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|
1494
|
+
var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
|
|
1495
|
+
// to include its full size in the calculation. If the reference is small
|
|
1496
|
+
// and near the edge of a boundary, the popper can overflow even if the
|
|
1497
|
+
// reference is not overflowing as well (e.g. virtual elements with no
|
|
1498
|
+
// width or height)
|
|
1499
|
+
|
|
1500
|
+
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
1501
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|
1502
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|
1503
|
+
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
1504
|
+
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
1505
|
+
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|
1506
|
+
var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
|
1507
|
+
var tetherMax = offset + maxOffset - offsetModifierValue;
|
|
1508
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
|
1509
|
+
popperOffsets[mainAxis] = preventedOffset;
|
|
1510
|
+
data[mainAxis] = preventedOffset - offset;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
if (checkAltAxis) {
|
|
1514
|
+
var _offsetModifierState$2;
|
|
1515
|
+
|
|
1516
|
+
var _mainSide = mainAxis === 'x' ? top : left;
|
|
1517
|
+
|
|
1518
|
+
var _altSide = mainAxis === 'x' ? bottom : right;
|
|
1519
|
+
|
|
1520
|
+
var _offset = popperOffsets[altAxis];
|
|
1521
|
+
|
|
1522
|
+
var _len = altAxis === 'y' ? 'height' : 'width';
|
|
1523
|
+
|
|
1524
|
+
var _min = _offset + overflow[_mainSide];
|
|
1525
|
+
|
|
1526
|
+
var _max = _offset - overflow[_altSide];
|
|
1527
|
+
|
|
1528
|
+
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|
1529
|
+
|
|
1530
|
+
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|
1531
|
+
|
|
1532
|
+
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|
1533
|
+
|
|
1534
|
+
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|
1535
|
+
|
|
1536
|
+
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|
1537
|
+
|
|
1538
|
+
popperOffsets[altAxis] = _preventedOffset;
|
|
1539
|
+
data[altAxis] = _preventedOffset - _offset;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
state.modifiersData[name] = data;
|
|
1543
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
var preventOverflow$1 = {
|
|
1547
|
+
name: 'preventOverflow',
|
|
1548
|
+
enabled: true,
|
|
1549
|
+
phase: 'main',
|
|
1550
|
+
fn: preventOverflow,
|
|
1551
|
+
requiresIfExists: ['offset']
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
function getHTMLElementScroll(element) {
|
|
1555
|
+
return {
|
|
1556
|
+
scrollLeft: element.scrollLeft,
|
|
1557
|
+
scrollTop: element.scrollTop
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
function getNodeScroll(node) {
|
|
1562
|
+
if (node === getWindow(node) || !isHTMLElement(node)) {
|
|
1563
|
+
return getWindowScroll(node);
|
|
1564
|
+
} else {
|
|
1565
|
+
return getHTMLElementScroll(node);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function isElementScaled(element) {
|
|
1570
|
+
var rect = element.getBoundingClientRect();
|
|
1571
|
+
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|
1572
|
+
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|
1573
|
+
return scaleX !== 1 || scaleY !== 1;
|
|
1574
|
+
} // Returns the composite rect of an element relative to its offsetParent.
|
|
1575
|
+
// Composite means it takes into account transforms as well as layout.
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
1579
|
+
if (isFixed === void 0) {
|
|
1580
|
+
isFixed = false;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1584
|
+
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
1585
|
+
var documentElement = getDocumentElement(offsetParent);
|
|
1586
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
1587
|
+
var scroll = {
|
|
1588
|
+
scrollLeft: 0,
|
|
1589
|
+
scrollTop: 0
|
|
1590
|
+
};
|
|
1591
|
+
var offsets = {
|
|
1592
|
+
x: 0,
|
|
1593
|
+
y: 0
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1597
|
+
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
|
|
1598
|
+
isScrollParent(documentElement)) {
|
|
1599
|
+
scroll = getNodeScroll(offsetParent);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
if (isHTMLElement(offsetParent)) {
|
|
1603
|
+
offsets = getBoundingClientRect(offsetParent, true);
|
|
1604
|
+
offsets.x += offsetParent.clientLeft;
|
|
1605
|
+
offsets.y += offsetParent.clientTop;
|
|
1606
|
+
} else if (documentElement) {
|
|
1607
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
return {
|
|
1612
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1613
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1614
|
+
width: rect.width,
|
|
1615
|
+
height: rect.height
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
function order(modifiers) {
|
|
1620
|
+
var map = new Map();
|
|
1621
|
+
var visited = new Set();
|
|
1622
|
+
var result = [];
|
|
1623
|
+
modifiers.forEach(function (modifier) {
|
|
1624
|
+
map.set(modifier.name, modifier);
|
|
1625
|
+
}); // On visiting object, check for its dependencies and visit them recursively
|
|
1626
|
+
|
|
1627
|
+
function sort(modifier) {
|
|
1628
|
+
visited.add(modifier.name);
|
|
1629
|
+
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|
1630
|
+
requires.forEach(function (dep) {
|
|
1631
|
+
if (!visited.has(dep)) {
|
|
1632
|
+
var depModifier = map.get(dep);
|
|
1633
|
+
|
|
1634
|
+
if (depModifier) {
|
|
1635
|
+
sort(depModifier);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
result.push(modifier);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
modifiers.forEach(function (modifier) {
|
|
1643
|
+
if (!visited.has(modifier.name)) {
|
|
1644
|
+
// check for visited object
|
|
1645
|
+
sort(modifier);
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
return result;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
function orderModifiers(modifiers) {
|
|
1652
|
+
// order based on dependencies
|
|
1653
|
+
var orderedModifiers = order(modifiers); // order based on phase
|
|
1654
|
+
|
|
1655
|
+
return modifierPhases.reduce(function (acc, phase) {
|
|
1656
|
+
return acc.concat(orderedModifiers.filter(function (modifier) {
|
|
1657
|
+
return modifier.phase === phase;
|
|
1658
|
+
}));
|
|
1659
|
+
}, []);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
function debounce(fn) {
|
|
1663
|
+
var pending;
|
|
1664
|
+
return function () {
|
|
1665
|
+
if (!pending) {
|
|
1666
|
+
pending = new Promise(function (resolve) {
|
|
1667
|
+
Promise.resolve().then(function () {
|
|
1668
|
+
pending = undefined;
|
|
1669
|
+
resolve(fn());
|
|
1670
|
+
});
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
return pending;
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
function mergeByName(modifiers) {
|
|
1679
|
+
var merged = modifiers.reduce(function (merged, current) {
|
|
1680
|
+
var existing = merged[current.name];
|
|
1681
|
+
merged[current.name] = existing ? Object.assign({}, existing, current, {
|
|
1682
|
+
options: Object.assign({}, existing.options, current.options),
|
|
1683
|
+
data: Object.assign({}, existing.data, current.data)
|
|
1684
|
+
}) : current;
|
|
1685
|
+
return merged;
|
|
1686
|
+
}, {}); // IE11 does not support Object.values
|
|
1687
|
+
|
|
1688
|
+
return Object.keys(merged).map(function (key) {
|
|
1689
|
+
return merged[key];
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
var DEFAULT_OPTIONS = {
|
|
1694
|
+
placement: 'bottom',
|
|
1695
|
+
modifiers: [],
|
|
1696
|
+
strategy: 'absolute'
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
function areValidElements() {
|
|
1700
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1701
|
+
args[_key] = arguments[_key];
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
return !args.some(function (element) {
|
|
1705
|
+
return !(element && typeof element.getBoundingClientRect === 'function');
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
function popperGenerator(generatorOptions) {
|
|
1710
|
+
if (generatorOptions === void 0) {
|
|
1711
|
+
generatorOptions = {};
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
var _generatorOptions = generatorOptions,
|
|
1715
|
+
_generatorOptions$def = _generatorOptions.defaultModifiers,
|
|
1716
|
+
defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
|
1717
|
+
_generatorOptions$def2 = _generatorOptions.defaultOptions,
|
|
1718
|
+
defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
|
1719
|
+
return function createPopper(reference, popper, options) {
|
|
1720
|
+
if (options === void 0) {
|
|
1721
|
+
options = defaultOptions;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
var state = {
|
|
1725
|
+
placement: 'bottom',
|
|
1726
|
+
orderedModifiers: [],
|
|
1727
|
+
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
|
1728
|
+
modifiersData: {},
|
|
1729
|
+
elements: {
|
|
1730
|
+
reference: reference,
|
|
1731
|
+
popper: popper
|
|
1732
|
+
},
|
|
1733
|
+
attributes: {},
|
|
1734
|
+
styles: {}
|
|
1735
|
+
};
|
|
1736
|
+
var effectCleanupFns = [];
|
|
1737
|
+
var isDestroyed = false;
|
|
1738
|
+
var instance = {
|
|
1739
|
+
state: state,
|
|
1740
|
+
setOptions: function setOptions(setOptionsAction) {
|
|
1741
|
+
var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
|
1742
|
+
cleanupModifierEffects();
|
|
1743
|
+
state.options = Object.assign({}, defaultOptions, state.options, options);
|
|
1744
|
+
state.scrollParents = {
|
|
1745
|
+
reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
|
1746
|
+
popper: listScrollParents(popper)
|
|
1747
|
+
}; // Orders the modifiers based on their dependencies and `phase`
|
|
1748
|
+
// properties
|
|
1749
|
+
|
|
1750
|
+
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
|
|
1751
|
+
|
|
1752
|
+
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
|
1753
|
+
return m.enabled;
|
|
1754
|
+
});
|
|
1755
|
+
runModifierEffects();
|
|
1756
|
+
return instance.update();
|
|
1757
|
+
},
|
|
1758
|
+
// Sync update – it will always be executed, even if not necessary. This
|
|
1759
|
+
// is useful for low frequency updates where sync behavior simplifies the
|
|
1760
|
+
// logic.
|
|
1761
|
+
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|
1762
|
+
// prefer the async Popper#update method
|
|
1763
|
+
forceUpdate: function forceUpdate() {
|
|
1764
|
+
if (isDestroyed) {
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
var _state$elements = state.elements,
|
|
1769
|
+
reference = _state$elements.reference,
|
|
1770
|
+
popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
|
|
1771
|
+
// anymore
|
|
1772
|
+
|
|
1773
|
+
if (!areValidElements(reference, popper)) {
|
|
1774
|
+
return;
|
|
1775
|
+
} // Store the reference and popper rects to be read by modifiers
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
state.rects = {
|
|
1779
|
+
reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
|
1780
|
+
popper: getLayoutRect(popper)
|
|
1781
|
+
}; // Modifiers have the ability to reset the current update cycle. The
|
|
1782
|
+
// most common use case for this is the `flip` modifier changing the
|
|
1783
|
+
// placement, which then needs to re-run all the modifiers, because the
|
|
1784
|
+
// logic was previously ran for the previous placement and is therefore
|
|
1785
|
+
// stale/incorrect
|
|
1786
|
+
|
|
1787
|
+
state.reset = false;
|
|
1788
|
+
state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
|
|
1789
|
+
// is filled with the initial data specified by the modifier. This means
|
|
1790
|
+
// it doesn't persist and is fresh on each update.
|
|
1791
|
+
// To ensure persistent data, use `${name}#persistent`
|
|
1792
|
+
|
|
1793
|
+
state.orderedModifiers.forEach(function (modifier) {
|
|
1794
|
+
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1797
|
+
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
1798
|
+
if (state.reset === true) {
|
|
1799
|
+
state.reset = false;
|
|
1800
|
+
index = -1;
|
|
1801
|
+
continue;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
var _state$orderedModifie = state.orderedModifiers[index],
|
|
1805
|
+
fn = _state$orderedModifie.fn,
|
|
1806
|
+
_state$orderedModifie2 = _state$orderedModifie.options,
|
|
1807
|
+
_options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
|
1808
|
+
name = _state$orderedModifie.name;
|
|
1809
|
+
|
|
1810
|
+
if (typeof fn === 'function') {
|
|
1811
|
+
state = fn({
|
|
1812
|
+
state: state,
|
|
1813
|
+
options: _options,
|
|
1814
|
+
name: name,
|
|
1815
|
+
instance: instance
|
|
1816
|
+
}) || state;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
// Async and optimistically optimized update – it will not be executed if
|
|
1821
|
+
// not necessary (debounced to run at most once-per-tick)
|
|
1822
|
+
update: debounce(function () {
|
|
1823
|
+
return new Promise(function (resolve) {
|
|
1824
|
+
instance.forceUpdate();
|
|
1825
|
+
resolve(state);
|
|
1826
|
+
});
|
|
1827
|
+
}),
|
|
1828
|
+
destroy: function destroy() {
|
|
1829
|
+
cleanupModifierEffects();
|
|
1830
|
+
isDestroyed = true;
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
if (!areValidElements(reference, popper)) {
|
|
1835
|
+
return instance;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
instance.setOptions(options).then(function (state) {
|
|
1839
|
+
if (!isDestroyed && options.onFirstUpdate) {
|
|
1840
|
+
options.onFirstUpdate(state);
|
|
1841
|
+
}
|
|
1842
|
+
}); // Modifiers have the ability to execute arbitrary code before the first
|
|
1843
|
+
// update cycle runs. They will be executed in the same order as the update
|
|
1844
|
+
// cycle. This is useful when a modifier adds some persistent data that
|
|
1845
|
+
// other modifiers need to use, but the modifier is run after the dependent
|
|
1846
|
+
// one.
|
|
1847
|
+
|
|
1848
|
+
function runModifierEffects() {
|
|
1849
|
+
state.orderedModifiers.forEach(function (_ref) {
|
|
1850
|
+
var name = _ref.name,
|
|
1851
|
+
_ref$options = _ref.options,
|
|
1852
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
1853
|
+
effect = _ref.effect;
|
|
1854
|
+
|
|
1855
|
+
if (typeof effect === 'function') {
|
|
1856
|
+
var cleanupFn = effect({
|
|
1857
|
+
state: state,
|
|
1858
|
+
name: name,
|
|
1859
|
+
instance: instance,
|
|
1860
|
+
options: options
|
|
1861
|
+
});
|
|
1862
|
+
|
|
1863
|
+
var noopFn = function noopFn() {};
|
|
1864
|
+
|
|
1865
|
+
effectCleanupFns.push(cleanupFn || noopFn);
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
function cleanupModifierEffects() {
|
|
1871
|
+
effectCleanupFns.forEach(function (fn) {
|
|
1872
|
+
return fn();
|
|
1873
|
+
});
|
|
1874
|
+
effectCleanupFns = [];
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
return instance;
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
|
1882
|
+
var createPopper = /*#__PURE__*/popperGenerator({
|
|
1883
|
+
defaultModifiers: defaultModifiers
|
|
1884
|
+
}); // eslint-disable-next-line import/no-unused-modules
|
|
1885
|
+
|
|
1886
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1887
|
+
// See LICENSE in the project root for license information.
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
// build the component class
|
|
1891
|
+
const popoverOffsetDistance = 18;
|
|
1892
|
+
const popoverOffsetSkidding = 0;
|
|
1893
|
+
|
|
1894
|
+
class Popover {
|
|
1895
|
+
constructor(anchor, popover, placement, boundary) {
|
|
1896
|
+
this.anchor = anchor;
|
|
1897
|
+
this.popover = popover;
|
|
1898
|
+
this.boundaryElement = this.setBoundary(boundary);
|
|
1899
|
+
this.options = {
|
|
1900
|
+
placement,
|
|
1901
|
+
visibleClass: "data-show",
|
|
1902
|
+
};
|
|
1903
|
+
this.popover.classList.remove(this.options.visibleClass);
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
setBoundary(boundary) {
|
|
1907
|
+
if (typeof boundary === "string") {
|
|
1908
|
+
return document.querySelector(boundary) || document.body;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
return boundary || document.body;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
show() {
|
|
1915
|
+
if (this.popper) {
|
|
1916
|
+
this.popper.destroy();
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
this.popper = createPopper(this.anchor, this.popover, {
|
|
1920
|
+
tooltip: this.anchor,
|
|
1921
|
+
placement: this.options.placement,
|
|
1922
|
+
modifiers: [
|
|
1923
|
+
{
|
|
1924
|
+
name: "offset",
|
|
1925
|
+
options: {
|
|
1926
|
+
offset: [popoverOffsetSkidding, popoverOffsetDistance],
|
|
1927
|
+
},
|
|
1928
|
+
},
|
|
1929
|
+
{
|
|
1930
|
+
name: "preventOverflow",
|
|
1931
|
+
options: {
|
|
1932
|
+
mainAxis: true,
|
|
1933
|
+
boundary: this.boundaryElement,
|
|
1934
|
+
rootBoundary: "document",
|
|
1935
|
+
padding: 16,
|
|
1936
|
+
},
|
|
1937
|
+
},
|
|
1938
|
+
],
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
triggerUpdate() {
|
|
1943
|
+
this.popper.update();
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
hide() {
|
|
1947
|
+
this.popover.classList.remove(this.options.visibleClass);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
var colorCss = i$3`::slotted(*){color:var(--ds-auro-popover-text-color)}.popover{background-color:var(--ds-auro-popover-container-color);box-shadow:var(--ds-auro-popover-boxshadow-color)}.arrow:before{background-color:var(--ds-auro-popover-container-color);box-shadow:2px 2px 1px 0 var(--ds-auro-popover-boxshadow-color)}
|
|
1952
|
+
`;
|
|
1953
|
+
|
|
1954
|
+
var styleCss = i$3`.body-default{font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default,.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-lg{font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-size:var(--wcss-body-sm-font-size, .875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm,.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-xs{font-size:var(--wcss-body-xs-font-size, .75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-2xs-font-size, .625rem);font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);line-height:var(--wcss-body-2xs-line-height, .875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));font-weight:var(--wcss-display-2xl-weight, 300);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);line-height:var(--wcss-display-2xl-line-height, 1.3)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));font-weight:var(--wcss-display-xl-weight, 300);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);line-height:var(--wcss-display-xl-line-height, 1.3)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));font-weight:var(--wcss-display-lg-weight, 300);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);line-height:var(--wcss-display-lg-line-height, 1.3)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));font-weight:var(--wcss-display-md-weight, 300);letter-spacing:var(--wcss-display-md-letter-spacing, 0);line-height:var(--wcss-display-md-line-height, 1.3)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));font-weight:var(--wcss-display-sm-weight, 300);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);line-height:var(--wcss-display-sm-line-height, 1.3)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));font-weight:var(--wcss-display-xs-weight, 300);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);line-height:var(--wcss-display-xs-line-height, 1.3)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));font-weight:var(--wcss-heading-xl-weight, 300);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);line-height:var(--wcss-heading-xl-line-height, 1.3)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));font-weight:var(--wcss-heading-lg-weight, 300);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);line-height:var(--wcss-heading-lg-line-height, 1.3)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));font-weight:var(--wcss-heading-md-weight, 300);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);line-height:var(--wcss-heading-md-line-height, 1.3)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));font-weight:var(--wcss-heading-sm-weight, 300);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);line-height:var(--wcss-heading-sm-line-height, 1.3)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));font-weight:var(--wcss-heading-xs-weight, 450);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);line-height:var(--wcss-heading-xs-line-height, 1.3)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));font-weight:var(--wcss-heading-2xs-weight, 450);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);line-height:var(--wcss-heading-2xs-line-height, 1.3)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));font-weight:var(--wcss-accent-2xl-weight, 450);letter-spacing:var(--wcss-accent-2xl-letter-spacing, .05em);line-height:var(--wcss-accent-2xl-line-height, 1)}.accent-2xl,.accent-xl{text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));font-weight:var(--wcss-accent-xl-weight, 450);letter-spacing:var(--wcss-accent-xl-letter-spacing, .05em);line-height:var(--wcss-accent-xl-line-height, 1.3)}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));font-weight:var(--wcss-accent-lg-weight, 450);letter-spacing:var(--wcss-accent-lg-letter-spacing, .05em);line-height:var(--wcss-accent-lg-line-height, 1.3)}.accent-lg,.accent-md{text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));font-weight:var(--wcss-accent-md-weight, 500);letter-spacing:var(--wcss-accent-md-letter-spacing, .05em);line-height:var(--wcss-accent-md-line-height, 1.3)}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));font-weight:var(--wcss-accent-sm-weight, 500);letter-spacing:var(--wcss-accent-sm-letter-spacing, .05em);line-height:var(--wcss-accent-sm-line-height, 1.3)}.accent-sm,.accent-xs{text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));font-weight:var(--wcss-accent-xs-weight, 500);letter-spacing:var(--wcss-accent-xs-letter-spacing, .1em);line-height:var(--wcss-accent-xs-line-height, 1.3)}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xs-font-size, clamp(.875rem, 1.1666666667vw, .875rem));font-weight:var(--wcss-accent-2xs-weight, 450);letter-spacing:var(--wcss-accent-2xs-letter-spacing, .1em);line-height:var(--wcss-accent-2xs-line-height, 1.3);text-transform:uppercase}:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host(:not([data-show])) .popover,:host([disabled]) .popover,:host([addSpace]) :host(:not([data-show])) .popover{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.util_insetNone{padding:0}.util_insetXxxs{padding:.125rem}.util_insetXxxs--stretch{padding:.25rem .125rem}.util_insetXxxs--squish{padding:0 .125rem}.util_insetXxs{padding:.25rem}.util_insetXxs--stretch{padding:.375rem .25rem}.util_insetXxs--squish{padding:.125rem .25rem}.util_insetXs{padding:.5rem}.util_insetXs--stretch{padding:.75rem .5rem}.util_insetXs--squish{padding:.25rem .5rem}.util_insetSm{padding:.75rem}.util_insetSm--stretch{padding:1.125rem .75rem}.util_insetSm--squish{padding:.375rem .75rem}.util_insetMd{padding:1rem}.util_insetMd--stretch{padding:1.5rem 1rem}.util_insetMd--squish{padding:.5rem 1rem}.util_insetLg{padding:1.5rem}.util_insetLg--stretch{padding:2.25rem 1.5rem}.util_insetLg--squish{padding:.75rem 1.5rem}.util_insetXl{padding:2rem}.util_insetXl--stretch{padding:3rem 2rem}.util_insetXl--squish{padding:1rem 2rem}.util_insetXxl{padding:3rem}.util_insetXxl--stretch{padding:4.5rem 3rem}.util_insetXxl--squish{padding:1.5rem 3rem}.util_insetXxxl{padding:4rem}.util_insetXxxl--stretch{padding:6rem 4rem}.util_insetXxxl--squish{padding:2rem 4rem}::slotted(*){white-space:normal}::slotted(*:hover){cursor:pointer}[data-trigger-placement]::slotted(*:hover){position:relative}[data-trigger-placement]::slotted(*:hover):before{position:absolute;left:0;display:block;width:100%;height:calc(var(--ds-size-200, 1rem) + var(--ds-size-50, .25rem));content:""}[data-trigger-placement^=top]::slotted(*:hover):before{top:calc(-1 * (var(--ds-size-200, 1rem) + var(--ds-size-50, .25rem)))}[data-trigger-placement^=bottom]::slotted(*:hover):before{bottom:calc(-1 * (var(--ds-size-200, 1rem) + var(--ds-size-50, .25rem)))}:host([data-show]) .popover{z-index:var(--ds-depth-tooltip, 400)}:host([removeSpace]) .popover{margin:calc(-1 * (var(--ds-size-50, .25rem) + 1px)) 0!important}:host([addSpace]) .popover{margin:var(--ds-size-200, 1rem) 0!important}:host([addSpace]) [data-trigger-placement]::slotted(*:hover):before{height:var(--ds-size-500, 2.5rem)}:host([addSpace]) [data-trigger-placement^=top]::slotted(*:hover):before{top:calc(-1 * var(--ds-size-500, 2.5rem))}:host([addSpace]) [data-trigger-placement^=bottom]::slotted(*:hover):before{bottom:calc(-1 * var(--ds-size-500, 2.5rem))}.popover{display:inline-block;max-width:calc(100% - var(--ds-size-400, 2rem));border-radius:var(--ds-border-radius, .375rem)}@media screen and (min-width: 576px){.popover{max-width:50%}}@media screen and (min-width: 768px){.popover{max-width:40%}}@media screen and (min-width: 1024px){.popover{max-width:27rem}}[data-popper-placement^=top]>.arrow{bottom:calc(-1 * (var(--ds-size-100, .5rem) + var(--ds-size-25, .125rem)))}[data-popper-placement^=top]>.arrow:before{top:calc(-1 * var(--ds-size-200, 1rem));left:calc(-1 * var(--ds-size-75, .375rem));transform:rotate(45deg)}[data-popper-placement^=bottom]>.arrow{top:calc(-1 * (var(--ds-size-100, .5rem) + var(--ds-size-25, .125rem)))}[data-popper-placement^=bottom]>.arrow:before{top:var(--ds-size-50, .25rem);right:calc(-1 * var(--ds-size-200, 1rem));transform:rotate(-135deg)}.arrow{position:relative;margin-top:-var(--ds-size-100,.5rem)}.arrow:before{position:absolute;width:var(--ds-size-150, .75rem);height:var(--ds-size-150, .75rem);content:""}
|
|
1955
|
+
`;
|
|
1956
|
+
|
|
1957
|
+
var tokensCss = i$3`:host{--ds-auro-popover-boxshadow-color: var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, .15));--ds-auro-popover-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-popover-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}
|
|
1958
|
+
`;
|
|
1959
|
+
|
|
1960
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1961
|
+
// See LICENSE in the project root for license information.
|
|
1962
|
+
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* Popover attaches to an element and displays on hover/blur.
|
|
1966
|
+
*
|
|
1967
|
+
* @attr {boolean} addSpace - If true, will add additional top and bottom space around the appearance of the popover in relation to the trigger
|
|
1968
|
+
* @attr {boolean} disabled - If true, will disable the popover from showing on hover and focus
|
|
1969
|
+
* @attr {String} for - Directly associate the popover with a trigger element with the given ID. In most cases, this should not be necessary and set slot="trigger" on the element instead.
|
|
1970
|
+
* @attr {String} placement - Expects top/bottom - position for popover in relation to the element
|
|
1971
|
+
* @attr {boolean} removeSpace - If true, will remove top and bottom space around the appearance of the popover in relation to the trigger
|
|
1972
|
+
* @attr {String | Object} boundary - The element to use as the boundary for the popover. Can be a query selector or an HTML element.
|
|
1973
|
+
* @slot - Default unnamed slot for the use of popover content
|
|
1974
|
+
* @slot trigger - The element in this slot triggers hiding and showing the popover.
|
|
1975
|
+
*/
|
|
1976
|
+
class AuroPopover extends i {
|
|
1977
|
+
constructor() {
|
|
1978
|
+
super();
|
|
1979
|
+
|
|
1980
|
+
this.placement = "top";
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* Internal Defaults.
|
|
1985
|
+
* @private
|
|
1986
|
+
* @returns {void}
|
|
1987
|
+
*/
|
|
1988
|
+
privateDefaults() {
|
|
1989
|
+
this.isPopoverVisible = false;
|
|
1990
|
+
this.id = `popover-${(Math.random() + 1).toString(36).substring(7)}`;
|
|
1991
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
// function to define props used within the scope of this component
|
|
1995
|
+
static get properties() {
|
|
1996
|
+
return {
|
|
1997
|
+
placement: { type: String },
|
|
1998
|
+
for: { type: String },
|
|
1999
|
+
disabled: { type: Boolean },
|
|
2000
|
+
boundary: { type: String },
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
static get styles() {
|
|
2005
|
+
return [i$3`${styleCss}`, i$3`${colorCss}`, i$3`${tokensCss}`];
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* This will register this element with the browser.
|
|
2010
|
+
* @param {string} [name="auro-popover"] - The name of element that you want to register to.
|
|
2011
|
+
*
|
|
2012
|
+
* @example
|
|
2013
|
+
* AuroPopover.register("custom-popover") // this will register this element to <custom-popover/>
|
|
2014
|
+
*
|
|
2015
|
+
*/
|
|
2016
|
+
static register(name = "auro-popover") {
|
|
2017
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroPopover);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
connectedCallback() {
|
|
2021
|
+
super.connectedCallback();
|
|
2022
|
+
|
|
2023
|
+
this.privateDefaults();
|
|
2024
|
+
|
|
2025
|
+
// adds toggle function to root element based on touch
|
|
2026
|
+
this.addEventListener("touchstart", function () {
|
|
2027
|
+
this.toggle();
|
|
2028
|
+
this.setAttribute("isTouch", "true");
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
disconnectedCallback() {
|
|
2033
|
+
super.disconnectedCallback();
|
|
2034
|
+
document.removeEventListener("click", this.documentClickHandler);
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
firstUpdated() {
|
|
2038
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
2039
|
+
this.runtimeUtils.handleComponentTagRename(this, "auro-popover");
|
|
2040
|
+
|
|
2041
|
+
if (this.for) {
|
|
2042
|
+
this.trigger =
|
|
2043
|
+
document.querySelector(`#${this.for}`) ||
|
|
2044
|
+
this.getRootNode().querySelector(`#${this.for}`);
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
if (!this.trigger) {
|
|
2048
|
+
[this.trigger] = this.shadowRoot
|
|
2049
|
+
.querySelector('slot[name="trigger"]')
|
|
2050
|
+
.assignedElements();
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
this.auroPopover = this.shadowRoot.querySelector("#popover");
|
|
2054
|
+
this.popper = new Popover(
|
|
2055
|
+
this.trigger,
|
|
2056
|
+
this.auroPopover,
|
|
2057
|
+
this.placement,
|
|
2058
|
+
this.boundary,
|
|
2059
|
+
);
|
|
2060
|
+
|
|
2061
|
+
const handleShow = () => {
|
|
2062
|
+
this.toggleShow();
|
|
2063
|
+
};
|
|
2064
|
+
const handleHide = () => {
|
|
2065
|
+
this.toggleHide();
|
|
2066
|
+
};
|
|
2067
|
+
const handleKeyboardWhenFocusOnTrigger = (event) => {
|
|
2068
|
+
const key = event.key.toLowerCase();
|
|
2069
|
+
|
|
2070
|
+
if (this.isPopoverVisible) {
|
|
2071
|
+
if (key === "tab" || key === "escape") {
|
|
2072
|
+
this.toggleHide();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
if (key === " " || key === "enter") {
|
|
2077
|
+
this.toggle();
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
const element =
|
|
2081
|
+
this.trigger.parentElement.nodeName === "AURO-POPOVER"
|
|
2082
|
+
? this
|
|
2083
|
+
: this.trigger;
|
|
2084
|
+
|
|
2085
|
+
element.addEventListener("mouseenter", handleShow);
|
|
2086
|
+
element.addEventListener("mouseleave", handleHide);
|
|
2087
|
+
|
|
2088
|
+
// if user tabs off of trigger, then hide the popover.
|
|
2089
|
+
this.trigger.addEventListener("keydown", handleKeyboardWhenFocusOnTrigger);
|
|
2090
|
+
|
|
2091
|
+
// handle gain/loss of focus
|
|
2092
|
+
this.trigger.addEventListener("focus", handleShow);
|
|
2093
|
+
this.trigger.addEventListener("blur", handleHide);
|
|
2094
|
+
|
|
2095
|
+
// e.g. for a closePopover button in the popover
|
|
2096
|
+
this.addEventListener("hidePopover", handleHide);
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* Toggles the display of the popover content.
|
|
2101
|
+
* @private
|
|
2102
|
+
* @returns {void} Fires an update lifecycle.
|
|
2103
|
+
*/
|
|
2104
|
+
toggle() {
|
|
2105
|
+
if (this.isPopoverVisible) {
|
|
2106
|
+
this.toggleHide();
|
|
2107
|
+
} else {
|
|
2108
|
+
this.toggleShow();
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Hides the popover.
|
|
2114
|
+
* @private
|
|
2115
|
+
* @returns {void} Fires an update lifecycle.
|
|
2116
|
+
*/
|
|
2117
|
+
toggleHide() {
|
|
2118
|
+
this.popper.hide();
|
|
2119
|
+
this.isPopoverVisible = false;
|
|
2120
|
+
this.removeAttribute("data-show");
|
|
2121
|
+
|
|
2122
|
+
document
|
|
2123
|
+
.querySelector("body")
|
|
2124
|
+
.removeEventListener("mouseover", this.mouseoverHandler);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
/**
|
|
2128
|
+
* Shows the popover.
|
|
2129
|
+
* @private
|
|
2130
|
+
* @returns {void} Fires an update lifecycle.
|
|
2131
|
+
*/
|
|
2132
|
+
toggleShow() {
|
|
2133
|
+
this.popper.show();
|
|
2134
|
+
this.isPopoverVisible = true;
|
|
2135
|
+
this.setAttribute("data-show", true);
|
|
2136
|
+
|
|
2137
|
+
this.mouseoverHandler = (evt) => this.handleMouseoverEvent(evt);
|
|
2138
|
+
|
|
2139
|
+
document
|
|
2140
|
+
.querySelector("body")
|
|
2141
|
+
.addEventListener("mouseover", this.mouseoverHandler);
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* Hides the popover when hovering outside of the popover or it's trigger.
|
|
2146
|
+
* @private
|
|
2147
|
+
* @param {Event} evt - The event object.
|
|
2148
|
+
* @returns {void}
|
|
2149
|
+
*/
|
|
2150
|
+
handleMouseoverEvent(evt) {
|
|
2151
|
+
if (this.isPopoverVisible && !evt.composedPath().includes(this)) {
|
|
2152
|
+
this.toggleHide();
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
updated(changedProperties) {
|
|
2157
|
+
if (changedProperties.has("boundary")) {
|
|
2158
|
+
this.popper.boundaryElement = this.boundary;
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
2163
|
+
render() {
|
|
2164
|
+
return x`
|
|
2165
|
+
<div id="popover" class="popover util_insetLg body-default" aria-live="polite" part="popover">
|
|
2166
|
+
<div id="arrow" class="arrow" data-popper-arrow></div>
|
|
2167
|
+
<span role="tooltip" aria-labelledby="${this.id}"><slot></slot></span>
|
|
2168
|
+
</div>
|
|
2169
|
+
|
|
2170
|
+
<span id="${this.id}">
|
|
2171
|
+
<slot name="trigger" data-trigger-placement="${this.placement}"></slot>
|
|
2172
|
+
</span>
|
|
2173
|
+
`;
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
export { AuroPopover as A };
|