@salla.sa/twilight-components 1.0.35 → 1.0.37
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/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_7.cjs.entry.js +34 -29
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +14 -4
- package/dist/cjs/salla-offer.cjs.entry.js +65 -16
- package/dist/cjs/salla-product-availability.cjs.entry.js +14 -10
- package/dist/cjs/salla-rating.cjs.entry.js +7 -8
- package/dist/cjs/{salla-search-6738ec5e.js → salla-search-f95dcd0c.js} +8 -6
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +14 -4
- package/dist/collection/components/salla-localization/salla-localization.js +22 -25
- package/dist/collection/components/salla-login/salla-login.css +0 -4
- package/dist/collection/components/salla-login/salla-login.js +6 -4
- package/dist/collection/components/salla-modal/salla-modal.js +7 -5
- package/dist/collection/components/salla-offer/salla-offer.css +23 -0
- package/dist/collection/components/salla-offer/salla-offer.js +88 -25
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +16 -11
- package/dist/collection/components/salla-rating/salla-rating.js +7 -8
- package/dist/collection/components/salla-search/salla-search.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_7.entry.js +34 -29
- package/dist/esm/salla-infinite-scroll.entry.js +14 -4
- package/dist/esm/salla-offer.entry.js +65 -16
- package/dist/esm/salla-product-availability.entry.js +14 -10
- package/dist/esm/salla-rating.entry.js +7 -8
- package/dist/esm/{salla-search-90231876.js → salla-search-8bb6a0da.js} +8 -6
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-187bdf52.js +1 -0
- package/dist/twilight-components/p-19a124e9.entry.js +1 -0
- package/dist/twilight-components/p-6ccad297.entry.js +1 -0
- package/dist/twilight-components/p-855690ed.entry.js +1 -0
- package/dist/twilight-components/p-a90a5872.entry.js +1 -0
- package/dist/twilight-components/p-ec676556.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +2 -1
- package/dist/types/components/salla-offer/salla-offer.d.ts +4 -1
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +1 -0
- package/dist/types/components.d.ts +1 -1
- package/example/index.html +1 -1
- package/package.json +2 -2
- package/dist/twilight-components/p-15751894.entry.js +0 -1
- package/dist/twilight-components/p-2abf9fc5.js +0 -1
- package/dist/twilight-components/p-5a498763.entry.js +0 -1
- package/dist/twilight-components/p-ca832aac.entry.js +0 -1
- package/dist/twilight-components/p-f36fa4c6.entry.js +0 -1
- package/dist/twilight-components/p-fa3b938e.entry.js +0 -1
|
@@ -9,10 +9,11 @@ import Helper from "../../Helpers/Helper";
|
|
|
9
9
|
export class SallaLocalization {
|
|
10
10
|
constructor() {
|
|
11
11
|
var _a, _b;
|
|
12
|
-
this.language = salla.config.get('
|
|
13
|
-
this.currency = salla.config.get('
|
|
12
|
+
this.language = salla.config.get('user.language_code');
|
|
13
|
+
this.currency = salla.config.get('user.currency_code');
|
|
14
14
|
this.languages = [];
|
|
15
15
|
this.currencies = [];
|
|
16
|
+
this.isLoading = true;
|
|
16
17
|
Helper.setHost(this.host);
|
|
17
18
|
salla.event.on('localization::show', () => this.show());
|
|
18
19
|
salla.event.on('languages::translations.loaded', () => {
|
|
@@ -37,9 +38,10 @@ export class SallaLocalization {
|
|
|
37
38
|
* Show the component
|
|
38
39
|
*/
|
|
39
40
|
async show() {
|
|
40
|
-
return this.
|
|
41
|
+
return this.modal.show()
|
|
42
|
+
.then(() => this.getLanguages())
|
|
41
43
|
.then(() => this.getCurrencies())
|
|
42
|
-
.then(() => this.
|
|
44
|
+
.then(() => this.isLoading = false);
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Hide the component
|
|
@@ -54,52 +56,49 @@ export class SallaLocalization {
|
|
|
54
56
|
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
|
|
55
57
|
}
|
|
56
58
|
onChangeCurrency(event) {
|
|
57
|
-
this.currency =
|
|
59
|
+
this.currency = event.target.value;
|
|
58
60
|
}
|
|
59
61
|
onChangeLanguage(event) {
|
|
60
|
-
this.language =
|
|
62
|
+
this.language = event.target.value;
|
|
61
63
|
}
|
|
62
64
|
async submit() {
|
|
63
65
|
let url;
|
|
64
|
-
console.log('this.currency.code::::', this.currency, this.currency.code); //todo:: remove it
|
|
65
66
|
this.btn.load()
|
|
66
|
-
.then(() => this.currency
|
|
67
|
-
.then(() => this.language
|
|
67
|
+
.then(() => this.currency === salla.config.get('user.currency_code', 'SAR') || ((url = window.location.href) && salla.currency.api.change(this.currency)))
|
|
68
|
+
.then(() => this.language === salla.config.get('user.language_code', 'ar') || (url = salla.helpers.addParamsToUrl('lang', this.language)))
|
|
68
69
|
.then(() => this.btn.stop())
|
|
69
70
|
.then(() => this.hide())
|
|
70
71
|
.then(() => url && (window.location.href = url));
|
|
71
72
|
}
|
|
72
73
|
render() {
|
|
73
|
-
return (h("salla-modal", { id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" },
|
|
74
|
-
h("div", { slot: "header" },
|
|
75
|
-
h("slot", { name: "header" })),
|
|
74
|
+
return (h("salla-modal", { isLoading: this.isLoading, id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" }, !this.isLoading ?
|
|
76
75
|
h("div", { class: "s-localization-inner" },
|
|
77
76
|
this.languages.length > 1 ?
|
|
78
77
|
h("div", { class: "s-localization-section" },
|
|
79
78
|
h("label", { class: "s-localization-title" }, this.languagesTitle),
|
|
80
79
|
h("div", { class: "s-localization-section-inner" }, this.languages.length < 6 ?
|
|
81
80
|
this.languages.map(lang => h("div", { class: "s-localization-item" },
|
|
82
|
-
h("input", { class: "s-localization-input", type: "radio", checked: this.language
|
|
81
|
+
h("input", { class: "s-localization-input", type: "radio", checked: this.language == lang.iso_code, onChange: () => this.language = lang.iso_code, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }),
|
|
83
82
|
h("div", { id: "language-slot", innerHTML: this.languageSlot
|
|
84
83
|
.replace(/\{name\}/g, lang.name)
|
|
85
84
|
.replace(/\{code\}/g, lang.code)
|
|
86
85
|
.replace(/\{country_code\}/g, lang.country_code) }))) :
|
|
87
|
-
h("select", { class: "s-
|
|
86
|
+
h("select", { class: "s-localization-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => h("option", { value: lang.code, selected: this.language == lang.code }, lang.name)))))
|
|
88
87
|
: '',
|
|
89
88
|
this.currencies.length > 1 ?
|
|
90
89
|
h("div", { class: "s-localization-section" },
|
|
91
90
|
h("label", { class: "s-localization-title" }, this.currenciesTitle),
|
|
92
91
|
h("div", { class: "s-localization-section-inner" }, this.currencies.length < 6 ?
|
|
93
92
|
this.currencies.map(currency => h("div", { class: "s-localization-item" },
|
|
94
|
-
h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency
|
|
93
|
+
h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency == currency.code, onChange: () => this.currency = currency.code, id: 'currency-' + currency.code, value: currency.code }),
|
|
95
94
|
h("div", { id: "currency-slot", innerHTML: this.currencySlot
|
|
96
95
|
.replace(/\{name\}/g, currency.name)
|
|
97
96
|
.replace(/\{code\}/g, currency.code)
|
|
98
97
|
.replace(/\{country_code\}/g, currency.country_code) }))) :
|
|
99
|
-
h("select", { class: "s-
|
|
100
|
-
: ''
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
h("select", { class: "s-localization-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => h("option", { value: currency.code, selected: this.currency == currency.code }, currency.name)))))
|
|
99
|
+
: '',
|
|
100
|
+
h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))
|
|
101
|
+
: ''));
|
|
103
102
|
}
|
|
104
103
|
/**
|
|
105
104
|
* to reduce dom levels we will move slot data into the parent dom
|
|
@@ -113,22 +112,20 @@ export class SallaLocalization {
|
|
|
113
112
|
"languages": {},
|
|
114
113
|
"currencies": {},
|
|
115
114
|
"languagesTitle": {},
|
|
116
|
-
"currenciesTitle": {}
|
|
115
|
+
"currenciesTitle": {},
|
|
116
|
+
"isLoading": {}
|
|
117
117
|
}; }
|
|
118
118
|
static get methods() { return {
|
|
119
119
|
"show": {
|
|
120
120
|
"complexType": {
|
|
121
|
-
"signature": "() => Promise<
|
|
121
|
+
"signature": "() => Promise<boolean>",
|
|
122
122
|
"parameters": [],
|
|
123
123
|
"references": {
|
|
124
124
|
"Promise": {
|
|
125
125
|
"location": "global"
|
|
126
|
-
},
|
|
127
|
-
"HTMLElement": {
|
|
128
|
-
"location": "global"
|
|
129
126
|
}
|
|
130
127
|
},
|
|
131
|
-
"return": "Promise<
|
|
128
|
+
"return": "Promise<boolean>"
|
|
132
129
|
},
|
|
133
130
|
"docs": {
|
|
134
131
|
"text": "Show the component",
|
|
@@ -84,14 +84,13 @@ export class SallaLogin {
|
|
|
84
84
|
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
85
85
|
this.host.removeAttribute('title');
|
|
86
86
|
salla.event.on('languages::translations.loaded', () => {
|
|
87
|
-
var _a;
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
88
|
this.title = salla.lang.get('blocks.header.login');
|
|
89
89
|
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
90
90
|
this.loginText = salla.lang.get('blocks.header.login');
|
|
91
91
|
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
92
92
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
93
93
|
this.emailLabel = salla.lang.get('common.elements.email');
|
|
94
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
95
94
|
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
96
95
|
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
97
96
|
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
@@ -100,6 +99,9 @@ export class SallaLogin {
|
|
|
100
99
|
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
101
100
|
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
102
101
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
102
|
+
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
103
|
+
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
104
|
+
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
103
105
|
});
|
|
104
106
|
salla.auth.event.onVerificationFailed(() => {
|
|
105
107
|
//
|
|
@@ -199,7 +201,7 @@ export class SallaLogin {
|
|
|
199
201
|
h("slot", { name: "before-login-mobile" }),
|
|
200
202
|
h("label", { class: "s-login-label" }, this.mobileLabel),
|
|
201
203
|
h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }),
|
|
202
|
-
h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b },
|
|
204
|
+
h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')),
|
|
203
205
|
this.isEmailAllowed ?
|
|
204
206
|
h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-link" }, this.byEmailText) : '',
|
|
205
207
|
h("slot", { name: "after-login-mobile" })) : '',
|
|
@@ -209,7 +211,7 @@ export class SallaLogin {
|
|
|
209
211
|
h("label", { class: "s-login-label" }, this.emailLabel),
|
|
210
212
|
h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-input s-ltr" }),
|
|
211
213
|
h("span", { class: "s-login-error-message" }),
|
|
212
|
-
h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b },
|
|
214
|
+
h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')),
|
|
213
215
|
this.isMobileAllowed ?
|
|
214
216
|
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-link" }, this.bySMSText) : '',
|
|
215
217
|
h("slot", { name: "after-login-email" })) : '',
|
|
@@ -90,7 +90,8 @@ export class SallaModal {
|
|
|
90
90
|
return this.host;
|
|
91
91
|
}
|
|
92
92
|
toggleModal(isOpen) {
|
|
93
|
-
|
|
93
|
+
const body = this.host.querySelector('.s-modal-body');
|
|
94
|
+
Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
94
95
|
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
95
96
|
//todo:: use united class names
|
|
96
97
|
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
@@ -126,14 +127,15 @@ export class SallaModal {
|
|
|
126
127
|
render() {
|
|
127
128
|
this.host.id = this.host.id || 'salla-modal';
|
|
128
129
|
return (h(Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" },
|
|
130
|
+
h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }),
|
|
129
131
|
h("div", { class: "s-modal-wrapper" },
|
|
130
|
-
h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }),
|
|
131
132
|
h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"),
|
|
132
|
-
h("div", { class: 's-modal-body
|
|
133
|
-
|
|
133
|
+
h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading ?
|
|
134
|
+
h("div", { class: "s-modal-loader-wrap" },
|
|
134
135
|
h("span", { class: "s-modal-loader" }))
|
|
135
136
|
:
|
|
136
|
-
[
|
|
137
|
+
[
|
|
138
|
+
h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } },
|
|
137
139
|
this.isClosable ?
|
|
138
140
|
h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" },
|
|
139
141
|
h("span", { class: "sicon-cancel" }))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial Variables
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Functions
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Delivered variables
|
|
9
|
+
*/
|
|
10
|
+
.s-offer-body {
|
|
11
|
+
-webkit-overflow-scrolling: touch;
|
|
12
|
+
}
|
|
13
|
+
.s-offer-body::-webkit-scrollbar {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.s-offer-next-btn {
|
|
18
|
+
background: linear-gradient(90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.s-offer-prev-btn {
|
|
22
|
+
background: linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%);
|
|
23
|
+
}
|
|
@@ -7,12 +7,17 @@ import Helper from "../../Helpers/Helper";
|
|
|
7
7
|
*/
|
|
8
8
|
export class SallaOffer {
|
|
9
9
|
constructor() {
|
|
10
|
-
var _a, _b
|
|
10
|
+
var _a, _b;
|
|
11
11
|
this.offer = null;
|
|
12
|
+
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
13
|
+
this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
|
|
12
14
|
Helper.setHost(this.host);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
16
|
+
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
17
|
+
this.remember_my_choice = salla.lang.get('common.remember_my_choice');
|
|
18
|
+
});
|
|
19
|
+
this.categorySlot = ((_a = Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-badge-icon sicon-tag"></i><span class="s-offer-badge-text">{name}</span>';
|
|
20
|
+
this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
|
|
16
21
|
salla.offer.event.onExisted(data => {
|
|
17
22
|
//TODO:: use the best, should we hide the offer by product Id or Offer id🤔
|
|
18
23
|
if (salla.localData.get('remember-offer-' + data.offer.offer_id)) {
|
|
@@ -28,7 +33,8 @@ export class SallaOffer {
|
|
|
28
33
|
*/
|
|
29
34
|
async show(product_id) {
|
|
30
35
|
//TODO:: make sure there is only one offer
|
|
31
|
-
return salla.api.offer.details(product_id)
|
|
36
|
+
return salla.api.offer.details(product_id)
|
|
37
|
+
.then(response => this.showOffer(response.data[0]));
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Show offer details
|
|
@@ -36,6 +42,8 @@ export class SallaOffer {
|
|
|
36
42
|
*/
|
|
37
43
|
async showOffer(offer) {
|
|
38
44
|
this.offer = offer;
|
|
45
|
+
this.offer_name = offer.name;
|
|
46
|
+
this.offer_message = offer.message;
|
|
39
47
|
return this.modal.show();
|
|
40
48
|
}
|
|
41
49
|
rememberMe(event) {
|
|
@@ -49,7 +57,7 @@ export class SallaOffer {
|
|
|
49
57
|
.finally(() => this['stop']());
|
|
50
58
|
}
|
|
51
59
|
defaultProductSlot() {
|
|
52
|
-
return '<a href={url} class="s-offer-product-image"><img class="s-offer-product-
|
|
60
|
+
return '<a href={url} class="s-offer-product-image-wrap"><img class="s-offer-product-image" src="{image}" /></a>' +
|
|
53
61
|
'<div class="s-offer-product-info">' +
|
|
54
62
|
' <a href={url} class="s-offer-product-name">{name}</a>' +
|
|
55
63
|
' <div class="s-offer-product-price">{price}</div>' +
|
|
@@ -57,43 +65,98 @@ export class SallaOffer {
|
|
|
57
65
|
}
|
|
58
66
|
render() {
|
|
59
67
|
var _a, _b;
|
|
60
|
-
return h("salla-modal", { ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
|
|
61
|
-
? [h("div", { class: "s-offer-
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
return h("salla-modal", { "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
|
|
69
|
+
? [h("div", { class: "s-offer-scrolled-slider-wrap" },
|
|
70
|
+
h("div", { class: "s-offer-body s-offer-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
71
|
+
? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-badge s-offer-slider-item", innerHTML: this.categorySlot
|
|
72
|
+
.replace(/\{name\}/g, category.name)
|
|
73
|
+
.replace(/\{url\}/g, category.urls.customer) }))
|
|
74
|
+
: (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-product s-offer-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
|
|
75
|
+
.replace(/\{name\}/g, product.name)
|
|
76
|
+
.replace(/\{url\}/g, product.url)
|
|
77
|
+
.replace(/\{image\}/g, product.thumbnail)
|
|
78
|
+
.replace(/\{price\}/g, product.has_special_price
|
|
79
|
+
? salla.money(product.price) + '<span class="s-offer-product-old-price">' + salla.money(product.regular_price) + '</span>'
|
|
80
|
+
: salla.money({ amount: product.price, currency: salla.config.get('user').currency_code })) },
|
|
81
|
+
h("div", { class: "s-offer-btn-wrap" },
|
|
82
|
+
h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))),
|
|
83
|
+
h("div", { class: "s-offer-slider-nav" },
|
|
84
|
+
h("button", { class: "s-offer-nav-btn s-offer-prev-btn" },
|
|
85
|
+
h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_right" })),
|
|
86
|
+
h("button", { class: "s-offer-nav-btn s-offer-next-btn" },
|
|
87
|
+
h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_left" })))),
|
|
76
88
|
h("div", { class: "s-offer-footer", slot: "footer" },
|
|
77
89
|
this.offer.expiry_date ?
|
|
78
90
|
h("p", { class: "s-offer-expiry" },
|
|
79
|
-
|
|
91
|
+
this.offer_expires_in,
|
|
80
92
|
" ",
|
|
81
93
|
this.offer.expiry_date)
|
|
82
94
|
: '',
|
|
83
95
|
h("label", { class: "s-offer-remember-label" },
|
|
84
96
|
h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }),
|
|
85
97
|
"\u00A0 ",
|
|
86
|
-
|
|
98
|
+
this.remember_my_choice)),
|
|
87
99
|
] : '');
|
|
88
100
|
}
|
|
89
101
|
componentDidRender() {
|
|
90
102
|
//todo:: know from where there is hidden attributes to the doms🤔
|
|
91
103
|
//todo:: add animation
|
|
92
104
|
this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
|
|
105
|
+
// Sooo mini Slider
|
|
106
|
+
if (this.offer && window.screen.width > 639) {
|
|
107
|
+
let sliderWrap = this.host.querySelector('.s-offer-scrolled-slider-wrap'), slider = this.host.querySelector('.s-offer-scrolled-slider'), navButtons = this.host.querySelectorAll('.s-offer-nav-btn'), nexBtn = this.host.querySelector('.s-offer-next-btn'), prevBtn = this.host.querySelector('.s-offer-prev-btn'), items = this.host.querySelectorAll('.s-offer-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
|
|
108
|
+
current = 0, // current slide
|
|
109
|
+
slidesToScroll = 3, itemsLength = items.length, itemSize = items[0].offsetWidth, sliderSize = itemsLength * itemSize, sliderWrapperSize = sliderWrap.offsetWidth, sliderInvisibleSize = sliderSize - sliderWrapperSize, isRTL = document.body.classList.contains('rtl') ? true : false;
|
|
110
|
+
if (sliderInvisibleSize > sliderNavMargin)
|
|
111
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
112
|
+
window.onresize = function () {
|
|
113
|
+
sliderWrapperSize = sliderWrap.offsetWidth;
|
|
114
|
+
sliderInvisibleSize = sliderSize - sliderWrapperSize;
|
|
115
|
+
};
|
|
116
|
+
slider.addEventListener('scroll', function () {
|
|
117
|
+
let sliderPosition = Math.abs(slider.scrollLeft);
|
|
118
|
+
let sliderEndOffset = sliderInvisibleSize - sliderNavMargin;
|
|
119
|
+
// show & hide the navigation btns depending on scroll position
|
|
120
|
+
if (sliderPosition <= sliderNavMargin) {
|
|
121
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
122
|
+
prevBtn.classList.remove('s-offer-btn-is-active');
|
|
123
|
+
}
|
|
124
|
+
else if (sliderPosition < sliderEndOffset) {
|
|
125
|
+
// show both btns in the middle
|
|
126
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
127
|
+
prevBtn.classList.add('s-offer-btn-is-active');
|
|
128
|
+
}
|
|
129
|
+
else if (sliderPosition >= sliderEndOffset) {
|
|
130
|
+
nexBtn.classList.remove('s-offer-btn-is-active');
|
|
131
|
+
prevBtn.classList.add('s-offer-btn-is-active');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
// Navigation
|
|
135
|
+
navButtons.forEach(btn => {
|
|
136
|
+
btn.addEventListener('click', function () {
|
|
137
|
+
btn.classList.contains('s-offer-next-btn') ? current++ : current--;
|
|
138
|
+
slider.scrollTo({
|
|
139
|
+
top: 0,
|
|
140
|
+
left: itemSize * slidesToScroll * current * (isRTL ? -1 : 1),
|
|
141
|
+
behavior: 'smooth'
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
93
146
|
}
|
|
94
147
|
static get is() { return "salla-offer"; }
|
|
148
|
+
static get originalStyleUrls() { return {
|
|
149
|
+
"$": ["salla-offer.scss"]
|
|
150
|
+
}; }
|
|
151
|
+
static get styleUrls() { return {
|
|
152
|
+
"$": ["salla-offer.css"]
|
|
153
|
+
}; }
|
|
95
154
|
static get states() { return {
|
|
96
|
-
"offer": {}
|
|
155
|
+
"offer": {},
|
|
156
|
+
"offer_name": {},
|
|
157
|
+
"offer_message": {},
|
|
158
|
+
"offer_expires_in": {},
|
|
159
|
+
"remember_my_choice": {}
|
|
97
160
|
}; }
|
|
98
161
|
static get methods() { return {
|
|
99
162
|
"show": {
|
|
@@ -24,7 +24,10 @@ export class SallaProductAvailability {
|
|
|
24
24
|
return this.btn.load()
|
|
25
25
|
.then(() => this.btn.disable())
|
|
26
26
|
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
27
|
-
.then(() =>
|
|
27
|
+
.then(() => {
|
|
28
|
+
this.isSubscribed = true;
|
|
29
|
+
salla.localData.set(`product-${this.productId}-subscribed`, true);
|
|
30
|
+
}) //no need to wait until finishing alert animation
|
|
28
31
|
.then(() => this.btn.stop())
|
|
29
32
|
.then(() => this.modal.hide())
|
|
30
33
|
.catch(() => this.btn.stop() && this.btn.enable());
|
|
@@ -36,26 +39,27 @@ export class SallaProductAvailability {
|
|
|
36
39
|
(error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
|
|
37
40
|
e.key == 'Enter' && submitMethod();
|
|
38
41
|
};
|
|
39
|
-
if (this.isUser) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.channelsWatcher(this.channels);
|
|
43
|
-
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
44
|
-
this.host.removeAttribute('title');
|
|
45
42
|
salla.event.on('languages::translations.loaded', () => {
|
|
46
43
|
var _a, _b, _c, _d;
|
|
44
|
+
// console.log('translations:', salla.lang);
|
|
45
|
+
this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
47
46
|
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
48
47
|
this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
|
|
49
48
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
50
49
|
this.emailLabel = salla.lang.get('common.elements.email');
|
|
51
50
|
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
52
|
-
this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
53
51
|
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
54
52
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
|
|
55
53
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('common.elements.submit'));
|
|
56
54
|
(_c = this.cancelBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('common.elements.cancel'));
|
|
57
55
|
(_d = this.inlineBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('pages.products.notify_availability'));
|
|
58
56
|
});
|
|
57
|
+
if (this.isUser)
|
|
58
|
+
return;
|
|
59
|
+
this.channelsWatcher(this.channels);
|
|
60
|
+
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
61
|
+
this.host.removeAttribute('title');
|
|
62
|
+
this.isVisitorSubscribed = salla.localData.get(`product-${this.productId}-subscribed`);
|
|
59
63
|
}
|
|
60
64
|
channelsWatcher(newValue) {
|
|
61
65
|
this.channels_ = newValue.split(',');
|
|
@@ -80,14 +84,14 @@ export class SallaProductAvailability {
|
|
|
80
84
|
}
|
|
81
85
|
render() {
|
|
82
86
|
return (h(Host, null,
|
|
83
|
-
this.isSubscribed
|
|
87
|
+
this.isSubscribed || this.isVisitorSubscribed
|
|
84
88
|
? h("div", { class: "s-product-availability-subscribed" },
|
|
85
89
|
h("i", { class: "sicon-bell-ring s-product-availability-subs-icon" }),
|
|
86
90
|
" ",
|
|
87
91
|
this.subscribedMessage)
|
|
88
92
|
: h("slot", null,
|
|
89
93
|
h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show(), wide: true, ref: btn => this.inlineBtn = btn }, salla.lang.get('pages.products.notify_availability'))),
|
|
90
|
-
this.isUser || this.isSubscribed ? '' : this.renderModal()));
|
|
94
|
+
this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
|
|
91
95
|
}
|
|
92
96
|
renderModal() {
|
|
93
97
|
return (h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "sm" },
|
|
@@ -168,7 +172,8 @@ export class SallaProductAvailability {
|
|
|
168
172
|
"emailPlaceholder": {},
|
|
169
173
|
"subscribedMessage": {},
|
|
170
174
|
"title_": {},
|
|
171
|
-
"emailErrorMsg": {}
|
|
175
|
+
"emailErrorMsg": {},
|
|
176
|
+
"isVisitorSubscribed": {}
|
|
172
177
|
}; }
|
|
173
178
|
static get elementRef() { return "host"; }
|
|
174
179
|
static get watchers() { return [{
|
|
@@ -56,7 +56,7 @@ export class SallaRating {
|
|
|
56
56
|
// Prevent form from submitting
|
|
57
57
|
event.preventDefault();
|
|
58
58
|
// Get the selected star - activeElement is not supported in safari
|
|
59
|
-
let activeStars = event.target.querySelectorAll('.s-rating-btn-star.hovered');
|
|
59
|
+
let activeStars = event.target.querySelectorAll('.s-rating-btn-star.s-rating-hovered');
|
|
60
60
|
let selected = activeStars[activeStars.length - 1];
|
|
61
61
|
if (!selected)
|
|
62
62
|
return;
|
|
@@ -66,7 +66,7 @@ export class SallaRating {
|
|
|
66
66
|
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
67
67
|
event.target
|
|
68
68
|
.querySelectorAll('.s-rating-btn-star')
|
|
69
|
-
.forEach((star, index) => Helper.toggleElement(star, 'selected', 'un-selected', () => index < selectedIndex));
|
|
69
|
+
.forEach((star, index) => Helper.toggleElement(star, 's-rating-selected', 's-rating-un-selected', () => index < selectedIndex));
|
|
70
70
|
// Remove aria-pressed from any previously selected star
|
|
71
71
|
event.target.querySelectorAll('.s-rating-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
|
|
72
72
|
// Add aria-pressed role to the selected button
|
|
@@ -91,13 +91,12 @@ export class SallaRating {
|
|
|
91
91
|
}
|
|
92
92
|
// Btn text
|
|
93
93
|
let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
|
|
94
|
-
this.nextBtn.
|
|
95
|
-
|
|
96
|
-
: salla.lang.get('pages.rating.send_ratings');
|
|
94
|
+
this.nextBtn.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
|
|
95
|
+
: salla.lang.get('pages.rating.send_ratings'));
|
|
97
96
|
setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
|
|
98
97
|
}
|
|
99
98
|
highlightSelectedStars() {
|
|
100
|
-
let hover = ['hovered'];
|
|
99
|
+
let hover = ['s-rating-hovered'];
|
|
101
100
|
Helper.all('.s-rating-stars-element', el => {
|
|
102
101
|
let starElements = el.querySelectorAll('.s-rating-btn-star');
|
|
103
102
|
// remove hovered state from stars ---
|
|
@@ -151,12 +150,12 @@ export class SallaRating {
|
|
|
151
150
|
let comment = rating.querySelector('.s-rating-comment');
|
|
152
151
|
let validationMessage = rating.querySelector('.s-rating-validation-msg');
|
|
153
152
|
if (stars && comment.value && comment.value.length > 3) {
|
|
154
|
-
comment.classList.remove('s-
|
|
153
|
+
comment.classList.remove('s-has-error');
|
|
155
154
|
validationMessage.innerHTML = '';
|
|
156
155
|
return;
|
|
157
156
|
}
|
|
158
157
|
type = type || rating['dataset'].type;
|
|
159
|
-
Helper.toggleElement(comment, 'save', 's-
|
|
158
|
+
Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
|
|
160
159
|
throw validationMessage.innerHTML = stars
|
|
161
160
|
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
|
|
162
161
|
: salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
|
|
@@ -27,7 +27,7 @@ export class SallaSearch {
|
|
|
27
27
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
28
28
|
'</div>' +
|
|
29
29
|
'<div class="s-search-product-details">' +
|
|
30
|
-
' <div class="s-search-product-
|
|
30
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
31
31
|
'</div>';
|
|
32
32
|
}
|
|
33
33
|
//todo:: reset data when closing
|
package/dist/esm/index.js
CHANGED
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[
|
|
13
|
+
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches",[[4,"salla-branches",{"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]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|