@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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
var Genders;
|
|
5
|
+
(function (Genders) {
|
|
6
|
+
Genders["Female"] = "female";
|
|
7
|
+
Genders["Male"] = "male";
|
|
8
|
+
})(Genders || (Genders = {}));
|
|
9
|
+
var FormFieldTypes;
|
|
10
|
+
(function (FormFieldTypes) {
|
|
11
|
+
FormFieldTypes["Photo"] = "photo";
|
|
12
|
+
FormFieldTypes["Text"] = "Text";
|
|
13
|
+
})(FormFieldTypes || (FormFieldTypes = {}));
|
|
14
|
+
|
|
15
|
+
export { FormFieldTypes as F, Genders as G };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SallaCustomFields extends Components.SallaCustomFields, HTMLElement {}
|
|
4
|
+
export const SallaCustomFields: {
|
|
5
|
+
prototype: SallaCustomFields;
|
|
6
|
+
new (): SallaCustomFields;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
5
|
+
import { C as CameraIcon } from './camera.js';
|
|
6
|
+
import { F as FormFieldTypes } from './interfaces.js';
|
|
7
|
+
import { d as defineCustomElement$3 } from './salla-button2.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './salla-file-upload2.js';
|
|
9
|
+
|
|
10
|
+
const sallaCustomFieldsCss = ":host{display:block}";
|
|
11
|
+
|
|
12
|
+
const SallaCustomFields$1 = /*@__PURE__*/ proxyCustomElement(class SallaCustomFields extends HTMLElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.__registerHost();
|
|
16
|
+
this.fieldChanged = createEvent(this, "fieldChanged", 7);
|
|
17
|
+
this.fileUploaded = createEvent(this, "fileUploaded", 7);
|
|
18
|
+
this.isEditable = true;
|
|
19
|
+
this.fieldErrors = {};
|
|
20
|
+
this.isSubmitting = false;
|
|
21
|
+
}
|
|
22
|
+
get dragAndDropText() {
|
|
23
|
+
return salla.lang.get("common.uploader.drag_and_drop");
|
|
24
|
+
}
|
|
25
|
+
get browseText() {
|
|
26
|
+
return salla.lang.get("common.uploader.browse");
|
|
27
|
+
}
|
|
28
|
+
get saveButtonText() {
|
|
29
|
+
return salla.lang.get("common.elements.save");
|
|
30
|
+
}
|
|
31
|
+
async setFields(fields) {
|
|
32
|
+
this.parsedFields = fields;
|
|
33
|
+
}
|
|
34
|
+
async getFieldValues() {
|
|
35
|
+
return this.parsedFields?.reduce((values, field) => {
|
|
36
|
+
values[`custom_fields[${field.id}]`] = field.value;
|
|
37
|
+
return values;
|
|
38
|
+
}, {}) || {};
|
|
39
|
+
}
|
|
40
|
+
async validateFields() {
|
|
41
|
+
if (!this.parsedFields)
|
|
42
|
+
return true;
|
|
43
|
+
const errors = this.parsedFields.reduce((acc, field) => {
|
|
44
|
+
if (field.required && (!field.value || field.value === "")) {
|
|
45
|
+
acc[field.id.toString()] = `${field.label} is required`;
|
|
46
|
+
}
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
this.fieldErrors = errors;
|
|
50
|
+
return Object.keys(errors).length === 0;
|
|
51
|
+
}
|
|
52
|
+
handleFieldChange(field, event) {
|
|
53
|
+
const value = event.target.value;
|
|
54
|
+
field.value = value;
|
|
55
|
+
this.clearFieldError(field.id);
|
|
56
|
+
const isValid = !(field.required && !value);
|
|
57
|
+
if (!isValid) {
|
|
58
|
+
this.setFieldError(field.id, `${field.label} is required`);
|
|
59
|
+
}
|
|
60
|
+
this.fieldChanged.emit({ fieldId: field.id, value, isValid });
|
|
61
|
+
}
|
|
62
|
+
handleFileUpload(field, event) {
|
|
63
|
+
const { error, file } = event.detail;
|
|
64
|
+
const isValid = !error;
|
|
65
|
+
this.clearFieldError(field.id);
|
|
66
|
+
if (isValid) {
|
|
67
|
+
field.value = file;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.setFieldError(field.id, "File upload failed");
|
|
71
|
+
}
|
|
72
|
+
this.fileUploaded.emit({ fieldId: field.id, file, isValid });
|
|
73
|
+
}
|
|
74
|
+
clearFieldError(fieldId) {
|
|
75
|
+
this.fieldErrors = { ...this.fieldErrors };
|
|
76
|
+
delete this.fieldErrors[fieldId];
|
|
77
|
+
}
|
|
78
|
+
setFieldError(fieldId, message) {
|
|
79
|
+
this.fieldErrors = { ...this.fieldErrors, [fieldId]: message };
|
|
80
|
+
}
|
|
81
|
+
renderTextField(field) {
|
|
82
|
+
return (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 }));
|
|
83
|
+
}
|
|
84
|
+
renderFileField(field) {
|
|
85
|
+
return (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) => {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
field.value = "";
|
|
89
|
+
e.target.value = "";
|
|
90
|
+
}, payloadName: "files[]", payloadParams: { type: 'registration' }, "instant-upload": true }, h("div", { class: "s-custom-fields-filepond-placeholder" }, h("span", { class: "s-custom-fields-filepond-placeholder-icon" }, h("i", { innerHTML: CameraIcon })), h("p", { class: "s-custom-fields-filepond-placeholder-text" }, this.dragAndDropText), h("span", { class: "filepond--label-action" }, this.browseText))));
|
|
91
|
+
}
|
|
92
|
+
renderField(field) {
|
|
93
|
+
return (h("div", { class: "s-custom-fields-field", key: field.id }, h("label", { class: "s-custom-fields-field-label", htmlFor: `custom-field-${field.id}` }, field.label, field.required && h("span", { class: "s-custom-fields-required" }, "*")), h("div", null, field.type === FormFieldTypes.Photo
|
|
94
|
+
? this.renderFileField(field)
|
|
95
|
+
: this.renderTextField(field), this.fieldErrors[field.id] && (h("p", { class: "s-custom-fields-error" }, this.fieldErrors[field.id])))));
|
|
96
|
+
}
|
|
97
|
+
componentWillLoad() {
|
|
98
|
+
this.parsedFields = this.parseFields(this.fields);
|
|
99
|
+
}
|
|
100
|
+
parseFields(fields) {
|
|
101
|
+
if (!fields)
|
|
102
|
+
return [];
|
|
103
|
+
return typeof fields === "string"
|
|
104
|
+
? JSON.parse(fields)
|
|
105
|
+
: Array.isArray(fields) ? fields : [];
|
|
106
|
+
}
|
|
107
|
+
async handleSubmit(e) {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
this.isSubmitting = true;
|
|
110
|
+
try {
|
|
111
|
+
const payload = {};
|
|
112
|
+
const form = e.target;
|
|
113
|
+
const elements = form.elements;
|
|
114
|
+
for (let i = 0; i < elements.length; i++) {
|
|
115
|
+
const element = elements[i];
|
|
116
|
+
if (element.name && !element.name.startsWith("hidden") && element.value) {
|
|
117
|
+
payload[element.name] = element.value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
await salla.api.profile.updateCustomFields({
|
|
121
|
+
id: salla.config.get("store.id"),
|
|
122
|
+
fields: payload,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
this.isSubmitting = false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
render() {
|
|
130
|
+
if (!this.parsedFields?.length)
|
|
131
|
+
return null;
|
|
132
|
+
return (h("form", { class: "s-custom-fields-wrapper", onSubmit: this.handleSubmit }, this.parsedFields.map(field => this.renderField(field)), h("salla-button", { type: "submit", loading: this.isSubmitting, disabled: this.isSubmitting || !this.isEditable, "loader-position": "end", class: "s-custom-fields-submit-btn" }, this.saveButtonText)));
|
|
133
|
+
}
|
|
134
|
+
static get style() { return sallaCustomFieldsCss; }
|
|
135
|
+
}, [0, "salla-custom-fields", {
|
|
136
|
+
"fields": [1],
|
|
137
|
+
"isEditable": [4, "is-editable"],
|
|
138
|
+
"fileUploadUrl": [1, "file-upload-url"],
|
|
139
|
+
"parsedFields": [32],
|
|
140
|
+
"fieldErrors": [32],
|
|
141
|
+
"isSubmitting": [32],
|
|
142
|
+
"setFields": [64],
|
|
143
|
+
"getFieldValues": [64],
|
|
144
|
+
"validateFields": [64]
|
|
145
|
+
}]);
|
|
146
|
+
function defineCustomElement$1() {
|
|
147
|
+
if (typeof customElements === "undefined") {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const components = ["salla-custom-fields", "salla-button", "salla-file-upload"];
|
|
151
|
+
components.forEach(tagName => { switch (tagName) {
|
|
152
|
+
case "salla-custom-fields":
|
|
153
|
+
if (!customElements.get(tagName)) {
|
|
154
|
+
customElements.define(tagName, SallaCustomFields$1);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case "salla-button":
|
|
158
|
+
if (!customElements.get(tagName)) {
|
|
159
|
+
defineCustomElement$3();
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case "salla-file-upload":
|
|
163
|
+
if (!customElements.get(tagName)) {
|
|
164
|
+
defineCustomElement$2();
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
} });
|
|
168
|
+
}
|
|
169
|
+
defineCustomElement$1();
|
|
170
|
+
|
|
171
|
+
const SallaCustomFields = SallaCustomFields$1;
|
|
172
|
+
const defineCustomElement = defineCustomElement$1;
|
|
173
|
+
|
|
174
|
+
export { SallaCustomFields, defineCustomElement };
|
|
@@ -51,6 +51,10 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class SallaFileUpload e
|
|
|
51
51
|
* Set the component to be profile image uploader with a preview and a circular shape
|
|
52
52
|
*/
|
|
53
53
|
this.profileImage = false;
|
|
54
|
+
/**
|
|
55
|
+
* Allow to pass extra params to be sent with the upload request
|
|
56
|
+
*/
|
|
57
|
+
this.payloadParams = {};
|
|
54
58
|
/**
|
|
55
59
|
* Accepted file types
|
|
56
60
|
*/
|
|
@@ -312,11 +316,11 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class SallaFileUpload e
|
|
|
312
316
|
}
|
|
313
317
|
}
|
|
314
318
|
render() {
|
|
315
|
-
return (h(Host, { key: '
|
|
319
|
+
return (h(Host, { key: '68939496fd8cfcc89a7a5d21e7e4daedab0db536', class: {
|
|
316
320
|
"s-file-upload": true,
|
|
317
321
|
"s-file-upload-profile-image": this.profileImage,
|
|
318
322
|
"s-file-upload-multiple": this.allowMultiple,
|
|
319
|
-
} }, h("input", { key: '
|
|
323
|
+
} }, 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 ? h("div", { class: "s-file-upload-hint s-hidden" }, this.max_count_hint(this.maxFilesCount)) : '', h("input", { key: 'dc74f8a155eeedd294548f782ed158f1a889b373', class: "s-hidden", name: 'hidden-' + this.name, required: this.required, value: this.value, ref: input => this.hiddenInput = input })));
|
|
320
324
|
}
|
|
321
325
|
componentDidLoad() {
|
|
322
326
|
let files = this.getFiles();
|
|
@@ -399,7 +403,7 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class SallaFileUpload e
|
|
|
399
403
|
process: {
|
|
400
404
|
onload: (response) => {
|
|
401
405
|
let responseData = JSON.parse(response).data;
|
|
402
|
-
if (this.allowMultiple && Array.isArray(responseData) && responseData.length > 0) {
|
|
406
|
+
if ((this.instantUpload || this.allowMultiple) && Array.isArray(responseData) && responseData.length > 0) {
|
|
403
407
|
const fileId = `${this.host.id}-${Math.floor(100 + Math.random() * 900)}`;
|
|
404
408
|
this.uploadedFiles.push({
|
|
405
409
|
id: fileId,
|
|
@@ -443,6 +447,11 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class SallaFileUpload e
|
|
|
443
447
|
formData.append(this.payloadName, this.filepond.getFile(0).file);
|
|
444
448
|
formData.delete(this.name);
|
|
445
449
|
}
|
|
450
|
+
if (this.payloadParams) {
|
|
451
|
+
for (const [k, v] of Object.entries(this.payloadParams)) {
|
|
452
|
+
formData.append(k, v);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
446
455
|
if (this.cartItemId) {
|
|
447
456
|
formData.append('cart_item_id', this.cartItemId);
|
|
448
457
|
}
|
|
@@ -497,6 +506,7 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class SallaFileUpload e
|
|
|
497
506
|
"profileImage": [516, "profile-image"],
|
|
498
507
|
"name": [1537],
|
|
499
508
|
"payloadName": [1, "payload-name"],
|
|
509
|
+
"payloadParams": [16, "payload-params"],
|
|
500
510
|
"type": [1],
|
|
501
511
|
"accept": [1537],
|
|
502
512
|
"fileId": [2, "file-id"],
|
|
@@ -38,6 +38,13 @@ var WalletIcon = `<!-- Generated by IcoMoon.io -->
|
|
|
38
38
|
</svg>
|
|
39
39
|
`;
|
|
40
40
|
|
|
41
|
+
var SettingstIcon = `<!-- Generated by IcoMoon.io -->
|
|
42
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
43
|
+
<title>settings</title>
|
|
44
|
+
<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>
|
|
45
|
+
</svg>
|
|
46
|
+
`;
|
|
47
|
+
|
|
41
48
|
const sallaUserMenuCss = "";
|
|
42
49
|
|
|
43
50
|
const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu extends HTMLElement {
|
|
@@ -49,9 +56,10 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
49
56
|
orders: OrderIcon,
|
|
50
57
|
pending_orders: PendingOrdersIcon,
|
|
51
58
|
wishlist: WishListIcon,
|
|
52
|
-
profile: UserCircle,
|
|
53
59
|
wallet: WalletIcon,
|
|
54
60
|
loyalty_program: loyaltyProgramIcon,
|
|
61
|
+
profile: UserCircle,
|
|
62
|
+
settings: SettingstIcon,
|
|
55
63
|
};
|
|
56
64
|
this.accountLoading = false;
|
|
57
65
|
this.opened = false;
|
|
@@ -62,6 +70,7 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
62
70
|
this.profile = salla.lang.get('common.titles.profile');
|
|
63
71
|
this.rating = salla.lang.get('common.titles.rating');
|
|
64
72
|
this.wallet = salla.lang.get('common.titles.wallet');
|
|
73
|
+
this.settings = salla.lang.get('common.titles.settings');
|
|
65
74
|
this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
|
|
66
75
|
this.logout = salla.lang.get('blocks.header.logout');
|
|
67
76
|
this.hello = salla.lang.get('pages.checkout.hello');
|
|
@@ -106,6 +115,7 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
106
115
|
this.hello = salla.lang.get('pages.checkout.hello');
|
|
107
116
|
this.rating = salla.lang.get('common.titles.rating');
|
|
108
117
|
this.wallet = salla.lang.get('common.titles.wallet');
|
|
118
|
+
this.settings = salla.lang.get('common.titles.settings');
|
|
109
119
|
this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
|
|
110
120
|
this.logout = salla.lang.get('blocks.header.logout');
|
|
111
121
|
});
|
|
@@ -147,8 +157,9 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
147
157
|
});
|
|
148
158
|
}
|
|
149
159
|
componentWillLoad() {
|
|
150
|
-
return
|
|
151
|
-
|
|
160
|
+
return salla.onReady().then(() => {
|
|
161
|
+
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')}`;
|
|
162
|
+
const trigger = this.host.querySelector('[slot="trigger"]');
|
|
152
163
|
this.triggerSlot =
|
|
153
164
|
'<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>';
|
|
154
165
|
if (!trigger) {
|
|
@@ -185,8 +196,8 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
185
196
|
window.addEventListener('click', this.onClickOutside);
|
|
186
197
|
}
|
|
187
198
|
}
|
|
188
|
-
menuItemClicked(event,
|
|
189
|
-
if (
|
|
199
|
+
menuItemClicked(event, itemKey) {
|
|
200
|
+
if (itemKey !== 'logout') {
|
|
190
201
|
return;
|
|
191
202
|
}
|
|
192
203
|
event.preventDefault();
|
|
@@ -205,18 +216,23 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
205
216
|
's-user-menu-trigger-slot': true,
|
|
206
217
|
's-user-menu-red-dot': this.hasBadges,
|
|
207
218
|
's-user-menu-trigger-avatar-only': this.avatarOnly,
|
|
208
|
-
}, id: "trigger-slot", onClick: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
|
|
219
|
+
}, id: "trigger-slot", onClick: e => this.open(e), onKeyUp: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
|
|
220
|
+
}
|
|
221
|
+
getItemAnchorLinkAttrs(itemKey) {
|
|
222
|
+
// Fix loyalty program URL mapping from master
|
|
223
|
+
const urlKey = itemKey === 'loyalty_program' ? 'loyalty' : itemKey;
|
|
224
|
+
return { href: salla.url.get(urlKey) };
|
|
209
225
|
}
|
|
210
|
-
getMenuItem(
|
|
226
|
+
getMenuItem([itemKey, itemValue], i) {
|
|
211
227
|
//todo:: enhancement support slot here
|
|
212
|
-
if (
|
|
228
|
+
if (itemKey === 'wallet' && !window.can_access_wallet)
|
|
213
229
|
return;
|
|
214
|
-
if (
|
|
230
|
+
if (itemKey === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
|
|
215
231
|
return;
|
|
216
232
|
return (h("li", { class: {
|
|
217
233
|
's-user-menu-dropdown-item': true,
|
|
218
|
-
's-user-menu-dropdown-item-logout': i + 1
|
|
219
|
-
} }, h("a", {
|
|
234
|
+
's-user-menu-dropdown-item-logout': i + 1 === Object.entries(this.items).length,
|
|
235
|
+
} }, h("a", { ...this.getItemAnchorLinkAttrs(itemKey), class: "s-user-menu-dropdown-item-link", onClick: event => this.menuItemClicked(event, itemKey) }, h("i", { class: "s-user-menu-dropdown-item-prefix", innerHTML: itemValue }), h("span", { class: "s-user-menu-dropdown-item-title" }, this[itemKey]), !['٠', '0', undefined].includes(this.badges[itemKey]) ? (h("span", { class: "s-user-menu-dropdown-item-badge" }, this.badges[itemKey])) : (''))));
|
|
220
236
|
}
|
|
221
237
|
componentShouldUpdate() {
|
|
222
238
|
if (!this.opened) {
|
|
@@ -225,7 +241,7 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
225
241
|
}
|
|
226
242
|
render() {
|
|
227
243
|
if (!this.is_loggedIn) {
|
|
228
|
-
return (h(Host, null, h("slot", { name: "login-btn" }, h("button", { class: "s-user-menu-login-btn", onClick: () => salla.event.dispatch('login::open'), innerHTML: UserCircle }))));
|
|
244
|
+
return (h(Host, null, h("slot", { name: "login-btn" }, h("button", { type: "button", class: "s-user-menu-login-btn", onClick: () => salla.event.dispatch('login::open'), innerHTML: UserCircle }))));
|
|
229
245
|
}
|
|
230
246
|
if (this.inline) {
|
|
231
247
|
return (h(Host, null, h("ul", { class: "s-user-menu-inline" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i)))));
|
|
@@ -233,10 +249,9 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
233
249
|
return (h(Host, null, h("div", { class: {
|
|
234
250
|
's-user-menu-wrapper': true,
|
|
235
251
|
's-user-menu-relative-dropdown': this.relativeDropdown,
|
|
236
|
-
} }, this.getTheHeader(), h("div", { class: { 's-user-menu-toggler': true, opened: this.opened } }, h("div", { class: "s-user-menu-dropdown", onClick: e => e.stopPropagation() }, this.showHeader ? (h("div", { class: "s-user-menu-dropdown-header" }, h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), h("div", { class: "s-user-menu-dropdown-header-content" }, h("span", null, this.hello), h("p", null, this.first_name, " ", this.last_name)), h("button", { class: "s-user-menu-dropdown-header-close", innerHTML: Cancel, onClick: () =>
|
|
252
|
+
} }, this.getTheHeader(), h("div", { class: { 's-user-menu-toggler': true, opened: this.opened } }, h("div", { class: "s-user-menu-dropdown", onClick: e => e.stopPropagation(), onKeyUp: e => e.stopPropagation() }, this.showHeader ? (h("div", { class: "s-user-menu-dropdown-header" }, h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), h("div", { class: "s-user-menu-dropdown-header-content" }, h("span", null, this.hello), h("p", null, this.first_name, " ", this.last_name)), h("button", { type: 'button', class: "s-user-menu-dropdown-header-close", innerHTML: Cancel, onClick: () => { this.opened = false; } }))) : (''), h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
|
|
237
253
|
}
|
|
238
254
|
componentDidLoad() {
|
|
239
|
-
//make sure to load the avatar if it's lazy, we use it in Y
|
|
240
255
|
document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));
|
|
241
256
|
}
|
|
242
257
|
get host() { return this; }
|
|
@@ -255,6 +270,7 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
255
270
|
"profile": [32],
|
|
256
271
|
"rating": [32],
|
|
257
272
|
"wallet": [32],
|
|
273
|
+
"settings": [32],
|
|
258
274
|
"loyalty_program": [32],
|
|
259
275
|
"logout": [32],
|
|
260
276
|
"hello": [32],
|
|
@@ -264,6 +280,7 @@ const SallaUserMenu$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserMenu ext
|
|
|
264
280
|
"is_loggedIn": [32],
|
|
265
281
|
"badges": [32],
|
|
266
282
|
"hasBadges": [32],
|
|
283
|
+
"profileUrl": [32],
|
|
267
284
|
"OrderUpdate": [32]
|
|
268
285
|
}]);
|
|
269
286
|
function defineCustomElement$1() {
|
|
@@ -2,24 +2,12 @@
|
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
4
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
5
|
-
import {
|
|
6
|
-
import { d as defineCustomElement$
|
|
7
|
-
import { d as defineCustomElement$
|
|
8
|
-
import { d as defineCustomElement$4 } from './salla-file-upload2.js';
|
|
5
|
+
import { G as Genders } from './interfaces.js';
|
|
6
|
+
import { d as defineCustomElement$5 } from './salla-button2.js';
|
|
7
|
+
import { d as defineCustomElement$4 } from './salla-datetime-picker2.js';
|
|
9
8
|
import { d as defineCustomElement$3 } from './salla-skeleton2.js';
|
|
10
9
|
import { d as defineCustomElement$2 } from './salla-tel-input2.js';
|
|
11
10
|
|
|
12
|
-
var Genders;
|
|
13
|
-
(function (Genders) {
|
|
14
|
-
Genders["Female"] = "female";
|
|
15
|
-
Genders["Male"] = "male";
|
|
16
|
-
})(Genders || (Genders = {}));
|
|
17
|
-
var FormFieldTypes;
|
|
18
|
-
(function (FormFieldTypes) {
|
|
19
|
-
FormFieldTypes["Photo"] = "photo";
|
|
20
|
-
FormFieldTypes["Text"] = "Text";
|
|
21
|
-
})(FormFieldTypes || (FormFieldTypes = {}));
|
|
22
|
-
|
|
23
11
|
const sallaUserProfileCss = ":host{display:block}";
|
|
24
12
|
|
|
25
13
|
const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfile extends HTMLElement {
|
|
@@ -30,7 +18,6 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
30
18
|
/**
|
|
31
19
|
* The minimum allowed age for a user. Users with a birthdate indicating an age less than this value will be considered invalid.
|
|
32
20
|
* Defaults to 10.
|
|
33
|
-
* @type {number}
|
|
34
21
|
*/
|
|
35
22
|
this.minAge = 10;
|
|
36
23
|
this.isEditable = true;
|
|
@@ -77,20 +64,13 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
77
64
|
});
|
|
78
65
|
});
|
|
79
66
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Sets custom fields for the component. Can be handy for non HTML usage.
|
|
82
|
-
*
|
|
83
|
-
* @param fields - An array of custom fields.
|
|
84
|
-
*/
|
|
85
|
-
async setCustomFields(fields) {
|
|
86
|
-
this.userDefinedFields = fields;
|
|
87
|
-
}
|
|
88
67
|
// Event handler for phone number field changes
|
|
89
68
|
phoneNumberFieldEventHandler(data) {
|
|
90
69
|
if (!data.detail.number) {
|
|
91
|
-
|
|
70
|
+
this.disableAction = true;
|
|
71
|
+
return;
|
|
92
72
|
}
|
|
93
|
-
this.userData.phone.number = parseInt(data.detail.number);
|
|
73
|
+
this.userData.phone.number = Number.parseInt(data.detail.number);
|
|
94
74
|
this.userData.phone.country = data.detail.country_code;
|
|
95
75
|
this.disableAction = false;
|
|
96
76
|
}
|
|
@@ -106,74 +86,34 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
106
86
|
}
|
|
107
87
|
}
|
|
108
88
|
}
|
|
109
|
-
// Event handler for file upload changes
|
|
110
|
-
handleOnFileAdded(key, data) {
|
|
111
|
-
// TODO: the key in here, shall be not have whitespace. or the key for
|
|
112
|
-
// the field shall be provided with one of the properties of the custom field
|
|
113
|
-
if (!data.detail.error) {
|
|
114
|
-
this.userData[key] = data.detail.file;
|
|
115
|
-
this.disableAction = false;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this.disableAction = true;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
89
|
// Event handler for email input changes
|
|
122
90
|
handleEmailInput(key, event) {
|
|
123
91
|
const emailErrorDisplaySection = document.getElementById('email-error');
|
|
124
92
|
const email = event.target.value;
|
|
125
93
|
if (!email) {
|
|
126
94
|
this.disableAction = true;
|
|
127
|
-
|
|
95
|
+
emailErrorDisplaySection.textContent = this.email_required_trans;
|
|
96
|
+
return;
|
|
128
97
|
}
|
|
129
98
|
const emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
130
99
|
if (!emailPattern.test(email)) {
|
|
131
100
|
this.disableAction = true;
|
|
132
|
-
|
|
101
|
+
emailErrorDisplaySection.textContent = this.invalid_email_trans;
|
|
133
102
|
}
|
|
134
103
|
emailErrorDisplaySection.textContent = '';
|
|
135
104
|
this.userData[key] = email;
|
|
136
105
|
this.disableAction = false;
|
|
137
106
|
}
|
|
138
|
-
// Helper method to trim language code from URL
|
|
139
|
-
trimLanguageCodeFromUrl(url, languageCode) {
|
|
140
|
-
const pattern = new RegExp(`^(https?://[^/]+)\\/${languageCode}(.*)`, 'i');
|
|
141
|
-
const match = url.replace(/\/+$/, '').match(pattern);
|
|
142
|
-
if (match && match.length >= 2) {
|
|
143
|
-
const [, baseUrl, restOfUrl] = match;
|
|
144
|
-
return baseUrl + restOfUrl;
|
|
145
|
-
}
|
|
146
|
-
return url;
|
|
147
|
-
}
|
|
148
|
-
// Helper method to get file upload URL
|
|
149
|
-
getFileUploadUrl() {
|
|
150
|
-
return `${this.trimLanguageCodeFromUrl(salla.config.get('store.url'), salla.config.get('user.language_code'))}/upload-image`;
|
|
151
|
-
}
|
|
152
|
-
// Render custom fields based on user-defined fields
|
|
153
|
-
renderCustomFields() {
|
|
154
|
-
if (!this.userDefinedFields) {
|
|
155
|
-
return '';
|
|
156
|
-
}
|
|
157
|
-
return this.userDefinedFields.map((field) => {
|
|
158
|
-
return (h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: `${field.id}`, class: "s-user-profile-field-label" }, field.label), this.renderCustomField(field)));
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
renderCustomField(field) {
|
|
162
|
-
if (field.type !== FormFieldTypes.Photo) {
|
|
163
|
-
return (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 }));
|
|
164
|
-
}
|
|
165
|
-
return (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) }, h("div", { class: "s-user-profile-filepond-placeholder" }, h("span", { class: "s-user-profile-filepond-placeholder-icon" }, h("i", { innerHTML: CameraIcon })), h("p", { class: "s-user-profile-filepond-placeholder-text" }, this.drag_and_drop_trans), h("span", { class: "filepond--label-action" }, this.browse_trans))));
|
|
166
|
-
}
|
|
167
107
|
// Submit form method
|
|
168
108
|
submitForm(event) {
|
|
169
109
|
event.preventDefault();
|
|
170
110
|
this.disableAction = true;
|
|
171
|
-
|
|
172
|
-
|
|
111
|
+
const payload = Object.assign({}, this.userData);
|
|
112
|
+
payload.phone = undefined;
|
|
173
113
|
//@ts-ignore
|
|
174
|
-
payload
|
|
175
|
-
payload
|
|
176
|
-
|
|
114
|
+
payload.phone = this.userData.phone.number;
|
|
115
|
+
payload.country_code = this.userData.phone.country;
|
|
116
|
+
salla.api.profile.update(payload).finally(() => { this.disableAction = false; });
|
|
177
117
|
}
|
|
178
118
|
getBirthDateRestriction() {
|
|
179
119
|
const now = new Date();
|
|
@@ -182,19 +122,9 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
182
122
|
return now;
|
|
183
123
|
}
|
|
184
124
|
fetchData() {
|
|
185
|
-
let customFields = null;
|
|
186
|
-
// Load user-defined fields and initial user data
|
|
187
|
-
if (this.customFields) {
|
|
188
|
-
customFields = typeof this.customFields === 'string'
|
|
189
|
-
? JSON.parse(this.customFields)
|
|
190
|
-
: this.customFields;
|
|
191
|
-
}
|
|
192
|
-
if (customFields && Array.isArray(customFields)) {
|
|
193
|
-
this.userDefinedFields = customFields;
|
|
194
|
-
}
|
|
195
125
|
return salla.api.profile
|
|
196
126
|
.info()
|
|
197
|
-
.then(resp =>
|
|
127
|
+
.then(resp => { this.userData = resp.data; })
|
|
198
128
|
.finally(() => {
|
|
199
129
|
this.isLoading = false;
|
|
200
130
|
this.isEditable = !Salla.config.get('store.features').includes('sso-login');
|
|
@@ -210,15 +140,13 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
210
140
|
if (this.isLoading) {
|
|
211
141
|
return this.renderLoadingSection();
|
|
212
142
|
}
|
|
213
|
-
return (h("form", { onSubmit: event => this.submitForm(event) }, h("div", { class: "s-user-profile-wrapper" }, h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "first-name", class: "s-user-profile-field-label" }, this.first_name_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "last-name", class: "s-user-profile-field-label" }, this.last_name_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "birthday", class: "s-user-profile-field-label" }, this.birthday_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "gender", class: "s-user-profile-field-label" }, this.gender_trans), h("select", { disabled: !this.isEditable, class: "form-input", name: "gender", required: true, onChange: event => this.handleFieldChange('gender', event) }, h("option", { value: "" }, this.gender_placeholder_trans), h("option", { value: Genders.Male, selected: this.userData.gender
|
|
143
|
+
return (h("form", { onSubmit: event => this.submitForm(event) }, h("div", { class: "s-user-profile-wrapper" }, h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "first-name", class: "s-user-profile-field-label" }, this.first_name_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "last-name", class: "s-user-profile-field-label" }, this.last_name_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "birthday", class: "s-user-profile-field-label" }, this.birthday_trans), 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) })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "gender", class: "s-user-profile-field-label" }, this.gender_trans), h("select", { disabled: !this.isEditable, class: "form-input", name: "gender", required: true, onChange: event => this.handleFieldChange('gender', event) }, h("option", { value: "" }, this.gender_placeholder_trans), h("option", { value: Genders.Male, selected: this.userData.gender === Genders.Male }, this.male_trans), h("option", { value: Genders.Female, selected: this.userData.gender === Genders.Female }, this.female_trans))), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "email", class: "s-user-profile-field-label" }, this.email_trans), 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) }), h("p", { id: "email-error", class: "s-user-profile-field-error" })), h("div", { class: "s-user-profile-field" }, h("label", { htmlFor: "international-mobile", class: "s-user-profile-field-label" }, this.mobile_trans), 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) }))), 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)));
|
|
214
144
|
}
|
|
215
145
|
static get style() { return sallaUserProfileCss; }
|
|
216
146
|
}, [0, "salla-user-profile", {
|
|
217
|
-
"customFields": [1, "custom-fields"],
|
|
218
147
|
"minAge": [2, "min-age"],
|
|
219
148
|
"userData": [32],
|
|
220
149
|
"isEditable": [32],
|
|
221
|
-
"userDefinedFields": [32],
|
|
222
150
|
"disableAction": [32],
|
|
223
151
|
"isLoading": [32],
|
|
224
152
|
"first_name_trans": [32],
|
|
@@ -235,14 +163,13 @@ const SallaUserProfile$1 = /*@__PURE__*/ proxyCustomElement(class SallaUserProfi
|
|
|
235
163
|
"drag_and_drop_trans": [32],
|
|
236
164
|
"browse_trans": [32],
|
|
237
165
|
"email_required_trans": [32],
|
|
238
|
-
"invalid_email_trans": [32]
|
|
239
|
-
"setCustomFields": [64]
|
|
166
|
+
"invalid_email_trans": [32]
|
|
240
167
|
}]);
|
|
241
168
|
function defineCustomElement$1() {
|
|
242
169
|
if (typeof customElements === "undefined") {
|
|
243
170
|
return;
|
|
244
171
|
}
|
|
245
|
-
const components = ["salla-user-profile", "salla-button", "salla-datetime-picker", "salla-
|
|
172
|
+
const components = ["salla-user-profile", "salla-button", "salla-datetime-picker", "salla-skeleton", "salla-tel-input"];
|
|
246
173
|
components.forEach(tagName => { switch (tagName) {
|
|
247
174
|
case "salla-user-profile":
|
|
248
175
|
if (!customElements.get(tagName)) {
|
|
@@ -250,16 +177,11 @@ function defineCustomElement$1() {
|
|
|
250
177
|
}
|
|
251
178
|
break;
|
|
252
179
|
case "salla-button":
|
|
253
|
-
if (!customElements.get(tagName)) {
|
|
254
|
-
defineCustomElement$6();
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
case "salla-datetime-picker":
|
|
258
180
|
if (!customElements.get(tagName)) {
|
|
259
181
|
defineCustomElement$5();
|
|
260
182
|
}
|
|
261
183
|
break;
|
|
262
|
-
case "salla-
|
|
184
|
+
case "salla-datetime-picker":
|
|
263
185
|
if (!customElements.get(tagName)) {
|
|
264
186
|
defineCustomElement$4();
|
|
265
187
|
}
|