@salla.sa/twilight-components 1.6.3 → 1.6.4
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_27.cjs.entry.js +27879 -0
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +26 -0
- package/dist/cjs/salla-scopes.cjs.entry.js +9 -6
- package/dist/cjs/salla-select.cjs.entry.js +159 -0
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/assets/svg/caret-down.svg +0 -1
- package/dist/collection/assets/svg/images.svg +0 -1
- package/dist/collection/collection-manifest.json +5 -0
- package/dist/collection/components/salla-datetime-picker/interfaces.js +4 -0
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.css +13 -0
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1374 -0
- package/dist/collection/components/salla-file-upload/interfaces.js +42 -0
- package/dist/collection/components/salla-file-upload/salla-file-upload.css +219 -0
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +1435 -0
- package/dist/collection/components/salla-gifting/gift-schema.js +4 -0
- package/dist/collection/components/salla-gifting/intefaces.js +4 -0
- package/dist/collection/components/salla-gifting/salla-gifting.css +20 -0
- package/dist/collection/components/salla-gifting/salla-gifting.js +564 -0
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +23 -13
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +48 -29
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.css +3 -0
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +69 -0
- package/dist/collection/components/salla-loyalty/salla-loyalty.css +0 -4
- package/dist/collection/components/salla-loyalty/salla-loyalty.js +29 -16
- package/dist/collection/components/salla-modal/salla-modal.css +6 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +37 -13
- package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +23 -8
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +87 -64
- package/dist/collection/components/salla-scopes/salla-scopes.js +11 -7
- package/dist/collection/components/salla-search/salla-search.js +1 -1
- package/dist/collection/components/salla-select/salla-select.css +86 -0
- package/dist/collection/components/salla-select/salla-select.js +610 -0
- package/dist/collection/components/salla-tel-input/interfaces.js +4 -0
- package/dist/collection/components/salla-tel-input/salla-tel-input.css +1 -2
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +32 -3
- package/dist/collection/components/salla-verify/salla-verify.js +1 -1
- package/dist/collection/global/app.js +15 -12
- package/dist/components/_commonjsHelpers.js +24 -0
- package/dist/components/anime.es.js +1312 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/salla-datetime-picker.d.ts +11 -0
- package/dist/components/salla-datetime-picker.js +9 -0
- package/dist/components/salla-datetime-picker2.js +2876 -0
- package/dist/components/salla-file-upload.d.ts +11 -0
- package/dist/components/salla-file-upload.js +9 -0
- package/dist/components/salla-file-upload2.js +14623 -0
- package/dist/components/salla-gifting.d.ts +11 -0
- package/dist/components/salla-gifting.js +499 -0
- package/dist/components/salla-localization-modal.js +31 -16
- package/dist/components/salla-login-modal.js +37 -20
- package/dist/components/salla-loyalty-prize-item.d.ts +11 -0
- package/dist/components/salla-loyalty-prize-item.js +42 -0
- package/dist/components/salla-loyalty.js +28 -17
- package/dist/components/salla-modal2.js +1 -1
- package/dist/components/salla-offer-modal.js +42 -12
- package/dist/components/salla-product-size-guide.js +21 -6
- package/dist/components/salla-rating-modal.js +47 -19
- package/dist/components/salla-scopes.js +10 -6
- package/dist/components/salla-search.js +1 -1
- package/dist/components/salla-select.d.ts +11 -0
- package/dist/components/salla-select.js +199 -0
- package/dist/components/salla-social-share.js +1 -1308
- package/dist/components/salla-swiper2.js +9 -9
- package/dist/components/salla-tel-input2.js +15 -18
- package/dist/components/salla-verify2.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_27.entry.js +27849 -0
- package/dist/esm/salla-loyalty-prize-item.entry.js +22 -0
- package/dist/esm/salla-scopes.entry.js +9 -6
- package/dist/esm/salla-select.entry.js +155 -0
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/p-49125b6a.entry.js +4 -0
- package/dist/twilight-components/p-9a25753c.entry.js +4 -0
- package/dist/twilight-components/p-b7b9439d.entry.js +22 -0
- package/dist/twilight-components/p-df1eb1e5.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-datetime-picker/interfaces.d.ts +8 -0
- package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +250 -0
- package/dist/types/components/salla-file-upload/interfaces.d.ts +766 -0
- package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +267 -0
- package/dist/types/components/salla-gifting/gift-schema.d.ts +20 -0
- package/dist/types/components/salla-gifting/intefaces.d.ts +18 -0
- package/dist/types/components/salla-gifting/salla-gifting.d.ts +98 -0
- package/dist/types/components/salla-localization-modal/salla-localization-modal.d.ts +3 -2
- package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +13 -3
- package/dist/types/components/salla-loyalty/salla-loyalty-prize-item.d.ts +8 -0
- package/dist/types/components/salla-loyalty/salla-loyalty.d.ts +2 -0
- package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +3 -1
- package/dist/types/components/salla-product-size-guide/salla-product-size-guide.d.ts +4 -0
- package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +3 -2
- package/dist/types/components/salla-scopes/salla-scopes.d.ts +1 -0
- package/dist/types/components/salla-select/salla-select.d.ts +110 -0
- package/dist/types/components/salla-tel-input/interfaces.d.ts +4 -0
- package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +3 -0
- package/dist/types/components.d.ts +1253 -10
- package/package.json +2 -2
- package/dist/cjs/salla-button_24.cjs.entry.js +0 -10087
- package/dist/esm/salla-button_24.entry.js +0 -10060
- package/dist/twilight-components/p-30b2c5b0.entry.js +0 -4
- package/dist/twilight-components/p-5fb32395.entry.js +0 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.s-gifting-steps-wrapper {
|
|
2
|
+
transition: 0.2s cubic-bezier(0.55, 0, 0.1, 1) 0s;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.is-current-step-2 .gift-step-1,
|
|
6
|
+
.is-current-step-1 .gift-step-2 {
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.is-current-step-1 .gift-step-2 {
|
|
11
|
+
transform: translateX(105%);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.s-gifting-modal .s-modal-body::-webkit-scrollbar {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.s-gifting-select {
|
|
19
|
+
background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
|
|
20
|
+
}
|
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import anime from 'animejs';
|
|
5
|
+
import { Component, h, Prop, State, Method } from '@stencil/core';
|
|
6
|
+
import Images from '../../assets/svg/images.svg';
|
|
7
|
+
import RightArrow from '../../assets/svg/arrow-right.svg';
|
|
8
|
+
import LeftArrow from '../../assets/svg/arrow-left.svg';
|
|
9
|
+
import Cancel from '../../assets/svg/cancel.svg';
|
|
10
|
+
import GiftSharing from '../../assets/svg/gift-sharing.svg';
|
|
11
|
+
export class SallaGifting {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.currentStep = 1;
|
|
14
|
+
this.showCalendar = false;
|
|
15
|
+
this.showGiftText = false;
|
|
16
|
+
this.currentLang = '';
|
|
17
|
+
this.parentClass = "is-current-step-1";
|
|
18
|
+
this.errors = {};
|
|
19
|
+
this.gift = undefined;
|
|
20
|
+
// @State() selectedImage: GiftImage = undefined;
|
|
21
|
+
this.selectedGiftTextOption = undefined;
|
|
22
|
+
this.showTextArea = false;
|
|
23
|
+
/// Gift Form Data
|
|
24
|
+
this.selectedImage = undefined;
|
|
25
|
+
this.uploadedImage = undefined;
|
|
26
|
+
this.selectedText = undefined;
|
|
27
|
+
this.hasError = false;
|
|
28
|
+
this.timeZone = null;
|
|
29
|
+
salla.lang.onLoaded(() => {
|
|
30
|
+
this.selectImageOrUpload = salla.lang.get('blocks.buy_as_gift.select_image_or_upload');
|
|
31
|
+
this.step1Elems = document.querySelectorAll('.gift-step-1 .anime-item');
|
|
32
|
+
this.step2Elems = document.querySelectorAll('.gift-step-2 .anime-item');
|
|
33
|
+
this.imageCover = document.querySelector('.s-gifting-modal-uploader');
|
|
34
|
+
this.stepsWrapper = document.querySelector('.steps-wrapper');
|
|
35
|
+
this.textSelect = document.querySelector('.s-gifting-selectText');
|
|
36
|
+
this.customTextArea = document.querySelector('.s-gifting-textarea');
|
|
37
|
+
this.calendarFormGroup = document.querySelector('.s-gifting-calendar');
|
|
38
|
+
this.sectionTitle = salla.lang.get('blocks.buy_as_gift.gift_the_one_you_love');
|
|
39
|
+
this.sectionSubtitle = salla.lang.get('blocks.buy_as_gift.gift_the_one_you_love_message');
|
|
40
|
+
this.sectionBtnText = salla.lang.get('blocks.buy_as_gift.send_as_a_gift');
|
|
41
|
+
this.giftDetails = salla.lang.get('blocks.buy_as_gift.gift_details');
|
|
42
|
+
this.selectImageForYourGift = salla.lang.get('blocks.buy_as_gift.select_image_for_your_gift');
|
|
43
|
+
this.selectGiftMessage = salla.lang.get('blocks.buy_as_gift.select_gift_message');
|
|
44
|
+
this.giftCustomText = salla.lang.get('blocks.buy_as_gift.gift_custom_text');
|
|
45
|
+
this.textId = salla.lang.get('blocks.buy_as_gift.text_id');
|
|
46
|
+
this.incorrectGiftText = salla.lang.get('blocks.buy_as_gift.incorrect_gift_text');
|
|
47
|
+
this.nextStep = salla.lang.get('blocks.buy_as_gift.next_step');
|
|
48
|
+
this.senderNameLabel = salla.lang.get('blocks.buy_as_gift.sender_name');
|
|
49
|
+
this.receiverNameFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_name');
|
|
50
|
+
this.receiverMobileFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_mobile');
|
|
51
|
+
this.receiverEmailFieldLabel = salla.lang.get('blocks.buy_as_gift.receiver_email');
|
|
52
|
+
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
53
|
+
this.sendLater = salla.lang.get('blocks.buy_as_gift.send_later');
|
|
54
|
+
this.selectSendDateAndTime = salla.lang.get('blocks.buy_as_gift.select_send_date_and_time');
|
|
55
|
+
this.canNotEditOrderAfterSelectDate = salla.lang.get('blocks.buy_as_gift.can_not_edit_order_after_select_date');
|
|
56
|
+
this.sendGift = salla.lang.get('blocks.buy_as_gift.send_gift');
|
|
57
|
+
this.donationRequired = salla.lang.get('pages.products.donation_amount_required');
|
|
58
|
+
this.currentLang = salla.lang.locale;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Show the gifting modal window
|
|
63
|
+
*/
|
|
64
|
+
async open() {
|
|
65
|
+
this.modal.open();
|
|
66
|
+
return await salla.api.withoutNotifier(salla.product.getGiftDetails(this.productId)
|
|
67
|
+
.then((response) => {
|
|
68
|
+
this.gift = response.data;
|
|
69
|
+
this.senderName = this.gift.sender_name;
|
|
70
|
+
})
|
|
71
|
+
.catch(e => {
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
|
+
this.hasError = true;
|
|
74
|
+
this.errorMessage = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data);
|
|
75
|
+
})
|
|
76
|
+
.finally(() => this.modal.stopLoading()));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* Hide the gifting modal window
|
|
81
|
+
*/
|
|
82
|
+
async close() {
|
|
83
|
+
return this.modal.close();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* Update the modal height based on the changes on the inner elements height for a specific step OR just a pass a new fixed height
|
|
88
|
+
*/
|
|
89
|
+
async setWrapperHeight(asStep = 1, delay = 250, additionSpace = 0, newHeight = 0) {
|
|
90
|
+
let currentStep = document.querySelector(`.gift-step-${asStep}`);
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
let currentStepHeight = currentStep.offsetHeight;
|
|
93
|
+
if (newHeight) {
|
|
94
|
+
this.stepsWrapper.style.height = `${newHeight}px`;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.stepsWrapper.style.height = currentStepHeight + additionSpace + 'px';
|
|
98
|
+
}
|
|
99
|
+
}, delay);
|
|
100
|
+
}
|
|
101
|
+
toggleCalendar() {
|
|
102
|
+
this.showCalendar = !this.showCalendar;
|
|
103
|
+
this.setWrapperHeight(2, 150, 0);
|
|
104
|
+
}
|
|
105
|
+
toggleGiftText(event) {
|
|
106
|
+
this.textSelect.classList.remove('s-form-has-error');
|
|
107
|
+
let dataID = event.target.children[event.target.selectedIndex].getAttribute('data-id');
|
|
108
|
+
let customID = dataID == "custom";
|
|
109
|
+
this.showGiftText = customID;
|
|
110
|
+
// dataID ? this.selectedGiftTextOption = dataID : this.selectedGiftTextOption = undefined;
|
|
111
|
+
if (dataID) {
|
|
112
|
+
this.selectedGiftTextOption = dataID;
|
|
113
|
+
this.setWrapperHeight(1, 150, 0);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.selectedGiftTextOption = undefined;
|
|
117
|
+
this.setWrapperHeight(1, 150, -25);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* Go to the step 2
|
|
123
|
+
*/
|
|
124
|
+
async goToStep2() {
|
|
125
|
+
if (!this.selectedGiftTextOption) {
|
|
126
|
+
this.textSelect.classList.add('s-form-has-error');
|
|
127
|
+
this.customTextArea.classList.remove('s-form-has-error');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
else if (this.selectedGiftTextOption == 'custom' && !this.selectedText) {
|
|
131
|
+
this.textSelect.classList.remove('s-form-has-error');
|
|
132
|
+
this.customTextArea.classList.add('s-form-has-error');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.textSelect.classList.remove('s-form-has-error');
|
|
137
|
+
this.customTextArea.classList.remove('s-form-has-error');
|
|
138
|
+
}
|
|
139
|
+
this.setWrapperHeight(2, 600, 0);
|
|
140
|
+
let stepNextAnime = new anime.timeline();
|
|
141
|
+
stepNextAnime.add({
|
|
142
|
+
targets: this.step1Elems,
|
|
143
|
+
opacity: [1, 0],
|
|
144
|
+
translateX: [0, 50],
|
|
145
|
+
delay: anime.stagger(70),
|
|
146
|
+
// easing: 'easeOutExpo',
|
|
147
|
+
duration: 1200,
|
|
148
|
+
})
|
|
149
|
+
.add({
|
|
150
|
+
targets: '.gift-step-2',
|
|
151
|
+
translateX: ['-110%', 0],
|
|
152
|
+
opacity: [0, 1],
|
|
153
|
+
}, '-=1800')
|
|
154
|
+
.add({
|
|
155
|
+
targets: this.step2Elems,
|
|
156
|
+
opacity: [0, 1],
|
|
157
|
+
translateX: [-50, 0],
|
|
158
|
+
delay: anime.stagger(70),
|
|
159
|
+
duration: 1200,
|
|
160
|
+
complete: () => {
|
|
161
|
+
this.step2Elems.forEach(item => {
|
|
162
|
+
item.classList.remove('opacity-0');
|
|
163
|
+
item.removeAttribute('style');
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}, '-=1200');
|
|
167
|
+
this.currentStep = 2;
|
|
168
|
+
this.stepsWrapper.classList.remove('is-current-step-1', 'is-current-step-2');
|
|
169
|
+
this.stepsWrapper.classList.add(`is-current-step-${this.currentStep}`);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* Go to the step 1
|
|
174
|
+
*/
|
|
175
|
+
goToStep1() {
|
|
176
|
+
let stepBackAnime = new anime.timeline({
|
|
177
|
+
autoplay: false,
|
|
178
|
+
});
|
|
179
|
+
stepBackAnime.add({
|
|
180
|
+
targets: this.step2Elems,
|
|
181
|
+
opacity: [1, 0],
|
|
182
|
+
translateX: [0, -50],
|
|
183
|
+
delay: anime.stagger(70),
|
|
184
|
+
// easing: 'easeOutExpo',
|
|
185
|
+
duration: 1200,
|
|
186
|
+
})
|
|
187
|
+
.add({
|
|
188
|
+
targets: '.gift-step-1',
|
|
189
|
+
translateX: ['110%', 0],
|
|
190
|
+
opacity: [0, 1],
|
|
191
|
+
}, '-=1800')
|
|
192
|
+
.add({
|
|
193
|
+
targets: this.step1Elems,
|
|
194
|
+
opacity: [0, 1],
|
|
195
|
+
translateX: [50, 0],
|
|
196
|
+
delay: anime.stagger(70),
|
|
197
|
+
duration: 1200,
|
|
198
|
+
complete: () => {
|
|
199
|
+
this.step1Elems.forEach(item => {
|
|
200
|
+
item.classList.remove('opacity-0');
|
|
201
|
+
item.removeAttribute('style');
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}, '-=1200');
|
|
205
|
+
stepBackAnime.play();
|
|
206
|
+
this.setWrapperHeight(1, 600, 0);
|
|
207
|
+
this.currentStep = 1;
|
|
208
|
+
this.stepsWrapper.classList.remove('is-current-step-1', 'is-current-step-2');
|
|
209
|
+
this.stepsWrapper.classList.add(`is-current-step-${this.currentStep}`);
|
|
210
|
+
}
|
|
211
|
+
getFilepondPlaceholder() {
|
|
212
|
+
return `<div class="s-gifting-filepond-placeholder"><span class="s-gifting-filepond-placeholder-icon">${Images}</span><p class="s-gifting-filepond-placeholder-text">${this.selectImageOrUpload ? this.selectImageOrUpload : ''}</p></div>`;
|
|
213
|
+
}
|
|
214
|
+
setPreview(image) {
|
|
215
|
+
this.imageCover.classList.add('has-bg');
|
|
216
|
+
var bg = document.querySelector('.filepond-bg') ? document.querySelector('.filepond-bg') : document.createElement('div');
|
|
217
|
+
bg.classList.add('filepond-bg');
|
|
218
|
+
bg.classList.remove('s-hidden');
|
|
219
|
+
bg.style.backgroundImage = "url('" + image.url + "')";
|
|
220
|
+
this.imageCover.querySelector('.filepond--root').appendChild(bg);
|
|
221
|
+
this.uploadedImage = image.url;
|
|
222
|
+
if (!!this.gift && this.gift.gift_images.length) {
|
|
223
|
+
this.setWrapperHeight(1, 150, 0);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
removePreview() {
|
|
227
|
+
this.imageCover.classList.remove('has-bg');
|
|
228
|
+
let bg = document.querySelector('.filepond-bg');
|
|
229
|
+
bg.removeAttribute('style');
|
|
230
|
+
bg.classList.add('s-hidden');
|
|
231
|
+
this.handleRemoveImage();
|
|
232
|
+
}
|
|
233
|
+
handleTextAreaChange(event) {
|
|
234
|
+
this.selectedText = event.target.value;
|
|
235
|
+
this.customTextArea.classList.remove('s-form-has-error');
|
|
236
|
+
}
|
|
237
|
+
handleSenderName(event) {
|
|
238
|
+
this.senderName = event.target.value;
|
|
239
|
+
}
|
|
240
|
+
handleReceiverName(event) {
|
|
241
|
+
this.receiverName = event.target.value;
|
|
242
|
+
}
|
|
243
|
+
handleRemoveImage() {
|
|
244
|
+
this.uploadedImage = '';
|
|
245
|
+
if (!!this.gift && this.gift.gift_images.length) {
|
|
246
|
+
this.setWrapperHeight(1, 150, 0);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// private handleReceiverEmail(event) {
|
|
250
|
+
// this.receiverEmail = event.target.value;
|
|
251
|
+
// }
|
|
252
|
+
handlePhoneInputChange(event) {
|
|
253
|
+
let phone = event.detail;
|
|
254
|
+
this.receiverMobile = phone.number;
|
|
255
|
+
this.receiverCountryCode = phone.country_code;
|
|
256
|
+
}
|
|
257
|
+
handleDateTimePicker(event) {
|
|
258
|
+
this.deliveryDate = event.detail;
|
|
259
|
+
}
|
|
260
|
+
getCalendarClasses() {
|
|
261
|
+
return {
|
|
262
|
+
"s-form-group": true,
|
|
263
|
+
"anime-item": true,
|
|
264
|
+
"opacity-0": true,
|
|
265
|
+
"s-gifting-calendar": true,
|
|
266
|
+
"shown": this.showCalendar,
|
|
267
|
+
"hide": !this.showCalendar,
|
|
268
|
+
"s-form-has-error": !!this.errors && this.errors['deliver_at']
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// TODO: make it default server config --> add it to file-upload
|
|
272
|
+
getServerConfig() {
|
|
273
|
+
return {
|
|
274
|
+
process: async (_fieldName, file, _metadata, load, error, _progress, abort, _transfer, _options) => {
|
|
275
|
+
const formData = new FormData();
|
|
276
|
+
formData.append("image_url", file, file.name);
|
|
277
|
+
return await salla.product.uploadGiftImage(formData)
|
|
278
|
+
.then((resp) => {
|
|
279
|
+
this.uploadedImage = resp.data.url;
|
|
280
|
+
load('success');
|
|
281
|
+
file.metadata = `_${new Date().getTime()}`;
|
|
282
|
+
if (!!this.gift && this.gift.gift_images.length) {
|
|
283
|
+
this.setWrapperHeight(1, 150, 0);
|
|
284
|
+
}
|
|
285
|
+
}).catch(e => {
|
|
286
|
+
console.log(e);
|
|
287
|
+
error('error');
|
|
288
|
+
})
|
|
289
|
+
.finally(() => {
|
|
290
|
+
return {
|
|
291
|
+
abort: () => {
|
|
292
|
+
abort();
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async submitForm() {
|
|
300
|
+
var _a;
|
|
301
|
+
this.calendarFormGroup.classList.remove('s-form-has-error');
|
|
302
|
+
if (!!this.errors) {
|
|
303
|
+
this.errors = {};
|
|
304
|
+
this.setWrapperHeight(2, 150, 0);
|
|
305
|
+
}
|
|
306
|
+
if (this.showCalendar && !this.deliveryDate) {
|
|
307
|
+
this.calendarFormGroup.classList.add('s-form-has-error');
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
let payload = {
|
|
311
|
+
text: this.selectedText,
|
|
312
|
+
sender_name: this.senderName,
|
|
313
|
+
quantity: 1,
|
|
314
|
+
deliver_at: this.showCalendar ? this.deliveryDate : null,
|
|
315
|
+
image_url: (_a = this.uploadedImage) !== null && _a !== void 0 ? _a : this.selectedImage,
|
|
316
|
+
receiver: {
|
|
317
|
+
name: this.receiverName,
|
|
318
|
+
country_code: this.receiverCountryCode,
|
|
319
|
+
mobile: this.receiverMobile
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
return await salla.product.addGiftToCart(this.productId, payload, true).then((resp) => {
|
|
323
|
+
console.log(resp);
|
|
324
|
+
}).catch((e) => {
|
|
325
|
+
if (e.response.status == 422) {
|
|
326
|
+
this.errors = e.response.data.error.fields;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
console.log(e);
|
|
330
|
+
}
|
|
331
|
+
this.setWrapperHeight(2, 150, 0);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
render() {
|
|
335
|
+
var _a, _b;
|
|
336
|
+
return [
|
|
337
|
+
h("div", null,
|
|
338
|
+
h("salla-list-tile", { class: "s-gifting-widget" },
|
|
339
|
+
h("div", { slot: "title" },
|
|
340
|
+
h("h3", null, this.sectionTitle)),
|
|
341
|
+
h("div", { slot: "subtitle" },
|
|
342
|
+
h("div", null, this.sectionSubtitle)),
|
|
343
|
+
h("div", { slot: "action" },
|
|
344
|
+
h("salla-button", { class: "s-gifting-widget-action", color: "gray", onClick: () => this.open() },
|
|
345
|
+
h("span", { innerHTML: GiftSharing }),
|
|
346
|
+
" \u00A0",
|
|
347
|
+
h("span", null, this.sectionBtnText)))),
|
|
348
|
+
h("salla-modal", { id: 'salla-gifting-modal', isLoading: true, class: "s-gifting-modal", width: "sm", ref: modal => this.modal = modal },
|
|
349
|
+
h("div", { slot: "loading" },
|
|
350
|
+
h("div", { class: "s-gifting-skeleton" },
|
|
351
|
+
h("div", { class: "s-gifting-modal-header" },
|
|
352
|
+
h("salla-skeleton", { type: 'circle', height: '5rem', width: '5rem' }),
|
|
353
|
+
h("h2", { class: "s-gifting-modal-title" },
|
|
354
|
+
h("div", { class: "s-gifting-modal-badge-wrapper" },
|
|
355
|
+
h("salla-skeleton", { height: '15px', width: '150px' })))),
|
|
356
|
+
h("div", { class: "s-gifting-skeleton-content" },
|
|
357
|
+
h("salla-skeleton", { height: '10px', width: '150px' }),
|
|
358
|
+
h("salla-skeleton", { height: '230px' }),
|
|
359
|
+
h("salla-skeleton", { height: '10px', width: '150px' }),
|
|
360
|
+
h("salla-skeleton", { height: '30px' }),
|
|
361
|
+
h("salla-skeleton", { height: '40px' })))),
|
|
362
|
+
h("slot", { name: "header" }),
|
|
363
|
+
!!this.hasError ?
|
|
364
|
+
h("salla-placeholder", { alignment: "center" },
|
|
365
|
+
h("span", { slot: "description" }, this.errorMessage))
|
|
366
|
+
:
|
|
367
|
+
[
|
|
368
|
+
h("div", { class: "s-gifting-modal-header" },
|
|
369
|
+
h("span", { class: "s-gifting-modal-icon" },
|
|
370
|
+
h("span", { innerHTML: GiftSharing })),
|
|
371
|
+
h("h2", { class: "s-gifting-modal-title" },
|
|
372
|
+
h("div", { class: "s-gifting-modal-badge-wrapper" },
|
|
373
|
+
h("div", { class: "s-gifting-modal-badge" },
|
|
374
|
+
h("span", null,
|
|
375
|
+
h("span", null, this.currentStep),
|
|
376
|
+
"/2")),
|
|
377
|
+
h("span", null, this.giftDetails)))),
|
|
378
|
+
h("div", { class: "s-gifting-steps-wrapper steps-wrapper" },
|
|
379
|
+
h("div", { class: "s-gifting-step-one gift-step-1" },
|
|
380
|
+
h("div", { class: "s-gifting-modal-uploader-title anime-item opacity-0" }, this.selectImageForYourGift),
|
|
381
|
+
h("div", { class: "s-gifting-modal-uploader anime-item opacity-0" },
|
|
382
|
+
h("span", { class: "s-gifting-remove-preview", onClick: () => this.removePreview(), innerHTML: Cancel }),
|
|
383
|
+
this.selectImageOrUpload && h("salla-file-upload", { "instant-upload": true, labelIdle: this.getFilepondPlaceholder(), serverConfig: this.getServerConfig(), onRemove: () => this.handleRemoveImage() }, " ")),
|
|
384
|
+
h("div", { class: "anime-item opacity-0" },
|
|
385
|
+
!this.uploadedImage && !!this.gift && this.gift.gift_images.length > 0 ?
|
|
386
|
+
h("salla-swiper", { "space-between-items": "10", "item-per-view": "4" }, (_a = this.gift) === null || _a === void 0 ? void 0 : _a.gift_images.map((item) => h("img", { class: "s-gifting-image s-gifting-clickable", src: item.url, onClick: () => this.setPreview(item), alt: `${item.id}` })))
|
|
387
|
+
: "",
|
|
388
|
+
h("div", { class: "s-form-group s-gifting-selectText anime-item opacity-0" },
|
|
389
|
+
h("label", { htmlFor: "gift-text-selection", class: "s-form-label" }, this.selectGiftMessage),
|
|
390
|
+
h("select", { id: "gift-text-selection", name: "gift-text-selection", class: "s-form-control s-gifting-select", onChange: e => this.toggleGiftText(e) },
|
|
391
|
+
h("option", { "data-id": null, selected: true }, this.selectGiftMessage), (_b = this.gift) === null || _b === void 0 ? void 0 :
|
|
392
|
+
_b.gift_texts.map((txt) => h("option", { "data-id": txt.id, value: txt.text, key: txt.id }, txt.text)),
|
|
393
|
+
h("option", { "data-id": "custom" }, this.giftCustomText))),
|
|
394
|
+
h("div", { class: this.showGiftText ? "s-form-group anime-item opacity-0 s-gifting-textarea shown" : "s-form-group s-gifting-textarea hide" },
|
|
395
|
+
h("label", { htmlFor: "gift-custom-text", class: "s-form-label" }, this.giftCustomText),
|
|
396
|
+
h("div", { class: "mt-1" },
|
|
397
|
+
h("textarea", { onInput: (event) => this.handleTextAreaChange(event), rows: 4, name: "gift-custom-text", id: "gift-custom-text", class: "s-form-control" }))),
|
|
398
|
+
h("div", { class: "anime-item opacity-0" },
|
|
399
|
+
h("salla-button", { color: "primary", width: "wide", onClick: () => this.goToStep2() },
|
|
400
|
+
h("span", null, this.nextStep))))),
|
|
401
|
+
h("div", { class: "s-gifting-step-two gift-step-2" },
|
|
402
|
+
h("div", { class: this.errors && this.errors['sender_name'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" },
|
|
403
|
+
h("label", { htmlFor: "sender_name", class: "s-form-label" }, this.senderNameLabel),
|
|
404
|
+
h("input", { type: "text", class: "s-form-control", name: "sender_name", id: "sender_name", value: this.senderName, onInput: (event) => this.handleSenderName(event), placeholder: "" }),
|
|
405
|
+
this.errors && this.errors['sender_name'] ? h("span", { class: "text-danger text-xs" }, this.errors['sender_name']) : ''),
|
|
406
|
+
h("div", { class: this.errors && this.errors['receiver.name'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" },
|
|
407
|
+
h("label", { htmlFor: "receiver_name", class: "s-form-label" }, this.receiverNameFieldLabel),
|
|
408
|
+
h("input", { type: "text", class: "s-form-control", name: "receiver_name", id: "receiver_name", value: "", onInput: (event) => this.handleReceiverName(event), placeholder: "" }),
|
|
409
|
+
this.errors && this.errors['receiver.name'] ? h("span", { class: "text-danger text-xs" }, this.errors['receiver.name']) : ''),
|
|
410
|
+
h("div", { class: this.errors && this.errors['receiver.mobile'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" },
|
|
411
|
+
h("label", { class: "s-form-label" }, this.receiverMobileFieldLabel),
|
|
412
|
+
h("salla-tel-input", { class: "s-gifting-tel-input", phone: this.receiverMobile, countryCode: this.receiverCountryCode, onPhoneEntered: (e) => this.handlePhoneInputChange(e) }),
|
|
413
|
+
this.errors && this.errors['receiver.mobile'] ? h("span", { class: "text-danger text-xs" }, this.errors['receiver.mobile']) : ''),
|
|
414
|
+
h("div", { class: "anime-item opacity-0" },
|
|
415
|
+
h("label", { class: "s-gifting-schedule s-gifting-clickable", htmlFor: "schedule" },
|
|
416
|
+
h("input", { type: "checkbox", name: 'schedule', id: 'schedule', onChange: () => this.toggleCalendar(), class: "s-checkbox" }),
|
|
417
|
+
h("span", { class: "s-form-label" },
|
|
418
|
+
" ",
|
|
419
|
+
this.sendLater,
|
|
420
|
+
" "))),
|
|
421
|
+
h("div", { class: this.getCalendarClasses() },
|
|
422
|
+
h("label", { class: "s-form-label" }, this.selectSendDateAndTime),
|
|
423
|
+
h("salla-datetime-picker", { value: this.deliveryDate, placeholder: this.selectSendDateAndTime, "enable-time": true, "date-format": "Y-m-d H:i", onPicked: (event) => this.handleDateTimePicker(event) }),
|
|
424
|
+
h("span", { class: "s-gifting-calendar-hint" }, this.canNotEditOrderAfterSelectDate)),
|
|
425
|
+
h("div", { class: "s-gifting-step-two-footer anime-item opacity-0" },
|
|
426
|
+
h("a", { href: "#!", innerHTML: this.currentLang == 'ar' ? RightArrow : LeftArrow, onClick: () => this.goToStep1() }),
|
|
427
|
+
h("salla-button", { onClick: () => this.submitForm(), color: "primary", width: 'wide' },
|
|
428
|
+
h("span", null, this.sendGift)))))
|
|
429
|
+
],
|
|
430
|
+
h("slot", { name: "footer" })))
|
|
431
|
+
];
|
|
432
|
+
}
|
|
433
|
+
static get is() { return "salla-gifting"; }
|
|
434
|
+
static get originalStyleUrls() { return {
|
|
435
|
+
"$": ["salla-gifting.scss"]
|
|
436
|
+
}; }
|
|
437
|
+
static get styleUrls() { return {
|
|
438
|
+
"$": ["salla-gifting.css"]
|
|
439
|
+
}; }
|
|
440
|
+
static get properties() { return {
|
|
441
|
+
"productId": {
|
|
442
|
+
"type": "number",
|
|
443
|
+
"mutable": false,
|
|
444
|
+
"complexType": {
|
|
445
|
+
"original": "number",
|
|
446
|
+
"resolved": "number",
|
|
447
|
+
"references": {}
|
|
448
|
+
},
|
|
449
|
+
"required": false,
|
|
450
|
+
"optional": false,
|
|
451
|
+
"docs": {
|
|
452
|
+
"tags": [],
|
|
453
|
+
"text": "The product id for which the gifting system is required."
|
|
454
|
+
},
|
|
455
|
+
"attribute": "product-id",
|
|
456
|
+
"reflect": false
|
|
457
|
+
}
|
|
458
|
+
}; }
|
|
459
|
+
static get states() { return {
|
|
460
|
+
"sectionTitle": {},
|
|
461
|
+
"sectionSubtitle": {},
|
|
462
|
+
"sectionBtnText": {},
|
|
463
|
+
"giftDetails": {},
|
|
464
|
+
"selectImageForYourGift": {},
|
|
465
|
+
"selectImageOrUpload": {},
|
|
466
|
+
"selectGiftMessage": {},
|
|
467
|
+
"giftCustomText": {},
|
|
468
|
+
"textId": {},
|
|
469
|
+
"incorrectGiftText": {},
|
|
470
|
+
"nextStep": {},
|
|
471
|
+
"senderNameLabel": {},
|
|
472
|
+
"receiverNameFieldLabel": {},
|
|
473
|
+
"receiverMobileFieldLabel": {},
|
|
474
|
+
"receiverEmailFieldLabel": {},
|
|
475
|
+
"emailPlaceholder": {},
|
|
476
|
+
"sendLater": {},
|
|
477
|
+
"selectSendDateAndTime": {},
|
|
478
|
+
"canNotEditOrderAfterSelectDate": {},
|
|
479
|
+
"sendGift": {},
|
|
480
|
+
"donationRequired": {},
|
|
481
|
+
"step1Elems": {},
|
|
482
|
+
"step2Elems": {},
|
|
483
|
+
"stepsWrapper": {},
|
|
484
|
+
"imageCover": {},
|
|
485
|
+
"textSelect": {},
|
|
486
|
+
"customTextArea": {},
|
|
487
|
+
"calendarFormGroup": {},
|
|
488
|
+
"currentStep": {},
|
|
489
|
+
"showCalendar": {},
|
|
490
|
+
"showGiftText": {},
|
|
491
|
+
"currentLang": {},
|
|
492
|
+
"parentClass": {},
|
|
493
|
+
"errors": {},
|
|
494
|
+
"gift": {},
|
|
495
|
+
"selectedGiftTextOption": {},
|
|
496
|
+
"showTextArea": {},
|
|
497
|
+
"selectedImage": {},
|
|
498
|
+
"uploadedImage": {},
|
|
499
|
+
"selectedText": {},
|
|
500
|
+
"senderName": {},
|
|
501
|
+
"errorMessage": {},
|
|
502
|
+
"hasError": {},
|
|
503
|
+
"quantity": {},
|
|
504
|
+
"deliveryDate": {},
|
|
505
|
+
"timeZone": {},
|
|
506
|
+
"receiverName": {},
|
|
507
|
+
"receiverMobile": {},
|
|
508
|
+
"receiverCountryCode": {},
|
|
509
|
+
"receiverEmail": {}
|
|
510
|
+
}; }
|
|
511
|
+
static get methods() { return {
|
|
512
|
+
"open": {
|
|
513
|
+
"complexType": {
|
|
514
|
+
"signature": "() => Promise<any>",
|
|
515
|
+
"parameters": [],
|
|
516
|
+
"references": {
|
|
517
|
+
"Promise": {
|
|
518
|
+
"location": "global"
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
"return": "Promise<any>"
|
|
522
|
+
},
|
|
523
|
+
"docs": {
|
|
524
|
+
"text": "Show the gifting modal window",
|
|
525
|
+
"tags": []
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
"close": {
|
|
529
|
+
"complexType": {
|
|
530
|
+
"signature": "() => Promise<HTMLElement>",
|
|
531
|
+
"parameters": [],
|
|
532
|
+
"references": {
|
|
533
|
+
"Promise": {
|
|
534
|
+
"location": "global"
|
|
535
|
+
},
|
|
536
|
+
"HTMLElement": {
|
|
537
|
+
"location": "global"
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
"return": "Promise<HTMLElement>"
|
|
541
|
+
},
|
|
542
|
+
"docs": {
|
|
543
|
+
"text": "\nHide the gifting modal window",
|
|
544
|
+
"tags": []
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
"goToStep2": {
|
|
548
|
+
"complexType": {
|
|
549
|
+
"signature": "() => Promise<void>",
|
|
550
|
+
"parameters": [],
|
|
551
|
+
"references": {
|
|
552
|
+
"Promise": {
|
|
553
|
+
"location": "global"
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
"return": "Promise<void>"
|
|
557
|
+
},
|
|
558
|
+
"docs": {
|
|
559
|
+
"text": "\nGo to the step 2",
|
|
560
|
+
"tags": []
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}; }
|
|
564
|
+
}
|