@salla.sa/twilight-components 1.0.21 → 1.0.22

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 (95) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-714023c8.js +1653 -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 +1727 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-c438bb35.js +128 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +79 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +195 -0
  12. package/dist/cjs/salla-search-45173394.js +85 -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 +380 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +477 -0
  26. package/dist/collection/components/salla-offer/offer-schema.js +1 -0
  27. package/dist/collection/components/salla-offer/salla-offer.js +110 -0
  28. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  29. package/dist/collection/components/salla-rating/order-feedback-response.js +1 -0
  30. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  31. package/dist/collection/components/salla-rating/salla-rating.js +277 -0
  32. package/dist/collection/components/salla-search/salla-search.css +24 -0
  33. package/dist/collection/components/salla-search/salla-search.js +143 -0
  34. package/dist/collection/components/salla-tel-input/salla-tel-input.js +121 -0
  35. package/dist/collection/components/salla-verify/salla-verify.js +280 -0
  36. package/dist/collection/index.js +2 -0
  37. package/dist/collection/interfaces/colors.js +1 -0
  38. package/dist/collection/interfaces/index.js +2 -0
  39. package/dist/collection/interfaces/ratio.js +1 -0
  40. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  41. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  42. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  43. package/dist/esm/index-a1bf769d.js +1625 -0
  44. package/dist/esm/index.js +4 -0
  45. package/dist/esm/loader.js +17 -0
  46. package/dist/esm/polyfills/core-js.js +11 -0
  47. package/dist/esm/polyfills/css-shim.js +1 -0
  48. package/dist/esm/polyfills/dom.js +79 -0
  49. package/dist/esm/polyfills/es5-html-element.js +1 -0
  50. package/dist/esm/polyfills/index.js +34 -0
  51. package/dist/esm/polyfills/system.js +6 -0
  52. package/dist/{twilight-components → esm}/salla-branches.entry.js +2 -2
  53. package/dist/{twilight-components/salla-tel-input.entry.js → esm/salla-button_5.entry.js} +337 -35
  54. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  55. package/dist/{twilight-components/salla-login-57b18c2c.js → esm/salla-login-dd957742.js} +26 -23
  56. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  57. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  58. package/dist/{twilight-components → esm}/salla-rating.entry.js +71 -108
  59. package/dist/{twilight-components/salla-search-30fec1e8.js → esm/salla-search-5e691ebb.js} +15 -11
  60. package/dist/esm/salla-search.entry.js +3 -0
  61. package/dist/esm/twilight-components.js +17 -0
  62. package/dist/index.cjs.js +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/twilight-components/index.esm.js +1 -4
  65. package/dist/twilight-components/p-1a6d8171.entry.js +1 -0
  66. package/dist/twilight-components/p-1deb8111.entry.js +1 -0
  67. package/dist/twilight-components/p-3a4d963e.js +1 -0
  68. package/dist/twilight-components/p-47f17d3b.js +1 -0
  69. package/dist/twilight-components/p-5b2eb87d.entry.js +1 -0
  70. package/dist/twilight-components/p-6a5be894.js +1 -0
  71. package/dist/twilight-components/p-7fbdf746.entry.js +1 -0
  72. package/dist/twilight-components/p-7fe5d346.entry.js +1 -0
  73. package/dist/twilight-components/p-81a61f4e.js +1 -0
  74. package/dist/twilight-components/p-ce991664.entry.js +1 -0
  75. package/dist/twilight-components/p-da73fc9b.entry.js +1 -0
  76. package/dist/twilight-components/twilight-components.css +1 -3
  77. package/dist/twilight-components/twilight-components.esm.js +1 -125
  78. package/dist/types/components/salla-login/salla-login.d.ts +3 -3
  79. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  80. package/dist/types/components/salla-rating/salla-rating.d.ts +6 -23
  81. package/dist/types/components/salla-search/salla-search.d.ts +1 -1
  82. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +14 -0
  83. package/dist/types/components/salla-verify/salla-verify.d.ts +3 -1
  84. package/dist/types/components.d.ts +12 -35
  85. package/package.json +1 -1
  86. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  87. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  88. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  89. package/dist/twilight-components/index-9c087700.js +0 -3010
  90. package/dist/twilight-components/salla-button.entry.js +0 -75
  91. package/dist/twilight-components/salla-login.entry.js +0 -3
  92. package/dist/twilight-components/salla-modal.entry.js +0 -113
  93. package/dist/twilight-components/salla-search.entry.js +0 -3
  94. package/dist/twilight-components/salla-verify.entry.js +0 -114
  95. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,380 @@
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 = 'phone';
6
+ this.isEmailAllowed = 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 == 'phone' ? this.showTab(this.tab2) : this.showTab(this.tab3);
44
+ }
45
+ async show() {
46
+ this.showTab(this.isEmailAllowed ? 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 ? 'phone' : 'email';
55
+ }
56
+ let isRegistrationTab = tab == this.tab5;
57
+ isRegistrationTab && this.firstName.focus();
58
+ this.modal.setTitle(isRegistrationTab ? salla.lang.get('common.titles.registration') : this.title);
59
+ if (!isRegistrationTab) {
60
+ Helper.toggleElement(this.regMobileBlock, 's-hidden', 's-block', () => this.regType === 'phone')
61
+ .toggleElement(this.regEmailBlock, 's-hidden', 's-block', () => this.regType === 'email');
62
+ }
63
+ return this;
64
+ }
65
+ loginByEmail() {
66
+ if (!Helper.isValidEmail(this.email.value)) {
67
+ this.email.classList.add('s-has-error');
68
+ this.email.nextElementSibling['innerText'] = '* ' + salla.lang.get('common.elements.email_is_valid');
69
+ return;
70
+ }
71
+ this.email.nextElementSibling['innerText'] = '';
72
+ this.email.classList.remove('s-has-error');
73
+ salla.auth.api.login({ type: 'email', email: this.email.value })
74
+ .then(() => this.showTab(this.tab4))
75
+ .then(() => (this.tab4.by = 'email') && (this.tab4.url = 'auth/email/verify'))
76
+ .then(() => this.tab4.show({ email: this.email.value }));
77
+ }
78
+ async loginBySMS() {
79
+ const { phone, countryCode } = await this.loginTelInput.getValues();
80
+ if (phone.length < 6) {
81
+ this.loginTelInput.classList.add('s-has-error');
82
+ this.loginTelInput.nextElementSibling['innerText'] = '* ' + salla.lang.get('mobile_app.strings.incorrect_mobile');
83
+ return;
84
+ }
85
+ this.loginTelInput.nextElementSibling['innerText'] = '';
86
+ this.loginTelInput.classList.remove('s-has-error');
87
+ salla.auth.api.login({ type: 'mobile', phone: phone, country_code: countryCode })
88
+ .then(() => this.showTab(this.tab4))
89
+ .then(() => (this.tab4.by = 'sms') && (this.tab4.url = 'auth/mobile/verify'))
90
+ .then(() => this.tab4.show({ phone: phone, country_code: countryCode }));
91
+ }
92
+ //TODO:: if it's enter, go submit
93
+ typing({ target }) {
94
+ target.type === 'tel' && salla.helpers.digitsOnly(target);
95
+ target.classList.remove('s-has-error');
96
+ target.nextElementSibling.innerText = '';
97
+ }
98
+ async newUser() {
99
+ const { phone: regPhone, countryCode, countryKey } = await this.regTelInput.getValues();
100
+ this.tab4.getCode()
101
+ .then(code => salla.auth.api.register({
102
+ first_name: this.firstName.value,
103
+ last_name: this.lastName.value,
104
+ phone: regPhone || this.loginTelInput.phone,
105
+ email: this.regEmail.value || this.email.value,
106
+ country_code: countryCode,
107
+ country_key: countryKey,
108
+ code: code,
109
+ verified_by: this.regType,
110
+ })).then(() => window.location.reload());
111
+ }
112
+ render() {
113
+ return (h("salla-modal", { id: "salla-login", title: this.title, ref: modal => this.modal = modal, width: "xs" },
114
+ h("div", { class: "s-login-wrapper" },
115
+ this.isEmailAllowed ?
116
+ h("div", { class: "s-login-tab", ref: tab => this.tab1 = tab },
117
+ h("p", { class: "s-login-sub-title" }, this.loginTypeTitle),
118
+ h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab2) },
119
+ h("i", { class: "s-login-main-btn-icon sicon-phone" }),
120
+ h("span", { class: "s-login-main-btn-text" }, this.smsLabel),
121
+ h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })),
122
+ h("a", { href: "#", class: "s-login-main-btn", onClick: () => this.showTab(this.tab3) },
123
+ h("i", { class: "s-login-main-btn-icon sicon-mail" }),
124
+ h("span", { class: "s-login-main-btn-text" }, this.emailLabel),
125
+ h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })))
126
+ : '',
127
+ h("div", { class: "s-login-tab", ref: tab => this.tab2 = tab },
128
+ h("label", { class: "s-login-label" }, this.mobileLabel),
129
+ h("salla-tel-input", { phone: '', ref: el => this.loginTelInput = el }),
130
+ h("span", { class: "s-login-error-message" }),
131
+ h("salla-button", { wide: true, onClick: () => this.loginBySMS() }, this.enterText),
132
+ this.isEmailAllowed ? h("a", { href: "#", onClick: () => this.showTab(this.tab3), class: "s-login-link" }, this.byEmailText) : ''),
133
+ this.isEmailAllowed ?
134
+ h("div", { class: "s-login-tab", ref: tab => this.tab3 = tab },
135
+ h("label", { class: "s-login-label" }, this.emailLabel),
136
+ 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" }),
137
+ h("span", { class: "s-login-error-message" }),
138
+ h("salla-button", { wide: true, onClick: () => this.loginByEmail() }, this.enterText),
139
+ h("a", { href: "#", onClick: () => this.showTab(this.tab2), class: "s-login-link" }, this.bySMSText)) : '',
140
+ h("salla-verify", { "without-modal": true, ref: tab => this.tab4 = tab, autoReload: false, "back-text": this.backText }),
141
+ h("div", { ref: tab => this.tab5 = tab },
142
+ h("label", { class: "s-login-label" }, salla.lang.get('blocks.header.your_name')),
143
+ h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, placeholder: salla.lang.get('pages.profile.first_name') }),
144
+ h("label", { class: "s-login-label" }, salla.lang.get('pages.profile.last_name')),
145
+ h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, placeholder: salla.lang.get('pages.profile.last_name') }),
146
+ h("div", { ref: el => this.regMobileBlock = el },
147
+ h("label", { class: "s-login-label" }, this.mobileLabel),
148
+ h("salla-tel-input", { phone: '', ref: el => this.regTelInput = el }),
149
+ h("span", { class: "s-login-error-message" })),
150
+ h("div", { ref: el => this.regEmailBlock = el },
151
+ h("label", { class: "s-login-label" }, this.emailLabel),
152
+ h("input", { type: "email", ref: el => this.regEmail = el, onInput: this.typing, placeholder: "your@email.com", class: "s-login-input s-ltr" }),
153
+ h("span", { class: "s-login-error-message" })),
154
+ h("salla-button", { wide: true, onClick: () => this.newUser() }, salla.lang.get('blocks.header.register'))))));
155
+ }
156
+ static get is() { return "salla-login"; }
157
+ static get originalStyleUrls() { return {
158
+ "$": ["salla-login.css"]
159
+ }; }
160
+ static get styleUrls() { return {
161
+ "$": ["salla-login.css"]
162
+ }; }
163
+ static get properties() { return {
164
+ "isEmailAllowed": {
165
+ "type": "boolean",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "boolean",
169
+ "resolved": "boolean",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": ""
177
+ },
178
+ "attribute": "is-email-allowed",
179
+ "reflect": false,
180
+ "defaultValue": "true"
181
+ },
182
+ "loginTypeTitle": {
183
+ "type": "string",
184
+ "mutable": false,
185
+ "complexType": {
186
+ "original": "string",
187
+ "resolved": "string",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": false,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": ""
195
+ },
196
+ "attribute": "login-type-title",
197
+ "reflect": false,
198
+ "defaultValue": "salla.lang.get('blocks.header.select_login_way')"
199
+ },
200
+ "loginText": {
201
+ "type": "string",
202
+ "mutable": false,
203
+ "complexType": {
204
+ "original": "string",
205
+ "resolved": "string",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": ""
213
+ },
214
+ "attribute": "login-text",
215
+ "reflect": false,
216
+ "defaultValue": "salla.lang.get('blocks.header.login')"
217
+ },
218
+ "smsLabel": {
219
+ "type": "string",
220
+ "mutable": false,
221
+ "complexType": {
222
+ "original": "string",
223
+ "resolved": "string",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [],
230
+ "text": ""
231
+ },
232
+ "attribute": "sms-label",
233
+ "reflect": false,
234
+ "defaultValue": "salla.lang.get('blocks.header.sms')"
235
+ },
236
+ "mobileLabel": {
237
+ "type": "string",
238
+ "mutable": false,
239
+ "complexType": {
240
+ "original": "string",
241
+ "resolved": "string",
242
+ "references": {}
243
+ },
244
+ "required": false,
245
+ "optional": false,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": ""
249
+ },
250
+ "attribute": "mobile-label",
251
+ "reflect": false,
252
+ "defaultValue": "salla.lang.get('common.elements.mobile')"
253
+ },
254
+ "emailLabel": {
255
+ "type": "string",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "string",
259
+ "resolved": "string",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": ""
267
+ },
268
+ "attribute": "email-label",
269
+ "reflect": false,
270
+ "defaultValue": "salla.lang.get('common.elements.email')"
271
+ },
272
+ "enterText": {
273
+ "type": "string",
274
+ "mutable": false,
275
+ "complexType": {
276
+ "original": "string",
277
+ "resolved": "string",
278
+ "references": {}
279
+ },
280
+ "required": false,
281
+ "optional": false,
282
+ "docs": {
283
+ "tags": [],
284
+ "text": ""
285
+ },
286
+ "attribute": "enter-text",
287
+ "reflect": false,
288
+ "defaultValue": "salla.lang.get('blocks.header.enter')"
289
+ },
290
+ "bySMSText": {
291
+ "type": "string",
292
+ "mutable": false,
293
+ "complexType": {
294
+ "original": "string",
295
+ "resolved": "string",
296
+ "references": {}
297
+ },
298
+ "required": false,
299
+ "optional": false,
300
+ "docs": {
301
+ "tags": [],
302
+ "text": ""
303
+ },
304
+ "attribute": "by-s-m-s-text",
305
+ "reflect": false,
306
+ "defaultValue": "salla.lang.get('blocks.header.login_by_sms')"
307
+ },
308
+ "byEmailText": {
309
+ "type": "string",
310
+ "mutable": false,
311
+ "complexType": {
312
+ "original": "string",
313
+ "resolved": "string",
314
+ "references": {}
315
+ },
316
+ "required": false,
317
+ "optional": false,
318
+ "docs": {
319
+ "tags": [],
320
+ "text": ""
321
+ },
322
+ "attribute": "by-email-text",
323
+ "reflect": false,
324
+ "defaultValue": "salla.lang.get('blocks.header.login_by_email')"
325
+ },
326
+ "backText": {
327
+ "type": "string",
328
+ "mutable": false,
329
+ "complexType": {
330
+ "original": "string",
331
+ "resolved": "string",
332
+ "references": {}
333
+ },
334
+ "required": false,
335
+ "optional": false,
336
+ "docs": {
337
+ "tags": [],
338
+ "text": ""
339
+ },
340
+ "attribute": "back-text",
341
+ "reflect": false,
342
+ "defaultValue": "salla.lang.get('common.elements.back')"
343
+ }
344
+ }; }
345
+ static get methods() { return {
346
+ "show": {
347
+ "complexType": {
348
+ "signature": "() => Promise<HTMLElement>",
349
+ "parameters": [],
350
+ "references": {
351
+ "Promise": {
352
+ "location": "global"
353
+ },
354
+ "HTMLElement": {
355
+ "location": "global"
356
+ }
357
+ },
358
+ "return": "Promise<HTMLElement>"
359
+ },
360
+ "docs": {
361
+ "text": "",
362
+ "tags": []
363
+ }
364
+ }
365
+ }; }
366
+ static get elementRef() { return "host"; }
367
+ static get listeners() { return [{
368
+ "name": "verified",
369
+ "method": "onVerified",
370
+ "target": undefined,
371
+ "capture": false,
372
+ "passive": false
373
+ }, {
374
+ "name": "backClicked",
375
+ "method": "onbackClicked",
376
+ "target": undefined,
377
+ "capture": false,
378
+ "passive": false
379
+ }]; }
380
+ }