@salla.sa/twilight-components 2.14.295 → 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.
- package/dist/cjs/{filepond-CEfkKwxm.js → filepond-E7NOvLwV.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-U5caDeXK.js → filepond-plugin-file-poster-D3bKYBq5.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-5eUt8fIA.js → filepond-plugin-file-validate-size-D4sJa2nT.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BdNoSu6e.js → filepond-plugin-file-validate-type-DDz99ei0.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DFm7eyxh.js → filepond-plugin-image-edit-yDHuyk0R.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-BfH19uNR.js → filepond-plugin-image-exif-orientation-hj89JJI_.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-BCQL6DBC.js → filepond-plugin-image-preview-UoTioUkG.js} +1 -1
- package/dist/cjs/{index-TCPzRuQa.js → index-BZQAN2JT.js} +1 -1
- package/dist/cjs/{index-CMFmTYR8.js → index-BfEIQrIk.js} +6 -2
- package/dist/cjs/interfaces-CX9-6aLf.js +24 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_62.cjs.entry.js +65 -116
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +135 -0
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-custom-fields/salla-custom-fields.css +3 -0
- package/dist/collection/components/salla-custom-fields/salla-custom-fields.js +313 -0
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +36 -3
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +25 -14
- package/dist/collection/components/salla-user-profile/salla-user-profile.js +15 -132
- package/dist/components/index.js +2 -2
- package/dist/components/interfaces.js +15 -0
- package/dist/components/salla-custom-fields.d.ts +11 -0
- package/dist/components/salla-custom-fields.js +174 -0
- package/dist/components/salla-file-upload2.js +13 -3
- package/dist/components/salla-user-menu.js +31 -14
- package/dist/components/salla-user-profile.js +19 -97
- package/dist/esm/{filepond-vl78959W.js → filepond-BEN4Pt87.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-CqR_Dwed.js → filepond-plugin-file-poster-B7t9aVVy.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-B6Dk56YE.js → filepond-plugin-file-validate-size-DFkfdHfo.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-P-_BDRkR.js → filepond-plugin-file-validate-type-CU-RnplM.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-DWNUa3R3.js → filepond-plugin-image-edit-Dz3oYXef.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-dnXbnCGP.js → filepond-plugin-image-exif-orientation-DJrUnj97.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-CGT6aBAl.js → filepond-plugin-image-preview-BCWlifYd.js} +1 -1
- package/dist/esm/{index-Ziat6EbF.js → index-bXg2F_NN.js} +6 -2
- package/dist/esm/{index-DvtO64lP.js → index-fxSENfiU.js} +1 -1
- package/dist/esm/interfaces-CBT_Nxny.js +22 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_62.entry.js +64 -115
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +133 -0
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-review-card.entry.js +1 -1
- package/dist/esm/salla-reviews-page.entry.js +1 -1
- package/dist/esm/salla-reviews.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/twilight/{p-9c51b8d3.entry.js → p-0645c8e3.entry.js} +1 -1
- package/dist/twilight/{p-a328c3d1.entry.js → p-0b970445.entry.js} +1 -1
- package/dist/twilight/{p-2a2a02d6.entry.js → p-193bea42.entry.js} +1 -1
- package/dist/twilight/{p-Ez0e1PVX.js → p-1Xk7fjpB.js} +1 -1
- package/dist/twilight/{p-1287dd6d.entry.js → p-1b7cfbae.entry.js} +1 -1
- package/dist/twilight/{p-3d19d1d8.entry.js → p-22f479da.entry.js} +1 -1
- package/dist/twilight/{p-5f9bc177.entry.js → p-32512487.entry.js} +1 -1
- package/dist/twilight/{p-745e8f76.entry.js → p-4dd68813.entry.js} +1 -1
- package/dist/twilight/{p-ca431a2c.entry.js → p-4fb7f400.entry.js} +1 -1
- package/dist/twilight/{p-c9109a79.entry.js → p-51ef83f7.entry.js} +1 -1
- package/dist/twilight/{p-8cfd00b9.entry.js → p-56dde07a.entry.js} +1 -1
- package/dist/twilight/p-5dd1b37c.entry.js +4 -0
- package/dist/twilight/{p-f5a11fd5.entry.js → p-5f247331.entry.js} +1 -1
- package/dist/twilight/{p-ab6a475b.entry.js → p-67ed25a4.entry.js} +1 -1
- package/dist/twilight/{p-64d30453.entry.js → p-7012bda9.entry.js} +1 -1
- package/dist/twilight/{p-415cf3e3.entry.js → p-732c5190.entry.js} +1 -1
- package/dist/twilight/{p-f38b2e17.entry.js → p-76657684.entry.js} +1 -1
- package/dist/twilight/{p-a9da8a2e.entry.js → p-8220b125.entry.js} +1 -1
- package/dist/twilight/{p-66ab7e17.entry.js → p-8d3f2028.entry.js} +1 -1
- package/dist/twilight/{p-6822a113.entry.js → p-988ea6cb.entry.js} +1 -1
- package/dist/twilight/{p-b3fafad2.entry.js → p-9f42e27b.entry.js} +1 -1
- package/dist/twilight/{p-BBY0-pTD.js → p-BIRmkG1d.js} +1 -1
- package/dist/twilight/{p-7wg_fRFs.js → p-BW8LVXVp.js} +2 -2
- package/dist/twilight/p-CBT_Nxny.js +4 -0
- package/dist/twilight/{p-C0j6-TqH.js → p-CD5i_50p.js} +1 -1
- package/dist/twilight/{p-BXOeDpV2.js → p-CP2LDZCD.js} +1 -1
- package/dist/twilight/{p-BX_7gR2g.js → p-CWkLySV3.js} +1 -1
- package/dist/twilight/{p-ZreQEa1A.js → p-CoLlt5es.js} +1 -1
- package/dist/twilight/{p-cd7e4279.entry.js → p-a6ebba30.entry.js} +1 -1
- package/dist/twilight/{p-Ziat6EbF.js → p-bXg2F_NN.js} +2 -2
- package/dist/twilight/{p-d107dc1a.entry.js → p-c5afe02a.entry.js} +1 -1
- package/dist/twilight/{p-e79994cc.entry.js → p-c691fd39.entry.js} +1 -1
- package/dist/twilight/{p-917e7e9e.entry.js → p-c848e1d3.entry.js} +1 -1
- package/dist/twilight/{p-15d9e580.entry.js → p-c88d32f0.entry.js} +1 -1
- package/dist/twilight/p-d08cedb0.entry.js +11 -0
- package/dist/twilight/{p-9b480b59.entry.js → p-dcd9e688.entry.js} +1 -1
- package/dist/twilight/{p-a9c627f1.entry.js → p-dd84065f.entry.js} +1 -1
- package/dist/twilight/{p-93a27904.entry.js → p-e4418e6f.entry.js} +1 -1
- package/dist/twilight/{p-67038367.entry.js → p-ef3a4d3e.entry.js} +1 -1
- package/dist/twilight/{p-30edc8e4.entry.js → p-ef9ac6cb.entry.js} +1 -1
- package/dist/twilight/{p-4edf534b.entry.js → p-f4549e2e.entry.js} +1 -1
- package/dist/twilight/{p-bf70d878.entry.js → p-fa379f1e.entry.js} +1 -1
- package/dist/twilight/{p-2b8846ae.entry.js → p-fcd1344e.entry.js} +1 -1
- package/dist/twilight/{p-hVSNpsuQ.js → p-k3nBgoPC.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-custom-fields/salla-custom-fields.d.ts +39 -0
- package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +4 -0
- package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +4 -1
- package/dist/types/components/salla-user-profile/interfaces.d.ts +1 -0
- package/dist/types/components/salla-user-profile/salla-user-profile.d.ts +1 -20
- package/dist/types/components.d.ts +74 -25
- package/package.json +5 -5
- 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-
|
|
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-
|
|
3547
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-size-
|
|
3548
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-image-exif-orientation-
|
|
3549
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-image-preview-
|
|
3550
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-image-edit-
|
|
3551
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-file-validate-type-
|
|
3552
|
-
Promise.resolve().then(function () { return require('./filepond-plugin-file-poster-
|
|
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: '
|
|
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: '
|
|
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-
|
|
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
|
|
12787
|
-
|
|
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,
|
|
12825
|
-
if (
|
|
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(
|
|
12865
|
+
getMenuItem([itemKey, itemValue], i) {
|
|
12847
12866
|
//todo:: enhancement support slot here
|
|
12848
|
-
if (
|
|
12867
|
+
if (itemKey === 'wallet' && !window.can_access_wallet)
|
|
12849
12868
|
return;
|
|
12850
|
-
if (
|
|
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
|
|
12855
|
-
} }, index.h("a", {
|
|
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: () =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13041
|
-
|
|
12999
|
+
const payload = Object.assign({}, this.userData);
|
|
13000
|
+
payload.phone = undefined;
|
|
13042
13001
|
//@ts-ignore
|
|
13043
|
-
payload
|
|
13044
|
-
payload
|
|
13045
|
-
|
|
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 =>
|
|
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
|
|
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;
|
|
@@ -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;
|