@salla.sa/twilight-components 1.6.2 → 1.6.4

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 (152) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_27.cjs.entry.js +27879 -0
  3. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +26 -0
  4. package/dist/cjs/salla-scopes.cjs.entry.js +9 -6
  5. package/dist/cjs/salla-select.cjs.entry.js +159 -0
  6. package/dist/cjs/twilight-components.cjs.js +1 -1
  7. package/dist/collection/assets/svg/caret-down.svg +0 -1
  8. package/dist/collection/assets/svg/images.svg +0 -1
  9. package/dist/collection/collection-manifest.json +5 -0
  10. package/dist/collection/components/salla-datetime-picker/interfaces.js +4 -0
  11. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.css +13 -0
  12. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1374 -0
  13. package/dist/collection/components/salla-file-upload/interfaces.js +42 -0
  14. package/dist/collection/components/salla-file-upload/salla-file-upload.css +219 -0
  15. package/dist/collection/components/salla-file-upload/salla-file-upload.js +1435 -0
  16. package/dist/collection/components/salla-gifting/gift-schema.js +4 -0
  17. package/dist/collection/components/salla-gifting/intefaces.js +4 -0
  18. package/dist/collection/components/salla-gifting/salla-gifting.css +20 -0
  19. package/dist/collection/components/salla-gifting/salla-gifting.js +564 -0
  20. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +23 -13
  21. package/dist/collection/components/salla-login-modal/salla-login-modal.js +46 -28
  22. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.css +3 -0
  23. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +69 -0
  24. package/dist/collection/components/salla-loyalty/salla-loyalty.css +0 -4
  25. package/dist/collection/components/salla-loyalty/salla-loyalty.js +29 -16
  26. package/dist/collection/components/salla-modal/salla-modal.css +6 -1
  27. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +37 -13
  28. package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +23 -8
  29. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +87 -64
  30. package/dist/collection/components/salla-scopes/salla-scopes.js +11 -7
  31. package/dist/collection/components/salla-search/salla-search.js +1 -1
  32. package/dist/collection/components/salla-select/salla-select.css +86 -0
  33. package/dist/collection/components/salla-select/salla-select.js +610 -0
  34. package/dist/collection/components/salla-tel-input/interfaces.js +4 -0
  35. package/dist/collection/components/salla-tel-input/salla-tel-input.css +1 -2
  36. package/dist/collection/components/salla-tel-input/salla-tel-input.js +32 -3
  37. package/dist/collection/components/salla-verify/salla-verify.js +1 -1
  38. package/dist/collection/global/app.js +15 -12
  39. package/dist/components/_commonjsHelpers.js +24 -0
  40. package/dist/{esm/salla-social-share.entry.js → components/anime.es.js} +1 -132
  41. package/dist/components/index.d.ts +5 -0
  42. package/dist/components/index.js +5 -0
  43. package/dist/components/salla-datetime-picker.d.ts +11 -0
  44. package/dist/components/salla-datetime-picker.js +9 -0
  45. package/dist/components/salla-datetime-picker2.js +2876 -0
  46. package/dist/components/salla-file-upload.d.ts +11 -0
  47. package/dist/components/salla-file-upload.js +9 -0
  48. package/dist/components/salla-file-upload2.js +14623 -0
  49. package/dist/components/salla-gifting.d.ts +11 -0
  50. package/dist/components/salla-gifting.js +499 -0
  51. package/dist/components/salla-localization-modal.js +31 -16
  52. package/dist/components/salla-login-modal.js +35 -19
  53. package/dist/components/salla-loyalty-prize-item.d.ts +11 -0
  54. package/dist/components/salla-loyalty-prize-item.js +42 -0
  55. package/dist/components/salla-loyalty.js +28 -17
  56. package/dist/components/salla-modal2.js +1 -1
  57. package/dist/components/salla-offer-modal.js +42 -12
  58. package/dist/components/salla-product-size-guide.js +21 -6
  59. package/dist/components/salla-rating-modal.js +47 -19
  60. package/dist/components/salla-scopes.js +10 -6
  61. package/dist/components/salla-search.js +1 -1
  62. package/dist/components/salla-select.d.ts +11 -0
  63. package/dist/components/salla-select.js +199 -0
  64. package/dist/components/salla-social-share.js +1 -1308
  65. package/dist/components/salla-swiper2.js +9 -9
  66. package/dist/components/salla-tel-input2.js +15 -18
  67. package/dist/components/salla-verify2.js +1 -1
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/salla-button_27.entry.js +27849 -0
  70. package/dist/esm/salla-loyalty-prize-item.entry.js +22 -0
  71. package/dist/esm/salla-scopes.entry.js +9 -6
  72. package/dist/esm/salla-select.entry.js +155 -0
  73. package/dist/esm/twilight-components.js +1 -1
  74. package/dist/twilight-components/p-49125b6a.entry.js +4 -0
  75. package/dist/twilight-components/p-9a25753c.entry.js +4 -0
  76. package/dist/twilight-components/p-b7b9439d.entry.js +22 -0
  77. package/dist/twilight-components/p-df1eb1e5.entry.js +4 -0
  78. package/dist/twilight-components/twilight-components.esm.js +1 -1
  79. package/dist/types/components/salla-datetime-picker/interfaces.d.ts +8 -0
  80. package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +250 -0
  81. package/dist/types/components/salla-file-upload/interfaces.d.ts +766 -0
  82. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +267 -0
  83. package/dist/types/components/salla-gifting/gift-schema.d.ts +20 -0
  84. package/dist/types/components/salla-gifting/intefaces.d.ts +18 -0
  85. package/dist/types/components/salla-gifting/salla-gifting.d.ts +98 -0
  86. package/dist/types/components/salla-localization-modal/salla-localization-modal.d.ts +3 -2
  87. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +13 -3
  88. package/dist/types/components/salla-loyalty/salla-loyalty-prize-item.d.ts +8 -0
  89. package/dist/types/components/salla-loyalty/salla-loyalty.d.ts +2 -0
  90. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +3 -1
  91. package/dist/types/components/salla-product-size-guide/salla-product-size-guide.d.ts +4 -0
  92. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +3 -2
  93. package/dist/types/components/salla-scopes/salla-scopes.d.ts +1 -0
  94. package/dist/types/components/salla-select/salla-select.d.ts +110 -0
  95. package/dist/types/components/salla-tel-input/interfaces.d.ts +4 -0
  96. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +3 -0
  97. package/dist/types/components.d.ts +1253 -10
  98. package/package.json +9 -3
  99. package/dist/cjs/Helper-8ae6a805.js +0 -28
  100. package/dist/cjs/arrow-right-3d137e4c.js +0 -13
  101. package/dist/cjs/cancel-ae668d91.js +0 -13
  102. package/dist/cjs/check-circle2-1aac98d1.js +0 -13
  103. package/dist/cjs/mail-2db058ee.js +0 -13
  104. package/dist/cjs/salla-button_10.cjs.entry.js +0 -2584
  105. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +0 -93
  106. package/dist/cjs/salla-list-tile_2.cjs.entry.js +0 -80
  107. package/dist/cjs/salla-loyalty.cjs.entry.js +0 -229
  108. package/dist/cjs/salla-product-availability.cjs.entry.js +0 -128
  109. package/dist/cjs/salla-product-size-guide.cjs.entry.js +0 -52
  110. package/dist/cjs/salla-quantity-input.cjs.entry.js +0 -101
  111. package/dist/cjs/salla-rating-modal.cjs.entry.js +0 -169
  112. package/dist/cjs/salla-rating-stars.cjs.entry.js +0 -83
  113. package/dist/cjs/salla-social-share.cjs.entry.js +0 -1447
  114. package/dist/cjs/salla-swiper.cjs.entry.js +0 -5023
  115. package/dist/cjs/salla-tab-content_3.cjs.entry.js +0 -159
  116. package/dist/cjs/star2-8288e6e1.js +0 -13
  117. package/dist/esm/Helper-e1d414a5.js +0 -26
  118. package/dist/esm/arrow-right-1c3e04f2.js +0 -11
  119. package/dist/esm/cancel-41a92070.js +0 -11
  120. package/dist/esm/check-circle2-f6e5f685.js +0 -11
  121. package/dist/esm/mail-9d5204c6.js +0 -11
  122. package/dist/esm/salla-button_10.entry.js +0 -2571
  123. package/dist/esm/salla-infinite-scroll.entry.js +0 -89
  124. package/dist/esm/salla-list-tile_2.entry.js +0 -75
  125. package/dist/esm/salla-loyalty.entry.js +0 -225
  126. package/dist/esm/salla-product-availability.entry.js +0 -124
  127. package/dist/esm/salla-product-size-guide.entry.js +0 -48
  128. package/dist/esm/salla-quantity-input.entry.js +0 -97
  129. package/dist/esm/salla-rating-modal.entry.js +0 -165
  130. package/dist/esm/salla-rating-stars.entry.js +0 -79
  131. package/dist/esm/salla-swiper.entry.js +0 -5019
  132. package/dist/esm/salla-tab-content_3.entry.js +0 -153
  133. package/dist/esm/star2-b134fc74.js +0 -11
  134. package/dist/twilight-components/p-0d498694.entry.js +0 -4
  135. package/dist/twilight-components/p-14f0ff17.entry.js +0 -4
  136. package/dist/twilight-components/p-335abbbb.entry.js +0 -4
  137. package/dist/twilight-components/p-4cafb11b.entry.js +0 -4
  138. package/dist/twilight-components/p-5e63e308.entry.js +0 -4
  139. package/dist/twilight-components/p-5fb32395.entry.js +0 -4
  140. package/dist/twilight-components/p-648e74e5.entry.js +0 -4
  141. package/dist/twilight-components/p-6a3adf55.entry.js +0 -4
  142. package/dist/twilight-components/p-6da4bb74.entry.js +0 -4
  143. package/dist/twilight-components/p-897b2018.js +0 -4
  144. package/dist/twilight-components/p-93708e1e.js +0 -4
  145. package/dist/twilight-components/p-9d236cf4.entry.js +0 -4
  146. package/dist/twilight-components/p-9d2ca9c8.js +0 -4
  147. package/dist/twilight-components/p-af7d5660.js +0 -4
  148. package/dist/twilight-components/p-bdbd2386.entry.js +0 -4
  149. package/dist/twilight-components/p-cac3db69.entry.js +0 -4
  150. package/dist/twilight-components/p-d914a212.js +0 -4
  151. package/dist/twilight-components/p-dace8e6d.js +0 -4
  152. package/dist/twilight-components/p-f9253fda.entry.js +0 -4
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SallaGifting extends Components.SallaGifting, HTMLElement {}
4
+ export const SallaGifting: {
5
+ prototype: SallaGifting;
6
+ new (): SallaGifting;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,499 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
5
+ import { a as anime } from './anime.es.js';
6
+ import { A as ArrowRightIcon } from './arrow-right.js';
7
+ import { L as LeftArrow, d as defineCustomElement$3 } from './salla-swiper2.js';
8
+ import { C as Cancel } from './cancel.js';
9
+ import { d as defineCustomElement$b } from './salla-button2.js';
10
+ import { d as defineCustomElement$a } from './salla-datetime-picker2.js';
11
+ import { d as defineCustomElement$9 } from './salla-file-upload2.js';
12
+ import { d as defineCustomElement$8 } from './salla-list-tile2.js';
13
+ import { d as defineCustomElement$7 } from './salla-loading2.js';
14
+ import { d as defineCustomElement$6 } from './salla-modal2.js';
15
+ import { d as defineCustomElement$5 } from './salla-placeholder2.js';
16
+ import { d as defineCustomElement$4 } from './salla-skeleton2.js';
17
+ import { d as defineCustomElement$2 } from './salla-tel-input2.js';
18
+
19
+ const Images = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
20
+ <title>images</title>
21
+ <path d="M22.667 29.333h-13.333c-3.676 0-6.667-2.991-6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v13.333c0 5.145 4.187 9.333 9.333 9.333h13.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM22.667 5.333c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 10.667c-0.735 0-1.333-0.597-1.333-1.333s0.599-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.599 1.333-1.333 1.333zM25.333 0h-13.333c-3.676 0-6.667 2.991-6.667 6.667v13.333c0 1.055 0.268 2.040 0.707 2.927 0.039 0.099 0.088 0.188 0.151 0.277 1.137 2.053 3.301 3.463 5.809 3.463h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-3.676-2.991-6.667-6.667-6.667zM12 24c-1.244 0-2.344-0.583-3.077-1.476l5.721-7.047 6.629 8.523zM29.333 20c0 2.205-1.795 4-4 4h-0.68l-8.933-11.485c-0.251-0.32-0.633-0.511-1.039-0.515h-0.015c-0.401 0-0.781 0.181-1.035 0.492l-5.632 6.935v-12.76c0-2.205 1.795-4 4-4h13.333c2.205 0 4 1.795 4 4z"></path>
22
+ </svg>
23
+ `;
24
+
25
+ const GiftSharing = `<!-- Generated by IcoMoon.io -->
26
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
27
+ <title>gift-sharing</title>
28
+ <path d="M5 32h-4c-0.552 0-1-0.448-1-1v0-14c0-0.552 0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 14c0 0.552-0.448 1-1 1v0zM2 30h2v-12h-2zM19.32 30h-14.32v-2h14.32c0.693-0.005 1.329-0.242 1.837-0.637l-0.007 0.005 8.45-6.568c0.216-0.16 0.365-0.402 0.399-0.679l0-0.005c0.005-0.036 0.007-0.077 0.007-0.119 0-0.226-0.078-0.434-0.209-0.599l0.002 0.002c-0.16-0.216-0.401-0.364-0.677-0.399l-0.005-0.001c-0.034-0.004-0.073-0.007-0.113-0.007-0.227 0-0.436 0.078-0.601 0.208l0.002-0.002-7.126 5.526c-1.003 0.793-2.285 1.273-3.68 1.274h-6.6v-2h6.6c0.926-0.001 1.777-0.32 2.45-0.852l-0.008 0.006 7.126-5.526c0.492-0.39 1.122-0.625 1.807-0.625 0.135 0 0.268 0.009 0.398 0.027l-0.015-0.002c0.824 0.102 1.534 0.524 2.011 1.137l0.005 0.007c0.39 0.494 0.625 1.127 0.625 1.814 0 0.136-0.009 0.27-0.027 0.402l0.002-0.015c-0.106 0.819-0.529 1.523-1.141 1.995l-0.007 0.005-8.458 6.578c-0.834 0.649-1.894 1.043-3.047 1.050h-0.002zM11 26c-0.552 0-1-0.448-1-1s0.448-1 1-1v0c2.406-0.004 4.415-1.703 4.894-3.967l0.006-0.033h-10.9c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h12c0.552 0 1 0.448 1 1v0c0 3.866-3.134 7-7 7v0zM24 12h-16c-1.105 0-2-0.895-2-2v0-2c0-1.105 0.895-2 2-2v0h16c1.105 0 2 0.895 2 2v0 2c0 1.105-0.895 2-2 2v0zM24 10v0zM8 8v2h16v-2zM23 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM9 16c-0.552 0-1-0.448-1-1v0-4c0-0.552 0.448-1 1-1s1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM16 16c-0.552 0-1-0.448-1-1v0-8c0-0.552 0.448-1 1-1s1 0.448 1 1v0 8c0 0.552-0.448 1-1 1v0zM16 8c-0.552-0-1-0.448-1-1 0-0.077 0.009-0.151 0.025-0.223l-0.001 0.007c0.314-1.849 0.963-3.5 1.887-4.961l-0.033 0.055c0.539-0.521 1.274-0.842 2.084-0.842 1.657 0 3 1.343 3 3 0 0.81-0.321 1.545-0.843 2.085l0.001-0.001c-1.405 0.891-3.056 1.541-4.824 1.845l-0.080 0.011c-0.065 0.015-0.139 0.024-0.216 0.024h-0zM19 3c-0.001 0-0.001 0-0.002 0-0.276 0-0.525 0.112-0.706 0.292l0-0c-0.391 0.669-0.703 1.444-0.897 2.264l-0.011 0.058c0.878-0.205 1.653-0.517 2.363-0.93l-0.041 0.022c0.18-0.181 0.292-0.43 0.292-0.706 0-0.551-0.446-0.999-0.998-1h-0zM16 8c-0.077-0-0.151-0.009-0.223-0.025l0.007 0.001c-1.848-0.315-3.499-0.965-4.959-1.888l0.055 0.032c-0.521-0.539-0.842-1.274-0.842-2.084 0-1.657 1.343-3 3-3 0.81 0 1.545 0.321 2.085 0.843l-0.001-0.001c0.891 1.405 1.541 3.056 1.845 4.824l0.011 0.080c0.015 0.066 0.024 0.141 0.024 0.218 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0zM13 3c-0.001 0-0.001 0-0.002 0-0.552 0-1 0.448-1 1 0 0.277 0.112 0.527 0.294 0.708l0 0c0.669 0.391 1.444 0.703 2.264 0.897l0.058 0.011c-0.205-0.878-0.517-1.653-0.93-2.363l0.022 0.041c-0.181-0.181-0.43-0.293-0.706-0.294h-0z"></path>
29
+ </svg>
30
+ `;
31
+
32
+ const sallaGiftingCss = ".s-gifting-steps-wrapper{transition:0.2s cubic-bezier(0.55, 0, 0.1, 1) 0s}.is-current-step-2 .gift-step-1,.is-current-step-1 .gift-step-2{pointer-events:none}.is-current-step-1 .gift-step-2{transform:translateX(105%)}.s-gifting-modal .s-modal-body::-webkit-scrollbar{display:none}.s-gifting-select{background-image:url(\"data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>\")}";
33
+
34
+ const SallaGifting$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
35
+ constructor() {
36
+ super();
37
+ this.__registerHost();
38
+ this.currentStep = 1;
39
+ this.showCalendar = false;
40
+ this.showGiftText = false;
41
+ this.currentLang = '';
42
+ this.parentClass = "is-current-step-1";
43
+ this.errors = {};
44
+ this.gift = undefined;
45
+ // @State() selectedImage: GiftImage = undefined;
46
+ this.selectedGiftTextOption = undefined;
47
+ this.showTextArea = false;
48
+ /// Gift Form Data
49
+ this.selectedImage = undefined;
50
+ this.uploadedImage = undefined;
51
+ this.selectedText = undefined;
52
+ this.hasError = false;
53
+ this.timeZone = null;
54
+ salla.lang.onLoaded(() => {
55
+ this.selectImageOrUpload = salla.lang.get('blocks.buy_as_gift.select_image_or_upload');
56
+ this.step1Elems = document.querySelectorAll('.gift-step-1 .anime-item');
57
+ this.step2Elems = document.querySelectorAll('.gift-step-2 .anime-item');
58
+ this.imageCover = document.querySelector('.s-gifting-modal-uploader');
59
+ this.stepsWrapper = document.querySelector('.steps-wrapper');
60
+ this.textSelect = document.querySelector('.s-gifting-selectText');
61
+ this.customTextArea = document.querySelector('.s-gifting-textarea');
62
+ this.calendarFormGroup = document.querySelector('.s-gifting-calendar');
63
+ this.sectionTitle = salla.lang.get('blocks.buy_as_gift.gift_the_one_you_love');
64
+ this.sectionSubtitle = salla.lang.get('blocks.buy_as_gift.gift_the_one_you_love_message');
65
+ this.sectionBtnText = salla.lang.get('blocks.buy_as_gift.send_as_a_gift');
66
+ this.giftDetails = salla.lang.get('blocks.buy_as_gift.gift_details');
67
+ this.selectImageForYourGift = salla.lang.get('blocks.buy_as_gift.select_image_for_your_gift');
68
+ this.selectGiftMessage = salla.lang.get('blocks.buy_as_gift.select_gift_message');
69
+ this.giftCustomText = salla.lang.get('blocks.buy_as_gift.gift_custom_text');
70
+ this.textId = salla.lang.get('blocks.buy_as_gift.text_id');
71
+ this.incorrectGiftText = salla.lang.get('blocks.buy_as_gift.incorrect_gift_text');
72
+ this.nextStep = salla.lang.get('blocks.buy_as_gift.next_step');
73
+ this.senderNameLabel = salla.lang.get('blocks.buy_as_gift.sender_name');
74
+ this.receiverNameFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_name');
75
+ this.receiverMobileFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_mobile');
76
+ this.receiverEmailFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_email');
77
+ this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
78
+ this.sendLater = salla.lang.get('blocks.buy_as_gift.send_later');
79
+ this.selectSendDateAndTime = salla.lang.get('blocks.buy_as_gift.select_send_date_and_time');
80
+ this.canNotEditOrderAfterSelectDate = salla.lang.get('blocks.buy_as_gift.can_not_edit_order_after_select_date');
81
+ this.sendGift = salla.lang.get('blocks.buy_as_gift.send_gift');
82
+ this.donationRequired = salla.lang.get('pages.products.donation_amount_required');
83
+ this.currentLang = salla.lang.locale;
84
+ });
85
+ }
86
+ /**
87
+ * Show the gifting modal window
88
+ */
89
+ async open() {
90
+ this.modal.open();
91
+ return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
92
+ .then((response) => {
93
+ this.gift = response.data;
94
+ this.senderName = this.gift.sender_name;
95
+ })
96
+ .catch(e => {
97
+ var _a, _b, _c, _d;
98
+ this.hasError = true;
99
+ this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
100
+ })
101
+ .finally(() => this.modal.stopLoading()));
102
+ }
103
+ /**
104
+ *
105
+ * Hide the gifting modal window
106
+ */
107
+ async close() {
108
+ return this.modal.close();
109
+ }
110
+ /**
111
+ *
112
+ * Update the modal height based on the changes on the inner elements height for a specific step OR just a pass a new fixed height
113
+ */
114
+ async setWrapperHeight(asStep = 1, delay = 250, additionSpace = 0, newHeight = 0) {
115
+ let currentStep = document.querySelector(`.gift-step-${asStep}`);
116
+ setTimeout(() => {
117
+ let currentStepHeight = currentStep.offsetHeight;
118
+ if (newHeight) {
119
+ this.stepsWrapper.style.height = `${newHeight}px`;
120
+ }
121
+ else {
122
+ this.stepsWrapper.style.height = currentStepHeight + additionSpace + 'px';
123
+ }
124
+ }, delay);
125
+ }
126
+ toggleCalendar() {
127
+ this.showCalendar = !this.showCalendar;
128
+ this.setWrapperHeight(2, 150, 0);
129
+ }
130
+ toggleGiftText(event) {
131
+ this.textSelect.classList.remove('s-form-has-error');
132
+ let dataID = event.target.children[event.target.selectedIndex].getAttribute('data-id');
133
+ let customID = dataID == "custom";
134
+ this.showGiftText = customID;
135
+ // dataID ? this.selectedGiftTextOption = dataID : this.selectedGiftTextOption = undefined;
136
+ if (dataID) {
137
+ this.selectedGiftTextOption = dataID;
138
+ this.setWrapperHeight(1, 150, 0);
139
+ }
140
+ else {
141
+ this.selectedGiftTextOption = undefined;
142
+ this.setWrapperHeight(1, 150, -25);
143
+ }
144
+ }
145
+ /**
146
+ *
147
+ * Go to the step 2
148
+ */
149
+ async goToStep2() {
150
+ if (!this.selectedGiftTextOption) {
151
+ this.textSelect.classList.add('s-form-has-error');
152
+ this.customTextArea.classList.remove('s-form-has-error');
153
+ return;
154
+ }
155
+ else if (this.selectedGiftTextOption == 'custom' && !this.selectedText) {
156
+ this.textSelect.classList.remove('s-form-has-error');
157
+ this.customTextArea.classList.add('s-form-has-error');
158
+ return;
159
+ }
160
+ else {
161
+ this.textSelect.classList.remove('s-form-has-error');
162
+ this.customTextArea.classList.remove('s-form-has-error');
163
+ }
164
+ this.setWrapperHeight(2, 600, 0);
165
+ let stepNextAnime = new anime.timeline();
166
+ stepNextAnime.add({
167
+ targets: this.step1Elems,
168
+ opacity: [1, 0],
169
+ translateX: [0, 50],
170
+ delay: anime.stagger(70),
171
+ // easing: 'easeOutExpo',
172
+ duration: 1200,
173
+ })
174
+ .add({
175
+ targets: '.gift-step-2',
176
+ translateX: ['-110%', 0],
177
+ opacity: [0, 1],
178
+ }, '-=1800')
179
+ .add({
180
+ targets: this.step2Elems,
181
+ opacity: [0, 1],
182
+ translateX: [-50, 0],
183
+ delay: anime.stagger(70),
184
+ duration: 1200,
185
+ complete: () => {
186
+ this.step2Elems.forEach(item => {
187
+ item.classList.remove('opacity-0');
188
+ item.removeAttribute('style');
189
+ });
190
+ }
191
+ }, '-=1200');
192
+ this.currentStep = 2;
193
+ this.stepsWrapper.classList.remove('is-current-step-1', 'is-current-step-2');
194
+ this.stepsWrapper.classList.add(`is-current-step-${this.currentStep}`);
195
+ }
196
+ /**
197
+ *
198
+ * Go to the step 1
199
+ */
200
+ goToStep1() {
201
+ let stepBackAnime = new anime.timeline({
202
+ autoplay: false,
203
+ });
204
+ stepBackAnime.add({
205
+ targets: this.step2Elems,
206
+ opacity: [1, 0],
207
+ translateX: [0, -50],
208
+ delay: anime.stagger(70),
209
+ // easing: 'easeOutExpo',
210
+ duration: 1200,
211
+ })
212
+ .add({
213
+ targets: '.gift-step-1',
214
+ translateX: ['110%', 0],
215
+ opacity: [0, 1],
216
+ }, '-=1800')
217
+ .add({
218
+ targets: this.step1Elems,
219
+ opacity: [0, 1],
220
+ translateX: [50, 0],
221
+ delay: anime.stagger(70),
222
+ duration: 1200,
223
+ complete: () => {
224
+ this.step1Elems.forEach(item => {
225
+ item.classList.remove('opacity-0');
226
+ item.removeAttribute('style');
227
+ });
228
+ }
229
+ }, '-=1200');
230
+ stepBackAnime.play();
231
+ this.setWrapperHeight(1, 600, 0);
232
+ this.currentStep = 1;
233
+ this.stepsWrapper.classList.remove('is-current-step-1', 'is-current-step-2');
234
+ this.stepsWrapper.classList.add(`is-current-step-${this.currentStep}`);
235
+ }
236
+ getFilepondPlaceholder() {
237
+ return `<div class="s-gifting-filepond-placeholder"><span class="s-gifting-filepond-placeholder-icon">${Images}</span><p class="s-gifting-filepond-placeholder-text">${this.selectImageOrUpload ? this.selectImageOrUpload : ''}</p></div>`;
238
+ }
239
+ setPreview(image) {
240
+ this.imageCover.classList.add('has-bg');
241
+ var bg = document.querySelector('.filepond-bg') ? document.querySelector('.filepond-bg') : document.createElement('div');
242
+ bg.classList.add('filepond-bg');
243
+ bg.classList.remove('s-hidden');
244
+ bg.style.backgroundImage = "url('" + image.url + "')";
245
+ this.imageCover.querySelector('.filepond--root').appendChild(bg);
246
+ this.uploadedImage = image.url;
247
+ if (!!this.gift && this.gift.gift_images.length) {
248
+ this.setWrapperHeight(1, 150, 0);
249
+ }
250
+ }
251
+ removePreview() {
252
+ this.imageCover.classList.remove('has-bg');
253
+ let bg = document.querySelector('.filepond-bg');
254
+ bg.removeAttribute('style');
255
+ bg.classList.add('s-hidden');
256
+ this.handleRemoveImage();
257
+ }
258
+ handleTextAreaChange(event) {
259
+ this.selectedText = event.target.value;
260
+ this.customTextArea.classList.remove('s-form-has-error');
261
+ }
262
+ handleSenderName(event) {
263
+ this.senderName = event.target.value;
264
+ }
265
+ handleReceiverName(event) {
266
+ this.receiverName = event.target.value;
267
+ }
268
+ handleRemoveImage() {
269
+ this.uploadedImage = '';
270
+ if (!!this.gift && this.gift.gift_images.length) {
271
+ this.setWrapperHeight(1, 150, 0);
272
+ }
273
+ }
274
+ // private handleReceiverEmail(event) {
275
+ // this.receiverEmail = event.target.value;
276
+ // }
277
+ handlePhoneInputChange(event) {
278
+ let phone = event.detail;
279
+ this.receiverMobile = phone.number;
280
+ this.receiverCountryCode = phone.country_code;
281
+ }
282
+ handleDateTimePicker(event) {
283
+ this.deliveryDate = event.detail;
284
+ }
285
+ getCalendarClasses() {
286
+ return {
287
+ "s-form-group": true,
288
+ "anime-item": true,
289
+ "opacity-0": true,
290
+ "s-gifting-calendar": true,
291
+ "shown": this.showCalendar,
292
+ "hide": !this.showCalendar,
293
+ "s-form-has-error": !!this.errors && this.errors['deliver_at']
294
+ };
295
+ }
296
+ // TODO: make it default server config --> add it to file-upload
297
+ getServerConfig() {
298
+ return {
299
+ process: async (_fieldName, file, _metadata, load, error, _progress, abort, _transfer, _options) => {
300
+ const formData = new FormData();
301
+ formData.append("image_url", file, file.name);
302
+ return await salla.product.uploadGiftImage(formData)
303
+ .then((resp) => {
304
+ this.uploadedImage = resp.data.url;
305
+ load('success');
306
+ file.metadata = `_${new Date().getTime()}`;
307
+ if (!!this.gift && this.gift.gift_images.length) {
308
+ this.setWrapperHeight(1, 150, 0);
309
+ }
310
+ }).catch(e => {
311
+ console.log(e);
312
+ error('error');
313
+ })
314
+ .finally(() => {
315
+ return {
316
+ abort: () => {
317
+ abort();
318
+ },
319
+ };
320
+ });
321
+ }
322
+ };
323
+ }
324
+ async submitForm() {
325
+ var _a;
326
+ this.calendarFormGroup.classList.remove('s-form-has-error');
327
+ if (!!this.errors) {
328
+ this.errors = {};
329
+ this.setWrapperHeight(2, 150, 0);
330
+ }
331
+ if (this.showCalendar && !this.deliveryDate) {
332
+ this.calendarFormGroup.classList.add('s-form-has-error');
333
+ return;
334
+ }
335
+ let payload = {
336
+ text: this.selectedText,
337
+ sender_name: this.senderName,
338
+ quantity: 1,
339
+ deliver_at: this.showCalendar ? this.deliveryDate : null,
340
+ image_url: (_a = this.uploadedImage) !== null && _a !== void 0 ? _a : this.selectedImage,
341
+ receiver: {
342
+ name: this.receiverName,
343
+ country_code: this.receiverCountryCode,
344
+ mobile: this.receiverMobile
345
+ }
346
+ };
347
+ return await salla.product.addGiftToCart(this.productId, payload, true).then((resp) => {
348
+ console.log(resp);
349
+ }).catch((e) => {
350
+ if (e.response.status == 422) {
351
+ this.errors = e.response.data.error.fields;
352
+ }
353
+ else {
354
+ console.log(e);
355
+ }
356
+ this.setWrapperHeight(2, 150, 0);
357
+ });
358
+ }
359
+ render() {
360
+ var _a, _b;
361
+ return [
362
+ h("div", null, h("salla-list-tile", { class: "s-gifting-widget" }, h("div", { slot: "title" }, h("h3", null, this.sectionTitle)), h("div", { slot: "subtitle" }, h("div", null, this.sectionSubtitle)), h("div", { slot: "action" }, h("salla-button", { class: "s-gifting-widget-action", color: "gray", onClick: () => this.open() }, h("span", { innerHTML: GiftSharing }), " \u00A0", h("span", null, this.sectionBtnText)))), h("salla-modal", { id: 'salla-gifting-modal', isLoading: true, class: "s-gifting-modal", width: "sm", ref: modal => this.modal = modal }, h("div", { slot: "loading" }, h("div", { class: "s-gifting-skeleton" }, h("div", { class: "s-gifting-modal-header" }, h("salla-skeleton", { type: 'circle', height: '5rem', width: '5rem' }), h("h2", { class: "s-gifting-modal-title" }, h("div", { class: "s-gifting-modal-badge-wrapper" }, h("salla-skeleton", { height: '15px', width: '150px' })))), h("div", { class: "s-gifting-skeleton-content" }, h("salla-skeleton", { height: '10px', width: '150px' }), h("salla-skeleton", { height: '230px' }), h("salla-skeleton", { height: '10px', width: '150px' }), h("salla-skeleton", { height: '30px' }), h("salla-skeleton", { height: '40px' })))), h("slot", { name: "header" }), !!this.hasError ?
363
+ h("salla-placeholder", { alignment: "center" }, h("span", { slot: "description" }, this.errorMessage))
364
+ :
365
+ [
366
+ h("div", { class: "s-gifting-modal-header" }, h("span", { class: "s-gifting-modal-icon" }, h("span", { innerHTML: GiftSharing })), h("h2", { class: "s-gifting-modal-title" }, h("div", { class: "s-gifting-modal-badge-wrapper" }, h("div", { class: "s-gifting-modal-badge" }, h("span", null, h("span", null, this.currentStep), "/2")), h("span", null, this.giftDetails)))),
367
+ h("div", { class: "s-gifting-steps-wrapper steps-wrapper" }, h("div", { class: "s-gifting-step-one gift-step-1" }, h("div", { class: "s-gifting-modal-uploader-title anime-item opacity-0" }, this.selectImageForYourGift), h("div", { class: "s-gifting-modal-uploader anime-item opacity-0" }, h("span", { class: "s-gifting-remove-preview", onClick: () => this.removePreview(), innerHTML: Cancel }), this.selectImageOrUpload && h("salla-file-upload", { "instant-upload": true, labelIdle: this.getFilepondPlaceholder(), serverConfig: this.getServerConfig(), onRemove: () => this.handleRemoveImage() }, " ")), h("div", { class: "anime-item opacity-0" }, !this.uploadedImage && !!this.gift && this.gift.gift_images.length > 0 ?
368
+ h("salla-swiper", { "space-between-items": "10", "item-per-view": "4" }, (_a = this.gift) === null || _a === void 0 ? void 0 : _a.gift_images.map((item) => h("img", { class: "s-gifting-image s-gifting-clickable", src: item.url, onClick: () => this.setPreview(item), alt: `${item.id}` })))
369
+ : "", h("div", { class: "s-form-group s-gifting-selectText anime-item opacity-0" }, h("label", { htmlFor: "gift-text-selection", class: "s-form-label" }, this.selectGiftMessage), h("select", { id: "gift-text-selection", name: "gift-text-selection", class: "s-form-control s-gifting-select", onChange: e => this.toggleGiftText(e) }, h("option", { "data-id": null, selected: true }, this.selectGiftMessage), (_b = this.gift) === null || _b === void 0 ? void 0 :
370
+ _b.gift_texts.map((txt) => h("option", { "data-id": txt.id, value: txt.text, key: txt.id }, txt.text)), h("option", { "data-id": "custom" }, this.giftCustomText))), h("div", { class: this.showGiftText ? "s-form-group anime-item opacity-0 s-gifting-textarea shown" : "s-form-group s-gifting-textarea hide" }, h("label", { htmlFor: "gift-custom-text", class: "s-form-label" }, this.giftCustomText), h("div", { class: "mt-1" }, h("textarea", { onInput: (event) => this.handleTextAreaChange(event), rows: 4, name: "gift-custom-text", id: "gift-custom-text", class: "s-form-control" }))), h("div", { class: "anime-item opacity-0" }, h("salla-button", { color: "primary", width: "wide", onClick: () => this.goToStep2() }, h("span", null, this.nextStep))))), h("div", { class: "s-gifting-step-two gift-step-2" }, h("div", { class: this.errors && this.errors['sender_name'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" }, h("label", { htmlFor: "sender_name", class: "s-form-label" }, this.senderNameLabel), h("input", { type: "text", class: "s-form-control", name: "sender_name", id: "sender_name", value: this.senderName, onInput: (event) => this.handleSenderName(event), placeholder: "" }), this.errors && this.errors['sender_name'] ? h("span", { class: "text-danger text-xs" }, this.errors['sender_name']) : ''), h("div", { class: this.errors && this.errors['receiver.name'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" }, h("label", { htmlFor: "receiver_name", class: "s-form-label" }, this.receiverNameFieldLabel), h("input", { type: "text", class: "s-form-control", name: "receiver_name", id: "receiver_name", value: "", onInput: (event) => this.handleReceiverName(event), placeholder: "" }), this.errors && this.errors['receiver.name'] ? h("span", { class: "text-danger text-xs" }, this.errors['receiver.name']) : ''), h("div", { class: this.errors && this.errors['receiver.mobile'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" }, h("label", { class: "s-form-label" }, this.receiverMobileFieldLabel), h("salla-tel-input", { class: "s-gifting-tel-input", phone: this.receiverMobile, countryCode: this.receiverCountryCode, onPhoneEntered: (e) => this.handlePhoneInputChange(e) }), this.errors && this.errors['receiver.mobile'] ? h("span", { class: "text-danger text-xs" }, this.errors['receiver.mobile']) : ''), h("div", { class: "anime-item opacity-0" }, h("label", { class: "s-gifting-schedule s-gifting-clickable", htmlFor: "schedule" }, h("input", { type: "checkbox", name: 'schedule', id: 'schedule', onChange: () => this.toggleCalendar(), class: "s-checkbox" }), h("span", { class: "s-form-label" }, " ", this.sendLater, " "))), h("div", { class: this.getCalendarClasses() }, h("label", { class: "s-form-label" }, this.selectSendDateAndTime), h("salla-datetime-picker", { value: this.deliveryDate, placeholder: this.selectSendDateAndTime, "enable-time": true, "date-format": "Y-m-d H:i", onPicked: (event) => this.handleDateTimePicker(event) }), h("span", { class: "s-gifting-calendar-hint" }, this.canNotEditOrderAfterSelectDate)), h("div", { class: "s-gifting-step-two-footer anime-item opacity-0" }, h("a", { href: "#!", innerHTML: this.currentLang == 'ar' ? ArrowRightIcon : LeftArrow, onClick: () => this.goToStep1() }), h("salla-button", { onClick: () => this.submitForm(), color: "primary", width: 'wide' }, h("span", null, this.sendGift)))))
371
+ ], h("slot", { name: "footer" })))
372
+ ];
373
+ }
374
+ static get style() { return sallaGiftingCss; }
375
+ }, [4, "salla-gifting", {
376
+ "productId": [2, "product-id"],
377
+ "sectionTitle": [32],
378
+ "sectionSubtitle": [32],
379
+ "sectionBtnText": [32],
380
+ "giftDetails": [32],
381
+ "selectImageForYourGift": [32],
382
+ "selectImageOrUpload": [32],
383
+ "selectGiftMessage": [32],
384
+ "giftCustomText": [32],
385
+ "textId": [32],
386
+ "incorrectGiftText": [32],
387
+ "nextStep": [32],
388
+ "senderNameLabel": [32],
389
+ "receiverNameFieldLabel": [32],
390
+ "receiverMobileFieldLabel": [32],
391
+ "receiverEmailFieldLabel": [32],
392
+ "emailPlaceholder": [32],
393
+ "sendLater": [32],
394
+ "selectSendDateAndTime": [32],
395
+ "canNotEditOrderAfterSelectDate": [32],
396
+ "sendGift": [32],
397
+ "donationRequired": [32],
398
+ "step1Elems": [32],
399
+ "step2Elems": [32],
400
+ "stepsWrapper": [32],
401
+ "imageCover": [32],
402
+ "textSelect": [32],
403
+ "customTextArea": [32],
404
+ "calendarFormGroup": [32],
405
+ "currentStep": [32],
406
+ "showCalendar": [32],
407
+ "showGiftText": [32],
408
+ "currentLang": [32],
409
+ "parentClass": [32],
410
+ "errors": [32],
411
+ "gift": [32],
412
+ "selectedGiftTextOption": [32],
413
+ "showTextArea": [32],
414
+ "selectedImage": [32],
415
+ "uploadedImage": [32],
416
+ "selectedText": [32],
417
+ "senderName": [32],
418
+ "errorMessage": [32],
419
+ "hasError": [32],
420
+ "quantity": [32],
421
+ "deliveryDate": [32],
422
+ "timeZone": [32],
423
+ "receiverName": [32],
424
+ "receiverMobile": [32],
425
+ "receiverCountryCode": [32],
426
+ "receiverEmail": [32],
427
+ "open": [64],
428
+ "close": [64],
429
+ "goToStep2": [64]
430
+ }]);
431
+ function defineCustomElement$1() {
432
+ if (typeof customElements === "undefined") {
433
+ return;
434
+ }
435
+ const components = ["salla-gifting", "salla-button", "salla-datetime-picker", "salla-file-upload", "salla-list-tile", "salla-loading", "salla-modal", "salla-placeholder", "salla-skeleton", "salla-swiper", "salla-tel-input"];
436
+ components.forEach(tagName => { switch (tagName) {
437
+ case "salla-gifting":
438
+ if (!customElements.get(tagName)) {
439
+ customElements.define(tagName, SallaGifting$1);
440
+ }
441
+ break;
442
+ case "salla-button":
443
+ if (!customElements.get(tagName)) {
444
+ defineCustomElement$b();
445
+ }
446
+ break;
447
+ case "salla-datetime-picker":
448
+ if (!customElements.get(tagName)) {
449
+ defineCustomElement$a();
450
+ }
451
+ break;
452
+ case "salla-file-upload":
453
+ if (!customElements.get(tagName)) {
454
+ defineCustomElement$9();
455
+ }
456
+ break;
457
+ case "salla-list-tile":
458
+ if (!customElements.get(tagName)) {
459
+ defineCustomElement$8();
460
+ }
461
+ break;
462
+ case "salla-loading":
463
+ if (!customElements.get(tagName)) {
464
+ defineCustomElement$7();
465
+ }
466
+ break;
467
+ case "salla-modal":
468
+ if (!customElements.get(tagName)) {
469
+ defineCustomElement$6();
470
+ }
471
+ break;
472
+ case "salla-placeholder":
473
+ if (!customElements.get(tagName)) {
474
+ defineCustomElement$5();
475
+ }
476
+ break;
477
+ case "salla-skeleton":
478
+ if (!customElements.get(tagName)) {
479
+ defineCustomElement$4();
480
+ }
481
+ break;
482
+ case "salla-swiper":
483
+ if (!customElements.get(tagName)) {
484
+ defineCustomElement$3();
485
+ }
486
+ break;
487
+ case "salla-tel-input":
488
+ if (!customElements.get(tagName)) {
489
+ defineCustomElement$2();
490
+ }
491
+ break;
492
+ } });
493
+ }
494
+ defineCustomElement$1();
495
+
496
+ const SallaGifting = SallaGifting$1;
497
+ const defineCustomElement = defineCustomElement$1;
498
+
499
+ export { SallaGifting, defineCustomElement };