@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,123 @@
1
+ import { defineComponent, h, mergeProps, type SlotsType } from 'nativescript-vue'
2
+ import {
3
+ useButtonAction,
4
+ accordionProps,
5
+ accordionEmits,
6
+ useMavisTheme,
7
+ } from '@getcortexlabs/mavis-core/vue'
8
+ import {
9
+ choiceKey,
10
+ validateAccordion,
11
+ toggleAccordion,
12
+ type AccordionPanelProps,
13
+ } from '@getcortexlabs/mavis-core'
14
+ import { MColumn } from './layout.js'
15
+ import { MListItem } from './MListItem.js'
16
+ import { MIcon } from './MIcon.js'
17
+ import { MReveal } from './MReveal.js'
18
+ import { MSeparator } from './MSeparator.js'
19
+
20
+ export const MAccordion = defineComponent({
21
+ name: 'MAccordion',
22
+ inheritAttrs: false,
23
+ props: accordionProps,
24
+ emits: accordionEmits,
25
+ slots: Object as SlotsType<{ default: AccordionPanelProps }>,
26
+ setup(props, { attrs, emit, slots }) {
27
+ useButtonAction()
28
+ const { theme } = useMavisTheme()
29
+ return () => {
30
+ validateAccordion(
31
+ props.items,
32
+ props.modelValue,
33
+ props.multiple,
34
+ props.label,
35
+ props.expandedLabel,
36
+ props.collapsedLabel,
37
+ )
38
+ const { colors } = theme.value
39
+ return h(
40
+ MColumn,
41
+ mergeProps(attrs, {
42
+ id: props.id,
43
+ width: props.width,
44
+ grow: props.grow,
45
+ shrink: props.shrink,
46
+ accessibilityHidden: props.accessibilityHidden,
47
+ gap: 'sm',
48
+ }),
49
+ {
50
+ default: () =>
51
+ props.items.map((item) => {
52
+ const expanded = props.modelValue.includes(item.value)
53
+ return h(
54
+ MColumn,
55
+ {
56
+ key: choiceKey(item.value),
57
+ radius: 'md',
58
+ backgroundColor: colors.surface,
59
+ style: {
60
+ borderWidth: 1,
61
+ borderColor: expanded ? colors.primarySoft : colors.border,
62
+ },
63
+ },
64
+ {
65
+ default: () => [
66
+ h(
67
+ MListItem,
68
+ {
69
+ title: item.title,
70
+ description: item.description,
71
+ interactive: true,
72
+ disabled: props.disabled || item.disabled,
73
+ accessibilityHidden: props.accessibilityHidden,
74
+ accessibilityHint: props.label,
75
+ accessibilityValue: expanded ? props.expandedLabel : props.collapsedLabel,
76
+ onClick() {
77
+ const next = toggleAccordion(
78
+ item,
79
+ props.modelValue,
80
+ props.multiple,
81
+ props.disabled,
82
+ )
83
+ if (next) emit('update:modelValue', next)
84
+ },
85
+ },
86
+ {
87
+ ...(item.icon
88
+ ? {
89
+ leading: () =>
90
+ h(MIcon, {
91
+ name: item.icon!,
92
+ tone: expanded ? 'primary' : 'muted',
93
+ }),
94
+ }
95
+ : {}),
96
+ trailing: () =>
97
+ h(MIcon, {
98
+ name: expanded ? 'chevron-up' : 'chevron-down',
99
+ size: 'sm',
100
+ tone: expanded ? 'primary' : 'muted',
101
+ }),
102
+ },
103
+ ),
104
+ h(
105
+ MReveal,
106
+ {
107
+ show: expanded,
108
+ padding: 'md',
109
+ gap: 'md',
110
+ style: { paddingTop: 0 },
111
+ accessibilityHidden: props.accessibilityHidden,
112
+ },
113
+ { default: () => [h(MSeparator), slots.default?.({ item })] },
114
+ ),
115
+ ],
116
+ },
117
+ )
118
+ }),
119
+ },
120
+ )
121
+ }
122
+ },
123
+ })
@@ -0,0 +1,156 @@
1
+ import { defineComponent, h, mergeProps, onBeforeUnmount, watch } from 'nativescript-vue'
2
+ import type { EventData, View } from '@nativescript/core'
3
+ import { alertProps, alertEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
4
+ import { alertAppearance, checkAlertLabels } from '@getcortexlabs/mavis-core'
5
+ import { announceToast as announceMessage } from '../../native/toast'
6
+ import { ActionChildren, useNativeViewAttrs } from '../accessibility.js'
7
+ import { MBox, MColumn, MRow } from './layout.js'
8
+ import { MText } from './MText.js'
9
+ import { MIcon } from './MIcon.js'
10
+ import { MButton } from './MButton.js'
11
+
12
+ export const MAlert = defineComponent({
13
+ name: 'MAlert',
14
+ inheritAttrs: false,
15
+ props: alertProps,
16
+ emits: alertEmits,
17
+ setup(props, { attrs, slots, emit }) {
18
+ const { theme } = useMavisTheme()
19
+ const nativeAttrs = useNativeViewAttrs(props)
20
+ let content: View | undefined
21
+ let pending: ReturnType<typeof setTimeout> | undefined
22
+ let announced = ''
23
+ const message = () => [props.title, props.description].filter(Boolean).join('\n')
24
+ function announce() {
25
+ clearTimeout(pending)
26
+ if (!props.announce) {
27
+ announced = ''
28
+ return
29
+ }
30
+ pending = setTimeout(() => {
31
+ pending = undefined
32
+ if (!content?.isLoaded || nativeAttrs().accessibilityHidden) return
33
+ const text = message()
34
+ if (text === announced) return
35
+ announceMessage(content, text)
36
+ announced = text
37
+ }, 0)
38
+ }
39
+ function release() {
40
+ clearTimeout(pending)
41
+ pending = undefined
42
+ content = undefined
43
+ }
44
+ watch(
45
+ () => [props.announce, props.title, props.description, nativeAttrs().accessibilityHidden],
46
+ announce,
47
+ { flush: 'post' },
48
+ )
49
+ onBeforeUnmount(release)
50
+ return () => {
51
+ checkAlertLabels(props.title, props.dismissible, props.closeLabel)
52
+ const { colors } = theme.value
53
+ const appearance = alertAppearance[props.tone]
54
+ return h(
55
+ MColumn,
56
+ mergeProps(
57
+ {
58
+ width: props.width,
59
+ grow: props.grow,
60
+ shrink: props.shrink,
61
+ padding: 'md',
62
+ gap: 'md',
63
+ radius: 'md',
64
+ backgroundColor: colors.surface,
65
+ style: {
66
+ borderWidth: 1,
67
+ borderColor: colors[appearance.tone],
68
+ },
69
+ },
70
+ attrs,
71
+ nativeAttrs(),
72
+ { accessible: false },
73
+ ),
74
+ {
75
+ default: () => [
76
+ h(
77
+ MRow,
78
+ { gap: 'sm', align: 'start' },
79
+ {
80
+ default: () => [
81
+ h(
82
+ MBox,
83
+ {
84
+ width: 32,
85
+ height: 32,
86
+ radius: 'sm',
87
+ shrink: 0,
88
+ backgroundColor: colors.elevated,
89
+ },
90
+ {
91
+ default: () =>
92
+ h(MIcon, {
93
+ name: appearance.icon,
94
+ tone: appearance.tone,
95
+ size: 20,
96
+ horizontalAlignment: 'center',
97
+ verticalAlignment: 'middle',
98
+ }),
99
+ },
100
+ ),
101
+ h(
102
+ MColumn,
103
+ {
104
+ width: 0,
105
+ grow: 1,
106
+ gap: 'xs',
107
+ accessible: true,
108
+ accessibilityRole: 'text',
109
+ accessibilityLabel: message(),
110
+ accessibilityHidden: nativeAttrs().accessibilityHidden,
111
+ onLoaded: (event: EventData) => {
112
+ content = event.object as View
113
+ announce()
114
+ },
115
+ onUnloaded: release,
116
+ },
117
+ {
118
+ default: () =>
119
+ h(
120
+ ActionChildren,
121
+ { hidden: true },
122
+ {
123
+ default: () => [
124
+ h(MText, { text: props.title, style: { fontWeight: '600' } }),
125
+ props.description
126
+ ? h(MText, { text: props.description, tone: 'muted' })
127
+ : null,
128
+ ],
129
+ },
130
+ ),
131
+ },
132
+ ),
133
+ props.dismissible
134
+ ? h(MButton, {
135
+ icon: 'x',
136
+ variant: 'ghost',
137
+ size: 'sm',
138
+ accessibilityLabel: props.closeLabel,
139
+ width: 44,
140
+ shrink: 0,
141
+ style: { paddingLeft: 0, paddingRight: 0 },
142
+ onClick: () => emit('close'),
143
+ })
144
+ : null,
145
+ ],
146
+ },
147
+ ),
148
+ slots.actions
149
+ ? h(MRow, { gap: 'sm', wrap: true, align: 'start' }, { default: slots.actions })
150
+ : null,
151
+ ],
152
+ },
153
+ )
154
+ }
155
+ },
156
+ })
@@ -0,0 +1,103 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ mergeProps,
5
+ onBeforeUnmount,
6
+ shallowRef,
7
+ watch,
8
+ registerElement,
9
+ } from 'nativescript-vue'
10
+ import { avatarProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
11
+ import { avatarSizes, avatarInitials, iconGlyph, iconFontFamily } from '@getcortexlabs/mavis-core'
12
+ import type { ImageSource } from '@nativescript/core'
13
+ import { loadAvatarImage } from '../../native/avatar-image'
14
+ import { useNativeViewAttrs } from '../accessibility.js'
15
+ import { MBox } from './layout.js'
16
+ import { MavisAvatarLabel } from '../../native/avatar-label'
17
+
18
+ registerElement('MavisAvatarLabel', () => MavisAvatarLabel)
19
+
20
+ export const MAvatar = defineComponent({
21
+ name: 'MAvatar',
22
+ inheritAttrs: false,
23
+ props: avatarProps,
24
+ setup(props, { attrs }) {
25
+ const { theme } = useMavisTheme()
26
+ const nativeAttrs = useNativeViewAttrs(props)
27
+ const image = shallowRef<ImageSource | null>(null)
28
+ let request = 0
29
+ watch(
30
+ () => props.src,
31
+ async (value) => {
32
+ const current = ++request
33
+ image.value = null
34
+ if (!value.trim()) return
35
+ try {
36
+ const result = await loadAvatarImage(value.trim())
37
+ if (current === request)
38
+ image.value = result && result.width > 0 && result.height > 0 ? result : null
39
+ } catch {
40
+ // Missing files, network failures and decode errors all keep the fallback.
41
+ }
42
+ },
43
+ { immediate: true },
44
+ )
45
+ onBeforeUnmount(() => {
46
+ request++
47
+ image.value = null
48
+ })
49
+ return () => {
50
+ const size = avatarSizes[props.size]
51
+ const radius = props.shape === 'circle' ? size / 2 : size / 4
52
+ const initials = avatarInitials(props.name)
53
+ const label = props.accessibilityLabel ?? props.name.trim()
54
+ return h(
55
+ MBox,
56
+ mergeProps(attrs, nativeAttrs(), {
57
+ width: size,
58
+ height: size,
59
+ radius,
60
+ shrink: 0,
61
+ backgroundColor: theme.value.colors.primarySoft,
62
+ accessible: Boolean(label),
63
+ accessibilityRole: 'image',
64
+ accessibilityLabel: label,
65
+ accessibilityHidden: nativeAttrs().accessibilityHidden || !label,
66
+ style: { alignSelf: 'flex-start' },
67
+ }),
68
+ {
69
+ default: () =>
70
+ image.value
71
+ ? [
72
+ h('Image', {
73
+ imageSource: image.value,
74
+ stretch: 'aspectFill',
75
+ width: size,
76
+ height: size,
77
+ borderRadius: radius,
78
+ accessible: false,
79
+ accessibilityHidden: true,
80
+ }),
81
+ ]
82
+ : [
83
+ h('MavisAvatarLabel', {
84
+ text: initials || iconGlyph('user-round'),
85
+ textWrap: false,
86
+ accessible: false,
87
+ accessibilityHidden: true,
88
+ iosAccessibilityAdjustsFontSize: false,
89
+ style: {
90
+ fontFamily: initials ? undefined : iconFontFamily,
91
+ fontSize: Math.round(size * (initials ? 0.34 : 0.46)),
92
+ fontWeight: '600',
93
+ color: theme.value.colors.primary,
94
+ textAlignment: 'center',
95
+ verticalAlignment: 'middle',
96
+ },
97
+ }),
98
+ ],
99
+ },
100
+ )
101
+ }
102
+ },
103
+ })
@@ -0,0 +1,34 @@
1
+ import { defineComponent, h, mergeProps } from 'nativescript-vue'
2
+ import { badgeProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
3
+ import { badgeColors } from '@getcortexlabs/mavis-core'
4
+ import { MText } from './MText.js'
5
+
6
+ export const MBadge = defineComponent({
7
+ name: 'MBadge',
8
+ inheritAttrs: false,
9
+ props: badgeProps,
10
+ setup(props, { attrs }) {
11
+ const { theme } = useMavisTheme()
12
+ return () =>
13
+ h(
14
+ MText,
15
+ mergeProps(attrs, {
16
+ id: props.id,
17
+ text: String(props.text),
18
+ variant: 'caption',
19
+ accessibilityLabel: props.accessibilityLabel,
20
+ accessibilityHidden: props.accessibilityHidden,
21
+ style: {
22
+ ...badgeColors(theme.value.colors, props.tone),
23
+ alignSelf: 'flex-start',
24
+ fontSize: props.size === 'sm' ? 11 : 13,
25
+ fontWeight: '600',
26
+ padding: props.size === 'sm' ? '3 8' : '5 10',
27
+ borderRadius: 999,
28
+ textAlignment: 'center',
29
+ minWidth: props.size === 'sm' ? 22 : 28,
30
+ },
31
+ }),
32
+ )
33
+ },
34
+ })
@@ -1,19 +1,40 @@
1
- import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
1
+ import { MRow } from './layout.js'
2
+ import { MText } from './MText.js'
3
+ import { MIcon } from './MIcon.js'
4
+ import { ActionChildren } from '../accessibility.js'
5
+ import { observeComposedButton } from '../../native/composed-button'
2
6
  import {
7
+ defineComponent,
8
+ h,
9
+ mergeProps,
10
+ registerElement,
11
+ onBeforeUnmount,
12
+ ref,
13
+ type VNode,
14
+ type SlotsType,
15
+ } from 'nativescript-vue'
16
+ import {
17
+ useButtonAction,
3
18
  buttonProps,
19
+ buttonContent,
20
+ ButtonAdornment,
4
21
  useMavisTheme,
5
22
  actionEmits,
6
23
  textContent,
7
24
  useDefaultShrink,
8
25
  } from '@getcortexlabs/mavis-core/vue'
9
26
  import {
27
+ fontFamily,
28
+ resolveRadius,
29
+ shadowStyle,
10
30
  nonNegative,
11
31
  iconGlyph,
12
32
  iconFontFamily,
13
33
  iconSizes,
14
34
  checkIconOnly,
15
35
  } from '@getcortexlabs/mavis-core'
16
- import { isAndroid } from '@nativescript/core'
36
+ import { isAndroid, type EventData, type View } from '@nativescript/core'
37
+ import { useMotionSurface } from '../use-motion-surface.js'
17
38
  import { usePressFeedback } from '../use-press.js'
18
39
  import { MavisButton } from '../../native/button'
19
40
  import { useNativeViewAttrs } from '../accessibility.js'
@@ -25,20 +46,44 @@ export const MButton = defineComponent({
25
46
  inheritAttrs: false,
26
47
  props: buttonProps,
27
48
  emits: actionEmits,
49
+ slots: Object as SlotsType<{
50
+ default?: () => VNode[]
51
+ leading?: () => VNode[]
52
+ trailing?: () => VNode[]
53
+ }>,
28
54
  setup(props, { attrs, slots, emit }) {
55
+ useButtonAction()
29
56
  const { theme } = useMavisTheme()
30
57
  const nativeAttrs = useNativeViewAttrs(props)
31
58
  const shrink = useDefaultShrink()
32
59
  const enabled = () => !props.disabled && !props.loading
33
- const lifecycle = usePressFeedback(enabled, theme)
60
+ const keyboardPressed = ref(false)
61
+ const lifecycle = usePressFeedback(enabled, theme, keyboardPressed)
62
+ const { allowsActivation, ...surface } = useMotionSurface(() => props.motionSurface, enabled)
63
+ const focused = ref(false)
64
+ let releaseFocus: (() => void) | undefined
65
+ const clearFocus = () => {
66
+ releaseFocus?.()
67
+ releaseFocus = undefined
68
+ focused.value = false
69
+ }
70
+ onBeforeUnmount(clearFocus)
34
71
  return () => {
35
72
  const { colors, control, radius } = theme.value
73
+ const tokens = theme.value.components.button
74
+ const family = fontFamily(
75
+ tokens.fontFamily ?? theme.value.typography.body.fontFamily,
76
+ isAndroid ? 'android' : 'ios',
77
+ )
36
78
  const size = control[props.size]
37
79
  const primary = props.variant === 'primary'
38
80
  const text = props.loading
39
81
  ? props.loadingText
40
82
  : (props.text ?? textContent(slots.default?.()))
41
- const hasIcon = Boolean(props.icon || props.trailingIcon)
83
+ const leading = buttonContent(slots.leading?.())
84
+ const trailing = buttonContent(slots.trailing?.())
85
+ const composed = Boolean(slots.leading || slots.trailing)
86
+ const hasIcon = Boolean(composed || props.icon || props.trailingIcon)
42
87
  checkIconOnly(text, hasIcon, props.accessibilityLabel)
43
88
  const iconSize = iconSizes[props.size]
44
89
  const minHeight = Math.max(size.height, isAndroid ? 48 : 44)
@@ -47,6 +92,121 @@ export const MButton = defineComponent({
47
92
  name
48
93
  ? h('Span', { text: iconGlyph(name), fontFamily: iconFontFamily, fontSize: iconSize })
49
94
  : null
95
+ if (composed) {
96
+ const tone = primary ? 'onPrimary' : 'text'
97
+ const adornment = (children: ReturnType<typeof buttonContent>) =>
98
+ h(
99
+ MRow,
100
+ {
101
+ shrink: 0,
102
+ align: 'center',
103
+ accessibilityHidden: true,
104
+ isUserInteractionEnabled: false,
105
+ },
106
+ { default: () => h(ButtonAdornment, {}, { default: () => children }) },
107
+ )
108
+ return h(
109
+ MRow,
110
+ mergeProps(
111
+ {
112
+ justify: 'center',
113
+ align: 'center',
114
+ wrap: true,
115
+ gap: 8,
116
+ style: {
117
+ minWidth: minHeight,
118
+ minHeight,
119
+ margin: 0,
120
+ paddingLeft: paddingX,
121
+ paddingRight: paddingX,
122
+ paddingTop: tokens.paddingY,
123
+ paddingBottom: tokens.paddingY,
124
+ backgroundColor: primary
125
+ ? colors.primary
126
+ : props.variant === 'secondary'
127
+ ? colors.elevated
128
+ : 'transparent',
129
+ borderRadius: resolveRadius(theme.value, tokens.radius),
130
+ borderWidth: focused.value ? 2 : 0,
131
+ borderColor: colors.primary,
132
+ boxShadow:
133
+ tokens.elevation === 'none'
134
+ ? undefined
135
+ : shadowStyle(theme.value.elevation[tokens.elevation], 'native'),
136
+ opacity: props.disabled ? 0.45 : 1,
137
+ flexGrow: nonNegative(props.grow, 'grow'),
138
+ flexShrink: nonNegative(props.shrink ?? shrink, 'shrink'),
139
+ },
140
+ },
141
+ nativeAttrs(),
142
+ attrs,
143
+ lifecycle,
144
+ surface,
145
+ {
146
+ isEnabled: enabled(),
147
+ accessible: true,
148
+ accessibilityRole: 'button',
149
+ accessibilityState: enabled() ? '' : 'disabled',
150
+ accessibilityLabel: props.accessibilityLabel ?? text,
151
+ accessibilityValue: props.accessibilityLabel ? text : undefined,
152
+ onTap: () => {
153
+ if (enabled() && allowsActivation()) emit('click')
154
+ },
155
+ onLoaded: (event: EventData) => {
156
+ clearFocus()
157
+ releaseFocus = observeComposedButton(
158
+ event.object as View,
159
+ (value) => {
160
+ focused.value = value
161
+ },
162
+ () => {
163
+ if (enabled() && allowsActivation()) emit('click')
164
+ },
165
+ (value) => {
166
+ keyboardPressed.value = value
167
+ },
168
+ )
169
+ },
170
+ onUnloaded: clearFocus,
171
+ },
172
+ ),
173
+ {
174
+ default: () =>
175
+ h(
176
+ ActionChildren,
177
+ { hidden: true },
178
+ {
179
+ default: () => [
180
+ slots.leading
181
+ ? adornment(leading)
182
+ : props.icon
183
+ ? h(MIcon, { name: props.icon, size: props.size, tone })
184
+ : null,
185
+ text
186
+ ? h(MText, {
187
+ text,
188
+ shrink: 0,
189
+ tone,
190
+ align: 'center',
191
+ style: {
192
+ fontSize: size.fontSize,
193
+ fontWeight: tokens.fontWeight,
194
+ fontFamily: family,
195
+ lineHeight: size.fontSize * (tokens.lineHeight - 1),
196
+ },
197
+ })
198
+ : null,
199
+ slots.trailing
200
+ ? adornment(trailing)
201
+ : props.trailingIcon
202
+ ? h(MIcon, { name: props.trailingIcon, size: props.size, tone })
203
+ : null,
204
+ ],
205
+ },
206
+ ),
207
+ },
208
+ )
209
+ }
50
210
  return h(
51
211
  'MavisButton',
52
212
  mergeProps(
@@ -62,10 +222,12 @@ export const MButton = defineComponent({
62
222
  minHeight,
63
223
  paddingLeft: paddingX,
64
224
  paddingRight: paddingX,
65
- paddingTop: 12,
66
- paddingBottom: 12,
225
+ paddingTop: tokens.paddingY,
226
+ paddingBottom: tokens.paddingY,
67
227
  fontSize: size.fontSize,
68
- fontWeight: '600',
228
+ fontWeight: tokens.fontWeight,
229
+ fontFamily: family,
230
+ lineHeight: size.fontSize * (tokens.lineHeight - 1),
69
231
  textTransform: 'none',
70
232
  backgroundColor: primary
71
233
  ? colors.primary
@@ -73,7 +235,11 @@ export const MButton = defineComponent({
73
235
  ? colors.elevated
74
236
  : 'transparent',
75
237
  color: primary ? colors.onPrimary : colors.text,
76
- borderRadius: radius.md,
238
+ borderRadius: resolveRadius(theme.value, tokens.radius),
239
+ boxShadow:
240
+ tokens.elevation === 'none'
241
+ ? undefined
242
+ : shadowStyle(theme.value.elevation[tokens.elevation], 'native'),
77
243
  borderWidth: 0,
78
244
  androidElevation: 0,
79
245
  androidDynamicElevationOffset: 0,
@@ -87,6 +253,7 @@ export const MButton = defineComponent({
87
253
  nativeAttrs(),
88
254
  attrs,
89
255
  lifecycle,
256
+ surface,
90
257
  {
91
258
  isEnabled: enabled(),
92
259
  accessible: true,
@@ -96,7 +263,7 @@ export const MButton = defineComponent({
96
263
  accessibilityValue:
97
264
  attrs.accessibilityValue ?? (props.accessibilityLabel ? text : undefined),
98
265
  onTap: () => {
99
- if (enabled()) emit('click')
266
+ if (enabled() && allowsActivation()) emit('click')
100
267
  },
101
268
  },
102
269
  ),