@salla.sa/twilight-components 1.0.33 → 1.0.34
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 +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-branches.cjs.entry.js +5 -6
- package/dist/cjs/salla-button_7.cjs.entry.js +143 -52
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -0
- package/dist/cjs/salla-offer.cjs.entry.js +10 -2
- package/dist/cjs/salla-product-availability.cjs.entry.js +6 -0
- package/dist/cjs/salla-rating.cjs.entry.js +12 -2
- package/dist/cjs/{salla-search-62921989.js → salla-search-6738ec5e.js} +11 -10
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-branches/salla-branches.js +6 -8
- package/dist/collection/components/salla-button/salla-button.js +62 -26
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +4 -1
- package/dist/collection/components/salla-localization/salla-localization.js +11 -5
- package/dist/collection/components/salla-login/salla-login.js +32 -17
- package/dist/collection/components/salla-modal/salla-modal.js +84 -47
- package/dist/collection/components/salla-offer/salla-offer.js +29 -9
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +11 -5
- package/dist/collection/components/salla-rating/salla-rating.js +35 -5
- package/dist/collection/components/salla-search/salla-search.js +3 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +30 -14
- package/dist/collection/components/salla-verify/salla-verify.js +43 -50
- package/dist/collection/plugins/tailwind-theme/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +5 -6
- package/dist/esm/salla-button_7.entry.js +143 -52
- package/dist/esm/salla-infinite-scroll.entry.js +3 -0
- package/dist/esm/salla-offer.entry.js +10 -2
- package/dist/esm/salla-product-availability.entry.js +6 -0
- package/dist/esm/salla-rating.entry.js +12 -2
- package/dist/esm/{salla-search-96520d15.js → salla-search-90231876.js} +11 -10
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-2abf9fc5.js +1 -0
- package/dist/twilight-components/p-dd9469a1.entry.js +1 -0
- package/dist/twilight-components/p-ebc6e474.entry.js +1 -0
- package/dist/twilight-components/p-f36fa4c6.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-branches/salla-branches.d.ts +0 -1
- package/dist/types/components/salla-button/salla-button.d.ts +32 -1
- package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +3 -0
- package/dist/types/components/salla-localization/salla-localization.d.ts +6 -0
- package/dist/types/components/salla-login/salla-login.d.ts +14 -1
- package/dist/types/components/salla-modal/salla-modal.d.ts +37 -2
- package/dist/types/components/salla-offer/salla-offer.d.ts +9 -1
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +10 -1
- package/dist/types/components/salla-rating/salla-rating.d.ts +10 -0
- package/dist/types/components/salla-search/salla-search.d.ts +3 -0
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +15 -1
- package/dist/types/components/salla-verify/salla-verify.d.ts +26 -4
- package/dist/types/components.d.ts +209 -10
- package/example/.DS_Store +0 -0
- package/example/dist/.DS_Store +0 -0
- package/example/dist/twilight.js +1 -1
- package/example/index.html +2 -2
- package/example/products/search +13 -0
- package/package.json +1 -1
- package/dist/twilight-components/p-352ce785.js +0 -1
- package/dist/twilight-components/p-9cabc8a4.entry.js +0 -1
- package/dist/twilight-components/p-a841c013.entry.js +0 -1
- package/dist/twilight-components/p-fbfd14a6.entry.js +0 -1
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Component, Element, Event, h, Method, Prop, State } from '@stencil/core';
|
|
2
2
|
import Helper from "../../Helpers/Helper";
|
|
3
|
+
/**
|
|
4
|
+
* @slot footer - Replaces the footer, by default it contains: verify button, resend, and timer
|
|
5
|
+
* @slot after-footer - placeholder position
|
|
6
|
+
*/
|
|
3
7
|
export class SallaVerify {
|
|
4
8
|
constructor() {
|
|
9
|
+
this.initiated = false;
|
|
10
|
+
/**
|
|
11
|
+
* Verifying method
|
|
12
|
+
*/
|
|
5
13
|
this.by = 'sms';
|
|
14
|
+
/**
|
|
15
|
+
* should auto reloading the page after success verification
|
|
16
|
+
*/
|
|
6
17
|
this.autoReload = true;
|
|
7
|
-
this.initiated = false;
|
|
8
18
|
Helper.setHost(this.host);
|
|
9
19
|
if (this.withoutModal) {
|
|
10
20
|
this.modal = { show: () => '', hide: () => '' };
|
|
@@ -16,12 +26,22 @@ export class SallaVerify {
|
|
|
16
26
|
});
|
|
17
27
|
}
|
|
18
28
|
salla.event.on('languages::translations.loaded', () => {
|
|
29
|
+
var _a;
|
|
19
30
|
this.title = salla.lang.get('pages.profile.verify_title');
|
|
31
|
+
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('pages.profile.verify'));
|
|
20
32
|
});
|
|
21
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Get current code
|
|
36
|
+
* @return {string}
|
|
37
|
+
*/
|
|
22
38
|
async getCode() {
|
|
23
39
|
return this.code.value;
|
|
24
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Show verifying modal
|
|
43
|
+
* @param data
|
|
44
|
+
*/
|
|
25
45
|
async show(data) {
|
|
26
46
|
var _a;
|
|
27
47
|
this.data = data;
|
|
@@ -116,7 +136,6 @@ export class SallaVerify {
|
|
|
116
136
|
myBody() {
|
|
117
137
|
return [
|
|
118
138
|
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
119
|
-
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
120
139
|
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
121
140
|
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 }))),
|
|
122
141
|
h("div", { slot: "footer", class: "s-verify-footer" },
|
|
@@ -124,11 +143,8 @@ export class SallaVerify {
|
|
|
124
143
|
h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
|
|
125
144
|
salla.lang.get('blocks.header.resend_after'),
|
|
126
145
|
h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
|
|
127
|
-
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')),
|
|
128
|
-
|
|
129
|
-
h("a", { href: "#", class: "s-verify-back", onClick: () => this.backClicked.emit() },
|
|
130
|
-
h("i", { class: "sicon-arrow-right" }))
|
|
131
|
-
: '')
|
|
146
|
+
h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit'))),
|
|
147
|
+
h("slot", { name: "after-footer" })
|
|
132
148
|
];
|
|
133
149
|
}
|
|
134
150
|
static get is() { return "salla-verify"; }
|
|
@@ -162,7 +178,7 @@ export class SallaVerify {
|
|
|
162
178
|
"optional": true,
|
|
163
179
|
"docs": {
|
|
164
180
|
"tags": [],
|
|
165
|
-
"text": ""
|
|
181
|
+
"text": "Submitting url, default will use salla api auth: `salla.api.auth.verify`"
|
|
166
182
|
},
|
|
167
183
|
"attribute": "url",
|
|
168
184
|
"reflect": true
|
|
@@ -171,37 +187,20 @@ export class SallaVerify {
|
|
|
171
187
|
"type": "string",
|
|
172
188
|
"mutable": false,
|
|
173
189
|
"complexType": {
|
|
174
|
-
"original": "
|
|
175
|
-
"resolved": "
|
|
190
|
+
"original": "'sms' | 'email'",
|
|
191
|
+
"resolved": "\"email\" | \"sms\"",
|
|
176
192
|
"references": {}
|
|
177
193
|
},
|
|
178
194
|
"required": false,
|
|
179
195
|
"optional": false,
|
|
180
196
|
"docs": {
|
|
181
197
|
"tags": [],
|
|
182
|
-
"text": ""
|
|
198
|
+
"text": "Verifying method"
|
|
183
199
|
},
|
|
184
200
|
"attribute": "by",
|
|
185
201
|
"reflect": false,
|
|
186
202
|
"defaultValue": "'sms'"
|
|
187
203
|
},
|
|
188
|
-
"isShowBack": {
|
|
189
|
-
"type": "boolean",
|
|
190
|
-
"mutable": false,
|
|
191
|
-
"complexType": {
|
|
192
|
-
"original": "boolean",
|
|
193
|
-
"resolved": "boolean",
|
|
194
|
-
"references": {}
|
|
195
|
-
},
|
|
196
|
-
"required": false,
|
|
197
|
-
"optional": false,
|
|
198
|
-
"docs": {
|
|
199
|
-
"tags": [],
|
|
200
|
-
"text": ""
|
|
201
|
-
},
|
|
202
|
-
"attribute": "is-show-back",
|
|
203
|
-
"reflect": false
|
|
204
|
-
},
|
|
205
204
|
"autoReload": {
|
|
206
205
|
"type": "boolean",
|
|
207
206
|
"mutable": false,
|
|
@@ -214,7 +213,7 @@ export class SallaVerify {
|
|
|
214
213
|
"optional": false,
|
|
215
214
|
"docs": {
|
|
216
215
|
"tags": [],
|
|
217
|
-
"text": ""
|
|
216
|
+
"text": "should auto reloading the page after success verification"
|
|
218
217
|
},
|
|
219
218
|
"attribute": "auto-reload",
|
|
220
219
|
"reflect": false,
|
|
@@ -232,22 +231,7 @@ export class SallaVerify {
|
|
|
232
231
|
"composed": true,
|
|
233
232
|
"docs": {
|
|
234
233
|
"tags": [],
|
|
235
|
-
"text": ""
|
|
236
|
-
},
|
|
237
|
-
"complexType": {
|
|
238
|
-
"original": "any",
|
|
239
|
-
"resolved": "any",
|
|
240
|
-
"references": {}
|
|
241
|
-
}
|
|
242
|
-
}, {
|
|
243
|
-
"method": "backClicked",
|
|
244
|
-
"name": "backClicked",
|
|
245
|
-
"bubbles": true,
|
|
246
|
-
"cancelable": true,
|
|
247
|
-
"composed": true,
|
|
248
|
-
"docs": {
|
|
249
|
-
"tags": [],
|
|
250
|
-
"text": ""
|
|
234
|
+
"text": "Event when success verification"
|
|
251
235
|
},
|
|
252
236
|
"complexType": {
|
|
253
237
|
"original": "any",
|
|
@@ -268,15 +252,21 @@ export class SallaVerify {
|
|
|
268
252
|
"return": "Promise<string>"
|
|
269
253
|
},
|
|
270
254
|
"docs": {
|
|
271
|
-
"text": "",
|
|
272
|
-
"tags": [
|
|
255
|
+
"text": "Get current code",
|
|
256
|
+
"tags": [{
|
|
257
|
+
"name": "return",
|
|
258
|
+
"text": undefined
|
|
259
|
+
}]
|
|
273
260
|
}
|
|
274
261
|
},
|
|
275
262
|
"show": {
|
|
276
263
|
"complexType": {
|
|
277
264
|
"signature": "(data: any) => Promise<void>",
|
|
278
265
|
"parameters": [{
|
|
279
|
-
"tags": [
|
|
266
|
+
"tags": [{
|
|
267
|
+
"text": "data",
|
|
268
|
+
"name": "param"
|
|
269
|
+
}],
|
|
280
270
|
"text": ""
|
|
281
271
|
}],
|
|
282
272
|
"references": {
|
|
@@ -287,8 +277,11 @@ export class SallaVerify {
|
|
|
287
277
|
"return": "Promise<void>"
|
|
288
278
|
},
|
|
289
279
|
"docs": {
|
|
290
|
-
"text": "",
|
|
291
|
-
"tags": [
|
|
280
|
+
"text": "Show verifying modal",
|
|
281
|
+
"tags": [{
|
|
282
|
+
"name": "param",
|
|
283
|
+
"text": "data"
|
|
284
|
+
}]
|
|
292
285
|
}
|
|
293
286
|
}
|
|
294
287
|
}; }
|
|
@@ -4,7 +4,7 @@ module.exports = require('tailwindcss/plugin').withOptions(() => {
|
|
|
4
4
|
// TODO :: find if there are used and defined them here if its.
|
|
5
5
|
'.s-hidden' : {'@apply hidden': {}},
|
|
6
6
|
'.text-md' : {},
|
|
7
|
-
'.has-error' : {'@apply border-red-400 focus:border-red-500': {}},
|
|
7
|
+
'.s-has-error' : {'@apply border-red-400 focus:border-red-500': {}},
|
|
8
8
|
'.rounded-icon' : {'@apply w-16 h-16 flex justify-center items-center rounded-full text-3xl': {}},
|
|
9
9
|
'.form-input' : {'@apply w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary dark:focus:border-primary sm:text-sm border-border-color dark:bg-gray-600 dark:border-gray-600 rounded-md': {}},
|
|
10
10
|
'.btn' : {'@apply transition duration-300 flex-1 inline-flex justify-center items-center px-6 pb-2.5 pt-2 text-sm font-bold rounded-md hover:opacity-80 whitespace-nowrap': {}},
|
package/dist/esm/index.js
CHANGED
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_7",[[
|
|
13
|
+
return bootstrapLazy([["salla-button_7",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[4,"salla-localization",{"languagesTitle":[32],"currenciesTitle":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[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"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32]}]]],["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-offer",[[0,"salla-offer",{"offer":[32],"show":[64],"showOffer":[64]}]]],["salla-rating",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -7,8 +7,8 @@ const SallaBranches = class {
|
|
|
7
7
|
registerInstance(this, hostRef);
|
|
8
8
|
this.open = false;
|
|
9
9
|
this.isOpenedBefore = salla.localData.get("branch-choosed-before");
|
|
10
|
-
this.displayAs = 'default';
|
|
11
|
-
this.browseProductsFrom = 'all';
|
|
10
|
+
this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
|
|
11
|
+
this.browseProductsFrom = 'all'; //todo:: get better name
|
|
12
12
|
this.branches = [
|
|
13
13
|
{ id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
|
|
14
14
|
{ id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
|
|
@@ -35,10 +35,9 @@ const SallaBranches = class {
|
|
|
35
35
|
: 'التسوق من فرع آخر';
|
|
36
36
|
};
|
|
37
37
|
salla.event.on('branches::show', () => this.show());
|
|
38
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
39
|
-
this.ok = salla.lang.get('common.elements.ok');
|
|
40
|
-
});
|
|
38
|
+
salla.event.on('languages::translations.loaded', () => { var _a; return (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok')); });
|
|
41
39
|
}
|
|
40
|
+
//todo:: add description for all @methods
|
|
42
41
|
async show() {
|
|
43
42
|
return this.modal.show();
|
|
44
43
|
}
|
|
@@ -73,7 +72,7 @@ const SallaBranches = class {
|
|
|
73
72
|
h("span", { class: this.statusColor(branch) }, branch.tag)))))
|
|
74
73
|
:
|
|
75
74
|
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 },
|
|
75
|
+
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
76
|
: ''));
|
|
78
77
|
}
|
|
79
78
|
componentDidRender() {
|
|
@@ -1,19 +1,33 @@
|
|
|
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-7162a06c.js';
|
|
3
|
-
export { S as salla_login, a as salla_search } from './salla-search-
|
|
3
|
+
export { S as salla_login, a as salla_search } from './salla-search-90231876.js';
|
|
4
4
|
|
|
5
5
|
const sallaButtonCss = ":host{display:block}";
|
|
6
6
|
|
|
7
7
|
const SallaButton = class {
|
|
8
8
|
constructor(hostRef) {
|
|
9
9
|
registerInstance(this, hostRef);
|
|
10
|
+
/**
|
|
11
|
+
* Button Style
|
|
12
|
+
*/
|
|
10
13
|
this.btnStyle = 'primary';
|
|
14
|
+
/**
|
|
15
|
+
* Is the button currently loading
|
|
16
|
+
*/
|
|
11
17
|
this.loading = false;
|
|
18
|
+
/**
|
|
19
|
+
* Is the button currently disabled
|
|
20
|
+
*/
|
|
12
21
|
this.disabled = false;
|
|
22
|
+
/**
|
|
23
|
+
* If there is need to change loader position, pass the position
|
|
24
|
+
*/
|
|
13
25
|
this.loaderPosition = 'before';
|
|
26
|
+
/**
|
|
27
|
+
* Is the button wide
|
|
28
|
+
*/
|
|
14
29
|
this.wide = false;
|
|
15
30
|
this.hostAttributes = {};
|
|
16
|
-
//============= Initiate Button Attributes =============//
|
|
17
31
|
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
18
32
|
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
19
33
|
}
|
|
@@ -21,7 +35,7 @@ const SallaButton = class {
|
|
|
21
35
|
this.hostAttributes.class += ' s-button-btn btn--has-loading'
|
|
22
36
|
+ ' s-button-' + this.btnStyle
|
|
23
37
|
+ (this.wide ? ' s-button-wide ' : '')
|
|
24
|
-
+ ' loader-' + this.loaderPosition
|
|
38
|
+
+ ' loader-' + this.loaderPosition //todo:: it looks there is no need for this class🤔
|
|
25
39
|
+ (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
|
|
26
40
|
delete this.hostAttributes['btn-style'];
|
|
27
41
|
delete this.hostAttributes['id'];
|
|
@@ -29,25 +43,41 @@ const SallaButton = class {
|
|
|
29
43
|
this.host.classList.add('s-button-wide');
|
|
30
44
|
}
|
|
31
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Run loading animation
|
|
48
|
+
*/
|
|
32
49
|
async load() {
|
|
33
50
|
if (this.loaderPosition == 'center')
|
|
34
51
|
this.text.classList.add('s-button-hide');
|
|
35
52
|
this.host.setAttribute('loading', '');
|
|
36
53
|
return this.host;
|
|
37
54
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
55
|
+
/**
|
|
56
|
+
* Stop loading animation
|
|
57
|
+
*/
|
|
42
58
|
async stop() {
|
|
43
59
|
this.host.removeAttribute('loading');
|
|
44
60
|
if (this.loaderPosition == 'center')
|
|
45
61
|
this.text.classList.remove('s-button-hide');
|
|
46
62
|
return this.host;
|
|
47
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Changing the body of the button
|
|
66
|
+
* @param html
|
|
67
|
+
*/
|
|
68
|
+
async setText(html) {
|
|
69
|
+
this.text.innerHTML = html;
|
|
70
|
+
return this.host;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Add `disabled` attribute
|
|
74
|
+
*/
|
|
48
75
|
async disable() {
|
|
49
76
|
this.host.setAttribute('disabled', '');
|
|
50
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Remove `disabled` attribute
|
|
80
|
+
*/
|
|
51
81
|
async enable() {
|
|
52
82
|
this.host.removeAttribute('disabled');
|
|
53
83
|
}
|
|
@@ -107,9 +137,15 @@ const SallaLocalization = class {
|
|
|
107
137
|
this.languages = Object.values(salla.config.get('languages', {}));
|
|
108
138
|
this.currencies = Object.values(salla.config.get('currencies', {}));
|
|
109
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Show the component
|
|
142
|
+
*/
|
|
110
143
|
async show() {
|
|
111
144
|
return this.modal.show();
|
|
112
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Hide the component
|
|
148
|
+
*/
|
|
113
149
|
async hide() {
|
|
114
150
|
return this.modal.hide();
|
|
115
151
|
}
|
|
@@ -121,10 +157,10 @@ const SallaLocalization = class {
|
|
|
121
157
|
}
|
|
122
158
|
async submit() {
|
|
123
159
|
let url;
|
|
124
|
-
console.log('this.currency.code::::', this.currency, this.currency.code);
|
|
160
|
+
console.log('this.currency.code::::', this.currency, this.currency.code); //todo:: remove it
|
|
125
161
|
this.btn.load()
|
|
126
|
-
.then(() => this.currency.code === salla.config.get('user.
|
|
127
|
-
.then(() => this.language.code === salla.config.get('user.
|
|
162
|
+
.then(() => this.currency.code === salla.config.get('user.currency_code', 'SAR') || ((url = window.location.href) && salla.currency.api.change(this.currency.code)))
|
|
163
|
+
.then(() => this.language.code === salla.config.get('user.language_code', 'ar') || (url = this.language.url))
|
|
128
164
|
.then(() => this.btn.stop())
|
|
129
165
|
.then(() => this.hide())
|
|
130
166
|
.then(() => url && (window.location.href = url));
|
|
@@ -163,27 +199,43 @@ const SallaModal = class {
|
|
|
163
199
|
registerInstance(this, hostRef);
|
|
164
200
|
this.modalOpened = createEvent(this, "modalOpened", 7);
|
|
165
201
|
this.modalClosed = createEvent(this, "modalClosed", 7);
|
|
166
|
-
var _a;
|
|
167
202
|
//todo:: unite three colors (error, success, primary) in one prop
|
|
168
203
|
this.error = false;
|
|
169
204
|
this.success = false;
|
|
170
205
|
this.primary = false;
|
|
171
|
-
this.isClosable = true;
|
|
206
|
+
this.isClosable = true; //todo::rename unclude
|
|
207
|
+
/**
|
|
208
|
+
* The size of the modal
|
|
209
|
+
*/
|
|
172
210
|
this.width = 'md';
|
|
173
|
-
|
|
211
|
+
/**
|
|
212
|
+
* The position of the modal
|
|
213
|
+
*/
|
|
214
|
+
this.position = 'middle';
|
|
215
|
+
/**
|
|
216
|
+
* Show the modal on rendering
|
|
217
|
+
*/
|
|
174
218
|
this.visible = false;
|
|
219
|
+
/**
|
|
220
|
+
* Show loading in the middle
|
|
221
|
+
*/
|
|
175
222
|
this.isLoading = false;
|
|
176
|
-
this.subTitleFirst = false;
|
|
177
|
-
this.noPadding = false;
|
|
223
|
+
this.subTitleFirst = false; //todo:: choose better name
|
|
224
|
+
this.noPadding = false; //todo:: choose better name
|
|
178
225
|
this.subTitle = '';
|
|
226
|
+
/**
|
|
227
|
+
* Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
|
|
228
|
+
*/
|
|
179
229
|
this.icon = '';
|
|
230
|
+
/**
|
|
231
|
+
* url of an image
|
|
232
|
+
*/
|
|
180
233
|
this.imageIcon = '';
|
|
181
234
|
Helper.setHost(this.host);
|
|
182
235
|
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
183
236
|
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
184
237
|
this.title = this.host.title;
|
|
185
238
|
this.host.removeAttribute('title');
|
|
186
|
-
(_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
|
|
187
239
|
}
|
|
188
240
|
handleVisible(newValue) {
|
|
189
241
|
if (!newValue) {
|
|
@@ -195,30 +247,44 @@ const SallaModal = class {
|
|
|
195
247
|
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
196
248
|
this.modalOpened.emit();
|
|
197
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Show the modal
|
|
252
|
+
*/
|
|
198
253
|
async show() {
|
|
199
254
|
this.host.setAttribute('visible', '');
|
|
200
255
|
return this.host;
|
|
201
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* hide the modal
|
|
259
|
+
*/
|
|
202
260
|
async hide() {
|
|
203
261
|
this.host.removeAttribute('visible');
|
|
204
262
|
return this.host;
|
|
205
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Change the title
|
|
266
|
+
* @param {string} title
|
|
267
|
+
*/
|
|
206
268
|
async setTitle(title) {
|
|
207
269
|
this.title = title;
|
|
208
270
|
return this.host;
|
|
209
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Start loading
|
|
274
|
+
*/
|
|
210
275
|
async loading() {
|
|
211
276
|
this.isLoading = true;
|
|
212
277
|
return this.host;
|
|
213
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Stop the loading
|
|
281
|
+
*/
|
|
214
282
|
async stopLoading() {
|
|
215
283
|
this.isLoading = false;
|
|
216
284
|
return this.host;
|
|
217
285
|
}
|
|
218
286
|
toggleModal(isOpen) {
|
|
219
|
-
Helper
|
|
220
|
-
// .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
221
|
-
.toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
287
|
+
Helper.toggleElement(this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
222
288
|
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
223
289
|
//todo:: use united class names
|
|
224
290
|
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
@@ -232,34 +298,36 @@ const SallaModal = class {
|
|
|
232
298
|
}
|
|
233
299
|
this.host.removeAttribute('visible');
|
|
234
300
|
}
|
|
301
|
+
iconBlockClasses() {
|
|
302
|
+
return {
|
|
303
|
+
's-modal-icon': true,
|
|
304
|
+
's-modal-bg-error': this.error,
|
|
305
|
+
's-modal-bg-success': this.success,
|
|
306
|
+
's-modal-bg-normal': !this.error && !this.success,
|
|
307
|
+
's-modal-bg-primary': this.primary
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
iconClasses() {
|
|
311
|
+
return {
|
|
312
|
+
[this.icon]: true,
|
|
313
|
+
's-modal-text-error': this.error,
|
|
314
|
+
's-modal-text-success': this.success,
|
|
315
|
+
'sicon-alert-engine': !this.icon && this.error && !this.imageIcon,
|
|
316
|
+
'sicon-check-circle2': !this.icon && this.success && !this.imageIcon,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
235
319
|
//todo:: pref for each modal
|
|
236
320
|
render() {
|
|
237
321
|
this.host.id = this.host.id || 'salla-modal';
|
|
238
|
-
return (
|
|
239
|
-
//todo:: use suitable class name instead of hidden
|
|
240
|
-
h(Host, { class: 's-modal-container s-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-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding'), slot: "body" }, this.isLoading
|
|
322
|
+
return (h(Host, { class: 's-modal-container s-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-scroll-y ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading
|
|
241
323
|
? h("div", { class: "s-modal-loader-wrap" }, h("span", { class: "s-modal-loader" }))
|
|
242
324
|
:
|
|
243
325
|
[h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
244
326
|
h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
|
|
245
327
|
: '', this.title || this.subTitle ?
|
|
246
328
|
h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
|
|
247
|
-
? h("div", { class: {
|
|
248
|
-
|
|
249
|
-
's-modal-bg-error': this.error,
|
|
250
|
-
's-modal-bg-success': this.success,
|
|
251
|
-
's-modal-bg-normal': !this.error && !this.success,
|
|
252
|
-
's-modal-bg-primary': this.primary
|
|
253
|
-
} }, h("i", { class: {
|
|
254
|
-
[this.icon]: true,
|
|
255
|
-
's-modal-text-error': this.error,
|
|
256
|
-
's-modal-text-success': this.success,
|
|
257
|
-
'sicon-alert-engine': !this.icon && this.error,
|
|
258
|
-
'sicon-check-circle2': !this.icon && this.success,
|
|
259
|
-
} }))
|
|
260
|
-
: this.imageIcon ?
|
|
261
|
-
h("img", { class: "s-modal-header-img", src: this.imageIcon })
|
|
262
|
-
: '', 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 })))
|
|
329
|
+
? h("div", { class: this.iconBlockClasses() }, h("i", { class: this.iconClasses() }))
|
|
330
|
+
: this.imageIcon ? h("img", { class: "s-modal-header-img", src: this.imageIcon }) : '', 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 })))
|
|
263
331
|
: ''),
|
|
264
332
|
h("slot", null),
|
|
265
333
|
h("slot", { name: "footer" })
|
|
@@ -1649,8 +1717,11 @@ const SallaTelInput = class {
|
|
|
1649
1717
|
constructor(hostRef) {
|
|
1650
1718
|
registerInstance(this, hostRef);
|
|
1651
1719
|
this.enterClicked = createEvent(this, "enterClicked", 7);
|
|
1720
|
+
/**
|
|
1721
|
+
* Current country_code
|
|
1722
|
+
*/
|
|
1652
1723
|
this.countryCode = salla.config.get('user.country_code', 'SA');
|
|
1653
|
-
this.countryKey = "+966"; //TODO:: why we need it
|
|
1724
|
+
this.countryKey = "+966"; //TODO:: why we need it, if it's important find a way to get it automatically for the current user
|
|
1654
1725
|
this.countryCodeLabel = salla.lang.get('common.country_code');
|
|
1655
1726
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
1656
1727
|
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
@@ -1670,12 +1741,21 @@ const SallaTelInput = class {
|
|
|
1670
1741
|
this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
|
|
1671
1742
|
});
|
|
1672
1743
|
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Get current values
|
|
1746
|
+
* @return {{mobile:number,countryCode:'SA'|string, countryKey:'+966'|string}}
|
|
1747
|
+
*/
|
|
1673
1748
|
async getValues() {
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1749
|
+
return {
|
|
1750
|
+
mobile: this.mobile = this.phoneInput.value,
|
|
1751
|
+
countryCode: this.countryCode = this.countryCodeInput.value,
|
|
1752
|
+
countryKey: this.countryKey = this.countryKeyInput.value
|
|
1753
|
+
};
|
|
1678
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Is current data valid or not
|
|
1757
|
+
* @return {boolean}
|
|
1758
|
+
*/
|
|
1679
1759
|
async isValid() {
|
|
1680
1760
|
this.reset();
|
|
1681
1761
|
if (this.iti.isValidNumber())
|
|
@@ -1708,9 +1788,7 @@ const SallaTelInput = class {
|
|
|
1708
1788
|
});
|
|
1709
1789
|
});
|
|
1710
1790
|
// on blur: validate
|
|
1711
|
-
this.phoneInput.addEventListener('blur', () =>
|
|
1712
|
-
this.isValid();
|
|
1713
|
-
});
|
|
1791
|
+
this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1714
1792
|
// on keyup / change flag: reset
|
|
1715
1793
|
this.phoneInput.addEventListener('input', e => {
|
|
1716
1794
|
salla.helpers.digitsOnly(e.target);
|
|
@@ -1735,10 +1813,15 @@ const SallaVerify = class {
|
|
|
1735
1813
|
constructor(hostRef) {
|
|
1736
1814
|
registerInstance(this, hostRef);
|
|
1737
1815
|
this.verified = createEvent(this, "verified", 7);
|
|
1738
|
-
this.
|
|
1816
|
+
this.initiated = false;
|
|
1817
|
+
/**
|
|
1818
|
+
* Verifying method
|
|
1819
|
+
*/
|
|
1739
1820
|
this.by = 'sms';
|
|
1821
|
+
/**
|
|
1822
|
+
* should auto reloading the page after success verification
|
|
1823
|
+
*/
|
|
1740
1824
|
this.autoReload = true;
|
|
1741
|
-
this.initiated = false;
|
|
1742
1825
|
Helper.setHost(this.host);
|
|
1743
1826
|
if (this.withoutModal) {
|
|
1744
1827
|
this.modal = { show: () => '', hide: () => '' };
|
|
@@ -1750,12 +1833,22 @@ const SallaVerify = class {
|
|
|
1750
1833
|
});
|
|
1751
1834
|
}
|
|
1752
1835
|
salla.event.on('languages::translations.loaded', () => {
|
|
1836
|
+
var _a;
|
|
1753
1837
|
this.title = salla.lang.get('pages.profile.verify_title');
|
|
1838
|
+
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('pages.profile.verify'));
|
|
1754
1839
|
});
|
|
1755
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Get current code
|
|
1843
|
+
* @return {string}
|
|
1844
|
+
*/
|
|
1756
1845
|
async getCode() {
|
|
1757
1846
|
return this.code.value;
|
|
1758
1847
|
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Show verifying modal
|
|
1850
|
+
* @param data
|
|
1851
|
+
*/
|
|
1759
1852
|
async show(data) {
|
|
1760
1853
|
var _a;
|
|
1761
1854
|
this.data = data;
|
|
@@ -1850,12 +1943,10 @@ const SallaVerify = class {
|
|
|
1850
1943
|
myBody() {
|
|
1851
1944
|
return [
|
|
1852
1945
|
h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
|
|
1853
|
-
// <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
|
|
1854
1946
|
h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
|
|
1855
1947
|
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 }))),
|
|
1856
|
-
h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", "loader-position": 'center', 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')),
|
|
1857
|
-
|
|
1858
|
-
: '')
|
|
1948
|
+
h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", "loader-position": 'center', 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'))),
|
|
1949
|
+
h("slot", { name: "after-footer" })
|
|
1859
1950
|
];
|
|
1860
1951
|
}
|
|
1861
1952
|
get host() { return getElement(this); }
|
|
@@ -8,6 +8,9 @@ const SallaInfiniteScroll = class {
|
|
|
8
8
|
* Next Page element
|
|
9
9
|
*/
|
|
10
10
|
this.nextPage = '';
|
|
11
|
+
/**
|
|
12
|
+
* Is there is need to autoload next page when scroll
|
|
13
|
+
*/
|
|
11
14
|
this.autoload = false;
|
|
12
15
|
/**
|
|
13
16
|
* Class selector to know the container if it's not the host `<salla-infinite-scroll>`
|