@salla.sa/twilight-components 2.14.294 → 2.14.296

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/cjs/{filepond-CGGCjN56.js → filepond-E7NOvLwV.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-CSZViO2Z.js → filepond-plugin-file-poster-D3bKYBq5.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-E6Gv15oF.js → filepond-plugin-file-validate-size-D4sJa2nT.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-CPyu8pxB.js → filepond-plugin-file-validate-type-DDz99ei0.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CSNer-A5.js → filepond-plugin-image-edit-yDHuyk0R.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-DEzwTEOc.js → filepond-plugin-image-exif-orientation-hj89JJI_.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CFGHrSPe.js → filepond-plugin-image-preview-UoTioUkG.js} +1 -1
  8. package/dist/cjs/{index-COQqEmIG.js → index-BZQAN2JT.js} +1 -1
  9. package/dist/cjs/{index-BKN6oqfk.js → index-BfEIQrIk.js} +6 -2
  10. package/dist/cjs/interfaces-CX9-6aLf.js +24 -0
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion_62.cjs.entry.js +66 -117
  13. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-custom-fields.cjs.entry.js +135 -0
  20. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  46. package/dist/cjs/twilight.cjs.js +2 -2
  47. package/dist/collection/collection-manifest.json +1 -0
  48. package/dist/collection/components/salla-custom-fields/salla-custom-fields.css +3 -0
  49. package/dist/collection/components/salla-custom-fields/salla-custom-fields.js +313 -0
  50. package/dist/collection/components/salla-file-upload/salla-file-upload.js +36 -3
  51. package/dist/collection/components/salla-product-options/salla-product-options.js +1 -1
  52. package/dist/collection/components/salla-user-menu/salla-user-menu.js +25 -14
  53. package/dist/collection/components/salla-user-profile/salla-user-profile.js +15 -132
  54. package/dist/components/index.js +2 -2
  55. package/dist/components/interfaces.js +15 -0
  56. package/dist/components/salla-custom-fields.d.ts +11 -0
  57. package/dist/components/salla-custom-fields.js +174 -0
  58. package/dist/components/salla-file-upload2.js +13 -3
  59. package/dist/components/salla-product-options2.js +1 -1
  60. package/dist/components/salla-user-menu.js +31 -14
  61. package/dist/components/salla-user-profile.js +19 -97
  62. package/dist/esm/{filepond-9s_hrH-T.js → filepond-BEN4Pt87.js} +1 -1
  63. package/dist/esm/{filepond-plugin-file-poster-B0Eow32y.js → filepond-plugin-file-poster-B7t9aVVy.js} +1 -1
  64. package/dist/esm/{filepond-plugin-file-validate-size-Cqzs4jCA.js → filepond-plugin-file-validate-size-DFkfdHfo.js} +1 -1
  65. package/dist/esm/{filepond-plugin-file-validate-type-uJfZLwRE.js → filepond-plugin-file-validate-type-CU-RnplM.js} +1 -1
  66. package/dist/esm/{filepond-plugin-image-edit-Ck70H3zM.js → filepond-plugin-image-edit-Dz3oYXef.js} +1 -1
  67. package/dist/esm/{filepond-plugin-image-exif-orientation-BB-xgO8T.js → filepond-plugin-image-exif-orientation-DJrUnj97.js} +1 -1
  68. package/dist/esm/{filepond-plugin-image-preview-CO4zuhvC.js → filepond-plugin-image-preview-BCWlifYd.js} +1 -1
  69. package/dist/esm/{index-BzYM6G5p.js → index-bXg2F_NN.js} +6 -2
  70. package/dist/esm/{index-CTrhtRUR.js → index-fxSENfiU.js} +1 -1
  71. package/dist/esm/interfaces-CBT_Nxny.js +22 -0
  72. package/dist/esm/loader.js +3 -3
  73. package/dist/esm/salla-accordion_62.entry.js +65 -116
  74. package/dist/esm/salla-advertisement.entry.js +1 -1
  75. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  76. package/dist/esm/salla-apps-icons.entry.js +1 -1
  77. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  78. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  79. package/dist/esm/salla-contacts.entry.js +1 -1
  80. package/dist/esm/salla-custom-fields.entry.js +133 -0
  81. package/dist/esm/salla-filters-widget.entry.js +1 -1
  82. package/dist/esm/salla-filters.entry.js +1 -1
  83. package/dist/esm/salla-installment.entry.js +1 -1
  84. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  85. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  86. package/dist/esm/salla-metadata.entry.js +1 -1
  87. package/dist/esm/salla-notification-item.entry.js +1 -1
  88. package/dist/esm/salla-notifications.entry.js +1 -1
  89. package/dist/esm/salla-offer.entry.js +1 -1
  90. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  91. package/dist/esm/salla-order-details-options.entry.js +1 -1
  92. package/dist/esm/salla-order-details.entry.js +1 -1
  93. package/dist/esm/salla-order-summary.entry.js +1 -1
  94. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  95. package/dist/esm/salla-orders.entry.js +1 -1
  96. package/dist/esm/salla-payments.entry.js +1 -1
  97. package/dist/esm/salla-price-range.entry.js +1 -1
  98. package/dist/esm/salla-review-card.entry.js +1 -1
  99. package/dist/esm/salla-reviews-page.entry.js +1 -1
  100. package/dist/esm/salla-reviews.entry.js +1 -1
  101. package/dist/esm/salla-social.entry.js +1 -1
  102. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  103. package/dist/esm/salla-tooltip.entry.js +1 -1
  104. package/dist/esm/salla-trust-badges.entry.js +1 -1
  105. package/dist/esm/salla-verify.entry.js +1 -1
  106. package/dist/esm/salla-wallet.entry.js +1 -1
  107. package/dist/esm/twilight.js +3 -3
  108. package/dist/twilight/{p-4e11facd.entry.js → p-0645c8e3.entry.js} +1 -1
  109. package/dist/twilight/{p-5a86632d.entry.js → p-0b970445.entry.js} +1 -1
  110. package/dist/twilight/{p-394506f0.entry.js → p-193bea42.entry.js} +1 -1
  111. package/dist/twilight/{p-B86wiAo3.js → p-1Xk7fjpB.js} +1 -1
  112. package/dist/twilight/{p-9757dde8.entry.js → p-1b7cfbae.entry.js} +1 -1
  113. package/dist/twilight/{p-03c963db.entry.js → p-22f479da.entry.js} +1 -1
  114. package/dist/twilight/{p-97dc4af6.entry.js → p-32512487.entry.js} +1 -1
  115. package/dist/twilight/{p-e0414354.entry.js → p-4dd68813.entry.js} +1 -1
  116. package/dist/twilight/{p-d267acaf.entry.js → p-4fb7f400.entry.js} +1 -1
  117. package/dist/twilight/{p-f494e503.entry.js → p-51ef83f7.entry.js} +1 -1
  118. package/dist/twilight/{p-2c65b54d.entry.js → p-56dde07a.entry.js} +1 -1
  119. package/dist/twilight/p-5dd1b37c.entry.js +4 -0
  120. package/dist/twilight/{p-3c2fd683.entry.js → p-5f247331.entry.js} +1 -1
  121. package/dist/twilight/{p-dce21b0f.entry.js → p-67ed25a4.entry.js} +1 -1
  122. package/dist/twilight/{p-7bc8f5f2.entry.js → p-7012bda9.entry.js} +1 -1
  123. package/dist/twilight/{p-5e2486f2.entry.js → p-732c5190.entry.js} +1 -1
  124. package/dist/twilight/{p-a887c4e9.entry.js → p-76657684.entry.js} +1 -1
  125. package/dist/twilight/{p-cda63906.entry.js → p-8220b125.entry.js} +1 -1
  126. package/dist/twilight/{p-ce99c462.entry.js → p-8d3f2028.entry.js} +1 -1
  127. package/dist/twilight/{p-bf81d2cb.entry.js → p-988ea6cb.entry.js} +1 -1
  128. package/dist/twilight/{p-a2e4c4e9.entry.js → p-9f42e27b.entry.js} +1 -1
  129. package/dist/twilight/{p-uGfP8-tV.js → p-BIRmkG1d.js} +1 -1
  130. package/dist/twilight/{p-DZjKCWKU.js → p-BW8LVXVp.js} +2 -2
  131. package/dist/twilight/p-CBT_Nxny.js +4 -0
  132. package/dist/twilight/{p-CDmVMECr.js → p-CD5i_50p.js} +1 -1
  133. package/dist/twilight/{p-CczoUZzK.js → p-CP2LDZCD.js} +1 -1
  134. package/dist/twilight/{p-5M19N20S.js → p-CWkLySV3.js} +1 -1
  135. package/dist/twilight/{p-CZPa2uSm.js → p-CoLlt5es.js} +1 -1
  136. package/dist/twilight/{p-3de1d08f.entry.js → p-a6ebba30.entry.js} +1 -1
  137. package/dist/twilight/p-bXg2F_NN.js +5 -0
  138. package/dist/twilight/{p-4ef533e4.entry.js → p-c5afe02a.entry.js} +1 -1
  139. package/dist/twilight/{p-881a41b7.entry.js → p-c691fd39.entry.js} +1 -1
  140. package/dist/twilight/{p-0d5c3afe.entry.js → p-c848e1d3.entry.js} +1 -1
  141. package/dist/twilight/{p-5c3aacf5.entry.js → p-c88d32f0.entry.js} +1 -1
  142. package/dist/twilight/p-d08cedb0.entry.js +11 -0
  143. package/dist/twilight/{p-bb15a2d4.entry.js → p-dcd9e688.entry.js} +1 -1
  144. package/dist/twilight/{p-823202a3.entry.js → p-dd84065f.entry.js} +1 -1
  145. package/dist/twilight/{p-f3b2d756.entry.js → p-e4418e6f.entry.js} +1 -1
  146. package/dist/twilight/{p-d35d16fd.entry.js → p-ef3a4d3e.entry.js} +1 -1
  147. package/dist/twilight/{p-e4e3ed35.entry.js → p-ef9ac6cb.entry.js} +1 -1
  148. package/dist/twilight/{p-f7c29e31.entry.js → p-f4549e2e.entry.js} +1 -1
  149. package/dist/twilight/{p-454504b2.entry.js → p-fa379f1e.entry.js} +1 -1
  150. package/dist/twilight/{p-2b23018d.entry.js → p-fcd1344e.entry.js} +1 -1
  151. package/dist/twilight/{p-Ie0stZTt.js → p-k3nBgoPC.js} +1 -1
  152. package/dist/twilight/twilight.esm.js +1 -1
  153. package/dist/types/components/salla-custom-fields/salla-custom-fields.d.ts +39 -0
  154. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +4 -0
  155. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +4 -1
  156. package/dist/types/components/salla-user-profile/interfaces.d.ts +1 -0
  157. package/dist/types/components/salla-user-profile/salla-user-profile.d.ts +1 -20
  158. package/dist/types/components.d.ts +74 -25
  159. package/package.json +5 -5
  160. package/dist/twilight/p-29f0ab1e.entry.js +0 -11
  161. package/dist/twilight/p-BzYM6G5p.js +0 -5
@@ -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: 'b5d3d0cf960e703c563f8999d55a99cbfe7a85e3', class: {
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: '5e9cc8cd73e83acbb0a9f04e15e530563e94988b', type: "file", name: this.name, value: this.value, ref: ele => this.fileUploader = ele, required: this.required, class: "s-file-upload-wrapper s-file-upload-input", accept: this.accept }), this.allowMultiple && this.showMaxCountHint ? h("div", { class: "s-file-upload-hint s-hidden" }, this.max_count_hint(this.maxFilesCount)) : '', h("input", { key: '13a402c070302bfb00d82a24f523a9b764e39037', class: "s-hidden", name: 'hidden-' + this.name, required: this.required, value: this.value, ref: input => this.hiddenInput = input })));
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",
@@ -397,7 +397,7 @@ export class SallaProductOptions {
397
397
  */
398
398
  handlePaste(event) {
399
399
  const target = event.target;
400
- if (!Salla.helpers.hasApplePay()
400
+ if (!Salla.helpers.isAppleDevice()
401
401
  || !(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)
402
402
  || !target.classList.contains('s-form-control')) {
403
403
  return;
@@ -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 new Promise(resolve => salla.onReady(resolve)).then(() => {
128
- let trigger = this.host.querySelector('[slot="trigger"]');
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, item) {
166
- if (item[0] !== 'logout') {
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(item, i) {
197
+ getMenuItem([itemKey, itemValue], i) {
188
198
  //todo:: enhancement support slot here
189
- if (item[0] === 'wallet' && !window.can_access_wallet)
199
+ if (itemKey === 'wallet' && !window.can_access_wallet)
190
200
  return;
191
- if (item[0] === 'loyalty_program' && !salla.config.get('store.features').includes('loyalty-system'))
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 == Object.entries(this.items).length,
196
- } }, h("a", { href: salla.url.get(item[0] === 'loyalty_program' ? 'loyalty' : item[0]), onClick: event => this.menuItemClicked(event, item) }, h("i", { innerHTML: item[1] }, " "), h("span", { class: "s-user-menu-dropdown-item-title" }, this[item[0]]), !['٠', '0', undefined].includes(this.badges[item[0]]) ? (h("span", { class: "s-user-menu-dropdown-item-badge" }, this.badges[item[0]])) : (''))));
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: () => (this.opened = false) }))) : (''), h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
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
  }