@salla.sa/twilight-components 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Helper-8c75b6ac.js → Helper-8852feaa.js} +3 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{multi-warehouse_3.cjs.entry.js → multi-warehouse_4.cjs.entry.js} +91 -10
- package/dist/cjs/salla-localization.cjs.entry.js +35 -11
- package/dist/cjs/salla-product-availability.cjs.entry.js +78 -0
- package/dist/cjs/salla-rating.cjs.entry.js +299 -0
- package/dist/cjs/{salla-search-b9403062.js → salla-search-f9e00be9.js} +1 -0
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +5 -3
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/Helpers/Helper.js +3 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/multi-warehouse/multi-warehouse.css +13 -0
- package/dist/collection/components/multi-warehouse/multi-warehouse.js +38 -39
- package/dist/collection/components/salla-button/salla-button.js +42 -9
- package/dist/collection/components/salla-localization/salla-localization.js +112 -20
- package/dist/collection/components/salla-modal/salla-modal.js +26 -19
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +333 -0
- package/dist/collection/components/{order-rating/order-rating.css → salla-rating/salla-rating.css} +0 -0
- package/dist/collection/components/salla-rating/salla-rating.js +484 -0
- package/dist/collection/components/salla-search/salla-search.js +1 -0
- package/dist/collection/components/salla-verify/salla-verify.js +4 -2
- package/dist/esm/{Helper-23b2de40.js → Helper-81ac9a8c.js} +3 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{multi-warehouse_3.entry.js → multi-warehouse_4.entry.js} +91 -11
- package/dist/esm/salla-localization.entry.js +35 -11
- package/dist/esm/salla-product-availability.entry.js +74 -0
- package/dist/esm/salla-rating.entry.js +295 -0
- package/dist/esm/{salla-search-5d4a6f1a.js → salla-search-615b8f94.js} +1 -0
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +5 -3
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-2b8a5fa4.entry.js +1 -0
- package/dist/twilight-components/p-4e37a6cb.entry.js +1 -0
- package/dist/twilight-components/p-751643d8.entry.js +1 -0
- package/dist/twilight-components/{p-4b137380.js → p-8a2410e6.js} +0 -0
- package/dist/twilight-components/p-94b18718.entry.js +1 -0
- package/dist/twilight-components/{p-520446eb.js → p-9bc28e0c.js} +1 -1
- package/dist/twilight-components/p-bb503365.entry.js +1 -0
- package/dist/twilight-components/p-d34bbfc4.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/Helpers/Helper.d.ts +1 -0
- package/dist/types/components/multi-warehouse/multi-warehouse.d.ts +1 -0
- package/dist/types/components/salla-button/salla-button.d.ts +2 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +10 -3
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +27 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +35 -0
- package/dist/types/components.d.ts +76 -17
- package/package.json +1 -1
- package/dist/cjs/order-rating.cjs.entry.js +0 -252
- package/dist/cjs/salla-button.cjs.entry.js +0 -57
- package/dist/collection/components/order-rating/order-rating.js +0 -321
- package/dist/esm/order-rating.entry.js +0 -248
- package/dist/esm/salla-button.entry.js +0 -53
- package/dist/twilight-components/p-653bb9a8.entry.js +0 -1
- package/dist/twilight-components/p-a2395c9d.entry.js +0 -1
- package/dist/twilight-components/p-baeca520.entry.js +0 -1
- package/dist/twilight-components/p-bd10d8d5.entry.js +0 -1
- package/dist/twilight-components/p-ea986bca.entry.js +0 -1
- package/dist/twilight-components/p-f4340bd9.entry.js +0 -1
- package/dist/types/components/order-rating/order-rating.d.ts +0 -20
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const sallaLogin = require('./salla-login-476fb312.js');
|
|
6
|
-
const sallaSearch = require('./salla-search-
|
|
6
|
+
const sallaSearch = require('./salla-search-f9e00be9.js');
|
|
7
7
|
require('./index-23da2c6b.js');
|
|
8
8
|
|
|
9
9
|
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["
|
|
17
|
+
return index.bootstrapLazy([["multi-warehouse_4.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languages":[1],"currencies":[1],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"title_":[1],"subscribe":[1],"cancel":[1],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribed":[1],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-verify.cjs",[[0,"salla-verify"]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-23da2c6b.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
6
7
|
const sallaLogin = require('./salla-login-476fb312.js');
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
const multiWarehouseCss = "#s-multi-warehouse-modal .s-modal-header{display:flex;flex-direction:column;margin-bottom:40px}#s-multi-warehouse-modal .s-modal-sub-title{margin:0}#s-multi-warehouse-modal .s-modal-title{order:10}";
|
|
8
10
|
|
|
9
11
|
// import Helper from "../../Helpers/Helper";
|
|
10
12
|
let engine = require('store/src/store-engine');
|
|
@@ -54,6 +56,9 @@ const MultiWarehouse = class {
|
|
|
54
56
|
this.selected = event.target.value;
|
|
55
57
|
}
|
|
56
58
|
handleSubmit() {
|
|
59
|
+
this.btn.load().then(() => {
|
|
60
|
+
setTimeout(() => location.reload(), 2000);
|
|
61
|
+
});
|
|
57
62
|
sessionStore.set("multi-warehouse-opened-before", true);
|
|
58
63
|
this.show();
|
|
59
64
|
setTimeout(() => {
|
|
@@ -61,7 +66,7 @@ const MultiWarehouse = class {
|
|
|
61
66
|
}, 300);
|
|
62
67
|
}
|
|
63
68
|
render() {
|
|
64
|
-
return (index.h("salla-modal", { "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "multi-warehouse-modal", class: "hidden" }, index.h("
|
|
69
|
+
return (index.h("salla-modal", { icon: "sicon-store-alt", title: "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "s-multi-warehouse-modal", class: "hidden" }, index.h("div", { class: "text-right" }, index.h("fieldset", { class: "mt-4" }, index.h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()), index.h("legend", { class: "sr-only" }, this.formTitle()), this.branches.length <= 5 ?
|
|
65
70
|
index.h("div", { class: "space-y-5" }, this.branches.map((branch) => index.h("div", { class: "flex items-center" }, index.h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
|
|
66
71
|
'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
|
|
67
72
|
'opacity-50': !branch.open,
|
|
@@ -74,14 +79,81 @@ const MultiWarehouse = class {
|
|
|
74
79
|
:
|
|
75
80
|
index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
76
81
|
:
|
|
77
|
-
index.h("select", { class: "w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary sm:text-sm border-gray-200 rounded-md appearance-none visibility_condition px-4", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (index.h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق'))))))
|
|
78
|
-
index.h("
|
|
82
|
+
index.h("select", { class: "w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary sm:text-sm border-gray-200 rounded-md appearance-none visibility_condition px-4", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (index.h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))))), this.isChoiceable() ?
|
|
83
|
+
index.h("div", { slot: "footer", class: "mt-6" }, index.h("slot", { name: "footer" }, index.h("salla-button", { "loader-position": "before", ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "w-full" }, salla.lang.get('common.elements.ok'))))
|
|
79
84
|
: ''));
|
|
80
85
|
}
|
|
81
86
|
componentDidRender() {
|
|
87
|
+
if (!this.isOpenedBefore && this.displayAs == 'popup') {
|
|
88
|
+
this.show();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get host() { return index.getElement(this); }
|
|
92
|
+
};
|
|
93
|
+
MultiWarehouse.style = multiWarehouseCss;
|
|
94
|
+
|
|
95
|
+
const sallaButtonCss = ":host{display:block}";
|
|
96
|
+
|
|
97
|
+
const SallaButton = class {
|
|
98
|
+
constructor(hostRef) {
|
|
99
|
+
index.registerInstance(this, hostRef);
|
|
100
|
+
this.btnStyle = 'primary'; // outline, outline-primary ,danger
|
|
101
|
+
this.loading = false;
|
|
102
|
+
this.disabled = false;
|
|
103
|
+
this.loaderPosition = 'before';
|
|
104
|
+
this.hostAttributes = {};
|
|
105
|
+
//============= Initiate Button Attributes =============//
|
|
106
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
107
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
108
|
+
}
|
|
109
|
+
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
110
|
+
this.hostAttributes.class = (this.hostAttributes.class || '') +
|
|
111
|
+
' s-button-btn btn--has-loading btn-' + this.btnStyle + ' loader-' + this.loaderPosition;
|
|
112
|
+
this.hostAttributes.class += this.loaderPosition == 'before' ? ' flex-row-reverse' : '';
|
|
113
|
+
// if(this.hostAttributes.onclick){
|
|
114
|
+
// this.hostAttributes.onclick=eval(this.hostAttributes.onclick);
|
|
115
|
+
// }
|
|
116
|
+
delete this.hostAttributes['btn-style'];
|
|
117
|
+
delete this.hostAttributes['id'];
|
|
118
|
+
}
|
|
119
|
+
async load() {
|
|
120
|
+
if (this.loaderPosition == 'center')
|
|
121
|
+
this.host.querySelector('.btn-text').classList.add('opacity-0');
|
|
122
|
+
this.host.setAttribute('loading', '');
|
|
123
|
+
return this.host;
|
|
124
|
+
}
|
|
125
|
+
async stop() {
|
|
126
|
+
this.host.removeAttribute('loading');
|
|
127
|
+
return this.host;
|
|
128
|
+
}
|
|
129
|
+
async disable() {
|
|
130
|
+
this.host.setAttribute('disabled', '');
|
|
131
|
+
}
|
|
132
|
+
async enable() {
|
|
133
|
+
this.host.removeAttribute('disabled');
|
|
134
|
+
}
|
|
135
|
+
handleVisible(newKind, oldKind) {
|
|
136
|
+
this.btn.classList.remove('btn-' + oldKind);
|
|
137
|
+
this.btn.classList.add('btn-' + newKind);
|
|
138
|
+
}
|
|
139
|
+
handleLoading(newVal) {
|
|
140
|
+
Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
return (index.h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), index.h("span", { class: "btn-text transition-opacity duration-300" }, index.h("slot", null)), this.loading ? index.h("span", { class: {
|
|
144
|
+
'loader loader--small s-button-loader': true,
|
|
145
|
+
'absolute right-2': this.loaderPosition === 'start',
|
|
146
|
+
'absolute left-2': this.loaderPosition === 'end',
|
|
147
|
+
'absolute top-1/2 left-1/2 !-translate-x-1/2 !-translate-y-1/2 !m-0': this.loaderPosition === 'center',
|
|
148
|
+
} }) : ''));
|
|
82
149
|
}
|
|
83
150
|
get host() { return index.getElement(this); }
|
|
151
|
+
static get watchers() { return {
|
|
152
|
+
"btnStyle": ["handleVisible"],
|
|
153
|
+
"loading": ["handleLoading"]
|
|
154
|
+
}; }
|
|
84
155
|
};
|
|
156
|
+
SallaButton.style = sallaButtonCss;
|
|
85
157
|
|
|
86
158
|
const SallaModal = class {
|
|
87
159
|
constructor(hostRef) {
|
|
@@ -94,7 +166,7 @@ const SallaModal = class {
|
|
|
94
166
|
this.modalWidth = 'w-96'; //todo use friendly names
|
|
95
167
|
this.visible = false;
|
|
96
168
|
this.subTitle = '';
|
|
97
|
-
this.icon = '
|
|
169
|
+
this.icon = '';
|
|
98
170
|
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
99
171
|
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
100
172
|
this.title = this.host.title;
|
|
@@ -123,6 +195,7 @@ const SallaModal = class {
|
|
|
123
195
|
return this.host;
|
|
124
196
|
}
|
|
125
197
|
toggleModal(isOpen) {
|
|
198
|
+
//todo:: use ref
|
|
126
199
|
Helper.Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
|
|
127
200
|
.toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
|
|
128
201
|
'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
|
|
@@ -138,17 +211,24 @@ const SallaModal = class {
|
|
|
138
211
|
}
|
|
139
212
|
this.host.removeAttribute('visible');
|
|
140
213
|
}
|
|
214
|
+
//todo:: pref for each modal
|
|
141
215
|
render() {
|
|
142
216
|
this.host.id = this.host.id || 'salla-modal';
|
|
143
|
-
return (index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), index.h("span", { class: "s-modal-spacer" }, "\u200B"), index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("
|
|
217
|
+
return (index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), index.h("span", { class: "s-modal-spacer" }, "\u200B"), index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("div", { class: { 's-modal-header': true,
|
|
218
|
+
'text-center': this.icon != '' } }, this.isClosable ?
|
|
144
219
|
index.h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
145
|
-
: '', this.error || this.success
|
|
146
|
-
? index.h("div", { class: {
|
|
220
|
+
: '', this.error || this.success || this.icon
|
|
221
|
+
? index.h("div", { class: {
|
|
222
|
+
's-modal-icon': true,
|
|
223
|
+
's-modal-bg-error': this.error,
|
|
224
|
+
's-modal-bg-success': this.success,
|
|
225
|
+
's-modal-bg-normal': !this.error && !this.success
|
|
226
|
+
} }, index.h("i", { class: {
|
|
147
227
|
[this.icon]: true,
|
|
148
228
|
's-modal-text-error': this.error,
|
|
149
|
-
's-modal-text-success': this.success
|
|
229
|
+
's-modal-text-success': this.success,
|
|
150
230
|
} }))
|
|
151
|
-
: '', index.h("div", { class: "s-modal-title", innerHTML: this.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))
|
|
231
|
+
: '', index.h("div", { class: "s-modal-title", innerHTML: this.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle })), index.h("slot", null), index.h("slot", { name: "footer" })))));
|
|
152
232
|
}
|
|
153
233
|
get host() { return index.getElement(this); }
|
|
154
234
|
static get watchers() { return {
|
|
@@ -158,4 +238,5 @@ const SallaModal = class {
|
|
|
158
238
|
|
|
159
239
|
exports.salla_login = sallaLogin.SallaLogin;
|
|
160
240
|
exports.multi_warehouse = MultiWarehouse;
|
|
241
|
+
exports.salla_button = SallaButton;
|
|
161
242
|
exports.salla_modal = SallaModal;
|
|
@@ -3,19 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-23da2c6b.js');
|
|
6
|
-
const Helper = require('./Helper-
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
7
|
|
|
8
8
|
const SallaLocalization = class {
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
index.registerInstance(this, hostRef);
|
|
11
|
+
var _a, _b;
|
|
12
|
+
this.language = salla.config.language;
|
|
13
|
+
this.currency = salla.config.currency;
|
|
14
|
+
this.languages = salla.lang.get('common.titles.language');
|
|
15
|
+
this.currencies = salla.lang.get('common.titles.currency');
|
|
16
|
+
this.ok = salla.lang.get('common.elements.ok');
|
|
11
17
|
Helper.Helper.setHost(this.host);
|
|
12
18
|
salla.event.on('localization::show', () => this.show());
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* letting developer to insert his own slot like:
|
|
21
|
+
* <salla-localization>
|
|
22
|
+
* <div slot="language">...{name}....</div>
|
|
23
|
+
* <div slot="currency">...{name}....</div>
|
|
24
|
+
* </salla-localization>
|
|
25
|
+
* Because scoped templates not supported in stencil );
|
|
26
|
+
* we made a workaround to pass language & currency attributes, then replace names in rendering
|
|
27
|
+
*/
|
|
28
|
+
this.languageSlot = ((_a = Helper.Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for"lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
|
|
29
|
+
this.currencySlot = ((_b = Helper.Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
|
|
19
30
|
}
|
|
20
31
|
async show() {
|
|
21
32
|
return this.modal.show();
|
|
@@ -23,7 +34,7 @@ const SallaLocalization = class {
|
|
|
23
34
|
async hide() {
|
|
24
35
|
return this.modal.hide();
|
|
25
36
|
}
|
|
26
|
-
submit() {
|
|
37
|
+
async submit() {
|
|
27
38
|
let url;
|
|
28
39
|
this.btn.load()
|
|
29
40
|
.then(() => {
|
|
@@ -41,10 +52,23 @@ const SallaLocalization = class {
|
|
|
41
52
|
}
|
|
42
53
|
render() {
|
|
43
54
|
return (index.h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, index.h("slot", { name: "header" }, index.h("div", { slot: "header" })), index.h("div", { class: "s-localization-inner" }, salla.config.languages
|
|
44
|
-
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" },
|
|
55
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.languages), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), index.h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), index.h("div", { id: "language-slot", innerHTML: this.languageSlot
|
|
56
|
+
.replace(/\{name\}/g, lang.name)
|
|
57
|
+
.replace(/\{code\}/g, lang.code)
|
|
58
|
+
.replace(/\{country_code\}/g, lang.country_code) }))))))
|
|
45
59
|
: '', salla.config.currencies
|
|
46
|
-
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" },
|
|
47
|
-
|
|
60
|
+
? index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.currencies), index.h("fieldset", { class: "s-localization-fieldset" }, index.h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), index.h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), index.h("div", { id: "currency-slot", innerHTML: this.currencySlot
|
|
61
|
+
.replace(/\{name\}/g, currency.name)
|
|
62
|
+
.replace(/\{code\}/g, currency.code)
|
|
63
|
+
.replace(/\{country_code\}/g, currency.country_code) }))))))
|
|
64
|
+
: ''), index.h("p", { slot: "footer" }, index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.submit(), class: "w-full" }, this.ok)))));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* to reduce dom levels we will move slot data into the parent dom
|
|
68
|
+
*/
|
|
69
|
+
componentDidRender() {
|
|
70
|
+
this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
71
|
+
this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
48
72
|
}
|
|
49
73
|
get host() { return index.getElement(this); }
|
|
50
74
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-23da2c6b.js');
|
|
6
|
+
const Helper = require('./Helper-8852feaa.js');
|
|
7
|
+
|
|
8
|
+
const SallaProductAvailability = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
this.isUser = Helper.Helper.isUser();
|
|
12
|
+
this.buttonText = salla.lang.get('pages.products.notify_availability');
|
|
13
|
+
this.countryCode = salla.config.country_code || 'SA';
|
|
14
|
+
this.subscribe = salla.lang.get('common.elements.submit');
|
|
15
|
+
this.cancel = salla.lang.get('common.elements.cancel');
|
|
16
|
+
this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
|
|
17
|
+
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
18
|
+
this.emailLabel = salla.lang.get('common.elements.email');
|
|
19
|
+
this.mobilePlaceholder = salla.lang.get('common.elements.mobile_placeholder');
|
|
20
|
+
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
21
|
+
this.productId = salla.config.page.id;
|
|
22
|
+
this.subscribed = salla.lang.get('pages.products.notify_availability_success');
|
|
23
|
+
if (this.isUser) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.channelsWatcher(this.channels);
|
|
27
|
+
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
28
|
+
this.host.removeAttribute('title');
|
|
29
|
+
}
|
|
30
|
+
channelsWatcher(newValue) {
|
|
31
|
+
this.channels_ = newValue.split(',');
|
|
32
|
+
}
|
|
33
|
+
async submit() {
|
|
34
|
+
if (this.isUser) {
|
|
35
|
+
return salla.api.product.availabilitySubscribe(this.productId)
|
|
36
|
+
.then(() => {
|
|
37
|
+
salla.success(this.subscribed);
|
|
38
|
+
}) //no need to wait until finishing alert animation
|
|
39
|
+
.then(() => this.host.remove());
|
|
40
|
+
}
|
|
41
|
+
let data = { id: this.productId, country_code: this.countryCode };
|
|
42
|
+
if (this.mobile.value !== '') {
|
|
43
|
+
data['mobile'] = this.mobile.value;
|
|
44
|
+
}
|
|
45
|
+
if (this.email.value !== '') {
|
|
46
|
+
data['email'] = this.email.value;
|
|
47
|
+
}
|
|
48
|
+
return this.btn.load()
|
|
49
|
+
.then(() => this.btn.disable())
|
|
50
|
+
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
51
|
+
.then(() => {
|
|
52
|
+
salla.success(this.subscribed);
|
|
53
|
+
}) //no need to wait until finishing alert animation
|
|
54
|
+
.then(() => this.btn.stop())
|
|
55
|
+
.then(() => this.modal.hide())
|
|
56
|
+
.then(() => this.host.remove())
|
|
57
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return (index.h(index.Host, null, index.h("slot", null, index.h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser ? '' : this.renderModal()));
|
|
61
|
+
}
|
|
62
|
+
renderModal() {
|
|
63
|
+
return (index.h("salla-modal", { ref: modal => this.modal = modal, id: "product-availability-modal", title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
|
|
64
|
+
index.h("label", { class: "s-product-availability-label" }, this.emailLabel),
|
|
65
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
|
|
66
|
+
] : '', this.channels_.includes('sms') ? [
|
|
67
|
+
index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
|
|
68
|
+
index.h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
|
|
69
|
+
index.h("input", { type: "hidden", value: this.countryCode }),
|
|
70
|
+
] : ''), index.h("div", { slot: "footer", class: "common-anime flex justify-between space-s-4" }, index.h("salla-button", { ref: btn => this.btn = btn, class: "w-full", onClick: () => this.submit() }, this.subscribe), index.h("salla-button", { class: "w-full", color: "outline" }, this.cancel))));
|
|
71
|
+
}
|
|
72
|
+
get host() { return index.getElement(this); }
|
|
73
|
+
static get watchers() { return {
|
|
74
|
+
"channels": ["channelsWatcher"]
|
|
75
|
+
}; }
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.salla_product_availability = SallaProductAvailability;
|