@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.
Files changed (62) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-branches.cjs.entry.js +5 -6
  4. package/dist/cjs/salla-button_7.cjs.entry.js +143 -52
  5. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -0
  6. package/dist/cjs/salla-offer.cjs.entry.js +10 -2
  7. package/dist/cjs/salla-product-availability.cjs.entry.js +6 -0
  8. package/dist/cjs/salla-rating.cjs.entry.js +12 -2
  9. package/dist/cjs/{salla-search-62921989.js → salla-search-6738ec5e.js} +11 -10
  10. package/dist/cjs/twilight-components.cjs.js +1 -1
  11. package/dist/collection/components/salla-branches/salla-branches.js +6 -8
  12. package/dist/collection/components/salla-button/salla-button.js +62 -26
  13. package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +4 -1
  14. package/dist/collection/components/salla-localization/salla-localization.js +11 -5
  15. package/dist/collection/components/salla-login/salla-login.js +32 -17
  16. package/dist/collection/components/salla-modal/salla-modal.js +84 -47
  17. package/dist/collection/components/salla-offer/salla-offer.js +29 -9
  18. package/dist/collection/components/salla-product-availability/salla-product-availability.js +11 -5
  19. package/dist/collection/components/salla-rating/salla-rating.js +35 -5
  20. package/dist/collection/components/salla-search/salla-search.js +3 -0
  21. package/dist/collection/components/salla-tel-input/salla-tel-input.js +30 -14
  22. package/dist/collection/components/salla-verify/salla-verify.js +43 -50
  23. package/dist/collection/plugins/tailwind-theme/index.js +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/salla-branches.entry.js +5 -6
  27. package/dist/esm/salla-button_7.entry.js +143 -52
  28. package/dist/esm/salla-infinite-scroll.entry.js +3 -0
  29. package/dist/esm/salla-offer.entry.js +10 -2
  30. package/dist/esm/salla-product-availability.entry.js +6 -0
  31. package/dist/esm/salla-rating.entry.js +12 -2
  32. package/dist/esm/{salla-search-96520d15.js → salla-search-90231876.js} +11 -10
  33. package/dist/esm/twilight-components.js +1 -1
  34. package/dist/twilight-components/index.esm.js +1 -1
  35. package/dist/twilight-components/p-2abf9fc5.js +1 -0
  36. package/dist/twilight-components/p-dd9469a1.entry.js +1 -0
  37. package/dist/twilight-components/p-ebc6e474.entry.js +1 -0
  38. package/dist/twilight-components/p-f36fa4c6.entry.js +1 -0
  39. package/dist/twilight-components/twilight-components.esm.js +1 -1
  40. package/dist/types/components/salla-branches/salla-branches.d.ts +0 -1
  41. package/dist/types/components/salla-button/salla-button.d.ts +32 -1
  42. package/dist/types/components/salla-infinite-scroll/salla-infinite-scroll.d.ts +3 -0
  43. package/dist/types/components/salla-localization/salla-localization.d.ts +6 -0
  44. package/dist/types/components/salla-login/salla-login.d.ts +14 -1
  45. package/dist/types/components/salla-modal/salla-modal.d.ts +37 -2
  46. package/dist/types/components/salla-offer/salla-offer.d.ts +9 -1
  47. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +10 -1
  48. package/dist/types/components/salla-rating/salla-rating.d.ts +10 -0
  49. package/dist/types/components/salla-search/salla-search.d.ts +3 -0
  50. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +15 -1
  51. package/dist/types/components/salla-verify/salla-verify.d.ts +26 -4
  52. package/dist/types/components.d.ts +209 -10
  53. package/example/.DS_Store +0 -0
  54. package/example/dist/.DS_Store +0 -0
  55. package/example/dist/twilight.js +1 -1
  56. package/example/index.html +2 -2
  57. package/example/products/search +13 -0
  58. package/package.json +1 -1
  59. package/dist/twilight-components/p-352ce785.js +0 -1
  60. package/dist/twilight-components/p-9cabc8a4.entry.js +0 -1
  61. package/dist/twilight-components/p-a841c013.entry.js +0 -1
  62. package/dist/twilight-components/p-fbfd14a6.entry.js +0 -1
@@ -1,32 +1,47 @@
1
1
  import { Component, h, Prop, Host, Element, Event, Watch, Method, State } from '@stencil/core';
2
2
  import Helper from "../../Helpers/Helper";
3
3
  /**
4
- * @slot body - The content of modal
5
4
  * @slot footer - The footer of modal
6
5
  */
7
6
  export class SallaModal {
8
7
  constructor() {
9
- var _a;
10
8
  //todo:: unite three colors (error, success, primary) in one prop
11
9
  this.error = false;
12
10
  this.success = false;
13
11
  this.primary = false;
14
- this.isClosable = true;
12
+ this.isClosable = true; //todo::rename unclude
13
+ /**
14
+ * The size of the modal
15
+ */
15
16
  this.width = 'md';
16
- this.position = 'middel';
17
+ /**
18
+ * The position of the modal
19
+ */
20
+ this.position = 'middle';
21
+ /**
22
+ * Show the modal on rendering
23
+ */
17
24
  this.visible = false;
25
+ /**
26
+ * Show loading in the middle
27
+ */
18
28
  this.isLoading = false;
19
- this.subTitleFirst = false;
20
- this.noPadding = false;
29
+ this.subTitleFirst = false; //todo:: choose better name
30
+ this.noPadding = false; //todo:: choose better name
21
31
  this.subTitle = '';
32
+ /**
33
+ * Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
34
+ */
22
35
  this.icon = '';
36
+ /**
37
+ * url of an image
38
+ */
23
39
  this.imageIcon = '';
24
40
  Helper.setHost(this.host);
25
41
  salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
26
42
  salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
27
43
  this.title = this.host.title;
28
44
  this.host.removeAttribute('title');
29
- (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
30
45
  }
31
46
  handleVisible(newValue) {
32
47
  if (!newValue) {
@@ -38,30 +53,44 @@ export class SallaModal {
38
53
  setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
39
54
  this.modalOpened.emit();
40
55
  }
56
+ /**
57
+ * Show the modal
58
+ */
41
59
  async show() {
42
60
  this.host.setAttribute('visible', '');
43
61
  return this.host;
44
62
  }
63
+ /**
64
+ * hide the modal
65
+ */
45
66
  async hide() {
46
67
  this.host.removeAttribute('visible');
47
68
  return this.host;
48
69
  }
70
+ /**
71
+ * Change the title
72
+ * @param {string} title
73
+ */
49
74
  async setTitle(title) {
50
75
  this.title = title;
51
76
  return this.host;
52
77
  }
78
+ /**
79
+ * Start loading
80
+ */
53
81
  async loading() {
54
82
  this.isLoading = true;
55
83
  return this.host;
56
84
  }
85
+ /**
86
+ * Stop the loading
87
+ */
57
88
  async stopLoading() {
58
89
  this.isLoading = false;
59
90
  return this.host;
60
91
  }
61
92
  toggleModal(isOpen) {
62
- Helper
63
- // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
64
- .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
93
+ Helper.toggleElement(this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
65
94
  .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
66
95
  //todo:: use united class names
67
96
  .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
@@ -75,16 +104,32 @@ export class SallaModal {
75
104
  }
76
105
  this.host.removeAttribute('visible');
77
106
  }
107
+ iconBlockClasses() {
108
+ return {
109
+ 's-modal-icon': true,
110
+ 's-modal-bg-error': this.error,
111
+ 's-modal-bg-success': this.success,
112
+ 's-modal-bg-normal': !this.error && !this.success,
113
+ 's-modal-bg-primary': this.primary
114
+ };
115
+ }
116
+ iconClasses() {
117
+ return {
118
+ [this.icon]: true,
119
+ 's-modal-text-error': this.error,
120
+ 's-modal-text-success': this.success,
121
+ 'sicon-alert-engine': !this.icon && this.error && !this.imageIcon,
122
+ 'sicon-check-circle2': !this.icon && this.success && !this.imageIcon,
123
+ };
124
+ }
78
125
  //todo:: pref for each modal
79
126
  render() {
80
127
  this.host.id = this.host.id || 'salla-modal';
81
- return (
82
- //todo:: use suitable class name instead of hidden
83
- h(Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" },
128
+ return (h(Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" },
84
129
  h("div", { class: "s-modal-wrapper" },
85
130
  h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }),
86
131
  h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"),
87
- 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
132
+ 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
88
133
  ? h("div", { class: "s-modal-loader-wrap" },
89
134
  h("span", { class: "s-modal-loader" }))
90
135
  :
@@ -96,23 +141,9 @@ export class SallaModal {
96
141
  this.title || this.subTitle ?
97
142
  h("div", { class: "s-modal-header-inner" },
98
143
  this.error || this.success || this.icon
99
- ? h("div", { class: {
100
- 's-modal-icon': true,
101
- 's-modal-bg-error': this.error,
102
- 's-modal-bg-success': this.success,
103
- 's-modal-bg-normal': !this.error && !this.success,
104
- 's-modal-bg-primary': this.primary
105
- } },
106
- h("i", { class: {
107
- [this.icon]: true,
108
- 's-modal-text-error': this.error,
109
- 's-modal-text-success': this.success,
110
- 'sicon-alert-engine': !this.icon && this.error,
111
- 'sicon-check-circle2': !this.icon && this.success,
112
- } }))
113
- : this.imageIcon ?
114
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
115
- : '',
144
+ ? h("div", { class: this.iconBlockClasses() },
145
+ h("i", { class: this.iconClasses() }))
146
+ : this.imageIcon ? h("img", { class: "s-modal-header-img", src: this.imageIcon }) : '',
116
147
  h("div", { class: "s-modal-header-content" },
117
148
  h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }),
118
149
  h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
@@ -213,7 +244,7 @@ export class SallaModal {
213
244
  "optional": false,
214
245
  "docs": {
215
246
  "tags": [],
216
- "text": ""
247
+ "text": "The size of the modal"
217
248
  },
218
249
  "attribute": "width",
219
250
  "reflect": true,
@@ -223,19 +254,19 @@ export class SallaModal {
223
254
  "type": "string",
224
255
  "mutable": false,
225
256
  "complexType": {
226
- "original": "'top' | 'middel' | 'bottom'",
227
- "resolved": "\"bottom\" | \"middel\" | \"top\"",
257
+ "original": "'top' | 'middle' | 'bottom'",
258
+ "resolved": "\"bottom\" | \"middle\" | \"top\"",
228
259
  "references": {}
229
260
  },
230
261
  "required": false,
231
262
  "optional": false,
232
263
  "docs": {
233
264
  "tags": [],
234
- "text": ""
265
+ "text": "The position of the modal"
235
266
  },
236
267
  "attribute": "position",
237
268
  "reflect": true,
238
- "defaultValue": "'middel'"
269
+ "defaultValue": "'middle'"
239
270
  },
240
271
  "visible": {
241
272
  "type": "boolean",
@@ -249,7 +280,7 @@ export class SallaModal {
249
280
  "optional": false,
250
281
  "docs": {
251
282
  "tags": [],
252
- "text": ""
283
+ "text": "Show the modal on rendering"
253
284
  },
254
285
  "attribute": "visible",
255
286
  "reflect": true,
@@ -267,7 +298,7 @@ export class SallaModal {
267
298
  "optional": false,
268
299
  "docs": {
269
300
  "tags": [],
270
- "text": ""
301
+ "text": "Show loading in the middle"
271
302
  },
272
303
  "attribute": "is-loading",
273
304
  "reflect": true,
@@ -339,7 +370,7 @@ export class SallaModal {
339
370
  "optional": false,
340
371
  "docs": {
341
372
  "tags": [],
342
- "text": ""
373
+ "text": "Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`"
343
374
  },
344
375
  "attribute": "icon",
345
376
  "reflect": false,
@@ -357,7 +388,7 @@ export class SallaModal {
357
388
  "optional": false,
358
389
  "docs": {
359
390
  "tags": [],
360
- "text": ""
391
+ "text": "url of an image"
361
392
  },
362
393
  "attribute": "image-icon",
363
394
  "reflect": false,
@@ -414,7 +445,7 @@ export class SallaModal {
414
445
  "return": "Promise<HTMLElement>"
415
446
  },
416
447
  "docs": {
417
- "text": "",
448
+ "text": "Show the modal",
418
449
  "tags": []
419
450
  }
420
451
  },
@@ -433,7 +464,7 @@ export class SallaModal {
433
464
  "return": "Promise<HTMLElement>"
434
465
  },
435
466
  "docs": {
436
- "text": "",
467
+ "text": "hide the modal",
437
468
  "tags": []
438
469
  }
439
470
  },
@@ -441,7 +472,10 @@ export class SallaModal {
441
472
  "complexType": {
442
473
  "signature": "(title: any) => Promise<HTMLElement>",
443
474
  "parameters": [{
444
- "tags": [],
475
+ "tags": [{
476
+ "text": "title",
477
+ "name": "param"
478
+ }],
445
479
  "text": ""
446
480
  }],
447
481
  "references": {
@@ -455,8 +489,11 @@ export class SallaModal {
455
489
  "return": "Promise<HTMLElement>"
456
490
  },
457
491
  "docs": {
458
- "text": "",
459
- "tags": []
492
+ "text": "Change the title",
493
+ "tags": [{
494
+ "name": "param",
495
+ "text": "title"
496
+ }]
460
497
  }
461
498
  },
462
499
  "loading": {
@@ -474,7 +511,7 @@ export class SallaModal {
474
511
  "return": "Promise<HTMLElement>"
475
512
  },
476
513
  "docs": {
477
- "text": "",
514
+ "text": "Start loading",
478
515
  "tags": []
479
516
  }
480
517
  },
@@ -493,7 +530,7 @@ export class SallaModal {
493
530
  "return": "Promise<HTMLElement>"
494
531
  },
495
532
  "docs": {
496
- "text": "",
533
+ "text": "Stop the loading",
497
534
  "tags": []
498
535
  }
499
536
  }
@@ -22,10 +22,18 @@ export class SallaOffer {
22
22
  this.show(data.product_id);
23
23
  });
24
24
  }
25
- async show(productId) {
25
+ /**
26
+ * Show the available offers for the product
27
+ * @param product_id
28
+ */
29
+ async show(product_id) {
26
30
  //TODO:: make sure there is only one offer
27
- return salla.api.offer.details(productId).then(response => this.offer = response.data[0]);
31
+ return salla.api.offer.details(product_id).then(response => this.offer = response.data[0]);
28
32
  }
33
+ /**
34
+ * Show offer details
35
+ * @param {Offer} offer
36
+ */
29
37
  async showOffer(offer) {
30
38
  this.offer = offer;
31
39
  return this.modal.show();
@@ -90,9 +98,12 @@ export class SallaOffer {
90
98
  static get methods() { return {
91
99
  "show": {
92
100
  "complexType": {
93
- "signature": "(productId: number) => Promise<any>",
101
+ "signature": "(product_id: number) => Promise<any>",
94
102
  "parameters": [{
95
- "tags": [],
103
+ "tags": [{
104
+ "text": "product_id",
105
+ "name": "param"
106
+ }],
96
107
  "text": ""
97
108
  }],
98
109
  "references": {
@@ -103,15 +114,21 @@ export class SallaOffer {
103
114
  "return": "Promise<any>"
104
115
  },
105
116
  "docs": {
106
- "text": "",
107
- "tags": []
117
+ "text": "Show the available offers for the product",
118
+ "tags": [{
119
+ "name": "param",
120
+ "text": "product_id"
121
+ }]
108
122
  }
109
123
  },
110
124
  "showOffer": {
111
125
  "complexType": {
112
126
  "signature": "(offer: any) => Promise<HTMLElement>",
113
127
  "parameters": [{
114
- "tags": [],
128
+ "tags": [{
129
+ "text": "offer",
130
+ "name": "param"
131
+ }],
115
132
  "text": ""
116
133
  }],
117
134
  "references": {
@@ -125,8 +142,11 @@ export class SallaOffer {
125
142
  "return": "Promise<HTMLElement>"
126
143
  },
127
144
  "docs": {
128
- "text": "",
129
- "tags": []
145
+ "text": "Show offer details",
146
+ "tags": [{
147
+ "name": "param",
148
+ "text": "offer"
149
+ }]
130
150
  }
131
151
  }
132
152
  }; }
@@ -3,7 +3,13 @@ import Helper from "../../Helpers/Helper";
3
3
  export class SallaProductAvailability {
4
4
  constructor() {
5
5
  this.isUser = Helper.isUser();
6
+ /**
7
+ * product id that can visitor subscribe to its availability notification
8
+ */
6
9
  this.productId = salla.config.get('page.id');
10
+ /**
11
+ * is current user already subscribed
12
+ */
7
13
  this.isSubscribed = false;
8
14
  // @Method()
9
15
  this.submit = async () => {
@@ -105,15 +111,15 @@ export class SallaProductAvailability {
105
111
  "type": "string",
106
112
  "mutable": false,
107
113
  "complexType": {
108
- "original": "string",
109
- "resolved": "string",
114
+ "original": "'sms' | 'mobile' | 'sms,mobile'",
115
+ "resolved": "\"mobile\" | \"sms\" | \"sms,mobile\"",
110
116
  "references": {}
111
117
  },
112
118
  "required": false,
113
119
  "optional": false,
114
120
  "docs": {
115
121
  "tags": [],
116
- "text": ""
122
+ "text": "Notification channels"
117
123
  },
118
124
  "attribute": "channels",
119
125
  "reflect": false
@@ -130,7 +136,7 @@ export class SallaProductAvailability {
130
136
  "optional": false,
131
137
  "docs": {
132
138
  "tags": [],
133
- "text": ""
139
+ "text": "product id that can visitor subscribe to its availability notification"
134
140
  },
135
141
  "attribute": "product-id",
136
142
  "reflect": false,
@@ -148,7 +154,7 @@ export class SallaProductAvailability {
148
154
  "optional": false,
149
155
  "docs": {
150
156
  "tags": [],
151
- "text": ""
157
+ "text": "is current user already subscribed"
152
158
  },
153
159
  "attribute": "is-subscribed",
154
160
  "reflect": false,
@@ -1,10 +1,14 @@
1
- import { Component, h, Method, Element, Host, State } from '@stencil/core';
1
+ import { Component, h, Method, Element, Host, State, Prop } from '@stencil/core';
2
2
  import Helper from "../../Helpers/Helper";
3
3
  export class SallaRating {
4
4
  constructor() {
5
5
  this.stepsCount = 0;
6
6
  this.currentIndex = 0;
7
7
  this.submitted = [];
8
+ /**
9
+ * The order id, to rate on its products & shipping
10
+ */
11
+ this.orderId = salla.config.get('page.id');
8
12
  this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
9
13
  this.write_store_rate = salla.lang.get('pages.rating.write_store_rate');
10
14
  this.rate_product_stars = salla.lang.get('pages.rating.rate_product_stars');
@@ -28,14 +32,20 @@ export class SallaRating {
28
32
  this.next = salla.lang.get('common.elements.next');
29
33
  });
30
34
  }
35
+ /**
36
+ * Show the rating modal
37
+ */
31
38
  async show() {
32
39
  return this.modal.show()
33
- .then(() => this.order || salla.feedback.api.order(salla.config.get('page.id')).then(res => this.order = res.data))
40
+ .then(() => this.order || salla.feedback.api.order(this.orderId).then(res => this.order = res.data))
34
41
  .then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
35
42
  .then(() => this.modal.stopLoading())
36
43
  .then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
37
44
  .then(() => setTimeout(() => this.initiateRating(), 100));
38
45
  }
46
+ /**
47
+ * Show the rating modal
48
+ */
39
49
  async hide() {
40
50
  return this.modal.hide();
41
51
  }
@@ -161,7 +171,7 @@ export class SallaRating {
161
171
  if (Object.keys(data).length == 0) {
162
172
  return;
163
173
  }
164
- data['order_id'] = salla.config.get('page.id');
174
+ data['order_id'] = this.orderId;
165
175
  data['type'] = this.currentTab.dataset.type;
166
176
  this.submitted.push(this.currentIndex);
167
177
  return salla.feedback.api[this.currentTab.dataset.type](data);
@@ -255,6 +265,26 @@ export class SallaRating {
255
265
  static get styleUrls() { return {
256
266
  "$": ["salla-rating.css"]
257
267
  }; }
268
+ static get properties() { return {
269
+ "orderId": {
270
+ "type": "number",
271
+ "mutable": false,
272
+ "complexType": {
273
+ "original": "number",
274
+ "resolved": "number",
275
+ "references": {}
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": "The order id, to rate on its products & shipping"
282
+ },
283
+ "attribute": "order-id",
284
+ "reflect": false,
285
+ "defaultValue": "salla.config.get('page.id')"
286
+ }
287
+ }; }
258
288
  static get states() { return {
259
289
  "order": {}
260
290
  }; }
@@ -274,7 +304,7 @@ export class SallaRating {
274
304
  "return": "Promise<Timeout>"
275
305
  },
276
306
  "docs": {
277
- "text": "",
307
+ "text": "Show the rating modal",
278
308
  "tags": []
279
309
  }
280
310
  },
@@ -293,7 +323,7 @@ export class SallaRating {
293
323
  "return": "Promise<HTMLElement>"
294
324
  },
295
325
  "docs": {
296
- "text": "",
326
+ "text": "Show the rating modal",
297
327
  "tags": []
298
328
  }
299
329
  }
@@ -1,5 +1,8 @@
1
1
  import { Component, h, State, Element, Listen } from '@stencil/core';
2
2
  import Helper from "../../Helpers/Helper";
3
+ /**
4
+ * @slot product - Replaces products card in the results, has replaceable props `{name}`, `{price}`, `{name}`.
5
+ */
3
6
  export class SallaSearch {
4
7
  constructor() {
5
8
  var _a;
@@ -3,8 +3,11 @@ import TelInput from "intl-tel-input";
3
3
  import Helper from "../../Helpers/Helper";
4
4
  export class SallaTelInput {
5
5
  constructor() {
6
+ /**
7
+ * Current country_code
8
+ */
6
9
  this.countryCode = salla.config.get('user.country_code', 'SA');
7
- this.countryKey = "+966"; //TODO:: why we need it
10
+ this.countryKey = "+966"; //TODO:: why we need it, if it's important find a way to get it automatically for the current user
8
11
  this.countryCodeLabel = salla.lang.get('common.country_code');
9
12
  this.mobileLabel = salla.lang.get('common.elements.mobile');
10
13
  this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
@@ -24,12 +27,21 @@ export class SallaTelInput {
24
27
  this.errorMap = [this.invalidNumber, this.invalidCountryCode, this.tooShort, this.tooLong, this.invalidNumber];
25
28
  });
26
29
  }
30
+ /**
31
+ * Get current values
32
+ * @return {{mobile:number,countryCode:'SA'|string, countryKey:'+966'|string}}
33
+ */
27
34
  async getValues() {
28
- this.mobile = this.phoneInput.value;
29
- this.countryCode = this.countryCodeInput.value;
30
- this.countryKey = this.countryKeyInput.value;
31
- return { mobile: this.phoneInput.value, countryCode: this.countryCodeInput.value, countryKey: this.countryKeyInput.value };
35
+ return {
36
+ mobile: this.mobile = this.phoneInput.value,
37
+ countryCode: this.countryCode = this.countryCodeInput.value,
38
+ countryKey: this.countryKey = this.countryKeyInput.value
39
+ };
32
40
  }
41
+ /**
42
+ * Is current data valid or not
43
+ * @return {boolean}
44
+ */
33
45
  async isValid() {
34
46
  this.reset();
35
47
  if (this.iti.isValidNumber())
@@ -62,9 +74,7 @@ export class SallaTelInput {
62
74
  });
63
75
  });
64
76
  // on blur: validate
65
- this.phoneInput.addEventListener('blur', () => {
66
- this.isValid();
67
- });
77
+ this.phoneInput.addEventListener('blur', () => this.isValid());
68
78
  // on keyup / change flag: reset
69
79
  this.phoneInput.addEventListener('input', e => {
70
80
  salla.helpers.digitsOnly(e.target);
@@ -100,7 +110,7 @@ export class SallaTelInput {
100
110
  "optional": false,
101
111
  "docs": {
102
112
  "tags": [],
103
- "text": ""
113
+ "text": "Current mobile number"
104
114
  },
105
115
  "attribute": "mobile",
106
116
  "reflect": false
@@ -117,7 +127,7 @@ export class SallaTelInput {
117
127
  "optional": false,
118
128
  "docs": {
119
129
  "tags": [],
120
- "text": ""
130
+ "text": "Current country_code"
121
131
  },
122
132
  "attribute": "country-code",
123
133
  "reflect": false,
@@ -181,8 +191,11 @@ export class SallaTelInput {
181
191
  "return": "Promise<{ mobile: string; countryCode: string; countryKey: string; }>"
182
192
  },
183
193
  "docs": {
184
- "text": "",
185
- "tags": []
194
+ "text": "Get current values",
195
+ "tags": [{
196
+ "name": "return",
197
+ "text": undefined
198
+ }]
186
199
  }
187
200
  },
188
201
  "isValid": {
@@ -197,8 +210,11 @@ export class SallaTelInput {
197
210
  "return": "Promise<boolean>"
198
211
  },
199
212
  "docs": {
200
- "text": "",
201
- "tags": []
213
+ "text": "Is current data valid or not",
214
+ "tags": [{
215
+ "name": "return",
216
+ "text": undefined
217
+ }]
202
218
  }
203
219
  }
204
220
  }; }