@salla.sa/twilight-components 2.14.295 → 2.14.297

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 (158) hide show
  1. package/dist/cjs/{filepond-CEfkKwxm.js → filepond-B40UxVrp.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-U5caDeXK.js → filepond-plugin-file-poster-BJ2is-CR.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-5eUt8fIA.js → filepond-plugin-file-validate-size-jaoaOCNL.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BdNoSu6e.js → filepond-plugin-file-validate-type-CjxCZWaY.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-DFm7eyxh.js → filepond-plugin-image-edit-JEKYuBL0.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-BfH19uNR.js → filepond-plugin-image-exif-orientation-DmK-aAfe.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-BCQL6DBC.js → filepond-plugin-image-preview-BZxhd7ci.js} +1 -1
  8. package/dist/cjs/{index-CMFmTYR8.js → index-Bc1Blm9E.js} +6 -2
  9. package/dist/cjs/{index-TCPzRuQa.js → index-CYgngxgk.js} +1 -1
  10. package/dist/cjs/interfaces-CX9-6aLf.js +24 -0
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion_62.cjs.entry.js +79 -124
  13. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-custom-fields.cjs.entry.js +135 -0
  20. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  46. package/dist/cjs/twilight.cjs.js +2 -2
  47. package/dist/collection/collection-manifest.json +1 -0
  48. package/dist/collection/components/salla-custom-fields/salla-custom-fields.css +3 -0
  49. package/dist/collection/components/salla-custom-fields/salla-custom-fields.js +313 -0
  50. package/dist/collection/components/salla-file-upload/salla-file-upload.js +36 -3
  51. package/dist/collection/components/salla-user-menu/salla-user-menu.js +40 -22
  52. package/dist/collection/components/salla-user-profile/salla-user-profile.js +15 -132
  53. package/dist/components/index.js +2 -2
  54. package/dist/components/interfaces.js +15 -0
  55. package/dist/components/salla-custom-fields.d.ts +11 -0
  56. package/dist/components/salla-custom-fields.js +174 -0
  57. package/dist/components/salla-file-upload2.js +13 -3
  58. package/dist/components/salla-user-menu.js +46 -22
  59. package/dist/components/salla-user-profile.js +19 -97
  60. package/dist/esm/{filepond-vl78959W.js → filepond-DjIxwPi0.js} +1 -1
  61. package/dist/esm/{filepond-plugin-file-poster-CqR_Dwed.js → filepond-plugin-file-poster-CYvspSki.js} +1 -1
  62. package/dist/esm/{filepond-plugin-file-validate-size-B6Dk56YE.js → filepond-plugin-file-validate-size-Cf09KKtA.js} +1 -1
  63. package/dist/esm/{filepond-plugin-file-validate-type-P-_BDRkR.js → filepond-plugin-file-validate-type-ByZikBAG.js} +1 -1
  64. package/dist/esm/{filepond-plugin-image-edit-DWNUa3R3.js → filepond-plugin-image-edit-DbT6_H2k.js} +1 -1
  65. package/dist/esm/{filepond-plugin-image-exif-orientation-dnXbnCGP.js → filepond-plugin-image-exif-orientation-BhEk_QOu.js} +1 -1
  66. package/dist/esm/{filepond-plugin-image-preview-CGT6aBAl.js → filepond-plugin-image-preview-Bsa9hzKo.js} +1 -1
  67. package/dist/esm/{index-DvtO64lP.js → index-CYhDRQ7q.js} +1 -1
  68. package/dist/esm/{index-Ziat6EbF.js → index-D8Ikl-5X.js} +6 -2
  69. package/dist/esm/interfaces-CBT_Nxny.js +22 -0
  70. package/dist/esm/loader.js +3 -3
  71. package/dist/esm/salla-accordion_62.entry.js +78 -123
  72. package/dist/esm/salla-advertisement.entry.js +1 -1
  73. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  74. package/dist/esm/salla-apps-icons.entry.js +1 -1
  75. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  76. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  77. package/dist/esm/salla-contacts.entry.js +1 -1
  78. package/dist/esm/salla-custom-fields.entry.js +133 -0
  79. package/dist/esm/salla-filters-widget.entry.js +1 -1
  80. package/dist/esm/salla-filters.entry.js +1 -1
  81. package/dist/esm/salla-installment.entry.js +1 -1
  82. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  83. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  84. package/dist/esm/salla-metadata.entry.js +1 -1
  85. package/dist/esm/salla-notification-item.entry.js +1 -1
  86. package/dist/esm/salla-notifications.entry.js +1 -1
  87. package/dist/esm/salla-offer.entry.js +1 -1
  88. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  89. package/dist/esm/salla-order-details-options.entry.js +1 -1
  90. package/dist/esm/salla-order-details.entry.js +1 -1
  91. package/dist/esm/salla-order-summary.entry.js +1 -1
  92. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  93. package/dist/esm/salla-orders.entry.js +1 -1
  94. package/dist/esm/salla-payments.entry.js +1 -1
  95. package/dist/esm/salla-price-range.entry.js +1 -1
  96. package/dist/esm/salla-review-card.entry.js +1 -1
  97. package/dist/esm/salla-reviews-page.entry.js +1 -1
  98. package/dist/esm/salla-reviews.entry.js +1 -1
  99. package/dist/esm/salla-social.entry.js +1 -1
  100. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  101. package/dist/esm/salla-tooltip.entry.js +1 -1
  102. package/dist/esm/salla-trust-badges.entry.js +1 -1
  103. package/dist/esm/salla-verify.entry.js +1 -1
  104. package/dist/esm/salla-wallet.entry.js +1 -1
  105. package/dist/esm/twilight.js +3 -3
  106. package/dist/twilight/p-00042305.entry.js +4 -0
  107. package/dist/twilight/{p-9b480b59.entry.js → p-03907a0b.entry.js} +1 -1
  108. package/dist/twilight/{p-8cfd00b9.entry.js → p-067eafaf.entry.js} +1 -1
  109. package/dist/twilight/{p-93a27904.entry.js → p-199025a7.entry.js} +1 -1
  110. package/dist/twilight/{p-d107dc1a.entry.js → p-243e9c31.entry.js} +1 -1
  111. package/dist/twilight/{p-2b8846ae.entry.js → p-26c2b559.entry.js} +1 -1
  112. package/dist/twilight/{p-67038367.entry.js → p-28eae4bb.entry.js} +1 -1
  113. package/dist/twilight/{p-b3fafad2.entry.js → p-2a59b701.entry.js} +1 -1
  114. package/dist/twilight/{p-6822a113.entry.js → p-37249106.entry.js} +1 -1
  115. package/dist/twilight/{p-2a2a02d6.entry.js → p-3d7b61c6.entry.js} +1 -1
  116. package/dist/twilight/{p-f38b2e17.entry.js → p-3f2a0489.entry.js} +1 -1
  117. package/dist/twilight/{p-a328c3d1.entry.js → p-3fe694f7.entry.js} +1 -1
  118. package/dist/twilight/{p-bf70d878.entry.js → p-407a5e84.entry.js} +1 -1
  119. package/dist/twilight/{p-3d19d1d8.entry.js → p-4713b2c5.entry.js} +1 -1
  120. package/dist/twilight/{p-15d9e580.entry.js → p-5fe10b3f.entry.js} +1 -1
  121. package/dist/twilight/{p-415cf3e3.entry.js → p-60a1cceb.entry.js} +1 -1
  122. package/dist/twilight/{p-5f9bc177.entry.js → p-60aa330e.entry.js} +1 -1
  123. package/dist/twilight/{p-917e7e9e.entry.js → p-62b33ee4.entry.js} +1 -1
  124. package/dist/twilight/{p-ab6a475b.entry.js → p-66ccff79.entry.js} +1 -1
  125. package/dist/twilight/{p-64d30453.entry.js → p-6781caef.entry.js} +1 -1
  126. package/dist/twilight/{p-c9109a79.entry.js → p-747b3306.entry.js} +1 -1
  127. package/dist/twilight/{p-a9c627f1.entry.js → p-8713ed50.entry.js} +1 -1
  128. package/dist/twilight/{p-9c51b8d3.entry.js → p-87c26055.entry.js} +1 -1
  129. package/dist/twilight/{p-30edc8e4.entry.js → p-9bb74d00.entry.js} +1 -1
  130. package/dist/twilight/{p-Ez0e1PVX.js → p-BENXSP8S.js} +1 -1
  131. package/dist/twilight/{p-BX_7gR2g.js → p-BdPzpmIq.js} +1 -1
  132. package/dist/twilight/p-CBT_Nxny.js +4 -0
  133. package/dist/twilight/{p-hVSNpsuQ.js → p-CFX5Won9.js} +1 -1
  134. package/dist/twilight/{p-BXOeDpV2.js → p-CYIyfWLw.js} +1 -1
  135. package/dist/twilight/{p-7wg_fRFs.js → p-CdhBe5Fz.js} +1 -1
  136. package/dist/twilight/{p-C0j6-TqH.js → p-D7xuopBR.js} +1 -1
  137. package/dist/twilight/{p-Ziat6EbF.js → p-D8Ikl-5X.js} +2 -2
  138. package/dist/twilight/{p-ZreQEa1A.js → p-DQJu53PU.js} +1 -1
  139. package/dist/twilight/{p-4edf534b.entry.js → p-a608994f.entry.js} +1 -1
  140. package/dist/twilight/{p-ca431a2c.entry.js → p-ade5c1b4.entry.js} +1 -1
  141. package/dist/twilight/{p-1287dd6d.entry.js → p-c0804853.entry.js} +1 -1
  142. package/dist/twilight/{p-745e8f76.entry.js → p-dded0945.entry.js} +1 -1
  143. package/dist/twilight/p-e7b610b8.entry.js +11 -0
  144. package/dist/twilight/{p-e79994cc.entry.js → p-e82e0803.entry.js} +1 -1
  145. package/dist/twilight/{p-cd7e4279.entry.js → p-ecdb32fb.entry.js} +1 -1
  146. package/dist/twilight/{p-a9da8a2e.entry.js → p-f0267809.entry.js} +1 -1
  147. package/dist/twilight/{p-66ab7e17.entry.js → p-f30f7e03.entry.js} +1 -1
  148. package/dist/twilight/{p-f5a11fd5.entry.js → p-f8beff97.entry.js} +1 -1
  149. package/dist/twilight/{p-BBY0-pTD.js → p-fl5mSXGV.js} +1 -1
  150. package/dist/twilight/twilight.esm.js +1 -1
  151. package/dist/types/components/salla-custom-fields/salla-custom-fields.d.ts +39 -0
  152. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +4 -0
  153. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +6 -2
  154. package/dist/types/components/salla-user-profile/interfaces.d.ts +1 -0
  155. package/dist/types/components/salla-user-profile/salla-user-profile.d.ts +1 -20
  156. package/dist/types/components.d.ts +74 -25
  157. package/package.json +5 -5
  158. package/dist/twilight/p-c6d04437.entry.js +0 -11
@@ -3,12 +3,13 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
  var anime_es = require('./anime.es-BqW8JHZi.js');
8
8
  var specialDiscount = require('./special-discount-OVG_9Kf9.js');
9
9
  var check = require('./check-CLRvuniI.js');
10
10
  var Helper = require('./Helper-C9UmWIYn.js');
11
11
  var arrowLeft = require('./arrow-left-xSEmRpp6.js');
12
+ var interfaces = require('./interfaces-CX9-6aLf.js');
12
13
  var shoppingBag = require('./shopping-bag-C1gvTVHr.js');
13
14
  var mail = require('./mail-CO8cFZH7.js');
14
15
  var whatsapp2 = require('./whatsapp2-D7Sbg8Ey.js');
@@ -3543,13 +3544,13 @@ const SallaFileUpload = class {
3543
3544
  return;
3544
3545
  try {
3545
3546
  const [FilePondModule, FilePondPluginFileValidateSize, FilePondPluginImageExifOrientation, FilePondPluginImagePreview, FilePondPluginImageEdit, FilePondPluginFileValidateType, FilePondPluginFilePoster] = await Promise.all([
3546
- Promise.resolve().then(function () { return require('./filepond-CEfkKwxm.js'); }).then(function (n) { return n.filepond; }),
3547
- Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-size-5eUt8fIA.js'); }).then(function (n) { return n.filepondPluginFileValidateSize; }),
3548
- Promise.resolve().then(function () { return require('./filepond-plugin-image-exif-orientation-BfH19uNR.js'); }).then(function (n) { return n.filepondPluginImageExifOrientation; }),
3549
- Promise.resolve().then(function () { return require('./filepond-plugin-image-preview-BCQL6DBC.js'); }).then(function (n) { return n.filepondPluginImagePreview; }),
3550
- Promise.resolve().then(function () { return require('./filepond-plugin-image-edit-DFm7eyxh.js'); }).then(function (n) { return n.filepondPluginImageEdit; }),
3551
- Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-type-BdNoSu6e.js'); }).then(function (n) { return n.filepondPluginFileValidateType; }),
3552
- Promise.resolve().then(function () { return require('./filepond-plugin-file-poster-U5caDeXK.js'); }).then(function (n) { return n.filepondPluginFilePoster; })
3547
+ Promise.resolve().then(function () { return require('./filepond-B40UxVrp.js'); }).then(function (n) { return n.filepond; }),
3548
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-size-jaoaOCNL.js'); }).then(function (n) { return n.filepondPluginFileValidateSize; }),
3549
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-exif-orientation-DmK-aAfe.js'); }).then(function (n) { return n.filepondPluginImageExifOrientation; }),
3550
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-preview-BZxhd7ci.js'); }).then(function (n) { return n.filepondPluginImagePreview; }),
3551
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-edit-JEKYuBL0.js'); }).then(function (n) { return n.filepondPluginImageEdit; }),
3552
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-type-CjxCZWaY.js'); }).then(function (n) { return n.filepondPluginFileValidateType; }),
3553
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-poster-BJ2is-CR.js'); }).then(function (n) { return n.filepondPluginFilePoster; })
3553
3554
  ]);
3554
3555
  this.FilePond = FilePondModule;
3555
3556
  // Register plugins
@@ -3578,6 +3579,10 @@ const SallaFileUpload = class {
3578
3579
  * Set the component to be profile image uploader with a preview and a circular shape
3579
3580
  */
3580
3581
  this.profileImage = false;
3582
+ /**
3583
+ * Allow to pass extra params to be sent with the upload request
3584
+ */
3585
+ this.payloadParams = {};
3581
3586
  /**
3582
3587
  * Accepted file types
3583
3588
  */
@@ -3839,11 +3844,11 @@ const SallaFileUpload = class {
3839
3844
  }
3840
3845
  }
3841
3846
  render() {
3842
- return (index.h(index.Host, { key: 'b5d3d0cf960e703c563f8999d55a99cbfe7a85e3', class: {
3847
+ return (index.h(index.Host, { key: '68939496fd8cfcc89a7a5d21e7e4daedab0db536', class: {
3843
3848
  "s-file-upload": true,
3844
3849
  "s-file-upload-profile-image": this.profileImage,
3845
3850
  "s-file-upload-multiple": this.allowMultiple,
3846
- } }, index.h("input", { key: '5e9cc8cd73e83acbb0a9f04e15e530563e94988b', type: "file", name: this.name, value: this.value, ref: ele => this.fileUploader = ele, required: this.required, class: "s-file-upload-wrapper s-file-upload-input", accept: this.accept }), this.allowMultiple && this.showMaxCountHint ? index.h("div", { class: "s-file-upload-hint s-hidden" }, this.max_count_hint(this.maxFilesCount)) : '', index.h("input", { key: '13a402c070302bfb00d82a24f523a9b764e39037', class: "s-hidden", name: 'hidden-' + this.name, required: this.required, value: this.value, ref: input => this.hiddenInput = input })));
3851
+ } }, index.h("input", { key: 'adef3f296d759850322faf038602143a0239201d', type: "file", name: this.name, value: this.value, ref: ele => this.fileUploader = ele, required: this.required, class: "s-file-upload-wrapper s-file-upload-input", accept: this.accept }), this.allowMultiple && this.showMaxCountHint ? index.h("div", { class: "s-file-upload-hint s-hidden" }, this.max_count_hint(this.maxFilesCount)) : '', index.h("input", { key: 'dc74f8a155eeedd294548f782ed158f1a889b373', class: "s-hidden", name: 'hidden-' + this.name, required: this.required, value: this.value, ref: input => this.hiddenInput = input })));
3847
3852
  }
3848
3853
  componentDidLoad() {
3849
3854
  let files = this.getFiles();
@@ -3926,7 +3931,7 @@ const SallaFileUpload = class {
3926
3931
  process: {
3927
3932
  onload: (response) => {
3928
3933
  let responseData = JSON.parse(response).data;
3929
- if (this.allowMultiple && Array.isArray(responseData) && responseData.length > 0) {
3934
+ if ((this.instantUpload || this.allowMultiple) && Array.isArray(responseData) && responseData.length > 0) {
3930
3935
  const fileId = `${this.host.id}-${Math.floor(100 + Math.random() * 900)}`;
3931
3936
  this.uploadedFiles.push({
3932
3937
  id: fileId,
@@ -3970,6 +3975,11 @@ const SallaFileUpload = class {
3970
3975
  formData.append(this.payloadName, this.filepond.getFile(0).file);
3971
3976
  formData.delete(this.name);
3972
3977
  }
3978
+ if (this.payloadParams) {
3979
+ for (const [k, v] of Object.entries(this.payloadParams)) {
3980
+ formData.append(k, v);
3981
+ }
3982
+ }
3973
3983
  if (this.cartItemId) {
3974
3984
  formData.append('cart_item_id', this.cartItemId);
3975
3985
  }
@@ -7730,13 +7740,6 @@ var Currency;
7730
7740
  Currency["Sar"] = "SAR";
7731
7741
  })(Currency || (Currency = {}));
7732
7742
 
7733
- var CameraIcon = `<!-- Generated by IcoMoon.io -->
7734
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
7735
- <title>camera</title>
7736
- <path d="M16 10.667c-4.044 0-7.333 3.289-7.333 7.333s3.289 7.333 7.333 7.333 7.333-3.289 7.333-7.333-3.289-7.333-7.333-7.333zM16 22.667c-2.573 0-4.667-2.093-4.667-4.667s2.093-4.667 4.667-4.667 4.667 2.093 4.667 4.667-2.093 4.667-4.667 4.667zM28 5.333h-3.287l-2.271-3.407c-0.248-0.371-0.664-0.593-1.109-0.593h-10.667c-0.445 0-0.861 0.223-1.109 0.593l-2.271 3.407h-3.287c-2.205 0-4 1.795-4 4v17.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-17.333c0-2.205-1.795-4-4-4zM29.333 26.667c0 0.735-0.599 1.333-1.333 1.333h-24c-0.735 0-1.333-0.599-1.333-1.333v-17.333c0-0.735 0.599-1.333 1.333-1.333h4c0.445 0 0.861-0.223 1.109-0.593l2.272-3.407h9.239l2.271 3.407c0.248 0.371 0.664 0.593 1.109 0.593h4c0.735 0 1.333 0.599 1.333 1.333zM25.333 10.66c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327z"></path>
7737
- </svg>
7738
- `;
7739
-
7740
7743
  var FileIcon = `<!-- Generated by IcoMoon.io -->
7741
7744
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
7742
7745
  <title>file-upload</title>
@@ -8272,7 +8275,7 @@ const SallaProductOptions = class {
8272
8275
  }
8273
8276
  fileUploader(option, additions = null) {
8274
8277
  return index.h("salla-file-upload", { ...(additions || {}), "payload-name": "file", value: option.value, "instant-upload": true, name: this.generateInputName(option.id), required: !option.visibility_condition && option.required, height: "120px", onAdded: (e) => this.changedHandler(e, option), url: salla.cart.api.getUploadImageEndpoint(), "form-data": { cart_item_id: this.productId, product_id: this.productId }, onInvalidInput: (e) => this.invalidHandler(e, option), class: { "s-product-options-image-input": true, required: option.required } }, index.h("div", { class: "s-product-options-filepond-placeholder" }, index.h("span", { class: "s-product-options-filepond-placeholder-icon", innerHTML: additions.accept?.split(',').every(type => type.includes('image'))
8275
- ? CameraIcon
8278
+ ? interfaces.CameraIcon
8276
8279
  : FileIcon }), index.h("p", { class: "s-product-options-filepond-placeholder-text" }, salla.lang.get('common.uploader.drag_and_drop')), index.h("span", { class: "filepond--label-action" }, salla.lang.get('common.uploader.browse'))));
8277
8280
  }
8278
8281
  //@ts-ignore
@@ -12524,7 +12527,7 @@ const SallaTelInput = class {
12524
12527
  if (this.TelInput)
12525
12528
  return;
12526
12529
  try {
12527
- const telInputModule = await Promise.resolve().then(function () { return require('./index-TCPzRuQa.js'); }).then(function (n) { return n.index; });
12530
+ const telInputModule = await Promise.resolve().then(function () { return require('./index-CYgngxgk.js'); }).then(function (n) { return n.index; });
12528
12531
  this.TelInput = telInputModule.default;
12529
12532
  }
12530
12533
  catch (error) {
@@ -12675,20 +12678,18 @@ var WalletIcon = `<!-- Generated by IcoMoon.io -->
12675
12678
  </svg>
12676
12679
  `;
12677
12680
 
12681
+ var SettingstIcon = `<!-- Generated by IcoMoon.io -->
12682
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
12683
+ <title>settings</title>
12684
+ <path d="M29.717 19.037l-1.817-1.499c0.067-0.512 0.1-1.028 0.1-1.539s-0.033-1.027-0.1-1.54l1.817-1.499c1.177-0.969 1.479-2.633 0.716-3.956l-1.159-2.009c-0.761-1.324-2.349-1.895-3.784-1.359l-2.212 0.829c-0.817-0.627-1.704-1.139-2.649-1.535l-0.388-2.332c-0.251-1.507-1.54-2.6-3.067-2.6h-2.319c-1.525 0-2.815 1.093-3.065 2.6l-0.388 2.332c-0.945 0.396-1.833 0.909-2.649 1.535l-2.212-0.829c-1.428-0.533-3.021 0.036-3.783 1.359l-1.16 2.011c-0.763 1.323-0.46 2.985 0.716 3.955l1.817 1.499c-0.067 0.513-0.1 1.029-0.1 1.54s0.033 1.027 0.1 1.539l-1.819 1.5c-1.176 0.971-1.476 2.635-0.715 3.955l1.159 2.011c0.763 1.324 2.356 1.899 3.784 1.36l2.212-0.831c0.816 0.625 1.703 1.139 2.649 1.535l0.388 2.332c0.251 1.507 1.54 2.6 3.067 2.6h2.319c1.527 0 2.816-1.093 3.065-2.6l0.389-2.332c0.947-0.396 1.833-0.909 2.649-1.535l2.212 0.831c1.432 0.539 3.023-0.035 3.783-1.36l1.16-2.011c0.76-1.32 0.459-2.984-0.717-3.956zM28.123 21.663l-1.16 2.011c-0.108 0.188-0.336 0.267-0.536 0.193l-2.931-1.1c-0.459-0.173-0.979-0.079-1.349 0.248-0.923 0.811-1.979 1.423-3.139 1.819-0.464 0.157-0.804 0.559-0.885 1.043l-0.515 3.087c-0.033 0.215-0.216 0.371-0.433 0.371h-2.319c-0.217 0-0.4-0.156-0.436-0.371l-0.513-3.087c-0.080-0.484-0.42-0.884-0.885-1.043-1.16-0.396-2.216-1.008-3.139-1.819-0.248-0.217-0.561-0.332-0.88-0.332-0.157 0-0.316 0.028-0.469 0.084l-2.931 1.1c-0.199 0.079-0.428-0.004-0.537-0.193l-1.159-2.011c-0.109-0.191-0.067-0.428 0.101-0.568l2.409-1.985c0.379-0.312 0.555-0.807 0.46-1.288-0.119-0.605-0.179-1.219-0.179-1.821 0-0.604 0.060-1.217 0.181-1.823 0.095-0.481-0.081-0.976-0.46-1.288l-2.409-1.985c-0.168-0.139-0.211-0.376-0.101-0.567l1.16-2.011c0.107-0.188 0.332-0.268 0.536-0.193l2.931 1.1c0.459 0.172 0.979 0.079 1.348-0.247 0.924-0.812 1.98-1.424 3.139-1.817 0.465-0.159 0.805-0.559 0.885-1.044l0.513-3.088c0.036-0.215 0.219-0.371 0.436-0.371h2.319c0.217 0 0.4 0.156 0.436 0.371l0.515 3.088c0.081 0.484 0.42 0.885 0.885 1.044 1.157 0.393 2.213 1.005 3.139 1.817 0.371 0.325 0.889 0.42 1.349 0.247l2.929-1.099c0.203-0.076 0.428 0.005 0.537 0.193l1.159 2.009c0.109 0.191 0.067 0.428-0.101 0.567l-2.409 1.985c-0.379 0.312-0.555 0.807-0.46 1.288 0.119 0.605 0.179 1.219 0.179 1.823 0 0.603-0.060 1.216-0.181 1.821-0.095 0.48 0.081 0.975 0.46 1.288l2.408 1.984c0.169 0.141 0.212 0.379 0.103 0.569zM16.016 10.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM16.016 18.667c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>
12685
+ </svg>
12686
+ `;
12687
+
12678
12688
  const sallaUserMenuCss = "";
12679
12689
 
12680
12690
  const SallaUserMenu = class {
12681
12691
  constructor(hostRef) {
12682
12692
  index.registerInstance(this, hostRef);
12683
- this.items = {
12684
- notifications: BellRing,
12685
- orders: OrderIcon,
12686
- pending_orders: PendingOrdersIcon,
12687
- wishlist: WishListIcon,
12688
- profile: UserCircle,
12689
- wallet: WalletIcon,
12690
- loyalty_program: gift.GiftIcon,
12691
- };
12692
12693
  this.accountLoading = false;
12693
12694
  this.opened = false;
12694
12695
  this.notifications = salla.lang.get('common.titles.notifications');
@@ -12698,6 +12699,7 @@ const SallaUserMenu = class {
12698
12699
  this.profile = salla.lang.get('common.titles.profile');
12699
12700
  this.rating = salla.lang.get('common.titles.rating');
12700
12701
  this.wallet = salla.lang.get('common.titles.wallet');
12702
+ this.settings = salla.lang.get('common.titles.settings');
12701
12703
  this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
12702
12704
  this.logout = salla.lang.get('blocks.header.logout');
12703
12705
  this.hello = salla.lang.get('pages.checkout.hello');
@@ -12708,6 +12710,7 @@ const SallaUserMenu = class {
12708
12710
  notifications: salla.helpers.number(salla.storage.get('user.notifications') || 0),
12709
12711
  pending_orders: salla.helpers.number(salla.storage.get('user.pending_orders') || 0),
12710
12712
  };
12713
+ this.sallaAccountEnabled = Salla.config.get('store.features').includes('salla-account');
12711
12714
  this.hasBadges = Number(salla.storage.get('user.pending_orders')) > 0 ||
12712
12715
  Number(salla.storage.get('user.notifications')) > 0;
12713
12716
  /**
@@ -12730,6 +12733,16 @@ const SallaUserMenu = class {
12730
12733
  this.opened = false;
12731
12734
  };
12732
12735
  this.OrderUpdate = 0;
12736
+ this.items = {
12737
+ notifications: BellRing,
12738
+ orders: OrderIcon,
12739
+ pending_orders: PendingOrdersIcon,
12740
+ wishlist: WishListIcon,
12741
+ wallet: WalletIcon,
12742
+ loyalty_program: gift.GiftIcon,
12743
+ profile: UserCircle,
12744
+ ...(this.sallaAccountEnabled ? { settings: SettingstIcon } : {})
12745
+ };
12733
12746
  // salla.auth.event.onLoggedIn(() => {
12734
12747
  // this.is_loggedIn = true
12735
12748
  // })
@@ -12742,6 +12755,7 @@ const SallaUserMenu = class {
12742
12755
  this.hello = salla.lang.get('pages.checkout.hello');
12743
12756
  this.rating = salla.lang.get('common.titles.rating');
12744
12757
  this.wallet = salla.lang.get('common.titles.wallet');
12758
+ this.settings = salla.lang.get('common.titles.settings');
12745
12759
  this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
12746
12760
  this.logout = salla.lang.get('blocks.header.logout');
12747
12761
  });
@@ -12783,8 +12797,9 @@ const SallaUserMenu = class {
12783
12797
  });
12784
12798
  }
12785
12799
  componentWillLoad() {
12786
- return new Promise(resolve => salla.onReady(resolve)).then(() => {
12787
- let trigger = this.host.querySelector('[slot="trigger"]');
12800
+ return salla.onReady().then(() => {
12801
+ this.profileUrl = `${salla.config.get('account.url', 'https://accounts.salla.com')}/${salla.config.get('user.language_code')}/user?store=${salla.config.get('store.id')}&info=${salla.storage.get('token')}`;
12802
+ const trigger = this.host.querySelector('[slot="trigger"]');
12788
12803
  this.triggerSlot =
12789
12804
  '<div class="s-user-menu-trigger"><div class="s-user-menu-avatar-wrap"><img class="s-user-menu-trigger-avatar" src="{avatar}" alt="{first_name}{last_name}" /></div><div class="s-user-menu-trigger-content"><span class="s-user-menu-trigger-hello">{hello}</span><p class="s-user-menu-trigger-name">{first_name} {last_name}</p></div> <i class="s-user-menu-trigger-icon">{icon}</i></div>';
12790
12805
  if (!trigger) {
@@ -12821,8 +12836,8 @@ const SallaUserMenu = class {
12821
12836
  window.addEventListener('click', this.onClickOutside);
12822
12837
  }
12823
12838
  }
12824
- menuItemClicked(event, item) {
12825
- if (item[0] !== 'logout') {
12839
+ menuItemClicked(event, itemKey) {
12840
+ if (itemKey !== 'logout') {
12826
12841
  return;
12827
12842
  }
12828
12843
  event.preventDefault();
@@ -12841,18 +12856,28 @@ const SallaUserMenu = class {
12841
12856
  's-user-menu-trigger-slot': true,
12842
12857
  's-user-menu-red-dot': this.hasBadges,
12843
12858
  's-user-menu-trigger-avatar-only': this.avatarOnly,
12844
- }, id: "trigger-slot", onClick: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
12859
+ }, id: "trigger-slot", onClick: e => this.open(e), onKeyUp: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
12860
+ }
12861
+ getItemAnchorLinkAttrs(itemKey) {
12862
+ if (itemKey === 'profile' && this.profileUrl) {
12863
+ return this.sallaAccountEnabled ?
12864
+ { href: this.profileUrl, target: '_blank', rel: 'noopener noreferrer' } :
12865
+ { href: '/profile' };
12866
+ }
12867
+ // Fix loyalty program URL mapping from master
12868
+ const urlKey = itemKey === 'loyalty_program' ? 'loyalty' : itemKey;
12869
+ return { href: salla.url.get(urlKey) };
12845
12870
  }
12846
- getMenuItem(item, i) {
12871
+ getMenuItem([itemKey, itemValue], i) {
12847
12872
  //todo:: enhancement support slot here
12848
- if (item[0] === 'wallet' && !window.can_access_wallet)
12873
+ if (itemKey === 'wallet' && !window.can_access_wallet)
12849
12874
  return;
12850
- if (item[0] === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
12875
+ if (itemKey === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
12851
12876
  return;
12852
12877
  return (index.h("li", { class: {
12853
12878
  's-user-menu-dropdown-item': true,
12854
- 's-user-menu-dropdown-item-logout': i + 1 == Object.entries(this.items).length,
12855
- } }, index.h("a", { href: salla.url.get(item[0] === 'loyalty_program' ? 'loyalty' : item[0]), onClick: event => this.menuItemClicked(event, item) }, index.h("i", { innerHTML: item[1] }, " "), index.h("span", { class: "s-user-menu-dropdown-item-title" }, this[item[0]]), !['٠', '0', undefined].includes(this.badges[item[0]]) ? (index.h("span", { class: "s-user-menu-dropdown-item-badge" }, this.badges[item[0]])) : (''))));
12879
+ 's-user-menu-dropdown-item-logout': i + 1 === Object.entries(this.items).length,
12880
+ } }, index.h("a", { ...this.getItemAnchorLinkAttrs(itemKey), class: "s-user-menu-dropdown-item-link", onClick: event => this.menuItemClicked(event, itemKey) }, index.h("i", { class: "s-user-menu-dropdown-item-prefix", innerHTML: itemValue }), index.h("span", { class: "s-user-menu-dropdown-item-title" }, this[itemKey]), !['٠', '0', undefined].includes(this.badges[itemKey]) ? (index.h("span", { class: "s-user-menu-dropdown-item-badge" }, this.badges[itemKey])) : (''))));
12856
12881
  }
12857
12882
  componentShouldUpdate() {
12858
12883
  if (!this.opened) {
@@ -12861,7 +12886,7 @@ const SallaUserMenu = class {
12861
12886
  }
12862
12887
  render() {
12863
12888
  if (!this.is_loggedIn) {
12864
- return (index.h(index.Host, null, index.h("slot", { name: "login-btn" }, index.h("button", { class: "s-user-menu-login-btn", onClick: () => salla.event.dispatch('login::open'), innerHTML: UserCircle }))));
12889
+ return (index.h(index.Host, null, index.h("slot", { name: "login-btn" }, index.h("button", { type: "button", class: "s-user-menu-login-btn", onClick: () => salla.event.dispatch('login::open'), innerHTML: UserCircle }))));
12865
12890
  }
12866
12891
  if (this.inline) {
12867
12892
  return (index.h(index.Host, null, index.h("ul", { class: "s-user-menu-inline" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i)))));
@@ -12869,27 +12894,15 @@ const SallaUserMenu = class {
12869
12894
  return (index.h(index.Host, null, index.h("div", { class: {
12870
12895
  's-user-menu-wrapper': true,
12871
12896
  's-user-menu-relative-dropdown': this.relativeDropdown,
12872
- } }, this.getTheHeader(), index.h("div", { class: { 's-user-menu-toggler': true, opened: this.opened } }, index.h("div", { class: "s-user-menu-dropdown", onClick: e => e.stopPropagation() }, this.showHeader ? (index.h("div", { class: "s-user-menu-dropdown-header" }, index.h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), index.h("div", { class: "s-user-menu-dropdown-header-content" }, index.h("span", null, this.hello), index.h("p", null, this.first_name, " ", this.last_name)), index.h("button", { class: "s-user-menu-dropdown-header-close", innerHTML: Cancel, onClick: () => (this.opened = false) }))) : (''), index.h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
12897
+ } }, this.getTheHeader(), index.h("div", { class: { 's-user-menu-toggler': true, opened: this.opened } }, index.h("div", { class: "s-user-menu-dropdown", onClick: e => e.stopPropagation(), onKeyUp: e => e.stopPropagation() }, this.showHeader ? (index.h("div", { class: "s-user-menu-dropdown-header" }, index.h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), index.h("div", { class: "s-user-menu-dropdown-header-content" }, index.h("span", null, this.hello), index.h("p", null, this.first_name, " ", this.last_name)), index.h("button", { type: 'button', class: "s-user-menu-dropdown-header-close", innerHTML: Cancel, onClick: () => { this.opened = false; } }))) : (''), index.h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
12873
12898
  }
12874
12899
  componentDidLoad() {
12875
- //make sure to load the avatar if it's lazy, we use it in Y
12876
12900
  document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));
12877
12901
  }
12878
12902
  get host() { return index.getElement(this); }
12879
12903
  };
12880
12904
  SallaUserMenu.style = sallaUserMenuCss;
12881
12905
 
12882
- var Genders;
12883
- (function (Genders) {
12884
- Genders["Female"] = "female";
12885
- Genders["Male"] = "male";
12886
- })(Genders || (Genders = {}));
12887
- var FormFieldTypes;
12888
- (function (FormFieldTypes) {
12889
- FormFieldTypes["Photo"] = "photo";
12890
- FormFieldTypes["Text"] = "Text";
12891
- })(FormFieldTypes || (FormFieldTypes = {}));
12892
-
12893
12906
  const sallaUserProfileCss = ":host{display:block}";
12894
12907
 
12895
12908
  const SallaUserProfile = class {
@@ -12899,7 +12912,6 @@ const SallaUserProfile = class {
12899
12912
  /**
12900
12913
  * The minimum allowed age for a user. Users with a birthdate indicating an age less than this value will be considered invalid.
12901
12914
  * Defaults to 10.
12902
- * @type {number}
12903
12915
  */
12904
12916
  this.minAge = 10;
12905
12917
  this.isEditable = true;
@@ -12946,20 +12958,13 @@ const SallaUserProfile = class {
12946
12958
  });
12947
12959
  });
12948
12960
  }
12949
- /**
12950
- * Sets custom fields for the component. Can be handy for non HTML usage.
12951
- *
12952
- * @param fields - An array of custom fields.
12953
- */
12954
- async setCustomFields(fields) {
12955
- this.userDefinedFields = fields;
12956
- }
12957
12961
  // Event handler for phone number field changes
12958
12962
  phoneNumberFieldEventHandler(data) {
12959
12963
  if (!data.detail.number) {
12960
- return (this.disableAction = true);
12964
+ this.disableAction = true;
12965
+ return;
12961
12966
  }
12962
- this.userData.phone.number = parseInt(data.detail.number);
12967
+ this.userData.phone.number = Number.parseInt(data.detail.number);
12963
12968
  this.userData.phone.country = data.detail.country_code;
12964
12969
  this.disableAction = false;
12965
12970
  }
@@ -12975,74 +12980,34 @@ const SallaUserProfile = class {
12975
12980
  }
12976
12981
  }
12977
12982
  }
12978
- // Event handler for file upload changes
12979
- handleOnFileAdded(key, data) {
12980
- // TODO: the key in here, shall be not have whitespace. or the key for
12981
- // the field shall be provided with one of the properties of the custom field
12982
- if (!data.detail.error) {
12983
- this.userData[key] = data.detail.file;
12984
- this.disableAction = false;
12985
- }
12986
- else {
12987
- this.disableAction = true;
12988
- }
12989
- }
12990
12983
  // Event handler for email input changes
12991
12984
  handleEmailInput(key, event) {
12992
12985
  const emailErrorDisplaySection = document.getElementById('email-error');
12993
12986
  const email = event.target.value;
12994
12987
  if (!email) {
12995
12988
  this.disableAction = true;
12996
- return (emailErrorDisplaySection.textContent = this.email_required_trans);
12989
+ emailErrorDisplaySection.textContent = this.email_required_trans;
12990
+ return;
12997
12991
  }
12998
12992
  const emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
12999
12993
  if (!emailPattern.test(email)) {
13000
12994
  this.disableAction = true;
13001
- return (emailErrorDisplaySection.textContent = this.invalid_email_trans);
12995
+ emailErrorDisplaySection.textContent = this.invalid_email_trans;
13002
12996
  }
13003
12997
  emailErrorDisplaySection.textContent = '';
13004
12998
  this.userData[key] = email;
13005
12999
  this.disableAction = false;
13006
13000
  }
13007
- // Helper method to trim language code from URL
13008
- trimLanguageCodeFromUrl(url, languageCode) {
13009
- const pattern = new RegExp(`^(https?://[^/]+)\\/${languageCode}(.*)`, 'i');
13010
- const match = url.replace(/\/+$/, '').match(pattern);
13011
- if (match && match.length >= 2) {
13012
- const [, baseUrl, restOfUrl] = match;
13013
- return baseUrl + restOfUrl;
13014
- }
13015
- return url;
13016
- }
13017
- // Helper method to get file upload URL
13018
- getFileUploadUrl() {
13019
- return `${this.trimLanguageCodeFromUrl(salla.config.get('store.url'), salla.config.get('user.language_code'))}/upload-image`;
13020
- }
13021
- // Render custom fields based on user-defined fields
13022
- renderCustomFields() {
13023
- if (!this.userDefinedFields) {
13024
- return '';
13025
- }
13026
- return this.userDefinedFields.map((field) => {
13027
- return (index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: `${field.id}`, class: "s-user-profile-field-label" }, field.label), this.renderCustomField(field)));
13028
- });
13029
- }
13030
- renderCustomField(field) {
13031
- if (field.type !== FormFieldTypes.Photo) {
13032
- return (index.h("input", { type: field.type, id: `${field.id}`, value: field.value, onChange: event => this.handleFieldChange(`custom_fields[${field.id}]`, event), name: `custom_fields[${field.id}]`, class: "form-input", required: field.required }));
13033
- }
13034
- return (index.h("salla-file-upload", { "instant-upload": true, value: field.value, url: this.getFileUploadUrl(), name: `custom_fields[${field.id}]`, "payload-name": "image", height: "120px", onAdded: data => this.handleOnFileAdded(`custom_fields[${field.id}]`, data) }, index.h("div", { class: "s-user-profile-filepond-placeholder" }, index.h("span", { class: "s-user-profile-filepond-placeholder-icon" }, index.h("i", { innerHTML: CameraIcon })), index.h("p", { class: "s-user-profile-filepond-placeholder-text" }, this.drag_and_drop_trans), index.h("span", { class: "filepond--label-action" }, this.browse_trans))));
13035
- }
13036
13001
  // Submit form method
13037
13002
  submitForm(event) {
13038
13003
  event.preventDefault();
13039
13004
  this.disableAction = true;
13040
- let payload = Object.assign({}, this.userData);
13041
- delete payload.phone;
13005
+ const payload = Object.assign({}, this.userData);
13006
+ payload.phone = undefined;
13042
13007
  //@ts-ignore
13043
- payload['phone'] = this.userData.phone.number;
13044
- payload['country_code'] = this.userData.phone.country;
13045
- return salla.api.profile.update(payload).finally(() => (this.disableAction = false));
13008
+ payload.phone = this.userData.phone.number;
13009
+ payload.country_code = this.userData.phone.country;
13010
+ salla.api.profile.update(payload).finally(() => { this.disableAction = false; });
13046
13011
  }
13047
13012
  getBirthDateRestriction() {
13048
13013
  const now = new Date();
@@ -13051,19 +13016,9 @@ const SallaUserProfile = class {
13051
13016
  return now;
13052
13017
  }
13053
13018
  fetchData() {
13054
- let customFields = null;
13055
- // Load user-defined fields and initial user data
13056
- if (this.customFields) {
13057
- customFields = typeof this.customFields === 'string'
13058
- ? JSON.parse(this.customFields)
13059
- : this.customFields;
13060
- }
13061
- if (customFields && Array.isArray(customFields)) {
13062
- this.userDefinedFields = customFields;
13063
- }
13064
13019
  return salla.api.profile
13065
13020
  .info()
13066
- .then(resp => (this.userData = resp.data))
13021
+ .then(resp => { this.userData = resp.data; })
13067
13022
  .finally(() => {
13068
13023
  this.isLoading = false;
13069
13024
  this.isEditable = !Salla.config.get('store.features').includes('sso-login');
@@ -13079,7 +13034,7 @@ const SallaUserProfile = class {
13079
13034
  if (this.isLoading) {
13080
13035
  return this.renderLoadingSection();
13081
13036
  }
13082
- return (index.h("form", { onSubmit: event => this.submitForm(event) }, index.h("div", { class: "s-user-profile-wrapper" }, index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "first-name", class: "s-user-profile-field-label" }, this.first_name_trans), index.h("input", { disabled: !this.isEditable, type: "text", name: "first_name", value: this.userData.first_name, id: "first-name", required: true, autocomplete: "first_name", class: "form-input", onChange: event => this.handleFieldChange('first_name', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "last-name", class: "s-user-profile-field-label" }, this.last_name_trans), index.h("input", { disabled: !this.isEditable, type: "text", name: "last_name", value: this.userData.last_name, id: "last-name", required: true, autocomplete: "last_name", class: "form-input", onChange: event => this.handleFieldChange('last_name', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "birthday", class: "s-user-profile-field-label" }, this.birthday_trans), index.h("salla-datetime-picker", { disabled: !this.isEditable, dateFormat: "Y-m-d", value: this.userData.birthday, placeholder: this.birthday_placeholder_trans, required: true, maxDate: this.getBirthDateRestriction(), name: "birthday", onPicked: event => this.handleFieldChange('birthday', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "gender", class: "s-user-profile-field-label" }, this.gender_trans), index.h("select", { disabled: !this.isEditable, class: "form-input", name: "gender", required: true, onChange: event => this.handleFieldChange('gender', event) }, index.h("option", { value: "" }, this.gender_placeholder_trans), index.h("option", { value: Genders.Male, selected: this.userData.gender == Genders.Male }, this.male_trans), index.h("option", { value: Genders.Female, selected: this.userData.gender == Genders.Female }, this.female_trans))), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "email", class: "s-user-profile-field-label" }, this.email_trans), index.h("input", { disabled: !this.isEditable, type: "email", name: "email", value: this.userData.email, id: "email", class: "form-input", required: true, onInput: event => this.handleEmailInput('email', event) }), index.h("p", { id: "email-error", class: "s-user-profile-field-error" })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "international-mobile", class: "s-user-profile-field-label" }, this.mobile_trans), index.h("salla-tel-input", { disabled: !this.isEditable, name: "international-mobile", "country-code": this.userData.phone.country, phone: `${this.userData.phone.number}`, onPhoneEntered: data => this.phoneNumberFieldEventHandler(data) })), this.isEditable && this.renderCustomFields()), index.h("salla-button", { type: "submit", loading: this.disableAction, disabled: this.disableAction || !this.isEditable, "loader-position": "end", class: "s-user-profile-submit" }, this.save_btn_trans)));
13037
+ return (index.h("form", { onSubmit: event => this.submitForm(event) }, index.h("div", { class: "s-user-profile-wrapper" }, index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "first-name", class: "s-user-profile-field-label" }, this.first_name_trans), index.h("input", { disabled: !this.isEditable, type: "text", name: "first_name", value: this.userData.first_name, id: "first-name", required: true, autocomplete: "first_name", class: "form-input", onChange: event => this.handleFieldChange('first_name', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "last-name", class: "s-user-profile-field-label" }, this.last_name_trans), index.h("input", { disabled: !this.isEditable, type: "text", name: "last_name", value: this.userData.last_name, id: "last-name", required: true, autocomplete: "last_name", class: "form-input", onChange: event => this.handleFieldChange('last_name', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "birthday", class: "s-user-profile-field-label" }, this.birthday_trans), index.h("salla-datetime-picker", { disabled: !this.isEditable, dateFormat: "Y-m-d", value: this.userData.birthday, placeholder: this.birthday_placeholder_trans, required: true, maxDate: this.getBirthDateRestriction(), name: "birthday", onPicked: event => this.handleFieldChange('birthday', event) })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "gender", class: "s-user-profile-field-label" }, this.gender_trans), index.h("select", { disabled: !this.isEditable, class: "form-input", name: "gender", required: true, onChange: event => this.handleFieldChange('gender', event) }, index.h("option", { value: "" }, this.gender_placeholder_trans), index.h("option", { value: interfaces.Genders.Male, selected: this.userData.gender === interfaces.Genders.Male }, this.male_trans), index.h("option", { value: interfaces.Genders.Female, selected: this.userData.gender === interfaces.Genders.Female }, this.female_trans))), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "email", class: "s-user-profile-field-label" }, this.email_trans), index.h("input", { disabled: !this.isEditable, type: "email", name: "email", value: this.userData.email, id: "email", class: "form-input", required: true, onInput: event => this.handleEmailInput('email', event) }), index.h("p", { id: "email-error", class: "s-user-profile-field-error" })), index.h("div", { class: "s-user-profile-field" }, index.h("label", { htmlFor: "international-mobile", class: "s-user-profile-field-label" }, this.mobile_trans), index.h("salla-tel-input", { disabled: !this.isEditable, name: "international-mobile", "country-code": this.userData.phone.country, phone: `${this.userData.phone.number}`, onPhoneEntered: data => this.phoneNumberFieldEventHandler(data) }))), index.h("salla-button", { type: "submit", loading: this.disableAction, disabled: this.disableAction || !this.isEditable, "loader-position": "end", class: "s-user-profile-submit" }, this.save_btn_trans)));
13083
13038
  }
13084
13039
  };
13085
13040
  SallaUserProfile.style = sallaUserProfileCss;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
  var anime_es = require('./anime.es-BqW8JHZi.js');
8
8
 
9
9
  const sallaAdvertisementCss = ":host{display:block}";
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
 
8
8
  const sallaAppInstallAlertCss = ":host{display:block}";
9
9
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
 
8
8
  const sallaAppsIconsCss = ":host{display:block}";
9
9
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
  var specialDiscount = require('./special-discount-OVG_9Kf9.js');
8
8
  var gift = require('./gift-BPDUPIY_.js');
9
9
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
 
8
8
  var DiscountType;
9
9
  (function (DiscountType) {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-CMFmTYR8.js');
6
+ var index = require('./index-Bc1Blm9E.js');
7
7
  var whatsapp2 = require('./whatsapp2-D7Sbg8Ey.js');
8
8
  var mail = require('./mail-CO8cFZH7.js');
9
9
 
@@ -0,0 +1,135 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ 'use strict';
5
+
6
+ var index = require('./index-Bc1Blm9E.js');
7
+ var interfaces = require('./interfaces-CX9-6aLf.js');
8
+
9
+ const sallaCustomFieldsCss = ":host{display:block}";
10
+
11
+ const SallaCustomFields = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.fieldChanged = index.createEvent(this, "fieldChanged");
15
+ this.fileUploaded = index.createEvent(this, "fileUploaded");
16
+ this.isEditable = true;
17
+ this.fieldErrors = {};
18
+ this.isSubmitting = false;
19
+ }
20
+ get dragAndDropText() {
21
+ return salla.lang.get("common.uploader.drag_and_drop");
22
+ }
23
+ get browseText() {
24
+ return salla.lang.get("common.uploader.browse");
25
+ }
26
+ get saveButtonText() {
27
+ return salla.lang.get("common.elements.save");
28
+ }
29
+ async setFields(fields) {
30
+ this.parsedFields = fields;
31
+ }
32
+ async getFieldValues() {
33
+ return this.parsedFields?.reduce((values, field) => {
34
+ values[`custom_fields[${field.id}]`] = field.value;
35
+ return values;
36
+ }, {}) || {};
37
+ }
38
+ async validateFields() {
39
+ if (!this.parsedFields)
40
+ return true;
41
+ const errors = this.parsedFields.reduce((acc, field) => {
42
+ if (field.required && (!field.value || field.value === "")) {
43
+ acc[field.id.toString()] = `${field.label} is required`;
44
+ }
45
+ return acc;
46
+ }, {});
47
+ this.fieldErrors = errors;
48
+ return Object.keys(errors).length === 0;
49
+ }
50
+ handleFieldChange(field, event) {
51
+ const value = event.target.value;
52
+ field.value = value;
53
+ this.clearFieldError(field.id);
54
+ const isValid = !(field.required && !value);
55
+ if (!isValid) {
56
+ this.setFieldError(field.id, `${field.label} is required`);
57
+ }
58
+ this.fieldChanged.emit({ fieldId: field.id, value, isValid });
59
+ }
60
+ handleFileUpload(field, event) {
61
+ const { error, file } = event.detail;
62
+ const isValid = !error;
63
+ this.clearFieldError(field.id);
64
+ if (isValid) {
65
+ field.value = file;
66
+ }
67
+ else {
68
+ this.setFieldError(field.id, "File upload failed");
69
+ }
70
+ this.fileUploaded.emit({ fieldId: field.id, file, isValid });
71
+ }
72
+ clearFieldError(fieldId) {
73
+ this.fieldErrors = { ...this.fieldErrors };
74
+ delete this.fieldErrors[fieldId];
75
+ }
76
+ setFieldError(fieldId, message) {
77
+ this.fieldErrors = { ...this.fieldErrors, [fieldId]: message };
78
+ }
79
+ renderTextField(field) {
80
+ return (index.h("input", { disabled: !this.isEditable, type: field.type, id: `custom-field-${field.id}`, value: field.value?.toString() || "", onChange: (e) => this.handleFieldChange(field, e), name: `${field.id}`, class: "form-input", required: field.required }));
81
+ }
82
+ renderFileField(field) {
83
+ return (index.h("salla-file-upload", { url: salla.url.api('upload'), id: `custom-field-${field.id}`, name: `${field.id}`, type: "registration", value: field.value, height: "120px", onAdded: (e) => this.handleFileUpload(field, e), required: field.required, disabled: !this.isEditable, onUploaded: e => { e.target.value = e.target.value?.url; }, allowRemove: true, onRemoved: (e) => {
84
+ e.preventDefault();
85
+ e.stopPropagation();
86
+ field.value = "";
87
+ e.target.value = "";
88
+ }, payloadName: "files[]", payloadParams: { type: 'registration' }, "instant-upload": true }, index.h("div", { class: "s-custom-fields-filepond-placeholder" }, index.h("span", { class: "s-custom-fields-filepond-placeholder-icon" }, index.h("i", { innerHTML: interfaces.CameraIcon })), index.h("p", { class: "s-custom-fields-filepond-placeholder-text" }, this.dragAndDropText), index.h("span", { class: "filepond--label-action" }, this.browseText))));
89
+ }
90
+ renderField(field) {
91
+ return (index.h("div", { class: "s-custom-fields-field", key: field.id }, index.h("label", { class: "s-custom-fields-field-label", htmlFor: `custom-field-${field.id}` }, field.label, field.required && index.h("span", { class: "s-custom-fields-required" }, "*")), index.h("div", null, field.type === interfaces.FormFieldTypes.Photo
92
+ ? this.renderFileField(field)
93
+ : this.renderTextField(field), this.fieldErrors[field.id] && (index.h("p", { class: "s-custom-fields-error" }, this.fieldErrors[field.id])))));
94
+ }
95
+ componentWillLoad() {
96
+ this.parsedFields = this.parseFields(this.fields);
97
+ }
98
+ parseFields(fields) {
99
+ if (!fields)
100
+ return [];
101
+ return typeof fields === "string"
102
+ ? JSON.parse(fields)
103
+ : Array.isArray(fields) ? fields : [];
104
+ }
105
+ async handleSubmit(e) {
106
+ e.preventDefault();
107
+ this.isSubmitting = true;
108
+ try {
109
+ const payload = {};
110
+ const form = e.target;
111
+ const elements = form.elements;
112
+ for (let i = 0; i < elements.length; i++) {
113
+ const element = elements[i];
114
+ if (element.name && !element.name.startsWith("hidden") && element.value) {
115
+ payload[element.name] = element.value;
116
+ }
117
+ }
118
+ await salla.api.profile.updateCustomFields({
119
+ id: salla.config.get("store.id"),
120
+ fields: payload,
121
+ });
122
+ }
123
+ finally {
124
+ this.isSubmitting = false;
125
+ }
126
+ }
127
+ render() {
128
+ if (!this.parsedFields?.length)
129
+ return null;
130
+ return (index.h("form", { class: "s-custom-fields-wrapper", onSubmit: this.handleSubmit }, this.parsedFields.map(field => this.renderField(field)), index.h("salla-button", { type: "submit", loading: this.isSubmitting, disabled: this.isSubmitting || !this.isEditable, "loader-position": "end", class: "s-custom-fields-submit-btn" }, this.saveButtonText)));
131
+ }
132
+ };
133
+ SallaCustomFields.style = sallaCustomFieldsCss;
134
+
135
+ exports.salla_custom_fields = SallaCustomFields;