@harshit-wander/component-lib 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -80,6 +80,12 @@ interface EventVideoBannerProps extends HTMLAttributes<HTMLElement> {
80
80
  videoUrl: string;
81
81
  alt: string;
82
82
  href?: string | undefined;
83
+ /**
84
+ * When false, renders only the poster image (no <video> element, no HLS load).
85
+ * Used by EventCarousel to avoid loading every video in the carousel at once.
86
+ * Defaults to true to preserve standalone usage.
87
+ */
88
+ isActive?: boolean;
83
89
  }
84
90
 
85
91
  declare const EventVideoBanner: react.ForwardRefExoticComponent<EventVideoBannerProps & react.RefAttributes<HTMLDivElement>>;
package/dist/index.d.ts CHANGED
@@ -80,6 +80,12 @@ interface EventVideoBannerProps extends HTMLAttributes<HTMLElement> {
80
80
  videoUrl: string;
81
81
  alt: string;
82
82
  href?: string | undefined;
83
+ /**
84
+ * When false, renders only the poster image (no <video> element, no HLS load).
85
+ * Used by EventCarousel to avoid loading every video in the carousel at once.
86
+ * Defaults to true to preserve standalone usage.
87
+ */
88
+ isActive?: boolean;
83
89
  }
84
90
 
85
91
  declare const EventVideoBanner: react.ForwardRefExoticComponent<EventVideoBannerProps & react.RefAttributes<HTMLDivElement>>;
package/dist/index.js CHANGED
@@ -276,11 +276,12 @@ var EventBanner = forwardRef(
276
276
  );
277
277
  EventBanner.displayName = "EventBanner";
278
278
  var frameClass2 = "block w-full h-[300px] overflow-hidden rounded-md no-underline text-inherit focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2";
279
- var videoClass = "block w-full h-full object-cover";
279
+ var mediaClass = "block w-full h-full object-cover";
280
280
  var EventVideoBanner = forwardRef(
281
- ({ posterUrl, videoUrl, alt, href, className, ...rest }, ref) => {
281
+ ({ posterUrl, videoUrl, alt, href, isActive = true, className, ...rest }, ref) => {
282
282
  const videoRef = useRef(null);
283
283
  useEffect(() => {
284
+ if (!isActive) return;
284
285
  const video = videoRef.current;
285
286
  if (!video || !videoUrl) return;
286
287
  if (!videoUrl.includes(".m3u8")) {
@@ -304,8 +305,8 @@ var EventVideoBanner = forwardRef(
304
305
  const stored = video._hls;
305
306
  stored?.destroy();
306
307
  };
307
- }, [videoUrl]);
308
- const videoEl = /* @__PURE__ */ jsx(
308
+ }, [videoUrl, isActive]);
309
+ const mediaEl = isActive ? /* @__PURE__ */ jsx(
309
310
  "video",
310
311
  {
311
312
  ref: videoRef,
@@ -317,10 +318,10 @@ var EventVideoBanner = forwardRef(
317
318
  loop: true,
318
319
  playsInline: true,
319
320
  preload: "metadata",
320
- className: videoClass
321
+ className: mediaClass
321
322
  }
322
- );
323
- return /* @__PURE__ */ jsx("div", { ref, className: cn("shrink-0 w-full snap-start", className), ...rest, children: href ? /* @__PURE__ */ jsx("a", { href, className: frameClass2, children: videoEl }) : /* @__PURE__ */ jsx("div", { className: frameClass2, children: videoEl }) });
323
+ ) : /* @__PURE__ */ jsx("img", { src: posterUrl, alt, loading: "lazy", decoding: "async", className: mediaClass });
324
+ return /* @__PURE__ */ jsx("div", { ref, className: cn("shrink-0 w-full snap-start", className), ...rest, children: href ? /* @__PURE__ */ jsx("a", { href, className: frameClass2, children: mediaEl }) : /* @__PURE__ */ jsx("div", { className: frameClass2, children: mediaEl }) });
324
325
  }
325
326
  );
326
327
  EventVideoBanner.displayName = "EventVideoBanner";
@@ -1572,7 +1573,9 @@ var useScrollSnap = (itemCount) => {
1572
1573
  setScrollProgress(maxScroll > 0 ? el.scrollLeft / maxScroll : 0);
1573
1574
  if (itemCount > 0) {
1574
1575
  const itemWidth = el.scrollWidth / itemCount;
1575
- setActiveIndex(Math.round(el.scrollLeft / itemWidth));
1576
+ if (itemWidth > 0) {
1577
+ setActiveIndex(Math.round(el.scrollLeft / itemWidth));
1578
+ }
1576
1579
  }
1577
1580
  }, [itemCount]);
1578
1581
  const setRef = useCallback(
@@ -1674,13 +1677,14 @@ var EventCarousel = forwardRef(
1674
1677
  ref: trackRef,
1675
1678
  className: "flex w-full gap-sm overflow-x-auto snap-x [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
1676
1679
  children: events.map(
1677
- (event) => "videoUrl" in event ? /* @__PURE__ */ jsx(
1680
+ (event, index) => "videoUrl" in event ? /* @__PURE__ */ jsx(
1678
1681
  EventVideoBanner,
1679
1682
  {
1680
1683
  posterUrl: event.posterUrl,
1681
1684
  videoUrl: event.videoUrl,
1682
1685
  alt: event.alt,
1683
- href: event.href
1686
+ href: event.href,
1687
+ isActive: index === activeIndex
1684
1688
  },
1685
1689
  `${event.videoUrl}|${event.alt}`
1686
1690
  ) : /* @__PURE__ */ jsx(
@@ -2713,6 +2717,34 @@ var TextSection = forwardRef(
2713
2717
  )
2714
2718
  );
2715
2719
  TextSection.displayName = "TextSection";
2720
+ var useDesktopVideoVisible = (ref, breakpointPx = 768) => {
2721
+ const [shouldRender, setShouldRender] = useState(false);
2722
+ useEffect(() => {
2723
+ if (typeof window === "undefined") return;
2724
+ const mq = window.matchMedia(`(min-width: ${breakpointPx}px)`);
2725
+ if (!mq.matches) {
2726
+ setShouldRender(false);
2727
+ return;
2728
+ }
2729
+ const el = ref.current;
2730
+ if (!el || typeof IntersectionObserver === "undefined") {
2731
+ setShouldRender(true);
2732
+ return;
2733
+ }
2734
+ const io = new IntersectionObserver(
2735
+ (entries) => {
2736
+ if (entries[0]?.isIntersecting) {
2737
+ setShouldRender(true);
2738
+ io.disconnect();
2739
+ }
2740
+ },
2741
+ { rootMargin: "200px" }
2742
+ );
2743
+ io.observe(el);
2744
+ return () => io.disconnect();
2745
+ }, [ref, breakpointPx]);
2746
+ return shouldRender;
2747
+ };
2716
2748
  var ChevronLeft5 = () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
2717
2749
  "path",
2718
2750
  {
@@ -2744,6 +2776,8 @@ var TripsCategorySection = forwardRef(
2744
2776
  canNext,
2745
2777
  scrollProgress
2746
2778
  } = useScrollSnap(trips.length);
2779
+ const heroRef = useRef(null);
2780
+ const showDesktopVideo = useDesktopVideoVisible(heroRef);
2747
2781
  const handleCtaClick = () => {
2748
2782
  if (cta.href) {
2749
2783
  window.location.assign(cta.href);
@@ -2752,134 +2786,152 @@ var TripsCategorySection = forwardRef(
2752
2786
  cta.onClick?.();
2753
2787
  };
2754
2788
  const progressWidth = Math.min(33 + scrollProgress * (120 - 33), 120);
2755
- return /* @__PURE__ */ jsxs("section", { ref, className: cn("relative flex flex-col bg-surface max-md:overflow-x-clip", className), ...rest, children: [
2756
- /* @__PURE__ */ jsxs("div", { className: "relative h-[318px] rounded-lg overflow-hidden max-md:h-[260px]", children: [
2757
- /* @__PURE__ */ jsxs("div", { className: "absolute inset-0", children: [
2758
- /* @__PURE__ */ jsx(
2759
- "img",
2789
+ return /* @__PURE__ */ jsxs(
2790
+ "section",
2791
+ {
2792
+ ref,
2793
+ className: cn("relative flex flex-col bg-surface max-md:overflow-x-clip", className),
2794
+ ...rest,
2795
+ children: [
2796
+ /* @__PURE__ */ jsxs(
2797
+ "div",
2760
2798
  {
2761
- src: poster,
2762
- alt: "",
2763
- "aria-hidden": "true",
2764
- className: "w-full h-full object-cover md:hidden"
2799
+ ref: heroRef,
2800
+ className: "relative h-[318px] rounded-lg overflow-hidden max-md:h-[260px]",
2801
+ children: [
2802
+ /* @__PURE__ */ jsxs("div", { className: "absolute inset-0", children: [
2803
+ /* @__PURE__ */ jsx(
2804
+ "img",
2805
+ {
2806
+ src: poster,
2807
+ alt: "",
2808
+ "aria-hidden": "true",
2809
+ className: "w-full h-full object-cover",
2810
+ loading: "lazy",
2811
+ decoding: "async"
2812
+ }
2813
+ ),
2814
+ showDesktopVideo && /* @__PURE__ */ jsx(
2815
+ "video",
2816
+ {
2817
+ autoPlay: true,
2818
+ muted: true,
2819
+ loop: true,
2820
+ playsInline: true,
2821
+ preload: "metadata",
2822
+ poster,
2823
+ src: videoSrc,
2824
+ className: "hidden md:block absolute inset-0 w-full h-full object-cover"
2825
+ }
2826
+ )
2827
+ ] }),
2828
+ /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex flex-col justify-center gap-lg p-[44px] max-md:p-[24px] text-on-image [text-shadow:0px_6px_24px_rgba(0,0,0,0.16)]", children: [
2829
+ /* @__PURE__ */ jsx("h2", { className: "m-0 text-hero-title max-w-[436px] max-md:text-secondary max-md:[text-shadow:none]", children: title }),
2830
+ /* @__PURE__ */ jsx("p", { className: "max-md:hidden m-0 text-xs font-bold leading-5", children: description }),
2831
+ /* @__PURE__ */ jsx(
2832
+ "button",
2833
+ {
2834
+ type: "button",
2835
+ onClick: handleCtaClick,
2836
+ className: "max-md:hidden inline-flex items-center justify-center self-start h-11 px-xl bg-accent text-secondary border-none rounded-md font-[inherit] text-button cursor-pointer shadow-[inset_0_0_6px_rgba(0,0,0,0.14)] transition-colors duration-150 ease-in hover:bg-accent-hover focus-visible:outline-2 focus-visible:outline-white focus-visible:outline-offset-2",
2837
+ children: cta.label
2838
+ }
2839
+ )
2840
+ ] })
2841
+ ]
2765
2842
  }
2766
2843
  ),
2767
- /* @__PURE__ */ jsx(
2768
- "video",
2769
- {
2770
- autoPlay: true,
2771
- muted: true,
2772
- loop: true,
2773
- playsInline: true,
2774
- poster,
2775
- src: videoSrc,
2776
- className: "hidden md:block w-full h-full object-cover"
2777
- }
2778
- )
2779
- ] }),
2780
- /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex flex-col justify-center gap-lg p-[44px] max-md:p-[24px] text-on-image [text-shadow:0px_6px_24px_rgba(0,0,0,0.16)]", children: [
2781
- /* @__PURE__ */ jsx("h2", { className: "m-0 text-hero-title max-w-[436px] max-md:text-secondary max-md:[text-shadow:none]", children: title }),
2782
- /* @__PURE__ */ jsx("p", { className: "max-md:hidden m-0 text-xs font-bold leading-5", children: description }),
2783
- /* @__PURE__ */ jsx(
2784
- "button",
2785
- {
2786
- type: "button",
2787
- onClick: handleCtaClick,
2788
- className: "max-md:hidden inline-flex items-center justify-center self-start h-11 px-xl bg-accent text-secondary border-none rounded-md font-[inherit] text-button cursor-pointer shadow-[inset_0_0_6px_rgba(0,0,0,0.14)] transition-colors duration-150 ease-in hover:bg-accent-hover focus-visible:outline-2 focus-visible:outline-white focus-visible:outline-offset-2",
2789
- children: cta.label
2790
- }
2791
- )
2792
- ] })
2793
- ] }),
2794
- /* @__PURE__ */ jsxs("div", { className: "relative -mt-[68px] py-sm px-[25px] hidden md:block", children: [
2795
- /* @__PURE__ */ jsx(
2796
- "button",
2797
- {
2798
- type: "button",
2799
- onClick: scrollPrev,
2800
- disabled: !canPrev,
2801
- "aria-label": "Previous trips",
2802
- className: cn(arrowBase4, "left-2"),
2803
- children: /* @__PURE__ */ jsx(ChevronLeft5, {})
2804
- }
2805
- ),
2806
- /* @__PURE__ */ jsx(
2807
- "div",
2808
- {
2809
- ref: trackRef,
2810
- className: "flex gap-sm overflow-x-auto snap-x [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
2811
- children: trips.map((trip) => /* @__PURE__ */ jsx(
2812
- TripCategoryCard,
2844
+ /* @__PURE__ */ jsxs("div", { className: "relative -mt-[68px] py-sm px-[25px] hidden md:block", children: [
2845
+ /* @__PURE__ */ jsx(
2846
+ "button",
2813
2847
  {
2814
- image: trip.image,
2815
- alt: trip.alt,
2816
- destination: trip.destination,
2817
- startingPrice: trip.startingPrice,
2818
- href: trip.href
2819
- },
2820
- `${trip.image}|${trip.destination}`
2821
- ))
2822
- }
2823
- ),
2824
- /* @__PURE__ */ jsx(
2825
- "button",
2826
- {
2827
- type: "button",
2828
- onClick: scrollNext,
2829
- disabled: !canNext,
2830
- "aria-label": "Next trips",
2831
- className: cn(arrowBase4, "right-2"),
2832
- children: /* @__PURE__ */ jsx(ChevronRight5, {})
2833
- }
2834
- ),
2835
- /* @__PURE__ */ jsx(
2836
- "div",
2837
- {
2838
- role: "progressbar",
2839
- "aria-valuenow": Math.round(scrollProgress * 100),
2840
- "aria-valuemin": 0,
2841
- "aria-valuemax": 100,
2842
- "aria-label": "Scroll position",
2843
- className: "relative w-[120px] h-[6px] mt-md mx-auto bg-track rounded-[32px] overflow-hidden",
2844
- children: /* @__PURE__ */ jsx(
2845
- "span",
2848
+ type: "button",
2849
+ onClick: scrollPrev,
2850
+ disabled: !canPrev,
2851
+ "aria-label": "Previous trips",
2852
+ className: cn(arrowBase4, "left-2"),
2853
+ children: /* @__PURE__ */ jsx(ChevronLeft5, {})
2854
+ }
2855
+ ),
2856
+ /* @__PURE__ */ jsx(
2857
+ "div",
2846
2858
  {
2847
- className: "absolute top-0 left-0 h-full bg-primary rounded-[32px] transition-[width] duration-200 ease-in",
2848
- style: { width: `${progressWidth}px` }
2859
+ ref: trackRef,
2860
+ className: "flex gap-sm overflow-x-auto snap-x [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
2861
+ children: trips.map((trip) => /* @__PURE__ */ jsx(
2862
+ TripCategoryCard,
2863
+ {
2864
+ image: trip.image,
2865
+ alt: trip.alt,
2866
+ destination: trip.destination,
2867
+ startingPrice: trip.startingPrice,
2868
+ href: trip.href
2869
+ },
2870
+ `${trip.image}|${trip.destination}`
2871
+ ))
2872
+ }
2873
+ ),
2874
+ /* @__PURE__ */ jsx(
2875
+ "button",
2876
+ {
2877
+ type: "button",
2878
+ onClick: scrollNext,
2879
+ disabled: !canNext,
2880
+ "aria-label": "Next trips",
2881
+ className: cn(arrowBase4, "right-2"),
2882
+ children: /* @__PURE__ */ jsx(ChevronRight5, {})
2883
+ }
2884
+ ),
2885
+ /* @__PURE__ */ jsx(
2886
+ "div",
2887
+ {
2888
+ role: "progressbar",
2889
+ "aria-valuenow": Math.round(scrollProgress * 100),
2890
+ "aria-valuemin": 0,
2891
+ "aria-valuemax": 100,
2892
+ "aria-label": "Scroll position",
2893
+ className: "relative w-[120px] h-[6px] mt-md mx-auto bg-track rounded-[32px] overflow-hidden",
2894
+ children: /* @__PURE__ */ jsx(
2895
+ "span",
2896
+ {
2897
+ className: "absolute top-0 left-0 h-full bg-primary rounded-[32px] transition-[width] duration-200 ease-in",
2898
+ style: { width: `${progressWidth}px` }
2899
+ }
2900
+ )
2849
2901
  }
2850
2902
  )
2851
- }
2852
- )
2853
- ] }),
2854
- /* @__PURE__ */ jsx("div", { className: "relative -mt-[60px] pb-md md:hidden flex justify-center", children: /* @__PURE__ */ jsx(
2855
- Swiper,
2856
- {
2857
- effect: "cards",
2858
- grabCursor: true,
2859
- modules: [EffectCards],
2860
- className: "w-[74vw] [aspect-ratio:289/367]",
2861
- style: { overflow: "visible" },
2862
- children: trips.map((trip) => /* @__PURE__ */ jsx(
2863
- SwiperSlide,
2903
+ ] }),
2904
+ /* @__PURE__ */ jsx("div", { className: "relative -mt-[60px] pb-md md:hidden flex justify-center", children: /* @__PURE__ */ jsx(
2905
+ Swiper,
2864
2906
  {
2865
- style: { borderRadius: "12px", overflow: "hidden" },
2866
- children: /* @__PURE__ */ jsx(
2867
- TripCategoryCard,
2907
+ effect: "cards",
2908
+ grabCursor: true,
2909
+ modules: [EffectCards],
2910
+ className: "w-[74vw] [aspect-ratio:289/367]",
2911
+ style: { overflow: "visible" },
2912
+ children: trips.map((trip) => /* @__PURE__ */ jsx(
2913
+ SwiperSlide,
2868
2914
  {
2869
- image: trip.image,
2870
- alt: trip.alt,
2871
- destination: trip.destination,
2872
- startingPrice: trip.startingPrice,
2873
- href: trip.href,
2874
- className: "w-full h-full rounded-xl shrink-0"
2875
- }
2876
- )
2877
- },
2878
- `${trip.image}|${trip.destination}|mobile`
2879
- ))
2880
- }
2881
- ) })
2882
- ] });
2915
+ style: { borderRadius: "12px", overflow: "hidden" },
2916
+ children: /* @__PURE__ */ jsx(
2917
+ TripCategoryCard,
2918
+ {
2919
+ image: trip.image,
2920
+ alt: trip.alt,
2921
+ destination: trip.destination,
2922
+ startingPrice: trip.startingPrice,
2923
+ href: trip.href,
2924
+ className: "w-full h-full rounded-xl shrink-0"
2925
+ }
2926
+ )
2927
+ },
2928
+ `${trip.image}|${trip.destination}|mobile`
2929
+ ))
2930
+ }
2931
+ ) })
2932
+ ]
2933
+ }
2934
+ );
2883
2935
  }
2884
2936
  );
2885
2937
  TripsCategorySection.displayName = "TripsCategorySection";