@salla.sa/twilight-components 2.11.9 → 2.11.11

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 (38) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_37.cjs.entry.js +127 -101
  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-conditional-fields/salla-conditional-fields.js +23 -12
  6. package/dist/collection/components/salla-file-upload/salla-file-upload.js +64 -78
  7. package/dist/collection/components/salla-map/salla-map.js +58 -18
  8. package/dist/collection/components/salla-product-options/interfaces.js +3 -0
  9. package/dist/collection/components/salla-product-options/salla-product-options.js +70 -21
  10. package/dist/collection/components/salla-slider/salla-slider.js +2 -2
  11. package/dist/components/salla-color-picker.js +1 -1174
  12. package/dist/components/salla-color-picker2.js +1192 -0
  13. package/dist/components/salla-conditional-fields2.js +23 -12
  14. package/dist/components/salla-file-upload2.js +30 -75
  15. package/dist/components/salla-map.js +1 -716
  16. package/dist/components/salla-map2.js +728 -0
  17. package/dist/components/salla-product-options.js +83 -27
  18. package/dist/components/salla-slider2.js +2 -2
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-button_37.entry.js +127 -101
  21. package/dist/esm/twilight.js +1 -1
  22. package/dist/esm-es5/loader.js +1 -1
  23. package/dist/esm-es5/salla-button_37.entry.js +4 -4
  24. package/dist/esm-es5/twilight.js +1 -1
  25. package/dist/twilight/p-bb361b66.system.entry.js +53 -0
  26. package/dist/twilight/p-c71ec183.system.js +1 -1
  27. package/dist/twilight/p-ee192b12.entry.js +36 -0
  28. package/dist/twilight/twilight.esm.js +1 -1
  29. package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +9 -0
  30. package/dist/types/components/salla-conditional-fields/salla-conditional-fields.d.ts +2 -0
  31. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +9 -25
  32. package/dist/types/components/salla-map/salla-map.d.ts +13 -2
  33. package/dist/types/components/salla-product-options/interfaces.d.ts +4 -1
  34. package/dist/types/components/salla-product-options/salla-product-options.d.ts +14 -3
  35. package/dist/types/components.d.ts +60 -4
  36. package/package.json +4 -4
  37. package/dist/twilight/p-9f9c6276.entry.js +0 -36
  38. package/dist/twilight/p-ecac0cdc.system.entry.js +0 -53
@@ -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
  }
@@ -66,7 +83,7 @@ export class SallaProductOptions {
66
83
  return;
67
84
  }
68
85
  return (h(Host, { class: "s-product-options-wrapper" },
69
- h("salla-conditional-fields", null, this.optionsData.map((option) => h("div", Object.assign({ class: `s-product-options-option-container${option.visibility_condition ? ' hidden' : ''}` }, this.getOptionShownWhen(option)), option.name == 'splitter' ?
86
+ h("salla-conditional-fields", null, this.optionsData.map((option) => h("div", Object.assign({ class: `s-product-options-option-container${option.visibility_condition ? ' hidden' : ''}`, "data-option-id": option.id }, this.getOptionShownWhen(option)), option.name == 'splitter' ?
70
87
  this.splitterOption()
71
88
  : h("div", { class: "s-product-options-option" },
72
89
  h("label", { htmlFor: 'options[' + option.id + ']', class: "s-product-options-option-label" },
@@ -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 ?