@planetaexo/design-system 0.54.0 → 0.54.1

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
@@ -2428,18 +2428,52 @@ interface PictureProps extends React.ImgHTMLAttributes<HTMLImageElement> {
2428
2428
  * AVIF, art-direction, etc. Render order = priority.
2429
2429
  */
2430
2430
  extraSources?: React.ReactNode;
2431
+ /**
2432
+ * Disable lazy loading. Use for LCP (hero, first card above the fold)
2433
+ * so the browser starts the request immediately instead of waiting for
2434
+ * the IntersectionObserver to fire.
2435
+ * @default false
2436
+ */
2437
+ eager?: boolean;
2438
+ /**
2439
+ * How far before the image enters the viewport to start loading.
2440
+ * Matches WP-Rocket's "Load images on visible viewport" — anything
2441
+ * within `rootMargin` triggers the swap. @default "200px"
2442
+ */
2443
+ rootMargin?: string;
2431
2444
  }
2432
2445
  /**
2433
- * `<img>` with a transparent WebP `<source>` wrapper.
2446
+ * `<img>` with a transparent WebP `<source>` wrapper AND
2447
+ * IntersectionObserver-based lazy load (WP-Rocket style).
2448
+ *
2449
+ * Behavior:
2450
+ * - SSR / first paint: the `<img>` renders a 1×1 transparent placeholder
2451
+ * in `src`; the real URL lives in `data-src`. The `<source srcset>` is
2452
+ * only emitted once the image enters the viewport — so no network
2453
+ * request fires for off-screen images, period.
2454
+ * - On mount: an `IntersectionObserver` watches with
2455
+ * `rootMargin: 200px` (configurable). When the placeholder gets within
2456
+ * 200px of the viewport, state flips and the component re-renders
2457
+ * with the real `src` (+ WebP `<source>` if eligible). The browser
2458
+ * decodes asynchronously thanks to `decoding="async"`.
2459
+ * - Pass `eager` to skip the observer entirely — required for LCP
2460
+ * images (hero, above-the-fold cards). Eager renders the real URL
2461
+ * synchronously.
2434
2462
  *
2435
- * Drop-in replacement for `<img>`. For sources that aren't WebP-eligible
2436
- * (SVG, GIF, base64), the `<picture>` wrapper is skipped and we render
2437
- * the plain `<img>` saves a useless `<picture>` element in the markup.
2463
+ * Why not just `loading="lazy"`?
2464
+ * Native `loading="lazy"` is honored by modern browsers but the
2465
+ * threshold isn't tunable (Chromium loads at ~3 viewports out, Firefox
2466
+ * at the next page). WP-Rocket's appeal is the predictable, small
2467
+ * `rootMargin` — 200px feels much more "just in time", saves more
2468
+ * bandwidth on long pages, and tests cleanly via DevTools network throttling.
2438
2469
  *
2439
- * Intentionally lightweight: no probing, no fetch, no preload. The
2440
- * browser's native `<picture>` resolver does the right thing for free.
2470
+ * SSR safety:
2471
+ * Marked `"use client"` because of the observer. The first render
2472
+ * (server + client hydration) emits the placeholder; the swap happens
2473
+ * one effect tick later. Hydration mismatch is impossible because both
2474
+ * sides start from `visible = eager`.
2441
2475
  */
2442
- declare function Picture({ src, extraSources, ...imgProps }: PictureProps): react_jsx_runtime.JSX.Element;
2476
+ declare function Picture({ src, extraSources, eager, rootMargin, decoding, loading, ...imgProps }: PictureProps): react_jsx_runtime.JSX.Element;
2443
2477
 
2444
2478
  /**
2445
2479
  * WebP-fallback helpers for components that render content-image URLs.
package/dist/index.d.ts CHANGED
@@ -2428,18 +2428,52 @@ interface PictureProps extends React.ImgHTMLAttributes<HTMLImageElement> {
2428
2428
  * AVIF, art-direction, etc. Render order = priority.
2429
2429
  */
2430
2430
  extraSources?: React.ReactNode;
2431
+ /**
2432
+ * Disable lazy loading. Use for LCP (hero, first card above the fold)
2433
+ * so the browser starts the request immediately instead of waiting for
2434
+ * the IntersectionObserver to fire.
2435
+ * @default false
2436
+ */
2437
+ eager?: boolean;
2438
+ /**
2439
+ * How far before the image enters the viewport to start loading.
2440
+ * Matches WP-Rocket's "Load images on visible viewport" — anything
2441
+ * within `rootMargin` triggers the swap. @default "200px"
2442
+ */
2443
+ rootMargin?: string;
2431
2444
  }
2432
2445
  /**
2433
- * `<img>` with a transparent WebP `<source>` wrapper.
2446
+ * `<img>` with a transparent WebP `<source>` wrapper AND
2447
+ * IntersectionObserver-based lazy load (WP-Rocket style).
2448
+ *
2449
+ * Behavior:
2450
+ * - SSR / first paint: the `<img>` renders a 1×1 transparent placeholder
2451
+ * in `src`; the real URL lives in `data-src`. The `<source srcset>` is
2452
+ * only emitted once the image enters the viewport — so no network
2453
+ * request fires for off-screen images, period.
2454
+ * - On mount: an `IntersectionObserver` watches with
2455
+ * `rootMargin: 200px` (configurable). When the placeholder gets within
2456
+ * 200px of the viewport, state flips and the component re-renders
2457
+ * with the real `src` (+ WebP `<source>` if eligible). The browser
2458
+ * decodes asynchronously thanks to `decoding="async"`.
2459
+ * - Pass `eager` to skip the observer entirely — required for LCP
2460
+ * images (hero, above-the-fold cards). Eager renders the real URL
2461
+ * synchronously.
2434
2462
  *
2435
- * Drop-in replacement for `<img>`. For sources that aren't WebP-eligible
2436
- * (SVG, GIF, base64), the `<picture>` wrapper is skipped and we render
2437
- * the plain `<img>` saves a useless `<picture>` element in the markup.
2463
+ * Why not just `loading="lazy"`?
2464
+ * Native `loading="lazy"` is honored by modern browsers but the
2465
+ * threshold isn't tunable (Chromium loads at ~3 viewports out, Firefox
2466
+ * at the next page). WP-Rocket's appeal is the predictable, small
2467
+ * `rootMargin` — 200px feels much more "just in time", saves more
2468
+ * bandwidth on long pages, and tests cleanly via DevTools network throttling.
2438
2469
  *
2439
- * Intentionally lightweight: no probing, no fetch, no preload. The
2440
- * browser's native `<picture>` resolver does the right thing for free.
2470
+ * SSR safety:
2471
+ * Marked `"use client"` because of the observer. The first render
2472
+ * (server + client hydration) emits the placeholder; the swap happens
2473
+ * one effect tick later. Hydration mismatch is impossible because both
2474
+ * sides start from `visible = eager`.
2441
2475
  */
2442
- declare function Picture({ src, extraSources, ...imgProps }: PictureProps): react_jsx_runtime.JSX.Element;
2476
+ declare function Picture({ src, extraSources, eager, rootMargin, decoding, loading, ...imgProps }: PictureProps): react_jsx_runtime.JSX.Element;
2443
2477
 
2444
2478
  /**
2445
2479
  * WebP-fallback helpers for components that render content-image URLs.