UNPKG

@salla.sa/twilight-components

Version:
5 lines 8.94 kB
var __awaiter=this&&this.__awaiter||function(n,t,r,e){function i(n){return n instanceof r?n:new r((function(t){t(n)}))}return new(r||(r=Promise))((function(r,s){function c(n){try{o(e.next(n))}catch(n){s(n)}}function a(n){try{o(e["throw"](n))}catch(n){s(n)}}function o(n){n.done?r(n.value):i(n.value).then(c,a)}o((e=e.apply(n,t||[])).next())}))};var __generator=this&&this.__generator||function(n,t){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},e,i,s,c;return c={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(n){return function(t){return o([n,t])}}function o(a){if(e)throw new TypeError("Generator is already executing.");while(c&&(c=0,a[0]&&(r=0)),r)try{if(e=1,i&&(s=a[0]&2?i["return"]:a[0]?i["throw"]||((s=i["return"])&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;if(i=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(s=r.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){r.label=a[1];break}if(a[0]===6&&r.label<s[1]){r.label=s[1];s=a;break}if(s&&r.label<s[2]){r.label=s[2];r.ops.push(a);break}if(s[2])r.ops.pop();r.trys.pop();continue}a=t.call(n,r)}catch(n){a=[6,n];i=0}finally{e=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}; /*! * Crafted with ❤ by Salla */import{r as registerInstance,h}from"./index-BrMYHkA5.js";import{C as CheckCircleIcon}from"./check-B-rij7Or.js";var iconFileArchive='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-archive</title>\n<path d="M17.333 16h-5.333c-0.737 0-1.333 0.597-1.333 1.333v2.667c0 2.205 1.795 4 4 4s4-1.795 4-4v-2.667c0-0.736-0.596-1.333-1.333-1.333zM16 20c0 0.735-0.597 1.333-1.333 1.333s-1.333-0.599-1.333-1.333v-1.333h2.667zM17.333 12h-5.333c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h5.333c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333zM28.943 8.391l-8-8c-0.249-0.251-0.588-0.391-0.943-0.391h-13.333c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h18.667c2.205 0 4-1.795 4-4v-18.667c0-0.353-0.14-0.693-0.391-0.943zM26.667 28c0 0.735-0.597 1.333-1.333 1.333h-18.667c-0.736 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.597-1.333 1.333-1.333h12.781l7.219 7.219zM17.333 8h-5.333c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h5.333c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333zM17.333 4h-5.333c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h5.333c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333z"></path>\n</svg>\n';var iconDownload='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>download</title>\n<path d="M15.056 20.941c0.123 0.124 0.271 0.221 0.435 0.289 0.163 0.067 0.336 0.103 0.509 0.103s0.347-0.036 0.509-0.103c0.164-0.068 0.311-0.165 0.435-0.289l5.332-5.332c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-3.057 3.057v-12.781c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v12.781l-3.057-3.057c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885zM25.333 26.667h-18.667c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h18.667c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>\n</svg>\n';var iconCopy='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>swap-stroke</title>\n<path d="M6.667 18.667h-2.667c-0.736 0-1.333-0.597-1.333-1.333v-13.333c0-0.736 0.597-1.333 1.333-1.333h13.333c0.736 0 1.333 0.597 1.333 1.333v2.667c0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667c0-2.205-1.795-4-4-4h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h2.667c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333zM28 10.667h-13.333c-2.205 0-4 1.795-4 4v13.333c0 2.205 1.795 4 4 4h13.333c2.205 0 4-1.795 4-4v-13.333c0-2.205-1.795-4-4-4zM29.333 28c0 0.736-0.597 1.333-1.333 1.333h-13.333c-0.736 0-1.333-0.597-1.333-1.333v-13.333c0-0.736 0.597-1.333 1.333-1.333h13.333c0.736 0 1.333 0.597 1.333 1.333z"></path>\n</svg>\n';var iconCreditCard='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>debit-card-back</title>\n<path d="M30 28h-28c-1.105 0-2-0.895-2-2v0-18c0-1.105 0.895-2 2-2v0h28c1.105 0 2 0.895 2 2v0 18c0 1.105-0.895 2-2 2v0zM30 26v0zM2 8v18h28v-18zM31 14h-30c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h30c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM11 22h-6c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM24 24c-2.209 0-4-1.791-4-4s1.791-4 4-4c2.209 0 4 1.791 4 4v0c0 2.209-1.791 4-4 4v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2c1.105 0 2-0.895 2-2v0c0-1.105-0.895-2-2-2v0zM20 24c-2.209 0-4-1.791-4-4s1.791-4 4-4v0c0.002 0 0.005 0 0.007 0 1.032 0 1.972 0.398 2.673 1.048l-0.003-0.002c0.191 0.183 0.311 0.439 0.311 0.724 0 0.552-0.448 1-1 1-0.257 0-0.492-0.097-0.669-0.257l0.001 0.001c-0.345-0.319-0.807-0.514-1.315-0.514-0.002 0-0.003 0-0.005 0h0c-1.105 0-2 0.895-2 2s0.895 2 2 2v0c0.002 0 0.004 0 0.007 0 0.508 0 0.971-0.195 1.317-0.515l-0.001 0.001c0.179-0.171 0.422-0.276 0.689-0.276 0.552 0 1 0.448 1 1 0 0.295-0.128 0.56-0.331 0.743l-0.001 0.001c-0.699 0.648-1.638 1.046-2.671 1.046-0.003 0-0.007 0-0.010 0h0.001z"></path>\n</svg>\n';var sallaOrderSummaryCss=":host{display:block}";var SallaOrderSummary=function(){function n(n){registerInstance(this,n);this.codeCopied=null;this.noItemFound=true;this.order_items=[];this.isDigitalCard=function(n){return n.product.type==="codes"};this.isDigitalProduct=function(n){return n.product.type==="digital"}}n.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var n=this;return __generator(this,(function(t){switch(t.label){case 0:salla.lang.onLoaded((function(){n.codes_text=salla.lang.get("pages.thank_you.codes");n.copy_text=salla.lang.get("common.elements.copy");n.files_text=salla.lang.get("pages.thank_you.files");n.download_text=salla.lang.get("pages.thank_you.download")}));return[4,this.getOrderItems()];case 1:return[2,t.sent()]}}))}))};n.prototype.copyToClipboardHandler=function(n){var t=this;if(navigator&&"clipboard"in navigator){try{navigator.clipboard.writeText(n).then((function(){t.codeCopied=n;t.copyCodeButtonTimeout=setTimeout((function(){t.codeCopied=null}),3e3)}))}catch(n){salla.loggers.error("copy functionality is not supported by the browser")}}};n.prototype.getOrderItems=function(){return __awaiter(this,void 0,void 0,(function(){var n,t,r,e,i,s;var c=this;return __generator(this,(function(a){switch(a.label){case 0:n=this.orderId||salla.config.get("page.id");t="Failed to fetch order items";if(!n){salla.logger.error(t);throw new Error(t)}a.label=1;case 1:a.trys.push([1,3,,4]);return[4,salla.api.request("orders/".concat(n))];case 2:r=a.sent().data.items,e=r===void 0?[]:r;i=e.some((function(n){return c.isDigitalCard(n)||c.isDigitalProduct(n)}));if(i){this.order_items=e;this.noItemFound=false}return[3,4];case 3:s=a.sent();salla.logger.error(t);return[3,4];case 4:return[2]}}))}))};n.prototype.disconnectedCallback=function(){this.copyCodeButtonTimeout&&clearTimeout(this.copyCodeButtonTimeout)};n.prototype.render=function(){var n=this;return h("ul",{key:"e5fb79540f0dc836b97c04c38a183341b7bfa64d",class:"s-order-summary-wrapper"},this.noItemFound?h("salla-placeholder",{alignment:"center"},h("span",{slot:"title"})):this.order_items.map((function(t){return n.isDigitalCard(t)?h("li",{key:t.product.id,class:"s-order-summary-item"},h("h2",{class:"s-order-summary-item-title"},n.codes_text," (",t.name,")"),t.codes.map((function(t){return h("div",{key:t.code,class:"s-order-summary-code-item-wrapper"},h("p",null,h("span",{innerHTML:iconCreditCard}),h("span",null,t.code)),h("salla-button",{class:"s-order-summary-item-copy-button ".concat(n.codeCopied===t.code?"copied":""),onClick:function(){return n.copyToClipboardHandler(t.code)},shape:"link"},h("span",{innerHTML:n.codeCopied===t.code?CheckCircleIcon:iconCopy}),h("span",null,n.copy_text)))}))):n.isDigitalProduct(t)?h("li",{key:t.product.id,class:"s-order-summary-item"},h("h2",{class:"s-order-summary-item-title"},n.files_text," (",t.name,")"),h("ul",null,t.files.map((function(t){return h("li",{class:"s-order-summary-digital-item-wrapper"},h("div",null,h("span",{innerHTML:iconFileArchive}),h("span",null,t.name)),h("a",{href:t.url,target:"_blank",class:"s-order-summary-item-download"},h("span",{innerHTML:iconDownload}),h("span",null,n.download_text)))})))):null})))};return n}();SallaOrderSummary.style=sallaOrderSummaryCss;export{SallaOrderSummary as salla_order_summary}; //# sourceMappingURL=salla-order-summary.entry.js.map