UNPKG

@salla.sa/twilight-components

Version:
134 lines (128 loc) 8.95 kB
/*! * Crafted with ❤ by Salla */ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client'; import { d as defineCustomElement$8 } from './salla-loading2.js'; import { d as defineCustomElement$7 } from './salla-modal2.js'; import { d as defineCustomElement$6 } from './salla-placeholder2.js'; import { d as defineCustomElement$5 } from './salla-skeleton2.js'; import { d as defineCustomElement$4 } from './salla-tab-content2.js'; import { d as defineCustomElement$3 } from './salla-tab-header2.js'; import { d as defineCustomElement$2 } from './salla-tabs2.js'; var PencilRuler = `<!-- Generated by IcoMoon.io --> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"> <title>pencil-ruler</title> <path d="M3.057 11.609c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l6.667-6.667c0.521-0.521 0.521-1.364 0-1.885l-1.285-1.285c-1.143-1.143-2.661-1.772-4.276-1.772-1.616 0-3.135 0.629-4.276 1.772-1.143 1.141-1.772 2.66-1.772 4.276 0 1.615 0.629 3.135 1.772 4.276zM3.657 3.657c1.277-1.277 3.504-1.277 4.781 0l0.343 0.343-4.781 4.781-0.343-0.343c-0.639-0.639-0.991-1.488-0.991-2.391s0.352-1.752 0.991-2.391zM29.317 20.972c-0.2-0.707-0.932-1.119-1.645-0.921-0.709 0.2-1.121 0.937-0.921 1.645l1.987 7.041-7.041-1.987c-0.707-0.195-1.444 0.213-1.645 0.921-0.2 0.708 0.212 1.445 0.921 1.645l9.333 2.633c0.119 0.032 0.24 0.049 0.361 0.049 0.349 0 0.689-0.137 0.943-0.391 0.341-0.341 0.472-0.84 0.34-1.305zM31.609 8.772l-8.381-8.381c-0.5-0.5-1.385-0.5-1.885 0l-8.171 8.171s-0.001 0-0.001 0.001 0 0.001-0.001 0.001l-4.607 4.607s0 0-0.001 0 0 0 0 0.001l-8.171 8.171c-0.251 0.249-0.391 0.588-0.391 0.943 0 0.353 0.14 0.693 0.391 0.943l8.381 8.381c0.249 0.251 0.589 0.391 0.943 0.391s0.693-0.14 0.943-0.391l20.952-20.952c0.521-0.521 0.521-1.365 0-1.885zM9.715 28.781l-6.495-6.496 1.676-1.676 1.851 1.851c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885l-1.851-1.851 2.724-2.724 3.008 3.008c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885l-3.008-3.008 2.724-2.724 1.851 1.851c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.52 0.521-1.364 0-1.885l-1.851-1.851 2.724-2.724 3.008 3.008c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.365 0-1.885l-3.008-3.008 1.677-1.677 6.496 6.496z"></path> </svg> `; const sallaProductSizeGuideCss = ""; const SallaProductSizeGuide$1 = /*@__PURE__*/ proxyCustomElement(class SallaProductSizeGuide extends HTMLElement { constructor() { super(); this.__registerHost(); this.hasError = false; salla.event.on('size-guide::open', (product_id) => this.open(product_id)); salla.lang.onLoaded(() => { this.placeholder_title = salla.lang.get('pages.products.size_guide_placeholder'); this.placeholder_description = salla.lang.get('pages.products.size_guide_placeholder_info'); this.modal_title = salla.lang.get('pages.products.size_guides'); }); } /** * Show the size-guide modal window */ async open(product_id) { this.modal.setTitle(this.modal_title); this.modal.open(); return await salla.api.withoutNotifier(() => salla.product.getSizeGuides(product_id)) .then((response) => { this.guides = response.data; }) .catch(e => { console.log(e); this.hasError = true; this.placeholder_description = e.response?.data?.error?.message || e.response?.data; }) .finally(() => this.modal.stopLoading()); } /** * * Hide the size-guide modal window */ async close() { return this.modal.close(); } showPlaceholder() { return h("salla-placeholder", { alignment: "center", iconSize: "xl" }, h("div", { slot: "title" }, this.placeholder_title), h("div", { slot: "description" }, this.placeholder_description)); } render() { return (h("salla-modal", { key: 'ad8cbc23e60bc0d463f5b94febeab699dd96e2b4', class: "s-product-size-guide-wrapper", id: 'salla-product-size-guide-modal', isLoading: true, "has-skeleton": true, width: "md", ref: modal => this.modal = modal }, h("span", { key: 'b3dc61221d36a2680f74280e5fdb7601e5e70e62', slot: 'icon', class: "s-product-size-guide-header-icon", innerHTML: PencilRuler }), h("div", { key: '9735c6681e3e7c15c5d346f6cfca4c7d34542061', slot: "loading" }, h("div", { key: '65224399d086d931c5c978dd00cf2d4d1ec3c082', class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { key: '05c0eda8bc21f5a2e2a89424bed145e61cd5a29e', height: '15px', width: '25%' }), h("div", { key: 'af0e4801d3e27f664b38577c61ae3fc15e4c5c95', class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { key: '614ad02c61d7c44ec768a060cf7a25f04b618056', height: '40px' }), h("salla-skeleton", { key: 'a4da4e2fa6ded411938fd90c4e11d368baadf03e', height: '40px' }), h("salla-skeleton", { key: 'fb2fc13e520d704ad02d9c90f3678d7ec18e89f9', height: '40px' }), h("salla-skeleton", { key: '8b4723988f62458876f4b915f11df73bbf7717a8', height: '40px' })), h("div", { key: '9ae65ff980ee9458d1c2996465dcd7815bae0c1f', class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { key: '9d970f8d2d116845a902f7bcab944b48c781024f', height: '15px', width: '25%' }), h("salla-skeleton", { key: 'a8150338ad24a94552796f948b4dddfd280179aa', height: '10px', width: '75%' }), h("salla-skeleton", { key: '34446a9a1948c7c006f6e13b26cacd7e20d16238', height: '10px', width: '50%' }), h("salla-skeleton", { key: '8838c419ac7f384861188d7ab96e8f42473c04c0', height: '10px', width: '75%' }), h("salla-skeleton", { key: '21f8e182ba77e35b0f02f1cbcd21ee8effd94ac0', height: '10px', width: '100%' }), h("salla-skeleton", { key: '5391e8a3a133dd2ccf7087590113391da080ca8a', height: '10px', width: '25%' }), h("salla-skeleton", { key: '743ba490362dd541229cb5c60feb0b6dc5750714', height: '10px', width: '60%' }), h("salla-skeleton", { key: '58e6839c74e13e11f4ef84fa4ec85e1f2f9868f4', height: '10px', width: '45%' }), h("salla-skeleton", { key: 'a6f771e12046112b282dede2d759ed3d019bedcc', height: '10px', width: '30%' })))), h("slot", { key: '3ed1875a19be5a65afbf912fb0819dd92ded3062', name: "header" }), !this.hasError && !!this.guides ? [ h("salla-tabs", null, this.guides.map((guide) => h("salla-tab-header", { slot: "header", name: guide.name }, h("span", null, guide.name))), this.guides.map((guide) => h("salla-tab-content", { slot: "content", name: guide.name }, h("div", { innerHTML: guide.description })))) ] : this.showPlaceholder(), h("slot", { key: 'ca9526f3f95675dab2a38d2715ed3cf842d93174', name: "footer" }))); } get host() { return this; } static get style() { return sallaProductSizeGuideCss; } }, [4, "salla-product-size-guide", { "guides": [32], "productId": [32], "placeholder_title": [32], "placeholder_description": [32], "modal_title": [32], "hasError": [32], "open": [64], "close": [64] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["salla-product-size-guide", "salla-loading", "salla-modal", "salla-placeholder", "salla-skeleton", "salla-tab-content", "salla-tab-header", "salla-tabs"]; components.forEach(tagName => { switch (tagName) { case "salla-product-size-guide": if (!customElements.get(tagName)) { customElements.define(tagName, SallaProductSizeGuide$1); } break; case "salla-loading": if (!customElements.get(tagName)) { defineCustomElement$8(); } break; case "salla-modal": if (!customElements.get(tagName)) { defineCustomElement$7(); } break; case "salla-placeholder": if (!customElements.get(tagName)) { defineCustomElement$6(); } break; case "salla-skeleton": if (!customElements.get(tagName)) { defineCustomElement$5(); } break; case "salla-tab-content": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "salla-tab-header": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "salla-tabs": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } defineCustomElement$1(); const SallaProductSizeGuide = SallaProductSizeGuide$1; const defineCustomElement = defineCustomElement$1; export { SallaProductSizeGuide, defineCustomElement };