@salla.sa/twilight-components 2.11.9 → 2.11.10

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 (35) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_37.cjs.entry.js +103 -88
  3. package/dist/cjs/twilight.cjs.js +1 -1
  4. package/dist/collection/components/salla-color-picker/salla-color-picker.js +49 -1
  5. package/dist/collection/components/salla-file-upload/salla-file-upload.js +64 -78
  6. package/dist/collection/components/salla-map/salla-map.js +58 -18
  7. package/dist/collection/components/salla-product-options/interfaces.js +3 -0
  8. package/dist/collection/components/salla-product-options/salla-product-options.js +69 -20
  9. package/dist/collection/components/salla-slider/salla-slider.js +2 -2
  10. package/dist/components/salla-color-picker.js +1 -1174
  11. package/dist/components/salla-color-picker2.js +1192 -0
  12. package/dist/components/salla-file-upload2.js +30 -75
  13. package/dist/components/salla-map.js +1 -716
  14. package/dist/components/salla-map2.js +728 -0
  15. package/dist/components/salla-product-options.js +82 -26
  16. package/dist/components/salla-slider2.js +2 -2
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/salla-button_37.entry.js +103 -88
  19. package/dist/esm/twilight.js +1 -1
  20. package/dist/esm-es5/loader.js +1 -1
  21. package/dist/esm-es5/salla-button_37.entry.js +4 -4
  22. package/dist/esm-es5/twilight.js +1 -1
  23. package/dist/twilight/p-184f8592.system.entry.js +53 -0
  24. package/dist/twilight/p-301c6601.entry.js +36 -0
  25. package/dist/twilight/p-c71ec183.system.js +1 -1
  26. package/dist/twilight/twilight.esm.js +1 -1
  27. package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +9 -0
  28. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +9 -25
  29. package/dist/types/components/salla-map/salla-map.d.ts +13 -2
  30. package/dist/types/components/salla-product-options/interfaces.d.ts +4 -1
  31. package/dist/types/components/salla-product-options/salla-product-options.d.ts +14 -3
  32. package/dist/types/components.d.ts +60 -4
  33. package/package.json +4 -4
  34. package/dist/twilight/p-9f9c6276.entry.js +0 -36
  35. package/dist/twilight/p-ecac0cdc.system.entry.js +0 -53
@@ -6,6 +6,14 @@ import Picker from 'vanilla-picker';
6
6
  import ArrowDown from "../../assets/svg/keyboard_arrow_down.svg";
7
7
  export class SallaColorPicker {
8
8
  constructor() {
9
+ /**
10
+ * File input name for the native formData
11
+ */
12
+ this.name = 'color';
13
+ /**
14
+ * Set if the color picker input is required or not
15
+ */
16
+ this.required = false;
9
17
  /**
10
18
  * Initial color for the picker.
11
19
  */
@@ -29,11 +37,14 @@ export class SallaColorPicker {
29
37
  this.enableAlpha = false;
30
38
  }
31
39
  colorChangeHandler(color) {
40
+ this.colorInput.value = color.hex;
32
41
  this.colorChanged.emit(color);
33
42
  }
34
43
  submittedHandler(color) {
35
44
  this.setColorValue(color.rgbaString, true);
36
45
  this.canvas.style.backgroundColor = color.rgbString;
46
+ this.colorInput.value = color.hex;
47
+ this.colorInput.dispatchEvent(new window.Event('change', { bubbles: true }));
37
48
  this.submitted.emit(color);
38
49
  }
39
50
  popupOpenedHandler(color) {
@@ -139,7 +150,8 @@ export class SallaColorPicker {
139
150
  h("slot", null,
140
151
  h("div", { class: "s-color-picker-widget" },
141
152
  h("div", { class: "s-color-picker-widget-canvas", ref: dv => this.canvas = dv }),
142
- h("span", { innerHTML: ArrowDown })))));
153
+ h("span", { innerHTML: ArrowDown }))),
154
+ h("input", { type: "hidden", name: this.name, required: this.required, value: this.color, ref: color => this.colorInput = color })));
143
155
  }
144
156
  static get is() { return "salla-color-picker"; }
145
157
  static get originalStyleUrls() { return {
@@ -149,6 +161,42 @@ export class SallaColorPicker {
149
161
  "$": ["salla-color-picker.css"]
150
162
  }; }
151
163
  static get properties() { return {
164
+ "name": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "string",
169
+ "resolved": "string",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "File input name for the native formData"
177
+ },
178
+ "attribute": "name",
179
+ "reflect": false,
180
+ "defaultValue": "'color'"
181
+ },
182
+ "required": {
183
+ "type": "boolean",
184
+ "mutable": false,
185
+ "complexType": {
186
+ "original": "boolean",
187
+ "resolved": "boolean",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": false,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": "Set if the color picker input is required or not"
195
+ },
196
+ "attribute": "required",
197
+ "reflect": false,
198
+ "defaultValue": "false"
199
+ },
152
200
  "color": {
153
201
  "type": "string",
154
202
  "mutable": false,
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { Component, Prop, State, h, Element, Host, Event, Method } from '@stencil/core';
4
+ import { Component, Prop, h, Element, Host, Event, Method } from '@stencil/core';
5
5
  import * as FilePond from 'filepond';
6
6
  import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size';
7
7
  import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orientation';
@@ -15,6 +15,10 @@ export class SallaFileUpload {
15
15
  * Set the component to be profile image uploader with a preview and a circular shape
16
16
  */
17
17
  this.profileImage = false;
18
+ /**
19
+ * Accepted file types
20
+ */
21
+ this.accept = "image/png, image/jpeg, image/jpg, image/gif, video/*";
18
22
  /**
19
23
  * The submit request method.
20
24
  */
@@ -107,32 +111,6 @@ export class SallaFileUpload {
107
111
  * The icon used for undo actions
108
112
  */
109
113
  this.iconUndo = '<svg>...</svg>';
110
- /// STATES
111
- /**
112
- * //todo:: drop all of there and set them directly @see how we set `labelFileTypeNotAllowed`
113
- * Translations
114
- */
115
- this.labelInvalidField = salla.lang.get("common.uploader.invalid_field");
116
- this.labelFileWaitingForSize = salla.lang.get('common.uploader.waiting_file_info');
117
- this.labelFileSizeNotAvailable = salla.lang.get('common.uploader.size_not_available');
118
- this.labelFileLoading = salla.lang.get('common.elements.loading');
119
- this.labelFileLoadError = salla.lang.get('common.uploader.failed_to_load');
120
- this.labelFileProcessing = salla.lang.get('common.uploader.uploading');
121
- this.labelFileProcessingComplete = salla.lang.get('common.uploader.upload_completed');
122
- this.labelFileProcessingAborted = salla.lang.get('common.uploader.upload_cancelled');
123
- this.labelFileProcessingError = salla.lang.get('common.uploader.error_uploading');
124
- this.labelFileProcessingRevertError = salla.lang.get('common.uploader.error_reverting');
125
- this.labelFileRemoveError = salla.lang.get('common.uploader.error_removing');
126
- this.labelTapToCancel = salla.lang.get("common.elements.cancel");
127
- this.labelTapToRetry = salla.lang.get("common.elements.retry");
128
- this.labelTapToUndo = salla.lang.get("common.uploader.revert");
129
- this.labelButtonRemoveItem = salla.lang.get("common.elements.remove");
130
- this.labelButtonAbortItemLoad = salla.lang.get("common.elements.abort");
131
- this.labelButtonRetryItemLoad = salla.lang.get("common.elements.retry");
132
- this.labelButtonAbortItemProcessing = salla.lang.get("common.uploader.abort_upload");
133
- this.labelButtonUndoItemProcessing = salla.lang.get("common.elements.undo");
134
- this.labelButtonRetryItemProcessing = `${salla.lang.get("common.elements.retry")} ${salla.lang.get("common.uploader.upload")}`;
135
- this.labelButtonProcessItem = salla.lang.get("common.uploader.upload");
136
114
  FilePond.registerPlugin(FilePondPluginImagePreview, FilePondPluginImageExifOrientation, FilePondPluginFileValidateSize, FilePondPluginImageEdit, FilePondPluginFileValidateType, FilePondPluginFilePoster);
137
115
  //if cartItemIdIsPassed, we need to set the url
138
116
  if (!this.url && this.cartItemId) {
@@ -149,30 +127,21 @@ export class SallaFileUpload {
149
127
  }
150
128
  salla.lang.onLoaded(() => {
151
129
  this.host.querySelectorAll('.filepond--drop-label>label').forEach(label => label.innerHTML = this.getLabel());
152
- this.labelInvalidField = salla.lang.get("common.uploader.invalid_field");
153
- this.labelFileWaitingForSize = salla.lang.get('common.uploader.waiting_file_info');
154
- this.labelFileSizeNotAvailable = salla.lang.get('common.uploader.size_not_available');
155
- this.labelFileLoading = salla.lang.get('common.elements.loading');
156
- this.labelFileLoadError = salla.lang.get('common.uploader.failed_to_load');
157
- this.labelFileProcessing = salla.lang.get('common.uploader.uploading');
158
- this.labelFileProcessingComplete = salla.lang.get('common.uploader.upload_completed');
159
- this.labelFileProcessingAborted = salla.lang.get('common.uploader.upload_cancelled');
160
- this.labelFileProcessingError = salla.lang.get('common.uploader.error_uploading');
161
- this.labelFileProcessingRevertError = salla.lang.get('common.uploader.error_reverting');
162
- this.labelFileRemoveError = salla.lang.get('common.uploader.error_removing');
163
- this.labelTapToCancel = salla.lang.get("common.elements.cancel");
164
- this.labelTapToRetry = salla.lang.get("common.elements.retry");
165
- this.labelTapToUndo = salla.lang.get("common.uploader.revert");
166
- this.labelButtonRemoveItem = salla.lang.get("common.elements.remove");
167
- this.labelButtonAbortItemLoad = salla.lang.get("common.elements.abort");
168
- this.labelButtonRetryItemLoad = salla.lang.get("common.elements.retry");
169
- this.labelButtonAbortItemProcessing = salla.lang.get("common.uploader.abort_upload");
170
- this.labelButtonUndoItemProcessing = salla.lang.get("common.elements.undo");
171
- this.labelButtonRetryItemProcessing = `${salla.lang.get("common.elements.retry")} ${salla.lang.get("common.uploader.upload")}`;
172
- this.labelButtonProcessItem = salla.lang.get("common.uploader.upload");
173
130
  if (this.filepond) {
174
131
  this.filepond.labelFileTypeNotAllowed = salla.lang.get('common.uploader.invalid_type');
175
132
  this.filepond.labelMaxFileSizeExceeded = salla.lang.get('common.uploader.too_large');
133
+ this.filepond.labelFileSizeNotAvailable = salla.lang.get('common.uploader.size_not_available');
134
+ this.filepond.labelFileLoading = salla.lang.get('common.elements.loading');
135
+ this.filepond.labelFileLoadError = salla.lang.get('common.uploader.failed_to_load');
136
+ this.filepond.labelFileProcessing = salla.lang.get('common.uploader.uploading');
137
+ this.filepond.labelFileProcessingComplete = salla.lang.get('common.uploader.upload_completed');
138
+ this.filepond.labelFileProcessingAborted = salla.lang.get('common.uploader.upload_cancelled');
139
+ this.filepond.labelFileProcessingError = salla.lang.get('common.uploader.error_uploading');
140
+ this.filepond.labelTapToCancel = salla.lang.get("common.elements.cancel");
141
+ this.filepond.labelTapToRetry = salla.lang.get("common.elements.retry");
142
+ this.filepond.labelButtonRemoveItem = salla.lang.get("common.elements.remove");
143
+ this.filepond.labelButtonUndoItemProcessing = salla.lang.get("common.elements.undo");
144
+ this.filepond.labelButtonProcessItem = salla.lang.get("common.uploader.upload");
176
145
  }
177
146
  });
178
147
  }
@@ -188,11 +157,13 @@ export class SallaFileUpload {
188
157
  container.items.add(file.file);
189
158
  fileInput.type = 'file';
190
159
  fileInput.files = container.files;
160
+ fileInput.dispatchEvent(new window.Event('change', { bubbles: true }));
191
161
  }
192
162
  uploadedHandler() {
193
163
  let fileInput = this.getFormDataFileInput();
194
164
  fileInput.type = 'hidden';
195
165
  fileInput.value = this.value;
166
+ fileInput.dispatchEvent(new window.Event('change', { bubbles: true }));
196
167
  return this.uploaded.emit(this.value);
197
168
  }
198
169
  removedHandler(deletedFile) {
@@ -202,6 +173,10 @@ export class SallaFileUpload {
202
173
  if (deletedFile.getMetadata('id')) {
203
174
  salla.cart.api.deleteImage(deletedFile.getMetadata('id'));
204
175
  }
176
+ if (this.height) {
177
+ setTimeout(() => this.host.querySelector('.filepond--root').style.height = this.height, 1000);
178
+ }
179
+ fileInput.dispatchEvent(new window.Event('change', { bubbles: true }));
205
180
  return this.removed.emit(deletedFile);
206
181
  }
207
182
  async setOption(key, value) {
@@ -248,16 +223,18 @@ export class SallaFileUpload {
248
223
  }
249
224
  return [];
250
225
  }
251
- render() {
226
+ componentWillLoad() {
252
227
  if (!this.labelIdle) {
253
228
  this.labelIdle = this.host.innerHTML;
254
229
  this.host.innerHTML = '';
255
230
  }
231
+ }
232
+ render() {
256
233
  return (h(Host, { class: {
257
234
  "s-file-upload": true,
258
235
  "s-file-upload-profile-image": this.profileImage,
259
236
  } },
260
- h("input", { 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: "image/png, image/jpeg, image/jpg, image/gif" })));
237
+ h("input", { 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 })));
261
238
  }
262
239
  componentDidLoad() {
263
240
  let files = this.getFiles();
@@ -337,10 +314,7 @@ export class SallaFileUpload {
337
314
  labelDecimalSeparator: this.labelDecimalSeparator,
338
315
  labelThousandsSeparator: this.labelThousandsSeparator,
339
316
  labelIdle: this.getLabel(),
340
- //todo:: pass support types from props
341
- acceptedFileTypes: ['image/jpg', 'image/png', 'image/jpeg', 'image/gif', 'video/*'],
342
- labelInvalidField: this.labelInvalidField,
343
- labelFileWaitingForSize: this.labelFileWaitingForSize,
317
+ acceptedFileTypes: this.accept.replace(/\s+/g, '').split(','),
344
318
  labelFileTypeNotAllowed: salla.lang.get('common.uploader.invalid_type'),
345
319
  fileValidateTypeLabelExpectedTypes: '{allButLastType}, {lastType}',
346
320
  labelMaxFileSizeExceeded: salla.lang.get('common.uploader.too_large'),
@@ -395,6 +369,23 @@ export class SallaFileUpload {
395
369
  "attribute": "files",
396
370
  "reflect": true
397
371
  },
372
+ "height": {
373
+ "type": "string",
374
+ "mutable": false,
375
+ "complexType": {
376
+ "original": "string",
377
+ "resolved": "string",
378
+ "references": {}
379
+ },
380
+ "required": false,
381
+ "optional": false,
382
+ "docs": {
383
+ "tags": [],
384
+ "text": "The original height of the uploader, will be used to reset the height after the image is removed."
385
+ },
386
+ "attribute": "height",
387
+ "reflect": true
388
+ },
398
389
  "cartItemId": {
399
390
  "type": "string",
400
391
  "mutable": false,
@@ -464,6 +455,24 @@ export class SallaFileUpload {
464
455
  "attribute": "payload-name",
465
456
  "reflect": false
466
457
  },
458
+ "accept": {
459
+ "type": "string",
460
+ "mutable": false,
461
+ "complexType": {
462
+ "original": "string",
463
+ "resolved": "string",
464
+ "references": {}
465
+ },
466
+ "required": false,
467
+ "optional": false,
468
+ "docs": {
469
+ "tags": [],
470
+ "text": "Accepted file types"
471
+ },
472
+ "attribute": "accept",
473
+ "reflect": false,
474
+ "defaultValue": "\"image/png, image/jpeg, image/jpg, image/gif, video/*\""
475
+ },
467
476
  "fileId": {
468
477
  "type": "number",
469
478
  "mutable": false,
@@ -1088,7 +1097,7 @@ export class SallaFileUpload {
1088
1097
  },
1089
1098
  "labelIdle": {
1090
1099
  "type": "string",
1091
- "mutable": false,
1100
+ "mutable": true,
1092
1101
  "complexType": {
1093
1102
  "original": "string",
1094
1103
  "resolved": "string",
@@ -1179,29 +1188,6 @@ export class SallaFileUpload {
1179
1188
  "defaultValue": "'<svg>...</svg>'"
1180
1189
  }
1181
1190
  }; }
1182
- static get states() { return {
1183
- "labelInvalidField": {},
1184
- "labelFileWaitingForSize": {},
1185
- "labelFileSizeNotAvailable": {},
1186
- "labelFileLoading": {},
1187
- "labelFileLoadError": {},
1188
- "labelFileProcessing": {},
1189
- "labelFileProcessingComplete": {},
1190
- "labelFileProcessingAborted": {},
1191
- "labelFileProcessingError": {},
1192
- "labelFileProcessingRevertError": {},
1193
- "labelFileRemoveError": {},
1194
- "labelTapToCancel": {},
1195
- "labelTapToRetry": {},
1196
- "labelTapToUndo": {},
1197
- "labelButtonRemoveItem": {},
1198
- "labelButtonAbortItemLoad": {},
1199
- "labelButtonRetryItemLoad": {},
1200
- "labelButtonAbortItemProcessing": {},
1201
- "labelButtonUndoItemProcessing": {},
1202
- "labelButtonRetryItemProcessing": {},
1203
- "labelButtonProcessItem": {}
1204
- }; }
1205
1191
  static get events() { return [{
1206
1192
  "method": "added",
1207
1193
  "name": "added",
@@ -11,6 +11,8 @@ import styles from './map-styles';
11
11
  import { Loader } from 'google-maps';
12
12
  export class SallaMap {
13
13
  constructor() {
14
+ this.defaultLat = 21.419421; //Mecca 🕋
15
+ this.defaultLng = 39.82553; //Mecca 🕋
14
16
  // state variables
15
17
  this.modalActivityTitle = 'Activity Location';
16
18
  this.confirmButtonTitle = 'Confirm';
@@ -19,21 +21,21 @@ export class SallaMap {
19
21
  this.searchInputValue = null;
20
22
  this.geolocationError = false;
21
23
  /**
22
- * Disable or enable actions
24
+ * File input name for the native formData
23
25
  */
24
- this.readonly = false;
26
+ this.name = 'location';
25
27
  /**
26
- * Sets the search bar visibility.
28
+ * Set if the location input is required or not
27
29
  */
28
- this.searchable = false;
30
+ this.required = false;
29
31
  /**
30
- * Latitude coordinate, defaults to Mecca 🕋 ❤️
32
+ * Disable or enable actions
31
33
  */
32
- this.lat = 21.419421;
34
+ this.readonly = false;
33
35
  /**
34
- * Longitude coordinate, defaults to Mecca 🕋 ❤️
36
+ * Sets the search bar visibility.
35
37
  */
36
- this.lng = 39.82553;
38
+ this.searchable = false;
37
39
  /**
38
40
  * Sets google api key value
39
41
  */
@@ -78,10 +80,10 @@ export class SallaMap {
78
80
  const loader = new Loader(this.apiKey, options);
79
81
  loader.load().then(google => {
80
82
  this.map = new google.maps.Map(mapDOM, {
81
- center: {
83
+ center: (this.lat || this.lng) ? {
82
84
  lat: this.lat,
83
85
  lng: this.lng,
84
- },
86
+ } : null,
85
87
  zoom: this.zoom,
86
88
  zoomControl: true,
87
89
  mapTypeControl: false,
@@ -132,7 +134,7 @@ export class SallaMap {
132
134
  address: this.searchInputValue ? this.searchInputValue : null,
133
135
  });
134
136
  });
135
- if (!this.host.hasAttribute('lat') && !this.host.hasAttribute('lng')) {
137
+ if (this.lat == this.defaultLat && this.lng == this.defaultLng) {
136
138
  this.getCurrentLocation();
137
139
  if (this.geolocationError) {
138
140
  this.map.setCenter({
@@ -223,8 +225,10 @@ export class SallaMap {
223
225
  lng: this.lng,
224
226
  address: this.searchInputValue ? this.searchInputValue : null,
225
227
  };
228
+ this.mapInput.value = `${points.lat}, ${points.lng}`;
226
229
  salla.event.emit('salla-map::selected', points);
227
230
  this.selected.emit(points);
231
+ this.mapInput.dispatchEvent(new window.Event('change', { bubbles: true }));
228
232
  this.locationModal.close();
229
233
  } }, this.confirmButtonTitle)
230
234
  ])));
@@ -243,7 +247,8 @@ export class SallaMap {
243
247
  this.searchInputValue ? (h("div", null,
244
248
  this.locateButtonEdit,
245
249
  " | ",
246
- this.formatAddress(this.searchInputValue))) : (this.locateButtonTitle)))));
250
+ this.formatAddress(this.searchInputValue))) : (this.locateButtonTitle))),
251
+ h("input", { type: "hidden", name: this.name, required: this.required, value: `${this.lat}, ${this.lng}`, ref: color => this.mapInput = color })));
247
252
  }
248
253
  static get is() { return "salla-map"; }
249
254
  static get originalStyleUrls() { return {
@@ -253,6 +258,42 @@ export class SallaMap {
253
258
  "$": ["salla-map.css"]
254
259
  }; }
255
260
  static get properties() { return {
261
+ "name": {
262
+ "type": "string",
263
+ "mutable": false,
264
+ "complexType": {
265
+ "original": "string",
266
+ "resolved": "string",
267
+ "references": {}
268
+ },
269
+ "required": false,
270
+ "optional": false,
271
+ "docs": {
272
+ "tags": [],
273
+ "text": "File input name for the native formData"
274
+ },
275
+ "attribute": "name",
276
+ "reflect": false,
277
+ "defaultValue": "'location'"
278
+ },
279
+ "required": {
280
+ "type": "boolean",
281
+ "mutable": false,
282
+ "complexType": {
283
+ "original": "boolean",
284
+ "resolved": "boolean",
285
+ "references": {}
286
+ },
287
+ "required": false,
288
+ "optional": false,
289
+ "docs": {
290
+ "tags": [],
291
+ "text": "Set if the location input is required or not"
292
+ },
293
+ "attribute": "required",
294
+ "reflect": false,
295
+ "defaultValue": "false"
296
+ },
256
297
  "readonly": {
257
298
  "type": "boolean",
258
299
  "mutable": false,
@@ -301,11 +342,10 @@ export class SallaMap {
301
342
  "optional": false,
302
343
  "docs": {
303
344
  "tags": [],
304
- "text": "Latitude coordinate, defaults to Mecca \uD83D\uDD4B \u2764\uFE0F"
345
+ "text": "Latitude coordinate, defaults to current user location"
305
346
  },
306
347
  "attribute": "lat",
307
- "reflect": false,
308
- "defaultValue": "21.419421"
348
+ "reflect": false
309
349
  },
310
350
  "lng": {
311
351
  "type": "number",
@@ -319,11 +359,10 @@ export class SallaMap {
319
359
  "optional": false,
320
360
  "docs": {
321
361
  "tags": [],
322
- "text": "Longitude coordinate, defaults to Mecca \uD83D\uDD4B \u2764\uFE0F"
362
+ "text": "Longitude coordinate, defaults to current user location"
323
363
  },
324
364
  "attribute": "lng",
325
- "reflect": false,
326
- "defaultValue": "39.82553"
365
+ "reflect": false
327
366
  },
328
367
  "apiKey": {
329
368
  "type": "string",
@@ -406,6 +445,7 @@ export class SallaMap {
406
445
  "searchInputValue": {},
407
446
  "geolocationError": {},
408
447
  "searchInput": {},
448
+ "mapInput": {},
409
449
  "mapElement": {}
410
450
  }; }
411
451
  static get events() { return [{
@@ -18,6 +18,9 @@ export var DisplayType;
18
18
  DisplayType["TIME"] = "time";
19
19
  DisplayType["RADIO"] = "radio";
20
20
  DisplayType["CHECKBOX"] = "checkbox";
21
+ DisplayType["MAP"] = "map";
22
+ DisplayType["FILE"] = "file";
23
+ DisplayType["COLOR_PICKER"] = "color_picker";
21
24
  })(DisplayType || (DisplayType = {}));
22
25
  export var Currency;
23
26
  (function (Currency) {
@@ -5,8 +5,17 @@ import { Component, Prop, h, State, Element, Host, Event } from '@stencil/core';
5
5
  import { DisplayType } from './interfaces';
6
6
  import CheckCircleIcon from '../../assets/svg/check.svg';
7
7
  import CameraIcon from '../../assets/svg/camera.svg';
8
+ import FileIcon from '../../assets/svg/file-upload.svg';
8
9
  export class SallaProductOptions {
9
10
  constructor() {
11
+ this.fileTypes = {
12
+ pdf: 'application/pdf',
13
+ png: 'image/png',
14
+ jpg: 'image/jpeg',
15
+ word: 'application/msword',
16
+ exl: 'application/vnd.ms-excel',
17
+ txt: 'text/plain',
18
+ };
10
19
  this.outOfStockText = salla.lang.get("pages.products.out_of_stock");
11
20
  this.donationAmount = salla.lang.get('pages.products.donation_amount');
12
21
  /**
@@ -39,10 +48,18 @@ export class SallaProductOptions {
39
48
  }
40
49
  this.itemsSelected.emit(multiSelectedItems);
41
50
  }
51
+ getLatLng(value, type) {
52
+ return value
53
+ ? value.split(',')[type == 'lat' ? 0 : 1]
54
+ : '';
55
+ }
42
56
  getDisplayForType(option) {
43
57
  if (this[`${option.type}Option`]) {
44
58
  return this[`${option.type}Option`](option);
45
59
  }
60
+ if (option.type === DisplayType.COLOR_PICKER) {
61
+ return this.colorPickerOption(option);
62
+ }
46
63
  if (option.type === DisplayType.MULTIPLE_OPTIONS) {
47
64
  return this.multipleOptions(option);
48
65
  }
@@ -83,33 +100,28 @@ export class SallaProductOptions {
83
100
  h("input", { type: "text", id: "donating-amount", name: "donating_amount", class: "s-form-control", value: option.value, placeholder: option.placeholder, onInput: e => salla.helpers.inputDigitsOnly(e.target), onBlur: e => this.donationMoneyEntered.emit(e) }),
84
101
  h("span", { class: "s-product-options-donation-amount-currency" }, salla.config.currency(salla.config.get('user.currency_code')).symbol));
85
102
  }
86
- getFilepondPlaceholder() {
87
- //todo:: add translatable string
88
- return `<div class="s-product-options-filepond-placeholder"><span class="s-product-options-filepond-placeholder-icon">${CameraIcon}</span><p class="s-product-options-filepond-placeholder-text">اسحب او افلت الصورة هنا</p> <span class="filepond--label-action">او تصفح من جهازك</span></div>`;
89
- }
90
- handleOnImageRemoved(event) {
91
- //todo:: add on remove from cartitem images
92
- // use salla.url.is_page('cart')
93
- // call salla.cart.api.deleteImage(file('id'))
94
- //@ts-ignore
95
- setTimeout(() => event.target.querySelector('.filepond--root').style.height = '120px', 1000);
96
- }
97
- handleOnImageUploaded(event) {
98
- //todo:: fire imageUploaded from salla-product-options
99
- event.target.querySelector('.filepond--data input[type="hidden"]').dispatchEvent(new window.Event('change', { bubbles: true }));
100
- }
101
103
  //todo:: why we need this way, use the native way!!
102
104
  //@ts-ignore
103
105
  selectThumbnail(e, value) {
104
106
  this.thumbnailSelected.emit(e);
105
107
  }
108
+ fileUploader(option, additions = null) {
109
+ return h("salla-file-upload", Object.assign({}, (additions || {}), { "payload-name": "file", value: option.value, "instant-upload": true, name: `options[${option.id}]`, height: "120px", url: salla.cart.api.getUploadImageEndpoint(), "form-data": { cart_item_id: this.productId, product_id: this.productId }, class: { "s-product-options-image-input": true, required: option.required } }),
110
+ h("div", { class: "s-product-options-filepond-placeholder" },
111
+ h("span", { class: "s-product-options-filepond-placeholder-icon", innerHTML: additions ? FileIcon : CameraIcon }),
112
+ h("p", { class: "s-product-options-filepond-placeholder-text" }, salla.lang.get('common.uploader.drag_and_drop')),
113
+ h("span", { class: "filepond--label-action" }, salla.lang.get('common.uploader.browse'))));
114
+ }
106
115
  //@ts-ignore
107
116
  imageOption(option) {
108
- return h("salla-file-upload", { "instant-upload": true, name: `options[${option.id}]`, "payload-name": "file", "data-item-id": salla.url.is_page('cart') ? option.id : '', class: { "s-product-options-image-input": true, required: option.required }, labelIdle: this.getFilepondPlaceholder(), onRemoved: event => this.handleOnImageRemoved(event), onUploaded: event => this.handleOnImageUploaded(event), value: option.value, url: salla.cart.api.getUploadImageEndpoint(), "form-data": {
109
- _token: salla.config.get('_token'),
110
- cart_item_id: this.productId,
111
- product_id: this.productId,
112
- } });
117
+ return this.fileUploader(option);
118
+ }
119
+ //@ts-ignore
120
+ fileOption(option) {
121
+ let types = option.details.map(detail => this.fileTypes[detail.name]).filter(Boolean);
122
+ return types.length
123
+ ? this.fileUploader(option, { accept: types.join(',') })
124
+ : 'File types not selected.';
113
125
  }
114
126
  //@ts-ignore
115
127
  numberOption(option) {
@@ -131,6 +143,13 @@ export class SallaProductOptions {
131
143
  h("div", { class: "mt-1" },
132
144
  h("textarea", { rows: 4, value: option.value, class: "s-form-control", required: option.required, id: `options[${option.id}]`, name: `options[${option.id}]`, placeholder: option.placeholder, onInput: (e) => this.textareaOptionEntered.emit(e) })));
133
145
  }
146
+ //@ts-ignore
147
+ mapOption(option) {
148
+ return h("salla-map", { zoom: 15, lat: this.getLatLng(option.value, 'lat'), lng: this.getLatLng(option.value, 'lng'), name: `options[${option.id}]`, searchable: true, required: option.required, onSelected: e => this.locationSelected.emit(e) });
149
+ }
150
+ colorPickerOption(option) {
151
+ return h("salla-color-picker", { onSubmitted: e => this.colorPicked.emit(e), name: `options[${option.id}]`, required: option.required, color: option.value || '#5dd5c4' });
152
+ }
134
153
  /**
135
154
  * ============= Date Time options =============
136
155
  */
@@ -411,6 +430,36 @@ export class SallaProductOptions {
411
430
  "resolved": "any",
412
431
  "references": {}
413
432
  }
433
+ }, {
434
+ "method": "colorPicked",
435
+ "name": "colorPicked",
436
+ "bubbles": true,
437
+ "cancelable": true,
438
+ "composed": true,
439
+ "docs": {
440
+ "tags": [],
441
+ "text": "Color Picker option"
442
+ },
443
+ "complexType": {
444
+ "original": "any",
445
+ "resolved": "any",
446
+ "references": {}
447
+ }
448
+ }, {
449
+ "method": "locationSelected",
450
+ "name": "locationSelected",
451
+ "bubbles": true,
452
+ "cancelable": true,
453
+ "composed": true,
454
+ "docs": {
455
+ "tags": [],
456
+ "text": "Map (Location Selection) option"
457
+ },
458
+ "complexType": {
459
+ "original": "any",
460
+ "resolved": "any",
461
+ "references": {}
462
+ }
414
463
  }]; }
415
464
  static get elementRef() { return "host"; }
416
465
  }
@@ -410,8 +410,8 @@ export class SallaSwiper {
410
410
  var _a, _b, _c, _d;
411
411
  let classes = this.type ? this.type + '-slider ' : '';
412
412
  classes += this.controlsOuter ? ' s-slider-controls-outer ' : '';
413
- classes += this.blockTitle == '' ? ' s-slider-has-notitle ' : '';
414
- classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal';
413
+ classes += this.blockTitle == '' ? ' s-slider-has-notitle s-slider-v-centered ' : '';
414
+ classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
415
415
  classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
416
416
  return (h(Host, { class: 's-slider-wrapper ' + classes },
417
417
  this.blockTitle || this.showControls ?