@salla.sa/twilight-components 1.0.22 → 1.0.24
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 +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-branches.cjs.entry.js +5 -2
- package/dist/cjs/salla-button_5.cjs.entry.js +79 -29
- package/dist/cjs/salla-localization.cjs.entry.js +6 -4
- package/dist/cjs/salla-login-c74587ef.js +154 -0
- package/dist/cjs/salla-offer.cjs.entry.js +2 -2
- package/dist/cjs/salla-rating.cjs.entry.js +12 -9
- package/dist/cjs/{salla-search-45173394.js → salla-search-eb0112c0.js} +16 -23
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-branches/salla-branches.js +7 -3
- package/dist/collection/components/salla-button/salla-button.js +2 -0
- package/dist/collection/components/salla-localization/salla-localization.js +11 -60
- package/dist/collection/components/salla-login/salla-login.css +15 -2
- package/dist/collection/components/salla-login/salla-login.js +132 -252
- package/dist/collection/components/salla-modal/salla-modal.css +0 -0
- package/dist/collection/components/salla-modal/salla-modal.js +28 -20
- package/dist/collection/components/salla-offer/salla-offer.js +2 -2
- package/dist/collection/components/salla-rating/salla-rating.js +12 -9
- package/dist/collection/components/salla-search/salla-search.css +1 -0
- package/dist/collection/components/salla-search/salla-search.js +19 -62
- package/dist/collection/components/salla-search/search-response.js +1 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +86 -6
- package/dist/collection/components/salla-verify/salla-verify.js +18 -13
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +5 -2
- package/dist/esm/salla-button_5.entry.js +79 -29
- package/dist/esm/salla-localization.entry.js +6 -4
- package/dist/esm/salla-login-d08f0d7e.js +152 -0
- package/dist/esm/salla-offer.entry.js +2 -2
- package/dist/esm/salla-rating.entry.js +12 -9
- package/dist/esm/{salla-search-5e691ebb.js → salla-search-57bd45eb.js} +16 -23
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-1918a33c.js +1 -0
- package/dist/twilight-components/p-22f06d26.entry.js +1 -0
- package/dist/twilight-components/p-47f3d098.entry.js +1 -0
- package/dist/twilight-components/p-5bf5ce53.entry.js +1 -0
- package/dist/twilight-components/p-aa9880cb.entry.js +1 -0
- package/dist/twilight-components/p-b195e28c.entry.js +1 -0
- package/dist/twilight-components/p-e6a3a0dc.entry.js +1 -0
- package/dist/twilight-components/p-e7edc889.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-branches/salla-branches.d.ts +1 -0
- package/dist/types/components/salla-login/salla-login.d.ts +21 -12
- package/dist/types/components/salla-search/salla-search.d.ts +2 -7
- package/dist/types/components/salla-search/search-response.d.ts +18 -0
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +18 -6
- package/dist/types/components/salla-verify/salla-verify.d.ts +2 -2
- package/dist/types/components.d.ts +5 -43
- package/package.json +1 -1
- package/dist/cjs/salla-login-c438bb35.js +0 -128
- package/dist/esm/salla-login-dd957742.js +0 -126
- package/dist/twilight-components/p-1a6d8171.entry.js +0 -1
- package/dist/twilight-components/p-1deb8111.entry.js +0 -1
- package/dist/twilight-components/p-3a4d963e.js +0 -1
- package/dist/twilight-components/p-5b2eb87d.entry.js +0 -1
- package/dist/twilight-components/p-7fbdf746.entry.js +0 -1
- package/dist/twilight-components/p-81a61f4e.js +0 -1
- package/dist/twilight-components/p-ce991664.entry.js +0 -1
- package/dist/twilight-components/p-da73fc9b.entry.js +0 -1
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { Component, h,
|
|
1
|
+
import { Component, h, State, Element, Listen } from '@stencil/core';
|
|
2
2
|
import Helper from "../../Helpers/Helper";
|
|
3
3
|
export class SallaSearch {
|
|
4
4
|
constructor() {
|
|
5
5
|
var _a;
|
|
6
|
-
this.results = [];
|
|
7
|
-
/**
|
|
8
|
-
* Override search placeholder.
|
|
9
|
-
*/
|
|
10
|
-
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
11
|
-
/**
|
|
12
|
-
* Override no results error message.
|
|
13
|
-
*/
|
|
14
|
-
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
15
6
|
Helper.setHost(this.host);
|
|
16
7
|
this.productSlot = ((_a = Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
|
|
8
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
9
|
+
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
10
|
+
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
11
|
+
});
|
|
17
12
|
}
|
|
18
13
|
onModalOpen() {
|
|
19
14
|
this.modal.querySelector('.s-search-input').focus();
|
|
20
15
|
}
|
|
21
16
|
onModalClose() {
|
|
22
17
|
this.modal.querySelector('.s-search-input').value = '';
|
|
23
|
-
this.results =
|
|
18
|
+
this.results = undefined;
|
|
24
19
|
this.afterSearching();
|
|
25
20
|
}
|
|
26
21
|
getDefaultProductSlot() {
|
|
@@ -35,7 +30,7 @@ export class SallaSearch {
|
|
|
35
30
|
search(e) {
|
|
36
31
|
Helper.hideElement(this.noResults);
|
|
37
32
|
if (e.target.value.length === 0) {
|
|
38
|
-
this.results =
|
|
33
|
+
this.results = undefined;
|
|
39
34
|
this.afterSearching();
|
|
40
35
|
return;
|
|
41
36
|
}
|
|
@@ -45,13 +40,14 @@ export class SallaSearch {
|
|
|
45
40
|
//run loading spinner or stop it
|
|
46
41
|
Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
|
|
47
42
|
salla.search.api.search(e.target.value)
|
|
48
|
-
.then(response => this.results = response
|
|
49
|
-
.catch(err => err !== 'Query Same As Previous!' ? this.results =
|
|
43
|
+
.then(response => this.results = response)
|
|
44
|
+
.catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
|
|
50
45
|
.finally(() => this.afterSearching(/*isEmpty*/ false));
|
|
51
46
|
}
|
|
52
47
|
afterSearching(isEmpty = true) {
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
var _a;
|
|
49
|
+
this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
|
|
50
|
+
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; })
|
|
55
51
|
.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
|
|
56
52
|
salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
|
|
57
53
|
}
|
|
@@ -63,13 +59,10 @@ export class SallaSearch {
|
|
|
63
59
|
h("span", { class: "s-search-icon" },
|
|
64
60
|
h("i", { class: "sicon-search", ref: el => this.searchIcon = el })),
|
|
65
61
|
h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
66
|
-
_a.map(item => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
.replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
|
|
71
|
-
.replace(/\{image\}/g, item.thumb) });
|
|
72
|
-
}),
|
|
62
|
+
_a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
63
|
+
.replace(/\{name\}/g, item.name)
|
|
64
|
+
.replace(/\{price\}/g, item.price) //todo:: get discounted price too
|
|
65
|
+
.replace(/\{image\}/g, item.image_url) })),
|
|
73
66
|
h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
@@ -85,46 +78,10 @@ export class SallaSearch {
|
|
|
85
78
|
static get styleUrls() { return {
|
|
86
79
|
"$": ["salla-search.css"]
|
|
87
80
|
}; }
|
|
88
|
-
static get properties() { return {
|
|
89
|
-
"placeholder": {
|
|
90
|
-
"type": "string",
|
|
91
|
-
"mutable": false,
|
|
92
|
-
"complexType": {
|
|
93
|
-
"original": "string",
|
|
94
|
-
"resolved": "string",
|
|
95
|
-
"references": {}
|
|
96
|
-
},
|
|
97
|
-
"required": false,
|
|
98
|
-
"optional": false,
|
|
99
|
-
"docs": {
|
|
100
|
-
"tags": [],
|
|
101
|
-
"text": "Override search placeholder."
|
|
102
|
-
},
|
|
103
|
-
"attribute": "placeholder",
|
|
104
|
-
"reflect": false,
|
|
105
|
-
"defaultValue": "salla.lang.get('blocks.header.search_placeholder')"
|
|
106
|
-
},
|
|
107
|
-
"noResultsText": {
|
|
108
|
-
"type": "string",
|
|
109
|
-
"mutable": false,
|
|
110
|
-
"complexType": {
|
|
111
|
-
"original": "string",
|
|
112
|
-
"resolved": "string",
|
|
113
|
-
"references": {}
|
|
114
|
-
},
|
|
115
|
-
"required": false,
|
|
116
|
-
"optional": false,
|
|
117
|
-
"docs": {
|
|
118
|
-
"tags": [],
|
|
119
|
-
"text": "Override no results error message."
|
|
120
|
-
},
|
|
121
|
-
"attribute": "no-results-text",
|
|
122
|
-
"reflect": false,
|
|
123
|
-
"defaultValue": "salla.lang.get('common.elements.no_options')"
|
|
124
|
-
}
|
|
125
|
-
}; }
|
|
126
81
|
static get states() { return {
|
|
127
|
-
"results": {}
|
|
82
|
+
"results": {},
|
|
83
|
+
"placeholder": {},
|
|
84
|
+
"noResultsText": {}
|
|
128
85
|
}; }
|
|
129
86
|
static get elementRef() { return "host"; }
|
|
130
87
|
static get listeners() { return [{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, Component, Host, h, Prop, Method } from '@stencil/core';
|
|
1
|
+
import { Element, Component, Host, h, Prop, Method, Event, State } from '@stencil/core';
|
|
2
2
|
import TelInput from "intl-tel-input";
|
|
3
3
|
import Helper from "../../Helpers/Helper";
|
|
4
4
|
export class SallaTelInput {
|
|
@@ -6,6 +6,14 @@ export class SallaTelInput {
|
|
|
6
6
|
this.countryCode = "SA";
|
|
7
7
|
this.countryKey = "+966";
|
|
8
8
|
Helper.setHost(this.host);
|
|
9
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
10
|
+
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
11
|
+
this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
12
|
+
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
13
|
+
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
14
|
+
this.tooLong = salla.lang.get('common.errors.too_long', { attribute: this.mobileLabel });
|
|
15
|
+
this.mobileRequired = salla.lang.get('common.errors.field_required', { attribute: this.mobileLabel });
|
|
16
|
+
});
|
|
9
17
|
}
|
|
10
18
|
async getValues() {
|
|
11
19
|
this.phone = this.phoneInput.value;
|
|
@@ -13,11 +21,25 @@ export class SallaTelInput {
|
|
|
13
21
|
this.countryKey = this.countryKeyInput.value;
|
|
14
22
|
return { phone: this.phoneInput.value, countryCode: this.countryCodeInput.value, countryKey: this.countryKeyInput.value };
|
|
15
23
|
}
|
|
24
|
+
async isValid() {
|
|
25
|
+
const errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
26
|
+
this.reset();
|
|
27
|
+
if (this.iti.isValidNumber())
|
|
28
|
+
return true;
|
|
29
|
+
if (!this.phoneInput.value.trim()) {
|
|
30
|
+
this.phoneInput.classList.add("s-has-error");
|
|
31
|
+
this.errorMsg.innerText = this.mobileRequired || '';
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.phoneInput.classList.add("s-has-error");
|
|
35
|
+
let errorCode = this.iti.getValidationError();
|
|
36
|
+
this.errorMsg.innerText = errorMap[errorCode] || '';
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
16
39
|
initTelInput() {
|
|
17
|
-
|
|
18
|
-
document.querySelectorAll('.tel-input').forEach((intlInput) => {
|
|
40
|
+
this.host.querySelectorAll('.tel-input').forEach((intlInput) => {
|
|
19
41
|
salla.helpers.digitsOnly(intlInput);
|
|
20
|
-
|
|
42
|
+
this.iti = TelInput(intlInput, {
|
|
21
43
|
initialCountry: intlInput.dataset.code || 'sa',
|
|
22
44
|
preferredCountries: ['sa', 'ae', 'kw', 'bh', 'qa', 'iq', 'om', 'ye', 'eg', 'jo', 'sy', 'ps', 'sd', 'lb', 'dz', 'tn', 'ma', 'ly'],
|
|
23
45
|
formatOnDisplay: false,
|
|
@@ -26,21 +48,39 @@ export class SallaTelInput {
|
|
|
26
48
|
utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js',
|
|
27
49
|
});
|
|
28
50
|
intlInput.addEventListener("countrychange", () => {
|
|
29
|
-
let data = iti.getSelectedCountryData();
|
|
51
|
+
let data = this.iti.getSelectedCountryData();
|
|
30
52
|
this.host.querySelectorAll('.country_code').forEach((input) => input.value = data.iso2.toUpperCase());
|
|
31
53
|
this.host.querySelectorAll('.country_key').forEach((input) => {
|
|
32
54
|
input.value = ('+' + data.dialCode).replace('++', '+');
|
|
33
55
|
});
|
|
34
56
|
});
|
|
57
|
+
// on blur: validate
|
|
58
|
+
intlInput.addEventListener('blur', () => {
|
|
59
|
+
this.isValid();
|
|
60
|
+
});
|
|
61
|
+
// on keyup / change flag: reset
|
|
62
|
+
// this.phoneInput.addEventListener('change', () => this.reset());
|
|
63
|
+
salla.document.event.onKeyup('.tel-input', e => {
|
|
64
|
+
if (e.key == 'Enter')
|
|
65
|
+
return;
|
|
66
|
+
salla.helpers.digitsOnly(e.target);
|
|
67
|
+
this.reset();
|
|
68
|
+
});
|
|
35
69
|
});
|
|
36
70
|
}
|
|
71
|
+
reset() {
|
|
72
|
+
this.phoneInput.classList.remove("s-has-error");
|
|
73
|
+
this.errorMsg.innerHTML = "";
|
|
74
|
+
}
|
|
75
|
+
;
|
|
37
76
|
render() {
|
|
38
77
|
return (h(Host, null,
|
|
39
78
|
h("input", { type: "tel", name: "mobile", "data-code": this.countryCode, value: this.phone, ref: el => this.phoneInput = el, class: "s-tel-input-control tel-input s-ltr" }),
|
|
79
|
+
h("span", { class: "s-tel-input-error-msg", ref: el => this.errorMsg = el }),
|
|
40
80
|
h("input", { type: "hidden", name: "country_code", value: this.countryCode, ref: el => this.countryCodeInput = el, class: "country_code" }),
|
|
41
81
|
h("input", { type: "hidden", name: "country_key", value: this.countryKey, ref: el => this.countryKeyInput = el, class: "country_key" })));
|
|
42
82
|
}
|
|
43
|
-
|
|
83
|
+
componentDidLoad() {
|
|
44
84
|
this.initTelInput();
|
|
45
85
|
}
|
|
46
86
|
static get is() { return "salla-tel-input"; }
|
|
@@ -99,6 +139,30 @@ export class SallaTelInput {
|
|
|
99
139
|
"defaultValue": "\"+966\""
|
|
100
140
|
}
|
|
101
141
|
}; }
|
|
142
|
+
static get states() { return {
|
|
143
|
+
"invalidNumber": {},
|
|
144
|
+
"invalidCountryCode": {},
|
|
145
|
+
"tooShort": {},
|
|
146
|
+
"tooLong": {},
|
|
147
|
+
"mobileLabel": {},
|
|
148
|
+
"mobileRequired": {}
|
|
149
|
+
}; }
|
|
150
|
+
static get events() { return [{
|
|
151
|
+
"method": "enterClicked",
|
|
152
|
+
"name": "enterClicked",
|
|
153
|
+
"bubbles": true,
|
|
154
|
+
"cancelable": true,
|
|
155
|
+
"composed": true,
|
|
156
|
+
"docs": {
|
|
157
|
+
"tags": [],
|
|
158
|
+
"text": ""
|
|
159
|
+
},
|
|
160
|
+
"complexType": {
|
|
161
|
+
"original": "any",
|
|
162
|
+
"resolved": "any",
|
|
163
|
+
"references": {}
|
|
164
|
+
}
|
|
165
|
+
}]; }
|
|
102
166
|
static get methods() { return {
|
|
103
167
|
"getValues": {
|
|
104
168
|
"complexType": {
|
|
@@ -115,6 +179,22 @@ export class SallaTelInput {
|
|
|
115
179
|
"text": "",
|
|
116
180
|
"tags": []
|
|
117
181
|
}
|
|
182
|
+
},
|
|
183
|
+
"isValid": {
|
|
184
|
+
"complexType": {
|
|
185
|
+
"signature": "() => Promise<boolean>",
|
|
186
|
+
"parameters": [],
|
|
187
|
+
"references": {
|
|
188
|
+
"Promise": {
|
|
189
|
+
"location": "global"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"return": "Promise<boolean>"
|
|
193
|
+
},
|
|
194
|
+
"docs": {
|
|
195
|
+
"text": "",
|
|
196
|
+
"tags": []
|
|
197
|
+
}
|
|
118
198
|
}
|
|
119
199
|
}; }
|
|
120
200
|
static get elementRef() { return "host"; }
|
|
@@ -2,7 +2,6 @@ import { Component, Element, Event, h, Method, Prop } from '@stencil/core';
|
|
|
2
2
|
import Helper from "../../Helpers/Helper";
|
|
3
3
|
export class SallaVerify {
|
|
4
4
|
constructor() {
|
|
5
|
-
this.url = 'profile/verify-mobile';
|
|
6
5
|
this.by = 'sms';
|
|
7
6
|
this.autoReload = true;
|
|
8
7
|
Helper.setHost(this.host);
|
|
@@ -10,7 +9,10 @@ export class SallaVerify {
|
|
|
10
9
|
this.modal = { show: () => '', hide: () => '' };
|
|
11
10
|
}
|
|
12
11
|
else {
|
|
13
|
-
salla.event.on('profile::verify.mobile', data =>
|
|
12
|
+
salla.event.on('profile::verify.mobile', data => {
|
|
13
|
+
this.url = 'profile/verify-mobile';
|
|
14
|
+
this.show(data);
|
|
15
|
+
});
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
async getCode() {
|
|
@@ -87,9 +89,12 @@ export class SallaVerify {
|
|
|
87
89
|
.catch(() => this.resendTimer());
|
|
88
90
|
}
|
|
89
91
|
submit() {
|
|
92
|
+
let data = Object.assign({ code: this.code.value }, this.data);
|
|
90
93
|
return this.btn.load()
|
|
91
94
|
.then(() => this.btn.disable())
|
|
92
|
-
.then(() =>
|
|
95
|
+
.then(() => this.url
|
|
96
|
+
? salla.api.auth.request(this.url, data)
|
|
97
|
+
: salla.api.auth.verify(this.by == 'sms' ? 'mobile' : this.by, data))
|
|
93
98
|
.then(response => this.verified.emit(response))
|
|
94
99
|
.then(() => this.btn.stop() && this.btn.disable())
|
|
95
100
|
.then(() => this.modal.hide())
|
|
@@ -112,8 +117,9 @@ export class SallaVerify {
|
|
|
112
117
|
salla.lang.get('blocks.header.resend_after'),
|
|
113
118
|
h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
|
|
114
119
|
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')),
|
|
115
|
-
this.
|
|
116
|
-
h("a", { href: "#", class: "s-verify-
|
|
120
|
+
this.isShowBack ?
|
|
121
|
+
h("a", { href: "#", class: "s-verify-back", onClick: () => this.backClicked.emit() },
|
|
122
|
+
h("i", { class: "sicon-arrow-right" }))
|
|
117
123
|
: '')
|
|
118
124
|
];
|
|
119
125
|
}
|
|
@@ -145,14 +151,13 @@ export class SallaVerify {
|
|
|
145
151
|
"references": {}
|
|
146
152
|
},
|
|
147
153
|
"required": false,
|
|
148
|
-
"optional":
|
|
154
|
+
"optional": true,
|
|
149
155
|
"docs": {
|
|
150
156
|
"tags": [],
|
|
151
157
|
"text": ""
|
|
152
158
|
},
|
|
153
159
|
"attribute": "url",
|
|
154
|
-
"reflect":
|
|
155
|
-
"defaultValue": "'profile/verify-mobile'"
|
|
160
|
+
"reflect": true
|
|
156
161
|
},
|
|
157
162
|
"by": {
|
|
158
163
|
"type": "string",
|
|
@@ -172,12 +177,12 @@ export class SallaVerify {
|
|
|
172
177
|
"reflect": false,
|
|
173
178
|
"defaultValue": "'sms'"
|
|
174
179
|
},
|
|
175
|
-
"
|
|
176
|
-
"type": "
|
|
180
|
+
"isShowBack": {
|
|
181
|
+
"type": "boolean",
|
|
177
182
|
"mutable": false,
|
|
178
183
|
"complexType": {
|
|
179
|
-
"original": "
|
|
180
|
-
"resolved": "
|
|
184
|
+
"original": "boolean",
|
|
185
|
+
"resolved": "boolean",
|
|
181
186
|
"references": {}
|
|
182
187
|
},
|
|
183
188
|
"required": false,
|
|
@@ -186,7 +191,7 @@ export class SallaVerify {
|
|
|
186
191
|
"tags": [],
|
|
187
192
|
"text": ""
|
|
188
193
|
},
|
|
189
|
-
"attribute": "back
|
|
194
|
+
"attribute": "is-show-back",
|
|
190
195
|
"reflect": false
|
|
191
196
|
},
|
|
192
197
|
"autoReload": {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SallaLogin } from './salla-login-
|
|
2
|
-
export { S as SallaSearch } from './salla-search-
|
|
1
|
+
export { S as SallaLogin } from './salla-login-d08f0d7e.js';
|
|
2
|
+
export { S as SallaSearch } from './salla-search-57bd45eb.js';
|
|
3
3
|
import './index-a1bf769d.js';
|
|
4
4
|
import './Helper-d07ebbc7.js';
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"
|
|
13
|
+
return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"isEmailValid":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameRequired":[32],"lastNameRequired":[32],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"isShowBack":[4,"is-show-back"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"invalidNumber":[32],"invalidCountryCode":[32],"tooShort":[32],"tooLong":[32],"mobileLabel":[32],"mobileRequired":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"ok":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"ok":[32],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -38,6 +38,9 @@ const SallaBranches = class {
|
|
|
38
38
|
: 'التسوق من فرع آخر';
|
|
39
39
|
};
|
|
40
40
|
salla.event.on('branches::show', () => this.show());
|
|
41
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
42
|
+
this.ok = salla.lang.get('common.elements.ok');
|
|
43
|
+
});
|
|
41
44
|
}
|
|
42
45
|
async show() {
|
|
43
46
|
return this.modal.show();
|
|
@@ -59,7 +62,7 @@ const SallaBranches = class {
|
|
|
59
62
|
}, 300);
|
|
60
63
|
}
|
|
61
64
|
render() {
|
|
62
|
-
return (h("salla-modal", { icon: "sicon-store-alt", title: "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal,
|
|
65
|
+
return (h("salla-modal", { icon: "sicon-store-alt", title: "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "sub-title-first": true, "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, width: "sm", id: "s-branches-modal", class: "hidden" }, h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
|
|
63
66
|
h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => h("div", { class: "s-branches-input-wrap" }, h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
|
|
64
67
|
's-branches-input': true,
|
|
65
68
|
'opacity-50': !branch.open,
|
|
@@ -73,7 +76,7 @@ const SallaBranches = class {
|
|
|
73
76
|
h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
74
77
|
:
|
|
75
78
|
h("select", { class: "s-branches-select", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))), this.isChoiceable() ?
|
|
76
|
-
h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true },
|
|
79
|
+
h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", wide: true }, this.ok))
|
|
77
80
|
: ''));
|
|
78
81
|
}
|
|
79
82
|
componentDidRender() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-a1bf769d.js';
|
|
2
2
|
import { H as Helper } from './Helper-d07ebbc7.js';
|
|
3
|
-
export { S as salla_login } from './salla-login-
|
|
3
|
+
export { S as salla_login } from './salla-login-d08f0d7e.js';
|
|
4
4
|
|
|
5
5
|
const sallaButtonCss = ":host{display:block}";
|
|
6
6
|
|
|
@@ -37,6 +37,8 @@ const SallaButton = class {
|
|
|
37
37
|
}
|
|
38
38
|
async stop() {
|
|
39
39
|
this.host.removeAttribute('loading');
|
|
40
|
+
if (this.loaderPosition == 'center')
|
|
41
|
+
this.text.classList.remove('s-button-hide');
|
|
40
42
|
return this.host;
|
|
41
43
|
}
|
|
42
44
|
async disable() {
|
|
@@ -73,6 +75,8 @@ const SallaButton = class {
|
|
|
73
75
|
};
|
|
74
76
|
SallaButton.style = sallaButtonCss;
|
|
75
77
|
|
|
78
|
+
const sallaModalCss = "";
|
|
79
|
+
|
|
76
80
|
const SallaModal = class {
|
|
77
81
|
constructor(hostRef) {
|
|
78
82
|
registerInstance(this, hostRef);
|
|
@@ -152,26 +156,26 @@ const SallaModal = class {
|
|
|
152
156
|
return (
|
|
153
157
|
//todo:: use suitable class name instead of hidden
|
|
154
158
|
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 s-modal-align-' + this.position }, "\u200B"), h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width, slot: "body" }, this.isLoading
|
|
155
|
-
? h("
|
|
159
|
+
? h("div", { class: "s-modal-loader-wrap" }, h("span", { class: "s-modal-loader" }))
|
|
156
160
|
:
|
|
157
161
|
[h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
158
162
|
h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
|
|
159
|
-
: '', this.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
: '', this.title || this.subTitle ?
|
|
164
|
+
h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
|
|
165
|
+
? h("div", { class: {
|
|
166
|
+
's-modal-icon': true,
|
|
167
|
+
's-modal-bg-error': this.error,
|
|
168
|
+
's-modal-bg-success': this.success,
|
|
169
|
+
's-modal-bg-normal': !this.error && !this.success,
|
|
170
|
+
's-modal-bg-primary': this.primary
|
|
171
|
+
} }, h("i", { class: {
|
|
172
|
+
[this.icon]: true,
|
|
173
|
+
's-modal-text-error': this.error,
|
|
174
|
+
's-modal-text-success': this.success,
|
|
175
|
+
} }))
|
|
176
|
+
: this.imageIcon ?
|
|
177
|
+
h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
178
|
+
: '', 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 })))
|
|
175
179
|
: ''),
|
|
176
180
|
h("slot", null),
|
|
177
181
|
h("slot", { name: "footer" })
|
|
@@ -182,6 +186,7 @@ const SallaModal = class {
|
|
|
182
186
|
"visible": ["handleVisible"]
|
|
183
187
|
}; }
|
|
184
188
|
};
|
|
189
|
+
SallaModal.style = sallaModalCss;
|
|
185
190
|
|
|
186
191
|
function createCommonjsModule(fn, basedir, module) {
|
|
187
192
|
return module = {
|
|
@@ -1559,9 +1564,18 @@ var intlTelInput = intlTelInput$1;
|
|
|
1559
1564
|
const SallaTelInput = class {
|
|
1560
1565
|
constructor(hostRef) {
|
|
1561
1566
|
registerInstance(this, hostRef);
|
|
1567
|
+
this.enterClicked = createEvent(this, "enterClicked", 7);
|
|
1562
1568
|
this.countryCode = "SA";
|
|
1563
1569
|
this.countryKey = "+966";
|
|
1564
1570
|
Helper.setHost(this.host);
|
|
1571
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
1572
|
+
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
1573
|
+
this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
1574
|
+
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
1575
|
+
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
1576
|
+
this.tooLong = salla.lang.get('common.errors.too_long', { attribute: this.mobileLabel });
|
|
1577
|
+
this.mobileRequired = salla.lang.get('common.errors.field_required', { attribute: this.mobileLabel });
|
|
1578
|
+
});
|
|
1565
1579
|
}
|
|
1566
1580
|
async getValues() {
|
|
1567
1581
|
this.phone = this.phoneInput.value;
|
|
@@ -1569,11 +1583,25 @@ const SallaTelInput = class {
|
|
|
1569
1583
|
this.countryKey = this.countryKeyInput.value;
|
|
1570
1584
|
return { phone: this.phoneInput.value, countryCode: this.countryCodeInput.value, countryKey: this.countryKeyInput.value };
|
|
1571
1585
|
}
|
|
1586
|
+
async isValid() {
|
|
1587
|
+
const errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
1588
|
+
this.reset();
|
|
1589
|
+
if (this.iti.isValidNumber())
|
|
1590
|
+
return true;
|
|
1591
|
+
if (!this.phoneInput.value.trim()) {
|
|
1592
|
+
this.phoneInput.classList.add("s-has-error");
|
|
1593
|
+
this.errorMsg.innerText = this.mobileRequired || '';
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
this.phoneInput.classList.add("s-has-error");
|
|
1597
|
+
let errorCode = this.iti.getValidationError();
|
|
1598
|
+
this.errorMsg.innerText = errorMap[errorCode] || '';
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1572
1601
|
initTelInput() {
|
|
1573
|
-
|
|
1574
|
-
document.querySelectorAll('.tel-input').forEach((intlInput) => {
|
|
1602
|
+
this.host.querySelectorAll('.tel-input').forEach((intlInput) => {
|
|
1575
1603
|
salla.helpers.digitsOnly(intlInput);
|
|
1576
|
-
|
|
1604
|
+
this.iti = intlTelInput(intlInput, {
|
|
1577
1605
|
initialCountry: intlInput.dataset.code || 'sa',
|
|
1578
1606
|
preferredCountries: ['sa', 'ae', 'kw', 'bh', 'qa', 'iq', 'om', 'ye', 'eg', 'jo', 'sy', 'ps', 'sd', 'lb', 'dz', 'tn', 'ma', 'ly'],
|
|
1579
1607
|
formatOnDisplay: false,
|
|
@@ -1582,18 +1610,35 @@ const SallaTelInput = class {
|
|
|
1582
1610
|
utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js',
|
|
1583
1611
|
});
|
|
1584
1612
|
intlInput.addEventListener("countrychange", () => {
|
|
1585
|
-
let data = iti.getSelectedCountryData();
|
|
1613
|
+
let data = this.iti.getSelectedCountryData();
|
|
1586
1614
|
this.host.querySelectorAll('.country_code').forEach((input) => input.value = data.iso2.toUpperCase());
|
|
1587
1615
|
this.host.querySelectorAll('.country_key').forEach((input) => {
|
|
1588
1616
|
input.value = ('+' + data.dialCode).replace('++', '+');
|
|
1589
1617
|
});
|
|
1590
1618
|
});
|
|
1619
|
+
// on blur: validate
|
|
1620
|
+
intlInput.addEventListener('blur', () => {
|
|
1621
|
+
this.isValid();
|
|
1622
|
+
});
|
|
1623
|
+
// on keyup / change flag: reset
|
|
1624
|
+
// this.phoneInput.addEventListener('change', () => this.reset());
|
|
1625
|
+
salla.document.event.onKeyup('.tel-input', e => {
|
|
1626
|
+
if (e.key == 'Enter')
|
|
1627
|
+
return;
|
|
1628
|
+
salla.helpers.digitsOnly(e.target);
|
|
1629
|
+
this.reset();
|
|
1630
|
+
});
|
|
1591
1631
|
});
|
|
1592
1632
|
}
|
|
1633
|
+
reset() {
|
|
1634
|
+
this.phoneInput.classList.remove("s-has-error");
|
|
1635
|
+
this.errorMsg.innerHTML = "";
|
|
1636
|
+
}
|
|
1637
|
+
;
|
|
1593
1638
|
render() {
|
|
1594
|
-
return (h(Host, null, h("input", { type: "tel", name: "mobile", "data-code": this.countryCode, value: this.phone, ref: el => this.phoneInput = el, class: "s-tel-input-control tel-input s-ltr" }), h("input", { type: "hidden", name: "country_code", value: this.countryCode, ref: el => this.countryCodeInput = el, class: "country_code" }), h("input", { type: "hidden", name: "country_key", value: this.countryKey, ref: el => this.countryKeyInput = el, class: "country_key" })));
|
|
1639
|
+
return (h(Host, null, h("input", { type: "tel", name: "mobile", "data-code": this.countryCode, value: this.phone, ref: el => this.phoneInput = el, class: "s-tel-input-control tel-input s-ltr" }), h("span", { class: "s-tel-input-error-msg", ref: el => this.errorMsg = el }), h("input", { type: "hidden", name: "country_code", value: this.countryCode, ref: el => this.countryCodeInput = el, class: "country_code" }), h("input", { type: "hidden", name: "country_key", value: this.countryKey, ref: el => this.countryKeyInput = el, class: "country_key" })));
|
|
1595
1640
|
}
|
|
1596
|
-
|
|
1641
|
+
componentDidLoad() {
|
|
1597
1642
|
this.initTelInput();
|
|
1598
1643
|
}
|
|
1599
1644
|
get host() { return getElement(this); }
|
|
@@ -1604,7 +1649,6 @@ const SallaVerify = class {
|
|
|
1604
1649
|
registerInstance(this, hostRef);
|
|
1605
1650
|
this.verified = createEvent(this, "verified", 7);
|
|
1606
1651
|
this.backClicked = createEvent(this, "backClicked", 7);
|
|
1607
|
-
this.url = 'profile/verify-mobile';
|
|
1608
1652
|
this.by = 'sms';
|
|
1609
1653
|
this.autoReload = true;
|
|
1610
1654
|
Helper.setHost(this.host);
|
|
@@ -1612,7 +1656,10 @@ const SallaVerify = class {
|
|
|
1612
1656
|
this.modal = { show: () => '', hide: () => '' };
|
|
1613
1657
|
}
|
|
1614
1658
|
else {
|
|
1615
|
-
salla.event.on('profile::verify.mobile', data =>
|
|
1659
|
+
salla.event.on('profile::verify.mobile', data => {
|
|
1660
|
+
this.url = 'profile/verify-mobile';
|
|
1661
|
+
this.show(data);
|
|
1662
|
+
});
|
|
1616
1663
|
}
|
|
1617
1664
|
}
|
|
1618
1665
|
async getCode() {
|
|
@@ -1689,9 +1736,12 @@ const SallaVerify = class {
|
|
|
1689
1736
|
.catch(() => this.resendTimer());
|
|
1690
1737
|
}
|
|
1691
1738
|
submit() {
|
|
1739
|
+
let data = Object.assign({ code: this.code.value }, this.data);
|
|
1692
1740
|
return this.btn.load()
|
|
1693
1741
|
.then(() => this.btn.disable())
|
|
1694
|
-
.then(() =>
|
|
1742
|
+
.then(() => this.url
|
|
1743
|
+
? salla.api.auth.request(this.url, data)
|
|
1744
|
+
: salla.api.auth.verify(this.by == 'sms' ? 'mobile' : this.by, data))
|
|
1695
1745
|
.then(response => this.verified.emit(response))
|
|
1696
1746
|
.then(() => this.btn.stop() && this.btn.disable())
|
|
1697
1747
|
.then(() => this.modal.hide())
|
|
@@ -1708,8 +1758,8 @@ const SallaVerify = class {
|
|
|
1708
1758
|
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
1709
1759
|
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
1710
1760
|
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 }))),
|
|
1711
|
-
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.
|
|
1712
|
-
h("a", { href: "#", class: "s-verify-
|
|
1761
|
+
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.isShowBack ?
|
|
1762
|
+
h("a", { href: "#", class: "s-verify-back", onClick: () => this.backClicked.emit() }, h("i", { class: "sicon-arrow-right" }))
|
|
1713
1763
|
: '')
|
|
1714
1764
|
];
|
|
1715
1765
|
}
|