@canopy-iiif/app 1.9.8 → 1.9.9

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.
@@ -702,10 +702,11 @@ function Button({
702
702
  variant = "primary",
703
703
  className = "",
704
704
  children,
705
+ as: Element = "a",
705
706
  ...rest
706
707
  }) {
707
708
  const resolvedVariant = VARIANTS.has(variant) ? variant : "primary";
708
- const computedRel = target === "_blank" && !rel ? "noopener noreferrer" : rel;
709
+ const computedRel = Element === "a" && target === "_blank" && !rel ? "noopener noreferrer" : rel;
709
710
  const content = children != null ? children : label;
710
711
  if (!content) return null;
711
712
  const classes = [
@@ -713,17 +714,19 @@ function Button({
713
714
  `canopy-button--${resolvedVariant}`,
714
715
  className
715
716
  ].filter(Boolean).join(" ");
716
- return /* @__PURE__ */ React8.createElement(
717
- "a",
718
- {
719
- href,
720
- className: classes,
721
- target,
722
- rel: computedRel,
723
- ...rest
724
- },
725
- content
726
- );
717
+ const elementProps = {
718
+ className: classes,
719
+ ...rest
720
+ };
721
+ if (Element === "a") {
722
+ elementProps.href = href;
723
+ if (target) elementProps.target = target;
724
+ if (computedRel) elementProps.rel = computedRel;
725
+ } else {
726
+ if (typeof target !== "undefined") elementProps.target = target;
727
+ if (computedRel) elementProps.rel = computedRel;
728
+ }
729
+ return /* @__PURE__ */ React8.createElement(Element, { ...elementProps }, content);
727
730
  }
728
731
 
729
732
  // ui/src/layout/ButtonWrapper.jsx
@@ -887,8 +890,8 @@ function Hero({
887
890
  }) {
888
891
  const normalizedVariant = normalizeVariant(variant);
889
892
  const isBreadcrumbVariant = normalizedVariant === "breadcrumb";
890
- const PageContext = navigationHelpers && typeof navigationHelpers.getPageContext === "function" ? navigationHelpers.getPageContext() : null;
891
- const pageContext = PageContext ? React10.useContext(PageContext) : null;
893
+ const PageContext2 = navigationHelpers && typeof navigationHelpers.getPageContext === "function" ? navigationHelpers.getPageContext() : null;
894
+ const pageContext = PageContext2 ? React10.useContext(PageContext2) : null;
892
895
  let orderedSlides = [];
893
896
  if (!isBreadcrumbVariant) {
894
897
  const resolved = resolveFeaturedItem({ item, index, random });
@@ -1248,8 +1251,8 @@ function SubNavigation({
1248
1251
  heading,
1249
1252
  ariaLabel
1250
1253
  }) {
1251
- const PageContext = navigationHelpers2 && navigationHelpers2.getPageContext ? navigationHelpers2.getPageContext() : null;
1252
- const context = PageContext ? React12.useContext(PageContext) : null;
1254
+ const PageContext2 = navigationHelpers2 && navigationHelpers2.getPageContext ? navigationHelpers2.getPageContext() : null;
1255
+ const context = PageContext2 ? React12.useContext(PageContext2) : null;
1253
1256
  const contextNavigation = context && context.navigation ? context.navigation : null;
1254
1257
  const contextPage = context && context.page ? context.page : null;
1255
1258
  const effectiveNavigation = navigationProp || contextNavigation;
@@ -2013,8 +2016,8 @@ function Layout({
2013
2016
  contentNavigationClassName = "",
2014
2017
  ...rest
2015
2018
  }) {
2016
- const PageContext = navigationHelpers3 && typeof navigationHelpers3.getPageContext === "function" ? navigationHelpers3.getPageContext() : null;
2017
- const context = PageContext ? React14.useContext(PageContext) : null;
2019
+ const PageContext2 = navigationHelpers3 && typeof navigationHelpers3.getPageContext === "function" ? navigationHelpers3.getPageContext() : null;
2020
+ const context = PageContext2 ? React14.useContext(PageContext2) : null;
2018
2021
  const pageHeadings = React14.useMemo(() => {
2019
2022
  const headings = context && context.page ? context.page.headings : null;
2020
2023
  return Array.isArray(headings) ? headings : [];
@@ -2315,22 +2318,40 @@ function SearchPanel(props = {}) {
2315
2318
  }
2316
2319
 
2317
2320
  // ui/src/layout/CanopyBrand.jsx
2321
+ import React20 from "react";
2322
+
2323
+ // ui/src/layout/pageContext.js
2318
2324
  import React19 from "react";
2325
+ var CONTEXT_KEY = typeof Symbol === "function" ? Symbol.for("__CANOPY_PAGE_CONTEXT__") : "__CANOPY_PAGE_CONTEXT__";
2326
+ function getSharedRoot() {
2327
+ if (typeof globalThis !== "undefined") return globalThis;
2328
+ if (typeof window !== "undefined") return window;
2329
+ if (typeof global !== "undefined") return global;
2330
+ return null;
2331
+ }
2332
+ function getSafePageContext() {
2333
+ const root = getSharedRoot();
2334
+ if (root && root[CONTEXT_KEY]) return root[CONTEXT_KEY];
2335
+ const ctx = React19.createContext({ navigation: null, page: null, site: null });
2336
+ if (root) root[CONTEXT_KEY] = ctx;
2337
+ return ctx;
2338
+ }
2339
+
2340
+ // ui/src/layout/CanopyBrand.jsx
2341
+ var PageContext = getSafePageContext();
2319
2342
  function CanopyBrand(props = {}) {
2320
- const {
2321
- labelId,
2322
- label = "Canopy IIIF",
2323
- href = "/",
2324
- className,
2325
- Logo
2326
- } = props || {};
2343
+ const { labelId, label: labelProp, href = "/", className, Logo } = props || {};
2344
+ const context = React20.useContext(PageContext);
2345
+ const contextSiteTitle = context && context.site && typeof context.site.title === "string" ? context.site.title.trim() : "";
2346
+ const normalizedLabel = typeof labelProp === "string" && labelProp.trim() ? labelProp : "";
2347
+ const resolvedLabel = normalizedLabel || contextSiteTitle || "Site title";
2327
2348
  const spanProps = labelId ? { id: labelId } : {};
2328
2349
  const classes = ["canopy-logo", className].filter(Boolean).join(" ");
2329
- return /* @__PURE__ */ React19.createElement("a", { href, className: classes }, typeof Logo === "function" ? /* @__PURE__ */ React19.createElement(Logo, null) : null, /* @__PURE__ */ React19.createElement("span", { ...spanProps }, label));
2350
+ return /* @__PURE__ */ React20.createElement("a", { href, className: classes }, typeof Logo === "function" ? /* @__PURE__ */ React20.createElement(Logo, null) : null, /* @__PURE__ */ React20.createElement("span", { ...spanProps }, resolvedLabel));
2330
2351
  }
2331
2352
 
2332
2353
  // ui/src/layout/CanopyModal.jsx
2333
- import React20 from "react";
2354
+ import React21 from "react";
2334
2355
  function CanopyModal(props = {}) {
2335
2356
  const {
2336
2357
  id,
@@ -2381,7 +2402,7 @@ function CanopyModal(props = {}) {
2381
2402
  if (padded) bodyClasses.push("canopy-modal__body--padded");
2382
2403
  if (bodyClassName) bodyClasses.push(bodyClassName);
2383
2404
  const bodyClassNameValue = bodyClasses.join(" ");
2384
- return /* @__PURE__ */ React20.createElement("div", { ...modalProps }, /* @__PURE__ */ React20.createElement("div", { className: "canopy-modal__panel" }, /* @__PURE__ */ React20.createElement("button", { ...closeButtonProps }, /* @__PURE__ */ React20.createElement(
2405
+ return /* @__PURE__ */ React21.createElement("div", { ...modalProps }, /* @__PURE__ */ React21.createElement("div", { className: "canopy-modal__panel" }, /* @__PURE__ */ React21.createElement("button", { ...closeButtonProps }, /* @__PURE__ */ React21.createElement(
2385
2406
  "svg",
2386
2407
  {
2387
2408
  xmlns: "http://www.w3.org/2000/svg",
@@ -2391,8 +2412,8 @@ function CanopyModal(props = {}) {
2391
2412
  strokeWidth: "1.5",
2392
2413
  className: "canopy-modal__close-icon"
2393
2414
  },
2394
- /* @__PURE__ */ React20.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 6l12 12M6 18L18 6" })
2395
- ), /* @__PURE__ */ React20.createElement("span", { className: "sr-only" }, closeLabel)), /* @__PURE__ */ React20.createElement("div", { className: bodyClassNameValue }, label ? /* @__PURE__ */ React20.createElement("div", { className: "canopy-modal__brand" }, /* @__PURE__ */ React20.createElement(
2415
+ /* @__PURE__ */ React21.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 6l12 12M6 18L18 6" })
2416
+ ), /* @__PURE__ */ React21.createElement("span", { className: "sr-only" }, closeLabel)), /* @__PURE__ */ React21.createElement("div", { className: bodyClassNameValue }, label ? /* @__PURE__ */ React21.createElement("div", { className: "canopy-modal__brand" }, /* @__PURE__ */ React21.createElement(
2396
2417
  CanopyBrand,
2397
2418
  {
2398
2419
  labelId: resolvedLabelId,
@@ -2404,23 +2425,6 @@ function CanopyModal(props = {}) {
2404
2425
  )) : null, children)));
2405
2426
  }
2406
2427
 
2407
- // ui/src/layout/pageContext.js
2408
- import React21 from "react";
2409
- var CONTEXT_KEY = typeof Symbol === "function" ? Symbol.for("__CANOPY_PAGE_CONTEXT__") : "__CANOPY_PAGE_CONTEXT__";
2410
- function getSharedRoot() {
2411
- if (typeof globalThis !== "undefined") return globalThis;
2412
- if (typeof window !== "undefined") return window;
2413
- if (typeof global !== "undefined") return global;
2414
- return null;
2415
- }
2416
- function getSafePageContext() {
2417
- const root = getSharedRoot();
2418
- if (root && root[CONTEXT_KEY]) return root[CONTEXT_KEY];
2419
- const ctx = React21.createContext({ navigation: null, page: null, site: null });
2420
- if (root) root[CONTEXT_KEY] = ctx;
2421
- return ctx;
2422
- }
2423
-
2424
2428
  // ui/src/layout/LanguageToggle.jsx
2425
2429
  import React23 from "react";
2426
2430
 
@@ -2733,8 +2737,8 @@ function LanguageToggle({
2733
2737
  label,
2734
2738
  ariaLabel
2735
2739
  }) {
2736
- const PageContext = getSafePageContext();
2737
- const context = React23.useContext(PageContext);
2740
+ const PageContext2 = getSafePageContext();
2741
+ const context = React23.useContext(PageContext2);
2738
2742
  const siteLanguageToggle = context && context.site && context.site.languageToggle || null;
2739
2743
  const pageData = page || (context && context.page ? context.page : null);
2740
2744
  const resolvedToggle = languageToggle === false ? null : languageToggle === true || typeof languageToggle === "undefined" ? siteLanguageToggle : languageToggle;
@@ -3132,8 +3136,8 @@ function CanopyHeader(props = {}) {
3132
3136
  logo: SiteLogo,
3133
3137
  languageToggle: languageToggleProp
3134
3138
  } = props;
3135
- const PageContext = getSafePageContext();
3136
- const context = React24.useContext(PageContext);
3139
+ const PageContext2 = getSafePageContext();
3140
+ const context = React24.useContext(PageContext2);
3137
3141
  const contextPrimaryNav = context && Array.isArray(context.primaryNavigation) ? context.primaryNavigation : [];
3138
3142
  const navLinks = navLinksProp && navLinksProp.length ? ensureArray(navLinksProp) : ensureArray(contextPrimaryNav);
3139
3143
  const contextNavigation = context && context.navigation ? context.navigation : null;
@@ -3608,9 +3612,9 @@ import React30 from "react";
3608
3612
  import navigationHelpers4 from "@canopy-iiif/app/lib/components/navigation.js";
3609
3613
  function useReferencedItems(itemsProp) {
3610
3614
  if (Array.isArray(itemsProp)) return itemsProp;
3611
- const PageContext = navigationHelpers4 && typeof navigationHelpers4.getPageContext === "function" ? navigationHelpers4.getPageContext() : null;
3612
- if (!PageContext) return [];
3613
- const context = React30.useContext(PageContext);
3615
+ const PageContext2 = navigationHelpers4 && typeof navigationHelpers4.getPageContext === "function" ? navigationHelpers4.getPageContext() : null;
3616
+ if (!PageContext2) return [];
3617
+ const context = React30.useContext(PageContext2);
3614
3618
  const items = context && context.page ? context.page.referencedItems : null;
3615
3619
  return Array.isArray(items) ? items : [];
3616
3620
  }
@@ -3683,8 +3687,8 @@ function References({
3683
3687
  children,
3684
3688
  ...rest
3685
3689
  }) {
3686
- const PageContext = getPageContext();
3687
- const context = PageContext ? React31.useContext(PageContext) : null;
3690
+ const PageContext2 = getPageContext();
3691
+ const context = PageContext2 ? React31.useContext(PageContext2) : null;
3688
3692
  const contextPage = context && context.page ? context.page : null;
3689
3693
  const manifestId = id || contextPage && contextPage.manifestId || "";
3690
3694
  const contextReferences = !id && contextPage && Array.isArray(contextPage.referencedBy) ? contextPage.referencedBy : null;
@@ -4708,8 +4712,8 @@ function getReferencedModule() {
4708
4712
  return referencedModule;
4709
4713
  }
4710
4714
  function useReferencedManifestMap() {
4711
- const PageContext = getPageContext2() || PageContextFallback;
4712
- const pageContext = React36.useContext(PageContext);
4715
+ const PageContext2 = getPageContext2() || PageContextFallback;
4716
+ const pageContext = React36.useContext(PageContext2);
4713
4717
  const referencedItems = pageContext && pageContext.page && Array.isArray(pageContext.page.referencedItems) ? pageContext.page.referencedItems : [];
4714
4718
  return React36.useMemo(() => {
4715
4719
  const map = /* @__PURE__ */ new Map();