@salla.sa/twilight-components 2.14.349 → 2.14.351
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/{Helper-B5NunIdR.js → Helper-DHRnzcFm.js} +14 -0
- package/dist/cjs/{filepond-DFhbfTkt.js → filepond-DmgB2usw.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-Dj4Zm459.js → filepond-plugin-file-poster-Qz9yBcC6.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DsH6GzKJ.js → filepond-plugin-file-validate-size-BpxufYGC.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-DfaEudMs.js → filepond-plugin-file-validate-type-DPpMnDuU.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-gz-CV83v.js → filepond-plugin-image-edit-DSig_Hnr.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-DfkLjcpx.js → filepond-plugin-image-exif-orientation-BdyyWkN_.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-BxaEwNCI.js → filepond-plugin-image-preview-ClN5AjHL.js} +1 -1
- package/dist/cjs/{index-C9ymZIiv.js → index-ByiRU---.js} +1 -1
- package/dist/cjs/{index-DcTksD2K.js → index-wroCOFea.js} +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_62.cjs.entry.js +83 -52
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
- package/dist/cjs/salla-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +2 -2
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +2 -2
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews-page.cjs.entry.js +2 -2
- package/dist/cjs/salla-reviews.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-BYDLZw1n.js → vanilla-picker-Dud2hHSp.js} +1 -1
- package/dist/collection/Helpers/Helper.js +14 -0
- package/dist/collection/components/salla-product-options/salla-product-options.js +44 -10
- package/dist/collection/components/salla-products-list/salla-products-list.js +9 -22
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +9 -7
- package/dist/collection/components/salla-slider/salla-slider.js +15 -7
- package/dist/components/Helper.js +14 -0
- package/dist/components/index.js +2 -2
- package/dist/components/salla-product-options2.js +44 -10
- package/dist/components/salla-products-list2.js +7 -20
- package/dist/components/salla-products-slider2.js +7 -5
- package/dist/components/salla-slider2.js +15 -7
- package/dist/esm/{Helper-Bt5Zv9cl.js → Helper-B5RLi6Xo.js} +14 -0
- package/dist/esm/{filepond-DQR2YBu7.js → filepond-BcVCWOQQ.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-XvYa1rlk.js → filepond-plugin-file-poster-B6OLqzjJ.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-BRBnctOE.js → filepond-plugin-file-validate-size-BCifsMdp.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-BuD6F1gi.js → filepond-plugin-file-validate-type-BzRNZ2wk.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-BJ8YnBRL.js → filepond-plugin-image-edit-Dvu8RWud.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-BGad_AoX.js → filepond-plugin-image-exif-orientation-DtlS_Id7.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-Cb6UzPfa.js → filepond-plugin-image-preview-DRaZsLxF.js} +1 -1
- package/dist/esm/{index-DIfeuyTs.js → index-BT5aIJiI.js} +1 -1
- package/dist/esm/{index-Bhszo8cU.js → index-D8IUoDXw.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_62.entry.js +83 -52
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +2 -2
- package/dist/esm/salla-filters.entry.js +2 -2
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +2 -2
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +2 -2
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-review-card.entry.js +1 -1
- package/dist/esm/salla-reviews-page.entry.js +2 -2
- package/dist/esm/salla-reviews.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-C4Kwbr5L.js → vanilla-picker-BPR2c_5J.js} +1 -1
- package/dist/twilight/{p-0daa34c4.entry.js → p-0fb07494.entry.js} +1 -1
- package/dist/twilight/{p-5bb9ace5.entry.js → p-1d6ae0cd.entry.js} +1 -1
- package/dist/twilight/{p-a25fe3c1.entry.js → p-234d4270.entry.js} +1 -1
- package/dist/twilight/{p-f4bf39fb.entry.js → p-2986242d.entry.js} +1 -1
- package/dist/twilight/p-319d0ee6.entry.js +4 -0
- package/dist/twilight/{p-112e9574.entry.js → p-403fc5a0.entry.js} +1 -1
- package/dist/twilight/{p-574bd55f.entry.js → p-44c225e2.entry.js} +1 -1
- package/dist/twilight/{p-64c18854.entry.js → p-46095c81.entry.js} +1 -1
- package/dist/twilight/{p-66c5dcd3.entry.js → p-4a269d95.entry.js} +1 -1
- package/dist/twilight/{p-a6f250b8.entry.js → p-53bbd4e8.entry.js} +1 -1
- package/dist/twilight/{p-7a706d50.entry.js → p-5a27fc24.entry.js} +1 -1
- package/dist/twilight/{p-a5df8334.entry.js → p-5e83dab1.entry.js} +1 -1
- package/dist/twilight/{p-b0abcc89.entry.js → p-6961de25.entry.js} +1 -1
- package/dist/twilight/{p-ed0f40e2.entry.js → p-88aa8e1c.entry.js} +1 -1
- package/dist/twilight/{p-ae93ed50.entry.js → p-8af29c6e.entry.js} +1 -1
- package/dist/twilight/{p-de290cc2.entry.js → p-8d0e34f8.entry.js} +1 -1
- package/dist/twilight/{p-cc43a1bd.entry.js → p-97d6ac02.entry.js} +1 -1
- package/dist/twilight/{p-6222b0fa.entry.js → p-993dff37.entry.js} +1 -1
- package/dist/twilight/{p-004be2ff.entry.js → p-9a6195f6.entry.js} +1 -1
- package/dist/twilight/{p-129e02c2.entry.js → p-9ab1a8dd.entry.js} +1 -1
- package/dist/twilight/{p-af8daa75.entry.js → p-9dc0d7cb.entry.js} +1 -1
- package/dist/twilight/{p-DAM1DKLB.js → p-B1PME38e.js} +1 -1
- package/dist/twilight/{p-ByJhdNbq.js → p-BjevMNf5.js} +1 -1
- package/dist/twilight/{p-B-MyfVCv.js → p-CLCMzFCR.js} +1 -1
- package/dist/twilight/{p-Bhszo8cU.js → p-D8IUoDXw.js} +1 -1
- package/dist/twilight/{p-NTgp-Syt.js → p-DMvcLQlj.js} +1 -1
- package/dist/twilight/{p-CmuTtBET.js → p-DNuuIRPk.js} +1 -1
- package/dist/twilight/p-DgNC8L6e.js +4 -0
- package/dist/twilight/{p-CuNS5C_o.js → p-DhPpUonS.js} +1 -1
- package/dist/twilight/{p-BVmy-j16.js → p-R8UuPKQS.js} +1 -1
- package/dist/twilight/{p-BvldZUSR.js → p-VHxFG8vR.js} +1 -1
- package/dist/twilight/{p-9f541d63.entry.js → p-a0fb9e8d.entry.js} +1 -1
- package/dist/twilight/{p-48617181.entry.js → p-a50658ad.entry.js} +1 -1
- package/dist/twilight/{p-b8a203c1.entry.js → p-af71190f.entry.js} +1 -1
- package/dist/twilight/{p-f3d3e11e.entry.js → p-b4bb7b69.entry.js} +1 -1
- package/dist/twilight/{p-25f64b3e.entry.js → p-c5dc7685.entry.js} +1 -1
- package/dist/twilight/{p-1bfef164.entry.js → p-c8f83a29.entry.js} +1 -1
- package/dist/twilight/{p-55c9e7fe.entry.js → p-cef109da.entry.js} +1 -1
- package/dist/twilight/{p-60747f3b.entry.js → p-d8c30c7b.entry.js} +1 -1
- package/dist/twilight/{p-cadbe7b6.entry.js → p-de74f566.entry.js} +1 -1
- package/dist/twilight/{p-cc6238be.entry.js → p-eb109f9d.entry.js} +1 -1
- package/dist/twilight/{p-48df4495.entry.js → p-ef9334ed.entry.js} +1 -1
- package/dist/twilight/{p-46fb77ce.entry.js → p-faa4c75d.entry.js} +1 -1
- package/dist/twilight/{p-911bbc7d.entry.js → p-fad69d7b.entry.js} +1 -1
- package/dist/twilight/{p-307b5fa0.entry.js → p-ffcfb224.entry.js} +1 -1
- package/dist/twilight/{p-Cy9bcLMa.js → p-mIk_7HE4.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/Helpers/Helper.d.ts +2 -0
- package/dist/types/components/salla-products-list/salla-products-list.d.ts +1 -1
- package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +1 -1
- package/dist/types/components/salla-slider/salla-slider.d.ts +4 -1
- package/dist/types/components.d.ts +4 -4
- package/package.json +5 -5
- package/dist/twilight/p-4fc33cee.entry.js +0 -4
- package/dist/twilight/p-Dljb4XCt.js +0 -4
|
@@ -197,19 +197,6 @@ export class SallaProductsList {
|
|
|
197
197
|
//as a request they don't want to let the user to open the product details
|
|
198
198
|
//todo:: find a better way to handle this request
|
|
199
199
|
this.getSource() === 'landing-page' && (product.url = '');
|
|
200
|
-
try {
|
|
201
|
-
// Add source query param to product URL for tracking in Product Viewed event
|
|
202
|
-
if (this.source && product.url && !product.url.includes('s-product-source=')) {
|
|
203
|
-
const [urlWithoutFragment, fragment] = product.url.split('#');
|
|
204
|
-
const separator = urlWithoutFragment.includes('?') ? '&' : '?';
|
|
205
|
-
const pageSlug = salla.config?.get('page.slug') || 'unknown';
|
|
206
|
-
const sourceValue = `${pageSlug}.${this.source}`;
|
|
207
|
-
product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
Salla.log('Error with source');
|
|
212
|
-
}
|
|
213
200
|
const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
|
|
214
201
|
const productCard = document.createElement(customComponentTag);
|
|
215
202
|
productCard.product = product;
|
|
@@ -217,15 +204,15 @@ export class SallaProductsList {
|
|
|
217
204
|
this.applyHorizontalCardStyles(productCard);
|
|
218
205
|
// Attach click event listener to save the current products snapshot
|
|
219
206
|
productCard.addEventListener('click', (event) => {
|
|
220
|
-
if (!this.hasInfiniteScroll) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
207
|
const target = event.target;
|
|
224
208
|
// Check if the clicked element is an anchor or inside an anchor
|
|
225
209
|
const anchor = target.closest('a');
|
|
226
210
|
if (anchor) {
|
|
227
|
-
this.
|
|
228
|
-
|
|
211
|
+
Helper.saveProductSource(this.getSource());
|
|
212
|
+
if (this.hasInfiniteScroll) {
|
|
213
|
+
this.takeStateSnapshot();
|
|
214
|
+
sessionStorage.setItem(this.lastViewedProductKey, product.id);
|
|
215
|
+
}
|
|
229
216
|
}
|
|
230
217
|
});
|
|
231
218
|
return productCard;
|
|
@@ -555,7 +542,7 @@ export class SallaProductsList {
|
|
|
555
542
|
}
|
|
556
543
|
getInitialData() {
|
|
557
544
|
this.loading();
|
|
558
|
-
return salla.product.api.fetch({ source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit }).then(async (response) => {
|
|
545
|
+
return salla.product.api.fetch({ source: Helper.getApiSource(this.getSource()), source_value: this.getSourceValue(), limit: this.limit }).then(async (response) => {
|
|
559
546
|
if (!response.data.length) {
|
|
560
547
|
this.showPlaceholder = true;
|
|
561
548
|
this.placeholderLoader && this.placeholderLoader.remove();
|
|
@@ -581,7 +568,7 @@ export class SallaProductsList {
|
|
|
581
568
|
.then(() => {
|
|
582
569
|
this.hasCustomComponent = !!customElements.get(this.productCardComponent);
|
|
583
570
|
this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
|
|
584
|
-
this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource()) && !this.limit;
|
|
571
|
+
this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page', 'recently'].includes(this.getSource()) && !this.limit;
|
|
585
572
|
let searchParams = new URLSearchParams(window.location.search);
|
|
586
573
|
try {
|
|
587
574
|
this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
|
|
@@ -773,8 +760,8 @@ export class SallaProductsList {
|
|
|
773
760
|
"attribute": "source",
|
|
774
761
|
"mutable": true,
|
|
775
762
|
"complexType": {
|
|
776
|
-
"original": "'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated' | 'reorder'",
|
|
777
|
-
"resolved": "\"brands\" | \"categories\" | \"json\" | \"landing-page\" | \"latest\" | \"offers\" | \"related\" | \"reorder\" | \"sales\" | \"search\" | \"selected\" | \"tags\" | \"top-rated\" | \"wishlist\"",
|
|
763
|
+
"original": "'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated' | 'reorder' | 'recently'",
|
|
764
|
+
"resolved": "\"brands\" | \"categories\" | \"json\" | \"landing-page\" | \"latest\" | \"offers\" | \"recently\" | \"related\" | \"reorder\" | \"sales\" | \"search\" | \"selected\" | \"tags\" | \"top-rated\" | \"wishlist\"",
|
|
778
765
|
"references": {}
|
|
779
766
|
},
|
|
780
767
|
"required": false,
|
|
@@ -42,7 +42,7 @@ export class SallaProductsSlider {
|
|
|
42
42
|
this.isReady = false;
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
return salla.product.api.fetch({ source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit })
|
|
45
|
+
return salla.product.api.fetch({ source: Helper.getApiSource(this.getSource()), source_value: this.getSourceValue(), limit: this.limit })
|
|
46
46
|
.then(response => Helper.injectExtraFieldsToResponse(response))
|
|
47
47
|
.then(response => {
|
|
48
48
|
this.productsData = response.data;
|
|
@@ -72,18 +72,20 @@ export class SallaProductsSlider {
|
|
|
72
72
|
getItemHTML(product) {
|
|
73
73
|
//as a request they don't want to let the user to open the product details
|
|
74
74
|
//todo:: find a better way to handle this request
|
|
75
|
-
this.getSource() === 'landing-page'
|
|
75
|
+
const isLandingPage = this.getSource() === 'landing-page';
|
|
76
|
+
isLandingPage && (product.url = '');
|
|
77
|
+
const handleClick = isLandingPage ? undefined : () => Helper.saveProductSource(this.getSource());
|
|
76
78
|
if (this.hasCustomComponent && this.productCardComponent.toLowerCase() == 'custom-salla-product-card') {
|
|
77
|
-
return h("div", { class: "s-products-slider-card" }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
|
|
79
|
+
return h("div", { class: "s-products-slider-card", onClick: handleClick }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
|
|
78
80
|
}
|
|
79
81
|
if (this.hasCustomComponent) {
|
|
80
82
|
const customElem = document.createElement(this.productCardComponent);
|
|
81
83
|
customElem.setAttribute('product', JSON.stringify(product));
|
|
82
84
|
customElem.setAttribute('source', this.getSource());
|
|
83
85
|
customElem.setAttribute('source-value', this.getSourceValue());
|
|
84
|
-
return h("div", { class: "s-products-slider-card", innerHTML: customElem.outerHTML });
|
|
86
|
+
return h("div", { class: "s-products-slider-card", onClick: handleClick, innerHTML: customElem.outerHTML });
|
|
85
87
|
}
|
|
86
|
-
return h("div", { class: "s-products-slider-card" }, h("salla-product-card", { "show-quantity":
|
|
88
|
+
return h("div", { class: "s-products-slider-card", onClick: handleClick }, h("salla-product-card", { "show-quantity": isLandingPage, "hide-add-btn": isLandingPage, "shadow-on-hover": true, product: product }));
|
|
87
89
|
}
|
|
88
90
|
canRender() {
|
|
89
91
|
return this.sourceValueIsValid && this.isReady;
|
|
@@ -237,8 +239,8 @@ export class SallaProductsSlider {
|
|
|
237
239
|
"attribute": "source",
|
|
238
240
|
"mutable": true,
|
|
239
241
|
"complexType": {
|
|
240
|
-
"original": "'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'wishlist' | 'top-rated'",
|
|
241
|
-
"resolved": "\"brands\" | \"categories\" | \"json\" | \"landing-page\" | \"latest\" | \"offers\" | \"related\" | \"selected\" | \"tags\" | \"top-rated\" | \"wishlist\"",
|
|
242
|
+
"original": "'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'wishlist' | 'top-rated' | 'recently'",
|
|
243
|
+
"resolved": "\"brands\" | \"categories\" | \"json\" | \"landing-page\" | \"latest\" | \"offers\" | \"recently\" | \"related\" | \"selected\" | \"tags\" | \"top-rated\" | \"wishlist\"",
|
|
242
244
|
"references": {}
|
|
243
245
|
},
|
|
244
246
|
"required": false,
|
|
@@ -89,7 +89,9 @@ export class SallaSlider {
|
|
|
89
89
|
this.currentIndex = undefined;
|
|
90
90
|
this.isEnd = false;
|
|
91
91
|
this.isBeginning = true;
|
|
92
|
-
|
|
92
|
+
/** Use matchMedia instead of window.innerWidth to avoid forced reflow (Lighthouse recommended) */
|
|
93
|
+
this.isDesktopViewport = typeof window !== 'undefined' ? window.matchMedia('(min-width: 768px)').matches : true;
|
|
94
|
+
this.viewportMediaQuery = null;
|
|
93
95
|
this.hasThumbSlot = false;
|
|
94
96
|
this.pre_defined_config = {
|
|
95
97
|
carousel: {
|
|
@@ -133,6 +135,9 @@ export class SallaSlider {
|
|
|
133
135
|
spaceBetween: 30
|
|
134
136
|
}
|
|
135
137
|
};
|
|
138
|
+
this.onViewportChange = (e) => {
|
|
139
|
+
this.isDesktopViewport = e.matches;
|
|
140
|
+
};
|
|
136
141
|
this.direction = this.direction || document.documentElement.dir;
|
|
137
142
|
}
|
|
138
143
|
// Methods
|
|
@@ -429,11 +434,11 @@ export class SallaSlider {
|
|
|
429
434
|
return pre_defined_config;
|
|
430
435
|
}
|
|
431
436
|
getThumbsDirection() {
|
|
432
|
-
const { verticalThumbs,
|
|
433
|
-
if (verticalThumbs &&
|
|
437
|
+
const { verticalThumbs, isDesktopViewport, direction } = this;
|
|
438
|
+
if (verticalThumbs && !isDesktopViewport && direction === 'rtl') {
|
|
434
439
|
return 'rtl';
|
|
435
440
|
}
|
|
436
|
-
if (verticalThumbs &&
|
|
441
|
+
if (verticalThumbs && isDesktopViewport && direction === 'rtl') {
|
|
437
442
|
return 'ltr';
|
|
438
443
|
}
|
|
439
444
|
return direction;
|
|
@@ -488,7 +493,7 @@ export class SallaSlider {
|
|
|
488
493
|
classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
|
|
489
494
|
classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
|
|
490
495
|
classes += this.gridThumbs ? ' s-slider-with-grid-thumbs ' : '';
|
|
491
|
-
return (h(Host, { key: '
|
|
496
|
+
return (h(Host, { key: '44f6baf2ec3a6421cd8d8ce6779c6ce781cecc7f', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
|
|
492
497
|
h("div", { class: "s-slider-block__title" }, this.blockTitle ?
|
|
493
498
|
h("div", { class: "s-slider-block__title-right" }, h("h2", null, this.blockTitle), this.blockSubtitle ? h("p", { innerHTML: this.blockSubtitle }) : '')
|
|
494
499
|
: '', h("div", { class: "s-slider-block__title-left" }, this.displayAllUrl ?
|
|
@@ -496,7 +501,7 @@ export class SallaSlider {
|
|
|
496
501
|
: '', this.showControls ?
|
|
497
502
|
h("div", { class: "s-slider-block__title-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowRightIcon : ArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowLeftIcon : ArrowRightIcon })))
|
|
498
503
|
: ''))
|
|
499
|
-
: '', h("div", { key: '
|
|
504
|
+
: '', h("div", { key: '384d3224e9e2f9ad08d71093ee4c6f907232c07e', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: '578756df5b652d9b7e86d3f0424e4ec886b7a75f' }), h("div", { key: '7966a00ec720374a3dac1533d72fdfeb31db8105', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '39f9656cabb053dc4878ae1f2bd94a6efc19f975', name: 'items' })), this.pagination ? h("div", { class: "swiper-pagination" }) : ''), this.type == 'thumbs' && this.hasThumbSlot ? h("div", { class: "s-slider-thumbs" }, h("div", { class: "swiper s-slider-thumbs-container", dir: this.getThumbsDirection(), ref: el => this.thumbsSliderContainer = el }, h("div", { class: { "s-slider-swiper-wrapper swiper-wrapper": true, "s-slider-grid-thumbs": this.gridThumbs }, ref: el => this.thumbsSliderWrapper = el }, h("slot", { name: "thumbs" })), this.showThumbsControls ?
|
|
500
505
|
h("div", { class: "s-slider-thumbs-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-thumbs-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowRightIcon : ArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-thumbs-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? ArrowLeftIcon : ArrowRightIcon })))
|
|
501
506
|
: null))
|
|
502
507
|
: null));
|
|
@@ -570,8 +575,11 @@ export class SallaSlider {
|
|
|
570
575
|
this.flattenSlotToElements(this.thumbsSliderWrapper, 'div[slot="thumbs"]');
|
|
571
576
|
}
|
|
572
577
|
this.initSlider();
|
|
578
|
+
this.viewportMediaQuery = window.matchMedia('(min-width: 768px)');
|
|
579
|
+
this.viewportMediaQuery.addEventListener('change', this.onViewportChange);
|
|
573
580
|
}
|
|
574
581
|
disconnectedCallback() {
|
|
582
|
+
this.viewportMediaQuery?.removeEventListener('change', this.onViewportChange);
|
|
575
583
|
this.lazyObserver?.disconnect();
|
|
576
584
|
this.lazyImageObserver?.disconnect();
|
|
577
585
|
}
|
|
@@ -1019,7 +1027,7 @@ export class SallaSlider {
|
|
|
1019
1027
|
"isEnd": {},
|
|
1020
1028
|
"isBeginning": {},
|
|
1021
1029
|
"displayAllTitle": {},
|
|
1022
|
-
"
|
|
1030
|
+
"isDesktopViewport": {}
|
|
1023
1031
|
};
|
|
1024
1032
|
}
|
|
1025
1033
|
static get events() {
|
|
@@ -51,6 +51,10 @@ class Helper {
|
|
|
51
51
|
'components.most_sales_products': 'sales', //temporary, delete it after two days from now
|
|
52
52
|
}[source || salla.config.get('page.slug')] || source || 'latest';
|
|
53
53
|
}
|
|
54
|
+
getApiSource(source) {
|
|
55
|
+
const apiSourceMap = { 'recently': 'selected' };
|
|
56
|
+
return apiSourceMap[source] || source;
|
|
57
|
+
}
|
|
54
58
|
getPageTitleForSource(source) {
|
|
55
59
|
source = {
|
|
56
60
|
'brands': 'common.titles.brands',
|
|
@@ -177,6 +181,16 @@ class Helper {
|
|
|
177
181
|
productsIncludes() {
|
|
178
182
|
return this.includes?.filter(field => field != 'metadata');
|
|
179
183
|
}
|
|
184
|
+
saveProductSource(source) {
|
|
185
|
+
if (!source)
|
|
186
|
+
return;
|
|
187
|
+
try {
|
|
188
|
+
sessionStorage.setItem('s-viewed-source', source);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
salla.logger.warn('Error saving product source to session storage');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
180
194
|
parseJson(includes) {
|
|
181
195
|
if (typeof includes !== 'string') {
|
|
182
196
|
return includes;
|