@salla.sa/twilight-components 1.0.21 → 1.0.23

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 (98) 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-6229ec94.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-eb0112c0.js +78 -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 +16 -0
  24. package/dist/collection/components/salla-login/salla-login.js +380 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +478 -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 +25 -0
  33. package/dist/collection/components/salla-search/salla-search.js +100 -0
  34. package/dist/collection/components/salla-search/search-response.js +1 -0
  35. package/dist/collection/components/salla-tel-input/salla-tel-input.js +121 -0
  36. package/dist/collection/components/salla-verify/salla-verify.js +280 -0
  37. package/dist/collection/index.js +2 -0
  38. package/dist/collection/interfaces/colors.js +1 -0
  39. package/dist/collection/interfaces/index.js +2 -0
  40. package/dist/collection/interfaces/ratio.js +1 -0
  41. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  42. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  43. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  44. package/dist/esm/index-a1bf769d.js +1625 -0
  45. package/dist/esm/index.js +4 -0
  46. package/dist/esm/loader.js +17 -0
  47. package/dist/esm/polyfills/core-js.js +11 -0
  48. package/dist/esm/polyfills/css-shim.js +1 -0
  49. package/dist/esm/polyfills/dom.js +79 -0
  50. package/dist/esm/polyfills/es5-html-element.js +1 -0
  51. package/dist/esm/polyfills/index.js +34 -0
  52. package/dist/esm/polyfills/system.js +6 -0
  53. package/dist/{twilight-components → esm}/salla-branches.entry.js +2 -2
  54. package/dist/{twilight-components/salla-tel-input.entry.js → esm/salla-button_5.entry.js} +337 -35
  55. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  56. package/dist/{twilight-components/salla-login-57b18c2c.js → esm/salla-login-c368f5b3.js} +27 -24
  57. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  58. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  59. package/dist/{twilight-components → esm}/salla-rating.entry.js +71 -108
  60. package/dist/esm/salla-search-57bd45eb.js +76 -0
  61. package/dist/esm/salla-search.entry.js +3 -0
  62. package/dist/esm/twilight-components.js +17 -0
  63. package/dist/index.cjs.js +1 -0
  64. package/dist/index.js +1 -0
  65. package/dist/twilight-components/index.esm.js +1 -4
  66. package/dist/twilight-components/p-1a6d8171.entry.js +1 -0
  67. package/dist/twilight-components/p-47f17d3b.js +1 -0
  68. package/dist/twilight-components/p-47f3d098.entry.js +1 -0
  69. package/dist/twilight-components/p-48931f49.entry.js +1 -0
  70. package/dist/twilight-components/p-4d329f0d.js +1 -0
  71. package/dist/twilight-components/p-6a5be894.js +1 -0
  72. package/dist/twilight-components/p-7fbdf746.entry.js +1 -0
  73. package/dist/twilight-components/p-7fe5d346.entry.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/p-e7edc889.js +1 -0
  77. package/dist/twilight-components/twilight-components.css +1 -3
  78. package/dist/twilight-components/twilight-components.esm.js +1 -125
  79. package/dist/types/components/salla-login/salla-login.d.ts +3 -3
  80. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  81. package/dist/types/components/salla-rating/salla-rating.d.ts +6 -23
  82. package/dist/types/components/salla-search/salla-search.d.ts +3 -8
  83. package/dist/types/components/salla-search/search-response.d.ts +18 -0
  84. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +14 -0
  85. package/dist/types/components/salla-verify/salla-verify.d.ts +3 -1
  86. package/dist/types/components.d.ts +12 -51
  87. package/package.json +1 -1
  88. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  89. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  90. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  91. package/dist/twilight-components/index-9c087700.js +0 -3010
  92. package/dist/twilight-components/salla-button.entry.js +0 -75
  93. package/dist/twilight-components/salla-login.entry.js +0 -3
  94. package/dist/twilight-components/salla-modal.entry.js +0 -113
  95. package/dist/twilight-components/salla-search-30fec1e8.js +0 -79
  96. package/dist/twilight-components/salla-search.entry.js +0 -3
  97. package/dist/twilight-components/salla-verify.entry.js +0 -114
  98. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,478 @@
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.title || this.subTitle ?
95
+ h("div", { class: "s-modal-header-inner" },
96
+ this.error || this.success || this.icon
97
+ ? h("div", { class: {
98
+ 's-modal-icon': true,
99
+ 's-modal-bg-error': this.error,
100
+ 's-modal-bg-success': this.success,
101
+ 's-modal-bg-normal': !this.error && !this.success,
102
+ 's-modal-bg-primary': this.primary
103
+ } },
104
+ h("i", { class: {
105
+ [this.icon]: true,
106
+ 's-modal-text-error': this.error,
107
+ 's-modal-text-success': this.success,
108
+ } }))
109
+ : this.imageIcon ?
110
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
111
+ : '',
112
+ h("div", { class: "s-modal-header-content" },
113
+ h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }),
114
+ h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
115
+ : ''),
116
+ h("slot", null),
117
+ h("slot", { name: "footer" })
118
+ ]))));
119
+ }
120
+ static get is() { return "salla-modal"; }
121
+ static get properties() { return {
122
+ "error": {
123
+ "type": "boolean",
124
+ "mutable": false,
125
+ "complexType": {
126
+ "original": "boolean",
127
+ "resolved": "boolean",
128
+ "references": {}
129
+ },
130
+ "required": false,
131
+ "optional": false,
132
+ "docs": {
133
+ "tags": [],
134
+ "text": ""
135
+ },
136
+ "attribute": "error",
137
+ "reflect": false,
138
+ "defaultValue": "false"
139
+ },
140
+ "success": {
141
+ "type": "boolean",
142
+ "mutable": false,
143
+ "complexType": {
144
+ "original": "boolean",
145
+ "resolved": "boolean",
146
+ "references": {}
147
+ },
148
+ "required": false,
149
+ "optional": false,
150
+ "docs": {
151
+ "tags": [],
152
+ "text": ""
153
+ },
154
+ "attribute": "success",
155
+ "reflect": false,
156
+ "defaultValue": "false"
157
+ },
158
+ "primary": {
159
+ "type": "boolean",
160
+ "mutable": false,
161
+ "complexType": {
162
+ "original": "boolean",
163
+ "resolved": "boolean",
164
+ "references": {}
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": ""
171
+ },
172
+ "attribute": "primary",
173
+ "reflect": false,
174
+ "defaultValue": "false"
175
+ },
176
+ "isClosable": {
177
+ "type": "boolean",
178
+ "mutable": true,
179
+ "complexType": {
180
+ "original": "boolean",
181
+ "resolved": "boolean",
182
+ "references": {}
183
+ },
184
+ "required": false,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": ""
189
+ },
190
+ "attribute": "is-closable",
191
+ "reflect": false,
192
+ "defaultValue": "true"
193
+ },
194
+ "width": {
195
+ "type": "string",
196
+ "mutable": false,
197
+ "complexType": {
198
+ "original": "'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full'",
199
+ "resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"",
200
+ "references": {}
201
+ },
202
+ "required": false,
203
+ "optional": false,
204
+ "docs": {
205
+ "tags": [],
206
+ "text": ""
207
+ },
208
+ "attribute": "width",
209
+ "reflect": true,
210
+ "defaultValue": "'md'"
211
+ },
212
+ "position": {
213
+ "type": "string",
214
+ "mutable": false,
215
+ "complexType": {
216
+ "original": "'top' | 'middel' | 'bottom'",
217
+ "resolved": "\"bottom\" | \"middel\" | \"top\"",
218
+ "references": {}
219
+ },
220
+ "required": false,
221
+ "optional": false,
222
+ "docs": {
223
+ "tags": [],
224
+ "text": ""
225
+ },
226
+ "attribute": "position",
227
+ "reflect": true,
228
+ "defaultValue": "'middel'"
229
+ },
230
+ "visible": {
231
+ "type": "boolean",
232
+ "mutable": false,
233
+ "complexType": {
234
+ "original": "boolean",
235
+ "resolved": "boolean",
236
+ "references": {}
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": ""
243
+ },
244
+ "attribute": "visible",
245
+ "reflect": true,
246
+ "defaultValue": "false"
247
+ },
248
+ "isLoading": {
249
+ "type": "boolean",
250
+ "mutable": true,
251
+ "complexType": {
252
+ "original": "boolean",
253
+ "resolved": "boolean",
254
+ "references": {}
255
+ },
256
+ "required": false,
257
+ "optional": false,
258
+ "docs": {
259
+ "tags": [],
260
+ "text": ""
261
+ },
262
+ "attribute": "is-loading",
263
+ "reflect": true,
264
+ "defaultValue": "false"
265
+ },
266
+ "subTitleFirst": {
267
+ "type": "boolean",
268
+ "mutable": false,
269
+ "complexType": {
270
+ "original": "boolean",
271
+ "resolved": "boolean",
272
+ "references": {}
273
+ },
274
+ "required": false,
275
+ "optional": false,
276
+ "docs": {
277
+ "tags": [],
278
+ "text": ""
279
+ },
280
+ "attribute": "sub-title-first",
281
+ "reflect": false,
282
+ "defaultValue": "false"
283
+ },
284
+ "subTitle": {
285
+ "type": "string",
286
+ "mutable": false,
287
+ "complexType": {
288
+ "original": "string",
289
+ "resolved": "string",
290
+ "references": {}
291
+ },
292
+ "required": false,
293
+ "optional": false,
294
+ "docs": {
295
+ "tags": [],
296
+ "text": ""
297
+ },
298
+ "attribute": "sub-title",
299
+ "reflect": false,
300
+ "defaultValue": "''"
301
+ },
302
+ "icon": {
303
+ "type": "string",
304
+ "mutable": false,
305
+ "complexType": {
306
+ "original": "string",
307
+ "resolved": "string",
308
+ "references": {}
309
+ },
310
+ "required": false,
311
+ "optional": false,
312
+ "docs": {
313
+ "tags": [],
314
+ "text": ""
315
+ },
316
+ "attribute": "icon",
317
+ "reflect": false,
318
+ "defaultValue": "''"
319
+ },
320
+ "imageIcon": {
321
+ "type": "string",
322
+ "mutable": false,
323
+ "complexType": {
324
+ "original": "string",
325
+ "resolved": "string",
326
+ "references": {}
327
+ },
328
+ "required": false,
329
+ "optional": false,
330
+ "docs": {
331
+ "tags": [],
332
+ "text": ""
333
+ },
334
+ "attribute": "image-icon",
335
+ "reflect": false,
336
+ "defaultValue": "''"
337
+ }
338
+ }; }
339
+ static get states() { return {
340
+ "title": {}
341
+ }; }
342
+ static get events() { return [{
343
+ "method": "modalOpened",
344
+ "name": "modalOpened",
345
+ "bubbles": true,
346
+ "cancelable": true,
347
+ "composed": true,
348
+ "docs": {
349
+ "tags": [],
350
+ "text": ""
351
+ },
352
+ "complexType": {
353
+ "original": "any",
354
+ "resolved": "any",
355
+ "references": {}
356
+ }
357
+ }, {
358
+ "method": "modalClosed",
359
+ "name": "modalClosed",
360
+ "bubbles": true,
361
+ "cancelable": true,
362
+ "composed": true,
363
+ "docs": {
364
+ "tags": [],
365
+ "text": ""
366
+ },
367
+ "complexType": {
368
+ "original": "any",
369
+ "resolved": "any",
370
+ "references": {}
371
+ }
372
+ }]; }
373
+ static get methods() { return {
374
+ "show": {
375
+ "complexType": {
376
+ "signature": "() => Promise<HTMLElement>",
377
+ "parameters": [],
378
+ "references": {
379
+ "Promise": {
380
+ "location": "global"
381
+ },
382
+ "HTMLElement": {
383
+ "location": "global"
384
+ }
385
+ },
386
+ "return": "Promise<HTMLElement>"
387
+ },
388
+ "docs": {
389
+ "text": "",
390
+ "tags": []
391
+ }
392
+ },
393
+ "hide": {
394
+ "complexType": {
395
+ "signature": "() => Promise<HTMLElement>",
396
+ "parameters": [],
397
+ "references": {
398
+ "Promise": {
399
+ "location": "global"
400
+ },
401
+ "HTMLElement": {
402
+ "location": "global"
403
+ }
404
+ },
405
+ "return": "Promise<HTMLElement>"
406
+ },
407
+ "docs": {
408
+ "text": "",
409
+ "tags": []
410
+ }
411
+ },
412
+ "setTitle": {
413
+ "complexType": {
414
+ "signature": "(title: any) => Promise<HTMLElement>",
415
+ "parameters": [{
416
+ "tags": [],
417
+ "text": ""
418
+ }],
419
+ "references": {
420
+ "Promise": {
421
+ "location": "global"
422
+ },
423
+ "HTMLElement": {
424
+ "location": "global"
425
+ }
426
+ },
427
+ "return": "Promise<HTMLElement>"
428
+ },
429
+ "docs": {
430
+ "text": "",
431
+ "tags": []
432
+ }
433
+ },
434
+ "loading": {
435
+ "complexType": {
436
+ "signature": "() => Promise<HTMLElement>",
437
+ "parameters": [],
438
+ "references": {
439
+ "Promise": {
440
+ "location": "global"
441
+ },
442
+ "HTMLElement": {
443
+ "location": "global"
444
+ }
445
+ },
446
+ "return": "Promise<HTMLElement>"
447
+ },
448
+ "docs": {
449
+ "text": "",
450
+ "tags": []
451
+ }
452
+ },
453
+ "stopLoading": {
454
+ "complexType": {
455
+ "signature": "() => Promise<HTMLElement>",
456
+ "parameters": [],
457
+ "references": {
458
+ "Promise": {
459
+ "location": "global"
460
+ },
461
+ "HTMLElement": {
462
+ "location": "global"
463
+ }
464
+ },
465
+ "return": "Promise<HTMLElement>"
466
+ },
467
+ "docs": {
468
+ "text": "",
469
+ "tags": []
470
+ }
471
+ }
472
+ }; }
473
+ static get elementRef() { return "host"; }
474
+ static get watchers() { return [{
475
+ "propName": "visible",
476
+ "methodName": "handleVisible"
477
+ }]; }
478
+ }
@@ -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
+ }