@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,313 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import { h, } from "@stencil/core";
|
|
5
|
+
import CameraIcon from "../../assets/svg/camera.svg";
|
|
6
|
+
import { FormFieldTypes, } from "../salla-user-profile/interfaces";
|
|
7
|
+
export class SallaCustomFields {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.isEditable = true;
|
|
10
|
+
this.fieldErrors = {};
|
|
11
|
+
this.isSubmitting = false;
|
|
12
|
+
}
|
|
13
|
+
get dragAndDropText() {
|
|
14
|
+
return salla.lang.get("common.uploader.drag_and_drop");
|
|
15
|
+
}
|
|
16
|
+
get browseText() {
|
|
17
|
+
return salla.lang.get("common.uploader.browse");
|
|
18
|
+
}
|
|
19
|
+
get saveButtonText() {
|
|
20
|
+
return salla.lang.get("common.elements.save");
|
|
21
|
+
}
|
|
22
|
+
async setFields(fields) {
|
|
23
|
+
this.parsedFields = fields;
|
|
24
|
+
}
|
|
25
|
+
async getFieldValues() {
|
|
26
|
+
return this.parsedFields?.reduce((values, field) => {
|
|
27
|
+
values[`custom_fields[${field.id}]`] = field.value;
|
|
28
|
+
return values;
|
|
29
|
+
}, {}) || {};
|
|
30
|
+
}
|
|
31
|
+
async validateFields() {
|
|
32
|
+
if (!this.parsedFields)
|
|
33
|
+
return true;
|
|
34
|
+
const errors = this.parsedFields.reduce((acc, field) => {
|
|
35
|
+
if (field.required && (!field.value || field.value === "")) {
|
|
36
|
+
acc[field.id.toString()] = `${field.label} is required`;
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
this.fieldErrors = errors;
|
|
41
|
+
return Object.keys(errors).length === 0;
|
|
42
|
+
}
|
|
43
|
+
handleFieldChange(field, event) {
|
|
44
|
+
const value = event.target.value;
|
|
45
|
+
field.value = value;
|
|
46
|
+
this.clearFieldError(field.id);
|
|
47
|
+
const isValid = !(field.required && !value);
|
|
48
|
+
if (!isValid) {
|
|
49
|
+
this.setFieldError(field.id, `${field.label} is required`);
|
|
50
|
+
}
|
|
51
|
+
this.fieldChanged.emit({ fieldId: field.id, value, isValid });
|
|
52
|
+
}
|
|
53
|
+
handleFileUpload(field, event) {
|
|
54
|
+
const { error, file } = event.detail;
|
|
55
|
+
const isValid = !error;
|
|
56
|
+
this.clearFieldError(field.id);
|
|
57
|
+
if (isValid) {
|
|
58
|
+
field.value = file;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.setFieldError(field.id, "File upload failed");
|
|
62
|
+
}
|
|
63
|
+
this.fileUploaded.emit({ fieldId: field.id, file, isValid });
|
|
64
|
+
}
|
|
65
|
+
clearFieldError(fieldId) {
|
|
66
|
+
this.fieldErrors = { ...this.fieldErrors };
|
|
67
|
+
delete this.fieldErrors[fieldId];
|
|
68
|
+
}
|
|
69
|
+
setFieldError(fieldId, message) {
|
|
70
|
+
this.fieldErrors = { ...this.fieldErrors, [fieldId]: message };
|
|
71
|
+
}
|
|
72
|
+
renderTextField(field) {
|
|
73
|
+
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 }));
|
|
74
|
+
}
|
|
75
|
+
renderFileField(field) {
|
|
76
|
+
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) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
field.value = "";
|
|
80
|
+
e.target.value = "";
|
|
81
|
+
}, 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))));
|
|
82
|
+
}
|
|
83
|
+
renderField(field) {
|
|
84
|
+
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
|
|
85
|
+
? this.renderFileField(field)
|
|
86
|
+
: this.renderTextField(field), this.fieldErrors[field.id] && (h("p", { class: "s-custom-fields-error" }, this.fieldErrors[field.id])))));
|
|
87
|
+
}
|
|
88
|
+
componentWillLoad() {
|
|
89
|
+
this.parsedFields = this.parseFields(this.fields);
|
|
90
|
+
}
|
|
91
|
+
parseFields(fields) {
|
|
92
|
+
if (!fields)
|
|
93
|
+
return [];
|
|
94
|
+
return typeof fields === "string"
|
|
95
|
+
? JSON.parse(fields)
|
|
96
|
+
: Array.isArray(fields) ? fields : [];
|
|
97
|
+
}
|
|
98
|
+
async handleSubmit(e) {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
this.isSubmitting = true;
|
|
101
|
+
try {
|
|
102
|
+
const payload = {};
|
|
103
|
+
const form = e.target;
|
|
104
|
+
const elements = form.elements;
|
|
105
|
+
for (let i = 0; i < elements.length; i++) {
|
|
106
|
+
const element = elements[i];
|
|
107
|
+
if (element.name && !element.name.startsWith("hidden") && element.value) {
|
|
108
|
+
payload[element.name] = element.value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
await salla.api.profile.updateCustomFields({
|
|
112
|
+
id: salla.config.get("store.id"),
|
|
113
|
+
fields: payload,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
this.isSubmitting = false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
if (!this.parsedFields?.length)
|
|
122
|
+
return null;
|
|
123
|
+
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)));
|
|
124
|
+
}
|
|
125
|
+
static get is() { return "salla-custom-fields"; }
|
|
126
|
+
static get originalStyleUrls() {
|
|
127
|
+
return {
|
|
128
|
+
"$": ["salla-custom-fields.scss"]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
static get styleUrls() {
|
|
132
|
+
return {
|
|
133
|
+
"$": ["salla-custom-fields.css"]
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
static get properties() {
|
|
137
|
+
return {
|
|
138
|
+
"fields": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"attribute": "fields",
|
|
141
|
+
"mutable": false,
|
|
142
|
+
"complexType": {
|
|
143
|
+
"original": "string | CustomField[]",
|
|
144
|
+
"resolved": "CustomField[] | string",
|
|
145
|
+
"references": {
|
|
146
|
+
"CustomField": {
|
|
147
|
+
"location": "import",
|
|
148
|
+
"path": "../salla-user-profile/interfaces",
|
|
149
|
+
"id": "src/components/salla-user-profile/interfaces.ts::CustomField"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"required": false,
|
|
154
|
+
"optional": false,
|
|
155
|
+
"docs": {
|
|
156
|
+
"tags": [],
|
|
157
|
+
"text": ""
|
|
158
|
+
},
|
|
159
|
+
"getter": false,
|
|
160
|
+
"setter": false,
|
|
161
|
+
"reflect": false
|
|
162
|
+
},
|
|
163
|
+
"isEditable": {
|
|
164
|
+
"type": "boolean",
|
|
165
|
+
"attribute": "is-editable",
|
|
166
|
+
"mutable": false,
|
|
167
|
+
"complexType": {
|
|
168
|
+
"original": "boolean",
|
|
169
|
+
"resolved": "boolean",
|
|
170
|
+
"references": {}
|
|
171
|
+
},
|
|
172
|
+
"required": false,
|
|
173
|
+
"optional": false,
|
|
174
|
+
"docs": {
|
|
175
|
+
"tags": [],
|
|
176
|
+
"text": ""
|
|
177
|
+
},
|
|
178
|
+
"getter": false,
|
|
179
|
+
"setter": false,
|
|
180
|
+
"reflect": false,
|
|
181
|
+
"defaultValue": "true"
|
|
182
|
+
},
|
|
183
|
+
"fileUploadUrl": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"attribute": "file-upload-url",
|
|
186
|
+
"mutable": false,
|
|
187
|
+
"complexType": {
|
|
188
|
+
"original": "string",
|
|
189
|
+
"resolved": "string",
|
|
190
|
+
"references": {}
|
|
191
|
+
},
|
|
192
|
+
"required": false,
|
|
193
|
+
"optional": false,
|
|
194
|
+
"docs": {
|
|
195
|
+
"tags": [],
|
|
196
|
+
"text": ""
|
|
197
|
+
},
|
|
198
|
+
"getter": false,
|
|
199
|
+
"setter": false,
|
|
200
|
+
"reflect": false
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
static get states() {
|
|
205
|
+
return {
|
|
206
|
+
"parsedFields": {},
|
|
207
|
+
"fieldErrors": {},
|
|
208
|
+
"isSubmitting": {}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
static get events() {
|
|
212
|
+
return [{
|
|
213
|
+
"method": "fieldChanged",
|
|
214
|
+
"name": "fieldChanged",
|
|
215
|
+
"bubbles": true,
|
|
216
|
+
"cancelable": true,
|
|
217
|
+
"composed": true,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": ""
|
|
221
|
+
},
|
|
222
|
+
"complexType": {
|
|
223
|
+
"original": "{\n fieldId: string | number;\n value: unknown;\n isValid: boolean;\n }",
|
|
224
|
+
"resolved": "{ fieldId: string | number; value: unknown; isValid: boolean; }",
|
|
225
|
+
"references": {}
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
"method": "fileUploaded",
|
|
229
|
+
"name": "fileUploaded",
|
|
230
|
+
"bubbles": true,
|
|
231
|
+
"cancelable": true,
|
|
232
|
+
"composed": true,
|
|
233
|
+
"docs": {
|
|
234
|
+
"tags": [],
|
|
235
|
+
"text": ""
|
|
236
|
+
},
|
|
237
|
+
"complexType": {
|
|
238
|
+
"original": "{\n fieldId: string | number;\n file: File;\n isValid: boolean;\n }",
|
|
239
|
+
"resolved": "{ fieldId: string | number; file: File; isValid: boolean; }",
|
|
240
|
+
"references": {
|
|
241
|
+
"File": {
|
|
242
|
+
"location": "global",
|
|
243
|
+
"id": "global::File"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}];
|
|
248
|
+
}
|
|
249
|
+
static get methods() {
|
|
250
|
+
return {
|
|
251
|
+
"setFields": {
|
|
252
|
+
"complexType": {
|
|
253
|
+
"signature": "(fields: CustomField[]) => Promise<void>",
|
|
254
|
+
"parameters": [{
|
|
255
|
+
"name": "fields",
|
|
256
|
+
"type": "CustomField[]",
|
|
257
|
+
"docs": ""
|
|
258
|
+
}],
|
|
259
|
+
"references": {
|
|
260
|
+
"Promise": {
|
|
261
|
+
"location": "global",
|
|
262
|
+
"id": "global::Promise"
|
|
263
|
+
},
|
|
264
|
+
"CustomField": {
|
|
265
|
+
"location": "import",
|
|
266
|
+
"path": "../salla-user-profile/interfaces",
|
|
267
|
+
"id": "src/components/salla-user-profile/interfaces.ts::CustomField"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"return": "Promise<void>"
|
|
271
|
+
},
|
|
272
|
+
"docs": {
|
|
273
|
+
"text": "",
|
|
274
|
+
"tags": []
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"getFieldValues": {
|
|
278
|
+
"complexType": {
|
|
279
|
+
"signature": "() => Promise<{ [key: string]: unknown; }>",
|
|
280
|
+
"parameters": [],
|
|
281
|
+
"references": {
|
|
282
|
+
"Promise": {
|
|
283
|
+
"location": "global",
|
|
284
|
+
"id": "global::Promise"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
"return": "Promise<{ [key: string]: unknown; }>"
|
|
288
|
+
},
|
|
289
|
+
"docs": {
|
|
290
|
+
"text": "",
|
|
291
|
+
"tags": []
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"validateFields": {
|
|
295
|
+
"complexType": {
|
|
296
|
+
"signature": "() => Promise<boolean>",
|
|
297
|
+
"parameters": [],
|
|
298
|
+
"references": {
|
|
299
|
+
"Promise": {
|
|
300
|
+
"location": "global",
|
|
301
|
+
"id": "global::Promise"
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"return": "Promise<boolean>"
|
|
305
|
+
},
|
|
306
|
+
"docs": {
|
|
307
|
+
"text": "",
|
|
308
|
+
"tags": []
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -42,6 +42,10 @@ export class SallaFileUpload {
|
|
|
42
42
|
* Set the component to be profile image uploader with a preview and a circular shape
|
|
43
43
|
*/
|
|
44
44
|
this.profileImage = false;
|
|
45
|
+
/**
|
|
46
|
+
* Allow to pass extra params to be sent with the upload request
|
|
47
|
+
*/
|
|
48
|
+
this.payloadParams = {};
|
|
45
49
|
/**
|
|
46
50
|
* Accepted file types
|
|
47
51
|
*/
|
|
@@ -303,11 +307,11 @@ export class SallaFileUpload {
|
|
|
303
307
|
}
|
|
304
308
|
}
|
|
305
309
|
render() {
|
|
306
|
-
return (h(Host, { key: '
|
|
310
|
+
return (h(Host, { key: '68939496fd8cfcc89a7a5d21e7e4daedab0db536', class: {
|
|
307
311
|
"s-file-upload": true,
|
|
308
312
|
"s-file-upload-profile-image": this.profileImage,
|
|
309
313
|
"s-file-upload-multiple": this.allowMultiple,
|
|
310
|
-
} }, h("input", { key: '
|
|
314
|
+
} }, 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 })));
|
|
311
315
|
}
|
|
312
316
|
componentDidLoad() {
|
|
313
317
|
let files = this.getFiles();
|
|
@@ -390,7 +394,7 @@ export class SallaFileUpload {
|
|
|
390
394
|
process: {
|
|
391
395
|
onload: (response) => {
|
|
392
396
|
let responseData = JSON.parse(response).data;
|
|
393
|
-
if (this.allowMultiple && Array.isArray(responseData) && responseData.length > 0) {
|
|
397
|
+
if ((this.instantUpload || this.allowMultiple) && Array.isArray(responseData) && responseData.length > 0) {
|
|
394
398
|
const fileId = `${this.host.id}-${Math.floor(100 + Math.random() * 900)}`;
|
|
395
399
|
this.uploadedFiles.push({
|
|
396
400
|
id: fileId,
|
|
@@ -434,6 +438,11 @@ export class SallaFileUpload {
|
|
|
434
438
|
formData.append(this.payloadName, this.filepond.getFile(0).file);
|
|
435
439
|
formData.delete(this.name);
|
|
436
440
|
}
|
|
441
|
+
if (this.payloadParams) {
|
|
442
|
+
for (const [k, v] of Object.entries(this.payloadParams)) {
|
|
443
|
+
formData.append(k, v);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
437
446
|
if (this.cartItemId) {
|
|
438
447
|
formData.append('cart_item_id', this.cartItemId);
|
|
439
448
|
}
|
|
@@ -626,6 +635,30 @@ export class SallaFileUpload {
|
|
|
626
635
|
"setter": false,
|
|
627
636
|
"reflect": false
|
|
628
637
|
},
|
|
638
|
+
"payloadParams": {
|
|
639
|
+
"type": "unknown",
|
|
640
|
+
"attribute": "payload-params",
|
|
641
|
+
"mutable": false,
|
|
642
|
+
"complexType": {
|
|
643
|
+
"original": "Record<string,unknown>",
|
|
644
|
+
"resolved": "{ [x: string]: unknown; }",
|
|
645
|
+
"references": {
|
|
646
|
+
"Record": {
|
|
647
|
+
"location": "global",
|
|
648
|
+
"id": "global::Record"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
"required": false,
|
|
653
|
+
"optional": true,
|
|
654
|
+
"docs": {
|
|
655
|
+
"tags": [],
|
|
656
|
+
"text": "Allow to pass extra params to be sent with the upload request"
|
|
657
|
+
},
|
|
658
|
+
"getter": false,
|
|
659
|
+
"setter": false,
|
|
660
|
+
"defaultValue": "{}"
|
|
661
|
+
},
|
|
629
662
|
"type": {
|
|
630
663
|
"type": "string",
|
|
631
664
|
"attribute": "type",
|
|
@@ -15,6 +15,7 @@ import Rate from "../../assets/svg/star2.svg";
|
|
|
15
15
|
import UserCircle from "../../assets/svg/user-circle.svg";
|
|
16
16
|
import WalletIcon from "../../assets/svg/wallet.svg";
|
|
17
17
|
import loyaltyProgramIcon from "../../assets/svg/gift.svg";
|
|
18
|
+
import SettingstIcon from "../../assets/svg/settings.svg";
|
|
18
19
|
/**
|
|
19
20
|
* @slot trigger - Replaces trigger widget, has replaceable props `{avatar}`, `{hello}`, `{first_name}`, `{last_name}`, `{icon}`.
|
|
20
21
|
* @slot login-btn - Replaces the login button, it must be used with `salla.event.dispatch('login::open')` to open the login modal.
|
|
@@ -26,9 +27,10 @@ export class SallaUserMenu {
|
|
|
26
27
|
orders: OrderIcon,
|
|
27
28
|
pending_orders: PendingOrdersIcon,
|
|
28
29
|
wishlist: WishListIcon,
|
|
29
|
-
profile: ProfileIcon,
|
|
30
30
|
wallet: WalletIcon,
|
|
31
31
|
loyalty_program: loyaltyProgramIcon,
|
|
32
|
+
profile: ProfileIcon,
|
|
33
|
+
settings: SettingstIcon,
|
|
32
34
|
};
|
|
33
35
|
this.accountLoading = false;
|
|
34
36
|
this.opened = false;
|
|
@@ -39,6 +41,7 @@ export class SallaUserMenu {
|
|
|
39
41
|
this.profile = salla.lang.get('common.titles.profile');
|
|
40
42
|
this.rating = salla.lang.get('common.titles.rating');
|
|
41
43
|
this.wallet = salla.lang.get('common.titles.wallet');
|
|
44
|
+
this.settings = salla.lang.get('common.titles.settings');
|
|
42
45
|
this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
|
|
43
46
|
this.logout = salla.lang.get('blocks.header.logout');
|
|
44
47
|
this.hello = salla.lang.get('pages.checkout.hello');
|
|
@@ -83,6 +86,7 @@ export class SallaUserMenu {
|
|
|
83
86
|
this.hello = salla.lang.get('pages.checkout.hello');
|
|
84
87
|
this.rating = salla.lang.get('common.titles.rating');
|
|
85
88
|
this.wallet = salla.lang.get('common.titles.wallet');
|
|
89
|
+
this.settings = salla.lang.get('common.titles.settings');
|
|
86
90
|
this.loyalty_program = salla.lang.get('pages.loyalty_program.loyalty_points');
|
|
87
91
|
this.logout = salla.lang.get('blocks.header.logout');
|
|
88
92
|
});
|
|
@@ -124,8 +128,9 @@ export class SallaUserMenu {
|
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
130
|
componentWillLoad() {
|
|
127
|
-
return
|
|
128
|
-
|
|
131
|
+
return salla.onReady().then(() => {
|
|
132
|
+
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')}`;
|
|
133
|
+
const trigger = this.host.querySelector('[slot="trigger"]');
|
|
129
134
|
this.triggerSlot =
|
|
130
135
|
'<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>';
|
|
131
136
|
if (!trigger) {
|
|
@@ -162,8 +167,8 @@ export class SallaUserMenu {
|
|
|
162
167
|
window.addEventListener('click', this.onClickOutside);
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
|
-
menuItemClicked(event,
|
|
166
|
-
if (
|
|
170
|
+
menuItemClicked(event, itemKey) {
|
|
171
|
+
if (itemKey !== 'logout') {
|
|
167
172
|
return;
|
|
168
173
|
}
|
|
169
174
|
event.preventDefault();
|
|
@@ -182,18 +187,23 @@ export class SallaUserMenu {
|
|
|
182
187
|
's-user-menu-trigger-slot': true,
|
|
183
188
|
's-user-menu-red-dot': this.hasBadges,
|
|
184
189
|
's-user-menu-trigger-avatar-only': this.avatarOnly,
|
|
185
|
-
}, id: "trigger-slot", onClick: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
|
|
190
|
+
}, id: "trigger-slot", onClick: e => this.open(e), onKeyUp: e => this.open(e), innerHTML: this.replaceParams(this.triggerSlot) }));
|
|
191
|
+
}
|
|
192
|
+
getItemAnchorLinkAttrs(itemKey) {
|
|
193
|
+
// Fix loyalty program URL mapping from master
|
|
194
|
+
const urlKey = itemKey === 'loyalty_program' ? 'loyalty' : itemKey;
|
|
195
|
+
return { href: salla.url.get(urlKey) };
|
|
186
196
|
}
|
|
187
|
-
getMenuItem(
|
|
197
|
+
getMenuItem([itemKey, itemValue], i) {
|
|
188
198
|
//todo:: enhancement support slot here
|
|
189
|
-
if (
|
|
199
|
+
if (itemKey === 'wallet' && !window.can_access_wallet)
|
|
190
200
|
return;
|
|
191
|
-
if (
|
|
201
|
+
if (itemKey === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
|
|
192
202
|
return;
|
|
193
203
|
return (h("li", { class: {
|
|
194
204
|
's-user-menu-dropdown-item': true,
|
|
195
|
-
's-user-menu-dropdown-item-logout': i + 1
|
|
196
|
-
} }, h("a", {
|
|
205
|
+
's-user-menu-dropdown-item-logout': i + 1 === Object.entries(this.items).length,
|
|
206
|
+
} }, 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])) : (''))));
|
|
197
207
|
}
|
|
198
208
|
componentShouldUpdate() {
|
|
199
209
|
if (!this.opened) {
|
|
@@ -202,7 +212,7 @@ export class SallaUserMenu {
|
|
|
202
212
|
}
|
|
203
213
|
render() {
|
|
204
214
|
if (!this.is_loggedIn) {
|
|
205
|
-
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 }))));
|
|
215
|
+
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 }))));
|
|
206
216
|
}
|
|
207
217
|
if (this.inline) {
|
|
208
218
|
return (h(Host, null, h("ul", { class: "s-user-menu-inline" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i)))));
|
|
@@ -210,10 +220,9 @@ export class SallaUserMenu {
|
|
|
210
220
|
return (h(Host, null, h("div", { class: {
|
|
211
221
|
's-user-menu-wrapper': true,
|
|
212
222
|
's-user-menu-relative-dropdown': this.relativeDropdown,
|
|
213
|
-
} }, 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: () =>
|
|
223
|
+
} }, 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))))))));
|
|
214
224
|
}
|
|
215
225
|
componentDidLoad() {
|
|
216
|
-
//make sure to load the avatar if it's lazy, we use it in Y
|
|
217
226
|
document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));
|
|
218
227
|
}
|
|
219
228
|
static get is() { return "salla-user-menu"; }
|
|
@@ -322,6 +331,7 @@ export class SallaUserMenu {
|
|
|
322
331
|
"profile": {},
|
|
323
332
|
"rating": {},
|
|
324
333
|
"wallet": {},
|
|
334
|
+
"settings": {},
|
|
325
335
|
"loyalty_program": {},
|
|
326
336
|
"logout": {},
|
|
327
337
|
"hello": {},
|
|
@@ -331,6 +341,7 @@ export class SallaUserMenu {
|
|
|
331
341
|
"is_loggedIn": {},
|
|
332
342
|
"badges": {},
|
|
333
343
|
"hasBadges": {},
|
|
344
|
+
"profileUrl": {},
|
|
334
345
|
"OrderUpdate": {}
|
|
335
346
|
};
|
|
336
347
|
}
|