@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
@@ -1,8 +1,15 @@
1
+ import { resolveSpace, resolveRadius, shadowStyle } from '@getcortexlabs/mavis-core'
1
2
  import { ActionChildren } from '../accessibility.js'
2
3
  import { defineComponent, h, mergeProps } from 'nativescript-vue'
3
- import { cardProps, useMavisTheme, actionEmits } from '@getcortexlabs/mavis-core/vue'
4
+ import {
5
+ useButtonAction,
6
+ cardProps,
7
+ useMavisTheme,
8
+ actionEmits,
9
+ } from '@getcortexlabs/mavis-core/vue'
4
10
  import { MColumn } from './layout.js'
5
11
  import { usePressFeedback } from '../use-press.js'
12
+ import { useMotionSurface } from '../use-motion-surface.js'
6
13
 
7
14
  export const MCard = defineComponent({
8
15
  name: 'MCard',
@@ -10,17 +17,29 @@ export const MCard = defineComponent({
10
17
  props: cardProps,
11
18
  emits: actionEmits,
12
19
  setup(props, { attrs, slots, emit }) {
20
+ useButtonAction(() => props.interactive)
13
21
  const { theme } = useMavisTheme()
14
22
  const enabled = () => props.interactive && !props.disabled
15
23
  const lifecycle = usePressFeedback(enabled, theme)
24
+ const { allowsActivation, ...surface } = useMotionSurface(
25
+ () => props.motionSurface,
26
+ () => !props.disabled,
27
+ )
16
28
  return () => {
17
- const { interactive, disabled, ...layout } = props
29
+ const { interactive, disabled, elevation, motionSurface, ...layout } = props
30
+ const tokens = theme.value.components.card
31
+ layout.padding ??= tokens.padding
32
+ layout.radius ??= tokens.radius
18
33
  return h(
19
34
  MColumn,
20
35
  mergeProps(
21
36
  layout,
22
37
  {
23
38
  style: {
39
+ boxShadow:
40
+ (elevation ?? tokens.elevation) === 'none'
41
+ ? undefined
42
+ : shadowStyle(theme.value.elevation[elevation ?? tokens.elevation], 'native'),
24
43
  backgroundColor: props.backgroundColor ?? theme.value.colors.surface,
25
44
  borderColor: theme.value.colors.border,
26
45
  borderWidth: 1,
@@ -29,13 +48,14 @@ export const MCard = defineComponent({
29
48
  },
30
49
  attrs,
31
50
  lifecycle,
51
+ surface,
32
52
  {
33
53
  accessible: interactive,
34
54
  accessibilityRole: interactive ? 'button' : '',
35
55
  accessibilityState: interactive && disabled ? 'disabled' : '',
36
56
  onTap: interactive
37
57
  ? () => {
38
- if (enabled()) emit('click')
58
+ if (enabled() && allowsActivation()) emit('click')
39
59
  }
40
60
  : undefined,
41
61
  },
@@ -0,0 +1,25 @@
1
+ import { defineComponent, h } from 'nativescript-vue'
2
+ import { useButtonAction, checkboxProps, checkboxEmits } from '@getcortexlabs/mavis-core/vue'
3
+ import { ChoiceControl } from './ChoiceControl.js'
4
+
5
+ export const MCheckbox = defineComponent({
6
+ name: 'MCheckbox',
7
+ inheritAttrs: false,
8
+ props: checkboxProps,
9
+ emits: checkboxEmits,
10
+ setup(props, { attrs, emit }) {
11
+ useButtonAction()
12
+ return () =>
13
+ h(ChoiceControl, {
14
+ ...attrs,
15
+ ...props,
16
+ radio: false,
17
+ onActivate() {
18
+ if (props.disabled) return
19
+ const next = props.indeterminate || !props.modelValue
20
+ if (props.indeterminate) emit('update:indeterminate', false)
21
+ emit('update:modelValue', next)
22
+ },
23
+ })
24
+ },
25
+ })
@@ -0,0 +1,134 @@
1
+ import { defineComponent, h, mergeProps } from 'nativescript-vue'
2
+ import { checkChipLabels, chipColors } from '@getcortexlabs/mavis-core'
3
+ import { useButtonAction, chipProps, chipEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
4
+ import { usePressFeedback } from '../use-press.js'
5
+ import { ActionChildren, useNativeViewAttrs } from '../accessibility.js'
6
+ import { MRow } from './layout.js'
7
+ import { MText } from './MText.js'
8
+ import { MIcon } from './MIcon.js'
9
+ import { MButton } from './MButton.js'
10
+
11
+ export const MChip = defineComponent({
12
+ name: 'MChip',
13
+ inheritAttrs: false,
14
+ props: chipProps,
15
+ emits: chipEmits,
16
+ setup(props, { attrs, emit }) {
17
+ useButtonAction()
18
+ const { theme } = useMavisTheme()
19
+ const nativeAttrs = useNativeViewAttrs(props)
20
+ const lifecycle = usePressFeedback(() => props.selectable && !props.disabled, theme)
21
+ return () => {
22
+ checkChipLabels(props.label, props.removable, props.removeLabel)
23
+ const selected = props.selectable && props.modelValue
24
+ const colors = chipColors(theme.value.colors, props.tone, selected)
25
+ const icon = selected ? 'check' : props.icon
26
+ return h(
27
+ MRow,
28
+ mergeProps(attrs, {
29
+ id: props.id,
30
+ width: props.width,
31
+ grow: props.grow,
32
+ shrink: props.shrink,
33
+ accessibilityHidden: props.accessibilityHidden,
34
+ align: 'stretch',
35
+ radius: 'full',
36
+ style: {
37
+ ...colors,
38
+ borderWidth: 1,
39
+ opacity: props.disabled ? 0.45 : 1,
40
+ alignSelf: 'flex-start',
41
+ },
42
+ }),
43
+ {
44
+ default: () => [
45
+ h(
46
+ MRow,
47
+ mergeProps(
48
+ {
49
+ gap: 'xs',
50
+ paddingX: 14,
51
+ paddingY: 15,
52
+ grow: 1,
53
+ shrink: 1,
54
+ radius: 'full',
55
+ accessible: true,
56
+ accessibilityRole: props.selectable ? 'button' : 'text',
57
+ accessibilityLabel: props.label,
58
+ // Core accepts one state token; unavailable takes precedence over selected.
59
+ accessibilityState: props.selectable
60
+ ? props.disabled
61
+ ? 'disabled'
62
+ : selected
63
+ ? 'selected'
64
+ : ''
65
+ : '',
66
+ accessibilityHidden: nativeAttrs().accessibilityHidden,
67
+ isEnabled: !props.disabled,
68
+ style: { minHeight: 46 },
69
+ onTap: props.selectable
70
+ ? () => {
71
+ if (!props.disabled) emit('update:modelValue', !props.modelValue)
72
+ }
73
+ : undefined,
74
+ },
75
+ lifecycle,
76
+ ),
77
+ {
78
+ default: () =>
79
+ h(
80
+ ActionChildren,
81
+ { hidden: true },
82
+ {
83
+ default: () => [
84
+ icon || props.selectable
85
+ ? h(MIcon, {
86
+ name: icon ?? 'check',
87
+ size: 'sm',
88
+ tone: selected ? props.tone : 'muted',
89
+ style: { opacity: icon ? 1 : 0 },
90
+ })
91
+ : null,
92
+ h(MText, {
93
+ text: props.label,
94
+ variant: 'caption',
95
+ tone: selected ? props.tone : 'text',
96
+ shrink: 1,
97
+ style: { fontWeight: '600' },
98
+ }),
99
+ ],
100
+ },
101
+ ),
102
+ },
103
+ ),
104
+ props.removable
105
+ ? h(MButton, {
106
+ icon: 'x',
107
+ size: 'sm',
108
+ variant: 'ghost',
109
+ disabled: props.disabled,
110
+ accessibilityHidden: props.accessibilityHidden,
111
+ accessibilityLabel: props.removeLabel,
112
+ width: 46,
113
+ shrink: 0,
114
+ style: {
115
+ minHeight: 46,
116
+ borderRadius: 999,
117
+ paddingLeft: 0,
118
+ paddingRight: 0,
119
+ paddingTop: 0,
120
+ paddingBottom: 0,
121
+ color: colors.color,
122
+ opacity: 1,
123
+ },
124
+ onClick: () => {
125
+ if (!props.disabled) emit('remove')
126
+ },
127
+ })
128
+ : null,
129
+ ],
130
+ },
131
+ )
132
+ }
133
+ },
134
+ })
@@ -0,0 +1,312 @@
1
+ import { useButtonAction, themeKey, type MavisThemeContext } from '@getcortexlabs/mavis-core/vue'
2
+ import {
3
+ provide,
4
+ computed,
5
+ defineComponent,
6
+ h,
7
+ inject,
8
+ onBeforeUnmount,
9
+ ref,
10
+ shallowRef,
11
+ watch,
12
+ type PropType,
13
+ } from 'nativescript-vue'
14
+ import { Application, Utils, type EventData, type View } from '@nativescript/core'
15
+ import { JoltTransition } from '@rafaelaugusto/jolt/vue'
16
+ import { checkDialogLabels } from '@getcortexlabs/mavis-core'
17
+ import {
18
+ dialogProps,
19
+ dialogEmits,
20
+ useDialogState,
21
+ useMavisTheme,
22
+ } from '@getcortexlabs/mavis-core/vue'
23
+ import { useLayerHost } from '../layers.js'
24
+ import { systemBackKey } from '../system-back.js'
25
+ import { nativeViewOf } from '../native-view.js'
26
+ import { watchBack, setModal, safeAreaOf, contentInsets } from '../../native/sheet'
27
+ import { bindDialogFocus } from '../../native/dialog'
28
+ import { MBox, MColumn, MRow } from './layout.js'
29
+ import { MText } from './MText.js'
30
+ import { MButton } from './MButton.js'
31
+ import { MIcon } from './MIcon.js'
32
+
33
+ type Bridge = {
34
+ context: MavisThemeContext
35
+ props: Readonly<import('nativescript-vue').ExtractPropTypes<typeof dialogProps>>
36
+ state: ReturnType<typeof useDialogState>
37
+ theme: ReturnType<typeof useMavisTheme>['theme']
38
+ }
39
+ type Element = { nativeView: View }
40
+ const DialogLayer = defineComponent({
41
+ name: 'MDialogLayer',
42
+ props: { bridge: { type: Object as PropType<Bridge>, required: true } },
43
+ setup({ bridge }) {
44
+ useButtonAction()
45
+ provide(themeKey, bridge.context)
46
+ const { props, state, theme } = bridge
47
+ const claim = inject(systemBackKey, undefined)
48
+ const panel = shallowRef<Element>(),
49
+ title = shallowRef<View>()
50
+ const cancel = shallowRef<View>(),
51
+ confirm = shallowRef<View>()
52
+ const width = ref(320),
53
+ available = ref(600),
54
+ footerHeight = ref(56)
55
+ const padding = ref({ top: 24, right: 24, bottom: 24, left: 24 })
56
+ let host: View | undefined
57
+ let focus: ReturnType<typeof bindDialogFocus> | undefined
58
+ let releaseBack = () => {},
59
+ releaseClaim = () => {}
60
+ function size() {
61
+ if (!host) return
62
+ const area = safeAreaOf(host),
63
+ insets = contentInsets(host)
64
+ const bounds = host.getActualSize()
65
+ padding.value = {
66
+ top: area.top + 24,
67
+ right: insets.right + 24,
68
+ bottom: insets.bottom + 24,
69
+ left: insets.left + 24,
70
+ }
71
+ width.value = Math.max(0, Math.min(440, bounds.width - insets.left - insets.right - 48))
72
+ available.value = Math.max(170, bounds.height - area.top - insets.bottom - 48)
73
+ }
74
+ function release() {
75
+ host?.off('layoutChanged', size)
76
+ host = undefined
77
+ releaseBack()
78
+ releaseClaim()
79
+ releaseBack = releaseClaim = () => {}
80
+ focus?.dispose(Boolean(nativeViewOf(panel.value)?.page?.isLoaded && !Application.suspended))
81
+ focus = undefined
82
+ }
83
+ function entered() {
84
+ const views = {
85
+ panel: nativeViewOf(panel.value),
86
+ title: title.value,
87
+ cancel: cancel.value,
88
+ confirm: confirm.value,
89
+ }
90
+ if (!views.panel || !views.title || !views.cancel || !views.confirm) return
91
+ setModal(views.panel, true)
92
+ focus?.dispose(false)
93
+ focus = bindDialogFocus(
94
+ views as { panel: View; title: View; cancel: View; confirm: View },
95
+ () => state.request('escape'),
96
+ )
97
+ focus.update(props.loading)
98
+ }
99
+ watch(
100
+ () => props.loading,
101
+ (loading) => focus?.update(loading),
102
+ { flush: 'post' },
103
+ )
104
+ onBeforeUnmount(release)
105
+ return () => {
106
+ const { colors, radius } = theme.value
107
+ const danger = props.tone === 'danger'
108
+ const footerMax = Math.max(48, available.value - 122)
109
+ const bodyMax = Math.max(48, available.value - Math.min(footerHeight.value, footerMax) - 74)
110
+ return h(
111
+ JoltTransition,
112
+ {
113
+ appear: true,
114
+ enter: [{ opacity: [0, 1] }, { duration: 180 }],
115
+ leave: [{ opacity: 0 }, { duration: 120 }],
116
+ onAfterEnter: entered,
117
+ onAfterLeave: state.left,
118
+ },
119
+ {
120
+ default: () =>
121
+ state.visible.value
122
+ ? h(
123
+ 'GridLayout',
124
+ {
125
+ iosIgnoreSafeArea: true,
126
+ onLoaded: (event: EventData) => {
127
+ host = (event.object as View).parent as View
128
+ size()
129
+ host.on('layoutChanged', size)
130
+ releaseBack = watchBack((event) => {
131
+ event.cancel = true
132
+ state.request('back')
133
+ })
134
+ releaseClaim =
135
+ claim?.({
136
+ owns: () => state.presented.value,
137
+ back: () => state.request('back'),
138
+ }) ?? (() => {})
139
+ },
140
+ onUnloaded: release,
141
+ },
142
+ [
143
+ h('MavisBox', {
144
+ backgroundColor: 'rgba(16, 11, 28, 0.5)',
145
+ accessible: false,
146
+ accessibilityHidden: true,
147
+ onTap: () => state.request('backdrop'),
148
+ }),
149
+ h(
150
+ 'MavisBox',
151
+ {
152
+ ref: panel,
153
+ id: props.id,
154
+ rows: 'auto,auto',
155
+ marginTop: padding.value.top,
156
+ marginRight: padding.value.right,
157
+ marginBottom: padding.value.bottom,
158
+ marginLeft: padding.value.left,
159
+ width: width.value,
160
+ padding: 24,
161
+ horizontalAlignment: 'center',
162
+ verticalAlignment: 'middle',
163
+ borderWidth: 1,
164
+ borderColor: colors.border,
165
+ borderRadius: radius.lg,
166
+ backgroundColor: colors.surface,
167
+ },
168
+ [
169
+ h('ScrollView', { row: 0, style: { maxHeight: bodyMax } }, [
170
+ h(
171
+ MColumn,
172
+ { gap: 'md', verticalAlignment: 'top' },
173
+ {
174
+ default: () => [
175
+ h(
176
+ MBox,
177
+ {
178
+ width: 48,
179
+ height: 48,
180
+ radius: 'md',
181
+ style: { alignSelf: 'flex-start' },
182
+ backgroundColor: danger ? colors.elevated : colors.primarySoft,
183
+ },
184
+ {
185
+ default: () =>
186
+ h(MIcon, {
187
+ name: danger ? 'triangle-alert' : 'circle-check',
188
+ tone: danger ? 'danger' : 'primary',
189
+ size: 'lg',
190
+ horizontalAlignment: 'center',
191
+ verticalAlignment: 'middle',
192
+ }),
193
+ },
194
+ ),
195
+ h(MText, {
196
+ as: 'h2',
197
+ variant: 'heading',
198
+ text: props.title,
199
+ onLoaded: (event: EventData) => {
200
+ title.value = event.object as View
201
+ },
202
+ }),
203
+ props.description
204
+ ? h(MText, { text: props.description, tone: 'muted' })
205
+ : null,
206
+ ],
207
+ },
208
+ ),
209
+ ]),
210
+ h(
211
+ 'ScrollView',
212
+ { row: 1, marginTop: 24, style: { maxHeight: footerMax } },
213
+ [
214
+ h(
215
+ MRow,
216
+ {
217
+ gap: 'sm',
218
+ align: 'stretch',
219
+ verticalAlignment: 'top',
220
+ onLayoutChanged: (event: EventData) => {
221
+ footerHeight.value = (event.object as View).getActualSize().height
222
+ },
223
+ },
224
+ {
225
+ default: () => [
226
+ h(MButton, {
227
+ onLoaded: (event: EventData) => {
228
+ cancel.value = event.object as View
229
+ },
230
+ text: props.cancelLabel,
231
+ variant: 'secondary',
232
+ grow: 1,
233
+ disabled: props.loading,
234
+ style: { width: 0 },
235
+ onClick: () => state.request('cancel'),
236
+ }),
237
+ h(MButton, {
238
+ onLoaded: (event: EventData) => {
239
+ confirm.value = event.object as View
240
+ },
241
+ text: props.confirmLabel,
242
+ loading: props.loading,
243
+ loadingText: props.loadingLabel,
244
+ grow: 1,
245
+ style: {
246
+ width: 0,
247
+ ...(danger
248
+ ? { backgroundColor: colors.danger, color: colors.surface }
249
+ : {}),
250
+ },
251
+ onClick: state.confirm,
252
+ }),
253
+ ],
254
+ },
255
+ ),
256
+ ],
257
+ ),
258
+ ],
259
+ ),
260
+ ],
261
+ )
262
+ : null,
263
+ },
264
+ )
265
+ }
266
+ },
267
+ })
268
+
269
+ export const MDialog = defineComponent({
270
+ name: 'MDialog',
271
+ inheritAttrs: false,
272
+ props: dialogProps,
273
+ emits: dialogEmits,
274
+ setup(props, { emit }) {
275
+ const layers = useLayerHost('MDialog')
276
+ const state = useDialogState(props, emit)
277
+ const context = useMavisTheme()
278
+ const { theme } = context
279
+ const active = ref(false)
280
+ const bridge: Bridge = { props, state, theme, context }
281
+ watch(
282
+ () => props.open,
283
+ (open) => {
284
+ if (open && active.value) Utils.dismissKeyboard()
285
+ },
286
+ )
287
+ onBeforeUnmount(
288
+ layers.add({
289
+ component: DialogLayer,
290
+ props: { bridge },
291
+ presented: computed(() => active.value && state.presented.value),
292
+ }),
293
+ )
294
+ return () => {
295
+ checkDialogLabels(props.title, props.confirmLabel, props.cancelLabel, props.loadingLabel)
296
+ // The anchor observes a retained page even when its dialog is closed.
297
+ return h('MavisBox', {
298
+ visibility: 'collapse',
299
+ accessibilityHidden: true,
300
+ height: 0,
301
+ onLoaded: () => {
302
+ active.value = true
303
+ if (props.open) Utils.dismissKeyboard()
304
+ },
305
+ onUnloaded: () => {
306
+ if (!Application.suspended) state.request('navigation')
307
+ active.value = false
308
+ },
309
+ })
310
+ }
311
+ },
312
+ })
@@ -0,0 +1,96 @@
1
+ import { defineComponent, h, mergeProps, type SlotsType, type VNode } from 'nativescript-vue'
2
+ import { checkEmptyStateTitle } from '@getcortexlabs/mavis-core'
3
+ import { emptyStateProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
4
+ import { ActionChildren } from '../accessibility.js'
5
+ import { MColumn, MRow, MBox } from './layout.js'
6
+ import { MText } from './MText.js'
7
+ import { MIcon } from './MIcon.js'
8
+
9
+ export const MEmptyState = defineComponent({
10
+ name: 'MEmptyState',
11
+ inheritAttrs: false,
12
+ props: emptyStateProps,
13
+ slots: Object as SlotsType<{ illustration?: () => VNode[]; actions?: () => VNode[] }>,
14
+ setup(props, { attrs, slots }) {
15
+ const { theme } = useMavisTheme()
16
+ return () => {
17
+ checkEmptyStateTitle(props.title)
18
+ const { colors } = theme.value
19
+ const size = props.compact ? 64 : 88
20
+ const illustration = () =>
21
+ slots.illustration?.() ??
22
+ h(
23
+ MBox,
24
+ {
25
+ width: size,
26
+ height: size,
27
+ },
28
+ {
29
+ default: () => [
30
+ h(MBox, {
31
+ width: size,
32
+ height: size,
33
+ radius: 'full',
34
+ backgroundColor: colors[props.tone === 'primary' ? 'primarySoft' : 'accentSoft'],
35
+ }),
36
+ h(MIcon, {
37
+ name: props.icon,
38
+ size: props.compact ? 28 : 36,
39
+ tone: props.tone,
40
+ style: { horizontalAlignment: 'center', verticalAlignment: 'middle' },
41
+ }),
42
+ h(MBox, {
43
+ width: 18,
44
+ height: 18,
45
+ radius: 'full',
46
+ backgroundColor: colors[props.tone === 'primary' ? 'accent' : 'primary'],
47
+ style: { horizontalAlignment: 'right', verticalAlignment: 'top' },
48
+ }),
49
+ ],
50
+ },
51
+ )
52
+ return h(
53
+ MColumn,
54
+ mergeProps(attrs, {
55
+ id: props.id,
56
+ width: props.width,
57
+ grow: props.grow,
58
+ shrink: props.shrink,
59
+ accessibilityHidden: props.accessibilityHidden,
60
+ gap: props.compact ? 'md' : 'lg',
61
+ padding: props.compact ? 'lg' : '2xl',
62
+ align: 'stretch',
63
+ }),
64
+ {
65
+ default: () => [
66
+ h(
67
+ MColumn,
68
+ { align: 'center', accessibilityHidden: true },
69
+ { default: () => h(ActionChildren, { hidden: true }, { default: illustration }) },
70
+ ),
71
+ h(
72
+ MColumn,
73
+ { gap: 'sm' },
74
+ {
75
+ default: () => [
76
+ h(MText, {
77
+ text: props.title,
78
+ variant: props.compact ? 'heading' : 'title',
79
+ as: props.titleAs,
80
+ align: 'center',
81
+ }),
82
+ props.description
83
+ ? h(MText, { text: props.description, tone: 'muted', align: 'center' })
84
+ : null,
85
+ ],
86
+ },
87
+ ),
88
+ slots.actions
89
+ ? h(MRow, { gap: 'sm', wrap: true, justify: 'center' }, { default: slots.actions })
90
+ : null,
91
+ ],
92
+ },
93
+ )
94
+ }
95
+ },
96
+ })