@canopy-iiif/app 0.13.0 → 0.13.2

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.
@@ -4,7 +4,10 @@ import CloverSlider from '@samvera/clover-iiif/slider';
4
4
  import 'swiper/css';
5
5
  import 'swiper/css/navigation';
6
6
  import 'swiper/css/pagination';
7
- import { mergeSliderOptions, normalizeSliderOptions } from '../../ui/src/iiif/sliderOptions.js';
7
+ import {
8
+ mergeSliderOptions,
9
+ normalizeSliderOptions,
10
+ } from '../../ui/dist/index.mjs';
8
11
 
9
12
  function ready(fn) {
10
13
  if (document.readyState === 'loading') {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { createRoot, hydrateRoot } from 'react-dom/client';
3
- import Timeline from '../../ui/src/content/timeline/Timeline.jsx';
3
+ import { Timeline } from '../../ui/dist/index.mjs';
4
4
 
5
5
  function ready(fn) {
6
6
  if (typeof document === 'undefined') return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",
package/ui/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ var HelloWorld = () => {
6
6
 
7
7
  // ui/src/layout/Card.jsx
8
8
  import React2, { useEffect, useRef, useState } from "react";
9
+ var DEFAULT_CARD_ASPECT_RATIO = 4 / 3;
9
10
  function Card({
10
11
  href,
11
12
  src,
@@ -23,12 +24,15 @@ function Card({
23
24
  ...rest
24
25
  }) {
25
26
  const containerRef = useRef(null);
26
- const [inView, setInView] = useState(!lazy);
27
- const [imageLoaded, setImageLoaded] = useState(!lazy);
27
+ const isBrowser = typeof window !== "undefined";
28
+ const supportsIntersectionObserver = typeof IntersectionObserver === "function";
29
+ const shouldRenderImmediately = !lazy || !isBrowser || !supportsIntersectionObserver;
30
+ const [inView, setInView] = useState(shouldRenderImmediately);
31
+ const [imageLoaded, setImageLoaded] = useState(shouldRenderImmediately);
28
32
  useEffect(() => {
29
33
  if (!lazy) return;
30
34
  if (!containerRef.current) return;
31
- if (typeof IntersectionObserver !== "function") {
35
+ if (!supportsIntersectionObserver) {
32
36
  setInView(true);
33
37
  return;
34
38
  }
@@ -58,10 +62,12 @@ function Card({
58
62
  } catch (_) {
59
63
  }
60
64
  };
61
- }, [lazy]);
65
+ }, [lazy, supportsIntersectionObserver]);
62
66
  const w = Number(imgWidth);
63
67
  const h = Number(imgHeight);
64
- const ratio = Number.isFinite(Number(aspectRatio)) && Number(aspectRatio) > 0 ? Number(aspectRatio) : Number.isFinite(w) && w > 0 && Number.isFinite(h) && h > 0 ? w / h : void 0;
68
+ const hasAspectRatio = Number.isFinite(Number(aspectRatio)) && Number(aspectRatio) > 0;
69
+ const hasDimensions = Number.isFinite(w) && w > 0 && Number.isFinite(h) && h > 0;
70
+ const ratio = hasAspectRatio ? Number(aspectRatio) : hasDimensions ? w / h : src ? DEFAULT_CARD_ASPECT_RATIO : void 0;
65
71
  const paddingPercent = ratio ? 100 / ratio : 100;
66
72
  const caption = /* @__PURE__ */ React2.createElement("figcaption", null, title && /* @__PURE__ */ React2.createElement("span", null, title), subtitle && /* @__PURE__ */ React2.createElement("span", null, subtitle), children);
67
73
  return /* @__PURE__ */ React2.createElement(
@@ -2682,6 +2688,9 @@ export {
2682
2688
  TeaserCard,
2683
2689
  Timeline,
2684
2690
  TimelinePoint,
2685
- Viewer
2691
+ Viewer,
2692
+ mergeSliderOptions,
2693
+ normalizeSliderOptions,
2694
+ sliderOptions
2686
2695
  };
2687
2696
  //# sourceMappingURL=index.mjs.map