@salla.sa/twilight-components 1.0.58 → 1.0.61
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-0b5b5867.js → index-543e387e.js} +293 -8
- package/dist/cjs/index.cjs.js +0 -11
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-branches.cjs.entry.js +2 -2
- package/dist/cjs/salla-button.cjs.entry.js +2 -2
- package/dist/cjs/salla-conditional-fields.cjs.entry.js +17 -3
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +2 -2
- package/dist/cjs/salla-localization-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-login-modal.cjs.entry.js +199 -4
- package/dist/cjs/salla-modal_2.cjs.entry.js +87 -4
- package/dist/cjs/salla-offer-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-product-availability.cjs.entry.js +2 -2
- package/dist/cjs/salla-quantity-input.cjs.entry.js +9 -6
- package/dist/cjs/salla-rating-modal.cjs.entry.js +6 -56
- package/dist/cjs/salla-rating-stars.cjs.entry.js +80 -0
- package/dist/cjs/salla-tabby.cjs.entry.js +19 -0
- package/dist/cjs/salla-tamara.cjs.entry.js +19 -0
- package/dist/cjs/salla-tel-input.cjs.entry.js +2 -2
- package/dist/cjs/salla-verify-modal.cjs.entry.js +2 -2
- package/dist/cjs/twilight-components.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/salla-branches/salla-branches.css +1077 -0
- package/dist/collection/components/salla-button/salla-button.css +1077 -0
- package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +16 -2
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.css +1077 -0
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.css +1077 -0
- package/dist/collection/components/salla-login-modal/salla-login-modal.css +1077 -0
- package/dist/collection/components/salla-modal/salla-modal.css +1077 -0
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.css +1077 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.css +1077 -0
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +8 -5
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.css +1077 -0
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +5 -59
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.css +1089 -0
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +137 -0
- package/dist/collection/components/salla-search/salla-search.css +1077 -0
- package/dist/collection/components/salla-tabby/salla-tabby.css +1117 -0
- package/dist/collection/components/salla-tabby/salla-tabby.js +14 -0
- package/dist/collection/components/salla-tamara/salla-tamara.css +1135 -0
- package/dist/collection/components/salla-tamara/salla-tamara.js +15 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.css +1290 -0
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.css +1077 -0
- package/dist/collection/index.js +1 -2
- package/dist/components/Helper.js +23 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/salla-branches.d.ts +7 -0
- package/dist/components/salla-branches.js +90 -0
- package/dist/components/salla-button.d.ts +7 -0
- package/dist/components/salla-button.js +118 -0
- package/dist/components/salla-conditional-fields.d.ts +7 -0
- package/dist/components/salla-conditional-fields.js +89 -0
- package/dist/components/salla-infinite-scroll.d.ts +7 -0
- package/dist/components/salla-infinite-scroll.js +93 -0
- package/dist/components/salla-localization-modal.d.ts +7 -0
- package/dist/components/salla-localization-modal.js +116 -0
- package/dist/components/salla-login-modal.d.ts +7 -0
- package/dist/components/salla-login-modal.js +205 -0
- package/dist/components/salla-modal.d.ts +7 -0
- package/dist/components/salla-modal.js +152 -0
- package/dist/components/salla-offer-modal.d.ts +7 -0
- package/dist/components/salla-offer-modal.js +141 -0
- package/dist/components/salla-product-availability.d.ts +7 -0
- package/dist/components/salla-product-availability.js +114 -0
- package/dist/components/salla-quantity-input.d.ts +7 -0
- package/dist/components/salla-quantity-input.js +66 -0
- package/dist/components/salla-rating-modal.d.ts +7 -0
- package/dist/components/salla-rating-modal.js +178 -0
- package/dist/components/salla-rating-stars.d.ts +7 -0
- package/dist/components/salla-rating-stars.js +79 -0
- package/dist/components/salla-search.d.ts +7 -0
- package/dist/components/salla-search.js +91 -0
- package/dist/components/salla-tabby.d.ts +7 -0
- package/dist/components/salla-tabby.js +18 -0
- package/dist/components/salla-tamara.d.ts +7 -0
- package/dist/components/salla-tamara.js +19 -0
- package/dist/components/salla-tel-input.d.ts +7 -0
- package/dist/components/salla-tel-input.js +1477 -0
- package/dist/components/salla-verify-modal.d.ts +7 -0
- package/dist/components/salla-verify-modal.js +147 -0
- package/dist/esm/{index-8b97d225.js → index-2423ebcb.js} +293 -8
- package/dist/esm/index.js +1 -4
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-branches.entry.js +2 -2
- package/dist/esm/salla-button.entry.js +2 -2
- package/dist/esm/salla-conditional-fields.entry.js +17 -3
- package/dist/esm/salla-infinite-scroll.entry.js +2 -2
- package/dist/esm/salla-localization-modal.entry.js +2 -2
- package/dist/esm/salla-login-modal.entry.js +202 -3
- package/dist/esm/salla-modal_2.entry.js +87 -4
- package/dist/esm/salla-offer-modal.entry.js +2 -2
- package/dist/esm/salla-product-availability.entry.js +2 -2
- package/dist/esm/salla-quantity-input.entry.js +9 -6
- package/dist/esm/salla-rating-modal.entry.js +6 -56
- package/dist/esm/salla-rating-stars.entry.js +76 -0
- package/dist/esm/salla-tabby.entry.js +15 -0
- package/dist/esm/salla-tamara.entry.js +15 -0
- package/dist/esm/salla-tel-input.entry.js +2 -2
- package/dist/esm/salla-verify-modal.entry.js +2 -2
- package/dist/esm/twilight-components.js +2 -2
- package/dist/twilight-components/index.esm.js +0 -1
- package/dist/twilight-components/p-01accdcd.entry.js +1 -0
- package/dist/twilight-components/p-0e85664f.entry.js +1 -0
- package/dist/twilight-components/p-0ee36dd8.entry.js +1 -0
- package/dist/twilight-components/p-1fb0ca8a.js +1 -0
- package/dist/twilight-components/p-1ffd27c4.entry.js +1 -0
- package/dist/twilight-components/p-2012882b.entry.js +1 -0
- package/dist/twilight-components/p-3d9fd3d3.entry.js +1 -0
- package/dist/twilight-components/p-5b2cdd7c.entry.js +1 -0
- package/dist/twilight-components/p-728bd268.entry.js +1 -0
- package/dist/twilight-components/p-72985a41.entry.js +1 -0
- package/dist/twilight-components/p-747f80df.entry.js +1 -0
- package/dist/twilight-components/p-81a7a676.entry.js +1 -0
- package/dist/twilight-components/p-880711d4.entry.js +1 -0
- package/dist/twilight-components/p-8dd742df.entry.js +1 -0
- package/dist/twilight-components/p-9642541b.entry.js +1 -0
- package/dist/twilight-components/p-a24588ab.entry.js +1 -0
- package/dist/twilight-components/p-e3cbda45.entry.js +1 -0
- package/dist/twilight-components/twilight-components.css +1 -1
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +1 -0
- package/dist/types/components/salla-quantity-input/salla-quantity-input.d.ts +2 -1
- package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +0 -3
- package/dist/types/components/salla-rating-stars/salla-rating-stars.d.ts +11 -0
- package/dist/types/components/salla-tabby/salla-tabby.d.ts +3 -0
- package/dist/types/components/salla-tamara/salla-tamara.d.ts +3 -0
- package/dist/types/components.d.ts +45 -0
- package/dist/types/index.d.ts +1 -2
- package/example/assets/images/star.png +0 -0
- package/example/dist/demo.js +47 -7
- package/example/dist/tailwind.css +161 -175
- package/example/dist/twilight.js +437 -2
- package/example/index.html +542 -288
- package/package.json +17 -10
- package/dist/cjs/salla-login-modal-02e4e65e.js +0 -204
- package/dist/cjs/salla-search-9d17eb96.js +0 -90
- package/dist/esm/salla-login-modal-7ad386c8.js +0 -202
- package/dist/esm/salla-search-ce45eb5b.js +0 -88
- package/dist/loader/cdn.js +0 -3
- package/dist/loader/index.cjs.js +0 -3
- package/dist/loader/index.d.ts +0 -13
- package/dist/loader/index.es2017.js +0 -3
- package/dist/loader/index.js +0 -4
- package/dist/loader/package.json +0 -10
- package/dist/twilight-components/p-1514ed09.js +0 -1
- package/dist/twilight-components/p-2a032b88.entry.js +0 -1
- package/dist/twilight-components/p-2f3f4cce.entry.js +0 -1
- package/dist/twilight-components/p-40693cd3.entry.js +0 -1
- package/dist/twilight-components/p-5d5b04ec.entry.js +0 -1
- package/dist/twilight-components/p-635c08a7.entry.js +0 -1
- package/dist/twilight-components/p-64977eab.entry.js +0 -1
- package/dist/twilight-components/p-6c928c14.entry.js +0 -1
- package/dist/twilight-components/p-79ab1ed9.entry.js +0 -1
- package/dist/twilight-components/p-7c4ba872.entry.js +0 -1
- package/dist/twilight-components/p-84936d9d.entry.js +0 -1
- package/dist/twilight-components/p-884a80ca.entry.js +0 -1
- package/dist/twilight-components/p-c51984d6.entry.js +0 -1
- package/dist/twilight-components/p-cb1c59a2.js +0 -1
- package/dist/twilight-components/p-ebd63ad4.js +0 -1
- package/dist/twilight-components/p-ee9d8563.entry.js +0 -1
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"author": "Salla Team <support@salla.dev> (https://salla.dev)",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/sallaapp/twilight-components",
|
|
8
|
+
"email": "support@salla.dev"
|
|
9
|
+
},
|
|
5
10
|
"keywords": [
|
|
6
11
|
"twilight",
|
|
7
12
|
"Salla",
|
|
8
|
-
"Salla
|
|
9
|
-
"Salla
|
|
13
|
+
"Salla theme",
|
|
14
|
+
"Salla-web-component"
|
|
10
15
|
],
|
|
11
16
|
"description": "Salla Web Component",
|
|
12
17
|
"main": "dist/index.cjs.js",
|
|
13
18
|
"module": "dist/index.js",
|
|
14
19
|
"es2015": "dist/esm/index.mjs",
|
|
15
20
|
"es2017": "dist/esm/index.mjs",
|
|
16
|
-
"types": "dist/types/
|
|
21
|
+
"types": "dist/types/components.d.ts",
|
|
17
22
|
"collection": "dist/collection/collection-manifest.json",
|
|
18
23
|
"collection:main": "dist/collection/index.js",
|
|
19
|
-
"unpkg": "dist/
|
|
24
|
+
"unpkg": "dist/twilight-components/twilight-components.esm.js",
|
|
20
25
|
"files": [
|
|
21
26
|
"dist/",
|
|
22
27
|
"loader/",
|
|
@@ -46,30 +51,32 @@
|
|
|
46
51
|
},
|
|
47
52
|
"devDependencies": {
|
|
48
53
|
"@compodoc/compodoc": "^1.1.14",
|
|
49
|
-
"@stencil/core": "2.
|
|
54
|
+
"@stencil/core": "^2.13.0",
|
|
50
55
|
"@stencil/eslint-plugin": "^0.3.1",
|
|
51
56
|
"@stencil/react-output-target": "^0.1.0",
|
|
52
57
|
"@stencil/sass": "1.4.1",
|
|
53
58
|
"@stencil/vue-output-target": "^0.5.1",
|
|
54
|
-
"@types/jest": "
|
|
59
|
+
"@types/jest": "^27.0.3",
|
|
60
|
+
"jest": "^27.4.5",
|
|
61
|
+
"jest-cli": "^27.4.5",
|
|
62
|
+
"puppeteer": "^10.0.0",
|
|
55
63
|
"@types/puppeteer": "3.0.2",
|
|
56
64
|
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
|
57
65
|
"@typescript-eslint/parser": "^2.34.0",
|
|
58
66
|
"eslint": "^7.32.0",
|
|
59
67
|
"eslint-config-prettier": "^8.3.0",
|
|
60
68
|
"eslint-plugin-react": "^7.26.0",
|
|
61
|
-
"jest": "26.6.1",
|
|
62
|
-
"jest-cli": "26.6.1",
|
|
63
69
|
"lodash": "^4.17.21",
|
|
64
70
|
"prettier": "^2.4.1",
|
|
65
71
|
"promisify-child-process": "^3.1.4",
|
|
66
|
-
"puppeteer": "^5.4.1",
|
|
67
72
|
"tailwindcss": "^2.2.19",
|
|
68
73
|
"typescript": "^4.4.3"
|
|
69
74
|
},
|
|
70
75
|
"dependencies": {
|
|
71
76
|
"@salla.sa/twilight": "^2.0.162",
|
|
77
|
+
"@stencil/core": "^2.13.0",
|
|
72
78
|
"intl-tel-input": "^17.0.13",
|
|
79
|
+
"module-alias": "^2.2.2",
|
|
73
80
|
"store": "^2.0.12"
|
|
74
81
|
}
|
|
75
82
|
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const index = require('./index-0b5b5867.js');
|
|
4
|
-
const Helper = require('./Helper-98cc9f18.js');
|
|
5
|
-
|
|
6
|
-
const sallaLoginModalCss = "[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";
|
|
7
|
-
|
|
8
|
-
const SallaLoginModal = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
index.registerInstance(this, hostRef);
|
|
11
|
-
/**
|
|
12
|
-
* Does the merchant allow to login using email
|
|
13
|
-
*/
|
|
14
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', true);
|
|
15
|
-
/**
|
|
16
|
-
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
17
|
-
*/
|
|
18
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
19
|
-
/**
|
|
20
|
-
* Does the merchant require registration with email & mobile
|
|
21
|
-
*/
|
|
22
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
23
|
-
this.regType = 'phone';
|
|
24
|
-
//TODO:: any salla-button, text should updated by this.btn?.setText(newText)
|
|
25
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
26
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
27
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
28
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
29
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
30
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
31
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
32
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
33
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
34
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
35
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
36
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
37
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
38
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
39
|
-
this.typing = (e, submitMethod) => {
|
|
40
|
-
const error = e.target.nextElementSibling;
|
|
41
|
-
e.target.classList.remove('s-has-error');
|
|
42
|
-
(error === null || error === void 0 ? void 0 : error.classList.contains('s-login-modal-error-message')) && (error.innerText = '');
|
|
43
|
-
e.key == 'Enter' && submitMethod();
|
|
44
|
-
};
|
|
45
|
-
this.loginBySMS = async () => {
|
|
46
|
-
const { mobile, countryCode } = await this.loginTelInput.getValues();
|
|
47
|
-
const isPhoneValid = await this.loginTelInput.isValid();
|
|
48
|
-
if (!isPhoneValid)
|
|
49
|
-
return;
|
|
50
|
-
this.smsBtn.load()
|
|
51
|
-
.then(() => this.smsBtn.disable())
|
|
52
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
53
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
54
|
-
.then(() => this.showTab(this.verifyTab))
|
|
55
|
-
.then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
56
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
57
|
-
};
|
|
58
|
-
this.loginByEmail = () => {
|
|
59
|
-
if (!Helper.Helper.isValidEmail(this.loginEmail.value)) {
|
|
60
|
-
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.emailBtn.load()
|
|
64
|
-
.then(() => this.emailBtn.disable())
|
|
65
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
66
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
67
|
-
.then(() => this.showTab(this.verifyTab))
|
|
68
|
-
.then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
69
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
70
|
-
};
|
|
71
|
-
this.newUser = async () => {
|
|
72
|
-
var _a;
|
|
73
|
-
const { mobile: regPhone, countryCode, countryKey } = this.regType == "email" ? await this.regTelInput.getValues() : await this.loginTelInput.getValues(), emailValue = this.regEmail.value || ((_a = this.loginEmail) === null || _a === void 0 ? void 0 : _a.value);
|
|
74
|
-
await this.newUserValidation();
|
|
75
|
-
await this.regBtn.load();
|
|
76
|
-
await this.regBtn.disable();
|
|
77
|
-
let data = {
|
|
78
|
-
first_name: this.firstName.value,
|
|
79
|
-
last_name: this.lastName.value,
|
|
80
|
-
phone: regPhone || this.loginTelInput.mobile,
|
|
81
|
-
country_code: countryCode,
|
|
82
|
-
country_key: countryKey,
|
|
83
|
-
verified_by: this.regType,
|
|
84
|
-
};
|
|
85
|
-
emailValue && (data = Object.assign(Object.assign({}, data), { email: emailValue }));
|
|
86
|
-
this.verifyTab.getCode()
|
|
87
|
-
.then(code => salla.auth.api.register(Object.assign(Object.assign({}, data), { code })))
|
|
88
|
-
.then(() => window.location.reload())
|
|
89
|
-
.catch(() => this.regBtn.stop() && this.regBtn.enable());
|
|
90
|
-
};
|
|
91
|
-
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
92
|
-
this.host.removeAttribute('title');
|
|
93
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
94
|
-
var _a, _b, _c, _d;
|
|
95
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
96
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
97
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
98
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
99
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
100
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
101
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
102
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
103
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
104
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
105
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
106
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
107
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
108
|
-
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
109
|
-
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
110
|
-
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
111
|
-
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
112
|
-
});
|
|
113
|
-
salla.auth.event.onVerificationFailed(() => {
|
|
114
|
-
//
|
|
115
|
-
});
|
|
116
|
-
salla.event.on('login::show', () => this.show());
|
|
117
|
-
salla.event.on('twilight::initiated', () => {
|
|
118
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
|
|
119
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
|
|
120
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', !!this.isEmailRequired);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
125
|
-
*/
|
|
126
|
-
onVerified(event) {
|
|
127
|
-
if (!event.detail.case) {
|
|
128
|
-
console.log('verified but without case!');
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (event.detail.case === "new_customer") {
|
|
132
|
-
return this.showTab(this.registrationTab);
|
|
133
|
-
}
|
|
134
|
-
//TODO::It looks that this is a workaround for something, so needs to be enhanced🤔
|
|
135
|
-
if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (event.redirect_url) {
|
|
139
|
-
return window.location.href = event.redirect_url;
|
|
140
|
-
}
|
|
141
|
-
window.location.reload();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Show login component
|
|
145
|
-
*/
|
|
146
|
-
async show() {
|
|
147
|
-
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
148
|
-
this.showTab(this.homeTab);
|
|
149
|
-
}
|
|
150
|
-
else if (this.isEmailAllowed) {
|
|
151
|
-
this.showTab(this.emailTab);
|
|
152
|
-
}
|
|
153
|
-
else if (this.isMobileAllowed) {
|
|
154
|
-
this.showTab(this.mobileTab);
|
|
155
|
-
}
|
|
156
|
-
return this.modal.show();
|
|
157
|
-
}
|
|
158
|
-
showTab(tab, evt) {
|
|
159
|
-
var _a, _b;
|
|
160
|
-
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
161
|
-
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
162
|
-
tabs.map(el => Helper.Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
|
|
163
|
-
setTimeout(() => tabs.map(el => Helper.Helper.toggleElementClassIf(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
|
-
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
166
|
-
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
167
|
-
}
|
|
168
|
-
let isRegistrationTab = tab == this.registrationTab;
|
|
169
|
-
isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
|
|
170
|
-
(_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
|
|
171
|
-
if (!isRegistrationTab) {
|
|
172
|
-
Helper.Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
|
|
173
|
-
.toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
|
|
174
|
-
}
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
async newUserValidation() {
|
|
178
|
-
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
179
|
-
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
180
|
-
return;
|
|
181
|
-
!isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);
|
|
182
|
-
!isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);
|
|
183
|
-
!isLastNameValid && this.validateField(this.lastName, this.lastNameErrorMsg);
|
|
184
|
-
throw ('Please insert required fields');
|
|
185
|
-
}
|
|
186
|
-
// eslint-disable-next-line @stencil/own-methods-must-be-private
|
|
187
|
-
validateField(field, errorMsg) {
|
|
188
|
-
field.classList.add('s-has-error');
|
|
189
|
-
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
190
|
-
}
|
|
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-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: "sicon-keyboard_arrow_left arrow" })), 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: "sicon-keyboard_arrow_left arrow" })), index.h("slot", { name: "after-login-type" }))
|
|
194
|
-
: '', this.isMobileAllowed ?
|
|
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', width: "wide", 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', width: "wide", 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', width: "wide", onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), index.h("slot", { name: "after-registration" })))));
|
|
199
|
-
}
|
|
200
|
-
get host() { return index.getElement(this); }
|
|
201
|
-
};
|
|
202
|
-
SallaLoginModal.style = sallaLoginModalCss;
|
|
203
|
-
|
|
204
|
-
exports.SallaLoginModal = SallaLoginModal;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const index = require('./index-0b5b5867.js');
|
|
4
|
-
const Helper = require('./Helper-98cc9f18.js');
|
|
5
|
-
|
|
6
|
-
const sallaSearchCss = "#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image[src=null]{opacity:0}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";
|
|
7
|
-
|
|
8
|
-
const SallaSearch = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
index.registerInstance(this, hostRef);
|
|
11
|
-
var _a;
|
|
12
|
-
this.inputValue = '';
|
|
13
|
-
this.inline = false;
|
|
14
|
-
this.oval = false;
|
|
15
|
-
this.height = 60;
|
|
16
|
-
Helper.Helper.setHost(this.host);
|
|
17
|
-
this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
|
|
18
|
-
salla.event.on('search::show', () => this.modal.show());
|
|
19
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
20
|
-
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
21
|
-
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
onModalOpen() {
|
|
25
|
-
this.modal.querySelector('.s-search-input').focus();
|
|
26
|
-
}
|
|
27
|
-
onModalClose() {
|
|
28
|
-
this.modal.querySelector('.s-search-input').value = '';
|
|
29
|
-
this.results = undefined;
|
|
30
|
-
this.afterSearching();
|
|
31
|
-
this.container.classList.remove('s-search-no-results');
|
|
32
|
-
}
|
|
33
|
-
getDefaultProductSlot() {
|
|
34
|
-
return '<div class="s-search-product-image-container">' +
|
|
35
|
-
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
36
|
-
'</div>' +
|
|
37
|
-
'<div class="s-search-product-details">' +
|
|
38
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
39
|
-
'</div>';
|
|
40
|
-
}
|
|
41
|
-
//todo:: reset data when closing
|
|
42
|
-
search(e) {
|
|
43
|
-
this.inputValue = e.target.value;
|
|
44
|
-
Helper.Helper.hideElement(this.noResults);
|
|
45
|
-
if (e.target.value.length === 0) {
|
|
46
|
-
this.results = undefined;
|
|
47
|
-
this.afterSearching();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (e.target.value.length <= 2) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
//run loading spinner or stop it
|
|
54
|
-
Helper.Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
|
|
55
|
-
salla.search.api.search(e.target.value)
|
|
56
|
-
.then(response => this.results = response)
|
|
57
|
-
.catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
|
|
58
|
-
.finally(() => this.afterSearching(/*isEmpty*/ false));
|
|
59
|
-
}
|
|
60
|
-
afterSearching(isEmpty = true) {
|
|
61
|
-
var _a;
|
|
62
|
-
this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
|
|
63
|
-
Helper.Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
|
|
64
|
-
.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
|
|
65
|
-
salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
|
|
66
|
-
this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
|
|
67
|
-
}
|
|
68
|
-
render() {
|
|
69
|
-
var _a;
|
|
70
|
-
const searchContent = index.h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), index.h("span", { class: "s-search-icon-wrap" }, index.h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
71
|
-
_a.data.map(item => index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
72
|
-
.replace(/\{name\}/g, item.name)
|
|
73
|
-
.replace(/\{price\}/g, item.price) //todo:: get discounted price too
|
|
74
|
-
.replace(/\{image\}/g, item.image_url) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
75
|
-
return (this.inline ?
|
|
76
|
-
index.h("div", { id: "s-search-modal" }, searchContent)
|
|
77
|
-
:
|
|
78
|
-
index.h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, searchContent));
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Run it one time after load
|
|
82
|
-
*/
|
|
83
|
-
componentDidLoad() {
|
|
84
|
-
this.afterSearching();
|
|
85
|
-
}
|
|
86
|
-
get host() { return index.getElement(this); }
|
|
87
|
-
};
|
|
88
|
-
SallaSearch.style = sallaSearchCss;
|
|
89
|
-
|
|
90
|
-
exports.SallaSearch = SallaSearch;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-8b97d225.js';
|
|
2
|
-
import { H as Helper } from './Helper-7162a06c.js';
|
|
3
|
-
|
|
4
|
-
const sallaLoginModalCss = "[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";
|
|
5
|
-
|
|
6
|
-
const SallaLoginModal = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
/**
|
|
10
|
-
* Does the merchant allow to login using email
|
|
11
|
-
*/
|
|
12
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', true);
|
|
13
|
-
/**
|
|
14
|
-
* Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`
|
|
15
|
-
*/
|
|
16
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', true);
|
|
17
|
-
/**
|
|
18
|
-
* Does the merchant require registration with email & mobile
|
|
19
|
-
*/
|
|
20
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
21
|
-
this.regType = 'phone';
|
|
22
|
-
//TODO:: any salla-button, text should updated by this.btn?.setText(newText)
|
|
23
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
24
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
25
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
26
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
27
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
28
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
29
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
30
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
31
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
32
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
33
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
34
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
35
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
36
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
37
|
-
this.typing = (e, submitMethod) => {
|
|
38
|
-
const error = e.target.nextElementSibling;
|
|
39
|
-
e.target.classList.remove('s-has-error');
|
|
40
|
-
(error === null || error === void 0 ? void 0 : error.classList.contains('s-login-modal-error-message')) && (error.innerText = '');
|
|
41
|
-
e.key == 'Enter' && submitMethod();
|
|
42
|
-
};
|
|
43
|
-
this.loginBySMS = async () => {
|
|
44
|
-
const { mobile, countryCode } = await this.loginTelInput.getValues();
|
|
45
|
-
const isPhoneValid = await this.loginTelInput.isValid();
|
|
46
|
-
if (!isPhoneValid)
|
|
47
|
-
return;
|
|
48
|
-
this.smsBtn.load()
|
|
49
|
-
.then(() => this.smsBtn.disable())
|
|
50
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
51
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
52
|
-
.then(() => this.showTab(this.verifyTab))
|
|
53
|
-
.then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
54
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
55
|
-
};
|
|
56
|
-
this.loginByEmail = () => {
|
|
57
|
-
if (!Helper.isValidEmail(this.loginEmail.value)) {
|
|
58
|
-
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.emailBtn.load()
|
|
62
|
-
.then(() => this.emailBtn.disable())
|
|
63
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
64
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
65
|
-
.then(() => this.showTab(this.verifyTab))
|
|
66
|
-
.then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
67
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
68
|
-
};
|
|
69
|
-
this.newUser = async () => {
|
|
70
|
-
var _a;
|
|
71
|
-
const { mobile: regPhone, countryCode, countryKey } = this.regType == "email" ? await this.regTelInput.getValues() : await this.loginTelInput.getValues(), emailValue = this.regEmail.value || ((_a = this.loginEmail) === null || _a === void 0 ? void 0 : _a.value);
|
|
72
|
-
await this.newUserValidation();
|
|
73
|
-
await this.regBtn.load();
|
|
74
|
-
await this.regBtn.disable();
|
|
75
|
-
let data = {
|
|
76
|
-
first_name: this.firstName.value,
|
|
77
|
-
last_name: this.lastName.value,
|
|
78
|
-
phone: regPhone || this.loginTelInput.mobile,
|
|
79
|
-
country_code: countryCode,
|
|
80
|
-
country_key: countryKey,
|
|
81
|
-
verified_by: this.regType,
|
|
82
|
-
};
|
|
83
|
-
emailValue && (data = Object.assign(Object.assign({}, data), { email: emailValue }));
|
|
84
|
-
this.verifyTab.getCode()
|
|
85
|
-
.then(code => salla.auth.api.register(Object.assign(Object.assign({}, data), { code })))
|
|
86
|
-
.then(() => window.location.reload())
|
|
87
|
-
.catch(() => this.regBtn.stop() && this.regBtn.enable());
|
|
88
|
-
};
|
|
89
|
-
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
90
|
-
this.host.removeAttribute('title');
|
|
91
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
92
|
-
var _a, _b, _c, _d;
|
|
93
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
94
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
95
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
96
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
97
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
98
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
99
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
100
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
101
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
102
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
103
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
104
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
105
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
106
|
-
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
107
|
-
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
108
|
-
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
109
|
-
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
110
|
-
});
|
|
111
|
-
salla.auth.event.onVerificationFailed(() => {
|
|
112
|
-
//
|
|
113
|
-
});
|
|
114
|
-
salla.event.on('login::show', () => this.show());
|
|
115
|
-
salla.event.on('twilight::initiated', () => {
|
|
116
|
-
this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', !!this.isEmailAllowed);
|
|
117
|
-
this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', !!this.isMobileAllowed);
|
|
118
|
-
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', !!this.isEmailRequired);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
|
|
123
|
-
*/
|
|
124
|
-
onVerified(event) {
|
|
125
|
-
if (!event.detail.case) {
|
|
126
|
-
console.log('verified but without case!');
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (event.detail.case === "new_customer") {
|
|
130
|
-
return this.showTab(this.registrationTab);
|
|
131
|
-
}
|
|
132
|
-
//TODO::It looks that this is a workaround for something, so needs to be enhanced🤔
|
|
133
|
-
if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (event.redirect_url) {
|
|
137
|
-
return window.location.href = event.redirect_url;
|
|
138
|
-
}
|
|
139
|
-
window.location.reload();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Show login component
|
|
143
|
-
*/
|
|
144
|
-
async show() {
|
|
145
|
-
if (this.isEmailAllowed && this.isMobileAllowed) {
|
|
146
|
-
this.showTab(this.homeTab);
|
|
147
|
-
}
|
|
148
|
-
else if (this.isEmailAllowed) {
|
|
149
|
-
this.showTab(this.emailTab);
|
|
150
|
-
}
|
|
151
|
-
else if (this.isMobileAllowed) {
|
|
152
|
-
this.showTab(this.mobileTab);
|
|
153
|
-
}
|
|
154
|
-
return this.modal.show();
|
|
155
|
-
}
|
|
156
|
-
showTab(tab, evt) {
|
|
157
|
-
var _a, _b;
|
|
158
|
-
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
159
|
-
let tabs = [this.homeTab, this.mobileTab, this.emailTab, this.verifyTab, this.registrationTab];
|
|
160
|
-
tabs.map(el => Helper.toggleElementClassIf(el, 'visible', 's-hidden', () => el == tab));
|
|
161
|
-
setTimeout(() => tabs.map(el => Helper.toggleElementClassIf(el, 's-login-modal-active', 's-login-modal-unactive', () => el == tab)), 200);
|
|
162
|
-
setTimeout(() => this.host.querySelector('.s-login-modal-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'));
|
|
163
|
-
if ([this.mobileTab, this.emailTab].includes(tab)) {
|
|
164
|
-
this.regType = tab === this.mobileTab ? 'phone' : 'email';
|
|
165
|
-
}
|
|
166
|
-
let isRegistrationTab = tab == this.registrationTab;
|
|
167
|
-
isRegistrationTab && ((_a = this.firstName) === null || _a === void 0 ? void 0 : _a.focus());
|
|
168
|
-
(_b = this.modal) === null || _b === void 0 ? void 0 : _b.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
|
|
169
|
-
if (!isRegistrationTab) {
|
|
170
|
-
Helper.toggleElementClassIf(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
|
|
171
|
-
.toggleElementClassIf(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
|
|
172
|
-
}
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
async newUserValidation() {
|
|
176
|
-
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
177
|
-
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
178
|
-
return;
|
|
179
|
-
!isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);
|
|
180
|
-
!isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);
|
|
181
|
-
!isLastNameValid && this.validateField(this.lastName, this.lastNameErrorMsg);
|
|
182
|
-
throw ('Please insert required fields');
|
|
183
|
-
}
|
|
184
|
-
// eslint-disable-next-line @stencil/own-methods-must-be-private
|
|
185
|
-
validateField(field, errorMsg) {
|
|
186
|
-
field.classList.add('s-has-error');
|
|
187
|
-
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
188
|
-
}
|
|
189
|
-
render() {
|
|
190
|
-
return (h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-modal-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
191
|
-
h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), h("slot", { name: "before-login-type" }), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("slot", { name: "after-login-type" }))
|
|
192
|
-
: '', this.isMobileAllowed ?
|
|
193
|
-
h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, h("slot", { name: "before-login-mobile" }), h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
194
|
-
h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, this.byEmailText) : '', h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
195
|
-
h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, h("slot", { name: "before-login-email" }), h("label", { class: "s-login-modal-label" }, this.emailLabel), 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" }), h("span", { class: "s-login-modal-error-message" }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
196
|
-
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText) : '', h("slot", { name: "after-login-email" })) : '', h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), h("div", { ref: tab => this.registrationTab = tab }, h("slot", { name: "before-registration" }), h("label", { class: "s-login-modal-label" }, this.firstNameLabel), 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') }), h("span", { class: "s-login-modal-error-message" }), h("label", { class: "s-login-modal-label" }, this.lastNameLabel), 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') }), h("span", { class: "s-login-modal-error-message" }), h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.emailLabel), 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" }), h("span", { class: "s-login-modal-error-message" })), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), h("slot", { name: "after-registration" })))));
|
|
197
|
-
}
|
|
198
|
-
get host() { return getElement(this); }
|
|
199
|
-
};
|
|
200
|
-
SallaLoginModal.style = sallaLoginModalCss;
|
|
201
|
-
|
|
202
|
-
export { SallaLoginModal as S };
|