UNPKG

@salla.sa/twilight-components

Version:
140 lines (134 loc) 7.83 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'; const 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.guides = undefined; this.productId = undefined; this.placeholder_title = undefined; this.placeholder_description = undefined; this.modal_title = undefined; 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 => { var _a, _b, _c, _d; console.log(e); this.hasError = true; this.placeholder_description = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.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", { 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", { slot: 'icon', class: "s-product-size-guide-header-icon", innerHTML: PencilRuler }), h("div", { slot: "loading" }, h("div", { class: "s-product-size-guide-skeleton" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("div", { class: "s-product-size-guide-skeleton-header" }, h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' }), h("salla-skeleton", { height: '40px' })), h("div", { class: "s-product-size-guide-skeleton-content" }, h("salla-skeleton", { height: '15px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '50%' }), h("salla-skeleton", { height: '10px', width: '75%' }), h("salla-skeleton", { height: '10px', width: '100%' }), h("salla-skeleton", { height: '10px', width: '25%' }), h("salla-skeleton", { height: '10px', width: '60%' }), h("salla-skeleton", { height: '10px', width: '45%' }), h("salla-skeleton", { height: '10px', width: '30%' })))), h("slot", { 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", { 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; } }); } const SallaProductSizeGuide = SallaProductSizeGuide$1; const defineCustomElement = defineCustomElement$1; export { SallaProductSizeGuide, defineCustomElement }; //# sourceMappingURL=salla-product-size-guide.js.map