@salla.sa/twilight-components 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-4b8b3ffe.js +1696 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_5.cjs.entry.js +1686 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-008cc893.js +125 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +50 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +300 -0
  12. package/dist/cjs/salla-search-c7aad59a.js +81 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +22 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +208 -0
  23. package/dist/collection/components/salla-login/salla-login.css +3 -0
  24. package/dist/collection/components/salla-login/salla-login.js +378 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +459 -0
  26. package/dist/collection/components/salla-offer/salla-offer.js +81 -0
  27. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  28. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  29. package/dist/collection/components/salla-rating/salla-rating.js +483 -0
  30. package/dist/collection/components/salla-search/salla-search.js +132 -0
  31. package/dist/collection/components/salla-tel-input/salla-tel-input.js +14 -0
  32. package/dist/collection/components/salla-verify/salla-verify.js +273 -0
  33. package/dist/collection/index.js +2 -0
  34. package/dist/collection/interfaces/colors.js +1 -0
  35. package/dist/collection/interfaces/index.js +2 -0
  36. package/dist/collection/interfaces/ratio.js +1 -0
  37. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  38. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  39. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  40. package/dist/esm/index-092659c7.js +1668 -0
  41. package/dist/esm/index.js +4 -0
  42. package/dist/esm/loader.js +17 -0
  43. package/dist/esm/polyfills/core-js.js +11 -0
  44. package/dist/esm/polyfills/css-shim.js +1 -0
  45. package/dist/esm/polyfills/dom.js +79 -0
  46. package/dist/esm/polyfills/es5-html-element.js +1 -0
  47. package/dist/esm/polyfills/index.js +34 -0
  48. package/dist/esm/polyfills/system.js +6 -0
  49. package/dist/{twilight-components → esm}/salla-branches.entry.js +1 -1
  50. package/dist/esm/salla-button_5.entry.js +1678 -0
  51. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  52. package/dist/{twilight-components/salla-login-b92c73dc.js → esm/salla-login-38586400.js} +2 -6
  53. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  54. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  55. package/dist/{twilight-components → esm}/salla-rating.entry.js +1 -1
  56. package/dist/{twilight-components/salla-search-69f2d9c1.js → esm/salla-search-ca856aab.js} +1 -1
  57. package/dist/esm/salla-search.entry.js +3 -0
  58. package/dist/esm/twilight-components.js +17 -0
  59. package/dist/index.cjs.js +1 -0
  60. package/dist/index.js +1 -0
  61. package/dist/twilight-components/index.esm.js +1 -4
  62. package/dist/twilight-components/p-03d0ec44.entry.js +1 -0
  63. package/dist/twilight-components/p-13a55257.entry.js +1 -0
  64. package/dist/twilight-components/p-160062c6.js +1 -0
  65. package/dist/twilight-components/p-47f17d3b.js +1 -0
  66. package/dist/twilight-components/p-5307c7b5.entry.js +1 -0
  67. package/dist/twilight-components/p-6a1f43c6.entry.js +1 -0
  68. package/dist/twilight-components/p-7088e517.entry.js +1 -0
  69. package/dist/twilight-components/p-924e3c88.js +1 -0
  70. package/dist/twilight-components/p-e8965b01.js +1 -0
  71. package/dist/twilight-components/p-ecb1b6cc.entry.js +1 -0
  72. package/dist/twilight-components/p-f11b401a.entry.js +1 -0
  73. package/dist/twilight-components/twilight-components.css +1 -3
  74. package/dist/twilight-components/twilight-components.esm.js +1 -125
  75. package/dist/types/components/salla-login/salla-login.d.ts +0 -1
  76. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +4 -0
  77. package/dist/types/components.d.ts +13 -0
  78. package/package.json +2 -1
  79. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  80. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  81. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  82. package/dist/twilight-components/index-8966d27f.js +0 -3010
  83. package/dist/twilight-components/salla-button.entry.js +0 -75
  84. package/dist/twilight-components/salla-login-7c25f64b.js +0 -116
  85. package/dist/twilight-components/salla-login.entry.js +0 -3
  86. package/dist/twilight-components/salla-modal.entry.js +0 -113
  87. package/dist/twilight-components/salla-search.entry.js +0 -3
  88. package/dist/twilight-components/salla-verify.entry.js +0 -114
  89. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,378 @@
1
+ import { Component, Element, h, Listen, Method, Prop } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaLogin {
4
+ constructor() {
5
+ this.regType = 'sms';
6
+ this.isLoginByMail = true;
7
+ this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
8
+ this.loginText = salla.lang.get('blocks.header.login');
9
+ this.smsLabel = salla.lang.get('blocks.header.sms');
10
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
11
+ this.emailLabel = salla.lang.get('common.elements.email');
12
+ this.enterText = salla.lang.get('blocks.header.enter');
13
+ this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
14
+ this.byEmailText = salla.lang.get('blocks.header.login_by_email');
15
+ this.backText = salla.lang.get('common.elements.back');
16
+ this.title = this.host.title || salla.lang.get('blocks.header.login');
17
+ this.host.removeAttribute('title');
18
+ salla.auth.event.onVerificationFailed(() => {
19
+ //
20
+ });
21
+ }
22
+ /**
23
+ * @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event
24
+ */
25
+ onVerified(event) {
26
+ if (!event.detail.case) {
27
+ console.log('verified but without case!');
28
+ return;
29
+ }
30
+ if (event.detail.case === "new_customer") {
31
+ return this.showTab(this.tab5);
32
+ }
33
+ //TODO::It looks that is this workaround🤔
34
+ if (salla.auth.event.getTypeActionOnVerified() !== 'redirect') {
35
+ return;
36
+ }
37
+ if (event.redirect_url) {
38
+ return window.location.href = event.redirect_url;
39
+ }
40
+ window.location.reload();
41
+ }
42
+ onbackClicked() {
43
+ this.regType == 'sms' ? this.showTab(this.tab2) : this.showTab(this.tab3);
44
+ }
45
+ async show() {
46
+ this.showTab(this.isLoginByMail ? this.tab1 : this.tab2);
47
+ return this.modal.show();
48
+ }
49
+ showTab(tab) {
50
+ [this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 'visible', 'hidden', () => el == tab));
51
+ setTimeout(() => { [this.tab1, this.tab2, this.tab3, this.tab4, this.tab5].map(el => Helper.toggleElement(el, 's-login-active', 's-login-unactive', () => el == tab)); }, 200);
52
+ setTimeout(() => { this.host.querySelector('.s-login-wrapper').setAttribute('style', 'height:' + (tab === null || tab === void 0 ? void 0 : tab.scrollHeight) + 'px'); });
53
+ if ([this.tab2, this.tab3].includes(tab)) {
54
+ this.regType = tab === this.tab2 ? 'sms' : 'email';
55
+ }
56
+ let isRegistrationTab = tab == this.tab5;
57
+ this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
58
+ if (!isRegistrationTab) {
59
+ Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'sms')
60
+ .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
61
+ }
62
+ return this;
63
+ }
64
+ loginByEmail() {
65
+ if (!Helper.isValidEmail(this.email.value)) {
66
+ this.email.classList.add('s-has-error');
67
+ this.email.nextElementSibling['innerText'] = '* ' + salla.lang.get('common.elements.email_is_valid');
68
+ return;
69
+ }
70
+ this.email.nextElementSibling['innerText'] = '';
71
+ this.email.classList.remove('s-has-error');
72
+ salla.auth.api.login({ type: 'email', email: this.email.value })
73
+ .then(() => this.showTab(this.tab4))
74
+ .then(() => (this.tab4.by = 'email') && (this.tab4.url = 'auth/email/verify'))
75
+ .then(() => this.tab4.show({ email: this.email.value }));
76
+ }
77
+ loginBySMS() {
78
+ if (this.mobile.value.length < 6) {
79
+ this.mobile.classList.add('s-has-error');
80
+ this.mobile.nextElementSibling['innerText'] = '* ' + salla.lang.get('mobile_app.strings.incorrect_mobile');
81
+ return;
82
+ }
83
+ this.mobile.nextElementSibling['innerText'] = '';
84
+ this.mobile.classList.remove('s-has-error');
85
+ salla.auth.api.login({ type: 'sms', mobile: this.mobile.value })
86
+ .then(() => this.showTab(this.tab4))
87
+ .then(() => (this.tab4.by = 'sms') && (this.tab4.url = 'auth/mobile/verify'))
88
+ .then(() => this.tab4.show({ mobile: this.mobile.value, country_code: 'SA' }));
89
+ }
90
+ //TODO:: if it's enter, go submit
91
+ typing({ target }) {
92
+ target.type === 'tel' && salla.helpers.digitsOnly(target);
93
+ target.classList.remove('s-has-error');
94
+ target.nextElementSibling.innerText = '';
95
+ }
96
+ newUser() {
97
+ this.tab4.getCode()
98
+ .then(code => salla.auth.api.register({
99
+ first_name: this.firstName.value,
100
+ last_name: this.lastName.value,
101
+ phone: this.regMobile.value || this.mobile.value,
102
+ email: this.regEmail.value || this.email.value,
103
+ country_code: '',
104
+ country_key: '',
105
+ code: code,
106
+ verified_by: this.regType,
107
+ }));
108
+ }
109
+ render() {
110
+ return (h("salla-modal", { id: "salla-login", title: this.title, ref: modal => this.modal = modal, width: "xs" },
111
+ h("div", { class: "s-login-wrapper" },
112
+ this.isLoginByMail ?
113
+ h("div", { class: "s-login-tab", ref: tab => this.tab1 = tab },
114
+ h("p", { class: "s-login-sub-title" }, this.loginTypeTitle),
115
+ h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab2) },
116
+ h("i", { class: "s-login-main-btn-icon sicon-phone" }),
117
+ h("span", { class: "s-login-main-btn-text" }, this.smsLabel),
118
+ h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })),
119
+ h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab3) },
120
+ h("i", { class: "s-login-main-btn-icon sicon-mail" }),
121
+ h("span", { class: "s-login-main-btn-text" }, this.emailLabel),
122
+ h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })))
123
+ : '',
124
+ h("div", { class: "s-login-tab", ref: tab => this.tab2 = tab },
125
+ h("label", { class: "s-login-label" }, this.mobileLabel),
126
+ h("salla-tel-input", null),
127
+ h("input", { onChange: () => this.loginBySMS(), type: "tel", ref: el => this.mobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input tel-input s-ltr" }),
128
+ h("span", { class: "s-login-error-message" }),
129
+ h("salla-button", { wide: true, onClick: () => this.loginBySMS() }, this.enterText),
130
+ this.isLoginByMail ? h("a", { href: "#", onClick: () => this.showTab(this.tab3), class: "s-login-link" }, this.byEmailText) : ''),
131
+ this.isLoginByMail ?
132
+ h("div", { class: "s-login-tab", ref: tab => this.tab3 = tab },
133
+ h("label", { class: "s-login-label" }, this.emailLabel),
134
+ h("input", { onChange: () => this.loginByEmail(), type: "email", ref: el => this.email = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }),
135
+ h("span", { class: "s-login-error-message" }),
136
+ h("salla-button", { wide: true, onClick: () => this.loginByEmail() }, this.enterText),
137
+ h("a", { href: "#", onClick: () => this.showTab(this.tab2), class: "s-login-link" }, this.bySMSText)) : '',
138
+ h("salla-verify", { "without-modal": true, ref: tab => this.tab4 = tab, autoReload: false, "back-text": this.backText }),
139
+ h("div", { ref: tab => this.tab5 = tab },
140
+ h("label", { class: "s-login-label" }, salla.lang.get('blocks.header.your_name')),
141
+ h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, placeholder: salla.lang.get('pages.profile.first_name') }),
142
+ h("label", { class: "s-login-label" }, salla.lang.get('pages.profile.last_name')),
143
+ h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, placeholder: salla.lang.get('pages.profile.last_name') }),
144
+ h("div", { ref: el => this.regMobileBlock = el },
145
+ h("label", { class: "s-login-label" }, this.mobileLabel),
146
+ h("input", { type: "tel", ref: el => this.regMobile = el, onInput: this.typing, placeholder: "5xx xxx xxx", class: "s-login-input s-ltr" }),
147
+ h("span", { class: "s-login-error-message" })),
148
+ h("div", { ref: el => this.regEmailBlock = el },
149
+ h("label", { class: "s-login-label" }, this.emailLabel),
150
+ h("input", { type: "email", ref: el => this.regEmail = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }),
151
+ h("span", { class: "s-login-error-message" })),
152
+ h("salla-button", { wide: true, onClick: () => this.newUser() }, salla.lang.get('blocks.header.register'))))));
153
+ }
154
+ static get is() { return "salla-login"; }
155
+ static get originalStyleUrls() { return {
156
+ "$": ["salla-login.css"]
157
+ }; }
158
+ static get styleUrls() { return {
159
+ "$": ["salla-login.css"]
160
+ }; }
161
+ static get properties() { return {
162
+ "isLoginByMail": {
163
+ "type": "boolean",
164
+ "mutable": false,
165
+ "complexType": {
166
+ "original": "boolean",
167
+ "resolved": "boolean",
168
+ "references": {}
169
+ },
170
+ "required": false,
171
+ "optional": false,
172
+ "docs": {
173
+ "tags": [],
174
+ "text": ""
175
+ },
176
+ "attribute": "is-login-by-mail",
177
+ "reflect": false,
178
+ "defaultValue": "true"
179
+ },
180
+ "loginTypeTitle": {
181
+ "type": "string",
182
+ "mutable": false,
183
+ "complexType": {
184
+ "original": "string",
185
+ "resolved": "string",
186
+ "references": {}
187
+ },
188
+ "required": false,
189
+ "optional": false,
190
+ "docs": {
191
+ "tags": [],
192
+ "text": ""
193
+ },
194
+ "attribute": "login-type-title",
195
+ "reflect": false,
196
+ "defaultValue": "salla.lang.get('blocks.header.select_login_way')"
197
+ },
198
+ "loginText": {
199
+ "type": "string",
200
+ "mutable": false,
201
+ "complexType": {
202
+ "original": "string",
203
+ "resolved": "string",
204
+ "references": {}
205
+ },
206
+ "required": false,
207
+ "optional": false,
208
+ "docs": {
209
+ "tags": [],
210
+ "text": ""
211
+ },
212
+ "attribute": "login-text",
213
+ "reflect": false,
214
+ "defaultValue": "salla.lang.get('blocks.header.login')"
215
+ },
216
+ "smsLabel": {
217
+ "type": "string",
218
+ "mutable": false,
219
+ "complexType": {
220
+ "original": "string",
221
+ "resolved": "string",
222
+ "references": {}
223
+ },
224
+ "required": false,
225
+ "optional": false,
226
+ "docs": {
227
+ "tags": [],
228
+ "text": ""
229
+ },
230
+ "attribute": "sms-label",
231
+ "reflect": false,
232
+ "defaultValue": "salla.lang.get('blocks.header.sms')"
233
+ },
234
+ "mobileLabel": {
235
+ "type": "string",
236
+ "mutable": false,
237
+ "complexType": {
238
+ "original": "string",
239
+ "resolved": "string",
240
+ "references": {}
241
+ },
242
+ "required": false,
243
+ "optional": false,
244
+ "docs": {
245
+ "tags": [],
246
+ "text": ""
247
+ },
248
+ "attribute": "mobile-label",
249
+ "reflect": false,
250
+ "defaultValue": "salla.lang.get('common.elements.mobile')"
251
+ },
252
+ "emailLabel": {
253
+ "type": "string",
254
+ "mutable": false,
255
+ "complexType": {
256
+ "original": "string",
257
+ "resolved": "string",
258
+ "references": {}
259
+ },
260
+ "required": false,
261
+ "optional": false,
262
+ "docs": {
263
+ "tags": [],
264
+ "text": ""
265
+ },
266
+ "attribute": "email-label",
267
+ "reflect": false,
268
+ "defaultValue": "salla.lang.get('common.elements.email')"
269
+ },
270
+ "enterText": {
271
+ "type": "string",
272
+ "mutable": false,
273
+ "complexType": {
274
+ "original": "string",
275
+ "resolved": "string",
276
+ "references": {}
277
+ },
278
+ "required": false,
279
+ "optional": false,
280
+ "docs": {
281
+ "tags": [],
282
+ "text": ""
283
+ },
284
+ "attribute": "enter-text",
285
+ "reflect": false,
286
+ "defaultValue": "salla.lang.get('blocks.header.enter')"
287
+ },
288
+ "bySMSText": {
289
+ "type": "string",
290
+ "mutable": false,
291
+ "complexType": {
292
+ "original": "string",
293
+ "resolved": "string",
294
+ "references": {}
295
+ },
296
+ "required": false,
297
+ "optional": false,
298
+ "docs": {
299
+ "tags": [],
300
+ "text": ""
301
+ },
302
+ "attribute": "by-s-m-s-text",
303
+ "reflect": false,
304
+ "defaultValue": "salla.lang.get('blocks.header.login_by_sms')"
305
+ },
306
+ "byEmailText": {
307
+ "type": "string",
308
+ "mutable": false,
309
+ "complexType": {
310
+ "original": "string",
311
+ "resolved": "string",
312
+ "references": {}
313
+ },
314
+ "required": false,
315
+ "optional": false,
316
+ "docs": {
317
+ "tags": [],
318
+ "text": ""
319
+ },
320
+ "attribute": "by-email-text",
321
+ "reflect": false,
322
+ "defaultValue": "salla.lang.get('blocks.header.login_by_email')"
323
+ },
324
+ "backText": {
325
+ "type": "string",
326
+ "mutable": false,
327
+ "complexType": {
328
+ "original": "string",
329
+ "resolved": "string",
330
+ "references": {}
331
+ },
332
+ "required": false,
333
+ "optional": false,
334
+ "docs": {
335
+ "tags": [],
336
+ "text": ""
337
+ },
338
+ "attribute": "back-text",
339
+ "reflect": false,
340
+ "defaultValue": "salla.lang.get('common.elements.back')"
341
+ }
342
+ }; }
343
+ static get methods() { return {
344
+ "show": {
345
+ "complexType": {
346
+ "signature": "() => Promise<HTMLElement>",
347
+ "parameters": [],
348
+ "references": {
349
+ "Promise": {
350
+ "location": "global"
351
+ },
352
+ "HTMLElement": {
353
+ "location": "global"
354
+ }
355
+ },
356
+ "return": "Promise<HTMLElement>"
357
+ },
358
+ "docs": {
359
+ "text": "",
360
+ "tags": []
361
+ }
362
+ }
363
+ }; }
364
+ static get elementRef() { return "host"; }
365
+ static get listeners() { return [{
366
+ "name": "verified",
367
+ "method": "onVerified",
368
+ "target": undefined,
369
+ "capture": false,
370
+ "passive": false
371
+ }, {
372
+ "name": "backClicked",
373
+ "method": "onbackClicked",
374
+ "target": undefined,
375
+ "capture": false,
376
+ "passive": false
377
+ }]; }
378
+ }