@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,95 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { animate, set, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
3
+ import { segmentedMotion } from '@getcortexlabs/mavis-core'
4
+
5
+ interface SegmentBounds {
6
+ key: string
7
+ x: number
8
+ width: number
9
+ height: number
10
+ }
11
+
12
+ /** The marker belongs to the control; application transforms are never animated. */
13
+ export function attachSegmentedIndicator(indicator: View, read: () => SegmentBounds | undefined) {
14
+ let motion: ReturnType<typeof animate> | undefined
15
+ let pending: ReturnType<typeof setTimeout> | undefined
16
+ let previous: SegmentBounds | undefined
17
+ let animateNext = false
18
+ let suspended = Application.suspended
19
+ let disposed = false
20
+ function stop() {
21
+ motion?.stop()
22
+ motion = undefined
23
+ }
24
+ function apply() {
25
+ pending = undefined
26
+ if (disposed) return
27
+ const next = read()
28
+ if (
29
+ !next ||
30
+ ![next.x, next.width, next.height].every(Number.isFinite) ||
31
+ next.width <= 0 ||
32
+ next.height <= 0
33
+ ) {
34
+ stop()
35
+ indicator.opacity = 0
36
+ previous = undefined
37
+ animateNext = false
38
+ return
39
+ }
40
+ const changed =
41
+ !previous ||
42
+ next.x !== previous.x ||
43
+ next.width !== previous.width ||
44
+ next.height !== previous.height
45
+ if (changed || suspended || reducedMotion()) {
46
+ stop()
47
+ indicator.width = next.width
48
+ indicator.height = next.height
49
+ indicator.opacity = 1
50
+ if (previous && previous.key !== next.key && animateNext && !suspended && !reducedMotion())
51
+ motion = animate(
52
+ indicator,
53
+ { x: next.x },
54
+ { duration: segmentedMotion.duration, ease: segmentedMotion.ease },
55
+ )
56
+ else set(indicator, { x: next.x })
57
+ }
58
+ previous = next
59
+ animateNext = false
60
+ }
61
+ function update(animated = false) {
62
+ if (disposed) return
63
+ animateNext ||= animated
64
+ if (pending === undefined) pending = setTimeout(apply, 0)
65
+ }
66
+ function suspend() {
67
+ suspended = true
68
+ clearTimeout(pending)
69
+ apply()
70
+ }
71
+ function resume() {
72
+ suspended = false
73
+ update()
74
+ }
75
+ const offMotion = onReducedMotion(() => {
76
+ stop()
77
+ previous = undefined
78
+ update()
79
+ })
80
+ Application.on(Application.suspendEvent, suspend)
81
+ Application.on(Application.resumeEvent, resume)
82
+ update()
83
+ return {
84
+ update,
85
+ dispose() {
86
+ if (disposed) return
87
+ disposed = true
88
+ clearTimeout(pending)
89
+ stop()
90
+ offMotion()
91
+ Application.off(Application.suspendEvent, suspend)
92
+ Application.off(Application.resumeEvent, resume)
93
+ },
94
+ }
95
+ }
@@ -19,6 +19,6 @@ export function safeAreaOf(_host: View): { readonly top: number; readonly bottom
19
19
 
20
20
  export function expandLayerHost(_host: View) {}
21
21
 
22
- export function bottomInset(_host: View): number {
23
- return 0
22
+ export function contentInsets(_host: View): { left: number; right: number; bottom: number } {
23
+ return { left: 0, right: 0, bottom: 0 }
24
24
  }
@@ -15,17 +15,21 @@ export function setModal(panel: View, modal: boolean) {
15
15
 
16
16
  interface Insets {
17
17
  top: number
18
+ right: number
18
19
  bottom: number
20
+ left: number
19
21
  }
20
22
  const windowInsets = (view: View): Insets | undefined =>
21
- (view.page?.ios as { safeAreaInsets?: Insets } | undefined)?.safeAreaInsets
23
+ (view.page?.ios as { view?: { safeAreaInsets?: Insets } } | undefined)?.view?.safeAreaInsets
22
24
 
23
25
  /** The page lays its content inside the safe area; the host grows back over it with negative margins. */
24
26
  export function expandLayerHost(host: View) {
25
27
  const insets = windowInsets(host)
26
28
  if (!insets) return
27
29
  if (host.marginTop !== -insets.top) host.marginTop = -insets.top
30
+ if (host.marginRight !== -insets.right) host.marginRight = -insets.right
28
31
  if (host.marginBottom !== -insets.bottom) host.marginBottom = -insets.bottom
32
+ if (host.marginLeft !== -insets.left) host.marginLeft = -insets.left
29
33
  }
30
34
 
31
35
  /** Keeps the panel below the status bar; the panel itself pads its content above the home indicator. */
@@ -38,6 +42,11 @@ export function safeAreaOf(host: View): { readonly top: number; readonly bottom:
38
42
  }
39
43
  }
40
44
 
41
- export function bottomInset(host: View): number {
42
- return windowInsets(host)?.bottom ?? 0
45
+ export function contentInsets(host: View): { left: number; right: number; bottom: number } {
46
+ const insets = windowInsets(host)
47
+ return {
48
+ left: insets?.left ?? 0,
49
+ right: insets?.right ?? 0,
50
+ bottom: insets?.bottom ?? 0,
51
+ }
43
52
  }
@@ -21,6 +21,6 @@ export function safeAreaOf(_host: View): { readonly top: number; readonly bottom
21
21
  /** Lets the layer host cover the whole window; only iOS insets it by default. */
22
22
  export function expandLayerHost(_host: View) {}
23
23
 
24
- export function bottomInset(_host: View): number {
25
- return 0
24
+ export function contentInsets(_host: View): { left: number; right: number; bottom: number } {
25
+ return { left: 0, right: 0, bottom: 0 }
26
26
  }
@@ -0,0 +1,58 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ declare const android: {
4
+ view: {
5
+ View: {
6
+ OnFocusChangeListener: new (listener: {
7
+ onFocusChange(view: unknown, focused: boolean): void
8
+ }) => unknown
9
+ OnKeyListener: new (listener: {
10
+ onKey(
11
+ view: unknown,
12
+ key: number,
13
+ event: {
14
+ getAction(): number
15
+ isAltPressed(): boolean
16
+ isCtrlPressed(): boolean
17
+ isMetaPressed(): boolean
18
+ },
19
+ ): boolean
20
+ }) => unknown
21
+ }
22
+ }
23
+ }
24
+
25
+ export function observeTab(
26
+ view: View,
27
+ focus: (focused: boolean) => void,
28
+ navigate: (key: string) => void,
29
+ ) {
30
+ const button = view.android
31
+ const focused = new android.view.View.OnFocusChangeListener({
32
+ onFocusChange: (_view, value) => focus(value),
33
+ })
34
+ const keys = new android.view.View.OnKeyListener({
35
+ onKey(_view, key, event) {
36
+ if (
37
+ event.getAction() !== 0 ||
38
+ event.isAltPressed() ||
39
+ event.isCtrlPressed() ||
40
+ event.isMetaPressed()
41
+ )
42
+ return false
43
+ const name = (
44
+ { 21: 'ArrowLeft', 22: 'ArrowRight', 122: 'Home', 123: 'End' } as Record<number, string>
45
+ )[key]
46
+ if (!name) return false
47
+ navigate(name)
48
+ return true
49
+ },
50
+ })
51
+ button.setOnFocusChangeListener(focused)
52
+ button.setOnKeyListener(keys)
53
+ // Preserve Android's default touch focus: forcing it would consume the first tap.
54
+ return () => {
55
+ if (button.getOnFocusChangeListener() === focused) button.setOnFocusChangeListener(null)
56
+ button.setOnKeyListener(null)
57
+ }
58
+ }
@@ -0,0 +1,8 @@
1
+ import type { View } from '@nativescript/core'
2
+ export function observeTab(
3
+ _view: View,
4
+ _focus: (focused: boolean) => void,
5
+ _navigate: (key: string) => void,
6
+ ) {
7
+ return () => {}
8
+ }
@@ -12,6 +12,11 @@ const NO_EXTRACT_UI = 0x10000000
12
12
  const setReturnKey = (TextField.prototype as unknown as Record<symbol, (value: string) => void>)[
13
13
  returnKeyTypeProperty.setNative
14
14
  ]!
15
+ const setInputType = (
16
+ TextField.prototype as unknown as {
17
+ _setInputType(this: TextField, value: number): void
18
+ }
19
+ )._setInputType
15
20
  interface KeyEvent {
16
21
  getKeyCode(): number
17
22
  getAction(): number
@@ -19,6 +24,20 @@ interface KeyEvent {
19
24
 
20
25
  /** Keep editing in the screen and let the application own focus after submit. */
21
26
  export class MavisTextField extends TextField {
27
+ _setInputType(value: number) {
28
+ const field = this.android
29
+ const start = field.getSelectionStart(),
30
+ end = field.getSelectionEnd()
31
+ const typeface = field.getTypeface()
32
+ setInputType.call(this, value)
33
+ // Android resets selection and may substitute a monospace face for passwords.
34
+ field.setTypeface(typeface)
35
+ if (start >= 0 && end >= 0) {
36
+ const length = field.getText().length()
37
+ field.setSelection(Math.min(start, length), Math.min(end, length))
38
+ }
39
+ }
40
+
22
41
  [editableProperty.setNative](value: boolean) {
23
42
  setInputEditable(this, value)
24
43
  }
@@ -0,0 +1,53 @@
1
+ import { TextField } from '@nativescript/core'
2
+ import { secureProperty } from '@nativescript/core/ui/text-field/text-field-common'
3
+ import { fontScaleInternalProperty } from '@nativescript/core/ui/styling/style-properties'
4
+ import { applyDynamicType } from './dynamic-type'
5
+
6
+ const setSecure = (TextField.prototype as unknown as Record<symbol, (value: boolean) => void>)[
7
+ secureProperty.setNative
8
+ ]!
9
+
10
+ /** Follows the system text size with the iOS body curve instead of Core's table. */
11
+ export class MavisTextField extends TextField {
12
+ [secureProperty.setNative](value: boolean) {
13
+ const field = this.ios
14
+ const text = field.text
15
+ const selection = field.selectedTextRange
16
+ const start = selection
17
+ ? field.offsetFromPositionToPosition(field.beginningOfDocument, selection.start)
18
+ : null
19
+ const end = selection
20
+ ? field.offsetFromPositionToPosition(field.beginningOfDocument, selection.end)
21
+ : null
22
+ setSecure.call(this, value)
23
+ if (field.isFirstResponder) {
24
+ // Core treats the first secure keystroke as replacing the whole value. This is
25
+ // an existing edit switching visibility, so its next keystroke must use the selection.
26
+ const state = this as unknown as { _firstEdit: boolean }
27
+ state._firstEdit = false
28
+ }
29
+ if (field.isFirstResponder && value && text) {
30
+ // UIKit otherwise clears the secure buffer on the next insertion. Reinsert
31
+ // the existing value without treating it as a new edit in Core's delegate.
32
+ const delegate = field.delegate
33
+ try {
34
+ field.delegate = null
35
+ field.text = ''
36
+ field.insertText(text)
37
+ } finally {
38
+ field.delegate = delegate
39
+ }
40
+ } else {
41
+ field.text = text
42
+ }
43
+ if (start !== null && end !== null) {
44
+ const from = field.positionFromPositionOffset(field.beginningOfDocument, start)
45
+ const to = field.positionFromPositionOffset(field.beginningOfDocument, end)
46
+ if (from && to) field.selectedTextRange = field.textRangeFromPositionToPosition(from, to)
47
+ }
48
+ }
49
+
50
+ [fontScaleInternalProperty.setNative]() {
51
+ applyDynamicType(this)
52
+ }
53
+ }
@@ -0,0 +1,10 @@
1
+ import { TextView } from '@nativescript/core'
2
+ import { fontScaleInternalProperty } from '@nativescript/core/ui/styling/style-properties'
3
+ import { applyDynamicType } from './dynamic-type'
4
+
5
+ /** Follows the system text size with the iOS body curve instead of Core's table. */
6
+ export class MavisTextView extends TextView {
7
+ [fontScaleInternalProperty.setNative]() {
8
+ applyDynamicType(this)
9
+ }
10
+ }
@@ -0,0 +1,9 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+
3
+ export function toastReaderActive(): boolean {
4
+ const manager = Application.android.context?.getSystemService('accessibility')
5
+ return Boolean(manager?.isTouchExplorationEnabled())
6
+ }
7
+ export function announceToast(view: View, message: string) {
8
+ if (view.isLoaded && toastReaderActive()) view.android?.announceForAccessibility(message)
9
+ }
@@ -0,0 +1,13 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ declare function UIAccessibilityIsVoiceOverRunning(): boolean
4
+ declare const UIAccessibilityAnnouncementNotification: number
5
+ declare function UIAccessibilityPostNotification(notification: number, argument: unknown): void
6
+
7
+ export function toastReaderActive() {
8
+ return UIAccessibilityIsVoiceOverRunning()
9
+ }
10
+ export function announceToast(view: View, message: string) {
11
+ if (view.isLoaded && toastReaderActive())
12
+ UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, message)
13
+ }
@@ -0,0 +1,6 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ export function announceToast(_view: View, _message: string) {}
4
+ export function toastReaderActive(): boolean {
5
+ return false
6
+ }
@@ -0,0 +1,238 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ mergeProps,
5
+ onBeforeUnmount,
6
+ ref,
7
+ registerElement,
8
+ watch,
9
+ } from 'nativescript-vue'
10
+ import type { EventData, TouchGestureEventData, View } from '@nativescript/core'
11
+ import { animate } from '@rafaelaugusto/jolt'
12
+ import { checkboxProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
13
+ import { MavisButton } from '../../native/button'
14
+ import { mixedValue, observeCheckbox } from '../../native/checkbox'
15
+ import { MBox, MRow, MColumn } from './layout.js'
16
+ import { MText } from './MText.js'
17
+ import { useNativeViewAttrs } from '../accessibility.js'
18
+
19
+ registerElement('MavisCheckboxButton', () => MavisButton)
20
+ registerElement('MavisRadioButton', () => MavisButton)
21
+
22
+ export const ChoiceControl = defineComponent({
23
+ name: 'ChoiceControl',
24
+ inheritAttrs: false,
25
+ props: { ...checkboxProps, radio: Boolean, pressFeedback: { type: Boolean, default: true } },
26
+ emits: ['activate'],
27
+ setup(props, { attrs, emit }) {
28
+ const { theme } = useMavisTheme()
29
+ const nativeAttrs = useNativeViewAttrs(props)
30
+ const focused = ref(false)
31
+ let mark: View | undefined
32
+ let motion: ReturnType<typeof animate> | undefined
33
+ let observer: ReturnType<typeof observeCheckbox> | undefined
34
+
35
+ function restore() {
36
+ motion?.stop()
37
+ motion = undefined
38
+ if (mark) {
39
+ mark.scaleX = 1
40
+ mark.scaleY = 1
41
+ }
42
+ }
43
+ function unload() {
44
+ restore()
45
+ observer?.dispose()
46
+ observer = undefined
47
+ }
48
+ onBeforeUnmount(unload)
49
+ watch(
50
+ () => props.disabled,
51
+ (disabled) => {
52
+ if (disabled) restore()
53
+ },
54
+ )
55
+ watch(
56
+ [() => props.indeterminate, () => props.indeterminateLabel],
57
+ () => {
58
+ observer?.setMixed(props.indeterminate ? props.indeterminateLabel : undefined)
59
+ },
60
+ { flush: 'post' },
61
+ )
62
+
63
+ function touch(event: TouchGestureEventData) {
64
+ if (!mark || props.disabled) return
65
+ if (!['down', 'up', 'cancel'].includes(event.action)) return
66
+ motion?.stop()
67
+ const scale = event.action === 'down' ? 0.9 : 1
68
+ motion = animate(
69
+ mark,
70
+ { scaleX: scale, scaleY: scale },
71
+ {
72
+ type: 'spring',
73
+ duration: 180,
74
+ bounce: 0,
75
+ },
76
+ )
77
+ }
78
+
79
+ return () => {
80
+ const { colors } = theme.value
81
+ const selected = props.indeterminate || props.modelValue
82
+ return h(
83
+ MBox,
84
+ mergeProps(
85
+ {
86
+ width: props.width,
87
+ grow: props.grow,
88
+ shrink: props.shrink,
89
+ style: {
90
+ minHeight: 48,
91
+ borderWidth: 2,
92
+ borderRadius: 10,
93
+ borderColor: focused.value && !props.disabled ? colors.primary : 'transparent',
94
+ opacity: props.disabled ? 0.45 : 1,
95
+ },
96
+ },
97
+ attrs,
98
+ { accessibilityHidden: props.accessibilityHidden },
99
+ ),
100
+ {
101
+ default: () => [
102
+ h(props.radio ? 'MavisRadioButton' : 'MavisCheckboxButton', {
103
+ ...nativeAttrs(),
104
+ text: '',
105
+ isEnabled: !props.disabled,
106
+ accessible: true,
107
+ accessibilityRole: props.radio ? 'radioButton' : 'checkbox',
108
+ accessibilityState:
109
+ props.modelValue && !props.indeterminate ? 'checked' : 'unchecked',
110
+ accessibilityLabel: props.label,
111
+ accessibilityHint: props.helperText || '',
112
+ accessibilityValue: mixedValue(props.indeterminate, props.indeterminateLabel),
113
+ style: {
114
+ minHeight: 48,
115
+ minWidth: 0,
116
+ margin: 0,
117
+ padding: 0,
118
+ borderWidth: 0,
119
+ backgroundColor: 'transparent',
120
+ androidElevation: 0,
121
+ androidDynamicElevationOffset: 0,
122
+ },
123
+ onTap: () => {
124
+ if (!props.disabled) emit('activate')
125
+ },
126
+ onTouch: props.pressFeedback ? touch : undefined,
127
+ onLoaded: (event: EventData) => {
128
+ unload()
129
+ observer = observeCheckbox(event.object as View, (value) => {
130
+ focused.value = value
131
+ })
132
+ observer.setMixed(props.indeterminate ? props.indeterminateLabel : undefined)
133
+ },
134
+ onUnloaded: unload,
135
+ }),
136
+ h(
137
+ MRow,
138
+ {
139
+ gap: 'md',
140
+ paddingY: 'sm',
141
+ isUserInteractionEnabled: false,
142
+ accessibilityHidden: true,
143
+ },
144
+ {
145
+ default: () => [
146
+ h(
147
+ MBox,
148
+ {
149
+ width: 24,
150
+ height: 24,
151
+ shrink: 0,
152
+ radius: props.radio ? 12 : 7,
153
+ isUserInteractionEnabled: false,
154
+ accessibilityHidden: true,
155
+ style: {
156
+ borderWidth: 2,
157
+ borderColor: selected ? colors.primary : colors.muted,
158
+ backgroundColor: !props.radio && selected ? colors.primary : 'transparent',
159
+ },
160
+ onLoaded: (event: EventData) => {
161
+ mark = event.object as View
162
+ },
163
+ onUnloaded: () => {
164
+ restore()
165
+ mark = undefined
166
+ },
167
+ },
168
+ {
169
+ default: () =>
170
+ selected
171
+ ? h(MBox, {
172
+ width: 12,
173
+ height: props.radio ? 12 : props.indeterminate ? 2 : 7,
174
+ isUserInteractionEnabled: false,
175
+ accessibilityHidden: true,
176
+ style: props.radio
177
+ ? {
178
+ backgroundColor: colors.primary,
179
+ borderRadius: 6,
180
+ horizontalAlignment: 'center',
181
+ verticalAlignment: 'middle',
182
+ }
183
+ : props.indeterminate
184
+ ? {
185
+ backgroundColor: colors.onPrimary,
186
+ borderRadius: 1,
187
+ horizontalAlignment: 'center',
188
+ verticalAlignment: 'middle',
189
+ }
190
+ : {
191
+ borderLeftWidth: 2,
192
+ borderBottomWidth: 2,
193
+ borderColor: colors.onPrimary,
194
+ rotate: -45,
195
+ translateY: -1,
196
+ horizontalAlignment: 'center',
197
+ verticalAlignment: 'middle',
198
+ },
199
+ })
200
+ : null,
201
+ },
202
+ ),
203
+ h(
204
+ MColumn,
205
+ {
206
+ gap: 'xs',
207
+ isUserInteractionEnabled: false,
208
+ accessibilityHidden: true,
209
+ },
210
+ {
211
+ default: () => [
212
+ h(MText, {
213
+ text: props.label,
214
+ accessibilityHidden: true,
215
+ isUserInteractionEnabled: false,
216
+ style: { fontWeight: '600' },
217
+ }),
218
+ props.helperText
219
+ ? h(MText, {
220
+ text: props.helperText,
221
+ variant: 'caption',
222
+ tone: 'muted',
223
+ accessibilityHidden: true,
224
+ isUserInteractionEnabled: false,
225
+ })
226
+ : null,
227
+ ],
228
+ },
229
+ ),
230
+ ],
231
+ },
232
+ ),
233
+ ],
234
+ },
235
+ )
236
+ }
237
+ },
238
+ })