@salla.sa/twilight-components 2.14.294 → 2.14.296

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 (161) hide show
  1. package/dist/cjs/{filepond-CGGCjN56.js → filepond-E7NOvLwV.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-CSZViO2Z.js → filepond-plugin-file-poster-D3bKYBq5.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-E6Gv15oF.js → filepond-plugin-file-validate-size-D4sJa2nT.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-CPyu8pxB.js → filepond-plugin-file-validate-type-DDz99ei0.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CSNer-A5.js → filepond-plugin-image-edit-yDHuyk0R.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-DEzwTEOc.js → filepond-plugin-image-exif-orientation-hj89JJI_.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CFGHrSPe.js → filepond-plugin-image-preview-UoTioUkG.js} +1 -1
  8. package/dist/cjs/{index-COQqEmIG.js → index-BZQAN2JT.js} +1 -1
  9. package/dist/cjs/{index-BKN6oqfk.js → index-BfEIQrIk.js} +6 -2
  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 +66 -117
  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-product-options/salla-product-options.js +1 -1
  52. package/dist/collection/components/salla-user-menu/salla-user-menu.js +25 -14
  53. package/dist/collection/components/salla-user-profile/salla-user-profile.js +15 -132
  54. package/dist/components/index.js +2 -2
  55. package/dist/components/interfaces.js +15 -0
  56. package/dist/components/salla-custom-fields.d.ts +11 -0
  57. package/dist/components/salla-custom-fields.js +174 -0
  58. package/dist/components/salla-file-upload2.js +13 -3
  59. package/dist/components/salla-product-options2.js +1 -1
  60. package/dist/components/salla-user-menu.js +31 -14
  61. package/dist/components/salla-user-profile.js +19 -97
  62. package/dist/esm/{filepond-9s_hrH-T.js → filepond-BEN4Pt87.js} +1 -1
  63. package/dist/esm/{filepond-plugin-file-poster-B0Eow32y.js → filepond-plugin-file-poster-B7t9aVVy.js} +1 -1
  64. package/dist/esm/{filepond-plugin-file-validate-size-Cqzs4jCA.js → filepond-plugin-file-validate-size-DFkfdHfo.js} +1 -1
  65. package/dist/esm/{filepond-plugin-file-validate-type-uJfZLwRE.js → filepond-plugin-file-validate-type-CU-RnplM.js} +1 -1
  66. package/dist/esm/{filepond-plugin-image-edit-Ck70H3zM.js → filepond-plugin-image-edit-Dz3oYXef.js} +1 -1
  67. package/dist/esm/{filepond-plugin-image-exif-orientation-BB-xgO8T.js → filepond-plugin-image-exif-orientation-DJrUnj97.js} +1 -1
  68. package/dist/esm/{filepond-plugin-image-preview-CO4zuhvC.js → filepond-plugin-image-preview-BCWlifYd.js} +1 -1
  69. package/dist/esm/{index-BzYM6G5p.js → index-bXg2F_NN.js} +6 -2
  70. package/dist/esm/{index-CTrhtRUR.js → index-fxSENfiU.js} +1 -1
  71. package/dist/esm/interfaces-CBT_Nxny.js +22 -0
  72. package/dist/esm/loader.js +3 -3
  73. package/dist/esm/salla-accordion_62.entry.js +65 -116
  74. package/dist/esm/salla-advertisement.entry.js +1 -1
  75. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  76. package/dist/esm/salla-apps-icons.entry.js +1 -1
  77. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  78. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  79. package/dist/esm/salla-contacts.entry.js +1 -1
  80. package/dist/esm/salla-custom-fields.entry.js +133 -0
  81. package/dist/esm/salla-filters-widget.entry.js +1 -1
  82. package/dist/esm/salla-filters.entry.js +1 -1
  83. package/dist/esm/salla-installment.entry.js +1 -1
  84. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  85. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  86. package/dist/esm/salla-metadata.entry.js +1 -1
  87. package/dist/esm/salla-notification-item.entry.js +1 -1
  88. package/dist/esm/salla-notifications.entry.js +1 -1
  89. package/dist/esm/salla-offer.entry.js +1 -1
  90. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  91. package/dist/esm/salla-order-details-options.entry.js +1 -1
  92. package/dist/esm/salla-order-details.entry.js +1 -1
  93. package/dist/esm/salla-order-summary.entry.js +1 -1
  94. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  95. package/dist/esm/salla-orders.entry.js +1 -1
  96. package/dist/esm/salla-payments.entry.js +1 -1
  97. package/dist/esm/salla-price-range.entry.js +1 -1
  98. package/dist/esm/salla-review-card.entry.js +1 -1
  99. package/dist/esm/salla-reviews-page.entry.js +1 -1
  100. package/dist/esm/salla-reviews.entry.js +1 -1
  101. package/dist/esm/salla-social.entry.js +1 -1
  102. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  103. package/dist/esm/salla-tooltip.entry.js +1 -1
  104. package/dist/esm/salla-trust-badges.entry.js +1 -1
  105. package/dist/esm/salla-verify.entry.js +1 -1
  106. package/dist/esm/salla-wallet.entry.js +1 -1
  107. package/dist/esm/twilight.js +3 -3
  108. package/dist/twilight/{p-4e11facd.entry.js → p-0645c8e3.entry.js} +1 -1
  109. package/dist/twilight/{p-5a86632d.entry.js → p-0b970445.entry.js} +1 -1
  110. package/dist/twilight/{p-394506f0.entry.js → p-193bea42.entry.js} +1 -1
  111. package/dist/twilight/{p-B86wiAo3.js → p-1Xk7fjpB.js} +1 -1
  112. package/dist/twilight/{p-9757dde8.entry.js → p-1b7cfbae.entry.js} +1 -1
  113. package/dist/twilight/{p-03c963db.entry.js → p-22f479da.entry.js} +1 -1
  114. package/dist/twilight/{p-97dc4af6.entry.js → p-32512487.entry.js} +1 -1
  115. package/dist/twilight/{p-e0414354.entry.js → p-4dd68813.entry.js} +1 -1
  116. package/dist/twilight/{p-d267acaf.entry.js → p-4fb7f400.entry.js} +1 -1
  117. package/dist/twilight/{p-f494e503.entry.js → p-51ef83f7.entry.js} +1 -1
  118. package/dist/twilight/{p-2c65b54d.entry.js → p-56dde07a.entry.js} +1 -1
  119. package/dist/twilight/p-5dd1b37c.entry.js +4 -0
  120. package/dist/twilight/{p-3c2fd683.entry.js → p-5f247331.entry.js} +1 -1
  121. package/dist/twilight/{p-dce21b0f.entry.js → p-67ed25a4.entry.js} +1 -1
  122. package/dist/twilight/{p-7bc8f5f2.entry.js → p-7012bda9.entry.js} +1 -1
  123. package/dist/twilight/{p-5e2486f2.entry.js → p-732c5190.entry.js} +1 -1
  124. package/dist/twilight/{p-a887c4e9.entry.js → p-76657684.entry.js} +1 -1
  125. package/dist/twilight/{p-cda63906.entry.js → p-8220b125.entry.js} +1 -1
  126. package/dist/twilight/{p-ce99c462.entry.js → p-8d3f2028.entry.js} +1 -1
  127. package/dist/twilight/{p-bf81d2cb.entry.js → p-988ea6cb.entry.js} +1 -1
  128. package/dist/twilight/{p-a2e4c4e9.entry.js → p-9f42e27b.entry.js} +1 -1
  129. package/dist/twilight/{p-uGfP8-tV.js → p-BIRmkG1d.js} +1 -1
  130. package/dist/twilight/{p-DZjKCWKU.js → p-BW8LVXVp.js} +2 -2
  131. package/dist/twilight/p-CBT_Nxny.js +4 -0
  132. package/dist/twilight/{p-CDmVMECr.js → p-CD5i_50p.js} +1 -1
  133. package/dist/twilight/{p-CczoUZzK.js → p-CP2LDZCD.js} +1 -1
  134. package/dist/twilight/{p-5M19N20S.js → p-CWkLySV3.js} +1 -1
  135. package/dist/twilight/{p-CZPa2uSm.js → p-CoLlt5es.js} +1 -1
  136. package/dist/twilight/{p-3de1d08f.entry.js → p-a6ebba30.entry.js} +1 -1
  137. package/dist/twilight/p-bXg2F_NN.js +5 -0
  138. package/dist/twilight/{p-4ef533e4.entry.js → p-c5afe02a.entry.js} +1 -1
  139. package/dist/twilight/{p-881a41b7.entry.js → p-c691fd39.entry.js} +1 -1
  140. package/dist/twilight/{p-0d5c3afe.entry.js → p-c848e1d3.entry.js} +1 -1
  141. package/dist/twilight/{p-5c3aacf5.entry.js → p-c88d32f0.entry.js} +1 -1
  142. package/dist/twilight/p-d08cedb0.entry.js +11 -0
  143. package/dist/twilight/{p-bb15a2d4.entry.js → p-dcd9e688.entry.js} +1 -1
  144. package/dist/twilight/{p-823202a3.entry.js → p-dd84065f.entry.js} +1 -1
  145. package/dist/twilight/{p-f3b2d756.entry.js → p-e4418e6f.entry.js} +1 -1
  146. package/dist/twilight/{p-d35d16fd.entry.js → p-ef3a4d3e.entry.js} +1 -1
  147. package/dist/twilight/{p-e4e3ed35.entry.js → p-ef9ac6cb.entry.js} +1 -1
  148. package/dist/twilight/{p-f7c29e31.entry.js → p-f4549e2e.entry.js} +1 -1
  149. package/dist/twilight/{p-454504b2.entry.js → p-fa379f1e.entry.js} +1 -1
  150. package/dist/twilight/{p-2b23018d.entry.js → p-fcd1344e.entry.js} +1 -1
  151. package/dist/twilight/{p-Ie0stZTt.js → p-k3nBgoPC.js} +1 -1
  152. package/dist/twilight/twilight.esm.js +1 -1
  153. package/dist/types/components/salla-custom-fields/salla-custom-fields.d.ts +39 -0
  154. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +4 -0
  155. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +4 -1
  156. package/dist/types/components/salla-user-profile/interfaces.d.ts +1 -0
  157. package/dist/types/components/salla-user-profile/salla-user-profile.d.ts +1 -20
  158. package/dist/types/components.d.ts +74 -25
  159. package/package.json +5 -5
  160. package/dist/twilight/p-29f0ab1e.entry.js +0 -11
  161. package/dist/twilight/p-BzYM6G5p.js +0 -5
@@ -3,12 +3,13 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-CGGCjN56.js'); }).then(function (n) { return n.filepond; }),
3547
- Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-size-E6Gv15oF.js'); }).then(function (n) { return n.filepondPluginFileValidateSize; }),
3548
- Promise.resolve().then(function () { return require('./filepond-plugin-image-exif-orientation-DEzwTEOc.js'); }).then(function (n) { return n.filepondPluginImageExifOrientation; }),
3549
- Promise.resolve().then(function () { return require('./filepond-plugin-image-preview-CFGHrSPe.js'); }).then(function (n) { return n.filepondPluginImagePreview; }),
3550
- Promise.resolve().then(function () { return require('./filepond-plugin-image-edit-CSNer-A5.js'); }).then(function (n) { return n.filepondPluginImageEdit; }),
3551
- Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-type-CPyu8pxB.js'); }).then(function (n) { return n.filepondPluginFileValidateType; }),
3552
- Promise.resolve().then(function () { return require('./filepond-plugin-file-poster-CSZViO2Z.js'); }).then(function (n) { return n.filepondPluginFilePoster; })
3547
+ Promise.resolve().then(function () { return require('./filepond-E7NOvLwV.js'); }).then(function (n) { return n.filepond; }),
3548
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-size-D4sJa2nT.js'); }).then(function (n) { return n.filepondPluginFileValidateSize; }),
3549
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-exif-orientation-hj89JJI_.js'); }).then(function (n) { return n.filepondPluginImageExifOrientation; }),
3550
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-preview-UoTioUkG.js'); }).then(function (n) { return n.filepondPluginImagePreview; }),
3551
+ Promise.resolve().then(function () { return require('./filepond-plugin-image-edit-yDHuyk0R.js'); }).then(function (n) { return n.filepondPluginImageEdit; }),
3552
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-type-DDz99ei0.js'); }).then(function (n) { return n.filepondPluginFileValidateType; }),
3553
+ Promise.resolve().then(function () { return require('./filepond-plugin-file-poster-D3bKYBq5.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>
@@ -8139,7 +8142,7 @@ const SallaProductOptions = class {
8139
8142
  */
8140
8143
  handlePaste(event) {
8141
8144
  const target = event.target;
8142
- if (!Salla.helpers.hasApplePay()
8145
+ if (!Salla.helpers.isAppleDevice()
8143
8146
  || !(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)
8144
8147
  || !target.classList.contains('s-form-control')) {
8145
8148
  return;
@@ -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-COQqEmIG.js'); }).then(function (n) { return n.index; });
12530
+ const telInputModule = await Promise.resolve().then(function () { return require('./index-BZQAN2JT.js'); }).then(function (n) { return n.index; });
12528
12531
  this.TelInput = telInputModule.default;
12529
12532
  }
12530
12533
  catch (error) {
@@ -12675,6 +12678,13 @@ 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 {
@@ -12685,9 +12695,10 @@ const SallaUserMenu = class {
12685
12695
  orders: OrderIcon,
12686
12696
  pending_orders: PendingOrdersIcon,
12687
12697
  wishlist: WishListIcon,
12688
- profile: UserCircle,
12689
12698
  wallet: WalletIcon,
12690
12699
  loyalty_program: gift.GiftIcon,
12700
+ profile: UserCircle,
12701
+ settings: SettingstIcon,
12691
12702
  };
12692
12703
  this.accountLoading = false;
12693
12704
  this.opened = false;
@@ -12698,6 +12709,7 @@ const SallaUserMenu = class {
12698
12709
  this.profile = salla.lang.get('common.titles.profile');
12699
12710
  this.rating = salla.lang.get('common.titles.rating');
12700
12711
  this.wallet = salla.lang.get('common.titles.wallet');
12712
+ this.settings = salla.lang.get('common.titles.settings');
12701
12713
  this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
12702
12714
  this.logout = salla.lang.get('blocks.header.logout');
12703
12715
  this.hello = salla.lang.get('pages.checkout.hello');
@@ -12742,6 +12754,7 @@ const SallaUserMenu = class {
12742
12754
  this.hello = salla.lang.get('pages.checkout.hello');
12743
12755
  this.rating = salla.lang.get('common.titles.rating');
12744
12756
  this.wallet = salla.lang.get('common.titles.wallet');
12757
+ this.settings = salla.lang.get('common.titles.settings');
12745
12758
  this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
12746
12759
  this.logout = salla.lang.get('blocks.header.logout');
12747
12760
  });
@@ -12783,8 +12796,9 @@ const SallaUserMenu = class {
12783
12796
  });
12784
12797
  }
12785
12798
  componentWillLoad() {
12786
- return new Promise(resolve => salla.onReady(resolve)).then(() => {
12787
- let trigger = this.host.querySelector('[slot="trigger"]');
12799
+ return salla.onReady().then(() => {
12800
+ 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')}`;
12801
+ const trigger = this.host.querySelector('[slot="trigger"]');
12788
12802
  this.triggerSlot =
12789
12803
  '<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
12804
  if (!trigger) {
@@ -12821,8 +12835,8 @@ const SallaUserMenu = class {
12821
12835
  window.addEventListener('click', this.onClickOutside);
12822
12836
  }
12823
12837
  }
12824
- menuItemClicked(event, item) {
12825
- if (item[0] !== 'logout') {
12838
+ menuItemClicked(event, itemKey) {
12839
+ if (itemKey !== 'logout') {
12826
12840
  return;
12827
12841
  }
12828
12842
  event.preventDefault();
@@ -12841,18 +12855,23 @@ const SallaUserMenu = class {
12841
12855
  's-user-menu-trigger-slot': true,
12842
12856
  's-user-menu-red-dot': this.hasBadges,
12843
12857
  's-user-menu-trigger-avatar-only': this.avatarOnly,
12844
- }, id: "trigger-slot", onClick: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
12858
+ }, id: "trigger-slot", onClick: e => this.open(e), onKeyUp: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
12859
+ }
12860
+ getItemAnchorLinkAttrs(itemKey) {
12861
+ // Fix loyalty program URL mapping from master
12862
+ const urlKey = itemKey === 'loyalty_program' ? 'loyalty' : itemKey;
12863
+ return { href: salla.url.get(urlKey) };
12845
12864
  }
12846
- getMenuItem(item, i) {
12865
+ getMenuItem([itemKey, itemValue], i) {
12847
12866
  //todo:: enhancement support slot here
12848
- if (item[0] === 'wallet' && !window.can_access_wallet)
12867
+ if (itemKey === 'wallet' && !window.can_access_wallet)
12849
12868
  return;
12850
- if (item[0] === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
12869
+ if (itemKey === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
12851
12870
  return;
12852
12871
  return (index.h("li", { class: {
12853
12872
  '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]])) : (''))));
12873
+ 's-user-menu-dropdown-item-logout': i + 1 === Object.entries(this.items).length,
12874
+ } }, 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
12875
  }
12857
12876
  componentShouldUpdate() {
12858
12877
  if (!this.opened) {
@@ -12861,7 +12880,7 @@ const SallaUserMenu = class {
12861
12880
  }
12862
12881
  render() {
12863
12882
  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 }))));
12883
+ 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
12884
  }
12866
12885
  if (this.inline) {
12867
12886
  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 +12888,15 @@ const SallaUserMenu = class {
12869
12888
  return (index.h(index.Host, null, index.h("div", { class: {
12870
12889
  's-user-menu-wrapper': true,
12871
12890
  '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))))))));
12891
+ } }, 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
12892
  }
12874
12893
  componentDidLoad() {
12875
- //make sure to load the avatar if it's lazy, we use it in Y
12876
12894
  document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));
12877
12895
  }
12878
12896
  get host() { return index.getElement(this); }
12879
12897
  };
12880
12898
  SallaUserMenu.style = sallaUserMenuCss;
12881
12899
 
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
12900
  const sallaUserProfileCss = ":host{display:block}";
12894
12901
 
12895
12902
  const SallaUserProfile = class {
@@ -12899,7 +12906,6 @@ const SallaUserProfile = class {
12899
12906
  /**
12900
12907
  * The minimum allowed age for a user. Users with a birthdate indicating an age less than this value will be considered invalid.
12901
12908
  * Defaults to 10.
12902
- * @type {number}
12903
12909
  */
12904
12910
  this.minAge = 10;
12905
12911
  this.isEditable = true;
@@ -12946,20 +12952,13 @@ const SallaUserProfile = class {
12946
12952
  });
12947
12953
  });
12948
12954
  }
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
12955
  // Event handler for phone number field changes
12958
12956
  phoneNumberFieldEventHandler(data) {
12959
12957
  if (!data.detail.number) {
12960
- return (this.disableAction = true);
12958
+ this.disableAction = true;
12959
+ return;
12961
12960
  }
12962
- this.userData.phone.number = parseInt(data.detail.number);
12961
+ this.userData.phone.number = Number.parseInt(data.detail.number);
12963
12962
  this.userData.phone.country = data.detail.country_code;
12964
12963
  this.disableAction = false;
12965
12964
  }
@@ -12975,74 +12974,34 @@ const SallaUserProfile = class {
12975
12974
  }
12976
12975
  }
12977
12976
  }
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
12977
  // Event handler for email input changes
12991
12978
  handleEmailInput(key, event) {
12992
12979
  const emailErrorDisplaySection = document.getElementById('email-error');
12993
12980
  const email = event.target.value;
12994
12981
  if (!email) {
12995
12982
  this.disableAction = true;
12996
- return (emailErrorDisplaySection.textContent = this.email_required_trans);
12983
+ emailErrorDisplaySection.textContent = this.email_required_trans;
12984
+ return;
12997
12985
  }
12998
12986
  const emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
12999
12987
  if (!emailPattern.test(email)) {
13000
12988
  this.disableAction = true;
13001
- return (emailErrorDisplaySection.textContent = this.invalid_email_trans);
12989
+ emailErrorDisplaySection.textContent = this.invalid_email_trans;
13002
12990
  }
13003
12991
  emailErrorDisplaySection.textContent = '';
13004
12992
  this.userData[key] = email;
13005
12993
  this.disableAction = false;
13006
12994
  }
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
12995
  // Submit form method
13037
12996
  submitForm(event) {
13038
12997
  event.preventDefault();
13039
12998
  this.disableAction = true;
13040
- let payload = Object.assign({}, this.userData);
13041
- delete payload.phone;
12999
+ const payload = Object.assign({}, this.userData);
13000
+ payload.phone = undefined;
13042
13001
  //@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));
13002
+ payload.phone = this.userData.phone.number;
13003
+ payload.country_code = this.userData.phone.country;
13004
+ salla.api.profile.update(payload).finally(() => { this.disableAction = false; });
13046
13005
  }
13047
13006
  getBirthDateRestriction() {
13048
13007
  const now = new Date();
@@ -13051,19 +13010,9 @@ const SallaUserProfile = class {
13051
13010
  return now;
13052
13011
  }
13053
13012
  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
13013
  return salla.api.profile
13065
13014
  .info()
13066
- .then(resp => (this.userData = resp.data))
13015
+ .then(resp => { this.userData = resp.data; })
13067
13016
  .finally(() => {
13068
13017
  this.isLoading = false;
13069
13018
  this.isEditable = !Salla.config.get('store.features').includes('sso-login');
@@ -13079,7 +13028,7 @@ const SallaUserProfile = class {
13079
13028
  if (this.isLoading) {
13080
13029
  return this.renderLoadingSection();
13081
13030
  }
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)));
13031
+ 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
13032
  }
13084
13033
  };
13085
13034
  SallaUserProfile.style = sallaUserProfileCss;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.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-BfEIQrIk.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;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.js');
7
7
  var Helper = require('./Helper-C9UmWIYn.js');
8
8
  var interfaces = require('./interfaces-DZDQwN6-.js');
9
9
  require('./anime.es-BqW8JHZi.js');
@@ -3,7 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-BKN6oqfk.js');
6
+ var index = require('./index-BfEIQrIk.js');
7
7
  var interfaces = require('./interfaces-DZDQwN6-.js');
8
8
  var Helper = require('./Helper-C9UmWIYn.js');
9
9
  require('./anime.es-BqW8JHZi.js');