@salla.sa/twilight-components 1.0.49 → 1.0.51
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 +3 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button.cjs.entry.js +116 -0
- package/dist/cjs/salla-localization-modal.cjs.entry.js +117 -0
- package/dist/cjs/{salla-search-a7147639.js → salla-login-modal-a2c7fa5d.js} +13 -87
- package/dist/cjs/salla-login-modal.cjs.entry.js +11 -0
- package/dist/cjs/salla-modal_2.cjs.entry.js +155 -0
- package/dist/cjs/{salla-offer.cjs.entry.js → salla-offer-modal.cjs.entry.js} +26 -26
- package/dist/cjs/{salla-rating.cjs.entry.js → salla-rating-modal.cjs.entry.js} +33 -33
- package/dist/cjs/salla-search-99d08b1f.js +79 -0
- package/dist/cjs/{salla-button_7.cjs.entry.js → salla-tel-input.cjs.entry.js} +0 -509
- package/dist/cjs/salla-verify-modal.cjs.entry.js +148 -0
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +4 -4
- package/dist/collection/components/{salla-localization/salla-localization.css → salla-localization-modal/salla-localization-modal.css} +0 -0
- package/dist/collection/components/{salla-localization/salla-localization.js → salla-localization-modal/salla-localization-modal.js} +19 -19
- package/dist/collection/components/{salla-login/salla-login.css → salla-login-modal/salla-login-modal.css} +0 -0
- package/dist/collection/components/{salla-login/salla-login.js → salla-login-modal/salla-login-modal.js} +34 -34
- package/dist/collection/components/{salla-offer → salla-offer-modal}/offer-schema.js +0 -0
- package/dist/collection/components/{salla-offer/salla-offer.css → salla-offer-modal/salla-offer-modal.css} +4 -4
- package/dist/collection/components/{salla-offer/salla-offer.js → salla-offer-modal/salla-offer-modal.js} +34 -34
- package/dist/collection/components/{salla-rating → salla-rating-modal}/order-feedback-response.js +0 -0
- package/dist/collection/components/{salla-rating/salla-rating.css → salla-rating-modal/salla-rating-modal.css} +1 -1
- package/dist/collection/components/{salla-rating/salla-rating.js → salla-rating-modal/salla-rating-modal.js} +57 -57
- package/dist/collection/index.js +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button.entry.js +112 -0
- package/dist/esm/salla-localization-modal.entry.js +113 -0
- package/dist/esm/{salla-search-813732a1.js → salla-login-modal-187c1f98.js} +13 -86
- package/dist/esm/salla-login-modal.entry.js +3 -0
- package/dist/esm/salla-modal_2.entry.js +150 -0
- package/dist/esm/{salla-offer.entry.js → salla-offer-modal.entry.js} +26 -26
- package/dist/esm/{salla-rating.entry.js → salla-rating-modal.entry.js} +33 -33
- package/dist/esm/salla-search-2e3e60cb.js +77 -0
- package/dist/esm/{salla-button_7.entry.js → salla-tel-input.entry.js} +2 -505
- package/dist/esm/salla-verify-modal.entry.js +144 -0
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-05dff05e.entry.js +1 -0
- package/dist/twilight-components/p-0b599094.js +1 -0
- package/dist/twilight-components/p-1f873057.entry.js +1 -0
- package/dist/twilight-components/p-2e03db57.entry.js +1 -0
- package/dist/twilight-components/p-5ffd56fb.js +1 -0
- package/dist/twilight-components/p-85427280.entry.js +1 -0
- package/dist/twilight-components/p-88d1bb89.entry.js +1 -0
- package/dist/twilight-components/p-8bfa19fb.entry.js +1 -0
- package/dist/twilight-components/p-ea455ae9.entry.js +1 -0
- package/dist/twilight-components/p-f0f51a3c.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/{salla-localization/salla-localization.d.ts → salla-localization-modal/salla-localization-modal.d.ts} +1 -1
- package/dist/types/components/{salla-login/salla-login.d.ts → salla-login-modal/salla-login-modal.d.ts} +1 -1
- package/dist/types/components/{salla-offer → salla-offer-modal}/offer-schema.d.ts +0 -0
- package/dist/types/components/{salla-offer/salla-offer.d.ts → salla-offer-modal/salla-offer-modal.d.ts} +1 -1
- package/dist/types/components/{salla-rating → salla-rating-modal}/order-feedback-response.d.ts +0 -0
- package/dist/types/components/{salla-rating/salla-rating.d.ts → salla-rating-modal/salla-rating-modal.d.ts} +1 -1
- package/dist/types/components.d.ts +36 -36
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/twilight-components/p-152b7287.entry.js +0 -1
- package/dist/twilight-components/p-4b774cf9.entry.js +0 -1
- package/dist/twilight-components/p-b584e892.entry.js +0 -1
- package/dist/twilight-components/p-b8ed7363.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const sallaLoginModal = require('./salla-login-modal-a2c7fa5d.js');
|
|
6
|
+
const sallaSearch = require('./salla-search-99d08b1f.js');
|
|
6
7
|
require('./index-0b5b5867.js');
|
|
7
8
|
require('./Helper-98cc9f18.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
exports.
|
|
12
|
+
exports.SallaLoginModal = sallaLoginModal.SallaLoginModal;
|
|
12
13
|
exports.SallaSearch = sallaSearch.SallaSearch;
|
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-
|
|
17
|
+
return index.bootstrapLazy([["salla-button.cjs",[[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]}]]],["salla-modal_2.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{"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],"iconStyle":[1,"icon-style"],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal.cjs",[[4,"salla-login-modal",{"isEmailAllowed":[1028,"is-email-allowed"],"isMobileAllowed":[1028,"is-mobile-allowed"],"isEmailRequired":[1028,"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"]]]]],["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],"isVisitorSubscribed":[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-localization-modal.cjs",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer-modal.cjs",[[0,"salla-offer-modal",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating-modal.cjs",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"nextPageAutoload":[1028,"next-page-autoload"],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-verify-modal.cjs",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}]]],["salla-tel-input.cjs",[[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]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.js');
|
|
6
|
+
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
+
|
|
8
|
+
const sallaButtonCss = "";
|
|
9
|
+
|
|
10
|
+
const SallaButton = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
/**
|
|
14
|
+
* Button Style
|
|
15
|
+
*/
|
|
16
|
+
this.btnStyle = 'primary';
|
|
17
|
+
/**
|
|
18
|
+
* Is the button currently loading
|
|
19
|
+
*/
|
|
20
|
+
this.loading = false;
|
|
21
|
+
/**
|
|
22
|
+
* Is the button currently disabled
|
|
23
|
+
*/
|
|
24
|
+
this.disabled = false;
|
|
25
|
+
/**
|
|
26
|
+
* If there is need to change loader position, pass the position
|
|
27
|
+
*/
|
|
28
|
+
this.loaderPosition = 'after';
|
|
29
|
+
/**
|
|
30
|
+
* Is the button wide
|
|
31
|
+
*/
|
|
32
|
+
this.wide = false;
|
|
33
|
+
this.hostAttributes = {};
|
|
34
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
35
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
36
|
+
}
|
|
37
|
+
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
38
|
+
this.hostAttributes.class += ' s-button-btn btn--has-loading'
|
|
39
|
+
+ ' s-button-' + this.btnStyle
|
|
40
|
+
+ (this.wide ? ' s-button-wide ' : '')
|
|
41
|
+
+ ' s-button-btn-loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
|
|
42
|
+
+ (this.loaderPosition == 'after' ? ' s-button-loader-after' : '');
|
|
43
|
+
delete this.hostAttributes['btn-style'];
|
|
44
|
+
delete this.hostAttributes['id'];
|
|
45
|
+
delete this.hostAttributes['data-on-click'];
|
|
46
|
+
if (this.wide) {
|
|
47
|
+
this.host.classList.add('s-button-wide');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run loading animation
|
|
52
|
+
*/
|
|
53
|
+
async load() {
|
|
54
|
+
if (this.loaderPosition == 'center')
|
|
55
|
+
this.text.classList.add('s-button-hide');
|
|
56
|
+
this.host.setAttribute('loading', '');
|
|
57
|
+
return this.host;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stop loading animation
|
|
61
|
+
*/
|
|
62
|
+
async stop() {
|
|
63
|
+
this.host.removeAttribute('loading');
|
|
64
|
+
if (this.loaderPosition == 'center')
|
|
65
|
+
this.text.classList.remove('s-button-hide');
|
|
66
|
+
return this.host;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Changing the body of the button
|
|
70
|
+
* @param html
|
|
71
|
+
*/
|
|
72
|
+
async setText(html) {
|
|
73
|
+
this.text.innerHTML = html;
|
|
74
|
+
return this.host;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Add `disabled` attribute
|
|
78
|
+
*/
|
|
79
|
+
async disable() {
|
|
80
|
+
this.host.setAttribute('disabled', '');
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove `disabled` attribute
|
|
84
|
+
*/
|
|
85
|
+
async enable() {
|
|
86
|
+
this.host.removeAttribute('disabled');
|
|
87
|
+
}
|
|
88
|
+
handleVisible(newKind, oldKind) {
|
|
89
|
+
//todo::use united styles
|
|
90
|
+
this.btn.classList.remove('btn-' + oldKind);
|
|
91
|
+
this.btn.classList.add('btn-' + newKind);
|
|
92
|
+
}
|
|
93
|
+
handleLoading(newVal) {
|
|
94
|
+
//todo::use united styles
|
|
95
|
+
Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
return (
|
|
99
|
+
//TODO:: use HOST then fake button behaviours
|
|
100
|
+
index.h(index.Host, { class: "s-button-wrap" }, index.h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), index.h("span", { class: { 's-button-text': true, 's-button-hide': this.loaderPosition == 'center' && this.loading }, ref: el => this.text = el }, index.h("slot", null)), this.loading ? index.h("span", { class: {
|
|
101
|
+
//todo::use united styles
|
|
102
|
+
's-button-loader': true,
|
|
103
|
+
's-button-loader-start': this.loaderPosition === 'start',
|
|
104
|
+
's-button-loader-end': this.loaderPosition === 'end',
|
|
105
|
+
's-button-loader-center': this.loaderPosition === 'center',
|
|
106
|
+
} }) : '')));
|
|
107
|
+
}
|
|
108
|
+
get host() { return index.getElement(this); }
|
|
109
|
+
static get watchers() { return {
|
|
110
|
+
"btnStyle": ["handleVisible"],
|
|
111
|
+
"loading": ["handleLoading"]
|
|
112
|
+
}; }
|
|
113
|
+
};
|
|
114
|
+
SallaButton.style = sallaButtonCss;
|
|
115
|
+
|
|
116
|
+
exports.salla_button = SallaButton;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.js');
|
|
6
|
+
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
+
|
|
8
|
+
const sallaLocalizationModalCss = "";
|
|
9
|
+
|
|
10
|
+
const SallaLocalizationModal = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
var _a, _b;
|
|
14
|
+
this.languages = [];
|
|
15
|
+
this.currencies = [];
|
|
16
|
+
this.isLoading = true;
|
|
17
|
+
this.language = salla.config.get('user.language_code');
|
|
18
|
+
this.currency = salla.config.get('user.currency_code');
|
|
19
|
+
Helper.Helper.setHost(this.host);
|
|
20
|
+
salla.event.on('localization::show', () => this.show());
|
|
21
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
22
|
+
var _a;
|
|
23
|
+
this.languagesTitle = salla.lang.get('common.titles.language');
|
|
24
|
+
this.currenciesTitle = salla.lang.get('common.titles.currency');
|
|
25
|
+
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok'));
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* letting developer to insert his own slot like:
|
|
29
|
+
* <salla-localization>
|
|
30
|
+
* <div slot="language">...{name}....</div>
|
|
31
|
+
* <div slot="currency">...{name}....</div>
|
|
32
|
+
* </salla-localization>
|
|
33
|
+
* Because scoped templates not supported in stencil );
|
|
34
|
+
* we made a workaround to pass language & currency attributes, then replace names in rendering
|
|
35
|
+
*/
|
|
36
|
+
this.languageSlot = ((_a = Helper.Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-modal-label" for="lang-{code}"><span>{name}</span><div class="s-localization-modal-flag flag iti__flag iti__{country_code}"></div></label>';
|
|
37
|
+
this.currencySlot = ((_b = Helper.Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-modal-label" for="currency-{code}"><span>{name}</span><small class="s-localization-modal-currency">{code}</small></label>';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Show the component
|
|
41
|
+
*/
|
|
42
|
+
async show() {
|
|
43
|
+
return this.modal.show()
|
|
44
|
+
.then(() => this.getLanguages())
|
|
45
|
+
.then(() => this.getCurrencies())
|
|
46
|
+
.then(() => this.isLoading = false);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hide the component
|
|
50
|
+
*/
|
|
51
|
+
async hide() {
|
|
52
|
+
return this.modal.hide();
|
|
53
|
+
}
|
|
54
|
+
async getLanguages() {
|
|
55
|
+
this.language = this.language || salla.config.get('user.language_code');
|
|
56
|
+
return this.languages.length > 1 ? null : await salla.config.languages().then(data => this.languages = data);
|
|
57
|
+
}
|
|
58
|
+
async getCurrencies() {
|
|
59
|
+
this.currency = this.currency || salla.config.get('user.currency_code');
|
|
60
|
+
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
|
|
61
|
+
}
|
|
62
|
+
onChangeCurrency(event) {
|
|
63
|
+
this.currency = event.target.value;
|
|
64
|
+
}
|
|
65
|
+
onChangeLanguage(event) {
|
|
66
|
+
this.language = event.target.value;
|
|
67
|
+
}
|
|
68
|
+
async submit() {
|
|
69
|
+
let url;
|
|
70
|
+
this.btn.load()
|
|
71
|
+
.then(() => {
|
|
72
|
+
if (!this.currency) {
|
|
73
|
+
salla.log('There is no currency!');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (this.currency === salla.config.get('user.currency_code', 'SAR')) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
url = window.location.href;
|
|
80
|
+
return salla.currency.api.change(this.currency);
|
|
81
|
+
})
|
|
82
|
+
.then(() => this.language === salla.config.get('user.language_code', 'ar') || (url = salla.helpers.addParamToUrl('lang', this.language)))
|
|
83
|
+
.then(() => this.btn.stop())
|
|
84
|
+
.then(() => this.hide())
|
|
85
|
+
.then(() => url && (window.location.href = url));
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return (index.h("salla-modal", { isLoading: this.isLoading, id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" }, !this.isLoading ?
|
|
89
|
+
index.h("div", { class: "s-localization-modal-inner" }, this.languages.length > 1 ?
|
|
90
|
+
index.h("div", { class: "s-localization-modal-section" }, index.h("label", { class: "s-localization-modal-title" }, this.languagesTitle), index.h("div", { class: "s-localization-modal-section-inner" }, this.languages.length < 6 ?
|
|
91
|
+
this.languages.map(lang => index.h("div", { class: "s-localization-modal-item" }, index.h("input", { class: "s-localization-modal-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 }), index.h("div", { id: "language-slot", innerHTML: this.languageSlot
|
|
92
|
+
.replace(/\{name\}/g, lang.name)
|
|
93
|
+
.replace(/\{code\}/g, lang.code)
|
|
94
|
+
.replace(/\{country_code\}/g, lang.country_code) }))) :
|
|
95
|
+
index.h("select", { class: "s-localization-modal-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => index.h("option", { value: lang.code, selected: this.language == lang.code }, lang.name)))))
|
|
96
|
+
: '', this.currencies.length > 1 ?
|
|
97
|
+
index.h("div", { class: "s-localization-modal-section" }, index.h("label", { class: "s-localization-modal-title" }, this.currenciesTitle), index.h("div", { class: "s-localization-modal-section-inner" }, this.currencies.length < 6 ?
|
|
98
|
+
this.currencies.map(currency => index.h("div", { class: "s-localization-modal-item" }, index.h("input", { class: "s-localization-modal-input", type: "radio", name: "currency", checked: this.currency == currency.code, onChange: () => this.currency = currency.code, id: 'currency-' + currency.code, value: currency.code }), index.h("div", { id: "currency-slot", innerHTML: this.currencySlot
|
|
99
|
+
.replace(/\{name\}/g, currency.name)
|
|
100
|
+
.replace(/\{code\}/g, currency.code)
|
|
101
|
+
.replace(/\{country_code\}/g, currency.country_code) }))) :
|
|
102
|
+
index.h("select", { class: "s-localization-modal-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => index.h("option", { value: currency.code, selected: this.currency == currency.code }, currency.name)))))
|
|
103
|
+
: '', index.h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))
|
|
104
|
+
: ''));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* to reduce dom levels we will move slot data into the parent dom
|
|
108
|
+
*/
|
|
109
|
+
componentDidRender() {
|
|
110
|
+
this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
111
|
+
this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
|
|
112
|
+
}
|
|
113
|
+
get host() { return index.getElement(this); }
|
|
114
|
+
};
|
|
115
|
+
SallaLocalizationModal.style = sallaLocalizationModalCss;
|
|
116
|
+
|
|
117
|
+
exports.salla_localization_modal = SallaLocalizationModal;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const index = require('./index-0b5b5867.js');
|
|
4
4
|
const Helper = require('./Helper-98cc9f18.js');
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const sallaLoginModalCss = "";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const SallaLoginModal = class {
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
index.registerInstance(this, hostRef);
|
|
11
11
|
/**
|
|
@@ -39,7 +39,7 @@ const SallaLogin = class {
|
|
|
39
39
|
this.typing = (e, submitMethod) => {
|
|
40
40
|
const error = e.target.nextElementSibling;
|
|
41
41
|
e.target.classList.remove('s-has-error');
|
|
42
|
-
(error === null || error === void 0 ? void 0 : error.classList.contains('s-login-error-message')) && (error.innerText = '');
|
|
42
|
+
(error === null || error === void 0 ? void 0 : error.classList.contains('s-login-modal-error-message')) && (error.innerText = '');
|
|
43
43
|
e.key == 'Enter' && submitMethod();
|
|
44
44
|
};
|
|
45
45
|
this.loginBySMS = async () => {
|
|
@@ -160,8 +160,8 @@ const SallaLogin = class {
|
|
|
160
160
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
161
161
|
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
162
162
|
tabs.map(el => Helper.Helper.toggleElement(el, 'visible', 's-hidden', () => el == tab));
|
|
163
|
-
setTimeout(() => tabs.map(el => Helper.Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)), 200);
|
|
164
|
-
setTimeout(() => this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
163
|
+
setTimeout(() => tabs.map(el => Helper.Helper.toggleElement(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
|
|
164
|
+
setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
165
165
|
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
166
166
|
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
167
167
|
}
|
|
@@ -189,90 +189,16 @@ const SallaLogin = class {
|
|
|
189
189
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
190
190
|
}
|
|
191
191
|
render() {
|
|
192
|
-
return (index.h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, index.h("div", { class: "s-login-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
193
|
-
index.h("div", { class: "s-login-tab", ref: tab => this.homeTab = tab }, index.h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), index.h("slot", { name: "before-login-type" }), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-phone" }), index.h("span", { class: "s-login-main-btn-text" }, this.smsLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-mail" }), index.h("span", { class: "s-login-main-btn-text" }, this.emailLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("slot", { name: "after-login-type" }))
|
|
192
|
+
return (index.h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, index.h("div", { class: "s-login-modal-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
193
|
+
index.h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, index.h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), index.h("slot", { name: "before-login-type" }), index.h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, index.h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), index.h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, index.h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), index.h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("slot", { name: "after-login-type" }))
|
|
194
194
|
: '', this.isMobileAllowed ?
|
|
195
|
-
index.h("div", { class: "s-login-tab", ref: tab => this.mobileTab = tab }, index.h("slot", { name: "before-login-mobile" }), index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
196
|
-
index.h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-link" }, this.byEmailText) : '', index.h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
197
|
-
index.h("div", { class: "s-login-tab", ref: tab => this.emailTab = tab }, index.h("slot", { name: "before-login-email" }), index.h("label", { class: "s-login-label" }, this.emailLabel), index.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" }), index.h("span", { class: "s-login-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
198
|
-
index.h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-link" }, this.bySMSText) : '', index.h("slot", { name: "after-login-email" })) : '', index.h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, index.h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), index.h("div", { ref: tab => this.registrationTab = tab }, index.h("slot", { name: "before-registration" }), index.h("label", { class: "s-login-label" }, this.firstNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), index.h("span", { class: "s-login-error-message" }), index.h("label", { class: "s-login-label" }, this.lastNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), index.h("span", { class: "s-login-error-message" }), index.h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), index.h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" })), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), index.h("slot", { name: "after-registration" })))));
|
|
195
|
+
index.h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, index.h("slot", { name: "before-login-mobile" }), index.h("label", { class: "s-login-modal-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
196
|
+
index.h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, this.byEmailText) : '', index.h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
197
|
+
index.h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, index.h("slot", { name: "before-login-email" }), index.h("label", { class: "s-login-modal-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), index.h("span", { class: "s-login-modal-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
198
|
+
index.h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText) : '', index.h("slot", { name: "after-login-email" })) : '', index.h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, index.h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), index.h("div", { ref: tab => this.registrationTab = tab }, index.h("slot", { name: "before-registration" }), index.h("label", { class: "s-login-modal-label" }, this.firstNameLabel), index.h("input", { type: "text", class: "s-login-modal-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), index.h("span", { class: "s-login-modal-error-message" }), index.h("label", { class: "s-login-modal-label" }, this.lastNameLabel), index.h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), index.h("span", { class: "s-login-modal-error-message" }), index.h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-modal-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), index.h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-modal-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), index.h("span", { class: "s-login-modal-error-message" })), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), index.h("slot", { name: "after-registration" })))));
|
|
199
199
|
}
|
|
200
200
|
get host() { return index.getElement(this); }
|
|
201
201
|
};
|
|
202
|
-
|
|
202
|
+
SallaLoginModal.style = sallaLoginModalCss;
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const SallaSearch = class {
|
|
207
|
-
constructor(hostRef) {
|
|
208
|
-
index.registerInstance(this, hostRef);
|
|
209
|
-
var _a;
|
|
210
|
-
Helper.Helper.setHost(this.host);
|
|
211
|
-
this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
|
|
212
|
-
salla.event.on('search::show', () => this.modal.show());
|
|
213
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
214
|
-
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
215
|
-
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
onModalOpen() {
|
|
219
|
-
this.modal.querySelector('.s-search-input').focus();
|
|
220
|
-
}
|
|
221
|
-
onModalClose() {
|
|
222
|
-
this.modal.querySelector('.s-search-input').value = '';
|
|
223
|
-
this.results = undefined;
|
|
224
|
-
this.afterSearching();
|
|
225
|
-
}
|
|
226
|
-
getDefaultProductSlot() {
|
|
227
|
-
return '<div class="s-search-product-image-container">' +
|
|
228
|
-
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
229
|
-
'</div>' +
|
|
230
|
-
'<div class="s-search-product-details">' +
|
|
231
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
232
|
-
'</div>';
|
|
233
|
-
}
|
|
234
|
-
//todo:: reset data when closing
|
|
235
|
-
search(e) {
|
|
236
|
-
Helper.Helper.hideElement(this.noResults);
|
|
237
|
-
if (e.target.value.length === 0) {
|
|
238
|
-
this.results = undefined;
|
|
239
|
-
this.afterSearching();
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (e.target.value.length <= 2) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
//run loading spinner or stop it
|
|
246
|
-
Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
|
|
247
|
-
salla.search.api.search(e.target.value)
|
|
248
|
-
.then(response => this.results = response)
|
|
249
|
-
.catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
|
|
250
|
-
.finally(() => this.afterSearching(/*isEmpty*/ false));
|
|
251
|
-
}
|
|
252
|
-
afterSearching(isEmpty = true) {
|
|
253
|
-
var _a;
|
|
254
|
-
this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
|
|
255
|
-
Helper.Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
|
|
256
|
-
.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
|
|
257
|
-
salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
|
|
258
|
-
}
|
|
259
|
-
render() {
|
|
260
|
-
var _a;
|
|
261
|
-
return (index.h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, index.h("div", { class: "s-search-container", ref: container => this.container = container }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), index.h("span", { class: "s-search-icon" }, index.h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
262
|
-
_a.data.map(item => index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
263
|
-
.replace(/\{name\}/g, item.name)
|
|
264
|
-
.replace(/\{price\}/g, item.price) //todo:: get discounted price too
|
|
265
|
-
.replace(/\{image\}/g, item.image_url) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Run it one time after load
|
|
269
|
-
*/
|
|
270
|
-
componentDidLoad() {
|
|
271
|
-
this.afterSearching();
|
|
272
|
-
}
|
|
273
|
-
get host() { return index.getElement(this); }
|
|
274
|
-
};
|
|
275
|
-
SallaSearch.style = sallaSearchCss;
|
|
276
|
-
|
|
277
|
-
exports.SallaLogin = SallaLogin;
|
|
278
|
-
exports.SallaSearch = SallaSearch;
|
|
204
|
+
exports.SallaLoginModal = SallaLoginModal;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const sallaLoginModal = require('./salla-login-modal-a2c7fa5d.js');
|
|
6
|
+
require('./index-0b5b5867.js');
|
|
7
|
+
require('./Helper-98cc9f18.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.salla_login_modal = sallaLoginModal.SallaLoginModal;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-0b5b5867.js');
|
|
6
|
+
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
+
const sallaSearch = require('./salla-search-99d08b1f.js');
|
|
8
|
+
|
|
9
|
+
const sallaModalCss = "";
|
|
10
|
+
|
|
11
|
+
const SallaModal = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.modalOpened = index.createEvent(this, "modalOpened", 7);
|
|
15
|
+
this.modalClosed = index.createEvent(this, "modalClosed", 7);
|
|
16
|
+
this.isClosable = true; //todo::rename unclude
|
|
17
|
+
/**
|
|
18
|
+
* The size of the modal
|
|
19
|
+
*/
|
|
20
|
+
this.width = 'md';
|
|
21
|
+
/**
|
|
22
|
+
* The position of the modal
|
|
23
|
+
*/
|
|
24
|
+
this.position = 'middle';
|
|
25
|
+
/**
|
|
26
|
+
* Show the modal on rendering
|
|
27
|
+
*/
|
|
28
|
+
this.visible = false;
|
|
29
|
+
/**
|
|
30
|
+
* Show loading in the middle
|
|
31
|
+
*/
|
|
32
|
+
this.isLoading = false;
|
|
33
|
+
this.subTitleFirst = false; //todo:: choose better name
|
|
34
|
+
this.noPadding = false; //todo:: choose better name
|
|
35
|
+
this.subTitle = '';
|
|
36
|
+
/**
|
|
37
|
+
* Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
|
|
38
|
+
*/
|
|
39
|
+
this.icon = '';
|
|
40
|
+
this.iconStyle = '';
|
|
41
|
+
/**
|
|
42
|
+
* url of an image
|
|
43
|
+
*/
|
|
44
|
+
this.imageIcon = '';
|
|
45
|
+
Helper.Helper.setHost(this.host);
|
|
46
|
+
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
47
|
+
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
48
|
+
this.title = this.host.title;
|
|
49
|
+
this.host.removeAttribute('title');
|
|
50
|
+
}
|
|
51
|
+
handleVisible(newValue) {
|
|
52
|
+
if (!newValue) {
|
|
53
|
+
this.toggleModal(false);
|
|
54
|
+
this.modalClosed.emit();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.host.classList.remove('s-hidden');
|
|
58
|
+
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
59
|
+
this.modalOpened.emit();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Show the modal
|
|
63
|
+
*/
|
|
64
|
+
async show() {
|
|
65
|
+
this.host.setAttribute('visible', '');
|
|
66
|
+
return this.host;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* hide the modal
|
|
70
|
+
*/
|
|
71
|
+
async hide() {
|
|
72
|
+
this.host.removeAttribute('visible');
|
|
73
|
+
return this.host;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Change the title
|
|
77
|
+
* @param {string} title
|
|
78
|
+
*/
|
|
79
|
+
async setTitle(title) {
|
|
80
|
+
this.title = title;
|
|
81
|
+
return this.host;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Start loading
|
|
85
|
+
*/
|
|
86
|
+
async loading() {
|
|
87
|
+
this.isLoading = true;
|
|
88
|
+
return this.host;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Stop the loading
|
|
92
|
+
*/
|
|
93
|
+
async stopLoading() {
|
|
94
|
+
this.isLoading = false;
|
|
95
|
+
return this.host;
|
|
96
|
+
}
|
|
97
|
+
toggleModal(isOpen) {
|
|
98
|
+
const body = this.host.querySelector('.s-modal-body');
|
|
99
|
+
Helper.Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
100
|
+
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
101
|
+
//todo:: use united class names
|
|
102
|
+
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
103
|
+
if (!isOpen) {
|
|
104
|
+
setTimeout(() => this.host.classList.add('s-hidden'), 350);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
closeModal() {
|
|
108
|
+
if (!this.isClosable) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.host.removeAttribute('visible');
|
|
112
|
+
}
|
|
113
|
+
iconBlockClasses() {
|
|
114
|
+
return {
|
|
115
|
+
's-modal-icon': true,
|
|
116
|
+
's-modal-bg-error': this.iconStyle == 'error',
|
|
117
|
+
's-modal-bg-success': this.iconStyle == 'success',
|
|
118
|
+
's-modal-bg-normal': this.iconStyle != 'error' && this.iconStyle != 'success',
|
|
119
|
+
's-modal-bg-primary': this.iconStyle == 'primary'
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
iconClasses() {
|
|
123
|
+
return {
|
|
124
|
+
[this.icon]: true,
|
|
125
|
+
'sicon-alert-engine': !this.icon && this.iconStyle == 'error' && !this.imageIcon,
|
|
126
|
+
'sicon-check-circle2': !this.icon && this.iconStyle == 'success' && !this.imageIcon,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//todo:: pref for each modal
|
|
130
|
+
render() {
|
|
131
|
+
this.host.id = this.host.id || 'salla-modal';
|
|
132
|
+
return (index.h(index.Host, { class: 'salla-modal s-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("div", { class: "s-modal-wrapper" }, index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.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 ?
|
|
133
|
+
index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
|
|
134
|
+
:
|
|
135
|
+
[
|
|
136
|
+
index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
137
|
+
index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
138
|
+
: '', this.title || this.subTitle ?
|
|
139
|
+
index.h("div", { class: "s-modal-header-inner" }, this.iconStyle || this.icon
|
|
140
|
+
? index.h("div", { class: this.iconBlockClasses() }, index.h("i", { class: this.iconClasses() }))
|
|
141
|
+
: 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 })))
|
|
142
|
+
: ''),
|
|
143
|
+
index.h("slot", null),
|
|
144
|
+
index.h("slot", { name: "footer" })
|
|
145
|
+
]))));
|
|
146
|
+
}
|
|
147
|
+
get host() { return index.getElement(this); }
|
|
148
|
+
static get watchers() { return {
|
|
149
|
+
"visible": ["handleVisible"]
|
|
150
|
+
}; }
|
|
151
|
+
};
|
|
152
|
+
SallaModal.style = sallaModalCss;
|
|
153
|
+
|
|
154
|
+
exports.salla_search = sallaSearch.SallaSearch;
|
|
155
|
+
exports.salla_modal = SallaModal;
|