@salla.sa/twilight-components 1.0.15 → 1.0.17
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 -5
- package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
- package/dist/cjs/salla-localization.cjs.entry.js +27 -24
- package/dist/cjs/salla-login-342876b9.js +118 -0
- package/dist/cjs/salla-offer.cjs.entry.js +25 -0
- package/dist/cjs/salla-product-availability.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating.cjs.entry.js +155 -158
- package/dist/cjs/{salla-search-311c7053.js → salla-search-28da4616.js} +2 -2
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-branches/salla-branches.js +26 -28
- package/dist/collection/components/salla-button/salla-button.js +26 -23
- package/dist/collection/components/salla-localization/salla-localization.js +35 -29
- package/dist/collection/components/salla-login/salla-login.js +343 -26
- package/dist/collection/components/salla-modal/salla-modal.js +144 -45
- package/dist/collection/components/salla-offer/salla-offer.js +40 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-rating/salla-rating.css +4 -0
- package/dist/collection/components/salla-rating/salla-rating.js +206 -211
- package/dist/collection/components/salla-search/salla-search.js +3 -3
- package/dist/collection/components/salla-verify/salla-verify.js +160 -21
- package/dist/collection/plugins/tailwind-theme/generator.js +21 -12
- package/dist/collection/plugins/tailwind-theme/index.js +9 -9
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +5 -5
- package/dist/esm/salla-button_4.entry.js +292 -0
- package/dist/esm/salla-localization.entry.js +27 -24
- package/dist/esm/salla-login-32d25ffa.js +116 -0
- package/dist/esm/salla-offer.entry.js +21 -0
- package/dist/esm/salla-product-availability.entry.js +1 -1
- package/dist/esm/salla-rating.entry.js +155 -158
- package/dist/esm/{salla-search-add7bdb6.js → salla-search-f552c487.js} +2 -2
- 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-d584d0c7.entry.js → p-33990e49.entry.js} +1 -1
- package/dist/twilight-components/p-36683152.js +1 -0
- package/dist/twilight-components/p-3cfede65.entry.js +1 -0
- package/dist/twilight-components/p-648661c8.entry.js +1 -0
- package/dist/twilight-components/p-93c3ac79.js +1 -0
- package/dist/twilight-components/p-a923a51e.entry.js +1 -0
- package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
- package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
- package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-button/salla-button.d.ts +3 -2
- package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
- package/dist/types/components/salla-login/salla-login.d.ts +39 -0
- package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
- package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +23 -9
- package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
- package/dist/types/components.d.ts +94 -8
- package/package.json +2 -1
- package/dist/cjs/salla-button.cjs.entry.js +0 -77
- package/dist/cjs/salla-login-6a54572d.js +0 -14
- package/dist/cjs/salla-login_2.cjs.entry.js +0 -97
- package/dist/cjs/salla-verify.cjs.entry.js +0 -96
- package/dist/esm/salla-button.entry.js +0 -73
- package/dist/esm/salla-login-c9c9fa57.js +0 -12
- package/dist/esm/salla-login_2.entry.js +0 -92
- package/dist/esm/salla-verify.entry.js +0 -92
- package/dist/twilight-components/p-010b8dfd.entry.js +0 -1
- package/dist/twilight-components/p-0ceecf63.js +0 -1
- package/dist/twilight-components/p-32d29245.entry.js +0 -1
- package/dist/twilight-components/p-50e70ad4.entry.js +0 -1
- package/dist/twilight-components/p-68c9f122.entry.js +0 -1
- package/dist/twilight-components/p-8126278e.entry.js +0 -1
- package/dist/twilight-components/p-9d327a79.entry.js +0 -1
- package/dist/twilight-components/p-b05450bc.entry.js +0 -1
- package/dist/twilight-components/p-bd5da080.js +0 -1
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import { Component, Element, h } from '@stencil/core';
|
|
1
|
+
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
|
+
this.by = 'sms';
|
|
7
|
+
this.autoReload = true;
|
|
5
8
|
Helper.setHost(this.host);
|
|
6
|
-
|
|
9
|
+
if (this.withoutModal) {
|
|
10
|
+
this.modal = { show: () => '', hide: () => '' };
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async getCode() {
|
|
17
|
+
return this.code.value;
|
|
7
18
|
}
|
|
8
|
-
show(
|
|
9
|
-
this.
|
|
10
|
-
this.country_code = country_code;
|
|
19
|
+
async show(data) {
|
|
20
|
+
this.data = data;
|
|
11
21
|
this.resendTimer();
|
|
12
22
|
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
13
23
|
this.otpInputs[0].focus();
|
|
24
|
+
Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
14
25
|
Helper.onKeyUp('.s-verify-input', event => {
|
|
15
26
|
var _a, _b, _c, _d;
|
|
16
27
|
let key = event.keyCode || event.charCode;
|
|
17
|
-
salla.helpers.digitsOnly(event.target);
|
|
18
28
|
if (event.target.value) {
|
|
19
29
|
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
20
30
|
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
@@ -58,18 +68,6 @@ export class SallaVerify {
|
|
|
58
68
|
}
|
|
59
69
|
}, 1000);
|
|
60
70
|
}
|
|
61
|
-
submit() {
|
|
62
|
-
return this.btn.load()
|
|
63
|
-
.then(() => this.btn.disable())
|
|
64
|
-
.then(() => salla.document.api.request('profile/verify-mobile', {
|
|
65
|
-
mobile: this.mobile,
|
|
66
|
-
country_code: this.country_code,
|
|
67
|
-
code: this.code.value
|
|
68
|
-
})).then(() => this.btn.stop() && this.btn.disable())
|
|
69
|
-
.then(() => this.modal.hide())
|
|
70
|
-
.then(() => window.location.reload())
|
|
71
|
-
.catch(() => this.btn.stop() && this.btn.enable());
|
|
72
|
-
}
|
|
73
71
|
resendCode() {
|
|
74
72
|
return this.btn.stop()
|
|
75
73
|
.then(() => this.btn.disable())
|
|
@@ -77,12 +75,26 @@ export class SallaVerify {
|
|
|
77
75
|
this.otpInputs.forEach(input => input.value = '');
|
|
78
76
|
this.otpInputs[0].focus();
|
|
79
77
|
})
|
|
80
|
-
.then(() => salla.api.auth.resend({
|
|
78
|
+
.then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
|
|
81
79
|
.then(() => this.resendTimer())
|
|
82
80
|
.catch(() => this.resendTimer());
|
|
83
81
|
}
|
|
82
|
+
submit() {
|
|
83
|
+
return this.btn.load()
|
|
84
|
+
.then(() => this.btn.disable())
|
|
85
|
+
.then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
|
|
86
|
+
.then(response => this.verified.emit(response))
|
|
87
|
+
.then(() => this.btn.stop() && this.btn.disable())
|
|
88
|
+
.then(() => this.modal.hide())
|
|
89
|
+
.then(() => this.autoReload && window.location.reload())
|
|
90
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
91
|
+
}
|
|
84
92
|
render() {
|
|
85
|
-
return
|
|
93
|
+
return this.withoutModal ? this.myBody() :
|
|
94
|
+
h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
|
|
95
|
+
}
|
|
96
|
+
myBody() {
|
|
97
|
+
return [
|
|
86
98
|
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
87
99
|
h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')),
|
|
88
100
|
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
@@ -92,8 +104,135 @@ export class SallaVerify {
|
|
|
92
104
|
h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
|
|
93
105
|
salla.lang.get('blocks.header.resend_after'),
|
|
94
106
|
h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
|
|
95
|
-
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))
|
|
107
|
+
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))
|
|
108
|
+
];
|
|
96
109
|
}
|
|
97
110
|
static get is() { return "salla-verify"; }
|
|
111
|
+
static get properties() { return {
|
|
112
|
+
"withoutModal": {
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"mutable": false,
|
|
115
|
+
"complexType": {
|
|
116
|
+
"original": "boolean",
|
|
117
|
+
"resolved": "boolean",
|
|
118
|
+
"references": {}
|
|
119
|
+
},
|
|
120
|
+
"required": false,
|
|
121
|
+
"optional": false,
|
|
122
|
+
"docs": {
|
|
123
|
+
"tags": [],
|
|
124
|
+
"text": "Should render component without modal"
|
|
125
|
+
},
|
|
126
|
+
"attribute": "without-modal",
|
|
127
|
+
"reflect": false
|
|
128
|
+
},
|
|
129
|
+
"url": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"mutable": false,
|
|
132
|
+
"complexType": {
|
|
133
|
+
"original": "string",
|
|
134
|
+
"resolved": "string",
|
|
135
|
+
"references": {}
|
|
136
|
+
},
|
|
137
|
+
"required": false,
|
|
138
|
+
"optional": false,
|
|
139
|
+
"docs": {
|
|
140
|
+
"tags": [],
|
|
141
|
+
"text": ""
|
|
142
|
+
},
|
|
143
|
+
"attribute": "url",
|
|
144
|
+
"reflect": false,
|
|
145
|
+
"defaultValue": "'profile/verify-mobile'"
|
|
146
|
+
},
|
|
147
|
+
"by": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"mutable": false,
|
|
150
|
+
"complexType": {
|
|
151
|
+
"original": "string",
|
|
152
|
+
"resolved": "string",
|
|
153
|
+
"references": {}
|
|
154
|
+
},
|
|
155
|
+
"required": false,
|
|
156
|
+
"optional": false,
|
|
157
|
+
"docs": {
|
|
158
|
+
"tags": [],
|
|
159
|
+
"text": ""
|
|
160
|
+
},
|
|
161
|
+
"attribute": "by",
|
|
162
|
+
"reflect": false,
|
|
163
|
+
"defaultValue": "'sms'"
|
|
164
|
+
},
|
|
165
|
+
"autoReload": {
|
|
166
|
+
"type": "boolean",
|
|
167
|
+
"mutable": false,
|
|
168
|
+
"complexType": {
|
|
169
|
+
"original": "boolean",
|
|
170
|
+
"resolved": "boolean",
|
|
171
|
+
"references": {}
|
|
172
|
+
},
|
|
173
|
+
"required": false,
|
|
174
|
+
"optional": false,
|
|
175
|
+
"docs": {
|
|
176
|
+
"tags": [],
|
|
177
|
+
"text": ""
|
|
178
|
+
},
|
|
179
|
+
"attribute": "auto-reload",
|
|
180
|
+
"reflect": false,
|
|
181
|
+
"defaultValue": "true"
|
|
182
|
+
}
|
|
183
|
+
}; }
|
|
184
|
+
static get events() { return [{
|
|
185
|
+
"method": "verified",
|
|
186
|
+
"name": "verified",
|
|
187
|
+
"bubbles": true,
|
|
188
|
+
"cancelable": true,
|
|
189
|
+
"composed": true,
|
|
190
|
+
"docs": {
|
|
191
|
+
"tags": [],
|
|
192
|
+
"text": ""
|
|
193
|
+
},
|
|
194
|
+
"complexType": {
|
|
195
|
+
"original": "any",
|
|
196
|
+
"resolved": "any",
|
|
197
|
+
"references": {}
|
|
198
|
+
}
|
|
199
|
+
}]; }
|
|
200
|
+
static get methods() { return {
|
|
201
|
+
"getCode": {
|
|
202
|
+
"complexType": {
|
|
203
|
+
"signature": "() => Promise<string>",
|
|
204
|
+
"parameters": [],
|
|
205
|
+
"references": {
|
|
206
|
+
"Promise": {
|
|
207
|
+
"location": "global"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"return": "Promise<string>"
|
|
211
|
+
},
|
|
212
|
+
"docs": {
|
|
213
|
+
"text": "",
|
|
214
|
+
"tags": []
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"show": {
|
|
218
|
+
"complexType": {
|
|
219
|
+
"signature": "(data: any) => Promise<any>",
|
|
220
|
+
"parameters": [{
|
|
221
|
+
"tags": [],
|
|
222
|
+
"text": ""
|
|
223
|
+
}],
|
|
224
|
+
"references": {
|
|
225
|
+
"Promise": {
|
|
226
|
+
"location": "global"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"return": "Promise<any>"
|
|
230
|
+
},
|
|
231
|
+
"docs": {
|
|
232
|
+
"text": "",
|
|
233
|
+
"tags": []
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}; }
|
|
98
237
|
static get elementRef() { return "host"; }
|
|
99
238
|
}
|
|
@@ -2,21 +2,30 @@ var fs = require('fs');
|
|
|
2
2
|
var path = require('path');
|
|
3
3
|
var _ = require('lodash');
|
|
4
4
|
var components = {};
|
|
5
|
-
|
|
5
|
+
var componentsPath = path.resolve(__dirname, '../../components');
|
|
6
|
+
|
|
7
|
+
//==================== Global Salla Components Styles ====================//
|
|
8
|
+
var utilities = {
|
|
9
|
+
'.s-has-error': {'@apply !border-red-500 !text-red-500': {}},
|
|
10
|
+
'.s-ltr' : {direction: 'ltr'},
|
|
11
|
+
'.s-input' : {'@apply appearance-none form-input': {}},
|
|
12
|
+
'.s-hidden' : {'@apply hidden': {}},
|
|
13
|
+
'.s-block' : {'@apply block': {}},
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
fs.readdirSync(componentsPath, {withFileTypes: true})
|
|
7
17
|
.filter(parent => parent.isDirectory())
|
|
8
18
|
.forEach(directory => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
var utilities = {};
|
|
19
|
+
try {
|
|
20
|
+
components[directory.name.replace('salla-', '')] = require(path.resolve(componentsPath, directory.name, 'utilities.json'));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// ignore
|
|
23
|
+
}
|
|
24
|
+
});
|
|
16
25
|
|
|
17
26
|
for (const [keyComponent, value] of Object.entries(components)) {
|
|
18
27
|
console.log('> Processing ' + keyComponent + ' ...');
|
|
19
|
-
_.forEach(value, function(value, keyUtility) {
|
|
28
|
+
_.forEach(value, function (value, keyUtility) {
|
|
20
29
|
keyUtility = '.s-' + keyComponent + '-' + keyUtility;
|
|
21
30
|
utilities[keyUtility] = {[`@apply ${value}`]: {}};
|
|
22
31
|
});
|
|
@@ -28,7 +37,7 @@ console.log('> Write utilities ...');
|
|
|
28
37
|
fs.writeFileSync(
|
|
29
38
|
path.resolve(__dirname, 'utilities.json'),
|
|
30
39
|
JSON.stringify(utilities),
|
|
31
|
-
function(err) {
|
|
40
|
+
function (err) {
|
|
32
41
|
if (err) {
|
|
33
42
|
return console.log(err);
|
|
34
43
|
}
|
|
@@ -41,8 +50,8 @@ fs.writeFileSync(
|
|
|
41
50
|
console.log('> Write safe-list-css ...');
|
|
42
51
|
fs.writeFileSync(
|
|
43
52
|
path.resolve(__dirname, 'safe-list-css.txt'),
|
|
44
|
-
Object.keys(utilities).map((name) => name.replace('.','')).join('\n'),
|
|
45
|
-
function(err) {
|
|
53
|
+
Object.keys(utilities).map((name) => name.replace('.', '')).join('\n'),
|
|
54
|
+
function (err) {
|
|
46
55
|
if (err) {
|
|
47
56
|
return console.log(err);
|
|
48
57
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
module.exports = require('tailwindcss/plugin').withOptions(() => {
|
|
2
|
-
return function({addUtilities}) {
|
|
2
|
+
return function ({addUtilities}) {
|
|
3
3
|
addUtilities({
|
|
4
4
|
// TODO :: find if there are used and defined them here if its.
|
|
5
|
-
'.anime-item': {},
|
|
6
|
-
'.text-md': {},
|
|
7
|
-
'.items-top': {},
|
|
8
|
-
'.error': {},
|
|
9
|
-
'.search-box': {},
|
|
10
|
-
'.spinner-loader-wrap': {}
|
|
5
|
+
'.anime-item' : {},
|
|
6
|
+
'.text-md' : {},
|
|
7
|
+
'.items-top' : {},
|
|
8
|
+
'.error' : {},
|
|
9
|
+
'.search-box' : {},
|
|
10
|
+
'.spinner-loader-wrap': {},
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
// todo :: move it to global
|
|
14
14
|
addUtilities({
|
|
15
15
|
'.spinner-loader': {
|
|
16
|
-
'border-right-color': 'var(--main
|
|
16
|
+
'border-right-color': 'var(--color-main) !important',
|
|
17
17
|
'&.reverse': {
|
|
18
18
|
'border-right-color': '#9f7171 !important',
|
|
19
|
-
'background-color': '#f98181'
|
|
19
|
+
'background-color' : '#f98181'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
});
|
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-32d25ffa.js';
|
|
2
|
+
export { S as SallaSearch } from './salla-search-f552c487.js';
|
|
3
3
|
import './index-8b97d225.js';
|
|
4
4
|
import './Helper-81ac9a8c.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-
|
|
13
|
+
return bootstrapLazy([["salla-button_4",[[0,"salla-login",{"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"modalClosed","onModalClose"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[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],"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],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[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",{"orderId":[2,"order-id"],"thanksMsg":[1,"thanks-msg"],"isStoreRating":[4,"is-store-rating"],"isProductsRating":[4,"is-products-rating"],"isShippingRating":[4,"is-shipping-rating"],"show":[64],"hide":[64]}]]],["salla-offer",[[4,"salla-offer",{"show":[64]}]]],["salla-search",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalClosed","onModalClose"]]]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -25,9 +25,9 @@ const SallaBranches = class {
|
|
|
25
25
|
};
|
|
26
26
|
this.statusColor = (branch = null) => {
|
|
27
27
|
return branch ?
|
|
28
|
-
branch.limited ? '
|
|
28
|
+
branch.limited ? 's-branches-color-red' : branch.available ? 's-branches-color-green' : 's-branches-color-gray'
|
|
29
29
|
:
|
|
30
|
-
this.currentBranch('limited') ? '
|
|
30
|
+
this.currentBranch('limited') ? 's-branches-color-red' : this.currentBranch('available') ? 's-branches-color-green' : 's-branches-color-gray';
|
|
31
31
|
};
|
|
32
32
|
this.isChoiceable = () => {
|
|
33
33
|
return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
|
|
@@ -59,7 +59,7 @@ const SallaBranches = class {
|
|
|
59
59
|
}, 300);
|
|
60
60
|
}
|
|
61
61
|
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, "modal-width": "
|
|
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, "modal-width": "sm", id: "s-branches-modal", class: "hidden" }, h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
|
|
63
63
|
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
64
|
's-branches-input': true,
|
|
65
65
|
'opacity-50': !branch.open,
|
|
@@ -72,8 +72,8 @@ const SallaBranches = class {
|
|
|
72
72
|
:
|
|
73
73
|
h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
74
74
|
:
|
|
75
|
-
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 ? '' : '- مُغلق'))))
|
|
76
|
-
h("slot", { name: "footer" }, h("salla-button", {
|
|
75
|
+
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 }, salla.lang.get('common.elements.ok')))
|
|
77
77
|
: ''));
|
|
78
78
|
}
|
|
79
79
|
componentDidRender() {
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-8b97d225.js';
|
|
2
|
+
import { H as Helper } from './Helper-81ac9a8c.js';
|
|
3
|
+
export { S as salla_login } from './salla-login-32d25ffa.js';
|
|
4
|
+
|
|
5
|
+
const sallaButtonCss = ":host{display:block}";
|
|
6
|
+
|
|
7
|
+
const SallaButton = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.btnStyle = 'primary';
|
|
11
|
+
this.loading = false;
|
|
12
|
+
this.disabled = false;
|
|
13
|
+
this.loaderPosition = 'before';
|
|
14
|
+
this.wide = false;
|
|
15
|
+
this.hostAttributes = {};
|
|
16
|
+
//============= Initiate Button Attributes =============//
|
|
17
|
+
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
18
|
+
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
19
|
+
}
|
|
20
|
+
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
21
|
+
this.hostAttributes.class += ' s-button-btn btn--has-loading'
|
|
22
|
+
+ ' s-button-' + this.btnStyle
|
|
23
|
+
+ (this.wide ? ' s-button-wide ' : '')
|
|
24
|
+
+ ' loader-' + this.loaderPosition
|
|
25
|
+
+ (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
|
|
26
|
+
delete this.hostAttributes['btn-style'];
|
|
27
|
+
delete this.hostAttributes['id'];
|
|
28
|
+
if (this.wide) {
|
|
29
|
+
this.host.classList.add('s-button-wide');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async load() {
|
|
33
|
+
if (this.loaderPosition == 'center')
|
|
34
|
+
this.text.classList.add('s-button-hide');
|
|
35
|
+
this.host.setAttribute('loading', '');
|
|
36
|
+
return this.host;
|
|
37
|
+
}
|
|
38
|
+
async stop() {
|
|
39
|
+
this.host.removeAttribute('loading');
|
|
40
|
+
return this.host;
|
|
41
|
+
}
|
|
42
|
+
async disable() {
|
|
43
|
+
this.host.setAttribute('disabled', '');
|
|
44
|
+
}
|
|
45
|
+
async enable() {
|
|
46
|
+
this.host.removeAttribute('disabled');
|
|
47
|
+
}
|
|
48
|
+
handleVisible(newKind, oldKind) {
|
|
49
|
+
//todo::use united styles
|
|
50
|
+
this.btn.classList.remove('btn-' + oldKind);
|
|
51
|
+
this.btn.classList.add('btn-' + newKind);
|
|
52
|
+
}
|
|
53
|
+
handleLoading(newVal) {
|
|
54
|
+
//todo::use united styles
|
|
55
|
+
Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
return (
|
|
59
|
+
//TODO:: use HOST then fake button behaviours
|
|
60
|
+
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: {
|
|
61
|
+
//todo::use united styles
|
|
62
|
+
's-button-loader': true,
|
|
63
|
+
's-button-loader-start': this.loaderPosition === 'start',
|
|
64
|
+
's-button-loader-end': this.loaderPosition === 'end',
|
|
65
|
+
's-button-loader-center': this.loaderPosition === 'center',
|
|
66
|
+
} }) : '')));
|
|
67
|
+
}
|
|
68
|
+
get host() { return getElement(this); }
|
|
69
|
+
static get watchers() { return {
|
|
70
|
+
"btnStyle": ["handleVisible"],
|
|
71
|
+
"loading": ["handleLoading"]
|
|
72
|
+
}; }
|
|
73
|
+
};
|
|
74
|
+
SallaButton.style = sallaButtonCss;
|
|
75
|
+
|
|
76
|
+
const SallaModal = class {
|
|
77
|
+
constructor(hostRef) {
|
|
78
|
+
registerInstance(this, hostRef);
|
|
79
|
+
this.modalOpened = createEvent(this, "modalOpened", 7);
|
|
80
|
+
this.modalClosed = createEvent(this, "modalClosed", 7);
|
|
81
|
+
var _a;
|
|
82
|
+
//todo:: unite three colors (error, success, primary) in one prop
|
|
83
|
+
this.error = false;
|
|
84
|
+
this.success = false;
|
|
85
|
+
this.primary = false;
|
|
86
|
+
this.isClosable = true;
|
|
87
|
+
this.width = 'md';
|
|
88
|
+
this.visible = false;
|
|
89
|
+
this.isLoading = false;
|
|
90
|
+
this.subTitleFirst = false;
|
|
91
|
+
this.subTitle = '';
|
|
92
|
+
this.icon = '';
|
|
93
|
+
this.imageIcon = '';
|
|
94
|
+
Helper.setHost(this.host);
|
|
95
|
+
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
96
|
+
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
97
|
+
this.title = this.host.title;
|
|
98
|
+
this.host.removeAttribute('title');
|
|
99
|
+
(_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
|
|
100
|
+
}
|
|
101
|
+
handleVisible(newValue) {
|
|
102
|
+
if (!newValue) {
|
|
103
|
+
this.toggleModal(false);
|
|
104
|
+
this.modalClosed.emit();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.host.classList.remove('hidden');
|
|
108
|
+
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
109
|
+
this.modalOpened.emit();
|
|
110
|
+
}
|
|
111
|
+
async show() {
|
|
112
|
+
this.host.setAttribute('visible', '');
|
|
113
|
+
return this.host;
|
|
114
|
+
}
|
|
115
|
+
async hide() {
|
|
116
|
+
this.host.removeAttribute('visible');
|
|
117
|
+
return this.host;
|
|
118
|
+
}
|
|
119
|
+
async setTitle(title) {
|
|
120
|
+
this.title = title;
|
|
121
|
+
return this.host;
|
|
122
|
+
}
|
|
123
|
+
async loading() {
|
|
124
|
+
this.isLoading = true;
|
|
125
|
+
return this.host;
|
|
126
|
+
}
|
|
127
|
+
async stopLoading() {
|
|
128
|
+
this.isLoading = false;
|
|
129
|
+
return this.host;
|
|
130
|
+
}
|
|
131
|
+
toggleModal(isOpen) {
|
|
132
|
+
Helper
|
|
133
|
+
// .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
134
|
+
.toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
135
|
+
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
136
|
+
//todo:: use united class names
|
|
137
|
+
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
138
|
+
if (!isOpen) {
|
|
139
|
+
setTimeout(() => this.host.classList.add('hidden'), 350);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
closeModal() {
|
|
143
|
+
if (!this.isClosable) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.host.removeAttribute('visible');
|
|
147
|
+
}
|
|
148
|
+
//todo:: pref for each modal
|
|
149
|
+
render() {
|
|
150
|
+
this.host.id = this.host.id || 'salla-modal';
|
|
151
|
+
return (
|
|
152
|
+
//todo:: use suitable class name instead of hidden
|
|
153
|
+
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
|
|
154
|
+
? h("span", null, "Loading...")
|
|
155
|
+
: [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
156
|
+
//todo:: remove cursor-pointer
|
|
157
|
+
h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
|
|
158
|
+
: '', this.error || this.success || this.icon
|
|
159
|
+
? h("div", { class: {
|
|
160
|
+
's-modal-icon': true,
|
|
161
|
+
's-modal-bg-error': this.error,
|
|
162
|
+
's-modal-bg-success': this.success,
|
|
163
|
+
's-modal-bg-normal': !this.error && !this.success,
|
|
164
|
+
's-modal-bg-primary': this.primary
|
|
165
|
+
} }, h("i", { class: {
|
|
166
|
+
[this.icon]: true,
|
|
167
|
+
's-modal-text-error': this.error,
|
|
168
|
+
's-modal-text-success': this.success,
|
|
169
|
+
} }))
|
|
170
|
+
: this.imageIcon ?
|
|
171
|
+
h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
172
|
+
: '', this.title || this.subTitle ?
|
|
173
|
+
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 }))
|
|
174
|
+
: ''),
|
|
175
|
+
h("slot", null),
|
|
176
|
+
h("slot", { name: "footer" })
|
|
177
|
+
])))));
|
|
178
|
+
}
|
|
179
|
+
get host() { return getElement(this); }
|
|
180
|
+
static get watchers() { return {
|
|
181
|
+
"visible": ["handleVisible"]
|
|
182
|
+
}; }
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const SallaVerify = class {
|
|
186
|
+
constructor(hostRef) {
|
|
187
|
+
registerInstance(this, hostRef);
|
|
188
|
+
this.verified = createEvent(this, "verified", 7);
|
|
189
|
+
this.url = 'profile/verify-mobile';
|
|
190
|
+
this.by = 'sms';
|
|
191
|
+
this.autoReload = true;
|
|
192
|
+
Helper.setHost(this.host);
|
|
193
|
+
if (this.withoutModal) {
|
|
194
|
+
this.modal = { show: () => '', hide: () => '' };
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
salla.event.on('profile::verify.mobile', data => this.show(data));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async getCode() {
|
|
201
|
+
return this.code.value;
|
|
202
|
+
}
|
|
203
|
+
async show(data) {
|
|
204
|
+
this.data = data;
|
|
205
|
+
this.resendTimer();
|
|
206
|
+
this.otpInputs = document.querySelectorAll('.s-verify-input');
|
|
207
|
+
this.otpInputs[0].focus();
|
|
208
|
+
Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
|
|
209
|
+
Helper.onKeyUp('.s-verify-input', event => {
|
|
210
|
+
var _a, _b, _c, _d;
|
|
211
|
+
let key = event.keyCode || event.charCode;
|
|
212
|
+
if (event.target.value) {
|
|
213
|
+
(_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
214
|
+
(_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
|
|
215
|
+
}
|
|
216
|
+
else if ([8, 46].includes(key)) {
|
|
217
|
+
(_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
|
|
218
|
+
(_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
|
|
219
|
+
}
|
|
220
|
+
this.toggleOTPSubmit();
|
|
221
|
+
});
|
|
222
|
+
Helper.on('paste', '.s-verify-input', event => {
|
|
223
|
+
let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
|
|
224
|
+
this.otpInputs.forEach((input, i) => input.value = text[i] || '');
|
|
225
|
+
this.toggleOTPSubmit();
|
|
226
|
+
setTimeout(() => this.otpInputs[3].focus(), 100);
|
|
227
|
+
});
|
|
228
|
+
return this.modal.show();
|
|
229
|
+
}
|
|
230
|
+
toggleOTPSubmit() {
|
|
231
|
+
let otp = [];
|
|
232
|
+
this.otpInputs.forEach(input => input.value && otp.push(input.value));
|
|
233
|
+
this.code.value = otp.join('');
|
|
234
|
+
if (otp.length === 4) {
|
|
235
|
+
this.btn.removeAttribute('disabled');
|
|
236
|
+
this.btn.click();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.btn.setAttribute('disabled', '');
|
|
240
|
+
}
|
|
241
|
+
resendTimer() {
|
|
242
|
+
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
243
|
+
let resendAfter = 30;
|
|
244
|
+
let timerId = setInterval(() => {
|
|
245
|
+
if (resendAfter === -1) {
|
|
246
|
+
clearTimeout(timerId);
|
|
247
|
+
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
251
|
+
resendAfter--;
|
|
252
|
+
}
|
|
253
|
+
}, 1000);
|
|
254
|
+
}
|
|
255
|
+
resendCode() {
|
|
256
|
+
return this.btn.stop()
|
|
257
|
+
.then(() => this.btn.disable())
|
|
258
|
+
.then(() => {
|
|
259
|
+
this.otpInputs.forEach(input => input.value = '');
|
|
260
|
+
this.otpInputs[0].focus();
|
|
261
|
+
})
|
|
262
|
+
.then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
|
|
263
|
+
.then(() => this.resendTimer())
|
|
264
|
+
.catch(() => this.resendTimer());
|
|
265
|
+
}
|
|
266
|
+
submit() {
|
|
267
|
+
return this.btn.load()
|
|
268
|
+
.then(() => this.btn.disable())
|
|
269
|
+
.then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
|
|
270
|
+
.then(response => this.verified.emit(response))
|
|
271
|
+
.then(() => this.btn.stop() && this.btn.disable())
|
|
272
|
+
.then(() => this.modal.hide())
|
|
273
|
+
.then(() => this.autoReload && window.location.reload())
|
|
274
|
+
.catch(() => this.btn.stop() && this.btn.enable());
|
|
275
|
+
}
|
|
276
|
+
render() {
|
|
277
|
+
return this.withoutModal ? this.myBody() :
|
|
278
|
+
h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
|
|
279
|
+
}
|
|
280
|
+
myBody() {
|
|
281
|
+
return [
|
|
282
|
+
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
283
|
+
h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')),
|
|
284
|
+
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
285
|
+
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 }))),
|
|
286
|
+
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')))
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
get host() { return getElement(this); }
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export { SallaButton as salla_button, SallaModal as salla_modal, SallaVerify as salla_verify };
|