@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,477 @@
1
+ import { Component, h, Prop, Host, Element, Event, Watch, Method, State } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ /**
4
+ * @slot body - The content of modal
5
+ * @slot footer - The footer of modal
6
+ */
7
+ export class SallaModal {
8
+ constructor() {
9
+ var _a;
10
+ //todo:: unite three colors (error, success, primary) in one prop
11
+ this.error = false;
12
+ this.success = false;
13
+ this.primary = false;
14
+ this.isClosable = true;
15
+ this.width = 'md';
16
+ this.position = 'middel';
17
+ this.visible = false;
18
+ this.isLoading = false;
19
+ this.subTitleFirst = false;
20
+ this.subTitle = '';
21
+ this.icon = '';
22
+ this.imageIcon = '';
23
+ Helper.setHost(this.host);
24
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
25
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
26
+ this.title = this.host.title;
27
+ this.host.removeAttribute('title');
28
+ (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
29
+ }
30
+ handleVisible(newValue) {
31
+ if (!newValue) {
32
+ this.toggleModal(false);
33
+ this.modalClosed.emit();
34
+ return;
35
+ }
36
+ this.host.classList.remove('hidden');
37
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
38
+ this.modalOpened.emit();
39
+ }
40
+ async show() {
41
+ this.host.setAttribute('visible', '');
42
+ return this.host;
43
+ }
44
+ async hide() {
45
+ this.host.removeAttribute('visible');
46
+ return this.host;
47
+ }
48
+ async setTitle(title) {
49
+ this.title = title;
50
+ return this.host;
51
+ }
52
+ async loading() {
53
+ this.isLoading = true;
54
+ return this.host;
55
+ }
56
+ async stopLoading() {
57
+ this.isLoading = false;
58
+ return this.host;
59
+ }
60
+ toggleModal(isOpen) {
61
+ Helper
62
+ // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
63
+ .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
64
+ .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
65
+ //todo:: use united class names
66
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
67
+ if (!isOpen) {
68
+ setTimeout(() => this.host.classList.add('hidden'), 350);
69
+ }
70
+ }
71
+ closeModal() {
72
+ if (!this.isClosable) {
73
+ return;
74
+ }
75
+ this.host.removeAttribute('visible');
76
+ }
77
+ //todo:: pref for each modal
78
+ render() {
79
+ this.host.id = this.host.id || 'salla-modal';
80
+ return (
81
+ //todo:: use suitable class name instead of hidden
82
+ h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" },
83
+ h("div", { class: "s-modal-wrapper" },
84
+ h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }),
85
+ h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"),
86
+ h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width, slot: "body" }, this.isLoading
87
+ ? h("span", null, "Loading...")
88
+ :
89
+ [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } },
90
+ this.isClosable ?
91
+ h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" },
92
+ h("span", { class: "sicon-cancel" }))
93
+ : '',
94
+ this.error || this.success || this.icon
95
+ ? h("div", { class: {
96
+ 's-modal-icon': true,
97
+ 's-modal-bg-error': this.error,
98
+ 's-modal-bg-success': this.success,
99
+ 's-modal-bg-normal': !this.error && !this.success,
100
+ 's-modal-bg-primary': this.primary
101
+ } },
102
+ h("i", { class: {
103
+ [this.icon]: true,
104
+ 's-modal-text-error': this.error,
105
+ 's-modal-text-success': this.success,
106
+ } }))
107
+ : this.imageIcon ?
108
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
109
+ : '',
110
+ this.title || this.subTitle ?
111
+ h("div", { class: "s-modal-header-content" },
112
+ h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }),
113
+ h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
114
+ : ''),
115
+ h("slot", null),
116
+ h("slot", { name: "footer" })
117
+ ]))));
118
+ }
119
+ static get is() { return "salla-modal"; }
120
+ static get properties() { return {
121
+ "error": {
122
+ "type": "boolean",
123
+ "mutable": false,
124
+ "complexType": {
125
+ "original": "boolean",
126
+ "resolved": "boolean",
127
+ "references": {}
128
+ },
129
+ "required": false,
130
+ "optional": false,
131
+ "docs": {
132
+ "tags": [],
133
+ "text": ""
134
+ },
135
+ "attribute": "error",
136
+ "reflect": false,
137
+ "defaultValue": "false"
138
+ },
139
+ "success": {
140
+ "type": "boolean",
141
+ "mutable": false,
142
+ "complexType": {
143
+ "original": "boolean",
144
+ "resolved": "boolean",
145
+ "references": {}
146
+ },
147
+ "required": false,
148
+ "optional": false,
149
+ "docs": {
150
+ "tags": [],
151
+ "text": ""
152
+ },
153
+ "attribute": "success",
154
+ "reflect": false,
155
+ "defaultValue": "false"
156
+ },
157
+ "primary": {
158
+ "type": "boolean",
159
+ "mutable": false,
160
+ "complexType": {
161
+ "original": "boolean",
162
+ "resolved": "boolean",
163
+ "references": {}
164
+ },
165
+ "required": false,
166
+ "optional": false,
167
+ "docs": {
168
+ "tags": [],
169
+ "text": ""
170
+ },
171
+ "attribute": "primary",
172
+ "reflect": false,
173
+ "defaultValue": "false"
174
+ },
175
+ "isClosable": {
176
+ "type": "boolean",
177
+ "mutable": true,
178
+ "complexType": {
179
+ "original": "boolean",
180
+ "resolved": "boolean",
181
+ "references": {}
182
+ },
183
+ "required": false,
184
+ "optional": false,
185
+ "docs": {
186
+ "tags": [],
187
+ "text": ""
188
+ },
189
+ "attribute": "is-closable",
190
+ "reflect": false,
191
+ "defaultValue": "true"
192
+ },
193
+ "width": {
194
+ "type": "string",
195
+ "mutable": false,
196
+ "complexType": {
197
+ "original": "'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full'",
198
+ "resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"",
199
+ "references": {}
200
+ },
201
+ "required": false,
202
+ "optional": false,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": ""
206
+ },
207
+ "attribute": "width",
208
+ "reflect": true,
209
+ "defaultValue": "'md'"
210
+ },
211
+ "position": {
212
+ "type": "string",
213
+ "mutable": false,
214
+ "complexType": {
215
+ "original": "'top' | 'middel' | 'bottom'",
216
+ "resolved": "\"bottom\" | \"middel\" | \"top\"",
217
+ "references": {}
218
+ },
219
+ "required": false,
220
+ "optional": false,
221
+ "docs": {
222
+ "tags": [],
223
+ "text": ""
224
+ },
225
+ "attribute": "position",
226
+ "reflect": true,
227
+ "defaultValue": "'middel'"
228
+ },
229
+ "visible": {
230
+ "type": "boolean",
231
+ "mutable": false,
232
+ "complexType": {
233
+ "original": "boolean",
234
+ "resolved": "boolean",
235
+ "references": {}
236
+ },
237
+ "required": false,
238
+ "optional": false,
239
+ "docs": {
240
+ "tags": [],
241
+ "text": ""
242
+ },
243
+ "attribute": "visible",
244
+ "reflect": true,
245
+ "defaultValue": "false"
246
+ },
247
+ "isLoading": {
248
+ "type": "boolean",
249
+ "mutable": true,
250
+ "complexType": {
251
+ "original": "boolean",
252
+ "resolved": "boolean",
253
+ "references": {}
254
+ },
255
+ "required": false,
256
+ "optional": false,
257
+ "docs": {
258
+ "tags": [],
259
+ "text": ""
260
+ },
261
+ "attribute": "is-loading",
262
+ "reflect": true,
263
+ "defaultValue": "false"
264
+ },
265
+ "subTitleFirst": {
266
+ "type": "boolean",
267
+ "mutable": false,
268
+ "complexType": {
269
+ "original": "boolean",
270
+ "resolved": "boolean",
271
+ "references": {}
272
+ },
273
+ "required": false,
274
+ "optional": false,
275
+ "docs": {
276
+ "tags": [],
277
+ "text": ""
278
+ },
279
+ "attribute": "sub-title-first",
280
+ "reflect": false,
281
+ "defaultValue": "false"
282
+ },
283
+ "subTitle": {
284
+ "type": "string",
285
+ "mutable": false,
286
+ "complexType": {
287
+ "original": "string",
288
+ "resolved": "string",
289
+ "references": {}
290
+ },
291
+ "required": false,
292
+ "optional": false,
293
+ "docs": {
294
+ "tags": [],
295
+ "text": ""
296
+ },
297
+ "attribute": "sub-title",
298
+ "reflect": false,
299
+ "defaultValue": "''"
300
+ },
301
+ "icon": {
302
+ "type": "string",
303
+ "mutable": false,
304
+ "complexType": {
305
+ "original": "string",
306
+ "resolved": "string",
307
+ "references": {}
308
+ },
309
+ "required": false,
310
+ "optional": false,
311
+ "docs": {
312
+ "tags": [],
313
+ "text": ""
314
+ },
315
+ "attribute": "icon",
316
+ "reflect": false,
317
+ "defaultValue": "''"
318
+ },
319
+ "imageIcon": {
320
+ "type": "string",
321
+ "mutable": false,
322
+ "complexType": {
323
+ "original": "string",
324
+ "resolved": "string",
325
+ "references": {}
326
+ },
327
+ "required": false,
328
+ "optional": false,
329
+ "docs": {
330
+ "tags": [],
331
+ "text": ""
332
+ },
333
+ "attribute": "image-icon",
334
+ "reflect": false,
335
+ "defaultValue": "''"
336
+ }
337
+ }; }
338
+ static get states() { return {
339
+ "title": {}
340
+ }; }
341
+ static get events() { return [{
342
+ "method": "modalOpened",
343
+ "name": "modalOpened",
344
+ "bubbles": true,
345
+ "cancelable": true,
346
+ "composed": true,
347
+ "docs": {
348
+ "tags": [],
349
+ "text": ""
350
+ },
351
+ "complexType": {
352
+ "original": "any",
353
+ "resolved": "any",
354
+ "references": {}
355
+ }
356
+ }, {
357
+ "method": "modalClosed",
358
+ "name": "modalClosed",
359
+ "bubbles": true,
360
+ "cancelable": true,
361
+ "composed": true,
362
+ "docs": {
363
+ "tags": [],
364
+ "text": ""
365
+ },
366
+ "complexType": {
367
+ "original": "any",
368
+ "resolved": "any",
369
+ "references": {}
370
+ }
371
+ }]; }
372
+ static get methods() { return {
373
+ "show": {
374
+ "complexType": {
375
+ "signature": "() => Promise<HTMLElement>",
376
+ "parameters": [],
377
+ "references": {
378
+ "Promise": {
379
+ "location": "global"
380
+ },
381
+ "HTMLElement": {
382
+ "location": "global"
383
+ }
384
+ },
385
+ "return": "Promise<HTMLElement>"
386
+ },
387
+ "docs": {
388
+ "text": "",
389
+ "tags": []
390
+ }
391
+ },
392
+ "hide": {
393
+ "complexType": {
394
+ "signature": "() => Promise<HTMLElement>",
395
+ "parameters": [],
396
+ "references": {
397
+ "Promise": {
398
+ "location": "global"
399
+ },
400
+ "HTMLElement": {
401
+ "location": "global"
402
+ }
403
+ },
404
+ "return": "Promise<HTMLElement>"
405
+ },
406
+ "docs": {
407
+ "text": "",
408
+ "tags": []
409
+ }
410
+ },
411
+ "setTitle": {
412
+ "complexType": {
413
+ "signature": "(title: any) => Promise<HTMLElement>",
414
+ "parameters": [{
415
+ "tags": [],
416
+ "text": ""
417
+ }],
418
+ "references": {
419
+ "Promise": {
420
+ "location": "global"
421
+ },
422
+ "HTMLElement": {
423
+ "location": "global"
424
+ }
425
+ },
426
+ "return": "Promise<HTMLElement>"
427
+ },
428
+ "docs": {
429
+ "text": "",
430
+ "tags": []
431
+ }
432
+ },
433
+ "loading": {
434
+ "complexType": {
435
+ "signature": "() => Promise<HTMLElement>",
436
+ "parameters": [],
437
+ "references": {
438
+ "Promise": {
439
+ "location": "global"
440
+ },
441
+ "HTMLElement": {
442
+ "location": "global"
443
+ }
444
+ },
445
+ "return": "Promise<HTMLElement>"
446
+ },
447
+ "docs": {
448
+ "text": "",
449
+ "tags": []
450
+ }
451
+ },
452
+ "stopLoading": {
453
+ "complexType": {
454
+ "signature": "() => Promise<HTMLElement>",
455
+ "parameters": [],
456
+ "references": {
457
+ "Promise": {
458
+ "location": "global"
459
+ },
460
+ "HTMLElement": {
461
+ "location": "global"
462
+ }
463
+ },
464
+ "return": "Promise<HTMLElement>"
465
+ },
466
+ "docs": {
467
+ "text": "",
468
+ "tags": []
469
+ }
470
+ }
471
+ }; }
472
+ static get elementRef() { return "host"; }
473
+ static get watchers() { return [{
474
+ "propName": "visible",
475
+ "methodName": "handleVisible"
476
+ }]; }
477
+ }
@@ -0,0 +1,110 @@
1
+ import { Component, h, Element, Method, State } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ /**
4
+ * @slot header - The top of the popup, has replaceable props `{name}`, `{message}`.
5
+ * @slot product - Replaces product card, has replaceable props `{name}`, `{url}`, `{image}`, `{price}`.
6
+ * @slot category - Replaces Category badge, has replaceable props `{name}`, `{url}`.
7
+ */
8
+ export class SallaOffer {
9
+ constructor() {
10
+ var _a, _b, _c;
11
+ this.offer = null;
12
+ Helper.setHost(this.host);
13
+ this.headerSlot = ((_a = Helper.getElement('[slot="header"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<b class="s-offer-title">{name}</b><h3 class="s-offer-subtitle">{message}</h3>';
14
+ this.categorySlot = ((_b = Helper.getElement('[slot="category"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<i class="s-offer-badge-icon sicon-tag"></i><span class="s-offer-badge-text">{name}</span>';
15
+ this.productSlot = ((_c = Helper.getElement('[slot="product"]')) === null || _c === void 0 ? void 0 : _c.innerHTML) || this.defaultProductSlot();
16
+ salla.offer.event.onExisted(data => {
17
+ //TODO:: use the best, should we hide the offer by product Id or Offer id🤔
18
+ if (salla.localStore.get('remember-offer-' + data.offer.offer_id)) {
19
+ salla.log('User selected to don\'t show this offer again.');
20
+ return;
21
+ }
22
+ this.show(data.product_id);
23
+ });
24
+ }
25
+ async show(productId) {
26
+ return this.modal.show()
27
+ .then(() => salla.api.offer.details(productId))
28
+ //TODO:: make sure there is only one offer
29
+ .then(response => this.offer = response.data[0]);
30
+ }
31
+ rememberMe(event) {
32
+ salla.localStore.set('remember-offer-' + this.offer.id, event.target.checked);
33
+ }
34
+ addItem() {
35
+ // this here, is sallaButton
36
+ this['load']();
37
+ return salla.cart.api
38
+ .quickAdd(this['dataset'].id)
39
+ .finally(() => this['stop']());
40
+ }
41
+ defaultProductSlot() {
42
+ return '<a href={url} class="s-offer-product-image"><img class="s-offer-product-img" src="{image}" /></a>' +
43
+ '<div class="s-offer-product-info">' +
44
+ ' <a href={url} class="s-offer-product-name">{name}</a>' +
45
+ ' <div class="s-offer-product-price">{price}</div>' +
46
+ '</div>';
47
+ }
48
+ render() {
49
+ var _a, _b;
50
+ return h("salla-modal", { ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
51
+ ? [h("div", { class: "s-offer-header", innerHTML: this.headerSlot
52
+ .replace(/\{name\}/g, this.offer.name)
53
+ .replace(/\{message\}/g, this.offer.message) }),
54
+ h("div", { class: "s-offer-body" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
55
+ ? this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-badge", innerHTML: this.categorySlot
56
+ .replace(/\{name\}/g, category.name)
57
+ .replace(/\{url\}/g, category.urls.customer) }))
58
+ : (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => h("div", { class: "s-offer-product", id: 'product_' + product.id, innerHTML: this.productSlot
59
+ .replace(/\{name\}/g, product.name)
60
+ .replace(/\{url\}/g, product.url)
61
+ .replace(/\{image\}/g, product.thumbnail)
62
+ .replace(/\{price\}/g, product.has_special_price
63
+ ? salla.money(product.sale_price) + '<span class="s-offer-product-old-price">' + salla.money(product.regular_price) + '</span>'
64
+ : salla.money(product.price)) },
65
+ h("salla-button", { "btn-style": 'outline-primary', "data-id": product.id, onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart'))))),
66
+ h("div", { class: "s-offer-footer", slot: "footer" },
67
+ this.offer.expiry_date ?
68
+ h("p", { class: "s-offer-expiry" },
69
+ salla.lang.get('pages.products.offer_expires_in'),
70
+ " ",
71
+ this.offer.expiry_date)
72
+ : '',
73
+ h("label", { class: "s-offer-remember-label" },
74
+ h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }),
75
+ "\u00A0 ",
76
+ salla.lang.get('common.remember_my_choice'))),
77
+ ] : '');
78
+ }
79
+ componentDidRender() {
80
+ //todo:: know from where there is hidden attributes to the doms🤔
81
+ //todo:: add animation
82
+ this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
83
+ }
84
+ static get is() { return "salla-offer"; }
85
+ static get states() { return {
86
+ "offer": {}
87
+ }; }
88
+ static get methods() { return {
89
+ "show": {
90
+ "complexType": {
91
+ "signature": "(productId: number) => Promise<any>",
92
+ "parameters": [{
93
+ "tags": [],
94
+ "text": ""
95
+ }],
96
+ "references": {
97
+ "Promise": {
98
+ "location": "global"
99
+ }
100
+ },
101
+ "return": "Promise<any>"
102
+ },
103
+ "docs": {
104
+ "text": "",
105
+ "tags": []
106
+ }
107
+ }
108
+ }; }
109
+ static get elementRef() { return "host"; }
110
+ }