@deriv-web-design/ui 0.1.18 → 0.1.20

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.
@@ -891,7 +891,7 @@
891
891
  "name": "DotLottieInView",
892
892
  "source": "components/DotLottieInView/DotLottieInView.tsx",
893
893
  "props": {},
894
- "description": "Plays a .lottie once when it scrolls into view. Stops and resets when it leaves view. When it enters view again, it plays once more. Set `enabled={false}` to force stop (e.g. hidden slides) without relying on geometry alone. The player itself is fetched lazily, the first time this instance is both enabled and in view — so a page with no animation never downloads it, and a below-the-fold band does not pay for it during initial load."
894
+ "description": "Plays a .lottie once when it scrolls into view. Stops and resets when it leaves view. When it enters view again, it plays once more. Set `enabled={false}` to force stop (e.g. hidden slides) without relying on geometry alone. The player itself is fetched lazily, the first time this instance is in view — so a page with no animation never downloads it, and a below-the-fold band does not pay for it during initial load. `enabled` gates playback only: a consumer that crossfades between stacked instances needs them all loaded, not just the one currently showing."
895
895
  },
896
896
  "DownloadBadge": {
897
897
  "name": "DownloadBadge",
@@ -1826,6 +1826,16 @@
1826
1826
  "required": true,
1827
1827
  "description": "Visible label on the link, e.g. \"Learn more\""
1828
1828
  },
1829
+ "mediaSizes": {
1830
+ "type": "string",
1831
+ "required": false,
1832
+ "description": "Browser layout contract for `mediaSrcSet`. Defaults to the column this template actually lays out (`(min-width: 992px) 50vw, 100vw`), so a consumer supplying only `mediaSrcSet` still gets a correct pick."
1833
+ },
1834
+ "mediaSrcSet": {
1835
+ "type": "string",
1836
+ "required": false,
1837
+ "description": "Responsive candidates for `mediaUrl`, as a standard `srcset` string. Render-time only — a CMS stores one master URL and the renderer derives these. Without them the same file is sent to every device: the desktop media column is ~560 CSS px (1120 at DPR 2, so a 1200w rendition), while a phone paints the same slot at ~382 CSS px and needs 800w. Measured on one asset: 64,736 B against 40,120 B for the width that actually paints. Ignored for `\"lottie\"` items — an animation is played, not resized."
1838
+ },
1829
1839
  "mediaType": {
1830
1840
  "type": "\"image\" | \"lottie\"",
1831
1841
  "required": false,
@@ -1836,6 +1846,16 @@
1836
1846
  "required": true,
1837
1847
  "description": "URL to the .lottie file or any image asset (png, jpg, svg, webp…)"
1838
1848
  },
1849
+ "posterSizes": {
1850
+ "type": "string",
1851
+ "required": false,
1852
+ "description": "Layout contract for `posterSrcSet`. Same default as `mediaSizes`."
1853
+ },
1854
+ "posterSrcSet": {
1855
+ "type": "string",
1856
+ "required": false,
1857
+ "description": "Responsive candidates for `posterUrl`. Same contract as `mediaSrcSet`."
1858
+ },
1839
1859
  "posterUrl": {
1840
1860
  "type": "string",
1841
1861
  "required": false,
package/dist/index.d.mts CHANGED
@@ -750,6 +750,24 @@ interface FeatureScrollItem {
750
750
  mediaType?: "lottie" | "image";
751
751
  /** URL to the .lottie file or any image asset (png, jpg, svg, webp…) */
752
752
  mediaUrl: string;
753
+ /**
754
+ * Responsive candidates for `mediaUrl`, as a standard `srcset` string.
755
+ *
756
+ * Render-time only — a CMS stores one master URL and the renderer derives
757
+ * these. Without them the same file is sent to every device: the desktop
758
+ * media column is ~560 CSS px (1120 at DPR 2, so a 1200w rendition), while a
759
+ * phone paints the same slot at ~382 CSS px and needs 800w. Measured on one
760
+ * asset: 64,736 B against 40,120 B for the width that actually paints.
761
+ *
762
+ * Ignored for `"lottie"` items — an animation is played, not resized.
763
+ */
764
+ mediaSrcSet?: string;
765
+ /**
766
+ * Browser layout contract for `mediaSrcSet`. Defaults to the column this
767
+ * template actually lays out (`(min-width: 992px) 50vw, 100vw`), so a
768
+ * consumer supplying only `mediaSrcSet` still gets a correct pick.
769
+ */
770
+ mediaSizes?: string;
753
771
  /**
754
772
  * Still frame painted while an animation's player and engine are loading.
755
773
  *
@@ -760,6 +778,10 @@ interface FeatureScrollItem {
760
778
  * a hole in the layout. Ignored once the animation is playing.
761
779
  */
762
780
  posterUrl?: string;
781
+ /** Responsive candidates for `posterUrl`. Same contract as `mediaSrcSet`. */
782
+ posterSrcSet?: string;
783
+ /** Layout contract for `posterSrcSet`. Same default as `mediaSizes`. */
784
+ posterSizes?: string;
763
785
  }
764
786
  interface FeatureScrollProps extends HTMLAttributes<HTMLElement> {
765
787
  /** Section heading rendered as an H2 */
@@ -844,9 +866,11 @@ type DotLottieInViewProps = Omit<ComponentProps<typeof DotLottieReact>, "autopla
844
866
  * When it enters view again, it plays once more. Set `enabled={false}` to force stop
845
867
  * (e.g. hidden slides) without relying on geometry alone.
846
868
  *
847
- * The player itself is fetched lazily, the first time this instance is both
848
- * enabled and in view — so a page with no animation never downloads it, and a
849
- * below-the-fold band does not pay for it during initial load.
869
+ * The player itself is fetched lazily, the first time this instance is in view —
870
+ * so a page with no animation never downloads it, and a below-the-fold band does
871
+ * not pay for it during initial load. `enabled` gates playback only: a consumer
872
+ * that crossfades between stacked instances needs them all loaded, not just the
873
+ * one currently showing.
850
874
  */
851
875
  declare function DotLottieInView({ enabled, rootMargin, threshold, className, style, poster, ...dotProps }: DotLottieInViewProps): react_jsx_runtime.JSX.Element;
852
876
 
package/dist/index.d.ts CHANGED
@@ -750,6 +750,24 @@ interface FeatureScrollItem {
750
750
  mediaType?: "lottie" | "image";
751
751
  /** URL to the .lottie file or any image asset (png, jpg, svg, webp…) */
752
752
  mediaUrl: string;
753
+ /**
754
+ * Responsive candidates for `mediaUrl`, as a standard `srcset` string.
755
+ *
756
+ * Render-time only — a CMS stores one master URL and the renderer derives
757
+ * these. Without them the same file is sent to every device: the desktop
758
+ * media column is ~560 CSS px (1120 at DPR 2, so a 1200w rendition), while a
759
+ * phone paints the same slot at ~382 CSS px and needs 800w. Measured on one
760
+ * asset: 64,736 B against 40,120 B for the width that actually paints.
761
+ *
762
+ * Ignored for `"lottie"` items — an animation is played, not resized.
763
+ */
764
+ mediaSrcSet?: string;
765
+ /**
766
+ * Browser layout contract for `mediaSrcSet`. Defaults to the column this
767
+ * template actually lays out (`(min-width: 992px) 50vw, 100vw`), so a
768
+ * consumer supplying only `mediaSrcSet` still gets a correct pick.
769
+ */
770
+ mediaSizes?: string;
753
771
  /**
754
772
  * Still frame painted while an animation's player and engine are loading.
755
773
  *
@@ -760,6 +778,10 @@ interface FeatureScrollItem {
760
778
  * a hole in the layout. Ignored once the animation is playing.
761
779
  */
762
780
  posterUrl?: string;
781
+ /** Responsive candidates for `posterUrl`. Same contract as `mediaSrcSet`. */
782
+ posterSrcSet?: string;
783
+ /** Layout contract for `posterSrcSet`. Same default as `mediaSizes`. */
784
+ posterSizes?: string;
763
785
  }
764
786
  interface FeatureScrollProps extends HTMLAttributes<HTMLElement> {
765
787
  /** Section heading rendered as an H2 */
@@ -844,9 +866,11 @@ type DotLottieInViewProps = Omit<ComponentProps<typeof DotLottieReact>, "autopla
844
866
  * When it enters view again, it plays once more. Set `enabled={false}` to force stop
845
867
  * (e.g. hidden slides) without relying on geometry alone.
846
868
  *
847
- * The player itself is fetched lazily, the first time this instance is both
848
- * enabled and in view — so a page with no animation never downloads it, and a
849
- * below-the-fold band does not pay for it during initial load.
869
+ * The player itself is fetched lazily, the first time this instance is in view —
870
+ * so a page with no animation never downloads it, and a below-the-fold band does
871
+ * not pay for it during initial load. `enabled` gates playback only: a consumer
872
+ * that crossfades between stacked instances needs them all loaded, not just the
873
+ * one currently showing.
850
874
  */
851
875
  declare function DotLottieInView({ enabled, rootMargin, threshold, className, style, poster, ...dotProps }: DotLottieInViewProps): react_jsx_runtime.JSX.Element;
852
876
 
package/dist/index.js CHANGED
@@ -2676,7 +2676,7 @@ function DotLottieInView({
2676
2676
  }, [rootMargin, threshold]);
2677
2677
  (0, import_react12.useEffect)(() => {
2678
2678
  if (mounted) return;
2679
- if (!(inView && enabled)) return;
2679
+ if (!inView) return;
2680
2680
  if (typeof window === "undefined") return;
2681
2681
  let cancelled = false;
2682
2682
  const commit = () => {
@@ -2691,15 +2691,23 @@ function DotLottieInView({
2691
2691
  }
2692
2692
  if (timerId !== null) window.clearTimeout(timerId);
2693
2693
  };
2694
- }, [inView, enabled, mounted]);
2694
+ }, [inView, mounted]);
2695
2695
  (0, import_react12.useEffect)(() => {
2696
2696
  if (!dotLottie) return;
2697
2697
  if (!enabled || !inView) {
2698
2698
  dotLottie.stop();
2699
2699
  return;
2700
2700
  }
2701
- dotLottie.stop();
2702
- dotLottie.play();
2701
+ const start = () => {
2702
+ dotLottie.stop();
2703
+ dotLottie.play();
2704
+ };
2705
+ if (dotLottie.isLoaded) {
2706
+ start();
2707
+ return;
2708
+ }
2709
+ dotLottie.addEventListener("load", start);
2710
+ return () => dotLottie.removeEventListener("load", start);
2703
2711
  }, [dotLottie, enabled, inView]);
2704
2712
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2705
2713
  "div",
@@ -2796,6 +2804,7 @@ var ChevronRight2 = () => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2796
2804
  )
2797
2805
  }
2798
2806
  );
2807
+ var DEFAULT_MEDIA_SIZES = "(min-width: 992px) 50vw, 100vw";
2799
2808
  function mediaSrc(item) {
2800
2809
  return typeof item.mediaUrl === "string" && item.mediaUrl !== "" ? item.mediaUrl : null;
2801
2810
  }
@@ -2819,6 +2828,10 @@ var MediaRenderer = ({ item, active, rootMargin, threshold }) => {
2819
2828
  "img",
2820
2829
  {
2821
2830
  src: item.posterUrl,
2831
+ ...item.posterSrcSet ? {
2832
+ srcSet: item.posterSrcSet,
2833
+ sizes: item.posterSizes ?? DEFAULT_MEDIA_SIZES
2834
+ } : {},
2822
2835
  alt: "",
2823
2836
  "aria-hidden": "true",
2824
2837
  loading: "lazy",
@@ -2832,6 +2845,7 @@ var MediaRenderer = ({ item, active, rootMargin, threshold }) => {
2832
2845
  "img",
2833
2846
  {
2834
2847
  src,
2848
+ ...item.mediaSrcSet ? { srcSet: item.mediaSrcSet, sizes: item.mediaSizes ?? DEFAULT_MEDIA_SIZES } : {},
2835
2849
  alt: item.title,
2836
2850
  loading: "lazy",
2837
2851
  decoding: "async"