@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,214 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ mergeProps,
5
+ onBeforeUnmount,
6
+ ref,
7
+ registerElement,
8
+ watch,
9
+ } from 'nativescript-vue'
10
+ import type { EventData, View } from '@nativescript/core'
11
+ import {
12
+ canChoose,
13
+ choiceKey,
14
+ segmentedFocusTarget,
15
+ validateSegments,
16
+ type SegmentedOption,
17
+ } from '@getcortexlabs/mavis-core'
18
+ import {
19
+ useButtonAction,
20
+ segmentedProps,
21
+ segmentedEmits,
22
+ useMavisTheme,
23
+ } from '@getcortexlabs/mavis-core/vue'
24
+ import { MavisButton } from '../../native/button'
25
+ import { observeTab } from '../../native/tabs'
26
+ import { attachSegmentedIndicator } from '../../native/segmented'
27
+ import { useNativeViewAttrs } from '../accessibility.js'
28
+ import { MBox, MRow } from './layout.js'
29
+
30
+ registerElement('MavisSegmentButton', () => MavisButton)
31
+
32
+ export const MSegmentedControl = defineComponent({
33
+ name: 'MSegmentedControl',
34
+ inheritAttrs: false,
35
+ props: segmentedProps,
36
+ emits: segmentedEmits,
37
+ setup(props, { attrs, emit }) {
38
+ useButtonAction()
39
+ const { theme } = useMavisTheme()
40
+ const nativeAttrs = useNativeViewAttrs(props)
41
+ const controls = new Map<string, View>()
42
+ const observers = new Map<string, () => void>()
43
+ const focusKey = ref<string>()
44
+ let row: View | undefined, indicator: View | undefined
45
+ let motion: ReturnType<typeof attachSegmentedIndicator> | undefined
46
+ function connect() {
47
+ if (row && indicator && !motion)
48
+ motion = attachSegmentedIndicator(indicator, () => {
49
+ const active = props.options.find((option) => option.value === props.modelValue)
50
+ const key = active && choiceKey(active.value)
51
+ const button = key && controls.get(key)
52
+ const point = button && row && button.getLocationRelativeTo(row)
53
+ if (!key || !button || !point) return
54
+ return { key, x: point.x, ...button.getActualSize() }
55
+ })
56
+ motion?.update()
57
+ }
58
+ function release() {
59
+ motion?.dispose()
60
+ motion = undefined
61
+ for (const dispose of observers.values()) dispose()
62
+ observers.clear()
63
+ controls.clear()
64
+ row = indicator = undefined
65
+ focusKey.value = undefined
66
+ }
67
+ onBeforeUnmount(release)
68
+ watch(
69
+ () => props.modelValue,
70
+ () => motion?.update(true),
71
+ { flush: 'post' },
72
+ )
73
+ watch(
74
+ () => [props.options, props.disabled],
75
+ () => motion?.update(),
76
+ { deep: true, flush: 'post' },
77
+ )
78
+ function request(option: SegmentedOption) {
79
+ if (canChoose(option, props.modelValue, props.disabled))
80
+ emit('update:modelValue', option.value)
81
+ }
82
+ function navigate(option: SegmentedOption, key: string) {
83
+ if (props.disabled || props.options.find((item) => item.value === option.value)?.disabled)
84
+ return
85
+ const rtl =
86
+ row?.android?.getLayoutDirection() === 1 ||
87
+ row?.ios?.effectiveUserInterfaceLayoutDirection === 1
88
+ const next = segmentedFocusTarget(props.options, option.value, key, rtl)
89
+ if (!next) return
90
+ controls.get(choiceKey(next.value))?.focus()
91
+ request(next)
92
+ }
93
+ return () => {
94
+ validateSegments(props.options, props.modelValue, props.label)
95
+ const { colors, radius, typography } = theme.value
96
+ return h(
97
+ MBox,
98
+ mergeProps(attrs, {
99
+ id: props.id,
100
+ width: props.width,
101
+ grow: props.grow,
102
+ shrink: props.shrink,
103
+ accessibilityHidden: props.accessibilityHidden,
104
+ padding: 4,
105
+ radius: 'md',
106
+ backgroundColor: colors.elevated,
107
+ style: { borderWidth: 1, borderColor: colors.border, opacity: props.disabled ? 0.45 : 1 },
108
+ onUnloaded: release,
109
+ }),
110
+ {
111
+ default: () => [
112
+ h('MavisBox', {
113
+ accessible: false,
114
+ accessibilityHidden: true,
115
+ isUserInteractionEnabled: false,
116
+ horizontalAlignment: 'left',
117
+ verticalAlignment: 'top',
118
+ width: 1,
119
+ height: 1,
120
+ backgroundColor: colors.primarySoft,
121
+ borderRadius: Math.max(0, radius.md - 4),
122
+ opacity: 0,
123
+ onLoaded: (event: EventData) => {
124
+ indicator = event.object as View
125
+ connect()
126
+ },
127
+ }),
128
+ h(
129
+ MRow,
130
+ {
131
+ gap: 4,
132
+ align: 'stretch',
133
+ onLoaded: (event: EventData) => {
134
+ row = event.object as View
135
+ connect()
136
+ },
137
+ onLayoutChanged: () => motion?.update(),
138
+ },
139
+ {
140
+ default: () =>
141
+ props.options.map((option) => {
142
+ const key = choiceKey(option.value),
143
+ selected = option.value === props.modelValue
144
+ const disabled = props.disabled || Boolean(option.disabled)
145
+ return h('MavisSegmentButton', {
146
+ ...nativeAttrs(),
147
+ id: undefined,
148
+ key,
149
+ text: option.label,
150
+ textWrap: true,
151
+ accessible: true,
152
+ accessibilityRole: 'radioButton',
153
+ accessibilityLabel: option.label,
154
+ accessibilityHint: props.label,
155
+ accessibilityState: selected ? 'checked' : 'unchecked',
156
+ isEnabled: !disabled,
157
+ iosAccessibilityAdjustsFontSize: true,
158
+ style: {
159
+ width: 0,
160
+ flexGrow: 1,
161
+ flexShrink: 1,
162
+ minHeight: 48,
163
+ margin: 0,
164
+ paddingLeft: 8,
165
+ paddingRight: 8,
166
+ paddingTop: 10,
167
+ paddingBottom: 10,
168
+ fontSize: typography.body.fontSize,
169
+ fontWeight: '600',
170
+ textTransform: 'none',
171
+ color: selected ? colors.primary : colors.text,
172
+ backgroundColor: 'transparent',
173
+ borderWidth: 2,
174
+ borderColor: focusKey.value === key ? colors.primary : 'transparent',
175
+ borderRadius: Math.max(0, radius.md - 4),
176
+ opacity: option.disabled && !props.disabled ? 0.45 : 1,
177
+ androidElevation: 0,
178
+ androidDynamicElevationOffset: 0,
179
+ },
180
+ onTap: () => request(option),
181
+ onLoaded: (event: EventData) => {
182
+ const button = event.object as View
183
+ controls.set(key, button)
184
+ observers.get(key)?.()
185
+ observers.set(
186
+ key,
187
+ observeTab(
188
+ button,
189
+ (focused) => {
190
+ if (focused) focusKey.value = key
191
+ else if (focusKey.value === key) focusKey.value = undefined
192
+ },
193
+ (direction) => navigate(option, direction),
194
+ ),
195
+ )
196
+ motion?.update()
197
+ },
198
+ onUnloaded: () => {
199
+ observers.get(key)?.()
200
+ observers.delete(key)
201
+ controls.delete(key)
202
+ motion?.update()
203
+ },
204
+ onLayoutChanged: () => motion?.update(),
205
+ })
206
+ }),
207
+ },
208
+ ),
209
+ ],
210
+ },
211
+ )
212
+ }
213
+ },
214
+ })
@@ -0,0 +1,185 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ mergeProps,
6
+ onBeforeUnmount,
7
+ ref,
8
+ watch,
9
+ } from 'nativescript-vue'
10
+ import { Utils, isAndroid, type EventData, type View } from '@nativescript/core'
11
+ import { canChoose, choiceKey, validateChoices, type ChoiceOption } from '@getcortexlabs/mavis-core'
12
+ import {
13
+ useButtonAction,
14
+ selectProps,
15
+ selectEmits,
16
+ useMavisTheme,
17
+ } from '@getcortexlabs/mavis-core/vue'
18
+ import { observeCheckbox } from '../../native/checkbox'
19
+ import { MColumn, MBox } from './layout.js'
20
+ import { MText } from './MText.js'
21
+ import { MButton } from './MButton.js'
22
+ import { MIcon } from './MIcon.js'
23
+ import { MSheet } from './MSheet.js'
24
+ import { ChoiceControl } from './ChoiceControl.js'
25
+
26
+ export const MSelect = defineComponent({
27
+ name: 'MSelect',
28
+ inheritAttrs: false,
29
+ props: selectProps,
30
+ emits: selectEmits,
31
+ setup(props, { attrs, emit }) {
32
+ useButtonAction()
33
+ const { theme } = useMavisTheme()
34
+ const open = ref(false)
35
+ const focused = ref(false)
36
+ let observer: ReturnType<typeof observeCheckbox> | undefined
37
+ const options = computed(() => {
38
+ validateChoices(props.options, props.modelValue)
39
+ return props.options
40
+ })
41
+ function unload() {
42
+ open.value = false
43
+ observer?.dispose()
44
+ observer = undefined
45
+ focused.value = false
46
+ }
47
+ onBeforeUnmount(unload)
48
+ watch(
49
+ () => props.disabled,
50
+ (disabled) => {
51
+ if (disabled) open.value = false
52
+ },
53
+ )
54
+ function show() {
55
+ if (props.disabled || open.value) return
56
+ Utils.dismissKeyboard()
57
+ open.value = true
58
+ }
59
+ function choose(option: ChoiceOption) {
60
+ // Resolve the live option again: removal or disabling while open must win over an old tap.
61
+ const current = options.value.find((item) => item.value === option.value)
62
+ if (!open.value || props.disabled || !current || current.disabled) return
63
+ if (canChoose(current, props.modelValue)) emit('update:modelValue', current.value)
64
+ open.value = false
65
+ }
66
+ return () => {
67
+ const { colors, typography } = theme.value
68
+ const selected = options.value.find((option) => option.value === props.modelValue)
69
+ const message = props.error || props.helperText
70
+ const active = open.value || focused.value
71
+ return h(
72
+ MColumn,
73
+ mergeProps(attrs, {
74
+ width: props.width,
75
+ grow: props.grow,
76
+ shrink: props.shrink,
77
+ gap: 'sm',
78
+ accessibilityHidden: props.accessibilityHidden,
79
+ onUnloaded: unload,
80
+ }),
81
+ {
82
+ default: () => [
83
+ h(MText, {
84
+ text: props.label,
85
+ variant: 'caption',
86
+ style: { fontWeight: '600' },
87
+ accessibilityHidden: true,
88
+ onTap: show,
89
+ }),
90
+ h(
91
+ MBox,
92
+ {},
93
+ {
94
+ default: () => [
95
+ h(MButton, {
96
+ id: props.id,
97
+ text: selected?.label ?? props.placeholder,
98
+ variant: 'secondary',
99
+ disabled: props.disabled,
100
+ accessibilityLabel: props.label,
101
+ accessibilityHint: message,
102
+ style: {
103
+ textAlignment: 'left',
104
+ fontSize: typography.body.fontSize,
105
+ fontWeight: '400',
106
+ paddingLeft: 16,
107
+ paddingRight: 48,
108
+ paddingTop: 14,
109
+ paddingBottom: 14,
110
+ backgroundColor: colors.surface,
111
+ color: selected ? colors.text : colors.muted,
112
+ borderWidth: 2,
113
+ borderColor: props.error
114
+ ? colors.danger
115
+ : active
116
+ ? colors.primary
117
+ : colors.border,
118
+ },
119
+ onClick: show,
120
+ onLoaded: (event: EventData) => {
121
+ observer?.dispose()
122
+ observer = observeCheckbox(event.object as View, (value) => {
123
+ focused.value = value
124
+ })
125
+ },
126
+ onUnloaded: unload,
127
+ }),
128
+ h(MIcon, {
129
+ name: 'chevron-down',
130
+ tone: props.error ? 'danger' : active ? 'primary' : 'muted',
131
+ isUserInteractionEnabled: false,
132
+ style: {
133
+ horizontalAlignment: 'right',
134
+ verticalAlignment: 'middle',
135
+ marginRight: 16,
136
+ opacity: props.disabled ? 0.45 : 1,
137
+ },
138
+ }),
139
+ ],
140
+ },
141
+ ),
142
+ message
143
+ ? h(MText, {
144
+ text: message,
145
+ variant: 'caption',
146
+ tone: props.error ? 'danger' : 'muted',
147
+ })
148
+ : null,
149
+ h(
150
+ MSheet,
151
+ {
152
+ open: open.value,
153
+ title: props.label,
154
+ closeLabel: props.closeLabel,
155
+ gap: 'sm',
156
+ 'onUpdate:open': (value: boolean) => {
157
+ open.value = value && !props.disabled
158
+ },
159
+ },
160
+ {
161
+ default: () =>
162
+ options.value.length
163
+ ? options.value.map((option) =>
164
+ h(ChoiceControl, {
165
+ key: choiceKey(option.value),
166
+ radio: true,
167
+ // Mark feedback blocks drags from reaching the nested Android ScrollView.
168
+ // Keep the native button gesture there; the field and Sheet still animate.
169
+ pressFeedback: !isAndroid,
170
+ label: option.label,
171
+ helperText: option.helperText,
172
+ modelValue: option.value === props.modelValue,
173
+ disabled: props.disabled || option.disabled,
174
+ onActivate: () => choose(option),
175
+ }),
176
+ )
177
+ : h(MText, { text: props.emptyText, tone: 'muted' }),
178
+ },
179
+ ),
180
+ ],
181
+ },
182
+ )
183
+ }
184
+ },
185
+ })
@@ -0,0 +1,40 @@
1
+ import { defineComponent, h, mergeProps } from 'nativescript-vue'
2
+ import { separatorProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
3
+ import { resolveSpace } from '@getcortexlabs/mavis-core'
4
+ import { MBox } from './layout.js'
5
+
6
+ export const MSeparator = defineComponent({
7
+ name: 'MSeparator',
8
+ inheritAttrs: false,
9
+ props: separatorProps,
10
+ setup(props, { attrs }) {
11
+ const { theme } = useMavisTheme()
12
+ return () => {
13
+ const vertical = props.orientation === 'vertical'
14
+ const spacing = resolveSpace(theme.value, props.spacing)
15
+ const inset = resolveSpace(theme.value, props.inset)
16
+ const x = vertical ? spacing : inset,
17
+ y = vertical ? inset : spacing
18
+ return h(
19
+ MBox,
20
+ mergeProps(attrs, {
21
+ id: props.id,
22
+ width: vertical ? 1 : props.length,
23
+ height: vertical ? props.length : 1,
24
+ shrink: 0,
25
+ backgroundColor: theme.value.colors.border,
26
+ accessible: false,
27
+ accessibilityHidden: true,
28
+ isUserInteractionEnabled: false,
29
+ style: {
30
+ alignSelf: props.length === undefined ? 'stretch' : 'center',
31
+ marginLeft: x,
32
+ marginRight: x,
33
+ marginTop: y,
34
+ marginBottom: y,
35
+ },
36
+ }),
37
+ )
38
+ }
39
+ },
40
+ })
@@ -1,3 +1,5 @@
1
+ import { computed } from 'nativescript-vue'
2
+ import { useButtonAction, useCachedActivity } from '@getcortexlabs/mavis-core/vue'
1
3
  import {
2
4
  defineComponent,
3
5
  getCurrentInstance,
@@ -16,8 +18,13 @@ import {
16
18
  type VNodeChild,
17
19
  } from 'nativescript-vue'
18
20
  import { bottomSheet, GestureSurface, type BottomSheet } from '@rafaelaugusto/jolt/bottom-sheet'
19
- import { sheetProps, sheetEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
20
- import { checkSheetName, type SheetCloseReason } from '@getcortexlabs/mavis-core'
21
+ import {
22
+ sheetProps,
23
+ sheetEmits,
24
+ useMavisTheme,
25
+ type MavisThemeContext,
26
+ } from '@getcortexlabs/mavis-core/vue'
27
+ import { checkSheetName, type SheetName, type SheetCloseReason } from '@getcortexlabs/mavis-core'
21
28
  import { isAndroid, type EventData, type ScrollView, type View } from '@nativescript/core'
22
29
  import { MRow, MColumn, MBox } from './layout.js'
23
30
  import { MText } from './MText.js'
@@ -25,7 +32,7 @@ import { MButton } from './MButton.js'
25
32
  import { useLayerHost } from '../layers.js'
26
33
  import { nativeViewOf } from '../native-view.js'
27
34
  import { systemBackKey } from '../system-back.js'
28
- import { watchBack, setModal, safeAreaOf, bottomInset } from '../../native/sheet'
35
+ import { watchBack, setModal, safeAreaOf, contentInsets } from '../../native/sheet'
29
36
  import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
30
37
 
31
38
  registerElement('MavisSheetPanel', () => GestureSurface, { viewFlags: 4 })
@@ -34,6 +41,7 @@ type SheetState = ExtractPropTypes<typeof sheetProps>
34
41
  type Element<T extends View = View> = { nativeView: T }
35
42
 
36
43
  interface Bridge {
44
+ context: MavisThemeContext
37
45
  state: SheetState
38
46
  content: () => VNodeChild
39
47
  provides: Record<PropertyKey, unknown>
@@ -73,16 +81,17 @@ const SheetLayer = defineComponent({
73
81
  name: 'MSheetLayer',
74
82
  props: { bridge: { type: Object as PropType<Bridge>, required: true } },
75
83
  setup(props) {
84
+ useButtonAction()
76
85
  const bridge = props.bridge
77
86
  bridgeProvides(bridge.provides)
78
- const { theme } = useMavisTheme()
87
+ const { theme } = bridge.context
79
88
  const claimSystemBack = inject(systemBackKey, undefined)
80
89
  const panel = shallowRef<Element<GestureSurface>>()
81
90
  const handle = shallowRef<Element>()
82
91
  const scroll = shallowRef<Element<ScrollView>>()
83
92
  const backdrop = shallowRef<Element>()
84
- // The panel reaches the bottom of the window; its content stays above the home indicator.
85
- const inset = ref(0)
93
+ // The surface covers the window edges; content clears the home indicator and landscape notch.
94
+ const insets = ref({ left: 0, right: 0, bottom: 0 })
86
95
  let title: View | undefined
87
96
  let sheet: BottomSheet | undefined
88
97
  let pending: SheetCloseReason | undefined
@@ -90,6 +99,19 @@ const SheetLayer = defineComponent({
90
99
  let releaseBack = () => {}
91
100
  let releaseClaim = () => {}
92
101
 
102
+ function updateInsets() {
103
+ const host = nativeViewOf(panel.value)?.parent as View | undefined
104
+ if (!host) return
105
+ const next = contentInsets(host)
106
+ const current = insets.value
107
+ if (
108
+ next.left !== current.left ||
109
+ next.right !== current.right ||
110
+ next.bottom !== current.bottom
111
+ )
112
+ insets.value = next
113
+ }
114
+
93
115
  function dispose() {
94
116
  releaseBack()
95
117
  releaseClaim()
@@ -108,7 +130,7 @@ const SheetLayer = defineComponent({
108
130
  if (sheet || !views.panel || !views.handle || !views.scroll || !views.backdrop) return
109
131
  const state = bridge.state
110
132
  const host = views.panel.parent as View
111
- inset.value = bottomInset(host)
133
+ updateInsets()
112
134
  pending = undefined
113
135
  requested = false
114
136
  const back = () => {
@@ -133,7 +155,7 @@ const SheetLayer = defineComponent({
133
155
  snap: [state.fullscreen ? '100%' : 'content'],
134
156
  dismissible: state.dismissible,
135
157
  accessibility: {
136
- label: state.title ?? state.accessibilityLabel,
158
+ label: checkSheetName(state.title, state.accessibilityLabel),
137
159
  dismiss: state.closeLabel,
138
160
  },
139
161
  onChange(point) {
@@ -184,19 +206,21 @@ const SheetLayer = defineComponent({
184
206
  if (!bridge.presented.value) return null
185
207
  const state = bridge.state
186
208
  const { colors, radius } = theme.value
209
+ const name = checkSheetName(state.title, state.accessibilityLabel)
210
+ const heading = state.title?.trim()
187
211
  const header =
188
- state.title || state.dismissible
212
+ heading || state.dismissible
189
213
  ? h(
190
214
  MRow,
191
- { paddingX: 'lg', paddingY: 'sm', gap: 'sm', justify: 'between' },
215
+ { row: 1, paddingX: 'lg', paddingY: 'sm', gap: 'sm', justify: 'between' },
192
216
  {
193
217
  default: () => [
194
- state.title
218
+ heading
195
219
  ? h(MText, {
196
220
  as: 'h2',
197
221
  variant: 'heading',
198
222
  grow: 1,
199
- text: state.title,
223
+ text: heading,
200
224
  onLoaded: (event: EventData) => {
201
225
  title = event.object as View
202
226
  },
@@ -231,42 +255,40 @@ const SheetLayer = defineComponent({
231
255
  {
232
256
  ref: panel,
233
257
  id: state.id,
258
+ accessibilityLabel: name,
259
+ onLayoutChanged: updateInsets,
234
260
  style: {
235
261
  backgroundColor: colors.surface,
236
262
  borderTopLeftRadius: radius.lg,
237
263
  borderTopRightRadius: radius.lg,
238
- paddingBottom: inset.value,
264
+ paddingLeft: insets.value.left,
265
+ paddingRight: insets.value.right,
266
+ paddingBottom: insets.value.bottom,
239
267
  },
240
268
  },
241
269
  [
242
- h(
243
- MColumn,
244
- {},
245
- {
246
- default: () => [
247
- h('GridLayout', { ref: handle, height: 24 }, [
248
- h('MavisBox', {
249
- width: 36,
250
- height: 5,
251
- borderRadius: 3,
252
- backgroundColor: colors.border,
253
- horizontalAlignment: 'center',
254
- verticalAlignment: 'middle',
255
- }),
256
- ]),
257
- header,
258
- // Jolt measures the content snap as the content plus the panel area outside the
259
- // scroll view, so the scroll view fills whatever height the panel receives.
260
- h('ScrollView', { ref: scroll, style: { flexGrow: 1, flexShrink: 1 } }, [
261
- h(
262
- MColumn,
263
- { padding: state.padding, gap: state.gap, align: state.align },
264
- { default: () => bridge.content() },
265
- ),
266
- ]),
267
- ],
268
- },
269
- ),
270
+ h('GridLayout', { rows: 'auto,auto,*' }, [
271
+ h('GridLayout', { ref: handle, accessibilityLabel: name, row: 0, height: 24 }, [
272
+ h('MavisBox', {
273
+ width: 36,
274
+ height: 5,
275
+ borderRadius: 3,
276
+ backgroundColor: colors.border,
277
+ horizontalAlignment: 'center',
278
+ verticalAlignment: 'middle',
279
+ }),
280
+ ]),
281
+ header,
282
+ // Reserve the handle/header before measuring the viewport. A flex child's
283
+ // initial measurement can otherwise retain the full panel height on Android.
284
+ h('ScrollView', { ref: scroll, row: 2 }, [
285
+ h(
286
+ MColumn,
287
+ { padding: state.padding, gap: state.gap, align: state.align },
288
+ { default: () => bridge.content() },
289
+ ),
290
+ ]),
291
+ ]),
270
292
  ],
271
293
  ),
272
294
  ]
@@ -274,13 +296,14 @@ const SheetLayer = defineComponent({
274
296
  },
275
297
  })
276
298
 
277
- export const MSheet = defineComponent({
299
+ const Sheet = defineComponent({
278
300
  name: 'MSheet',
279
301
  inheritAttrs: false,
280
302
  props: sheetProps,
281
303
  emits: sheetEmits,
282
304
  setup(props, { slots, emit }) {
283
305
  const host = useLayerHost('MSheet')
306
+ const active = useCachedActivity()
284
307
  checkSheetName(props.title, props.accessibilityLabel)
285
308
  // Vue keeps the injection chain on the instance without declaring it in its public types.
286
309
  const provides =
@@ -292,7 +315,14 @@ export const MSheet = defineComponent({
292
315
  emit('update:open', false)
293
316
  emit('close', reason)
294
317
  }
318
+ watch(active, (value) => {
319
+ if (!value) {
320
+ presented.value = false
321
+ if (props.open) announce('program')
322
+ }
323
+ })
295
324
  const bridge: Bridge = {
325
+ context: useMavisTheme(),
296
326
  state: props,
297
327
  content: () => slots.default?.(),
298
328
  provides,
@@ -325,7 +355,13 @@ export const MSheet = defineComponent({
325
355
  },
326
356
  { immediate: true },
327
357
  )
328
- onBeforeUnmount(host.add({ component: SheetLayer, props: { bridge }, presented }))
358
+ onBeforeUnmount(
359
+ host.add({
360
+ component: SheetLayer,
361
+ props: { bridge },
362
+ presented: computed(() => active.value && presented.value),
363
+ }),
364
+ )
329
365
  return () => {
330
366
  // An unnamed sheet fails where it is declared, not in the Screen's render.
331
367
  checkSheetName(props.title, props.accessibilityLabel)
@@ -333,3 +369,7 @@ export const MSheet = defineComponent({
333
369
  }
334
370
  },
335
371
  })
372
+
373
+ export const MSheet = Sheet as typeof Sheet & {
374
+ new (): InstanceType<typeof Sheet> & { $props: SheetName }
375
+ }