UNPKG

@salla.sa/twilight-components

Version:
144 lines (136 loc) 12.9 kB
/*! * Crafted with ❤ by Salla */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; import { d as defineCustomElement$5 } from './salla-button2.js'; import { d as defineCustomElement$4 } from './salla-list-tile2.js'; import { d as defineCustomElement$3 } from './salla-loading2.js'; import { d as defineCustomElement$2 } from './salla-modal2.js'; var Bullhorn = `<!-- 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>bullhorn</title> <path d="M30.129 0.264c-0.339-0.252-0.776-0.328-1.179-0.208l-24.951 7.485v-0.216c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v14.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-0.112l3.448 1.207-0.595 1.704c-0.321 1.019-0.227 2.103 0.267 3.051s1.327 1.647 2.345 1.968l6.359 2.004c0.399 0.127 0.804 0.187 1.201 0.187 1.699 0 3.277-1.091 3.812-2.785l0.423-1.295 7.633 2.672c0.143 0.049 0.292 0.075 0.44 0.075 0.273 0 0.543-0.084 0.772-0.247 0.352-0.249 0.561-0.655 0.561-1.087v-28c0-0.421-0.199-0.819-0.537-1.069zM18.297 28.4c-0.221 0.701-0.973 1.089-1.673 0.871l-6.357-2.004c-0.34-0.108-0.617-0.34-0.781-0.656s-0.196-0.676-0.101-0.977l0.581-1.665 8.777 3.072zM28 27.453l-24-8.4v-8.728l24-7.2z"></path> </svg> `; var UserOff = `<!-- 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>user-off</title> <path d="M10.837 19.309c-4.963 1.284-8.171 4.303-8.171 7.691v3.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-3.667c0-2.101 2.48-4.155 6.172-5.109 0.713-0.184 1.141-0.912 0.957-1.625-0.184-0.711-0.908-1.137-1.625-0.956zM12.859 3.715c0.933-0.685 2.020-1.048 3.141-1.048 2.941 0 5.333 2.392 5.333 5.333 0 1.121-0.363 2.208-1.048 3.141-0.436 0.593-0.308 1.428 0.284 1.864 0.239 0.175 0.515 0.259 0.788 0.259 0.411 0 0.815-0.188 1.076-0.544 1.025-1.393 1.567-3.025 1.567-4.72 0-4.412-3.588-8-8-8-1.695 0-3.327 0.541-4.721 1.567-0.592 0.435-0.72 1.269-0.284 1.864 0.436 0.593 1.269 0.721 1.864 0.284zM31.609 29.724l-29.333-29.333c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l29.333 29.333c0.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.885z"></path> </svg> `; var UserCancel = `<!-- 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>user-cancel</title> <path d="M29.885 16l1.724-1.724c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-1.724 1.724-1.724-1.724c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l1.724 1.724-1.724 1.724c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l1.724-1.724 1.724 1.724c0.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.885zM10.667 16c4.043 0 7.333-3.289 7.333-7.333s-3.291-7.333-7.333-7.333-7.333 3.289-7.333 7.333 3.291 7.333 7.333 7.333zM10.667 4c2.573 0 4.667 2.093 4.667 4.667s-2.093 4.667-4.667 4.667-4.667-2.093-4.667-4.667 2.093-4.667 4.667-4.667zM10.667 18.667c-5.881 0-10.667 3.813-10.667 8.5v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-3.217 3.588-5.833 8-5.833s8 2.616 8 5.833v2.167c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.167c0-4.687-4.785-8.5-10.667-8.5z"></path> </svg> `; const sallaUserSettingsCss = ""; const SallaUserSettings$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserSettings extends HTMLElement { constructor() { super(); this.__registerHost(); // Texts this.deactivateAccount = salla.lang.get('pages.profile.deactivate_account'); this.promotionalMsgs = salla.lang.get('pages.profile.promotional_messages'); this.hideMyName = salla.lang.get('pages.profile.hide_my_name'); this.hideMyNameDesc = salla.lang.get('pages.profile.hide_my_name_desc'); this.deactivateDesc = salla.lang.get('pages.profile.deactivate_account_description'); this.promotionalMsgsDesc = salla.lang.get('pages.profile.promotional_messages_description'); this.sorryForLeavingText = salla.lang.get('pages.profile.warning_for_deactivate'); this.warningText = salla.lang.get('pages.profile.sorry_for_leaving'); this.keepAccount = salla.lang.get('pages.profile.keep_account'); this.buttonLoading = false; this.canHideName = salla.config.get('store.settings.rating.can_customer_hide_name'); salla.onReady(() => { this.isHiddenName = salla.config.get('user.is_hidden_name'); this.isNotifiable = salla.config.get('user.is_notifiable'); this.canHideName = salla.config.get('store.settings.rating.can_customer_hide_name'); if (!this.isNotifiable || !this.isHiddenName) { salla.event.on('profile::info.fetched', res => { this.isHiddenName = res.data.is_hidden_name; this.isNotifiable = res.data.is_notifiable; }); } }); salla.lang.onLoaded(() => { this.deactivateAccount = salla.lang.get('pages.profile.deactivate_account'); this.promotionalMsgs = salla.lang.get('pages.profile.promotional_messages'); this.hideMyName = salla.lang.get('pages.profile.hide_my_name'); this.hideMyNameDesc = salla.lang.get('pages.profile.hide_my_name_desc'); this.deactivateDesc = salla.lang.get('pages.profile.deactivate_account_description'); this.promotionalMsgsDesc = salla.lang.get('pages.profile.promotional_messages_description'); this.warningText = salla.lang.get('pages.profile.warning_for_deactivate'); this.sorryForLeavingText = salla.lang.get('pages.profile.sorry_for_leaving'); this.keepAccount = salla.lang.get('pages.profile.keep_account'); }); } toggleSetting(setting, event) { salla.profile.updateSettings({ name: setting, value: event.target.checked }); } capitalizeText(str) { return str.charAt(0).toUpperCase() + str.slice(1); } openDeactivateModal() { this.confirmationModal.setTitle(this.capitalizeText(this.deactivateAccount)); this.confirmationModal.open(); } async deleteAccount() { await salla.profile.delete().finally(() => this.confirmationModal.close()); } render() { return (h(Host, { key: '57752922b2235fa8fd47d23e9be20be308a05f9b', class: "s-user-settings-wrapper" }, this.canHideName && h("div", { key: '90350bb7f41f00111432b61c8579d75a5b5ced55', class: "s-user-settings-section" }, h("salla-list-tile", { key: '12cbd1a2493fb4a4d1e7ac612938fe24bac6e24d' }, h("div", { key: '67f204dca1444cece1182f53f1953064dc6068a0', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: '6d29b2e7198fab58b992677677cf08e2c1bf9966', innerHTML: UserCancel })), h("div", { key: '8b722b04117c3e5d7a592df0b728f07299c9b1a4', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.hideMyName)), h("div", { key: 'f46dcf6961b4dfe095c35689f255b1247e7dc1f8', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.hideMyNameDesc)), h("div", { key: '60464113b7ce1b2a083340215802c78aff7ceb50', slot: 'action', class: "s-user-settings-section-action" }, h("label", { key: '350b7197b3bd766f55997c41d04c70258baaf088', class: "s-toggle" }, h("input", { key: '1dea7f08a1cdfb1c21d8cdaf05eb43f61e797a1d', class: "s-toggle-input", checked: this.isHiddenName, onChange: (e) => this.toggleSetting('is_hidden_name', e), type: "checkbox" }), h("div", { key: '944fbcd07280b482f429497dce640fac1f0cfd91', class: "s-toggle-switcher" }))))), h("div", { key: '8a479b9df759fc51d2a2f5fba1ba299a575e6a0f', class: "s-user-settings-section" }, h("salla-list-tile", { key: '6648c3fced6be40915956b7971029ec31cdaadf2' }, h("div", { key: '704af53886d7f7308637664290a3d7cbdfcc31cc', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: 'e3ddfc8c7550e6b28db5813bf0e87d0af58a2bf2', innerHTML: Bullhorn })), h("div", { key: 'b60e0750ed81f1f0da5fceed4c3a571fca3bc2ab', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.promotionalMsgs)), h("div", { key: 'a766705fb45e01046b8f896caee99c18299eaa41', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.promotionalMsgsDesc)), h("div", { key: '788d8c57dede1241ed293769b2a6dab8bfd4f6bf', slot: 'action', class: "s-user-settings-section-action" }, h("label", { key: 'bf8d527945c0f2114be7659bbf6ef2aae231f0d9', class: "s-toggle" }, h("input", { key: '43f76c3b27b1958f10a76e3525fde2269de93317', class: "s-toggle-input", checked: this.isNotifiable, onChange: (e) => this.toggleSetting('is_notifiable', e), type: "checkbox" }), h("div", { key: '7a5ea9a24669e9b2becb88b64a638e78f8c8e3bc', class: "s-toggle-switcher" }))))), h("div", { key: '6680b01b52f2153e5fa4ba002aceb69b342554c6', class: "s-user-settings-section s-user-settings-section-deactivate-user" }, h("salla-list-tile", { key: '69a9e59a5d4259c47acce4410c6539ce4ba4a49b' }, h("div", { key: '5eeb3d0e5973ec389757a36f9888b1ccedd12f8c', slot: "icon", class: "s-user-settings-section-icon" }, h("span", { key: '1e787a58f65f52acec9bd159e6fbae08a77715d0', innerHTML: UserOff })), h("div", { key: 'b4e08ff95767f82d126e44010ab54afedb34b565', slot: "title", class: "s-user-settings-section-title" }, this.capitalizeText(this.deactivateAccount)), h("div", { key: 'd3d67a431ee30599197889e3caaa6ba939eb711c', slot: "subtitle", class: "s-user-settings-section-subtitle" }, this.capitalizeText(this.deactivateDesc)), h("div", { key: 'a46cb8e089dfe2f54809bf0c76c1b400af79c83d', slot: 'action', class: "s-user-settings-section-action" }, h("salla-button", { key: 'b0634bdd3d7be1cd315598f3e46c979eaef1b54a', fill: "outline", color: "danger", shape: "btn", size: "medium", width: "normal", onClick: () => this.openDeactivateModal() }, this.capitalizeText(this.deactivateAccount))))), h("salla-modal", { key: 'c9b45ac4da317114bcef34b45246dd3c162b36b1', width: "sm", subTitle: this.capitalizeText(this.sorryForLeavingText), ref: modal => this.confirmationModal = modal }, h("span", { key: '2ab0e74ea53827a085cd0a805c5d8a7911b6ac74', slot: 'icon', class: "s-user-settings-confirmation-icon", innerHTML: UserOff }), h("div", { key: 'b11e615ee719521503bc190cc175f3e348b2e65a', class: "s-user-settings-confirmation" }, h("div", { key: '3cf4d7aa592a11d2b41fe5029e1d9b978b922d57', class: "s-user-settings-confirmation-warning" }, this.capitalizeText(this.warningText)), h("div", { key: '2a2f0ce558453c52faf7fa294701a62f9760afa7', class: "s-user-settings-confirmation-actions" }, h("salla-button", { key: '14c0911198f273704bef176e28fea00b930a9387', width: "wide", onClick: () => this.confirmationModal.close() }, this.capitalizeText(this.keepAccount)), h("salla-button", { key: 'd3d5c88f6f0a73c490e12767246799b214a74ce1', fill: 'outline', loading: this.buttonLoading, width: "wide", onClick: () => this.deleteAccount() }, this.capitalizeText(this.deactivateAccount))))))); } static get style() { return sallaUserSettingsCss; } }, [0, "salla-user-settings", { "deactivateAccount": [32], "promotionalMsgs": [32], "hideMyName": [32], "hideMyNameDesc": [32], "deactivateDesc": [32], "promotionalMsgsDesc": [32], "sorryForLeavingText": [32], "warningText": [32], "keepAccount": [32], "buttonLoading": [32], "canHideName": [32], "isHiddenName": [32], "isNotifiable": [32] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["salla-user-settings", "salla-button", "salla-list-tile", "salla-loading", "salla-modal"]; components.forEach(tagName => { switch (tagName) { case "salla-user-settings": if (!customElements.get(tagName)) { customElements.define(tagName, SallaUserSettings$1); } break; case "salla-button": if (!customElements.get(tagName)) { defineCustomElement$5(); } break; case "salla-list-tile": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "salla-loading": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "salla-modal": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } const SallaUserSettings = SallaUserSettings$1; const defineCustomElement = defineCustomElement$1; export { SallaUserSettings, defineCustomElement }; //# sourceMappingURL=salla-user-settings.js.map //# sourceMappingURL=salla-user-settings.js.map