@salla.sa/twilight-components 2.14.139 → 2.14.141
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/index-a2d7a914.js +2 -6
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{salla-add-product-button_48.cjs.entry.js → salla-add-product-button_49.cjs.entry.js} +163 -32
- package/dist/cjs/salla-add-product-button_49.cjs.entry.js.map +1 -0
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +50 -30
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js.map +1 -1
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.js +4 -0
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.js.map +1 -1
- package/dist/components/salla-offer-modal.js +110 -42
- package/dist/components/salla-offer-modal.js.map +1 -1
- package/dist/components/salla-products-slider.js +1 -206
- package/dist/components/salla-products-slider.js.map +1 -1
- package/dist/{esm/salla-products-slider.entry.js → components/salla-products-slider2.js} +108 -11
- package/dist/components/salla-products-slider2.js.map +1 -0
- package/dist/components/salla-reviews-summary2.js +4 -0
- package/dist/components/salla-reviews-summary2.js.map +1 -1
- package/dist/esm/index-114c614f.js +2 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{salla-add-product-button_48.entry.js → salla-add-product-button_49.entry.js} +163 -33
- package/dist/esm/salla-add-product-button_49.entry.js.map +1 -0
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/index-114c614f.js +1 -1
- package/dist/esm-es5/index-114c614f.js.map +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/{salla-add-product-button_48.entry.js → salla-add-product-button_49.entry.js} +2 -2
- package/dist/esm-es5/salla-add-product-button_49.entry.js.map +1 -0
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/esm-es5/twilight.js.map +1 -1
- package/dist/twilight/p-40f204a6.system.js +1 -1
- package/dist/twilight/p-40f204a6.system.js.map +1 -1
- package/dist/twilight/{p-a3c95fbd.entry.js → p-9ec0e4ed.entry.js} +2 -2
- package/dist/twilight/p-9ec0e4ed.entry.js.map +1 -0
- package/dist/twilight/{p-7bd8bfbe.system.entry.js → p-ce683cea.system.entry.js} +6 -6
- package/dist/twilight/p-ce683cea.system.entry.js.map +1 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.esm.js.map +1 -1
- package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +0 -3
- package/package.json +5 -5
- package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +0 -1
- package/dist/cjs/salla-products-slider.cjs.entry.js +0 -120
- package/dist/cjs/salla-products-slider.cjs.entry.js.map +0 -1
- package/dist/esm/salla-add-product-button_48.entry.js.map +0 -1
- package/dist/esm/salla-products-slider.entry.js.map +0 -1
- package/dist/esm-es5/salla-add-product-button_48.entry.js.map +0 -1
- package/dist/esm-es5/salla-products-slider.entry.js +0 -5
- package/dist/esm-es5/salla-products-slider.entry.js.map +0 -1
- package/dist/twilight/p-3c2d05e3.entry.js +0 -5
- package/dist/twilight/p-3c2d05e3.entry.js.map +0 -1
- package/dist/twilight/p-70f8669e.system.entry.js +0 -5
- package/dist/twilight/p-70f8669e.system.entry.js.map +0 -1
- package/dist/twilight/p-7bd8bfbe.system.entry.js.map +0 -1
- package/dist/twilight/p-a3c95fbd.entry.js.map +0 -1
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
5
5
|
import { S as SpecialDiscountIcon } from './special-discount.js';
|
|
6
|
-
import { d as defineCustomElement$
|
|
7
|
-
import { d as defineCustomElement$
|
|
8
|
-
import { d as defineCustomElement$
|
|
9
|
-
import { d as defineCustomElement$
|
|
10
|
-
import { d as defineCustomElement$
|
|
11
|
-
import { d as defineCustomElement$
|
|
6
|
+
import { d as defineCustomElement$f } from './salla-add-product-button2.js';
|
|
7
|
+
import { d as defineCustomElement$e } from './salla-button2.js';
|
|
8
|
+
import { d as defineCustomElement$d } from './salla-count-down2.js';
|
|
9
|
+
import { d as defineCustomElement$c } from './salla-loading2.js';
|
|
10
|
+
import { d as defineCustomElement$b } from './salla-modal2.js';
|
|
11
|
+
import { d as defineCustomElement$a } from './salla-placeholder2.js';
|
|
12
|
+
import { d as defineCustomElement$9 } from './salla-product-availability2.js';
|
|
13
|
+
import { d as defineCustomElement$8 } from './salla-product-card2.js';
|
|
14
|
+
import { d as defineCustomElement$7 } from './salla-products-slider2.js';
|
|
15
|
+
import { d as defineCustomElement$6 } from './salla-progress-bar2.js';
|
|
16
|
+
import { d as defineCustomElement$5 } from './salla-quick-buy2.js';
|
|
17
|
+
import { d as defineCustomElement$4 } from './salla-skeleton2.js';
|
|
18
|
+
import { d as defineCustomElement$3 } from './salla-slider2.js';
|
|
19
|
+
import { d as defineCustomElement$2 } from './salla-tel-input2.js';
|
|
12
20
|
|
|
13
21
|
const Tag = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
14
22
|
<title>tag</title>
|
|
@@ -29,7 +37,7 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class SallaOfferModal
|
|
|
29
37
|
constructor() {
|
|
30
38
|
super();
|
|
31
39
|
this.__registerHost();
|
|
32
|
-
var _a
|
|
40
|
+
var _a;
|
|
33
41
|
this.offer = null;
|
|
34
42
|
this.offer_name = undefined;
|
|
35
43
|
this.offer_message = undefined;
|
|
@@ -45,7 +53,7 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class SallaOfferModal
|
|
|
45
53
|
this.translationLoaded = true;
|
|
46
54
|
});
|
|
47
55
|
this.categorySlot = ((_a = this.host.querySelector('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || `<span class="s-offer-modal-badge-icon">{tagIcon}</span><span class="s-offer-modal-badge-text">{name}</span>`;
|
|
48
|
-
this.productSlot =
|
|
56
|
+
// this.productSlot = this.host.querySelector('[slot="product"]')?.innerHTML || this.defaultProductSlot();
|
|
49
57
|
salla.event.on('offer-modal::open', product_id => this.open(product_id));
|
|
50
58
|
salla.product.event.onOfferExisted(offer => {
|
|
51
59
|
if (salla.storage.get('remember-offer-' + offer.id)) {
|
|
@@ -101,45 +109,65 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class SallaOfferModal
|
|
|
101
109
|
salla.api.withoutNotifier(() => salla.cart.quickAdd(this.productID, qty, this.offer_type)).then(() => this.modal.close());
|
|
102
110
|
}
|
|
103
111
|
getOfferContent() {
|
|
104
|
-
var _a, _b, _c, _d, _e, _f
|
|
112
|
+
var _a, _b, _c, _d, _e, _f;
|
|
105
113
|
if (this.offer.get.discounts_table) {
|
|
106
114
|
return h("div", { class: "s-offer-modal-discount-table" }, h("table", null, h("tbody", null, (_a = this.offer.get.discounts_table) === null || _a === void 0 ? void 0 : _a.map(discount => h("tr", null, h("td", null, discount.text), h("td", { class: "s-offer-modal-discount-table-cell" }, h("salla-button", { fill: "outline", shape: "btn", color: "primary", size: "medium", width: "normal", onClick: () => this.addToCart(discount.quantity) }, this.addToCartLabel)))))));
|
|
107
115
|
}
|
|
108
116
|
else if ((_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.length) {
|
|
109
|
-
return h("salla-slider", {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
return (h("salla-products-slider", { source: "selected", "source-value": `[${(((_c = this.offer.get.products) === null || _c === void 0 ? void 0 : _c.map(product => product.id)) || []).join(",")}]`, "slider-config": '{"slidesPerView": 1, "spaceBetween": 16, "breakpoints": { "768": { "slidesPerView": 2 }, "1024": { "slidesPerView": 3 } }}' }));
|
|
118
|
+
// return <salla-slider
|
|
119
|
+
// type="carousel"
|
|
120
|
+
// class={{"s-offer-modal-slider-centered": this.offer.get.products?.length <= 2, "s-offer-modal-slider": true}}
|
|
121
|
+
// id="offer-modal-slider"
|
|
122
|
+
// controls-outer
|
|
123
|
+
// show-controls={this.offer.get.products?.length <= 2 ? 'false' : 'true'}>
|
|
124
|
+
// <div slot='items'>
|
|
125
|
+
// {
|
|
126
|
+
// this.offer.get.products?.map(product =>
|
|
127
|
+
// <div class={{
|
|
128
|
+
// "s-offer-modal-product": true,
|
|
129
|
+
// "s-offer-modal-slider-item": true,
|
|
130
|
+
// "s-offer-modal-not-available": !product.is_available
|
|
131
|
+
// }} id={'product_' + product.id} innerHTML={this.productSlot
|
|
132
|
+
// .replace(/\{name\}/g, product.name)
|
|
133
|
+
// .replace(/\{url\}/g, product.url)
|
|
134
|
+
// .replace(/\{image\}/g, product.thumbnail)
|
|
135
|
+
// .replace(/\{price\}/g, product.has_special_price
|
|
136
|
+
// ? '<span class="s-offer-modal-product-sale-price">' + salla.money(product.price) + '</span><span class="s-offer-modal-product-old-price">' + salla.money(product.regular_price) + '</span>'
|
|
137
|
+
// : salla.money(product.price))}>
|
|
138
|
+
// <div class="s-offer-modal-btn-wrap">
|
|
139
|
+
// <salla-button width="wide" fill='outline' data-id={product.id} disabled={!product.is_available}
|
|
140
|
+
// loader-position="center" onClick={this.addItem}>
|
|
141
|
+
// {product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')}
|
|
142
|
+
// </salla-button>
|
|
143
|
+
// </div>
|
|
144
|
+
// </div>)
|
|
145
|
+
// }
|
|
146
|
+
// </div>
|
|
147
|
+
// </salla-slider>
|
|
120
148
|
}
|
|
121
|
-
else if ((
|
|
122
|
-
return h("salla-slider", { type: "carousel", class: { "s-offer-modal-slider-centered": ((
|
|
149
|
+
else if ((_d = this.offer.get.categories) === null || _d === void 0 ? void 0 : _d.length) {
|
|
150
|
+
return h("salla-slider", { type: "carousel", class: { "s-offer-modal-slider-centered": ((_e = this.offer.get.categories) === null || _e === void 0 ? void 0 : _e.length) <= 2, "s-offer-modal-slider": true }, id: "offer-modal-slider", "controls-outer": true, "show-controls": ((_f = this.offer.get.categories) === null || _f === void 0 ? void 0 : _f.length) <= 2 ? 'false' : 'true' }, h("div", { slot: 'items' }, this.offer.get.categories.map(category => h("a", { href: category.urls.customer, class: "s-offer-modal-badge s-offer-modal-slider-item s-offer-modal-cat-item", innerHTML: this.categorySlot
|
|
123
151
|
.replace(/\{tagIcon\}/g, Tag)
|
|
124
152
|
.replace(/\{name\}/g, category.name)
|
|
125
153
|
.replace(/\{url\}/g, category.urls.customer) }))));
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
156
|
//todo:: pass event then use sallaButton from it
|
|
129
|
-
addItem() {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
defaultProductSlot() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
157
|
+
// private addItem() {
|
|
158
|
+
// // this here, is sallaButton
|
|
159
|
+
// this['load']();
|
|
160
|
+
// return salla.cart.api
|
|
161
|
+
// .quickAdd(this['dataset'].id)
|
|
162
|
+
// .finally(() => this['stop']());
|
|
163
|
+
// }
|
|
164
|
+
// private defaultProductSlot() {
|
|
165
|
+
// return '<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a>' +
|
|
166
|
+
// '<div class="s-offer-modal-product-info">' +
|
|
167
|
+
// ' <a href={url} class="s-offer-modal-product-name">{name}</a>' +
|
|
168
|
+
// ' <div class="s-offer-modal-product-price">{price}</div>' +
|
|
169
|
+
// '</div>';
|
|
170
|
+
// }
|
|
143
171
|
render() {
|
|
144
172
|
return h("salla-modal", { "has-skeleton": true, "sub-title": this.offer_message, ref: modal => this.modal = modal, isLoading: true, class: `s-offer-modal-type-${this.offer_type ? this.offer_type : ''}` }, h("div", { slot: 'loading' }, h("div", { class: "s-offer-modal-skeleton" }, h("div", { class: "s-offer-modal-skeleton-header" }, h("salla-skeleton", { type: 'circle', height: '80px', width: '80px' }), h("salla-skeleton", { height: '15px', width: '50%' }), h("salla-skeleton", { height: '10px', width: '30%' })), h("div", { class: "s-offer-modal-skeleton-items" }, [...Array(3)].map(() => h("div", { class: "s-offer-modal-skeleton-item" }, h("salla-skeleton", { height: '9rem' }), h("div", { class: "s-offer-modal-skeleton-item-title" }, h("salla-skeleton", { height: '15px', width: '100%' })), h("div", { class: "s-offer-modal-skeleton-item-subtitle" }, h("salla-skeleton", { height: '9px', width: '50%' }), h("div", { innerHTML: Cart2 }))))), h("div", { class: "s-offer-modal-skeleton-footer" }, h("salla-skeleton", { height: '15px', width: '50%' }), h("salla-skeleton", { height: '15px', width: '30%' })))), !this.hasError && this.offer !== null
|
|
145
173
|
? [h("span", { slot: 'icon', class: "s-offer-modal-header-icon", innerHTML: SpecialDiscountIcon }), this.getOfferContent(), h("div", { class: "s-offer-modal-footer", slot: "footer" }, this.offer.formatted_date ?
|
|
@@ -167,39 +195,79 @@ function defineCustomElement$1() {
|
|
|
167
195
|
if (typeof customElements === "undefined") {
|
|
168
196
|
return;
|
|
169
197
|
}
|
|
170
|
-
const components = ["salla-offer-modal", "salla-button", "salla-loading", "salla-modal", "salla-placeholder", "salla-skeleton", "salla-slider"];
|
|
198
|
+
const components = ["salla-offer-modal", "salla-add-product-button", "salla-button", "salla-count-down", "salla-loading", "salla-modal", "salla-placeholder", "salla-product-availability", "salla-product-card", "salla-products-slider", "salla-progress-bar", "salla-quick-buy", "salla-skeleton", "salla-slider", "salla-tel-input"];
|
|
171
199
|
components.forEach(tagName => { switch (tagName) {
|
|
172
200
|
case "salla-offer-modal":
|
|
173
201
|
if (!customElements.get(tagName)) {
|
|
174
202
|
customElements.define(tagName, SallaOfferModal$1);
|
|
175
203
|
}
|
|
176
204
|
break;
|
|
205
|
+
case "salla-add-product-button":
|
|
206
|
+
if (!customElements.get(tagName)) {
|
|
207
|
+
defineCustomElement$f();
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
177
210
|
case "salla-button":
|
|
178
211
|
if (!customElements.get(tagName)) {
|
|
179
|
-
defineCustomElement$
|
|
212
|
+
defineCustomElement$e();
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case "salla-count-down":
|
|
216
|
+
if (!customElements.get(tagName)) {
|
|
217
|
+
defineCustomElement$d();
|
|
180
218
|
}
|
|
181
219
|
break;
|
|
182
220
|
case "salla-loading":
|
|
183
221
|
if (!customElements.get(tagName)) {
|
|
184
|
-
defineCustomElement$
|
|
222
|
+
defineCustomElement$c();
|
|
185
223
|
}
|
|
186
224
|
break;
|
|
187
225
|
case "salla-modal":
|
|
188
226
|
if (!customElements.get(tagName)) {
|
|
189
|
-
defineCustomElement$
|
|
227
|
+
defineCustomElement$b();
|
|
190
228
|
}
|
|
191
229
|
break;
|
|
192
230
|
case "salla-placeholder":
|
|
193
231
|
if (!customElements.get(tagName)) {
|
|
194
|
-
defineCustomElement$
|
|
232
|
+
defineCustomElement$a();
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case "salla-product-availability":
|
|
236
|
+
if (!customElements.get(tagName)) {
|
|
237
|
+
defineCustomElement$9();
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
case "salla-product-card":
|
|
241
|
+
if (!customElements.get(tagName)) {
|
|
242
|
+
defineCustomElement$8();
|
|
243
|
+
}
|
|
244
|
+
break;
|
|
245
|
+
case "salla-products-slider":
|
|
246
|
+
if (!customElements.get(tagName)) {
|
|
247
|
+
defineCustomElement$7();
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
case "salla-progress-bar":
|
|
251
|
+
if (!customElements.get(tagName)) {
|
|
252
|
+
defineCustomElement$6();
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case "salla-quick-buy":
|
|
256
|
+
if (!customElements.get(tagName)) {
|
|
257
|
+
defineCustomElement$5();
|
|
195
258
|
}
|
|
196
259
|
break;
|
|
197
260
|
case "salla-skeleton":
|
|
198
261
|
if (!customElements.get(tagName)) {
|
|
199
|
-
defineCustomElement$
|
|
262
|
+
defineCustomElement$4();
|
|
200
263
|
}
|
|
201
264
|
break;
|
|
202
265
|
case "salla-slider":
|
|
266
|
+
if (!customElements.get(tagName)) {
|
|
267
|
+
defineCustomElement$3();
|
|
268
|
+
}
|
|
269
|
+
break;
|
|
270
|
+
case "salla-tel-input":
|
|
203
271
|
if (!customElements.get(tagName)) {
|
|
204
272
|
defineCustomElement$2();
|
|
205
273
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-offer-modal.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,EAAE;;MCgBhBA,iBAAe;EAa1B;;;;iBAR+B,IAAI;;;oBAGN,KAAK;;;;6BAyBI,KAAK;0BACT,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC;IApBxE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;MAC9D,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,0CAAE,SAAS,KAAI,6GAA6G,CAAC;IAC7L,IAAI,CAAC,WAAW,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,0CAAE,SAAS,KAAI,IAAI,CAAC,kBAAkB,EAA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E,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,YAAM,IAAI,EAAC,aAAa,IAAE,IAAI,CAAC,YAAY,CAAQ,GAAG,EAAE,CAC7D,CAEV,CAAA;GACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaOfferModal"],"sources":["src/components/salla-offer-modal/salla-offer-modal.scss?tag=salla-offer-modal","src/components/salla-offer-modal/salla-offer-modal.tsx"],"sourcesContent":["/*\n* Salla Offer Modal Component: popup modal to display the offers\n* You can use these classes to target the elements in the component.\n*/\n\n.s-offer-modal {\n &-body {\n \n }\n &-badge {\n &-icon {\n\n }\n &-text {\n\n }\n }\n &-product {\n &-image-wrap {\n\n }\n &-image {\n\n }\n &-info {\n\n }\n &-name {\n\n }\n &-price {\n\n }\n &-old-price {\n\n }\n }\n &-btn-wrap {\n\n }\n &-footer {\n\n }\n &-expiry {\n\n }\n &-remember-label {\n\n }\n &-remember-input {\n\n }\n &-scrolled-slider-wrap {\n\n }\n &-slider-nav {\n\n }\n &-nav-btn {\n\n }\n &-nav-btn-icon {\n\n }\n &-next-btn {\n \n }\n &-prev-btn {\n \n }\n &-btn-is-active {\n\n }\n}","import { Component, h, Element, Method, State } from '@stencil/core';\nimport Offer from \"./offer-schema\";\nimport SpecialDiscountIcon from '../../assets/svg/special-discount.svg';\nimport Tag from \"../../assets/svg/tag.svg\";\nimport Cart2 from '../../assets/svg/cart2.svg';\n\n/**\n * @slot header - The top of the popup, has replaceable props `{name}`, `{message}`.\n * @slot product - Replaces product card, has replaceable props `{name}`, `{url}`, `{image}`, `{price}`.\n * @slot category - Replaces Category badge, has replaceable props `{name}`, `{url}`.\n */\n@Component({\n tag: 'salla-offer-modal',\n styleUrl: 'salla-offer-modal.scss'\n})\n\nexport class SallaOfferModal {\n private productSlot: string;\n private categorySlot: string;\n private modal: HTMLSallaModalElement;\n @Element() host: HTMLElement;\n @State() offer: null | Offer = null;\n @State() offer_name: string;\n @State() offer_message: string;\n @State() hasError: boolean = false;\n @State() errorMessage: string;\n @State() productID: number;\n @State() offer_type: string;\n\n constructor() {\n salla.event.on('offer-modal::open', product_id => this.open(product_id));\n\n salla.lang.onLoaded(() => {\n this.addToCartLabel = salla.lang.get(\"pages.cart.add_to_cart\")\n this.translationLoaded = true;\n });\n\n this.categorySlot = this.host.querySelector('[slot=\"category\"]')?.innerHTML || `<span class=\"s-offer-modal-badge-icon\">{tagIcon}</span><span class=\"s-offer-modal-badge-text\">{name}</span>`;\n this.productSlot = this.host.querySelector('[slot=\"product\"]')?.innerHTML || this.defaultProductSlot();\n salla.event.on('offer-modal::open', product_id => this.open(product_id));\n salla.product.event.onOfferExisted(offer => {\n if (salla.storage.get('remember-offer-' + offer.id)) {\n salla.log('User selected to don\\'t show this offer again.');\n return;\n }\n this.open(offer.product_id);\n });\n }\n\n @State() translationLoaded: boolean = false;\n @State() addToCartLabel: string = salla.lang.get(\"pages.cart.add_to_cart\");\n\n /**\n * Show the available offers for the product\n * @param product_id\n */\n @Method()\n async open(product_id: number) {\n this.productID = product_id;\n //TODO:: make sure there is only one offer\n\n this.hasError = false;\n this.modal.open()\n return await salla.api.withoutNotifier(() => salla.product.offers(product_id))\n .then(response => this.showOffer(response.data[0]))\n .catch(e => {\n this.hasError = true;\n this.errorMessage = e.response?.data?.error?.message || e.response?.data;\n })\n .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));\n }\n\n /**\n * Show offer details\n * @param {Offer} offer\n */\n @Method()\n async showOffer(offer) {\n this.offer = offer;\n this.offer_name = offer.name;\n this.offer_message = offer.message;\n if (this.offer.get.discounts_table) {\n this.offer_type = 'discounts-table'\n } else if (this.offer.get.products?.length) {\n this.offer_type = 'products'\n } else if (this.offer.get.categories?.length) {\n this.offer_type = 'categories'\n }\n this.modal.setTitle(this.offer_name);\n }\n\n private rememberMe(event) {\n salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);\n }\n\n private addToCart(qty) {\n //todo:: add enhancement, to cover the previous quantity, because if the discount to add two, user already added one before.\n salla.api.withoutNotifier(() => salla.cart.quickAdd(this.productID, qty, this.offer_type)).then(() => this.modal.close())\n }\n\n private getOfferContent() {\n if (this.offer.get.discounts_table) {\n return <div class=\"s-offer-modal-discount-table\">\n <table>\n <tbody>\n {this.offer.get.discounts_table?.map(discount =>\n <tr>\n <td>{discount.text}</td>\n <td class=\"s-offer-modal-discount-table-cell\">\n <salla-button fill=\"outline\" shape=\"btn\" color=\"primary\" size=\"medium\" width=\"normal\"\n onClick={() => this.addToCart(discount.quantity)}>{this.addToCartLabel}</salla-button>\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n }\n else if (this.offer.get.products?.length) {\n return <salla-slider\n type=\"carousel\"\n class={{\"s-offer-modal-slider-centered\": this.offer.get.products?.length <= 2, \"s-offer-modal-slider\": true}}\n id=\"offer-modal-slider\"\n controls-outer\n show-controls={this.offer.get.products?.length <= 2 ? 'false' : 'true'}>\n <div slot='items'>\n {\n this.offer.get.products?.map(product =>\n <div class={{\n \"s-offer-modal-product\": true,\n \"s-offer-modal-slider-item\": true,\n \"s-offer-modal-not-available\": !product.is_available\n }} id={'product_' + product.id} innerHTML={this.productSlot\n .replace(/\\{name\\}/g, product.name)\n .replace(/\\{url\\}/g, product.url)\n .replace(/\\{image\\}/g, product.thumbnail)\n .replace(/\\{price\\}/g, product.has_special_price\n ? '<span class=\"s-offer-modal-product-sale-price\">' + salla.money(product.price) + '</span><span class=\"s-offer-modal-product-old-price\">' + salla.money(product.regular_price) + '</span>'\n : salla.money(product.price))}>\n <div class=\"s-offer-modal-btn-wrap\">\n <salla-button width=\"wide\" fill='outline' data-id={product.id} disabled={!product.is_available}\n loader-position=\"center\" onClick={this.addItem}>\n {product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')}\n </salla-button>\n </div>\n </div>)\n }\n </div>\n </salla-slider>\n }\n else if (this.offer.get.categories?.length) {\n return <salla-slider\n type=\"carousel\"\n class={{\"s-offer-modal-slider-centered\": this.offer.get.categories?.length <= 2, \"s-offer-modal-slider\": true}}\n id=\"offer-modal-slider\"\n controls-outer\n show-controls={this.offer.get.categories?.length <= 2 ? 'false' : 'true'}>\n <div slot='items'>\n {\n this.offer.get.categories.map(category =>\n <a href={category.urls.customer} class=\"s-offer-modal-badge s-offer-modal-slider-item s-offer-modal-cat-item\" innerHTML={\n this.categorySlot\n .replace(/\\{tagIcon\\}/g, Tag)\n .replace(/\\{name\\}/g, category.name)\n .replace(/\\{url\\}/g, category.urls.customer)\n }>\n </a>\n )}\n </div>\n </salla-slider>\n }\n }\n\n //todo:: pass event then use sallaButton from it\n private addItem() {\n // this here, is sallaButton\n this['load']();\n return salla.cart.api\n .quickAdd(this['dataset'].id)\n .finally(() => this['stop']());\n }\n\n private defaultProductSlot() {\n return '<a href={url} class=\"s-offer-modal-product-image-wrap\"><img class=\"s-offer-modal-product-image\" src=\"{image}\" /></a>' +\n '<div class=\"s-offer-modal-product-info\">' +\n ' <a href={url} class=\"s-offer-modal-product-name\">{name}</a>' +\n ' <div class=\"s-offer-modal-product-price\">{price}</div>' +\n '</div>';\n }\n\n render() {\n return <salla-modal has-skeleton sub-title={this.offer_message} ref={modal => this.modal = modal}\n isLoading={true} class={`s-offer-modal-type-${this.offer_type ? this.offer_type : ''}`}>\n <div slot='loading'>\n <div class=\"s-offer-modal-skeleton\">\n <div class=\"s-offer-modal-skeleton-header\">\n <salla-skeleton type='circle' height='80px' width='80px'></salla-skeleton>\n <salla-skeleton height='15px' width='50%'></salla-skeleton>\n <salla-skeleton height='10px' width='30%'></salla-skeleton>\n </div>\n <div class=\"s-offer-modal-skeleton-items\">\n {[...Array(3)].map(() =>\n <div class=\"s-offer-modal-skeleton-item\">\n <salla-skeleton height='9rem'></salla-skeleton>\n <div class=\"s-offer-modal-skeleton-item-title\">\n <salla-skeleton height='15px' width='100%'></salla-skeleton>\n </div>\n <div class=\"s-offer-modal-skeleton-item-subtitle\">\n <salla-skeleton height='9px' width='50%'></salla-skeleton>\n <div innerHTML={Cart2}></div>\n </div>\n </div>\n )}\n </div>\n <div class=\"s-offer-modal-skeleton-footer\">\n <salla-skeleton height='15px' width='50%'></salla-skeleton>\n <salla-skeleton height='15px' width='30%'></salla-skeleton>\n </div>\n </div>\n </div>\n {!this.hasError && this.offer !== null\n\n ? [<span slot='icon' class=\"s-offer-modal-header-icon\" innerHTML={SpecialDiscountIcon}></span>,\n this.getOfferContent(),\n <div class=\"s-offer-modal-footer\" slot=\"footer\">\n {this.offer.formatted_date ?\n <p\n class=\"s-offer-modal-expiry\">{salla.lang.get('pages.products.offer_expires_in')} {this.offer.formatted_date}</p>\n : ''}\n <label class=\"s-offer-modal-remember-label\">\n <input type=\"checkbox\" onChange={e => this.rememberMe(e)} class=\"s-offer-modal-remember-input\" />\n {salla.lang.get('common.elements.remember_my_choice')}\n </label>\n </div>,\n ] :\n <salla-placeholder class=\"s-loyalty-placeholder\" alignment=\"center\">\n {!!this.errorMessage ? <span slot=\"description\">{this.errorMessage}</span> : ''}\n </salla-placeholder>\n }\n </salla-modal>\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-offer-modal.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,EAAE;;MCgBhBA,iBAAe;EAa1B;;;;iBAR+B,IAAI;;;oBAGN,KAAK;;;;6BAyBI,KAAK;0BACT,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC;IApBxE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;MAC9D,IAAI,CAAC,iBAAiB,GAAG,I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AEV,CAAA;GACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaOfferModal"],"sources":["src/components/salla-offer-modal/salla-offer-modal.scss?tag=salla-offer-modal","src/components/salla-offer-modal/salla-offer-modal.tsx"],"sourcesContent":["/*\n* Salla Offer Modal Component: popup modal to display the offers\n* You can use these classes to target the elements in the component.\n*/\n\n.s-offer-modal {\n &-body {\n \n }\n &-badge {\n &-icon {\n\n }\n &-text {\n\n }\n }\n &-product {\n &-image-wrap {\n\n }\n &-image {\n\n }\n &-info {\n\n }\n &-name {\n\n }\n &-price {\n\n }\n &-old-price {\n\n }\n }\n &-btn-wrap {\n\n }\n &-footer {\n\n }\n &-expiry {\n\n }\n &-remember-label {\n\n }\n &-remember-input {\n\n }\n &-scrolled-slider-wrap {\n\n }\n &-slider-nav {\n\n }\n &-nav-btn {\n\n }\n &-nav-btn-icon {\n\n }\n &-next-btn {\n \n }\n &-prev-btn {\n \n }\n &-btn-is-active {\n\n }\n}","import { Component, h, Element, Method, State } from '@stencil/core';\nimport Offer from \"./offer-schema\";\nimport SpecialDiscountIcon from '../../assets/svg/special-discount.svg';\nimport Tag from \"../../assets/svg/tag.svg\";\nimport Cart2 from '../../assets/svg/cart2.svg';\n\n/**\n * @slot header - The top of the popup, has replaceable props `{name}`, `{message}`.\n * @slot product - Replaces product card, has replaceable props `{name}`, `{url}`, `{image}`, `{price}`.\n * @slot category - Replaces Category badge, has replaceable props `{name}`, `{url}`.\n */\n@Component({\n tag: 'salla-offer-modal',\n styleUrl: 'salla-offer-modal.scss'\n})\n\nexport class SallaOfferModal {\n// private productSlot: string;\n private categorySlot: string;\n private modal: HTMLSallaModalElement;\n @Element() host: HTMLElement;\n @State() offer: null | Offer = null;\n @State() offer_name: string;\n @State() offer_message: string;\n @State() hasError: boolean = false;\n @State() errorMessage: string;\n @State() productID: number;\n @State() offer_type: string;\n\n constructor() {\n salla.event.on('offer-modal::open', product_id => this.open(product_id));\n\n salla.lang.onLoaded(() => {\n this.addToCartLabel = salla.lang.get(\"pages.cart.add_to_cart\")\n this.translationLoaded = true;\n });\n\n this.categorySlot = this.host.querySelector('[slot=\"category\"]')?.innerHTML || `<span class=\"s-offer-modal-badge-icon\">{tagIcon}</span><span class=\"s-offer-modal-badge-text\">{name}</span>`;\n // this.productSlot = this.host.querySelector('[slot=\"product\"]')?.innerHTML || this.defaultProductSlot();\n salla.event.on('offer-modal::open', product_id => this.open(product_id));\n salla.product.event.onOfferExisted(offer => {\n if (salla.storage.get('remember-offer-' + offer.id)) {\n salla.log('User selected to don\\'t show this offer again.');\n return;\n }\n this.open(offer.product_id);\n });\n }\n\n @State() translationLoaded: boolean = false;\n @State() addToCartLabel: string = salla.lang.get(\"pages.cart.add_to_cart\");\n\n /**\n * Show the available offers for the product\n * @param product_id\n */\n @Method()\n async open(product_id: number) {\n this.productID = product_id;\n //TODO:: make sure there is only one offer\n\n this.hasError = false;\n this.modal.open()\n return await salla.api.withoutNotifier(() => salla.product.offers(product_id))\n .then(response => this.showOffer(response.data[0]))\n .catch(e => {\n this.hasError = true;\n this.errorMessage = e.response?.data?.error?.message || e.response?.data;\n })\n .finally(() => setTimeout(() => this.modal.stopLoading(), 1000));\n }\n\n /**\n * Show offer details\n * @param {Offer} offer\n */\n @Method()\n async showOffer(offer) {\n this.offer = offer;\n this.offer_name = offer.name;\n this.offer_message = offer.message;\n if (this.offer.get.discounts_table) {\n this.offer_type = 'discounts-table'\n } else if (this.offer.get.products?.length) {\n this.offer_type = 'products'\n } else if (this.offer.get.categories?.length) {\n this.offer_type = 'categories'\n }\n this.modal.setTitle(this.offer_name);\n }\n\n private rememberMe(event) {\n salla.storage.set('remember-offer-' + this.offer.id, event.target.checked);\n }\n\n private addToCart(qty) {\n //todo:: add enhancement, to cover the previous quantity, because if the discount to add two, user already added one before.\n salla.api.withoutNotifier(() => salla.cart.quickAdd(this.productID, qty, this.offer_type)).then(() => this.modal.close())\n }\n\n private getOfferContent() {\n if (this.offer.get.discounts_table) {\n return <div class=\"s-offer-modal-discount-table\">\n <table>\n <tbody>\n {this.offer.get.discounts_table?.map(discount =>\n <tr>\n <td>{discount.text}</td>\n <td class=\"s-offer-modal-discount-table-cell\">\n <salla-button fill=\"outline\" shape=\"btn\" color=\"primary\" size=\"medium\" width=\"normal\"\n onClick={() => this.addToCart(discount.quantity)}>{this.addToCartLabel}</salla-button>\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n }\n else if (this.offer.get.products?.length) {\n return (\n <salla-products-slider\n source=\"selected\"\n source-value={`[${(this.offer.get.products?.map(product => product.id) || []).join(\",\")}]`}\n slider-config='{\"slidesPerView\": 1, \"spaceBetween\": 16, \"breakpoints\": { \"768\": { \"slidesPerView\": 2 }, \"1024\": { \"slidesPerView\": 3 } }}'\n ></salla-products-slider>\n );\n // return <salla-slider\n // type=\"carousel\"\n // class={{\"s-offer-modal-slider-centered\": this.offer.get.products?.length <= 2, \"s-offer-modal-slider\": true}}\n // id=\"offer-modal-slider\"\n // controls-outer\n // show-controls={this.offer.get.products?.length <= 2 ? 'false' : 'true'}>\n // <div slot='items'>\n // {\n // this.offer.get.products?.map(product =>\n // <div class={{\n // \"s-offer-modal-product\": true,\n // \"s-offer-modal-slider-item\": true,\n // \"s-offer-modal-not-available\": !product.is_available\n // }} id={'product_' + product.id} innerHTML={this.productSlot\n // .replace(/\\{name\\}/g, product.name)\n // .replace(/\\{url\\}/g, product.url)\n // .replace(/\\{image\\}/g, product.thumbnail)\n // .replace(/\\{price\\}/g, product.has_special_price\n // ? '<span class=\"s-offer-modal-product-sale-price\">' + salla.money(product.price) + '</span><span class=\"s-offer-modal-product-old-price\">' + salla.money(product.regular_price) + '</span>'\n // : salla.money(product.price))}>\n // <div class=\"s-offer-modal-btn-wrap\">\n // <salla-button width=\"wide\" fill='outline' data-id={product.id} disabled={!product.is_available}\n // loader-position=\"center\" onClick={this.addItem}>\n // {product.is_available ? salla.lang.get('pages.cart.add_to_cart') : salla.lang.get('pages.products.out_of_stock')}\n // </salla-button>\n // </div>\n // </div>)\n // }\n // </div>\n // </salla-slider>\n }\n else if (this.offer.get.categories?.length) {\n return <salla-slider\n type=\"carousel\"\n class={{\"s-offer-modal-slider-centered\": this.offer.get.categories?.length <= 2, \"s-offer-modal-slider\": true}}\n id=\"offer-modal-slider\"\n controls-outer\n show-controls={this.offer.get.categories?.length <= 2 ? 'false' : 'true'}>\n <div slot='items'>\n {\n this.offer.get.categories.map(category =>\n <a href={category.urls.customer} class=\"s-offer-modal-badge s-offer-modal-slider-item s-offer-modal-cat-item\" innerHTML={\n this.categorySlot\n .replace(/\\{tagIcon\\}/g, Tag)\n .replace(/\\{name\\}/g, category.name)\n .replace(/\\{url\\}/g, category.urls.customer)\n }>\n </a>\n )}\n </div>\n </salla-slider>\n }\n }\n\n //todo:: pass event then use sallaButton from it\n// private addItem() {\n// // this here, is sallaButton\n// this['load']();\n// return salla.cart.api\n// .quickAdd(this['dataset'].id)\n// .finally(() => this['stop']());\n// }\n\n// private defaultProductSlot() {\n// return '<a href={url} class=\"s-offer-modal-product-image-wrap\"><img class=\"s-offer-modal-product-image\" src=\"{image}\" /></a>' +\n// '<div class=\"s-offer-modal-product-info\">' +\n// ' <a href={url} class=\"s-offer-modal-product-name\">{name}</a>' +\n// ' <div class=\"s-offer-modal-product-price\">{price}</div>' +\n// '</div>';\n// }\n\n render() {\n return <salla-modal has-skeleton sub-title={this.offer_message} ref={modal => this.modal = modal}\n isLoading={true} class={`s-offer-modal-type-${this.offer_type ? this.offer_type : ''}`}>\n <div slot='loading'>\n <div class=\"s-offer-modal-skeleton\">\n <div class=\"s-offer-modal-skeleton-header\">\n <salla-skeleton type='circle' height='80px' width='80px'></salla-skeleton>\n <salla-skeleton height='15px' width='50%'></salla-skeleton>\n <salla-skeleton height='10px' width='30%'></salla-skeleton>\n </div>\n <div class=\"s-offer-modal-skeleton-items\">\n {[...Array(3)].map(() =>\n <div class=\"s-offer-modal-skeleton-item\">\n <salla-skeleton height='9rem'></salla-skeleton>\n <div class=\"s-offer-modal-skeleton-item-title\">\n <salla-skeleton height='15px' width='100%'></salla-skeleton>\n </div>\n <div class=\"s-offer-modal-skeleton-item-subtitle\">\n <salla-skeleton height='9px' width='50%'></salla-skeleton>\n <div innerHTML={Cart2}></div>\n </div>\n </div>\n )}\n </div>\n <div class=\"s-offer-modal-skeleton-footer\">\n <salla-skeleton height='15px' width='50%'></salla-skeleton>\n <salla-skeleton height='15px' width='30%'></salla-skeleton>\n </div>\n </div>\n </div>\n {!this.hasError && this.offer !== null\n\n ? [<span slot='icon' class=\"s-offer-modal-header-icon\" innerHTML={SpecialDiscountIcon}></span>,\n this.getOfferContent(),\n <div class=\"s-offer-modal-footer\" slot=\"footer\">\n {this.offer.formatted_date ?\n <p\n class=\"s-offer-modal-expiry\">{salla.lang.get('pages.products.offer_expires_in')} {this.offer.formatted_date}</p>\n : ''}\n <label class=\"s-offer-modal-remember-label\">\n <input type=\"checkbox\" onChange={e => this.rememberMe(e)} class=\"s-offer-modal-remember-input\" />\n {salla.lang.get('common.elements.remember_my_choice')}\n </label>\n </div>,\n ] :\n <salla-placeholder class=\"s-loyalty-placeholder\" alignment=\"center\">\n {!!this.errorMessage ? <span slot=\"description\">{this.errorMessage}</span> : ''}\n </salla-placeholder>\n }\n </salla-modal>\n }\n}\n"],"version":3}
|
|
@@ -1,212 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { H as Helper } from './Helper.js';
|
|
6
|
-
import { d as defineCustomElement$c } from './salla-add-product-button2.js';
|
|
7
|
-
import { d as defineCustomElement$b } from './salla-button2.js';
|
|
8
|
-
import { d as defineCustomElement$a } from './salla-count-down2.js';
|
|
9
|
-
import { d as defineCustomElement$9 } from './salla-loading2.js';
|
|
10
|
-
import { d as defineCustomElement$8 } from './salla-modal2.js';
|
|
11
|
-
import { d as defineCustomElement$7 } from './salla-product-availability2.js';
|
|
12
|
-
import { d as defineCustomElement$6 } from './salla-product-card2.js';
|
|
13
|
-
import { d as defineCustomElement$5 } from './salla-progress-bar2.js';
|
|
14
|
-
import { d as defineCustomElement$4 } from './salla-quick-buy2.js';
|
|
15
|
-
import { d as defineCustomElement$3 } from './salla-slider2.js';
|
|
16
|
-
import { d as defineCustomElement$2 } from './salla-tel-input2.js';
|
|
17
|
-
|
|
18
|
-
const sallaProductsSliderCss = "";
|
|
19
|
-
|
|
20
|
-
const SallaProductsSlider$1 = /*@__PURE__*/ proxyCustomElement(class SallaProductsSlider extends HTMLElement {
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
this.__registerHost();
|
|
24
|
-
this.blockTitle = undefined;
|
|
25
|
-
this.subTitle = undefined;
|
|
26
|
-
this.sliderId = undefined;
|
|
27
|
-
this.displayAllUrl = undefined;
|
|
28
|
-
this.autoplay = undefined;
|
|
29
|
-
this.source = undefined;
|
|
30
|
-
this.sourceValue = undefined;
|
|
31
|
-
this.limit = undefined;
|
|
32
|
-
this.sliderConfig = undefined;
|
|
33
|
-
this.productCardComponent = 'custom-salla-product-card';
|
|
34
|
-
this.includes = undefined;
|
|
35
|
-
this.productsData = undefined;
|
|
36
|
-
this.isReady = undefined;
|
|
37
|
-
this.sourceValueIsValid = undefined;
|
|
38
|
-
this.hasCustomComponent = undefined;
|
|
39
|
-
this.apiUrl = '';
|
|
40
|
-
this.parsedSourceValue = undefined;
|
|
41
|
-
}
|
|
42
|
-
componentWillLoad() {
|
|
43
|
-
return salla.onReady()
|
|
44
|
-
.then(() => {
|
|
45
|
-
//TODO:: check why `this.includes` not working!!
|
|
46
|
-
this.includes = Helper.parseJson(this.includes || this.host.getAttribute('includes'));
|
|
47
|
-
if (!Array.isArray(this.includes)) {
|
|
48
|
-
this.includes = null;
|
|
49
|
-
}
|
|
50
|
-
Helper.setIncludes(this.includes);
|
|
51
|
-
this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
|
|
52
|
-
if (!this.sourceValueIsValid) {
|
|
53
|
-
salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.hasCustomComponent = !!customElements.get(this.productCardComponent);
|
|
57
|
-
if (this.source === 'json') {
|
|
58
|
-
this.productsData = this.getSourceValue();
|
|
59
|
-
this.isReady = true;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if ((this.getSource() == 'related' && !salla.config.get('store.settings.product.related_products_enabled'))) {
|
|
63
|
-
this.isReady = false;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
return salla.product.api.fetch({ source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit })
|
|
67
|
-
.then(response => Helper.injectExtraFieldsToResponse(response))
|
|
68
|
-
.then(response => {
|
|
69
|
-
this.productsData = response.data;
|
|
70
|
-
this.isReady = true;
|
|
71
|
-
salla.event.emit('salla-products-slider::products.fetched', response.data);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
componentDidRender() {
|
|
76
|
-
let processedCount = 0;
|
|
77
|
-
const intervalId = setInterval(() => {
|
|
78
|
-
var _a;
|
|
79
|
-
(_a = this.host.querySelectorAll('[loading="lazy"]')) === null || _a === void 0 ? void 0 : _a.forEach(img => img.removeAttribute('loading'));
|
|
80
|
-
processedCount++;
|
|
81
|
-
if (processedCount >= 10) {
|
|
82
|
-
clearInterval(intervalId);
|
|
83
|
-
}
|
|
84
|
-
}, 1000);
|
|
85
|
-
}
|
|
86
|
-
isSourceWithoutValue() {
|
|
87
|
-
return ['offers', 'latest', 'sales', 'top-rated'].includes(this.getSource());
|
|
88
|
-
}
|
|
89
|
-
getItemHTML(product) {
|
|
90
|
-
//as a request they don't want to let the user to open the product details
|
|
91
|
-
//todo:: find a better way to handle this request
|
|
92
|
-
this.getSource() === 'landing-page' && (product.url = '');
|
|
93
|
-
if (this.hasCustomComponent && this.productCardComponent.toLowerCase() == 'custom-salla-product-card') {
|
|
94
|
-
return h("div", { class: "s-products-slider-card" }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
|
|
95
|
-
}
|
|
96
|
-
if (this.hasCustomComponent) {
|
|
97
|
-
const customElem = document.createElement(this.productCardComponent);
|
|
98
|
-
customElem.setAttribute('product', JSON.stringify(product));
|
|
99
|
-
customElem.setAttribute('source', this.getSource());
|
|
100
|
-
customElem.setAttribute('source-value', this.getSourceValue());
|
|
101
|
-
return h("div", { class: "s-products-slider-card", innerHTML: customElem.outerHTML });
|
|
102
|
-
}
|
|
103
|
-
return h("div", { class: "s-products-slider-card" }, h("salla-product-card", { "show-quantity": this.getSource() == 'landing-page', "hide-add-btn": this.getSource() == 'landing-page', "shadow-on-hover": true, product: product }));
|
|
104
|
-
}
|
|
105
|
-
canRender() {
|
|
106
|
-
return this.sourceValueIsValid && this.isReady;
|
|
107
|
-
}
|
|
108
|
-
getSource() {
|
|
109
|
-
return Helper.getProductsSource(this.source);
|
|
110
|
-
}
|
|
111
|
-
getSourceValue() {
|
|
112
|
-
return Helper.getProductsSourceValue(this.source, this.sourceValue);
|
|
113
|
-
}
|
|
114
|
-
render() {
|
|
115
|
-
var _a;
|
|
116
|
-
if (!this.canRender()) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
return (h(Host, { class: "s-products-slider-wrapper" }, h("salla-slider", { class: "s-products-slider-slider", id: this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`, "auto-play": this.autoplay, type: "carousel", "block-title": this.blockTitle, "block-subTitle": this.subTitle, "display-all-url": this.displayAllUrl, sliderConfig: this.sliderConfig ? this.sliderConfig : null }, h("div", { slot: "items" }, (_a = this.productsData) === null || _a === void 0 ? void 0 : _a.map(product => this.getItemHTML(product))))));
|
|
120
|
-
}
|
|
121
|
-
get host() { return this; }
|
|
122
|
-
static get style() { return sallaProductsSliderCss; }
|
|
123
|
-
}, [0, "salla-products-slider", {
|
|
124
|
-
"blockTitle": [1, "block-title"],
|
|
125
|
-
"subTitle": [1, "sub-title"],
|
|
126
|
-
"sliderId": [1, "slider-id"],
|
|
127
|
-
"displayAllUrl": [1, "display-all-url"],
|
|
128
|
-
"autoplay": [1028],
|
|
129
|
-
"source": [1537],
|
|
130
|
-
"sourceValue": [1, "source-value"],
|
|
131
|
-
"limit": [1026],
|
|
132
|
-
"sliderConfig": [520, "slider-config"],
|
|
133
|
-
"productCardComponent": [1, "product-card-component"],
|
|
134
|
-
"includes": [1040],
|
|
135
|
-
"productsData": [32],
|
|
136
|
-
"isReady": [32],
|
|
137
|
-
"sourceValueIsValid": [32],
|
|
138
|
-
"hasCustomComponent": [32],
|
|
139
|
-
"apiUrl": [32],
|
|
140
|
-
"parsedSourceValue": [32]
|
|
141
|
-
}]);
|
|
142
|
-
function defineCustomElement$1() {
|
|
143
|
-
if (typeof customElements === "undefined") {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const components = ["salla-products-slider", "salla-add-product-button", "salla-button", "salla-count-down", "salla-loading", "salla-modal", "salla-product-availability", "salla-product-card", "salla-progress-bar", "salla-quick-buy", "salla-slider", "salla-tel-input"];
|
|
147
|
-
components.forEach(tagName => { switch (tagName) {
|
|
148
|
-
case "salla-products-slider":
|
|
149
|
-
if (!customElements.get(tagName)) {
|
|
150
|
-
customElements.define(tagName, SallaProductsSlider$1);
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
case "salla-add-product-button":
|
|
154
|
-
if (!customElements.get(tagName)) {
|
|
155
|
-
defineCustomElement$c();
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
case "salla-button":
|
|
159
|
-
if (!customElements.get(tagName)) {
|
|
160
|
-
defineCustomElement$b();
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case "salla-count-down":
|
|
164
|
-
if (!customElements.get(tagName)) {
|
|
165
|
-
defineCustomElement$a();
|
|
166
|
-
}
|
|
167
|
-
break;
|
|
168
|
-
case "salla-loading":
|
|
169
|
-
if (!customElements.get(tagName)) {
|
|
170
|
-
defineCustomElement$9();
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case "salla-modal":
|
|
174
|
-
if (!customElements.get(tagName)) {
|
|
175
|
-
defineCustomElement$8();
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
case "salla-product-availability":
|
|
179
|
-
if (!customElements.get(tagName)) {
|
|
180
|
-
defineCustomElement$7();
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
case "salla-product-card":
|
|
184
|
-
if (!customElements.get(tagName)) {
|
|
185
|
-
defineCustomElement$6();
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
case "salla-progress-bar":
|
|
189
|
-
if (!customElements.get(tagName)) {
|
|
190
|
-
defineCustomElement$5();
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
case "salla-quick-buy":
|
|
194
|
-
if (!customElements.get(tagName)) {
|
|
195
|
-
defineCustomElement$4();
|
|
196
|
-
}
|
|
197
|
-
break;
|
|
198
|
-
case "salla-slider":
|
|
199
|
-
if (!customElements.get(tagName)) {
|
|
200
|
-
defineCustomElement$3();
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
203
|
-
case "salla-tel-input":
|
|
204
|
-
if (!customElements.get(tagName)) {
|
|
205
|
-
defineCustomElement$2();
|
|
206
|
-
}
|
|
207
|
-
break;
|
|
208
|
-
} });
|
|
209
|
-
}
|
|
4
|
+
import { S as SallaProductsSlider$1, d as defineCustomElement$1 } from './salla-products-slider2.js';
|
|
210
5
|
|
|
211
6
|
const SallaProductsSlider = SallaProductsSlider$1;
|
|
212
7
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-products-slider.js","mappings":";;;;;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,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AC,0BAA0B,EAChC,EAAE,EAAE,IAAI,CAAC,QAAQ,IAAI,qBAAqB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,eACxE,IAAI,CAAC,QAAQ,EACxB,IAAI,EAAC,UAAU,iBACF,IAAI,CAAC,UAAU,oBACZ,IAAI,CAAC,QAAQ,qBACZ,IAAI,CAAC,aAAa,EACnC,YAAY,EAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,IAE1D,WAAK,IAAI,EAAC,OAAO,IACd,MAAA,IAAI,CAAC,YAAY,0CAAE,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CACzD,CACO,CACV,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaProductsSlider"],"sources":["src/components/salla-products-slider/salla-products-slider.scss?tag=salla-products-slider","src/components/salla-products-slider/salla-products-slider.tsx"],"sourcesContent":[".s-products-slider{\n &-wrapper{\n\n }\n &-slider{\n\n }\n &-card{\n\n }\n}","import { Component, Host, h, Prop, Element, State } from '@stencil/core';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-slider',\n styleUrl: 'salla-products-slider.scss'\n})\n\n//todo:: extends this component from salla-products-list or the opposite\nexport class SallaProductsSlider {\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * autoplay option for products slider\n */\n @Prop({ mutable: true }) autoplay: boolean\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'wishlist' | 'top-rated';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Slider Configs refer to https://swiperjs.com/swiper-api#parameters and pass the entire config object\n * @example\n * let productsSlider = document.querySelector('salla-products-slider');\n * productsSlider.sliderConfig = {\n * slidesPerView: 1,\n * spaceBetween : 30,\n * lazy: true,\n * }\n *\n */\n @Prop({ reflect: true }) sliderConfig: any;\n\n /**\n * Custom Card Component for the Salla Products Slider.\n *\n * This component allows you to customize the appearance of individual product cards within a Salla Products Slider.\n *\n * @example\n * <salla-products-slider product-card-component=\"my-custom-card-style1\" ...\n * <salla-products-slider product-card-component=\"my-custom-card-style2\" ...\n */\n @Prop() productCardComponent: string = 'custom-salla-product-card';\n\n /**\n * Specifies additional data to be included in the product fetch response.\n * The value can be an array of strings or a JSON string.\n * \n * Example:\n * - As an array: includes=[\"options\"]\n * - As a JSON string: includes='[\"options\"]'\n * \n * The array or JSON string can include:\n * - \"options\": Include product options in the response.\n * - \"images\": Include product images in the response.\n */\n @Prop({mutable: true}) includes: string[];\n\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n\n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n //TODO:: check why `this.includes` not working!!\n this.includes = Helper.parseJson(this.includes||this.host.getAttribute('includes'));\n if (!Array.isArray(this.includes)) {\n this.includes = null;\n }\n Helper.setIncludes(this.includes);\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()\n }]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get(this.productCardComponent);\n\n if (this.source === 'json') {\n this.productsData = this.getSourceValue();\n this.isReady = true\n return;\n }\n\n if ((this.getSource() == 'related' && !salla.config.get('store.settings.product.related_products_enabled'))) {\n this.isReady = false\n return;\n }\n\n return salla.product.api.fetch({source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit})\n .then(response => Helper.injectExtraFieldsToResponse(response))\n .then(response => {\n this.productsData = response.data;\n this.isReady = true;\n salla.event.emit('salla-products-slider::products.fetched', response.data);\n });\n });\n }\n componentDidRender() {\n let processedCount = 0;\n const intervalId = setInterval(() => {\n this.host.querySelectorAll('[loading=\"lazy\"]')?.forEach(img => img.removeAttribute('loading'));\n processedCount++;\n if (processedCount >= 10) {\n clearInterval(intervalId);\n }\n }, 1000);\n }\n\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales', 'top-rated'].includes(this.getSource());\n }\n\n private getItemHTML(product) {\n\n //as a request they don't want to let the user to open the product details\n //todo:: find a better way to handle this request\n this.getSource() === 'landing-page' && (product.url = '');\n if (this.hasCustomComponent && this.productCardComponent.toLowerCase() == 'custom-salla-product-card') {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.getSource()} source-value={this.getSourceValue()} />\n </div>\n }\n\n if (this.hasCustomComponent) {\n const customElem = document.createElement(this.productCardComponent);\n customElem.setAttribute('product', JSON.stringify(product));\n customElem.setAttribute('source', this.getSource());\n customElem.setAttribute('source-value', this.getSourceValue());\n\n return <div class=\"s-products-slider-card\" innerHTML={customElem.outerHTML} />;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.getSource() == 'landing-page'}\n hide-add-btn={this.getSource() == 'landing-page'}\n shadow-on-hover={true}\n product={product} />\n </div>;\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n render() {\n if (!this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n auto-play={this.autoplay}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n sliderConfig={this.sliderConfig ? this.sliderConfig : null}\n >\n <div slot=\"items\">\n {this.productsData?.map(product => this.getItemHTML(product))}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-products-slider.js","mappings":";;;;;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
|