@salla.sa/twilight-components 1.0.33 → 1.0.35
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-branches.cjs.entry.js +7 -8
- package/dist/cjs/salla-button_7.cjs.entry.js +156 -56
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -0
- package/dist/cjs/salla-offer.cjs.entry.js +10 -2
- package/dist/cjs/salla-product-availability.cjs.entry.js +6 -0
- package/dist/cjs/salla-rating.cjs.entry.js +12 -2
- package/dist/cjs/{salla-search-62921989.js → salla-search-6738ec5e.js} +11 -10
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-branches/salla-branches.js +8 -10
- package/dist/collection/components/salla-button/salla-button.js +63 -26
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +4 -1
- package/dist/collection/components/salla-localization/salla-localization.js +25 -9
- package/dist/collection/components/salla-login/salla-login.js +32 -17
- package/dist/collection/components/salla-modal/salla-modal.js +84 -47
- package/dist/collection/components/salla-offer/salla-offer.js +29 -9
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +11 -5
- package/dist/collection/components/salla-rating/salla-rating.js +35 -5
- package/dist/collection/components/salla-search/salla-search.js +3 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +30 -14
- package/dist/collection/components/salla-verify/salla-verify.js +43 -50
- package/dist/collection/plugins/tailwind-theme/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +7 -8
- package/dist/esm/salla-button_7.entry.js +156 -56
- package/dist/esm/salla-infinite-scroll.entry.js +3 -0
- package/dist/esm/salla-offer.entry.js +10 -2
- package/dist/esm/salla-product-availability.entry.js +6 -0
- package/dist/esm/salla-rating.entry.js +12 -2
- package/dist/esm/{salla-search-96520d15.js → salla-search-90231876.js} +11 -10
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-2abf9fc5.js +1 -0
- package/dist/twilight-components/p-5a498763.entry.js +1 -0
- package/dist/twilight-components/p-9b41d0b5.entry.js +1 -0
- package/dist/twilight-components/p-f36fa4c6.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-branches/salla-branches.d.ts +0 -1
- package/dist/types/components/salla-button/salla-button.d.ts +32 -1
- package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +3 -0
- package/dist/types/components/salla-localization/salla-localization.d.ts +10 -2
- package/dist/types/components/salla-login/salla-login.d.ts +14 -1
- package/dist/types/components/salla-modal/salla-modal.d.ts +37 -2
- package/dist/types/components/salla-offer/salla-offer.d.ts +9 -1
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +10 -1
- package/dist/types/components/salla-rating/salla-rating.d.ts +10 -0
- package/dist/types/components/salla-search/salla-search.d.ts +3 -0
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +15 -1
- package/dist/types/components/salla-verify/salla-verify.d.ts +26 -4
- package/dist/types/components.d.ts +209 -10
- package/example/.DS_Store +0 -0
- package/example/currencies +23 -0
- package/example/dist/.DS_Store +0 -0
- package/example/dist/twilight.js +1 -1
- package/example/index.html +3 -45
- package/example/languages +17 -0
- package/example/products/search +13 -0
- package/package.json +1 -1
- package/dist/twilight-components/p-352ce785.js +0 -1
- package/dist/twilight-components/p-9cabc8a4.entry.js +0 -1
- package/dist/twilight-components/p-a841c013.entry.js +0 -1
- package/dist/twilight-components/p-fbfd14a6.entry.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
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([["salla-button_7.cjs",[[
|
|
17
|
+
return index.bootstrapLazy([["salla-button_7.cjs",[[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"]]],[4,"salla-localization",{"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[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.cjs",[[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]}]]],["salla-branches.cjs",[[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.cjs",[[0,"salla-offer",{"offer":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -11,8 +11,8 @@ const SallaBranches = class {
|
|
|
11
11
|
index.registerInstance(this, hostRef);
|
|
12
12
|
this.open = false;
|
|
13
13
|
this.isOpenedBefore = salla.localData.get("branch-choosed-before");
|
|
14
|
-
this.displayAs = 'default';
|
|
15
|
-
this.browseProductsFrom = 'all';
|
|
14
|
+
this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
|
|
15
|
+
this.browseProductsFrom = 'all'; //todo:: get better name
|
|
16
16
|
this.branches = [
|
|
17
17
|
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
18
18
|
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
@@ -39,10 +39,9 @@ const SallaBranches = class {
|
|
|
39
39
|
: 'التسوق من فرع آخر';
|
|
40
40
|
};
|
|
41
41
|
salla.event.on('branches::show', () => this.show());
|
|
42
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
43
|
-
this.ok = salla.lang.get('common.elements.ok');
|
|
44
|
-
});
|
|
42
|
+
salla.event.on('languages::translations.loaded', () => { var _a; return (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok')); });
|
|
45
43
|
}
|
|
44
|
+
//todo:: add description for all @methods
|
|
46
45
|
async show() {
|
|
47
46
|
return this.modal.show();
|
|
48
47
|
}
|
|
@@ -63,11 +62,11 @@ const SallaBranches = class {
|
|
|
63
62
|
}, 300);
|
|
64
63
|
}
|
|
65
64
|
render() {
|
|
66
|
-
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", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, width: "sm", id: "s-branches-modal", class: "hidden" }, index.h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
|
|
65
|
+
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", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, width: "sm", id: "s-branches-modal", class: "s-hidden" }, index.h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
|
|
67
66
|
index.h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => index.h("div", { class: "s-branches-input-wrap" }, 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: {
|
|
68
67
|
's-branches-input': true,
|
|
69
68
|
'opacity-50': !branch.open,
|
|
70
|
-
'hidden': !this.isChoiceable()
|
|
69
|
+
's-hidden': !this.isChoiceable()
|
|
71
70
|
}, checked: this.current == branch.id }), index.h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
|
|
72
71
|
's-branches-label': true,
|
|
73
72
|
's-branches-clickable': this.isChoiceable()
|
|
@@ -77,7 +76,7 @@ const SallaBranches = class {
|
|
|
77
76
|
index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
78
77
|
:
|
|
79
78
|
index.h("select", { class: "s-branches-select", 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() ?
|
|
80
|
-
index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true },
|
|
79
|
+
index.h("slot", { name: "footer" }, index.h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true }, salla.lang.get('common.elements.ok')))
|
|
81
80
|
: ''));
|
|
82
81
|
}
|
|
83
82
|
componentDidRender() {
|
|
@@ -4,20 +4,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-714023c8.js');
|
|
6
6
|
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
-
const sallaSearch = require('./salla-search-
|
|
7
|
+
const sallaSearch = require('./salla-search-6738ec5e.js');
|
|
8
8
|
|
|
9
9
|
const sallaButtonCss = ":host{display:block}";
|
|
10
10
|
|
|
11
11
|
const SallaButton = class {
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
|
+
/**
|
|
15
|
+
* Button Style
|
|
16
|
+
*/
|
|
14
17
|
this.btnStyle = 'primary';
|
|
18
|
+
/**
|
|
19
|
+
* Is the button currently loading
|
|
20
|
+
*/
|
|
15
21
|
this.loading = false;
|
|
22
|
+
/**
|
|
23
|
+
* Is the button currently disabled
|
|
24
|
+
*/
|
|
16
25
|
this.disabled = false;
|
|
26
|
+
/**
|
|
27
|
+
* If there is need to change loader position, pass the position
|
|
28
|
+
*/
|
|
17
29
|
this.loaderPosition = 'before';
|
|
30
|
+
/**
|
|
31
|
+
* Is the button wide
|
|
32
|
+
*/
|
|
18
33
|
this.wide = false;
|
|
19
34
|
this.hostAttributes = {};
|
|
20
|
-
//============= Initiate Button Attributes =============//
|
|
21
35
|
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
22
36
|
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
23
37
|
}
|
|
@@ -25,33 +39,50 @@ const SallaButton = class {
|
|
|
25
39
|
this.hostAttributes.class += ' s-button-btn btn--has-loading'
|
|
26
40
|
+ ' s-button-' + this.btnStyle
|
|
27
41
|
+ (this.wide ? ' s-button-wide ' : '')
|
|
28
|
-
+ ' loader-' + this.loaderPosition
|
|
42
|
+
+ ' loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
|
|
29
43
|
+ (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
|
|
30
44
|
delete this.hostAttributes['btn-style'];
|
|
31
45
|
delete this.hostAttributes['id'];
|
|
46
|
+
delete this.hostAttributes['data-on-click'];
|
|
32
47
|
if (this.wide) {
|
|
33
48
|
this.host.classList.add('s-button-wide');
|
|
34
49
|
}
|
|
35
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Run loading animation
|
|
53
|
+
*/
|
|
36
54
|
async load() {
|
|
37
55
|
if (this.loaderPosition == 'center')
|
|
38
56
|
this.text.classList.add('s-button-hide');
|
|
39
57
|
this.host.setAttribute('loading', '');
|
|
40
58
|
return this.host;
|
|
41
59
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
60
|
+
/**
|
|
61
|
+
* Stop loading animation
|
|
62
|
+
*/
|
|
46
63
|
async stop() {
|
|
47
64
|
this.host.removeAttribute('loading');
|
|
48
65
|
if (this.loaderPosition == 'center')
|
|
49
66
|
this.text.classList.remove('s-button-hide');
|
|
50
67
|
return this.host;
|
|
51
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Changing the body of the button
|
|
71
|
+
* @param html
|
|
72
|
+
*/
|
|
73
|
+
async setText(html) {
|
|
74
|
+
this.text.innerHTML = html;
|
|
75
|
+
return this.host;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Add `disabled` attribute
|
|
79
|
+
*/
|
|
52
80
|
async disable() {
|
|
53
81
|
this.host.setAttribute('disabled', '');
|
|
54
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove `disabled` attribute
|
|
85
|
+
*/
|
|
55
86
|
async enable() {
|
|
56
87
|
this.host.removeAttribute('disabled');
|
|
57
88
|
}
|
|
@@ -89,6 +120,8 @@ const SallaLocalization = class {
|
|
|
89
120
|
var _a, _b;
|
|
90
121
|
this.language = salla.config.get('language', {});
|
|
91
122
|
this.currency = salla.config.get('currency', {});
|
|
123
|
+
this.languages = [];
|
|
124
|
+
this.currencies = [];
|
|
92
125
|
Helper.Helper.setHost(this.host);
|
|
93
126
|
salla.event.on('localization::show', () => this.show());
|
|
94
127
|
salla.event.on('languages::translations.loaded', () => {
|
|
@@ -108,15 +141,27 @@ const SallaLocalization = class {
|
|
|
108
141
|
*/
|
|
109
142
|
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>';
|
|
110
143
|
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>';
|
|
111
|
-
this.languages = Object.values(salla.config.get('languages', {}));
|
|
112
|
-
this.currencies = Object.values(salla.config.get('currencies', {}));
|
|
113
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Show the component
|
|
147
|
+
*/
|
|
114
148
|
async show() {
|
|
115
|
-
return this.
|
|
149
|
+
return this.getLanguages()
|
|
150
|
+
.then(() => this.getCurrencies())
|
|
151
|
+
.then(() => this.modal.show());
|
|
116
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Hide the component
|
|
155
|
+
*/
|
|
117
156
|
async hide() {
|
|
118
157
|
return this.modal.hide();
|
|
119
158
|
}
|
|
159
|
+
async getLanguages() {
|
|
160
|
+
return this.languages.length > 1 ? null : await salla.config.languages().then(data => this.languages = data);
|
|
161
|
+
}
|
|
162
|
+
async getCurrencies() {
|
|
163
|
+
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
|
|
164
|
+
}
|
|
120
165
|
onChangeCurrency(event) {
|
|
121
166
|
this.currency = salla.config.get('currencies.' + event.target.value);
|
|
122
167
|
}
|
|
@@ -125,16 +170,16 @@ const SallaLocalization = class {
|
|
|
125
170
|
}
|
|
126
171
|
async submit() {
|
|
127
172
|
let url;
|
|
128
|
-
console.log('this.currency.code::::', this.currency, this.currency.code);
|
|
173
|
+
console.log('this.currency.code::::', this.currency, this.currency.code); //todo:: remove it
|
|
129
174
|
this.btn.load()
|
|
130
|
-
.then(() => this.currency.code === salla.config.get('user.
|
|
131
|
-
.then(() => this.language.code === salla.config.get('user.
|
|
175
|
+
.then(() => this.currency.code === salla.config.get('user.currency_code', 'SAR') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
|
|
176
|
+
.then(() => this.language.code === salla.config.get('user.language_code', 'ar') || (url = this.language.url))
|
|
132
177
|
.then(() => this.btn.stop())
|
|
133
178
|
.then(() => this.hide())
|
|
134
179
|
.then(() => url && (window.location.href = url));
|
|
135
180
|
}
|
|
136
181
|
render() {
|
|
137
|
-
return (index.h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal, width: "xs" }, index.h("div", { slot: "header" }, index.h("slot", { name: "header" })), index.h("div", { class: "s-localization-inner" }, this.languages.length > 1 ?
|
|
182
|
+
return (index.h("salla-modal", { id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" }, index.h("div", { slot: "header" }, index.h("slot", { name: "header" })), index.h("div", { class: "s-localization-inner" }, this.languages.length > 1 ?
|
|
138
183
|
index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.languagesTitle), index.h("div", { class: "s-localization-section-inner" }, this.languages.length < 6 ?
|
|
139
184
|
this.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
|
|
140
185
|
.replace(/\{name\}/g, lang.name)
|
|
@@ -167,27 +212,43 @@ const SallaModal = class {
|
|
|
167
212
|
index.registerInstance(this, hostRef);
|
|
168
213
|
this.modalOpened = index.createEvent(this, "modalOpened", 7);
|
|
169
214
|
this.modalClosed = index.createEvent(this, "modalClosed", 7);
|
|
170
|
-
var _a;
|
|
171
215
|
//todo:: unite three colors (error, success, primary) in one prop
|
|
172
216
|
this.error = false;
|
|
173
217
|
this.success = false;
|
|
174
218
|
this.primary = false;
|
|
175
|
-
this.isClosable = true;
|
|
219
|
+
this.isClosable = true; //todo::rename unclude
|
|
220
|
+
/**
|
|
221
|
+
* The size of the modal
|
|
222
|
+
*/
|
|
176
223
|
this.width = 'md';
|
|
177
|
-
|
|
224
|
+
/**
|
|
225
|
+
* The position of the modal
|
|
226
|
+
*/
|
|
227
|
+
this.position = 'middle';
|
|
228
|
+
/**
|
|
229
|
+
* Show the modal on rendering
|
|
230
|
+
*/
|
|
178
231
|
this.visible = false;
|
|
232
|
+
/**
|
|
233
|
+
* Show loading in the middle
|
|
234
|
+
*/
|
|
179
235
|
this.isLoading = false;
|
|
180
|
-
this.subTitleFirst = false;
|
|
181
|
-
this.noPadding = false;
|
|
236
|
+
this.subTitleFirst = false; //todo:: choose better name
|
|
237
|
+
this.noPadding = false; //todo:: choose better name
|
|
182
238
|
this.subTitle = '';
|
|
239
|
+
/**
|
|
240
|
+
* Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
|
|
241
|
+
*/
|
|
183
242
|
this.icon = '';
|
|
243
|
+
/**
|
|
244
|
+
* url of an image
|
|
245
|
+
*/
|
|
184
246
|
this.imageIcon = '';
|
|
185
247
|
Helper.Helper.setHost(this.host);
|
|
186
248
|
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
187
249
|
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
188
250
|
this.title = this.host.title;
|
|
189
251
|
this.host.removeAttribute('title');
|
|
190
|
-
(_a = Helper.Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
|
|
191
252
|
}
|
|
192
253
|
handleVisible(newValue) {
|
|
193
254
|
if (!newValue) {
|
|
@@ -199,30 +260,44 @@ const SallaModal = class {
|
|
|
199
260
|
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
200
261
|
this.modalOpened.emit();
|
|
201
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Show the modal
|
|
265
|
+
*/
|
|
202
266
|
async show() {
|
|
203
267
|
this.host.setAttribute('visible', '');
|
|
204
268
|
return this.host;
|
|
205
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* hide the modal
|
|
272
|
+
*/
|
|
206
273
|
async hide() {
|
|
207
274
|
this.host.removeAttribute('visible');
|
|
208
275
|
return this.host;
|
|
209
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Change the title
|
|
279
|
+
* @param {string} title
|
|
280
|
+
*/
|
|
210
281
|
async setTitle(title) {
|
|
211
282
|
this.title = title;
|
|
212
283
|
return this.host;
|
|
213
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Start loading
|
|
287
|
+
*/
|
|
214
288
|
async loading() {
|
|
215
289
|
this.isLoading = true;
|
|
216
290
|
return this.host;
|
|
217
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Stop the loading
|
|
294
|
+
*/
|
|
218
295
|
async stopLoading() {
|
|
219
296
|
this.isLoading = false;
|
|
220
297
|
return this.host;
|
|
221
298
|
}
|
|
222
299
|
toggleModal(isOpen) {
|
|
223
|
-
Helper.Helper
|
|
224
|
-
// .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
225
|
-
.toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
300
|
+
Helper.Helper.toggleElement(this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
226
301
|
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
227
302
|
//todo:: use united class names
|
|
228
303
|
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
@@ -236,34 +311,36 @@ const SallaModal = class {
|
|
|
236
311
|
}
|
|
237
312
|
this.host.removeAttribute('visible');
|
|
238
313
|
}
|
|
314
|
+
iconBlockClasses() {
|
|
315
|
+
return {
|
|
316
|
+
's-modal-icon': true,
|
|
317
|
+
's-modal-bg-error': this.error,
|
|
318
|
+
's-modal-bg-success': this.success,
|
|
319
|
+
's-modal-bg-normal': !this.error && !this.success,
|
|
320
|
+
's-modal-bg-primary': this.primary
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
iconClasses() {
|
|
324
|
+
return {
|
|
325
|
+
[this.icon]: true,
|
|
326
|
+
's-modal-text-error': this.error,
|
|
327
|
+
's-modal-text-success': this.success,
|
|
328
|
+
'sicon-alert-engine': !this.icon && this.error && !this.imageIcon,
|
|
329
|
+
'sicon-check-circle2': !this.icon && this.success && !this.imageIcon,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
239
332
|
//todo:: pref for each modal
|
|
240
333
|
render() {
|
|
241
334
|
this.host.id = this.host.id || 'salla-modal';
|
|
242
|
-
return (
|
|
243
|
-
//todo:: use suitable class name instead of hidden
|
|
244
|
-
index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
|
|
335
|
+
return (index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body s-modal-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading
|
|
245
336
|
? index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
|
|
246
337
|
:
|
|
247
338
|
[index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
248
339
|
index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
249
340
|
: '', this.title || this.subTitle ?
|
|
250
341
|
index.h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
|
|
251
|
-
? index.h("div", { class: {
|
|
252
|
-
|
|
253
|
-
's-modal-bg-error': this.error,
|
|
254
|
-
's-modal-bg-success': this.success,
|
|
255
|
-
's-modal-bg-normal': !this.error && !this.success,
|
|
256
|
-
's-modal-bg-primary': this.primary
|
|
257
|
-
} }, index.h("i", { class: {
|
|
258
|
-
[this.icon]: true,
|
|
259
|
-
's-modal-text-error': this.error,
|
|
260
|
-
's-modal-text-success': this.success,
|
|
261
|
-
'sicon-alert-engine': !this.icon && this.error,
|
|
262
|
-
'sicon-check-circle2': !this.icon && this.success,
|
|
263
|
-
} }))
|
|
264
|
-
: this.imageIcon ?
|
|
265
|
-
index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
266
|
-
: '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
|
|
342
|
+
? index.h("div", { class: this.iconBlockClasses() }, index.h("i", { class: this.iconClasses() }))
|
|
343
|
+
: this.imageIcon ? index.h("img", { class: "s-modal-header-img", src: this.imageIcon }) : '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
|
|
267
344
|
: ''),
|
|
268
345
|
index.h("slot", null),
|
|
269
346
|
index.h("slot", { name: "footer" })
|
|
@@ -1653,8 +1730,11 @@ const SallaTelInput = class {
|
|
|
1653
1730
|
constructor(hostRef) {
|
|
1654
1731
|
index.registerInstance(this, hostRef);
|
|
1655
1732
|
this.enterClicked = index.createEvent(this, "enterClicked", 7);
|
|
1733
|
+
/**
|
|
1734
|
+
* Current country_code
|
|
1735
|
+
*/
|
|
1656
1736
|
this.countryCode = salla.config.get('user.country_code', 'SA');
|
|
1657
|
-
this.countryKey = "+966"; //TODO:: why we need it
|
|
1737
|
+
this.countryKey = "+966"; //TODO:: why we need it, if it's important find a way to get it automatically for the current user
|
|
1658
1738
|
this.countryCodeLabel = salla.lang.get('common.country_code');
|
|
1659
1739
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
1660
1740
|
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
@@ -1674,12 +1754,21 @@ const SallaTelInput = class {
|
|
|
1674
1754
|
this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
1675
1755
|
});
|
|
1676
1756
|
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Get current values
|
|
1759
|
+
* @return {{mobile:number,countryCode:'SA'|string, countryKey:'+966'|string}}
|
|
1760
|
+
*/
|
|
1677
1761
|
async getValues() {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1762
|
+
return {
|
|
1763
|
+
mobile: this.mobile = this.phoneInput.value,
|
|
1764
|
+
countryCode: this.countryCode = this.countryCodeInput.value,
|
|
1765
|
+
countryKey: this.countryKey = this.countryKeyInput.value
|
|
1766
|
+
};
|
|
1682
1767
|
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Is current data valid or not
|
|
1770
|
+
* @return {boolean}
|
|
1771
|
+
*/
|
|
1683
1772
|
async isValid() {
|
|
1684
1773
|
this.reset();
|
|
1685
1774
|
if (this.iti.isValidNumber())
|
|
@@ -1712,9 +1801,7 @@ const SallaTelInput = class {
|
|
|
1712
1801
|
});
|
|
1713
1802
|
});
|
|
1714
1803
|
// on blur: validate
|
|
1715
|
-
this.phoneInput.addEventListener('blur', () =>
|
|
1716
|
-
this.isValid();
|
|
1717
|
-
});
|
|
1804
|
+
this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1718
1805
|
// on keyup / change flag: reset
|
|
1719
1806
|
this.phoneInput.addEventListener('input', e => {
|
|
1720
1807
|
salla.helpers.digitsOnly(e.target);
|
|
@@ -1739,10 +1826,15 @@ const SallaVerify = class {
|
|
|
1739
1826
|
constructor(hostRef) {
|
|
1740
1827
|
index.registerInstance(this, hostRef);
|
|
1741
1828
|
this.verified = index.createEvent(this, "verified", 7);
|
|
1742
|
-
this.
|
|
1829
|
+
this.initiated = false;
|
|
1830
|
+
/**
|
|
1831
|
+
* Verifying method
|
|
1832
|
+
*/
|
|
1743
1833
|
this.by = 'sms';
|
|
1834
|
+
/**
|
|
1835
|
+
* should auto reloading the page after success verification
|
|
1836
|
+
*/
|
|
1744
1837
|
this.autoReload = true;
|
|
1745
|
-
this.initiated = false;
|
|
1746
1838
|
Helper.Helper.setHost(this.host);
|
|
1747
1839
|
if (this.withoutModal) {
|
|
1748
1840
|
this.modal = { show: () => '', hide: () => '' };
|
|
@@ -1754,12 +1846,22 @@ const SallaVerify = class {
|
|
|
1754
1846
|
});
|
|
1755
1847
|
}
|
|
1756
1848
|
salla.event.on('languages::translations.loaded', () => {
|
|
1849
|
+
var _a;
|
|
1757
1850
|
this.title = salla.lang.get('pages.profile.verify_title');
|
|
1851
|
+
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('pages.profile.verify'));
|
|
1758
1852
|
});
|
|
1759
1853
|
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Get current code
|
|
1856
|
+
* @return {string}
|
|
1857
|
+
*/
|
|
1760
1858
|
async getCode() {
|
|
1761
1859
|
return this.code.value;
|
|
1762
1860
|
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Show verifying modal
|
|
1863
|
+
* @param data
|
|
1864
|
+
*/
|
|
1763
1865
|
async show(data) {
|
|
1764
1866
|
var _a;
|
|
1765
1867
|
this.data = data;
|
|
@@ -1854,12 +1956,10 @@ const SallaVerify = class {
|
|
|
1854
1956
|
myBody() {
|
|
1855
1957
|
return [
|
|
1856
1958
|
index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
1857
|
-
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
1858
1959
|
index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
1859
1960
|
index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
|
|
1860
|
-
index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')),
|
|
1861
|
-
|
|
1862
|
-
: '')
|
|
1961
|
+
index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", "loader-position": 'center', disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
|
|
1962
|
+
index.h("slot", { name: "after-footer" })
|
|
1863
1963
|
];
|
|
1864
1964
|
}
|
|
1865
1965
|
get host() { return index.getElement(this); }
|
|
@@ -12,6 +12,9 @@ const SallaInfiniteScroll = class {
|
|
|
12
12
|
* Next Page element
|
|
13
13
|
*/
|
|
14
14
|
this.nextPage = '';
|
|
15
|
+
/**
|
|
16
|
+
* Is there is need to autoload next page when scroll
|
|
17
|
+
*/
|
|
15
18
|
this.autoload = false;
|
|
16
19
|
/**
|
|
17
20
|
* Class selector to know the container if it's not the host `<salla-infinite-scroll>`
|
|
@@ -23,10 +23,18 @@ const SallaOffer = class {
|
|
|
23
23
|
this.show(data.product_id);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Show the available offers for the product
|
|
28
|
+
* @param product_id
|
|
29
|
+
*/
|
|
30
|
+
async show(product_id) {
|
|
27
31
|
//TODO:: make sure there is only one offer
|
|
28
|
-
return salla.api.offer.details(
|
|
32
|
+
return salla.api.offer.details(product_id).then(response => this.offer = response.data[0]);
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Show offer details
|
|
36
|
+
* @param {Offer} offer
|
|
37
|
+
*/
|
|
30
38
|
async showOffer(offer) {
|
|
31
39
|
this.offer = offer;
|
|
32
40
|
return this.modal.show();
|
|
@@ -9,7 +9,13 @@ const SallaProductAvailability = class {
|
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
index.registerInstance(this, hostRef);
|
|
11
11
|
this.isUser = Helper.Helper.isUser();
|
|
12
|
+
/**
|
|
13
|
+
* product id that can visitor subscribe to its availability notification
|
|
14
|
+
*/
|
|
12
15
|
this.productId = salla.config.get('page.id');
|
|
16
|
+
/**
|
|
17
|
+
* is current user already subscribed
|
|
18
|
+
*/
|
|
13
19
|
this.isSubscribed = false;
|
|
14
20
|
// @Method()
|
|
15
21
|
this.submit = async () => {
|
|
@@ -13,6 +13,10 @@ const SallaRating = class {
|
|
|
13
13
|
this.stepsCount = 0;
|
|
14
14
|
this.currentIndex = 0;
|
|
15
15
|
this.submitted = [];
|
|
16
|
+
/**
|
|
17
|
+
* The order id, to rate on its products & shipping
|
|
18
|
+
*/
|
|
19
|
+
this.orderId = salla.config.get('page.id');
|
|
16
20
|
this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
|
|
17
21
|
this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
|
|
18
22
|
this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
|
|
@@ -36,14 +40,20 @@ const SallaRating = class {
|
|
|
36
40
|
this.next = salla.lang.get('common.elements.next');
|
|
37
41
|
});
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Show the rating modal
|
|
45
|
+
*/
|
|
39
46
|
async show() {
|
|
40
47
|
return this.modal.show()
|
|
41
|
-
.then(() => this.order || salla.feedback.api.order(
|
|
48
|
+
.then(() => this.order || salla.feedback.api.order(this.orderId).then(res => this.order = res.data))
|
|
42
49
|
.then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
|
|
43
50
|
.then(() => this.modal.stopLoading())
|
|
44
51
|
.then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
|
|
45
52
|
.then(() => setTimeout(() => this.initiateRating(), 100));
|
|
46
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Show the rating modal
|
|
56
|
+
*/
|
|
47
57
|
async hide() {
|
|
48
58
|
return this.modal.hide();
|
|
49
59
|
}
|
|
@@ -169,7 +179,7 @@ const SallaRating = class {
|
|
|
169
179
|
if (Object.keys(data).length == 0) {
|
|
170
180
|
return;
|
|
171
181
|
}
|
|
172
|
-
data['order_id'] =
|
|
182
|
+
data['order_id'] = this.orderId;
|
|
173
183
|
data['type'] = this.currentTab.dataset.type;
|
|
174
184
|
this.submitted.push(this.currentIndex);
|
|
175
185
|
return salla.feedback.api[this.currentTab.dataset.type](data);
|