@canopy-iiif/app 1.9.4 → 1.9.5

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.
@@ -5753,13 +5753,40 @@ function renderPreview(props = {}) {
5753
5753
  }
5754
5754
  return /* @__PURE__ */ React39.createElement("div", { className: "canopy-gallery__placeholder", "aria-hidden": "true" });
5755
5755
  }
5756
+ function renderFlexibleContent(content, options = {}) {
5757
+ var _a, _b;
5758
+ const {
5759
+ inlineTag: InlineTag = "span",
5760
+ blockTag: BlockTag = "div",
5761
+ className,
5762
+ id
5763
+ } = options;
5764
+ if (content == null || content === false) return null;
5765
+ const isPrimitive = typeof content === "string" || typeof content === "number" || typeof content === "bigint";
5766
+ if (isPrimitive) {
5767
+ return /* @__PURE__ */ React39.createElement(InlineTag, { className, id }, content);
5768
+ }
5769
+ if (React39.isValidElement(content)) {
5770
+ if (content.type === React39.Fragment) {
5771
+ return /* @__PURE__ */ React39.createElement(BlockTag, { className, id }, content);
5772
+ }
5773
+ const mergedClassName = [(_a = content.props) == null ? void 0 : _a.className, className].filter(Boolean).join(" ");
5774
+ return React39.cloneElement(content, {
5775
+ ...content.props,
5776
+ className: mergedClassName || void 0,
5777
+ id: ((_b = content.props) == null ? void 0 : _b.id) || id
5778
+ });
5779
+ }
5780
+ const FallbackTag = BlockTag;
5781
+ return /* @__PURE__ */ React39.createElement(FallbackTag, { className, id }, content);
5782
+ }
5756
5783
  function normalizeItem(child, index, galleryId, manifestMap) {
5757
5784
  var _a;
5758
5785
  if (!React39.isValidElement(child)) return null;
5759
5786
  if (child.type !== GalleryItem && ((_a = child.type) == null ? void 0 : _a.displayName) !== "GalleryItem")
5760
5787
  return null;
5761
5788
  const props = child.props || {};
5762
- const manifestValues = Array.isArray(props.referencedManifests) ? props.referencedManifests : props.manifest ? [props.manifest] : Array.isArray(props.manifests) ? props.manifests : [];
5789
+ const manifestValues = props.referencedManifests ? ensureArray2(props.referencedManifests) : props.manifest ? [props.manifest] : props.manifests ? ensureArray2(props.manifests) : [];
5763
5790
  const manifests = resolveReferencedManifests(manifestValues, manifestMap);
5764
5791
  const normalizedProps = { ...props };
5765
5792
  if (!normalizedProps.title) {
@@ -5830,7 +5857,11 @@ function buildCaptionContent(itemProps) {
5830
5857
  if (itemProps.caption) return itemProps.caption;
5831
5858
  const kicker = itemProps.kicker || itemProps.label || itemProps.eyebrow;
5832
5859
  const summary = itemProps.summary || itemProps.description;
5833
- return /* @__PURE__ */ React39.createElement(React39.Fragment, null, kicker ? /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__kicker" }, kicker) : null, itemProps.title ? /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__title-text" }, itemProps.title) : null, summary ? /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__summary" }, summary) : null, renderMetaList(
5860
+ return /* @__PURE__ */ React39.createElement(React39.Fragment, null, kicker ? /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__kicker" }, kicker) : null, itemProps.title ? /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__title-text" }, itemProps.title) : null, renderFlexibleContent(summary, {
5861
+ inlineTag: "span",
5862
+ blockTag: "div",
5863
+ className: "canopy-gallery__summary"
5864
+ }), renderMetaList(
5834
5865
  itemProps.meta,
5835
5866
  "canopy-gallery__meta canopy-gallery__meta--caption"
5836
5867
  ));
@@ -5912,14 +5943,12 @@ function GalleryModal({ item, closeTargetId, navItems, navGroupName }) {
5912
5943
  ">"
5913
5944
  ),
5914
5945
  /* @__PURE__ */ React39.createElement("span", { className: "canopy-gallery__visually-hidden" }, "Next item")
5915
- ), /* @__PURE__ */ React39.createElement("header", { className: "canopy-gallery__modal-header" }, /* @__PURE__ */ React39.createElement("div", { className: "canopy-gallery__modal-text" }, kicker ? /* @__PURE__ */ React39.createElement("p", { className: "canopy-gallery__modal-kicker" }, kicker) : null, /* @__PURE__ */ React39.createElement("h3", { id: modalTitleId, className: "canopy-gallery__modal-title" }, modalTitle), summary ? /* @__PURE__ */ React39.createElement(
5916
- "p",
5917
- {
5918
- id: modalDescriptionId || void 0,
5919
- className: "canopy-gallery__modal-summary"
5920
- },
5921
- summary
5922
- ) : null, renderMetaList(
5946
+ ), /* @__PURE__ */ React39.createElement("header", { className: "canopy-gallery__modal-header" }, /* @__PURE__ */ React39.createElement("div", { className: "canopy-gallery__modal-text" }, kicker ? /* @__PURE__ */ React39.createElement("p", { className: "canopy-gallery__modal-kicker" }, kicker) : null, /* @__PURE__ */ React39.createElement("h3", { id: modalTitleId, className: "canopy-gallery__modal-title" }, modalTitle), renderFlexibleContent(summary, {
5947
+ inlineTag: "p",
5948
+ blockTag: "div",
5949
+ className: "canopy-gallery__modal-summary",
5950
+ id: modalDescriptionId || void 0
5951
+ }), renderMetaList(
5923
5952
  props.meta,
5924
5953
  "canopy-gallery__meta canopy-gallery__meta--modal"
5925
5954
  ), manifests && manifests.length ? manifests.map((manifest) => /* @__PURE__ */ React39.createElement("a", { key: manifest.id || manifest.href, href: manifest.href }, manifest.title || manifest.href)) : null)), /* @__PURE__ */ React39.createElement("div", { className: "canopy-gallery__modal-body" }, props.children)))