@malga-checkout/core
Version:
Core components for Malga Checkout
1 lines • 18.6 kB
JavaScript
import{r as t,c as n,h as o,H as r}from"./p-b48ba462.js";import{c as e,g as i}from"./p-3e8ff66b.js";var c=Math.ceil,a=Math.floor,u=function(t){return isNaN(t=+t)?0:(t>0?a:c)(t)},s=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},l=e((function(t){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)})),f=e((function(t){var n=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=n)})),h=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},d=function(t,n,o){if(h(t),void 0===n)return t;switch(o){case 1:return function(o){return t.call(n,o)};case 2:return function(o,r){return t.call(n,o,r)};case 3:return function(o,r,e){return t.call(n,o,r,e)}}return function(){return t.apply(n,arguments)}},g=function(t){return"object"==typeof t?null!==t:"function"==typeof t},p=function(t){if(!g(t))throw TypeError(t+" is not an object!");return t},m=function(t){try{return!!t()}catch(t){return!0}},v=!m((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})),k=l.document,b=g(k)&&g(k.createElement),y=function(t){return b?k.createElement(t):{}},w=!v&&!m((function(){return 7!=Object.defineProperty(y("div"),"a",{get:function(){return 7}}).a})),_=Object.defineProperty,x={f:v?Object.defineProperty:function(t,n,o){if(p(t),n=function(t){if(!g(t))return t;var n,o;if("function"==typeof(n=t.toString)&&!g(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!g(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}(n),p(o),w)try{return _(t,n,o)}catch(t){}if("get"in o||"set"in o)throw TypeError("Accessors not supported!");return"value"in o&&(t[n]=o.value),t}},O=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}},S=v?function(t,n,o){return x.f(t,n,O(1,o))}:function(t,n,o){return t[n]=o,t},E={}.hasOwnProperty,L=function(t,n){return E.call(t,n)},j=function(t,n,o){var r,e,i,c=t&j.F,a=t&j.G,u=t&j.S,s=t&j.P,h=t&j.B,g=t&j.W,p=a?f:f[n]||(f[n]={}),m=p.prototype,v=a?l:u?l[n]:(l[n]||{}).prototype;for(r in a&&(o=n),o)(e=!c&&v&&void 0!==v[r])&&L(p,r)||(i=e?v[r]:o[r],p[r]=a&&"function"!=typeof v[r]?o[r]:h&&e?d(i,l):g&&v[r]==i?function(t){var n=function(n,o,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,o)}return new t(n,o,r)}return t.apply(this,arguments)};return n.prototype=t.prototype,n}(i):s&&"function"==typeof i?d(Function.call,i):i,s&&((p.virtual||(p.virtual={}))[r]=i,t&j.R&&m&&!m[r]&&S(m,r,i)))};j.F=1,j.G=2,j.S=4,j.P=8,j.B=16,j.W=32,j.U=64,j.R=128;var F=j,M=S,T={},D={}.toString,A=function(t){return D.call(t).slice(8,-1)},C=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==A(t)?t.split(""):Object(t)},P=function(t){return C(s(t))},N=Math.min,I=function(t){return t>0?N(u(t),9007199254740991):0},z=Math.max,B=Math.min,R=e((function(t){var n="__core-js_shared__",o=l[n]||(l[n]={});(t.exports=function(t,n){return o[t]||(o[t]=void 0!==n?n:{})})("versions",[]).push({version:f.version,mode:"pure",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),V=0,G=Math.random(),H=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++V+G).toString(36))},J=R("keys"),q=function(t){return J[t]||(J[t]=H(t))},K=(!1,function(t,n,o){var r=P(t),e=I(r.length),i=function(t,n){return(t=u(t))<0?z(t+n,0):B(t,n)}(o,e);for(false;e>i;i++)if(i in r&&r[i]===n)return i||0;return-1}),U=q("IE_PROTO"),W="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),Y=Object.keys||function(t){return function(t,n){var o,r=P(t),e=0,i=[];for(o in r)o!=U&&L(r,o)&&i.push(o);for(;n.length>e;)L(r,o=n[e++])&&(~K(i,o)||i.push(o));return i}(t,W)},Q=v?Object.defineProperties:function(t,n){p(t);for(var o,r=Y(n),e=r.length,i=0;e>i;)x.f(t,o=r[i++],n[o]);return t},X=l.document,Z=X&&X.documentElement,$=q("IE_PROTO"),tt=function(){},nt=function(){var t,n=y("iframe"),o=W.length;for(n.style.display="none",Z.appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),nt=t.F;o--;)delete nt.prototype[W[o]];return nt()},ot=Object.create||function(t,n){var o;return null!==t?(tt.prototype=p(t),o=new tt,tt.prototype=null,o[$]=t):o=nt(),void 0===n?o:Q(o,n)},rt=e((function(t){var n=R("wks"),o=l.Symbol,r="function"==typeof o;(t.exports=function(t){return n[t]||(n[t]=r&&o[t]||(r?o:H)("Symbol."+t))}).store=n})),et=x.f,it=rt("toStringTag"),ct=function(t,n,o){t&&!L(t=o?t:t.prototype,it)&&et(t,it,{configurable:!0,value:n})},at={};S(at,rt("iterator"),(function(){return this}));var ut=function(t,n,o){t.prototype=ot(at,{next:O(1,o)}),ct(t,n+" Iterator")},st=function(t){return Object(s(t))},lt=q("IE_PROTO"),ft=Object.prototype,ht=Object.getPrototypeOf||function(t){return t=st(t),L(t,lt)?t[lt]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?ft:null},dt=rt("iterator"),gt=!([].keys&&"next"in[].keys()),pt=function(){return this},mt=function(t,n,o,r,e,i,c){ut(o,n,r);var a,u,s,l=function(t){if(!gt&&t in g)return g[t];switch(t){case"keys":case"values":return function(){return new o(this,t)}}return function(){return new o(this,t)}},f=n+" Iterator",h="values"==e,d=!1,g=t.prototype,p=g[dt]||g["@@iterator"]||e&&g[e],m=p||l(e),v=e?h?l("entries"):m:void 0,k="Array"==n&&g.entries||p;if(k&&(s=ht(k.call(new t)))!==Object.prototype&&s.next&&ct(s,f,!0),h&&p&&"values"!==p.name&&(d=!0,m=function(){return p.call(this)}),c&&(gt||d||!g[dt])&&S(g,dt,m),T[n]=m,T[f]=pt,e)if(a={values:h?m:l("values"),keys:i?m:l("keys"),entries:v},c)for(u in a)u in g||M(g,u,a[u]);else F(F.P+F.F*(gt||d),n,a);return a},vt=(!0,function(t,n){var o,r,e=String(s(t)),i=u(n),c=e.length;return i<0||i>=c?"":(o=e.charCodeAt(i))<55296||o>56319||i+1===c||(r=e.charCodeAt(i+1))<56320||r>57343?e.charAt(i):e.slice(i,i+2)});mt(String,"String",(function(t){this._t=String(t),this._i=0}),(function(){var t,n=this._t,o=this._i;return o>=n.length?{value:void 0,done:!0}:(t=vt(n,o),this._i+=t.length,{value:t,done:!1})}));var kt=function(t,n){return{value:n,done:!!t}};mt(Array,"Array",(function(t,n){this._t=P(t),this._i=0,this._k=n}),(function(){var t=this._t,n=this._k,o=this._i++;return!t||o>=t.length?(this._t=void 0,kt(1)):kt(0,"keys"==n?o:"values"==n?t[o]:[o,t[o]])}),"values"),T.Arguments=T.Array;for(var bt=rt("toStringTag"),yt="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),wt=0;wt<yt.length;wt++){var _t=yt[wt],xt=l[_t],Ot=xt&&xt.prototype;Ot&&!Ot[bt]&&S(Ot,bt,_t),T[_t]=T.Array}var St,Et,Lt=function(t,n,o){for(var r in n)o&&t[r]?t[r]=n[r]:S(t,r,n[r]);return t},jt=function(t,n,o,r){if(!(t instanceof n)||void 0!==r&&r in t)throw TypeError(o+": incorrect invocation!");return t},Ft=function(t,n,o,r){try{return r?n(p(o)[0],o[1]):n(o)}catch(n){var e=t.return;throw void 0!==e&&p(e.call(t)),n}},Mt=rt("iterator"),Tt=Array.prototype,Dt=rt("toStringTag"),At="Arguments"==A(function(){return arguments}()),Ct=function(t){var n,o,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(o=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),Dt))?o:At?A(n):"Object"==(r=A(n))&&"function"==typeof n.callee?"Arguments":r},Pt=rt("iterator"),Nt=f.getIteratorMethod=function(t){if(null!=t)return t[Pt]||t["@@iterator"]||T[Ct(t)]},It=e((function(t){var n={},o={},r=t.exports=function(t,r,e,i,c){var a,u,s,l,f,h=c?function(){return t}:Nt(t),g=d(e,i,r?2:1),m=0;if("function"!=typeof h)throw TypeError(t+" is not iterable!");if(void 0===(f=h)||T.Array!==f&&Tt[Mt]!==f){for(s=h.call(t);!(u=s.next()).done;)if((l=Ft(s,g,u.value,r))===n||l===o)return l}else for(a=I(t.length);a>m;m++)if((l=r?g(p(u=t[m])[0],u[1]):g(t[m]))===n||l===o)return l};r.BREAK=n,r.RETURN=o})),zt=rt("species"),Bt=e((function(t){var n=H("meta"),o=x.f,r=0,e=Object.isExtensible||function(){return!0},i=!m((function(){return e(Object.preventExtensions({}))})),c=function(t){o(t,n,{value:{i:"O"+ ++r,w:{}}})},a=t.exports={KEY:n,NEED:!1,fastKey:function(t,o){if(!g(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!L(t,n)){if(!e(t))return"F";if(!o)return"E";c(t)}return t[n].i},getWeak:function(t,o){if(!L(t,n)){if(!e(t))return!0;if(!o)return!1;c(t)}return t[n].w},onFreeze:function(t){return i&&a.NEED&&e(t)&&!L(t,n)&&c(t),t}}})),Rt=function(t,n){if(!g(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t},Vt=x.f,Gt=Bt.fastKey,Ht=v?"_s":"size",Jt=function(t,n){var o,r=Gt(n);if("F"!==r)return t._i[r];for(o=t._f;o;o=o.n)if(o.k==n)return o},qt={getConstructor:function(t,n,o,r){var e=t((function(t,i){jt(t,e,n,"_i"),t._t=n,t._i=ot(null),t._f=void 0,t._l=void 0,t[Ht]=0,null!=i&&It(i,o,t[r],t)}));return Lt(e.prototype,{clear:function(){for(var t=Rt(this,n),o=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete o[r.i];t._f=t._l=void 0,t[Ht]=0},delete:function(t){var o=Rt(this,n),r=Jt(o,t);if(r){var e=r.n,i=r.p;delete o._i[r.i],r.r=!0,i&&(i.n=e),e&&(e.p=i),o._f==r&&(o._f=e),o._l==r&&(o._l=i),o[Ht]--}return!!r},forEach:function(t){Rt(this,n);for(var o,r=d(t,arguments.length>1?arguments[1]:void 0,3);o=o?o.n:this._f;)for(r(o.v,o.k,this);o&&o.r;)o=o.p},has:function(t){return!!Jt(Rt(this,n),t)}}),v&&Vt(e.prototype,"size",{get:function(){return Rt(this,n)[Ht]}}),e},def:function(t,n,o){var r,e,i=Jt(t,n);return i?i.v=o:(t._l=i={i:e=Gt(n,!0),k:n,v:o,p:r=t._l,n:void 0,r:!1},t._f||(t._f=i),r&&(r.n=i),t[Ht]++,"F"!==e&&(t._i[e]=i)),t},getEntry:Jt,setStrong:function(t,n,o){mt(t,n,(function(t,o){this._t=Rt(t,n),this._k=o,this._l=void 0}),(function(){for(var t=this,n=t._k,o=t._l;o&&o.r;)o=o.p;return t._t&&(t._l=o=o?o.n:t._t._f)?kt(0,"keys"==n?o.k:"values"==n?o.v:[o.k,o.v]):(t._t=void 0,kt(1))}),o?"entries":"values",!o,!0),function(t){var n="function"==typeof f[t]?f[t]:l[t];v&&n&&!n[zt]&&x.f(n,zt,{configurable:!0,get:function(){return this}})}(n)}},Kt=Array.isArray||function(t){return"Array"==A(t)},Ut=rt("species"),Wt=x.f,Yt=(St=1==0,!1,!1,!1,!1,false,Et=function(t,n){return new(function(t){var n;return Kt(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Kt(n.prototype)||(n=void 0),g(n)&&null===(n=n[Ut])&&(n=void 0)),void 0===n?Array:n}(t))(n)},function(t,n,o){for(var r,e=st(t),i=C(e),c=d(n,o,3),a=I(i.length),u=0,s=St?Et(t,a):void 0;a>u;u++)u in i&&(r=c(i[u],u,e),0)&&St&&(s[u]=r);return s});!function(t,n,o,r,e){var i=l.Map,c=i,a=c&&c.prototype,u={};v&&"function"==typeof c&&a.forEach&&!m((function(){(new c).entries().next()}))?(c=n((function(n,o){jt(n,c,t,"_c"),n._c=new i,null!=o&&It(o,e,n.set,n)})),Yt("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),(function(t){var n="add"==t||"set"==t;!(t in a)||S(c.prototype,t,(function(o,r){jt(this,c,t);var e=this._c[t](0===o?0:o,r);return n?this:e}))})),Wt(c.prototype,"size",{get:function(){return this._c.size}})):(c=r.getConstructor(n,t,e,"set"),Lt(c.prototype,o),Bt.NEED=!0),ct(c,t),u.Map=c,F(F.G+F.W+F.F,u),r.setStrong(c,t,e)}("Map",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{get:function(t){var n=qt.getEntry(Rt(this,"Map"),t);return n&&n.v},set:function(t,n){return qt.def(Rt(this,"Map"),0===t?0:t,n)}},qt,!0),F(F.P+F.R,"Map",{toJSON:function(){if("Map"!=Ct(this))throw TypeError("Map#toJSON isn't generic");return It(this,!1,(t=[]).push,t,void 0),t;var t}}),F(F.S,"Map",{of:function(){for(var t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return new this(n)}}),F(F.S,"Map",{from:function(t){var n,o,r,e,i=arguments[1];return h(this),(n=void 0!==i)&&h(i),null==t?new this:(o=[],n?(r=0,e=d(i,arguments[2],2),It(t,!1,(function(t){o.push(e(t,r++))}))):It(t,!1,o.push,o),new this(o))}});var Qt=f.Map,Xt=e((function(t){t.exports={default:Qt,__esModule:!0}})),Zt=window.addEventListener?"addEventListener":"attachEvent",$t=window.removeEventListener?"removeEventListener":"detachEvent",tn="addEventListener"!==Zt?"on":"",nn={bind:function(t,n,o,r){return t[Zt](tn+n,o,r||!1),o},unbind:function(t,n,o,r){return t[$t](tn+n,o,r||!1),o}},on=function(t,n){return t===n||!!(16&t.compareDocumentPosition(n))};const rn=i(e((function(t,n){Object.defineProperty(n,"__esModule",{value:!0});var o=i(Xt);n.default=a;var r=i(nn),e=i(on);function i(t){return t&&t.__esModule?t:{default:t}}var c=new o.default;function a(t,n){return c.set(t,n),function(){c.delete(t)}}function u(t){c.forEach((function(n,o){(0,e.default)(o,t.target)||n.call(o,t)}))}function s(t){t||(t=document),r.default.bind(t,"click",u)}a.globalClick=u,a.install=s,"undefined"!=typeof document&&s(document),t.exports=n.default}))),en=class{constructor(r){t(this,r),this.changed=n(this,"changed",7),this.fullWidth=!1,this.endIcon="arrowDown",this.showOptions=!1,this.dropdownRef=null,this.toggleShowOptions=()=>{this.showOptions=!this.showOptions},this.handleCloseShowOptions=()=>{this.showOptions=!1},this.handleSelectOption=t=>{this.changed.emit({value:t}),this.handleCloseShowOptions()},this.renderOptions=()=>this.options.filter((t=>t.value!==this.value)).map((t=>o("li",{class:{"checkout-dropdown__list-item":!0},onClick:()=>this.handleSelectOption(t.value)},t.label))),this.getCurrentLabel=()=>this.label?this.label:this.options.find((t=>t.value===this.value)).label}componentDidRender(){this.dropdownRef&&rn(this.dropdownRef,(()=>{this.showOptions&&(this.showOptions=!1)}))}render(){return o(r,{class:{"checkout-dropdown__container":!0,"checkout-dropdown__container--full-width":this.fullWidth}},o("button",{ref:t=>this.dropdownRef=t,class:{"checkout-dropdown__button":!0},onClick:this.toggleShowOptions},o("span",null,o("checkout-icon",{icon:this.startIcon}),this.getCurrentLabel()),o("checkout-icon",{icon:this.endIcon})),this.showOptions&&o("ul",{class:{"checkout-dropdown__list":!0}},this.renderOptions()))}};en.style='@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap"); :root{--malga-checkout-color-page-background:#eef2f6;--malga-checkout-color-brand-accent-light:#79DBD4;--malga-checkout-color-brand-accent-normal:#39BFAD;--malga-checkout-color-brand-clean:#C3F4EF;--malga-checkout-color-brand-light:#79DBD4;--malga-checkout-color-brand-normal:#39BFAD;--malga-checkout-color-brand-middle:#2FAC9B;--malga-checkout-color-brand-dark:#147F70;--malga-checkout-color-grey-light:#666666;--malga-checkout-color-grey-normal:#4D4D4D;--malga-checkout-color-grey-middle:#333333;--malga-checkout-color-grey-dark:#1A1A1A;--malga-checkout-color-grey-darkness:#000000;--malga-checkout-color-accent-light:#ffffff;--malga-checkout-color-accent-normal:#F1F1F1;--malga-checkout-color-accent-middle:#CBCBCB;--malga-checkout-color-warning-light:#FFF8E6;--malga-checkout-color-warning-normal:#F9DF8D;--malga-checkout-color-warning-middle:#FFA400;--malga-checkout-color-warning-dark:#ED3A3D;--malga-checkout-color-modal-success:#00AE42;--malga-checkout-color-modal-error:#ED3A3D;--malga-checkout-color-modal-neutral:#4D4D4D;--malga-checkout-color-disabled:#F9F9F9;--malga-checkout-color-modal-action-button-error:#000000;--malga-checkout-color-modal-action-button-error-hover:#333333;--malga-checkout-color-modal-action-button-success:#000000;--malga-checkout-color-modal-action-button-success-hover:#333333;--malga-checkout-color-modal-action-button-success-font-color:#ffffff;--malga-checkout-color-modal-action-button-error-font-color:#ffffff;--malga-checkout-typography-family:"Inter", sans-serif;--malga-checkout-spacing-xxs:4px;--malga-checkout-spacing-xs:8px;--malga-checkout-spacing-sm:16px;--malga-checkout-spacing-default:24px;--malga-checkout-spacing-md:32px;--malga-checkout-spacing-lg:48px;--malga-checkout-spacing-xlg:64px;--malga-checkout-spacing-xxlg:96px;--malga-checkout-size-min-width:250px;--malga-checkout-border-radius-default:4px;--malga-checkout-border-radius-md:6px;--malga-checkout-border-radius-lg:20px;--malga-checkout-transition-slow:0.3s;--malga-checkout-transition-default:0.5s}.checkout-dropdown__list-item,.checkout-dropdown__button{font-family:var(--malga-checkout-typography-family);font-size:12px;font-style:normal;font-weight:normal}.checkout-dropdown__list-item,.checkout-dropdown__list,.checkout-dropdown__button{font-family:var(--malga-checkout-typography-family);padding:0;margin:0;box-sizing:border-box}.checkout-dropdown__container{position:relative}.checkout-dropdown__container--full-width{width:100%}.checkout-dropdown__button{transition:border-color var(--malga-checkout-transition-default) ease;display:flex;flex-direction:row;justify-content:space-between;align-items:center;cursor:pointer;outline:none;background-color:transparent;height:40px;min-width:180px;padding:calc(var(--malga-checkout-spacing-sm) - 3px);border:1px solid var(--malga-checkout-color-grey-light);border-radius:var(--malga-checkout-border-radius-default)}.checkout-dropdown__button:hover,.checkout-dropdown__button:focus{border:2px solid var(--malga-checkout-color-brand-middle)}.checkout-dropdown__button>span{display:flex;flex-direction:row;align-items:center}.checkout-dropdown__button>span>checkout-icon{margin-right:14px}.checkout-dropdown__button>span>checkout-icon>i>svg{width:18px;height:18px;color:var(--malga-checkout-color-brand-middle)}.checkout-dropdown__button>checkout-icon{margin-left:14px;color:var(--malga-checkout-color-grey-darkness)}.checkout-dropdown__list{list-style:none;position:absolute;left:0;display:flex;flex-direction:column;width:100%;padding-top:var(--malga-checkout-spacing-xs);padding-bottom:var(--malga-checkout-spacing-xs);background-color:var(--malga-checkout-color-accent-light);box-shadow:0px 2px 2px rgba(0, 0, 0, 0.2);border-radius:var(--malga-checkout-border-radius-default)}.checkout-dropdown__list-item{transition:background-color var(--malga-checkout-transition-default) ease;display:flex;flex-direction:row;align-items:center;justify-content:center;padding-top:var(--malga-checkout-spacing-xs);padding-bottom:var(--malga-checkout-spacing-xs);cursor:pointer;background-color:var(--malga-checkout-color-accent-light)}.checkout-dropdown__list-item:hover{background-color:var(--malga-checkout-color-brand-clean)}.checkout-dropdown__list-item--selected{background-color:var(--malga-checkout-color-brand-clean)}';export{en as checkout_dropdown}