@canopy-iiif/app 1.8.8 → 1.8.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.
@@ -4758,6 +4758,9 @@ var INLINE_SCRIPT2 = `(() => {
4758
4758
  return window.setTimeout(cb, 0);
4759
4759
  };
4760
4760
  let activeModal = null;
4761
+ const NAV_SELECTOR = '[data-canopy-gallery-nav]';
4762
+ const NAV_OPTION_SELECTOR = '[data-canopy-gallery-nav-option]';
4763
+ const NAV_ITEM_SELECTOR = '[data-canopy-gallery-nav-item]';
4761
4764
 
4762
4765
  function isVisible(node) {
4763
4766
  return !!(node && (node.offsetWidth || node.offsetHeight || node.getClientRects().length));
@@ -4786,6 +4789,40 @@ var INLINE_SCRIPT2 = `(() => {
4786
4789
  }
4787
4790
  }
4788
4791
 
4792
+ function resetModalScroll(modal) {
4793
+ if (!modal) return;
4794
+ const panel = modal.querySelector('.canopy-gallery__modal-panel');
4795
+ if (panel) {
4796
+ panel.scrollTop = 0;
4797
+ panel.scrollLeft = 0;
4798
+ }
4799
+ }
4800
+
4801
+ function getOptionItem(option) {
4802
+ if (!option || typeof option.closest !== 'function') return null;
4803
+ return option.closest(NAV_ITEM_SELECTOR);
4804
+ }
4805
+
4806
+ function focusActiveNav(modal) {
4807
+ if (!modal) return false;
4808
+ const nav = modal.querySelector(NAV_SELECTOR);
4809
+ if (!nav) return false;
4810
+ const activeOption =
4811
+ nav.querySelector(NAV_OPTION_SELECTOR + ':checked') ||
4812
+ nav.querySelector(NAV_OPTION_SELECTOR);
4813
+ if (!activeOption) return false;
4814
+ raf(() => {
4815
+ try {
4816
+ activeOption.focus({preventScroll: true});
4817
+ } catch (_) {
4818
+ try {
4819
+ activeOption.focus();
4820
+ } catch (err) {}
4821
+ }
4822
+ });
4823
+ return true;
4824
+ }
4825
+
4789
4826
  function focusInitial(modal) {
4790
4827
  if (!modal) return;
4791
4828
  const focusables = getFocusable(modal);
@@ -4859,7 +4896,10 @@ var INLINE_SCRIPT2 = `(() => {
4859
4896
  }
4860
4897
  activeModal = modal;
4861
4898
  modal.setAttribute('data-canopy-gallery-active', '1');
4862
- focusInitial(modal);
4899
+ resetModalScroll(modal);
4900
+ if (!focusActiveNav(modal)) {
4901
+ focusInitial(modal);
4902
+ }
4863
4903
  return;
4864
4904
  }
4865
4905
  if (!activeModal) return;
@@ -4912,9 +4952,266 @@ var INLINE_SCRIPT2 = `(() => {
4912
4952
  }
4913
4953
  }
4914
4954
 
4915
- window.addEventListener('hashchange', syncFromHash);
4916
- window.addEventListener('pageshow', syncFromHash);
4955
+ function initGalleryNav(nav) {
4956
+ if (!nav || nav.getAttribute('data-canopy-gallery-nav-bound') === '1') {
4957
+ return;
4958
+ }
4959
+ const viewport =
4960
+ nav.querySelector('[data-canopy-gallery-nav-viewport]') ||
4961
+ nav.querySelector('[data-canopy-gallery-nav-track]');
4962
+ if (!viewport) return;
4963
+ const optionNodes = nav.querySelectorAll(NAV_OPTION_SELECTOR);
4964
+ const navOptions = optionNodes ? Array.prototype.slice.call(optionNodes) : [];
4965
+ if (!navOptions.length) return;
4966
+ nav.setAttribute('data-canopy-gallery-nav-bound', '1');
4967
+ const prevBtn = nav.querySelector('[data-canopy-gallery-nav-prev]');
4968
+ const nextBtn = nav.querySelector('[data-canopy-gallery-nav-next]');
4969
+
4970
+ function updateButtons() {
4971
+ if (prevBtn) prevBtn.disabled = false;
4972
+ if (nextBtn) nextBtn.disabled = false;
4973
+ }
4974
+
4975
+ function getOptionLabel(option) {
4976
+ if (!option) return null;
4977
+ let label = option.nextElementSibling;
4978
+ if (label && label.tagName && label.tagName.toLowerCase() === 'label') {
4979
+ return label;
4980
+ }
4981
+ if (option.id) {
4982
+ try {
4983
+ label = nav.querySelector('label[for="' + escapeSelector(option.id) + '"]');
4984
+ if (label) return label;
4985
+ } catch (_) {}
4986
+ }
4987
+ return null;
4988
+ }
4989
+
4990
+ function getTargetIdFromOption(option) {
4991
+ if (!option) return '';
4992
+ const dataId = option.getAttribute('data-canopy-gallery-nav-modal');
4993
+ if (dataId) return String(dataId);
4994
+ const value = option.value || option.getAttribute('value') || '';
4995
+ return String(value);
4996
+ }
4997
+
4998
+ function focusOption(option) {
4999
+ if (!option) return;
5000
+ try {
5001
+ option.focus({preventScroll: true});
5002
+ } catch (_) {
5003
+ try {
5004
+ option.focus();
5005
+ } catch (err) {}
5006
+ }
5007
+ }
5008
+
5009
+ function getActiveIndex() {
5010
+ const currentId = window.location.hash.replace(/^#/, '');
5011
+ if (!currentId) return 0;
5012
+ for (let i = 0; i < navOptions.length; i += 1) {
5013
+ if (getTargetIdFromOption(navOptions[i]) === currentId) {
5014
+ return i;
5015
+ }
5016
+ }
5017
+ return 0;
5018
+ }
5019
+
5020
+ function scrollOptionIntoView(option) {
5021
+ const label = getOptionLabel(option);
5022
+ const target = label || option;
5023
+ if (!target) return;
5024
+ try {
5025
+ target.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'center'});
5026
+ } catch (_) {
5027
+ try {
5028
+ target.scrollIntoView();
5029
+ } catch (err) {}
5030
+ }
5031
+ }
5032
+
5033
+ function activateOption(option, opts = {}) {
5034
+ if (!option) return;
5035
+ const targetId = getTargetIdFromOption(option);
5036
+ if (!targetId) return;
5037
+ const targetHash = '#' + targetId;
5038
+ syncActiveState({targetHash, reveal: true, focus: !!opts.focus});
5039
+ if (window.location.hash === targetHash) {
5040
+ try {
5041
+ window.location.hash = targetHash;
5042
+ } catch (_) {}
5043
+ } else {
5044
+ window.location.hash = targetHash;
5045
+ }
5046
+ }
5047
+
5048
+ function openByOffset(direction) {
5049
+ const total = navOptions.length;
5050
+ if (!total) return;
5051
+ const currentIndex = getActiveIndex();
5052
+ const nextIndex = (currentIndex + direction + total) % total;
5053
+ const nextOption = navOptions[nextIndex];
5054
+ if (!nextOption) return;
5055
+ activateOption(nextOption, {focus: true});
5056
+ }
5057
+
5058
+ function syncActiveState(options) {
5059
+ const targetHash =
5060
+ (options && options.targetHash) || window.location.hash || '';
5061
+ const normalized = String(targetHash)
5062
+ .split('#')
5063
+ .pop()
5064
+ .replace(/^#/, '');
5065
+ let activeIndex = -1;
5066
+ let activeOption = null;
5067
+ navOptions.forEach((option, index) => {
5068
+ const linkTarget = getTargetIdFromOption(option);
5069
+ const isActive = normalized && linkTarget === normalized;
5070
+ const label = getOptionLabel(option);
5071
+ const navItem = getOptionItem(option);
5072
+ if (isActive) {
5073
+ activeIndex = index;
5074
+ activeOption = option;
5075
+ option.checked = true;
5076
+ option.setAttribute('checked', 'checked');
5077
+ option.setAttribute('data-canopy-gallery-nav-active', '1');
5078
+ option.setAttribute('data-canopy-gallery-nav-selected', '1');
5079
+ option.tabIndex = 0;
5080
+ if (label) {
5081
+ label.setAttribute('data-canopy-gallery-nav-active', '1');
5082
+ }
5083
+ if (navItem) {
5084
+ navItem.setAttribute('data-canopy-gallery-nav-selected', '1');
5085
+ }
5086
+ } else {
5087
+ option.checked = false;
5088
+ option.removeAttribute('checked');
5089
+ option.removeAttribute('data-canopy-gallery-nav-active');
5090
+ option.removeAttribute('data-canopy-gallery-nav-selected');
5091
+ option.tabIndex = -1;
5092
+ if (label) {
5093
+ label.removeAttribute('data-canopy-gallery-nav-active');
5094
+ }
5095
+ if (navItem) {
5096
+ navItem.removeAttribute('data-canopy-gallery-nav-selected');
5097
+ }
5098
+ }
5099
+ });
5100
+ if (options && options.reveal && activeIndex >= 0) {
5101
+ scrollOptionIntoView(navOptions[activeIndex]);
5102
+ }
5103
+ if (options && options.focus && activeIndex >= 0) {
5104
+ focusOption(activeOption);
5105
+ }
5106
+ }
5107
+
5108
+ if (prevBtn) {
5109
+ prevBtn.addEventListener('click', function (event) {
5110
+ event.preventDefault();
5111
+ openByOffset(-1);
5112
+ });
5113
+ }
5114
+ if (nextBtn) {
5115
+ nextBtn.addEventListener('click', function (event) {
5116
+ event.preventDefault();
5117
+ openByOffset(1);
5118
+ });
5119
+ }
5120
+
5121
+ viewport.addEventListener('scroll', function () {
5122
+ raf(updateButtons);
5123
+ });
5124
+ window.addEventListener('resize', function () {
5125
+ raf(updateButtons);
5126
+ });
5127
+
5128
+ nav.addEventListener('keydown', function (event) {
5129
+ const target = event.target || event.srcElement;
5130
+ const isOption =
5131
+ target && target.hasAttribute && target.hasAttribute('data-canopy-gallery-nav-option');
5132
+ if (!isOption) return;
5133
+ if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
5134
+ event.preventDefault();
5135
+ openByOffset(1);
5136
+ return;
5137
+ }
5138
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
5139
+ event.preventDefault();
5140
+ openByOffset(-1);
5141
+ return;
5142
+ }
5143
+ if (event.key === 'Tab' && !event.shiftKey) {
5144
+ const actions = nav.closest('.canopy-gallery__modal-actions');
5145
+ const closeBtn = actions && actions.querySelector('.canopy-gallery__modal-close');
5146
+ if (closeBtn) {
5147
+ event.preventDefault();
5148
+ try {
5149
+ closeBtn.focus({preventScroll: true});
5150
+ } catch (_) {
5151
+ try {
5152
+ closeBtn.focus();
5153
+ } catch (err) {}
5154
+ }
5155
+ }
5156
+ }
5157
+ });
5158
+
5159
+ nav.addEventListener('change', function (event) {
5160
+ const target = event.target || event.srcElement;
5161
+ if (!target || typeof target.matches !== 'function') return;
5162
+ if (!target.matches(NAV_OPTION_SELECTOR)) return;
5163
+ activateOption(target, {focus: true});
5164
+ });
5165
+
5166
+ updateButtons();
5167
+ syncActiveState({reveal: true});
5168
+ nav.__canopyGalleryNavUpdate = updateButtons;
5169
+ nav.__canopyGalleryNavRefresh = function (options) {
5170
+ syncActiveState({
5171
+ reveal: options && options.reveal,
5172
+ focus: options && options.focus,
5173
+ });
5174
+ };
5175
+ }
5176
+
5177
+ function bindGalleryNavs() {
5178
+ const navs = document.querySelectorAll('[data-canopy-gallery-nav]');
5179
+ if (!navs || !navs.length) return;
5180
+ Array.prototype.forEach.call(navs, initGalleryNav);
5181
+ refreshGalleryNavs({reveal: true});
5182
+ }
5183
+
5184
+ function refreshGalleryNavs(options) {
5185
+ const opts = options || {};
5186
+ const navs = document.querySelectorAll('[data-canopy-gallery-nav-bound="1"]');
5187
+ if (!navs || !navs.length) return;
5188
+ Array.prototype.forEach.call(navs, function (nav) {
5189
+ if (typeof nav.__canopyGalleryNavUpdate === 'function') {
5190
+ raf(nav.__canopyGalleryNavUpdate);
5191
+ }
5192
+ if (typeof nav.__canopyGalleryNavRefresh === 'function') {
5193
+ raf(function () {
5194
+ nav.__canopyGalleryNavRefresh({
5195
+ reveal: !!opts.reveal,
5196
+ focus: !!opts.focus,
5197
+ });
5198
+ });
5199
+ }
5200
+ });
5201
+ }
5202
+
5203
+ window.addEventListener('hashchange', function () {
5204
+ syncFromHash();
5205
+ refreshGalleryNavs({reveal: true});
5206
+ });
5207
+ window.addEventListener('pageshow', function () {
5208
+ syncFromHash();
5209
+ bindGalleryNavs();
5210
+ refreshGalleryNavs({reveal: true});
5211
+ });
4917
5212
  syncFromHash();
5213
+ bindGalleryNavs();
5214
+ refreshGalleryNavs({reveal: true});
4918
5215
  })()`;
4919
5216
  var galleryInstanceCounter = 0;
4920
5217
  function nextGalleryInstanceId() {
@@ -5051,7 +5348,7 @@ function buildCaptionContent(itemProps) {
5051
5348
  "canopy-gallery__meta canopy-gallery__meta--caption"
5052
5349
  ));
5053
5350
  }
5054
- function GalleryModal({ item, total, closeTargetId, prevTarget, nextTarget }) {
5351
+ function GalleryModal({ item, closeTargetId, navItems, navGroupName }) {
5055
5352
  const {
5056
5353
  props,
5057
5354
  modalId,
@@ -5064,7 +5361,6 @@ function GalleryModal({ item, total, closeTargetId, prevTarget, nextTarget }) {
5064
5361
  const kicker = props.kicker || props.label || props.eyebrow;
5065
5362
  const summary = props.popupDescription || props.modalDescription || props.description || props.summary || null;
5066
5363
  const modalTitle = props.popupTitle || props.modalTitle || props.title || `Item ${index + 1}`;
5067
- const preview = renderPreview(props);
5068
5364
  return /* @__PURE__ */ React36.createElement(
5069
5365
  "div",
5070
5366
  {
@@ -5078,17 +5374,14 @@ function GalleryModal({ item, total, closeTargetId, prevTarget, nextTarget }) {
5078
5374
  "data-canopy-gallery-modal": "true",
5079
5375
  "data-canopy-gallery-close": closeTargetId
5080
5376
  },
5081
- /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-scrim" }, /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-panel" }, /* @__PURE__ */ React36.createElement("header", { className: "canopy-gallery__modal-header" }, preview ? /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-thumb", "aria-hidden": "true" }, preview) : null, /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-text" }, kicker ? /* @__PURE__ */ React36.createElement("p", { className: "canopy-gallery__modal-kicker" }, kicker) : null, /* @__PURE__ */ React36.createElement("h3", { id: modalTitleId, className: "canopy-gallery__modal-title" }, modalTitle), summary ? /* @__PURE__ */ React36.createElement(
5082
- "p",
5377
+ /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-scrim" }, /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-panel" }, /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-actions" }, /* @__PURE__ */ React36.createElement(
5378
+ GalleryThumbnailNav,
5083
5379
  {
5084
- id: modalDescriptionId || void 0,
5085
- className: "canopy-gallery__modal-summary"
5086
- },
5087
- summary
5088
- ) : null, renderMetaList(
5089
- props.meta,
5090
- "canopy-gallery__meta canopy-gallery__meta--modal"
5091
- ))), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-body" }, props.children, manifests && manifests.length ? /* @__PURE__ */ React36.createElement("section", { className: "canopy-gallery__referenced" }, /* @__PURE__ */ React36.createElement("h4", null, "Referenced works"), /* @__PURE__ */ React36.createElement("ul", { role: "list" }, manifests.map((manifest) => /* @__PURE__ */ React36.createElement("li", { key: manifest.id || manifest.href }, /* @__PURE__ */ React36.createElement("a", { href: manifest.href }, manifest.title || manifest.href))))) : null), /* @__PURE__ */ React36.createElement("footer", { className: "canopy-gallery__modal-footer" }, /* @__PURE__ */ React36.createElement(
5380
+ items: navItems,
5381
+ activeModalId: modalId,
5382
+ groupName: `${navGroupName || "canopy-gallery"}-${modalId}`
5383
+ }
5384
+ ), /* @__PURE__ */ React36.createElement(
5092
5385
  "a",
5093
5386
  {
5094
5387
  className: "canopy-gallery__modal-close",
@@ -5096,31 +5389,17 @@ function GalleryModal({ item, total, closeTargetId, prevTarget, nextTarget }) {
5096
5389
  "aria-label": `Close popup for ${modalTitle}`
5097
5390
  },
5098
5391
  "Close"
5099
- ), total > 1 ? /* @__PURE__ */ React36.createElement(
5100
- "nav",
5392
+ )), /* @__PURE__ */ React36.createElement("header", { className: "canopy-gallery__modal-header" }, /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-text" }, kicker ? /* @__PURE__ */ React36.createElement("p", { className: "canopy-gallery__modal-kicker" }, kicker) : null, /* @__PURE__ */ React36.createElement("h3", { id: modalTitleId, className: "canopy-gallery__modal-title" }, modalTitle), summary ? /* @__PURE__ */ React36.createElement(
5393
+ "p",
5101
5394
  {
5102
- className: "canopy-gallery__modal-nav",
5103
- "aria-label": "Gallery popup navigation"
5395
+ id: modalDescriptionId || void 0,
5396
+ className: "canopy-gallery__modal-summary"
5104
5397
  },
5105
- /* @__PURE__ */ React36.createElement(
5106
- "a",
5107
- {
5108
- className: "canopy-gallery__modal-nav-link canopy-gallery__modal-nav-link--prev",
5109
- href: `#${prevTarget}`,
5110
- "aria-label": `Show previous popup before ${modalTitle}`
5111
- },
5112
- "Prev"
5113
- ),
5114
- /* @__PURE__ */ React36.createElement(
5115
- "a",
5116
- {
5117
- className: "canopy-gallery__modal-nav-link canopy-gallery__modal-nav-link--next",
5118
- href: `#${nextTarget}`,
5119
- "aria-label": `Show next popup after ${modalTitle}`
5120
- },
5121
- "Next"
5122
- )
5123
- ) : null)))
5398
+ summary
5399
+ ) : null, renderMetaList(
5400
+ props.meta,
5401
+ "canopy-gallery__meta canopy-gallery__meta--modal"
5402
+ ))), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modal-body" }, props.children, manifests && manifests.length ? /* @__PURE__ */ React36.createElement("section", { className: "canopy-gallery__referenced" }, /* @__PURE__ */ React36.createElement("h4", null, "Referenced works"), /* @__PURE__ */ React36.createElement("ul", { role: "list" }, manifests.map((manifest) => /* @__PURE__ */ React36.createElement("li", { key: manifest.id || manifest.href }, /* @__PURE__ */ React36.createElement("a", { href: manifest.href }, manifest.title || manifest.href))))) : null)))
5124
5403
  );
5125
5404
  }
5126
5405
  function GalleryFigure({ item }) {
@@ -5147,6 +5426,109 @@ function GalleryFigure({ item }) {
5147
5426
  )
5148
5427
  );
5149
5428
  }
5429
+ function GalleryThumbnailNav({ items, activeModalId, groupName }) {
5430
+ if (!items || items.length < 2) return null;
5431
+ const radioGroup = groupName || "canopy-gallery-nav";
5432
+ return /* @__PURE__ */ React36.createElement(
5433
+ "nav",
5434
+ {
5435
+ className: "canopy-gallery__nav",
5436
+ "aria-label": "Gallery navigation",
5437
+ "data-canopy-gallery-nav": "true"
5438
+ },
5439
+ /* @__PURE__ */ React36.createElement(
5440
+ "div",
5441
+ {
5442
+ className: "canopy-gallery__nav-viewport",
5443
+ "data-canopy-gallery-nav-viewport": "true"
5444
+ },
5445
+ /* @__PURE__ */ React36.createElement(
5446
+ "ul",
5447
+ {
5448
+ className: "canopy-gallery__nav-list",
5449
+ role: "list",
5450
+ "data-canopy-gallery-nav-track": "true"
5451
+ },
5452
+ items.map((item, index) => {
5453
+ const optionId = `${radioGroup}-${item.modalId || index}`;
5454
+ const isActive = item.modalId === activeModalId;
5455
+ return /* @__PURE__ */ React36.createElement(
5456
+ "li",
5457
+ {
5458
+ key: `${item.key}-nav`,
5459
+ className: "canopy-gallery__nav-item",
5460
+ "data-canopy-gallery-nav-item": "true",
5461
+ "data-canopy-gallery-nav-selected": isActive ? "1" : void 0
5462
+ },
5463
+ /* @__PURE__ */ React36.createElement(
5464
+ "input",
5465
+ {
5466
+ type: "radio",
5467
+ className: "canopy-gallery__nav-radio",
5468
+ id: optionId,
5469
+ name: radioGroup,
5470
+ value: item.modalId,
5471
+ checked: isActive ? true : void 0,
5472
+ readOnly: true,
5473
+ "data-canopy-gallery-nav-option": "true",
5474
+ "data-canopy-gallery-nav-modal": item.modalId,
5475
+ tabIndex: isActive ? 0 : -1,
5476
+ "data-canopy-gallery-nav-selected": isActive ? "1" : void 0
5477
+ }
5478
+ ),
5479
+ /* @__PURE__ */ React36.createElement(
5480
+ "label",
5481
+ {
5482
+ className: "canopy-gallery__nav-link",
5483
+ htmlFor: optionId,
5484
+ "data-canopy-gallery-nav-active": isActive ? "1" : void 0
5485
+ },
5486
+ /* @__PURE__ */ React36.createElement("span", { className: "canopy-gallery__nav-thumb" }, renderPreview(item.props)),
5487
+ /* @__PURE__ */ React36.createElement("span", { className: "canopy-gallery__nav-label" }, item.props.title || `Item ${item.index + 1}`)
5488
+ )
5489
+ );
5490
+ })
5491
+ )
5492
+ ),
5493
+ /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__nav-controls" }, /* @__PURE__ */ React36.createElement(
5494
+ "button",
5495
+ {
5496
+ type: "button",
5497
+ className: "canopy-gallery__nav-button canopy-gallery__nav-button--prev",
5498
+ "aria-label": "Scroll left through gallery thumbnails",
5499
+ "data-canopy-gallery-nav-prev": "true"
5500
+ },
5501
+ /* @__PURE__ */ React36.createElement(
5502
+ "span",
5503
+ {
5504
+ className: "canopy-gallery__nav-button-icon",
5505
+ "aria-hidden": "true",
5506
+ role: "presentation"
5507
+ },
5508
+ "<"
5509
+ ),
5510
+ /* @__PURE__ */ React36.createElement("span", { className: "canopy-gallery__visually-hidden" }, "Previous item")
5511
+ ), /* @__PURE__ */ React36.createElement(
5512
+ "button",
5513
+ {
5514
+ type: "button",
5515
+ className: "canopy-gallery__nav-button canopy-gallery__nav-button--next",
5516
+ "aria-label": "Scroll right through gallery thumbnails",
5517
+ "data-canopy-gallery-nav-next": "true"
5518
+ },
5519
+ /* @__PURE__ */ React36.createElement(
5520
+ "span",
5521
+ {
5522
+ className: "canopy-gallery__nav-button-icon",
5523
+ "aria-hidden": "true",
5524
+ role: "presentation"
5525
+ },
5526
+ ">"
5527
+ ),
5528
+ /* @__PURE__ */ React36.createElement("span", { className: "canopy-gallery__visually-hidden" }, "Next item")
5529
+ ))
5530
+ );
5531
+ }
5150
5532
  function GalleryContent({ children, flex = false }) {
5151
5533
  const contentClassName = [
5152
5534
  "canopy-gallery-item__content",
@@ -5187,6 +5569,7 @@ function Gallery({
5187
5569
  popupMode === "medium" ? "canopy-gallery--popup-medium" : "canopy-gallery--popup-full",
5188
5570
  className
5189
5571
  ].filter(Boolean).join(" ");
5572
+ const navGroupName = `${galleryId}-nav`;
5190
5573
  return /* @__PURE__ */ React36.createElement("section", { className: rootClassName, style, "data-canopy-gallery": "true" }, /* @__PURE__ */ React36.createElement(
5191
5574
  "div",
5192
5575
  {
@@ -5195,22 +5578,16 @@ function Gallery({
5195
5578
  "aria-hidden": "true",
5196
5579
  tabIndex: -1
5197
5580
  }
5198
- ), (title || description) && /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__header" }, title ? /* @__PURE__ */ React36.createElement(HeadingTag, { className: "canopy-gallery__heading" }, title) : null, description ? /* @__PURE__ */ React36.createElement("p", { className: "canopy-gallery__description" }, description) : null), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__grid" }, orderedItems.map((item) => /* @__PURE__ */ React36.createElement(GalleryFigure, { key: item.key, item }))), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modals" }, orderedItems.map((item, index) => {
5199
- const total = orderedItems.length;
5200
- const prevIndex = (index - 1 + total) % total;
5201
- const nextIndex = (index + 1) % total;
5202
- return /* @__PURE__ */ React36.createElement(
5203
- GalleryModal,
5204
- {
5205
- key: `${item.modalId}-modal`,
5206
- item,
5207
- total,
5208
- closeTargetId,
5209
- prevTarget: orderedItems[prevIndex].modalId,
5210
- nextTarget: orderedItems[nextIndex].modalId
5211
- }
5212
- );
5213
- })), /* @__PURE__ */ React36.createElement(
5581
+ ), (title || description) && /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__header" }, title ? /* @__PURE__ */ React36.createElement(HeadingTag, { className: "canopy-gallery__heading" }, title) : null, description ? /* @__PURE__ */ React36.createElement("p", { className: "canopy-gallery__description" }, description) : null), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__grid" }, orderedItems.map((item) => /* @__PURE__ */ React36.createElement(GalleryFigure, { key: item.key, item }))), /* @__PURE__ */ React36.createElement("div", { className: "canopy-gallery__modals" }, orderedItems.map((item) => /* @__PURE__ */ React36.createElement(
5582
+ GalleryModal,
5583
+ {
5584
+ key: `${item.modalId}-modal`,
5585
+ item,
5586
+ closeTargetId,
5587
+ navItems: orderedItems,
5588
+ navGroupName
5589
+ }
5590
+ ))), /* @__PURE__ */ React36.createElement(
5214
5591
  "script",
5215
5592
  {
5216
5593
  "data-canopy-gallery-script": "true",