@getcortexlabs/mavis 0.1.0-alpha.3 → 0.1.0-alpha.4

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 (370) hide show
  1. package/README.md +7 -5
  2. package/dist/native/avatar-image.d.ts +4 -0
  3. package/dist/native/avatar-image.d.ts.map +1 -0
  4. package/dist/native/avatar-image.js +12 -0
  5. package/dist/native/avatar-image.js.map +1 -0
  6. package/dist/native/avatar-label.android.d.ts +9 -0
  7. package/dist/native/avatar-label.android.d.ts.map +1 -0
  8. package/dist/native/avatar-label.android.js +9 -0
  9. package/dist/native/avatar-label.android.js.map +1 -0
  10. package/dist/native/avatar-label.d.ts +2 -0
  11. package/dist/native/avatar-label.d.ts.map +1 -0
  12. package/dist/native/avatar-label.js +2 -0
  13. package/dist/native/avatar-label.js.map +1 -0
  14. package/dist/native/box.ios.d.ts.map +1 -1
  15. package/dist/native/box.ios.js +16 -1
  16. package/dist/native/box.ios.js.map +1 -1
  17. package/dist/native/button.ios.d.ts +9 -1
  18. package/dist/native/button.ios.d.ts.map +1 -1
  19. package/dist/native/button.ios.js +17 -1
  20. package/dist/native/button.ios.js.map +1 -1
  21. package/dist/native/checkbox.android.d.ts +7 -0
  22. package/dist/native/checkbox.android.d.ts.map +1 -0
  23. package/dist/native/checkbox.android.js +26 -0
  24. package/dist/native/checkbox.android.js.map +1 -0
  25. package/dist/native/checkbox.d.ts +7 -0
  26. package/dist/native/checkbox.d.ts.map +1 -0
  27. package/dist/native/checkbox.js +7 -0
  28. package/dist/native/checkbox.js.map +1 -0
  29. package/dist/native/composed-button.android.d.ts +4 -0
  30. package/dist/native/composed-button.android.d.ts.map +1 -0
  31. package/dist/native/composed-button.android.js +53 -0
  32. package/dist/native/composed-button.android.js.map +1 -0
  33. package/dist/native/composed-button.d.ts +3 -0
  34. package/dist/native/composed-button.d.ts.map +1 -0
  35. package/dist/native/composed-button.js +4 -0
  36. package/dist/native/composed-button.js.map +1 -0
  37. package/dist/native/dialog.android.d.ts +12 -0
  38. package/dist/native/dialog.android.d.ts.map +1 -0
  39. package/dist/native/dialog.android.js +46 -0
  40. package/dist/native/dialog.android.js.map +1 -0
  41. package/dist/native/dialog.d.ts +12 -0
  42. package/dist/native/dialog.d.ts.map +1 -0
  43. package/dist/native/dialog.ios.d.ts +12 -0
  44. package/dist/native/dialog.ios.d.ts.map +1 -0
  45. package/dist/native/dialog.ios.js +13 -0
  46. package/dist/native/dialog.ios.js.map +1 -0
  47. package/dist/native/dialog.js +4 -0
  48. package/dist/native/dialog.js.map +1 -0
  49. package/dist/native/dynamic-type.d.ts +15 -0
  50. package/dist/native/dynamic-type.d.ts.map +1 -0
  51. package/dist/native/dynamic-type.js +47 -0
  52. package/dist/native/dynamic-type.js.map +1 -0
  53. package/dist/native/flex-layout.ios.d.ts +5 -0
  54. package/dist/native/flex-layout.ios.d.ts.map +1 -1
  55. package/dist/native/flex-layout.ios.js +63 -2
  56. package/dist/native/flex-layout.ios.js.map +1 -1
  57. package/dist/native/input-action.d.ts +5 -0
  58. package/dist/native/input-action.d.ts.map +1 -0
  59. package/dist/native/input-action.js +13 -0
  60. package/dist/native/input-action.js.map +1 -0
  61. package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -1
  62. package/dist/native/keyboard-dismiss.ios.js +3 -0
  63. package/dist/native/keyboard-dismiss.ios.js.map +1 -1
  64. package/dist/native/label.android.d.ts +12 -0
  65. package/dist/native/label.android.d.ts.map +1 -0
  66. package/dist/native/label.android.js +19 -0
  67. package/dist/native/label.android.js.map +1 -0
  68. package/dist/native/label.ios.d.ts +10 -1
  69. package/dist/native/label.ios.d.ts.map +1 -1
  70. package/dist/native/label.ios.js +25 -1
  71. package/dist/native/label.ios.js.map +1 -1
  72. package/dist/native/motion-surface.d.ts +9 -0
  73. package/dist/native/motion-surface.d.ts.map +1 -0
  74. package/dist/native/motion-surface.js +119 -0
  75. package/dist/native/motion-surface.js.map +1 -0
  76. package/dist/native/press.d.ts +5 -2
  77. package/dist/native/press.d.ts.map +1 -1
  78. package/dist/native/press.js +52 -8
  79. package/dist/native/press.js.map +1 -1
  80. package/dist/native/progress.d.ts +7 -0
  81. package/dist/native/progress.d.ts.map +1 -0
  82. package/dist/native/progress.js +77 -0
  83. package/dist/native/progress.js.map +1 -0
  84. package/dist/native/scroll-motion.d.ts +11 -0
  85. package/dist/native/scroll-motion.d.ts.map +1 -0
  86. package/dist/native/scroll-motion.js +94 -0
  87. package/dist/native/scroll-motion.js.map +1 -0
  88. package/dist/native/segmented.d.ts +14 -0
  89. package/dist/native/segmented.d.ts.map +1 -0
  90. package/dist/native/segmented.js +86 -0
  91. package/dist/native/segmented.js.map +1 -0
  92. package/dist/native/sheet.android.d.ts +5 -1
  93. package/dist/native/sheet.android.d.ts.map +1 -1
  94. package/dist/native/sheet.android.js +2 -2
  95. package/dist/native/sheet.android.js.map +1 -1
  96. package/dist/native/sheet.d.ts +5 -1
  97. package/dist/native/sheet.d.ts.map +1 -1
  98. package/dist/native/sheet.ios.d.ts +5 -1
  99. package/dist/native/sheet.ios.d.ts.map +1 -1
  100. package/dist/native/sheet.ios.js +12 -3
  101. package/dist/native/sheet.ios.js.map +1 -1
  102. package/dist/native/sheet.js +2 -2
  103. package/dist/native/sheet.js.map +1 -1
  104. package/dist/native/tabs.android.d.ts +3 -0
  105. package/dist/native/tabs.android.d.ts.map +1 -0
  106. package/dist/native/tabs.android.js +29 -0
  107. package/dist/native/tabs.android.js.map +1 -0
  108. package/dist/native/tabs.d.ts +3 -0
  109. package/dist/native/tabs.d.ts.map +1 -0
  110. package/dist/native/tabs.js +4 -0
  111. package/dist/native/tabs.js.map +1 -0
  112. package/dist/native/text-field.android.d.ts +1 -0
  113. package/dist/native/text-field.android.d.ts.map +1 -1
  114. package/dist/native/text-field.android.js +13 -0
  115. package/dist/native/text-field.android.js.map +1 -1
  116. package/dist/native/text-field.ios.d.ts +9 -0
  117. package/dist/native/text-field.ios.d.ts.map +1 -0
  118. package/dist/native/text-field.ios.js +52 -0
  119. package/dist/native/text-field.ios.js.map +1 -0
  120. package/dist/native/text-view.ios.d.ts +7 -0
  121. package/dist/native/text-view.ios.d.ts.map +1 -0
  122. package/dist/native/text-view.ios.js +10 -0
  123. package/dist/native/text-view.ios.js.map +1 -0
  124. package/dist/native/toast.android.d.ts +4 -0
  125. package/dist/native/toast.android.d.ts.map +1 -0
  126. package/dist/native/toast.android.js +10 -0
  127. package/dist/native/toast.android.js.map +1 -0
  128. package/dist/native/toast.d.ts +4 -0
  129. package/dist/native/toast.d.ts.map +1 -0
  130. package/dist/native/toast.ios.d.ts +4 -0
  131. package/dist/native/toast.ios.d.ts.map +1 -0
  132. package/dist/native/toast.ios.js +8 -0
  133. package/dist/native/toast.ios.js.map +1 -0
  134. package/dist/native/toast.js +5 -0
  135. package/dist/native/toast.js.map +1 -0
  136. package/dist/vue/components/ChoiceControl.d.ts +101 -0
  137. package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
  138. package/dist/vue/components/ChoiceControl.js +196 -0
  139. package/dist/vue/components/ChoiceControl.js.map +1 -0
  140. package/dist/vue/components/MAccordion.d.ts +109 -0
  141. package/dist/vue/components/MAccordion.d.ts.map +1 -0
  142. package/dist/vue/components/MAccordion.js +83 -0
  143. package/dist/vue/components/MAccordion.js.map +1 -0
  144. package/dist/vue/components/MAlert.d.ts +99 -0
  145. package/dist/vue/components/MAlert.d.ts.map +1 -0
  146. package/dist/vue/components/MAlert.js +126 -0
  147. package/dist/vue/components/MAlert.js.map +1 -0
  148. package/dist/vue/components/MAvatar.d.ts +74 -0
  149. package/dist/vue/components/MAvatar.d.ts.map +1 -0
  150. package/dist/vue/components/MAvatar.js +86 -0
  151. package/dist/vue/components/MAvatar.js.map +1 -0
  152. package/dist/vue/components/MBadge.d.ts +64 -0
  153. package/dist/vue/components/MBadge.d.ts.map +1 -0
  154. package/dist/vue/components/MBadge.js +30 -0
  155. package/dist/vue/components/MBadge.js.map +1 -0
  156. package/dist/vue/components/MButton.d.ts +57 -5
  157. package/dist/vue/components/MButton.d.ts.map +1 -1
  158. package/dist/vue/components/MButton.js +129 -11
  159. package/dist/vue/components/MButton.js.map +1 -1
  160. package/dist/vue/components/MCard.d.ts +25 -7
  161. package/dist/vue/components/MCard.d.ts.map +1 -1
  162. package/dist/vue/components/MCard.js +14 -4
  163. package/dist/vue/components/MCard.js.map +1 -1
  164. package/dist/vue/components/MCheckbox.d.ts +93 -0
  165. package/dist/vue/components/MCheckbox.d.ts.map +1 -0
  166. package/dist/vue/components/MCheckbox.js +26 -0
  167. package/dist/vue/components/MCheckbox.js.map +1 -0
  168. package/dist/vue/components/MChip.d.ts +107 -0
  169. package/dist/vue/components/MChip.d.ts.map +1 -0
  170. package/dist/vue/components/MChip.js +120 -0
  171. package/dist/vue/components/MChip.js.map +1 -0
  172. package/dist/vue/components/MDialog.d.ts +95 -0
  173. package/dist/vue/components/MDialog.d.ts.map +1 -0
  174. package/dist/vue/components/MDialog.js +245 -0
  175. package/dist/vue/components/MDialog.js.map +1 -0
  176. package/dist/vue/components/MEmptyState.d.ts +107 -0
  177. package/dist/vue/components/MEmptyState.d.ts.map +1 -0
  178. package/dist/vue/components/MEmptyState.js +79 -0
  179. package/dist/vue/components/MEmptyState.js.map +1 -0
  180. package/dist/vue/components/MInput.d.ts +63 -8
  181. package/dist/vue/components/MInput.d.ts.map +1 -1
  182. package/dist/vue/components/MInput.js +88 -14
  183. package/dist/vue/components/MInput.js.map +1 -1
  184. package/dist/vue/components/MListItem.d.ts +92 -0
  185. package/dist/vue/components/MListItem.d.ts.map +1 -0
  186. package/dist/vue/components/MListItem.js +53 -0
  187. package/dist/vue/components/MListItem.js.map +1 -0
  188. package/dist/vue/components/MProgress.d.ts +112 -0
  189. package/dist/vue/components/MProgress.d.ts.map +1 -0
  190. package/dist/vue/components/MProgress.js +75 -0
  191. package/dist/vue/components/MProgress.js.map +1 -0
  192. package/dist/vue/components/MRadioGroup.d.ts +93 -0
  193. package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
  194. package/dist/vue/components/MRadioGroup.js +57 -0
  195. package/dist/vue/components/MRadioGroup.js.map +1 -0
  196. package/dist/vue/components/MReveal.d.ts +2 -2
  197. package/dist/vue/components/MReveal.d.ts.map +1 -1
  198. package/dist/vue/components/MReveal.js +5 -7
  199. package/dist/vue/components/MReveal.js.map +1 -1
  200. package/dist/vue/components/MScreen.d.ts +9 -0
  201. package/dist/vue/components/MScreen.d.ts.map +1 -1
  202. package/dist/vue/components/MScreen.js +19 -4
  203. package/dist/vue/components/MScreen.js.map +1 -1
  204. package/dist/vue/components/MSegmentedControl.d.ts +85 -0
  205. package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
  206. package/dist/vue/components/MSegmentedControl.js +172 -0
  207. package/dist/vue/components/MSegmentedControl.js.map +1 -0
  208. package/dist/vue/components/MSelect.d.ts +130 -0
  209. package/dist/vue/components/MSelect.d.ts.map +1 -0
  210. package/dist/vue/components/MSelect.js +158 -0
  211. package/dist/vue/components/MSelect.js.map +1 -0
  212. package/dist/vue/components/MSeparator.d.ts +54 -0
  213. package/dist/vue/components/MSeparator.d.ts.map +1 -0
  214. package/dist/vue/components/MSeparator.js +36 -0
  215. package/dist/vue/components/MSeparator.js.map +1 -0
  216. package/dist/vue/components/MSheet.d.ts +10 -4
  217. package/dist/vue/components/MSheet.d.ts.map +1 -1
  218. package/dist/vue/components/MSheet.js +66 -34
  219. package/dist/vue/components/MSheet.js.map +1 -1
  220. package/dist/vue/components/MSkeleton.d.ts +70 -0
  221. package/dist/vue/components/MSkeleton.d.ts.map +1 -0
  222. package/dist/vue/components/MSkeleton.js +87 -0
  223. package/dist/vue/components/MSkeleton.js.map +1 -0
  224. package/dist/vue/components/MSlider.d.ts +1 -1
  225. package/dist/vue/components/MSlider.d.ts.map +1 -1
  226. package/dist/vue/components/MSlider.js +2 -1
  227. package/dist/vue/components/MSlider.js.map +1 -1
  228. package/dist/vue/components/MSwitch.d.ts +79 -0
  229. package/dist/vue/components/MSwitch.d.ts.map +1 -0
  230. package/dist/vue/components/MSwitch.js +163 -0
  231. package/dist/vue/components/MSwitch.js.map +1 -0
  232. package/dist/vue/components/MTabs.d.ts +91 -0
  233. package/dist/vue/components/MTabs.d.ts.map +1 -0
  234. package/dist/vue/components/MTabs.js +245 -0
  235. package/dist/vue/components/MTabs.js.map +1 -0
  236. package/dist/vue/components/MText.d.ts +17 -8
  237. package/dist/vue/components/MText.d.ts.map +1 -1
  238. package/dist/vue/components/MText.js +43 -17
  239. package/dist/vue/components/MText.js.map +1 -1
  240. package/dist/vue/components/MToast.d.ts +23 -0
  241. package/dist/vue/components/MToast.d.ts.map +1 -0
  242. package/dist/vue/components/MToast.js +242 -0
  243. package/dist/vue/components/MToast.js.map +1 -0
  244. package/dist/vue/components/layout.d.ts +6 -6
  245. package/dist/vue/index.d.ts +24 -3
  246. package/dist/vue/index.d.ts.map +1 -1
  247. package/dist/vue/index.js +43 -4
  248. package/dist/vue/index.js.map +1 -1
  249. package/dist/vue/layers.d.ts +2 -0
  250. package/dist/vue/layers.d.ts.map +1 -1
  251. package/dist/vue/layers.js.map +1 -1
  252. package/dist/vue/reveal-motion.d.ts +13 -0
  253. package/dist/vue/reveal-motion.d.ts.map +1 -0
  254. package/dist/vue/reveal-motion.js +55 -0
  255. package/dist/vue/reveal-motion.js.map +1 -0
  256. package/dist/vue/use-motion-surface.d.ts +8 -0
  257. package/dist/vue/use-motion-surface.d.ts.map +1 -0
  258. package/dist/vue/use-motion-surface.js +75 -0
  259. package/dist/vue/use-motion-surface.js.map +1 -0
  260. package/dist/vue/use-press.d.ts +1 -1
  261. package/dist/vue/use-press.d.ts.map +1 -1
  262. package/dist/vue/use-press.js +12 -4
  263. package/dist/vue/use-press.js.map +1 -1
  264. package/dist/vue/use-scroll-motion.d.ts +7 -0
  265. package/dist/vue/use-scroll-motion.d.ts.map +1 -0
  266. package/dist/vue/use-scroll-motion.js +30 -0
  267. package/dist/vue/use-scroll-motion.js.map +1 -0
  268. package/package.json +3 -3
  269. package/platforms/android/java/com/mavis/ui/Box.java +3 -1
  270. package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
  271. package/platforms/android/java/com/mavis/ui/FlexLayout.java +5 -1
  272. package/src/native/avatar-image.ts +9 -0
  273. package/src/native/avatar-label.android.ts +14 -0
  274. package/src/native/avatar-label.ts +1 -0
  275. package/src/native/box.ios.ts +21 -1
  276. package/src/native/button.ios.ts +40 -2
  277. package/src/native/checkbox.android.ts +35 -0
  278. package/src/native/checkbox.ts +9 -0
  279. package/src/native/composed-button.android.ts +74 -0
  280. package/src/native/composed-button.ts +9 -0
  281. package/src/native/dialog.android.ts +56 -0
  282. package/src/native/dialog.ios.ts +23 -0
  283. package/src/native/dialog.ts +10 -0
  284. package/src/native/dynamic-type.ts +71 -0
  285. package/src/native/flex-layout.ios.ts +74 -2
  286. package/src/native/input-action.ts +15 -0
  287. package/src/native/keyboard-dismiss.ios.ts +2 -0
  288. package/src/native/label.android.ts +27 -0
  289. package/src/native/label.ios.ts +40 -1
  290. package/src/native/motion-surface.ts +137 -0
  291. package/src/native/press.ts +52 -10
  292. package/src/native/progress.ts +78 -0
  293. package/src/native/scroll-motion.ts +101 -0
  294. package/src/native/segmented.ts +95 -0
  295. package/src/native/sheet.android.ts +2 -2
  296. package/src/native/sheet.ios.ts +12 -3
  297. package/src/native/sheet.ts +2 -2
  298. package/src/native/tabs.android.ts +58 -0
  299. package/src/native/tabs.ts +8 -0
  300. package/src/native/text-field.android.ts +19 -0
  301. package/src/native/text-field.ios.ts +53 -0
  302. package/src/native/text-view.ios.ts +10 -0
  303. package/src/native/toast.android.ts +9 -0
  304. package/src/native/toast.ios.ts +13 -0
  305. package/src/native/toast.ts +6 -0
  306. package/src/vue/components/ChoiceControl.ts +238 -0
  307. package/src/vue/components/MAccordion.ts +123 -0
  308. package/src/vue/components/MAlert.ts +156 -0
  309. package/src/vue/components/MAvatar.ts +103 -0
  310. package/src/vue/components/MBadge.ts +34 -0
  311. package/src/vue/components/MButton.ts +176 -9
  312. package/src/vue/components/MCard.ts +23 -3
  313. package/src/vue/components/MCheckbox.ts +25 -0
  314. package/src/vue/components/MChip.ts +134 -0
  315. package/src/vue/components/MDialog.ts +312 -0
  316. package/src/vue/components/MEmptyState.ts +96 -0
  317. package/src/vue/components/MInput.ts +96 -12
  318. package/src/vue/components/MListItem.ts +66 -0
  319. package/src/vue/components/MProgress.ts +94 -0
  320. package/src/vue/components/MRadioGroup.ts +64 -0
  321. package/src/vue/components/MReveal.ts +6 -7
  322. package/src/vue/components/MScreen.ts +21 -6
  323. package/src/vue/components/MSegmentedControl.ts +214 -0
  324. package/src/vue/components/MSelect.ts +185 -0
  325. package/src/vue/components/MSeparator.ts +40 -0
  326. package/src/vue/components/MSheet.ts +83 -43
  327. package/src/vue/components/MSkeleton.ts +100 -0
  328. package/src/vue/components/MSlider.ts +7 -1
  329. package/src/vue/components/MSwitch.ts +187 -0
  330. package/src/vue/components/MTabs.ts +302 -0
  331. package/src/vue/components/MText.ts +37 -6
  332. package/src/vue/components/MToast.ts +289 -0
  333. package/src/vue/index.ts +65 -2
  334. package/src/vue/layers.ts +2 -0
  335. package/src/vue/reveal-motion.ts +61 -0
  336. package/src/vue/use-motion-surface.ts +77 -0
  337. package/src/vue/use-press.ts +12 -4
  338. package/src/vue/use-scroll-motion.ts +31 -0
  339. package/dist/native/input-description.android.d.ts +0 -4
  340. package/dist/native/input-description.android.d.ts.map +0 -1
  341. package/dist/native/input-description.android.js +0 -18
  342. package/dist/native/input-description.android.js.map +0 -1
  343. package/dist/theme/resolve.d.ts +0 -3
  344. package/dist/theme/resolve.d.ts.map +0 -1
  345. package/dist/theme/resolve.js +0 -8
  346. package/dist/theme/resolve.js.map +0 -1
  347. package/dist/theme/themes.d.ts +0 -6
  348. package/dist/theme/themes.d.ts.map +0 -1
  349. package/dist/theme/themes.js +0 -83
  350. package/dist/theme/themes.js.map +0 -1
  351. package/dist/theme/types.d.ts +0 -50
  352. package/dist/theme/types.d.ts.map +0 -1
  353. package/dist/theme/types.js +0 -2
  354. package/dist/theme/types.js.map +0 -1
  355. package/dist/vue/global-components.d.ts +0 -21
  356. package/dist/vue/global-components.d.ts.map +0 -1
  357. package/dist/vue/global-components.js +0 -2
  358. package/dist/vue/global-components.js.map +0 -1
  359. package/dist/vue/layout-context.d.ts +0 -5
  360. package/dist/vue/layout-context.d.ts.map +0 -1
  361. package/dist/vue/layout-context.js +0 -7
  362. package/dist/vue/layout-context.js.map +0 -1
  363. package/dist/vue/text-content.d.ts +0 -4
  364. package/dist/vue/text-content.d.ts.map +0 -1
  365. package/dist/vue/text-content.js +0 -17
  366. package/dist/vue/text-content.js.map +0 -1
  367. package/dist/vue/theme.d.ts +0 -177
  368. package/dist/vue/theme.d.ts.map +0 -1
  369. package/dist/vue/theme.js +0 -17
  370. package/dist/vue/theme.js.map +0 -1
@@ -0,0 +1,71 @@
1
+ import { Font, type TextBase } from '@nativescript/core'
2
+ import type { TextVariant } from '@getcortexlabs/mavis-core'
3
+
4
+ interface Metrics {
5
+ scaledValueForValueCompatibleWithTraitCollection(value: number, traits: unknown): number
6
+ }
7
+ declare const UIApplication: { sharedApplication: { preferredContentSizeCategory: string } }
8
+ declare const UITraitCollection: {
9
+ traitCollectionWithPreferredContentSizeCategory(category: string): unknown
10
+ }
11
+ declare const UIFontMetrics: { metricsForTextStyle(style: string): Metrics }
12
+ declare const UIButton: unknown
13
+ declare const UIFontTextStyleLargeTitle: string
14
+ declare const UIFontTextStyleTitle1: string
15
+ declare const UIFontTextStyleTitle3: string
16
+ declare const UIFontTextStyleBody: string
17
+ declare const UIFontTextStyleFootnote: string
18
+ declare const UIFontTextStyleCaption2: string
19
+
20
+ export interface DynamicTypeView extends TextBase {
21
+ dynamicTypeStyle?: TextVariant
22
+ }
23
+ interface NativeText {
24
+ font: { pointSize: number }
25
+ titleLabel?: { font: { pointSize: number } }
26
+ }
27
+
28
+ // The iOS text style whose default size is closest to each Mavis variant.
29
+ const textStyle = (variant: TextVariant) =>
30
+ ({
31
+ display: UIFontTextStyleLargeTitle,
32
+ title: UIFontTextStyleTitle1,
33
+ heading: UIFontTextStyleTitle3,
34
+ body: UIFontTextStyleBody,
35
+ caption: UIFontTextStyleFootnote,
36
+ overline: UIFontTextStyleCaption2,
37
+ })[variant]
38
+
39
+ /**
40
+ * The ratio iOS applies to a font of `size` points in the view's text style at the current
41
+ * content size category. Core maps the categories to its own table, which halves text at the
42
+ * smallest size and snaps any other value back to it, so Mavis reads the system's Dynamic Type
43
+ * curve instead. The curve is not linear since iOS 17, so the ratio depends on the size.
44
+ */
45
+ export function dynamicTypeScale(view: DynamicTypeView, size: number): number {
46
+ if (!view.iosAccessibilityAdjustsFontSize || !(size > 0)) return 1
47
+ const category = UIApplication.sharedApplication.preferredContentSizeCategory
48
+ const traits = UITraitCollection.traitCollectionWithPreferredContentSizeCategory(category)
49
+ const metrics = UIFontMetrics.metricsForTextStyle(textStyle(view.dynamicTypeStyle ?? 'body'))
50
+ let scale = metrics.scaledValueForValueCompatibleWithTraitCollection(size, traits) / size
51
+ const { iosAccessibilityMinFontScale: min, iosAccessibilityMaxFontScale: max } = view
52
+ if (min && min > scale) scale = min
53
+ if (max && max < scale) scale = max
54
+ return scale
55
+ }
56
+
57
+ /** Core's font scale setter with the system ratio in place of Core's table. */
58
+ export function applyDynamicType(view: DynamicTypeView) {
59
+ const native = view.nativeTextViewProtected as NativeText | undefined
60
+ if (!native) return
61
+ const label =
62
+ native instanceof (UIButton as never) && native.titleLabel ? native.titleLabel : native
63
+ const font = view.style.fontInternal || Font.default.withFontSize(label.font.pointSize)
64
+ const scale = dynamicTypeScale(view, font.fontSize)
65
+ if (font.fontScale !== scale) {
66
+ view.style.fontInternal = font.withFontScale(scale)
67
+ view.requestLayout()
68
+ } else if (!view.style.fontInternal) {
69
+ view.style.fontInternal = font
70
+ }
71
+ }
@@ -10,6 +10,10 @@ import {
10
10
  // Core 9.1.3 computes row heights before growing children. This adapter runs after width
11
11
  // allocation and before cross-axis alignment; no global prototype or consumer styles change.
12
12
  interface FlexMeasurement {
13
+ _checkSizeConstraints(child: View): void
14
+ _stretchViewHorizontally(child: View, crossSize: number): void
15
+ _currentWidthMeasureSpec: number
16
+ _currentHeightMeasureSpec: number
13
17
  _determineMainSize(direction: string, widthSpec: number, heightSpec: number): void
14
18
  _flexLines: {
15
19
  _itemCount: number
@@ -29,6 +33,61 @@ const base = FlexboxLayout.prototype as unknown as FlexMeasurement
29
33
  export class MavisFlexLayout extends FlexboxLayout {
30
34
  measureRecord?: MeasureRecord
31
35
 
36
+ // Core's iOS Flexbox omits borders from its content insets. Keep the adjustment local
37
+ // to measurement/layout and leave the declared padding and derived values intact afterwards.
38
+ private withBorderPadding(run: () => void) {
39
+ const left = this.effectivePaddingLeft
40
+ const right = this.effectivePaddingRight
41
+ const top = this.effectivePaddingTop
42
+ const bottom = this.effectivePaddingBottom
43
+ this.effectivePaddingLeft += this.effectiveBorderLeftWidth
44
+ this.effectivePaddingRight += this.effectiveBorderRightWidth
45
+ this.effectivePaddingTop += this.effectiveBorderTopWidth
46
+ this.effectivePaddingBottom += this.effectiveBorderBottomWidth
47
+ try {
48
+ run()
49
+ } finally {
50
+ this.effectivePaddingLeft = left
51
+ this.effectivePaddingRight = right
52
+ this.effectivePaddingTop = top
53
+ this.effectivePaddingBottom = bottom
54
+ }
55
+ }
56
+
57
+ onMeasure(widthSpec: number, heightSpec: number) {
58
+ this.withBorderPadding(() => super.onMeasure(widthSpec, heightSpec))
59
+ }
60
+
61
+ onLayout(left: number, top: number, right: number, bottom: number) {
62
+ this.withBorderPadding(() => super.onLayout(left, top, right, bottom))
63
+ }
64
+
65
+ _checkSizeConstraints(child: View) {
66
+ const measurement = this as unknown as FlexMeasurement
67
+ const width = child.width
68
+ const spec = measurement._currentWidthMeasureSpec
69
+ if (
70
+ typeof width === 'object' &&
71
+ width.unit === '%' &&
72
+ layout.getMeasureSpecMode(spec) !== layout.UNSPECIFIED
73
+ ) {
74
+ // Core initially resolves percentages against the outer request. Correct the derived
75
+ // size before it forms flex lines, so wrapping/growth/shrink use the content-box basis.
76
+ child.effectiveWidth =
77
+ Math.max(
78
+ 0,
79
+ layout.getMeasureSpecSize(spec) - this.effectivePaddingLeft - this.effectivePaddingRight,
80
+ ) * width.value
81
+ this.measureAtWidth(child, child.effectiveWidth, measurement._currentHeightMeasureSpec)
82
+ }
83
+ base._checkSizeConstraints.call(this, child)
84
+ }
85
+
86
+ _stretchViewHorizontally(child: View, crossSize: number) {
87
+ // A declared width wins over alignItems=stretch, as it does in CSS flex layout.
88
+ if (child.effectiveWidth < 0) base._stretchViewHorizontally.call(this, child, crossSize)
89
+ }
90
+
32
91
  measure(widthSpec: number, heightSpec: number) {
33
92
  if (reuseMeasurement(this, widthSpec, heightSpec)) return
34
93
  super.measure(widthSpec, heightSpec)
@@ -48,8 +107,20 @@ export class MavisFlexLayout extends FlexboxLayout {
48
107
  const column = this.flexDirection.startsWith('column')
49
108
  const main = measurement._getLargestMainSize()
50
109
  const cross = measurement._getSumOfCrossSize()
51
- const maxHeight = column ? main : cross + this.effectivePaddingTop + this.effectivePaddingBottom
52
- const maxWidth = column ? cross + this.effectivePaddingLeft + this.effectivePaddingRight : main
110
+ const maxHeight = column
111
+ ? main
112
+ : cross +
113
+ this.effectivePaddingTop +
114
+ this.effectivePaddingBottom +
115
+ this.effectiveBorderTopWidth +
116
+ this.effectiveBorderBottomWidth
117
+ const maxWidth = column
118
+ ? cross +
119
+ this.effectivePaddingLeft +
120
+ this.effectivePaddingRight +
121
+ this.effectiveBorderLeftWidth +
122
+ this.effectiveBorderRightWidth
123
+ : main
53
124
  const exceeds = (spec: number, size: number) =>
54
125
  layout.getMeasureSpecMode(spec) === layout.AT_MOST && layout.getMeasureSpecSize(spec) < size
55
126
  return exceeds(heightSpec, maxHeight) || exceeds(widthSpec, maxWidth)
@@ -83,6 +154,7 @@ export class MavisFlexLayout extends FlexboxLayout {
83
154
  for (let i = 0; i < line._itemCount; i++, index++) {
84
155
  const child = measurement._getReorderedChildAt(index)
85
156
  if (!child || child.isCollapsed) continue
157
+ if (child.effectiveWidth >= 0) continue
86
158
  const alignSelf = FlexboxLayout.getAlignSelf(child)
87
159
  if (alignSelf !== 'auto' && alignSelf !== 'stretch') continue
88
160
  const oldHeight = child.getMeasuredHeight()
@@ -0,0 +1,15 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ const actions = new WeakMap<object, () => boolean>()
4
+
5
+ /** An input's own action is part of the active edit, not a tap outside it. */
6
+ export function keepEditingOn(action: View, editor: () => View | undefined): () => void {
7
+ const native = action.ios as object | undefined
8
+ if (!native) return () => {}
9
+ actions.set(native, () => editor()?.ios?.isFirstResponder === true)
10
+ return () => actions.delete(native)
11
+ }
12
+
13
+ export function isEditingAction(native: object) {
14
+ return actions.get(native)?.() ?? false
15
+ }
@@ -1,4 +1,5 @@
1
1
  import { ScrollView, type View } from '@nativescript/core'
2
+ import { isEditingAction } from './input-action'
2
3
 
3
4
  export interface KeyboardDismissal {
4
5
  tap: boolean
@@ -34,6 +35,7 @@ declare const interop: { types: { void: unknown } }
34
35
 
35
36
  const editor = (view: NativeView | null) => {
36
37
  for (let current = view; current; current = current.superview) {
38
+ if (isEditingAction(current)) return true
37
39
  if (current instanceof (UITextField as never) || current instanceof (UITextView as never))
38
40
  return true
39
41
  }
@@ -0,0 +1,27 @@
1
+ import { Label, type FormattedString } from '@nativescript/core'
2
+
3
+ declare const android: { text: { style: { AbsoluteSizeSpan: { class: unknown } } } }
4
+ interface StyledText {
5
+ length(): number
6
+ getSpans(start: number, end: number, type: unknown): ArrayLike<unknown>
7
+ removeSpan(span: unknown): void
8
+ }
9
+ const format = (
10
+ Label.prototype as unknown as {
11
+ createFormattedTextNative(value: FormattedString): StyledText
12
+ }
13
+ ).createFormattedTextNative
14
+
15
+ /** MSpan inherits one label size; keep Android's scaled text size instead of Core's fixed-size spans. */
16
+ export class MavisLabel extends Label {
17
+ createFormattedTextNative(value: FormattedString) {
18
+ const text = format.call(this, value)
19
+ if (!text) return text
20
+ // Core skips the TextView size setter for formatted text. Use sp here so the
21
+ // same inherited size reaches every run and Android applies system scaling.
22
+ if (this.fontSize > 0) this.nativeTextViewProtected.setTextSize(this.fontSize)
23
+ const sizes = text.getSpans(0, text.length(), android.text.style.AbsoluteSizeSpan.class)
24
+ for (let index = 0; index < sizes.length; index++) text.removeSpan(sizes[index])
25
+ return text
26
+ }
27
+ }
@@ -1,8 +1,47 @@
1
- import { Label, Utils } from '@nativescript/core'
1
+ import { Label, Utils, Font, type Span } from '@nativescript/core'
2
+ import { fontScaleInternalProperty } from '@nativescript/core/ui/styling/style-properties'
3
+ import type { TextVariant } from '@getcortexlabs/mavis-core'
2
4
  import { recordMeasurement, reuseMeasurement, type MeasureRecord } from './measure-memo'
5
+ import { applyDynamicType, dynamicTypeScale } from './dynamic-type'
6
+
7
+ const spanDetails = (
8
+ Label.prototype as unknown as {
9
+ createMutableStringDetails(span: Span, text: string, index: number): { iosFont: unknown }
10
+ }
11
+ ).createMutableStringDetails
3
12
 
4
13
  export class MavisLabel extends Label {
14
+ createMutableStringDetails(span: Span, text: string, index: number) {
15
+ const details = spanDetails.call(this, span, text, index)
16
+ const style = span.style
17
+ const size = style.fontSize || this.fontSize
18
+ const font = new Font(
19
+ style.fontFamily,
20
+ size,
21
+ style.fontStyle,
22
+ style.fontWeight,
23
+ dynamicTypeScale(this, size),
24
+ )
25
+ details.iosFont = font.getUIFont(this.ios.font)
26
+ return details
27
+ }
28
+
5
29
  measureRecord?: MeasureRecord
30
+ private textStyle: TextVariant = 'body'
31
+
32
+ get dynamicTypeStyle() {
33
+ return this.textStyle
34
+ }
35
+
36
+ set dynamicTypeStyle(value: TextVariant) {
37
+ if (value === this.textStyle) return
38
+ this.textStyle = value
39
+ applyDynamicType(this)
40
+ }
41
+
42
+ [fontScaleInternalProperty.setNative]() {
43
+ applyDynamicType(this)
44
+ }
6
45
 
7
46
  measure(widthSpec: number, heightSpec: number) {
8
47
  if (reuseMeasurement(this, widthSpec, heightSpec)) return
@@ -0,0 +1,137 @@
1
+ import { nativeScrollMotion } from './scroll-motion.js'
2
+ import type { View, EventData, TouchGestureEventData } from '@nativescript/core'
3
+ import {
4
+ bind,
5
+ motionValue,
6
+ springValue,
7
+ set,
8
+ stop,
9
+ drag,
10
+ type DerivedValue,
11
+ } from '@rafaelaugusto/jolt'
12
+ import type {
13
+ MotionSurfaceAdapter,
14
+ MotionValueAdapter,
15
+ } from '@getcortexlabs/mavis-core/experimental'
16
+
17
+ export function nativeContinuousSurface(target: View, enabled: () => boolean) {
18
+ const sources = new WeakMap<object, DerivedValue>()
19
+ const refreshes = new Set<() => void>()
20
+ const scrolls = new Set<ReturnType<typeof nativeScrollMotion>>()
21
+ const interrupt = (properties: readonly string[]) => {
22
+ for (const scroll of scrolls) scroll.interrupt(properties)
23
+ }
24
+ let suppressUntil = 0
25
+ const adapter: Pick<
26
+ MotionSurfaceAdapter,
27
+ 'motionValue' | 'springValue' | 'bind' | 'drag' | 'map' | 'refresh' | 'scrollLinked'
28
+ > = {
29
+ scrollLinked(source, frames, options) {
30
+ interrupt(Object.keys(frames))
31
+ const scroll = nativeScrollMotion(source, target, frames, options)
32
+ scrolls.add(scroll)
33
+ return {
34
+ get execution() {
35
+ return scroll.execution
36
+ },
37
+ refresh: () => scroll.refresh(),
38
+ dispose() {
39
+ scrolls.delete(scroll)
40
+ scroll.dispose()
41
+ },
42
+ }
43
+ },
44
+ // Native views keep their fractional pivot through layout; no surface recreation.
45
+ refresh: () => target.requestLayout(),
46
+ map(source, input, output, options) {
47
+ const mapped = sources.get(source)!.to(input, output, options)
48
+ const value = { get: () => mapped.get(), dispose() {} }
49
+ sources.set(value, mapped)
50
+ return value
51
+ },
52
+ motionValue(initial) {
53
+ const source = motionValue(initial)
54
+ const value: MotionValueAdapter = {
55
+ get: () => source.get(),
56
+ set: (value) => set(source, value),
57
+ dispose: () => stop(source),
58
+ }
59
+ sources.set(value, source)
60
+ return value
61
+ },
62
+ springValue(input, options) {
63
+ const spring = springValue(sources.get(input)!, options)
64
+ const value = {
65
+ get: () => spring.get(),
66
+ getVelocity: () => spring.getVelocity(),
67
+ get moving() {
68
+ return spring.moving
69
+ },
70
+ get paused() {
71
+ return spring.paused
72
+ },
73
+ pause: () => spring.pause(),
74
+ resume: () => spring.play(),
75
+ dispose: () => spring.dispose(),
76
+ }
77
+ sources.set(value, spring)
78
+ return value
79
+ },
80
+ bind(values) {
81
+ interrupt(Object.keys(values))
82
+ const dispose = bind(
83
+ target,
84
+ Object.fromEntries(
85
+ Object.entries(values).map(([key, value]) => [key, sources.get(value)!]),
86
+ ),
87
+ )
88
+ return { dispose }
89
+ },
90
+ drag(options) {
91
+ let paused = false
92
+ const gesture = drag(target, {
93
+ ...options,
94
+ onMove: () => {
95
+ suppressUntil = Date.now() + 500
96
+ },
97
+ onRelease: () => {
98
+ suppressUntil = Date.now() + 500
99
+ },
100
+ })
101
+ const refresh = () => (paused || !enabled() ? gesture.pause() : gesture.play())
102
+ refreshes.add(refresh)
103
+ refresh()
104
+ const touch = (event: EventData) => {
105
+ if ((event as TouchGestureEventData).action === 'down') suppressUntil = 0
106
+ }
107
+ target.on('touch', touch)
108
+ return {
109
+ get dragging() {
110
+ return gesture.dragging
111
+ },
112
+ pause() {
113
+ paused = true
114
+ refresh()
115
+ },
116
+ resume() {
117
+ paused = false
118
+ refresh()
119
+ },
120
+ cancel: () => gesture.cancel(),
121
+ dispose() {
122
+ refreshes.delete(refresh)
123
+ target.off('touch', touch)
124
+ gesture.dispose()
125
+ },
126
+ }
127
+ },
128
+ }
129
+ return {
130
+ adapter,
131
+ interrupt,
132
+ refresh() {
133
+ for (const refresh of refreshes) refresh()
134
+ },
135
+ allowsActivation: () => Date.now() >= suppressUntil,
136
+ }
137
+ }
@@ -1,13 +1,55 @@
1
- import type { View } from '@nativescript/core'
2
- import { press } from '@rafaelaugusto/jolt'
1
+ import type { EventData, TouchGestureEventData, View } from '@nativescript/core'
2
+ import { animate, stop, onReducedMotion } from '@rafaelaugusto/jolt'
3
+ import { pressMotion } from '@getcortexlabs/mavis-core'
3
4
 
4
- /** Own the effect so disabling or unloading a pressed control restores its scale. */
5
- export function attachPressFeedback(view: View, scale: number): () => void {
6
- const { scaleX, scaleY } = view
7
- const remove = press(view, { scaleX: scaleX * scale, scaleY: scaleY * scale })
8
- return () => {
9
- remove()
10
- view.scaleX = scaleX
11
- view.scaleY = scaleY
5
+ let nextLayer = 0
6
+
7
+ /** Press multiplies the app's scale; releasing it removes only that contribution. */
8
+ export function attachPressFeedback(view: View, scale: number) {
9
+ let motion = pressMotion(scale)
10
+ // Each attachment owns its channel, including after a theme change or reload.
11
+ const layer = `mavis-press-${++nextLayer}`
12
+ let pressed = false
13
+ let used = false
14
+ let disposed = false
15
+
16
+ const onTouch = (event: EventData) => {
17
+ if (disposed) return
18
+ const { action } = event as TouchGestureEventData
19
+ if (action === 'down' && !pressed && view.isEnabled !== false) {
20
+ pressed = true
21
+ used = true
22
+ animate(view, motion.pressed[0], { ...motion.pressed[1], layer })
23
+ } else if ((action === 'up' || action === 'cancel') && pressed) {
24
+ pressed = false
25
+ animate(view, motion.released[0], { ...motion.released[1], layer })
26
+ }
27
+ }
28
+ const remove = () => {
29
+ if (disposed) return
30
+ disposed = true
31
+ offPreference()
32
+ view.off('touch', onTouch)
33
+ view.off('unloaded', remove)
34
+ // A finished press can still hold its multiplier. stop(layer) also removes that rest.
35
+ if (used) {
36
+ stop(view, ['scale'], { layer })
37
+ }
12
38
  }
39
+ const offPreference = onReducedMotion((reduced) => {
40
+ if (reduced && used && !disposed) {
41
+ animate(view, motion[pressed ? 'pressed' : 'released'][0], { duration: 0, layer })
42
+ }
43
+ })
44
+ view.on('touch', onTouch)
45
+ view.on('unloaded', remove)
46
+ return Object.assign(remove, {
47
+ press(pressed: boolean) {
48
+ onTouch({ action: pressed ? 'down' : 'cancel' } as TouchGestureEventData)
49
+ },
50
+ update(scale: number) {
51
+ motion = pressMotion(scale)
52
+ if (pressed && !disposed) animate(view, motion.pressed[0], { ...motion.pressed[1], layer })
53
+ },
54
+ })
13
55
  }
@@ -0,0 +1,78 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { animate, set, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
3
+ import { progressMotion } from '@getcortexlabs/mavis-core'
4
+
5
+ /** The fill is private to Progress; only its translation is animated. */
6
+ export function attachProgressMotion(track: View, fill: View, indeterminate: boolean) {
7
+ let motion: ReturnType<typeof animate> | undefined
8
+ let pending: ReturnType<typeof setTimeout> | undefined
9
+ let suspended = Application.suspended
10
+ let disposed = false
11
+ let previous = ''
12
+
13
+ function stop() {
14
+ motion?.stop()
15
+ motion = undefined
16
+ }
17
+ function apply() {
18
+ pending = undefined
19
+ if (disposed) return
20
+ const measured = track.getActualSize().width
21
+ const width = Number.isFinite(measured) ? measured : 0
22
+ const reduced = reducedMotion()
23
+ const key = `${indeterminate}/${width}/${reduced}/${suspended}`
24
+ if (key === previous) return
25
+ previous = key
26
+ stop()
27
+ const travel = Math.max(0, width * (1 - progressMotion.segment))
28
+ set(fill, { x: indeterminate && reduced ? travel / 2 : 0 })
29
+ if (indeterminate && !reduced && !suspended && width > 0) {
30
+ motion = animate(
31
+ fill,
32
+ { x: [0, travel, 0] },
33
+ {
34
+ duration: progressMotion.duration,
35
+ ease: 'easeInOut',
36
+ repeat: Infinity,
37
+ },
38
+ )
39
+ }
40
+ }
41
+ function schedule() {
42
+ if (disposed) return
43
+ clearTimeout(pending)
44
+ // Native styles finish syncing after loaded and after a mode change.
45
+ pending = setTimeout(apply, 0)
46
+ }
47
+ function suspend() {
48
+ suspended = true
49
+ clearTimeout(pending)
50
+ apply()
51
+ }
52
+ function resume() {
53
+ suspended = false
54
+ schedule()
55
+ }
56
+ const offMotion = onReducedMotion(schedule)
57
+ track.on('layoutChanged', schedule)
58
+ Application.on(Application.suspendEvent, suspend)
59
+ Application.on(Application.resumeEvent, resume)
60
+ schedule()
61
+ return {
62
+ update(value: boolean) {
63
+ indeterminate = value
64
+ schedule()
65
+ },
66
+ dispose() {
67
+ if (disposed) return
68
+ disposed = true
69
+ clearTimeout(pending)
70
+ stop()
71
+ set(fill, { x: 0 })
72
+ offMotion()
73
+ track.off('layoutChanged', schedule)
74
+ Application.off(Application.suspendEvent, suspend)
75
+ Application.off(Application.resumeEvent, resume)
76
+ },
77
+ }
78
+ }
@@ -0,0 +1,101 @@
1
+ import type { EventData, ScrollView, View } from '@nativescript/core'
2
+ import { bind, scrollValue, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
3
+ import {
4
+ bindMotionScrollSource,
5
+ type MotionScrollAdapter,
6
+ type MotionScrollSource,
7
+ type MotionScrollFrames,
8
+ type MotionScrollOptions,
9
+ } from '@getcortexlabs/mavis-core/experimental'
10
+
11
+ const sources = new WeakMap<MotionScrollAdapter, ScrollView>()
12
+ export function attachNativeScrollSource(reference: MotionScrollSource, source: ScrollView) {
13
+ const adapter: MotionScrollAdapter = { kind: 'native' }
14
+ sources.set(adapter, source)
15
+ const unbind = bindMotionScrollSource(reference, adapter)
16
+ return () => {
17
+ unbind()
18
+ sources.delete(adapter)
19
+ }
20
+ }
21
+
22
+ /** Jolt owns numeric mappings and the application channels; Mavis resolves Screen/layout. */
23
+ export function nativeScrollMotion(
24
+ adapter: MotionScrollAdapter,
25
+ target: View,
26
+ frames: MotionScrollFrames,
27
+ options: MotionScrollOptions,
28
+ ) {
29
+ const source = sources.get(adapter)
30
+ if (!source) throw new TypeError('Use a scrolling MScreen in this renderer.')
31
+ const offset = scrollValue(source)
32
+ const active = new Map<string, readonly number[]>()
33
+ for (const [key, values] of Object.entries(frames)) {
34
+ if (key === 'scale') {
35
+ if (!frames.scaleX) active.set('scaleX', values)
36
+ if (!frames.scaleY) active.set('scaleY', values)
37
+ } else active.set(key, values)
38
+ }
39
+ const bindings = new Map<string, () => void>()
40
+ let disposed = false
41
+ let maximum = -1
42
+ let content: View | undefined
43
+ const apply = () => {
44
+ if (disposed) return
45
+ const bounded = offset.to([0, Math.max(1, maximum)], [0, Math.max(0, maximum)])
46
+ for (const [key, output] of active) {
47
+ bindings.get(key)?.()
48
+ const input = output.map(
49
+ (_, index) =>
50
+ options.range[0] + (index * (options.range[1] - options.range[0])) / (output.length - 1),
51
+ )
52
+ const values =
53
+ reducedMotion() && key !== 'opacity' ? output.map(() => output.at(-1)!) : output
54
+ bindings.set(key, bind(target, { [key]: bounded.to(input, values) }))
55
+ }
56
+ }
57
+ const refresh = () => {
58
+ if (disposed) return
59
+ const next = Math.max(0, source.scrollableHeight)
60
+ const changed = maximum !== next
61
+ maximum = next
62
+ if (content !== source.content) {
63
+ content?.off('layoutChanged', layout)
64
+ content = source.content
65
+ content?.on('layoutChanged', layout)
66
+ }
67
+ if (changed) apply()
68
+ // Re-read the actual bounded offset without a Vue update or an additional clock.
69
+ offset.ref(null)
70
+ offset.ref(source)
71
+ }
72
+ const layout = (_event: EventData) => refresh()
73
+ source.on('layoutChanged', layout)
74
+ const offReduced = onReducedMotion(apply)
75
+ refresh()
76
+ return {
77
+ get execution() {
78
+ return disposed || !active.size ? ('released' as const) : ('native' as const)
79
+ },
80
+ refresh,
81
+ interrupt(properties: readonly string[]) {
82
+ for (const property of properties)
83
+ for (const key of property === 'scale' ? ['scaleX', 'scaleY'] : [property]) {
84
+ active.delete(key)
85
+ bindings.get(key)?.()
86
+ bindings.delete(key)
87
+ }
88
+ },
89
+ dispose() {
90
+ if (disposed) return
91
+ disposed = true
92
+ source.off('layoutChanged', layout)
93
+ content?.off('layoutChanged', layout)
94
+ offReduced()
95
+ for (const release of bindings.values()) release()
96
+ bindings.clear()
97
+ active.clear()
98
+ offset.dispose()
99
+ },
100
+ }
101
+ }