@salla.sa/twilight-components 2.11.8 → 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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_37.cjs.entry.js +202 -136
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +63 -14
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +233 -122
- package/dist/collection/components/salla-map/salla-map.js +58 -18
- package/dist/collection/components/salla-product-options/interfaces.js +3 -0
- package/dist/collection/components/salla-product-options/salla-product-options.js +69 -20
- package/dist/collection/components/salla-slider/salla-slider.js +27 -7
- package/dist/components/salla-color-picker.js +1 -1173
- package/dist/components/salla-color-picker2.js +1192 -0
- package/dist/components/salla-file-upload2.js +116 -111
- package/dist/components/salla-map.js +1 -716
- package/dist/components/salla-map2.js +728 -0
- package/dist/components/salla-product-options.js +82 -26
- package/dist/components/salla-slider2.js +8 -5
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_37.entry.js +202 -136
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/salla-button_37.entry.js +2 -2
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/twilight/p-184f8592.system.entry.js +53 -0
- package/dist/twilight/p-301c6601.entry.js +36 -0
- package/dist/twilight/p-c71ec183.system.js +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +9 -0
- package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +35 -31
- package/dist/types/components/salla-map/salla-map.d.ts +13 -2
- package/dist/types/components/salla-product-options/interfaces.d.ts +4 -1
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +14 -3
- package/dist/types/components/salla-slider/salla-slider.d.ts +8 -2
- package/dist/types/components.d.ts +101 -8
- package/package.json +4 -4
- package/dist/twilight/p-95e1fd9d.system.entry.js +0 -53
- package/dist/twilight/p-e31a8a33.entry.js +0 -36
|
@@ -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
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
}
|
|
@@ -26,6 +26,10 @@ export class SallaSwiper {
|
|
|
26
26
|
* Show/hide display all button beside arrows
|
|
27
27
|
*/
|
|
28
28
|
this.displayAllUrl = '';
|
|
29
|
+
/**
|
|
30
|
+
* Show/hide display all button beside arrows
|
|
31
|
+
*/
|
|
32
|
+
this.arrowsCentered = false;
|
|
29
33
|
/**
|
|
30
34
|
* Vertical or Horizontal thumbs slider
|
|
31
35
|
*/
|
|
@@ -113,9 +117,6 @@ export class SallaSwiper {
|
|
|
113
117
|
fullwidth: {
|
|
114
118
|
speed: 750,
|
|
115
119
|
parallax: true,
|
|
116
|
-
autoplay: {
|
|
117
|
-
delay: 5000,
|
|
118
|
-
},
|
|
119
120
|
},
|
|
120
121
|
fullscreen: {
|
|
121
122
|
speed: 1000,
|
|
@@ -308,7 +309,7 @@ export class SallaSwiper {
|
|
|
308
309
|
getSwiperConfig() {
|
|
309
310
|
let pre_defined_config = {
|
|
310
311
|
loop: this.loop,
|
|
311
|
-
autoplay: this.autoPlay,
|
|
312
|
+
autoplay: this.type == 'fullwidth' && !!this.autoPlay ? { delay: 5000 } : this.autoPlay,
|
|
312
313
|
centeredSlides: this.centered,
|
|
313
314
|
slidesPerView: this.slidesPerView,
|
|
314
315
|
autoHeight: this.autoHeight,
|
|
@@ -410,7 +411,8 @@ export class SallaSwiper {
|
|
|
410
411
|
let classes = this.type ? this.type + '-slider ' : '';
|
|
411
412
|
classes += this.controlsOuter ? ' s-slider-controls-outer ' : '';
|
|
412
413
|
classes += this.blockTitle == '' ? ' s-slider-has-notitle s-slider-v-centered ' : '';
|
|
413
|
-
classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal';
|
|
414
|
+
classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
|
|
415
|
+
classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
|
|
414
416
|
return (h(Host, { class: 's-slider-wrapper ' + classes },
|
|
415
417
|
this.blockTitle || this.showControls ?
|
|
416
418
|
h("div", { class: "s-slider-block__title" },
|
|
@@ -524,6 +526,24 @@ export class SallaSwiper {
|
|
|
524
526
|
"reflect": true,
|
|
525
527
|
"defaultValue": "''"
|
|
526
528
|
},
|
|
529
|
+
"arrowsCentered": {
|
|
530
|
+
"type": "boolean",
|
|
531
|
+
"mutable": false,
|
|
532
|
+
"complexType": {
|
|
533
|
+
"original": "boolean",
|
|
534
|
+
"resolved": "boolean",
|
|
535
|
+
"references": {}
|
|
536
|
+
},
|
|
537
|
+
"required": false,
|
|
538
|
+
"optional": false,
|
|
539
|
+
"docs": {
|
|
540
|
+
"tags": [],
|
|
541
|
+
"text": "Show/hide display all button beside arrows"
|
|
542
|
+
},
|
|
543
|
+
"attribute": "arrows-centered",
|
|
544
|
+
"reflect": true,
|
|
545
|
+
"defaultValue": "false"
|
|
546
|
+
},
|
|
527
547
|
"verticalThumbs": {
|
|
528
548
|
"type": "boolean",
|
|
529
549
|
"mutable": false,
|
|
@@ -726,8 +746,8 @@ export class SallaSwiper {
|
|
|
726
746
|
"type": "string",
|
|
727
747
|
"mutable": false,
|
|
728
748
|
"complexType": {
|
|
729
|
-
"original": "'carousel' | 'fullscreen' | 'thumbs' | 'default' | 'hero' | 'testimonials' | 'blog' | ''",
|
|
730
|
-
"resolved": "\"\" | \"blog\" | \"carousel\" | \"default\" | \"fullscreen\" | \"hero\" | \"testimonials\" | \"thumbs\"",
|
|
749
|
+
"original": "'carousel' | 'fullscreen' | 'thumbs' | 'default' | 'hero' | 'testimonials' | 'blog' | 'fullwidth' | ''",
|
|
750
|
+
"resolved": "\"\" | \"blog\" | \"carousel\" | \"default\" | \"fullscreen\" | \"fullwidth\" | \"hero\" | \"testimonials\" | \"thumbs\"",
|
|
731
751
|
"references": {}
|
|
732
752
|
},
|
|
733
753
|
"required": false,
|