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: '7f3163771a6fe805ee75842c83c792b6a7dd0a2b', 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: '6358583b137c5aa191d0b0b5a3f91a8934340271', slot: 'icon', class: "s-product-size-guide-header-icon", innerHTML: PencilRuler }), h("div", { key: 'de9f920cd4c75f8089c7f3c426965e4551ffc77b', slot: "loading" }, h("div", { key: '67cb37e30e211233c10b14ad4d91bc5c5b24da6d', class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { key: '28cca753f94de6eaee5dce72929d0df79ee5fa04', height: '15px', width: '25%' }), h("div", { key: 'a5281ef076771baaca25938ee50d16ab2d720753', class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { key: 'a1d4a72b246a6a47c7b7d4bdbbb9404f00cda07f', height: '40px' }), h("salla-skeleton", { key: '1928477107338585e9ede41e2770b2269af3931c', height: '40px' }), h("salla-skeleton", { key: 'f8066e7ea05f580eec61529cfe24f3610b009ac6', height: '40px' }), h("salla-skeleton", { key: '3fdc216da7789b27061a2a9ef7f0abe96677d7c1', height: '40px' })), h("div", { key: '957b3b2951821bfd8bf6d382777a9f680c4e36ed', class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { key: '49f609d34eae8f4c0256a559bd12396bdbd4b996', height: '15px', width: '25%' }), h("salla-skeleton", { key: '2c20035b717f0b35212b066f39030bfbd17a597b', height: '10px', width: '75%' }), h("salla-skeleton", { key: '2e003fe9f76575c9b60b0aa86d650091213d8bb7', height: '10px', width: '50%' }), h("salla-skeleton", { key: 'ae28bd7c1770938e2a02b23a960bad255d59329e', height: '10px', width: '75%' }), h("salla-skeleton", { key: '3737f5b2d81b852e4c2b269bd61e73740341e32a', height: '10px', width: '100%' }), h("salla-skeleton", { key: 'e7e82f9ba968478ab38b1e9db94a98f2162b4e73', height: '10px', width: '25%' }), h("salla-skeleton", { key: 'd97efa180720f9ac39fa9bdb17f73cc27fb4a3f0', height: '10px', width: '60%' }), h("salla-skeleton", { key: 'ff3934e9aa7f58cbec9b42c772f7ee30e7cd69ea', height: '10px', width: '45%' }), h("salla-skeleton", { key: '5bc02f885b39fd6585a40f38299610e181414c43', height: '10px', width: '30%' })))), h("slot", { key: 'b8d469ede8c64d77c57888b08b749e5642da90b1', 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: '04df3ec4386e0beff2d18cc9df73dc427e9cf507', 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 };