@salla.sa/twilight-components 2.14.346 → 2.14.349

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/cjs/{filepond-D3JT19b9.js → filepond-DFhbfTkt.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-vIqpi5Jb.js → filepond-plugin-file-poster-Dj4Zm459.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-CGka-OOR.js → filepond-plugin-file-validate-size-DsH6GzKJ.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-D5Xexu4N.js → filepond-plugin-file-validate-type-DfaEudMs.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CIxcoEFX.js → filepond-plugin-image-edit-gz-CV83v.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-yRezDeUb.js → filepond-plugin-image-exif-orientation-DfkLjcpx.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CPE8T2_S.js → filepond-plugin-image-preview-BxaEwNCI.js} +1 -1
  8. package/dist/cjs/{index-B_jylE1-.js → index-C9ymZIiv.js} +1 -1
  9. package/dist/cjs/{index-CBbHmJY_.js → index-DcTksD2K.js} +2 -2
  10. package/dist/cjs/loader.cjs.js +2 -2
  11. package/dist/cjs/salla-accordion_62.cjs.entry.js +10395 -1320
  12. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -11
  30. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  46. package/dist/cjs/twilight.cjs.js +2 -2
  47. package/dist/cjs/vanilla-picker-BYDLZw1n.js +1045 -0
  48. package/dist/collection/components/salla-color-picker/salla-color-picker.js +67 -37
  49. package/dist/collection/components/salla-count-down/salla-count-down.js +125 -1
  50. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +4 -5
  51. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +1 -1
  52. package/dist/collection/components/salla-order-details/salla-order-details-multiple-bundle-product.js +0 -10
  53. package/dist/collection/components/salla-products-slider/salla-products-slider.js +3 -0
  54. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +68 -55
  55. package/dist/collection/components/salla-slider/salla-slider.css +691 -238
  56. package/dist/collection/components/salla-slider/salla-slider.js +96 -58
  57. package/dist/components/index.js +2 -2
  58. package/dist/components/salla-color-picker2.js +69 -1056
  59. package/dist/components/salla-count-down2.js +24 -2
  60. package/dist/components/salla-multiple-bundle-product-options-modal2.js +4 -5
  61. package/dist/components/salla-multiple-bundle-product-slider2.js +1 -1
  62. package/dist/components/salla-order-details-multiple-bundle-product2.js +0 -10
  63. package/dist/components/salla-products-slider2.js +3 -0
  64. package/dist/components/salla-quick-buy2.js +367 -139
  65. package/dist/components/salla-slider2.js +9881 -61
  66. package/dist/components/vanilla-picker.js +1043 -0
  67. package/dist/esm/{filepond-ESI025KA.js → filepond-DQR2YBu7.js} +1 -1
  68. package/dist/esm/{filepond-plugin-file-poster-CWHjkl55.js → filepond-plugin-file-poster-XvYa1rlk.js} +1 -1
  69. package/dist/esm/{filepond-plugin-file-validate-size-B7W5i7Mk.js → filepond-plugin-file-validate-size-BRBnctOE.js} +1 -1
  70. package/dist/esm/{filepond-plugin-file-validate-type-B1Ny76Ep.js → filepond-plugin-file-validate-type-BuD6F1gi.js} +1 -1
  71. package/dist/esm/{filepond-plugin-image-edit-DfqS6NSZ.js → filepond-plugin-image-edit-BJ8YnBRL.js} +1 -1
  72. package/dist/esm/{filepond-plugin-image-exif-orientation-3kpdQNdB.js → filepond-plugin-image-exif-orientation-BGad_AoX.js} +1 -1
  73. package/dist/esm/{filepond-plugin-image-preview-Ck91BQiY.js → filepond-plugin-image-preview-Cb6UzPfa.js} +1 -1
  74. package/dist/esm/{index-gdKTeC4S.js → index-Bhszo8cU.js} +2 -2
  75. package/dist/esm/{index-5xSCOnsp.js → index-DIfeuyTs.js} +1 -1
  76. package/dist/esm/loader.js +3 -3
  77. package/dist/esm/salla-accordion_62.entry.js +10395 -1320
  78. package/dist/esm/salla-advertisement.entry.js +1 -1
  79. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  80. package/dist/esm/salla-apps-icons.entry.js +1 -1
  81. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  82. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  83. package/dist/esm/salla-contacts.entry.js +1 -1
  84. package/dist/esm/salla-custom-fields.entry.js +1 -1
  85. package/dist/esm/salla-filters-widget.entry.js +1 -1
  86. package/dist/esm/salla-filters.entry.js +1 -1
  87. package/dist/esm/salla-hook.entry.js +1 -1
  88. package/dist/esm/salla-installment.entry.js +1 -1
  89. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  90. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  91. package/dist/esm/salla-metadata.entry.js +1 -1
  92. package/dist/esm/salla-notification-item.entry.js +1 -1
  93. package/dist/esm/salla-notifications.entry.js +1 -1
  94. package/dist/esm/salla-offer.entry.js +1 -1
  95. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -11
  96. package/dist/esm/salla-order-details-options.entry.js +1 -1
  97. package/dist/esm/salla-order-details.entry.js +1 -1
  98. package/dist/esm/salla-order-summary.entry.js +1 -1
  99. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  100. package/dist/esm/salla-orders.entry.js +1 -1
  101. package/dist/esm/salla-payments.entry.js +1 -1
  102. package/dist/esm/salla-price-range.entry.js +1 -1
  103. package/dist/esm/salla-review-card.entry.js +1 -1
  104. package/dist/esm/salla-reviews-page.entry.js +1 -1
  105. package/dist/esm/salla-reviews.entry.js +1 -1
  106. package/dist/esm/salla-social.entry.js +1 -1
  107. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  108. package/dist/esm/salla-tooltip.entry.js +1 -1
  109. package/dist/esm/salla-trust-badges.entry.js +1 -1
  110. package/dist/esm/salla-verify.entry.js +1 -1
  111. package/dist/esm/salla-wallet.entry.js +1 -1
  112. package/dist/esm/twilight.js +3 -3
  113. package/dist/esm/vanilla-picker-C4Kwbr5L.js +1043 -0
  114. package/dist/twilight/{p-936a76d1.entry.js → p-004be2ff.entry.js} +1 -1
  115. package/dist/twilight/{p-0a4b04a4.entry.js → p-0daa34c4.entry.js} +1 -1
  116. package/dist/twilight/{p-6bd166a7.entry.js → p-112e9574.entry.js} +1 -1
  117. package/dist/twilight/{p-369ada5a.entry.js → p-129e02c2.entry.js} +1 -1
  118. package/dist/twilight/{p-d5da6f45.entry.js → p-1bfef164.entry.js} +1 -1
  119. package/dist/twilight/{p-36a95a0f.entry.js → p-25f64b3e.entry.js} +1 -1
  120. package/dist/twilight/{p-8563e747.entry.js → p-307b5fa0.entry.js} +1 -1
  121. package/dist/twilight/{p-a7a488d5.entry.js → p-46fb77ce.entry.js} +1 -1
  122. package/dist/twilight/{p-b0e7c134.entry.js → p-48617181.entry.js} +1 -1
  123. package/dist/twilight/{p-4e98e961.entry.js → p-48df4495.entry.js} +1 -1
  124. package/dist/twilight/p-4fc33cee.entry.js +4 -0
  125. package/dist/twilight/{p-aefe5639.entry.js → p-55c9e7fe.entry.js} +1 -1
  126. package/dist/twilight/{p-5570cae4.entry.js → p-574bd55f.entry.js} +1 -1
  127. package/dist/twilight/{p-ef0fa205.entry.js → p-5bb9ace5.entry.js} +1 -1
  128. package/dist/twilight/{p-eab13555.entry.js → p-60747f3b.entry.js} +1 -1
  129. package/dist/twilight/{p-3e410acd.entry.js → p-6222b0fa.entry.js} +1 -1
  130. package/dist/twilight/{p-b8f7b4eb.entry.js → p-64c18854.entry.js} +1 -1
  131. package/dist/twilight/{p-e465a952.entry.js → p-66c5dcd3.entry.js} +1 -1
  132. package/dist/twilight/{p-343c8271.entry.js → p-7a706d50.entry.js} +1 -1
  133. package/dist/twilight/{p-ad2b2919.entry.js → p-911bbc7d.entry.js} +1 -1
  134. package/dist/twilight/{p-7b5906b8.entry.js → p-9f541d63.entry.js} +1 -1
  135. package/dist/twilight/{p-DId3Z42j.js → p-B-MyfVCv.js} +1 -1
  136. package/dist/twilight/{p-D3JRC8L6.js → p-BVmy-j16.js} +1 -1
  137. package/dist/twilight/{p-gdKTeC4S.js → p-Bhszo8cU.js} +1 -1
  138. package/dist/twilight/{p-CUtvZOiz.js → p-BvldZUSR.js} +1 -1
  139. package/dist/twilight/{p-CMYBgZIX.js → p-ByJhdNbq.js} +1 -1
  140. package/dist/twilight/{p-DH5ljldi.js → p-CmuTtBET.js} +1 -1
  141. package/dist/twilight/{p-EnsROQgl.js → p-CuNS5C_o.js} +2 -2
  142. package/dist/twilight/{p-DpJnHcvE.js → p-Cy9bcLMa.js} +1 -1
  143. package/dist/twilight/{p-rYLDeLaL.js → p-DAM1DKLB.js} +1 -1
  144. package/dist/twilight/p-NTgp-Syt.js +11 -0
  145. package/dist/twilight/{p-5099bc51.entry.js → p-a25fe3c1.entry.js} +1 -1
  146. package/dist/twilight/{p-49638a91.entry.js → p-a5df8334.entry.js} +1 -1
  147. package/dist/twilight/{p-46b242d9.entry.js → p-a6f250b8.entry.js} +1 -1
  148. package/dist/twilight/{p-ebd8dbf8.entry.js → p-ae93ed50.entry.js} +1 -1
  149. package/dist/twilight/{p-f64cd638.entry.js → p-af8daa75.entry.js} +1 -1
  150. package/dist/twilight/{p-8100a941.entry.js → p-b0abcc89.entry.js} +1 -1
  151. package/dist/twilight/{p-360a28b9.entry.js → p-b8a203c1.entry.js} +1 -1
  152. package/dist/twilight/p-cadbe7b6.entry.js +4 -0
  153. package/dist/twilight/{p-1037bca4.entry.js → p-cc43a1bd.entry.js} +1 -1
  154. package/dist/twilight/{p-db68f32e.entry.js → p-cc6238be.entry.js} +1 -1
  155. package/dist/twilight/{p-158398ff.entry.js → p-de290cc2.entry.js} +1 -1
  156. package/dist/twilight/{p-8a1aa61c.entry.js → p-ed0f40e2.entry.js} +1 -1
  157. package/dist/twilight/{p-003a77fe.entry.js → p-f3d3e11e.entry.js} +1 -1
  158. package/dist/twilight/{p-8418b725.entry.js → p-f4bf39fb.entry.js} +1 -1
  159. package/dist/twilight/twilight.esm.js +1 -1
  160. package/dist/types/components/salla-color-picker/interfaces.d.ts +9 -0
  161. package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +4 -1
  162. package/dist/types/components/salla-count-down/salla-count-down.d.ts +22 -0
  163. package/dist/types/components/salla-order-details/salla-order-details-multiple-bundle-product.d.ts +0 -1
  164. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +1 -0
  165. package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +2 -0
  166. package/dist/types/components/salla-slider/salla-slider.d.ts +12 -3
  167. package/dist/types/components.d.ts +48 -0
  168. package/package.json +6 -6
  169. package/dist/twilight/p-04e81b46.entry.js +0 -11
  170. package/dist/twilight/p-1445c077.entry.js +0 -4
@@ -2,6 +2,8 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { h, Host } from "@stencil/core";
5
+ // Import from bundle.mjs to avoid bundling issue since module resolution is set to `node`
6
+ import Swiper from "swiper/swiper-bundle.mjs";
5
7
  import ArrowRightIcon from "../../assets/svg/keyboard_arrow_right.svg";
6
8
  import ArrowLeftIcon from "../../assets/svg/keyboard_arrow_left.svg";
7
9
  /**
@@ -105,7 +107,7 @@ export class SallaSlider {
105
107
  direction: "vertical",
106
108
  followFinger: false,
107
109
  touchReleaseOnEdges: true,
108
- lazy: true,
110
+ // v9+: lazy is native (use loading="lazy" on images + .swiper-lazy-preloader)
109
111
  mousewheel: {}
110
112
  },
111
113
  testimonials: {
@@ -123,7 +125,7 @@ export class SallaSlider {
123
125
  breakpoints: {
124
126
  320: { spaceBetween: 10 },
125
127
  768: { spaceBetween: 15 },
126
- 980: { paceBetween: 30 },
128
+ 980: { spaceBetween: 30 },
127
129
  }
128
130
  },
129
131
  thumbs: {
@@ -315,42 +317,11 @@ export class SallaSlider {
315
317
  if (this.listenToThumbnailsOption) {
316
318
  salla.event.on('product-options::change', data => {
317
319
  if (data.option.type == 'thumbnail') {
318
- const slideIndex = this.sliderWrapper.querySelector(`[data-img-id="${data.detail.option_value}"]`)?.getAttribute('data-slid-index');
320
+ const slideIndex = this.sliderWrapper?.querySelector(`[data-img-id="${data.detail.option_value}"]`)?.getAttribute('data-slid-index');
319
321
  slideIndex ? this.slideTo(parseInt(slideIndex), 300, false) : '';
320
322
  }
321
323
  });
322
324
  }
323
- return new Promise((resolve, reject) => {
324
- // @ts-ignore
325
- if (typeof Swiper !== 'undefined') {
326
- return resolve(true);
327
- }
328
- if (document.getElementById('swiper-script')) {
329
- let interval = setInterval(() => {
330
- // @ts-ignore
331
- if (typeof Swiper !== 'undefined') {
332
- clearInterval(interval);
333
- resolve(true);
334
- }
335
- }, 5);
336
- }
337
- else {
338
- // ? There is an issue with stencil bundling it breaks the swiper import, so we need to import it manually by swiperjs rerendered file
339
- // ! IT'S NOT A GOOD SOLUTION, BUT IT WORKS, WE NEED TO FIND A BETTER SOLUTION
340
- this.swiperScript = document.createElement('script');
341
- this.swiperScript.onload = () => {
342
- resolve(true);
343
- salla.event.emit('swiper::loaded');
344
- };
345
- this.swiperScript.onerror = (error) => {
346
- salla.logger.warn('failed load swiper bundle', error);
347
- reject(true);
348
- };
349
- this.swiperScript.src = 'https://cdn.salla.network/js/swiper@8.js';
350
- this.swiperScript.setAttribute('id', 'swiper-script');
351
- document.body.appendChild(this.swiperScript);
352
- }
353
- });
354
325
  }
355
326
  getSwiperConfig() {
356
327
  let autoplay = this.autoPlay;
@@ -363,7 +334,7 @@ export class SallaSlider {
363
334
  centeredSlides: this.centered,
364
335
  slidesPerView: this.slidesPerView,
365
336
  autoHeight: this.autoHeight,
366
- lazy: true,
337
+ // v9+: native lazy (loading="lazy" on images); no lazy module
367
338
  on: {
368
339
  // todo:: find better way for this workaround to show lazyLoad for duplicated slides, because it clones the slide after it's already rendered,
369
340
  // then it re appended it as is,in this case the image is loaded but class not added.
@@ -398,7 +369,6 @@ export class SallaSlider {
398
369
  slidesPerView: 4,
399
370
  spaceBetween: 10,
400
371
  watchOverflow: true,
401
- watchSlidesVisibility: true,
402
372
  breakpoints: {
403
373
  768: {
404
374
  direction: this.verticalThumbs ? "vertical" : "horizontal",
@@ -418,9 +388,9 @@ export class SallaSlider {
418
388
  ...(this.pre_defined_config[this.type] || {})
419
389
  };
420
390
  if (this.type == 'thumbs' && this.thumbsSliderWrapper) {
421
- for (const slide of this.thumbsSliderWrapper.children) {
422
- //todo:: use `s-slider-slide`
423
- slide.classList.add('swiper-slide');
391
+ for (const slide of Array.from(this.thumbsSliderWrapper.children)) {
392
+ if (slide.nodeType === Node.ELEMENT_NODE)
393
+ slide.classList.add('swiper-slide');
424
394
  }
425
395
  if (this.hasThumbSlot && this.thumbsConfig) {
426
396
  try {
@@ -433,7 +403,9 @@ export class SallaSlider {
433
403
  salla.logger.warn('Failed to parse thumbs slider config:', error);
434
404
  }
435
405
  }
436
- // @ts-ignore
406
+ if (!this.thumbsSliderContainer) {
407
+ return pre_defined_config;
408
+ }
437
409
  this.thumbsSlider = new Swiper(this.thumbsSliderContainer, pre_defined_thumbs_config);
438
410
  // @ts-ignore
439
411
  pre_defined_config.thumbs = {
@@ -467,11 +439,20 @@ export class SallaSlider {
467
439
  return direction;
468
440
  }
469
441
  initSlider() {
470
- for (const slide of this.sliderWrapper.children) {
471
- slide.classList.add('swiper-slide');
442
+ for (const slide of Array.from(this.sliderWrapper?.children || [])) {
443
+ if (slide.nodeType === Node.ELEMENT_NODE)
444
+ slide.classList.add('swiper-slide');
445
+ }
446
+ if (!this.sliderContainer) {
447
+ salla.logger.warn('Slider container not found');
448
+ return;
472
449
  }
473
- // @ts-ignore
474
450
  this.slider = new Swiper(this.sliderContainer, this.getSwiperConfig());
451
+ // Backward compatibility: lazy load data-background as background-image (removed in Swiper v9+)
452
+ this.loadLazyBackgrounds();
453
+ this.slider.on('slideChange', () => this.loadLazyBackgrounds());
454
+ // Add swiper-lazy-loaded to lazy images when visible
455
+ this.observeLazyImages();
475
456
  // Expose slider events
476
457
  this.slider.on('slideChange', (slider) => {
477
458
  //todo:: it doesn't change when loop is active, always will be false
@@ -507,7 +488,7 @@ export class SallaSlider {
507
488
  classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
508
489
  classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
509
490
  classes += this.gridThumbs ? ' s-slider-with-grid-thumbs ' : '';
510
- return (h(Host, { key: '1ea8cca50a8069cfa57617a79d84a1d9a9f85d8a', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
491
+ return (h(Host, { key: '0b3f597ee3e0b5bfddfdcc9e3167edc93273defe', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
511
492
  h("div", { class: "s-slider-block__title" }, this.blockTitle ?
512
493
  h("div", { class: "s-slider-block__title-right" }, h("h2", null, this.blockTitle), this.blockSubtitle ? h("p", { innerHTML: this.blockSubtitle }) : '')
513
494
  : '', h("div", { class: "s-slider-block__title-left" }, this.displayAllUrl ?
@@ -515,26 +496,84 @@ export class SallaSlider {
515
496
  : '', this.showControls ?
516
497
  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 })))
517
498
  : ''))
518
- : '', h("div", { key: 'e782e1a255ef74387e143be5e54ec8212b133f63', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: 'e69fb142f47b11d749a0ea2676177118eaa2093a' }), h("div", { key: '469f85e0a975a1de25c6c6c47918b85bb640e271', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '87d7c9b65e2d499bbd716a17ec5ce1f3079cc750', 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 ?
499
+ : '', h("div", { key: 'b4439c52238fef56cb59af6a568759dbe4ff7b3b', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: '9f527368279faa132cd8f451d231da84d37736b4' }), h("div", { key: '1a25a9068037cd732c5d0dcba32fbf630b812acd', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '777e3773d840abaf0fc55cdcdf50b504696fdd5c', 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 ?
519
500
  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 })))
520
501
  : null))
521
502
  : null));
522
503
  }
523
- componentDidLoad() {
524
- let itemsSlot = this.sliderWrapper.querySelector('div[slot="items"]');
525
- !!itemsSlot ? itemsSlot.replaceWith(...itemsSlot.children) : null;
526
- if (this.type == 'thumbs' && this.hasThumbSlot) {
527
- let thumbsSlot = this.thumbsSliderWrapper.querySelector('div[slot="thumbs"]');
528
- !!thumbsSlot ? thumbsSlot.replaceWith(...thumbsSlot.children) : null;
504
+ /** Observe all .swiper-lazy images and add swiper-lazy-loaded when they enter viewport. */
505
+ observeLazyImages() {
506
+ const lazyEls = this.sliderContainer?.querySelectorAll('.swiper-lazy:not(.swiper-lazy-loaded)');
507
+ if (!lazyEls?.length)
508
+ return;
509
+ if (!this.lazyImageObserver) {
510
+ this.lazyImageObserver = new IntersectionObserver((entries, observer) => {
511
+ entries.forEach(entry => {
512
+ if (!entry.isIntersecting)
513
+ return;
514
+ entry.target.classList.add('swiper-lazy-loaded');
515
+ observer.unobserve(entry.target);
516
+ });
517
+ }, { rootMargin: '50px' });
529
518
  }
530
- // if swiper is not loaded, lets relay on event
531
- // @ts-ignore
532
- if (typeof Swiper === 'undefined') {
533
- salla.event.once('swiper::loaded', () => this.initSlider());
519
+ lazyEls.forEach(el => this.lazyImageObserver.observe(el));
520
+ }
521
+ /** Lazy load data-background for active slide and adjacent slides (backward compat for Swiper v9+). */
522
+ loadLazyBackgrounds() {
523
+ if (!this.slider?.slides)
524
+ return;
525
+ const active = this.slider.activeIndex;
526
+ const toLoad = [active - 1, active, active + 1];
527
+ toLoad.forEach(i => {
528
+ const slide = this.slider.slides[i];
529
+ if (!slide)
530
+ return;
531
+ slide.querySelectorAll('[data-background]').forEach((el) => {
532
+ this.loadBackgroundIfVisible(el);
533
+ });
534
+ });
535
+ }
536
+ /** Load background only when element is in viewport. */
537
+ loadBackgroundIfVisible(el) {
538
+ if (el.classList.contains('swiper-lazy-loaded'))
539
+ return;
540
+ if (!this.lazyObserver) {
541
+ this.lazyObserver = new IntersectionObserver((entries, observer) => {
542
+ entries.forEach(entry => {
543
+ if (!entry.isIntersecting)
544
+ return;
545
+ const target = entry.target;
546
+ const bg = target.getAttribute('data-background');
547
+ if (bg) {
548
+ target.style.backgroundImage = `url('${bg}')`;
549
+ target.classList.add('swiper-lazy-loaded');
550
+ target.removeAttribute('data-background');
551
+ }
552
+ observer.unobserve(target);
553
+ });
554
+ }, { rootMargin: '50px' });
534
555
  }
535
- else { // if swiper is loaded lets init our slider
536
- this.initSlider();
556
+ this.lazyObserver.observe(el);
557
+ }
558
+ /** Keep only element nodes so Swiper never sees text nodes (getAttribute would throw). */
559
+ flattenSlotToElements(container, slotSelector) {
560
+ const slotEl = container?.querySelector(slotSelector);
561
+ if (!slotEl)
562
+ return;
563
+ const elements = Array.from(slotEl.children).filter((node) => node.nodeType === Node.ELEMENT_NODE);
564
+ if (elements.length)
565
+ slotEl.replaceWith(...elements);
566
+ }
567
+ componentDidLoad() {
568
+ this.flattenSlotToElements(this.sliderWrapper, 'div[slot="items"]');
569
+ if (this.type == 'thumbs' && this.hasThumbSlot) {
570
+ this.flattenSlotToElements(this.thumbsSliderWrapper, 'div[slot="thumbs"]');
537
571
  }
572
+ this.initSlider();
573
+ }
574
+ disconnectedCallback() {
575
+ this.lazyObserver?.disconnect();
576
+ this.lazyImageObserver?.disconnect();
538
577
  }
539
578
  static get is() { return "salla-slider"; }
540
579
  static get originalStyleUrls() {
@@ -979,7 +1018,6 @@ export class SallaSlider {
979
1018
  "currentIndex": {},
980
1019
  "isEnd": {},
981
1020
  "isBeginning": {},
982
- "swiperScript": {},
983
1021
  "displayAllTitle": {},
984
1022
  "windowWidth": {}
985
1023
  };