@aurodesignsystem-dev/auro-slideshow 0.0.0-pr18.0 → 0.0.0-pr19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -30
- package/demo/api.html +2 -2
- package/demo/api.js +1 -1
- package/demo/api.md +217 -147
- package/demo/api.min.js +2 -4417
- package/demo/auro-slideshow.min.js +4327 -0
- package/demo/demo-index.js +1 -1
- package/demo/demo-index.min.js +1 -2222
- package/demo/index.md +126 -41
- package/dist/auro-slideshow-DwITKEwA.js +106 -0
- package/dist/index.d.ts +101 -155
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +10 -6
- package/dist/auro-slideshow-CQx2uBIO.js +0 -101
|
@@ -0,0 +1,4327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t$2=globalThis,e$4=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$3=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$3)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$3("string"==typeof t?t:t+"",void 0,s$3),i$5=(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$3(o,t,s$3)},S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/const{is:i$4,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$2=globalThis,c$1=a$2.trustedTypes,l$2=c$1?c$1.emptyScript:"",p$1=a$2.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$2={toAttribute(t,s){switch(s){case Boolean:t=t?l$2: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$4(t,s),b={attribute:true,type:String,converter:u$2,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$2.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$3(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$1(t),...o$4(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$2).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$2;this._$Em=e,this[e]=h.fromAttribute(s,t.type)??this._$Ej?.get(e)??null,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$2.reactiveElementVersions??=[]).push("2.1.0");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const t$1=globalThis,i$3=t$1.trustedTypes,s$2=i$3?i$3.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$2="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r=document,l$1=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a$1=Array.isArray,u$1=t=>a$1(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a$1(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$2?s$2.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$2+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$2)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$3?i$3.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l$1()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l$1());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u$1(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a$1(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l$1()),this.O(l$1()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.3.0");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l$1(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const s$1=globalThis;let i$2 = class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}};i$2._$litElement$=true,i$2["finalized"]=true,s$1.litElementHydrateSupport?.({LitElement:i$2});const o$2=s$1.litElementPolyfillSupport;o$2?.({LitElement:i$2});(s$1.litElementVersions??=[]).push("4.2.0");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2020 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/
|
|
32
|
+
const a=Symbol.for(""),o$1=t=>{if(t?.r===a)return t?._$litStatic$},s=t=>({_$litStatic$:t,r:a}),i$1=(t,...r)=>({_$litStatic$:r.reduce(((r,e,a)=>r+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(e)+t[a+1]),t[0]),r:a}),l=new Map,n=t=>(r,...e)=>{const a=e.length;let s,i;const n=[],u=[];let c,$=0,f=false;for(;$<a;){for(c=r[$];$<a&&void 0!==(i=e[$],s=o$1(i));)c+=s+r[++$],f=true;$!==a&&u.push(i),n.push(c),$++;}if($===a&&n.push(r[a]),f){const t=n.join("$$lit$$");void 0===(r=l.get(t))&&(n.raw=n,l.set(t,r=n)),e=u;}return t(r,...e)},u=n(x);
|
|
33
|
+
|
|
34
|
+
function isNumber(subject) {
|
|
35
|
+
return typeof subject === 'number';
|
|
36
|
+
}
|
|
37
|
+
function isString(subject) {
|
|
38
|
+
return typeof subject === 'string';
|
|
39
|
+
}
|
|
40
|
+
function isBoolean(subject) {
|
|
41
|
+
return typeof subject === 'boolean';
|
|
42
|
+
}
|
|
43
|
+
function isObject(subject) {
|
|
44
|
+
return Object.prototype.toString.call(subject) === '[object Object]';
|
|
45
|
+
}
|
|
46
|
+
function mathAbs(n) {
|
|
47
|
+
return Math.abs(n);
|
|
48
|
+
}
|
|
49
|
+
function mathSign(n) {
|
|
50
|
+
return Math.sign(n);
|
|
51
|
+
}
|
|
52
|
+
function deltaAbs(valueB, valueA) {
|
|
53
|
+
return mathAbs(valueB - valueA);
|
|
54
|
+
}
|
|
55
|
+
function factorAbs(valueB, valueA) {
|
|
56
|
+
if (valueB === 0 || valueA === 0) return 0;
|
|
57
|
+
if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
|
|
58
|
+
const diff = deltaAbs(mathAbs(valueB), mathAbs(valueA));
|
|
59
|
+
return mathAbs(diff / valueB);
|
|
60
|
+
}
|
|
61
|
+
function roundToTwoDecimals(num) {
|
|
62
|
+
return Math.round(num * 100) / 100;
|
|
63
|
+
}
|
|
64
|
+
function arrayKeys(array) {
|
|
65
|
+
return objectKeys(array).map(Number);
|
|
66
|
+
}
|
|
67
|
+
function arrayLast(array) {
|
|
68
|
+
return array[arrayLastIndex(array)];
|
|
69
|
+
}
|
|
70
|
+
function arrayLastIndex(array) {
|
|
71
|
+
return Math.max(0, array.length - 1);
|
|
72
|
+
}
|
|
73
|
+
function arrayIsLastIndex(array, index) {
|
|
74
|
+
return index === arrayLastIndex(array);
|
|
75
|
+
}
|
|
76
|
+
function arrayFromNumber(n, startAt = 0) {
|
|
77
|
+
return Array.from(Array(n), (_, i) => startAt + i);
|
|
78
|
+
}
|
|
79
|
+
function objectKeys(object) {
|
|
80
|
+
return Object.keys(object);
|
|
81
|
+
}
|
|
82
|
+
function objectsMergeDeep(objectA, objectB) {
|
|
83
|
+
return [objectA, objectB].reduce((mergedObjects, currentObject) => {
|
|
84
|
+
objectKeys(currentObject).forEach(key => {
|
|
85
|
+
const valueA = mergedObjects[key];
|
|
86
|
+
const valueB = currentObject[key];
|
|
87
|
+
const areObjects = isObject(valueA) && isObject(valueB);
|
|
88
|
+
mergedObjects[key] = areObjects ? objectsMergeDeep(valueA, valueB) : valueB;
|
|
89
|
+
});
|
|
90
|
+
return mergedObjects;
|
|
91
|
+
}, {});
|
|
92
|
+
}
|
|
93
|
+
function isMouseEvent(evt, ownerWindow) {
|
|
94
|
+
return typeof ownerWindow.MouseEvent !== 'undefined' && evt instanceof ownerWindow.MouseEvent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function Alignment(align, viewSize) {
|
|
98
|
+
const predefined = {
|
|
99
|
+
start,
|
|
100
|
+
center,
|
|
101
|
+
end
|
|
102
|
+
};
|
|
103
|
+
function start() {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
function center(n) {
|
|
107
|
+
return end(n) / 2;
|
|
108
|
+
}
|
|
109
|
+
function end(n) {
|
|
110
|
+
return viewSize - n;
|
|
111
|
+
}
|
|
112
|
+
function measure(n, index) {
|
|
113
|
+
if (isString(align)) return predefined[align](n);
|
|
114
|
+
return align(viewSize, n, index);
|
|
115
|
+
}
|
|
116
|
+
const self = {
|
|
117
|
+
measure
|
|
118
|
+
};
|
|
119
|
+
return self;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function EventStore() {
|
|
123
|
+
let listeners = [];
|
|
124
|
+
function add(node, type, handler, options = {
|
|
125
|
+
passive: true
|
|
126
|
+
}) {
|
|
127
|
+
let removeListener;
|
|
128
|
+
if ('addEventListener' in node) {
|
|
129
|
+
node.addEventListener(type, handler, options);
|
|
130
|
+
removeListener = () => node.removeEventListener(type, handler, options);
|
|
131
|
+
} else {
|
|
132
|
+
const legacyMediaQueryList = node;
|
|
133
|
+
legacyMediaQueryList.addListener(handler);
|
|
134
|
+
removeListener = () => legacyMediaQueryList.removeListener(handler);
|
|
135
|
+
}
|
|
136
|
+
listeners.push(removeListener);
|
|
137
|
+
return self;
|
|
138
|
+
}
|
|
139
|
+
function clear() {
|
|
140
|
+
listeners = listeners.filter(remove => remove());
|
|
141
|
+
}
|
|
142
|
+
const self = {
|
|
143
|
+
add,
|
|
144
|
+
clear
|
|
145
|
+
};
|
|
146
|
+
return self;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function Animations(ownerDocument, ownerWindow, update, render) {
|
|
150
|
+
const documentVisibleHandler = EventStore();
|
|
151
|
+
const fixedTimeStep = 1000 / 60;
|
|
152
|
+
let lastTimeStamp = null;
|
|
153
|
+
let accumulatedTime = 0;
|
|
154
|
+
let animationId = 0;
|
|
155
|
+
function init() {
|
|
156
|
+
documentVisibleHandler.add(ownerDocument, 'visibilitychange', () => {
|
|
157
|
+
if (ownerDocument.hidden) reset();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function destroy() {
|
|
161
|
+
stop();
|
|
162
|
+
documentVisibleHandler.clear();
|
|
163
|
+
}
|
|
164
|
+
function animate(timeStamp) {
|
|
165
|
+
if (!animationId) return;
|
|
166
|
+
if (!lastTimeStamp) {
|
|
167
|
+
lastTimeStamp = timeStamp;
|
|
168
|
+
update();
|
|
169
|
+
update();
|
|
170
|
+
}
|
|
171
|
+
const timeElapsed = timeStamp - lastTimeStamp;
|
|
172
|
+
lastTimeStamp = timeStamp;
|
|
173
|
+
accumulatedTime += timeElapsed;
|
|
174
|
+
while (accumulatedTime >= fixedTimeStep) {
|
|
175
|
+
update();
|
|
176
|
+
accumulatedTime -= fixedTimeStep;
|
|
177
|
+
}
|
|
178
|
+
const alpha = accumulatedTime / fixedTimeStep;
|
|
179
|
+
render(alpha);
|
|
180
|
+
if (animationId) {
|
|
181
|
+
animationId = ownerWindow.requestAnimationFrame(animate);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function start() {
|
|
185
|
+
if (animationId) return;
|
|
186
|
+
animationId = ownerWindow.requestAnimationFrame(animate);
|
|
187
|
+
}
|
|
188
|
+
function stop() {
|
|
189
|
+
ownerWindow.cancelAnimationFrame(animationId);
|
|
190
|
+
lastTimeStamp = null;
|
|
191
|
+
accumulatedTime = 0;
|
|
192
|
+
animationId = 0;
|
|
193
|
+
}
|
|
194
|
+
function reset() {
|
|
195
|
+
lastTimeStamp = null;
|
|
196
|
+
accumulatedTime = 0;
|
|
197
|
+
}
|
|
198
|
+
const self = {
|
|
199
|
+
init,
|
|
200
|
+
destroy,
|
|
201
|
+
start,
|
|
202
|
+
stop,
|
|
203
|
+
update,
|
|
204
|
+
render
|
|
205
|
+
};
|
|
206
|
+
return self;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function Axis(axis, contentDirection) {
|
|
210
|
+
const isRightToLeft = contentDirection === 'rtl';
|
|
211
|
+
const isVertical = axis === 'y';
|
|
212
|
+
const scroll = isVertical ? 'y' : 'x';
|
|
213
|
+
const cross = isVertical ? 'x' : 'y';
|
|
214
|
+
const sign = !isVertical && isRightToLeft ? -1 : 1;
|
|
215
|
+
const startEdge = getStartEdge();
|
|
216
|
+
const endEdge = getEndEdge();
|
|
217
|
+
function measureSize(nodeRect) {
|
|
218
|
+
const {
|
|
219
|
+
height,
|
|
220
|
+
width
|
|
221
|
+
} = nodeRect;
|
|
222
|
+
return isVertical ? height : width;
|
|
223
|
+
}
|
|
224
|
+
function getStartEdge() {
|
|
225
|
+
if (isVertical) return 'top';
|
|
226
|
+
return isRightToLeft ? 'right' : 'left';
|
|
227
|
+
}
|
|
228
|
+
function getEndEdge() {
|
|
229
|
+
if (isVertical) return 'bottom';
|
|
230
|
+
return isRightToLeft ? 'left' : 'right';
|
|
231
|
+
}
|
|
232
|
+
function direction(n) {
|
|
233
|
+
return n * sign;
|
|
234
|
+
}
|
|
235
|
+
const self = {
|
|
236
|
+
scroll,
|
|
237
|
+
cross,
|
|
238
|
+
startEdge,
|
|
239
|
+
endEdge,
|
|
240
|
+
measureSize,
|
|
241
|
+
direction
|
|
242
|
+
};
|
|
243
|
+
return self;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function Limit(min = 0, max = 0) {
|
|
247
|
+
const length = mathAbs(min - max);
|
|
248
|
+
function reachedMin(n) {
|
|
249
|
+
return n < min;
|
|
250
|
+
}
|
|
251
|
+
function reachedMax(n) {
|
|
252
|
+
return n > max;
|
|
253
|
+
}
|
|
254
|
+
function reachedAny(n) {
|
|
255
|
+
return reachedMin(n) || reachedMax(n);
|
|
256
|
+
}
|
|
257
|
+
function constrain(n) {
|
|
258
|
+
if (!reachedAny(n)) return n;
|
|
259
|
+
return reachedMin(n) ? min : max;
|
|
260
|
+
}
|
|
261
|
+
function removeOffset(n) {
|
|
262
|
+
if (!length) return n;
|
|
263
|
+
return n - length * Math.ceil((n - max) / length);
|
|
264
|
+
}
|
|
265
|
+
const self = {
|
|
266
|
+
length,
|
|
267
|
+
max,
|
|
268
|
+
min,
|
|
269
|
+
constrain,
|
|
270
|
+
reachedAny,
|
|
271
|
+
reachedMax,
|
|
272
|
+
reachedMin,
|
|
273
|
+
removeOffset
|
|
274
|
+
};
|
|
275
|
+
return self;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function Counter(max, start, loop) {
|
|
279
|
+
const {
|
|
280
|
+
constrain
|
|
281
|
+
} = Limit(0, max);
|
|
282
|
+
const loopEnd = max + 1;
|
|
283
|
+
let counter = withinLimit(start);
|
|
284
|
+
function withinLimit(n) {
|
|
285
|
+
return !loop ? constrain(n) : mathAbs((loopEnd + n) % loopEnd);
|
|
286
|
+
}
|
|
287
|
+
function get() {
|
|
288
|
+
return counter;
|
|
289
|
+
}
|
|
290
|
+
function set(n) {
|
|
291
|
+
counter = withinLimit(n);
|
|
292
|
+
return self;
|
|
293
|
+
}
|
|
294
|
+
function add(n) {
|
|
295
|
+
return clone().set(get() + n);
|
|
296
|
+
}
|
|
297
|
+
function clone() {
|
|
298
|
+
return Counter(max, get(), loop);
|
|
299
|
+
}
|
|
300
|
+
const self = {
|
|
301
|
+
get,
|
|
302
|
+
set,
|
|
303
|
+
add,
|
|
304
|
+
clone
|
|
305
|
+
};
|
|
306
|
+
return self;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function DragHandler(axis, rootNode, ownerDocument, ownerWindow, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction, watchDrag) {
|
|
310
|
+
const {
|
|
311
|
+
cross: crossAxis,
|
|
312
|
+
direction
|
|
313
|
+
} = axis;
|
|
314
|
+
const focusNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
|
|
315
|
+
const nonPassiveEvent = {
|
|
316
|
+
passive: false
|
|
317
|
+
};
|
|
318
|
+
const initEvents = EventStore();
|
|
319
|
+
const dragEvents = EventStore();
|
|
320
|
+
const goToNextThreshold = Limit(50, 225).constrain(percentOfView.measure(20));
|
|
321
|
+
const snapForceBoost = {
|
|
322
|
+
mouse: 300,
|
|
323
|
+
touch: 400
|
|
324
|
+
};
|
|
325
|
+
const freeForceBoost = {
|
|
326
|
+
mouse: 500,
|
|
327
|
+
touch: 600
|
|
328
|
+
};
|
|
329
|
+
const baseSpeed = dragFree ? 43 : 25;
|
|
330
|
+
let isMoving = false;
|
|
331
|
+
let startScroll = 0;
|
|
332
|
+
let startCross = 0;
|
|
333
|
+
let pointerIsDown = false;
|
|
334
|
+
let preventScroll = false;
|
|
335
|
+
let preventClick = false;
|
|
336
|
+
let isMouse = false;
|
|
337
|
+
function init(emblaApi) {
|
|
338
|
+
if (!watchDrag) return;
|
|
339
|
+
function downIfAllowed(evt) {
|
|
340
|
+
if (isBoolean(watchDrag) || watchDrag(emblaApi, evt)) down(evt);
|
|
341
|
+
}
|
|
342
|
+
const node = rootNode;
|
|
343
|
+
initEvents.add(node, 'dragstart', evt => evt.preventDefault(), nonPassiveEvent).add(node, 'touchmove', () => undefined, nonPassiveEvent).add(node, 'touchend', () => undefined).add(node, 'touchstart', downIfAllowed).add(node, 'mousedown', downIfAllowed).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click, true);
|
|
344
|
+
}
|
|
345
|
+
function destroy() {
|
|
346
|
+
initEvents.clear();
|
|
347
|
+
dragEvents.clear();
|
|
348
|
+
}
|
|
349
|
+
function addDragEvents() {
|
|
350
|
+
const node = isMouse ? ownerDocument : rootNode;
|
|
351
|
+
dragEvents.add(node, 'touchmove', move, nonPassiveEvent).add(node, 'touchend', up).add(node, 'mousemove', move, nonPassiveEvent).add(node, 'mouseup', up);
|
|
352
|
+
}
|
|
353
|
+
function isFocusNode(node) {
|
|
354
|
+
const nodeName = node.nodeName || '';
|
|
355
|
+
return focusNodes.includes(nodeName);
|
|
356
|
+
}
|
|
357
|
+
function forceBoost() {
|
|
358
|
+
const boost = dragFree ? freeForceBoost : snapForceBoost;
|
|
359
|
+
const type = isMouse ? 'mouse' : 'touch';
|
|
360
|
+
return boost[type];
|
|
361
|
+
}
|
|
362
|
+
function allowedForce(force, targetChanged) {
|
|
363
|
+
const next = index.add(mathSign(force) * -1);
|
|
364
|
+
const baseForce = scrollTarget.byDistance(force, !dragFree).distance;
|
|
365
|
+
if (dragFree || mathAbs(force) < goToNextThreshold) return baseForce;
|
|
366
|
+
if (skipSnaps && targetChanged) return baseForce * 0.5;
|
|
367
|
+
return scrollTarget.byIndex(next.get(), 0).distance;
|
|
368
|
+
}
|
|
369
|
+
function down(evt) {
|
|
370
|
+
const isMouseEvt = isMouseEvent(evt, ownerWindow);
|
|
371
|
+
isMouse = isMouseEvt;
|
|
372
|
+
preventClick = dragFree && isMouseEvt && !evt.buttons && isMoving;
|
|
373
|
+
isMoving = deltaAbs(target.get(), location.get()) >= 2;
|
|
374
|
+
if (isMouseEvt && evt.button !== 0) return;
|
|
375
|
+
if (isFocusNode(evt.target)) return;
|
|
376
|
+
pointerIsDown = true;
|
|
377
|
+
dragTracker.pointerDown(evt);
|
|
378
|
+
scrollBody.useFriction(0).useDuration(0);
|
|
379
|
+
target.set(location);
|
|
380
|
+
addDragEvents();
|
|
381
|
+
startScroll = dragTracker.readPoint(evt);
|
|
382
|
+
startCross = dragTracker.readPoint(evt, crossAxis);
|
|
383
|
+
eventHandler.emit('pointerDown');
|
|
384
|
+
}
|
|
385
|
+
function move(evt) {
|
|
386
|
+
const isTouchEvt = !isMouseEvent(evt, ownerWindow);
|
|
387
|
+
if (isTouchEvt && evt.touches.length >= 2) return up(evt);
|
|
388
|
+
const lastScroll = dragTracker.readPoint(evt);
|
|
389
|
+
const lastCross = dragTracker.readPoint(evt, crossAxis);
|
|
390
|
+
const diffScroll = deltaAbs(lastScroll, startScroll);
|
|
391
|
+
const diffCross = deltaAbs(lastCross, startCross);
|
|
392
|
+
if (!preventScroll && !isMouse) {
|
|
393
|
+
if (!evt.cancelable) return up(evt);
|
|
394
|
+
preventScroll = diffScroll > diffCross;
|
|
395
|
+
if (!preventScroll) return up(evt);
|
|
396
|
+
}
|
|
397
|
+
const diff = dragTracker.pointerMove(evt);
|
|
398
|
+
if (diffScroll > dragThreshold) preventClick = true;
|
|
399
|
+
scrollBody.useFriction(0.3).useDuration(0.75);
|
|
400
|
+
animation.start();
|
|
401
|
+
target.add(direction(diff));
|
|
402
|
+
evt.preventDefault();
|
|
403
|
+
}
|
|
404
|
+
function up(evt) {
|
|
405
|
+
const currentLocation = scrollTarget.byDistance(0, false);
|
|
406
|
+
const targetChanged = currentLocation.index !== index.get();
|
|
407
|
+
const rawForce = dragTracker.pointerUp(evt) * forceBoost();
|
|
408
|
+
const force = allowedForce(direction(rawForce), targetChanged);
|
|
409
|
+
const forceFactor = factorAbs(rawForce, force);
|
|
410
|
+
const speed = baseSpeed - 10 * forceFactor;
|
|
411
|
+
const friction = baseFriction + forceFactor / 50;
|
|
412
|
+
preventScroll = false;
|
|
413
|
+
pointerIsDown = false;
|
|
414
|
+
dragEvents.clear();
|
|
415
|
+
scrollBody.useDuration(speed).useFriction(friction);
|
|
416
|
+
scrollTo.distance(force, !dragFree);
|
|
417
|
+
isMouse = false;
|
|
418
|
+
eventHandler.emit('pointerUp');
|
|
419
|
+
}
|
|
420
|
+
function click(evt) {
|
|
421
|
+
if (preventClick) {
|
|
422
|
+
evt.stopPropagation();
|
|
423
|
+
evt.preventDefault();
|
|
424
|
+
preventClick = false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function pointerDown() {
|
|
428
|
+
return pointerIsDown;
|
|
429
|
+
}
|
|
430
|
+
const self = {
|
|
431
|
+
init,
|
|
432
|
+
destroy,
|
|
433
|
+
pointerDown
|
|
434
|
+
};
|
|
435
|
+
return self;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function DragTracker(axis, ownerWindow) {
|
|
439
|
+
const logInterval = 170;
|
|
440
|
+
let startEvent;
|
|
441
|
+
let lastEvent;
|
|
442
|
+
function readTime(evt) {
|
|
443
|
+
return evt.timeStamp;
|
|
444
|
+
}
|
|
445
|
+
function readPoint(evt, evtAxis) {
|
|
446
|
+
const property = evtAxis || axis.scroll;
|
|
447
|
+
const coord = `client${property === 'x' ? 'X' : 'Y'}`;
|
|
448
|
+
return (isMouseEvent(evt, ownerWindow) ? evt : evt.touches[0])[coord];
|
|
449
|
+
}
|
|
450
|
+
function pointerDown(evt) {
|
|
451
|
+
startEvent = evt;
|
|
452
|
+
lastEvent = evt;
|
|
453
|
+
return readPoint(evt);
|
|
454
|
+
}
|
|
455
|
+
function pointerMove(evt) {
|
|
456
|
+
const diff = readPoint(evt) - readPoint(lastEvent);
|
|
457
|
+
const expired = readTime(evt) - readTime(startEvent) > logInterval;
|
|
458
|
+
lastEvent = evt;
|
|
459
|
+
if (expired) startEvent = evt;
|
|
460
|
+
return diff;
|
|
461
|
+
}
|
|
462
|
+
function pointerUp(evt) {
|
|
463
|
+
if (!startEvent || !lastEvent) return 0;
|
|
464
|
+
const diffDrag = readPoint(lastEvent) - readPoint(startEvent);
|
|
465
|
+
const diffTime = readTime(evt) - readTime(startEvent);
|
|
466
|
+
const expired = readTime(evt) - readTime(lastEvent) > logInterval;
|
|
467
|
+
const force = diffDrag / diffTime;
|
|
468
|
+
const isFlick = diffTime && !expired && mathAbs(force) > 0.1;
|
|
469
|
+
return isFlick ? force : 0;
|
|
470
|
+
}
|
|
471
|
+
const self = {
|
|
472
|
+
pointerDown,
|
|
473
|
+
pointerMove,
|
|
474
|
+
pointerUp,
|
|
475
|
+
readPoint
|
|
476
|
+
};
|
|
477
|
+
return self;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function NodeRects() {
|
|
481
|
+
function measure(node) {
|
|
482
|
+
const {
|
|
483
|
+
offsetTop,
|
|
484
|
+
offsetLeft,
|
|
485
|
+
offsetWidth,
|
|
486
|
+
offsetHeight
|
|
487
|
+
} = node;
|
|
488
|
+
const offset = {
|
|
489
|
+
top: offsetTop,
|
|
490
|
+
right: offsetLeft + offsetWidth,
|
|
491
|
+
bottom: offsetTop + offsetHeight,
|
|
492
|
+
left: offsetLeft,
|
|
493
|
+
width: offsetWidth,
|
|
494
|
+
height: offsetHeight
|
|
495
|
+
};
|
|
496
|
+
return offset;
|
|
497
|
+
}
|
|
498
|
+
const self = {
|
|
499
|
+
measure
|
|
500
|
+
};
|
|
501
|
+
return self;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function PercentOfView(viewSize) {
|
|
505
|
+
function measure(n) {
|
|
506
|
+
return viewSize * (n / 100);
|
|
507
|
+
}
|
|
508
|
+
const self = {
|
|
509
|
+
measure
|
|
510
|
+
};
|
|
511
|
+
return self;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects) {
|
|
515
|
+
const observeNodes = [container].concat(slides);
|
|
516
|
+
let resizeObserver;
|
|
517
|
+
let containerSize;
|
|
518
|
+
let slideSizes = [];
|
|
519
|
+
let destroyed = false;
|
|
520
|
+
function readSize(node) {
|
|
521
|
+
return axis.measureSize(nodeRects.measure(node));
|
|
522
|
+
}
|
|
523
|
+
function init(emblaApi) {
|
|
524
|
+
if (!watchResize) return;
|
|
525
|
+
containerSize = readSize(container);
|
|
526
|
+
slideSizes = slides.map(readSize);
|
|
527
|
+
function defaultCallback(entries) {
|
|
528
|
+
for (const entry of entries) {
|
|
529
|
+
if (destroyed) return;
|
|
530
|
+
const isContainer = entry.target === container;
|
|
531
|
+
const slideIndex = slides.indexOf(entry.target);
|
|
532
|
+
const lastSize = isContainer ? containerSize : slideSizes[slideIndex];
|
|
533
|
+
const newSize = readSize(isContainer ? container : slides[slideIndex]);
|
|
534
|
+
const diffSize = mathAbs(newSize - lastSize);
|
|
535
|
+
if (diffSize >= 0.5) {
|
|
536
|
+
emblaApi.reInit();
|
|
537
|
+
eventHandler.emit('resize');
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
resizeObserver = new ResizeObserver(entries => {
|
|
543
|
+
if (isBoolean(watchResize) || watchResize(emblaApi, entries)) {
|
|
544
|
+
defaultCallback(entries);
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
ownerWindow.requestAnimationFrame(() => {
|
|
548
|
+
observeNodes.forEach(node => resizeObserver.observe(node));
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function destroy() {
|
|
552
|
+
destroyed = true;
|
|
553
|
+
if (resizeObserver) resizeObserver.disconnect();
|
|
554
|
+
}
|
|
555
|
+
const self = {
|
|
556
|
+
init,
|
|
557
|
+
destroy
|
|
558
|
+
};
|
|
559
|
+
return self;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
|
|
563
|
+
let scrollVelocity = 0;
|
|
564
|
+
let scrollDirection = 0;
|
|
565
|
+
let scrollDuration = baseDuration;
|
|
566
|
+
let scrollFriction = baseFriction;
|
|
567
|
+
let rawLocation = location.get();
|
|
568
|
+
let rawLocationPrevious = 0;
|
|
569
|
+
function seek() {
|
|
570
|
+
const displacement = target.get() - location.get();
|
|
571
|
+
const isInstant = !scrollDuration;
|
|
572
|
+
let scrollDistance = 0;
|
|
573
|
+
if (isInstant) {
|
|
574
|
+
scrollVelocity = 0;
|
|
575
|
+
previousLocation.set(target);
|
|
576
|
+
location.set(target);
|
|
577
|
+
scrollDistance = displacement;
|
|
578
|
+
} else {
|
|
579
|
+
previousLocation.set(location);
|
|
580
|
+
scrollVelocity += displacement / scrollDuration;
|
|
581
|
+
scrollVelocity *= scrollFriction;
|
|
582
|
+
rawLocation += scrollVelocity;
|
|
583
|
+
location.add(scrollVelocity);
|
|
584
|
+
scrollDistance = rawLocation - rawLocationPrevious;
|
|
585
|
+
}
|
|
586
|
+
scrollDirection = mathSign(scrollDistance);
|
|
587
|
+
rawLocationPrevious = rawLocation;
|
|
588
|
+
return self;
|
|
589
|
+
}
|
|
590
|
+
function settled() {
|
|
591
|
+
const diff = target.get() - offsetLocation.get();
|
|
592
|
+
return mathAbs(diff) < 0.001;
|
|
593
|
+
}
|
|
594
|
+
function duration() {
|
|
595
|
+
return scrollDuration;
|
|
596
|
+
}
|
|
597
|
+
function direction() {
|
|
598
|
+
return scrollDirection;
|
|
599
|
+
}
|
|
600
|
+
function velocity() {
|
|
601
|
+
return scrollVelocity;
|
|
602
|
+
}
|
|
603
|
+
function useBaseDuration() {
|
|
604
|
+
return useDuration(baseDuration);
|
|
605
|
+
}
|
|
606
|
+
function useBaseFriction() {
|
|
607
|
+
return useFriction(baseFriction);
|
|
608
|
+
}
|
|
609
|
+
function useDuration(n) {
|
|
610
|
+
scrollDuration = n;
|
|
611
|
+
return self;
|
|
612
|
+
}
|
|
613
|
+
function useFriction(n) {
|
|
614
|
+
scrollFriction = n;
|
|
615
|
+
return self;
|
|
616
|
+
}
|
|
617
|
+
const self = {
|
|
618
|
+
direction,
|
|
619
|
+
duration,
|
|
620
|
+
velocity,
|
|
621
|
+
seek,
|
|
622
|
+
settled,
|
|
623
|
+
useBaseFriction,
|
|
624
|
+
useBaseDuration,
|
|
625
|
+
useFriction,
|
|
626
|
+
useDuration
|
|
627
|
+
};
|
|
628
|
+
return self;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function ScrollBounds(limit, location, target, scrollBody, percentOfView) {
|
|
632
|
+
const pullBackThreshold = percentOfView.measure(10);
|
|
633
|
+
const edgeOffsetTolerance = percentOfView.measure(50);
|
|
634
|
+
const frictionLimit = Limit(0.1, 0.99);
|
|
635
|
+
let disabled = false;
|
|
636
|
+
function shouldConstrain() {
|
|
637
|
+
if (disabled) return false;
|
|
638
|
+
if (!limit.reachedAny(target.get())) return false;
|
|
639
|
+
if (!limit.reachedAny(location.get())) return false;
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
function constrain(pointerDown) {
|
|
643
|
+
if (!shouldConstrain()) return;
|
|
644
|
+
const edge = limit.reachedMin(location.get()) ? 'min' : 'max';
|
|
645
|
+
const diffToEdge = mathAbs(limit[edge] - location.get());
|
|
646
|
+
const diffToTarget = target.get() - location.get();
|
|
647
|
+
const friction = frictionLimit.constrain(diffToEdge / edgeOffsetTolerance);
|
|
648
|
+
target.subtract(diffToTarget * friction);
|
|
649
|
+
if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
|
|
650
|
+
target.set(limit.constrain(target.get()));
|
|
651
|
+
scrollBody.useDuration(25).useBaseFriction();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
function toggleActive(active) {
|
|
655
|
+
disabled = !active;
|
|
656
|
+
}
|
|
657
|
+
const self = {
|
|
658
|
+
shouldConstrain,
|
|
659
|
+
constrain,
|
|
660
|
+
toggleActive
|
|
661
|
+
};
|
|
662
|
+
return self;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance) {
|
|
666
|
+
const scrollBounds = Limit(-contentSize + viewSize, 0);
|
|
667
|
+
const snapsBounded = measureBounded();
|
|
668
|
+
const scrollContainLimit = findScrollContainLimit();
|
|
669
|
+
const snapsContained = measureContained();
|
|
670
|
+
function usePixelTolerance(bound, snap) {
|
|
671
|
+
return deltaAbs(bound, snap) <= 1;
|
|
672
|
+
}
|
|
673
|
+
function findScrollContainLimit() {
|
|
674
|
+
const startSnap = snapsBounded[0];
|
|
675
|
+
const endSnap = arrayLast(snapsBounded);
|
|
676
|
+
const min = snapsBounded.lastIndexOf(startSnap);
|
|
677
|
+
const max = snapsBounded.indexOf(endSnap) + 1;
|
|
678
|
+
return Limit(min, max);
|
|
679
|
+
}
|
|
680
|
+
function measureBounded() {
|
|
681
|
+
return snapsAligned.map((snapAligned, index) => {
|
|
682
|
+
const {
|
|
683
|
+
min,
|
|
684
|
+
max
|
|
685
|
+
} = scrollBounds;
|
|
686
|
+
const snap = scrollBounds.constrain(snapAligned);
|
|
687
|
+
const isFirst = !index;
|
|
688
|
+
const isLast = arrayIsLastIndex(snapsAligned, index);
|
|
689
|
+
if (isFirst) return max;
|
|
690
|
+
if (isLast) return min;
|
|
691
|
+
if (usePixelTolerance(min, snap)) return min;
|
|
692
|
+
if (usePixelTolerance(max, snap)) return max;
|
|
693
|
+
return snap;
|
|
694
|
+
}).map(scrollBound => parseFloat(scrollBound.toFixed(3)));
|
|
695
|
+
}
|
|
696
|
+
function measureContained() {
|
|
697
|
+
if (contentSize <= viewSize + pixelTolerance) return [scrollBounds.max];
|
|
698
|
+
if (containScroll === 'keepSnaps') return snapsBounded;
|
|
699
|
+
const {
|
|
700
|
+
min,
|
|
701
|
+
max
|
|
702
|
+
} = scrollContainLimit;
|
|
703
|
+
return snapsBounded.slice(min, max);
|
|
704
|
+
}
|
|
705
|
+
const self = {
|
|
706
|
+
snapsContained,
|
|
707
|
+
scrollContainLimit
|
|
708
|
+
};
|
|
709
|
+
return self;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function ScrollLimit(contentSize, scrollSnaps, loop) {
|
|
713
|
+
const max = scrollSnaps[0];
|
|
714
|
+
const min = loop ? max - contentSize : arrayLast(scrollSnaps);
|
|
715
|
+
const limit = Limit(min, max);
|
|
716
|
+
const self = {
|
|
717
|
+
limit
|
|
718
|
+
};
|
|
719
|
+
return self;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function ScrollLooper(contentSize, limit, location, vectors) {
|
|
723
|
+
const jointSafety = 0.1;
|
|
724
|
+
const min = limit.min + jointSafety;
|
|
725
|
+
const max = limit.max + jointSafety;
|
|
726
|
+
const {
|
|
727
|
+
reachedMin,
|
|
728
|
+
reachedMax
|
|
729
|
+
} = Limit(min, max);
|
|
730
|
+
function shouldLoop(direction) {
|
|
731
|
+
if (direction === 1) return reachedMax(location.get());
|
|
732
|
+
if (direction === -1) return reachedMin(location.get());
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
function loop(direction) {
|
|
736
|
+
if (!shouldLoop(direction)) return;
|
|
737
|
+
const loopDistance = contentSize * (direction * -1);
|
|
738
|
+
vectors.forEach(v => v.add(loopDistance));
|
|
739
|
+
}
|
|
740
|
+
const self = {
|
|
741
|
+
loop
|
|
742
|
+
};
|
|
743
|
+
return self;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function ScrollProgress(limit) {
|
|
747
|
+
const {
|
|
748
|
+
max,
|
|
749
|
+
length
|
|
750
|
+
} = limit;
|
|
751
|
+
function get(n) {
|
|
752
|
+
const currentLocation = n - max;
|
|
753
|
+
return length ? currentLocation / -length : 0;
|
|
754
|
+
}
|
|
755
|
+
const self = {
|
|
756
|
+
get
|
|
757
|
+
};
|
|
758
|
+
return self;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll) {
|
|
762
|
+
const {
|
|
763
|
+
startEdge,
|
|
764
|
+
endEdge
|
|
765
|
+
} = axis;
|
|
766
|
+
const {
|
|
767
|
+
groupSlides
|
|
768
|
+
} = slidesToScroll;
|
|
769
|
+
const alignments = measureSizes().map(alignment.measure);
|
|
770
|
+
const snaps = measureUnaligned();
|
|
771
|
+
const snapsAligned = measureAligned();
|
|
772
|
+
function measureSizes() {
|
|
773
|
+
return groupSlides(slideRects).map(rects => arrayLast(rects)[endEdge] - rects[0][startEdge]).map(mathAbs);
|
|
774
|
+
}
|
|
775
|
+
function measureUnaligned() {
|
|
776
|
+
return slideRects.map(rect => containerRect[startEdge] - rect[startEdge]).map(snap => -mathAbs(snap));
|
|
777
|
+
}
|
|
778
|
+
function measureAligned() {
|
|
779
|
+
return groupSlides(snaps).map(g => g[0]).map((snap, index) => snap + alignments[index]);
|
|
780
|
+
}
|
|
781
|
+
const self = {
|
|
782
|
+
snaps,
|
|
783
|
+
snapsAligned
|
|
784
|
+
};
|
|
785
|
+
return self;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes) {
|
|
789
|
+
const {
|
|
790
|
+
groupSlides
|
|
791
|
+
} = slidesToScroll;
|
|
792
|
+
const {
|
|
793
|
+
min,
|
|
794
|
+
max
|
|
795
|
+
} = scrollContainLimit;
|
|
796
|
+
const slideRegistry = createSlideRegistry();
|
|
797
|
+
function createSlideRegistry() {
|
|
798
|
+
const groupedSlideIndexes = groupSlides(slideIndexes);
|
|
799
|
+
const doNotContain = !containSnaps || containScroll === 'keepSnaps';
|
|
800
|
+
if (scrollSnaps.length === 1) return [slideIndexes];
|
|
801
|
+
if (doNotContain) return groupedSlideIndexes;
|
|
802
|
+
return groupedSlideIndexes.slice(min, max).map((group, index, groups) => {
|
|
803
|
+
const isFirst = !index;
|
|
804
|
+
const isLast = arrayIsLastIndex(groups, index);
|
|
805
|
+
if (isFirst) {
|
|
806
|
+
const range = arrayLast(groups[0]) + 1;
|
|
807
|
+
return arrayFromNumber(range);
|
|
808
|
+
}
|
|
809
|
+
if (isLast) {
|
|
810
|
+
const range = arrayLastIndex(slideIndexes) - arrayLast(groups)[0] + 1;
|
|
811
|
+
return arrayFromNumber(range, arrayLast(groups)[0]);
|
|
812
|
+
}
|
|
813
|
+
return group;
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
const self = {
|
|
817
|
+
slideRegistry
|
|
818
|
+
};
|
|
819
|
+
return self;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
|
|
823
|
+
const {
|
|
824
|
+
reachedAny,
|
|
825
|
+
removeOffset,
|
|
826
|
+
constrain
|
|
827
|
+
} = limit;
|
|
828
|
+
function minDistance(distances) {
|
|
829
|
+
return distances.concat().sort((a, b) => mathAbs(a) - mathAbs(b))[0];
|
|
830
|
+
}
|
|
831
|
+
function findTargetSnap(target) {
|
|
832
|
+
const distance = loop ? removeOffset(target) : constrain(target);
|
|
833
|
+
const ascDiffsToSnaps = scrollSnaps.map((snap, index) => ({
|
|
834
|
+
diff: shortcut(snap - distance, 0),
|
|
835
|
+
index
|
|
836
|
+
})).sort((d1, d2) => mathAbs(d1.diff) - mathAbs(d2.diff));
|
|
837
|
+
const {
|
|
838
|
+
index
|
|
839
|
+
} = ascDiffsToSnaps[0];
|
|
840
|
+
return {
|
|
841
|
+
index,
|
|
842
|
+
distance
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function shortcut(target, direction) {
|
|
846
|
+
const targets = [target, target + contentSize, target - contentSize];
|
|
847
|
+
if (!loop) return target;
|
|
848
|
+
if (!direction) return minDistance(targets);
|
|
849
|
+
const matchingTargets = targets.filter(t => mathSign(t) === direction);
|
|
850
|
+
if (matchingTargets.length) return minDistance(matchingTargets);
|
|
851
|
+
return arrayLast(targets) - contentSize;
|
|
852
|
+
}
|
|
853
|
+
function byIndex(index, direction) {
|
|
854
|
+
const diffToSnap = scrollSnaps[index] - targetVector.get();
|
|
855
|
+
const distance = shortcut(diffToSnap, direction);
|
|
856
|
+
return {
|
|
857
|
+
index,
|
|
858
|
+
distance
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function byDistance(distance, snap) {
|
|
862
|
+
const target = targetVector.get() + distance;
|
|
863
|
+
const {
|
|
864
|
+
index,
|
|
865
|
+
distance: targetSnapDistance
|
|
866
|
+
} = findTargetSnap(target);
|
|
867
|
+
const reachedBound = !loop && reachedAny(target);
|
|
868
|
+
if (!snap || reachedBound) return {
|
|
869
|
+
index,
|
|
870
|
+
distance
|
|
871
|
+
};
|
|
872
|
+
const diffToSnap = scrollSnaps[index] - targetSnapDistance;
|
|
873
|
+
const snapDistance = distance + shortcut(diffToSnap, 0);
|
|
874
|
+
return {
|
|
875
|
+
index,
|
|
876
|
+
distance: snapDistance
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
const self = {
|
|
880
|
+
byDistance,
|
|
881
|
+
byIndex,
|
|
882
|
+
shortcut
|
|
883
|
+
};
|
|
884
|
+
return self;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function ScrollTo(animation, indexCurrent, indexPrevious, scrollBody, scrollTarget, targetVector, eventHandler) {
|
|
888
|
+
function scrollTo(target) {
|
|
889
|
+
const distanceDiff = target.distance;
|
|
890
|
+
const indexDiff = target.index !== indexCurrent.get();
|
|
891
|
+
targetVector.add(distanceDiff);
|
|
892
|
+
if (distanceDiff) {
|
|
893
|
+
if (scrollBody.duration()) {
|
|
894
|
+
animation.start();
|
|
895
|
+
} else {
|
|
896
|
+
animation.update();
|
|
897
|
+
animation.render(1);
|
|
898
|
+
animation.update();
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (indexDiff) {
|
|
902
|
+
indexPrevious.set(indexCurrent.get());
|
|
903
|
+
indexCurrent.set(target.index);
|
|
904
|
+
eventHandler.emit('select');
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function distance(n, snap) {
|
|
908
|
+
const target = scrollTarget.byDistance(n, snap);
|
|
909
|
+
scrollTo(target);
|
|
910
|
+
}
|
|
911
|
+
function index(n, direction) {
|
|
912
|
+
const targetIndex = indexCurrent.clone().set(n);
|
|
913
|
+
const target = scrollTarget.byIndex(targetIndex.get(), direction);
|
|
914
|
+
scrollTo(target);
|
|
915
|
+
}
|
|
916
|
+
const self = {
|
|
917
|
+
distance,
|
|
918
|
+
index
|
|
919
|
+
};
|
|
920
|
+
return self;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus) {
|
|
924
|
+
const focusListenerOptions = {
|
|
925
|
+
passive: true,
|
|
926
|
+
capture: true
|
|
927
|
+
};
|
|
928
|
+
let lastTabPressTime = 0;
|
|
929
|
+
function init(emblaApi) {
|
|
930
|
+
if (!watchFocus) return;
|
|
931
|
+
function defaultCallback(index) {
|
|
932
|
+
const nowTime = new Date().getTime();
|
|
933
|
+
const diffTime = nowTime - lastTabPressTime;
|
|
934
|
+
if (diffTime > 10) return;
|
|
935
|
+
eventHandler.emit('slideFocusStart');
|
|
936
|
+
root.scrollLeft = 0;
|
|
937
|
+
const group = slideRegistry.findIndex(group => group.includes(index));
|
|
938
|
+
if (!isNumber(group)) return;
|
|
939
|
+
scrollBody.useDuration(0);
|
|
940
|
+
scrollTo.index(group, 0);
|
|
941
|
+
eventHandler.emit('slideFocus');
|
|
942
|
+
}
|
|
943
|
+
eventStore.add(document, 'keydown', registerTabPress, false);
|
|
944
|
+
slides.forEach((slide, slideIndex) => {
|
|
945
|
+
eventStore.add(slide, 'focus', evt => {
|
|
946
|
+
if (isBoolean(watchFocus) || watchFocus(emblaApi, evt)) {
|
|
947
|
+
defaultCallback(slideIndex);
|
|
948
|
+
}
|
|
949
|
+
}, focusListenerOptions);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function registerTabPress(event) {
|
|
953
|
+
if (event.code === 'Tab') lastTabPressTime = new Date().getTime();
|
|
954
|
+
}
|
|
955
|
+
const self = {
|
|
956
|
+
init
|
|
957
|
+
};
|
|
958
|
+
return self;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function Vector1D(initialValue) {
|
|
962
|
+
let value = initialValue;
|
|
963
|
+
function get() {
|
|
964
|
+
return value;
|
|
965
|
+
}
|
|
966
|
+
function set(n) {
|
|
967
|
+
value = normalizeInput(n);
|
|
968
|
+
}
|
|
969
|
+
function add(n) {
|
|
970
|
+
value += normalizeInput(n);
|
|
971
|
+
}
|
|
972
|
+
function subtract(n) {
|
|
973
|
+
value -= normalizeInput(n);
|
|
974
|
+
}
|
|
975
|
+
function normalizeInput(n) {
|
|
976
|
+
return isNumber(n) ? n : n.get();
|
|
977
|
+
}
|
|
978
|
+
const self = {
|
|
979
|
+
get,
|
|
980
|
+
set,
|
|
981
|
+
add,
|
|
982
|
+
subtract
|
|
983
|
+
};
|
|
984
|
+
return self;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
function Translate(axis, container) {
|
|
988
|
+
const translate = axis.scroll === 'x' ? x : y;
|
|
989
|
+
const containerStyle = container.style;
|
|
990
|
+
let previousTarget = null;
|
|
991
|
+
let disabled = false;
|
|
992
|
+
function x(n) {
|
|
993
|
+
return `translate3d(${n}px,0px,0px)`;
|
|
994
|
+
}
|
|
995
|
+
function y(n) {
|
|
996
|
+
return `translate3d(0px,${n}px,0px)`;
|
|
997
|
+
}
|
|
998
|
+
function to(target) {
|
|
999
|
+
if (disabled) return;
|
|
1000
|
+
const newTarget = roundToTwoDecimals(axis.direction(target));
|
|
1001
|
+
if (newTarget === previousTarget) return;
|
|
1002
|
+
containerStyle.transform = translate(newTarget);
|
|
1003
|
+
previousTarget = newTarget;
|
|
1004
|
+
}
|
|
1005
|
+
function toggleActive(active) {
|
|
1006
|
+
disabled = !active;
|
|
1007
|
+
}
|
|
1008
|
+
function clear() {
|
|
1009
|
+
if (disabled) return;
|
|
1010
|
+
containerStyle.transform = '';
|
|
1011
|
+
if (!container.getAttribute('style')) container.removeAttribute('style');
|
|
1012
|
+
}
|
|
1013
|
+
const self = {
|
|
1014
|
+
clear,
|
|
1015
|
+
to,
|
|
1016
|
+
toggleActive
|
|
1017
|
+
};
|
|
1018
|
+
return self;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, location, slides) {
|
|
1022
|
+
const roundingSafety = 0.5;
|
|
1023
|
+
const ascItems = arrayKeys(slideSizesWithGaps);
|
|
1024
|
+
const descItems = arrayKeys(slideSizesWithGaps).reverse();
|
|
1025
|
+
const loopPoints = startPoints().concat(endPoints());
|
|
1026
|
+
function removeSlideSizes(indexes, from) {
|
|
1027
|
+
return indexes.reduce((a, i) => {
|
|
1028
|
+
return a - slideSizesWithGaps[i];
|
|
1029
|
+
}, from);
|
|
1030
|
+
}
|
|
1031
|
+
function slidesInGap(indexes, gap) {
|
|
1032
|
+
return indexes.reduce((a, i) => {
|
|
1033
|
+
const remainingGap = removeSlideSizes(a, gap);
|
|
1034
|
+
return remainingGap > 0 ? a.concat([i]) : a;
|
|
1035
|
+
}, []);
|
|
1036
|
+
}
|
|
1037
|
+
function findSlideBounds(offset) {
|
|
1038
|
+
return snaps.map((snap, index) => ({
|
|
1039
|
+
start: snap - slideSizes[index] + roundingSafety + offset,
|
|
1040
|
+
end: snap + viewSize - roundingSafety + offset
|
|
1041
|
+
}));
|
|
1042
|
+
}
|
|
1043
|
+
function findLoopPoints(indexes, offset, isEndEdge) {
|
|
1044
|
+
const slideBounds = findSlideBounds(offset);
|
|
1045
|
+
return indexes.map(index => {
|
|
1046
|
+
const initial = isEndEdge ? 0 : -contentSize;
|
|
1047
|
+
const altered = isEndEdge ? contentSize : 0;
|
|
1048
|
+
const boundEdge = isEndEdge ? 'end' : 'start';
|
|
1049
|
+
const loopPoint = slideBounds[index][boundEdge];
|
|
1050
|
+
return {
|
|
1051
|
+
index,
|
|
1052
|
+
loopPoint,
|
|
1053
|
+
slideLocation: Vector1D(-1),
|
|
1054
|
+
translate: Translate(axis, slides[index]),
|
|
1055
|
+
target: () => location.get() > loopPoint ? initial : altered
|
|
1056
|
+
};
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
function startPoints() {
|
|
1060
|
+
const gap = scrollSnaps[0];
|
|
1061
|
+
const indexes = slidesInGap(descItems, gap);
|
|
1062
|
+
return findLoopPoints(indexes, contentSize, false);
|
|
1063
|
+
}
|
|
1064
|
+
function endPoints() {
|
|
1065
|
+
const gap = viewSize - scrollSnaps[0] - 1;
|
|
1066
|
+
const indexes = slidesInGap(ascItems, gap);
|
|
1067
|
+
return findLoopPoints(indexes, -contentSize, true);
|
|
1068
|
+
}
|
|
1069
|
+
function canLoop() {
|
|
1070
|
+
return loopPoints.every(({
|
|
1071
|
+
index
|
|
1072
|
+
}) => {
|
|
1073
|
+
const otherIndexes = ascItems.filter(i => i !== index);
|
|
1074
|
+
return removeSlideSizes(otherIndexes, viewSize) <= 0.1;
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
function loop() {
|
|
1078
|
+
loopPoints.forEach(loopPoint => {
|
|
1079
|
+
const {
|
|
1080
|
+
target,
|
|
1081
|
+
translate,
|
|
1082
|
+
slideLocation
|
|
1083
|
+
} = loopPoint;
|
|
1084
|
+
const shiftLocation = target();
|
|
1085
|
+
if (shiftLocation === slideLocation.get()) return;
|
|
1086
|
+
translate.to(shiftLocation);
|
|
1087
|
+
slideLocation.set(shiftLocation);
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
function clear() {
|
|
1091
|
+
loopPoints.forEach(loopPoint => loopPoint.translate.clear());
|
|
1092
|
+
}
|
|
1093
|
+
const self = {
|
|
1094
|
+
canLoop,
|
|
1095
|
+
clear,
|
|
1096
|
+
loop,
|
|
1097
|
+
loopPoints
|
|
1098
|
+
};
|
|
1099
|
+
return self;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
function SlidesHandler(container, eventHandler, watchSlides) {
|
|
1103
|
+
let mutationObserver;
|
|
1104
|
+
let destroyed = false;
|
|
1105
|
+
function init(emblaApi) {
|
|
1106
|
+
if (!watchSlides) return;
|
|
1107
|
+
function defaultCallback(mutations) {
|
|
1108
|
+
for (const mutation of mutations) {
|
|
1109
|
+
if (mutation.type === 'childList') {
|
|
1110
|
+
emblaApi.reInit();
|
|
1111
|
+
eventHandler.emit('slidesChanged');
|
|
1112
|
+
break;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
mutationObserver = new MutationObserver(mutations => {
|
|
1117
|
+
if (destroyed) return;
|
|
1118
|
+
if (isBoolean(watchSlides) || watchSlides(emblaApi, mutations)) {
|
|
1119
|
+
defaultCallback(mutations);
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
mutationObserver.observe(container, {
|
|
1123
|
+
childList: true
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
function destroy() {
|
|
1127
|
+
if (mutationObserver) mutationObserver.disconnect();
|
|
1128
|
+
destroyed = true;
|
|
1129
|
+
}
|
|
1130
|
+
const self = {
|
|
1131
|
+
init,
|
|
1132
|
+
destroy
|
|
1133
|
+
};
|
|
1134
|
+
return self;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function SlidesInView(container, slides, eventHandler, threshold) {
|
|
1138
|
+
const intersectionEntryMap = {};
|
|
1139
|
+
let inViewCache = null;
|
|
1140
|
+
let notInViewCache = null;
|
|
1141
|
+
let intersectionObserver;
|
|
1142
|
+
let destroyed = false;
|
|
1143
|
+
function init() {
|
|
1144
|
+
intersectionObserver = new IntersectionObserver(entries => {
|
|
1145
|
+
if (destroyed) return;
|
|
1146
|
+
entries.forEach(entry => {
|
|
1147
|
+
const index = slides.indexOf(entry.target);
|
|
1148
|
+
intersectionEntryMap[index] = entry;
|
|
1149
|
+
});
|
|
1150
|
+
inViewCache = null;
|
|
1151
|
+
notInViewCache = null;
|
|
1152
|
+
eventHandler.emit('slidesInView');
|
|
1153
|
+
}, {
|
|
1154
|
+
root: container.parentElement,
|
|
1155
|
+
threshold
|
|
1156
|
+
});
|
|
1157
|
+
slides.forEach(slide => intersectionObserver.observe(slide));
|
|
1158
|
+
}
|
|
1159
|
+
function destroy() {
|
|
1160
|
+
if (intersectionObserver) intersectionObserver.disconnect();
|
|
1161
|
+
destroyed = true;
|
|
1162
|
+
}
|
|
1163
|
+
function createInViewList(inView) {
|
|
1164
|
+
return objectKeys(intersectionEntryMap).reduce((list, slideIndex) => {
|
|
1165
|
+
const index = parseInt(slideIndex);
|
|
1166
|
+
const {
|
|
1167
|
+
isIntersecting
|
|
1168
|
+
} = intersectionEntryMap[index];
|
|
1169
|
+
const inViewMatch = inView && isIntersecting;
|
|
1170
|
+
const notInViewMatch = !inView && !isIntersecting;
|
|
1171
|
+
if (inViewMatch || notInViewMatch) list.push(index);
|
|
1172
|
+
return list;
|
|
1173
|
+
}, []);
|
|
1174
|
+
}
|
|
1175
|
+
function get(inView = true) {
|
|
1176
|
+
if (inView && inViewCache) return inViewCache;
|
|
1177
|
+
if (!inView && notInViewCache) return notInViewCache;
|
|
1178
|
+
const slideIndexes = createInViewList(inView);
|
|
1179
|
+
if (inView) inViewCache = slideIndexes;
|
|
1180
|
+
if (!inView) notInViewCache = slideIndexes;
|
|
1181
|
+
return slideIndexes;
|
|
1182
|
+
}
|
|
1183
|
+
const self = {
|
|
1184
|
+
init,
|
|
1185
|
+
destroy,
|
|
1186
|
+
get
|
|
1187
|
+
};
|
|
1188
|
+
return self;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow) {
|
|
1192
|
+
const {
|
|
1193
|
+
measureSize,
|
|
1194
|
+
startEdge,
|
|
1195
|
+
endEdge
|
|
1196
|
+
} = axis;
|
|
1197
|
+
const withEdgeGap = slideRects[0] && readEdgeGap;
|
|
1198
|
+
const startGap = measureStartGap();
|
|
1199
|
+
const endGap = measureEndGap();
|
|
1200
|
+
const slideSizes = slideRects.map(measureSize);
|
|
1201
|
+
const slideSizesWithGaps = measureWithGaps();
|
|
1202
|
+
function measureStartGap() {
|
|
1203
|
+
if (!withEdgeGap) return 0;
|
|
1204
|
+
const slideRect = slideRects[0];
|
|
1205
|
+
return mathAbs(containerRect[startEdge] - slideRect[startEdge]);
|
|
1206
|
+
}
|
|
1207
|
+
function measureEndGap() {
|
|
1208
|
+
if (!withEdgeGap) return 0;
|
|
1209
|
+
const style = ownerWindow.getComputedStyle(arrayLast(slides));
|
|
1210
|
+
return parseFloat(style.getPropertyValue(`margin-${endEdge}`));
|
|
1211
|
+
}
|
|
1212
|
+
function measureWithGaps() {
|
|
1213
|
+
return slideRects.map((rect, index, rects) => {
|
|
1214
|
+
const isFirst = !index;
|
|
1215
|
+
const isLast = arrayIsLastIndex(rects, index);
|
|
1216
|
+
if (isFirst) return slideSizes[index] + startGap;
|
|
1217
|
+
if (isLast) return slideSizes[index] + endGap;
|
|
1218
|
+
return rects[index + 1][startEdge] - rect[startEdge];
|
|
1219
|
+
}).map(mathAbs);
|
|
1220
|
+
}
|
|
1221
|
+
const self = {
|
|
1222
|
+
slideSizes,
|
|
1223
|
+
slideSizesWithGaps,
|
|
1224
|
+
startGap,
|
|
1225
|
+
endGap
|
|
1226
|
+
};
|
|
1227
|
+
return self;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function SlidesToScroll(axis, viewSize, slidesToScroll, loop, containerRect, slideRects, startGap, endGap, pixelTolerance) {
|
|
1231
|
+
const {
|
|
1232
|
+
startEdge,
|
|
1233
|
+
endEdge,
|
|
1234
|
+
direction
|
|
1235
|
+
} = axis;
|
|
1236
|
+
const groupByNumber = isNumber(slidesToScroll);
|
|
1237
|
+
function byNumber(array, groupSize) {
|
|
1238
|
+
return arrayKeys(array).filter(i => i % groupSize === 0).map(i => array.slice(i, i + groupSize));
|
|
1239
|
+
}
|
|
1240
|
+
function bySize(array) {
|
|
1241
|
+
if (!array.length) return [];
|
|
1242
|
+
return arrayKeys(array).reduce((groups, rectB, index) => {
|
|
1243
|
+
const rectA = arrayLast(groups) || 0;
|
|
1244
|
+
const isFirst = rectA === 0;
|
|
1245
|
+
const isLast = rectB === arrayLastIndex(array);
|
|
1246
|
+
const edgeA = containerRect[startEdge] - slideRects[rectA][startEdge];
|
|
1247
|
+
const edgeB = containerRect[startEdge] - slideRects[rectB][endEdge];
|
|
1248
|
+
const gapA = !loop && isFirst ? direction(startGap) : 0;
|
|
1249
|
+
const gapB = !loop && isLast ? direction(endGap) : 0;
|
|
1250
|
+
const chunkSize = mathAbs(edgeB - gapB - (edgeA + gapA));
|
|
1251
|
+
if (index && chunkSize > viewSize + pixelTolerance) groups.push(rectB);
|
|
1252
|
+
if (isLast) groups.push(array.length);
|
|
1253
|
+
return groups;
|
|
1254
|
+
}, []).map((currentSize, index, groups) => {
|
|
1255
|
+
const previousSize = Math.max(groups[index - 1] || 0);
|
|
1256
|
+
return array.slice(previousSize, currentSize);
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
function groupSlides(array) {
|
|
1260
|
+
return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array);
|
|
1261
|
+
}
|
|
1262
|
+
const self = {
|
|
1263
|
+
groupSlides
|
|
1264
|
+
};
|
|
1265
|
+
return self;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
function Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler) {
|
|
1269
|
+
// Options
|
|
1270
|
+
const {
|
|
1271
|
+
align,
|
|
1272
|
+
axis: scrollAxis,
|
|
1273
|
+
direction,
|
|
1274
|
+
startIndex,
|
|
1275
|
+
loop,
|
|
1276
|
+
duration,
|
|
1277
|
+
dragFree,
|
|
1278
|
+
dragThreshold,
|
|
1279
|
+
inViewThreshold,
|
|
1280
|
+
slidesToScroll: groupSlides,
|
|
1281
|
+
skipSnaps,
|
|
1282
|
+
containScroll,
|
|
1283
|
+
watchResize,
|
|
1284
|
+
watchSlides,
|
|
1285
|
+
watchDrag,
|
|
1286
|
+
watchFocus
|
|
1287
|
+
} = options;
|
|
1288
|
+
// Measurements
|
|
1289
|
+
const pixelTolerance = 2;
|
|
1290
|
+
const nodeRects = NodeRects();
|
|
1291
|
+
const containerRect = nodeRects.measure(container);
|
|
1292
|
+
const slideRects = slides.map(nodeRects.measure);
|
|
1293
|
+
const axis = Axis(scrollAxis, direction);
|
|
1294
|
+
const viewSize = axis.measureSize(containerRect);
|
|
1295
|
+
const percentOfView = PercentOfView(viewSize);
|
|
1296
|
+
const alignment = Alignment(align, viewSize);
|
|
1297
|
+
const containSnaps = !loop && !!containScroll;
|
|
1298
|
+
const readEdgeGap = loop || !!containScroll;
|
|
1299
|
+
const {
|
|
1300
|
+
slideSizes,
|
|
1301
|
+
slideSizesWithGaps,
|
|
1302
|
+
startGap,
|
|
1303
|
+
endGap
|
|
1304
|
+
} = SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow);
|
|
1305
|
+
const slidesToScroll = SlidesToScroll(axis, viewSize, groupSlides, loop, containerRect, slideRects, startGap, endGap, pixelTolerance);
|
|
1306
|
+
const {
|
|
1307
|
+
snaps,
|
|
1308
|
+
snapsAligned
|
|
1309
|
+
} = ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll);
|
|
1310
|
+
const contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
|
|
1311
|
+
const {
|
|
1312
|
+
snapsContained,
|
|
1313
|
+
scrollContainLimit
|
|
1314
|
+
} = ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance);
|
|
1315
|
+
const scrollSnaps = containSnaps ? snapsContained : snapsAligned;
|
|
1316
|
+
const {
|
|
1317
|
+
limit
|
|
1318
|
+
} = ScrollLimit(contentSize, scrollSnaps, loop);
|
|
1319
|
+
// Indexes
|
|
1320
|
+
const index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
|
|
1321
|
+
const indexPrevious = index.clone();
|
|
1322
|
+
const slideIndexes = arrayKeys(slides);
|
|
1323
|
+
// Animation
|
|
1324
|
+
const update = ({
|
|
1325
|
+
dragHandler,
|
|
1326
|
+
scrollBody,
|
|
1327
|
+
scrollBounds,
|
|
1328
|
+
options: {
|
|
1329
|
+
loop
|
|
1330
|
+
}
|
|
1331
|
+
}) => {
|
|
1332
|
+
if (!loop) scrollBounds.constrain(dragHandler.pointerDown());
|
|
1333
|
+
scrollBody.seek();
|
|
1334
|
+
};
|
|
1335
|
+
const render = ({
|
|
1336
|
+
scrollBody,
|
|
1337
|
+
translate,
|
|
1338
|
+
location,
|
|
1339
|
+
offsetLocation,
|
|
1340
|
+
previousLocation,
|
|
1341
|
+
scrollLooper,
|
|
1342
|
+
slideLooper,
|
|
1343
|
+
dragHandler,
|
|
1344
|
+
animation,
|
|
1345
|
+
eventHandler,
|
|
1346
|
+
scrollBounds,
|
|
1347
|
+
options: {
|
|
1348
|
+
loop
|
|
1349
|
+
}
|
|
1350
|
+
}, alpha) => {
|
|
1351
|
+
const shouldSettle = scrollBody.settled();
|
|
1352
|
+
const withinBounds = !scrollBounds.shouldConstrain();
|
|
1353
|
+
const hasSettled = loop ? shouldSettle : shouldSettle && withinBounds;
|
|
1354
|
+
const hasSettledAndIdle = hasSettled && !dragHandler.pointerDown();
|
|
1355
|
+
if (hasSettledAndIdle) animation.stop();
|
|
1356
|
+
const interpolatedLocation = location.get() * alpha + previousLocation.get() * (1 - alpha);
|
|
1357
|
+
offsetLocation.set(interpolatedLocation);
|
|
1358
|
+
if (loop) {
|
|
1359
|
+
scrollLooper.loop(scrollBody.direction());
|
|
1360
|
+
slideLooper.loop();
|
|
1361
|
+
}
|
|
1362
|
+
translate.to(offsetLocation.get());
|
|
1363
|
+
if (hasSettledAndIdle) eventHandler.emit('settle');
|
|
1364
|
+
if (!hasSettled) eventHandler.emit('scroll');
|
|
1365
|
+
};
|
|
1366
|
+
const animation = Animations(ownerDocument, ownerWindow, () => update(engine), alpha => render(engine, alpha));
|
|
1367
|
+
// Shared
|
|
1368
|
+
const friction = 0.68;
|
|
1369
|
+
const startLocation = scrollSnaps[index.get()];
|
|
1370
|
+
const location = Vector1D(startLocation);
|
|
1371
|
+
const previousLocation = Vector1D(startLocation);
|
|
1372
|
+
const offsetLocation = Vector1D(startLocation);
|
|
1373
|
+
const target = Vector1D(startLocation);
|
|
1374
|
+
const scrollBody = ScrollBody(location, offsetLocation, previousLocation, target, duration, friction);
|
|
1375
|
+
const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
|
|
1376
|
+
const scrollTo = ScrollTo(animation, index, indexPrevious, scrollBody, scrollTarget, target, eventHandler);
|
|
1377
|
+
const scrollProgress = ScrollProgress(limit);
|
|
1378
|
+
const eventStore = EventStore();
|
|
1379
|
+
const slidesInView = SlidesInView(container, slides, eventHandler, inViewThreshold);
|
|
1380
|
+
const {
|
|
1381
|
+
slideRegistry
|
|
1382
|
+
} = SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes);
|
|
1383
|
+
const slideFocus = SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus);
|
|
1384
|
+
// Engine
|
|
1385
|
+
const engine = {
|
|
1386
|
+
ownerDocument,
|
|
1387
|
+
ownerWindow,
|
|
1388
|
+
eventHandler,
|
|
1389
|
+
containerRect,
|
|
1390
|
+
slideRects,
|
|
1391
|
+
animation,
|
|
1392
|
+
axis,
|
|
1393
|
+
dragHandler: DragHandler(axis, root, ownerDocument, ownerWindow, target, DragTracker(axis, ownerWindow), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction, watchDrag),
|
|
1394
|
+
eventStore,
|
|
1395
|
+
percentOfView,
|
|
1396
|
+
index,
|
|
1397
|
+
indexPrevious,
|
|
1398
|
+
limit,
|
|
1399
|
+
location,
|
|
1400
|
+
offsetLocation,
|
|
1401
|
+
previousLocation,
|
|
1402
|
+
options,
|
|
1403
|
+
resizeHandler: ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects),
|
|
1404
|
+
scrollBody,
|
|
1405
|
+
scrollBounds: ScrollBounds(limit, offsetLocation, target, scrollBody, percentOfView),
|
|
1406
|
+
scrollLooper: ScrollLooper(contentSize, limit, offsetLocation, [location, offsetLocation, previousLocation, target]),
|
|
1407
|
+
scrollProgress,
|
|
1408
|
+
scrollSnapList: scrollSnaps.map(scrollProgress.get),
|
|
1409
|
+
scrollSnaps,
|
|
1410
|
+
scrollTarget,
|
|
1411
|
+
scrollTo,
|
|
1412
|
+
slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, offsetLocation, slides),
|
|
1413
|
+
slideFocus,
|
|
1414
|
+
slidesHandler: SlidesHandler(container, eventHandler, watchSlides),
|
|
1415
|
+
slidesInView,
|
|
1416
|
+
slideIndexes,
|
|
1417
|
+
slideRegistry,
|
|
1418
|
+
slidesToScroll,
|
|
1419
|
+
target,
|
|
1420
|
+
translate: Translate(axis, container)
|
|
1421
|
+
};
|
|
1422
|
+
return engine;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function EventHandler() {
|
|
1426
|
+
let listeners = {};
|
|
1427
|
+
let api;
|
|
1428
|
+
function init(emblaApi) {
|
|
1429
|
+
api = emblaApi;
|
|
1430
|
+
}
|
|
1431
|
+
function getListeners(evt) {
|
|
1432
|
+
return listeners[evt] || [];
|
|
1433
|
+
}
|
|
1434
|
+
function emit(evt) {
|
|
1435
|
+
getListeners(evt).forEach(e => e(api, evt));
|
|
1436
|
+
return self;
|
|
1437
|
+
}
|
|
1438
|
+
function on(evt, cb) {
|
|
1439
|
+
listeners[evt] = getListeners(evt).concat([cb]);
|
|
1440
|
+
return self;
|
|
1441
|
+
}
|
|
1442
|
+
function off(evt, cb) {
|
|
1443
|
+
listeners[evt] = getListeners(evt).filter(e => e !== cb);
|
|
1444
|
+
return self;
|
|
1445
|
+
}
|
|
1446
|
+
function clear() {
|
|
1447
|
+
listeners = {};
|
|
1448
|
+
}
|
|
1449
|
+
const self = {
|
|
1450
|
+
init,
|
|
1451
|
+
emit,
|
|
1452
|
+
off,
|
|
1453
|
+
on,
|
|
1454
|
+
clear
|
|
1455
|
+
};
|
|
1456
|
+
return self;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
const defaultOptions$3 = {
|
|
1460
|
+
align: 'center',
|
|
1461
|
+
axis: 'x',
|
|
1462
|
+
container: null,
|
|
1463
|
+
slides: null,
|
|
1464
|
+
containScroll: 'trimSnaps',
|
|
1465
|
+
direction: 'ltr',
|
|
1466
|
+
slidesToScroll: 1,
|
|
1467
|
+
inViewThreshold: 0,
|
|
1468
|
+
breakpoints: {},
|
|
1469
|
+
dragFree: false,
|
|
1470
|
+
dragThreshold: 10,
|
|
1471
|
+
loop: false,
|
|
1472
|
+
skipSnaps: false,
|
|
1473
|
+
duration: 25,
|
|
1474
|
+
startIndex: 0,
|
|
1475
|
+
active: true,
|
|
1476
|
+
watchDrag: true,
|
|
1477
|
+
watchResize: true,
|
|
1478
|
+
watchSlides: true,
|
|
1479
|
+
watchFocus: true
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
function OptionsHandler(ownerWindow) {
|
|
1483
|
+
function mergeOptions(optionsA, optionsB) {
|
|
1484
|
+
return objectsMergeDeep(optionsA, optionsB || {});
|
|
1485
|
+
}
|
|
1486
|
+
function optionsAtMedia(options) {
|
|
1487
|
+
const optionsAtMedia = options.breakpoints || {};
|
|
1488
|
+
const matchedMediaOptions = objectKeys(optionsAtMedia).filter(media => ownerWindow.matchMedia(media).matches).map(media => optionsAtMedia[media]).reduce((a, mediaOption) => mergeOptions(a, mediaOption), {});
|
|
1489
|
+
return mergeOptions(options, matchedMediaOptions);
|
|
1490
|
+
}
|
|
1491
|
+
function optionsMediaQueries(optionsList) {
|
|
1492
|
+
return optionsList.map(options => objectKeys(options.breakpoints || {})).reduce((acc, mediaQueries) => acc.concat(mediaQueries), []).map(ownerWindow.matchMedia);
|
|
1493
|
+
}
|
|
1494
|
+
const self = {
|
|
1495
|
+
mergeOptions,
|
|
1496
|
+
optionsAtMedia,
|
|
1497
|
+
optionsMediaQueries
|
|
1498
|
+
};
|
|
1499
|
+
return self;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
function PluginsHandler(optionsHandler) {
|
|
1503
|
+
let activePlugins = [];
|
|
1504
|
+
function init(emblaApi, plugins) {
|
|
1505
|
+
activePlugins = plugins.filter(({
|
|
1506
|
+
options
|
|
1507
|
+
}) => optionsHandler.optionsAtMedia(options).active !== false);
|
|
1508
|
+
activePlugins.forEach(plugin => plugin.init(emblaApi, optionsHandler));
|
|
1509
|
+
return plugins.reduce((map, plugin) => Object.assign(map, {
|
|
1510
|
+
[plugin.name]: plugin
|
|
1511
|
+
}), {});
|
|
1512
|
+
}
|
|
1513
|
+
function destroy() {
|
|
1514
|
+
activePlugins = activePlugins.filter(plugin => plugin.destroy());
|
|
1515
|
+
}
|
|
1516
|
+
const self = {
|
|
1517
|
+
init,
|
|
1518
|
+
destroy
|
|
1519
|
+
};
|
|
1520
|
+
return self;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
function EmblaCarousel(root, userOptions, userPlugins) {
|
|
1524
|
+
const ownerDocument = root.ownerDocument;
|
|
1525
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
1526
|
+
const optionsHandler = OptionsHandler(ownerWindow);
|
|
1527
|
+
const pluginsHandler = PluginsHandler(optionsHandler);
|
|
1528
|
+
const mediaHandlers = EventStore();
|
|
1529
|
+
const eventHandler = EventHandler();
|
|
1530
|
+
const {
|
|
1531
|
+
mergeOptions,
|
|
1532
|
+
optionsAtMedia,
|
|
1533
|
+
optionsMediaQueries
|
|
1534
|
+
} = optionsHandler;
|
|
1535
|
+
const {
|
|
1536
|
+
on,
|
|
1537
|
+
off,
|
|
1538
|
+
emit
|
|
1539
|
+
} = eventHandler;
|
|
1540
|
+
const reInit = reActivate;
|
|
1541
|
+
let destroyed = false;
|
|
1542
|
+
let engine;
|
|
1543
|
+
let optionsBase = mergeOptions(defaultOptions$3, EmblaCarousel.globalOptions);
|
|
1544
|
+
let options = mergeOptions(optionsBase);
|
|
1545
|
+
let pluginList = [];
|
|
1546
|
+
let pluginApis;
|
|
1547
|
+
let container;
|
|
1548
|
+
let slides;
|
|
1549
|
+
function storeElements() {
|
|
1550
|
+
const {
|
|
1551
|
+
container: userContainer,
|
|
1552
|
+
slides: userSlides
|
|
1553
|
+
} = options;
|
|
1554
|
+
const customContainer = isString(userContainer) ? root.querySelector(userContainer) : userContainer;
|
|
1555
|
+
container = customContainer || root.children[0];
|
|
1556
|
+
const customSlides = isString(userSlides) ? container.querySelectorAll(userSlides) : userSlides;
|
|
1557
|
+
slides = [].slice.call(customSlides || container.children);
|
|
1558
|
+
}
|
|
1559
|
+
function createEngine(options) {
|
|
1560
|
+
const engine = Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler);
|
|
1561
|
+
if (options.loop && !engine.slideLooper.canLoop()) {
|
|
1562
|
+
const optionsWithoutLoop = Object.assign({}, options, {
|
|
1563
|
+
loop: false
|
|
1564
|
+
});
|
|
1565
|
+
return createEngine(optionsWithoutLoop);
|
|
1566
|
+
}
|
|
1567
|
+
return engine;
|
|
1568
|
+
}
|
|
1569
|
+
function activate(withOptions, withPlugins) {
|
|
1570
|
+
if (destroyed) return;
|
|
1571
|
+
optionsBase = mergeOptions(optionsBase, withOptions);
|
|
1572
|
+
options = optionsAtMedia(optionsBase);
|
|
1573
|
+
pluginList = withPlugins || pluginList;
|
|
1574
|
+
storeElements();
|
|
1575
|
+
engine = createEngine(options);
|
|
1576
|
+
optionsMediaQueries([optionsBase, ...pluginList.map(({
|
|
1577
|
+
options
|
|
1578
|
+
}) => options)]).forEach(query => mediaHandlers.add(query, 'change', reActivate));
|
|
1579
|
+
if (!options.active) return;
|
|
1580
|
+
engine.translate.to(engine.location.get());
|
|
1581
|
+
engine.animation.init();
|
|
1582
|
+
engine.slidesInView.init();
|
|
1583
|
+
engine.slideFocus.init(self);
|
|
1584
|
+
engine.eventHandler.init(self);
|
|
1585
|
+
engine.resizeHandler.init(self);
|
|
1586
|
+
engine.slidesHandler.init(self);
|
|
1587
|
+
if (engine.options.loop) engine.slideLooper.loop();
|
|
1588
|
+
if (container.offsetParent && slides.length) engine.dragHandler.init(self);
|
|
1589
|
+
pluginApis = pluginsHandler.init(self, pluginList);
|
|
1590
|
+
}
|
|
1591
|
+
function reActivate(withOptions, withPlugins) {
|
|
1592
|
+
const startIndex = selectedScrollSnap();
|
|
1593
|
+
deActivate();
|
|
1594
|
+
activate(mergeOptions({
|
|
1595
|
+
startIndex
|
|
1596
|
+
}, withOptions), withPlugins);
|
|
1597
|
+
eventHandler.emit('reInit');
|
|
1598
|
+
}
|
|
1599
|
+
function deActivate() {
|
|
1600
|
+
engine.dragHandler.destroy();
|
|
1601
|
+
engine.eventStore.clear();
|
|
1602
|
+
engine.translate.clear();
|
|
1603
|
+
engine.slideLooper.clear();
|
|
1604
|
+
engine.resizeHandler.destroy();
|
|
1605
|
+
engine.slidesHandler.destroy();
|
|
1606
|
+
engine.slidesInView.destroy();
|
|
1607
|
+
engine.animation.destroy();
|
|
1608
|
+
pluginsHandler.destroy();
|
|
1609
|
+
mediaHandlers.clear();
|
|
1610
|
+
}
|
|
1611
|
+
function destroy() {
|
|
1612
|
+
if (destroyed) return;
|
|
1613
|
+
destroyed = true;
|
|
1614
|
+
mediaHandlers.clear();
|
|
1615
|
+
deActivate();
|
|
1616
|
+
eventHandler.emit('destroy');
|
|
1617
|
+
eventHandler.clear();
|
|
1618
|
+
}
|
|
1619
|
+
function scrollTo(index, jump, direction) {
|
|
1620
|
+
if (!options.active || destroyed) return;
|
|
1621
|
+
engine.scrollBody.useBaseFriction().useDuration(jump === true ? 0 : options.duration);
|
|
1622
|
+
engine.scrollTo.index(index, direction || 0);
|
|
1623
|
+
}
|
|
1624
|
+
function scrollNext(jump) {
|
|
1625
|
+
const next = engine.index.add(1).get();
|
|
1626
|
+
scrollTo(next, jump, -1);
|
|
1627
|
+
}
|
|
1628
|
+
function scrollPrev(jump) {
|
|
1629
|
+
const prev = engine.index.add(-1).get();
|
|
1630
|
+
scrollTo(prev, jump, 1);
|
|
1631
|
+
}
|
|
1632
|
+
function canScrollNext() {
|
|
1633
|
+
const next = engine.index.add(1).get();
|
|
1634
|
+
return next !== selectedScrollSnap();
|
|
1635
|
+
}
|
|
1636
|
+
function canScrollPrev() {
|
|
1637
|
+
const prev = engine.index.add(-1).get();
|
|
1638
|
+
return prev !== selectedScrollSnap();
|
|
1639
|
+
}
|
|
1640
|
+
function scrollSnapList() {
|
|
1641
|
+
return engine.scrollSnapList;
|
|
1642
|
+
}
|
|
1643
|
+
function scrollProgress() {
|
|
1644
|
+
return engine.scrollProgress.get(engine.offsetLocation.get());
|
|
1645
|
+
}
|
|
1646
|
+
function selectedScrollSnap() {
|
|
1647
|
+
return engine.index.get();
|
|
1648
|
+
}
|
|
1649
|
+
function previousScrollSnap() {
|
|
1650
|
+
return engine.indexPrevious.get();
|
|
1651
|
+
}
|
|
1652
|
+
function slidesInView() {
|
|
1653
|
+
return engine.slidesInView.get();
|
|
1654
|
+
}
|
|
1655
|
+
function slidesNotInView() {
|
|
1656
|
+
return engine.slidesInView.get(false);
|
|
1657
|
+
}
|
|
1658
|
+
function plugins() {
|
|
1659
|
+
return pluginApis;
|
|
1660
|
+
}
|
|
1661
|
+
function internalEngine() {
|
|
1662
|
+
return engine;
|
|
1663
|
+
}
|
|
1664
|
+
function rootNode() {
|
|
1665
|
+
return root;
|
|
1666
|
+
}
|
|
1667
|
+
function containerNode() {
|
|
1668
|
+
return container;
|
|
1669
|
+
}
|
|
1670
|
+
function slideNodes() {
|
|
1671
|
+
return slides;
|
|
1672
|
+
}
|
|
1673
|
+
const self = {
|
|
1674
|
+
canScrollNext,
|
|
1675
|
+
canScrollPrev,
|
|
1676
|
+
containerNode,
|
|
1677
|
+
internalEngine,
|
|
1678
|
+
destroy,
|
|
1679
|
+
off,
|
|
1680
|
+
on,
|
|
1681
|
+
emit,
|
|
1682
|
+
plugins,
|
|
1683
|
+
previousScrollSnap,
|
|
1684
|
+
reInit,
|
|
1685
|
+
rootNode,
|
|
1686
|
+
scrollNext,
|
|
1687
|
+
scrollPrev,
|
|
1688
|
+
scrollProgress,
|
|
1689
|
+
scrollSnapList,
|
|
1690
|
+
scrollTo,
|
|
1691
|
+
selectedScrollSnap,
|
|
1692
|
+
slideNodes,
|
|
1693
|
+
slidesInView,
|
|
1694
|
+
slidesNotInView
|
|
1695
|
+
};
|
|
1696
|
+
activate(userOptions, userPlugins);
|
|
1697
|
+
setTimeout(() => eventHandler.emit('init'), 0);
|
|
1698
|
+
return self;
|
|
1699
|
+
}
|
|
1700
|
+
EmblaCarousel.globalOptions = undefined;
|
|
1701
|
+
|
|
1702
|
+
const defaultOptions$2 = {
|
|
1703
|
+
direction: 'forward',
|
|
1704
|
+
speed: 2,
|
|
1705
|
+
startDelay: 1000,
|
|
1706
|
+
active: true,
|
|
1707
|
+
breakpoints: {},
|
|
1708
|
+
playOnInit: true,
|
|
1709
|
+
stopOnFocusIn: true,
|
|
1710
|
+
stopOnInteraction: true,
|
|
1711
|
+
stopOnMouseEnter: false,
|
|
1712
|
+
rootNode: null
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
function getAutoScrollRootNode(emblaApi, rootNode) {
|
|
1716
|
+
const emblaRootNode = emblaApi.rootNode();
|
|
1717
|
+
return rootNode && rootNode(emblaRootNode) || emblaRootNode;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function AutoScroll(userOptions = {}) {
|
|
1721
|
+
let options;
|
|
1722
|
+
let emblaApi;
|
|
1723
|
+
let destroyed;
|
|
1724
|
+
let startDelay;
|
|
1725
|
+
let timerId = 0;
|
|
1726
|
+
let autoScrollActive = false;
|
|
1727
|
+
let mouseIsOver = false;
|
|
1728
|
+
let defaultScrollBehaviour;
|
|
1729
|
+
function init(emblaApiInstance, optionsHandler) {
|
|
1730
|
+
emblaApi = emblaApiInstance;
|
|
1731
|
+
const {
|
|
1732
|
+
mergeOptions,
|
|
1733
|
+
optionsAtMedia
|
|
1734
|
+
} = optionsHandler;
|
|
1735
|
+
const optionsBase = mergeOptions(defaultOptions$2, AutoScroll.globalOptions);
|
|
1736
|
+
const allOptions = mergeOptions(optionsBase, userOptions);
|
|
1737
|
+
options = optionsAtMedia(allOptions);
|
|
1738
|
+
if (emblaApi.scrollSnapList().length <= 1) return;
|
|
1739
|
+
startDelay = options.startDelay;
|
|
1740
|
+
destroyed = false;
|
|
1741
|
+
defaultScrollBehaviour = emblaApi.internalEngine().scrollBody;
|
|
1742
|
+
const {
|
|
1743
|
+
eventStore
|
|
1744
|
+
} = emblaApi.internalEngine();
|
|
1745
|
+
const isDraggable = !!emblaApi.internalEngine().options.watchDrag;
|
|
1746
|
+
const root = getAutoScrollRootNode(emblaApi, options.rootNode);
|
|
1747
|
+
if (isDraggable) {
|
|
1748
|
+
emblaApi.on('pointerDown', pointerDown);
|
|
1749
|
+
}
|
|
1750
|
+
if (isDraggable && !options.stopOnInteraction) {
|
|
1751
|
+
emblaApi.on('pointerUp', pointerUp);
|
|
1752
|
+
}
|
|
1753
|
+
if (options.stopOnMouseEnter) {
|
|
1754
|
+
eventStore.add(root, 'mouseenter', mouseEnter);
|
|
1755
|
+
}
|
|
1756
|
+
if (options.stopOnMouseEnter && !options.stopOnInteraction) {
|
|
1757
|
+
eventStore.add(root, 'mouseleave', mouseLeave);
|
|
1758
|
+
}
|
|
1759
|
+
if (options.stopOnFocusIn) {
|
|
1760
|
+
emblaApi.on('slideFocusStart', stopAutoScroll);
|
|
1761
|
+
}
|
|
1762
|
+
if (options.stopOnFocusIn && !options.stopOnInteraction) {
|
|
1763
|
+
eventStore.add(emblaApi.containerNode(), 'focusout', startAutoScroll);
|
|
1764
|
+
}
|
|
1765
|
+
if (options.playOnInit) startAutoScroll();
|
|
1766
|
+
}
|
|
1767
|
+
function destroy() {
|
|
1768
|
+
emblaApi.off('pointerDown', pointerDown).off('pointerUp', pointerUp).off('slideFocusStart', stopAutoScroll).off('settle', settle);
|
|
1769
|
+
stopAutoScroll();
|
|
1770
|
+
destroyed = true;
|
|
1771
|
+
autoScrollActive = false;
|
|
1772
|
+
}
|
|
1773
|
+
function startAutoScroll() {
|
|
1774
|
+
if (destroyed) return;
|
|
1775
|
+
if (autoScrollActive) return;
|
|
1776
|
+
emblaApi.emit('autoScroll:play');
|
|
1777
|
+
const engine = emblaApi.internalEngine();
|
|
1778
|
+
const {
|
|
1779
|
+
ownerWindow
|
|
1780
|
+
} = engine;
|
|
1781
|
+
timerId = ownerWindow.setTimeout(() => {
|
|
1782
|
+
engine.scrollBody = createAutoScrollBehaviour(engine);
|
|
1783
|
+
engine.animation.start();
|
|
1784
|
+
}, startDelay);
|
|
1785
|
+
autoScrollActive = true;
|
|
1786
|
+
}
|
|
1787
|
+
function stopAutoScroll() {
|
|
1788
|
+
if (destroyed) return;
|
|
1789
|
+
if (!autoScrollActive) return;
|
|
1790
|
+
emblaApi.emit('autoScroll:stop');
|
|
1791
|
+
const engine = emblaApi.internalEngine();
|
|
1792
|
+
const {
|
|
1793
|
+
ownerWindow
|
|
1794
|
+
} = engine;
|
|
1795
|
+
engine.scrollBody = defaultScrollBehaviour;
|
|
1796
|
+
ownerWindow.clearTimeout(timerId);
|
|
1797
|
+
timerId = 0;
|
|
1798
|
+
autoScrollActive = false;
|
|
1799
|
+
}
|
|
1800
|
+
function createAutoScrollBehaviour(engine) {
|
|
1801
|
+
const {
|
|
1802
|
+
location,
|
|
1803
|
+
previousLocation,
|
|
1804
|
+
offsetLocation,
|
|
1805
|
+
target,
|
|
1806
|
+
scrollTarget,
|
|
1807
|
+
index,
|
|
1808
|
+
indexPrevious,
|
|
1809
|
+
limit: {
|
|
1810
|
+
reachedMin,
|
|
1811
|
+
reachedMax,
|
|
1812
|
+
constrain
|
|
1813
|
+
},
|
|
1814
|
+
options: {
|
|
1815
|
+
loop
|
|
1816
|
+
}
|
|
1817
|
+
} = engine;
|
|
1818
|
+
const directionSign = options.direction === 'forward' ? -1 : 1;
|
|
1819
|
+
const noop = () => self;
|
|
1820
|
+
let bodyVelocity = 0;
|
|
1821
|
+
let scrollDirection = 0;
|
|
1822
|
+
let rawLocation = location.get();
|
|
1823
|
+
let rawLocationPrevious = 0;
|
|
1824
|
+
let hasSettled = false;
|
|
1825
|
+
function seek() {
|
|
1826
|
+
let directionDiff = 0;
|
|
1827
|
+
previousLocation.set(location);
|
|
1828
|
+
bodyVelocity = directionSign * options.speed;
|
|
1829
|
+
rawLocation += bodyVelocity;
|
|
1830
|
+
location.add(bodyVelocity);
|
|
1831
|
+
target.set(location);
|
|
1832
|
+
directionDiff = rawLocation - rawLocationPrevious;
|
|
1833
|
+
scrollDirection = Math.sign(directionDiff);
|
|
1834
|
+
rawLocationPrevious = rawLocation;
|
|
1835
|
+
const currentIndex = scrollTarget.byDistance(0, false).index;
|
|
1836
|
+
if (index.get() !== currentIndex) {
|
|
1837
|
+
indexPrevious.set(index.get());
|
|
1838
|
+
index.set(currentIndex);
|
|
1839
|
+
emblaApi.emit('select');
|
|
1840
|
+
}
|
|
1841
|
+
const reachedEnd = options.direction === 'forward' ? reachedMin(offsetLocation.get()) : reachedMax(offsetLocation.get());
|
|
1842
|
+
if (!loop && reachedEnd) {
|
|
1843
|
+
hasSettled = true;
|
|
1844
|
+
const constrainedLocation = constrain(location.get());
|
|
1845
|
+
location.set(constrainedLocation);
|
|
1846
|
+
target.set(location);
|
|
1847
|
+
stopAutoScroll();
|
|
1848
|
+
}
|
|
1849
|
+
return self;
|
|
1850
|
+
}
|
|
1851
|
+
const self = {
|
|
1852
|
+
direction: () => scrollDirection,
|
|
1853
|
+
duration: () => -1,
|
|
1854
|
+
velocity: () => bodyVelocity,
|
|
1855
|
+
settled: () => hasSettled,
|
|
1856
|
+
seek,
|
|
1857
|
+
useBaseFriction: noop,
|
|
1858
|
+
useBaseDuration: noop,
|
|
1859
|
+
useFriction: noop,
|
|
1860
|
+
useDuration: noop
|
|
1861
|
+
};
|
|
1862
|
+
return self;
|
|
1863
|
+
}
|
|
1864
|
+
function pointerDown() {
|
|
1865
|
+
if (!mouseIsOver) stopAutoScroll();
|
|
1866
|
+
}
|
|
1867
|
+
function pointerUp() {
|
|
1868
|
+
if (!mouseIsOver) startAutoScrollOnSettle();
|
|
1869
|
+
}
|
|
1870
|
+
function mouseEnter() {
|
|
1871
|
+
mouseIsOver = true;
|
|
1872
|
+
stopAutoScroll();
|
|
1873
|
+
}
|
|
1874
|
+
function mouseLeave() {
|
|
1875
|
+
mouseIsOver = false;
|
|
1876
|
+
startAutoScroll();
|
|
1877
|
+
}
|
|
1878
|
+
function settle() {
|
|
1879
|
+
emblaApi.off('settle', settle);
|
|
1880
|
+
startAutoScroll();
|
|
1881
|
+
}
|
|
1882
|
+
function startAutoScrollOnSettle() {
|
|
1883
|
+
emblaApi.on('settle', settle);
|
|
1884
|
+
}
|
|
1885
|
+
function play(startDelayOverride) {
|
|
1886
|
+
if (typeof startDelayOverride !== 'undefined') {
|
|
1887
|
+
startDelay = startDelayOverride;
|
|
1888
|
+
}
|
|
1889
|
+
startAutoScroll();
|
|
1890
|
+
}
|
|
1891
|
+
function stop() {
|
|
1892
|
+
if (autoScrollActive) stopAutoScroll();
|
|
1893
|
+
}
|
|
1894
|
+
function reset() {
|
|
1895
|
+
if (autoScrollActive) {
|
|
1896
|
+
stopAutoScroll();
|
|
1897
|
+
startAutoScrollOnSettle();
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function isPlaying() {
|
|
1901
|
+
return autoScrollActive;
|
|
1902
|
+
}
|
|
1903
|
+
const self = {
|
|
1904
|
+
name: 'autoScroll',
|
|
1905
|
+
options: userOptions,
|
|
1906
|
+
init,
|
|
1907
|
+
destroy,
|
|
1908
|
+
play,
|
|
1909
|
+
stop,
|
|
1910
|
+
reset,
|
|
1911
|
+
isPlaying
|
|
1912
|
+
};
|
|
1913
|
+
return self;
|
|
1914
|
+
}
|
|
1915
|
+
AutoScroll.globalOptions = undefined;
|
|
1916
|
+
|
|
1917
|
+
const defaultOptions$1 = {
|
|
1918
|
+
active: true,
|
|
1919
|
+
breakpoints: {},
|
|
1920
|
+
delay: 4000,
|
|
1921
|
+
jump: false,
|
|
1922
|
+
playOnInit: true,
|
|
1923
|
+
stopOnFocusIn: true,
|
|
1924
|
+
stopOnInteraction: true,
|
|
1925
|
+
stopOnMouseEnter: false,
|
|
1926
|
+
stopOnLastSnap: false,
|
|
1927
|
+
rootNode: null
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
function normalizeDelay(emblaApi, delay) {
|
|
1931
|
+
const scrollSnaps = emblaApi.scrollSnapList();
|
|
1932
|
+
if (typeof delay === 'number') {
|
|
1933
|
+
return scrollSnaps.map(() => delay);
|
|
1934
|
+
}
|
|
1935
|
+
return delay(scrollSnaps, emblaApi);
|
|
1936
|
+
}
|
|
1937
|
+
function getAutoplayRootNode(emblaApi, rootNode) {
|
|
1938
|
+
const emblaRootNode = emblaApi.rootNode();
|
|
1939
|
+
return rootNode && rootNode(emblaRootNode) || emblaRootNode;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
function Autoplay(userOptions = {}) {
|
|
1943
|
+
let options;
|
|
1944
|
+
let emblaApi;
|
|
1945
|
+
let destroyed;
|
|
1946
|
+
let delay;
|
|
1947
|
+
let timerStartTime = null;
|
|
1948
|
+
let timerId = 0;
|
|
1949
|
+
let autoplayActive = false;
|
|
1950
|
+
let mouseIsOver = false;
|
|
1951
|
+
let playOnDocumentVisible = false;
|
|
1952
|
+
let jump = false;
|
|
1953
|
+
function init(emblaApiInstance, optionsHandler) {
|
|
1954
|
+
emblaApi = emblaApiInstance;
|
|
1955
|
+
const {
|
|
1956
|
+
mergeOptions,
|
|
1957
|
+
optionsAtMedia
|
|
1958
|
+
} = optionsHandler;
|
|
1959
|
+
const optionsBase = mergeOptions(defaultOptions$1, Autoplay.globalOptions);
|
|
1960
|
+
const allOptions = mergeOptions(optionsBase, userOptions);
|
|
1961
|
+
options = optionsAtMedia(allOptions);
|
|
1962
|
+
if (emblaApi.scrollSnapList().length <= 1) return;
|
|
1963
|
+
jump = options.jump;
|
|
1964
|
+
destroyed = false;
|
|
1965
|
+
delay = normalizeDelay(emblaApi, options.delay);
|
|
1966
|
+
const {
|
|
1967
|
+
eventStore,
|
|
1968
|
+
ownerDocument
|
|
1969
|
+
} = emblaApi.internalEngine();
|
|
1970
|
+
const isDraggable = !!emblaApi.internalEngine().options.watchDrag;
|
|
1971
|
+
const root = getAutoplayRootNode(emblaApi, options.rootNode);
|
|
1972
|
+
eventStore.add(ownerDocument, 'visibilitychange', visibilityChange);
|
|
1973
|
+
if (isDraggable) {
|
|
1974
|
+
emblaApi.on('pointerDown', pointerDown);
|
|
1975
|
+
}
|
|
1976
|
+
if (isDraggable && !options.stopOnInteraction) {
|
|
1977
|
+
emblaApi.on('pointerUp', pointerUp);
|
|
1978
|
+
}
|
|
1979
|
+
if (options.stopOnMouseEnter) {
|
|
1980
|
+
eventStore.add(root, 'mouseenter', mouseEnter);
|
|
1981
|
+
}
|
|
1982
|
+
if (options.stopOnMouseEnter && !options.stopOnInteraction) {
|
|
1983
|
+
eventStore.add(root, 'mouseleave', mouseLeave);
|
|
1984
|
+
}
|
|
1985
|
+
if (options.stopOnFocusIn) {
|
|
1986
|
+
emblaApi.on('slideFocusStart', stopAutoplay);
|
|
1987
|
+
}
|
|
1988
|
+
if (options.stopOnFocusIn && !options.stopOnInteraction) {
|
|
1989
|
+
eventStore.add(emblaApi.containerNode(), 'focusout', startAutoplay);
|
|
1990
|
+
}
|
|
1991
|
+
if (options.playOnInit) startAutoplay();
|
|
1992
|
+
}
|
|
1993
|
+
function destroy() {
|
|
1994
|
+
emblaApi.off('pointerDown', pointerDown).off('pointerUp', pointerUp).off('slideFocusStart', stopAutoplay);
|
|
1995
|
+
stopAutoplay();
|
|
1996
|
+
destroyed = true;
|
|
1997
|
+
autoplayActive = false;
|
|
1998
|
+
}
|
|
1999
|
+
function setTimer() {
|
|
2000
|
+
const {
|
|
2001
|
+
ownerWindow
|
|
2002
|
+
} = emblaApi.internalEngine();
|
|
2003
|
+
ownerWindow.clearTimeout(timerId);
|
|
2004
|
+
timerId = ownerWindow.setTimeout(next, delay[emblaApi.selectedScrollSnap()]);
|
|
2005
|
+
timerStartTime = new Date().getTime();
|
|
2006
|
+
emblaApi.emit('autoplay:timerset');
|
|
2007
|
+
}
|
|
2008
|
+
function clearTimer() {
|
|
2009
|
+
const {
|
|
2010
|
+
ownerWindow
|
|
2011
|
+
} = emblaApi.internalEngine();
|
|
2012
|
+
ownerWindow.clearTimeout(timerId);
|
|
2013
|
+
timerId = 0;
|
|
2014
|
+
timerStartTime = null;
|
|
2015
|
+
emblaApi.emit('autoplay:timerstopped');
|
|
2016
|
+
}
|
|
2017
|
+
function startAutoplay() {
|
|
2018
|
+
if (destroyed) return;
|
|
2019
|
+
if (documentIsHidden()) {
|
|
2020
|
+
playOnDocumentVisible = true;
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
if (!autoplayActive) emblaApi.emit('autoplay:play');
|
|
2024
|
+
setTimer();
|
|
2025
|
+
autoplayActive = true;
|
|
2026
|
+
}
|
|
2027
|
+
function stopAutoplay() {
|
|
2028
|
+
if (destroyed) return;
|
|
2029
|
+
if (autoplayActive) emblaApi.emit('autoplay:stop');
|
|
2030
|
+
clearTimer();
|
|
2031
|
+
autoplayActive = false;
|
|
2032
|
+
}
|
|
2033
|
+
function visibilityChange() {
|
|
2034
|
+
if (documentIsHidden()) {
|
|
2035
|
+
playOnDocumentVisible = autoplayActive;
|
|
2036
|
+
return stopAutoplay();
|
|
2037
|
+
}
|
|
2038
|
+
if (playOnDocumentVisible) startAutoplay();
|
|
2039
|
+
}
|
|
2040
|
+
function documentIsHidden() {
|
|
2041
|
+
const {
|
|
2042
|
+
ownerDocument
|
|
2043
|
+
} = emblaApi.internalEngine();
|
|
2044
|
+
return ownerDocument.visibilityState === 'hidden';
|
|
2045
|
+
}
|
|
2046
|
+
function pointerDown() {
|
|
2047
|
+
if (!mouseIsOver) stopAutoplay();
|
|
2048
|
+
}
|
|
2049
|
+
function pointerUp() {
|
|
2050
|
+
if (!mouseIsOver) startAutoplay();
|
|
2051
|
+
}
|
|
2052
|
+
function mouseEnter() {
|
|
2053
|
+
mouseIsOver = true;
|
|
2054
|
+
stopAutoplay();
|
|
2055
|
+
}
|
|
2056
|
+
function mouseLeave() {
|
|
2057
|
+
mouseIsOver = false;
|
|
2058
|
+
startAutoplay();
|
|
2059
|
+
}
|
|
2060
|
+
function play(jumpOverride) {
|
|
2061
|
+
if (typeof jumpOverride !== 'undefined') jump = jumpOverride;
|
|
2062
|
+
startAutoplay();
|
|
2063
|
+
}
|
|
2064
|
+
function stop() {
|
|
2065
|
+
if (autoplayActive) stopAutoplay();
|
|
2066
|
+
}
|
|
2067
|
+
function reset() {
|
|
2068
|
+
if (autoplayActive) startAutoplay();
|
|
2069
|
+
}
|
|
2070
|
+
function isPlaying() {
|
|
2071
|
+
return autoplayActive;
|
|
2072
|
+
}
|
|
2073
|
+
function next() {
|
|
2074
|
+
const {
|
|
2075
|
+
index
|
|
2076
|
+
} = emblaApi.internalEngine();
|
|
2077
|
+
const nextIndex = index.clone().add(1).get();
|
|
2078
|
+
const lastIndex = emblaApi.scrollSnapList().length - 1;
|
|
2079
|
+
const kill = options.stopOnLastSnap && nextIndex === lastIndex;
|
|
2080
|
+
if (emblaApi.canScrollNext()) {
|
|
2081
|
+
emblaApi.scrollNext(jump);
|
|
2082
|
+
} else {
|
|
2083
|
+
emblaApi.scrollTo(0, jump);
|
|
2084
|
+
}
|
|
2085
|
+
emblaApi.emit('autoplay:select');
|
|
2086
|
+
if (kill) return stopAutoplay();
|
|
2087
|
+
startAutoplay();
|
|
2088
|
+
}
|
|
2089
|
+
function timeUntilNext() {
|
|
2090
|
+
if (!timerStartTime) return null;
|
|
2091
|
+
const currentDelay = delay[emblaApi.selectedScrollSnap()];
|
|
2092
|
+
const timePastSinceStart = new Date().getTime() - timerStartTime;
|
|
2093
|
+
return currentDelay - timePastSinceStart;
|
|
2094
|
+
}
|
|
2095
|
+
const self = {
|
|
2096
|
+
name: 'autoplay',
|
|
2097
|
+
options: userOptions,
|
|
2098
|
+
init,
|
|
2099
|
+
destroy,
|
|
2100
|
+
play,
|
|
2101
|
+
stop,
|
|
2102
|
+
reset,
|
|
2103
|
+
isPlaying,
|
|
2104
|
+
timeUntilNext
|
|
2105
|
+
};
|
|
2106
|
+
return self;
|
|
2107
|
+
}
|
|
2108
|
+
Autoplay.globalOptions = undefined;
|
|
2109
|
+
|
|
2110
|
+
const defaultOptions = {
|
|
2111
|
+
active: true,
|
|
2112
|
+
breakpoints: {},
|
|
2113
|
+
snapped: 'is-snapped',
|
|
2114
|
+
inView: 'is-in-view',
|
|
2115
|
+
draggable: 'is-draggable',
|
|
2116
|
+
dragging: 'is-dragging',
|
|
2117
|
+
loop: 'is-loop'
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
function normalizeClassNames(classNames) {
|
|
2121
|
+
const normalized = Array.isArray(classNames) ? classNames : [classNames];
|
|
2122
|
+
return normalized.filter(Boolean);
|
|
2123
|
+
}
|
|
2124
|
+
function removeClass(node, classNames) {
|
|
2125
|
+
if (!node || !classNames.length) return;
|
|
2126
|
+
node.classList.remove(...classNames);
|
|
2127
|
+
}
|
|
2128
|
+
function addClass(node, classNames) {
|
|
2129
|
+
if (!node || !classNames.length) return;
|
|
2130
|
+
node.classList.add(...classNames);
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
function ClassNames(userOptions = {}) {
|
|
2134
|
+
let options;
|
|
2135
|
+
let emblaApi;
|
|
2136
|
+
let root;
|
|
2137
|
+
let slides;
|
|
2138
|
+
let snappedIndexes = [];
|
|
2139
|
+
let inViewIndexes = [];
|
|
2140
|
+
const selectedEvents = ['select'];
|
|
2141
|
+
const draggingEvents = ['pointerDown', 'pointerUp'];
|
|
2142
|
+
const inViewEvents = ['slidesInView'];
|
|
2143
|
+
const classNames = {
|
|
2144
|
+
snapped: [],
|
|
2145
|
+
inView: [],
|
|
2146
|
+
draggable: [],
|
|
2147
|
+
dragging: [],
|
|
2148
|
+
loop: []
|
|
2149
|
+
};
|
|
2150
|
+
function init(emblaApiInstance, optionsHandler) {
|
|
2151
|
+
emblaApi = emblaApiInstance;
|
|
2152
|
+
const {
|
|
2153
|
+
mergeOptions,
|
|
2154
|
+
optionsAtMedia
|
|
2155
|
+
} = optionsHandler;
|
|
2156
|
+
const optionsBase = mergeOptions(defaultOptions, ClassNames.globalOptions);
|
|
2157
|
+
const allOptions = mergeOptions(optionsBase, userOptions);
|
|
2158
|
+
options = optionsAtMedia(allOptions);
|
|
2159
|
+
root = emblaApi.rootNode();
|
|
2160
|
+
slides = emblaApi.slideNodes();
|
|
2161
|
+
const {
|
|
2162
|
+
watchDrag,
|
|
2163
|
+
loop
|
|
2164
|
+
} = emblaApi.internalEngine().options;
|
|
2165
|
+
const isDraggable = !!watchDrag;
|
|
2166
|
+
if (options.loop && loop) {
|
|
2167
|
+
classNames.loop = normalizeClassNames(options.loop);
|
|
2168
|
+
addClass(root, classNames.loop);
|
|
2169
|
+
}
|
|
2170
|
+
if (options.draggable && isDraggable) {
|
|
2171
|
+
classNames.draggable = normalizeClassNames(options.draggable);
|
|
2172
|
+
addClass(root, classNames.draggable);
|
|
2173
|
+
}
|
|
2174
|
+
if (options.dragging) {
|
|
2175
|
+
classNames.dragging = normalizeClassNames(options.dragging);
|
|
2176
|
+
draggingEvents.forEach(evt => emblaApi.on(evt, toggleDraggingClass));
|
|
2177
|
+
}
|
|
2178
|
+
if (options.snapped) {
|
|
2179
|
+
classNames.snapped = normalizeClassNames(options.snapped);
|
|
2180
|
+
selectedEvents.forEach(evt => emblaApi.on(evt, toggleSnappedClasses));
|
|
2181
|
+
toggleSnappedClasses();
|
|
2182
|
+
}
|
|
2183
|
+
if (options.inView) {
|
|
2184
|
+
classNames.inView = normalizeClassNames(options.inView);
|
|
2185
|
+
inViewEvents.forEach(evt => emblaApi.on(evt, toggleInViewClasses));
|
|
2186
|
+
toggleInViewClasses();
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function destroy() {
|
|
2190
|
+
draggingEvents.forEach(evt => emblaApi.off(evt, toggleDraggingClass));
|
|
2191
|
+
selectedEvents.forEach(evt => emblaApi.off(evt, toggleSnappedClasses));
|
|
2192
|
+
inViewEvents.forEach(evt => emblaApi.off(evt, toggleInViewClasses));
|
|
2193
|
+
removeClass(root, classNames.loop);
|
|
2194
|
+
removeClass(root, classNames.draggable);
|
|
2195
|
+
removeClass(root, classNames.dragging);
|
|
2196
|
+
toggleSlideClasses([], snappedIndexes, classNames.snapped);
|
|
2197
|
+
toggleSlideClasses([], inViewIndexes, classNames.inView);
|
|
2198
|
+
Object.keys(classNames).forEach(classNameKey => {
|
|
2199
|
+
const key = classNameKey;
|
|
2200
|
+
classNames[key] = [];
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
function toggleDraggingClass(_, evt) {
|
|
2204
|
+
const toggleClass = evt === 'pointerDown' ? addClass : removeClass;
|
|
2205
|
+
toggleClass(root, classNames.dragging);
|
|
2206
|
+
}
|
|
2207
|
+
function toggleSlideClasses(addClassIndexes = [], removeClassIndexes = [], classNames) {
|
|
2208
|
+
const removeClassSlides = removeClassIndexes.map(index => slides[index]);
|
|
2209
|
+
const addClassSlides = addClassIndexes.map(index => slides[index]);
|
|
2210
|
+
removeClassSlides.forEach(slide => removeClass(slide, classNames));
|
|
2211
|
+
addClassSlides.forEach(slide => addClass(slide, classNames));
|
|
2212
|
+
return addClassIndexes;
|
|
2213
|
+
}
|
|
2214
|
+
function toggleSnappedClasses() {
|
|
2215
|
+
const {
|
|
2216
|
+
slideRegistry
|
|
2217
|
+
} = emblaApi.internalEngine();
|
|
2218
|
+
const newSnappedIndexes = slideRegistry[emblaApi.selectedScrollSnap()];
|
|
2219
|
+
snappedIndexes = toggleSlideClasses(newSnappedIndexes, snappedIndexes, classNames.snapped);
|
|
2220
|
+
}
|
|
2221
|
+
function toggleInViewClasses() {
|
|
2222
|
+
const newInViewIndexes = emblaApi.slidesInView();
|
|
2223
|
+
inViewIndexes = toggleSlideClasses(newInViewIndexes, inViewIndexes, classNames.inView);
|
|
2224
|
+
}
|
|
2225
|
+
const self = {
|
|
2226
|
+
name: 'classNames',
|
|
2227
|
+
options: userOptions,
|
|
2228
|
+
init,
|
|
2229
|
+
destroy
|
|
2230
|
+
};
|
|
2231
|
+
return self;
|
|
2232
|
+
}
|
|
2233
|
+
ClassNames.globalOptions = undefined;
|
|
2234
|
+
|
|
2235
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2236
|
+
// See LICENSE in the project root for license information.
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
let AuroDependencyVersioning$1 = class AuroDependencyVersioning {
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2243
|
+
* @private
|
|
2244
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2245
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2246
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2247
|
+
*/
|
|
2248
|
+
generateElementName(baseName, version) {
|
|
2249
|
+
let result = baseName;
|
|
2250
|
+
|
|
2251
|
+
result += '-';
|
|
2252
|
+
result += version.replace(/[.]/g, '_');
|
|
2253
|
+
|
|
2254
|
+
return result;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2259
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2260
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2261
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2262
|
+
*/
|
|
2263
|
+
generateTag(baseName, version, tagClass) {
|
|
2264
|
+
const elementName = this.generateElementName(baseName, version);
|
|
2265
|
+
const tag = i$1`${s(elementName)}`;
|
|
2266
|
+
|
|
2267
|
+
if (!customElements.get(elementName)) {
|
|
2268
|
+
customElements.define(elementName, class extends tagClass {});
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
return tag;
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2276
|
+
// See LICENSE in the project root for license information.
|
|
2277
|
+
|
|
2278
|
+
// ---------------------------------------------------------------------
|
|
2279
|
+
|
|
2280
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
2281
|
+
|
|
2282
|
+
let AuroLibraryRuntimeUtils$1 = class AuroLibraryRuntimeUtils {
|
|
2283
|
+
|
|
2284
|
+
/* eslint-disable jsdoc/require-param */
|
|
2285
|
+
|
|
2286
|
+
/**
|
|
2287
|
+
* This will register a new custom element with the browser.
|
|
2288
|
+
* @param {String} name - The name of the custom element.
|
|
2289
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
2290
|
+
* @returns {void}
|
|
2291
|
+
*/
|
|
2292
|
+
registerComponent(name, componentClass) {
|
|
2293
|
+
if (!customElements.get(name)) {
|
|
2294
|
+
customElements.define(name, class extends componentClass {});
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
/**
|
|
2299
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
2300
|
+
* @returns {void}
|
|
2301
|
+
*/
|
|
2302
|
+
closestElement(
|
|
2303
|
+
selector, // selector like in .closest()
|
|
2304
|
+
base = this, // extra functionality to skip a parent
|
|
2305
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
2306
|
+
!el || el === document || el === window
|
|
2307
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
2308
|
+
: found
|
|
2309
|
+
? found // found a selector INside this element
|
|
2310
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
2311
|
+
) {
|
|
2312
|
+
return __Closest(base);
|
|
2313
|
+
}
|
|
2314
|
+
/* eslint-enable jsdoc/require-param */
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* 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.
|
|
2318
|
+
* @param {Object} elem - The element to check.
|
|
2319
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
2320
|
+
* @returns {void}
|
|
2321
|
+
*/
|
|
2322
|
+
handleComponentTagRename(elem, tagName) {
|
|
2323
|
+
const tag = tagName.toLowerCase();
|
|
2324
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
2325
|
+
|
|
2326
|
+
if (elemTag !== tag) {
|
|
2327
|
+
elem.setAttribute(tag, true);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
/**
|
|
2332
|
+
* Validates if an element is a specific Auro component.
|
|
2333
|
+
* @param {Object} elem - The element to validate.
|
|
2334
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
2335
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
2336
|
+
*/
|
|
2337
|
+
elementMatch(elem, tagName) {
|
|
2338
|
+
const tag = tagName.toLowerCase();
|
|
2339
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
2340
|
+
|
|
2341
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* Private module-level WeakMap to hold MutationObservers for each host element.
|
|
2347
|
+
*/
|
|
2348
|
+
const _observers = new WeakMap();
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Private module-level WeakMap to hold attribute matchers and targets for each host element.
|
|
2352
|
+
* Structure: {
|
|
2353
|
+
* host: {
|
|
2354
|
+
* matchers: Set<Function>,
|
|
2355
|
+
* targets: Map<HTMLElement, Map<Function, {removeOriginal: boolean, currentAttributes: Map<string, string>}>>
|
|
2356
|
+
* }
|
|
2357
|
+
* }
|
|
2358
|
+
*/
|
|
2359
|
+
const _transportConfig = new WeakMap();
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* Transfers all matching attributes from a host element to a target element and observes for future changes.
|
|
2363
|
+
*
|
|
2364
|
+
* @param {Object} params - The parameters for the function.
|
|
2365
|
+
* @param {HTMLElement} params.host - The host element from which attributes will be transported.
|
|
2366
|
+
* @param {HTMLElement} params.target - The target element to which attributes will be transported.
|
|
2367
|
+
* @param {boolean} [params.removeOriginal=true] - Whether to remove the attributes from the host element.
|
|
2368
|
+
* @param {boolean} [params.observe=true] - Whether to attach a MutationObserver to the host element.
|
|
2369
|
+
* @returns {Function} A function to detach the observer when no longer needed.
|
|
2370
|
+
* @throws {TypeError} If the host or target parameters are not instances of HTMLElement.
|
|
2371
|
+
*/
|
|
2372
|
+
const transportAttributes = ({ host, target, match, removeOriginal = true }) => {
|
|
2373
|
+
// Guard Clause: Ensure host is valid HTMLElement instance
|
|
2374
|
+
if (typeof host !== 'object' || !(host instanceof HTMLElement)) {
|
|
2375
|
+
throw new TypeError('a11yUtilities.js | transportAttributes | The "host" parameter must be an instance of HTMLElement.');
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
// Guard Clause: Ensure target is valid HTMLElement instance
|
|
2379
|
+
if (typeof target !== 'object' || !(target instanceof HTMLElement)) {
|
|
2380
|
+
throw new TypeError('a11yUtilities.js | transportAttributes | The "target" parameter must be an instance of HTMLElement.');
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// Guard Clause: Ensure match is a function
|
|
2384
|
+
if (typeof match !== 'function') {
|
|
2385
|
+
throw new TypeError('a11yUtilities.js | transportAttributes | The "match" parameter must be a function.');
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
// Guard Clause: Ensure removeOriginal is a boolean
|
|
2389
|
+
if (typeof removeOriginal !== 'boolean') {
|
|
2390
|
+
throw new TypeError('a11yUtilities.js | transportAttributes | The "removeOriginal" parameter must be a boolean.');
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
// Register this transport and get cleanup function
|
|
2394
|
+
return _registerTransport({
|
|
2395
|
+
host,
|
|
2396
|
+
target,
|
|
2397
|
+
matcher: match,
|
|
2398
|
+
removeOriginal
|
|
2399
|
+
});
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2402
|
+
/**
|
|
2403
|
+
* Registers a matcher and target for a host element and attaches an observer if needed.
|
|
2404
|
+
*
|
|
2405
|
+
* @param {Object} params - The parameters object.
|
|
2406
|
+
* @param {HTMLElement} params.host - The host element to observe.
|
|
2407
|
+
* @param {HTMLElement} params.target - The target element to receive attributes.
|
|
2408
|
+
* @param {Function} params.matcher - Function that determines which attributes to transport.
|
|
2409
|
+
* @param {boolean} [params.removeOriginal=true] - Whether to remove original attributes.
|
|
2410
|
+
* @param {boolean} [params.observe=true] - Whether to observe for attribute changes.
|
|
2411
|
+
* @returns {Function} Function to detach the specific matcher and target pairing.
|
|
2412
|
+
* @private
|
|
2413
|
+
*/
|
|
2414
|
+
const _registerTransport = ({ host, target, matcher, removeOriginal = true }) => {
|
|
2415
|
+
// Initialize config for this host if it doesn't exist
|
|
2416
|
+
if (!_transportConfig.has(host)) {
|
|
2417
|
+
_transportConfig.set(host, {
|
|
2418
|
+
matchers: new Set(),
|
|
2419
|
+
targets: new Map()
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
const config = _transportConfig.get(host);
|
|
2424
|
+
|
|
2425
|
+
// Add the matcher to the set of matchers for this host
|
|
2426
|
+
config.matchers.add(matcher);
|
|
2427
|
+
|
|
2428
|
+
// Initialize target entry if it doesn't exist
|
|
2429
|
+
if (!config.targets.has(target)) {
|
|
2430
|
+
config.targets.set(target, new Map());
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
// Store the matcher with its removeOriginal setting for this target
|
|
2434
|
+
config.targets.get(target).set(matcher, {
|
|
2435
|
+
removeOriginal,
|
|
2436
|
+
currentAttributes: new Map()
|
|
2437
|
+
});
|
|
2438
|
+
|
|
2439
|
+
// Perform initial attribute transport
|
|
2440
|
+
_transportAttributes({ host, target, matcher, removeOriginal });
|
|
2441
|
+
|
|
2442
|
+
// Attach observer
|
|
2443
|
+
_attachObserver(host);
|
|
2444
|
+
|
|
2445
|
+
// Return cleanup function and utility functions
|
|
2446
|
+
return {
|
|
2447
|
+
cleanup: () => _cleanupTransport(host, target, matcher),
|
|
2448
|
+
getObservedAttributes: () => _getObservedAttributes(host, target, matcher),
|
|
2449
|
+
getObservedAttribute: (attr) => _getObservedAttribute(host, target, matcher, attr),
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Cleans up resources associated with a specific matcher and target for a host element.
|
|
2455
|
+
*
|
|
2456
|
+
* @param {HTMLElement} host - The host element
|
|
2457
|
+
* @param {HTMLElement} target - The target element
|
|
2458
|
+
* @param {Function} matcher - The matcher function
|
|
2459
|
+
* @private
|
|
2460
|
+
*/
|
|
2461
|
+
const _cleanupTransport = (host, target, matcher) => {
|
|
2462
|
+
const config = _transportConfig.get(host);
|
|
2463
|
+
if (!config) return;
|
|
2464
|
+
|
|
2465
|
+
// Remove this matcher from this target
|
|
2466
|
+
const targetMatchers = config.targets.get(target);
|
|
2467
|
+
if (targetMatchers) {
|
|
2468
|
+
targetMatchers.delete(matcher);
|
|
2469
|
+
|
|
2470
|
+
// If this target has no more matchers, remove it
|
|
2471
|
+
if (targetMatchers.size === 0) {
|
|
2472
|
+
config.targets.delete(target);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
// Check if this matcher is still used by any target
|
|
2477
|
+
let matcherStillUsed = false;
|
|
2478
|
+
for (const matcherMap of config.targets.values()) {
|
|
2479
|
+
if (matcherMap.has(matcher)) {
|
|
2480
|
+
matcherStillUsed = true;
|
|
2481
|
+
break;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// If not used anymore, remove from matchers set
|
|
2486
|
+
if (!matcherStillUsed) {
|
|
2487
|
+
config.matchers.delete(matcher);
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
// If no more targets or matchers, detach observer
|
|
2491
|
+
if (config.targets.size === 0 || config.matchers.size === 0) {
|
|
2492
|
+
_detachObserver(host);
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
|
+
/**
|
|
2497
|
+
* Generic function to transport attributes from a host element to a target element.
|
|
2498
|
+
*
|
|
2499
|
+
* @param {Object} params - The parameters object.
|
|
2500
|
+
* @param {HTMLElement} params.host - The host element from which to transport attributes.
|
|
2501
|
+
* @param {HTMLElement} params.target - The target element to which attributes will be transported.
|
|
2502
|
+
* @param {Function} params.matcher - Function that takes an attribute name and returns true if it should be transported.
|
|
2503
|
+
* @param {boolean} [params.removeOriginal=true] - Whether to remove original attributes from host.
|
|
2504
|
+
* @returns {void}
|
|
2505
|
+
* @private
|
|
2506
|
+
*/
|
|
2507
|
+
const _transportAttributes = ({ host, target, matcher, removeOriginal = true }) => {
|
|
2508
|
+
// Get a list of all matching attributes on the host element and their values
|
|
2509
|
+
const matchingAttributes = host.getAttributeNames()
|
|
2510
|
+
.filter(attr => matcher(attr))
|
|
2511
|
+
.reduce((acc, attr) => {
|
|
2512
|
+
acc[attr] = host.getAttribute(attr);
|
|
2513
|
+
return acc;
|
|
2514
|
+
}, {});
|
|
2515
|
+
|
|
2516
|
+
// Move matching attributes to the target element, removing them from the host if removeOriginal is true
|
|
2517
|
+
Object.entries(matchingAttributes).forEach(([key, value]) => {
|
|
2518
|
+
_setObservedAttribute(host, target, matcher, key, value);
|
|
2519
|
+
target.setAttribute(key, value);
|
|
2520
|
+
if (removeOriginal) {
|
|
2521
|
+
host.removeAttribute(key);
|
|
2522
|
+
}
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* Attaches a MutationObserver to the host element to monitor attribute changes.
|
|
2528
|
+
*
|
|
2529
|
+
* @param {HTMLElement} host - The element to observe for attribute changes.
|
|
2530
|
+
* @returns {MutationObserver} The observer instance.
|
|
2531
|
+
* @private
|
|
2532
|
+
*/
|
|
2533
|
+
const _attachObserver = (host) => {
|
|
2534
|
+
// If an observer for this host already exists, return it
|
|
2535
|
+
if (_observers.has(host)) {
|
|
2536
|
+
return _observers.get(host);
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
// Create a new MutationObserver
|
|
2540
|
+
const observer = new MutationObserver((mutations) => {
|
|
2541
|
+
const config = _transportConfig.get(host);
|
|
2542
|
+
if (!config) return;
|
|
2543
|
+
|
|
2544
|
+
// For each mutation affecting attributes
|
|
2545
|
+
mutations
|
|
2546
|
+
.filter(mutation => mutation.type === 'attributes')
|
|
2547
|
+
.forEach(mutation => {
|
|
2548
|
+
const attributeName = mutation.attributeName;
|
|
2549
|
+
|
|
2550
|
+
// Find matchers that care about this attribute
|
|
2551
|
+
for (const matcher of config.matchers) {
|
|
2552
|
+
if (matcher(attributeName)) {
|
|
2553
|
+
// For each target that uses this matcher
|
|
2554
|
+
for (const [target, matcherConfigs] of config.targets.entries()) {
|
|
2555
|
+
if (matcherConfigs.has(matcher)) {
|
|
2556
|
+
const { removeOriginal } = matcherConfigs.get(matcher);
|
|
2557
|
+
_transportAttributes({
|
|
2558
|
+
host,
|
|
2559
|
+
target,
|
|
2560
|
+
matcher,
|
|
2561
|
+
removeOriginal
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
});
|
|
2569
|
+
|
|
2570
|
+
// Start observing attribute changes
|
|
2571
|
+
observer.observe(host, { attributes: true });
|
|
2572
|
+
|
|
2573
|
+
// Store the observer
|
|
2574
|
+
_observers.set(host, observer);
|
|
2575
|
+
|
|
2576
|
+
return observer;
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2579
|
+
/**
|
|
2580
|
+
* Detaches and cleans up the MutationObserver for a given host element.
|
|
2581
|
+
*
|
|
2582
|
+
* @param {HTMLElement} host - The element whose observer should be detached.
|
|
2583
|
+
* @private
|
|
2584
|
+
*/
|
|
2585
|
+
const _detachObserver = (host) => {
|
|
2586
|
+
if (_observers.has(host)) {
|
|
2587
|
+
const observer = _observers.get(host);
|
|
2588
|
+
observer.disconnect();
|
|
2589
|
+
_observers.delete(host);
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
// Clean up the transport config as well
|
|
2593
|
+
if (_transportConfig.has(host)) {
|
|
2594
|
+
_transportConfig.delete(host);
|
|
2595
|
+
}
|
|
2596
|
+
};
|
|
2597
|
+
|
|
2598
|
+
/**
|
|
2599
|
+
* Gets the matcher configuration for a specific host, target, and matcher
|
|
2600
|
+
* @param {HTMLElement} host - The host element
|
|
2601
|
+
* @param {HTMLElement} target - The target element
|
|
2602
|
+
* @param {Function} matcher - The matcher function
|
|
2603
|
+
* @returns {Object|undefined} The matcher configuration if found
|
|
2604
|
+
* @private
|
|
2605
|
+
*/
|
|
2606
|
+
const _getMatcherConfig = (host, target, matcher) => {
|
|
2607
|
+
const config = _transportConfig.get(host);
|
|
2608
|
+
if (!config) return undefined;
|
|
2609
|
+
|
|
2610
|
+
const targetMatchers = config.targets.get(target);
|
|
2611
|
+
if (!targetMatchers) return undefined;
|
|
2612
|
+
|
|
2613
|
+
return targetMatchers.get(matcher);
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2616
|
+
/**
|
|
2617
|
+
* Sets an observed attribute value
|
|
2618
|
+
* @param {HTMLElement} host - The host element
|
|
2619
|
+
* @param {HTMLElement} target - The target element
|
|
2620
|
+
* @param {Function} matcher - The matcher function
|
|
2621
|
+
* @param {string} key - The attribute name
|
|
2622
|
+
* @param {string} value - The attribute value
|
|
2623
|
+
* @private
|
|
2624
|
+
*/
|
|
2625
|
+
const _setObservedAttribute = (host, target, matcher, key, value) => {
|
|
2626
|
+
const matcherConfig = _getMatcherConfig(host, target, matcher);
|
|
2627
|
+
if (matcherConfig) {
|
|
2628
|
+
matcherConfig.currentAttributes.set(key, value);
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
const _getObservedAttribute = (host, target, matcher, attr) => {
|
|
2633
|
+
const matcherConfig = _getMatcherConfig(host, target, matcher);
|
|
2634
|
+
if (matcherConfig) return matcherConfig.currentAttributes.get(attr);
|
|
2635
|
+
return undefined;
|
|
2636
|
+
};
|
|
2637
|
+
|
|
2638
|
+
const _getObservedAttributes = (host, target, matcher) => {
|
|
2639
|
+
const matcherConfig = _getMatcherConfig(host, target, matcher);
|
|
2640
|
+
if (matcherConfig) return Array.from(matcherConfig.currentAttributes.entries());
|
|
2641
|
+
return [];
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
const _matchers = {
|
|
2645
|
+
'aria-': attr => attr.startsWith('aria-'),
|
|
2646
|
+
'role': attr => attr.match(/^role$/)
|
|
2647
|
+
};
|
|
2648
|
+
|
|
2649
|
+
const transportAllA11yAttributes = ({ host, target, removeOriginal = true }) => {
|
|
2650
|
+
return transportAttributes({
|
|
2651
|
+
host,
|
|
2652
|
+
target,
|
|
2653
|
+
match: attr => {
|
|
2654
|
+
for (const key in _matchers) {
|
|
2655
|
+
if (_matchers[key](attr)) return true;
|
|
2656
|
+
}
|
|
2657
|
+
return false;
|
|
2658
|
+
},
|
|
2659
|
+
removeOriginal
|
|
2660
|
+
});
|
|
2661
|
+
};
|
|
2662
|
+
|
|
2663
|
+
let AuroElement$1 = class AuroElement extends i$2 {
|
|
2664
|
+
|
|
2665
|
+
/**
|
|
2666
|
+
* @type {Object} return object from transportAttributes via a11yUtilities
|
|
2667
|
+
* @property {Function} cleanup - Function to clean up the attribute watcher.
|
|
2668
|
+
* @property {Function} getCurrentAttributes - Function to get the current attributes being watched and their values.
|
|
2669
|
+
* @property {Function} getObservedAttribute - Function to get the value of a specific observed attribute by name.
|
|
2670
|
+
* @private
|
|
2671
|
+
*/
|
|
2672
|
+
attributeWatcher;
|
|
2673
|
+
|
|
2674
|
+
static get properties() {
|
|
2675
|
+
return {
|
|
2676
|
+
|
|
2677
|
+
/**
|
|
2678
|
+
* Defines the layout of an element.
|
|
2679
|
+
* @default {'default'}
|
|
2680
|
+
*/
|
|
2681
|
+
layout: {
|
|
2682
|
+
type: String,
|
|
2683
|
+
attribute: "layout",
|
|
2684
|
+
reflect: true
|
|
2685
|
+
},
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* Defines the shape of an element.
|
|
2689
|
+
* @property {'default', 'rounded', 'pill', 'circle'}
|
|
2690
|
+
* @default {'default'}
|
|
2691
|
+
*/
|
|
2692
|
+
shape: {
|
|
2693
|
+
type: String,
|
|
2694
|
+
attribute: "shape",
|
|
2695
|
+
reflect: true
|
|
2696
|
+
},
|
|
2697
|
+
|
|
2698
|
+
/**
|
|
2699
|
+
* Defines the size of an element.
|
|
2700
|
+
* @property {'xs', 'sm', 'md', 'lg', 'xl'}
|
|
2701
|
+
* @default {'md'}
|
|
2702
|
+
*/
|
|
2703
|
+
size: {
|
|
2704
|
+
type: String,
|
|
2705
|
+
attribute: "size",
|
|
2706
|
+
reflect: true
|
|
2707
|
+
},
|
|
2708
|
+
|
|
2709
|
+
/**
|
|
2710
|
+
* This Boolean attribute lets you specify that the element should be rendered in dark mode.
|
|
2711
|
+
* @default {false}
|
|
2712
|
+
*/
|
|
2713
|
+
onDark: {
|
|
2714
|
+
type: Boolean,
|
|
2715
|
+
attribute: "ondark",
|
|
2716
|
+
reflect: true
|
|
2717
|
+
},
|
|
2718
|
+
|
|
2719
|
+
/**
|
|
2720
|
+
* A reference to the wrapper element in the shadow DOM.
|
|
2721
|
+
* This is used to apply layout and shape classes dynamically.
|
|
2722
|
+
* @type {HTMLElement|null}
|
|
2723
|
+
* @default {null}
|
|
2724
|
+
* @private
|
|
2725
|
+
*/
|
|
2726
|
+
wrapper: {
|
|
2727
|
+
type: HTMLElement,
|
|
2728
|
+
attribute: false,
|
|
2729
|
+
reflect: false
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
resetShapeClasses() {
|
|
2737
|
+
if (this.shape && this.size) {
|
|
2738
|
+
|
|
2739
|
+
if (this.wrapper) {
|
|
2740
|
+
this.wrapper.classList.forEach((className) => {
|
|
2741
|
+
if (className.startsWith('shape-')) {
|
|
2742
|
+
this.wrapper.classList.remove(className);
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
|
|
2746
|
+
this.wrapper.classList.add(`shape-${this.shape.toLowerCase()}-${this.size.toLowerCase()}`);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
resetLayoutClasses() {
|
|
2752
|
+
if (this.layout) {
|
|
2753
|
+
if (this.wrapper) {
|
|
2754
|
+
this.wrapper.classList.forEach((className) => {
|
|
2755
|
+
if (className.startsWith('layout-')) {
|
|
2756
|
+
this.wrapper.classList.remove(className);
|
|
2757
|
+
}
|
|
2758
|
+
});
|
|
2759
|
+
|
|
2760
|
+
this.wrapper.classList.add(`layout-${this.layout.toLowerCase()}`);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
updateComponentArchitecture() {
|
|
2766
|
+
this.resetLayoutClasses();
|
|
2767
|
+
this.resetShapeClasses();
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
updated(changedProperties) {
|
|
2771
|
+
if (changedProperties.has('layout') || changedProperties.has('shape') || changedProperties.has('size')) {
|
|
2772
|
+
this.updateComponentArchitecture();
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
firstUpdated() {
|
|
2777
|
+
super.firstUpdated();
|
|
2778
|
+
|
|
2779
|
+
// Set a reference to the wrapper element in the shadow DOM
|
|
2780
|
+
this.wrapper = this.shadowRoot.querySelector('.wrapper');
|
|
2781
|
+
|
|
2782
|
+
// Initialize the transportation of ARIA attributes to the target element and get the disconnect function for cleanup
|
|
2783
|
+
this.attributeWatcher = transportAllA11yAttributes({ host: this, target: this.shadowRoot.querySelector('.wrapper') });
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
disconnectedCallback() {
|
|
2787
|
+
super.disconnectedCallback();
|
|
2788
|
+
|
|
2789
|
+
// Cleanup the ARIA observer if it exists
|
|
2790
|
+
if (this.attributeWatcher) {
|
|
2791
|
+
this.attributeWatcher.cleanup();
|
|
2792
|
+
this.attributeWatcher = null;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
// Try to render the defined `this.layout` layout. If that fails, fall back to the default layout.
|
|
2797
|
+
// This will catch if an invalid layout value is passed in and render the default layout if so.
|
|
2798
|
+
render() {
|
|
2799
|
+
try {
|
|
2800
|
+
return this.renderLayout();
|
|
2801
|
+
} catch (error) {
|
|
2802
|
+
// failed to get the defined layout
|
|
2803
|
+
console.error('Failed to get the defined layout - using the default layout', error); // eslint-disable-line no-console
|
|
2804
|
+
|
|
2805
|
+
// fallback to the default layout
|
|
2806
|
+
return this.getLayout('default');
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
|
|
2811
|
+
/**
|
|
2812
|
+
* @license
|
|
2813
|
+
* Copyright 2017 Google LLC
|
|
2814
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2815
|
+
*/
|
|
2816
|
+
const t={ATTRIBUTE:1},e$1=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
2817
|
+
|
|
2818
|
+
/**
|
|
2819
|
+
* @license
|
|
2820
|
+
* Copyright 2018 Google LLC
|
|
2821
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2822
|
+
*/const e=e$1(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
|
|
2823
|
+
|
|
2824
|
+
/**
|
|
2825
|
+
* @license
|
|
2826
|
+
* Copyright 2018 Google LLC
|
|
2827
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2828
|
+
*/const o=o=>o??E;
|
|
2829
|
+
|
|
2830
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2831
|
+
// See LICENSE in the project root for license information.
|
|
2832
|
+
|
|
2833
|
+
|
|
2834
|
+
class AuroDependencyVersioning {
|
|
2835
|
+
|
|
2836
|
+
/**
|
|
2837
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2838
|
+
* @private
|
|
2839
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2840
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2841
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2842
|
+
*/
|
|
2843
|
+
generateElementName(baseName, version) {
|
|
2844
|
+
let result = baseName;
|
|
2845
|
+
|
|
2846
|
+
result += '-';
|
|
2847
|
+
result += version.replace(/[.]/g, '_');
|
|
2848
|
+
|
|
2849
|
+
return result;
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
/**
|
|
2853
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2854
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2855
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2856
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2857
|
+
*/
|
|
2858
|
+
generateTag(baseName, version, tagClass) {
|
|
2859
|
+
const elementName = this.generateElementName(baseName, version);
|
|
2860
|
+
const tag = i$1`${s(elementName)}`;
|
|
2861
|
+
|
|
2862
|
+
if (!customElements.get(elementName)) {
|
|
2863
|
+
customElements.define(elementName, class extends tagClass {});
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
return tag;
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2871
|
+
// See LICENSE in the project root for license information.
|
|
2872
|
+
|
|
2873
|
+
// ---------------------------------------------------------------------
|
|
2874
|
+
|
|
2875
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
2876
|
+
|
|
2877
|
+
class AuroLibraryRuntimeUtils {
|
|
2878
|
+
|
|
2879
|
+
/* eslint-disable jsdoc/require-param */
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* This will register a new custom element with the browser.
|
|
2883
|
+
* @param {String} name - The name of the custom element.
|
|
2884
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
2885
|
+
* @returns {void}
|
|
2886
|
+
*/
|
|
2887
|
+
registerComponent(name, componentClass) {
|
|
2888
|
+
if (!customElements.get(name)) {
|
|
2889
|
+
customElements.define(name, class extends componentClass {});
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
/**
|
|
2894
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
2895
|
+
* @returns {void}
|
|
2896
|
+
*/
|
|
2897
|
+
closestElement(
|
|
2898
|
+
selector, // selector like in .closest()
|
|
2899
|
+
base = this, // extra functionality to skip a parent
|
|
2900
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
2901
|
+
!el || el === document || el === window
|
|
2902
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
2903
|
+
: found
|
|
2904
|
+
? found // found a selector INside this element
|
|
2905
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
2906
|
+
) {
|
|
2907
|
+
return __Closest(base);
|
|
2908
|
+
}
|
|
2909
|
+
/* eslint-enable jsdoc/require-param */
|
|
2910
|
+
|
|
2911
|
+
/**
|
|
2912
|
+
* 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.
|
|
2913
|
+
* @param {Object} elem - The element to check.
|
|
2914
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
2915
|
+
* @returns {void}
|
|
2916
|
+
*/
|
|
2917
|
+
handleComponentTagRename(elem, tagName) {
|
|
2918
|
+
const tag = tagName.toLowerCase();
|
|
2919
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
2920
|
+
|
|
2921
|
+
if (elemTag !== tag) {
|
|
2922
|
+
elem.setAttribute(tag, true);
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
|
+
/**
|
|
2927
|
+
* Validates if an element is a specific Auro component.
|
|
2928
|
+
* @param {Object} elem - The element to validate.
|
|
2929
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
2930
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
2931
|
+
*/
|
|
2932
|
+
elementMatch(elem, tagName) {
|
|
2933
|
+
const tag = tagName.toLowerCase();
|
|
2934
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
2935
|
+
|
|
2936
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
var styleCss$3 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.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}:host([fluid]) .auro-button,:host([fluid=true]) .auro-button{min-width:auto;width:100%}:host([variant=flat]){display:inline-block}::slotted(svg){vertical-align:middle}slot{pointer-events:none}.auro-button{position:relative;padding:0 var(--ds-size-300, 1.5rem);cursor:pointer;border-width:1px;border-style:solid;border-radius:var(--ds-border-radius, 0.375rem);overflow:hidden;text-overflow:ellipsis;user-select:none;white-space:nowrap;min-height:var(--ds-size-600, 3rem);max-height:var(--ds-size-600, 3rem);display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:var(--ds-size-100, 0.5rem);margin:0;-webkit-touch-callout:none;-webkit-user-select:none;transition:padding 300ms ease-out}.auro-button:active{transform:scale(0.95)}.auro-button:focus-visible,.auro-button:focus{outline:none;outline-style:solid;outline-width:var(--ds-size-50, 0.25rem);outline-offset:calc(var(--ds-size-50, 0.25rem)*-1)}.auro-button:focus-visible:not([variant=secondary]):not([variant=tertiary]),.auro-button:focus:not([variant=secondary]):not([variant=tertiary]){outline-width:calc(var(--ds-size-50, 0.25rem) - 1px)}.auro-button.loading{cursor:not-allowed}.auro-button.loading *:not([auro-loader]){visibility:hidden}@media screen and (min-width: 576px){.auro-button{min-width:8.75rem;width:auto}}.auro-button:disabled{cursor:not-allowed;transform:unset}.auro-button[variant=secondary]:disabled{cursor:not-allowed;transform:unset}.auro-button[variant=tertiary]:disabled{cursor:not-allowed;transform:unset}.auro-button[variant=ghost]:disabled{cursor:not-allowed;transform:unset}.auro-button[onDark]:disabled{cursor:not-allowed;transform:unset}.auro-button[onDark][variant=secondary]:disabled{cursor:not-allowed;transform:unset}@media(hover: hover){.auro-button[onDark][variant=tertiary]:active,.auro-button[onDark][variant=tertiary]:hover{box-shadow:none}}.auro-button[onDark][variant=tertiary]:active{box-shadow:none}.auro-button[onDark][variant=tertiary]:disabled{cursor:not-allowed;transform:unset}.auro-button--slim{min-width:unset;min-height:calc(var(--ds-size-500, 2.5rem) - var(--ds-size-50, 0.25rem));max-height:calc(var(--ds-size-500, 2.5rem) - var(--ds-size-50, 0.25rem))}.auro-button--iconOnly{padding:0 var(--ds-size-100, 0.5rem);border-radius:100px;min-width:unset;height:var(--ds-size-600, 3rem);width:var(--ds-size-500, 2.5rem)}.auro-button--iconOnly ::slotted(auro-icon),.auro-button--iconOnly ::slotted([auro-icon]){--ds-auro-icon-size:var(--ds-size-300, 1.5rem)}.auro-button--iconOnly:not(.auro-button--rounded):focus-visible:not([variant=secondary]):not([variant=tertiary]):not([variant=flat]),.auro-button--iconOnly:not(.auro-button--rounded):focus:not([variant=secondary]):not([variant=tertiary]):not([variant=flat]){outline-width:1px;outline-offset:-2px}.auro-button--iconOnlySlim{padding:0 var(--ds-size-50, 0.25rem);height:calc(var(--ds-size-400, 2rem) + var(--ds-size-50, 0.25rem));width:calc(var(--ds-size-300, 1.5rem) + var(--ds-size-50, 0.25rem))}.auro-button--iconOnlySlim ::slotted(auro-icon),.auro-button--iconOnlySlim ::slotted([auro-icon]){--ds-auro-icon-size:calc(var(--ds-size-200, 1rem) + var(--ds-size-50, 0.25rem))}.auro-button--rounded{border-radius:100px;box-shadow:var(--ds-elevation-300, 0px 0px 15px rgba(0, 0, 0, 0.2));height:var(--ds-size-500, 2.5rem);min-width:unset;transition:padding 300ms ease-out,outline 0ms,outline-offset 0ms}.auro-button--rounded ::slotted(auro-icon),.auro-button--rounded ::slotted([auro-icon]){--ds-auro-icon-size:var(--ds-size-300, 1.5rem)}.auro-button--rounded:focus-visible:not([variant=flat]):after,.auro-button--rounded:focus:not([variant=flat]):after{border-radius:100px}:host([size=xs]) .wrapper:focus-visible,:host([size=xs]) .wrapper:focus{outline-width:1px;outline-offset:-2px}:host([rounded]) .textSlot{transition:opacity 300ms ease-in;opacity:1}:host([rounded][iconOnly]) .textSlot{opacity:0}:host([rounded][iconOnly]) .textWrapper{display:none}:host([rounded][iconOnly]) .auro-button{min-width:unset;padding:unset;width:var(--ds-size-600, 3rem)}[auro-loader]{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);pointer-events:none}`;
|
|
2941
|
+
|
|
2942
|
+
var colorCss$2 = i$5`[auro-loader]{color:var(--ds-auro-button-loader-color)}.auro-button{-webkit-tap-highlight-color:var(--ds-auro-button-tap-color);color:var(--ds-auro-button-text-color);background-color:var(--ds-auro-button-container-color);background-image:linear-gradient(var(--ds-auro-button-container-image), var(--ds-auro-button-container-image));border-color:var(--ds-auro-button-border-color)}.auro-button:not([variant=secondary]):not([variant=tertiary]):focus-visible{outline-color:var(--ds-auro-button-border-inset-color)}.auro-button:not([ondark]):active:not(:disabled),.auro-button:not([ondark]):hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-hover, #00274a);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-hover, #00274a);--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-hover, #00274a)}.auro-button:not([ondark]):disabled{--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-disabled, #acc9e2);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-disabled, #acc9e2);--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-disabled, #acc9e2)}.auro-button:not([ondark])[variant=secondary]{--ds-auro-button-container-color:var(--ds-advanced-color-button-secondary-background, #ffffff);--ds-auro-button-container-image:var(--ds-advanced-color-button-secondary-background, #ffffff);--ds-auro-button-border-color:var(--ds-advanced-color-button-secondary-border, #01426a);--ds-auro-button-text-color:var(--ds-advanced-color-button-secondary-text, #01426a);--ds-auro-button-loader-color:var(--ds-advanced-color-button-secondary-text, #01426a)}.auro-button:not([ondark])[variant=secondary]:active:not(:disabled),.auro-button:not([ondark])[variant=secondary]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-secondary-background-hover, #f2f2f2);--ds-auro-button-container-image:var(--ds-advanced-color-button-secondary-background-hover, #f2f2f2);--ds-auro-button-border-color:var(--ds-advanced-color-button-secondary-border-hover, #00274a);--ds-auro-button-text-color:var(--ds-advanced-color-button-secondary-text-hover, #00274a)}.auro-button:not([ondark])[variant=secondary]:focus-visible{--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused, #01426a)}.auro-button:not([ondark])[variant=secondary]:disabled{--ds-auro-button-container-color:var(--ds-advanced-color-button-secondary-background-disabled, #f7f7f7);--ds-auro-button-container-image:var(--ds-advanced-color-button-secondary-background-disabled, #f7f7f7);--ds-auro-button-border-color:var(--ds-advanced-color-button-secondary-border-disabled, #cfe0ef);--ds-auro-button-text-color:var(--ds-basic-color-texticon-disabled, #d0d0d0)}.auro-button:not([ondark])[variant=tertiary]{--ds-auro-button-container-color:var(--ds-advanced-color-button-tertiary-background, rgba(0, 0, 0, 0.05));--ds-auro-button-container-image:var(--ds-advanced-color-button-tertiary-background, rgba(0, 0, 0, 0.05));--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-advanced-color-button-tertiary-text, #01426a);--ds-auro-button-loader-color:var(--ds-advanced-color-button-tertiary-text, #01426a)}.auro-button:not([ondark])[variant=tertiary]:active:not(:disabled),.auro-button:not([ondark])[variant=tertiary]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-tertiary-background-hover, rgba(0, 0, 0, 0.1));--ds-auro-button-container-image:var(--ds-advanced-color-button-tertiary-background-hover, rgba(0, 0, 0, 0.1));--ds-auro-button-border-color:transparent}.auro-button:not([ondark])[variant=tertiary]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused, #01426a);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused, #01426a)}.auro-button:not([ondark])[variant=tertiary]:disabled{--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-basic-color-texticon-disabled, #d0d0d0)}.auro-button:not([ondark])[variant=ghost]{--ds-auro-button-container-color:transparent;--ds-auro-button-container-image:transparent;--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-advanced-color-button-ghost-text, #01426a);--ds-auro-button-loader-color:var(--ds-advanced-color-button-ghost-text, #01426a)}.auro-button:not([ondark])[variant=ghost]:active:not(:disabled),.auro-button:not([ondark])[variant=ghost]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-ghost-background-hover, rgba(0, 0, 0, 0.05));--ds-auro-button-container-image:var(--ds-advanced-color-button-ghost-background-hover, rgba(0, 0, 0, 0.05));--ds-auro-button-border-color:transparent}.auro-button:not([ondark])[variant=ghost]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused, #01426a);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused, #01426a)}.auro-button:not([ondark])[variant=ghost]:disabled{--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-basic-color-texticon-disabled, #d0d0d0)}.auro-button:not([ondark])[variant=flat]{color:var(--ds-advanced-color-button-flat-text, #676767);background-color:transparent;background-image:none;border-color:transparent}.auro-button:not([ondark])[variant=flat]:active:not(:disabled),.auro-button:not([ondark])[variant=flat]:hover:not(:disabled){color:var(--ds-advanced-color-button-flat-text-hover, #525252);background-color:transparent;background-image:none;border-color:transparent}.auro-button:not([ondark])[variant=flat]:disabled{color:var(--ds-advanced-color-button-flat-text-disabled, #d0d0d0);background-color:transparent;background-image:none;border-color:transparent}.auro-button:not([ondark])[variant=flat]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused, #01426a);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused, #01426a)}.auro-button[ondark]{--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-inverse, #ffffff);--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-inverse, #ffffff);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-inverse, #ffffff);--ds-auro-button-text-color:var(--ds-advanced-color-button-primary-text-inverse, #01426a);--ds-auro-button-loader-color:var(--ds-advanced-color-button-primary-text-inverse, #01426a)}.auro-button[ondark]:active:not(:disabled),.auro-button[ondark]:hover:not(:disabled){--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-inverse-hover, #ebf3f9);--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-inverse-hover, #ebf3f9);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-inverse-hover, #ebf3f9)}.auro-button[ondark]:focus-visible{--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused, #01426a)}.auro-button[ondark]:disabled{--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-inverse-disabled, rgba(255, 255, 255, 0.75));--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-inverse-disabled, rgba(255, 255, 255, 0.75));--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-inverse-disabled, rgba(255, 255, 255, 0.75));--ds-auro-button-text-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}.auro-button[ondark][variant=secondary]{--ds-auro-button-container-color:transparent;--ds-auro-button-container-image:transparent;--ds-auro-button-border-color:var(--ds-advanced-color-button-secondary-border-inverse, #ffffff);--ds-auro-button-text-color:var(--ds-advanced-color-button-secondary-text-inverse, #ffffff);--ds-auro-button-loader-color:var(--ds-advanced-color-button-secondary-text-inverse, #ffffff)}.auro-button[ondark][variant=secondary]:active:not(:disabled),.auro-button[ondark][variant=secondary]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-secondary-background-inverse-hover, rgba(255, 255, 255, 0.1));--ds-auro-button-container-image:var(--ds-advanced-color-button-secondary-background-inverse-hover, rgba(255, 255, 255, 0.1))}.auro-button[ondark][variant=secondary]:focus-visible{--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff)}.auro-button[ondark][variant=secondary]:disabled{--ds-auro-button-text-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894);--ds-auro-button-border-color:var(--ds-advanced-color-button-secondary-border-inverse-disabled, #dddddd)}.auro-button[ondark][variant=tertiary]{--ds-auro-button-container-color:var(--ds-advanced-color-button-tertiary-background-inverse, rgba(255, 255, 255, 0.05));--ds-auro-button-container-image:var(--ds-advanced-color-button-tertiary-background-inverse, rgba(255, 255, 255, 0.05));--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-advanced-color-button-tertiary-text-inverse, #ffffff);--ds-auro-button-loader-color:var(--ds-advanced-color-button-tertiary-text-inverse, #ffffff)}.auro-button[ondark][variant=tertiary]:active:not(:disabled),.auro-button[ondark][variant=tertiary]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-tertiary-background-inverse-hover, rgba(255, 255, 255, 0.1));--ds-auro-button-container-image:var(--ds-advanced-color-button-tertiary-background-inverse-hover, rgba(255, 255, 255, 0.1))}.auro-button[ondark][variant=tertiary]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff)}.auro-button[ondark][variant=tertiary]:disabled{--ds-auro-button-text-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}.auro-button[ondark][variant=ghost]{--ds-auro-button-container-color:transparent;--ds-auro-button-container-image:transparent;--ds-auro-button-border-color:transparent;--ds-auro-button-text-color:var(--ds-advanced-color-button-ghost-text-inverse, #ffffff);--ds-auro-button-loader-color:var(--ds-advanced-color-button-ghost-text-inverse, #ffffff)}.auro-button[ondark][variant=ghost]:active:not(:disabled),.auro-button[ondark][variant=ghost]:hover:not(:disabled){--ds-auro-button-container-color:var(--ds-advanced-color-button-ghost-background-inverse-hover, rgba(255, 255, 255, 0.05));--ds-auro-button-container-image:var(--ds-advanced-color-button-ghost-background-inverse-hover, rgba(255, 255, 255, 0.05))}.auro-button[ondark][variant=ghost]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff)}.auro-button[ondark][variant=ghost]:disabled{--ds-auro-button-text-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}.auro-button[ondark][variant=flat]{color:var(--ds-advanced-color-button-flat-text-inverse, #ffffff);background-color:transparent;background-image:none;border-color:transparent}.auro-button[ondark][variant=flat]:active:not(:disabled),.auro-button[ondark][variant=flat]:hover:not(:disabled){color:var(--ds-advanced-color-button-flat-text-inverse-hover, #adadad);background-color:transparent;background-image:none;border-color:transparent}.auro-button[ondark][variant=flat]:disabled{color:var(--ds-advanced-color-button-flat-text-inverse-disabled, #7e8894);background-color:transparent;background-image:none;border-color:transparent}.auro-button[ondark][variant=flat]:focus-visible{--ds-auro-button-border-color:var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff)}`;
|
|
2943
|
+
|
|
2944
|
+
var tokensCss$2 = i$5`:host(:not([onDark])){--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border, #01426a);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background, #01426a);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background, #01426a);--ds-auro-button-loader-color:var(--ds-advanced-color-button-primary-text, #ffffff);--ds-auro-button-text-color:var(--ds-advanced-color-button-primary-text, #ffffff);--ds-auro-button-tap-color:transparent}:host([onDark]){--ds-auro-button-border-color:var(--ds-advanced-color-button-primary-border-inverse, #ffffff);--ds-auro-button-border-inset-color:var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-button-container-color:var(--ds-advanced-color-button-primary-background-inverse, #ffffff);--ds-auro-button-container-image:var(--ds-advanced-color-button-primary-background-inverse, #ffffff);--ds-auro-button-loader-color:var(--ds-advanced-color-button-primary-text-inverse, #01426a);--ds-auro-button-text-color:var(--ds-advanced-color-button-primary-text-inverse, #01426a);--ds-auro-button-tap-color:transparent}`;
|
|
2945
|
+
|
|
2946
|
+
var shapeSize = i$5`.shape-rounded-xl{min-height:68px;max-height:68px;border-style:solid;border-radius:6px;overflow:hidden;font-size:18px}.shape-rounded-lg{min-height:52px;max-height:52px;border-style:solid;border-radius:6px;overflow:hidden;font-size:18px}.shape-rounded-md{min-height:44px;max-height:44px;border-style:solid;border-radius:6px;overflow:hidden;font-size:16px}.shape-rounded-sm{min-height:32px;max-height:32px;border-style:solid;border-radius:6px;overflow:hidden;font-size:14px}.shape-rounded-xs{min-height:20px;max-height:20px;border-style:solid;border-radius:4px;overflow:hidden;font-size:12px;outline-offset:-2px;outline-width:1px}.shape-pill-xl{min-height:68px;max-height:68px;border-style:solid;border-radius:34px;overflow:hidden;font-size:18px}.shape-pill-left-xl{min-height:68px;max-height:68px;border-style:solid;border-radius:34px 0 0 34px;overflow:hidden}.shape-pill-right-xl{min-height:68px;max-height:68px;border-style:solid;border-radius:0 34px 34px 0;overflow:hidden}.shape-pill-lg{min-height:52px;max-height:52px;border-style:solid;border-radius:26px;overflow:hidden;font-size:18px}.shape-pill-left-lg{min-height:52px;max-height:52px;border-style:solid;border-radius:26px 0 0 26px;overflow:hidden}.shape-pill-right-lg{min-height:52px;max-height:52px;border-style:solid;border-radius:0 26px 26px 0;overflow:hidden}.shape-pill-md{min-height:44px;max-height:44px;border-style:solid;border-radius:22px;overflow:hidden}.shape-pill-left-md{min-height:44px;max-height:44px;border-style:solid;border-radius:22px 0 0 22px;overflow:hidden}.shape-pill-right-md{min-height:44px;max-height:44px;border-style:solid;border-radius:0 22px 22px 0;overflow:hidden;font-size:16px}.shape-pill-sm{min-height:32px;max-height:32px;border-style:solid;border-radius:16px;overflow:hidden;font-size:14px}.shape-pill-left-sm{min-height:32px;max-height:32px;border-style:solid;border-radius:16px 0 0 16px;overflow:hidden}.shape-pill-right-sm{min-height:32px;max-height:32px;border-style:solid;border-radius:0 16px 16px 0;overflow:hidden}.shape-pill-xs{min-height:20px;max-height:20px;border-style:solid;border-radius:10px;overflow:hidden;font-size:12px;outline-offset:-2px;outline-width:1px}.shape-pill-left-xs{min-height:20px;max-height:20px;border-style:solid;border-radius:10px 0 0 10px;overflow:hidden;outline-offset:-2px;outline-width:1px}.shape-pill-right-xs{min-height:20px;max-height:20px;border-style:solid;border-radius:0 10px 10px 0;overflow:hidden;outline-offset:-2px;outline-width:1px}.shape-circle-xl{min-height:68px;max-height:68px;min-width:68px;max-width:68px;border-style:solid;border-radius:34px;overflow:hidden;padding:0}.shape-circle-lg{min-height:52px;max-height:52px;min-width:52px;max-width:52px;border-style:solid;border-radius:26px;overflow:hidden;padding:0}.shape-circle-md{min-height:44px;max-height:44px;min-width:44px;max-width:44px;border-style:solid;border-radius:22px;overflow:hidden;padding:0}.shape-circle-sm{min-height:32px;max-height:32px;min-width:32px;max-width:32px;border-style:solid;border-radius:16px;overflow:hidden;padding:0}.shape-circle-xs{min-height:20px;max-height:20px;min-width:20px;max-width:20px;border-style:solid;border-radius:10px;overflow:hidden;padding:0;outline-offset:-2px;outline-width:1px}`;
|
|
2947
|
+
|
|
2948
|
+
var styleCss$2 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}:host,:host>span{position:relative}:host{width:2rem;height:2rem;display:inline-block;font-size:0}:host>span{position:absolute;display:inline-block;float:none;top:0;left:0;width:2rem;height:2rem;border-radius:100%;border-style:solid;border-width:0}:host([xs]),:host([xs])>span{width:1.2rem;height:1.2rem}:host([sm]),:host([sm])>span{width:3rem;height:3rem}:host([md]),:host([md])>span{width:5rem;height:5rem}:host([lg]),:host([lg])>span{width:8rem;height:8rem}:host{--margin:0.375rem;--margin-xs:0.2rem;--margin-sm:0.5rem;--margin-md:0.75rem;--margin-lg:1rem}:host([pulse]),:host([pulse])>span{position:relative}:host([pulse]){width:calc(3rem + var(--margin)*6);height:1.5rem}:host([pulse])>span{width:1rem;height:1rem;margin:var(--margin);animation:pulse 1.5s ease infinite}:host([pulse][xs]){width:calc(2.55rem + var(--margin-xs)*6);height:1.55rem}:host([pulse][xs])>span{margin:var(--margin-xs);width:.65rem;height:.65rem}:host([pulse][sm]){width:calc(6rem + var(--margin-sm)*6);height:2.5rem}:host([pulse][sm])>span{margin:var(--margin-sm);width:2rem;height:2rem}:host([pulse][md]){width:calc(9rem + var(--margin-md)*6);height:3.5rem}:host([pulse][md])>span{margin:var(--margin-md);width:3rem;height:3rem}:host([pulse][lg]){width:calc(15rem + var(--margin-lg)*6);height:5.5rem}:host([pulse][lg])>span{margin:var(--margin-lg);width:5rem;height:5rem}:host([pulse])>span:nth-child(1){animation-delay:-400ms}:host([pulse])>span:nth-child(2){animation-delay:-200ms}:host([pulse])>span:nth-child(3){animation-delay:0ms}@keyframes pulse{0%,100%{opacity:.1;transform:scale(0.9)}50%{opacity:1;transform:scale(1.1)}}:host([orbit]),:host([orbit])>span{opacity:1}:host([orbit])>span{border-width:5px}:host([orbit])>span:nth-child(2){animation:orbit 2s linear infinite}:host([orbit][sm])>span{border-width:8px}:host([orbit][md])>span{border-width:13px}:host([orbit][lg])>span{border-width:21px}@keyframes orbit{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}:host([ringworm])>svg{animation:rotate 2s linear infinite;height:100%;width:100%;stroke:currentcolor;stroke-width:8}:host([ringworm]) .path{stroke-dashoffset:0;animation:ringworm 1.5s ease-in-out infinite;stroke-linecap:round}@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes ringworm{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:89,200;stroke-dashoffset:-35px}100%{stroke-dasharray:89,200;stroke-dashoffset:-124px}}:host([laser]){position:static;width:100%;display:block;height:0;overflow:hidden;font-size:unset}:host([laser])>span{position:fixed;width:100%;height:.25rem;border-radius:0;z-index:100}:host([laser])>span:nth-child(1){border-color:currentcolor;opacity:.25}:host([laser])>span:nth-child(2){border-color:currentcolor;animation:laser 2s linear infinite;opacity:1;width:50%}:host([laser][sm])>span:nth-child(2){width:20%}:host([laser][md])>span:nth-child(2){width:30%}:host([laser][lg])>span:nth-child(2){width:50%;animation-duration:1.5s}:host([laser][xl])>span:nth-child(2){width:80%;animation-duration:1.5s}@keyframes laser{0%{left:-100%}100%{left:110%}}:host>.no-animation{display:none}@media(prefers-reduced-motion: reduce){:host{display:flex;align-items:center;justify-content:center;font-size:1rem}:host>span{opacity:1}:host>.loader{display:none}:host>.no-animation{display:block}}`;
|
|
2949
|
+
|
|
2950
|
+
var colorCss$1 = i$5`:host{color:var(--ds-auro-loader-color)}:host>span{background-color:var(--ds-auro-loader-background-color);border-color:var(--ds-auro-loader-border-color)}:host([onlight]){--ds-auro-loader-color:var(--ds-basic-color-brand-primary, #01426a)}:host([ondark]){--ds-auro-loader-color:var(--ds-basic-color-texticon-inverse, #ffffff)}:host([orbit])>span{--ds-auro-loader-background-color:transparent}:host([orbit])>span:nth-child(1){--ds-auro-loader-border-color:currentcolor;opacity:.25}:host([orbit])>span:nth-child(2){--ds-auro-loader-border-color:currentcolor;border-right-color:transparent;border-bottom-color:transparent;border-left-color:transparent}`;
|
|
2951
|
+
|
|
2952
|
+
var tokensCss$1 = i$5`:host{--ds-auro-loader-background-color:currentcolor;--ds-auro-loader-border-color:currentcolor;--ds-auro-loader-color:currentcolor}`;
|
|
2953
|
+
|
|
2954
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2955
|
+
// See LICENSE in the project root for license information.
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
class AuroLoader extends i$2 {
|
|
2959
|
+
constructor() {
|
|
2960
|
+
super();
|
|
2961
|
+
|
|
2962
|
+
/**
|
|
2963
|
+
* @private
|
|
2964
|
+
*/
|
|
2965
|
+
this.keys = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* @private
|
|
2969
|
+
*/
|
|
2970
|
+
this.mdCount = 3;
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* @private
|
|
2974
|
+
*/
|
|
2975
|
+
this.smCount = 2;
|
|
2976
|
+
|
|
2977
|
+
/**
|
|
2978
|
+
* @private
|
|
2979
|
+
*/
|
|
2980
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
2981
|
+
|
|
2982
|
+
this.orbit = false;
|
|
2983
|
+
this.ringworm = false;
|
|
2984
|
+
this.laser = false;
|
|
2985
|
+
this.pulse = false;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
// function to define props used within the scope of this component
|
|
2989
|
+
static get properties() {
|
|
2990
|
+
return {
|
|
2991
|
+
|
|
2992
|
+
/**
|
|
2993
|
+
* Sets loader to laser type.
|
|
2994
|
+
*/
|
|
2995
|
+
laser: {
|
|
2996
|
+
type: Boolean,
|
|
2997
|
+
reflect: true
|
|
2998
|
+
},
|
|
2999
|
+
|
|
3000
|
+
/**
|
|
3001
|
+
* Sets loader to orbit type.
|
|
3002
|
+
*/
|
|
3003
|
+
orbit: {
|
|
3004
|
+
type: Boolean,
|
|
3005
|
+
reflect: true
|
|
3006
|
+
},
|
|
3007
|
+
|
|
3008
|
+
/**
|
|
3009
|
+
* Sets loader to pulse type.
|
|
3010
|
+
*/
|
|
3011
|
+
pulse: {
|
|
3012
|
+
type: Boolean,
|
|
3013
|
+
reflect: true
|
|
3014
|
+
},
|
|
3015
|
+
|
|
3016
|
+
/**
|
|
3017
|
+
* Sets loader to ringworm type.
|
|
3018
|
+
*/
|
|
3019
|
+
ringworm: {
|
|
3020
|
+
type: Boolean,
|
|
3021
|
+
reflect: true
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
static get styles() {
|
|
3027
|
+
return [
|
|
3028
|
+
i$5`${styleCss$2}`,
|
|
3029
|
+
i$5`${colorCss$1}`,
|
|
3030
|
+
i$5`${tokensCss$1}`
|
|
3031
|
+
];
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
/**
|
|
3035
|
+
* This will register this element with the browser.
|
|
3036
|
+
* @param {string} [name="auro-loader"] - The name of element that you want to register to.
|
|
3037
|
+
*
|
|
3038
|
+
* @example
|
|
3039
|
+
* AuroLoader.register("custom-loader") // this will register this element to <custom-loader/>
|
|
3040
|
+
*
|
|
3041
|
+
*/
|
|
3042
|
+
static register(name = "auro-loader") {
|
|
3043
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroLoader);
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
firstUpdated() {
|
|
3047
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
3048
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-loader');
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
connectedCallback() {
|
|
3052
|
+
super.connectedCallback();
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
/**
|
|
3056
|
+
* @private
|
|
3057
|
+
* @returns {Array} Numbered array for template map.
|
|
3058
|
+
*/
|
|
3059
|
+
defineTemplate() {
|
|
3060
|
+
let nodes = Array.from(Array(this.mdCount).keys());
|
|
3061
|
+
|
|
3062
|
+
if (this.orbit || this.laser) {
|
|
3063
|
+
nodes = Array.from(Array(this.smCount).keys());
|
|
3064
|
+
} else if (this.ringworm) {
|
|
3065
|
+
nodes = Array.from(Array(0).keys());
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
return nodes;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
// When using auroElement, use the following attribute and function when hiding content from screen readers.
|
|
3072
|
+
// aria-hidden="${this.hideAudible(this.hiddenAudible)}"
|
|
3073
|
+
|
|
3074
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
3075
|
+
render() {
|
|
3076
|
+
return x`
|
|
3077
|
+
${this.defineTemplate().map((idx) => x`
|
|
3078
|
+
<span part="element" class="loader node-${idx}"></span>
|
|
3079
|
+
`)}
|
|
3080
|
+
|
|
3081
|
+
<div class="no-animation">Loading...</div>
|
|
3082
|
+
|
|
3083
|
+
${this.ringworm ? x`
|
|
3084
|
+
<svg part="element" class="circular" viewBox="25 25 50 50">
|
|
3085
|
+
<circle class="path" cx="50" cy="50" r="20" fill="none"/>
|
|
3086
|
+
</svg>`
|
|
3087
|
+
: ``
|
|
3088
|
+
}
|
|
3089
|
+
`;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
var loaderVersion = '5.0.0';
|
|
3094
|
+
|
|
3095
|
+
/* eslint-disable max-lines, curly */
|
|
3096
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3097
|
+
// See LICENSE in the project root for license information.
|
|
3098
|
+
|
|
3099
|
+
|
|
3100
|
+
/**
|
|
3101
|
+
* @slot - Default slot for the text of the button.
|
|
3102
|
+
* @slot icon - Slot to provide auro-icon for the button.
|
|
3103
|
+
* @csspart button - Apply CSS to HTML5 button.
|
|
3104
|
+
* @csspart loader - Apply CSS to auro-loader.
|
|
3105
|
+
* @csspart text - Apply CSS to text slot.
|
|
3106
|
+
* @csspart icon - Apply CSS to icon slot.
|
|
3107
|
+
*/
|
|
3108
|
+
|
|
3109
|
+
/* eslint-disable lit/no-invalid-html, lit/binding-positions */
|
|
3110
|
+
|
|
3111
|
+
const ICON_ONLY_SHAPES = ['circle'];
|
|
3112
|
+
|
|
3113
|
+
/**
|
|
3114
|
+
* AuroButton is a custom element that provides a styled, accessible button with support for various states and form association.
|
|
3115
|
+
* It is designed to be flexible, supporting loading states, icon slots, and integration with HTML5 forms.
|
|
3116
|
+
* @property {'default', 'rounded', 'pill', 'circle'} shape - Defines the shape of the button.
|
|
3117
|
+
* @property {'xs', 'sm', 'md', 'lg', 'xl'} size - Defines the size of the button.
|
|
3118
|
+
* @property {'primary', 'secondary', 'tertiary', 'ghost', 'flat'} variant - Sets the button variant.
|
|
3119
|
+
* @property {'submit', 'reset', 'button'} type - The type of button. Matches HTML5 Button Spec.
|
|
3120
|
+
* @property {boolean} onDark - Indicates if the button is rendered in dark mode.
|
|
3121
|
+
*/
|
|
3122
|
+
class AuroButton extends AuroElement$1 {
|
|
3123
|
+
|
|
3124
|
+
/**
|
|
3125
|
+
* Enables form association for this element.
|
|
3126
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals
|
|
3127
|
+
* @returns {boolean} - Returns true to enable form association.
|
|
3128
|
+
*/
|
|
3129
|
+
static get formAssociated() {
|
|
3130
|
+
return true;
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
constructor() {
|
|
3134
|
+
super();
|
|
3135
|
+
this.autofocus = false;
|
|
3136
|
+
this.disabled = false;
|
|
3137
|
+
this.loading = false;
|
|
3138
|
+
this.size = "md";
|
|
3139
|
+
this.shape = "rounded";
|
|
3140
|
+
this.onDark = false;
|
|
3141
|
+
this.fluid = false;
|
|
3142
|
+
this.loadingText = this.loadingText || 'Loading...';
|
|
3143
|
+
|
|
3144
|
+
// Support for HTML5 forms
|
|
3145
|
+
if (typeof this.attachInternals === 'function') {
|
|
3146
|
+
this.internals = this.attachInternals();
|
|
3147
|
+
} else {
|
|
3148
|
+
this.internals = null;
|
|
3149
|
+
|
|
3150
|
+
// eslint-disable-next-line no-console
|
|
3151
|
+
console.warn('This browser does not support form association features. Some form-related functionality may not work as expected. Consider using a polyfill or handling click events manually.');
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* Generate unique names for dependency components.
|
|
3156
|
+
*/
|
|
3157
|
+
const versioning = new AuroDependencyVersioning();
|
|
3158
|
+
|
|
3159
|
+
/**
|
|
3160
|
+
* @private
|
|
3161
|
+
*/
|
|
3162
|
+
this.loaderTag = versioning.generateTag('auro-loader', loaderVersion, AuroLoader);
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
static get styles() {
|
|
3166
|
+
return [
|
|
3167
|
+
tokensCss$2,
|
|
3168
|
+
styleCss$3,
|
|
3169
|
+
colorCss$2,
|
|
3170
|
+
shapeSize
|
|
3171
|
+
];
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
static get properties() {
|
|
3175
|
+
return {
|
|
3176
|
+
|
|
3177
|
+
...super.properties,
|
|
3178
|
+
|
|
3179
|
+
/**
|
|
3180
|
+
* Override layout since it isn't used in this component.
|
|
3181
|
+
* @private
|
|
3182
|
+
*/
|
|
3183
|
+
layout: {
|
|
3184
|
+
type: Boolean,
|
|
3185
|
+
attribute: false,
|
|
3186
|
+
reflect: false
|
|
3187
|
+
},
|
|
3188
|
+
|
|
3189
|
+
/**
|
|
3190
|
+
* This Boolean attribute lets you specify that the button should have input focus when the page loads, unless overridden by the user.
|
|
3191
|
+
*/
|
|
3192
|
+
autofocus: {
|
|
3193
|
+
type: Boolean,
|
|
3194
|
+
reflect: true
|
|
3195
|
+
},
|
|
3196
|
+
|
|
3197
|
+
/**
|
|
3198
|
+
* If set to true, button will become disabled and not allow for interactions.
|
|
3199
|
+
*/
|
|
3200
|
+
disabled: {
|
|
3201
|
+
type: Boolean,
|
|
3202
|
+
reflect: true
|
|
3203
|
+
},
|
|
3204
|
+
|
|
3205
|
+
/**
|
|
3206
|
+
* Alters the shape of the button to be full width of its parent container.
|
|
3207
|
+
*/
|
|
3208
|
+
fluid: {
|
|
3209
|
+
type: Boolean,
|
|
3210
|
+
reflect: true
|
|
3211
|
+
},
|
|
3212
|
+
|
|
3213
|
+
/**
|
|
3214
|
+
* If set to true button text will be replaced with `auro-loader` and become disabled.
|
|
3215
|
+
*/
|
|
3216
|
+
loading: {
|
|
3217
|
+
type: Boolean,
|
|
3218
|
+
reflect: true
|
|
3219
|
+
},
|
|
3220
|
+
|
|
3221
|
+
/**
|
|
3222
|
+
* Sets custom loading text for the `aria-label` on a button in loading state. If not set, the default value of "Loading..." will be used.
|
|
3223
|
+
*/
|
|
3224
|
+
loadingText: {
|
|
3225
|
+
type: String
|
|
3226
|
+
},
|
|
3227
|
+
|
|
3228
|
+
/**
|
|
3229
|
+
* Populates `tabIndex` to define the focusable sequence in keyboard navigation.
|
|
3230
|
+
*/
|
|
3231
|
+
tIndex: {
|
|
3232
|
+
type: String,
|
|
3233
|
+
reflect: true
|
|
3234
|
+
},
|
|
3235
|
+
|
|
3236
|
+
/**
|
|
3237
|
+
* Sets title attribute. The information is most often shown as a tooltip text when the mouse moves over the element.
|
|
3238
|
+
*/
|
|
3239
|
+
title: {
|
|
3240
|
+
type: String,
|
|
3241
|
+
reflect: true
|
|
3242
|
+
},
|
|
3243
|
+
|
|
3244
|
+
/**
|
|
3245
|
+
* The type of the button. Possible values are: `submit`, `reset`, `button`.
|
|
3246
|
+
*/
|
|
3247
|
+
type: {
|
|
3248
|
+
type: String,
|
|
3249
|
+
reflect: true
|
|
3250
|
+
},
|
|
3251
|
+
|
|
3252
|
+
/**
|
|
3253
|
+
* Defines the value associated with the button which is submitted with the form data.
|
|
3254
|
+
*/
|
|
3255
|
+
value: {
|
|
3256
|
+
type: String,
|
|
3257
|
+
reflect: true
|
|
3258
|
+
},
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* Sets button variant option.
|
|
3262
|
+
* @default primary
|
|
3263
|
+
*/
|
|
3264
|
+
variant: {
|
|
3265
|
+
type: String,
|
|
3266
|
+
reflect: true
|
|
3267
|
+
},
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* This will register this element with the browser.
|
|
3273
|
+
* @param {string} [name="auro-button"] - The name of element that you want to register to.
|
|
3274
|
+
*
|
|
3275
|
+
* @example
|
|
3276
|
+
* AuroButton.register("custom-button") // this will register this element to <custom-button/>
|
|
3277
|
+
*
|
|
3278
|
+
*/
|
|
3279
|
+
static register(name = "auro-button") {
|
|
3280
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroButton);
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
/**
|
|
3284
|
+
* Internal method to apply focus to the HTML5 button.
|
|
3285
|
+
* @private
|
|
3286
|
+
* @returns {void}
|
|
3287
|
+
*/
|
|
3288
|
+
focus() {
|
|
3289
|
+
this.renderRoot.querySelector('button').focus();
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
/**
|
|
3293
|
+
* Submits the form that this button is associated with.
|
|
3294
|
+
* @private
|
|
3295
|
+
* @returns {void}
|
|
3296
|
+
*/
|
|
3297
|
+
surfaceSubmitEvent() {
|
|
3298
|
+
if (this.form) {
|
|
3299
|
+
this.form.requestSubmit();
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3303
|
+
/**
|
|
3304
|
+
* Returns the form element that this button is associated with.
|
|
3305
|
+
* @private
|
|
3306
|
+
* @returns {HTMLFormElement | null}
|
|
3307
|
+
*/
|
|
3308
|
+
get form() {
|
|
3309
|
+
return this.internals ? this.internals.form : null;
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
/**
|
|
3313
|
+
* @private
|
|
3314
|
+
* @returns {Boolean}
|
|
3315
|
+
*/
|
|
3316
|
+
get hideText() {
|
|
3317
|
+
return ICON_ONLY_SHAPES.includes(this.shape);
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
/**
|
|
3321
|
+
* Returns the current value of the projected `aria-label` attribute or undefined if not set.
|
|
3322
|
+
* @returns {string | undefined}
|
|
3323
|
+
* @private
|
|
3324
|
+
*/
|
|
3325
|
+
get currentAriaLabel() {
|
|
3326
|
+
if (!this.attributeWatcher) return undefined;
|
|
3327
|
+
|
|
3328
|
+
const ariaLabel = this.attributeWatcher.getObservedAttribute("aria-label");
|
|
3329
|
+
return ariaLabel || undefined;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
/**
|
|
3333
|
+
* Returns the current value of the projected `aria-labelledby` attribute or undefined if not set.
|
|
3334
|
+
* @returns {string | undefined}
|
|
3335
|
+
* @private
|
|
3336
|
+
*/
|
|
3337
|
+
get currentAriaLabelledBy() {
|
|
3338
|
+
if (!this.attributeWatcher) return undefined;
|
|
3339
|
+
|
|
3340
|
+
const ariaLabelledBy = this.attributeWatcher.getObservedAttribute("aria-labelledby");
|
|
3341
|
+
return ariaLabelledBy || undefined;
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
/**
|
|
3345
|
+
* Renders the default layout for the button.
|
|
3346
|
+
* @returns {TemplateResult}
|
|
3347
|
+
* @private
|
|
3348
|
+
*/
|
|
3349
|
+
renderLayoutDefault() {
|
|
3350
|
+
const classes = {
|
|
3351
|
+
"util_insetLg--squish": true,
|
|
3352
|
+
"auro-button": true,
|
|
3353
|
+
wrapper: true,
|
|
3354
|
+
loading: this.loading,
|
|
3355
|
+
};
|
|
3356
|
+
|
|
3357
|
+
return u`
|
|
3358
|
+
<button
|
|
3359
|
+
part="button"
|
|
3360
|
+
aria-label="${o(this.loading ? this.loadingText : this.currentAriaLabel || undefined)}"
|
|
3361
|
+
aria-labelledby="${o(this.loading ? undefined : this.currentAriaLabelledBy || undefined)}"
|
|
3362
|
+
tabIndex="${o(this.tIndex)}"
|
|
3363
|
+
?autofocus="${this.autofocus}"
|
|
3364
|
+
class="${e(classes)}"
|
|
3365
|
+
?disabled="${this.disabled || this.loading}"
|
|
3366
|
+
?onDark="${this.onDark}"
|
|
3367
|
+
title="${o(this.title ? this.title : undefined)}"
|
|
3368
|
+
name="${o(this.name ? this.name : undefined)}"
|
|
3369
|
+
type="${o(this.type ? this.type : undefined)}"
|
|
3370
|
+
variant="${o(this.variant ? this.variant : undefined)}"
|
|
3371
|
+
.value="${o(this.value ? this.value : undefined)}"
|
|
3372
|
+
@click="${this.type === 'submit' ? this.surfaceSubmitEvent : undefined}"
|
|
3373
|
+
>
|
|
3374
|
+
${o(this.loading ? u`<${this.loaderTag} pulse part="loader"></${this.loaderTag}>` : undefined)}
|
|
3375
|
+
|
|
3376
|
+
<span class="contentWrapper">
|
|
3377
|
+
<span class="textSlot" part="text">
|
|
3378
|
+
${this.hideText ? undefined : u`<slot></slot>`}
|
|
3379
|
+
</span>
|
|
3380
|
+
|
|
3381
|
+
<span part="icon">
|
|
3382
|
+
<slot name="icon"></slot>
|
|
3383
|
+
</span>
|
|
3384
|
+
</span>
|
|
3385
|
+
</button>
|
|
3386
|
+
`;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
/**
|
|
3390
|
+
* Renders the layout of the button
|
|
3391
|
+
* @returns {TemplateResult}
|
|
3392
|
+
* @private
|
|
3393
|
+
*/
|
|
3394
|
+
renderLayout() {
|
|
3395
|
+
return this.renderLayoutDefault();
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
var buttonVersion = "9.3.3";
|
|
3400
|
+
|
|
3401
|
+
var chevronLeft = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"chevron-left__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"chevron-left__desc\">Directional indicator; left.</desc><path d=\"m14.395 6.345.084.073a.75.75 0 0 1 .072.977l-.072.084-4.47 4.47 4.47 4.47a.75.75 0 0 1 .072.976l-.072.084a.75.75 0 0 1-.977.072l-.084-.072-4.823-4.823a1 1 0 0 1 0-1.415l4.823-4.823a.75.75 0 0 1 .977-.073\"/></svg>"};
|
|
3402
|
+
|
|
3403
|
+
var chevronRight = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"chevron-right__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"chevron-right__desc\">Directional indicator; right.</desc><path d=\"m9.605 17.551-.084-.072a.75.75 0 0 1-.072-.977l.072-.084 4.47-4.47-4.47-4.47a.75.75 0 0 1-.072-.976l.072-.084a.75.75 0 0 1 .977-.073l.084.073 4.823 4.823a1 1 0 0 1 0 1.415l-4.823 4.823a.75.75 0 0 1-.977.072\"/></svg>"};
|
|
3404
|
+
|
|
3405
|
+
var pause = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"pause__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"pause__desc\">two vertical parallel lines</desc><path fill-rule=\"evenodd\" d=\"M6 .5A1.5 1.5 0 0 1 7.5 2v20a1.5 1.5 0 0 1-3 0V2A1.5 1.5 0 0 1 6 .5m12 0A1.5 1.5 0 0 1 19.5 2v20a1.5 1.5 0 0 1-3 0V2A1.5 1.5 0 0 1 18 .5\" clip-rule=\"evenodd\"/></svg>"};
|
|
3406
|
+
|
|
3407
|
+
var play = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"play-filled__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"play-filled__desc\">solid triangle pointing right</desc><path fill-rule=\"evenodd\" d=\"m6.977 1.02.348.163 15.555 8.889c1.369.782 1.483 2.656.342 3.62l-.342.239-15.555 8.888c-1.368.782-3.044-.07-3.293-1.547L4 20.89V3.112C4 1.537 5.57.505 6.977 1.021\" clip-rule=\"evenodd\"/></svg>"};
|
|
3408
|
+
|
|
3409
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3410
|
+
// See LICENSE in the project root for license information.
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
/**
|
|
3414
|
+
* @attr {Boolean} hidden - If present, the component will be hidden both visually and from screen readers
|
|
3415
|
+
* @attr {Boolean} hiddenVisually - If present, the component will be hidden visually, but still read by screen readers
|
|
3416
|
+
* @attr {Boolean} hiddenAudible - If present, the component will be hidden from screen readers, but seen visually
|
|
3417
|
+
*/
|
|
3418
|
+
|
|
3419
|
+
class AuroElement extends i$2 {
|
|
3420
|
+
|
|
3421
|
+
// function to define props used within the scope of this component
|
|
3422
|
+
static get properties() {
|
|
3423
|
+
return {
|
|
3424
|
+
hidden: { type: Boolean,
|
|
3425
|
+
reflect: true },
|
|
3426
|
+
hiddenVisually: { type: Boolean,
|
|
3427
|
+
reflect: true },
|
|
3428
|
+
hiddenAudible: { type: Boolean,
|
|
3429
|
+
reflect: true },
|
|
3430
|
+
};
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
/**
|
|
3434
|
+
* @private Function that determines state of aria-hidden
|
|
3435
|
+
*/
|
|
3436
|
+
hideAudible(value) {
|
|
3437
|
+
if (value) {
|
|
3438
|
+
return 'true'
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
return 'false'
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
var error = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"error__desc\" class=\"ico_squareLarge\" data-deprecated=\"true\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"error__desc\">Error alert indicator.</desc><path d=\"m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583\"/></svg>"};
|
|
3446
|
+
|
|
3447
|
+
/* eslint-disable no-underscore-dangle, jsdoc/no-undefined-types, jsdoc/require-param-description */
|
|
3448
|
+
|
|
3449
|
+
const _fetchMap = new Map();
|
|
3450
|
+
|
|
3451
|
+
/**
|
|
3452
|
+
* A callback to parse Response body.
|
|
3453
|
+
*
|
|
3454
|
+
* @callback ResponseParser
|
|
3455
|
+
* @param {Fetch.Response} response
|
|
3456
|
+
* @returns {Promise}
|
|
3457
|
+
*/
|
|
3458
|
+
|
|
3459
|
+
/**
|
|
3460
|
+
* A minimal in-memory map to de-duplicate Fetch API media requests.
|
|
3461
|
+
*
|
|
3462
|
+
* @param {String} uri
|
|
3463
|
+
* @param {Object} [options={}]
|
|
3464
|
+
* @param {ResponseParser} [options.responseParser=(response) => response.text()]
|
|
3465
|
+
* @returns {Promise}
|
|
3466
|
+
*/
|
|
3467
|
+
const cacheFetch = (uri, options = {}) => {
|
|
3468
|
+
const responseParser = options.responseParser || ((response) => response.text());
|
|
3469
|
+
if (!_fetchMap.has(uri)) {
|
|
3470
|
+
_fetchMap.set(uri, fetch(uri).then(responseParser));
|
|
3471
|
+
}
|
|
3472
|
+
return _fetchMap.get(uri);
|
|
3473
|
+
};
|
|
3474
|
+
|
|
3475
|
+
var styleCss$1 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, 0.75rem))}:host{color:currentColor;vertical-align:middle;line-height:1;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem) !important;width:var(--ds-auro-icon-size, 1.5rem) !important;height:var(--ds-auro-icon-size, 1.5rem) !important}.componentWrapper{display:flex}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.labelWrapper{margin-left:var(--ds-size-50, 0.25rem);line-height:1.8}`;
|
|
3476
|
+
|
|
3477
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3478
|
+
// See LICENSE in the project root for license information.
|
|
3479
|
+
|
|
3480
|
+
|
|
3481
|
+
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
3482
|
+
/**
|
|
3483
|
+
* @slot - Hidden from visibility, used for a11y if icon description is needed
|
|
3484
|
+
*/
|
|
3485
|
+
|
|
3486
|
+
// build the component class
|
|
3487
|
+
class BaseIcon extends AuroElement {
|
|
3488
|
+
constructor() {
|
|
3489
|
+
super();
|
|
3490
|
+
this.onDark = false;
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
// function to define props used within the scope of this component
|
|
3494
|
+
static get properties() {
|
|
3495
|
+
return {
|
|
3496
|
+
...super.properties,
|
|
3497
|
+
|
|
3498
|
+
/**
|
|
3499
|
+
* Set value for on-dark version of auro-icon.
|
|
3500
|
+
*/
|
|
3501
|
+
onDark: {
|
|
3502
|
+
type: Boolean,
|
|
3503
|
+
reflect: true
|
|
3504
|
+
},
|
|
3505
|
+
|
|
3506
|
+
/**
|
|
3507
|
+
* @private
|
|
3508
|
+
*/
|
|
3509
|
+
svg: {
|
|
3510
|
+
attribute: false,
|
|
3511
|
+
reflect: true
|
|
3512
|
+
}
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
static get styles() {
|
|
3517
|
+
return i$5`
|
|
3518
|
+
${styleCss$1}
|
|
3519
|
+
`;
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
/**
|
|
3523
|
+
* Async function to fetch requested icon from npm CDN.
|
|
3524
|
+
* @private
|
|
3525
|
+
* @param {string} category - Icon category.
|
|
3526
|
+
* @param {string} name - Icon name.
|
|
3527
|
+
* @returns {SVGElement} DOM - Ready HTML to be appended.
|
|
3528
|
+
*/
|
|
3529
|
+
async fetchIcon(category, name) {
|
|
3530
|
+
let iconHTML = '';
|
|
3531
|
+
|
|
3532
|
+
if (category === 'logos') {
|
|
3533
|
+
iconHTML = await cacheFetch(`${this.uri}/${category}/${name}.svg`);
|
|
3534
|
+
} else {
|
|
3535
|
+
iconHTML = await cacheFetch(`${this.uri}/icons/${category}/${name}.svg`);
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
const dom = new DOMParser().parseFromString(iconHTML, 'text/html');
|
|
3539
|
+
|
|
3540
|
+
return dom.body.querySelector('svg');
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
// lifecycle function
|
|
3544
|
+
async firstUpdated() {
|
|
3545
|
+
if (!this.customSvg) {
|
|
3546
|
+
const svg = await this.fetchIcon(this.category, this.name);
|
|
3547
|
+
|
|
3548
|
+
if (svg) {
|
|
3549
|
+
this.svg = svg;
|
|
3550
|
+
} else if (!svg) {
|
|
3551
|
+
const penDOM = new DOMParser().parseFromString(error.svg, 'text/html');
|
|
3552
|
+
|
|
3553
|
+
this.svg = penDOM.body.firstChild;
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
var tokensCss = i$5`:host{--ds-auro-icon-color:var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color:#02426D;--ds-auro-icon-size:var(--ds-size-300, 1.5rem)}`;
|
|
3560
|
+
|
|
3561
|
+
var colorCss = i$5`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]){--ds-auro-icon-color:var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]){--ds-auro-icon-color:var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]){--ds-auro-icon-color:var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]){--ds-auro-icon-color:var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]){--ds-auro-icon-color:var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]){--ds-auro-icon-color:var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]){--ds-auro-icon-color:var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]){--ds-auro-icon-color:var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]){--ds-auro-icon-color:var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]){--ds-auro-icon-color:var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]){--ds-auro-icon-color:var(--ds-advanced-color-state-error-inverse, #f9a4a8)}`;
|
|
3562
|
+
|
|
3563
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3564
|
+
// See LICENSE in the project root for license information.
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
class AuroIcon extends BaseIcon {
|
|
3568
|
+
constructor() {
|
|
3569
|
+
super();
|
|
3570
|
+
|
|
3571
|
+
this.variant = undefined;
|
|
3572
|
+
this.privateDefaults();
|
|
3573
|
+
}
|
|
3574
|
+
|
|
3575
|
+
/**
|
|
3576
|
+
* Internal Defaults.
|
|
3577
|
+
* @private
|
|
3578
|
+
* @returns {void}
|
|
3579
|
+
*/
|
|
3580
|
+
privateDefaults() {
|
|
3581
|
+
this.uri = 'https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist';
|
|
3582
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
// function to define props used within the scope of this component
|
|
3586
|
+
static get properties() {
|
|
3587
|
+
return {
|
|
3588
|
+
...super.properties,
|
|
3589
|
+
|
|
3590
|
+
/**
|
|
3591
|
+
* Set aria-hidden value. Default is `true`. Option is `false`.
|
|
3592
|
+
*/
|
|
3593
|
+
ariaHidden: {
|
|
3594
|
+
type: String,
|
|
3595
|
+
reflect: true
|
|
3596
|
+
},
|
|
3597
|
+
|
|
3598
|
+
/**
|
|
3599
|
+
* The category of the icon you are looking for. See https://auro.alaskaair.com/icons/usage.
|
|
3600
|
+
*/
|
|
3601
|
+
category: {
|
|
3602
|
+
type: String,
|
|
3603
|
+
reflect: true
|
|
3604
|
+
},
|
|
3605
|
+
|
|
3606
|
+
/**
|
|
3607
|
+
* Allows custom color to be set.
|
|
3608
|
+
*/
|
|
3609
|
+
customColor: {
|
|
3610
|
+
type: Boolean
|
|
3611
|
+
},
|
|
3612
|
+
|
|
3613
|
+
/**
|
|
3614
|
+
* When true, auro-icon will render a custom SVG inside the default slot.
|
|
3615
|
+
*/
|
|
3616
|
+
customSvg: {
|
|
3617
|
+
type: Boolean
|
|
3618
|
+
},
|
|
3619
|
+
|
|
3620
|
+
/**
|
|
3621
|
+
* Exposes content in slot as icon label.
|
|
3622
|
+
*/
|
|
3623
|
+
label: {
|
|
3624
|
+
type: Boolean,
|
|
3625
|
+
reflect: true
|
|
3626
|
+
},
|
|
3627
|
+
|
|
3628
|
+
/**
|
|
3629
|
+
* The name of the icon you are looking for without the file extension. See https://auro.alaskaair.com/icons/usage.
|
|
3630
|
+
*/
|
|
3631
|
+
name: {
|
|
3632
|
+
type: String,
|
|
3633
|
+
reflect: true
|
|
3634
|
+
},
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
* The style of the icon. The accepted variants are `accent1`, `disabled`, `muted`, `statusDefault`, `statusInfo`, `statusSuccess`, `statusWarning`, `statusError`, `statusInfoSubtle`, `statusSuccessSubtle`, `statusWarningSubtle`, `statusErrorSubtle`, `fareBasicEconomy`, `fareBusiness`, `fareEconomy`, `fareFirst`, `farePremiumEconomy`, `tierOneWorldEmerald`, `tierOneWorldSapphire`, `tierOneWorldRuby`.
|
|
3638
|
+
*/
|
|
3639
|
+
variant: {
|
|
3640
|
+
type: String,
|
|
3641
|
+
reflect: true
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
static get styles() {
|
|
3647
|
+
return [
|
|
3648
|
+
super.styles,
|
|
3649
|
+
i$5`${tokensCss}`,
|
|
3650
|
+
i$5`${styleCss$1}`,
|
|
3651
|
+
i$5`${colorCss}`
|
|
3652
|
+
];
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
/**
|
|
3656
|
+
* This will register this element with the browser.
|
|
3657
|
+
* @param {string} [name="auro-icon"] - The name of element that you want to register to.
|
|
3658
|
+
*
|
|
3659
|
+
* @example
|
|
3660
|
+
* AuroIcon.register("custom-icon") // this will register this element to <custom-icon/>
|
|
3661
|
+
*
|
|
3662
|
+
*/
|
|
3663
|
+
static register(name = "auro-icon") {
|
|
3664
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroIcon);
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
connectedCallback() {
|
|
3668
|
+
super.connectedCallback();
|
|
3669
|
+
|
|
3670
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
3671
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-icon');
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
/**
|
|
3675
|
+
* @private
|
|
3676
|
+
* @returns {void} Exposes CSS parts for styling from parent components.
|
|
3677
|
+
*/
|
|
3678
|
+
exposeCssParts() {
|
|
3679
|
+
this.setAttribute('exportparts', 'svg:iconSvg');
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
async firstUpdated() {
|
|
3683
|
+
await super.firstUpdated();
|
|
3684
|
+
|
|
3685
|
+
/**
|
|
3686
|
+
* icons provide a description for screen readers. Icon only instances Auro-button
|
|
3687
|
+
* depend on this description to provide context for the user using a screen reader.
|
|
3688
|
+
* Removes the SVG description for screen reader if ariaHidden is set to true.
|
|
3689
|
+
*/
|
|
3690
|
+
if (this.hasAttribute('ariaHidden') && this.svg) {
|
|
3691
|
+
const svgDesc = this.svg.querySelector('desc');
|
|
3692
|
+
|
|
3693
|
+
if (svgDesc) {
|
|
3694
|
+
svgDesc.remove();
|
|
3695
|
+
this.svg.removeAttribute('aria-labelledby');
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
3701
|
+
render() {
|
|
3702
|
+
const labelClasses = {
|
|
3703
|
+
'labelWrapper': true,
|
|
3704
|
+
'util_displayHiddenVisually': !this.label
|
|
3705
|
+
};
|
|
3706
|
+
|
|
3707
|
+
const svgClasses = {
|
|
3708
|
+
'svgWrapper': true,
|
|
3709
|
+
};
|
|
3710
|
+
|
|
3711
|
+
return x`
|
|
3712
|
+
<div class="componentWrapper">
|
|
3713
|
+
<div
|
|
3714
|
+
class="${e(svgClasses)}"
|
|
3715
|
+
title="${o(this.title || undefined)}">
|
|
3716
|
+
<span aria-hidden="${o(this.ariaHidden || true)}" part="svg">
|
|
3717
|
+
${this.customSvg ? x`
|
|
3718
|
+
<slot name="svg"></slot>
|
|
3719
|
+
` : x`
|
|
3720
|
+
${this.svg}
|
|
3721
|
+
`
|
|
3722
|
+
}
|
|
3723
|
+
</span>
|
|
3724
|
+
</div>
|
|
3725
|
+
|
|
3726
|
+
<div class="${e(labelClasses)}">
|
|
3727
|
+
<slot></slot>
|
|
3728
|
+
</div>
|
|
3729
|
+
</div>
|
|
3730
|
+
`;
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
var iconVersion = "8.0.2";
|
|
3735
|
+
|
|
3736
|
+
var styleCss = i$5`:focus:not(:focus-visible){outline:3px solid transparent}:host{--border-size: 6px;--border-radius: 24px}.container{display:flex;width:100%;flex-direction:column;align-items:flex-start}.slideshow-wrapper{position:relative;width:100%;display:flex;justify-content:start;align-items:center;overflow:hidden;padding:var(--border-size)}.embla{max-width:100%;margin:0;--slide-size: 100%}.embla__container{display:flex}.embla__slide{transform:translateZ(0);flex:0 0 var(--slide-size);min-width:0;border-radius:var(--border-radius);margin-right:1rem;box-sizing:border-box;overflow:hidden}.embla__slide:focus-visible{outline:unset;box-shadow:0 0 0 2px #fff,0 0 0 var(--border-size) var(--ds-advanced-color-state-focused, #01426a)}.embla__slide:not(.active):not(.in-view){filter:brightness(30%)}.scroll-prev,.scroll-next{position:absolute;display:none;top:50%;transform:translateY(-50%);z-index:10;--ds-auro-button-container-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-button-container-image: var(--ds-advanced-color-state-focused, #01426a);color:var(--ds-advanced-color-shared-background, #ffffff)}.scroll-prev:hover,.scroll-next:hover{--ds-auro-button-container-color: var(--ds-advanced-color-button-primary-background-inverse-hover, #ebf3f9)}.scroll-prev{left:8px}.scroll-next{right:8px}.slideshow-wrapper:hover .scroll-prev,.slideshow-wrapper:hover .scroll-next{display:block}.pagination-container{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;width:100%;margin-top:40px;gap:14px}.embla__dots{display:flex;gap:16px}.embla__dot{width:12px;height:12px;border-radius:50%;border:none;background-color:var(--ds-advanced-color-button-primary-background-inactive, #cfe0ef);position:relative;cursor:pointer}.embla__dot:hover:not(.embla__dot--selected){background-color:var(--ds-advanced-color-button-primary-background-inactive-hover, #89b2d4)}.embla__dot:before{content:"";position:absolute;width:24px;height:24px;cursor:pointer;top:50%;left:50%;transform:translate(-50%,-50%)}.embla__dot--selected{width:52px;height:12px;border-radius:1.8rem;background-color:var(--ds-advanced-color-button-primary-background, #01426a)}.embla__dot--selected:before{width:64px}.embla__progress{border-radius:1.8rem;border:none;background-color:var(--ds-advanced-color-button-primary-background-inactive, #cfe0ef);position:relative;align-self:center;height:12px;width:56px;max-width:90%;overflow:hidden;cursor:pointer}.embla__progress:hover{background-color:var(--ds-advanced-color-button-primary-background-inactive-hover, #89b2d4)}.embla__progress__bar{border-radius:inherit;background-color:var(--ds-advanced-color-button-primary-background, #01426a);position:absolute;width:100%;top:0;bottom:0;left:-100%}.embla__progress{justify-self:center;transition:opacity .3s ease-in-out}.embla__progress__bar{animation-name:autoplay-progress;animation-timing-function:linear;animation-iteration-count:1;animation-play-state:running}.embla__progress--paused .embla__progress__bar{animation-play-state:paused}@keyframes autoplay-progress{0%{transform:translateZ(0)}to{transform:translate3d(100%,0,0)}}
|
|
3737
|
+
`;
|
|
3738
|
+
|
|
3739
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3740
|
+
// See LICENSE in the project root for license information.
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
class AuroSlideshow extends i$2 {
|
|
3744
|
+
constructor() {
|
|
3745
|
+
super();
|
|
3746
|
+
|
|
3747
|
+
this.autoplay = false;
|
|
3748
|
+
this.delay = 7000;
|
|
3749
|
+
|
|
3750
|
+
this.autoScroll = false;
|
|
3751
|
+
this.scrollSpeed = 1;
|
|
3752
|
+
this.startDelay = 1000;
|
|
3753
|
+
|
|
3754
|
+
this.playOnInit = false;
|
|
3755
|
+
this.loop = false;
|
|
3756
|
+
this.navigation = false;
|
|
3757
|
+
this.pagination = false;
|
|
3758
|
+
|
|
3759
|
+
this.playLabel = this.playLabel || "Play slideshow";
|
|
3760
|
+
this.pauseLabel = this.pauseLabel || "Pause slideshow";
|
|
3761
|
+
|
|
3762
|
+
/** @private */
|
|
3763
|
+
this.playBtnLabel = this.playLabel;
|
|
3764
|
+
|
|
3765
|
+
/** @private */
|
|
3766
|
+
this.isPlaying = false;
|
|
3767
|
+
|
|
3768
|
+
/** @private */
|
|
3769
|
+
this.embla = null;
|
|
3770
|
+
|
|
3771
|
+
/** @private */
|
|
3772
|
+
this.slides = [];
|
|
3773
|
+
|
|
3774
|
+
const versioning = new AuroDependencyVersioning$1();
|
|
3775
|
+
|
|
3776
|
+
/** @private */
|
|
3777
|
+
this.buttonTag = versioning.generateTag(
|
|
3778
|
+
"auro-button",
|
|
3779
|
+
buttonVersion,
|
|
3780
|
+
AuroButton,
|
|
3781
|
+
);
|
|
3782
|
+
|
|
3783
|
+
/** @private */
|
|
3784
|
+
this.iconTag = versioning.generateTag("auro-icon", iconVersion, AuroIcon);
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
/**
|
|
3788
|
+
* Registers the custom element with the browser.
|
|
3789
|
+
* @param {string} [name="auro-slideshow"] - Custom element name to register.
|
|
3790
|
+
* @example
|
|
3791
|
+
* AuroSlideshow.register("custom-slideshow") // registers <custom-slideshow/>
|
|
3792
|
+
*/
|
|
3793
|
+
static register(name = "auro-slideshow") {
|
|
3794
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroSlideshow);
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
static get styles() {
|
|
3798
|
+
return [styleCss];
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3801
|
+
static get properties() {
|
|
3802
|
+
return {
|
|
3803
|
+
/**
|
|
3804
|
+
* If true, the slideshow will play automatically.
|
|
3805
|
+
*/
|
|
3806
|
+
autoplay: {
|
|
3807
|
+
type: Boolean,
|
|
3808
|
+
reflect: true,
|
|
3809
|
+
},
|
|
3810
|
+
/**
|
|
3811
|
+
* If true, the slideshow will scroll continuously.
|
|
3812
|
+
*/
|
|
3813
|
+
autoScroll: {
|
|
3814
|
+
type: Boolean,
|
|
3815
|
+
reflect: true,
|
|
3816
|
+
},
|
|
3817
|
+
/**
|
|
3818
|
+
* If true, the slideshow will start playing automatically on page load.
|
|
3819
|
+
*/
|
|
3820
|
+
playOnInit: {
|
|
3821
|
+
type: Boolean,
|
|
3822
|
+
reflect: true,
|
|
3823
|
+
},
|
|
3824
|
+
/**
|
|
3825
|
+
* Slide duration in milliseconds.
|
|
3826
|
+
*/
|
|
3827
|
+
delay: {
|
|
3828
|
+
type: Number,
|
|
3829
|
+
reflect: true,
|
|
3830
|
+
},
|
|
3831
|
+
/**
|
|
3832
|
+
* Number of pixels auto scroll should advance per frame.
|
|
3833
|
+
*/
|
|
3834
|
+
scrollSpeed: {
|
|
3835
|
+
type: Number,
|
|
3836
|
+
reflect: true,
|
|
3837
|
+
},
|
|
3838
|
+
/**
|
|
3839
|
+
* Delay in milliseconds before the auto scroll starts.
|
|
3840
|
+
*/
|
|
3841
|
+
startDelay: {
|
|
3842
|
+
type: Number,
|
|
3843
|
+
reflect: true,
|
|
3844
|
+
},
|
|
3845
|
+
/**
|
|
3846
|
+
* The aria-label for the play button.
|
|
3847
|
+
* @default Play slideshow
|
|
3848
|
+
*/
|
|
3849
|
+
playLabel: {
|
|
3850
|
+
type: String,
|
|
3851
|
+
reflect: true,
|
|
3852
|
+
},
|
|
3853
|
+
/**
|
|
3854
|
+
* The aria-label for the pause button.
|
|
3855
|
+
* @default Pause slideshow
|
|
3856
|
+
*/
|
|
3857
|
+
pauseLabel: {
|
|
3858
|
+
type: String,
|
|
3859
|
+
reflect: true,
|
|
3860
|
+
},
|
|
3861
|
+
/**
|
|
3862
|
+
* If true, the slideshow will loop back to the first slide after reaching the last slide.
|
|
3863
|
+
*/
|
|
3864
|
+
loop: {
|
|
3865
|
+
type: Boolean,
|
|
3866
|
+
reflect: true,
|
|
3867
|
+
},
|
|
3868
|
+
/**
|
|
3869
|
+
* If true, the slideshow will display navigation arrows for previous and next slides when the slide container is hovered.
|
|
3870
|
+
*/
|
|
3871
|
+
navigation: {
|
|
3872
|
+
type: Boolean,
|
|
3873
|
+
reflect: true,
|
|
3874
|
+
},
|
|
3875
|
+
/**
|
|
3876
|
+
* If true, the slideshow will display pagination dots for each slide. If autoplay is on, the active dot will also show a progress bar.
|
|
3877
|
+
*/
|
|
3878
|
+
pagination: {
|
|
3879
|
+
type: Boolean,
|
|
3880
|
+
reflect: true,
|
|
3881
|
+
},
|
|
3882
|
+
/**
|
|
3883
|
+
* @private
|
|
3884
|
+
*/
|
|
3885
|
+
isPlaying: {
|
|
3886
|
+
type: Boolean,
|
|
3887
|
+
},
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
get _playBtn() {
|
|
3892
|
+
return this.shadowRoot.querySelector(".play-pause");
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
get _dotsNode() {
|
|
3896
|
+
return this.shadowRoot.querySelector(".embla__dots");
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
get _progressNode() {
|
|
3900
|
+
return this.shadowRoot.querySelector(".embla__progress");
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
/** @private */
|
|
3904
|
+
initializeEmbla() {
|
|
3905
|
+
const emblaNode = this.shadowRoot.querySelector(".embla");
|
|
3906
|
+
const options = { loop: this.loop, align: "start" };
|
|
3907
|
+
|
|
3908
|
+
const classNamesOptions = {
|
|
3909
|
+
snapped: "active",
|
|
3910
|
+
inView: "in-view",
|
|
3911
|
+
loop: "",
|
|
3912
|
+
draggable: "",
|
|
3913
|
+
dragging: "",
|
|
3914
|
+
};
|
|
3915
|
+
|
|
3916
|
+
const autoplayOptions = {
|
|
3917
|
+
playOnInit: this.playOnInit,
|
|
3918
|
+
delay: this.delay,
|
|
3919
|
+
stopOnMouseEnter: true,
|
|
3920
|
+
};
|
|
3921
|
+
|
|
3922
|
+
const autoscrollOptions = {
|
|
3923
|
+
playOnInit: this.playOnInit,
|
|
3924
|
+
speed: this.scrollSpeed,
|
|
3925
|
+
startDelay: this.startDelay,
|
|
3926
|
+
stopOnMouseEnter: true,
|
|
3927
|
+
};
|
|
3928
|
+
|
|
3929
|
+
const plugins = [ClassNames(classNamesOptions)];
|
|
3930
|
+
|
|
3931
|
+
// Autoplay and AutoScroll cannot be used together.
|
|
3932
|
+
if (this.autoplay) {
|
|
3933
|
+
plugins.push(Autoplay(autoplayOptions));
|
|
3934
|
+
}
|
|
3935
|
+
if (this.autoScroll) {
|
|
3936
|
+
plugins.push(AutoScroll(autoscrollOptions));
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
// Attach slides to the Embla instance
|
|
3940
|
+
const emblaContainer = this.shadowRoot.querySelector(".embla__container");
|
|
3941
|
+
emblaContainer.replaceChildren(...this.slides);
|
|
3942
|
+
|
|
3943
|
+
// Initialize Embla instance
|
|
3944
|
+
this.embla = EmblaCarousel(emblaNode, options, plugins);
|
|
3945
|
+
|
|
3946
|
+
if (this.pagination) {
|
|
3947
|
+
this.addDotBtnsAndClickHandlers(
|
|
3948
|
+
this.embla,
|
|
3949
|
+
this._dotsNode,
|
|
3950
|
+
this.onNavButtonClick,
|
|
3951
|
+
);
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
if (this.autoplay) {
|
|
3955
|
+
this.addAutoPlayBtnListener(this.embla, this._playBtn);
|
|
3956
|
+
this.embla
|
|
3957
|
+
.on("autoplay:stop", () => {
|
|
3958
|
+
this.isPlaying = false;
|
|
3959
|
+
})
|
|
3960
|
+
.on("autoplay:play", () => {
|
|
3961
|
+
this.isPlaying = true;
|
|
3962
|
+
});
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
if (this.autoScroll) {
|
|
3966
|
+
this.addAutoScrollBtnListener(this.embla, this._playBtn);
|
|
3967
|
+
this.embla
|
|
3968
|
+
.on("autoScroll:stop", () => {
|
|
3969
|
+
this.isPlaying = false;
|
|
3970
|
+
})
|
|
3971
|
+
.on("autoScroll:play", () => {
|
|
3972
|
+
this.isPlaying = true;
|
|
3973
|
+
});
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
firstUpdated() {
|
|
3978
|
+
this.updateSlides();
|
|
3979
|
+
this.initializeEmbla();
|
|
3980
|
+
|
|
3981
|
+
// add event listener to embla instance to toggle tabindex on active slide whenever slide is changed
|
|
3982
|
+
this.embla.on("select", () => {
|
|
3983
|
+
const activeSlide = this.slides[this.embla.selectedScrollSnap()];
|
|
3984
|
+
this.slides.forEach((slide) => {
|
|
3985
|
+
slide.setAttribute("tabindex", "-1");
|
|
3986
|
+
});
|
|
3987
|
+
activeSlide.setAttribute("tabindex", "0");
|
|
3988
|
+
});
|
|
3989
|
+
|
|
3990
|
+
const emblaContainer = this.shadowRoot.querySelector(".embla__container");
|
|
3991
|
+
emblaContainer.replaceChildren(...this.slides);
|
|
3992
|
+
|
|
3993
|
+
this.isPlaying = this.playOnInit;
|
|
3994
|
+
}
|
|
3995
|
+
|
|
3996
|
+
/**
|
|
3997
|
+
* @private
|
|
3998
|
+
* @param {KeyboardEvent} event - The keydown event triggered by the user.
|
|
3999
|
+
* @returns {void}
|
|
4000
|
+
*/
|
|
4001
|
+
handleKeydown(event) {
|
|
4002
|
+
const focusActiveSlide = () => {
|
|
4003
|
+
setTimeout(() => {
|
|
4004
|
+
const activeSlide = this.slides[this.embla.selectedScrollSnap()];
|
|
4005
|
+
activeSlide.focus();
|
|
4006
|
+
}, 200);
|
|
4007
|
+
};
|
|
4008
|
+
if (event.key === "ArrowLeft") {
|
|
4009
|
+
this.embla.scrollPrev();
|
|
4010
|
+
focusActiveSlide();
|
|
4011
|
+
} else if (event.key === "ArrowRight") {
|
|
4012
|
+
this.embla.scrollNext();
|
|
4013
|
+
focusActiveSlide();
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
/** @private */
|
|
4018
|
+
updateSlides() {
|
|
4019
|
+
const slot = this.shadowRoot.querySelector("slot:not([name])");
|
|
4020
|
+
slot.assignedElements().forEach((element, index) => {
|
|
4021
|
+
element.classList.add("embla__slide");
|
|
4022
|
+
element.addEventListener("keydown", this.handleKeydown.bind(this));
|
|
4023
|
+
if (index === 0) {
|
|
4024
|
+
element.setAttribute("tabindex", "0");
|
|
4025
|
+
} else {
|
|
4026
|
+
element.setAttribute("tabindex", "-1");
|
|
4027
|
+
}
|
|
4028
|
+
});
|
|
4029
|
+
this.slides = slot.assignedElements();
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
/**
|
|
4033
|
+
* @private
|
|
4034
|
+
* Stops autoplay when the user interacts with the navigation buttons.
|
|
4035
|
+
*/
|
|
4036
|
+
onNavButtonClick = (emblaApi) => {
|
|
4037
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
4038
|
+
if (!autoplay) return;
|
|
4039
|
+
|
|
4040
|
+
const resetOrStop =
|
|
4041
|
+
autoplay.options.stopOnInteraction === false
|
|
4042
|
+
? autoplay.reset
|
|
4043
|
+
: autoplay.stop;
|
|
4044
|
+
|
|
4045
|
+
resetOrStop();
|
|
4046
|
+
};
|
|
4047
|
+
|
|
4048
|
+
/**
|
|
4049
|
+
* @private
|
|
4050
|
+
* Adds event listeners to the play button to control autoplay.
|
|
4051
|
+
*/
|
|
4052
|
+
addAutoPlayBtnListener = (emblaApi, playBtn) => {
|
|
4053
|
+
const togglePlayBtnState = () => {
|
|
4054
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
4055
|
+
if (!autoplay) return;
|
|
4056
|
+
|
|
4057
|
+
// Investigate why values are reversed
|
|
4058
|
+
this.playBtnLabel = autoplay.isPlaying()
|
|
4059
|
+
? this.playLabel
|
|
4060
|
+
: this.pauseLabel;
|
|
4061
|
+
};
|
|
4062
|
+
|
|
4063
|
+
const onPlayBtnClick = () => {
|
|
4064
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
4065
|
+
if (!autoplay) return;
|
|
4066
|
+
|
|
4067
|
+
const playOrStop = autoplay.isPlaying() ? autoplay.stop : autoplay.play;
|
|
4068
|
+
playOrStop();
|
|
4069
|
+
this.isPlaying = autoplay.isPlaying();
|
|
4070
|
+
};
|
|
4071
|
+
|
|
4072
|
+
playBtn.addEventListener("click", onPlayBtnClick);
|
|
4073
|
+
emblaApi
|
|
4074
|
+
.on("autoplay:play", togglePlayBtnState)
|
|
4075
|
+
.on("autoplay:stop", togglePlayBtnState)
|
|
4076
|
+
.on("reInit", togglePlayBtnState);
|
|
4077
|
+
|
|
4078
|
+
return () => {
|
|
4079
|
+
playBtn.removeEventListener("click", onPlayBtnClick);
|
|
4080
|
+
emblaApi
|
|
4081
|
+
.off("autoplay:play", togglePlayBtnState)
|
|
4082
|
+
.off("autoplay:stop", togglePlayBtnState)
|
|
4083
|
+
.off("reInit", togglePlayBtnState);
|
|
4084
|
+
};
|
|
4085
|
+
};
|
|
4086
|
+
|
|
4087
|
+
/**
|
|
4088
|
+
* @private
|
|
4089
|
+
* Adds event listeners to the play button to control auto scroll.
|
|
4090
|
+
*/
|
|
4091
|
+
addAutoScrollBtnListener = (emblaApi, playBtn) => {
|
|
4092
|
+
const togglePlayBtnState = (emblaApi) => {
|
|
4093
|
+
const autoScroll = emblaApi?.plugins()?.autoScroll;
|
|
4094
|
+
if (!autoScroll) return;
|
|
4095
|
+
|
|
4096
|
+
this.playBtnLabel = autoScroll.isPlaying()
|
|
4097
|
+
? this.playLabel
|
|
4098
|
+
: this.pauseLabel;
|
|
4099
|
+
};
|
|
4100
|
+
|
|
4101
|
+
const onPlayBtnClick = () => {
|
|
4102
|
+
const autoScroll = emblaApi?.plugins()?.autoScroll;
|
|
4103
|
+
if (!autoScroll) return;
|
|
4104
|
+
|
|
4105
|
+
const playOrStop = autoScroll.isPlaying()
|
|
4106
|
+
? autoScroll.stop
|
|
4107
|
+
: autoScroll.play;
|
|
4108
|
+
playOrStop();
|
|
4109
|
+
this.isPlaying = autoScroll.isPlaying();
|
|
4110
|
+
};
|
|
4111
|
+
|
|
4112
|
+
playBtn.addEventListener("click", onPlayBtnClick);
|
|
4113
|
+
emblaApi
|
|
4114
|
+
.on("autoScroll:play", togglePlayBtnState)
|
|
4115
|
+
.on("autoScroll:stop", togglePlayBtnState)
|
|
4116
|
+
.on("reInit", togglePlayBtnState);
|
|
4117
|
+
|
|
4118
|
+
return () => {
|
|
4119
|
+
playBtn.removeEventListener("click", onPlayBtnClick);
|
|
4120
|
+
emblaApi
|
|
4121
|
+
.off("autoScroll:play", togglePlayBtnState)
|
|
4122
|
+
.off("autoScroll:stop", togglePlayBtnState)
|
|
4123
|
+
.off("reInit", togglePlayBtnState);
|
|
4124
|
+
};
|
|
4125
|
+
};
|
|
4126
|
+
|
|
4127
|
+
/**
|
|
4128
|
+
* @private
|
|
4129
|
+
* Adds dot buttons and click handlers for pagination.
|
|
4130
|
+
*/
|
|
4131
|
+
addDotBtnsAndClickHandlers = (emblaApi, dotsNode, onButtonClick) => {
|
|
4132
|
+
let dotNodes = [];
|
|
4133
|
+
|
|
4134
|
+
const addDotBtnsWithClickHandlers = () => {
|
|
4135
|
+
dotsNode.innerHTML = emblaApi
|
|
4136
|
+
.scrollSnapList()
|
|
4137
|
+
.map(
|
|
4138
|
+
() =>
|
|
4139
|
+
'<button class="embla__dot" type="button" tabindex="-1"></button>',
|
|
4140
|
+
)
|
|
4141
|
+
.join("");
|
|
4142
|
+
|
|
4143
|
+
const scrollTo = (index) => {
|
|
4144
|
+
emblaApi.scrollTo(index);
|
|
4145
|
+
if (onButtonClick) onButtonClick(emblaApi);
|
|
4146
|
+
};
|
|
4147
|
+
|
|
4148
|
+
dotNodes = Array.from(dotsNode.querySelectorAll(".embla__dot"));
|
|
4149
|
+
dotNodes.forEach((dotNode, index) => {
|
|
4150
|
+
dotNode.addEventListener("click", () => scrollTo(index), false);
|
|
4151
|
+
});
|
|
4152
|
+
};
|
|
4153
|
+
|
|
4154
|
+
const toggleDotBtnsActive = () => {
|
|
4155
|
+
const previous = emblaApi.previousScrollSnap();
|
|
4156
|
+
const selected = emblaApi.selectedScrollSnap();
|
|
4157
|
+
|
|
4158
|
+
if (this.autoplay) {
|
|
4159
|
+
const progressBar = document.createElement("div");
|
|
4160
|
+
progressBar.classList.add("embla__progress__bar");
|
|
4161
|
+
|
|
4162
|
+
dotNodes[previous].classList.replace("embla__progress", "embla__dot");
|
|
4163
|
+
dotNodes[previous].replaceChildren();
|
|
4164
|
+
|
|
4165
|
+
dotNodes[selected].classList.replace("embla__dot", "embla__progress");
|
|
4166
|
+
dotNodes[selected].appendChild(progressBar);
|
|
4167
|
+
|
|
4168
|
+
this.addAutoplayProgressListeners(this.embla, this._progressNode);
|
|
4169
|
+
} else {
|
|
4170
|
+
dotNodes[previous].classList.remove("embla__dot--selected");
|
|
4171
|
+
dotNodes[selected].classList.add("embla__dot--selected");
|
|
4172
|
+
}
|
|
4173
|
+
};
|
|
4174
|
+
|
|
4175
|
+
emblaApi
|
|
4176
|
+
.on("init", addDotBtnsWithClickHandlers)
|
|
4177
|
+
.on("reInit", addDotBtnsWithClickHandlers)
|
|
4178
|
+
.on("init", toggleDotBtnsActive)
|
|
4179
|
+
.on("reInit", toggleDotBtnsActive)
|
|
4180
|
+
.on("select", toggleDotBtnsActive);
|
|
4181
|
+
|
|
4182
|
+
return () => {
|
|
4183
|
+
dotsNode.innerHTML = "";
|
|
4184
|
+
};
|
|
4185
|
+
};
|
|
4186
|
+
|
|
4187
|
+
/**
|
|
4188
|
+
* @private
|
|
4189
|
+
*/
|
|
4190
|
+
addAutoplayProgressListeners = (emblaApi, progressNode) => {
|
|
4191
|
+
const progressBarNode = progressNode.querySelector(".embla__progress__bar");
|
|
4192
|
+
|
|
4193
|
+
let animationName = "";
|
|
4194
|
+
|
|
4195
|
+
const startProgress = (emblaApi) => {
|
|
4196
|
+
this._progressNode.classList.remove("embla__progress--paused");
|
|
4197
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
4198
|
+
if (!autoplay) return;
|
|
4199
|
+
|
|
4200
|
+
const timeUntilNext = autoplay.timeUntilNext();
|
|
4201
|
+
if (timeUntilNext === null) return;
|
|
4202
|
+
|
|
4203
|
+
if (!animationName) {
|
|
4204
|
+
const style = window.getComputedStyle(progressBarNode);
|
|
4205
|
+
animationName = style.animationName;
|
|
4206
|
+
}
|
|
4207
|
+
|
|
4208
|
+
progressBarNode.style.animationName = "none";
|
|
4209
|
+
progressBarNode.style.transform = "translate3d(0,0,0)";
|
|
4210
|
+
|
|
4211
|
+
window.requestAnimationFrame(() => {
|
|
4212
|
+
window.setTimeout(() => {
|
|
4213
|
+
progressBarNode.style.animationName = animationName;
|
|
4214
|
+
progressBarNode.style.animationDuration = `${timeUntilNext}ms`;
|
|
4215
|
+
}, 0);
|
|
4216
|
+
});
|
|
4217
|
+
};
|
|
4218
|
+
|
|
4219
|
+
const stopProgress = (emblaApi) => {
|
|
4220
|
+
this._progressNode.classList.add("embla__progress--paused");
|
|
4221
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
4222
|
+
if (!autoplay) return;
|
|
4223
|
+
};
|
|
4224
|
+
|
|
4225
|
+
emblaApi
|
|
4226
|
+
.on("autoplay:timerset", startProgress)
|
|
4227
|
+
.on("autoplay:timerstopped", stopProgress)
|
|
4228
|
+
.emit("autoplay:timerset"); // starts progress animation for playOnInit
|
|
4229
|
+
|
|
4230
|
+
return () => {
|
|
4231
|
+
emblaApi
|
|
4232
|
+
.off("autoplay:timerset", startProgress)
|
|
4233
|
+
.off("autoplay:timerstopped", stopProgress);
|
|
4234
|
+
};
|
|
4235
|
+
};
|
|
4236
|
+
|
|
4237
|
+
/**
|
|
4238
|
+
* Internal function to generate the HTML for the icon to use.
|
|
4239
|
+
* @private
|
|
4240
|
+
* @param {string} svgContent - The SVG content to be embedded.
|
|
4241
|
+
* @param {boolean} hideIcon - Whether the icon should be hidden
|
|
4242
|
+
* @returns {Element} The HTML element containing the SVG icon.
|
|
4243
|
+
*/
|
|
4244
|
+
generateIconHtml(svgContent, hideIcon) {
|
|
4245
|
+
const dom = new DOMParser().parseFromString(svgContent, "text/html");
|
|
4246
|
+
const svg = dom.body.firstChild;
|
|
4247
|
+
svg.setAttribute("slot", "svg");
|
|
4248
|
+
|
|
4249
|
+
const iconHtml = u`<${this.iconTag} customColor customSvg slot="icon" ?hidden="${hideIcon}">${svg}</${this.iconTag}>`;
|
|
4250
|
+
|
|
4251
|
+
return iconHtml;
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
/**
|
|
4255
|
+
* Generates the HTML for the navigation controls (previous and next buttons).
|
|
4256
|
+
* @private
|
|
4257
|
+
* @returns {Element} The HTML element containing the navigation controls.
|
|
4258
|
+
*/
|
|
4259
|
+
renderNavigationControls() {
|
|
4260
|
+
return u`
|
|
4261
|
+
<${this.buttonTag}
|
|
4262
|
+
aria-label="Previous slide"
|
|
4263
|
+
class="scroll-prev"
|
|
4264
|
+
shape="circle"
|
|
4265
|
+
onDark
|
|
4266
|
+
size="lg"
|
|
4267
|
+
@click=${() => this.embla.scrollPrev()}>
|
|
4268
|
+
${this.generateIconHtml(chevronLeft.svg)}
|
|
4269
|
+
</${this.buttonTag}>
|
|
4270
|
+
<${this.buttonTag}
|
|
4271
|
+
aria-label="Next slide"
|
|
4272
|
+
class="scroll-next"
|
|
4273
|
+
shape="circle"
|
|
4274
|
+
onDark
|
|
4275
|
+
size="lg"
|
|
4276
|
+
@click=${() => this.embla.scrollNext()}>
|
|
4277
|
+
${this.generateIconHtml(chevronRight.svg)}
|
|
4278
|
+
</${this.buttonTag}>`;
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
/** @private */
|
|
4282
|
+
renderPlayButton() {
|
|
4283
|
+
return u`
|
|
4284
|
+
<${this.buttonTag}
|
|
4285
|
+
aria-label="${this.playBtnLabel}"
|
|
4286
|
+
class="play-pause"
|
|
4287
|
+
shape="circle"
|
|
4288
|
+
>
|
|
4289
|
+
${this.generateIconHtml(play.svg, this.isPlaying)}
|
|
4290
|
+
${this.generateIconHtml(pause.svg, !this.isPlaying)}
|
|
4291
|
+
</${this.buttonTag}>
|
|
4292
|
+
`;
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
/**
|
|
4296
|
+
* Generates the HTML for the pagination container, which includes the play button and pagination dots.
|
|
4297
|
+
* If autoplay or autoScroll is enabled, it will render the play button.
|
|
4298
|
+
* If pagination is enabled, it will render the dots.
|
|
4299
|
+
* @private
|
|
4300
|
+
*/
|
|
4301
|
+
renderPaginationContainer() {
|
|
4302
|
+
return u`
|
|
4303
|
+
<div class="pagination-container">
|
|
4304
|
+
${this.autoplay || this.autoScroll ? this.renderPlayButton() : E}
|
|
4305
|
+
${this.pagination ? u`<div class="embla__dots"></div>` : E}
|
|
4306
|
+
</div>
|
|
4307
|
+
`;
|
|
4308
|
+
}
|
|
4309
|
+
|
|
4310
|
+
render() {
|
|
4311
|
+
return u`
|
|
4312
|
+
<div class="container">
|
|
4313
|
+
<div class="slideshow-wrapper">
|
|
4314
|
+
${this.navigation ? this.renderNavigationControls() : E}
|
|
4315
|
+
<div class="embla">
|
|
4316
|
+
<div class="embla__container">
|
|
4317
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
4318
|
+
</div>
|
|
4319
|
+
</div>
|
|
4320
|
+
</div>
|
|
4321
|
+
${this.pagination || this.autoplay || this.autoScroll ? this.renderPaginationContainer() : E}
|
|
4322
|
+
</div>
|
|
4323
|
+
`;
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4327
|
+
export { AuroSlideshow as A };
|