@aurodesignsystem-dev/auro-popover 0.0.0-pr131.2 → 0.0.0-pr131.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -41
- package/demo/api.md +144 -166
- package/demo/api.min.js +2670 -2
- package/demo/index.md +10 -12
- package/demo/index.min.js +2669 -1
- package/demo/readme.md +139 -0
- package/dist/auro-popover-Bu7mQ0Hu.js +19 -0
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +5 -5
- package/demo/auro-popover.min.js +0 -2655
- package/dist/auro-popover-BmBnLXlx.js +0 -19
package/demo/api.min.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { A as AuroPopover } from './auro-popover.min.js';
|
|
2
|
-
|
|
3
1
|
function boundaryExample() {
|
|
4
2
|
const boundaryExample = document.querySelector(".boundaryExample");
|
|
5
3
|
const popoverBoundary = document.querySelector("#popoverBoundary");
|
|
@@ -7,6 +5,2676 @@ function boundaryExample() {
|
|
|
7
5
|
boundaryExample.boundary = popoverBoundary;
|
|
8
6
|
}
|
|
9
7
|
|
|
8
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
9
|
+
// See LICENSE in the project root for license information.
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
14
|
+
|
|
15
|
+
class AuroLibraryRuntimeUtils {
|
|
16
|
+
|
|
17
|
+
/* eslint-disable jsdoc/require-param */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This will register a new custom element with the browser.
|
|
21
|
+
* @param {String} name - The name of the custom element.
|
|
22
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
registerComponent(name, componentClass) {
|
|
26
|
+
if (!customElements.get(name)) {
|
|
27
|
+
customElements.define(name, class extends componentClass {});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
closestElement(
|
|
36
|
+
selector, // selector like in .closest()
|
|
37
|
+
base = this, // extra functionality to skip a parent
|
|
38
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
39
|
+
!el || el === document || el === window
|
|
40
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
41
|
+
: found
|
|
42
|
+
? found // found a selector INside this element
|
|
43
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
44
|
+
) {
|
|
45
|
+
return __Closest(base);
|
|
46
|
+
}
|
|
47
|
+
/* eslint-enable jsdoc/require-param */
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 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.
|
|
51
|
+
* @param {Object} elem - The element to check.
|
|
52
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
handleComponentTagRename(elem, tagName) {
|
|
56
|
+
const tag = tagName.toLowerCase();
|
|
57
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
58
|
+
|
|
59
|
+
if (elemTag !== tag) {
|
|
60
|
+
elem.setAttribute(tag, true);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Validates if an element is a specific Auro component.
|
|
66
|
+
* @param {Object} elem - The element to validate.
|
|
67
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
68
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
69
|
+
*/
|
|
70
|
+
elementMatch(elem, tagName) {
|
|
71
|
+
const tag = tagName.toLowerCase();
|
|
72
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
73
|
+
|
|
74
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Gets the text content of a named slot.
|
|
79
|
+
* @returns {String}
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
getSlotText(elem, name) {
|
|
83
|
+
const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
|
|
84
|
+
const nodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
85
|
+
const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
|
|
86
|
+
|
|
87
|
+
return text || null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @license
|
|
93
|
+
* Copyright 2019 Google LLC
|
|
94
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
95
|
+
*/
|
|
96
|
+
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;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @license
|
|
100
|
+
* Copyright 2017 Google LLC
|
|
101
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
102
|
+
*/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$1={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$1){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$1}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,e=false,h){if(void 0!==t){const r=this.constructor;if(false===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$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.2");
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @license
|
|
106
|
+
* Copyright 2017 Google LLC
|
|
107
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
108
|
+
*/
|
|
109
|
+
const t=globalThis,i$1=t=>t,s$1=t.trustedTypes,e=s$1?s$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,h="$lit$",o$1=`lit$${Math.random().toFixed(9).slice(2)}$`,n="?"+o$1,r=`<${n}>`,l=document,c=()=>l.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,u=Array.isArray,d=t=>u(t)||"function"==typeof t?.[Symbol.iterator],f="[ \t\n\f\r]",v=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,m=/>/g,p=RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),g=/'/g,$=/"/g,y=/^(?:script|style|textarea|title)$/i,x=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),b=x(1),E=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),C=new WeakMap,P=l.createTreeWalker(l,129);function V(t,i){if(!u(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==e?e.createHTML(i):i}const N=(t,i)=>{const s=t.length-1,e=[];let n,l=2===i?"<svg>":3===i?"<math>":"",c=v;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,f=0;for(;f<s.length&&(c.lastIndex=f,u=c.exec(s),null!==u);)f=c.lastIndex,c===v?"!--"===u[1]?c=_:void 0!==u[1]?c=m:void 0!==u[2]?(y.test(u[2])&&(n=RegExp("</"+u[2],"g")),c=p):void 0!==u[3]&&(c=p):c===p?">"===u[0]?(c=n??v,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?p:'"'===u[3]?$:g):c===$||c===g?c=p:c===_||c===m?c=v:(c=p,n=void 0);const x=c===p&&t[i+1].startsWith("/>")?" ":"";l+=c===v?s+r:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o$1+x):s+o$1+(-2===d?i:x);}return [V(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),e]};class S{constructor({strings:t,_$litType$:i},e){let r;this.parts=[];let l=0,a=0;const u=t.length-1,d=this.parts,[f,v]=N(t,i);if(this.el=S.createElement(f,e),P.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=P.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(h)){const i=v[a++],s=r.getAttribute(t).split(o$1),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:l,name:e[2],strings:s,ctor:"."===e[1]?I:"?"===e[1]?L:"@"===e[1]?z:H}),r.removeAttribute(t);}else t.startsWith(o$1)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o$1),i=t.length-1;if(i>0){r.textContent=s$1?s$1.emptyScript:"";for(let s=0;s<i;s++)r.append(t[s],c()),P.nextNode(),d.push({type:2,index:++l});r.append(t[i],c());}}}else if(8===r.nodeType)if(r.data===n)d.push({type:2,index:l});else {let t=-1;for(;-1!==(t=r.data.indexOf(o$1,t+1));)d.push({type:7,index:l}),t+=o$1.length-1;}l++;}}static createElement(t,i){const s=l.createElement("template");return s.innerHTML=t,s}}function M(t,i,s=t,e){if(i===E)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=a(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=M(t,h._$AS(t,i.values),h,e)),i}class R{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??l).importNode(i,true);P.currentNode=e;let h=P.nextNode(),o=0,n=0,r=s[0];for(;void 0!==r;){if(o===r.index){let i;2===r.type?i=new k(h,h.nextSibling,this,t):1===r.type?i=new r.ctor(h,r.name,r.strings,this,t):6===r.type&&(i=new Z(h,this,t)),this._$AV.push(i),r=s[++n];}o!==r?.index&&(h=P.nextNode(),o++);}return P.currentNode=l,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 k{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=A,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=M(this,t,i),a(t)?t===A||null==t||""===t?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):d(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!==A&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.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=S.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new R(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=C.get(t.strings);return void 0===i&&C.set(t.strings,i=new S(t)),i}k(t){u(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 k(this.O(c()),this.O(c()),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,s){for(this._$AP?.(false,true,s);t!==this._$AB;){const s=i$1(t).nextSibling;i$1(t).remove(),t=s;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=A,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=A;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=M(this,t,i,0),o=!a(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=M(this,e[s+n],i,n),r===E&&(r=this._$AH[n]),o||=!a(r)||r!==this._$AH[n],r===A?t=A:t!==A&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class I extends H{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===A?void 0:t;}}class L extends H{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A);}}class z extends H{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=M(this,t,i,0)??A)===E)return;const s=this._$AH,e=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==A&&(s===A||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){M(this,t);}}const B=t.litHtmlPolyfillSupport;B?.(S,k),(t.litHtmlVersions??=[]).push("3.3.2");const D=(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 k(i.insertBefore(c(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @license
|
|
113
|
+
* Copyright 2017 Google LLC
|
|
114
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
115
|
+
*/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=D(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return E}}i._$litElement$=true,i["finalized"]=true,s.litElementHydrateSupport?.({LitElement:i});const o=s.litElementPolyfillSupport;o?.({LitElement:i});(s.litElementVersions??=[]).push("4.2.2");
|
|
116
|
+
|
|
117
|
+
var top = 'top';
|
|
118
|
+
var bottom = 'bottom';
|
|
119
|
+
var right = 'right';
|
|
120
|
+
var left = 'left';
|
|
121
|
+
var auto = 'auto';
|
|
122
|
+
var basePlacements = [top, bottom, right, left];
|
|
123
|
+
var start = 'start';
|
|
124
|
+
var end = 'end';
|
|
125
|
+
var clippingParents = 'clippingParents';
|
|
126
|
+
var viewport = 'viewport';
|
|
127
|
+
var popper = 'popper';
|
|
128
|
+
var reference = 'reference';
|
|
129
|
+
var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
|
|
130
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|
131
|
+
}, []);
|
|
132
|
+
var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
|
133
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
134
|
+
}, []); // modifiers that need to read the DOM
|
|
135
|
+
|
|
136
|
+
var beforeRead = 'beforeRead';
|
|
137
|
+
var read = 'read';
|
|
138
|
+
var afterRead = 'afterRead'; // pure-logic modifiers
|
|
139
|
+
|
|
140
|
+
var beforeMain = 'beforeMain';
|
|
141
|
+
var main = 'main';
|
|
142
|
+
var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
|
143
|
+
|
|
144
|
+
var beforeWrite = 'beforeWrite';
|
|
145
|
+
var write = 'write';
|
|
146
|
+
var afterWrite = 'afterWrite';
|
|
147
|
+
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
148
|
+
|
|
149
|
+
function getNodeName(element) {
|
|
150
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getWindow(node) {
|
|
154
|
+
if (node == null) {
|
|
155
|
+
return window;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (node.toString() !== '[object Window]') {
|
|
159
|
+
var ownerDocument = node.ownerDocument;
|
|
160
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return node;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function isElement(node) {
|
|
167
|
+
var OwnElement = getWindow(node).Element;
|
|
168
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function isHTMLElement(node) {
|
|
172
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
173
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function isShadowRoot(node) {
|
|
177
|
+
// IE 11 has no ShadowRoot
|
|
178
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
183
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// and applies them to the HTMLElements such as popper and arrow
|
|
187
|
+
|
|
188
|
+
function applyStyles(_ref) {
|
|
189
|
+
var state = _ref.state;
|
|
190
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
191
|
+
var style = state.styles[name] || {};
|
|
192
|
+
var attributes = state.attributes[name] || {};
|
|
193
|
+
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
194
|
+
|
|
195
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
196
|
+
return;
|
|
197
|
+
} // Flow doesn't support to extend this property, but it's the most
|
|
198
|
+
// effective way to apply styles to an HTMLElement
|
|
199
|
+
// $FlowFixMe[cannot-write]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
Object.assign(element.style, style);
|
|
203
|
+
Object.keys(attributes).forEach(function (name) {
|
|
204
|
+
var value = attributes[name];
|
|
205
|
+
|
|
206
|
+
if (value === false) {
|
|
207
|
+
element.removeAttribute(name);
|
|
208
|
+
} else {
|
|
209
|
+
element.setAttribute(name, value === true ? '' : value);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function effect$2(_ref2) {
|
|
216
|
+
var state = _ref2.state;
|
|
217
|
+
var initialStyles = {
|
|
218
|
+
popper: {
|
|
219
|
+
position: state.options.strategy,
|
|
220
|
+
left: '0',
|
|
221
|
+
top: '0',
|
|
222
|
+
margin: '0'
|
|
223
|
+
},
|
|
224
|
+
arrow: {
|
|
225
|
+
position: 'absolute'
|
|
226
|
+
},
|
|
227
|
+
reference: {}
|
|
228
|
+
};
|
|
229
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
230
|
+
state.styles = initialStyles;
|
|
231
|
+
|
|
232
|
+
if (state.elements.arrow) {
|
|
233
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return function () {
|
|
237
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
238
|
+
var element = state.elements[name];
|
|
239
|
+
var attributes = state.attributes[name] || {};
|
|
240
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
|
241
|
+
|
|
242
|
+
var style = styleProperties.reduce(function (style, property) {
|
|
243
|
+
style[property] = '';
|
|
244
|
+
return style;
|
|
245
|
+
}, {}); // arrow is optional + virtual elements
|
|
246
|
+
|
|
247
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
Object.assign(element.style, style);
|
|
252
|
+
Object.keys(attributes).forEach(function (attribute) {
|
|
253
|
+
element.removeAttribute(attribute);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
var applyStyles$1 = {
|
|
261
|
+
name: 'applyStyles',
|
|
262
|
+
enabled: true,
|
|
263
|
+
phase: 'write',
|
|
264
|
+
fn: applyStyles,
|
|
265
|
+
effect: effect$2,
|
|
266
|
+
requires: ['computeStyles']
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
function getBasePlacement(placement) {
|
|
270
|
+
return placement.split('-')[0];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var max = Math.max;
|
|
274
|
+
var min = Math.min;
|
|
275
|
+
var round = Math.round;
|
|
276
|
+
|
|
277
|
+
function getUAString() {
|
|
278
|
+
var uaData = navigator.userAgentData;
|
|
279
|
+
|
|
280
|
+
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
|
281
|
+
return uaData.brands.map(function (item) {
|
|
282
|
+
return item.brand + "/" + item.version;
|
|
283
|
+
}).join(' ');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return navigator.userAgent;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function isLayoutViewport() {
|
|
290
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
294
|
+
if (includeScale === void 0) {
|
|
295
|
+
includeScale = false;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (isFixedStrategy === void 0) {
|
|
299
|
+
isFixedStrategy = false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var clientRect = element.getBoundingClientRect();
|
|
303
|
+
var scaleX = 1;
|
|
304
|
+
var scaleY = 1;
|
|
305
|
+
|
|
306
|
+
if (includeScale && isHTMLElement(element)) {
|
|
307
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
308
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
312
|
+
visualViewport = _ref.visualViewport;
|
|
313
|
+
|
|
314
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
315
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
316
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
317
|
+
var width = clientRect.width / scaleX;
|
|
318
|
+
var height = clientRect.height / scaleY;
|
|
319
|
+
return {
|
|
320
|
+
width: width,
|
|
321
|
+
height: height,
|
|
322
|
+
top: y,
|
|
323
|
+
right: x + width,
|
|
324
|
+
bottom: y + height,
|
|
325
|
+
left: x,
|
|
326
|
+
x: x,
|
|
327
|
+
y: y
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// means it doesn't take into account transforms.
|
|
332
|
+
|
|
333
|
+
function getLayoutRect(element) {
|
|
334
|
+
var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
|
|
335
|
+
// Fixes https://github.com/popperjs/popper-core/issues/1223
|
|
336
|
+
|
|
337
|
+
var width = element.offsetWidth;
|
|
338
|
+
var height = element.offsetHeight;
|
|
339
|
+
|
|
340
|
+
if (Math.abs(clientRect.width - width) <= 1) {
|
|
341
|
+
width = clientRect.width;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (Math.abs(clientRect.height - height) <= 1) {
|
|
345
|
+
height = clientRect.height;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
x: element.offsetLeft,
|
|
350
|
+
y: element.offsetTop,
|
|
351
|
+
width: width,
|
|
352
|
+
height: height
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function contains(parent, child) {
|
|
357
|
+
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
|
358
|
+
|
|
359
|
+
if (parent.contains(child)) {
|
|
360
|
+
return true;
|
|
361
|
+
} // then fallback to custom implementation with Shadow DOM support
|
|
362
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
|
363
|
+
var next = child;
|
|
364
|
+
|
|
365
|
+
do {
|
|
366
|
+
if (next && parent.isSameNode(next)) {
|
|
367
|
+
return true;
|
|
368
|
+
} // $FlowFixMe[prop-missing]: need a better way to handle this...
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
next = next.parentNode || next.host;
|
|
372
|
+
} while (next);
|
|
373
|
+
} // Give up, the result is false
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function getComputedStyle(element) {
|
|
380
|
+
return getWindow(element).getComputedStyle(element);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function isTableElement(element) {
|
|
384
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function getDocumentElement(element) {
|
|
388
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
389
|
+
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
|
|
390
|
+
element.document) || window.document).documentElement;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function getParentNode(element) {
|
|
394
|
+
if (getNodeName(element) === 'html') {
|
|
395
|
+
return element;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
399
|
+
// $FlowFixMe[incompatible-return]
|
|
400
|
+
// $FlowFixMe[prop-missing]
|
|
401
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
402
|
+
element.parentNode || ( // DOM Element detected
|
|
403
|
+
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|
404
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|
405
|
+
getDocumentElement(element) // fallback
|
|
406
|
+
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function getTrueOffsetParent(element) {
|
|
411
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
412
|
+
getComputedStyle(element).position === 'fixed') {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return element.offsetParent;
|
|
417
|
+
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
|
418
|
+
// return the containing block
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
function getContainingBlock(element) {
|
|
422
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
423
|
+
var isIE = /Trident/i.test(getUAString());
|
|
424
|
+
|
|
425
|
+
if (isIE && isHTMLElement(element)) {
|
|
426
|
+
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
427
|
+
var elementCss = getComputedStyle(element);
|
|
428
|
+
|
|
429
|
+
if (elementCss.position === 'fixed') {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
var currentNode = getParentNode(element);
|
|
435
|
+
|
|
436
|
+
if (isShadowRoot(currentNode)) {
|
|
437
|
+
currentNode = currentNode.host;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
441
|
+
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
442
|
+
// create a containing block.
|
|
443
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
444
|
+
|
|
445
|
+
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') {
|
|
446
|
+
return currentNode;
|
|
447
|
+
} else {
|
|
448
|
+
currentNode = currentNode.parentNode;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return null;
|
|
453
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
454
|
+
// such as table ancestors and cross browser bugs.
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
function getOffsetParent(element) {
|
|
458
|
+
var window = getWindow(element);
|
|
459
|
+
var offsetParent = getTrueOffsetParent(element);
|
|
460
|
+
|
|
461
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
462
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
|
466
|
+
return window;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function getMainAxisFromPlacement(placement) {
|
|
473
|
+
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function within(min$1, value, max$1) {
|
|
477
|
+
return max(min$1, min(value, max$1));
|
|
478
|
+
}
|
|
479
|
+
function withinMaxClamp(min, value, max) {
|
|
480
|
+
var v = within(min, value, max);
|
|
481
|
+
return v > max ? max : v;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function getFreshSideObject() {
|
|
485
|
+
return {
|
|
486
|
+
top: 0,
|
|
487
|
+
right: 0,
|
|
488
|
+
bottom: 0,
|
|
489
|
+
left: 0
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function mergePaddingObject(paddingObject) {
|
|
494
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function expandToHashMap(value, keys) {
|
|
498
|
+
return keys.reduce(function (hashMap, key) {
|
|
499
|
+
hashMap[key] = value;
|
|
500
|
+
return hashMap;
|
|
501
|
+
}, {});
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
var toPaddingObject = function toPaddingObject(padding, state) {
|
|
505
|
+
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
|
506
|
+
placement: state.placement
|
|
507
|
+
})) : padding;
|
|
508
|
+
return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
function arrow(_ref) {
|
|
512
|
+
var _state$modifiersData$;
|
|
513
|
+
|
|
514
|
+
var state = _ref.state,
|
|
515
|
+
name = _ref.name,
|
|
516
|
+
options = _ref.options;
|
|
517
|
+
var arrowElement = state.elements.arrow;
|
|
518
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
519
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
520
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
|
521
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
522
|
+
var len = isVertical ? 'height' : 'width';
|
|
523
|
+
|
|
524
|
+
if (!arrowElement || !popperOffsets) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
|
529
|
+
var arrowRect = getLayoutRect(arrowElement);
|
|
530
|
+
var minProp = axis === 'y' ? top : left;
|
|
531
|
+
var maxProp = axis === 'y' ? bottom : right;
|
|
532
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
|
533
|
+
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
|
534
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
535
|
+
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
536
|
+
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
|
537
|
+
// outside of the popper bounds
|
|
538
|
+
|
|
539
|
+
var min = paddingObject[minProp];
|
|
540
|
+
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
541
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
542
|
+
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
|
543
|
+
|
|
544
|
+
var axisProp = axis;
|
|
545
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function effect$1(_ref2) {
|
|
549
|
+
var state = _ref2.state,
|
|
550
|
+
options = _ref2.options;
|
|
551
|
+
var _options$element = options.element,
|
|
552
|
+
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
|
553
|
+
|
|
554
|
+
if (arrowElement == null) {
|
|
555
|
+
return;
|
|
556
|
+
} // CSS selector
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
if (typeof arrowElement === 'string') {
|
|
560
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
561
|
+
|
|
562
|
+
if (!arrowElement) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
state.elements.arrow = arrowElement;
|
|
572
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
var arrow$1 = {
|
|
576
|
+
name: 'arrow',
|
|
577
|
+
enabled: true,
|
|
578
|
+
phase: 'main',
|
|
579
|
+
fn: arrow,
|
|
580
|
+
effect: effect$1,
|
|
581
|
+
requires: ['popperOffsets'],
|
|
582
|
+
requiresIfExists: ['preventOverflow']
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
function getVariation(placement) {
|
|
586
|
+
return placement.split('-')[1];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
var unsetSides = {
|
|
590
|
+
top: 'auto',
|
|
591
|
+
right: 'auto',
|
|
592
|
+
bottom: 'auto',
|
|
593
|
+
left: 'auto'
|
|
594
|
+
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
|
595
|
+
// Zooming can change the DPR, but it seems to report a value that will
|
|
596
|
+
// cleanly divide the values into the appropriate subpixels.
|
|
597
|
+
|
|
598
|
+
function roundOffsetsByDPR(_ref, win) {
|
|
599
|
+
var x = _ref.x,
|
|
600
|
+
y = _ref.y;
|
|
601
|
+
var dpr = win.devicePixelRatio || 1;
|
|
602
|
+
return {
|
|
603
|
+
x: round(x * dpr) / dpr || 0,
|
|
604
|
+
y: round(y * dpr) / dpr || 0
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function mapToStyles(_ref2) {
|
|
609
|
+
var _Object$assign2;
|
|
610
|
+
|
|
611
|
+
var popper = _ref2.popper,
|
|
612
|
+
popperRect = _ref2.popperRect,
|
|
613
|
+
placement = _ref2.placement,
|
|
614
|
+
variation = _ref2.variation,
|
|
615
|
+
offsets = _ref2.offsets,
|
|
616
|
+
position = _ref2.position,
|
|
617
|
+
gpuAcceleration = _ref2.gpuAcceleration,
|
|
618
|
+
adaptive = _ref2.adaptive,
|
|
619
|
+
roundOffsets = _ref2.roundOffsets,
|
|
620
|
+
isFixed = _ref2.isFixed;
|
|
621
|
+
var _offsets$x = offsets.x,
|
|
622
|
+
x = _offsets$x === void 0 ? 0 : _offsets$x,
|
|
623
|
+
_offsets$y = offsets.y,
|
|
624
|
+
y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
625
|
+
|
|
626
|
+
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
|
627
|
+
x: x,
|
|
628
|
+
y: y
|
|
629
|
+
}) : {
|
|
630
|
+
x: x,
|
|
631
|
+
y: y
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
x = _ref3.x;
|
|
635
|
+
y = _ref3.y;
|
|
636
|
+
var hasX = offsets.hasOwnProperty('x');
|
|
637
|
+
var hasY = offsets.hasOwnProperty('y');
|
|
638
|
+
var sideX = left;
|
|
639
|
+
var sideY = top;
|
|
640
|
+
var win = window;
|
|
641
|
+
|
|
642
|
+
if (adaptive) {
|
|
643
|
+
var offsetParent = getOffsetParent(popper);
|
|
644
|
+
var heightProp = 'clientHeight';
|
|
645
|
+
var widthProp = 'clientWidth';
|
|
646
|
+
|
|
647
|
+
if (offsetParent === getWindow(popper)) {
|
|
648
|
+
offsetParent = getDocumentElement(popper);
|
|
649
|
+
|
|
650
|
+
if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
|
|
651
|
+
heightProp = 'scrollHeight';
|
|
652
|
+
widthProp = 'scrollWidth';
|
|
653
|
+
}
|
|
654
|
+
} // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
offsetParent = offsetParent;
|
|
658
|
+
|
|
659
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
660
|
+
sideY = bottom;
|
|
661
|
+
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
|
|
662
|
+
offsetParent[heightProp];
|
|
663
|
+
y -= offsetY - popperRect.height;
|
|
664
|
+
y *= gpuAcceleration ? 1 : -1;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
668
|
+
sideX = right;
|
|
669
|
+
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
|
|
670
|
+
offsetParent[widthProp];
|
|
671
|
+
x -= offsetX - popperRect.width;
|
|
672
|
+
x *= gpuAcceleration ? 1 : -1;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
var commonStyles = Object.assign({
|
|
677
|
+
position: position
|
|
678
|
+
}, adaptive && unsetSides);
|
|
679
|
+
|
|
680
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
681
|
+
x: x,
|
|
682
|
+
y: y
|
|
683
|
+
}, getWindow(popper)) : {
|
|
684
|
+
x: x,
|
|
685
|
+
y: y
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
x = _ref4.x;
|
|
689
|
+
y = _ref4.y;
|
|
690
|
+
|
|
691
|
+
if (gpuAcceleration) {
|
|
692
|
+
var _Object$assign;
|
|
693
|
+
|
|
694
|
+
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));
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function computeStyles(_ref5) {
|
|
701
|
+
var state = _ref5.state,
|
|
702
|
+
options = _ref5.options;
|
|
703
|
+
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
704
|
+
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
705
|
+
_options$adaptive = options.adaptive,
|
|
706
|
+
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
|
707
|
+
_options$roundOffsets = options.roundOffsets,
|
|
708
|
+
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
709
|
+
var commonStyles = {
|
|
710
|
+
placement: getBasePlacement(state.placement),
|
|
711
|
+
variation: getVariation(state.placement),
|
|
712
|
+
popper: state.elements.popper,
|
|
713
|
+
popperRect: state.rects.popper,
|
|
714
|
+
gpuAcceleration: gpuAcceleration,
|
|
715
|
+
isFixed: state.options.strategy === 'fixed'
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
719
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|
720
|
+
offsets: state.modifiersData.popperOffsets,
|
|
721
|
+
position: state.options.strategy,
|
|
722
|
+
adaptive: adaptive,
|
|
723
|
+
roundOffsets: roundOffsets
|
|
724
|
+
})));
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (state.modifiersData.arrow != null) {
|
|
728
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|
729
|
+
offsets: state.modifiersData.arrow,
|
|
730
|
+
position: 'absolute',
|
|
731
|
+
adaptive: false,
|
|
732
|
+
roundOffsets: roundOffsets
|
|
733
|
+
})));
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
737
|
+
'data-popper-placement': state.placement
|
|
738
|
+
});
|
|
739
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
var computeStyles$1 = {
|
|
743
|
+
name: 'computeStyles',
|
|
744
|
+
enabled: true,
|
|
745
|
+
phase: 'beforeWrite',
|
|
746
|
+
fn: computeStyles,
|
|
747
|
+
data: {}
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
var passive = {
|
|
751
|
+
passive: true
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
function effect(_ref) {
|
|
755
|
+
var state = _ref.state,
|
|
756
|
+
instance = _ref.instance,
|
|
757
|
+
options = _ref.options;
|
|
758
|
+
var _options$scroll = options.scroll,
|
|
759
|
+
scroll = _options$scroll === void 0 ? true : _options$scroll,
|
|
760
|
+
_options$resize = options.resize,
|
|
761
|
+
resize = _options$resize === void 0 ? true : _options$resize;
|
|
762
|
+
var window = getWindow(state.elements.popper);
|
|
763
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
764
|
+
|
|
765
|
+
if (scroll) {
|
|
766
|
+
scrollParents.forEach(function (scrollParent) {
|
|
767
|
+
scrollParent.addEventListener('scroll', instance.update, passive);
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (resize) {
|
|
772
|
+
window.addEventListener('resize', instance.update, passive);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return function () {
|
|
776
|
+
if (scroll) {
|
|
777
|
+
scrollParents.forEach(function (scrollParent) {
|
|
778
|
+
scrollParent.removeEventListener('scroll', instance.update, passive);
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
if (resize) {
|
|
783
|
+
window.removeEventListener('resize', instance.update, passive);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
var eventListeners = {
|
|
790
|
+
name: 'eventListeners',
|
|
791
|
+
enabled: true,
|
|
792
|
+
phase: 'write',
|
|
793
|
+
fn: function fn() {},
|
|
794
|
+
effect: effect,
|
|
795
|
+
data: {}
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
var hash$1 = {
|
|
799
|
+
left: 'right',
|
|
800
|
+
right: 'left',
|
|
801
|
+
bottom: 'top',
|
|
802
|
+
top: 'bottom'
|
|
803
|
+
};
|
|
804
|
+
function getOppositePlacement(placement) {
|
|
805
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
806
|
+
return hash$1[matched];
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
var hash = {
|
|
811
|
+
start: 'end',
|
|
812
|
+
end: 'start'
|
|
813
|
+
};
|
|
814
|
+
function getOppositeVariationPlacement(placement) {
|
|
815
|
+
return placement.replace(/start|end/g, function (matched) {
|
|
816
|
+
return hash[matched];
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
function getWindowScroll(node) {
|
|
821
|
+
var win = getWindow(node);
|
|
822
|
+
var scrollLeft = win.pageXOffset;
|
|
823
|
+
var scrollTop = win.pageYOffset;
|
|
824
|
+
return {
|
|
825
|
+
scrollLeft: scrollLeft,
|
|
826
|
+
scrollTop: scrollTop
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function getWindowScrollBarX(element) {
|
|
831
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
832
|
+
// incorrect for RTL.
|
|
833
|
+
// Popper 1 is broken in this case and never had a bug report so let's assume
|
|
834
|
+
// it's not an issue. I don't think anyone ever specifies width on <html>
|
|
835
|
+
// anyway.
|
|
836
|
+
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
|
837
|
+
// this (e.g. Edge 2019, IE11, Safari)
|
|
838
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function getViewportRect(element, strategy) {
|
|
842
|
+
var win = getWindow(element);
|
|
843
|
+
var html = getDocumentElement(element);
|
|
844
|
+
var visualViewport = win.visualViewport;
|
|
845
|
+
var width = html.clientWidth;
|
|
846
|
+
var height = html.clientHeight;
|
|
847
|
+
var x = 0;
|
|
848
|
+
var y = 0;
|
|
849
|
+
|
|
850
|
+
if (visualViewport) {
|
|
851
|
+
width = visualViewport.width;
|
|
852
|
+
height = visualViewport.height;
|
|
853
|
+
var layoutViewport = isLayoutViewport();
|
|
854
|
+
|
|
855
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
856
|
+
x = visualViewport.offsetLeft;
|
|
857
|
+
y = visualViewport.offsetTop;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
return {
|
|
862
|
+
width: width,
|
|
863
|
+
height: height,
|
|
864
|
+
x: x + getWindowScrollBarX(element),
|
|
865
|
+
y: y
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
870
|
+
|
|
871
|
+
function getDocumentRect(element) {
|
|
872
|
+
var _element$ownerDocumen;
|
|
873
|
+
|
|
874
|
+
var html = getDocumentElement(element);
|
|
875
|
+
var winScroll = getWindowScroll(element);
|
|
876
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
877
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
878
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
879
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
880
|
+
var y = -winScroll.scrollTop;
|
|
881
|
+
|
|
882
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
883
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
return {
|
|
887
|
+
width: width,
|
|
888
|
+
height: height,
|
|
889
|
+
x: x,
|
|
890
|
+
y: y
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
function isScrollParent(element) {
|
|
895
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
896
|
+
var _getComputedStyle = getComputedStyle(element),
|
|
897
|
+
overflow = _getComputedStyle.overflow,
|
|
898
|
+
overflowX = _getComputedStyle.overflowX,
|
|
899
|
+
overflowY = _getComputedStyle.overflowY;
|
|
900
|
+
|
|
901
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function getScrollParent(node) {
|
|
905
|
+
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
|
906
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
907
|
+
return node.ownerDocument.body;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
911
|
+
return node;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
return getScrollParent(getParentNode(node));
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/*
|
|
918
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
919
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
|
920
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
921
|
+
reference element's position.
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
function listScrollParents(element, list) {
|
|
925
|
+
var _element$ownerDocumen;
|
|
926
|
+
|
|
927
|
+
if (list === void 0) {
|
|
928
|
+
list = [];
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
var scrollParent = getScrollParent(element);
|
|
932
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
933
|
+
var win = getWindow(scrollParent);
|
|
934
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
935
|
+
var updatedList = list.concat(target);
|
|
936
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
937
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function rectToClientRect(rect) {
|
|
941
|
+
return Object.assign({}, rect, {
|
|
942
|
+
left: rect.x,
|
|
943
|
+
top: rect.y,
|
|
944
|
+
right: rect.x + rect.width,
|
|
945
|
+
bottom: rect.y + rect.height
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
950
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
951
|
+
rect.top = rect.top + element.clientTop;
|
|
952
|
+
rect.left = rect.left + element.clientLeft;
|
|
953
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
954
|
+
rect.right = rect.left + element.clientWidth;
|
|
955
|
+
rect.width = element.clientWidth;
|
|
956
|
+
rect.height = element.clientHeight;
|
|
957
|
+
rect.x = rect.left;
|
|
958
|
+
rect.y = rect.top;
|
|
959
|
+
return rect;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
963
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
964
|
+
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
965
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
966
|
+
// `initial`
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
function getClippingParents(element) {
|
|
970
|
+
var clippingParents = listScrollParents(getParentNode(element));
|
|
971
|
+
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
972
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
973
|
+
|
|
974
|
+
if (!isElement(clipperElement)) {
|
|
975
|
+
return [];
|
|
976
|
+
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
return clippingParents.filter(function (clippingParent) {
|
|
980
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
|
981
|
+
});
|
|
982
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
|
983
|
+
// clipping parents
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
987
|
+
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
988
|
+
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
989
|
+
var firstClippingParent = clippingParents[0];
|
|
990
|
+
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
991
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
992
|
+
accRect.top = max(rect.top, accRect.top);
|
|
993
|
+
accRect.right = min(rect.right, accRect.right);
|
|
994
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
995
|
+
accRect.left = max(rect.left, accRect.left);
|
|
996
|
+
return accRect;
|
|
997
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
998
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
999
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
1000
|
+
clippingRect.x = clippingRect.left;
|
|
1001
|
+
clippingRect.y = clippingRect.top;
|
|
1002
|
+
return clippingRect;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function computeOffsets(_ref) {
|
|
1006
|
+
var reference = _ref.reference,
|
|
1007
|
+
element = _ref.element,
|
|
1008
|
+
placement = _ref.placement;
|
|
1009
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|
1010
|
+
var variation = placement ? getVariation(placement) : null;
|
|
1011
|
+
var commonX = reference.x + reference.width / 2 - element.width / 2;
|
|
1012
|
+
var commonY = reference.y + reference.height / 2 - element.height / 2;
|
|
1013
|
+
var offsets;
|
|
1014
|
+
|
|
1015
|
+
switch (basePlacement) {
|
|
1016
|
+
case top:
|
|
1017
|
+
offsets = {
|
|
1018
|
+
x: commonX,
|
|
1019
|
+
y: reference.y - element.height
|
|
1020
|
+
};
|
|
1021
|
+
break;
|
|
1022
|
+
|
|
1023
|
+
case bottom:
|
|
1024
|
+
offsets = {
|
|
1025
|
+
x: commonX,
|
|
1026
|
+
y: reference.y + reference.height
|
|
1027
|
+
};
|
|
1028
|
+
break;
|
|
1029
|
+
|
|
1030
|
+
case right:
|
|
1031
|
+
offsets = {
|
|
1032
|
+
x: reference.x + reference.width,
|
|
1033
|
+
y: commonY
|
|
1034
|
+
};
|
|
1035
|
+
break;
|
|
1036
|
+
|
|
1037
|
+
case left:
|
|
1038
|
+
offsets = {
|
|
1039
|
+
x: reference.x - element.width,
|
|
1040
|
+
y: commonY
|
|
1041
|
+
};
|
|
1042
|
+
break;
|
|
1043
|
+
|
|
1044
|
+
default:
|
|
1045
|
+
offsets = {
|
|
1046
|
+
x: reference.x,
|
|
1047
|
+
y: reference.y
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|
1052
|
+
|
|
1053
|
+
if (mainAxis != null) {
|
|
1054
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
1055
|
+
|
|
1056
|
+
switch (variation) {
|
|
1057
|
+
case start:
|
|
1058
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
|
1059
|
+
break;
|
|
1060
|
+
|
|
1061
|
+
case end:
|
|
1062
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
return offsets;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
function detectOverflow(state, options) {
|
|
1071
|
+
if (options === void 0) {
|
|
1072
|
+
options = {};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
var _options = options,
|
|
1076
|
+
_options$placement = _options.placement,
|
|
1077
|
+
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
1078
|
+
_options$strategy = _options.strategy,
|
|
1079
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
1080
|
+
_options$boundary = _options.boundary,
|
|
1081
|
+
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
1082
|
+
_options$rootBoundary = _options.rootBoundary,
|
|
1083
|
+
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
|
1084
|
+
_options$elementConte = _options.elementContext,
|
|
1085
|
+
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
|
1086
|
+
_options$altBoundary = _options.altBoundary,
|
|
1087
|
+
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
|
1088
|
+
_options$padding = _options.padding,
|
|
1089
|
+
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
1090
|
+
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
1091
|
+
var altContext = elementContext === popper ? reference : popper;
|
|
1092
|
+
var popperRect = state.rects.popper;
|
|
1093
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
1094
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
1095
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
1096
|
+
var popperOffsets = computeOffsets({
|
|
1097
|
+
reference: referenceClientRect,
|
|
1098
|
+
element: popperRect,
|
|
1099
|
+
placement: placement
|
|
1100
|
+
});
|
|
1101
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
|
1102
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
|
1103
|
+
// 0 or negative = within the clipping rect
|
|
1104
|
+
|
|
1105
|
+
var overflowOffsets = {
|
|
1106
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
1107
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
1108
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
1109
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
1110
|
+
};
|
|
1111
|
+
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
|
1112
|
+
|
|
1113
|
+
if (elementContext === popper && offsetData) {
|
|
1114
|
+
var offset = offsetData[placement];
|
|
1115
|
+
Object.keys(overflowOffsets).forEach(function (key) {
|
|
1116
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
1117
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
|
1118
|
+
overflowOffsets[key] += offset[axis] * multiply;
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
return overflowOffsets;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function computeAutoPlacement(state, options) {
|
|
1126
|
+
if (options === void 0) {
|
|
1127
|
+
options = {};
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
var _options = options,
|
|
1131
|
+
placement = _options.placement,
|
|
1132
|
+
boundary = _options.boundary,
|
|
1133
|
+
rootBoundary = _options.rootBoundary,
|
|
1134
|
+
padding = _options.padding,
|
|
1135
|
+
flipVariations = _options.flipVariations,
|
|
1136
|
+
_options$allowedAutoP = _options.allowedAutoPlacements,
|
|
1137
|
+
allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
|
1138
|
+
var variation = getVariation(placement);
|
|
1139
|
+
var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
|
1140
|
+
return getVariation(placement) === variation;
|
|
1141
|
+
}) : basePlacements;
|
|
1142
|
+
var allowedPlacements = placements$1.filter(function (placement) {
|
|
1143
|
+
return allowedAutoPlacements.indexOf(placement) >= 0;
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
if (allowedPlacements.length === 0) {
|
|
1147
|
+
allowedPlacements = placements$1;
|
|
1148
|
+
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
var overflows = allowedPlacements.reduce(function (acc, placement) {
|
|
1152
|
+
acc[placement] = detectOverflow(state, {
|
|
1153
|
+
placement: placement,
|
|
1154
|
+
boundary: boundary,
|
|
1155
|
+
rootBoundary: rootBoundary,
|
|
1156
|
+
padding: padding
|
|
1157
|
+
})[getBasePlacement(placement)];
|
|
1158
|
+
return acc;
|
|
1159
|
+
}, {});
|
|
1160
|
+
return Object.keys(overflows).sort(function (a, b) {
|
|
1161
|
+
return overflows[a] - overflows[b];
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function getExpandedFallbackPlacements(placement) {
|
|
1166
|
+
if (getBasePlacement(placement) === auto) {
|
|
1167
|
+
return [];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
1171
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
function flip(_ref) {
|
|
1175
|
+
var state = _ref.state,
|
|
1176
|
+
options = _ref.options,
|
|
1177
|
+
name = _ref.name;
|
|
1178
|
+
|
|
1179
|
+
if (state.modifiersData[name]._skip) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
var _options$mainAxis = options.mainAxis,
|
|
1184
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
1185
|
+
_options$altAxis = options.altAxis,
|
|
1186
|
+
checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
|
1187
|
+
specifiedFallbackPlacements = options.fallbackPlacements,
|
|
1188
|
+
padding = options.padding,
|
|
1189
|
+
boundary = options.boundary,
|
|
1190
|
+
rootBoundary = options.rootBoundary,
|
|
1191
|
+
altBoundary = options.altBoundary,
|
|
1192
|
+
_options$flipVariatio = options.flipVariations,
|
|
1193
|
+
flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
|
1194
|
+
allowedAutoPlacements = options.allowedAutoPlacements;
|
|
1195
|
+
var preferredPlacement = state.options.placement;
|
|
1196
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
|
1197
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
|
1198
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|
1199
|
+
var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
|
1200
|
+
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
|
1201
|
+
placement: placement,
|
|
1202
|
+
boundary: boundary,
|
|
1203
|
+
rootBoundary: rootBoundary,
|
|
1204
|
+
padding: padding,
|
|
1205
|
+
flipVariations: flipVariations,
|
|
1206
|
+
allowedAutoPlacements: allowedAutoPlacements
|
|
1207
|
+
}) : placement);
|
|
1208
|
+
}, []);
|
|
1209
|
+
var referenceRect = state.rects.reference;
|
|
1210
|
+
var popperRect = state.rects.popper;
|
|
1211
|
+
var checksMap = new Map();
|
|
1212
|
+
var makeFallbackChecks = true;
|
|
1213
|
+
var firstFittingPlacement = placements[0];
|
|
1214
|
+
|
|
1215
|
+
for (var i = 0; i < placements.length; i++) {
|
|
1216
|
+
var placement = placements[i];
|
|
1217
|
+
|
|
1218
|
+
var _basePlacement = getBasePlacement(placement);
|
|
1219
|
+
|
|
1220
|
+
var isStartVariation = getVariation(placement) === start;
|
|
1221
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
1222
|
+
var len = isVertical ? 'width' : 'height';
|
|
1223
|
+
var overflow = detectOverflow(state, {
|
|
1224
|
+
placement: placement,
|
|
1225
|
+
boundary: boundary,
|
|
1226
|
+
rootBoundary: rootBoundary,
|
|
1227
|
+
altBoundary: altBoundary,
|
|
1228
|
+
padding: padding
|
|
1229
|
+
});
|
|
1230
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
1231
|
+
|
|
1232
|
+
if (referenceRect[len] > popperRect[len]) {
|
|
1233
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
1237
|
+
var checks = [];
|
|
1238
|
+
|
|
1239
|
+
if (checkMainAxis) {
|
|
1240
|
+
checks.push(overflow[_basePlacement] <= 0);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
if (checkAltAxis) {
|
|
1244
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
if (checks.every(function (check) {
|
|
1248
|
+
return check;
|
|
1249
|
+
})) {
|
|
1250
|
+
firstFittingPlacement = placement;
|
|
1251
|
+
makeFallbackChecks = false;
|
|
1252
|
+
break;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
checksMap.set(placement, checks);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
if (makeFallbackChecks) {
|
|
1259
|
+
// `2` may be desired in some cases – research later
|
|
1260
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
|
1261
|
+
|
|
1262
|
+
var _loop = function _loop(_i) {
|
|
1263
|
+
var fittingPlacement = placements.find(function (placement) {
|
|
1264
|
+
var checks = checksMap.get(placement);
|
|
1265
|
+
|
|
1266
|
+
if (checks) {
|
|
1267
|
+
return checks.slice(0, _i).every(function (check) {
|
|
1268
|
+
return check;
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
if (fittingPlacement) {
|
|
1274
|
+
firstFittingPlacement = fittingPlacement;
|
|
1275
|
+
return "break";
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
1280
|
+
var _ret = _loop(_i);
|
|
1281
|
+
|
|
1282
|
+
if (_ret === "break") break;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
if (state.placement !== firstFittingPlacement) {
|
|
1287
|
+
state.modifiersData[name]._skip = true;
|
|
1288
|
+
state.placement = firstFittingPlacement;
|
|
1289
|
+
state.reset = true;
|
|
1290
|
+
}
|
|
1291
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
var flip$1 = {
|
|
1295
|
+
name: 'flip',
|
|
1296
|
+
enabled: true,
|
|
1297
|
+
phase: 'main',
|
|
1298
|
+
fn: flip,
|
|
1299
|
+
requiresIfExists: ['offset'],
|
|
1300
|
+
data: {
|
|
1301
|
+
_skip: false
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
function getSideOffsets(overflow, rect, preventedOffsets) {
|
|
1306
|
+
if (preventedOffsets === void 0) {
|
|
1307
|
+
preventedOffsets = {
|
|
1308
|
+
x: 0,
|
|
1309
|
+
y: 0
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
return {
|
|
1314
|
+
top: overflow.top - rect.height - preventedOffsets.y,
|
|
1315
|
+
right: overflow.right - rect.width + preventedOffsets.x,
|
|
1316
|
+
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|
1317
|
+
left: overflow.left - rect.width - preventedOffsets.x
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
function isAnySideFullyClipped(overflow) {
|
|
1322
|
+
return [top, right, bottom, left].some(function (side) {
|
|
1323
|
+
return overflow[side] >= 0;
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function hide(_ref) {
|
|
1328
|
+
var state = _ref.state,
|
|
1329
|
+
name = _ref.name;
|
|
1330
|
+
var referenceRect = state.rects.reference;
|
|
1331
|
+
var popperRect = state.rects.popper;
|
|
1332
|
+
var preventedOffsets = state.modifiersData.preventOverflow;
|
|
1333
|
+
var referenceOverflow = detectOverflow(state, {
|
|
1334
|
+
elementContext: 'reference'
|
|
1335
|
+
});
|
|
1336
|
+
var popperAltOverflow = detectOverflow(state, {
|
|
1337
|
+
altBoundary: true
|
|
1338
|
+
});
|
|
1339
|
+
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|
1340
|
+
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|
1341
|
+
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|
1342
|
+
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|
1343
|
+
state.modifiersData[name] = {
|
|
1344
|
+
referenceClippingOffsets: referenceClippingOffsets,
|
|
1345
|
+
popperEscapeOffsets: popperEscapeOffsets,
|
|
1346
|
+
isReferenceHidden: isReferenceHidden,
|
|
1347
|
+
hasPopperEscaped: hasPopperEscaped
|
|
1348
|
+
};
|
|
1349
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
1350
|
+
'data-popper-reference-hidden': isReferenceHidden,
|
|
1351
|
+
'data-popper-escaped': hasPopperEscaped
|
|
1352
|
+
});
|
|
1353
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
var hide$1 = {
|
|
1357
|
+
name: 'hide',
|
|
1358
|
+
enabled: true,
|
|
1359
|
+
phase: 'main',
|
|
1360
|
+
requiresIfExists: ['preventOverflow'],
|
|
1361
|
+
fn: hide
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
function distanceAndSkiddingToXY(placement, rects, offset) {
|
|
1365
|
+
var basePlacement = getBasePlacement(placement);
|
|
1366
|
+
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
|
1367
|
+
|
|
1368
|
+
var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
|
1369
|
+
placement: placement
|
|
1370
|
+
})) : offset,
|
|
1371
|
+
skidding = _ref[0],
|
|
1372
|
+
distance = _ref[1];
|
|
1373
|
+
|
|
1374
|
+
skidding = skidding || 0;
|
|
1375
|
+
distance = (distance || 0) * invertDistance;
|
|
1376
|
+
return [left, right].indexOf(basePlacement) >= 0 ? {
|
|
1377
|
+
x: distance,
|
|
1378
|
+
y: skidding
|
|
1379
|
+
} : {
|
|
1380
|
+
x: skidding,
|
|
1381
|
+
y: distance
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
function offset(_ref2) {
|
|
1386
|
+
var state = _ref2.state,
|
|
1387
|
+
options = _ref2.options,
|
|
1388
|
+
name = _ref2.name;
|
|
1389
|
+
var _options$offset = options.offset,
|
|
1390
|
+
offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
|
1391
|
+
var data = placements.reduce(function (acc, placement) {
|
|
1392
|
+
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
|
1393
|
+
return acc;
|
|
1394
|
+
}, {});
|
|
1395
|
+
var _data$state$placement = data[state.placement],
|
|
1396
|
+
x = _data$state$placement.x,
|
|
1397
|
+
y = _data$state$placement.y;
|
|
1398
|
+
|
|
1399
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
1400
|
+
state.modifiersData.popperOffsets.x += x;
|
|
1401
|
+
state.modifiersData.popperOffsets.y += y;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
state.modifiersData[name] = data;
|
|
1405
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
var offset$1 = {
|
|
1409
|
+
name: 'offset',
|
|
1410
|
+
enabled: true,
|
|
1411
|
+
phase: 'main',
|
|
1412
|
+
requires: ['popperOffsets'],
|
|
1413
|
+
fn: offset
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
function popperOffsets(_ref) {
|
|
1417
|
+
var state = _ref.state,
|
|
1418
|
+
name = _ref.name;
|
|
1419
|
+
// Offsets are the actual position the popper needs to have to be
|
|
1420
|
+
// properly positioned near its reference element
|
|
1421
|
+
// This is the most basic placement, and will be adjusted by
|
|
1422
|
+
// the modifiers in the next step
|
|
1423
|
+
state.modifiersData[name] = computeOffsets({
|
|
1424
|
+
reference: state.rects.reference,
|
|
1425
|
+
element: state.rects.popper,
|
|
1426
|
+
placement: state.placement
|
|
1427
|
+
});
|
|
1428
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
var popperOffsets$1 = {
|
|
1432
|
+
name: 'popperOffsets',
|
|
1433
|
+
enabled: true,
|
|
1434
|
+
phase: 'read',
|
|
1435
|
+
fn: popperOffsets,
|
|
1436
|
+
data: {}
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
function getAltAxis(axis) {
|
|
1440
|
+
return axis === 'x' ? 'y' : 'x';
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function preventOverflow(_ref) {
|
|
1444
|
+
var state = _ref.state,
|
|
1445
|
+
options = _ref.options,
|
|
1446
|
+
name = _ref.name;
|
|
1447
|
+
var _options$mainAxis = options.mainAxis,
|
|
1448
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
1449
|
+
_options$altAxis = options.altAxis,
|
|
1450
|
+
checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
|
1451
|
+
boundary = options.boundary,
|
|
1452
|
+
rootBoundary = options.rootBoundary,
|
|
1453
|
+
altBoundary = options.altBoundary,
|
|
1454
|
+
padding = options.padding,
|
|
1455
|
+
_options$tether = options.tether,
|
|
1456
|
+
tether = _options$tether === void 0 ? true : _options$tether,
|
|
1457
|
+
_options$tetherOffset = options.tetherOffset,
|
|
1458
|
+
tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|
1459
|
+
var overflow = detectOverflow(state, {
|
|
1460
|
+
boundary: boundary,
|
|
1461
|
+
rootBoundary: rootBoundary,
|
|
1462
|
+
padding: padding,
|
|
1463
|
+
altBoundary: altBoundary
|
|
1464
|
+
});
|
|
1465
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
1466
|
+
var variation = getVariation(state.placement);
|
|
1467
|
+
var isBasePlacement = !variation;
|
|
1468
|
+
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|
1469
|
+
var altAxis = getAltAxis(mainAxis);
|
|
1470
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
1471
|
+
var referenceRect = state.rects.reference;
|
|
1472
|
+
var popperRect = state.rects.popper;
|
|
1473
|
+
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
|
1474
|
+
placement: state.placement
|
|
1475
|
+
})) : tetherOffset;
|
|
1476
|
+
var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
|
1477
|
+
mainAxis: tetherOffsetValue,
|
|
1478
|
+
altAxis: tetherOffsetValue
|
|
1479
|
+
} : Object.assign({
|
|
1480
|
+
mainAxis: 0,
|
|
1481
|
+
altAxis: 0
|
|
1482
|
+
}, tetherOffsetValue);
|
|
1483
|
+
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|
1484
|
+
var data = {
|
|
1485
|
+
x: 0,
|
|
1486
|
+
y: 0
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
if (!popperOffsets) {
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
if (checkMainAxis) {
|
|
1494
|
+
var _offsetModifierState$;
|
|
1495
|
+
|
|
1496
|
+
var mainSide = mainAxis === 'y' ? top : left;
|
|
1497
|
+
var altSide = mainAxis === 'y' ? bottom : right;
|
|
1498
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
1499
|
+
var offset = popperOffsets[mainAxis];
|
|
1500
|
+
var min$1 = offset + overflow[mainSide];
|
|
1501
|
+
var max$1 = offset - overflow[altSide];
|
|
1502
|
+
var additive = tether ? -popperRect[len] / 2 : 0;
|
|
1503
|
+
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|
1504
|
+
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
|
1505
|
+
// outside the reference bounds
|
|
1506
|
+
|
|
1507
|
+
var arrowElement = state.elements.arrow;
|
|
1508
|
+
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|
1509
|
+
width: 0,
|
|
1510
|
+
height: 0
|
|
1511
|
+
};
|
|
1512
|
+
var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
|
1513
|
+
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|
1514
|
+
var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
|
|
1515
|
+
// to include its full size in the calculation. If the reference is small
|
|
1516
|
+
// and near the edge of a boundary, the popper can overflow even if the
|
|
1517
|
+
// reference is not overflowing as well (e.g. virtual elements with no
|
|
1518
|
+
// width or height)
|
|
1519
|
+
|
|
1520
|
+
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
1521
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|
1522
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|
1523
|
+
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
1524
|
+
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
1525
|
+
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|
1526
|
+
var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
|
1527
|
+
var tetherMax = offset + maxOffset - offsetModifierValue;
|
|
1528
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
|
1529
|
+
popperOffsets[mainAxis] = preventedOffset;
|
|
1530
|
+
data[mainAxis] = preventedOffset - offset;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
if (checkAltAxis) {
|
|
1534
|
+
var _offsetModifierState$2;
|
|
1535
|
+
|
|
1536
|
+
var _mainSide = mainAxis === 'x' ? top : left;
|
|
1537
|
+
|
|
1538
|
+
var _altSide = mainAxis === 'x' ? bottom : right;
|
|
1539
|
+
|
|
1540
|
+
var _offset = popperOffsets[altAxis];
|
|
1541
|
+
|
|
1542
|
+
var _len = altAxis === 'y' ? 'height' : 'width';
|
|
1543
|
+
|
|
1544
|
+
var _min = _offset + overflow[_mainSide];
|
|
1545
|
+
|
|
1546
|
+
var _max = _offset - overflow[_altSide];
|
|
1547
|
+
|
|
1548
|
+
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|
1549
|
+
|
|
1550
|
+
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|
1551
|
+
|
|
1552
|
+
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|
1553
|
+
|
|
1554
|
+
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|
1555
|
+
|
|
1556
|
+
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|
1557
|
+
|
|
1558
|
+
popperOffsets[altAxis] = _preventedOffset;
|
|
1559
|
+
data[altAxis] = _preventedOffset - _offset;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
state.modifiersData[name] = data;
|
|
1563
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
var preventOverflow$1 = {
|
|
1567
|
+
name: 'preventOverflow',
|
|
1568
|
+
enabled: true,
|
|
1569
|
+
phase: 'main',
|
|
1570
|
+
fn: preventOverflow,
|
|
1571
|
+
requiresIfExists: ['offset']
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
function getHTMLElementScroll(element) {
|
|
1575
|
+
return {
|
|
1576
|
+
scrollLeft: element.scrollLeft,
|
|
1577
|
+
scrollTop: element.scrollTop
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
function getNodeScroll(node) {
|
|
1582
|
+
if (node === getWindow(node) || !isHTMLElement(node)) {
|
|
1583
|
+
return getWindowScroll(node);
|
|
1584
|
+
} else {
|
|
1585
|
+
return getHTMLElementScroll(node);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
function isElementScaled(element) {
|
|
1590
|
+
var rect = element.getBoundingClientRect();
|
|
1591
|
+
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|
1592
|
+
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|
1593
|
+
return scaleX !== 1 || scaleY !== 1;
|
|
1594
|
+
} // Returns the composite rect of an element relative to its offsetParent.
|
|
1595
|
+
// Composite means it takes into account transforms as well as layout.
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
1599
|
+
if (isFixed === void 0) {
|
|
1600
|
+
isFixed = false;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1604
|
+
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
1605
|
+
var documentElement = getDocumentElement(offsetParent);
|
|
1606
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
1607
|
+
var scroll = {
|
|
1608
|
+
scrollLeft: 0,
|
|
1609
|
+
scrollTop: 0
|
|
1610
|
+
};
|
|
1611
|
+
var offsets = {
|
|
1612
|
+
x: 0,
|
|
1613
|
+
y: 0
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1617
|
+
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
|
|
1618
|
+
isScrollParent(documentElement)) {
|
|
1619
|
+
scroll = getNodeScroll(offsetParent);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
if (isHTMLElement(offsetParent)) {
|
|
1623
|
+
offsets = getBoundingClientRect(offsetParent, true);
|
|
1624
|
+
offsets.x += offsetParent.clientLeft;
|
|
1625
|
+
offsets.y += offsetParent.clientTop;
|
|
1626
|
+
} else if (documentElement) {
|
|
1627
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
return {
|
|
1632
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1633
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1634
|
+
width: rect.width,
|
|
1635
|
+
height: rect.height
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function order(modifiers) {
|
|
1640
|
+
var map = new Map();
|
|
1641
|
+
var visited = new Set();
|
|
1642
|
+
var result = [];
|
|
1643
|
+
modifiers.forEach(function (modifier) {
|
|
1644
|
+
map.set(modifier.name, modifier);
|
|
1645
|
+
}); // On visiting object, check for its dependencies and visit them recursively
|
|
1646
|
+
|
|
1647
|
+
function sort(modifier) {
|
|
1648
|
+
visited.add(modifier.name);
|
|
1649
|
+
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|
1650
|
+
requires.forEach(function (dep) {
|
|
1651
|
+
if (!visited.has(dep)) {
|
|
1652
|
+
var depModifier = map.get(dep);
|
|
1653
|
+
|
|
1654
|
+
if (depModifier) {
|
|
1655
|
+
sort(depModifier);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
result.push(modifier);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
modifiers.forEach(function (modifier) {
|
|
1663
|
+
if (!visited.has(modifier.name)) {
|
|
1664
|
+
// check for visited object
|
|
1665
|
+
sort(modifier);
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
return result;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
function orderModifiers(modifiers) {
|
|
1672
|
+
// order based on dependencies
|
|
1673
|
+
var orderedModifiers = order(modifiers); // order based on phase
|
|
1674
|
+
|
|
1675
|
+
return modifierPhases.reduce(function (acc, phase) {
|
|
1676
|
+
return acc.concat(orderedModifiers.filter(function (modifier) {
|
|
1677
|
+
return modifier.phase === phase;
|
|
1678
|
+
}));
|
|
1679
|
+
}, []);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
function debounce(fn) {
|
|
1683
|
+
var pending;
|
|
1684
|
+
return function () {
|
|
1685
|
+
if (!pending) {
|
|
1686
|
+
pending = new Promise(function (resolve) {
|
|
1687
|
+
Promise.resolve().then(function () {
|
|
1688
|
+
pending = undefined;
|
|
1689
|
+
resolve(fn());
|
|
1690
|
+
});
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
return pending;
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
function mergeByName(modifiers) {
|
|
1699
|
+
var merged = modifiers.reduce(function (merged, current) {
|
|
1700
|
+
var existing = merged[current.name];
|
|
1701
|
+
merged[current.name] = existing ? Object.assign({}, existing, current, {
|
|
1702
|
+
options: Object.assign({}, existing.options, current.options),
|
|
1703
|
+
data: Object.assign({}, existing.data, current.data)
|
|
1704
|
+
}) : current;
|
|
1705
|
+
return merged;
|
|
1706
|
+
}, {}); // IE11 does not support Object.values
|
|
1707
|
+
|
|
1708
|
+
return Object.keys(merged).map(function (key) {
|
|
1709
|
+
return merged[key];
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
var DEFAULT_OPTIONS = {
|
|
1714
|
+
placement: 'bottom',
|
|
1715
|
+
modifiers: [],
|
|
1716
|
+
strategy: 'absolute'
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
function areValidElements() {
|
|
1720
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1721
|
+
args[_key] = arguments[_key];
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
return !args.some(function (element) {
|
|
1725
|
+
return !(element && typeof element.getBoundingClientRect === 'function');
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
function popperGenerator(generatorOptions) {
|
|
1730
|
+
if (generatorOptions === void 0) {
|
|
1731
|
+
generatorOptions = {};
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
var _generatorOptions = generatorOptions,
|
|
1735
|
+
_generatorOptions$def = _generatorOptions.defaultModifiers,
|
|
1736
|
+
defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
|
1737
|
+
_generatorOptions$def2 = _generatorOptions.defaultOptions,
|
|
1738
|
+
defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
|
1739
|
+
return function createPopper(reference, popper, options) {
|
|
1740
|
+
if (options === void 0) {
|
|
1741
|
+
options = defaultOptions;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
var state = {
|
|
1745
|
+
placement: 'bottom',
|
|
1746
|
+
orderedModifiers: [],
|
|
1747
|
+
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
|
1748
|
+
modifiersData: {},
|
|
1749
|
+
elements: {
|
|
1750
|
+
reference: reference,
|
|
1751
|
+
popper: popper
|
|
1752
|
+
},
|
|
1753
|
+
attributes: {},
|
|
1754
|
+
styles: {}
|
|
1755
|
+
};
|
|
1756
|
+
var effectCleanupFns = [];
|
|
1757
|
+
var isDestroyed = false;
|
|
1758
|
+
var instance = {
|
|
1759
|
+
state: state,
|
|
1760
|
+
setOptions: function setOptions(setOptionsAction) {
|
|
1761
|
+
var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
|
1762
|
+
cleanupModifierEffects();
|
|
1763
|
+
state.options = Object.assign({}, defaultOptions, state.options, options);
|
|
1764
|
+
state.scrollParents = {
|
|
1765
|
+
reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
|
1766
|
+
popper: listScrollParents(popper)
|
|
1767
|
+
}; // Orders the modifiers based on their dependencies and `phase`
|
|
1768
|
+
// properties
|
|
1769
|
+
|
|
1770
|
+
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
|
|
1771
|
+
|
|
1772
|
+
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
|
1773
|
+
return m.enabled;
|
|
1774
|
+
});
|
|
1775
|
+
runModifierEffects();
|
|
1776
|
+
return instance.update();
|
|
1777
|
+
},
|
|
1778
|
+
// Sync update – it will always be executed, even if not necessary. This
|
|
1779
|
+
// is useful for low frequency updates where sync behavior simplifies the
|
|
1780
|
+
// logic.
|
|
1781
|
+
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|
1782
|
+
// prefer the async Popper#update method
|
|
1783
|
+
forceUpdate: function forceUpdate() {
|
|
1784
|
+
if (isDestroyed) {
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
var _state$elements = state.elements,
|
|
1789
|
+
reference = _state$elements.reference,
|
|
1790
|
+
popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
|
|
1791
|
+
// anymore
|
|
1792
|
+
|
|
1793
|
+
if (!areValidElements(reference, popper)) {
|
|
1794
|
+
return;
|
|
1795
|
+
} // Store the reference and popper rects to be read by modifiers
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
state.rects = {
|
|
1799
|
+
reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
|
1800
|
+
popper: getLayoutRect(popper)
|
|
1801
|
+
}; // Modifiers have the ability to reset the current update cycle. The
|
|
1802
|
+
// most common use case for this is the `flip` modifier changing the
|
|
1803
|
+
// placement, which then needs to re-run all the modifiers, because the
|
|
1804
|
+
// logic was previously ran for the previous placement and is therefore
|
|
1805
|
+
// stale/incorrect
|
|
1806
|
+
|
|
1807
|
+
state.reset = false;
|
|
1808
|
+
state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
|
|
1809
|
+
// is filled with the initial data specified by the modifier. This means
|
|
1810
|
+
// it doesn't persist and is fresh on each update.
|
|
1811
|
+
// To ensure persistent data, use `${name}#persistent`
|
|
1812
|
+
|
|
1813
|
+
state.orderedModifiers.forEach(function (modifier) {
|
|
1814
|
+
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
1815
|
+
});
|
|
1816
|
+
|
|
1817
|
+
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
1818
|
+
if (state.reset === true) {
|
|
1819
|
+
state.reset = false;
|
|
1820
|
+
index = -1;
|
|
1821
|
+
continue;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
var _state$orderedModifie = state.orderedModifiers[index],
|
|
1825
|
+
fn = _state$orderedModifie.fn,
|
|
1826
|
+
_state$orderedModifie2 = _state$orderedModifie.options,
|
|
1827
|
+
_options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
|
1828
|
+
name = _state$orderedModifie.name;
|
|
1829
|
+
|
|
1830
|
+
if (typeof fn === 'function') {
|
|
1831
|
+
state = fn({
|
|
1832
|
+
state: state,
|
|
1833
|
+
options: _options,
|
|
1834
|
+
name: name,
|
|
1835
|
+
instance: instance
|
|
1836
|
+
}) || state;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
// Async and optimistically optimized update – it will not be executed if
|
|
1841
|
+
// not necessary (debounced to run at most once-per-tick)
|
|
1842
|
+
update: debounce(function () {
|
|
1843
|
+
return new Promise(function (resolve) {
|
|
1844
|
+
instance.forceUpdate();
|
|
1845
|
+
resolve(state);
|
|
1846
|
+
});
|
|
1847
|
+
}),
|
|
1848
|
+
destroy: function destroy() {
|
|
1849
|
+
cleanupModifierEffects();
|
|
1850
|
+
isDestroyed = true;
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
if (!areValidElements(reference, popper)) {
|
|
1855
|
+
return instance;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
instance.setOptions(options).then(function (state) {
|
|
1859
|
+
if (!isDestroyed && options.onFirstUpdate) {
|
|
1860
|
+
options.onFirstUpdate(state);
|
|
1861
|
+
}
|
|
1862
|
+
}); // Modifiers have the ability to execute arbitrary code before the first
|
|
1863
|
+
// update cycle runs. They will be executed in the same order as the update
|
|
1864
|
+
// cycle. This is useful when a modifier adds some persistent data that
|
|
1865
|
+
// other modifiers need to use, but the modifier is run after the dependent
|
|
1866
|
+
// one.
|
|
1867
|
+
|
|
1868
|
+
function runModifierEffects() {
|
|
1869
|
+
state.orderedModifiers.forEach(function (_ref) {
|
|
1870
|
+
var name = _ref.name,
|
|
1871
|
+
_ref$options = _ref.options,
|
|
1872
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
1873
|
+
effect = _ref.effect;
|
|
1874
|
+
|
|
1875
|
+
if (typeof effect === 'function') {
|
|
1876
|
+
var cleanupFn = effect({
|
|
1877
|
+
state: state,
|
|
1878
|
+
name: name,
|
|
1879
|
+
instance: instance,
|
|
1880
|
+
options: options
|
|
1881
|
+
});
|
|
1882
|
+
|
|
1883
|
+
var noopFn = function noopFn() {};
|
|
1884
|
+
|
|
1885
|
+
effectCleanupFns.push(cleanupFn || noopFn);
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
function cleanupModifierEffects() {
|
|
1891
|
+
effectCleanupFns.forEach(function (fn) {
|
|
1892
|
+
return fn();
|
|
1893
|
+
});
|
|
1894
|
+
effectCleanupFns = [];
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
return instance;
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
|
1902
|
+
var createPopper = /*#__PURE__*/popperGenerator({
|
|
1903
|
+
defaultModifiers: defaultModifiers
|
|
1904
|
+
}); // eslint-disable-next-line import/no-unused-modules
|
|
1905
|
+
|
|
1906
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1907
|
+
// See LICENSE in the project root for license information.
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
// build the component class
|
|
1911
|
+
const popoverOffsetDistance = 18;
|
|
1912
|
+
const popoverOffsetSkidding = 0;
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* Whether `el` is currently in the top layer via the native popover API.
|
|
1916
|
+
* Gated on `showPopover` (spec-paired with `:popover-open`) plus try/catch
|
|
1917
|
+
* for older selector parsers that reject the unknown pseudo-class.
|
|
1918
|
+
* @param {Element | null | undefined} el
|
|
1919
|
+
* @returns {boolean}
|
|
1920
|
+
*/
|
|
1921
|
+
function isTopLayerOpen(el) {
|
|
1922
|
+
if (!el || typeof el.showPopover !== "function") {
|
|
1923
|
+
return false;
|
|
1924
|
+
}
|
|
1925
|
+
try {
|
|
1926
|
+
return el.matches(":popover-open");
|
|
1927
|
+
} catch {
|
|
1928
|
+
return false;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
class Popover {
|
|
1933
|
+
constructor(anchor, popover, placement, boundary) {
|
|
1934
|
+
this.anchor = anchor;
|
|
1935
|
+
this.popover = popover;
|
|
1936
|
+
this.boundaryElement = this.setBoundary(boundary);
|
|
1937
|
+
this.options = {
|
|
1938
|
+
placement,
|
|
1939
|
+
visibleClass: "data-show",
|
|
1940
|
+
};
|
|
1941
|
+
this.popover.classList.remove(this.options.visibleClass);
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
setBoundary(boundary) {
|
|
1945
|
+
if (typeof boundary === "string") {
|
|
1946
|
+
return document.querySelector(boundary) || document.body;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
return boundary || document.body;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
show() {
|
|
1953
|
+
if (this.popper) {
|
|
1954
|
+
this.popper.destroy();
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// Promote to the top layer so the containing block is the viewport,
|
|
1958
|
+
// sidestepping transformed ancestors Popper's parentNode walk can't
|
|
1959
|
+
// reach across shadow boundaries.
|
|
1960
|
+
if (
|
|
1961
|
+
this.popover.isConnected &&
|
|
1962
|
+
typeof this.popover.showPopover === "function" &&
|
|
1963
|
+
!isTopLayerOpen(this.popover)
|
|
1964
|
+
) {
|
|
1965
|
+
try {
|
|
1966
|
+
this.popover.showPopover();
|
|
1967
|
+
} catch {
|
|
1968
|
+
// InvalidStateError / NotAllowedError (e.g. detached between the
|
|
1969
|
+
// guard and this call, or a nested-invoker constraint) — fall back
|
|
1970
|
+
// to absolute positioning rather than breaking show() entirely.
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
// Gate the positioning strategy on actual top-layer promotion, not just
|
|
1975
|
+
// feature detection. If showPopover() silently failed or was blocked, the
|
|
1976
|
+
// bubble stays in normal flow and the viewport-coordinate modifier never
|
|
1977
|
+
// fires — pairing "fixed" with an offsetParent-derived reference rect
|
|
1978
|
+
// would produce a mismatched coordinate system.
|
|
1979
|
+
const isPromoted = isTopLayerOpen(this.popover);
|
|
1980
|
+
|
|
1981
|
+
this.popper = createPopper(this.anchor, this.popover, {
|
|
1982
|
+
tooltip: this.anchor,
|
|
1983
|
+
placement: this.options.placement,
|
|
1984
|
+
// Match the top-layer viewport containing block when the bubble is
|
|
1985
|
+
// promoted; otherwise leave Popper on its default to preserve legacy
|
|
1986
|
+
// positioning on browsers without the popover API.
|
|
1987
|
+
strategy: isPromoted ? "fixed" : "absolute",
|
|
1988
|
+
modifiers: [
|
|
1989
|
+
{
|
|
1990
|
+
// Override Popper's offsetParent-relative reference rect with
|
|
1991
|
+
// viewport coords so the math agrees with the top-layer bubble's
|
|
1992
|
+
// viewport containing block when a transformed ancestor is reachable.
|
|
1993
|
+
name: "viewportReferenceForTopLayer",
|
|
1994
|
+
phase: "beforeRead",
|
|
1995
|
+
enabled: true,
|
|
1996
|
+
fn: ({ state }) => {
|
|
1997
|
+
if (!isTopLayerOpen(state.elements.popper)) {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
const reference = state.elements.reference;
|
|
2001
|
+
if (!reference || typeof reference.getBoundingClientRect !== "function") {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
const r = reference.getBoundingClientRect();
|
|
2005
|
+
state.rects.reference = {
|
|
2006
|
+
x: r.left,
|
|
2007
|
+
y: r.top,
|
|
2008
|
+
width: r.width,
|
|
2009
|
+
height: r.height,
|
|
2010
|
+
};
|
|
2011
|
+
},
|
|
2012
|
+
},
|
|
2013
|
+
{
|
|
2014
|
+
name: "offset",
|
|
2015
|
+
options: {
|
|
2016
|
+
offset: [popoverOffsetSkidding, popoverOffsetDistance],
|
|
2017
|
+
},
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
name: "preventOverflow",
|
|
2021
|
+
options: {
|
|
2022
|
+
mainAxis: true,
|
|
2023
|
+
boundary: this.boundaryElement,
|
|
2024
|
+
rootBoundary: "document",
|
|
2025
|
+
padding: 16,
|
|
2026
|
+
},
|
|
2027
|
+
},
|
|
2028
|
+
],
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
triggerUpdate() {
|
|
2033
|
+
this.popper.update();
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
hide() {
|
|
2037
|
+
if (
|
|
2038
|
+
this.popover.isConnected &&
|
|
2039
|
+
typeof this.popover.hidePopover === "function" &&
|
|
2040
|
+
isTopLayerOpen(this.popover)
|
|
2041
|
+
) {
|
|
2042
|
+
try {
|
|
2043
|
+
this.popover.hidePopover();
|
|
2044
|
+
} catch {
|
|
2045
|
+
// Already hidden / disconnected — nothing to unwind.
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
this.popover.classList.remove(this.options.visibleClass);
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
var colorCss = i$3`::slotted(*):not([onDark]),::slotted(*):not([appearance=inverse]){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)}
|
|
2053
|
+
`;
|
|
2054
|
+
|
|
2055
|
+
var styleCss = i$3`.body-default{font-size:var(--wcss-body-default-font-size, 1rem);font-weight:var(--wcss-body-default-weight, );line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default,.body-default-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-default-emphasized{font-size:var(--wcss-body-default-emphasized-font-size, 1rem);font-weight:var(--wcss-body-default-emphasized-weight, );line-height:var(--wcss-body-default-emphasized-line-height, 1.5rem)}.body-lg{font-size:var(--wcss-body-lg-font-size, 1.125rem);font-weight:var(--wcss-body-lg-weight, );line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-lg,.body-lg-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-lg-emphasized{font-size:var(--wcss-body-lg-emphasized-font-size, 1.125rem);font-weight:var(--wcss-body-lg-emphasized-weight, );line-height:var(--wcss-body-lg-emphasized-line-height, 1.625rem)}.body-sm{font-size:var(--wcss-body-sm-font-size, .875rem);font-weight:var(--wcss-body-sm-weight, );line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm,.body-sm-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-sm-emphasized{font-size:var(--wcss-body-sm-emphasized-font-size, .875rem);font-weight:var(--wcss-body-sm-emphasized-weight, );line-height:var(--wcss-body-sm-emphasized-line-height, 1.25rem)}.body-xs{font-size:var(--wcss-body-xs-font-size, .75rem);font-weight:var(--wcss-body-xs-weight, );line-height:var(--wcss-body-xs-line-height, 1rem)}.body-xs,.body-xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-xs-emphasized{font-size:var(--wcss-body-xs-emphasized-font-size, .75rem);font-weight:var(--wcss-body-xs-emphasized-weight, );line-height:var(--wcss-body-xs-emphasized-line-height, 1rem)}.body-2xs{font-size:var(--wcss-body-2xs-font-size, .625rem);font-weight:var(--wcss-body-2xs-weight, );line-height:var(--wcss-body-2xs-line-height, .875rem)}.body-2xs,.body-2xs-emphasized{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-2xs-emphasized{font-size:var(--wcss-body-2xs-emphasized-font-size, .625rem);font-weight:var(--wcss-body-2xs-emphasized-weight, );line-height:var(--wcss-body-2xs-emphasized-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, 300);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, 300);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:0;overflow:visible;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:""}
|
|
2056
|
+
`;
|
|
2057
|
+
|
|
2058
|
+
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)}
|
|
2059
|
+
`;
|
|
2060
|
+
|
|
2061
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2062
|
+
// See LICENSE in the project root for license information.
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
/**
|
|
2066
|
+
* The `auro-popover` element attaches to another element and displays on hover.
|
|
2067
|
+
* @customElement auro-popover
|
|
2068
|
+
*
|
|
2069
|
+
* @slot - Default unnamed slot for the use of popover content
|
|
2070
|
+
* @slot trigger - The element in this slot triggers hiding and showing the popover.
|
|
2071
|
+
*/
|
|
2072
|
+
class AuroPopover extends i {
|
|
2073
|
+
constructor() {
|
|
2074
|
+
super();
|
|
2075
|
+
|
|
2076
|
+
this.placement = "top";
|
|
2077
|
+
this.isPopoverVisible = false;
|
|
2078
|
+
|
|
2079
|
+
// Stable event-listener references used across the component lifecycle.
|
|
2080
|
+
this._onTouchStart = null;
|
|
2081
|
+
this._onTriggerMouseEnter = null;
|
|
2082
|
+
this._onTriggerMouseLeave = null;
|
|
2083
|
+
this._onTriggerFocus = null;
|
|
2084
|
+
this._onTriggerBlur = null;
|
|
2085
|
+
this._onTriggerKeydown = null;
|
|
2086
|
+
this._onHidePopover = null;
|
|
2087
|
+
this._onBodyMouseover = null;
|
|
2088
|
+
this._onSlotChange = null;
|
|
2089
|
+
this._addedTabIndex = false;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* Internal Defaults.
|
|
2094
|
+
* @private
|
|
2095
|
+
* @returns {void}
|
|
2096
|
+
*/
|
|
2097
|
+
_initializeDefaults() {
|
|
2098
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
// function to define props used within the scope of this component
|
|
2102
|
+
static get properties() {
|
|
2103
|
+
return {
|
|
2104
|
+
/**
|
|
2105
|
+
* Adds additional top and bottom space around the appearance of the popover in relation to the trigger.
|
|
2106
|
+
*/
|
|
2107
|
+
addSpace: {
|
|
2108
|
+
type: Boolean,
|
|
2109
|
+
reflect: true
|
|
2110
|
+
},
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* The element to use as the boundary for the popover. Can be a query selector or an HTML element.
|
|
2114
|
+
* @type {string | object}
|
|
2115
|
+
*/
|
|
2116
|
+
boundary: { type: String },
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Disables the popover from showing on hover and focus.
|
|
2120
|
+
*/
|
|
2121
|
+
disabled: {
|
|
2122
|
+
type: Boolean,
|
|
2123
|
+
reflect: true
|
|
2124
|
+
},
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* Directly associates 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.
|
|
2128
|
+
*/
|
|
2129
|
+
for: {
|
|
2130
|
+
type: String,
|
|
2131
|
+
reflect: true
|
|
2132
|
+
},
|
|
2133
|
+
|
|
2134
|
+
/**
|
|
2135
|
+
* Position for popover in relation to the element {'top' | 'bottom'}.
|
|
2136
|
+
* @type {'top' | 'bottom'}
|
|
2137
|
+
* @default 'top'
|
|
2138
|
+
*/
|
|
2139
|
+
placement: { type: String },
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* Removes top and bottom space around the appearance of the popover in relation to the trigger.
|
|
2143
|
+
*/
|
|
2144
|
+
removeSpace: {
|
|
2145
|
+
type: Boolean,
|
|
2146
|
+
reflect: true
|
|
2147
|
+
},
|
|
2148
|
+
|
|
2149
|
+
/**
|
|
2150
|
+
* Whether the popover is currently visible. Reflected as the `data-show`
|
|
2151
|
+
* attribute so host-level CSS selectors (e.g. `:host([data-show])`) work.
|
|
2152
|
+
* Also drives `aria-hidden` on the popover div in the template.
|
|
2153
|
+
* @private
|
|
2154
|
+
*/
|
|
2155
|
+
isPopoverVisible: {
|
|
2156
|
+
type: Boolean,
|
|
2157
|
+
reflect: true,
|
|
2158
|
+
attribute: 'data-show',
|
|
2159
|
+
converter: {
|
|
2160
|
+
fromAttribute: (value) => value !== null,
|
|
2161
|
+
toAttribute: (value) => (value ? 'true' : null),
|
|
2162
|
+
},
|
|
2163
|
+
},
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
static get styles() {
|
|
2168
|
+
return [i$3`${styleCss}`, i$3`${colorCss}`, i$3`${tokensCss}`];
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* This will register this element with the browser.
|
|
2173
|
+
* @param {string} [name="auro-popover"] - The name of the element that you want to register.
|
|
2174
|
+
*
|
|
2175
|
+
* @example
|
|
2176
|
+
* AuroPopover.register("custom-popover") // this will register this element to <custom-popover/>
|
|
2177
|
+
*
|
|
2178
|
+
*/
|
|
2179
|
+
static register(name = "auro-popover") {
|
|
2180
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroPopover);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
connectedCallback() {
|
|
2184
|
+
super.connectedCallback();
|
|
2185
|
+
|
|
2186
|
+
// Prevent screen readers from announcing the custom element host as "group".
|
|
2187
|
+
if (!this.hasAttribute("role")) {
|
|
2188
|
+
this.setAttribute("role", "none");
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
this._initializeDefaults();
|
|
2192
|
+
|
|
2193
|
+
// adds toggle function to root element based on touch
|
|
2194
|
+
if (!this._onTouchStart) {
|
|
2195
|
+
this._onTouchStart = () => {
|
|
2196
|
+
this.toggle();
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
this.addEventListener("touchstart", this._onTouchStart);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
disconnectedCallback() {
|
|
2203
|
+
// NOTE: Teardown is one-way. This component does not currently support
|
|
2204
|
+
// reinitialization after being removed from the DOM.
|
|
2205
|
+
|
|
2206
|
+
super.disconnectedCallback();
|
|
2207
|
+
this.removeEventListener("touchstart", this._onTouchStart);
|
|
2208
|
+
|
|
2209
|
+
if (this.trigger) {
|
|
2210
|
+
// Remove listeners attached to the trigger element.
|
|
2211
|
+
if (this._onTriggerMouseEnter) {
|
|
2212
|
+
this._eventTarget.removeEventListener("mouseenter", this._onTriggerMouseEnter);
|
|
2213
|
+
}
|
|
2214
|
+
if (this._onTriggerMouseLeave) {
|
|
2215
|
+
this._eventTarget.removeEventListener("mouseleave", this._onTriggerMouseLeave);
|
|
2216
|
+
}
|
|
2217
|
+
if (this._onTriggerFocus) {
|
|
2218
|
+
this.trigger.removeEventListener("focusin", this._onTriggerFocus);
|
|
2219
|
+
}
|
|
2220
|
+
if (this._onTriggerBlur) {
|
|
2221
|
+
this.trigger.removeEventListener("focusout", this._onTriggerBlur);
|
|
2222
|
+
}
|
|
2223
|
+
if (this._onTriggerKeydown) {
|
|
2224
|
+
this.trigger.removeEventListener("keydown", this._onTriggerKeydown);
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
// Clean up aria-description and its sync listener set in firstUpdated.
|
|
2228
|
+
// Prevents stale descriptions if the trigger is reused after disconnect.
|
|
2229
|
+
if (this._onSlotChange) {
|
|
2230
|
+
this.shadowRoot?.querySelector("slot:not([name])")?.removeEventListener("slotchange", this._onSlotChange);
|
|
2231
|
+
}
|
|
2232
|
+
// Remove aria-description from every element that received it in
|
|
2233
|
+
// firstUpdated (focusable descendants or the trigger itself).
|
|
2234
|
+
for (const target of (this._ariaDescriptionTargets || [this.trigger])) {
|
|
2235
|
+
target.removeAttribute("aria-description");
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// Remove tabindex only if the component added it and the current value
|
|
2239
|
+
// still matches the value managed by the component. This avoids removing
|
|
2240
|
+
// an author-updated tabindex that was set after connection.
|
|
2241
|
+
if (this._addedTabIndex && this.trigger.getAttribute("tabindex") === "0") {
|
|
2242
|
+
this.trigger.removeAttribute("tabindex");
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
if (this._onHidePopover) {
|
|
2247
|
+
this.removeEventListener("hidePopover", this._onHidePopover);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// Remove the global mouseover handler if the popover was visible when disconnected.
|
|
2251
|
+
if (this._onBodyMouseover) {
|
|
2252
|
+
document.body.removeEventListener("mouseover", this._onBodyMouseover);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
// Destroy the Popper.js instance to release its internal references.
|
|
2256
|
+
if (this.popper?.popper && typeof this.popper.popper.destroy === "function") {
|
|
2257
|
+
this.popper.popper.destroy();
|
|
2258
|
+
this.popper.popper = null;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
firstUpdated() {
|
|
2263
|
+
/**
|
|
2264
|
+
* NOTE: This component is not currently designed for reinitialization.
|
|
2265
|
+
* All setup in firstUpdated() is assumed to run once per instance lifecycle.
|
|
2266
|
+
* If the element is removed and later reattached, event bindings,
|
|
2267
|
+
* Popper setup, and accessibility wiring will NOT be restored automatically.
|
|
2268
|
+
*/
|
|
2269
|
+
|
|
2270
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
2271
|
+
this.runtimeUtils.handleComponentTagRename(this, "auro-popover");
|
|
2272
|
+
|
|
2273
|
+
if (this.for) {
|
|
2274
|
+
this.trigger =
|
|
2275
|
+
document.querySelector(`#${this.for}`) ||
|
|
2276
|
+
this.getRootNode().querySelector(`#${this.for}`);
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
if (!this.trigger) {
|
|
2280
|
+
[this.trigger] = this.shadowRoot
|
|
2281
|
+
.querySelector('slot[name="trigger"]')
|
|
2282
|
+
.assignedElements();
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
// Guard: if neither the for attribute nor the trigger slot resolved an element,
|
|
2286
|
+
// there is nothing to attach to — exit cleanly rather than throwing on property access.
|
|
2287
|
+
if (!this.trigger) {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
// If the trigger is not keyboard accessible, make it focusable automatically.
|
|
2292
|
+
// Set up aria-description so screen readers announce popover content on focus.
|
|
2293
|
+
this._setupAccessibility();
|
|
2294
|
+
|
|
2295
|
+
// Set up Popper instance, event listeners, and keyboard/mouse handlers.
|
|
2296
|
+
this._setupEventListeners();
|
|
2297
|
+
|
|
2298
|
+
// If the component was initialized with data-show / isPopoverVisible
|
|
2299
|
+
// already true, the updated() lifecycle won't fire for that property
|
|
2300
|
+
// because it didn't change during this cycle. Sync Popper state now.
|
|
2301
|
+
if (this.isPopoverVisible && this.popper) {
|
|
2302
|
+
if (this.disabled) {
|
|
2303
|
+
this.isPopoverVisible = false;
|
|
2304
|
+
} else {
|
|
2305
|
+
this.popper.show();
|
|
2306
|
+
document.body.addEventListener("mouseover", this._onBodyMouseover);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
/**
|
|
2312
|
+
* Initializes the Popper instance and attaches all event listeners
|
|
2313
|
+
* for mouse, keyboard, and focus interactions on the trigger.
|
|
2314
|
+
* @private
|
|
2315
|
+
* @returns {void}
|
|
2316
|
+
*/
|
|
2317
|
+
_setupEventListeners() {
|
|
2318
|
+
this.auroPopover = this.shadowRoot.querySelector("#popover");
|
|
2319
|
+
this.popper = new Popover(
|
|
2320
|
+
this.trigger,
|
|
2321
|
+
this.auroPopover,
|
|
2322
|
+
this.placement,
|
|
2323
|
+
this.boundary,
|
|
2324
|
+
);
|
|
2325
|
+
|
|
2326
|
+
this._onBodyMouseover = (evt) => this.handleMouseoverEvent(evt);
|
|
2327
|
+
this._onTriggerMouseEnter = () => { this.toggleShow(); };
|
|
2328
|
+
this._onTriggerMouseLeave = () => { this.toggleHide(); };
|
|
2329
|
+
this._onTriggerFocus = () => { this.toggleShow(); };
|
|
2330
|
+
this._onTriggerBlur = (event) => {
|
|
2331
|
+
// Only hide if focus leaves the trigger and popover entirely, not
|
|
2332
|
+
// when moving between focusable children within the trigger or into
|
|
2333
|
+
// interactive content inside the popover.
|
|
2334
|
+
// Node.contains() does not cross shadow boundaries, so we walk
|
|
2335
|
+
// up through shadow hosts to detect targets inside a descendant
|
|
2336
|
+
// custom element's shadow root.
|
|
2337
|
+
let target = event.relatedTarget;
|
|
2338
|
+
let inside = false;
|
|
2339
|
+
|
|
2340
|
+
while (target) {
|
|
2341
|
+
if (this.trigger.contains(target) || this.contains(target)) {
|
|
2342
|
+
inside = true;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
const root = target.getRootNode();
|
|
2346
|
+
target = root instanceof ShadowRoot ? root.host : null;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
if (!inside) {
|
|
2350
|
+
this.toggleHide();
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
this._onTriggerKeydown = (event) => {
|
|
2354
|
+
const key = event.key.toLowerCase();
|
|
2355
|
+
|
|
2356
|
+
if (this.isPopoverVisible) {
|
|
2357
|
+
if (key === "tab" || key === "escape") {
|
|
2358
|
+
this.toggleHide();
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
if (key === " " || key === "enter") {
|
|
2363
|
+
// Only toggle from the trigger element itself, not from interactive
|
|
2364
|
+
// descendants inside a wrapper trigger. focusin/focusout bubble, so
|
|
2365
|
+
// keydown events from children (e.g. a link inside <div slot="trigger">)
|
|
2366
|
+
// also arrive here; letting them through would interfere with the
|
|
2367
|
+
// descendant's native activation (Enter on a link, Space on a button).
|
|
2368
|
+
if (event.target !== this.trigger && !this._addedTabIndex) {
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
// Prevent page scroll for Space only on non-native triggers.
|
|
2373
|
+
// Native elements (button, a) handle their own Space/Enter semantics.
|
|
2374
|
+
if (key === " " && this._addedTabIndex) {
|
|
2375
|
+
event.preventDefault();
|
|
2376
|
+
}
|
|
2377
|
+
this.toggle();
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
this._onHidePopover = () => { this.toggleHide(); };
|
|
2381
|
+
|
|
2382
|
+
// mouseenter/mouseleave attach to the host when the trigger is a direct
|
|
2383
|
+
// child of auro-popover (slotted), otherwise they attach to the trigger itself.
|
|
2384
|
+
this._eventTarget =
|
|
2385
|
+
this.trigger.parentElement.localName === this.localName
|
|
2386
|
+
? this
|
|
2387
|
+
: this.trigger;
|
|
2388
|
+
|
|
2389
|
+
this._eventTarget.addEventListener("mouseenter", this._onTriggerMouseEnter);
|
|
2390
|
+
this._eventTarget.addEventListener("mouseleave", this._onTriggerMouseLeave);
|
|
2391
|
+
|
|
2392
|
+
// if user tabs off of trigger, then hide the popover.
|
|
2393
|
+
this.trigger.addEventListener("keydown", this._onTriggerKeydown);
|
|
2394
|
+
|
|
2395
|
+
// handle gain/loss of focus — use focusin/focusout so events bubble
|
|
2396
|
+
// from focusable descendants inside wrapper triggers (e.g. <div><a>).
|
|
2397
|
+
this.trigger.addEventListener("focusin", this._onTriggerFocus);
|
|
2398
|
+
this.trigger.addEventListener("focusout", this._onTriggerBlur);
|
|
2399
|
+
|
|
2400
|
+
// e.g. for a closePopover button in the popover
|
|
2401
|
+
this.addEventListener("hidePopover", this._onHidePopover);
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
/**
|
|
2405
|
+
* Sets up auto-tabindex and aria-description on the trigger element.
|
|
2406
|
+
*
|
|
2407
|
+
* Auto-tabindex: ensures non-focusable triggers are keyboard accessible.
|
|
2408
|
+
* Covers native elements (e.g. <abbr>, <span>) and custom elements whose
|
|
2409
|
+
* shadow DOM contains no focusable descendant (e.g. auro-icon).
|
|
2410
|
+
*
|
|
2411
|
+
* We skip elements that are already accessible via the tab order:
|
|
2412
|
+
* - Natively focusable elements (tabIndex >= 0): <button>, <a href>, <input>, etc.
|
|
2413
|
+
* - Custom elements whose shadow DOM contains a focusable descendant (e.g. auro-button
|
|
2414
|
+
* has an inner <button>) — adding tabindex to the host would create a double tab stop.
|
|
2415
|
+
* - Elements where the author has explicitly set tabindex — their intent is respected.
|
|
2416
|
+
*
|
|
2417
|
+
* Known limitation: custom elements with a closed shadow root (mode: 'closed') cannot
|
|
2418
|
+
* be inspected — shadowRoot returns null. If such an element has an internal focusable
|
|
2419
|
+
* descendant and a host tabIndex of -1, tabindex="0" will be added, potentially
|
|
2420
|
+
* creating a double tab stop. Elements using delegatesFocus avoid this because the
|
|
2421
|
+
* browser reflects a non-negative tabIndex on the host.
|
|
2422
|
+
*
|
|
2423
|
+
* aria-description (ARIA 1.3): embeds the popover content string directly on
|
|
2424
|
+
* the trigger so screen readers announce it on focus. Preferred over
|
|
2425
|
+
* aria-describedby (cross-shadow ID lookup fails) and aria-live (display:none
|
|
2426
|
+
* removes the region from the accessibility tree).
|
|
2427
|
+
*
|
|
2428
|
+
* @private
|
|
2429
|
+
* @returns {void}
|
|
2430
|
+
*/
|
|
2431
|
+
_setupAccessibility() {
|
|
2432
|
+
const isNativelyFocusable = this.trigger.tabIndex >= 0;
|
|
2433
|
+
const focusableSelector =
|
|
2434
|
+
'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex^="-"]), [contenteditable]:not([contenteditable="false"]), summary, iframe, audio[controls], video[controls]';
|
|
2435
|
+
|
|
2436
|
+
// CSS selectors alone can match elements removed from the tab order
|
|
2437
|
+
// (e.g. <button tabindex="-1">) or hidden/inert descendants. Verify
|
|
2438
|
+
// actual keyboard reachability before treating a match as focusable.
|
|
2439
|
+
// closest() does not cross shadow boundaries, so we also walk up
|
|
2440
|
+
// through shadow hosts to catch hidden/inert ancestors in the light DOM.
|
|
2441
|
+
const isReachable = (el) => {
|
|
2442
|
+
if (el.tabIndex < 0) return false;
|
|
2443
|
+
let node = el;
|
|
2444
|
+
while (node) {
|
|
2445
|
+
if (node.closest('[hidden], [inert]')) return false;
|
|
2446
|
+
const root = node.getRootNode();
|
|
2447
|
+
node = root instanceof ShadowRoot ? root.host : null;
|
|
2448
|
+
}
|
|
2449
|
+
return true;
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
// Check light DOM children for focusable elements.
|
|
2453
|
+
let hasInternalFocus = [...this.trigger.querySelectorAll(focusableSelector)].some(isReachable);
|
|
2454
|
+
|
|
2455
|
+
// Also check light DOM custom element descendants whose shadow DOM
|
|
2456
|
+
// contains focusable content. querySelector cannot reach into shadow
|
|
2457
|
+
// roots, so custom elements like auro-button inside a wrapper trigger
|
|
2458
|
+
// would otherwise be missed (e.g. <div><auro-button></auro-button></div>).
|
|
2459
|
+
if (!hasInternalFocus) {
|
|
2460
|
+
const descendants = this.trigger.querySelectorAll('*');
|
|
2461
|
+
|
|
2462
|
+
for (const child of descendants) {
|
|
2463
|
+
if (child.localName.includes('-') && (child.tabIndex >= 0 ||
|
|
2464
|
+
(child.shadowRoot && [...child.shadowRoot.querySelectorAll(focusableSelector)].some(isReachable)))) {
|
|
2465
|
+
hasInternalFocus = true;
|
|
2466
|
+
break;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
// For custom elements used directly as the trigger (not wrapped),
|
|
2472
|
+
// also check the trigger's own shadow DOM for focusable descendants.
|
|
2473
|
+
// If the shadow root is inaccessible (closed mode or not yet upgraded),
|
|
2474
|
+
// we cannot inspect it — the element will receive tabindex if it is not
|
|
2475
|
+
// otherwise focusable. This is a known limitation documented above.
|
|
2476
|
+
if (!hasInternalFocus && this.trigger.localName.includes('-') && this.trigger.shadowRoot) {
|
|
2477
|
+
hasInternalFocus = [...this.trigger.shadowRoot.querySelectorAll(focusableSelector)].some(isReachable);
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
if (!isNativelyFocusable && !hasInternalFocus && !this.trigger.hasAttribute("tabindex")) {
|
|
2481
|
+
this.trigger.setAttribute("tabindex", "0");
|
|
2482
|
+
this._addedTabIndex = true;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// Set up aria-description on the appropriate focusable element(s).
|
|
2486
|
+
// NOTE: aria-description is defined in the ARIA 1.3 spec. It is well-supported
|
|
2487
|
+
// in modern browsers and screen readers (Chrome 92+, Firefox 92+, Safari 15.4+)
|
|
2488
|
+
// but may be unfamiliar — do not replace with aria-describedby.
|
|
2489
|
+
const slot = this.shadowRoot.querySelector("slot:not([name])");
|
|
2490
|
+
const getSlotText = () => slot.assignedNodes({ flatten: true })
|
|
2491
|
+
.map((n) => n.textContent ?? "")
|
|
2492
|
+
.join(" ")
|
|
2493
|
+
.replace(/\s+/g, " ")
|
|
2494
|
+
.trim();
|
|
2495
|
+
|
|
2496
|
+
// Determine which elements should receive aria-description.
|
|
2497
|
+
// When the trigger is a non-focusable wrapper around focusable content
|
|
2498
|
+
// (e.g. <div><a href="#">link</a></div>), the description must go on
|
|
2499
|
+
// every element that can actually receive focus so screen readers announce it.
|
|
2500
|
+
this._ariaDescriptionTargets = [];
|
|
2501
|
+
|
|
2502
|
+
if (!isNativelyFocusable && hasInternalFocus) {
|
|
2503
|
+
// Gather all keyboard-reachable light DOM descendants.
|
|
2504
|
+
const nativeMatches = [...this.trigger.querySelectorAll(focusableSelector)].filter(isReachable);
|
|
2505
|
+
|
|
2506
|
+
this._ariaDescriptionTargets.push(...nativeMatches);
|
|
2507
|
+
|
|
2508
|
+
// Check custom element descendants whose shadow DOM is focusable.
|
|
2509
|
+
const allDescendants = this.trigger.querySelectorAll('*');
|
|
2510
|
+
|
|
2511
|
+
for (const child of allDescendants) {
|
|
2512
|
+
if (!child.localName.includes('-')) continue;
|
|
2513
|
+
// Skip if already matched by the native selector (e.g. has tabindex attribute).
|
|
2514
|
+
if (nativeMatches.includes(child)) continue;
|
|
2515
|
+
|
|
2516
|
+
if (child.tabIndex >= 0) {
|
|
2517
|
+
// Host is keyboard-reachable (delegatesFocus or explicit tabindex).
|
|
2518
|
+
this._ariaDescriptionTargets.push(child);
|
|
2519
|
+
} else if (child.shadowRoot) {
|
|
2520
|
+
// Host is not keyboard-reachable; focus goes to internal elements.
|
|
2521
|
+
// Set description directly on the shadow DOM focusable controls.
|
|
2522
|
+
const shadowFocusable = [...child.shadowRoot.querySelectorAll(focusableSelector)].filter(isReachable);
|
|
2523
|
+
|
|
2524
|
+
for (const el of shadowFocusable) {
|
|
2525
|
+
this._ariaDescriptionTargets.push(el);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
if (this._ariaDescriptionTargets.length === 0) {
|
|
2531
|
+
// The trigger itself is a custom element with focusable shadow content
|
|
2532
|
+
// (e.g. mock-focusable, auro-button used directly as trigger).
|
|
2533
|
+
// Light DOM searches found nothing; add the shadow focusable controls
|
|
2534
|
+
// so the description is announced when focus lands inside the shadow root.
|
|
2535
|
+
if (this.trigger.localName.includes('-') && this.trigger.shadowRoot) {
|
|
2536
|
+
const shadowFocusable = [...this.trigger.shadowRoot.querySelectorAll(focusableSelector)].filter(isReachable);
|
|
2537
|
+
|
|
2538
|
+
this._ariaDescriptionTargets.push(...shadowFocusable);
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
// Final fallback: if no focusable targets were discovered, put the
|
|
2542
|
+
// description on the trigger host itself.
|
|
2543
|
+
if (this._ariaDescriptionTargets.length === 0) {
|
|
2544
|
+
this._ariaDescriptionTargets.push(this.trigger);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
} else {
|
|
2548
|
+
this._ariaDescriptionTargets.push(this.trigger);
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
const description = getSlotText();
|
|
2552
|
+
|
|
2553
|
+
for (const target of this._ariaDescriptionTargets) {
|
|
2554
|
+
target.setAttribute("aria-description", description);
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
// Keep aria-description in sync if slot content changes after first render.
|
|
2558
|
+
this._onSlotChange = () => {
|
|
2559
|
+
const text = getSlotText();
|
|
2560
|
+
|
|
2561
|
+
for (const target of this._ariaDescriptionTargets) {
|
|
2562
|
+
target?.setAttribute("aria-description", text);
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
slot.addEventListener("slotchange", this._onSlotChange);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Toggles the display of the popover content.
|
|
2570
|
+
* @private
|
|
2571
|
+
* @returns {void} Fires an update lifecycle.
|
|
2572
|
+
*/
|
|
2573
|
+
toggle() {
|
|
2574
|
+
if (!this.popper) {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
if (this.isPopoverVisible) {
|
|
2578
|
+
this.toggleHide();
|
|
2579
|
+
} else {
|
|
2580
|
+
this.toggleShow();
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
/**
|
|
2585
|
+
* Hides the popover.
|
|
2586
|
+
* @private
|
|
2587
|
+
* @returns {void} Fires an update lifecycle.
|
|
2588
|
+
*/
|
|
2589
|
+
toggleHide() {
|
|
2590
|
+
this.isPopoverVisible = false;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* Shows the popover.
|
|
2595
|
+
* @private
|
|
2596
|
+
* @returns {void} Fires an update lifecycle.
|
|
2597
|
+
*/
|
|
2598
|
+
toggleShow() {
|
|
2599
|
+
if (!this.popper || this.disabled) {
|
|
2600
|
+
return;
|
|
2601
|
+
}
|
|
2602
|
+
this.isPopoverVisible = true;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* Hides the popover when hovering outside of the popover or it's trigger.
|
|
2607
|
+
* @private
|
|
2608
|
+
* @param {Event} evt - The event object.
|
|
2609
|
+
* @returns {void}
|
|
2610
|
+
*/
|
|
2611
|
+
handleMouseoverEvent(evt) {
|
|
2612
|
+
if (this.isPopoverVisible && !evt.composedPath().includes(this)) {
|
|
2613
|
+
this.toggleHide();
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
updated(changedProperties) {
|
|
2618
|
+
if (changedProperties.has("boundary") && this.popper) {
|
|
2619
|
+
// Use setBoundary() rather than assigning directly — it resolves selector
|
|
2620
|
+
// strings to Elements. Assigning a raw string would break Popper's
|
|
2621
|
+
// preventOverflow modifier, which expects an Element.
|
|
2622
|
+
this.popper.boundaryElement = this.popper.setBoundary(this.boundary);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
// Sync Popper positioning and body listeners whenever visibility changes.
|
|
2626
|
+
// This runs after Lit has reflected the data-show attribute to the host,
|
|
2627
|
+
// so the CSS that controls .popover display is already applied and Popper
|
|
2628
|
+
// can measure a visible element. Centralising the side effects here also
|
|
2629
|
+
// guards against external data-show / isPopoverVisible changes that would
|
|
2630
|
+
// otherwise bypass toggleShow()/toggleHide().
|
|
2631
|
+
if (changedProperties.has("isPopoverVisible") && this.popper) {
|
|
2632
|
+
if (this.isPopoverVisible) {
|
|
2633
|
+
// Reject visibility when disabled — force back to false so the next
|
|
2634
|
+
// updated() cycle runs the hide/cleanup path instead.
|
|
2635
|
+
if (this.disabled) {
|
|
2636
|
+
this.isPopoverVisible = false;
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
this.popper.show();
|
|
2640
|
+
document.body.addEventListener("mouseover", this._onBodyMouseover);
|
|
2641
|
+
} else {
|
|
2642
|
+
if (this._onBodyMouseover) {
|
|
2643
|
+
document.body.removeEventListener("mouseover", this._onBodyMouseover);
|
|
2644
|
+
}
|
|
2645
|
+
this.popper.hide();
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
// If disabled becomes true while the popover is visible, force-hide so
|
|
2650
|
+
// aria-hidden, the body mouseover listener, and Popper stay in sync with
|
|
2651
|
+
// the CSS that hides the popover via :host([disabled]).
|
|
2652
|
+
if (changedProperties.has("disabled") && this.disabled && this.isPopoverVisible) {
|
|
2653
|
+
this.isPopoverVisible = false;
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
2658
|
+
render() {
|
|
2659
|
+
return b`
|
|
2660
|
+
<div
|
|
2661
|
+
id="popover"
|
|
2662
|
+
class="popover util_insetLg body-default"
|
|
2663
|
+
popover="manual"
|
|
2664
|
+
part="popover"
|
|
2665
|
+
role="tooltip"
|
|
2666
|
+
aria-hidden="${this.isPopoverVisible ? 'false' : 'true'}">
|
|
2667
|
+
<div id="arrow" class="arrow" data-popper-arrow></div>
|
|
2668
|
+
<slot></slot>
|
|
2669
|
+
</div>
|
|
2670
|
+
|
|
2671
|
+
<span role="presentation">
|
|
2672
|
+
<slot name="trigger" data-trigger-placement="${this.placement}"></slot>
|
|
2673
|
+
</span>
|
|
2674
|
+
`;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
|
|
10
2678
|
AuroPopover.register();
|
|
11
2679
|
|
|
12
2680
|
function initExamples(initCount) {
|