@salla.sa/twilight-components 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Helper-fcea994c.js +23 -0
- package/dist/cjs/index-4b8b3ffe.js +1696 -0
- package/dist/cjs/index.cjs.js +13 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/salla-branches.cjs.entry.js +92 -0
- package/dist/cjs/salla-button_5.cjs.entry.js +1686 -0
- package/dist/cjs/salla-localization.cjs.entry.js +82 -0
- package/dist/cjs/salla-login-008cc893.js +125 -0
- package/dist/cjs/salla-offer.cjs.entry.js +50 -0
- package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
- package/dist/cjs/salla-rating.cjs.entry.js +300 -0
- package/dist/cjs/salla-search-c7aad59a.js +81 -0
- package/dist/cjs/salla-search.cjs.entry.js +11 -0
- package/dist/cjs/twilight-components.cjs.js +19 -0
- package/dist/collection/Helpers/Helper.js +19 -0
- package/dist/collection/collection-manifest.json +22 -0
- package/dist/collection/components/generate-summary.js +35 -0
- package/dist/collection/components/salla-branches/salla-branches.css +12 -0
- package/dist/collection/components/salla-branches/salla-branches.js +233 -0
- package/dist/collection/components/salla-button/salla-button.css +3 -0
- package/dist/collection/components/salla-button/salla-button.js +246 -0
- package/dist/collection/components/salla-localization/salla-localization.js +208 -0
- package/dist/collection/components/salla-login/salla-login.css +3 -0
- package/dist/collection/components/salla-login/salla-login.js +378 -0
- package/dist/collection/components/salla-modal/salla-modal.js +459 -0
- package/dist/collection/components/salla-offer/salla-offer.js +81 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
- package/dist/collection/components/salla-rating/salla-rating.css +7 -0
- package/dist/collection/components/salla-rating/salla-rating.js +483 -0
- package/dist/collection/components/salla-search/salla-search.js +132 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +14 -0
- package/dist/collection/components/salla-verify/salla-verify.js +273 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/interfaces/colors.js +1 -0
- package/dist/collection/interfaces/index.js +2 -0
- package/dist/collection/interfaces/ratio.js +1 -0
- package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
- package/dist/collection/plugins/tailwind-theme/index.js +26 -0
- package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
- package/dist/esm/index-092659c7.js +1668 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/{twilight-components → esm}/salla-branches.entry.js +1 -1
- package/dist/esm/salla-button_5.entry.js +1678 -0
- package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
- package/dist/{twilight-components/salla-login-b92c73dc.js → esm/salla-login-38586400.js} +2 -6
- package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
- package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
- package/dist/{twilight-components → esm}/salla-rating.entry.js +1 -1
- package/dist/{twilight-components/salla-search-69f2d9c1.js → esm/salla-search-ca856aab.js} +1 -1
- package/dist/esm/salla-search.entry.js +3 -0
- package/dist/esm/twilight-components.js +17 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/twilight-components/index.esm.js +1 -4
- package/dist/twilight-components/p-03d0ec44.entry.js +1 -0
- package/dist/twilight-components/p-13a55257.entry.js +1 -0
- package/dist/twilight-components/p-160062c6.js +1 -0
- package/dist/twilight-components/p-47f17d3b.js +1 -0
- package/dist/twilight-components/p-5307c7b5.entry.js +1 -0
- package/dist/twilight-components/p-6a1f43c6.entry.js +1 -0
- package/dist/twilight-components/p-7088e517.entry.js +1 -0
- package/dist/twilight-components/p-924e3c88.js +1 -0
- package/dist/twilight-components/p-e8965b01.js +1 -0
- package/dist/twilight-components/p-ecb1b6cc.entry.js +1 -0
- package/dist/twilight-components/p-f11b401a.entry.js +1 -0
- package/dist/twilight-components/twilight-components.css +1 -3
- package/dist/twilight-components/twilight-components.esm.js +1 -125
- package/dist/types/components/salla-login/salla-login.d.ts +0 -1
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +4 -0
- package/dist/types/components.d.ts +13 -0
- package/package.json +2 -1
- package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
- package/dist/twilight-components/css-shim-a64b8820.js +0 -4
- package/dist/twilight-components/dom-d08ba8aa.js +0 -73
- package/dist/twilight-components/index-8966d27f.js +0 -3010
- package/dist/twilight-components/salla-button.entry.js +0 -75
- package/dist/twilight-components/salla-login-7c25f64b.js +0 -116
- package/dist/twilight-components/salla-login.entry.js +0 -3
- package/dist/twilight-components/salla-modal.entry.js +0 -113
- package/dist/twilight-components/salla-search.entry.js +0 -3
- package/dist/twilight-components/salla-verify.entry.js +0 -114
- package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, e as Host, g as getElement } from './index-8966d27f.js';
|
|
2
|
-
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
|
|
4
|
-
const sallaButtonCss = ":host{display:block}";
|
|
5
|
-
|
|
6
|
-
const SallaButton = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
this.btnStyle = 'primary';
|
|
10
|
-
this.loading = false;
|
|
11
|
-
this.disabled = false;
|
|
12
|
-
this.loaderPosition = 'before';
|
|
13
|
-
this.wide = false;
|
|
14
|
-
this.hostAttributes = {};
|
|
15
|
-
//============= Initiate Button Attributes =============//
|
|
16
|
-
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
17
|
-
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
18
|
-
}
|
|
19
|
-
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
20
|
-
this.hostAttributes.class += ' s-button-btn btn--has-loading'
|
|
21
|
-
+ ' s-button-' + this.btnStyle
|
|
22
|
-
+ (this.wide ? ' s-button-wide ' : '')
|
|
23
|
-
+ ' loader-' + this.loaderPosition
|
|
24
|
-
+ (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
|
|
25
|
-
delete this.hostAttributes['btn-style'];
|
|
26
|
-
delete this.hostAttributes['id'];
|
|
27
|
-
if (this.wide) {
|
|
28
|
-
this.host.classList.add('s-button-wide');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async load() {
|
|
32
|
-
if (this.loaderPosition == 'center')
|
|
33
|
-
this.text.classList.add('s-button-hide');
|
|
34
|
-
this.host.setAttribute('loading', '');
|
|
35
|
-
return this.host;
|
|
36
|
-
}
|
|
37
|
-
async stop() {
|
|
38
|
-
this.host.removeAttribute('loading');
|
|
39
|
-
return this.host;
|
|
40
|
-
}
|
|
41
|
-
async disable() {
|
|
42
|
-
this.host.setAttribute('disabled', '');
|
|
43
|
-
}
|
|
44
|
-
async enable() {
|
|
45
|
-
this.host.removeAttribute('disabled');
|
|
46
|
-
}
|
|
47
|
-
handleVisible(newKind, oldKind) {
|
|
48
|
-
//todo::use united styles
|
|
49
|
-
this.btn.classList.remove('btn-' + oldKind);
|
|
50
|
-
this.btn.classList.add('btn-' + newKind);
|
|
51
|
-
}
|
|
52
|
-
handleLoading(newVal) {
|
|
53
|
-
//todo::use united styles
|
|
54
|
-
Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
55
|
-
}
|
|
56
|
-
render() {
|
|
57
|
-
return (
|
|
58
|
-
//TODO:: use HOST then fake button behaviours
|
|
59
|
-
h(Host, { class: "s-button-host-tag" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
|
|
60
|
-
//todo::use united styles
|
|
61
|
-
's-button-loader': true,
|
|
62
|
-
's-button-loader-start': this.loaderPosition === 'start',
|
|
63
|
-
's-button-loader-end': this.loaderPosition === 'end',
|
|
64
|
-
's-button-loader-center': this.loaderPosition === 'center',
|
|
65
|
-
} }) : '')));
|
|
66
|
-
}
|
|
67
|
-
get host() { return getElement(this); }
|
|
68
|
-
static get watchers() { return {
|
|
69
|
-
"btnStyle": ["handleVisible"],
|
|
70
|
-
"loading": ["handleLoading"]
|
|
71
|
-
}; }
|
|
72
|
-
};
|
|
73
|
-
SallaButton.style = sallaButtonCss;
|
|
74
|
-
|
|
75
|
-
export { SallaButton as salla_button };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-8966d27f.js';
|
|
2
|
-
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
|
|
4
|
-
const SallaLogin = class {
|
|
5
|
-
constructor(hostRef) {
|
|
6
|
-
registerInstance(this, hostRef);
|
|
7
|
-
this.regType = 'sms';
|
|
8
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
9
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
10
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
11
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
12
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
13
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
14
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
15
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
16
|
-
this.backText = salla.lang.get('common.elements.back');
|
|
17
|
-
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
18
|
-
this.host.removeAttribute('title');
|
|
19
|
-
salla.auth.event.onVerificationFailed(() => {
|
|
20
|
-
//
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
25
|
-
*/
|
|
26
|
-
onVerified(event) {
|
|
27
|
-
if (!event.detail.case) {
|
|
28
|
-
console.log('verified but without case!');
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (event.detail.case === "new_customer") {
|
|
32
|
-
return this.showTab(this.tab5);
|
|
33
|
-
}
|
|
34
|
-
//TODO::It looks that is this workaround🤔
|
|
35
|
-
if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (event.redirect_url) {
|
|
39
|
-
return window.location.href = event.redirect_url;
|
|
40
|
-
}
|
|
41
|
-
window.location.reload();
|
|
42
|
-
}
|
|
43
|
-
onModalClose() {
|
|
44
|
-
this.showTab(this.tab1);
|
|
45
|
-
}
|
|
46
|
-
async show() {
|
|
47
|
-
return this.modal.show();
|
|
48
|
-
}
|
|
49
|
-
showTab(tab) {
|
|
50
|
-
[this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
|
|
51
|
-
if ([this.tab2, this.tab3].includes(tab)) {
|
|
52
|
-
this.regType = tab === this.tab2 ? 'sms' : 'email';
|
|
53
|
-
}
|
|
54
|
-
let isRegistrationTab = tab == this.tab5;
|
|
55
|
-
this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
|
|
56
|
-
if (!isRegistrationTab) {
|
|
57
|
-
Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'sms')
|
|
58
|
-
.toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
|
|
59
|
-
}
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
loginByEmail() {
|
|
63
|
-
if (!Helper.isValidEmail(this.email.value)) {
|
|
64
|
-
this.email.classList.add('s-has-error');
|
|
65
|
-
this.email.nextElementSibling['innerText'] = '* ' + salla.lang.get('common.elements.email_is_valid');
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.email.nextElementSibling['innerText'] = '';
|
|
69
|
-
this.email.classList.remove('s-has-error');
|
|
70
|
-
salla.auth.api.login({ type: 'email', email: this.email.value })
|
|
71
|
-
.then(() => this.showTab(this.tab4))
|
|
72
|
-
.then(() => (this.tab4.by = 'email') && (this.tab4.url = 'auth/email/verify'))
|
|
73
|
-
.then(() => this.tab4.show({ email: this.email.value }));
|
|
74
|
-
}
|
|
75
|
-
loginBySMS() {
|
|
76
|
-
if (this.mobile.value.length < 6) {
|
|
77
|
-
this.mobile.classList.add('s-has-error');
|
|
78
|
-
this.mobile.nextElementSibling['innerText'] = '* ' + salla.lang.get('mobile_app.strings.incorrect_mobile');
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this.mobile.nextElementSibling['innerText'] = '';
|
|
82
|
-
this.mobile.classList.remove('s-has-error');
|
|
83
|
-
salla.auth.api.login({ type: 'sms', mobile: this.mobile.value })
|
|
84
|
-
.then(() => this.showTab(this.tab4))
|
|
85
|
-
.then(() => (this.tab4.by = 'sms') && (this.tab4.url = 'auth/mobile/verify'))
|
|
86
|
-
.then(() => this.tab4.show({ mobile: this.mobile.value, country_code: 'SA' }));
|
|
87
|
-
}
|
|
88
|
-
//TODO:: if it's enter, go submit
|
|
89
|
-
typing({ target }) {
|
|
90
|
-
target.type === 'tel' && salla.helpers.digitsOnly(target);
|
|
91
|
-
target.classList.remove('s-has-error');
|
|
92
|
-
target.nextElementSibling.innerText = '';
|
|
93
|
-
}
|
|
94
|
-
newUser() {
|
|
95
|
-
this.tab4.getCode()
|
|
96
|
-
.then(code => salla.auth.api.register({
|
|
97
|
-
first_name: this.firstName.value,
|
|
98
|
-
last_name: this.lastName.value,
|
|
99
|
-
phone: this.regMobile.value || this.mobile.value,
|
|
100
|
-
email: this.regEmail.value || this.email.value,
|
|
101
|
-
country_code: '',
|
|
102
|
-
country_key: '',
|
|
103
|
-
code: code,
|
|
104
|
-
verified_by: this.regType,
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
render() {
|
|
108
|
-
return (h("salla-modal", { id: "salla-login", title: this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-tab", ref: tab => this.tab1 = tab }, h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab2) }, h("i", { class: "s-login-main-btn-icon sicon-phone" }), h("span", { class: "s-login-main-btn-text" }, this.smsLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab3) }, h("i", { class: "s-login-main-btn-icon sicon-mail" }), h("span", { class: "s-login-main-btn-text" }, this.emailLabel), h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" }))), h("div", { class: "s-login-tab", ref: tab => this.tab2 = tab }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { type: "tel", ref: el => this.mobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginBySMS() }, this.enterText), h("a", { href: "#", onClick: () => this.showTab(this.tab3), class: "s-login-link" }, this.byEmailText)), h("div", { class: "s-login-tab", ref: tab => this.tab3 = tab }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.email = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" }), h("salla-button", { wide: true, onClick: () => this.loginByEmail() }, this.enterText), h("a", { href: "#", onClick: () => this.showTab(this.tab2), class: "s-login-link" }, this.bySMSText)), h("salla-verify", { "without-modal": true, ref: tab => this.tab4 = tab, autoReload: false }), h("div", { ref: tab => this.tab5 = tab }, h("label", { class: "s-login-label" }, salla.lang.get('blocks.header.your_name')), h("div", { class: "s-login-input-group" }, h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, placeholder: salla.lang.get('pages.profile.first_name') }), h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, placeholder: salla.lang.get('pages.profile.last_name') })), h("div", { ref: el => this.regMobileBlock = el }, h("label", { class: "s-login-label" }, this.mobileLabel), h("input", { type: "tel", ref: el => this.regMobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("div", { ref: el => this.regEmailBlock = el }, h("label", { class: "s-login-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }), h("span", { class: "s-login-error-message" })), h("salla-button", { wide: true, onClick: () => this.newUser() }, salla.lang.get('blocks.header.register')))));
|
|
109
|
-
}
|
|
110
|
-
componentDidRender() {
|
|
111
|
-
this.showTab(this.tab1);
|
|
112
|
-
}
|
|
113
|
-
get host() { return getElement(this); }
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export { SallaLogin as S };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-8966d27f.js';
|
|
2
|
-
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
|
|
4
|
-
const SallaModal = class {
|
|
5
|
-
constructor(hostRef) {
|
|
6
|
-
registerInstance(this, hostRef);
|
|
7
|
-
this.modalOpened = createEvent(this, "modalOpened", 7);
|
|
8
|
-
this.modalClosed = createEvent(this, "modalClosed", 7);
|
|
9
|
-
var _a;
|
|
10
|
-
//todo:: unite three colors (error, success, primary) in one prop
|
|
11
|
-
this.error = false;
|
|
12
|
-
this.success = false;
|
|
13
|
-
this.primary = false;
|
|
14
|
-
this.isClosable = true;
|
|
15
|
-
this.width = 'md';
|
|
16
|
-
this.visible = false;
|
|
17
|
-
this.isLoading = false;
|
|
18
|
-
this.subTitleFirst = false;
|
|
19
|
-
this.subTitle = '';
|
|
20
|
-
this.icon = '';
|
|
21
|
-
this.imageIcon = '';
|
|
22
|
-
Helper.setHost(this.host);
|
|
23
|
-
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
24
|
-
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
25
|
-
this.title = this.host.title;
|
|
26
|
-
this.host.removeAttribute('title');
|
|
27
|
-
(_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
|
|
28
|
-
}
|
|
29
|
-
handleVisible(newValue) {
|
|
30
|
-
if (!newValue) {
|
|
31
|
-
this.toggleModal(false);
|
|
32
|
-
this.modalClosed.emit();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.host.classList.remove('hidden');
|
|
36
|
-
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
37
|
-
this.modalOpened.emit();
|
|
38
|
-
}
|
|
39
|
-
async show() {
|
|
40
|
-
this.host.setAttribute('visible', '');
|
|
41
|
-
return this.host;
|
|
42
|
-
}
|
|
43
|
-
async hide() {
|
|
44
|
-
this.host.removeAttribute('visible');
|
|
45
|
-
return this.host;
|
|
46
|
-
}
|
|
47
|
-
async setTitle(title) {
|
|
48
|
-
this.title = title;
|
|
49
|
-
return this.host;
|
|
50
|
-
}
|
|
51
|
-
async loading() {
|
|
52
|
-
this.isLoading = true;
|
|
53
|
-
return this.host;
|
|
54
|
-
}
|
|
55
|
-
async stopLoading() {
|
|
56
|
-
this.isLoading = false;
|
|
57
|
-
return this.host;
|
|
58
|
-
}
|
|
59
|
-
toggleModal(isOpen) {
|
|
60
|
-
Helper
|
|
61
|
-
// .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
62
|
-
.toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
63
|
-
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
64
|
-
//todo:: use united class names
|
|
65
|
-
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
66
|
-
if (!isOpen) {
|
|
67
|
-
setTimeout(() => this.host.classList.add('hidden'), 350);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
closeModal() {
|
|
71
|
-
if (!this.isClosable) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this.host.removeAttribute('visible');
|
|
75
|
-
}
|
|
76
|
-
//todo:: pref for each modal
|
|
77
|
-
render() {
|
|
78
|
-
this.host.id = this.host.id || 'salla-modal';
|
|
79
|
-
return (
|
|
80
|
-
//todo:: use suitable class name instead of hidden
|
|
81
|
-
h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + 's-modal-' + this.width, slot: "body" }, this.isLoading
|
|
82
|
-
? h("span", null, "Loading...")
|
|
83
|
-
: [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
84
|
-
//todo:: remove cursor-pointer
|
|
85
|
-
h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
|
|
86
|
-
: '', this.error || this.success || this.icon
|
|
87
|
-
? h("div", { class: {
|
|
88
|
-
's-modal-icon': true,
|
|
89
|
-
's-modal-bg-error': this.error,
|
|
90
|
-
's-modal-bg-success': this.success,
|
|
91
|
-
's-modal-bg-normal': !this.error && !this.success,
|
|
92
|
-
's-modal-bg-primary': this.primary
|
|
93
|
-
} }, h("i", { class: {
|
|
94
|
-
[this.icon]: true,
|
|
95
|
-
's-modal-text-error': this.error,
|
|
96
|
-
's-modal-text-success': this.success,
|
|
97
|
-
} }))
|
|
98
|
-
: this.imageIcon ?
|
|
99
|
-
h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
100
|
-
: '', this.title || this.subTitle ?
|
|
101
|
-
h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
|
|
102
|
-
: ''),
|
|
103
|
-
h("slot", null),
|
|
104
|
-
h("slot", { name: "footer" })
|
|
105
|
-
])))));
|
|
106
|
-
}
|
|
107
|
-
get host() { return getElement(this); }
|
|
108
|
-
static get watchers() { return {
|
|
109
|
-
"visible": ["handleVisible"]
|
|
110
|
-
}; }
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { SallaModal as salla_modal };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, f as createEvent, h, g as getElement } from './index-8966d27f.js';
|
|
2
|
-
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
|
|
4
|
-
const SallaVerify = class {
|
|
5
|
-
constructor(hostRef) {
|
|
6
|
-
registerInstance(this, hostRef);
|
|
7
|
-
this.verified = createEvent(this, "verified", 7);
|
|
8
|
-
this.backClicked = createEvent(this, "backClicked", 7);
|
|
9
|
-
this.url = 'profile/verify-mobile';
|
|
10
|
-
this.by = 'sms';
|
|
11
|
-
this.autoReload = true;
|
|
12
|
-
Helper.setHost(this.host);
|
|
13
|
-
if (this.withoutModal) {
|
|
14
|
-
this.modal = { show: () => '', hide: () => '' };
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
async getCode() {
|
|
21
|
-
return this.code.value;
|
|
22
|
-
}
|
|
23
|
-
async show(data) {
|
|
24
|
-
this.data = data;
|
|
25
|
-
this.resendTimer();
|
|
26
|
-
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
27
|
-
this.otpInputs[0].focus();
|
|
28
|
-
Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
29
|
-
Helper.onKeyUp('.s-verify-input', event => {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
31
|
-
let key = event.keyCode || event.charCode;
|
|
32
|
-
if (event.target.value) {
|
|
33
|
-
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
34
|
-
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
35
|
-
}
|
|
36
|
-
else if ([8, 46].includes(key)) {
|
|
37
|
-
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
38
|
-
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
39
|
-
}
|
|
40
|
-
this.toggleOTPSubmit();
|
|
41
|
-
});
|
|
42
|
-
Helper.on('paste', '.s-verify-input', event => {
|
|
43
|
-
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
44
|
-
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
45
|
-
this.toggleOTPSubmit();
|
|
46
|
-
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
47
|
-
});
|
|
48
|
-
return this.modal.show();
|
|
49
|
-
}
|
|
50
|
-
toggleOTPSubmit() {
|
|
51
|
-
let otp = [];
|
|
52
|
-
this.otpInputs.forEach(input => input.value && otp.push(input.value));
|
|
53
|
-
this.code.value = otp.join('');
|
|
54
|
-
if (otp.length === 4) {
|
|
55
|
-
this.btn.removeAttribute('disabled');
|
|
56
|
-
this.btn.click();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.btn.setAttribute('disabled', '');
|
|
60
|
-
}
|
|
61
|
-
resendTimer() {
|
|
62
|
-
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
63
|
-
let resendAfter = 30;
|
|
64
|
-
let timerId = setInterval(() => {
|
|
65
|
-
if (resendAfter === -1) {
|
|
66
|
-
clearTimeout(timerId);
|
|
67
|
-
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
71
|
-
resendAfter--;
|
|
72
|
-
}
|
|
73
|
-
}, 1000);
|
|
74
|
-
}
|
|
75
|
-
resendCode() {
|
|
76
|
-
return this.btn.stop()
|
|
77
|
-
.then(() => this.btn.disable())
|
|
78
|
-
.then(() => {
|
|
79
|
-
this.otpInputs.forEach(input => input.value = '');
|
|
80
|
-
this.otpInputs[0].focus();
|
|
81
|
-
})
|
|
82
|
-
.then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
|
|
83
|
-
.then(() => this.resendTimer())
|
|
84
|
-
.catch(() => this.resendTimer());
|
|
85
|
-
}
|
|
86
|
-
submit() {
|
|
87
|
-
return this.btn.load()
|
|
88
|
-
.then(() => this.btn.disable())
|
|
89
|
-
.then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
|
|
90
|
-
.then(response => this.verified.emit(response))
|
|
91
|
-
.then(() => this.btn.stop() && this.btn.disable())
|
|
92
|
-
.then(() => this.modal.hide())
|
|
93
|
-
.then(() => this.autoReload && window.location.reload())
|
|
94
|
-
.catch(() => this.btn.stop() && this.btn.enable());
|
|
95
|
-
}
|
|
96
|
-
render() {
|
|
97
|
-
return this.withoutModal ? this.myBody() :
|
|
98
|
-
h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
|
|
99
|
-
}
|
|
100
|
-
myBody() {
|
|
101
|
-
return [
|
|
102
|
-
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
103
|
-
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
104
|
-
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
105
|
-
h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
|
|
106
|
-
h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')), this.backText ?
|
|
107
|
-
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.backClicked.emit() }, this.backText)
|
|
108
|
-
: '')
|
|
109
|
-
];
|
|
110
|
-
}
|
|
111
|
-
get host() { return getElement(this); }
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export { SallaVerify as salla_verify };
|