@astryxdesign/core 0.7.15 → 0.7.16-canary.g54dd64e

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.
Files changed (256) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +8 -2
  3. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheet.js +11 -6
  5. package/dist/DateInput/DateInput.d.ts +3 -3
  6. package/dist/DateInput/DateInput.d.ts.map +1 -1
  7. package/dist/DateInput/DateInput.js +13 -2
  8. package/dist/DateInput/NativeDateField.d.ts +1 -1
  9. package/dist/DateInput/NativeDateField.d.ts.map +1 -1
  10. package/dist/DateInput/NativeDateField.js +48 -31
  11. package/dist/DateInput/useTypedDate.d.ts +66 -6
  12. package/dist/DateInput/useTypedDate.d.ts.map +1 -1
  13. package/dist/DateInput/useTypedDate.js +151 -21
  14. package/dist/DateTimeInput/DateTimeInput.d.ts +3 -3
  15. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  16. package/dist/DateTimeInput/DateTimeInput.js +26 -3
  17. package/dist/DateTimeInput/NativeDateSegment.d.ts +8 -1
  18. package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
  19. package/dist/DateTimeInput/NativeDateSegment.js +20 -14
  20. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  21. package/dist/DropdownMenu/DropdownMenu.js +10 -3
  22. package/dist/Field/InputClearButton.d.ts.map +1 -1
  23. package/dist/Field/InputClearButton.js +4 -2
  24. package/dist/InfoTip/InfoTip.d.ts +1 -1
  25. package/dist/InfoTip/InfoTip.d.ts.map +1 -1
  26. package/dist/InfoTip/InfoTip.js +4 -1
  27. package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
  28. package/dist/Layer/layerAnimations.stylex.js +17 -13
  29. package/dist/Layer/layerEntranceSide.d.ts +24 -10
  30. package/dist/Layer/layerEntranceSide.d.ts.map +1 -1
  31. package/dist/Layer/layerEntranceSide.js +28 -13
  32. package/dist/Layer/useLayer.d.ts.map +1 -1
  33. package/dist/Layer/useLayer.js +14 -11
  34. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  35. package/dist/Lightbox/Lightbox.js +625 -180
  36. package/dist/List/ListItem.d.ts +3 -2
  37. package/dist/List/ListItem.d.ts.map +1 -1
  38. package/dist/List/ListReorderHandle.d.ts +7 -0
  39. package/dist/List/ListReorderHandle.d.ts.map +1 -1
  40. package/dist/List/ListReorderHandle.js +42 -58
  41. package/dist/List/listReorderContext.d.ts.map +1 -1
  42. package/dist/List/listReorderContext.js +4 -4
  43. package/dist/List/listReorderEngine.d.ts +50 -2
  44. package/dist/List/listReorderEngine.d.ts.map +1 -1
  45. package/dist/List/listReorderEngine.js +205 -10
  46. package/dist/MoreMenu/MoreMenu.d.ts +1 -1
  47. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  48. package/dist/MoreMenu/MoreMenu.js +4 -1
  49. package/dist/PowerSearch/PowerSearch.d.ts +1 -1
  50. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  51. package/dist/PowerSearch/PowerSearch.js +8 -4
  52. package/dist/PowerSearch/PowerSearchEditPopover.d.ts +4 -1
  53. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  54. package/dist/PowerSearch/PowerSearchEditPopover.js +4 -1
  55. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts +1 -1
  56. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
  57. package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -3
  58. package/dist/PowerSearch/PowerSearchToken.d.ts +1 -1
  59. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  60. package/dist/PowerSearch/PowerSearchToken.js +4 -1
  61. package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
  62. package/dist/Selector/useSelectorPresentation.js +13 -12
  63. package/dist/Slider/Slider.d.ts.map +1 -1
  64. package/dist/Slider/Slider.js +6 -8
  65. package/dist/Table/BaseTable.d.ts +1 -1
  66. package/dist/Table/BaseTable.d.ts.map +1 -1
  67. package/dist/Table/BaseTable.js +265 -197
  68. package/dist/Table/Table.d.ts +5 -1
  69. package/dist/Table/Table.d.ts.map +1 -1
  70. package/dist/Table/index.d.ts +5 -3
  71. package/dist/Table/index.d.ts.map +1 -1
  72. package/dist/Table/index.js +2 -1
  73. package/dist/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.d.ts.map +1 -0
  74. package/dist/Table/plugins/infiniteScroll/index.d.ts +9 -0
  75. package/dist/Table/plugins/infiniteScroll/index.d.ts.map +1 -0
  76. package/dist/Table/plugins/infiniteScroll/index.js +9 -0
  77. package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts +29 -0
  78. package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts.map +1 -0
  79. package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.js +394 -0
  80. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  81. package/dist/Table/plugins/sortable/useTableSortableState.js +4 -4
  82. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  83. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +21 -1
  84. package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts +4 -0
  85. package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts.map +1 -0
  86. package/dist/Table/plugins/virtualization/TableColumnWindow.js +109 -0
  87. package/dist/Table/plugins/virtualization/index.d.ts +3 -1
  88. package/dist/Table/plugins/virtualization/index.d.ts.map +1 -1
  89. package/dist/Table/plugins/virtualization/index.js +3 -2
  90. package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts +33 -0
  91. package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts.map +1 -0
  92. package/dist/Table/plugins/virtualization/useTableColumnWindow.js +143 -0
  93. package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts +23 -0
  94. package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts.map +1 -0
  95. package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.js +37 -0
  96. package/dist/Table/tableColumnWindowing.d.ts +85 -0
  97. package/dist/Table/tableColumnWindowing.d.ts.map +1 -0
  98. package/dist/Table/tableColumnWindowing.js +47 -0
  99. package/dist/Table/tablePinnedColumnRuns.d.ts +23 -0
  100. package/dist/Table/tablePinnedColumnRuns.d.ts.map +1 -0
  101. package/dist/Table/tablePinnedColumnRuns.js +41 -0
  102. package/dist/Table/tableRuntime.d.ts +14 -2
  103. package/dist/Table/tableRuntime.d.ts.map +1 -1
  104. package/dist/Table/tableRuntime.js +32 -11
  105. package/dist/Table/types.d.ts +28 -2
  106. package/dist/Table/types.d.ts.map +1 -1
  107. package/dist/Table/useBaseTablePlugins.js +2 -2
  108. package/dist/Text/useTruncation.d.ts +6 -1
  109. package/dist/Text/useTruncation.d.ts.map +1 -1
  110. package/dist/Text/useTruncation.js +53 -35
  111. package/dist/TextArea/TextArea.d.ts +10 -1
  112. package/dist/TextArea/TextArea.d.ts.map +1 -1
  113. package/dist/TextArea/TextArea.js +2 -0
  114. package/dist/Toast/Toast.d.ts +1 -1
  115. package/dist/Toast/Toast.d.ts.map +1 -1
  116. package/dist/Toast/Toast.js +4 -2
  117. package/dist/astryx.css +22 -11
  118. package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts +156 -0
  119. package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts.map +1 -1
  120. package/dist/dragToSnapPoints/createDragToSnapPoints.js +313 -97
  121. package/dist/gestures/createPanGesture.d.ts +41 -0
  122. package/dist/gestures/createPanGesture.d.ts.map +1 -1
  123. package/dist/gestures/createPanGesture.js +66 -22
  124. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  125. package/dist/hooks/useMenuPress.js +36 -2
  126. package/dist/i18n/generated-english/DateInput/NativeDateField.generated.d.ts.map +1 -1
  127. package/dist/i18n/generated-english/DateInput/NativeDateField.generated.js +0 -1
  128. package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.d.ts.map +1 -1
  129. package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.js +0 -1
  130. package/dist/i18n/generated-english/Lightbox/Lightbox.generated.d.ts.map +1 -1
  131. package/dist/i18n/generated-english/Lightbox/Lightbox.generated.js +2 -0
  132. package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts +8 -0
  133. package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts.map +1 -0
  134. package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.js +12 -0
  135. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  136. package/dist/i18n/generated-locales/en.generated.js +32 -0
  137. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  138. package/dist/i18n/generated-locales/pseudo.generated.js +32 -0
  139. package/dist/internal/touch.d.ts +1 -1
  140. package/dist/internal/touch.d.ts.map +1 -1
  141. package/dist/internal/touch.js +1 -1
  142. package/dist/motion/animator.d.ts +28 -1
  143. package/dist/motion/animator.d.ts.map +1 -1
  144. package/dist/motion/animator.js +99 -19
  145. package/dist/theme/generateThemeRules.d.ts.map +1 -1
  146. package/dist/theme/generateThemeRules.js +14 -3
  147. package/dist/theme/tokenReferences.d.ts +7 -15
  148. package/dist/theme/tokenReferences.d.ts.map +1 -1
  149. package/dist/theme/tokenReferences.js +49 -7
  150. package/dist/utils/clickGuard.d.ts +8 -1
  151. package/dist/utils/clickGuard.d.ts.map +1 -1
  152. package/dist/utils/clickGuard.js +24 -4
  153. package/dist/utils/sharedResizeObserver.d.ts +18 -2
  154. package/dist/utils/sharedResizeObserver.d.ts.map +1 -1
  155. package/dist/utils/sharedResizeObserver.js +43 -2
  156. package/dist/utils/themeProps.d.ts +8 -0
  157. package/dist/utils/themeProps.d.ts.map +1 -1
  158. package/dist/utils/themeProps.js +17 -0
  159. package/dist/utils/timeParser.d.ts +3 -1
  160. package/dist/utils/timeParser.d.ts.map +1 -1
  161. package/dist/utils/timeParser.js +7 -3
  162. package/dist/virtualization/listWindow.d.ts +18 -2
  163. package/dist/virtualization/listWindow.d.ts.map +1 -1
  164. package/dist/virtualization/listWindow.js +55 -2
  165. package/dist/virtualization/useInlineListWindow.d.ts +40 -0
  166. package/dist/virtualization/useInlineListWindow.d.ts.map +1 -0
  167. package/dist/virtualization/useInlineListWindow.js +58 -0
  168. package/locales/en.json +129 -1
  169. package/locales/pseudo.json +96 -0
  170. package/package.json +5 -5
  171. package/src/AppShell/AppShell.tsx +12 -3
  172. package/src/BottomSheet/BottomSheet.tsx +12 -8
  173. package/src/ButtonGroup/ButtonGroup.doc.mjs +5 -0
  174. package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -0
  175. package/src/DateInput/DateInput.doc.mjs +3 -3
  176. package/src/DateInput/DateInput.tsx +27 -5
  177. package/src/DateInput/NativeDateField.tsx +58 -36
  178. package/src/DateInput/useTypedDate.ts +226 -55
  179. package/src/DateTimeInput/DateTimeInput.doc.mjs +3 -3
  180. package/src/DateTimeInput/DateTimeInput.tsx +38 -5
  181. package/src/DateTimeInput/NativeDateSegment.tsx +35 -13
  182. package/src/DropdownMenu/DropdownMenu.tsx +10 -3
  183. package/src/Field/InputClearButton.tsx +3 -1
  184. package/src/InfoTip/InfoTip.doc.mjs +2 -2
  185. package/src/InfoTip/InfoTip.tsx +3 -0
  186. package/src/Layer/layerAnimations.stylex.ts +13 -9
  187. package/src/Layer/layerEntranceSide.ts +48 -11
  188. package/src/Layer/useLayer.tsx +14 -12
  189. package/src/Lightbox/Lightbox.doc.mjs +2 -1
  190. package/src/Lightbox/Lightbox.tsx +864 -257
  191. package/src/List/ListItem.tsx +3 -2
  192. package/src/List/ListReorderHandle.tsx +59 -77
  193. package/src/List/listReorderContext.ts +3 -4
  194. package/src/List/listReorderEngine.tsx +246 -11
  195. package/src/MoreMenu/MoreMenu.doc.mjs +2 -2
  196. package/src/MoreMenu/MoreMenu.tsx +3 -0
  197. package/src/NumberInput/NumberInput.doc.mjs +3 -0
  198. package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
  199. package/src/PowerSearch/PowerSearch.tsx +7 -3
  200. package/src/PowerSearch/PowerSearchEditPopover.tsx +12 -2
  201. package/src/PowerSearch/PowerSearchFilterEditor.tsx +3 -0
  202. package/src/PowerSearch/PowerSearchToken.tsx +3 -0
  203. package/src/ProgressBar/ProgressBar.doc.mjs +3 -0
  204. package/src/SegmentedControl/SegmentedControl.doc.mjs +5 -0
  205. package/src/Selector/useSelectorPresentation.ts +16 -12
  206. package/src/Slider/Slider.tsx +6 -8
  207. package/src/StatusDot/StatusDot.doc.mjs +3 -0
  208. package/src/Switch/Switch.doc.mjs +3 -0
  209. package/src/TabList/TabList.doc.mjs +4 -0
  210. package/src/Table/BaseTable.tsx +406 -287
  211. package/src/Table/Table.doc.mjs +2 -2
  212. package/src/Table/Table.tsx +5 -1
  213. package/src/Table/index.ts +8 -1
  214. package/src/Table/plugins/infiniteScroll/index.ts +10 -0
  215. package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx +523 -0
  216. package/src/Table/plugins/sortable/useTableSortableState.tsx +4 -4
  217. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +31 -1
  218. package/src/Table/plugins/virtualization/TableColumnWindow.tsx +150 -0
  219. package/src/Table/plugins/virtualization/index.ts +3 -1
  220. package/src/Table/plugins/virtualization/useTableColumnWindow.ts +168 -0
  221. package/src/Table/plugins/virtualization/useTableColumnsVirtualization.ts +53 -0
  222. package/src/Table/tableColumnWindowing.ts +131 -0
  223. package/src/Table/tablePinnedColumnRuns.ts +55 -0
  224. package/src/Table/tableRuntime.ts +44 -11
  225. package/src/Table/types.ts +25 -2
  226. package/src/Table/useBaseTablePlugins.ts +2 -2
  227. package/src/Table/useTableColumnsVirtualization.doc.mjs +29 -0
  228. package/src/Table/useTableInfiniteScroll.doc.mjs +58 -0
  229. package/src/Text/Heading.doc.mjs +3 -0
  230. package/src/Text/useTruncation.doc.mjs +10 -0
  231. package/src/Text/useTruncation.ts +53 -35
  232. package/src/TextArea/TextArea.doc.mjs +15 -0
  233. package/src/TextArea/TextArea.tsx +11 -0
  234. package/src/TextInput/TextInput.doc.mjs +3 -0
  235. package/src/Toast/Toast.doc.mjs +2 -2
  236. package/src/Toast/Toast.tsx +3 -1
  237. package/src/TopNav/TopNav.doc.mjs +4 -0
  238. package/src/dragToSnapPoints/createDragToSnapPoints.ts +437 -119
  239. package/src/gestures/createPanGesture.ts +112 -39
  240. package/src/hooks/useMenuPress.ts +39 -0
  241. package/src/i18n/generated-english/DateInput/NativeDateField.generated.ts +0 -1
  242. package/src/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.ts +0 -1
  243. package/src/i18n/generated-english/Lightbox/Lightbox.generated.ts +2 -0
  244. package/src/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.ts +13 -0
  245. package/src/i18n/generated-locales/en.generated.ts +34 -0
  246. package/src/i18n/generated-locales/pseudo.generated.ts +34 -0
  247. package/src/internal/touch.ts +5 -1
  248. package/src/motion/animator.ts +181 -23
  249. package/src/theme/generateThemeRules.ts +14 -3
  250. package/src/theme/tokenReferences.ts +48 -7
  251. package/src/utils/clickGuard.ts +30 -3
  252. package/src/utils/sharedResizeObserver.ts +46 -2
  253. package/src/utils/themeProps.ts +17 -0
  254. package/src/utils/timeParser.ts +7 -9
  255. package/src/virtualization/listWindow.ts +76 -2
  256. package/src/virtualization/useInlineListWindow.ts +119 -0
@@ -23,7 +23,8 @@
23
23
  * - /apps/storybook/stories/Lightbox.stories.tsx (storybook stories)
24
24
  * - /packages/cli/assets/templates/blocks/components/Lightbox/ (showcase blocks)
25
25
  */
26
- import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
26
+ import { useCallback, useEffect, useId, useMemo, useReducer, useRef, useState } from 'react';
27
+ import { flushSync } from 'react-dom';
27
28
  import * as stylex from '@stylexjs/stylex';
28
29
  import "../theme/tokens.stylex.js";
29
30
  import { colorVars, focusVars, radiusVars, spacingVars, typeScaleVars } from "../theme/tokens.stylex.js";
@@ -33,7 +34,10 @@ import { announceInModal } from "../hooks/useAnnounce.js";
33
34
  import { useScrollLock } from "../hooks/useScrollLock.js";
34
35
  import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
35
36
  import { useAttachment } from "../hooks/useAttachment.js";
36
- import { observeResize } from "../utils/sharedResizeObserver.js";
37
+ import { observeResize, observeResizeAfterLayout } from "../utils/sharedResizeObserver.js";
38
+ import { useTouchHitArea } from "../utils/touchHitArea.js";
39
+ import { touchHitAreaStyles } from "../internal/touchHitArea.stylex.js";
40
+ import { usePressTracker } from "../gestures/usePressTracker.js";
37
41
  import { mergeProps, rtlStyles } from "../utils/index.js";
38
42
  import { themeProps } from "../utils/themeProps.js";
39
43
  import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
@@ -60,9 +64,14 @@ import { useTouchPresentation } from "../utils/touchPresentation.js";
60
64
  import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
61
65
  import english from "../i18n/generated-english/Lightbox/Lightbox.generated.js";
62
66
  import { isRenderable } from "../utils/isRenderable.js";
63
- import { prepareFocusReturnOnRemoval } from "../utils/focusReturn.js";
67
+ import { focusForLastInput, moveFocusLeftBehind, noteFocusWithin, prepareFocusReturnOnRemoval, returnFocusForLastInput } from "../utils/focusReturn.js";
64
68
  import { animatorFor } from "../motion/animator.js";
65
69
  import { dismissBackdropAlpha, dismissChromeAlpha } from "./zoomStage.js";
70
+ import { useInteractionModalityTracking } from "../utils/interactionModality.js";
71
+ import { MediaTheme } from "../theme/MediaTheme.js";
72
+ import { Text } from "../Text/Text.js";
73
+ import { useTruncation } from "../Text/useTruncation.js";
74
+ import { Link } from "../Link/Link.js";
66
75
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
67
76
  registerEnglishFallback(english);
68
77
  /**
@@ -79,6 +88,22 @@ registerEnglishFallback(english);
79
88
 
80
89
  /** Set on the stage while a mouse or a pen hovers over the fitted photo. */
81
90
  const OVER_PHOTO_ATTRIBUTE = 'data-lightbox-over-photo';
91
+
92
+ // The caption's backing: the controls' backing colour, darker, so the caption
93
+ // keeps 4.5:1 over any photo or backdrop behind it (WCAG 2.2 1.4.3).
94
+ const CAPTION_BACKING = `color-mix(in srgb, ${colorVars['--color-on-light']} 90%, transparent)`;
95
+ const _temp = {
96
+ k1xSpc: "x104kibb",
97
+ kgKLqz: "x1ua5tub",
98
+ kzqmXN: "x1uyokj7",
99
+ keTefX: "x11g1kdw",
100
+ kUuF72: "xx1nm32",
101
+ "$$css": true
102
+ };
103
+ const _temp2 = {
104
+ kwRFfy: "x120eax6",
105
+ "$$css": true
106
+ };
82
107
  const styles = {
83
108
  dialog: {
84
109
  kVAEAm: "xixxii4",
@@ -105,7 +130,7 @@ const styles = {
105
130
  kCS8Yb: "x1r8uery",
106
131
  $$css: true
107
132
  },
108
- imageWrapperFocusInset: {
133
+ zoomButtonFocusInset: {
109
134
  kInvED: "x1wfwxd8 x1nw7mhf",
110
135
  $$css: true
111
136
  },
@@ -124,6 +149,11 @@ const styles = {
124
149
  kFalU9: "x5ve5x3",
125
150
  $$css: true
126
151
  },
152
+ pageMediaZoomTarget: {
153
+ kFalU9: "x5ve5x3",
154
+ kkrTdU: "xmper1u x16khyan",
155
+ $$css: true
156
+ },
127
157
  imageWrapperDismissTarget: {
128
158
  kFalU9: "x1j4r261",
129
159
  $$css: true
@@ -138,14 +168,65 @@ const styles = {
138
168
  },
139
169
  page: {
140
170
  kVAEAm: "x1n2onr6",
141
- kJuA4N: "x15r89dc",
171
+ kBCFzs: "xgkxs2y",
172
+ kbNqZ1: "xa1s216",
173
+ k1xSpc: "xrvj5dj",
174
+ kumcoG: "x1ftzfwy",
175
+ k9llMU: "x1clt5hq",
176
+ kAzted: "x2lwn1j",
177
+ k6sLGO: "x1so62im",
178
+ $$css: true
179
+ },
180
+ pageMedia: {
181
+ kbNqZ1: "x1ms6mhf",
182
+ kAzted: "x2lwn1j",
183
+ k7Eaqz: "xeuugli",
142
184
  k1xSpc: "x78zum5",
143
- kXwgrk: "xdt5ytf",
144
185
  kGNEyG: "x6s0dn4",
145
186
  kjj79g: "xl56j7k",
146
- kAzted: "x2lwn1j",
187
+ kVQacm: "xb3r6kr x1odnnbo",
188
+ kY2c9j: "x1c34a00",
189
+ $$css: true
190
+ },
191
+ captionClamped: {
192
+ kmuXW: "xs83m0k",
147
193
  k7Eaqz: "xeuugli",
148
- k6sLGO: "x1so62im",
194
+ $$css: true
195
+ },
196
+ captionTogglePlace: {
197
+ kyUFMd: "x18mqm2i xl3jo06",
198
+ k1xSpc: "x1s85apg",
199
+ kVQacm: "xb3r6kr",
200
+ khDVqt: "x1sdyfia",
201
+ kfSwDN: "x87ps6o",
202
+ k33iCy: "xlshs6z",
203
+ kgeoSG: "x1jidjzq",
204
+ $$css: true
205
+ },
206
+ captionTogglePlaceShown: (width, lines) => [_temp, {
207
+ kJFfOR: lines != null ? "x1yhjpo9" : lines,
208
+ $$css: true
209
+ }, {
210
+ "--x-WebkitLineClamp": lines != null ? lines : undefined,
211
+ "--x-inlineSize": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(width)
212
+ }],
213
+ captionToggle: {
214
+ kVAEAm: "x10l6tqk",
215
+ kt4wiu: "x1mcfs9z",
216
+ krVfgx: "x1ey2m1c",
217
+ $$css: true
218
+ },
219
+ captionToggleHidden: {
220
+ k1xSpc: "x1s85apg",
221
+ $$css: true
222
+ },
223
+ captionTextBesideToggle: width => [_temp2, {
224
+ "--x-paddingInlineEnd": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(`calc(${spacingVars['--spacing-3']} + ${width}px + ${spacingVars['--spacing-1']})`)
225
+ }],
226
+ captionTextOpen: {
227
+ kskxy: "x9szg3b",
228
+ kORKVm: "x1odjw0f",
229
+ kFalU9: "xge0x1e",
149
230
  $$css: true
150
231
  },
151
232
  imageWrapperZoomable: {
@@ -156,6 +237,14 @@ const styles = {
156
237
  kkrTdU: "x1jm3nie x5qf8wv x16khyan",
157
238
  $$css: true
158
239
  },
240
+ caption: {
241
+ kLKAdn: "x1xye8es",
242
+ kGO01o: "x18d9i69",
243
+ kg3NbH: "xrrkdod",
244
+ ks0D6T: "xrlsmeg",
245
+ kmuXW: "x2lah0s",
246
+ $$css: true
247
+ },
159
248
  closeButton: {
160
249
  kVAEAm: "x10l6tqk",
161
250
  k87sOh: "xyx6v2t",
@@ -178,8 +267,15 @@ const styles = {
178
267
  kt4wiu: "x1mcfs9z",
179
268
  $$css: true
180
269
  },
270
+ counter: {
271
+ kVAEAm: "x10l6tqk",
272
+ k87sOh: "xyx6v2t",
273
+ kLqNvP: "x1ybfrjj",
274
+ kY2c9j: "x1vjfegm",
275
+ kfzvcC: "x67bb7w",
276
+ $$css: true
277
+ },
181
278
  controlButton: {
182
- kMwMTN: "x9e3rv5",
183
279
  kfzvcC: "x67bb7w",
184
280
  $$css: true
185
281
  },
@@ -189,17 +285,27 @@ const styles = {
189
285
  kaIpWk: "xjspbzw",
190
286
  $$css: true
191
287
  },
288
+ counterBacking: {
289
+ kWkggS: "x1ap9wa5",
290
+ kaIpWk: "xjspbzw",
291
+ kg3NbH: "xf314gf",
292
+ $$css: true
293
+ },
192
294
  controlIcon: {
193
295
  kMwMTN: "x9e3rv5",
194
296
  $$css: true
297
+ },
298
+ counterOnDark: {
299
+ kMwMTN: "x9e3rv5",
300
+ $$css: true
195
301
  }
196
302
  };
197
- const _temp = {
303
+ const _temp3 = {
198
304
  kLqNvP: "x1lxsm33",
199
305
  "$$css": true
200
306
  };
201
307
  const pageStyles = {
202
- position: index => [_temp, {
308
+ position: index => [_temp3, {
203
309
  "--x-insetInlineStart": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(`calc(${index} * (100% + ${zoomMedia.viewer.pageGap}px))`)
204
310
  }]
205
311
  };
@@ -282,7 +388,12 @@ export function Lightbox({
282
388
  }) {
283
389
  const t = useComponentTranslator();
284
390
  const dialogRef = useRef(null);
285
- const mergedDialogRef = useMergedRefs(ref, dialogRef);
391
+ // The last input in the viewer's own document, a Picture-in-Picture window's
392
+ // too, decides whether focus the viewer moves shows a ring.
393
+ const {
394
+ ref: modalityRef
395
+ } = useInteractionModalityTracking();
396
+ const mergedDialogRef = useMergedRefs(ref, dialogRef, modalityRef);
286
397
  // Native showModal() lets Tab leave for the browser's own UI, so the shared
287
398
  // module wraps it.
288
399
  useFocusRegionContainment(dialogRef, isOpen);
@@ -445,10 +556,17 @@ export function Lightbox({
445
556
  if (isOpen && !dialog.open) {
446
557
  triggerElementRef.current = document.activeElement;
447
558
  dialog.showModal();
559
+ // The browser focuses the viewer's first control as it opens. Its ring
560
+ // follows the last input, so a tap or a click shows none.
561
+ const view = dialog.ownerDocument.defaultView ?? window;
562
+ const focused = dialog.ownerDocument.activeElement;
563
+ if (focused instanceof view.HTMLElement && dialog.contains(focused)) {
564
+ focusForLastInput(focused);
565
+ }
448
566
  } else if (!isOpen && dialog.open) {
449
567
  dialog.close();
450
568
  if (triggerElementRef.current instanceof HTMLElement) {
451
- triggerElementRef.current.focus();
569
+ returnFocusForLastInput(triggerElementRef.current);
452
570
  }
453
571
  }
454
572
  }, [isOpen, hasItem]);
@@ -519,6 +637,197 @@ export function Lightbox({
519
637
  const didDragRef = useRef(false);
520
638
  const mediaGroupRef = useRef(null);
521
639
  const captionRef = useRef(null);
640
+ // The current item's caption, which is the viewer's accessible description.
641
+ const captionId = useId();
642
+ const fullCaptionId = useId();
643
+ // The item whose full caption is open over its photo. Paging closes it.
644
+ const [openCaptionIndex, setOpenCaptionIndex] = useState(null);
645
+ if (openCaptionIndex != null && openCaptionIndex !== index) {
646
+ setOpenCaptionIndex(null);
647
+ }
648
+ const isCaptionOpen = openCaptionIndex === index;
649
+ // The toggle's width, which its place in the caption's last line takes.
650
+ const [captionToggleWidth, setCaptionToggleWidth] = useState(0);
651
+ // The current page's caption in its band, and whether two lines clamp it.
652
+ // While the caption is open the check keeps its clamped answer, so the
653
+ // toggle stays mounted, with its focus, as the caption closes.
654
+ const bandCaptionRef = useRef(null);
655
+ const captionTruncation = useTruncation({
656
+ maxLines: 2,
657
+ isExpanded: isCaptionOpen
658
+ });
659
+ const isCaptionClamped = captionTruncation.isTruncated;
660
+ const bandCaptionMeasureRef = useMergedRefs(bandCaptionRef, captionTruncation.ref);
661
+ const [captionShownLines, setCaptionShownLines] = useState(0);
662
+ // The current caption's lines, without its toggle's place.
663
+ const bandCaptionFlowRef = useRef(null);
664
+ // The caption's width at its last measure, and the cancel of a smaller
665
+ // count that waits for the next frame.
666
+ const captionWidthRef = useRef(0);
667
+ const cancelCaptionShrinkRef = useRef(null);
668
+ // Whether the open caption scrolls inside its panel.
669
+ const [isCaptionScrolling, setIsCaptionScrolling] = useState(false);
670
+ // The caption's toggle. Under a coarse pointer it takes taps out toward
671
+ // 44 px. A finger's tap on it is its own, as UIKit gives a control's tap
672
+ // precedence over the single tap of the photo around it.
673
+ const captionToggleRef = useRef(null);
674
+ const measureCaptionLines = useCallback(() => {
675
+ // The toggle's committed state, so this measure stays one callback for
676
+ // the caption's observer.
677
+ const isCaptionOpen = captionToggleRef.current?.getAttribute('aria-expanded') === 'true';
678
+ // A measure in the same frame cancels a waiting smaller count, so it
679
+ // counts the text's lines again.
680
+ const wasShrinking = cancelCaptionShrinkRef.current != null;
681
+ cancelCaptionShrinkRef.current?.();
682
+ cancelCaptionShrinkRef.current = null;
683
+ const caption = bandCaptionRef.current;
684
+ if (caption != null) {
685
+ const view = caption.ownerDocument.defaultView ?? window;
686
+ const style = view.getComputedStyle(caption);
687
+ const line = parseFloat(style.lineHeight);
688
+ const hasLine = Number.isFinite(line) && line > 0;
689
+ const linesOf = height => Math.round((height - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom)) / line);
690
+ // The client height rounds to whole pixels, so this rounds to whole
691
+ // lines.
692
+ const lineCount = hasLine ? linesOf(caption.clientHeight) : 0;
693
+ setCaptionShownLines(lineCount);
694
+ // The open caption is a scroll container, so its height includes the
695
+ // toggle's place, and that height never falls by itself. A new width
696
+ // can need fewer lines. The flow's height counts only the text's lines.
697
+ const flow = bandCaptionFlowRef.current;
698
+ const width = caption.clientWidth;
699
+ if (isCaptionOpen && hasLine && flow != null && (width !== captionWidthRef.current || wasShrinking)) {
700
+ const textLines = Math.round(flow.getBoundingClientRect().height / line);
701
+ if (textLines < lineCount) {
702
+ // Fewer lines shrink the caption. Inside this delivery that is a
703
+ // resize loop, so they wait for the next frame. A toggle that no
704
+ // longer fits beside the last line then takes a line of its own.
705
+ const frame = view.requestAnimationFrame(() => {
706
+ cancelCaptionShrinkRef.current = null;
707
+ if (bandCaptionRef.current !== caption) {
708
+ return;
709
+ }
710
+ // eslint-disable-next-line @eslint-react/dom-no-flush-sync -- the smaller count must lay out before the caption is read again in this frame
711
+ flushSync(() => {
712
+ setCaptionShownLines(textLines);
713
+ });
714
+ setCaptionShownLines(Math.max(textLines, linesOf(caption.clientHeight)));
715
+ });
716
+ cancelCaptionShrinkRef.current = () => {
717
+ view.cancelAnimationFrame(frame);
718
+ };
719
+ }
720
+ }
721
+ captionWidthRef.current = width;
722
+ }
723
+ setIsCaptionScrolling(isCaptionOpen && caption != null && caption.scrollHeight > caption.clientHeight + 1);
724
+ }, []);
725
+ // The caption's reads and its toggle's width wait for one microtask after
726
+ // the observer's callback. There the caption is read before any write, and
727
+ // one commit lands before the frame paints. A read after a write in that
728
+ // delivery would force a layout before the browser's own.
729
+ const captionDeliveryRef = useRef(null);
730
+ const noteCaptionDelivery = useCallback((isCaptionDirty, toggleWidth) => {
731
+ let due = captionDeliveryRef.current;
732
+ if (due == null) {
733
+ due = {
734
+ isCaptionDirty: false,
735
+ toggleWidth: null
736
+ };
737
+ captionDeliveryRef.current = due;
738
+ queueMicrotask(() => {
739
+ const pending = captionDeliveryRef.current;
740
+ captionDeliveryRef.current = null;
741
+ if (pending == null) {
742
+ return;
743
+ }
744
+ // eslint-disable-next-line @eslint-react/dom-no-flush-sync -- a delivery comes after layout and before paint; the caption's "more" and the toggle's place commit in that frame
745
+ flushSync(() => {
746
+ if (pending.isCaptionDirty) {
747
+ measureCaptionLines();
748
+ }
749
+ if (pending.toggleWidth != null) {
750
+ setCaptionToggleWidth(pending.toggleWidth);
751
+ }
752
+ });
753
+ });
754
+ }
755
+ due.isCaptionDirty ||= isCaptionDirty;
756
+ due.toggleWidth = toggleWidth ?? due.toggleWidth;
757
+ }, [measureCaptionLines]);
758
+ // Syncs the toggle's place and the open caption's lines and scroll with
759
+ // the caption's laid-out size. A resize, a font load and the caption's own
760
+ // open resize it. Paging attaches the next page's caption, and a new
761
+ // caption or the dialog's opening attaches it again. Each registration
762
+ // gets one delivery after the browser lays the caption out, and the commit
763
+ // reads nothing. A delivery changes attributes and styles only and adds no
764
+ // element, so no observer that reacts to new elements runs mid-delivery.
765
+ // The toggle's observers sit deeper, so they deliver in the same frame.
766
+ useAttachment(bandCaptionRef, element => {
767
+ // A new caption has no measure yet, so an open caption's first
768
+ // delivery counts its text's lines, as a new width does.
769
+ captionWidthRef.current = 0;
770
+ const box = element.closest('[data-lightbox-caption]') ?? element;
771
+ const stop = observeResizeAfterLayout(box, () => {
772
+ noteCaptionDelivery(true, null);
773
+ });
774
+ if (stop == null) {
775
+ measureCaptionLines();
776
+ return () => {};
777
+ }
778
+ return stop;
779
+ }, isOpen ? currentItem?.caption : null);
780
+ // Close, where focus goes off a paged-away toggle when the stage takes none.
781
+ const closeButtonRef = useRef(null);
782
+ // The current caption's toggle shows while two lines clamp it, or open.
783
+ const hasCaptionToggle = isCaptionClamped || isCaptionOpen;
784
+ const captionToggleHitAreaRef = useTouchHitArea(hasCaptionToggle);
785
+ const captionToggleRefs = useMergedRefs(captionToggleRef, captionToggleHitAreaRef);
786
+ usePressTracker(captionToggleRef);
787
+ // Counts an open caption's lines while the toggle's place is not shown, so
788
+ // the count is the text's own lines. The place also takes the toggle's width
789
+ // for its current label. A toggle that does not fit beside the last line
790
+ // then takes a line of its own, before the resize delivery reads the
791
+ // caption.
792
+ const countOpenCaption = useCallback(() => {
793
+ const caption = bandCaptionRef.current;
794
+ const flow = bandCaptionFlowRef.current;
795
+ if (caption == null || flow == null) {
796
+ return;
797
+ }
798
+ const view = caption.ownerDocument.defaultView ?? window;
799
+ const line = parseFloat(view.getComputedStyle(caption).lineHeight);
800
+ if (!Number.isFinite(line) || line <= 0) {
801
+ return;
802
+ }
803
+ // The layout width, as the observer's own fallback reads it: a scaled
804
+ // ancestor does not change it.
805
+ const toggleWidth = captionToggleRef.current?.offsetWidth ?? 0;
806
+ if (toggleWidth > 0) {
807
+ setCaptionToggleWidth(toggleWidth);
808
+ }
809
+ setCaptionShownLines(Math.round(flow.getBoundingClientRect().height / line));
810
+ }, []);
811
+ // Syncs the toggle's place in the caption's last line with its width. The
812
+ // width is the delivery's own size, measured in the layout the delivery
813
+ // follows, so nothing reads the toggle there. A hidden toggle's size is
814
+ // zero, so the last width stays until a shown toggle's delivery brings
815
+ // another.
816
+ useAttachment(captionToggleRef, toggle => {
817
+ const stop = observeResizeAfterLayout(toggle, entry => {
818
+ // No entry: another subscriber already observes the toggle, so it
819
+ // is measured here.
820
+ const width = entry == null ? toggle.offsetWidth : entry.borderBoxSize?.[0]?.inlineSize ?? 0;
821
+ if (width > 0) {
822
+ noteCaptionDelivery(false, Math.round(width));
823
+ }
824
+ });
825
+ if (stop == null) {
826
+ setCaptionToggleWidth(toggle.offsetWidth);
827
+ return () => {};
828
+ }
829
+ return stop;
830
+ }, null);
522
831
  // Whether a mouse's or a pen's click on the media closes the viewer. It
523
832
  // does when its press or its release lands outside the media: a single
524
833
  // item's, or a gallery's current page's. The media runs from the fitted
@@ -549,10 +858,28 @@ export function Lightbox({
549
858
  const width = Math.min(viewer.clientWidth, Math.max(natural, caption?.offsetWidth ?? 0));
550
859
  const middle = boxRect.left + box.clientWidth / 2;
551
860
  const shown = media.getBoundingClientRect();
861
+ // A gallery's caption band can sit apart from the photo. There the media
862
+ // is the photo's rows, the band and the caption's own box, which an open
863
+ // caption lifts over the photo. So the space between the photo and the
864
+ // band is outside it.
865
+ const captionBox = page === viewer ? null : caption?.getBoundingClientRect();
866
+ const bandBox = page === viewer ? null : caption?.parentElement?.getBoundingClientRect();
552
867
  const isOutside = ({
553
868
  x,
554
869
  y
555
- }) => (y < top || y > bottom || Math.abs(x - middle) > width / 2) && !(x >= shown.left && x <= shown.right && y >= shown.top && y <= shown.bottom);
870
+ }) => {
871
+ const isOnShownPhoto = x >= shown.left && x <= shown.right && y >= shown.top && y <= shown.bottom;
872
+ if (isOnShownPhoto) {
873
+ return false;
874
+ }
875
+ if (captionBox == null) {
876
+ return y < top || y > bottom || Math.abs(x - middle) > width / 2;
877
+ }
878
+ const isOnPhotoRows = y >= top && y <= top + media.offsetHeight && Math.abs(x - middle) <= width / 2;
879
+ const isOnCaption = y >= captionBox.top && y <= captionBox.bottom && x >= captionBox.left && x <= captionBox.right;
880
+ const isOnBand = bandBox != null && y >= bandBox.top && y <= bandBox.bottom && x >= bandBox.left && x <= bandBox.right;
881
+ return !isOnPhotoRows && !isOnCaption && !isOnBand;
882
+ };
556
883
  const press = pressPointRef.current;
557
884
  return isOutside({
558
885
  x: e.clientX,
@@ -570,6 +897,10 @@ export function Lightbox({
570
897
  }
571
898
  }, [handleClose, hasZoom, isVideo, isGallery, isClickOutsideMedia]);
572
899
  const isZoomTarget = hasZoom && !isVideo;
900
+
901
+ // The current page's caption band. The drag to close fades it with the
902
+ // viewer's controls.
903
+ const currentCaptionBandRef = useRef(null);
573
904
  const dismissFades = useCallback(() => {
574
905
  const dialog = dialogRef.current;
575
906
  const container = containerRef.current;
@@ -579,9 +910,11 @@ export function Lightbox({
579
910
  chrome: []
580
911
  };
581
912
  }
582
- const chrome = [];
913
+ // A caption in a band fades as the band, which carries its backing.
914
+ const band = currentCaptionBandRef.current;
915
+ const chrome = band == null ? [] : [band];
583
916
  for (const element of container.querySelectorAll('[data-lightbox-chrome], [data-lightbox-page]:not([data-current]), [data-lightbox-caption]')) {
584
- if (element.parentElement?.closest('[data-lightbox-page]:not([data-current])') == null) {
917
+ if (element.parentElement?.closest('[data-lightbox-page]:not([data-current])') == null && band?.contains(element) !== true) {
585
918
  chrome.push(element);
586
919
  }
587
920
  }
@@ -603,22 +936,15 @@ export function Lightbox({
603
936
  // Meanwhile the caption goes back to its own place below the stage.
604
937
  const isShownAtFitRef = useRef(true);
605
938
  const placeCaption = useCallback(() => {
606
- // The stage's space below its fitted photo: the photo's laid-out height,
607
- // not its zoomed box.
608
- const place = (caption, stageElement, isAtFit) => {
609
- const photo = stageElement?.querySelector('img');
610
- if (caption == null) {
611
- return;
612
- }
613
- const below = isZoomTarget && isAtFit && stageElement != null && photo != null ? (stageElement.clientHeight - photo.offsetHeight) / 2 : 0;
614
- caption.style.translate = below > 0 ? `0 ${-below}px` : '';
615
- };
616
- place(captionRef.current, imageWrapperRef.current, isShownAtFitRef.current);
617
- // A gallery's pages, each with its own caption under its own photo. Only
618
- // the current one can be zoomed.
619
- for (const page of trackRef.current?.querySelectorAll(':scope > [data-lightbox-page]') ?? []) {
620
- place(page.querySelector(':scope > [data-lightbox-caption]'), page.querySelector(':scope > [data-lightbox-page-media]'), !page.hasAttribute('data-current') || isShownAtFitRef.current);
939
+ const caption = captionRef.current;
940
+ if (caption == null) {
941
+ return;
621
942
  }
943
+ const stageElement = imageWrapperRef.current;
944
+ const photo = stageElement?.querySelector('img');
945
+ // The photo's laid-out height, not its zoomed box.
946
+ const below = isZoomTarget && isShownAtFitRef.current && stageElement != null && photo != null ? (stageElement.clientHeight - photo.offsetHeight) / 2 : 0;
947
+ caption.style.translate = below > 0 ? `0 ${-below}px` : '';
622
948
  }, [isZoomTarget]);
623
949
  useAttachment(imageWrapperRef, element => observeResize(element, placeCaption), placeCaption);
624
950
  // Places the caption for the new item's layout before it paints.
@@ -803,6 +1129,21 @@ export function Lightbox({
803
1129
  const box = video.getBoundingClientRect();
804
1130
  return touch.startX >= box.left && touch.startX <= box.right && touch.startY <= box.bottom && touch.startY >= box.bottom - VIDEO_CONTROLS_BAND;
805
1131
  };
1132
+
1133
+ // Paging turns the page that holds focus inert, which drops focus inside
1134
+ // it, such as on its caption toggle or its photo. Such focus moves to the
1135
+ // new page's photo, or to Close without zoom, so the arrow keys keep paging.
1136
+ const pagingFocusRef = useRef(null);
1137
+ const noteFocusBeforePaging = useCallback(() => {
1138
+ pagingFocusRef.current = noteFocusWithin(imageWrapperRef.current?.querySelector('[data-current]'));
1139
+ }, []);
1140
+ // Effect: syncs DOM focus with the new page, since the browser drops focus
1141
+ // from the page that turned inert.
1142
+ useIsomorphicLayoutEffect(() => {
1143
+ const note = pagingFocusRef.current;
1144
+ pagingFocusRef.current = null;
1145
+ moveFocusLeftBehind(note, isZoomTarget ? pageMediaRef.current : closeButtonRef.current, note?.container);
1146
+ }, [index, isZoomTarget]);
806
1147
  usePager({
807
1148
  viewportRef: imageWrapperRef,
808
1149
  trackRef,
@@ -826,6 +1167,7 @@ export function Lightbox({
826
1167
  shouldBeginPan: direction => !stage.isZoomed() || stage.isAtEdge(direction),
827
1168
  onIndexChange: (next, reason) => {
828
1169
  if (reason === 'drag') {
1170
+ noteFocusBeforePaging();
829
1171
  setIndex(next);
830
1172
  }
831
1173
  },
@@ -842,14 +1184,23 @@ export function Lightbox({
842
1184
  }
843
1185
  });
844
1186
 
845
- // Whether a point is on the current page's media group: its photo or video
846
- // and its caption, as one box. The photo takes no pointer events, so a
847
- // press on it lands on its box. An element with no size yet (a photo still
848
- // loading) adds nothing to the box.
1187
+ // Whether a point is on the current page's media. That is inside its
1188
+ // caption's own box, or in its photo's or video's rows across the width of
1189
+ // both. So a click beside a narrow photo, within its caption's width, stays
1190
+ // on the media. The band between the photo and the caption row does not.
1191
+ // The photo takes no pointer events, so a press on it lands on its box. An
1192
+ // element with no size yet (a photo still loading) counts for nothing.
849
1193
  const isOnCurrentMedia = (x, y) => {
850
1194
  const page = imageWrapperRef.current?.querySelector('[data-current]');
851
- const boxes = [page?.querySelector('img'), page?.querySelector('video'), page?.querySelector('[data-lightbox-caption]')].map(element => element?.getBoundingClientRect()).filter(r => r != null && r.width > 0 && r.height > 0);
852
- return boxes.length > 0 && x >= Math.min(...boxes.map(r => r.left)) && x <= Math.max(...boxes.map(r => r.right)) && y >= Math.min(...boxes.map(r => r.top)) && y <= Math.max(...boxes.map(r => r.bottom));
1195
+ const sized = element => {
1196
+ const r = element?.getBoundingClientRect();
1197
+ return r != null && r.width > 0 && r.height > 0 ? r : null;
1198
+ };
1199
+ const media = sized(page?.querySelector('img')) ?? sized(page?.querySelector('video'));
1200
+ const caption = sized(page?.querySelector('[data-lightbox-caption]'));
1201
+ const boxes = [media, caption].filter(r => r != null);
1202
+ const inRows = r => r != null && y >= r.top && y <= r.bottom;
1203
+ return inRows(caption) && caption != null && x >= caption.left && x <= caption.right || inRows(media) && x >= Math.min(...boxes.map(r => r.left)) && x <= Math.max(...boxes.map(r => r.right));
853
1204
  };
854
1205
  // Without zoom, a gallery's stage fills the viewer. So a finger's tap on it
855
1206
  // beside the media closes the viewer, as a click on the backdrop does. A
@@ -882,14 +1233,16 @@ export function Lightbox({
882
1233
 
883
1234
  const goToPrev = useCallback(() => {
884
1235
  if (canPrev) {
1236
+ noteFocusBeforePaging();
885
1237
  setIndex(index - 1);
886
1238
  }
887
- }, [canPrev, index, setIndex]);
1239
+ }, [canPrev, index, noteFocusBeforePaging, setIndex]);
888
1240
  const goToNext = useCallback(() => {
889
1241
  if (canNext) {
1242
+ noteFocusBeforePaging();
890
1243
  setIndex(index + 1);
891
1244
  }
892
- }, [canNext, index, setIndex]);
1245
+ }, [canNext, index, noteFocusBeforePaging, setIndex]);
893
1246
 
894
1247
  // Keyboard navigation. While zoomed, arrows pan the image (matching common
895
1248
  // lightbox conventions); when not zoomed they navigate the gallery.
@@ -935,8 +1288,12 @@ export function Lightbox({
935
1288
  }
936
1289
  }, [isZoomTarget, stage, goToPrev, goToNext]);
937
1290
 
938
- // Enter/Space on the focused image wrapper (role="button") toggles zoom.
1291
+ // Enter/Space on the focused zoom button toggles zoom. Keys from a child
1292
+ // stay the child's.
939
1293
  const handleImageKeyDown = useCallback(e => {
1294
+ if (e.target !== e.currentTarget) {
1295
+ return;
1296
+ }
940
1297
  if (e.key === 'Enter' || e.key === ' ') {
941
1298
  e.preventDefault();
942
1299
  stage.toggle();
@@ -954,7 +1311,8 @@ export function Lightbox({
954
1311
  label,
955
1312
  isDisabled,
956
1313
  onClick,
957
- isMirrored = false
1314
+ isMirrored = false,
1315
+ buttonRef
958
1316
  }) => {
959
1317
  const button = /*#__PURE__*/_jsx(IconButton, {
960
1318
  icon: /*#__PURE__*/_jsx(Icon, {
@@ -963,6 +1321,7 @@ export function Lightbox({
963
1321
  color: "inherit",
964
1322
  xstyle: [isMirrored && rtlStyles.mirror, hasZoom && styles.controlIcon]
965
1323
  }),
1324
+ ref: buttonRef,
966
1325
  label: label,
967
1326
  variant: "ghost",
968
1327
  isDisabled: isDisabled,
@@ -989,7 +1348,7 @@ export function Lightbox({
989
1348
  }
990
1349
  }) : /*#__PURE__*/_jsx("img", {
991
1350
  ref: isCurrent ? stage.contentRef : undefined,
992
- onLoad: placeCaption,
1351
+ onLoad: isCurrent ? placeCaption : undefined,
993
1352
  src: src,
994
1353
  alt: isCurrent ? alt : '',
995
1354
  "aria-hidden": isCurrent ? undefined : true,
@@ -1000,6 +1359,19 @@ export function Lightbox({
1000
1359
  });
1001
1360
  // The current item and its neighbours; the pager shows one at rest.
1002
1361
  const pageIndexes = isGallery ? [index - 1, index, index + 1].filter(i => i >= 0 && i < mediaArray.length) : [];
1362
+ const hasCaptionBand = isGallery && mediaArray.some(item => isRenderable(item.caption));
1363
+ // Its place ends the caption's last line, unless the open caption scrolls.
1364
+ const hasCaptionTogglePlace = hasCaptionToggle && !isCaptionScrolling;
1365
+ // The keyboard's zoom button is the photo's wrapper. In a gallery it is the
1366
+ // current page's photo box, so the caption band stays outside it.
1367
+ const isWrapperZoomButton = isZoomTarget && !isGallery;
1368
+ const zoomButtonProps = {
1369
+ role: 'button',
1370
+ tabIndex: 0,
1371
+ 'aria-pressed': isZoomed,
1372
+ 'aria-label': t('@astryx.lightbox.zoom'),
1373
+ onKeyDown: handleImageKeyDown
1374
+ };
1003
1375
  return /*#__PURE__*/_jsx("dialog", {
1004
1376
  ref: mergedDialogRef,
1005
1377
  onCancel: handleCancel,
@@ -1008,6 +1380,7 @@ export function Lightbox({
1008
1380
  onKeyDownProp?.(e);
1009
1381
  },
1010
1382
  "aria-label": currentItem.alt || t('@astryx.lightbox.mediaViewer'),
1383
+ "aria-describedby": isRenderable(currentItem.caption) ? captionId : undefined,
1011
1384
  ...mergeProps(themeProps('lightbox'), stylex.props(layerTextReset.reset, layerStructureReset.reset, styles.dialog, overlayPaddingReset.reset, xstyle), className, style),
1012
1385
  ...props,
1013
1386
  ...layerClickBoundary({
@@ -1022,155 +1395,227 @@ export function Lightbox({
1022
1395
  dialogRef: dialogRef,
1023
1396
  isOpen: isOpen,
1024
1397
  children: /*#__PURE__*/_jsx(LayerContentBoundary, {
1025
- children: /*#__PURE__*/_jsxs("div", {
1026
- ref: containerRef,
1027
- ...{
1028
- className: "x78zum5 xdt5ytf x6s0dn4 xl56j7k xh8yej3 x5yr21d x1n2onr6"
1029
- },
1030
- // Every press in the viewer records where and how it began. A
1031
- // mouse's or a pen's press clears a zoomed drag's flag anywhere.
1032
- // A finger's press clears it only on the stage.
1033
- onPointerDown: e => {
1034
- pointerTypeRef.current = e.pointerType;
1035
- pressPointRef.current = {
1036
- x: e.clientX,
1037
- y: e.clientY
1038
- };
1039
- const isOnStage = e.target instanceof Node && imageWrapperRef.current?.contains(e.target) === true;
1040
- if (e.pointerType !== 'touch' || isOnStage) {
1041
- didDragRef.current = false;
1042
- }
1043
- },
1044
- children: [/*#__PURE__*/_jsxs("div", {
1045
- "data-lightbox-chrome": "",
1398
+ children: /*#__PURE__*/_jsx(MediaTheme, {
1399
+ mode: "dark",
1400
+ children: /*#__PURE__*/_jsxs("div", {
1401
+ ref: containerRef,
1046
1402
  ...{
1047
- className: "x10l6tqk x10a8y8t xhtitgo x47corl"
1403
+ className: "x78zum5 xdt5ytf x6s0dn4 xl56j7k xh8yej3 x5yr21d x1n2onr6"
1048
1404
  },
1049
- children: [control(styles.closeButton, {
1050
- icon: 'close',
1051
- label: t('@astryx.lightbox.close'),
1052
- onClick: handleClose
1053
- }), isGallery && control([styles.navButton, styles.navPrev], {
1054
- icon: 'chevronLeft',
1055
- label: t('@astryx.lightbox.previous'),
1056
- isDisabled: !canPrev,
1057
- onClick: goToPrev,
1058
- isMirrored: true
1059
- })]
1060
- }), /*#__PURE__*/_jsxs("div", {
1061
- ref: mediaGroupRef,
1062
- "data-lightbox-media": "",
1063
- ...{
1064
- 0: {
1065
- className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8"
1066
- },
1067
- 2: {
1068
- className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1069
- },
1070
- 1: {
1071
- className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1072
- },
1073
- 3: {
1074
- className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1405
+ // Every press in the viewer records where and how it began. A
1406
+ // mouse's or a pen's press clears a zoomed drag's flag anywhere.
1407
+ // A finger's press clears it only on the stage.
1408
+ onPointerDown: e => {
1409
+ pointerTypeRef.current = e.pointerType;
1410
+ pressPointRef.current = {
1411
+ x: e.clientX,
1412
+ y: e.clientY
1413
+ };
1414
+ const isOnStage = e.target instanceof Node && imageWrapperRef.current?.contains(e.target) === true;
1415
+ if (e.pointerType !== 'touch' || isOnStage) {
1416
+ didDragRef.current = false;
1075
1417
  }
1076
- }[!!(isZoomTarget && !isGallery) << 1 | !!isGallery << 0],
1077
- children: [/*#__PURE__*/_jsx("div", {
1078
- ref: imageWrapperRef
1079
- // The wrapper is a keyboard-operable zoom toggle when zoom is
1080
- // enabled: Enter/Space toggles, aria-pressed reflects state.
1081
- ,
1082
- role: isZoomTarget ? 'button' : undefined,
1083
- tabIndex: isZoomTarget ? 0 : undefined,
1084
- "aria-pressed": isZoomTarget ? isZoomed : undefined,
1085
- "aria-label": isZoomTarget ? t('@astryx.lightbox.zoom') : undefined,
1086
- ...stylex.props(styles.imageWrapper, isGallery && styles.imageWrapperGallery, isZoomTarget && !isGallery && styles.imageWrapperZoomTarget, isZoomTarget && !isGallery && styles.imageWrapperFill, isTouch && !isZoomTarget && !isVideo && !isGallery && styles.imageWrapperDismissTarget, isZoomTarget && focusOutlineStyles.focusVisible, isZoomTarget && styles.imageWrapperFocusInset, isZoomTarget && !isZoomed && styles.imageWrapperZoomable, isZoomTarget && isZoomed && styles.imageWrapperZoomed),
1087
- onKeyDown: isZoomTarget ? handleImageKeyDown : undefined,
1088
- onPointerMove: isZoomTarget ? markPointerOverPhoto : undefined,
1089
- onPointerLeave: isZoomTarget ? e => e.currentTarget.removeAttribute(OVER_PHOTO_ATTRIBUTE) : undefined,
1090
- onDoubleClick: isZoomTarget ? e => {
1091
- // A finger's double tap is the stage's own.
1092
- if (pointerTypeRef.current !== 'touch') {
1093
- stage.doubleClickAt(e.clientX, e.clientY);
1094
- }
1095
- } : undefined,
1096
- children: isGallery ? /*#__PURE__*/_jsx("div", {
1097
- ref: trackRef,
1098
- ...{
1099
- 0: {
1100
- className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x7k18q3"
1101
- },
1102
- 2: {
1103
- className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x7k18q3 x1j4r261"
1104
- },
1105
- 1: {
1106
- className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x7k18q3 x1j4r261"
1107
- },
1108
- 3: {
1109
- className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x7k18q3 x1j4r261"
1110
- }
1111
- }[!!isZoomTarget << 1 | !!(isTouch && !isZoomTarget && !isVideo) << 0],
1112
- children: pageIndexes.map(i => /*#__PURE__*/_jsxs("div", {
1113
- "data-lightbox-page": i,
1114
- "data-current": i === index ? '' : undefined
1115
- // Only the current page is on screen at rest: the
1116
- // others stay out of the tab order and the
1117
- // accessibility tree.
1118
- ,
1119
- inert: i !== index ? true : undefined,
1120
- "aria-hidden": i !== index ? true : undefined,
1121
- ...stylex.props(styles.page, pageStyles.position(i)),
1122
- children: [/*#__PURE__*/_jsx("div", {
1123
- ref: i === index ? pageMediaRef : undefined,
1124
- "data-lightbox-page-media": "",
1125
- ...{
1126
- 0: {
1127
- className: "x78zum5 x6s0dn4 xl56j7k xb3r6kr x1odnnbo x1c34a00 x2lwn1j xeuugli x193iq5w"
1128
- },
1129
- 1: {
1130
- className: "x78zum5 x6s0dn4 xl56j7k xb3r6kr x1odnnbo x1c34a00 x2lwn1j xeuugli x193iq5w x5ve5x3 xkh2ocl x1iyjqo2 xs83m0k x1r8uery"
1131
- }
1132
- }[!!isZoomTarget << 0],
1133
- children: renderMedia(mediaArray[i], i === index)
1134
- }), isRenderable(mediaArray[i].caption) && /*#__PURE__*/_jsx("div", {
1135
- "data-lightbox-caption": "",
1136
- ...{
1137
- className: "x9e3rv5 x18juvz8 xf74fhv x2b8uid x1xye8es x18d9i69 xrrkdod xrlsmeg x2lah0s"
1138
- },
1139
- children: mediaArray[i].caption
1140
- })]
1141
- }, i))
1142
- }) : renderMedia(currentItem, true)
1143
- }), !isGallery && isRenderable(currentItem.caption) && /*#__PURE__*/_jsx("div", {
1144
- ref: captionRef,
1145
- "data-lightbox-caption": "",
1418
+ },
1419
+ children: [/*#__PURE__*/_jsxs("div", {
1420
+ "data-lightbox-chrome": "",
1146
1421
  ...{
1147
- className: "x9e3rv5 x18juvz8 xf74fhv x2b8uid x1xye8es x18d9i69 xrrkdod xrlsmeg x2lah0s"
1422
+ className: "x10l6tqk x10a8y8t xhtitgo x47corl"
1148
1423
  },
1149
- children: currentItem.caption
1150
- })]
1151
- }), /*#__PURE__*/_jsxs("div", {
1152
- "data-lightbox-chrome": "",
1153
- ...{
1154
- className: "x10l6tqk x10a8y8t xhtitgo x47corl"
1155
- },
1156
- children: [isGallery && control([styles.navButton, styles.navNext], {
1157
- icon: 'chevronRight',
1158
- label: t('@astryx.lightbox.next'),
1159
- isDisabled: !canNext,
1160
- onClick: goToNext,
1161
- isMirrored: true
1162
- }), isGallery && mediaArray.length > 1 && /*#__PURE__*/_jsxs("div", {
1424
+ children: [control(styles.closeButton, {
1425
+ icon: 'close',
1426
+ label: t('@astryx.lightbox.close'),
1427
+ onClick: handleClose,
1428
+ buttonRef: closeButtonRef
1429
+ }), isGallery && control([styles.navButton, styles.navPrev], {
1430
+ icon: 'chevronLeft',
1431
+ label: t('@astryx.lightbox.previous'),
1432
+ isDisabled: !canPrev,
1433
+ onClick: goToPrev,
1434
+ isMirrored: true
1435
+ })]
1436
+ }), /*#__PURE__*/_jsxs("div", {
1437
+ ref: mediaGroupRef,
1438
+ "data-lightbox-media": "",
1163
1439
  ...{
1164
1440
  0: {
1165
- className: "x10l6tqk xyx6v2t x1ybfrjj x9e3rv5 xjm74w1 xw6l6zx x1vjfegm x67bb7w"
1441
+ className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8"
1442
+ },
1443
+ 2: {
1444
+ className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1166
1445
  },
1167
1446
  1: {
1168
- className: "x10l6tqk xyx6v2t x1ybfrjj x9e3rv5 xjm74w1 xw6l6zx x1vjfegm x67bb7w x1ap9wa5 xjspbzw xf314gf"
1447
+ className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1448
+ },
1449
+ 3: {
1450
+ className: "x78zum5 xdt5ytf x6s0dn4 x193iq5w xmz0i5r xb3r6kr x7l34b8 xkh2ocl x1iyjqo2 x2lwn1j"
1169
1451
  }
1170
- }[!!hasZoom << 0],
1171
- children: [index + 1, " / ", mediaArray.length]
1452
+ }[!!(isZoomTarget && !isGallery) << 1 | !!isGallery << 0],
1453
+ children: [/*#__PURE__*/_jsx("div", {
1454
+ ref: imageWrapperRef,
1455
+ ...(isWrapperZoomButton ? zoomButtonProps : undefined),
1456
+ ...stylex.props(styles.imageWrapper, isGallery && styles.imageWrapperGallery, isZoomTarget && !isGallery && styles.imageWrapperZoomTarget, isZoomTarget && !isGallery && styles.imageWrapperFill, isTouch && !isZoomTarget && !isVideo && !isGallery && styles.imageWrapperDismissTarget, isWrapperZoomButton && focusOutlineStyles.focusVisible, isWrapperZoomButton && styles.zoomButtonFocusInset, isZoomTarget && !isZoomed && styles.imageWrapperZoomable, isZoomTarget && isZoomed && styles.imageWrapperZoomed),
1457
+ onPointerMove: isZoomTarget ? markPointerOverPhoto : undefined,
1458
+ onPointerLeave: isZoomTarget ? e => e.currentTarget.removeAttribute(OVER_PHOTO_ATTRIBUTE) : undefined,
1459
+ onDoubleClick: isZoomTarget ? e => {
1460
+ // A finger's double tap is the stage's own.
1461
+ if (pointerTypeRef.current !== 'touch') {
1462
+ stage.doubleClickAt(e.clientX, e.clientY);
1463
+ }
1464
+ } : undefined,
1465
+ children: isGallery ? /*#__PURE__*/_jsx("div", {
1466
+ ref: trackRef,
1467
+ ...{
1468
+ 0: {
1469
+ className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x1sx1omo"
1470
+ },
1471
+ 2: {
1472
+ className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x1sx1omo x1j4r261"
1473
+ },
1474
+ 1: {
1475
+ className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x1sx1omo x1j4r261"
1476
+ },
1477
+ 3: {
1478
+ className: "x10l6tqk x10a8y8t xrvj5dj x1ftzfwy x1sx1omo x1j4r261"
1479
+ }
1480
+ }[!!isZoomTarget << 1 | !!(isTouch && !isZoomTarget && !isVideo) << 0],
1481
+ children: pageIndexes.map(i => /*#__PURE__*/_jsxs("div", {
1482
+ "data-lightbox-page": i,
1483
+ "data-current": i === index ? '' : undefined
1484
+ // Only the current page is on screen at rest: the
1485
+ // others stay out of the tab order and the
1486
+ // accessibility tree.
1487
+ ,
1488
+ inert: i !== index ? true : undefined,
1489
+ "aria-hidden": i !== index ? true : undefined,
1490
+ ...stylex.props(styles.page, pageStyles.position(i)),
1491
+ children: [/*#__PURE__*/_jsx("div", {
1492
+ ref: i === index ? pageMediaRef : undefined,
1493
+ "data-lightbox-page-media": "",
1494
+ ...(isZoomTarget && i === index ? zoomButtonProps : undefined),
1495
+ ...stylex.props(styles.pageMedia, isZoomTarget && styles.pageMediaZoomTarget, isZoomTarget && i === index && [focusOutlineStyles.focusVisible, styles.zoomButtonFocusInset]),
1496
+ children: renderMedia(mediaArray[i], i === index)
1497
+ }), hasCaptionBand && /*#__PURE__*/_jsx("div", {
1498
+ ref: i === index ? currentCaptionBandRef : undefined,
1499
+ ...{
1500
+ 0: {
1501
+ className: "x7sv70a x1n2onr6 x78zum5 xl56j7k x1cy8zhl xeuugli x1afcbsf xjm74w1 xw6l6zx xdvjn3b x6h9hlj xphgbls"
1502
+ },
1503
+ 2: {
1504
+ className: "x7sv70a x1n2onr6 x78zum5 xl56j7k x1cy8zhl xeuugli x1afcbsf xjm74w1 xw6l6zx xdvjn3b x6h9hlj xjbqb8w"
1505
+ },
1506
+ 1: {
1507
+ className: "x7sv70a x1n2onr6 x78zum5 xl56j7k x1cy8zhl xeuugli x1afcbsf xjm74w1 xw6l6zx xdvjn3b x6h9hlj xjbqb8w"
1508
+ },
1509
+ 3: {
1510
+ className: "x7sv70a x1n2onr6 x78zum5 xl56j7k x1cy8zhl xeuugli x1afcbsf xjm74w1 xw6l6zx xdvjn3b x6h9hlj xjbqb8w"
1511
+ }
1512
+ }[!!!isRenderable(mediaArray[i].caption) << 1 | !!(i === index && isCaptionOpen) << 0],
1513
+ children: isRenderable(mediaArray[i].caption) &&
1514
+ /*#__PURE__*/
1515
+ // The page's one caption: clamped in the
1516
+ // band, or open over the photo's bottom.
1517
+ _jsx("div", {
1518
+ id: i === index ? fullCaptionId : undefined,
1519
+ "data-lightbox-caption": "",
1520
+ ...{
1521
+ 0: {
1522
+ className: "x78zum5 xeuugli x193iq5w"
1523
+ },
1524
+ 1: {
1525
+ className: "x78zum5 xeuugli x10l6tqk x17y0mx6 x1ey2m1c xl56j7k x1x1rfll x6h9hlj xphgbls"
1526
+ }
1527
+ }[!!(i === index && isCaptionOpen) << 0],
1528
+ children: /*#__PURE__*/_jsxs("div", {
1529
+ ...{
1530
+ className: "x1n2onr6 x78zum5 x1cy8zhl xeuugli x193iq5w"
1531
+ },
1532
+ children: [/*#__PURE__*/_jsx(Text, {
1533
+ ref: i === index ? bandCaptionMeasureRef : undefined,
1534
+ id: i === index ? captionId : undefined,
1535
+ as: "div",
1536
+ type: "body",
1537
+ maxLines: i === index && isCaptionOpen ? 0 : 2,
1538
+ hasTruncateTooltip: false,
1539
+ xstyle: [styles.caption, styles.captionClamped, i === index && isCaptionOpen && styles.captionTextOpen, i === index && hasCaptionToggle && isCaptionScrolling && styles.captionTextBesideToggle(captionToggleWidth)],
1540
+ children: /*#__PURE__*/_jsxs("div", {
1541
+ ref: i === index ? bandCaptionFlowRef : undefined,
1542
+ ...{
1543
+ className: "x1lliihq"
1544
+ },
1545
+ children: [/*#__PURE__*/_jsx("span", {
1546
+ "aria-hidden": "true",
1547
+ ...stylex.props(styles.captionTogglePlace, i === index && hasCaptionTogglePlace && captionShownLines > 0 && styles.captionTogglePlaceShown(captionToggleWidth, captionShownLines))
1548
+ }), mediaArray[i].caption]
1549
+ })
1550
+ }), i === index &&
1551
+ /*#__PURE__*/
1552
+ // Mounted with the caption, and hidden
1553
+ // until the caption needs it. So a
1554
+ // measurement only shows or hides it,
1555
+ // and adds no element.
1556
+ _jsx(Link, {
1557
+ ref: captionToggleRefs,
1558
+ hidden: !hasCaptionToggle,
1559
+ type: "inherit"
1560
+ // The toggle takes the caption's
1561
+ // own colour. A theme's accent on
1562
+ // the media surface can match the
1563
+ // band. The underline sets the
1564
+ // toggle apart.
1565
+ ,
1566
+ color: "inherit",
1567
+ hasUnderline: true,
1568
+ "aria-expanded": isCaptionOpen,
1569
+ "aria-controls": fullCaptionId,
1570
+ onClick: () => {
1571
+ if (isCaptionOpen) {
1572
+ setOpenCaptionIndex(null);
1573
+ return;
1574
+ }
1575
+ // eslint-disable-next-line @eslint-react/dom-no-flush-sync -- the opened caption lays out without the toggle's place before its lines are counted
1576
+ flushSync(() => {
1577
+ setCaptionShownLines(0);
1578
+ setOpenCaptionIndex(index);
1579
+ });
1580
+ countOpenCaption();
1581
+ },
1582
+ xstyle: [styles.captionToggle, touchHitAreaStyles.layer, !hasCaptionToggle && styles.captionToggleHidden],
1583
+ children: isCaptionOpen ? t('@astryx.lightbox.captionLess') : t('@astryx.lightbox.captionMore')
1584
+ })]
1585
+ })
1586
+ })
1587
+ })]
1588
+ }, i))
1589
+ }) : renderMedia(currentItem, true)
1590
+ }), !isGallery && isRenderable(currentItem.caption) && /*#__PURE__*/_jsx(Text, {
1591
+ ref: captionRef,
1592
+ id: captionId,
1593
+ "data-lightbox-caption": "",
1594
+ as: "div",
1595
+ type: "body",
1596
+ xstyle: styles.caption,
1597
+ children: currentItem.caption
1598
+ })]
1599
+ }), /*#__PURE__*/_jsxs("div", {
1600
+ "data-lightbox-chrome": "",
1601
+ ...{
1602
+ className: "x10l6tqk x10a8y8t xhtitgo x47corl"
1603
+ },
1604
+ children: [isGallery && control([styles.navButton, styles.navNext], {
1605
+ icon: 'chevronRight',
1606
+ label: t('@astryx.lightbox.next'),
1607
+ isDisabled: !canNext,
1608
+ onClick: goToNext,
1609
+ isMirrored: true
1610
+ }), isGallery && mediaArray.length > 1 && /*#__PURE__*/_jsxs(Text, {
1611
+ as: "div",
1612
+ type: "body",
1613
+ color: hasZoom ? 'inherit' : undefined,
1614
+ xstyle: [styles.counter, hasZoom && styles.counterBacking, hasZoom && styles.counterOnDark],
1615
+ children: [index + 1, " / ", mediaArray.length]
1616
+ })]
1172
1617
  })]
1173
- })]
1618
+ })
1174
1619
  })
1175
1620
  })
1176
1621
  })