@canopy-iiif/app 1.6.20 → 1.6.22

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.
@@ -557,13 +557,31 @@ async function mountImageStory(element, props = {}) {
557
557
  }
558
558
 
559
559
  // ui/src/iiif/ImageStory.jsx
560
+ var DEFAULT_IMAGE_STORY_HEIGHT = 600;
561
+ var NUMERIC_HEIGHT_PATTERN = /^[+-]?(?:\d+|\d*\.\d+)$/;
562
+ function resolveContainerHeight(value) {
563
+ if (typeof value === "number" && Number.isFinite(value)) {
564
+ return `${value}px`;
565
+ }
566
+ if (typeof value === "string") {
567
+ const trimmed = value.trim();
568
+ if (!trimmed) {
569
+ return `${DEFAULT_IMAGE_STORY_HEIGHT}px`;
570
+ }
571
+ if (NUMERIC_HEIGHT_PATTERN.test(trimmed)) {
572
+ return `${trimmed}px`;
573
+ }
574
+ return trimmed;
575
+ }
576
+ return `${DEFAULT_IMAGE_STORY_HEIGHT}px`;
577
+ }
560
578
  var ImageStory = (props = {}) => {
561
579
  const {
562
580
  iiifContent,
563
581
  disablePanAndZoom,
564
582
  pointOfInterestSvgUrl,
565
583
  viewerOptions,
566
- height = 600,
584
+ height = DEFAULT_IMAGE_STORY_HEIGHT,
567
585
  className,
568
586
  style,
569
587
  ...rest
@@ -572,6 +590,9 @@ var ImageStory = (props = {}) => {
572
590
  const resolvedClassName = useMemo(() => {
573
591
  return ["canopy-image-story", className].filter(Boolean).join(" ");
574
592
  }, [className]);
593
+ const resolvedHeight = useMemo(() => {
594
+ return resolveContainerHeight(height);
595
+ }, [height]);
575
596
  const serializedProps = useMemo(() => {
576
597
  return serializeImageStoryProps({
577
598
  iiifContent,
@@ -617,7 +638,7 @@ var ImageStory = (props = {}) => {
617
638
  "data-canopy-image-story": "1",
618
639
  style: {
619
640
  width: "100%",
620
- height: typeof height === "number" ? `${height}px` : height,
641
+ height: resolvedHeight,
621
642
  ...style || {}
622
643
  },
623
644
  ...rest