@astryx-vue/core 0.40.0 → 0.41.0

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 (300) hide show
  1. package/dist/AlertDialog/index.js +1 -1
  2. package/dist/{AlertDialog-McG6w72O.js → AlertDialog-DxrO48Kg.js} +7 -7
  3. package/dist/AppShell/index.js +1 -1
  4. package/dist/{AppShell-lv3WDlCi.js → AppShell-Y-rwHGxA.js} +2 -2
  5. package/dist/Avatar/index.js +1 -1
  6. package/dist/{Avatar-BY-EWaJM.js → Avatar-z50mYJor.js} +1 -1
  7. package/dist/AvatarGroup/index.d.ts +1 -1
  8. package/dist/AvatarGroup/index.js +1 -1
  9. package/dist/{AvatarGroup-BSsARmYE.js → AvatarGroup-BZ5iG7M-.js} +1 -1
  10. package/dist/Banner/index.d.ts +1 -1
  11. package/dist/Banner/index.js +1 -1
  12. package/dist/{Banner-CmWBciT7.js → Banner-0YtnbBU6.js} +1 -1
  13. package/dist/BottomSheet/index.d.ts +1 -1
  14. package/dist/BottomSheet/index.js +2 -2
  15. package/dist/{BottomSheet-BkBRbF1_.js → BottomSheet-B8frtWqm.js} +8 -8
  16. package/dist/{BottomSheet-BOEmV4QT.js → BottomSheet-u57AJshc.js} +1 -1
  17. package/dist/Breadcrumbs/index.js +2 -2
  18. package/dist/{Breadcrumbs-D7dac2Vx.js → Breadcrumbs-9KMHiyXr.js} +1 -1
  19. package/dist/Button/index.d.ts +1 -1
  20. package/dist/Button/index.js +1 -1
  21. package/dist/{Button-pAwKXPpg.js → Button-ClyetTf6.js} +4 -4
  22. package/dist/ButtonGroup/index.d.ts +1 -1
  23. package/dist/ButtonGroup/index.js +1 -1
  24. package/dist/{ButtonGroup-CuxHcLGQ.js → ButtonGroup-tk0H2O8q.js} +2 -2
  25. package/dist/Calendar/index.d.ts +1 -1
  26. package/dist/Carousel/index.d.ts +1 -1
  27. package/dist/Carousel/index.js +1 -1
  28. package/dist/{Carousel-CS2e2A7m.js → Carousel-utfvjW5p.js} +1 -1
  29. package/dist/Chat/index.d.ts +1 -1
  30. package/dist/Chat/index.js +1 -1
  31. package/dist/{Chat-BpZRcgDp.js → Chat-DL583Xle.js} +6 -6
  32. package/dist/CheckboxInput/index.d.ts +1 -1
  33. package/dist/CheckboxInput/index.js +1 -1
  34. package/dist/{CheckboxInput-DhacWPUS.js → CheckboxInput-BQH87pfn.js} +4 -4
  35. package/dist/CheckboxList/index.d.ts +1 -1
  36. package/dist/CheckboxList/index.js +1 -1
  37. package/dist/{CheckboxListItem-D7PdrL6R.js → CheckboxListItem-CZ1B81gI.js} +4 -4
  38. package/dist/ClickableCard/index.d.ts +1 -1
  39. package/dist/ClickableCard/index.js +1 -1
  40. package/dist/{ClickableCard-DYcn-IFI.js → ClickableCard-CdByvXDr.js} +1 -1
  41. package/dist/Code/index.js +2 -2
  42. package/dist/{Code-CpOHgCdF.js → Code-KvqZ1ZES.js} +1 -1
  43. package/dist/{CodeBlock-CkGp6dGF.js → CodeBlock-e2rlXQWO.js} +1 -1
  44. package/dist/Collapsible/index.d.ts +1 -1
  45. package/dist/Collapsible/index.js +1 -1
  46. package/dist/{Collapsible-CaKmR3yE.js → Collapsible-CTc7irlw.js} +1 -1
  47. package/dist/CommandPalette/index.d.ts +1 -1
  48. package/dist/CommandPalette/index.js +1 -1
  49. package/dist/{CommandPalette-DiM8MlSa.js → CommandPalette-PBYSDIpx.js} +3 -3
  50. package/dist/ComplexSelector/index.js +1 -1
  51. package/dist/{ComplexSelector-BmXhD8Oe.js → ComplexSelector-CPg5jcdL.js} +2 -2
  52. package/dist/ContextMenu/index.d.ts +1 -1
  53. package/dist/ContextMenu/index.js +2 -2
  54. package/dist/{ContextMenu-DcqcObzD.js → ContextMenu-DcZEviKv.js} +5 -5
  55. package/dist/DateInput/index.d.ts +1 -1
  56. package/dist/DateInput/index.js +1 -1
  57. package/dist/{DateInput-C3KNWKD5.js → DateInput-C4qtEFDW.js} +5 -5
  58. package/dist/DateRangeInput/index.d.ts +1 -1
  59. package/dist/DateRangeInput/index.js +1 -1
  60. package/dist/{DateRangeInput-C7qeaG20.js → DateRangeInput-CGqCQAlT.js} +3 -3
  61. package/dist/DateTimeInput/index.d.ts +1 -1
  62. package/dist/DateTimeInput/index.js +1 -1
  63. package/dist/{DateTimeInput-L0EZbgPe.js → DateTimeInput-CAirxttc.js} +5 -5
  64. package/dist/Dialog/index.js +3 -3
  65. package/dist/{Dialog-DLg0POKn.js → Dialog-B2-5xYs2.js} +2 -2
  66. package/dist/{Dialog-iVqfWx9T.js → Dialog-CjN3cV-b.js} +1 -1
  67. package/dist/{DialogHeader-B0B8oATV.js → DialogHeader-BS8mjD8z.js} +2 -2
  68. package/dist/Divider/index.d.ts +1 -1
  69. package/dist/Drawer/index.d.ts +1 -1
  70. package/dist/Drawer/index.js +1 -1
  71. package/dist/{Drawer-C0x5HNmD.js → Drawer-Cq1Y_1iJ.js} +3 -3
  72. package/dist/DropdownMenu/index.js +2 -2
  73. package/dist/{DropdownMenu-pqhotFvD.js → DropdownMenu-CSn1OQ2D.js} +7 -7
  74. package/dist/EmptyState/index.js +1 -1
  75. package/dist/{EmptyState-BUmLBchw.js → EmptyState-uHOykbeo.js} +2 -2
  76. package/dist/Field/index.js +3 -3
  77. package/dist/{Field-D3W-qMmn.js → Field-BzGwGqwa.js} +1 -1
  78. package/dist/{FieldInfoTip-K-cUaCBk.js → FieldInfoTip-DqsdZxo0.js} +1 -1
  79. package/dist/{FieldLabel-CIe1tEyM.js → FieldLabel-DdMLaCP_.js} +1 -1
  80. package/dist/FileInput/index.js +1 -1
  81. package/dist/{FileInput-Crb5znnx.js → FileInput-B_BXknEU.js} +3 -3
  82. package/dist/Heading/index.d.ts +1 -1
  83. package/dist/Heading/index.js +1 -1
  84. package/dist/{Heading-SdObK_xM.js → Heading-BFJhZInd.js} +1 -1
  85. package/dist/HoverCard/index.d.ts +1 -1
  86. package/dist/HoverCard/index.js +1 -1
  87. package/dist/{HoverCard-B7hrl0Qz.js → HoverCard-Cbxy2KEM.js} +4 -4
  88. package/dist/IconButton/index.js +1 -1
  89. package/dist/{IconButton-Cug4YcFk.js → IconButton-kj1M_L7a.js} +1 -1
  90. package/dist/InfoTip/index.d.ts +1 -1
  91. package/dist/InfoTip/index.js +1 -1
  92. package/dist/{InfoTip-Cu4a1mi4.js → InfoTip-DJIb8b29.js} +2 -2
  93. package/dist/{InputClearButton-CgUhJflI.js → InputClearButton-wd0VoZja.js} +1 -1
  94. package/dist/InputGroup/index.js +1 -1
  95. package/dist/{InputGroup-BRsu7Tbv.js → InputGroup-DGiF9Xaz.js} +1 -1
  96. package/dist/{Item-DrV3f4fe.js → Item-DC1v56yE.js} +1 -1
  97. package/dist/{LayerContentBoundary-iYtfCpG9.js → LayerContentBoundary-tgsCvoNX.js} +1 -1
  98. package/dist/Layout/index.js +2 -2
  99. package/dist/{Layout-DTSKNAzq.js → Layout-C7oS06UY.js} +1 -1
  100. package/dist/{LayoutPanel-CH4HZGLR.js → LayoutPanel-BwvUhSM5.js} +1 -1
  101. package/dist/Lightbox/index.d.ts +1 -1
  102. package/dist/Lightbox/index.js +1 -1
  103. package/dist/Lightbox-Fu6RCX0k.js +2353 -0
  104. package/dist/Link/index.d.ts +1 -1
  105. package/dist/Link/index.js +1 -1
  106. package/dist/{Link-BsmxrY3Y.js → Link-zPVCNAM6.js} +2 -2
  107. package/dist/List/index.d.ts +1 -1
  108. package/dist/List/index.js +2 -2
  109. package/dist/{ListItem-DZwU5RrZ.js → ListItem-CrFLvZ6o.js} +2 -2
  110. package/dist/Markdown/index.d.ts +1 -1
  111. package/dist/Markdown/index.js +1 -1
  112. package/dist/{Markdown-CiLkzTFi.js → Markdown-BiXz75mz.js} +3 -3
  113. package/dist/MetadataList/index.d.ts +1 -1
  114. package/dist/MobileNav/index.js +1 -1
  115. package/dist/{MobileNavToggle-CiY__Fy9.js → MobileNavToggle-VB6SzHYo.js} +1 -1
  116. package/dist/MoreMenu/index.d.ts +1 -1
  117. package/dist/MoreMenu/index.js +1 -1
  118. package/dist/{MoreMenu-BWuzaT3K.js → MoreMenu-RbFK2t0J.js} +6 -6
  119. package/dist/MultiSelector/index.d.ts +1 -1
  120. package/dist/MultiSelector/index.js +1 -1
  121. package/dist/{MultiSelector-geUPBvlE.js → MultiSelector-CaL3UDIc.js} +5 -5
  122. package/dist/{NavDisclosure-l2h8R_ub.js → NavDisclosure-tEaEwaA0.js} +1 -1
  123. package/dist/{NavHeadingSurface-C3QJ64vm.js → NavHeadingSurface-CwSYyXFb.js} +1 -1
  124. package/dist/NavItem/index.d.ts +1 -1
  125. package/dist/NavItem/index.js +1 -1
  126. package/dist/{NavItem-BbnusKbo.js → NavItem-D_1ecPv_.js} +1 -1
  127. package/dist/NavMenu/index.js +3 -3
  128. package/dist/{NavMenu-BRWghdCF.js → NavMenu-CqhjkZuz.js} +2 -2
  129. package/dist/{NavMenuItem-BtYmdZGe.js → NavMenuItem-DqBCA1VP.js} +3 -3
  130. package/dist/NumberInput/index.d.ts +1 -1
  131. package/dist/NumberInput/index.js +1 -1
  132. package/dist/{NumberInput--sai94t9.js → NumberInput-0lTA5weY.js} +4 -4
  133. package/dist/Outline/index.js +1 -1
  134. package/dist/{Outline-DGntLLCe.js → Outline-BoxN40Bd.js} +2 -2
  135. package/dist/OverflowList/index.d.ts +1 -1
  136. package/dist/OverflowList/index.js +1 -1
  137. package/dist/{OverflowList-DJBaY3B_.js → OverflowList-7oui4oT5.js} +2 -2
  138. package/dist/Overlay/index.d.ts +1 -1
  139. package/dist/Pagination/index.d.ts +1 -1
  140. package/dist/Pagination/index.js +1 -1
  141. package/dist/{Pagination-C10gbfyv.js → Pagination-BrkX0lga.js} +2 -2
  142. package/dist/{PanGestureRecognizer-K-I6ORwh.js → PanGestureRecognizer-BFSO5U4N.js} +3 -3
  143. package/dist/{PickerWheel-CpAyp6NS.js → PickerWheel-CWT7l-9Q.js} +12 -11
  144. package/dist/Popover/index.js +1 -1
  145. package/dist/{Popover-C6_p8KAA.js → Popover-BZ4VWDtv.js} +6 -6
  146. package/dist/PowerSearch/index.d.ts +1 -1
  147. package/dist/PowerSearch/index.js +1 -1
  148. package/dist/{PowerSearch-D47zbO7s.js → PowerSearch-BEDWm7aj.js} +26 -26
  149. package/dist/{PressTracker-Byalgid0.js → PressTracker-DDRxFc0Y.js} +2 -2
  150. package/dist/ProgressBar/index.d.ts +1 -1
  151. package/dist/ProgressBar/index.js +1 -1
  152. package/dist/{ProgressBar-DJ79DNQq.js → ProgressBar-D4br-4_x.js} +2 -2
  153. package/dist/Radio/index.d.ts +1 -1
  154. package/dist/Radio/index.js +1 -1
  155. package/dist/{RadioGroup-C1VXRBSf.js → RadioGroup-CrRm7H51.js} +5 -5
  156. package/dist/RadioList/index.d.ts +1 -1
  157. package/dist/RadioList/index.js +1 -1
  158. package/dist/{RadioListItem-DrAwYoOz.js → RadioListItem-iPD3y2Eo.js} +1 -1
  159. package/dist/Resizable/index.js +1 -1
  160. package/dist/{ResizeHandle-ruXeaXUT.js → ResizeHandle-C7xEokaQ.js} +2 -2
  161. package/dist/ScrollableArea/index.d.ts +1 -1
  162. package/dist/SegmentedControl/index.js +1 -1
  163. package/dist/{SegmentedControl-D9atngIc.js → SegmentedControl-D8A_jaFC.js} +7 -7
  164. package/dist/SelectableCard/index.d.ts +1 -1
  165. package/dist/SelectableCard/index.js +1 -1
  166. package/dist/{SelectableCard-BSgi3FJf.js → SelectableCard-DIruuGBa.js} +1 -1
  167. package/dist/Selector/index.d.ts +1 -1
  168. package/dist/Selector/index.js +1 -1
  169. package/dist/{Selector-DFTryuh1.js → Selector-CFdM10Uc.js} +3 -3
  170. package/dist/SideNav/index.d.ts +1 -1
  171. package/dist/SideNav/index.js +1 -1
  172. package/dist/{SideNav-Bjk5ACqf.js → SideNav-Cl1H-baW.js} +7 -7
  173. package/dist/Slider/index.js +1 -1
  174. package/dist/{Slider-rOwQQK6G.js → Slider-Bd3wpFo7.js} +11 -10
  175. package/dist/Stack/index.d.ts +1 -1
  176. package/dist/StatusDot/index.js +1 -1
  177. package/dist/{StatusDot-DOf6Q4MC.js → StatusDot-arRs8rKk.js} +1 -1
  178. package/dist/Stepper/index.d.ts +1 -1
  179. package/dist/Stepper/index.js +1 -1
  180. package/dist/{Stepper-0ycdCwND.js → Stepper-CZU_Zvi5.js} +1 -1
  181. package/dist/Switch/index.d.ts +1 -1
  182. package/dist/Switch/index.js +1 -1
  183. package/dist/{Switch-BBfZ6XqA.js → Switch-BpkKyz98.js} +10 -10
  184. package/dist/TabList/index.d.ts +1 -1
  185. package/dist/TabList/index.js +1 -1
  186. package/dist/{TabList-BnLUktgm.js → TabList-DZ2i0QIt.js} +3 -3
  187. package/dist/Table/index.d.ts +1 -1
  188. package/dist/Table/index.js +1 -1
  189. package/dist/{Table-D0yjxm9X.js → Table-kq_-RxXg.js} +10 -10
  190. package/dist/{haptics-By_893U8.js → TapGestureRecognizer-DCiP88h8.js} +4 -21
  191. package/dist/Text/index.d.ts +1 -1
  192. package/dist/Text/index.js +1 -1
  193. package/dist/{Text-CILdp7jE.js → Text-DHm9r3Yh.js} +1 -1
  194. package/dist/TextArea/index.d.ts +1 -1
  195. package/dist/TextArea/index.js +1 -1
  196. package/dist/{TextArea-Cr00OL0D.js → TextArea-D5aDDlgr.js} +5 -5
  197. package/dist/TextInput/index.d.ts +1 -1
  198. package/dist/TextInput/index.js +1 -1
  199. package/dist/{TextInput-CVfvRHOa.js → TextInput-CVRWRtoL.js} +5 -5
  200. package/dist/Thumbnail/index.js +1 -1
  201. package/dist/{Thumbnail-CJPZ299u.js → Thumbnail-zFN5p6dk.js} +3 -3
  202. package/dist/{TimeField-Csp1-lRo.js → TimeField-B49DgkyR.js} +4 -4
  203. package/dist/TimeInput/index.d.ts +1 -1
  204. package/dist/TimeInput/index.js +1 -1
  205. package/dist/{TimeInput-B4JLpJ2N.js → TimeInput-BoFij92p.js} +2 -2
  206. package/dist/Timer/index.js +1 -1
  207. package/dist/{Timer-DOoFQEBD.js → Timer-zNCSMU7S.js} +1 -1
  208. package/dist/Timestamp/index.d.ts +1 -1
  209. package/dist/Timestamp/index.js +1 -1
  210. package/dist/{Timestamp-BmH-CQ8p.js → Timestamp-DunFvQYG.js} +3 -3
  211. package/dist/Toast/index.js +1 -1
  212. package/dist/{Toast-Cuc1o3ph.js → Toast-BnIq3gzw.js} +3 -3
  213. package/dist/ToggleButton/index.d.ts +1 -1
  214. package/dist/ToggleButton/index.js +1 -1
  215. package/dist/{ToggleButton-BsAi9ln1.js → ToggleButton-CLgj6yLQ.js} +3 -3
  216. package/dist/Token/index.js +1 -1
  217. package/dist/{Token-Di7w9Cvr.js → Token-BPjnWrHl.js} +1 -1
  218. package/dist/Tokenizer/index.d.ts +1 -1
  219. package/dist/Tokenizer/index.js +1 -1
  220. package/dist/{Tokenizer-CXCnZtY3.js → Tokenizer-CMv-Bi0y.js} +12 -12
  221. package/dist/Toolbar/index.d.ts +1 -1
  222. package/dist/Tooltip/index.d.ts +1 -1
  223. package/dist/Tooltip/index.js +2 -2
  224. package/dist/{Tooltip-DPiEYfao.js → Tooltip-BuPbbGtv.js} +1 -1
  225. package/dist/TopNav/index.d.ts +1 -1
  226. package/dist/TopNav/index.js +1 -1
  227. package/dist/{TopNav-GvK-XIRl.js → TopNav-DUkn4CMv.js} +5 -5
  228. package/dist/TreeList/index.d.ts +1 -1
  229. package/dist/TreeList/index.js +1 -1
  230. package/dist/{TreeList-CfELZwbQ.js → TreeList-o5MrA7rz.js} +1 -1
  231. package/dist/Typeahead/index.js +2 -2
  232. package/dist/{Typeahead-Csob3tst.js → Typeahead-DXlsxjkQ.js} +5 -5
  233. package/dist/{VelocityTracker-CWqXCLNe.js → VelocityTracker-D5wT6A0d.js} +1 -1
  234. package/dist/{accessibleName-CYV4uRm9.js → accessibleName-9UI6HUaA.js} +1 -1
  235. package/dist/{animator-i7djdtNK.js → animator-D6Buqmbt.js} +1 -1
  236. package/dist/{boxHold-ig0sUg95.js → boxHold-DfsWCZLh.js} +1 -1
  237. package/dist/composables/index.js +8 -8
  238. package/dist/{composables-DqaKLASV.js → composables-Dzpv7G2Z.js} +13 -409
  239. package/dist/{decay-DGF4-sPB.js → decay-CUtQFEXK.js} +6 -2
  240. package/dist/{geometry-BBqUriul.js → geometry-ae8bOxQ5.js} +1 -1
  241. package/dist/{gestures-CP1MX1rx.js → gestures-D_ih8YYG.js} +1 -1
  242. package/dist/haptics-BPQp81pc.js +19 -0
  243. package/dist/{index-DgNCHxvu.d.ts → index-B7-c8UTz.d.ts} +3 -3
  244. package/dist/{index-BuubzuE8.d.ts → index-BDZCJ9ri.d.ts} +2 -2
  245. package/dist/{index-ZKBj_1nu.d.ts → index-BfFpUr1B.d.ts} +1 -1
  246. package/dist/{index-BB9acgK8.d.ts → index-BgT6mH3U.d.ts} +1 -1
  247. package/dist/{index-CCpcerMA.d.ts → index-BhGIK1Hz.d.ts} +4 -1
  248. package/dist/{index-LvZ3vP29.d.ts → index-BylgDU_m.d.ts} +2 -2
  249. package/dist/{index-BjqoHLMq.d.ts → index-C1e8LNx2.d.ts} +1 -1
  250. package/dist/{index-CKnr0JlT.d.ts → index-C4S65SAW.d.ts} +1 -1
  251. package/dist/{index-D05JGsT3.d.ts → index-C8wfe0Mr.d.ts} +1 -1
  252. package/dist/{index-COgrQZIL.d.ts → index-CdvmnNMH.d.ts} +1 -1
  253. package/dist/{index-mK1ICsVg.d.ts → index-Cm36VS1A.d.ts} +2 -2
  254. package/dist/{index-YP5WRwXH.d.ts → index-DCH2D3wa.d.ts} +5 -5
  255. package/dist/{index-BFPb14Xj.d.ts → index-DQ5vPsr8.d.ts} +3 -3
  256. package/dist/{index-CuW4AQ7M.d.ts → index-DXHmlFcC.d.ts} +3 -3
  257. package/dist/{index-DPhQZXYw.d.ts → index-DYabo8TI.d.ts} +1 -1
  258. package/dist/{index-BtqvPjAf.d.ts → index-DofC9Rll.d.ts} +1 -1
  259. package/dist/{index-DN2b-w3H.d.ts → index-DrbxKOhR.d.ts} +51 -51
  260. package/dist/{index-utZGF4GR.d.ts → index-NOXYEdOI.d.ts} +1 -1
  261. package/dist/{index-0RIgvtdm.d.ts → index-ZXrvTM3A.d.ts} +2 -2
  262. package/dist/{index-Ak1b0V24.d.ts → index-a6o69uPN.d.ts} +1 -1
  263. package/dist/{index-Ds4dOCSy.d.ts → index-m-fFGq2e.d.ts} +1 -1
  264. package/dist/{index-yQc-te9a.d.ts → index-ql9ApSTF.d.ts} +2 -2
  265. package/dist/{index-CtYlR9Cu.d.ts → index-rdwI-mcm.d.ts} +1 -1
  266. package/dist/{index-C89cIh4E.d.ts → index-waTkqxTz.d.ts} +1 -1
  267. package/dist/index.d.ts +24 -24
  268. package/dist/index.js +99 -99
  269. package/dist/{layerDepth-C4altnV8.js → layerDepth-D576XVps.js} +1 -1
  270. package/dist/{lazyBottomSheet-0H4ih8Oh.js → lazyBottomSheet-gQtGKE8w.js} +1 -1
  271. package/dist/{position-CkZfFubr.js → position-DD8UQJ2A.js} +1 -1
  272. package/dist/{pressGesture-ZTBGwYpT.js → pressGesture-CwmZDuSC.js} +1 -1
  273. package/dist/{pressSlot-zlwhNl9N.js → pressSlot-5Bp-B175.js} +1 -1
  274. package/dist/{projection-DzrWyxL1.js → projection-Ccz44WX4.js} +1 -1
  275. package/dist/{reducedMotion-BHRhHfWB.js → reducedMotion-BcstlXZU.js} +1 -1
  276. package/dist/{resizableChannel-b7iQNnCj.js → resizableChannel-CABtOiJL.js} +1 -1
  277. package/dist/{resolveMotion-BCM4CX-R.js → resolveMotion-BHR1cz0Q.js} +1 -1
  278. package/dist/{resolveSnapPoint-D1yU-Z-K.js → resolveSnapPoint-C7GZY6jT.js} +1 -1
  279. package/dist/{rideKeyboard-BKGLLMuU.js → rideKeyboard-BldiTgxS.js} +2 -2
  280. package/dist/{rubberBand-C-2erWWl.js → rubberBand-Ct9HFML5.js} +1 -1
  281. package/dist/snapPagingCatcher-RkUaZdWD.js +407 -0
  282. package/dist/{stillPointerGate-DXFzBeMy.js → stillPointerGate-CCFCP1uz.js} +1 -1
  283. package/dist/{tooltipFocusRules-R21SPfWy.js → tooltipFocusRules-CfJwTrhE.js} +2 -2
  284. package/dist/{tooltipTriggerRules-CoGD2lVn.js → tooltipTriggerRules-DRhcB-wA.js} +1 -1
  285. package/dist/{useActionGroupTracking-SVkaaOzz.js → useActionGroupTracking-Cujjrmt3.js} +3 -3
  286. package/dist/{useDismiss-yu_sIa7a.js → useDismiss-Dq7HNw2m.js} +1 -1
  287. package/dist/{useGestureRecognizer-BKzTWKYx.js → useGestureRecognizer-CtfxP4uw.js} +1 -1
  288. package/dist/{useInputStatusIcon-CRG-be-K.js → useInputStatusIcon-2sRn-Nbf.js} +1 -1
  289. package/dist/{useMenuPress-DrrOBqjM.js → useMenuPress-B2Zt5xc5.js} +1 -1
  290. package/dist/{useMobileKeyboard-Cibxl8ZC.js → useMobileKeyboard-CN6o0BrJ.js} +2 -2
  291. package/dist/{usePressFeedback-BEY9kk8T.js → usePressFeedback-Ber7MRiI.js} +3 -3
  292. package/dist/{useResizable-CJQAV_tU.js → useResizable-Dme0X_ZM.js} +5 -5
  293. package/dist/{useTooltip-B2RrDbtI.js → useTooltip-Dg2459oV.js} +4 -4
  294. package/dist/{useTouchHitArea-BdpeksgK.js → useTouchHitArea-B6g7fhfF.js} +1 -1
  295. package/dist/{useTouchTriggerInternal-Obcx-oKN.js → useTouchTriggerInternal-DZ_e8l4G.js} +1 -1
  296. package/dist/{useTruncationTooltip-RUl8qSGz.js → useTruncationTooltip-CCVsMc8c.js} +3 -3
  297. package/dist/{useTypeaheadMenuConfig-0glQWHQd.js → useTypeaheadMenuConfig-CKEuRCOZ.js} +1 -1
  298. package/package.json +1 -1
  299. package/styles/lightbox.css +117 -33
  300. package/dist/Lightbox-_RBPOxDZ.js +0 -545
@@ -0,0 +1,2353 @@
1
+ import { a as registerMotionTable } from "./roles-D6hLs7Rg.js";
2
+ import { a as registerReducedMotionCrossFade } from "./linearEasing-CDsqxyiS.js";
3
+ import { a as UIKIT_PAN, o as UIKIT_PINCH } from "./gestures-D_ih8YYG.js";
4
+ import { r as resetLayerScopedContext } from "./scopedProvide-C-Df7c15.js";
5
+ import { t as _sfc_main$2 } from "./Icon-BUSj1-Th.js";
6
+ import { t as useCoarsePointer } from "./useCoarsePointer-GItEMrjX.js";
7
+ import { n as createMotionEngine, t as animatorFor } from "./animator-D6Buqmbt.js";
8
+ import { t as cubicBezier } from "./bezier-Dko5MnTp.js";
9
+ import { r as themeTempo, t as resolveMotion } from "./resolveMotion-BHR1cz0Q.js";
10
+ import { t as decayRestDistance } from "./decay-CUtQFEXK.js";
11
+ import { a as coast, i as LongPressGestureRecognizer, n as paging, r as registerPagingTable, t as SettleCatcher } from "./snapPagingCatcher-RkUaZdWD.js";
12
+ import { s as springs } from "./springs-B5hVbZta.js";
13
+ import { l as isActive, n as distance, t as centroid } from "./geometry-ae8bOxQ5.js";
14
+ import { n as GestureRecognizer, t as PanGestureRecognizer } from "./PanGestureRecognizer-BFSO5U4N.js";
15
+ import { i as locksSelectionFor, n as lockSelection } from "./selectionLock-BM8XEZQD.js";
16
+ import { t as isRtlElement } from "./isRtlElement-NHuH48AA.js";
17
+ import { t as VelocityTracker } from "./VelocityTracker-D5wT6A0d.js";
18
+ import { t as resolveSnapPoint } from "./resolveSnapPoint-C7GZY6jT.js";
19
+ import { o as useComponentMessages } from "./context-B8IEFCDR.js";
20
+ import { t as useAttachment } from "./useAttachment-CGiD9rt6.js";
21
+ import { t as useFocusTrap } from "./useFocusTrap-Bj9GskLh.js";
22
+ import { t as _sfc_main$3 } from "./IconButton-kj1M_L7a.js";
23
+ import { a as rubberBandUnclamp, n as rubberBandClamp } from "./rubberBand-Ct9HFML5.js";
24
+ import { t as useScrollLock } from "./scrollLock-CoVg9lLU.js";
25
+ import { n as observeResize } from "./sharedResizeObserver-BekhnB3E.js";
26
+ import { n as restoreLayerFocus, r as trackLayerFocus, t as isLayerFocusStranded } from "./layerFocusReturn-uixUCSc8.js";
27
+ import { n as useTruncation } from "./useTruncation-D_T-ezdp.js";
28
+ import { t as TapGestureRecognizer } from "./TapGestureRecognizer-DCiP88h8.js";
29
+ import { t as useGestureRecognizer } from "./useGestureRecognizer-CtfxP4uw.js";
30
+ import { t as lightboxMessages } from "./lightbox-BbwxSHdB.js";
31
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, ref, renderList, toDisplayString, toRef, unref, useId, useTemplateRef, watch, withCtx } from "vue";
32
+ import "../styles/visually-hidden-utility.css";
33
+ import "../styles/lightbox.css";
34
+ //#region src/motion/uikit/zoomMedia.ts
35
+ /**
36
+ * @file zoomMedia.ts
37
+ * @input The motion registry (motion/roles.ts)
38
+ * @output Exports `zoomMedia`: UIScrollView zooming in a photo viewer. It
39
+ * holds the give past the zoom limits, and Photos' double tap, maximum
40
+ * zoom, page gap and drag to dismiss. `registerZoomMediaTable` makes the
41
+ * dismissal's two springs motion roles
42
+ * @position A domain of the UIKit constants table (motion/uikit). Lightbox's
43
+ * zoom stage reads it
44
+ */
45
+ /**
46
+ * UIScrollView zooming as a photo viewer uses it, with Photos' double tap
47
+ * and maximum zoom. Re-exported from motion/uikit, inside core.
48
+ *
49
+ * Measured on the iOS 26.2 simulator (iPhone 17 Pro, 402 × 874 pt at 3×).
50
+ * The lab was a UIKit host app with a full-screen UIScrollView zooming one
51
+ * image view (minimum zoom = fit, maximum 4, bouncesZoom on). Photos was
52
+ * measured on 3000 × 2000 and 2000 × 3000 photos. Real HID touches drove
53
+ * both, and every `CAAnimation`, zoomScale and contentOffset was logged.
54
+ *
55
+ * Findings with no number: inside the limits, the zoom equals the pinch's
56
+ * scale 1:1. The content point under the fingers' centroid stays under it
57
+ * (within 1 pt), past the limits too. A pinch released inside the limits
58
+ * keeps no scale momentum. A two-finger tap does nothing. The double tap
59
+ * fires on the second lift, with no wait.
60
+ *
61
+ * Every leaf carries one or more `@source`. WebKit and GUESS values also
62
+ * carry the `@measure` task that will confirm or replace them, and
63
+ * uikit.test.ts enforces both.
64
+ */
65
+ const zoomMedia = {
66
+ overshoot: {
67
+ /**
68
+ * Past a zoom limit the zoom gives way. Past the maximum M it reads
69
+ * M·(f − (f − 1)·M ÷ s). Past the minimum m it reads
70
+ * m ÷ (f − (f − 1)·s ÷ m), where s is the pinch's own scale. With f = 2,
71
+ * the zoom leaves the limit at the pinch's pace and approaches f times the
72
+ * limit (2M, m ÷ 2). Pinches of 4.5, 5, 5.5 and 6 past a maximum of 4 read
73
+ * 4.444, 4.8, 5.091 and 5.333. Pinches of 0.85, 0.7, 0.474 and 0.323 past
74
+ * a minimum of 1 read 0.870, 0.769, 0.655 and 0.596.
75
+ * @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
76
+ * iPhone 17 Pro, zoomScale against the pinch recognizer's scale per
77
+ * event, Oct 23 2026
78
+ */
79
+ limitFactor: 2 },
80
+ viewer: {
81
+ /**
82
+ * In Photos, a double tap at the fitted size zooms until the photo fills
83
+ * the stage (aspect fill). A 402 × 268 landscape photo on the 874 pt tall
84
+ * screen zooms 3.261×, and a 402 × 603 portrait 1.449×. Photos brings the
85
+ * tapped point to the centre, kept inside the stage. A double tap while
86
+ * zoomed returns to the fitted size. Both run UIKit's zoom settle.
87
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro,
88
+ * zoomScale and contentOffset per frame after double taps at the
89
+ * centre and near the edge of 3000 × 2000 and 2000 × 3000 photos,
90
+ * Oct 23 2026
91
+ */
92
+ doubleTapZoom: "aspectFill",
93
+ /**
94
+ * The maximum zoom is this many times the zoom at which one image pixel
95
+ * covers one device pixel. That gives 14.93 for a 3000 × 2000 photo fitted
96
+ * 402 pt wide at 3×, and 9.95 for 2000 × 3000.
97
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the
98
+ * zoomScale a pinch settles on past the maximum, 3000 × 2000 and
99
+ * 2000 × 3000 photos, Oct 23 2026
100
+ */
101
+ maxPixelZoomMultiple: 6,
102
+ /**
103
+ * Space between photos while they page, pt: the pager's stride is the
104
+ * screen's width plus this (442 on the 402 pt screen). It shows only
105
+ * while a page moves.
106
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the
107
+ * pager's contentOffset per page, Oct 23 2026
108
+ */
109
+ pageGap: 40
110
+ },
111
+ dismiss: {
112
+ /**
113
+ * While a photo at its fitted size is dragged down, its centre follows
114
+ * the finger. It shrinks about that centre by 1 − k·d², where d is the
115
+ * drag's downward travel in pt. It gives 0.997 / 0.978 / 0.942 / 0.899 at
116
+ * 25 / 65 / 105 / 145 pt, with k the least-squares fit, within 0.004.
117
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, a 3000 ×
118
+ * 2000 photo at its fitted size dragged down 25–145 pt, the zoom
119
+ * view's bounds per frame, Oct 24 2026
120
+ */
121
+ scalePerTravelSquared: 491e-8,
122
+ /**
123
+ * The viewer's backdrop fades by 1 − k·d²: 1.0 / 0.95 / 0.86 / 0.71 at
124
+ * 25 / 65 / 105 / 145 pt (k the least-squares fit, within 0.009).
125
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the same
126
+ * drags, the backdrop view's alpha per frame, Oct 24 2026
127
+ */
128
+ backdropAlphaPerTravelSquared: 135e-7,
129
+ /**
130
+ * The neighbouring photos and the controls fade faster, linearly once
131
+ * the drag passes `chromeFadeStart`: 1 − k·(d − start). It gives 0.96 /
132
+ * 0.76 / 0.52 / 0.33 at 25 / 65 / 105 / 145 pt, fitted within 0.016.
133
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the same
134
+ * drags, the neighbouring pages' and the chrome's alpha per frame,
135
+ * Oct 24 2026
136
+ */
137
+ chromeAlphaPerPoint: .00533,
138
+ /**
139
+ * Travel, pt, before the controls start to fade (see
140
+ * `chromeAlphaPerPoint`).
141
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the
142
+ * intercept of the same fit, Oct 24 2026
143
+ */
144
+ chromeFadeStart: 17.8,
145
+ /**
146
+ * The commit point. A release whose projected travel (`projectionRate`)
147
+ * stays within this distance of where the drag started cancels, as a
148
+ * release moving up does. Any other release dismisses, however short the
149
+ * pull. Pulls of 20, 40 and 60 pt held still, then lifted, dismiss. A pull
150
+ * brought back to about 5 pt cancels.
151
+ * @source GUESS — between the measured 5 pt (cancels) and 20 pt
152
+ * (dismisses); Photos, iOS 26.2 simulator, Oct 24 2026
153
+ * @measure M-ZM3
154
+ */
155
+ cancelTravel: 10,
156
+ /**
157
+ * The deceleration rate that projects a release's travel. The drag
158
+ * dismisses when its travel plus where its velocity would coast passes
159
+ * `cancelTravel`, so a short flick down closes.
160
+ * @source GUESS — UIScrollView's normal deceleration rate, the WWDC18
161
+ * projection's default; Photos' own projection is not measured
162
+ * @measure M-ZM5
163
+ */
164
+ projectionRate: .998,
165
+ /**
166
+ * The dismissal's position spring (critically damped, response about
167
+ * 0.21 s): the photo leaves along it.
168
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, a
169
+ * committed drag-to-dismiss, the zoom view's position animation
170
+ * (`CASpringAnimation` mass 1, stiffness 918.09, damping 60.60),
171
+ * Oct 24 2026
172
+ */
173
+ dismissPositionSpring: {
174
+ mass: 1,
175
+ stiffness: 918.09,
176
+ damping: 60.6
177
+ },
178
+ /**
179
+ * The dismissal's spring for size and opacity (critically damped).
180
+ * @source measured: Photos, iOS 26.2 simulator, iPhone 17 Pro, the same
181
+ * dismissal, the bounds and opacity animations (stiffness 947.14,
182
+ * damping 61.55), Oct 24 2026
183
+ */
184
+ dismissSizeSpring: {
185
+ mass: 1,
186
+ stiffness: 947.14,
187
+ damping: 61.55
188
+ }
189
+ }
190
+ };
191
+ /**
192
+ * Registers this table with the motion registry (motion/roles.ts). The
193
+ * dismissal's two springs are roles, so the exit plays at the tempo of the
194
+ * viewer's theme, as every other viewer motion does. At tempo 1 they play
195
+ * exactly their measured values. The table's other values play as measured.
196
+ * The module registers its own table at import (one idempotent in-memory
197
+ * write, no DOM).
198
+ */
199
+ function registerZoomMediaTable() {
200
+ registerMotionTable("zoomMedia", zoomMedia, { roles: ["dismiss.dismissPositionSpring", "dismiss.dismissSizeSpring"] });
201
+ }
202
+ registerZoomMediaTable();
203
+ //#endregion
204
+ //#region src/Lightbox/LightboxCaption.vue
205
+ const _hoisted_1$1 = ["data-empty", "data-expanded"];
206
+ const _hoisted_2$1 = {
207
+ key: 0,
208
+ class: "astryx-lightbox__caption-panel",
209
+ "data-lightbox-caption": ""
210
+ };
211
+ const _hoisted_3$1 = ["id"];
212
+ const _hoisted_4$1 = ["aria-expanded", "aria-controls"];
213
+ const MAX_LINES = 2;
214
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
215
+ name: "AstryxLightboxCaption",
216
+ __name: "LightboxCaption",
217
+ props: {
218
+ text: {},
219
+ id: {}
220
+ },
221
+ setup(__props) {
222
+ const messages = useComponentMessages({ lightbox: lightboxMessages });
223
+ /**
224
+ * 图注最多显示两行。超出时第二行末尾跟一个「更多」,点开后整段图注盖在照片底部,
225
+ * 「收起」再合上。整段文字一直在 DOM 里,所以无障碍描述总是完整的图注。
226
+ */
227
+ const truncation = useTruncation(ref(MAX_LINES));
228
+ const isExpanded = ref(false);
229
+ /** 展开时文字不再被截断,量出来是 false;这时仍要留着「收起」。 */
230
+ const hasToggle = computed(() => isExpanded.value || truncation.isTruncated.value);
231
+ function bindText(element) {
232
+ truncation.bind(element instanceof Element ? element : null);
233
+ }
234
+ function toggle() {
235
+ isExpanded.value = !isExpanded.value;
236
+ }
237
+ return (_ctx, _cache) => {
238
+ return openBlock(), createElementBlock("div", {
239
+ class: "astryx-lightbox__caption-band",
240
+ "data-empty": __props.text ? void 0 : "",
241
+ "data-expanded": isExpanded.value || void 0
242
+ }, [__props.text ? (openBlock(), createElementBlock("div", _hoisted_2$1, [createElementVNode("p", {
243
+ id: __props.id,
244
+ ref: bindText,
245
+ class: "astryx-lightbox__caption astryx-lightbox__caption--band"
246
+ }, toDisplayString(__props.text), 9, _hoisted_3$1), hasToggle.value ? (openBlock(), createElementBlock("button", {
247
+ key: 0,
248
+ type: "button",
249
+ class: "astryx-lightbox__caption-toggle",
250
+ "aria-expanded": isExpanded.value,
251
+ "aria-controls": __props.id,
252
+ onClick: toggle
253
+ }, toDisplayString(isExpanded.value ? unref(messages).lightbox.captionLess : unref(messages).lightbox.captionMore), 9, _hoisted_4$1)) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true)], 8, _hoisted_1$1);
254
+ };
255
+ }
256
+ });
257
+ //#endregion
258
+ //#region src/Lightbox/lightboxPointer.ts
259
+ /**
260
+ * @file lightboxPointer.ts
261
+ * @input 鼠标、触控笔在灯箱舞台上的事件,当前页
262
+ * @output isClickOutsideMedia:一次点击算不算点在媒体外面;markPointerOverPhoto:放大镜光标只在照片上方显示
263
+ * @position Lightbox.vue 的指针辅助。舞台铺满灯箱,所以按照片的盒子判断,不按事件目标判断。
264
+ */
265
+ /** 鼠标或触控笔悬停在适应大小的照片上方时,舞台带这个属性,光标显示放大镜。 */
266
+ const OVER_PHOTO_ATTRIBUTE = "data-lightbox-over-photo";
267
+ function within$1(rect, { x, y }) {
268
+ return rect != null && x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
269
+ }
270
+ /**
271
+ * 鼠标或触控笔在媒体上的一次点击,按下或松开落在当前页媒体以外时关闭灯箱。
272
+ * 媒体是适应大小的照片排好的盒子、图注区域和图注自己的盒子;放大时照片显示出来的盒子也算。
273
+ * 键盘触发的点击(detail 为 0)不算。
274
+ */
275
+ function isClickOutsideMedia(event, { viewport, page, pressPoint }) {
276
+ const media = page?.querySelector("img") ?? page?.querySelector("video");
277
+ const box = media?.parentElement;
278
+ const group = viewport?.parentElement;
279
+ if (event.detail === 0 || media == null || box == null || page == null || group == null || !(event.target instanceof Node) || !group.contains(event.target)) return false;
280
+ const space = (box.clientHeight - media.offsetHeight) / 2;
281
+ const boxRect = box.getBoundingClientRect();
282
+ const top = boxRect.top + space;
283
+ const bottom = top + media.offsetHeight;
284
+ const width = media.offsetWidth;
285
+ const middle = boxRect.left + box.clientWidth / 2;
286
+ const shown = media.getBoundingClientRect();
287
+ const caption = page.querySelector("[data-lightbox-caption]");
288
+ const captionBox = caption?.getBoundingClientRect();
289
+ const bandBox = caption?.parentElement?.getBoundingClientRect();
290
+ const isOutside = (point) => {
291
+ if (within$1(shown, point)) return false;
292
+ const isOnPhotoRows = point.y >= top && point.y <= bottom && Math.abs(point.x - middle) <= width / 2;
293
+ if (captionBox == null) return !isOnPhotoRows;
294
+ return !isOnPhotoRows && !within$1(captionBox, point) && !within$1(bandBox, point);
295
+ };
296
+ return isOutside({
297
+ x: event.clientX,
298
+ y: event.clientY
299
+ }) || pressPoint != null && isOutside(pressPoint);
300
+ }
301
+ /** 鼠标或触控笔是否悬停在照片上方,写在舞台上,悬停不触发渲染。 */
302
+ function markPointerOverPhoto(event) {
303
+ const stage = event.currentTarget;
304
+ if (!(stage instanceof HTMLElement) || event.pointerType === "touch" || event.buttons !== 0) return;
305
+ const photo = stage.querySelector("[data-current] img") ?? stage.querySelector("img");
306
+ stage.toggleAttribute(OVER_PHOTO_ATTRIBUTE, within$1(photo?.getBoundingClientRect(), {
307
+ x: event.clientX,
308
+ y: event.clientY
309
+ }));
310
+ }
311
+ //#endregion
312
+ //#region src/Lightbox/lightboxViewer.ts
313
+ /** 序号取整:小数四舍五入到最近的一项,NaN 当作第一项。越界由调用方再夹紧。 */
314
+ function toWholeIndex(value) {
315
+ return Number.isNaN(value) ? 0 : Math.round(value);
316
+ }
317
+ /**
318
+ * 往灯箱自己的播报区域写一句话。模态 dialog 打开时外面的页面是 inert 的,
319
+ * 挂在 body 上的公共播报区域读屏听不到,所以灯箱在 dialog 里放一个自己的。
320
+ * 先清空再在下一帧写入,同一句话连着播两次也会被当成新内容。
321
+ */
322
+ function createModalAnnouncer(getRegion) {
323
+ let frame;
324
+ return (message) => {
325
+ const region = getRegion();
326
+ if (region == null) return;
327
+ region.textContent = "";
328
+ if (frame !== void 0 && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
329
+ if (typeof requestAnimationFrame !== "function") {
330
+ region.textContent = message;
331
+ return;
332
+ }
333
+ frame = requestAnimationFrame(() => {
334
+ frame = void 0;
335
+ region.textContent = message;
336
+ });
337
+ };
338
+ }
339
+ //#endregion
340
+ //#region src/Lightbox/zoomDismiss.ts
341
+ /**
342
+ * 下拉中的照片(从适应大小开始)。它的中心跟着指针 (dx, dy) 走,
343
+ * 并以中心为原点缩小 `scalePerTravelSquared` × 向下位移²。往上拖不缩小。
344
+ */
345
+ function dismissTransform(geometry, dx, dy) {
346
+ const travel = Math.max(0, dy);
347
+ const scale = Math.max(0, 1 - zoomMedia.dismiss.scalePerTravelSquared * travel * travel);
348
+ return {
349
+ x: dx + (1 - scale) * geometry.fit.width / 2,
350
+ y: dy + (1 - scale) * geometry.fit.height / 2,
351
+ scale
352
+ };
353
+ }
354
+ /** 向下位移(pt)时背景的不透明度。 */
355
+ function dismissBackdropAlpha(travel) {
356
+ const t = Math.max(0, travel);
357
+ return Math.min(1, Math.max(0, 1 - zoomMedia.dismiss.backdropAlphaPerTravelSquared * t * t));
358
+ }
359
+ /** 向下位移(pt)时控件和相邻照片的不透明度,比背景淡得快。 */
360
+ function dismissChromeAlpha(travel) {
361
+ const { chromeAlphaPerPoint, chromeFadeStart } = zoomMedia.dismiss;
362
+ return Math.min(1, Math.max(0, 1 - chromeAlphaPerPoint * (travel - chromeFadeStart)));
363
+ }
364
+ /**
365
+ * 松手时关不关,抬手那一刻按通用的松手规则(`resolveSnapPoint`)定一次。两个落点是
366
+ * 「回到适应位置」和「越过提交点后离开」,中点是 `cancelTravel`。判断用的是位移加上按速度
367
+ * 还能滑出去的距离(`projectionRate`),往回(向上)走的松手一律弹回。
368
+ * 所以往下轻轻一甩就关;拉一小段停住再抬手会弹回。
369
+ */
370
+ function dismissCommits(travel, velocityY) {
371
+ const { cancelTravel, projectionRate } = zoomMedia.dismiss;
372
+ return resolveSnapPoint({
373
+ points: [0, 2 * cancelTravel],
374
+ position: travel,
375
+ velocity: velocityY,
376
+ flickThreshold: Number.POSITIVE_INFINITY,
377
+ projection: { seconds: projectionRate / (1 - projectionRate) / 1e3 },
378
+ start: 0
379
+ }).index === 1;
380
+ }
381
+ /**
382
+ * 没有缩略图可回去时,关闭的照片一直往下走,直到顶边越过 `bottom`(舞台坐标)。
383
+ * 那是屏幕底边;只包住照片的舞台会在屏幕底边上方很远。默认是舞台自己的底边。
384
+ */
385
+ function dismissExitY(geometry, shown, bottom = geometry.height) {
386
+ return Math.max(shown.y, Math.max(bottom, geometry.height) - geometry.fit.y) + 1;
387
+ }
388
+ //#endregion
389
+ //#region src/Lightbox/lightboxDismissFades.ts
390
+ /** 控件层、相邻页、图注都跟着变淡;在相邻页里面的、在图注区域里面的跟着外层一起淡。 */
391
+ const CHROME_SELECTOR = "[data-lightbox-chrome], [data-lightbox-page]:not([data-current]), [data-lightbox-caption]";
392
+ function createDismissFades(targets) {
393
+ let faded = [];
394
+ let backdropMoves = 0;
395
+ const setBackdropMoving = (moving) => {
396
+ const dialog = targets.dialog();
397
+ if (moving) dialog?.style.setProperty("--_lightbox-backdrop-filter", "none");
398
+ else dialog?.style.removeProperty("--_lightbox-backdrop-filter");
399
+ };
400
+ const collect = () => {
401
+ const dialog = targets.dialog();
402
+ const container = targets.container();
403
+ if (dialog == null || container == null) return {
404
+ backdrop: null,
405
+ chrome: []
406
+ };
407
+ const band = targets.captionBand();
408
+ const elements = band == null ? [] : [band];
409
+ for (const element of container.querySelectorAll(CHROME_SELECTOR)) if (!(element.parentElement?.closest("[data-lightbox-page]:not([data-current])") != null) && band?.contains(element) !== true) elements.push(element);
410
+ const backdrop = animatorFor(dialog, { pseudoElement: "::backdrop" });
411
+ const chrome = elements.map((element) => animatorFor(element));
412
+ faded = [backdrop, ...chrome];
413
+ return {
414
+ backdrop,
415
+ chrome
416
+ };
417
+ };
418
+ return {
419
+ onDrag: (travel) => {
420
+ const { backdrop, chrome } = collect();
421
+ backdropMoves += 1;
422
+ setBackdropMoving(true);
423
+ backdrop?.set({ opacity: dismissBackdropAlpha(travel) });
424
+ const opacity = dismissChromeAlpha(travel);
425
+ for (const animator of chrome) animator.set({ opacity });
426
+ },
427
+ onRelease: (dismisses, touch) => {
428
+ const { backdrop, chrome } = collect();
429
+ const spring = dismisses ? zoomMedia.dismiss.dismissSizeSpring : resolveMotion(targets.stage(), springs.settle);
430
+ const opacity = dismisses ? 0 : 1;
431
+ const move = backdropMoves += 1;
432
+ setBackdropMoving(true);
433
+ const backdropMotion = backdrop?.animate({ opacity }, { spring }, { touchRelease: touch });
434
+ for (const animator of chrome) animator.animate({ opacity }, { spring }, { touchRelease: touch });
435
+ backdropMotion?.finished.then(() => {
436
+ if (!dismisses && backdropMoves === move) setBackdropMoving(false);
437
+ });
438
+ },
439
+ restore: () => {
440
+ backdropMoves += 1;
441
+ setBackdropMoving(false);
442
+ const previous = faded;
443
+ faded = [];
444
+ for (const animator of previous) animator.set({ opacity: 1 });
445
+ }
446
+ };
447
+ }
448
+ //#endregion
449
+ //#region src/motion/paging.ts
450
+ /**
451
+ * The velocity a paging settle starts at. It is the release velocity that every
452
+ * gesture reads, zeroed below `velocityFloor`. The page choice reads the
453
+ * release velocity itself.
454
+ */
455
+ function pagingSettleVelocity(velocity) {
456
+ return Math.abs(velocity) < paging.release.velocityFloor ? 0 : velocity;
457
+ }
458
+ /**
459
+ * UIKit's paging settle from `from` (px), moving at `velocity` (px/s), onto
460
+ * `to`. It steps `paging.integrator` `stepsPerSecond` times a second and ends
461
+ * exactly on `to`. The same motion returns an overscrolled pager to its first
462
+ * or last page.
463
+ *
464
+ * Positions are content offsets along the paging axis, 0 at page 0 and growing
465
+ * toward later pages. Velocities are px/s of that offset.
466
+ *
467
+ * No closed form reproduces the per-frame stepping, so the settle integrates
468
+ * once into a table, and the curve reads the table. A release needs at most
469
+ * about 400 steps, well under a millisecond of work.
470
+ *
471
+ * The release velocity enters in px per millisecond per step, as UIKit hands it
472
+ * to the integrator. At 960 steps a second, the content starts at 96 % of the
473
+ * finger's speed, as in UIKit.
474
+ *
475
+ * At a theme's `tempo`, each step lasts tempo times as long and carries tempo
476
+ * times the release's distance. So a settle from rest keeps its shape and
477
+ * takes tempo times as long, and a release still starts at 96 % of the
478
+ * finger's speed. At tempo 1 the settle is the measured one.
479
+ */
480
+ function solvePaging({ from, velocity, to, tempo = 1 }) {
481
+ const { springPull, friction, restDistance, restSpeed } = paging.integrator;
482
+ const pace = Number.isFinite(tempo) && tempo > 0 ? tempo : 1;
483
+ const stepsPerSecond = paging.integrator.stepsPerSecond / pace;
484
+ const startVelocity = velocity / 1e3 * pace;
485
+ const xs = [from];
486
+ const vs = [startVelocity];
487
+ let x = from;
488
+ let v = startVelocity;
489
+ const maxSteps = paging.integrator.stepsPerSecond * 10;
490
+ let steps = 0;
491
+ while (steps < maxSteps) {
492
+ if (Math.abs(to - x) < restDistance && Math.abs(v) < restSpeed) break;
493
+ v = (v + (to - x) * springPull) * friction;
494
+ x += v;
495
+ steps += 1;
496
+ xs.push(x);
497
+ vs.push(v);
498
+ }
499
+ xs[xs.length - 1] = to;
500
+ vs[vs.length - 1] = 0;
501
+ const duration = steps / stepsPerSecond;
502
+ const last = xs.length - 1;
503
+ const read = (table, t) => {
504
+ if (!(t > 0)) return table[0];
505
+ const s = t * stepsPerSecond;
506
+ if (s >= last) return table[last];
507
+ const i = Math.floor(s);
508
+ const f = s - i;
509
+ return table[i] + (table[i + 1] - table[i]) * f;
510
+ };
511
+ return {
512
+ from,
513
+ to,
514
+ steps,
515
+ duration,
516
+ at: (t) => read(xs, t),
517
+ velocity: (t) => read(vs, t) * stepsPerSecond
518
+ };
519
+ }
520
+ /**
521
+ * `setContentOffset(_:animated:)`: `paging.animatedScroll.durationMs` on its
522
+ * curve, from the current offset, at any distance. The pager passes the
523
+ * duration and curve that `resolveMotion` gives, which are the measured values
524
+ * of the table.
525
+ *
526
+ * `velocity` (px/s) is the velocity of a move that this one retargets. The new
527
+ * curve starts at it and still ends on `to`, at rest and on time. A new target
528
+ * keeps the current velocity, where UIKit drops it. The carry is a Hermite
529
+ * term, v × duration × u(1 − u)², less the curve's own starting slope. So a
530
+ * move from rest is the curve itself.
531
+ */
532
+ function solveAnimatedPageScroll({ from, to, durationMs = paging.animatedScroll.durationMs, curve = paging.animatedScroll.curve, velocity }) {
533
+ const duration = durationMs / 1e3;
534
+ const distance = to - from;
535
+ const ease = cubicBezier(curve);
536
+ const progress = (u) => ease(Math.min(1, Math.max(0, u)));
537
+ const startSlope = progress(1e-4) / 1e-4;
538
+ const carry = velocity == null ? 0 : velocity * duration - distance * startSlope;
539
+ const at = (t) => {
540
+ const u = Math.min(1, Math.max(0, t / duration));
541
+ return from + distance * progress(u) + carry * u * (1 - u) * (1 - u);
542
+ };
543
+ return {
544
+ duration,
545
+ at,
546
+ velocity: (t) => {
547
+ if (t <= 0) return velocity ?? 0;
548
+ if (t >= duration) return 0;
549
+ const h = Math.min(1e-4, t / 2, (duration - t) / 2);
550
+ return (at(t + h) - at(t - h)) / (2 * h);
551
+ }
552
+ };
553
+ }
554
+ //#endregion
555
+ //#region src/Lightbox/pagerRelease.ts
556
+ /**
557
+ * @file pagerRelease.ts
558
+ * @input 松手时内容的位置和速度、页距、页数、起拖那一页
559
+ * @output pageForRelease(UIKit 分页滚动视图实测的选页规则)、dragTrackPosition(拖动中轨道显示在哪)
560
+ * @position 纯函数,不碰 DOM;灯箱的翻页器(lightboxPager.ts)用它。常量在 motion/uikit/paging.ts。
561
+ */
562
+ /**
563
+ * 松手停在哪一页,照 UIKit 实测的分页规则(uikit/paging.ts 的 `release`),走通用的松手策略:
564
+ * - 速度到 `advanceSpeed` 就算轻扫,不论内容在哪,都朝速度方向翻到下一页;
565
+ * - 慢一点的松手停在离内容最近的一页(过半页就是下一页);
566
+ * - 速度指回起拖那一页时,不论拖了多远都回到那一页;
567
+ * - 离起拖那一页最多 `maxPagesFromStart` 页,并收在页数之内。
568
+ */
569
+ function pageForRelease({ position, velocity, stride, count, startIndex }) {
570
+ if (!(stride > 0) || count < 1) return 0;
571
+ const reach = paging.release.maxPagesFromStart;
572
+ const from = Math.min(Math.max(startIndex, 0), count - 1);
573
+ const first = Math.max(0, from - reach);
574
+ const last = Math.min(count - 1, from + reach);
575
+ const points = Array.from({ length: last - first + 1 }, (_, i) => (first + i) * stride);
576
+ const { index } = resolveSnapPoint({
577
+ points,
578
+ position,
579
+ velocity,
580
+ flickThreshold: paging.release.advanceSpeed,
581
+ tolerance: 1e-6 * stride,
582
+ start: from * stride,
583
+ fromIndex: from - first,
584
+ maxSteps: reach
585
+ });
586
+ return first + index;
587
+ }
588
+ /**
589
+ * 拖动中内容显示在哪:1:1 跟手,越过第一页或最后一页时按 UIKit 的橡皮筋让步(d = 页宽)。
590
+ * 触控板横扫(给了 `startIndex`)最多离起拖页一页,这个窗口也包含起拖的位置。
591
+ */
592
+ function dragTrackPosition({ start, delta, stride, count, pageWidth, startIndex }) {
593
+ let raw = start + delta;
594
+ if (startIndex != null && stride > 0) {
595
+ const before = startIndex > 0 ? (startIndex - 1) * stride : Number.NEGATIVE_INFINITY;
596
+ const after = startIndex < count - 1 ? (startIndex + 1) * stride : Number.POSITIVE_INFINITY;
597
+ raw = Math.min(Math.max(raw, Math.min(before, after, start)), Math.max(before, after, start));
598
+ }
599
+ return rubberBandClamp(raw, 0, Math.max(0, count - 1) * stride, pageWidth > 0 ? pageWidth : 1);
600
+ }
601
+ //#endregion
602
+ //#region src/Lightbox/lightboxPager.ts
603
+ /** 只认手指、触控笔、鼠标拖动和触控板横扫的分页拖动,记下这一下是哪种指针。 */
604
+ var PagerPan = class extends PanGestureRecognizer {
605
+ pointerType = null;
606
+ touchesBegan(touches, event) {
607
+ if (this.state === "possible" && touches.length > 0) this.pointerType = touches[0].pointerType;
608
+ super.touchesBegan(touches, event);
609
+ }
610
+ classify(translation) {
611
+ const decided = super.classify(translation);
612
+ if (decided !== "wait") return decided;
613
+ const along = Math.abs(translation.x);
614
+ const across = Math.abs(translation.y);
615
+ if (along === 0 && across === 0) return "wait";
616
+ return along >= paging.nestedPanAxisRatio * across ? "begin" : "fail";
617
+ }
618
+ };
619
+ /** 触控板横扫走过不到这么多页,不论多快都按静止松手。 */
620
+ const STILL_RELEASE_FRACTION = .1;
621
+ function isScrollContact(recognizer) {
622
+ return recognizer.trackedTouches[0]?.scrollType != null;
623
+ }
624
+ function useLightboxPager(options) {
625
+ registerPagingTable();
626
+ const animator = createMotionEngine(null);
627
+ let pageWidth = 0;
628
+ let isRtl = false;
629
+ let target = options.index();
630
+ let dragging = false;
631
+ let dragStart = 0;
632
+ let dragPosition = 0;
633
+ let dragStartIndex = 0;
634
+ let settleHandle = null;
635
+ let settleToken = 0;
636
+ let isReleaseSettle = false;
637
+ let isSwipeSettle = false;
638
+ let pendingReport = false;
639
+ let reportToken = 0;
640
+ let isCatchArmed = false;
641
+ let caughtSettle = false;
642
+ let suppressCancelSettle = false;
643
+ let releaseSelection = null;
644
+ const count = () => Math.max(1, options.count());
645
+ const stride = () => pageWidth + options.gap;
646
+ const sign = () => isRtl ? 1 : -1;
647
+ const clampIndex = (index) => Math.min(Math.max(0, index), count() - 1);
648
+ const offsetOf = (index) => index * stride();
649
+ const positionToX = (position) => sign() * position + 0;
650
+ const presentation = () => sign() * animator.get("x") + 0;
651
+ const nearestPage = (position) => stride() > 0 ? clampIndex(Math.round(position / stride())) : clampIndex(target);
652
+ const view = () => options.viewport()?.ownerDocument.defaultView ?? null;
653
+ const flushReport = () => {
654
+ if (!pendingReport) return;
655
+ pendingReport = false;
656
+ options.onIndexChange(target);
657
+ nextTick(() => {
658
+ const kept = options.index();
659
+ if (kept !== target) goTo(kept, true);
660
+ });
661
+ };
662
+ const afterFrames = (frames, callback) => {
663
+ const frame = view()?.requestAnimationFrame?.bind(view());
664
+ if (frame == null) {
665
+ callback();
666
+ return;
667
+ }
668
+ const step = (left) => {
669
+ if (left <= 0) callback();
670
+ else frame(() => step(left - 1));
671
+ };
672
+ step(frames);
673
+ };
674
+ const rest = () => {
675
+ flushReport();
676
+ isSwipeSettle = false;
677
+ options.onSettle?.(target);
678
+ };
679
+ const stopSettle = () => {
680
+ settleToken += 1;
681
+ if (settleHandle != null) {
682
+ settleHandle = null;
683
+ animator.stop(["x"]);
684
+ }
685
+ };
686
+ const play = (curve, touchRelease, isRelease) => {
687
+ isSwipeSettle = false;
688
+ isReleaseSettle = isRelease;
689
+ const s = sign();
690
+ const x = {
691
+ duration: curve.duration,
692
+ at: (t) => s * curve.at(t) + 0,
693
+ velocity: (t) => s * curve.velocity(t) + 0
694
+ };
695
+ const handle = animator.play({ x }, { touchRelease });
696
+ const token = ++settleToken;
697
+ settleHandle = handle;
698
+ if (pendingReport) {
699
+ const reportAt = reportToken;
700
+ handle.started.then(() => afterFrames(2, () => {
701
+ if (reportAt === reportToken) flushReport();
702
+ }));
703
+ }
704
+ handle.finished.then((finished) => {
705
+ if (token !== settleToken) return;
706
+ settleHandle = null;
707
+ if (finished) {
708
+ animator.set({ x: x.at(x.duration) });
709
+ rest();
710
+ }
711
+ });
712
+ };
713
+ /** 抬手(松开拖动,或停住后放开)后的落位。 */
714
+ const settleFrom = (position, velocity, touchRelease) => {
715
+ const to = offsetOf(target);
716
+ const curve = solvePaging({
717
+ from: position,
718
+ velocity,
719
+ to,
720
+ tempo: themeTempo(options.track())
721
+ });
722
+ if (curve.steps === 0) {
723
+ animator.set({ x: positionToX(to) });
724
+ rest();
725
+ return;
726
+ }
727
+ play(curve, touchRelease, true);
728
+ };
729
+ const releaseTo = (next, position, velocity, touchRelease) => {
730
+ target = next;
731
+ pendingReport = next !== options.index();
732
+ reportToken += 1;
733
+ settleFrom(position, pagingSettleVelocity(velocity), touchRelease);
734
+ };
735
+ const measure = () => {
736
+ const viewport = options.viewport();
737
+ if (viewport == null) return;
738
+ const width = viewport.clientWidth;
739
+ const rtl = isRtlElement(viewport);
740
+ if (width === pageWidth && rtl === isRtl) return;
741
+ pageWidth = width;
742
+ isRtl = rtl;
743
+ if (dragging) return;
744
+ const wasSettling = settleHandle != null;
745
+ stopSettle();
746
+ animator.set({ x: positionToX(offsetOf(target)) });
747
+ if (wasSettling) rest();
748
+ };
749
+ const pan = new PagerPan({
750
+ name: "Lightbox.pager",
751
+ direction: "horizontal",
752
+ axisRatio: paging.panAxisRatio,
753
+ maximumNumberOfTouches: 1,
754
+ allowedPointerTypes: [
755
+ "touch",
756
+ "pen",
757
+ "mouse"
758
+ ],
759
+ allowedScrollTypes: ["continuous"],
760
+ shouldBegin: (recognizer) => {
761
+ if (options.panShouldBegin?.(recognizer) === false) return false;
762
+ const direction = recognizer.totalTranslation().x < 0 ? "left" : "right";
763
+ return options.shouldBeginPan?.(direction) ?? true;
764
+ }
765
+ });
766
+ const catcher = new SettleCatcher({
767
+ minimumPressDuration: 0,
768
+ allowableMovement: Number.POSITIVE_INFINITY,
769
+ selectionLock: null,
770
+ shouldBegin: () => settleHandle != null && !dragging && options.isPanEnabled()
771
+ });
772
+ catcher.recognizeSimultaneouslyWith(pan);
773
+ useGestureRecognizer(options.viewport, () => pan, (recognizer) => {
774
+ const state = recognizer.state;
775
+ if (state === "began") {
776
+ const wasSwipeSettle = settleHandle != null && isSwipeSettle;
777
+ measure();
778
+ isCatchArmed = false;
779
+ catcher.disarmCatch();
780
+ const current = presentation();
781
+ stopSettle();
782
+ dragging = true;
783
+ dragStart = rubberBandUnclamp(current, 0, offsetOf(count() - 1), pageWidth > 0 ? pageWidth : 1);
784
+ dragPosition = current;
785
+ dragStartIndex = wasSwipeSettle && isScrollContact(recognizer) ? target : nearestPage(current);
786
+ return;
787
+ }
788
+ if (state === "changed") {
789
+ dragPosition = dragTrackPosition({
790
+ start: dragStart,
791
+ delta: sign() * recognizer.translation().x,
792
+ stride: stride(),
793
+ count: count(),
794
+ pageWidth,
795
+ startIndex: isScrollContact(recognizer) ? dragStartIndex : void 0
796
+ });
797
+ animator.set({ x: positionToX(dragPosition) });
798
+ return;
799
+ }
800
+ if (state !== "ended" && state !== "cancelled") return;
801
+ dragging = false;
802
+ if (state === "cancelled" && suppressCancelSettle) {
803
+ suppressCancelSettle = false;
804
+ return;
805
+ }
806
+ let velocity = state === "ended" ? sign() * recognizer.scrollVelocity().x : 0;
807
+ if (isScrollContact(recognizer) && stride() > 0 && Math.abs(dragPosition - dragStart) / stride() < STILL_RELEASE_FRACTION) velocity = 0;
808
+ const next = pageForRelease({
809
+ position: dragPosition,
810
+ velocity,
811
+ stride: stride(),
812
+ count: count(),
813
+ startIndex: dragStartIndex
814
+ });
815
+ releaseTo(next, dragPosition, velocity, pan.pointerType === "touch");
816
+ isSwipeSettle = settleHandle != null && isScrollContact(recognizer);
817
+ }, { isEnabled: options.isPanEnabled });
818
+ const holdSelection = (on) => {
819
+ const track = options.track();
820
+ if (on && releaseSelection == null && track != null && locksSelectionFor(catcher.pointerType ?? "touch")) releaseSelection = lockSelection([track], null);
821
+ else if (!on && releaseSelection != null) {
822
+ releaseSelection();
823
+ releaseSelection = null;
824
+ }
825
+ };
826
+ const catchSettle = () => {
827
+ if (settleHandle != null && !dragging) {
828
+ stopSettle();
829
+ caughtSettle = true;
830
+ }
831
+ };
832
+ useGestureRecognizer(options.track, () => catcher, (recognizer) => {
833
+ if (recognizer.state === "began") {
834
+ holdSelection(true);
835
+ const isMouse = catcher.pointerType === "mouse";
836
+ if (isReleaseSettle && !isMouse) catcher.takeFromContent();
837
+ caughtSettle = false;
838
+ if (!isReleaseSettle && !isMouse) {
839
+ catchSettle();
840
+ return;
841
+ }
842
+ isCatchArmed = true;
843
+ catcher.armCatch(paging.catchStopMs, () => {
844
+ if (!isCatchArmed) return;
845
+ isCatchArmed = false;
846
+ catchSettle();
847
+ });
848
+ return;
849
+ }
850
+ if (recognizer.state !== "ended" && recognizer.state !== "cancelled") return;
851
+ holdSelection(false);
852
+ if (isCatchArmed) {
853
+ isCatchArmed = false;
854
+ catcher.disarmCatch();
855
+ return;
856
+ }
857
+ const wasCaught = caughtSettle;
858
+ caughtSettle = false;
859
+ if (wasCaught && !dragging && settleHandle == null) {
860
+ const position = presentation();
861
+ const next = pageForRelease({
862
+ position,
863
+ velocity: 0,
864
+ stride: stride(),
865
+ count: count(),
866
+ startIndex: nearestPage(position)
867
+ });
868
+ releaseTo(next, position, 0, catcher.pointerType === "touch");
869
+ }
870
+ }, { manageStyle: false });
871
+ function goTo(index, animated) {
872
+ const next = clampIndex(Math.round(index));
873
+ if (dragging) {
874
+ suppressCancelSettle = true;
875
+ dragging = false;
876
+ pan.cancel();
877
+ }
878
+ const from = presentation();
879
+ const velocity = settleHandle != null ? sign() * animator.getVelocity("x") : void 0;
880
+ pendingReport = false;
881
+ reportToken += 1;
882
+ stopSettle();
883
+ target = next;
884
+ const to = offsetOf(next);
885
+ if (!animated || from === to || pageWidth === 0) {
886
+ animator.set({ x: positionToX(to) });
887
+ rest();
888
+ return;
889
+ }
890
+ const track = options.track();
891
+ play(solveAnimatedPageScroll({
892
+ from,
893
+ to,
894
+ durationMs: resolveMotion(track, paging.animatedScroll, "durationMs"),
895
+ curve: resolveMotion(track, paging.animatedScroll.curve),
896
+ velocity
897
+ }), false, false);
898
+ }
899
+ useAttachment(options.track, (track) => {
900
+ animator.attach(track);
901
+ pageWidth = 0;
902
+ measure();
903
+ animator.set({ x: positionToX(offsetOf(target)) });
904
+ const viewport = options.viewport();
905
+ const stopObserving = viewport != null ? observeResize(viewport, measure) : () => {};
906
+ return () => {
907
+ stopObserving();
908
+ stopSettle();
909
+ holdSelection(false);
910
+ animator.attach(null);
911
+ };
912
+ }, options.viewport);
913
+ watch(options.index, (index) => {
914
+ if (index !== target) goTo(index, options.isControlledChangeAnimated());
915
+ });
916
+ return {
917
+ pan,
918
+ isSettling: () => settleHandle != null,
919
+ presentation,
920
+ goTo
921
+ };
922
+ }
923
+ //#endregion
924
+ //#region src/gestures/PinchGestureRecognizer.ts
925
+ var PinchGestureRecognizer = class extends GestureRecognizer {
926
+ get kind() {
927
+ return "pinch";
928
+ }
929
+ hysteresis;
930
+ initialSpan = 0;
931
+ scaleValue = 1;
932
+ tracker = new VelocityTracker();
933
+ /** The lift's event time, for the stillness reset. */
934
+ liftTime;
935
+ constructor(options = {}) {
936
+ super(options);
937
+ this.hysteresis = options.hysteresis ?? UIKIT_PINCH.hysteresis.value;
938
+ }
939
+ /** Internal. The host's brand: a ctrl-wheel drives a pinch (recognizerInternals). */
940
+ get family() {
941
+ return "pinch";
942
+ }
943
+ /** A ctrl-wheel drives a pinch, from a trackpad or a mouse. */
944
+ get defaultScrollTypes() {
945
+ return ["continuous", "discrete"];
946
+ }
947
+ /** Current span over the span the fingers started at. */
948
+ get scale() {
949
+ return this.scaleValue;
950
+ }
951
+ /** Re-base: from now on the scale reads `value` at the current span. */
952
+ set scale(value) {
953
+ const span = this.span();
954
+ if (span > 0 && value > 0) {
955
+ const factor = this.scaleValue > 0 ? value / this.scaleValue : 1;
956
+ this.initialSpan = span / value;
957
+ this.scaleValue = value;
958
+ this.tracker.scaleBy(factor);
959
+ }
960
+ }
961
+ /** Scale per second (UIKit's filter; measured for pans, assumed here). */
962
+ get velocity() {
963
+ return this.tracker.velocity(this.liftTime).x;
964
+ }
965
+ /** The midpoint between the two fingers. */
966
+ focalPoint() {
967
+ return centroid(this.touches.values());
968
+ }
969
+ /** Two fingers on this view are this recognizer's, not the browser's zoom. */
970
+ get nativeTouchBehavior() {
971
+ return {
972
+ panX: true,
973
+ panY: true,
974
+ pinchZoom: false,
975
+ doubleTapZoom: false
976
+ };
977
+ }
978
+ acceptsTouch(touch) {
979
+ return this.numberOfTouches < 2 && super.acceptsTouch(touch);
980
+ }
981
+ touchesBegan(_touches, event) {
982
+ if (this.numberOfTouches === 2) {
983
+ this.initialSpan = this.span();
984
+ this.scaleValue = 1;
985
+ this.tracker.reset();
986
+ this.tracker.add(1, 0, event.time);
987
+ }
988
+ }
989
+ touchesMoved(_touches, event) {
990
+ if (this.numberOfTouches < 2 || this.initialSpan <= 0) return;
991
+ const span = this.span();
992
+ if (this.state === "possible" && this.pending == null) {
993
+ if (Math.abs(span - this.initialSpan) >= this.hysteresis) {
994
+ this.initialSpan += Math.sign(span - this.initialSpan) * this.hysteresis;
995
+ this.scaleValue = span / this.initialSpan;
996
+ this.tracker.add(this.scaleValue, 0, event.time);
997
+ this.setState("began");
998
+ }
999
+ return;
1000
+ }
1001
+ this.scaleValue = span / this.initialSpan;
1002
+ this.tracker.add(this.scaleValue, 0, event.time, { isMotion: true });
1003
+ if (isActive(this.state)) this.setState("changed");
1004
+ }
1005
+ touchesEnded(_touches, event) {
1006
+ this.liftTime = event.time;
1007
+ this.setState(isActive(this.state) ? "ended" : "failed");
1008
+ }
1009
+ reset() {
1010
+ this.liftTime = void 0;
1011
+ this.initialSpan = 0;
1012
+ this.scaleValue = 1;
1013
+ this.tracker.reset();
1014
+ }
1015
+ span() {
1016
+ const [a, b] = this.trackedTouches;
1017
+ return a == null || b == null ? 0 : distance(a, b);
1018
+ }
1019
+ };
1020
+ //#endregion
1021
+ //#region src/Lightbox/zoomStage.ts
1022
+ /**
1023
+ * @file zoomStage.ts
1024
+ * @input 舞台尺寸、照片适应大小时的盒子和像素尺寸、一个变换(相对适应位置的偏移和缩放)、指针位置
1025
+ * @output 缩放舞台的纯几何:缩放上下限、停靠位置、拖动的橡皮筋、捏合越界的回弹量,
1026
+ * 以及「保持某一点不动」的变换和键盘缩放
1027
+ * @position useZoomCore、useZoomStage 下面的纯数学,不碰 DOM。下拉关闭的几何在 zoomDismiss.ts。
1028
+ *
1029
+ * 模型是一个能缩放的 UIScrollView,常量来自 motion/uikit/zoomMedia.ts。
1030
+ */
1031
+ const IDENTITY = {
1032
+ x: 0,
1033
+ y: 0,
1034
+ scale: 1
1035
+ };
1036
+ /** 离适应大小不到这么多,算没放大。 */
1037
+ const ZOOMED_EPSILON = .001;
1038
+ /**
1039
+ * 手指双击从适应大小放大到的倍数:「铺满舞台」和 `ZOOM_STEP` 中较大的那个。
1040
+ * iOS 照片只按铺满算,所以铺满不到 2 倍的照片,灯箱会比照片 App 放得更大一点。
1041
+ */
1042
+ function doubleTapScaleFor(width, height, fitWidth, fitHeight) {
1043
+ if (!(fitWidth > 0) || !(fitHeight > 0)) return 2;
1044
+ return Math.max(2, width / fitWidth, height / fitHeight);
1045
+ }
1046
+ /**
1047
+ * 最大缩放:照片 App 的做法,是「一个图像像素对一个设备像素」那个倍数的若干倍。
1048
+ * 永远不小于 `doubleTapScale`,保证双击落在上下限以内。
1049
+ */
1050
+ function maxScaleFor(naturalWidth, fitWidth, devicePixelRatio, doubleTapScale) {
1051
+ const { maxPixelZoomMultiple } = zoomMedia.viewer;
1052
+ if (!(fitWidth > 0) || !(naturalWidth > 0) || !(devicePixelRatio > 0)) return doubleTapScale;
1053
+ const pixelScale = naturalWidth / (fitWidth * devicePixelRatio);
1054
+ return Math.max(doubleTapScale, maxPixelZoomMultiple * pixelScale);
1055
+ }
1056
+ /** 照片是不是比适应大小更大。 */
1057
+ function isZoomed(geometry, transform) {
1058
+ return transform.scale > geometry.minScale + ZOOMED_EPSILON;
1059
+ }
1060
+ function axisRange(stageSize, fitStart, fitSize, scale) {
1061
+ const size = fitSize * scale;
1062
+ if (size <= stageSize) {
1063
+ const centred = (stageSize - size) / 2 - fitStart;
1064
+ return {
1065
+ min: centred,
1066
+ max: centred
1067
+ };
1068
+ }
1069
+ return {
1070
+ min: stageSize - size - fitStart,
1071
+ max: 0 - fitStart
1072
+ };
1073
+ }
1074
+ /**
1075
+ * 照片在 `scale` 下能停的偏移范围。某个方向上照片比舞台小,就居中停(UIKit 照片查看器都这样);
1076
+ * 比舞台大,就停在两边都不露缝的范围里。
1077
+ */
1078
+ function restRange(geometry, scale) {
1079
+ const { fit } = geometry;
1080
+ return {
1081
+ x: axisRange(geometry.width, fit.x, fit.width, scale),
1082
+ y: axisRange(geometry.height, fit.y, fit.height, scale)
1083
+ };
1084
+ }
1085
+ /** 同一缩放下离 `transform` 最近的停靠位置。 */
1086
+ function restingTransform(geometry, transform) {
1087
+ const range = restRange(geometry, transform.scale);
1088
+ return {
1089
+ x: Math.min(range.x.max, Math.max(range.x.min, transform.x)),
1090
+ y: Math.min(range.y.max, Math.max(range.y.min, transform.y)),
1091
+ scale: transform.scale
1092
+ };
1093
+ }
1094
+ /** 捏合自身的倍数 `scale` 实际显示成多大:上下限以内 1:1,超出后越来越拉不动。 */
1095
+ function overshootScale(geometry, scale) {
1096
+ const f = zoomMedia.overshoot.limitFactor;
1097
+ const { minScale: m, maxScale: M } = geometry;
1098
+ if (scale > M) return M * (f - (f - 1) * M / scale);
1099
+ if (scale < m) return m / (f - (f - 1) * scale / m);
1100
+ return scale;
1101
+ }
1102
+ /** `overshootScale` 的反函数:照片已经越界时,新的捏合从这里接着算,不跳。 */
1103
+ function pinchScaleFor(geometry, shown) {
1104
+ const f = zoomMedia.overshoot.limitFactor;
1105
+ const { minScale: m, maxScale: M } = geometry;
1106
+ if (shown > M) {
1107
+ const gap = f * M - shown;
1108
+ return gap > 0 ? (f - 1) * M * M / gap : Number.POSITIVE_INFINITY;
1109
+ }
1110
+ if (shown < m) return Math.max(0, (f - m / shown) * m / (f - 1));
1111
+ return shown;
1112
+ }
1113
+ /**
1114
+ * 缩放到 `scale` 时,让 `from` 下 `anchor` 处的照片点出现在 `point`。
1115
+ * 捏合让起手质心下的点跟着当前质心走;双击和越界回弹让这个点原地不动(`point` = `anchor`)。
1116
+ */
1117
+ function transformKeepingPoint(geometry, from, anchor, point, scale) {
1118
+ const { fit } = geometry;
1119
+ const u = (anchor.x - fit.x - from.x) / from.scale;
1120
+ const v = (anchor.y - fit.y - from.y) / from.scale;
1121
+ return {
1122
+ x: point.x - fit.x - u * scale,
1123
+ y: point.y - fit.y - v * scale,
1124
+ scale
1125
+ };
1126
+ }
1127
+ /**
1128
+ * 拖动时照片显示在哪:`raw` 是没有边界时指针位移会把它带到的位置。越过边缘后按 UIScrollView 的
1129
+ * 橡皮筋让步,尺度是舞台在这个方向上的尺寸。照片比舞台小的方向保持居中,内容装得下的滚动视图不回弹。
1130
+ */
1131
+ function draggedTransform(geometry, raw) {
1132
+ const range = restRange(geometry, raw.scale);
1133
+ return {
1134
+ x: range.x.min === range.x.max ? range.x.min : rubberBandClamp(raw.x, range.x.min, range.x.max, geometry.width),
1135
+ y: range.y.min === range.y.max ? range.y.min : rubberBandClamp(raw.y, range.y.min, range.y.max, geometry.height),
1136
+ scale: raw.scale
1137
+ };
1138
+ }
1139
+ /** 显示位置背后的指针位移位置:`draggedTransform` 的反算。 */
1140
+ function rawForDragged(geometry, shown) {
1141
+ const range = restRange(geometry, shown.scale);
1142
+ return {
1143
+ x: range.x.min === range.x.max ? shown.x : rubberBandUnclamp(shown.x, range.x.min, range.x.max, geometry.width),
1144
+ y: range.y.min === range.y.max ? shown.y : rubberBandUnclamp(shown.y, range.y.min, range.y.max, geometry.height),
1145
+ scale: shown.scale
1146
+ };
1147
+ }
1148
+ /**
1149
+ * 手指在 `point` 双击后的停靠位置。适应大小时按点放大到 `doubleTapScale`,并保持在舞台里
1150
+ * (照片 App 是把点到的地方移到中间);已放大时回到适应大小。
1151
+ */
1152
+ function doubleTapTarget(geometry, from, point) {
1153
+ if (isZoomed(geometry, from)) return restingTransform(geometry, {
1154
+ ...IDENTITY,
1155
+ scale: geometry.minScale
1156
+ });
1157
+ return restingTransform(geometry, transformKeepingPoint(geometry, from, point, point, Math.min(geometry.maxScale, Math.max(geometry.minScale, geometry.doubleTapScale))));
1158
+ }
1159
+ /**
1160
+ * 松手后的停靠位置。上下限以内就是 `shown` 本身(拖动的惯性会处理边缘);越过上下限就回到
1161
+ * 那个极限,最后质心下的点原地不动,照片留在舞台里。
1162
+ */
1163
+ function releaseTarget(geometry, shown, centroid) {
1164
+ const limit = Math.min(geometry.maxScale, Math.max(geometry.minScale, shown.scale));
1165
+ if (limit === shown.scale) return shown;
1166
+ return restingTransform(geometry, transformKeepingPoint(geometry, shown, centroid, centroid, limit));
1167
+ }
1168
+ /** 鼠标或触控笔在 `point` 双击:按点放大 `ZOOM_STEP` 倍并留在舞台里;已放大时回到适应大小。 */
1169
+ function doubleClickTarget(geometry, from, point) {
1170
+ return doubleTapTarget({
1171
+ ...geometry,
1172
+ doubleTapScale: 2
1173
+ }, from, point);
1174
+ }
1175
+ /** 缩放键(Enter、空格、`+`):以舞台中心放大 `ZOOM_STEP` 倍,已放大时回到适应大小。 */
1176
+ function releasedZoomTarget(geometry, from) {
1177
+ return doubleClickTarget(geometry, from, {
1178
+ x: geometry.width / 2,
1179
+ y: geometry.height / 2
1180
+ });
1181
+ }
1182
+ /** 平移 (dx, dy) 后的停靠位置:键盘的一步。 */
1183
+ function pannedBy(geometry, from, dx, dy) {
1184
+ return restingTransform(geometry, {
1185
+ x: from.x + dx,
1186
+ y: from.y + dy,
1187
+ scale: from.scale
1188
+ });
1189
+ }
1190
+ /**
1191
+ * 舞台尺寸变了(比如旋转屏幕)以后,显示同一张照片的变换:舞台中心的照片点还在中心,
1192
+ * 照片在屏幕上的大小不变,所以相对适应大小的倍数跟着适应大小变。结果在新的上下限以内、停靠好。
1193
+ */
1194
+ function transformForResize(before, after, transform) {
1195
+ if (!isZoomed(before, transform)) return {
1196
+ ...IDENTITY,
1197
+ scale: after.minScale
1198
+ };
1199
+ const ratio = after.fit.width > 0 ? before.fit.width / after.fit.width : 1;
1200
+ const scale = Math.min(after.maxScale, Math.max(after.minScale, transform.scale * ratio));
1201
+ const u = (before.width / 2 - before.fit.x - transform.x) / transform.scale / before.fit.width;
1202
+ const v = (before.height / 2 - before.fit.y - transform.y) / transform.scale / before.fit.height;
1203
+ return restingTransform(after, {
1204
+ x: after.width / 2 - after.fit.x - u * after.fit.width * scale,
1205
+ y: after.height / 2 - after.fit.y - v * after.fit.height * scale,
1206
+ scale
1207
+ });
1208
+ }
1209
+ //#endregion
1210
+ //#region src/Lightbox/zoomCore.ts
1211
+ /** 手指或鼠标拖动放大后的照片时,舞台上带这个属性。 */
1212
+ const ZOOM_DRAGGING_ATTRIBUTE = "data-zoom-dragging";
1213
+ /**
1214
+ * 灯箱的缩放舞台。每一步都在合成器上播放烘焙好的关键帧,一步开始后不再读布局。
1215
+ * 键盘的一步从「要去的地方」接着走,所以弹簧途中连按会累加。Vue 只听到离散的状态变化。
1216
+ */
1217
+ function createZoomCore(options) {
1218
+ const animator = createMotionEngine(null);
1219
+ let content = null;
1220
+ let geometry = null;
1221
+ let origin = {
1222
+ x: 0,
1223
+ y: 0
1224
+ };
1225
+ let zoomed = false;
1226
+ let target = IDENTITY;
1227
+ const contentRef = (element) => {
1228
+ const next = element instanceof HTMLElement ? element : null;
1229
+ if (next === content) return;
1230
+ content = next;
1231
+ animator.attach(next);
1232
+ };
1233
+ const measure = () => {
1234
+ const stage = options.stage();
1235
+ const view = stage?.ownerDocument.defaultView;
1236
+ if (stage == null || content == null || view == null) return null;
1237
+ const rect = stage.getBoundingClientRect();
1238
+ const width = rect.width > 0 ? rect.width : stage.clientWidth;
1239
+ const height = rect.height > 0 ? rect.height : stage.clientHeight;
1240
+ const used = view.getComputedStyle(content);
1241
+ const fitWidth = Number.parseFloat(used.width) || content.offsetWidth;
1242
+ const fitHeight = Number.parseFloat(used.height) || content.offsetHeight;
1243
+ if (!(width > 0 && height > 0 && fitWidth > 0 && fitHeight > 0)) return null;
1244
+ origin = {
1245
+ x: rect.left + stage.clientLeft,
1246
+ y: rect.top + stage.clientTop
1247
+ };
1248
+ const naturalWidth = content.tagName === "IMG" ? content.naturalWidth : 0;
1249
+ const natural = naturalWidth > 0 ? naturalWidth : fitWidth;
1250
+ const doubleTapScale = doubleTapScaleFor(width, height, fitWidth, fitHeight);
1251
+ geometry = {
1252
+ width,
1253
+ height,
1254
+ fit: {
1255
+ x: (width - fitWidth) / 2,
1256
+ y: (height - fitHeight) / 2,
1257
+ width: fitWidth,
1258
+ height: fitHeight
1259
+ },
1260
+ minScale: 1,
1261
+ maxScale: maxScaleFor(natural, fitWidth, view.devicePixelRatio || 1, doubleTapScale),
1262
+ doubleTapScale
1263
+ };
1264
+ return geometry;
1265
+ };
1266
+ const toStage = (point) => ({
1267
+ x: point.x - origin.x,
1268
+ y: point.y - origin.y
1269
+ });
1270
+ const current = () => ({
1271
+ x: animator.get("x"),
1272
+ y: animator.get("y"),
1273
+ scale: animator.get("scale")
1274
+ });
1275
+ const write = (transform) => {
1276
+ target = transform;
1277
+ animator.set({
1278
+ x: transform.x,
1279
+ y: transform.y,
1280
+ scale: transform.scale
1281
+ });
1282
+ };
1283
+ const setTarget = (transform) => {
1284
+ target = transform;
1285
+ };
1286
+ const isMoving = () => {
1287
+ const shown = current();
1288
+ return Math.abs(shown.x - target.x) > .01 || Math.abs(shown.y - target.y) > .01 || Math.abs(shown.scale - target.scale) > 1e-4;
1289
+ };
1290
+ const isAtEdgeOf = (at, direction) => {
1291
+ const range = restRange(at, target.scale);
1292
+ return direction === "left" ? target.x <= range.x.min + .5 : target.x >= range.x.max - .5;
1293
+ };
1294
+ const setZoomed = (next) => {
1295
+ if (zoomed !== next) {
1296
+ zoomed = next;
1297
+ options.onZoomedChange(next);
1298
+ }
1299
+ };
1300
+ const settleTo = (at, to, { touchRelease = false, scaleVelocity = 0 } = {}) => {
1301
+ const from = current();
1302
+ animator.stop();
1303
+ if (animator.get("opacity") !== 1) animator.set({ opacity: 1 });
1304
+ target = to;
1305
+ setZoomed(isZoomed(at, to));
1306
+ if (from.x === to.x && from.y === to.y && from.scale === to.scale) return;
1307
+ registerReducedMotionCrossFade();
1308
+ const span = to.scale - from.scale;
1309
+ const rate = Number.isFinite(scaleVelocity) && span !== 0 ? scaleVelocity / span : 0;
1310
+ animator.animate({
1311
+ x: to.x,
1312
+ y: to.y,
1313
+ scale: to.scale
1314
+ }, {
1315
+ spring: resolveMotion(options.stage(), springs.settle),
1316
+ velocity: {
1317
+ x: (to.x - from.x) * rate,
1318
+ y: (to.y - from.y) * rate,
1319
+ scale: span * rate
1320
+ }
1321
+ }, { touchRelease });
1322
+ };
1323
+ watch(options.itemKey, () => {
1324
+ animator.stop();
1325
+ animator.set({
1326
+ x: 0,
1327
+ y: 0,
1328
+ scale: 1,
1329
+ opacity: 1
1330
+ });
1331
+ target = IDENTITY;
1332
+ zoomed = false;
1333
+ geometry = null;
1334
+ }, { flush: "pre" });
1335
+ const onResize = () => {
1336
+ const before = geometry;
1337
+ if (before == null || !zoomed) return;
1338
+ const after = measure();
1339
+ if (after == null) return;
1340
+ animator.stop();
1341
+ const next = transformForResize(before, after, target);
1342
+ write(next);
1343
+ setZoomed(isZoomed(after, next));
1344
+ };
1345
+ useAttachment(() => (options.surface ?? options.stage)(), (surface) => options.isEnabled() ? observeResize(surface, onResize) : () => {}, options.isEnabled);
1346
+ const zoomIn = () => {
1347
+ const at = measure();
1348
+ if (at == null || zoomed) return;
1349
+ settleTo(at, releasedZoomTarget(at, target));
1350
+ };
1351
+ const zoomOut = () => {
1352
+ const at = measure();
1353
+ if (at == null || !zoomed) return;
1354
+ settleTo(at, restingTransform(at, {
1355
+ ...IDENTITY,
1356
+ scale: at.minScale
1357
+ }));
1358
+ };
1359
+ return {
1360
+ api: {
1361
+ contentRef,
1362
+ isZoomed: () => zoomed,
1363
+ toggle: () => zoomed ? zoomOut() : zoomIn(),
1364
+ zoomIn,
1365
+ zoomOut,
1366
+ panBy: (dx, dy) => {
1367
+ const at = measure();
1368
+ if (at == null || !zoomed) return;
1369
+ settleTo(at, pannedBy(at, target, dx, dy));
1370
+ },
1371
+ doubleClickAt: (clientX, clientY) => {
1372
+ const at = measure();
1373
+ if (at == null) return;
1374
+ settleTo(at, doubleClickTarget(at, current(), toStage({
1375
+ x: clientX,
1376
+ y: clientY
1377
+ })));
1378
+ },
1379
+ isAtEdge: (direction) => {
1380
+ const at = geometry ?? measure();
1381
+ if (at == null || !zoomed) return true;
1382
+ return isAtEdgeOf(at, direction);
1383
+ }
1384
+ },
1385
+ animator,
1386
+ options,
1387
+ geometry: () => geometry,
1388
+ target: () => target,
1389
+ zoomed: () => zoomed,
1390
+ measure,
1391
+ toStage,
1392
+ current,
1393
+ write,
1394
+ setTarget,
1395
+ setZoomed,
1396
+ isMoving,
1397
+ isAtEdgeOf,
1398
+ settleTo
1399
+ };
1400
+ }
1401
+ //#endregion
1402
+ //#region src/Lightbox/zoomDismissGesture.ts
1403
+ /**
1404
+ * 下拉关闭时舞台带这个属性,直到照片落位。只包住照片的舞台这时让移出去的照片画在外面。
1405
+ */
1406
+ const ZOOM_DISMISSING_ATTRIBUTE = "data-zoom-dismissing";
1407
+ function useZoomDismiss(core, options) {
1408
+ const { animator, measure, current, write, setTarget, toStage } = core;
1409
+ const stage = () => core.options.stage();
1410
+ let dragging = null;
1411
+ let leaving = false;
1412
+ let finger = false;
1413
+ const recognizer = new PanGestureRecognizer({
1414
+ name: "Lightbox.dismissPan",
1415
+ maximumNumberOfTouches: 1,
1416
+ allowedPointerTypes: [
1417
+ "touch",
1418
+ "pen",
1419
+ "mouse"
1420
+ ],
1421
+ allowedScrollTypes: ["continuous"],
1422
+ shouldBegin: (pan) => {
1423
+ if (options.dismiss?.isEnabled() !== true || leaving) return false;
1424
+ const geometry = measure();
1425
+ if (geometry == null || isZoomed(geometry, core.target())) return false;
1426
+ const { x, y } = pan.totalTranslation();
1427
+ return y > 0 && y >= Math.abs(x);
1428
+ }
1429
+ });
1430
+ const release = (pan, geometry, dismiss) => {
1431
+ dragging = null;
1432
+ const translation = pan.translation();
1433
+ const velocity = pan.velocity();
1434
+ const dismisses = pan.state === "ended" && dismissCommits(translation.y, velocity.y);
1435
+ dismiss?.onRelease(dismisses, finger);
1436
+ const shown = current();
1437
+ if (dismisses) {
1438
+ leaving = true;
1439
+ const view = stage()?.ownerDocument.defaultView;
1440
+ const y = dismissExitY(geometry, shown, view != null ? toStage({
1441
+ x: 0,
1442
+ y: view.innerHeight
1443
+ }).y : geometry.height);
1444
+ setTarget({
1445
+ ...shown,
1446
+ y
1447
+ });
1448
+ animator.animate({
1449
+ x: shown.x,
1450
+ y
1451
+ }, {
1452
+ spring: zoomMedia.dismiss.dismissPositionSpring,
1453
+ velocity: {
1454
+ x: velocity.x,
1455
+ y: velocity.y
1456
+ }
1457
+ }, {
1458
+ crossfadeAs: "exit",
1459
+ touchRelease: finger
1460
+ }).finished.then(() => {
1461
+ if (leaving) dismiss?.onDismissed();
1462
+ });
1463
+ return;
1464
+ }
1465
+ setTarget(IDENTITY);
1466
+ const settle = resolveMotion(stage(), springs.settle);
1467
+ const position = animator.animate({
1468
+ x: 0,
1469
+ y: 0
1470
+ }, {
1471
+ spring: settle,
1472
+ velocity: {
1473
+ x: velocity.x,
1474
+ y: velocity.y
1475
+ }
1476
+ }, { touchRelease: finger });
1477
+ const size = animator.animate({ scale: 1 }, { spring: settle }, { touchRelease: finger });
1478
+ Promise.all([position.finished, size.finished]).then(() => {
1479
+ if (dragging == null && !leaving) stage()?.removeAttribute(ZOOM_DISMISSING_ATTRIBUTE);
1480
+ });
1481
+ };
1482
+ useGestureRecognizer(() => (core.options.surface ?? core.options.stage)(), () => recognizer, (pan) => {
1483
+ const dismiss = options.dismiss;
1484
+ if (pan.state === "began") {
1485
+ finger = pan.trackedTouches[0]?.pointerType === "touch";
1486
+ const geometry = measure();
1487
+ if (geometry == null || dismiss == null) return;
1488
+ animator.stop();
1489
+ options.onDragStart?.();
1490
+ dragging = geometry;
1491
+ stage()?.setAttribute(ZOOM_DISMISSING_ATTRIBUTE, "");
1492
+ }
1493
+ const geometry = dragging;
1494
+ if (geometry == null) return;
1495
+ if (pan.state === "began" || pan.state === "changed") {
1496
+ const translation = pan.translation();
1497
+ write(dismissTransform(geometry, translation.x, translation.y));
1498
+ dismiss?.onDrag(Math.max(0, translation.y));
1499
+ return;
1500
+ }
1501
+ release(pan, geometry, dismiss);
1502
+ }, {
1503
+ isEnabled: () => options.dismiss?.isEnabled() === true,
1504
+ manageStyle: false
1505
+ });
1506
+ watch(core.options.itemKey, () => {
1507
+ dragging = null;
1508
+ leaving = false;
1509
+ stage()?.removeAttribute(ZOOM_DISMISSING_ATTRIBUTE);
1510
+ }, { flush: "pre" });
1511
+ return {
1512
+ recognizer,
1513
+ isLeaving: () => leaving,
1514
+ reset: () => {
1515
+ if (!leaving) return;
1516
+ leaving = false;
1517
+ dragging = null;
1518
+ animator.stop();
1519
+ animator.set({
1520
+ x: 0,
1521
+ y: 0,
1522
+ scale: 1,
1523
+ opacity: 1
1524
+ });
1525
+ setTarget(IDENTITY);
1526
+ stage()?.removeAttribute(ZOOM_DISMISSING_ATTRIBUTE);
1527
+ }
1528
+ };
1529
+ }
1530
+ //#endregion
1531
+ //#region src/Lightbox/useZoomStage.ts
1532
+ const EVERY_POINTER = [
1533
+ "touch",
1534
+ "pen",
1535
+ "mouse"
1536
+ ];
1537
+ /** 只有手指捏合;ctrl + 滚轮也会捏合。 */
1538
+ const FINGERS = ["touch"];
1539
+ function useZoomStage(core, options) {
1540
+ const { animator, measure, toStage, current, write, setTarget, setZoomed, settleTo, isMoving, isAtEdgeOf } = core;
1541
+ let pinch = null;
1542
+ let pan = null;
1543
+ let caught = false;
1544
+ let draggedSinceCatch = false;
1545
+ const finger = {
1546
+ pinch: false,
1547
+ catch: false
1548
+ };
1549
+ const hasGive = () => options.isTouchPresentation();
1550
+ /** 放大后平移的松手:UIScrollView 的惯性,碰到边缘回弹。减少动效时也保留,这是人自己的动作。 */
1551
+ const coast$1 = (geometry, velocity) => {
1552
+ const from = current();
1553
+ const range = restRange(geometry, from.scale);
1554
+ const vx = range.x.min === range.x.max ? 0 : velocity.x;
1555
+ const vy = range.y.min === range.y.max ? 0 : velocity.y;
1556
+ const rest = (value, v, { min, max }) => Math.min(max, Math.max(min, value + decayRestDistance(v)));
1557
+ setTarget({
1558
+ x: rest(from.x, vx, range.x),
1559
+ y: rest(from.y, vy, range.y),
1560
+ scale: from.scale
1561
+ });
1562
+ setZoomed(isZoomed(geometry, from));
1563
+ animator.decay(coast(animator, {
1564
+ x: vx,
1565
+ y: vy
1566
+ }, { bounds: {
1567
+ x: range.x,
1568
+ y: range.y
1569
+ } }));
1570
+ };
1571
+ const dismiss = useZoomDismiss(core, options);
1572
+ const pinchRecognizer = new PinchGestureRecognizer({
1573
+ name: "Lightbox.zoomPinch",
1574
+ allowedPointerTypes: FINGERS,
1575
+ shouldBegin: (recognizer) => options.shouldBeginPinch?.(recognizer) ?? true
1576
+ });
1577
+ const panRecognizer = new PanGestureRecognizer({
1578
+ name: "Lightbox.zoomPan",
1579
+ maximumNumberOfTouches: 2,
1580
+ allowedPointerTypes: EVERY_POINTER,
1581
+ allowedScrollTypes: ["continuous"],
1582
+ shouldBegin: (recognizer) => {
1583
+ if (recognizer.numberOfTouches > 1) return options.shouldBeginPinch?.(recognizer) ?? true;
1584
+ const geometry = measure();
1585
+ if (geometry == null || !isZoomed(geometry, current())) return false;
1586
+ const { x, y } = recognizer.totalTranslation();
1587
+ return !(options.hasOuterPager() && Math.abs(x) >= Math.abs(y) && isAtEdgeOf(geometry, x < 0 ? "left" : "right"));
1588
+ },
1589
+ hysteresis: (touch) => {
1590
+ const geometry = core.geometry();
1591
+ return touch.pointerType !== "touch" && geometry != null && isZoomed(geometry, current()) ? 0 : UIKIT_PAN.hysteresis.value;
1592
+ }
1593
+ });
1594
+ const doubleTap = new TapGestureRecognizer({
1595
+ name: "lightbox-zoom-double-tap",
1596
+ numberOfTapsRequired: 2,
1597
+ allowedPointerTypes: FINGERS
1598
+ });
1599
+ const tap = new TapGestureRecognizer({
1600
+ name: "lightbox-zoom-tap",
1601
+ allowedPointerTypes: FINGERS
1602
+ });
1603
+ const touchDown = new LongPressGestureRecognizer({
1604
+ name: "lightbox-zoom-touch-down",
1605
+ minimumPressDuration: 0,
1606
+ allowableMovement: Number.POSITIVE_INFINITY,
1607
+ cancelsTouchesInView: false,
1608
+ delaysTouchesEnded: false,
1609
+ allowedPointerTypes: EVERY_POINTER,
1610
+ shouldBegin: () => !dismiss.isLeaving() && isMoving()
1611
+ });
1612
+ pinchRecognizer.recognizeSimultaneouslyWith(panRecognizer);
1613
+ tap.requireToFail(doubleTap);
1614
+ for (const other of [
1615
+ pinchRecognizer,
1616
+ panRecognizer,
1617
+ doubleTap,
1618
+ tap,
1619
+ dismiss.recognizer
1620
+ ]) touchDown.recognizeSimultaneouslyWith(other);
1621
+ const surface = () => (core.options.surface ?? core.options.stage)();
1622
+ const recognizerOptions = {
1623
+ isEnabled: options.isEnabled,
1624
+ manageStyle: false
1625
+ };
1626
+ useGestureRecognizer(surface, () => pinchRecognizer, (recognizer) => {
1627
+ if (recognizer.state === "began") {
1628
+ finger.pinch = recognizer.trackedTouches[0]?.pointerType === "touch";
1629
+ const geometry = measure();
1630
+ if (geometry == null) return;
1631
+ draggedSinceCatch = true;
1632
+ animator.stop();
1633
+ const start = current();
1634
+ const anchor = toStage(recognizer.focalPoint());
1635
+ pinch = {
1636
+ start,
1637
+ startPinchScale: pinchScaleFor(geometry, start.scale),
1638
+ anchor,
1639
+ centroid: anchor
1640
+ };
1641
+ }
1642
+ const session = pinch;
1643
+ const geometry = core.geometry();
1644
+ const moving = recognizer.state === "began" || recognizer.state === "changed";
1645
+ if (!moving) pinch = null;
1646
+ if (session == null || geometry == null) return;
1647
+ if (moving) {
1648
+ session.centroid = toStage(recognizer.focalPoint());
1649
+ const shown = overshootScale(geometry, session.startPinchScale * recognizer.scale);
1650
+ write(transformKeepingPoint(geometry, session.start, session.anchor, session.centroid, shown));
1651
+ return;
1652
+ }
1653
+ const shown = current();
1654
+ const to = releaseTarget(geometry, shown, session.centroid);
1655
+ if (to !== shown) {
1656
+ pan = null;
1657
+ const raw = session.startPinchScale * recognizer.scale;
1658
+ const step = raw * 1e-4;
1659
+ const give = (overshootScale(geometry, raw + step) - overshootScale(geometry, raw - step)) / (2 * step);
1660
+ settleTo(geometry, to, {
1661
+ touchRelease: finger.pinch,
1662
+ scaleVelocity: recognizer.state === "ended" ? give * session.startPinchScale * recognizer.velocity : 0
1663
+ });
1664
+ return;
1665
+ }
1666
+ if (panRecognizer.state === "began" || panRecognizer.state === "changed") {
1667
+ const withGive = hasGive();
1668
+ pan = {
1669
+ raw: rawForDragged(geometry, shown),
1670
+ translation: withGive ? panRecognizer.translation() : panRecognizer.totalTranslation(),
1671
+ hasGive: withGive
1672
+ };
1673
+ setZoomed(isZoomed(geometry, shown));
1674
+ return;
1675
+ }
1676
+ coast$1(geometry, {
1677
+ x: 0,
1678
+ y: 0
1679
+ });
1680
+ }, recognizerOptions);
1681
+ useGestureRecognizer(surface, () => panRecognizer, (recognizer) => {
1682
+ const stage = core.options.stage();
1683
+ if (recognizer.state === "began") {
1684
+ const geometry = measure();
1685
+ if (geometry == null) return;
1686
+ draggedSinceCatch = true;
1687
+ animator.stop();
1688
+ options.onDragStart?.();
1689
+ const shown = current();
1690
+ if (isZoomed(geometry, shown)) stage?.setAttribute(ZOOM_DRAGGING_ATTRIBUTE, "");
1691
+ pan = {
1692
+ raw: rawForDragged(geometry, shown),
1693
+ translation: {
1694
+ x: 0,
1695
+ y: 0
1696
+ },
1697
+ hasGive: hasGive()
1698
+ };
1699
+ }
1700
+ const geometry = core.geometry();
1701
+ if (recognizer.state === "began" || recognizer.state === "changed") {
1702
+ const session = pan;
1703
+ if (pinch != null || session == null || geometry == null) return;
1704
+ const translation = session.hasGive ? recognizer.translation() : recognizer.totalTranslation();
1705
+ const raw = {
1706
+ x: session.raw.x + translation.x - session.translation.x,
1707
+ y: session.raw.y + translation.y - session.translation.y,
1708
+ scale: session.raw.scale
1709
+ };
1710
+ if (session.hasGive) {
1711
+ write(draggedTransform(geometry, raw));
1712
+ return;
1713
+ }
1714
+ const range = restRange(geometry, raw.scale);
1715
+ write({
1716
+ x: Math.min(range.x.max, Math.max(range.x.min, raw.x)),
1717
+ y: Math.min(range.y.max, Math.max(range.y.min, raw.y)),
1718
+ scale: raw.scale
1719
+ });
1720
+ return;
1721
+ }
1722
+ stage?.removeAttribute(ZOOM_DRAGGING_ATTRIBUTE);
1723
+ const session = pan;
1724
+ pan = null;
1725
+ if (pinch != null || session == null || geometry == null) return;
1726
+ coast$1(geometry, recognizer.state === "ended" && session.hasGive ? recognizer.scrollVelocity() : {
1727
+ x: 0,
1728
+ y: 0
1729
+ });
1730
+ }, recognizerOptions);
1731
+ useGestureRecognizer(surface, () => touchDown, (recognizer) => {
1732
+ if (recognizer.state === "began") {
1733
+ finger.catch = recognizer.trackedTouches[0]?.pointerType === "touch";
1734
+ draggedSinceCatch = false;
1735
+ caught = true;
1736
+ const shown = current();
1737
+ animator.stop();
1738
+ setTarget(shown);
1739
+ return;
1740
+ }
1741
+ if (recognizer.state === "changed") return;
1742
+ const wasCaught = caught;
1743
+ caught = false;
1744
+ const geometry = core.geometry() ?? measure();
1745
+ if (!wasCaught || draggedSinceCatch || geometry == null) return;
1746
+ const shown = current();
1747
+ const limit = releaseTarget(geometry, shown, {
1748
+ x: geometry.width / 2,
1749
+ y: geometry.height / 2
1750
+ });
1751
+ if (limit !== shown) {
1752
+ settleTo(geometry, limit, { touchRelease: finger.catch });
1753
+ return;
1754
+ }
1755
+ coast$1(geometry, {
1756
+ x: 0,
1757
+ y: 0
1758
+ });
1759
+ }, recognizerOptions);
1760
+ useGestureRecognizer(surface, () => doubleTap, (recognizer) => {
1761
+ if (recognizer.state !== "ended") return;
1762
+ const geometry = measure();
1763
+ if (geometry == null) return;
1764
+ settleTo(geometry, doubleTapTarget(geometry, current(), toStage(recognizer.location())));
1765
+ }, recognizerOptions);
1766
+ useGestureRecognizer(surface, () => tap, (recognizer) => {
1767
+ if (recognizer.state !== "ended") return;
1768
+ const geometry = measure();
1769
+ if (geometry == null) return;
1770
+ const point = toStage(recognizer.location());
1771
+ const { x, y, scale } = current();
1772
+ const left = geometry.fit.x + x;
1773
+ const top = geometry.fit.y + y;
1774
+ if (!(point.x >= left && point.x <= left + geometry.fit.width * scale && point.y >= top && point.y <= top + geometry.fit.height * scale)) options.onTapOutside?.(recognizer.location());
1775
+ }, recognizerOptions);
1776
+ return {
1777
+ ...core.api,
1778
+ reset: dismiss.reset
1779
+ };
1780
+ }
1781
+ //#endregion
1782
+ //#region src/Lightbox/useLightboxStage.ts
1783
+ /** 视频原生控件在底边的这一条里(浏览器不给控件的几何)。从这里起的拖动归视频。 */
1784
+ const VIDEO_CONTROLS_BAND = 48;
1785
+ function within(rect, { x, y }) {
1786
+ return rect != null && x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
1787
+ }
1788
+ /** 有尺寸的元素的盒子;还没尺寸(照片在加载)的不算。 */
1789
+ function sized(element) {
1790
+ const rect = element?.getBoundingClientRect();
1791
+ return rect != null && rect.width > 0 && rect.height > 0 ? rect : null;
1792
+ }
1793
+ function useLightboxStage(options) {
1794
+ const currentPage = () => options.track()?.querySelector("[data-current]") ?? null;
1795
+ const zoomEnabled = () => options.isOpen() && options.isZoomTarget();
1796
+ const core = createZoomCore({
1797
+ stage: options.stage,
1798
+ surface: options.track,
1799
+ isEnabled: zoomEnabled,
1800
+ itemKey: options.itemKey,
1801
+ onZoomedChange: options.onZoomedChange
1802
+ });
1803
+ const fades = createDismissFades(options);
1804
+ const startsOnCaption = (touch) => {
1805
+ const target = touch?.target;
1806
+ return target instanceof Element && target.closest("[data-lightbox-caption]") != null;
1807
+ };
1808
+ const zoom = useZoomStage(core, {
1809
+ isEnabled: zoomEnabled,
1810
+ onTapOutside: (point) => {
1811
+ const caption = currentPage()?.querySelector("[data-lightbox-caption]")?.getBoundingClientRect();
1812
+ if (!within(caption, point)) options.close();
1813
+ },
1814
+ onDragStart: options.onDragStart,
1815
+ isTouchPresentation: options.isTouch,
1816
+ hasOuterPager: () => options.isGallery() && options.isTouch(),
1817
+ shouldBeginPinch: (recognizer) => !startsOnCaption(recognizer.trackedTouches[0]),
1818
+ dismiss: {
1819
+ isEnabled: () => options.isOpen() && !options.isVideo() && options.isTouch(),
1820
+ onDrag: fades.onDrag,
1821
+ onRelease: fades.onRelease,
1822
+ onDismissed: () => {
1823
+ options.close();
1824
+ nextTick(() => {
1825
+ if (options.isOpen()) restore();
1826
+ });
1827
+ }
1828
+ }
1829
+ });
1830
+ function restore() {
1831
+ zoom.reset();
1832
+ fades.restore();
1833
+ }
1834
+ watch(options.isOpen, (open) => {
1835
+ if (open) restore();
1836
+ }, { flush: "pre" });
1837
+ const startsOnVideoControls = (touch) => {
1838
+ const video = currentPage()?.querySelector("video[controls]");
1839
+ if (touch == null || video == null) return false;
1840
+ const box = video.getBoundingClientRect();
1841
+ return touch.startX >= box.left && touch.startX <= box.right && touch.startY <= box.bottom && touch.startY >= box.bottom - VIDEO_CONTROLS_BAND;
1842
+ };
1843
+ const pager = useLightboxPager({
1844
+ viewport: options.viewport,
1845
+ track: () => options.isGallery() ? options.track() : null,
1846
+ count: options.count,
1847
+ gap: zoomMedia.viewer.pageGap,
1848
+ index: options.index,
1849
+ isPanEnabled: () => options.isOpen() && options.isGallery() && options.isTouch(),
1850
+ isControlledChangeAnimated: options.isTouch,
1851
+ panShouldBegin: (pan) => !startsOnVideoControls(pan.trackedTouches[0]),
1852
+ shouldBeginPan: (direction) => !zoom.isZoomed() || zoom.isAtEdge(direction),
1853
+ onIndexChange: options.onSwipe,
1854
+ onSettle: (settled) => {
1855
+ for (const page of options.track()?.querySelectorAll(":scope > [data-lightbox-page]") ?? []) {
1856
+ const img = page.querySelector("img");
1857
+ if (img != null && page.dataset.lightboxPage !== String(settled)) {
1858
+ img.style.translate = "";
1859
+ img.style.scale = "";
1860
+ }
1861
+ }
1862
+ }
1863
+ });
1864
+ const isOnCurrentMedia = (point) => {
1865
+ const page = currentPage();
1866
+ const media = sized(page?.querySelector("img")) ?? sized(page?.querySelector("video"));
1867
+ const caption = sized(page?.querySelector("[data-lightbox-caption]"));
1868
+ const boxes = [media, caption].filter((rect) => rect != null);
1869
+ const inRows = (rect) => rect != null && point.y >= rect.top && point.y <= rect.bottom;
1870
+ return inRows(caption) && caption != null && point.x >= caption.left && point.x <= caption.right || inRows(media) && point.x >= Math.min(...boxes.map((r) => r.left)) && point.x <= Math.max(...boxes.map((r) => r.right));
1871
+ };
1872
+ useGestureRecognizer(options.viewport, () => new TapGestureRecognizer({
1873
+ name: "lightbox-backdrop-tap",
1874
+ allowedPointerTypes: ["touch"]
1875
+ }), (tap) => {
1876
+ if (tap.state === "ended" && !isOnCurrentMedia(tap.location())) options.close();
1877
+ }, {
1878
+ isEnabled: () => options.isOpen() && !options.isZoomTarget(),
1879
+ manageStyle: false
1880
+ });
1881
+ return {
1882
+ zoom,
1883
+ pager
1884
+ };
1885
+ }
1886
+ //#endregion
1887
+ //#region src/Lightbox/Lightbox.vue
1888
+ const _hoisted_1 = [
1889
+ "aria-label",
1890
+ "aria-describedby",
1891
+ "data-gallery",
1892
+ "data-caption-band",
1893
+ "data-has-zoom"
1894
+ ];
1895
+ const _hoisted_2 = {
1896
+ class: "astryx-lightbox__chrome",
1897
+ "data-lightbox-chrome": ""
1898
+ };
1899
+ const _hoisted_3 = { class: "astryx-lightbox__control astryx-lightbox__close" };
1900
+ const _hoisted_4 = {
1901
+ key: 0,
1902
+ class: "astryx-lightbox__control astryx-lightbox__nav astryx-lightbox__nav--prev"
1903
+ };
1904
+ const _hoisted_5 = {
1905
+ class: "astryx-lightbox__media",
1906
+ "data-lightbox-media": ""
1907
+ };
1908
+ const _hoisted_6 = ["data-zoomable", "data-zoomed"];
1909
+ const _hoisted_7 = ["data-zoom-target", "data-dismiss-target"];
1910
+ const _hoisted_8 = [
1911
+ "data-lightbox-page",
1912
+ "data-current",
1913
+ "inert"
1914
+ ];
1915
+ const _hoisted_9 = [
1916
+ "data-zoomable",
1917
+ "role",
1918
+ "tabindex",
1919
+ "aria-pressed",
1920
+ "aria-label",
1921
+ "onKeydown"
1922
+ ];
1923
+ const _hoisted_10 = [
1924
+ "src",
1925
+ "aria-label",
1926
+ "autoplay"
1927
+ ];
1928
+ const _hoisted_11 = ["src", "alt"];
1929
+ const _hoisted_12 = {
1930
+ class: "astryx-lightbox__chrome",
1931
+ "data-lightbox-chrome": ""
1932
+ };
1933
+ const _hoisted_13 = {
1934
+ key: 0,
1935
+ class: "astryx-lightbox__control astryx-lightbox__nav astryx-lightbox__nav--next"
1936
+ };
1937
+ const _hoisted_14 = {
1938
+ key: 1,
1939
+ class: "astryx-lightbox__counter"
1940
+ };
1941
+ const _hoisted_15 = {
1942
+ ref: "liveRegion",
1943
+ class: "astryx-lightbox__announcer astryx-visually-hidden",
1944
+ "aria-live": "polite",
1945
+ "aria-atomic": "true"
1946
+ };
1947
+ const KEYBOARD_PAN_STEP = 50;
1948
+ const _sfc_main = /*@__PURE__*/ defineComponent({
1949
+ name: "AstryxLightbox",
1950
+ inheritAttrs: false,
1951
+ __name: "Lightbox",
1952
+ props: {
1953
+ isOpen: { type: Boolean },
1954
+ media: {},
1955
+ index: {},
1956
+ defaultIndex: { default: 0 },
1957
+ hasZoom: {
1958
+ type: Boolean,
1959
+ default: false
1960
+ },
1961
+ hasAutoPlay: {
1962
+ type: Boolean,
1963
+ default: false
1964
+ }
1965
+ },
1966
+ emits: ["update:isOpen", "update:index"],
1967
+ setup(__props, { emit: __emit }) {
1968
+ const props = __props;
1969
+ const emit = __emit;
1970
+ const messages = useComponentMessages({ lightbox: lightboxMessages });
1971
+ const liveRegionRef = useTemplateRef("liveRegion");
1972
+ const announce = createModalAnnouncer(() => liveRegionRef.value);
1973
+ resetLayerScopedContext();
1974
+ const dialogRef = useTemplateRef("dialog");
1975
+ const containerRef = useTemplateRef("container");
1976
+ const viewportRef = useTemplateRef("viewport");
1977
+ const trackRef = useTemplateRef("track");
1978
+ const closeRef = useTemplateRef("close");
1979
+ const captionId = `astryx-lightbox-caption-${useId()}`;
1980
+ useScrollLock(toRef(props, "isOpen"));
1981
+ const isTouch = useCoarsePointer();
1982
+ const mediaList = computed(() => Array.isArray(props.media) ? props.media : [props.media]);
1983
+ const isGallery = computed(() => Array.isArray(props.media) && mediaList.value.length > 1);
1984
+ const internalIndex = ref(props.defaultIndex);
1985
+ const index = computed(() => {
1986
+ const last = Math.max(0, mediaList.value.length - 1);
1987
+ return Math.min(Math.max(0, toWholeIndex(props.index ?? internalIndex.value)), last);
1988
+ });
1989
+ const current = computed(() => mediaList.value[index.value]);
1990
+ const isVideo = computed(() => current.value?.type === "video");
1991
+ const hasCaptionBand = computed(() => isGallery.value || Boolean(current.value?.caption));
1992
+ const canPrev = computed(() => index.value > 0);
1993
+ const canNext = computed(() => index.value < mediaList.value.length - 1);
1994
+ const pageIndexes = computed(() => [
1995
+ index.value - 1,
1996
+ index.value,
1997
+ index.value + 1
1998
+ ].filter((i) => i >= 0 && i < mediaList.value.length));
1999
+ const isZoomTarget = computed(() => props.hasZoom && !isVideo.value);
2000
+ const isZoomed = ref(false);
2001
+ let pointerType = "";
2002
+ let pressPoint = null;
2003
+ let didDrag = false;
2004
+ let focusRecord = null;
2005
+ function close() {
2006
+ emit("update:isOpen", false);
2007
+ }
2008
+ function setIndex(next) {
2009
+ const last = Math.max(0, mediaList.value.length - 1);
2010
+ const clamped = Math.min(Math.max(0, toWholeIndex(next)), last);
2011
+ internalIndex.value = clamped;
2012
+ emit("update:index", clamped);
2013
+ }
2014
+ const { zoom } = useLightboxStage({
2015
+ dialog: () => dialogRef.value,
2016
+ container: () => containerRef.value,
2017
+ viewport: () => viewportRef.value,
2018
+ track: () => trackRef.value,
2019
+ stage: () => trackRef.value?.querySelector("[data-current] > [data-lightbox-page-media]") ?? null,
2020
+ captionBand: () => trackRef.value?.querySelector("[data-current] > .astryx-lightbox__caption-band") ?? null,
2021
+ isOpen: () => props.isOpen,
2022
+ isZoomTarget: () => isZoomTarget.value,
2023
+ isVideo: () => isVideo.value,
2024
+ isGallery: () => isGallery.value,
2025
+ isTouch: () => isTouch.value,
2026
+ index: () => index.value,
2027
+ count: () => mediaList.value.length,
2028
+ itemKey: () => current.value,
2029
+ close,
2030
+ onSwipe: setIndex,
2031
+ onZoomedChange: (next) => {
2032
+ isZoomed.value = next;
2033
+ announce(next ? messages.value.lightbox.zoomedIn : messages.value.lightbox.zoomedOut);
2034
+ },
2035
+ onDragStart: () => {
2036
+ didDrag = true;
2037
+ }
2038
+ });
2039
+ function onCancel(event) {
2040
+ if (event.target !== event.currentTarget) return;
2041
+ event.preventDefault();
2042
+ close();
2043
+ }
2044
+ function onContainerPointerDown(event) {
2045
+ pointerType = event.pointerType;
2046
+ pressPoint = {
2047
+ x: event.clientX,
2048
+ y: event.clientY
2049
+ };
2050
+ const isOnStage = event.target instanceof Node && viewportRef.value?.contains(event.target) === true;
2051
+ if (event.pointerType !== "touch" || isOnStage) didDrag = false;
2052
+ }
2053
+ function onBackdropClick(event) {
2054
+ if (didDrag) {
2055
+ didDrag = false;
2056
+ return;
2057
+ }
2058
+ const target = event.target;
2059
+ const isMediaClose = pointerType !== "touch" && isClickOutsideMedia(event, {
2060
+ viewport: viewportRef.value,
2061
+ page: trackRef.value?.querySelector("[data-current]") ?? null,
2062
+ pressPoint
2063
+ });
2064
+ if (target === event.currentTarget || target === containerRef.value || isMediaClose) close();
2065
+ }
2066
+ /** 放大时每按一次方向键平移的距离(px)。按右键露出右边的内容,所以照片本身往左移。 */
2067
+ const KEYBOARD_PAN_OFFSETS = {
2068
+ ArrowDown: [0, -50],
2069
+ ArrowLeft: [KEYBOARD_PAN_STEP, 0],
2070
+ ArrowRight: [-50, 0],
2071
+ ArrowUp: [0, KEYBOARD_PAN_STEP]
2072
+ };
2073
+ function onKeyDown(event) {
2074
+ if (isZoomTarget.value) {
2075
+ if (event.key === "+" || event.key === "=") {
2076
+ event.preventDefault();
2077
+ zoom.zoomIn();
2078
+ return;
2079
+ }
2080
+ if (event.key === "-" || event.key === "_" || event.key === "0" && !event.ctrlKey && !event.metaKey && !event.altKey) {
2081
+ event.preventDefault();
2082
+ zoom.zoomOut();
2083
+ return;
2084
+ }
2085
+ const offset = zoom.isZoomed() ? KEYBOARD_PAN_OFFSETS[event.key] : void 0;
2086
+ if (offset != null) {
2087
+ event.preventDefault();
2088
+ zoom.panBy(offset[0], offset[1]);
2089
+ return;
2090
+ }
2091
+ }
2092
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
2093
+ const towardEnd = event.key === "ArrowRight" !== isRtlElement(dialogRef.value);
2094
+ if (towardEnd && canNext.value) {
2095
+ event.preventDefault();
2096
+ setIndex(index.value + 1);
2097
+ } else if (!towardEnd && canPrev.value) {
2098
+ event.preventDefault();
2099
+ setIndex(index.value - 1);
2100
+ }
2101
+ }
2102
+ function onStageKeyDown(event) {
2103
+ if (event.target !== event.currentTarget) return;
2104
+ if (event.key === "Enter" || event.key === " ") {
2105
+ event.preventDefault();
2106
+ zoom.toggle();
2107
+ }
2108
+ }
2109
+ function onViewportDblclick(event) {
2110
+ if (isZoomTarget.value && pointerType !== "touch") zoom.doubleClickAt(event.clientX, event.clientY);
2111
+ }
2112
+ useFocusTrap({
2113
+ container: dialogRef,
2114
+ isEnabled: () => props.isOpen && current.value != null
2115
+ });
2116
+ function pauseVideos() {
2117
+ for (const video of dialogRef.value?.querySelectorAll("video") ?? []) if (!video.paused) video.pause();
2118
+ }
2119
+ watch([() => props.isOpen, () => current.value != null], ([open]) => {
2120
+ const dialog = dialogRef.value;
2121
+ if (dialog == null) return;
2122
+ if (open && !dialog.open) {
2123
+ focusRecord?.stop();
2124
+ focusRecord = trackLayerFocus({ getLayer: () => dialogRef.value });
2125
+ dialog.showModal();
2126
+ const video = dialog.querySelector("[data-current] video");
2127
+ if (props.hasAutoPlay && video != null && video.paused) video.play()?.catch(() => {});
2128
+ } else if (!open && dialog.open) {
2129
+ const record = focusRecord;
2130
+ focusRecord = null;
2131
+ const wasStranded = record != null && isLayerFocusStranded(record, dialog);
2132
+ pauseVideos();
2133
+ dialog.close();
2134
+ zoom.zoomOut();
2135
+ if (record != null) {
2136
+ if (wasStranded) restoreLayerFocus(record, {
2137
+ layer: dialog,
2138
+ name: "Lightbox"
2139
+ });
2140
+ record.stop();
2141
+ }
2142
+ }
2143
+ }, { flush: "post" });
2144
+ /**
2145
+ * 翻页让原来的当前页变成 inert,里面的焦点(图注的「更多」「收起」、照片盒子)会掉到 body。
2146
+ * 这时把焦点交给新一页的照片(能缩放时),否则交给关闭按钮,方向键还能接着翻页。
2147
+ */
2148
+ watch(index, () => {
2149
+ const active = document.activeElement;
2150
+ const page = trackRef.value?.querySelector("[data-current]");
2151
+ if (active instanceof HTMLElement && page?.contains(active) === true) nextTick(() => {
2152
+ const stage = trackRef.value?.querySelector("[data-current] > [data-lightbox-page-media]");
2153
+ (isZoomTarget.value ? stage : closeRef.value?.element)?.focus();
2154
+ });
2155
+ }, { flush: "pre" });
2156
+ watch(index, () => {
2157
+ pauseVideos();
2158
+ if (!props.isOpen) return;
2159
+ const item = current.value;
2160
+ if (item == null || mediaList.value.length < 2) return;
2161
+ const position = {
2162
+ index: index.value + 1,
2163
+ total: mediaList.value.length
2164
+ };
2165
+ announce(item.alt ? messages.value.lightbox.mediaPosition(item.alt, position.index, position.total) : messages.value.lightbox.imagePosition(position.index, position.total));
2166
+ });
2167
+ onBeforeUnmount(() => {
2168
+ const record = focusRecord;
2169
+ focusRecord = null;
2170
+ if (record == null) return;
2171
+ const wasStranded = dialogRef.value?.open === true && isLayerFocusStranded(record, dialogRef.value);
2172
+ queueMicrotask(() => {
2173
+ if (wasStranded) restoreLayerFocus(record, {
2174
+ layer: null,
2175
+ name: "Lightbox"
2176
+ });
2177
+ record.stop();
2178
+ });
2179
+ });
2180
+ function pageStyle(i) {
2181
+ return { insetInlineStart: `calc(${i} * (100% + ${zoomMedia.viewer.pageGap}px))` };
2182
+ }
2183
+ return (_ctx, _cache) => {
2184
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 点在 dialog 自身上等于点遮罩;键盘走 Escape 和方向键。 "), current.value ? (openBlock(), createElementBlock("dialog", {
2185
+ key: 0,
2186
+ ref: "dialog",
2187
+ class: normalizeClass(["astryx-lightbox astryx-layer", _ctx.$attrs.class]),
2188
+ style: normalizeStyle(_ctx.$attrs.style),
2189
+ "aria-label": current.value.alt || unref(messages).lightbox.mediaViewer,
2190
+ "aria-describedby": current.value.caption ? captionId : void 0,
2191
+ "data-gallery": isGallery.value || void 0,
2192
+ "data-caption-band": hasCaptionBand.value || void 0,
2193
+ "data-has-zoom": __props.hasZoom || void 0,
2194
+ "data-component": "lightbox",
2195
+ onCancel,
2196
+ onClick: onBackdropClick,
2197
+ onKeydown: onKeyDown
2198
+ }, [createElementVNode("div", {
2199
+ ref: "container",
2200
+ class: "astryx-lightbox__container",
2201
+ onPointerdown: onContainerPointerDown
2202
+ }, [
2203
+ createElementVNode("div", _hoisted_2, [createElementVNode("span", _hoisted_3, [createVNode(_sfc_main$3, {
2204
+ ref: "close",
2205
+ variant: "ghost",
2206
+ size: "sm",
2207
+ label: unref(messages).lightbox.close,
2208
+ onClick: close
2209
+ }, {
2210
+ default: withCtx(() => [createVNode(_sfc_main$2, {
2211
+ icon: "close",
2212
+ size: "sm"
2213
+ })]),
2214
+ _: 1
2215
+ }, 8, ["label"])]), isGallery.value ? (openBlock(), createElementBlock("span", _hoisted_4, [createVNode(_sfc_main$3, {
2216
+ variant: "ghost",
2217
+ size: "sm",
2218
+ label: unref(messages).lightbox.previous,
2219
+ "is-disabled": !canPrev.value,
2220
+ onClick: _cache[0] || (_cache[0] = ($event) => setIndex(index.value - 1))
2221
+ }, {
2222
+ default: withCtx(() => [createVNode(_sfc_main$2, {
2223
+ icon: "chevronLeft",
2224
+ size: "sm"
2225
+ })]),
2226
+ _: 1
2227
+ }, 8, ["label", "is-disabled"])])) : createCommentVNode("v-if", true)]),
2228
+ createElementVNode("div", _hoisted_5, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 舞台上的指针悬停和鼠标双击;键盘走照片盒子的 Enter / Space 和方向键。 "), createElementVNode("div", {
2229
+ ref: "viewport",
2230
+ class: "astryx-lightbox__viewport",
2231
+ "data-zoomable": isZoomTarget.value && !isZoomed.value || void 0,
2232
+ "data-zoomed": isZoomTarget.value && isZoomed.value || void 0,
2233
+ onPointermove: _cache[1] || (_cache[1] = ($event) => isZoomTarget.value ? unref(markPointerOverPhoto)($event) : void 0),
2234
+ onPointerleave: _cache[2] || (_cache[2] = ($event) => viewportRef.value?.removeAttribute(unref("data-lightbox-over-photo"))),
2235
+ onDblclick: onViewportDblclick
2236
+ }, [createElementVNode("div", {
2237
+ ref: "track",
2238
+ class: "astryx-lightbox__track",
2239
+ "data-zoom-target": isZoomTarget.value || void 0,
2240
+ "data-dismiss-target": unref(isTouch) && !isZoomTarget.value && !isVideo.value || void 0
2241
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(pageIndexes.value, (i) => {
2242
+ return openBlock(), createElementBlock("div", {
2243
+ key: i,
2244
+ class: "astryx-lightbox__page",
2245
+ "data-lightbox-page": i,
2246
+ "data-current": i === index.value ? "" : void 0,
2247
+ inert: i !== index.value || void 0,
2248
+ style: normalizeStyle(pageStyle(i))
2249
+ }, [
2250
+ createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 能缩放时当前页的照片盒子是缩放按钮,role 和 tabindex 从脚本绑上。 "),
2251
+ createElementVNode("div", {
2252
+ class: "astryx-lightbox__frame",
2253
+ "data-lightbox-page-media": "",
2254
+ "data-zoomable": isZoomTarget.value && i === index.value || void 0,
2255
+ role: isZoomTarget.value && i === index.value ? "button" : void 0,
2256
+ tabindex: isZoomTarget.value && i === index.value ? 0 : void 0,
2257
+ "aria-pressed": isZoomTarget.value && i === index.value ? isZoomed.value : void 0,
2258
+ "aria-label": isZoomTarget.value && i === index.value ? unref(messages).lightbox.zoom : void 0,
2259
+ onKeydown: ($event) => isZoomTarget.value && i === index.value ? onStageKeyDown($event) : void 0
2260
+ }, [createCommentVNode(" eslint-disable-next-line vue-a11y/media-has-caption -- 说明文字在灯箱 caption 里;媒体文件本身不带字幕轨。 "), mediaList.value[i].type === "video" ? (openBlock(), createElementBlock("video", {
2261
+ key: 0,
2262
+ class: "astryx-lightbox__video",
2263
+ src: mediaList.value[i].src,
2264
+ "aria-label": mediaList.value[i].alt,
2265
+ controls: "",
2266
+ autoplay: __props.hasAutoPlay && __props.isOpen && i === index.value
2267
+ }, null, 8, _hoisted_10)) : (openBlock(), createElementBlock("img", {
2268
+ key: 1,
2269
+ ref_for: true,
2270
+ ref: i === index.value ? unref(zoom).contentRef : void 0,
2271
+ class: "astryx-lightbox__image",
2272
+ src: mediaList.value[i].src,
2273
+ alt: i === index.value ? mediaList.value[i].alt : "",
2274
+ draggable: "false"
2275
+ }, null, 8, _hoisted_11))], 40, _hoisted_9),
2276
+ createCommentVNode(" 换成当前页时重新挂载:翻页合上展开的图注。 "),
2277
+ hasCaptionBand.value ? (openBlock(), createBlock(_sfc_main$1, {
2278
+ id: i === index.value ? captionId : `${captionId}-${i}`,
2279
+ key: i === index.value ? "current" : "neighbour",
2280
+ text: mediaList.value[i].caption
2281
+ }, null, 8, ["id", "text"])) : createCommentVNode("v-if", true)
2282
+ ], 12, _hoisted_8);
2283
+ }), 128))], 8, _hoisted_7)], 40, _hoisted_6)]),
2284
+ createElementVNode("div", _hoisted_12, [isGallery.value ? (openBlock(), createElementBlock("span", _hoisted_13, [createVNode(_sfc_main$3, {
2285
+ variant: "ghost",
2286
+ size: "sm",
2287
+ label: unref(messages).lightbox.next,
2288
+ "is-disabled": !canNext.value,
2289
+ onClick: _cache[3] || (_cache[3] = ($event) => setIndex(index.value + 1))
2290
+ }, {
2291
+ default: withCtx(() => [createVNode(_sfc_main$2, {
2292
+ icon: "chevronRight",
2293
+ size: "sm"
2294
+ })]),
2295
+ _: 1
2296
+ }, 8, ["label", "is-disabled"])])) : createCommentVNode("v-if", true), isGallery.value ? (openBlock(), createElementBlock("p", _hoisted_14, toDisplayString(index.value + 1) + " / " + toDisplayString(mediaList.value.length), 1)) : createCommentVNode("v-if", true)])
2297
+ ], 544), createElementVNode("div", _hoisted_15, null, 512)], 46, _hoisted_1)) : createCommentVNode("v-if", true)], 2112);
2298
+ };
2299
+ }
2300
+ });
2301
+ //#endregion
2302
+ //#region src/Lightbox/useLightbox.ts
2303
+ /**
2304
+ * Owns the open state and gallery index for a `Lightbox`.
2305
+ * Bind `bindings` onto `Lightbox`, and call `open(index)` from a thumbnail.
2306
+ */
2307
+ function useLightbox(options) {
2308
+ const isOpen = ref(false);
2309
+ const index = ref(0);
2310
+ function open(next = 0) {
2311
+ index.value = next;
2312
+ isOpen.value = true;
2313
+ }
2314
+ function close() {
2315
+ isOpen.value = false;
2316
+ }
2317
+ function triggerPropsFor(next) {
2318
+ return {
2319
+ "aria-haspopup": "dialog",
2320
+ "onClick": () => open(next),
2321
+ "onKeydown": (event) => {
2322
+ if (event.key !== "Enter" && event.key !== " ") return;
2323
+ event.preventDefault();
2324
+ open(next);
2325
+ },
2326
+ "role": "button",
2327
+ "tabindex": 0
2328
+ };
2329
+ }
2330
+ return {
2331
+ bindings: computed(() => ({
2332
+ "hasAutoPlay": options.hasAutoPlay,
2333
+ "hasZoom": options.hasZoom,
2334
+ "index": index.value,
2335
+ "isOpen": isOpen.value,
2336
+ "media": options.media,
2337
+ "onUpdate:index": (next) => {
2338
+ index.value = next;
2339
+ },
2340
+ "onUpdate:isOpen": (next) => {
2341
+ isOpen.value = next;
2342
+ }
2343
+ })),
2344
+ close,
2345
+ getTriggerProps: triggerPropsFor,
2346
+ index,
2347
+ isOpen,
2348
+ open,
2349
+ triggerProps: computed(() => triggerPropsFor(0))
2350
+ };
2351
+ }
2352
+ //#endregion
2353
+ export { _sfc_main as n, useLightbox as t };