@getcortexlabs/mavis 0.1.0-alpha.2 → 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 (413) 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 +4 -0
  15. package/dist/native/box.ios.d.ts.map +1 -1
  16. package/dist/native/box.ios.js +29 -1
  17. package/dist/native/box.ios.js.map +1 -1
  18. package/dist/native/button.ios.d.ts +13 -1
  19. package/dist/native/button.ios.d.ts.map +1 -1
  20. package/dist/native/button.ios.js +29 -1
  21. package/dist/native/button.ios.js.map +1 -1
  22. package/dist/native/checkbox.android.d.ts +7 -0
  23. package/dist/native/checkbox.android.d.ts.map +1 -0
  24. package/dist/native/checkbox.android.js +26 -0
  25. package/dist/native/checkbox.android.js.map +1 -0
  26. package/dist/native/checkbox.d.ts +7 -0
  27. package/dist/native/checkbox.d.ts.map +1 -0
  28. package/dist/native/checkbox.js +7 -0
  29. package/dist/native/checkbox.js.map +1 -0
  30. package/dist/native/composed-button.android.d.ts +4 -0
  31. package/dist/native/composed-button.android.d.ts.map +1 -0
  32. package/dist/native/composed-button.android.js +53 -0
  33. package/dist/native/composed-button.android.js.map +1 -0
  34. package/dist/native/composed-button.d.ts +3 -0
  35. package/dist/native/composed-button.d.ts.map +1 -0
  36. package/dist/native/composed-button.js +4 -0
  37. package/dist/native/composed-button.js.map +1 -0
  38. package/dist/native/dialog.android.d.ts +12 -0
  39. package/dist/native/dialog.android.d.ts.map +1 -0
  40. package/dist/native/dialog.android.js +46 -0
  41. package/dist/native/dialog.android.js.map +1 -0
  42. package/dist/native/dialog.d.ts +12 -0
  43. package/dist/native/dialog.d.ts.map +1 -0
  44. package/dist/native/dialog.ios.d.ts +12 -0
  45. package/dist/native/dialog.ios.d.ts.map +1 -0
  46. package/dist/native/dialog.ios.js +13 -0
  47. package/dist/native/dialog.ios.js.map +1 -0
  48. package/dist/native/dialog.js +4 -0
  49. package/dist/native/dialog.js.map +1 -0
  50. package/dist/native/dynamic-type.d.ts +15 -0
  51. package/dist/native/dynamic-type.d.ts.map +1 -0
  52. package/dist/native/dynamic-type.js +47 -0
  53. package/dist/native/dynamic-type.js.map +1 -0
  54. package/dist/native/flex-layout.ios.d.ts +10 -0
  55. package/dist/native/flex-layout.ios.d.ts.map +1 -1
  56. package/dist/native/flex-layout.ios.js +85 -0
  57. package/dist/native/flex-layout.ios.js.map +1 -1
  58. package/dist/native/input-action.d.ts +5 -0
  59. package/dist/native/input-action.d.ts.map +1 -0
  60. package/dist/native/input-action.js +13 -0
  61. package/dist/native/input-action.js.map +1 -0
  62. package/dist/native/keyboard-dismiss.android.d.ts +8 -0
  63. package/dist/native/keyboard-dismiss.android.d.ts.map +1 -0
  64. package/dist/native/keyboard-dismiss.android.js +9 -0
  65. package/dist/native/keyboard-dismiss.android.js.map +1 -0
  66. package/dist/native/keyboard-dismiss.d.ts +10 -0
  67. package/dist/native/keyboard-dismiss.d.ts.map +1 -0
  68. package/dist/native/keyboard-dismiss.ios.d.ts +8 -0
  69. package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -0
  70. package/dist/native/keyboard-dismiss.ios.js +91 -0
  71. package/dist/native/keyboard-dismiss.ios.js.map +1 -0
  72. package/dist/native/keyboard-dismiss.js +6 -0
  73. package/dist/native/keyboard-dismiss.js.map +1 -0
  74. package/dist/native/label.android.d.ts +12 -0
  75. package/dist/native/label.android.d.ts.map +1 -0
  76. package/dist/native/label.android.js +19 -0
  77. package/dist/native/label.android.js.map +1 -0
  78. package/dist/native/label.ios.d.ts +14 -1
  79. package/dist/native/label.ios.d.ts.map +1 -1
  80. package/dist/native/label.ios.js +37 -1
  81. package/dist/native/label.ios.js.map +1 -1
  82. package/dist/native/measure-memo.d.ts +37 -0
  83. package/dist/native/measure-memo.d.ts.map +1 -0
  84. package/dist/native/measure-memo.js +82 -0
  85. package/dist/native/measure-memo.js.map +1 -0
  86. package/dist/native/motion-surface.d.ts +9 -0
  87. package/dist/native/motion-surface.d.ts.map +1 -0
  88. package/dist/native/motion-surface.js +119 -0
  89. package/dist/native/motion-surface.js.map +1 -0
  90. package/dist/native/press.d.ts +5 -2
  91. package/dist/native/press.d.ts.map +1 -1
  92. package/dist/native/press.js +52 -8
  93. package/dist/native/press.js.map +1 -1
  94. package/dist/native/progress.d.ts +7 -0
  95. package/dist/native/progress.d.ts.map +1 -0
  96. package/dist/native/progress.js +77 -0
  97. package/dist/native/progress.js.map +1 -0
  98. package/dist/native/screen.android.d.ts +6 -0
  99. package/dist/native/screen.android.d.ts.map +1 -0
  100. package/dist/native/screen.android.js +8 -0
  101. package/dist/native/screen.android.js.map +1 -0
  102. package/dist/native/screen.d.ts +2 -0
  103. package/dist/native/screen.d.ts.map +1 -0
  104. package/dist/native/screen.js +3 -0
  105. package/dist/native/screen.js.map +1 -0
  106. package/dist/native/scroll-motion.d.ts +11 -0
  107. package/dist/native/scroll-motion.d.ts.map +1 -0
  108. package/dist/native/scroll-motion.js +94 -0
  109. package/dist/native/scroll-motion.js.map +1 -0
  110. package/dist/native/segmented.d.ts +14 -0
  111. package/dist/native/segmented.d.ts.map +1 -0
  112. package/dist/native/segmented.js +86 -0
  113. package/dist/native/segmented.js.map +1 -0
  114. package/dist/native/sheet.android.d.ts +18 -0
  115. package/dist/native/sheet.android.d.ts.map +1 -0
  116. package/dist/native/sheet.android.js +16 -0
  117. package/dist/native/sheet.android.js.map +1 -0
  118. package/dist/native/sheet.d.ts +21 -0
  119. package/dist/native/sheet.d.ts.map +1 -0
  120. package/dist/native/sheet.ios.d.ts +19 -0
  121. package/dist/native/sheet.ios.d.ts.map +1 -0
  122. package/dist/native/sheet.ios.js +41 -0
  123. package/dist/native/sheet.ios.js.map +1 -0
  124. package/dist/native/sheet.js +17 -0
  125. package/dist/native/sheet.js.map +1 -0
  126. package/dist/native/tabs.android.d.ts +3 -0
  127. package/dist/native/tabs.android.d.ts.map +1 -0
  128. package/dist/native/tabs.android.js +29 -0
  129. package/dist/native/tabs.android.js.map +1 -0
  130. package/dist/native/tabs.d.ts +3 -0
  131. package/dist/native/tabs.d.ts.map +1 -0
  132. package/dist/native/tabs.js +4 -0
  133. package/dist/native/tabs.js.map +1 -0
  134. package/dist/native/text-field.android.d.ts +1 -0
  135. package/dist/native/text-field.android.d.ts.map +1 -1
  136. package/dist/native/text-field.android.js +13 -0
  137. package/dist/native/text-field.android.js.map +1 -1
  138. package/dist/native/text-field.ios.d.ts +9 -0
  139. package/dist/native/text-field.ios.d.ts.map +1 -0
  140. package/dist/native/text-field.ios.js +52 -0
  141. package/dist/native/text-field.ios.js.map +1 -0
  142. package/dist/native/text-view.ios.d.ts +7 -0
  143. package/dist/native/text-view.ios.d.ts.map +1 -0
  144. package/dist/native/text-view.ios.js +10 -0
  145. package/dist/native/text-view.ios.js.map +1 -0
  146. package/dist/native/toast.android.d.ts +4 -0
  147. package/dist/native/toast.android.d.ts.map +1 -0
  148. package/dist/native/toast.android.js +10 -0
  149. package/dist/native/toast.android.js.map +1 -0
  150. package/dist/native/toast.d.ts +4 -0
  151. package/dist/native/toast.d.ts.map +1 -0
  152. package/dist/native/toast.ios.d.ts +4 -0
  153. package/dist/native/toast.ios.d.ts.map +1 -0
  154. package/dist/native/toast.ios.js +8 -0
  155. package/dist/native/toast.ios.js.map +1 -0
  156. package/dist/native/toast.js +5 -0
  157. package/dist/native/toast.js.map +1 -0
  158. package/dist/vue/components/ChoiceControl.d.ts +101 -0
  159. package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
  160. package/dist/vue/components/ChoiceControl.js +196 -0
  161. package/dist/vue/components/ChoiceControl.js.map +1 -0
  162. package/dist/vue/components/MAccordion.d.ts +109 -0
  163. package/dist/vue/components/MAccordion.d.ts.map +1 -0
  164. package/dist/vue/components/MAccordion.js +83 -0
  165. package/dist/vue/components/MAccordion.js.map +1 -0
  166. package/dist/vue/components/MAlert.d.ts +99 -0
  167. package/dist/vue/components/MAlert.d.ts.map +1 -0
  168. package/dist/vue/components/MAlert.js +126 -0
  169. package/dist/vue/components/MAlert.js.map +1 -0
  170. package/dist/vue/components/MAvatar.d.ts +74 -0
  171. package/dist/vue/components/MAvatar.d.ts.map +1 -0
  172. package/dist/vue/components/MAvatar.js +86 -0
  173. package/dist/vue/components/MAvatar.js.map +1 -0
  174. package/dist/vue/components/MBadge.d.ts +64 -0
  175. package/dist/vue/components/MBadge.d.ts.map +1 -0
  176. package/dist/vue/components/MBadge.js +30 -0
  177. package/dist/vue/components/MBadge.js.map +1 -0
  178. package/dist/vue/components/MButton.d.ts +57 -5
  179. package/dist/vue/components/MButton.d.ts.map +1 -1
  180. package/dist/vue/components/MButton.js +129 -11
  181. package/dist/vue/components/MButton.js.map +1 -1
  182. package/dist/vue/components/MCard.d.ts +23 -5
  183. package/dist/vue/components/MCard.d.ts.map +1 -1
  184. package/dist/vue/components/MCard.js +14 -4
  185. package/dist/vue/components/MCard.js.map +1 -1
  186. package/dist/vue/components/MCheckbox.d.ts +93 -0
  187. package/dist/vue/components/MCheckbox.d.ts.map +1 -0
  188. package/dist/vue/components/MCheckbox.js +26 -0
  189. package/dist/vue/components/MCheckbox.js.map +1 -0
  190. package/dist/vue/components/MChip.d.ts +107 -0
  191. package/dist/vue/components/MChip.d.ts.map +1 -0
  192. package/dist/vue/components/MChip.js +120 -0
  193. package/dist/vue/components/MChip.js.map +1 -0
  194. package/dist/vue/components/MDialog.d.ts +95 -0
  195. package/dist/vue/components/MDialog.d.ts.map +1 -0
  196. package/dist/vue/components/MDialog.js +245 -0
  197. package/dist/vue/components/MDialog.js.map +1 -0
  198. package/dist/vue/components/MEmptyState.d.ts +107 -0
  199. package/dist/vue/components/MEmptyState.d.ts.map +1 -0
  200. package/dist/vue/components/MEmptyState.js +79 -0
  201. package/dist/vue/components/MEmptyState.js.map +1 -0
  202. package/dist/vue/components/MInput.d.ts +62 -7
  203. package/dist/vue/components/MInput.d.ts.map +1 -1
  204. package/dist/vue/components/MInput.js +88 -14
  205. package/dist/vue/components/MInput.js.map +1 -1
  206. package/dist/vue/components/MListItem.d.ts +92 -0
  207. package/dist/vue/components/MListItem.d.ts.map +1 -0
  208. package/dist/vue/components/MListItem.js +53 -0
  209. package/dist/vue/components/MListItem.js.map +1 -0
  210. package/dist/vue/components/MProgress.d.ts +112 -0
  211. package/dist/vue/components/MProgress.d.ts.map +1 -0
  212. package/dist/vue/components/MProgress.js +75 -0
  213. package/dist/vue/components/MProgress.js.map +1 -0
  214. package/dist/vue/components/MRadioGroup.d.ts +93 -0
  215. package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
  216. package/dist/vue/components/MRadioGroup.js +57 -0
  217. package/dist/vue/components/MRadioGroup.js.map +1 -0
  218. package/dist/vue/components/MReveal.d.ts.map +1 -1
  219. package/dist/vue/components/MReveal.js +5 -7
  220. package/dist/vue/components/MReveal.js.map +1 -1
  221. package/dist/vue/components/MScreen.d.ts +18 -0
  222. package/dist/vue/components/MScreen.d.ts.map +1 -1
  223. package/dist/vue/components/MScreen.js +68 -5
  224. package/dist/vue/components/MScreen.js.map +1 -1
  225. package/dist/vue/components/MSegmentedControl.d.ts +85 -0
  226. package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
  227. package/dist/vue/components/MSegmentedControl.js +172 -0
  228. package/dist/vue/components/MSegmentedControl.js.map +1 -0
  229. package/dist/vue/components/MSelect.d.ts +130 -0
  230. package/dist/vue/components/MSelect.d.ts.map +1 -0
  231. package/dist/vue/components/MSelect.js +158 -0
  232. package/dist/vue/components/MSelect.js.map +1 -0
  233. package/dist/vue/components/MSeparator.d.ts +54 -0
  234. package/dist/vue/components/MSeparator.d.ts.map +1 -0
  235. package/dist/vue/components/MSeparator.js +36 -0
  236. package/dist/vue/components/MSeparator.js.map +1 -0
  237. package/dist/vue/components/MSheet.d.ts +101 -0
  238. package/dist/vue/components/MSheet.d.ts.map +1 -0
  239. package/dist/vue/components/MSheet.js +313 -0
  240. package/dist/vue/components/MSheet.js.map +1 -0
  241. package/dist/vue/components/MSkeleton.d.ts +70 -0
  242. package/dist/vue/components/MSkeleton.d.ts.map +1 -0
  243. package/dist/vue/components/MSkeleton.js +87 -0
  244. package/dist/vue/components/MSkeleton.js.map +1 -0
  245. package/dist/vue/components/MSlider.d.ts +1 -1
  246. package/dist/vue/components/MSlider.d.ts.map +1 -1
  247. package/dist/vue/components/MSlider.js +2 -1
  248. package/dist/vue/components/MSlider.js.map +1 -1
  249. package/dist/vue/components/MSwitch.d.ts +79 -0
  250. package/dist/vue/components/MSwitch.d.ts.map +1 -0
  251. package/dist/vue/components/MSwitch.js +163 -0
  252. package/dist/vue/components/MSwitch.js.map +1 -0
  253. package/dist/vue/components/MTabs.d.ts +91 -0
  254. package/dist/vue/components/MTabs.d.ts.map +1 -0
  255. package/dist/vue/components/MTabs.js +245 -0
  256. package/dist/vue/components/MTabs.js.map +1 -0
  257. package/dist/vue/components/MText.d.ts +16 -7
  258. package/dist/vue/components/MText.d.ts.map +1 -1
  259. package/dist/vue/components/MText.js +43 -17
  260. package/dist/vue/components/MText.js.map +1 -1
  261. package/dist/vue/components/MToast.d.ts +23 -0
  262. package/dist/vue/components/MToast.d.ts.map +1 -0
  263. package/dist/vue/components/MToast.js +242 -0
  264. package/dist/vue/components/MToast.js.map +1 -0
  265. package/dist/vue/index.d.ts +31 -4
  266. package/dist/vue/index.d.ts.map +1 -1
  267. package/dist/vue/index.js +48 -4
  268. package/dist/vue/index.js.map +1 -1
  269. package/dist/vue/layers.d.ts +19 -0
  270. package/dist/vue/layers.d.ts.map +1 -0
  271. package/dist/vue/layers.js +26 -0
  272. package/dist/vue/layers.js.map +1 -0
  273. package/dist/vue/native-view.d.ts +6 -0
  274. package/dist/vue/native-view.d.ts.map +1 -0
  275. package/dist/vue/native-view.js +5 -0
  276. package/dist/vue/native-view.js.map +1 -0
  277. package/dist/vue/props.d.ts +12 -11
  278. package/dist/vue/props.d.ts.map +1 -1
  279. package/dist/vue/props.js +25 -10
  280. package/dist/vue/props.js.map +1 -1
  281. package/dist/vue/reveal-motion.d.ts +13 -0
  282. package/dist/vue/reveal-motion.d.ts.map +1 -0
  283. package/dist/vue/reveal-motion.js +55 -0
  284. package/dist/vue/reveal-motion.js.map +1 -0
  285. package/dist/vue/system-back.d.ts +11 -0
  286. package/dist/vue/system-back.d.ts.map +1 -0
  287. package/dist/vue/system-back.js +2 -0
  288. package/dist/vue/system-back.js.map +1 -0
  289. package/dist/vue/use-motion-surface.d.ts +8 -0
  290. package/dist/vue/use-motion-surface.d.ts.map +1 -0
  291. package/dist/vue/use-motion-surface.js +75 -0
  292. package/dist/vue/use-motion-surface.js.map +1 -0
  293. package/dist/vue/use-press.d.ts +1 -1
  294. package/dist/vue/use-press.d.ts.map +1 -1
  295. package/dist/vue/use-press.js +12 -4
  296. package/dist/vue/use-press.js.map +1 -1
  297. package/dist/vue/use-scroll-motion.d.ts +7 -0
  298. package/dist/vue/use-scroll-motion.d.ts.map +1 -0
  299. package/dist/vue/use-scroll-motion.js +30 -0
  300. package/dist/vue/use-scroll-motion.js.map +1 -0
  301. package/package.json +3 -3
  302. package/platforms/android/java/com/mavis/ui/Box.java +38 -3
  303. package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
  304. package/platforms/android/java/com/mavis/ui/FlexLayout.java +80 -4
  305. package/platforms/android/java/com/mavis/ui/MeasureMemo.java +145 -0
  306. package/platforms/android/java/com/mavis/ui/Screen.java +108 -0
  307. package/src/native/avatar-image.ts +9 -0
  308. package/src/native/avatar-label.android.ts +14 -0
  309. package/src/native/avatar-label.ts +1 -0
  310. package/src/native/box.ios.ts +48 -1
  311. package/src/native/button.ios.ts +53 -1
  312. package/src/native/checkbox.android.ts +35 -0
  313. package/src/native/checkbox.ts +9 -0
  314. package/src/native/composed-button.android.ts +74 -0
  315. package/src/native/composed-button.ts +9 -0
  316. package/src/native/dialog.android.ts +56 -0
  317. package/src/native/dialog.ios.ts +23 -0
  318. package/src/native/dialog.ts +10 -0
  319. package/src/native/dynamic-type.ts +71 -0
  320. package/src/native/flex-layout.ios.ts +113 -0
  321. package/src/native/input-action.ts +15 -0
  322. package/src/native/keyboard-dismiss.android.ts +17 -0
  323. package/src/native/keyboard-dismiss.ios.ts +124 -0
  324. package/src/native/keyboard-dismiss.ts +14 -0
  325. package/src/native/label.android.ts +27 -0
  326. package/src/native/label.ios.ts +54 -1
  327. package/src/native/measure-memo.ts +116 -0
  328. package/src/native/motion-surface.ts +137 -0
  329. package/src/native/press.ts +52 -10
  330. package/src/native/progress.ts +78 -0
  331. package/src/native/screen.android.ts +12 -0
  332. package/src/native/screen.ts +2 -0
  333. package/src/native/scroll-motion.ts +101 -0
  334. package/src/native/segmented.ts +95 -0
  335. package/src/native/sheet.android.ts +24 -0
  336. package/src/native/sheet.ios.ts +52 -0
  337. package/src/native/sheet.ts +26 -0
  338. package/src/native/tabs.android.ts +58 -0
  339. package/src/native/tabs.ts +8 -0
  340. package/src/native/text-field.android.ts +19 -0
  341. package/src/native/text-field.ios.ts +53 -0
  342. package/src/native/text-view.ios.ts +10 -0
  343. package/src/native/toast.android.ts +9 -0
  344. package/src/native/toast.ios.ts +13 -0
  345. package/src/native/toast.ts +6 -0
  346. package/src/vue/components/ChoiceControl.ts +238 -0
  347. package/src/vue/components/MAccordion.ts +123 -0
  348. package/src/vue/components/MAlert.ts +156 -0
  349. package/src/vue/components/MAvatar.ts +103 -0
  350. package/src/vue/components/MBadge.ts +34 -0
  351. package/src/vue/components/MButton.ts +176 -9
  352. package/src/vue/components/MCard.ts +23 -3
  353. package/src/vue/components/MCheckbox.ts +25 -0
  354. package/src/vue/components/MChip.ts +134 -0
  355. package/src/vue/components/MDialog.ts +312 -0
  356. package/src/vue/components/MEmptyState.ts +96 -0
  357. package/src/vue/components/MInput.ts +96 -12
  358. package/src/vue/components/MListItem.ts +66 -0
  359. package/src/vue/components/MProgress.ts +94 -0
  360. package/src/vue/components/MRadioGroup.ts +64 -0
  361. package/src/vue/components/MReveal.ts +6 -7
  362. package/src/vue/components/MScreen.ts +93 -5
  363. package/src/vue/components/MSegmentedControl.ts +214 -0
  364. package/src/vue/components/MSelect.ts +185 -0
  365. package/src/vue/components/MSeparator.ts +40 -0
  366. package/src/vue/components/MSheet.ts +375 -0
  367. package/src/vue/components/MSkeleton.ts +100 -0
  368. package/src/vue/components/MSlider.ts +7 -1
  369. package/src/vue/components/MSwitch.ts +187 -0
  370. package/src/vue/components/MTabs.ts +302 -0
  371. package/src/vue/components/MText.ts +37 -6
  372. package/src/vue/components/MToast.ts +289 -0
  373. package/src/vue/index.ts +90 -4
  374. package/src/vue/layers.ts +48 -0
  375. package/src/vue/native-view.ts +6 -0
  376. package/src/vue/props.ts +37 -12
  377. package/src/vue/reveal-motion.ts +61 -0
  378. package/src/vue/system-back.ts +12 -0
  379. package/src/vue/use-motion-surface.ts +77 -0
  380. package/src/vue/use-press.ts +12 -4
  381. package/src/vue/use-scroll-motion.ts +31 -0
  382. package/dist/native/input-description.android.d.ts +0 -4
  383. package/dist/native/input-description.android.d.ts.map +0 -1
  384. package/dist/native/input-description.android.js +0 -18
  385. package/dist/native/input-description.android.js.map +0 -1
  386. package/dist/theme/resolve.d.ts +0 -3
  387. package/dist/theme/resolve.d.ts.map +0 -1
  388. package/dist/theme/resolve.js +0 -8
  389. package/dist/theme/resolve.js.map +0 -1
  390. package/dist/theme/themes.d.ts +0 -6
  391. package/dist/theme/themes.d.ts.map +0 -1
  392. package/dist/theme/themes.js +0 -83
  393. package/dist/theme/themes.js.map +0 -1
  394. package/dist/theme/types.d.ts +0 -50
  395. package/dist/theme/types.d.ts.map +0 -1
  396. package/dist/theme/types.js +0 -2
  397. package/dist/theme/types.js.map +0 -1
  398. package/dist/vue/global-components.d.ts +0 -21
  399. package/dist/vue/global-components.d.ts.map +0 -1
  400. package/dist/vue/global-components.js +0 -2
  401. package/dist/vue/global-components.js.map +0 -1
  402. package/dist/vue/layout-context.d.ts +0 -5
  403. package/dist/vue/layout-context.d.ts.map +0 -1
  404. package/dist/vue/layout-context.js +0 -7
  405. package/dist/vue/layout-context.js.map +0 -1
  406. package/dist/vue/text-content.d.ts +0 -4
  407. package/dist/vue/text-content.d.ts.map +0 -1
  408. package/dist/vue/text-content.js +0 -17
  409. package/dist/vue/text-content.js.map +0 -1
  410. package/dist/vue/theme.d.ts +0 -177
  411. package/dist/vue/theme.d.ts.map +0 -1
  412. package/dist/vue/theme.js +0 -17
  413. package/dist/vue/theme.js.map +0 -1
@@ -0,0 +1,56 @@
1
+ import type { View } from '@nativescript/core'
2
+ export interface DialogFocusViews {
3
+ panel: View
4
+ title: View
5
+ cancel: View
6
+ confirm: View
7
+ }
8
+ declare const android: {
9
+ view: {
10
+ View: {
11
+ OnKeyListener: new (handler: {
12
+ onKey(
13
+ view: unknown,
14
+ code: number,
15
+ event: { getAction(): number; isShiftPressed(): boolean },
16
+ ): boolean
17
+ }) => unknown
18
+ }
19
+ }
20
+ }
21
+ export function bindDialogFocus(views: DialogFocusViews, escape: () => void) {
22
+ const panel = views.panel.android
23
+ const cancel = views.cancel.android
24
+ const confirm = views.confirm.android
25
+ const previous = panel.getRootView().findFocus()
26
+ let busy = false
27
+ // Touch-focusable buttons consume their first tap to focus instead of clicking.
28
+ // Only the busy panel needs that behavior; buttons retain Android's defaults.
29
+ panel.setFocusableInTouchMode(true)
30
+ const listener = new android.view.View.OnKeyListener({
31
+ onKey(view, code, event) {
32
+ if (event.getAction() !== 0) return false
33
+ if (code === 111) {
34
+ escape()
35
+ return true
36
+ }
37
+ if (code !== 61) return false
38
+ if (busy) panel.requestFocus()
39
+ else if (view === cancel) confirm.requestFocus()
40
+ else if (view === confirm) cancel.requestFocus()
41
+ else (event.isShiftPressed() ? confirm : cancel).requestFocus()
42
+ return true
43
+ },
44
+ })
45
+ for (const view of [panel, cancel, confirm]) view.setOnKeyListener(listener)
46
+ return {
47
+ update(loading: boolean) {
48
+ busy = loading
49
+ ;(loading ? panel : cancel).requestFocus()
50
+ },
51
+ dispose(restore: boolean) {
52
+ for (const view of [panel, cancel, confirm]) view.setOnKeyListener(null)
53
+ if (restore && previous?.isAttachedToWindow()) previous.requestFocus()
54
+ },
55
+ }
56
+ }
@@ -0,0 +1,23 @@
1
+ import type { View } from '@nativescript/core'
2
+ import { notifyAccessibilityLayout } from './accessibility-layout'
3
+ export interface DialogFocusViews {
4
+ panel: View
5
+ title: View
6
+ cancel: View
7
+ confirm: View
8
+ }
9
+ declare function UIAccessibilityFocusedElement(technology: string): unknown
10
+ declare const UIAccessibilityNotificationVoiceOverIdentifier: string
11
+ declare const UIAccessibilityLayoutChangedNotification: number
12
+ declare function UIAccessibilityPostNotification(notification: number, argument: unknown): void
13
+ export function bindDialogFocus(views: DialogFocusViews, _escape: () => void) {
14
+ const previous = UIAccessibilityFocusedElement(UIAccessibilityNotificationVoiceOverIdentifier)
15
+ notifyAccessibilityLayout(views.title)
16
+ return {
17
+ update(_loading: boolean) {},
18
+ dispose(restore: boolean) {
19
+ if (restore && previous)
20
+ UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, previous)
21
+ },
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import type { View } from '@nativescript/core'
2
+ export interface DialogFocusViews {
3
+ panel: View
4
+ title: View
5
+ cancel: View
6
+ confirm: View
7
+ }
8
+ export function bindDialogFocus(_views: DialogFocusViews, _escape: () => void) {
9
+ return { update(_loading: boolean) {}, dispose(_restore: boolean) {} }
10
+ }
@@ -0,0 +1,71 @@
1
+ import { Font, type TextBase } from '@nativescript/core'
2
+ import type { TextVariant } from '@getcortexlabs/mavis-core'
3
+
4
+ interface Metrics {
5
+ scaledValueForValueCompatibleWithTraitCollection(value: number, traits: unknown): number
6
+ }
7
+ declare const UIApplication: { sharedApplication: { preferredContentSizeCategory: string } }
8
+ declare const UITraitCollection: {
9
+ traitCollectionWithPreferredContentSizeCategory(category: string): unknown
10
+ }
11
+ declare const UIFontMetrics: { metricsForTextStyle(style: string): Metrics }
12
+ declare const UIButton: unknown
13
+ declare const UIFontTextStyleLargeTitle: string
14
+ declare const UIFontTextStyleTitle1: string
15
+ declare const UIFontTextStyleTitle3: string
16
+ declare const UIFontTextStyleBody: string
17
+ declare const UIFontTextStyleFootnote: string
18
+ declare const UIFontTextStyleCaption2: string
19
+
20
+ export interface DynamicTypeView extends TextBase {
21
+ dynamicTypeStyle?: TextVariant
22
+ }
23
+ interface NativeText {
24
+ font: { pointSize: number }
25
+ titleLabel?: { font: { pointSize: number } }
26
+ }
27
+
28
+ // The iOS text style whose default size is closest to each Mavis variant.
29
+ const textStyle = (variant: TextVariant) =>
30
+ ({
31
+ display: UIFontTextStyleLargeTitle,
32
+ title: UIFontTextStyleTitle1,
33
+ heading: UIFontTextStyleTitle3,
34
+ body: UIFontTextStyleBody,
35
+ caption: UIFontTextStyleFootnote,
36
+ overline: UIFontTextStyleCaption2,
37
+ })[variant]
38
+
39
+ /**
40
+ * The ratio iOS applies to a font of `size` points in the view's text style at the current
41
+ * content size category. Core maps the categories to its own table, which halves text at the
42
+ * smallest size and snaps any other value back to it, so Mavis reads the system's Dynamic Type
43
+ * curve instead. The curve is not linear since iOS 17, so the ratio depends on the size.
44
+ */
45
+ export function dynamicTypeScale(view: DynamicTypeView, size: number): number {
46
+ if (!view.iosAccessibilityAdjustsFontSize || !(size > 0)) return 1
47
+ const category = UIApplication.sharedApplication.preferredContentSizeCategory
48
+ const traits = UITraitCollection.traitCollectionWithPreferredContentSizeCategory(category)
49
+ const metrics = UIFontMetrics.metricsForTextStyle(textStyle(view.dynamicTypeStyle ?? 'body'))
50
+ let scale = metrics.scaledValueForValueCompatibleWithTraitCollection(size, traits) / size
51
+ const { iosAccessibilityMinFontScale: min, iosAccessibilityMaxFontScale: max } = view
52
+ if (min && min > scale) scale = min
53
+ if (max && max < scale) scale = max
54
+ return scale
55
+ }
56
+
57
+ /** Core's font scale setter with the system ratio in place of Core's table. */
58
+ export function applyDynamicType(view: DynamicTypeView) {
59
+ const native = view.nativeTextViewProtected as NativeText | undefined
60
+ if (!native) return
61
+ const label =
62
+ native instanceof (UIButton as never) && native.titleLabel ? native.titleLabel : native
63
+ const font = view.style.fontInternal || Font.default.withFontSize(label.font.pointSize)
64
+ const scale = dynamicTypeScale(view, font.fontSize)
65
+ if (font.fontScale !== scale) {
66
+ view.style.fontInternal = font.withFontScale(scale)
67
+ view.requestLayout()
68
+ } else if (!view.style.fontInternal) {
69
+ view.style.fontInternal = font
70
+ }
71
+ }
@@ -1,9 +1,19 @@
1
1
  import { FlexboxLayout, Utils, type View } from '@nativescript/core'
2
2
  import { applyColumnShrink } from './flex-children'
3
+ import {
4
+ layoutChildren,
5
+ recordMeasurement,
6
+ reuseMeasurement,
7
+ type MeasureRecord,
8
+ } from './measure-memo'
3
9
 
4
10
  // Core 9.1.3 computes row heights before growing children. This adapter runs after width
5
11
  // allocation and before cross-axis alignment; no global prototype or consumer styles change.
6
12
  interface FlexMeasurement {
13
+ _checkSizeConstraints(child: View): void
14
+ _stretchViewHorizontally(child: View, crossSize: number): void
15
+ _currentWidthMeasureSpec: number
16
+ _currentHeightMeasureSpec: number
7
17
  _determineMainSize(direction: string, widthSpec: number, heightSpec: number): void
8
18
  _flexLines: {
9
19
  _itemCount: number
@@ -12,6 +22,8 @@ interface FlexMeasurement {
12
22
  _gapLengthInMainSize: number
13
23
  }[]
14
24
  _getReorderedChildAt(index: number): View
25
+ _getLargestMainSize(): number
26
+ _getSumOfCrossSize(): number
15
27
  effectiveRowGap: number
16
28
  }
17
29
 
@@ -19,6 +31,106 @@ const { layout } = Utils
19
31
  const base = FlexboxLayout.prototype as unknown as FlexMeasurement
20
32
 
21
33
  export class MavisFlexLayout extends FlexboxLayout {
34
+ measureRecord?: MeasureRecord
35
+
36
+ // Core's iOS Flexbox omits borders from its content insets. Keep the adjustment local
37
+ // to measurement/layout and leave the declared padding and derived values intact afterwards.
38
+ private withBorderPadding(run: () => void) {
39
+ const left = this.effectivePaddingLeft
40
+ const right = this.effectivePaddingRight
41
+ const top = this.effectivePaddingTop
42
+ const bottom = this.effectivePaddingBottom
43
+ this.effectivePaddingLeft += this.effectiveBorderLeftWidth
44
+ this.effectivePaddingRight += this.effectiveBorderRightWidth
45
+ this.effectivePaddingTop += this.effectiveBorderTopWidth
46
+ this.effectivePaddingBottom += this.effectiveBorderBottomWidth
47
+ try {
48
+ run()
49
+ } finally {
50
+ this.effectivePaddingLeft = left
51
+ this.effectivePaddingRight = right
52
+ this.effectivePaddingTop = top
53
+ this.effectivePaddingBottom = bottom
54
+ }
55
+ }
56
+
57
+ onMeasure(widthSpec: number, heightSpec: number) {
58
+ this.withBorderPadding(() => super.onMeasure(widthSpec, heightSpec))
59
+ }
60
+
61
+ onLayout(left: number, top: number, right: number, bottom: number) {
62
+ this.withBorderPadding(() => super.onLayout(left, top, right, bottom))
63
+ }
64
+
65
+ _checkSizeConstraints(child: View) {
66
+ const measurement = this as unknown as FlexMeasurement
67
+ const width = child.width
68
+ const spec = measurement._currentWidthMeasureSpec
69
+ if (
70
+ typeof width === 'object' &&
71
+ width.unit === '%' &&
72
+ layout.getMeasureSpecMode(spec) !== layout.UNSPECIFIED
73
+ ) {
74
+ // Core initially resolves percentages against the outer request. Correct the derived
75
+ // size before it forms flex lines, so wrapping/growth/shrink use the content-box basis.
76
+ child.effectiveWidth =
77
+ Math.max(
78
+ 0,
79
+ layout.getMeasureSpecSize(spec) - this.effectivePaddingLeft - this.effectivePaddingRight,
80
+ ) * width.value
81
+ this.measureAtWidth(child, child.effectiveWidth, measurement._currentHeightMeasureSpec)
82
+ }
83
+ base._checkSizeConstraints.call(this, child)
84
+ }
85
+
86
+ _stretchViewHorizontally(child: View, crossSize: number) {
87
+ // A declared width wins over alignItems=stretch, as it does in CSS flex layout.
88
+ if (child.effectiveWidth < 0) base._stretchViewHorizontally.call(this, child, crossSize)
89
+ }
90
+
91
+ measure(widthSpec: number, heightSpec: number) {
92
+ if (reuseMeasurement(this, widthSpec, heightSpec)) return
93
+ super.measure(widthSpec, heightSpec)
94
+ recordMeasurement(
95
+ this,
96
+ widthSpec,
97
+ heightSpec,
98
+ layoutChildren(this),
99
+ this.contentExceeds(widthSpec, heightSpec),
100
+ )
101
+ }
102
+
103
+ // Core measures a looser request without shrinking, so its lines tell whether the content
104
+ // wanted more room than the request allowed.
105
+ private contentExceeds(widthSpec: number, heightSpec: number) {
106
+ const measurement = this as unknown as FlexMeasurement
107
+ const column = this.flexDirection.startsWith('column')
108
+ const main = measurement._getLargestMainSize()
109
+ const cross = measurement._getSumOfCrossSize()
110
+ const maxHeight = column
111
+ ? main
112
+ : cross +
113
+ this.effectivePaddingTop +
114
+ this.effectivePaddingBottom +
115
+ this.effectiveBorderTopWidth +
116
+ this.effectiveBorderBottomWidth
117
+ const maxWidth = column
118
+ ? cross +
119
+ this.effectivePaddingLeft +
120
+ this.effectivePaddingRight +
121
+ this.effectiveBorderLeftWidth +
122
+ this.effectiveBorderRightWidth
123
+ : main
124
+ const exceeds = (spec: number, size: number) =>
125
+ layout.getMeasureSpecMode(spec) === layout.AT_MOST && layout.getMeasureSpecSize(spec) < size
126
+ return exceeds(heightSpec, maxHeight) || exceeds(widthSpec, maxWidth)
127
+ }
128
+
129
+ requestLayout() {
130
+ this.measureRecord = undefined
131
+ super.requestLayout()
132
+ }
133
+
22
134
  _registerLayoutChild(child: View) {
23
135
  super._registerLayoutChild(child)
24
136
  applyColumnShrink(this, child)
@@ -42,6 +154,7 @@ export class MavisFlexLayout extends FlexboxLayout {
42
154
  for (let i = 0; i < line._itemCount; i++, index++) {
43
155
  const child = measurement._getReorderedChildAt(index)
44
156
  if (!child || child.isCollapsed) continue
157
+ if (child.effectiveWidth >= 0) continue
45
158
  const alignSelf = FlexboxLayout.getAlignSelf(child)
46
159
  if (alignSelf !== 'auto' && alignSelf !== 'stretch') continue
47
160
  const oldHeight = child.getMeasuredHeight()
@@ -0,0 +1,15 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ const actions = new WeakMap<object, () => boolean>()
4
+
5
+ /** An input's own action is part of the active edit, not a tap outside it. */
6
+ export function keepEditingOn(action: View, editor: () => View | undefined): () => void {
7
+ const native = action.ios as object | undefined
8
+ if (!native) return () => {}
9
+ actions.set(native, () => editor()?.ios?.isFirstResponder === true)
10
+ return () => actions.delete(native)
11
+ }
12
+
13
+ export function isEditingAction(native: object) {
14
+ return actions.get(native)?.() ?? false
15
+ }
@@ -0,0 +1,17 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ export interface KeyboardDismissal {
4
+ tap: boolean
5
+ drag: boolean
6
+ }
7
+ interface ScreenView {
8
+ setKeyboardDismissal(onTap: boolean, onDrag: boolean): void
9
+ }
10
+
11
+ /** The container is a `com.mavis.ui.Screen`, which watches every touch of the page. */
12
+ export function dismissKeyboardOn(container: View, options: KeyboardDismissal): () => void {
13
+ const screen = container.android as Partial<ScreenView> | undefined
14
+ if (!screen?.setKeyboardDismissal) return () => {}
15
+ screen.setKeyboardDismissal(options.tap, options.drag)
16
+ return () => screen.setKeyboardDismissal?.(false, false)
17
+ }
@@ -0,0 +1,124 @@
1
+ import { ScrollView, type View } from '@nativescript/core'
2
+ import { isEditingAction } from './input-action'
3
+
4
+ export interface KeyboardDismissal {
5
+ tap: boolean
6
+ drag: boolean
7
+ }
8
+ interface NativeView {
9
+ superview: NativeView | null
10
+ subviews: { count: number; objectAtIndex(index: number): NativeView }
11
+ isFirstResponder: boolean
12
+ isEqual(other: NativeView): boolean
13
+ endEditing(force: boolean): boolean
14
+ addGestureRecognizer(recognizer: Recognizer): void
15
+ removeGestureRecognizer(recognizer: Recognizer): void
16
+ }
17
+ interface Recognizer {
18
+ view: NativeView
19
+ delegate: unknown
20
+ cancelsTouchesInView: boolean
21
+ delaysTouchesEnded: boolean
22
+ }
23
+ interface NativeClass {
24
+ extend(members: object, options: object): { new (): object }
25
+ }
26
+ declare const NSObject: NativeClass
27
+ declare const UITapGestureRecognizer: {
28
+ alloc(): { initWithTargetAction(target: object, action: string): Recognizer }
29
+ }
30
+ declare const UIGestureRecognizerDelegate: unknown
31
+ declare const UITextField: unknown
32
+ declare const UITextView: unknown
33
+ declare const UIGestureRecognizer: unknown
34
+ declare const interop: { types: { void: unknown } }
35
+
36
+ const editor = (view: NativeView | null) => {
37
+ for (let current = view; current; current = current.superview) {
38
+ if (isEditingAction(current)) return true
39
+ if (current instanceof (UITextField as never) || current instanceof (UITextView as never))
40
+ return true
41
+ }
42
+ return false
43
+ }
44
+
45
+ const firstResponder = (view: NativeView): NativeView | null => {
46
+ if (view.isFirstResponder) return view
47
+ const subviews = view.subviews
48
+ for (let index = 0; index < subviews.count; index++) {
49
+ const found = firstResponder(subviews.objectAtIndex(index))
50
+ if (found) return found
51
+ }
52
+ return null
53
+ }
54
+
55
+ // The recognizer only observes: it never cancels or delays the touches of the controls below
56
+ // it, and it recognizes together with the gesture recognizers of Core and Jolt. It takes a
57
+ // touch only while an editor is active and the touch is not on an editor. UIKit runs the tap
58
+ // action after the control's own action, so a control that focused another editor meanwhile
59
+ // keeps that focus.
60
+ let editing: NativeView | null = null
61
+ let Delegate: { new (): object } | undefined
62
+ let Target: { new (): object } | undefined
63
+ function classes() {
64
+ Delegate ??= NSObject.extend(
65
+ {
66
+ gestureRecognizerShouldReceiveTouch(recognizer: Recognizer, touch: { view: NativeView }) {
67
+ editing = editor(touch.view) ? null : firstResponder(recognizer.view)
68
+ return editing !== null
69
+ },
70
+ gestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer() {
71
+ return true
72
+ },
73
+ },
74
+ { protocols: [UIGestureRecognizerDelegate] },
75
+ )
76
+ Target ??= NSObject.extend(
77
+ {
78
+ dismiss(recognizer: Recognizer) {
79
+ const current = firstResponder(recognizer.view)
80
+ if (editing && current?.isEqual(editing)) recognizer.view.endEditing(true)
81
+ editing = null
82
+ },
83
+ },
84
+ { exposedMethods: { dismiss: { returns: interop.types.void, params: [UIGestureRecognizer] } } },
85
+ )
86
+ return { Delegate, Target }
87
+ }
88
+
89
+ /** A tap recognizer on the page container; the scroll view follows the drag with the keyboard. */
90
+ export function dismissKeyboardOn(container: View, options: KeyboardDismissal): () => void {
91
+ const native = container.ios as NativeView | undefined
92
+ if (!native) return () => {}
93
+ let recognizer: Recognizer | undefined
94
+ // The recognizer keeps neither object alive for the runtime: hold both until release.
95
+ let delegate: object | undefined
96
+ let target: object | undefined
97
+ if (options.tap) {
98
+ const { Delegate, Target } = classes()
99
+ delegate = new Delegate()
100
+ target = new Target()
101
+ recognizer = UITapGestureRecognizer.alloc().initWithTargetAction(target, 'dismiss')
102
+ recognizer.cancelsTouchesInView = false
103
+ recognizer.delaysTouchesEnded = false
104
+ recognizer.delegate = delegate
105
+ native.addGestureRecognizer(recognizer)
106
+ }
107
+ let scroll: ScrollView | undefined
108
+ container.eachChildView((child) => {
109
+ if (child instanceof ScrollView) scroll = child
110
+ return !scroll
111
+ })
112
+ // UIScrollViewKeyboardDismissMode: none (0) or interactive (2).
113
+ if (scroll?.ios) scroll.ios.keyboardDismissMode = options.drag ? 2 : 0
114
+ return () => {
115
+ if (recognizer) {
116
+ native.removeGestureRecognizer(recognizer)
117
+ recognizer.delegate = null
118
+ }
119
+ recognizer = undefined
120
+ delegate = undefined
121
+ target = undefined
122
+ if (scroll?.ios) scroll.ios.keyboardDismissMode = 0
123
+ }
124
+ }
@@ -0,0 +1,14 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ export interface KeyboardDismissal {
4
+ /** A tap anywhere on the page that is not an editor. */
5
+ tap: boolean
6
+ /** A drag of the scrolling content. */
7
+ drag: boolean
8
+ }
9
+
10
+ // NativeScript resolves the platform implementation before loading this module.
11
+ /** Puts the software keyboard away for the given gestures until the returned function runs. */
12
+ export function dismissKeyboardOn(_container: View, _options: KeyboardDismissal): () => void {
13
+ return () => {}
14
+ }
@@ -0,0 +1,27 @@
1
+ import { Label, type FormattedString } from '@nativescript/core'
2
+
3
+ declare const android: { text: { style: { AbsoluteSizeSpan: { class: unknown } } } }
4
+ interface StyledText {
5
+ length(): number
6
+ getSpans(start: number, end: number, type: unknown): ArrayLike<unknown>
7
+ removeSpan(span: unknown): void
8
+ }
9
+ const format = (
10
+ Label.prototype as unknown as {
11
+ createFormattedTextNative(value: FormattedString): StyledText
12
+ }
13
+ ).createFormattedTextNative
14
+
15
+ /** MSpan inherits one label size; keep Android's scaled text size instead of Core's fixed-size spans. */
16
+ export class MavisLabel extends Label {
17
+ createFormattedTextNative(value: FormattedString) {
18
+ const text = format.call(this, value)
19
+ if (!text) return text
20
+ // Core skips the TextView size setter for formatted text. Use sp here so the
21
+ // same inherited size reaches every run and Android applies system scaling.
22
+ if (this.fontSize > 0) this.nativeTextViewProtected.setTextSize(this.fontSize)
23
+ const sizes = text.getSpans(0, text.length(), android.text.style.AbsoluteSizeSpan.class)
24
+ for (let index = 0; index < sizes.length; index++) text.removeSpan(sizes[index])
25
+ return text
26
+ }
27
+ }
@@ -1,6 +1,59 @@
1
- import { Label, Utils } from '@nativescript/core'
1
+ import { Label, Utils, Font, type Span } from '@nativescript/core'
2
+ import { fontScaleInternalProperty } from '@nativescript/core/ui/styling/style-properties'
3
+ import type { TextVariant } from '@getcortexlabs/mavis-core'
4
+ import { recordMeasurement, reuseMeasurement, type MeasureRecord } from './measure-memo'
5
+ import { applyDynamicType, dynamicTypeScale } from './dynamic-type'
6
+
7
+ const spanDetails = (
8
+ Label.prototype as unknown as {
9
+ createMutableStringDetails(span: Span, text: string, index: number): { iosFont: unknown }
10
+ }
11
+ ).createMutableStringDetails
2
12
 
3
13
  export class MavisLabel extends Label {
14
+ createMutableStringDetails(span: Span, text: string, index: number) {
15
+ const details = spanDetails.call(this, span, text, index)
16
+ const style = span.style
17
+ const size = style.fontSize || this.fontSize
18
+ const font = new Font(
19
+ style.fontFamily,
20
+ size,
21
+ style.fontStyle,
22
+ style.fontWeight,
23
+ dynamicTypeScale(this, size),
24
+ )
25
+ details.iosFont = font.getUIFont(this.ios.font)
26
+ return details
27
+ }
28
+
29
+ measureRecord?: MeasureRecord
30
+ private textStyle: TextVariant = 'body'
31
+
32
+ get dynamicTypeStyle() {
33
+ return this.textStyle
34
+ }
35
+
36
+ set dynamicTypeStyle(value: TextVariant) {
37
+ if (value === this.textStyle) return
38
+ this.textStyle = value
39
+ applyDynamicType(this)
40
+ }
41
+
42
+ [fontScaleInternalProperty.setNative]() {
43
+ applyDynamicType(this)
44
+ }
45
+
46
+ measure(widthSpec: number, heightSpec: number) {
47
+ if (reuseMeasurement(this, widthSpec, heightSpec)) return
48
+ super.measure(widthSpec, heightSpec)
49
+ recordMeasurement(this, widthSpec, heightSpec)
50
+ }
51
+
52
+ requestLayout() {
53
+ this.measureRecord = undefined
54
+ super.requestLayout()
55
+ }
56
+
4
57
  disposeNativeView() {
5
58
  const native = this.nativeViewProtected
6
59
  super.disposeNativeView()
@@ -0,0 +1,116 @@
1
+ import { Utils, type View } from '@nativescript/core'
2
+
3
+ const { layout } = Utils
4
+
5
+ interface ChildRecord {
6
+ view: View
7
+ widthSpec: number
8
+ heightSpec: number
9
+ width: number
10
+ height: number
11
+ }
12
+ export interface MeasureRecord {
13
+ widthSpec: number
14
+ heightSpec: number
15
+ width: number
16
+ height: number
17
+ percent: boolean
18
+ /** The looser request clamped content that wanted more room; an exact size would shrink it. */
19
+ clamped: boolean
20
+ children: ChildRecord[]
21
+ }
22
+ interface Internals {
23
+ _currentWidthMeasureSpec: number
24
+ _currentHeightMeasureSpec: number
25
+ _measuredWidth: number
26
+ _measuredHeight: number
27
+ _setCurrentMeasureSpecs(widthSpec: number, heightSpec: number): boolean
28
+ isLayoutRequested: boolean
29
+ }
30
+ export interface Memoized extends View {
31
+ measureRecord?: MeasureRecord
32
+ }
33
+
34
+ const isPercent = (value: unknown) =>
35
+ typeof value === 'object' && value !== null && (value as { unit?: string }).unit === '%'
36
+
37
+ // An exact request for the size a looser request produced is the same measurement, unless a
38
+ // child resolves a percentage against the request itself or the looser request clamped content
39
+ // that wanted more room: an exact size would then shrink the children instead. Core keeps the
40
+ // too-small state only for widths, so layouts report clamping themselves.
41
+ function matches(spec: number, record: MeasureRecord, recordedSpec: number, sizeAndState: number) {
42
+ if (spec === recordedSpec) return true
43
+ if (record.percent || record.clamped) return false
44
+ if (layout.getMeasureSpecMode(spec) !== layout.EXACTLY) return false
45
+ if (layout.getMeasureSpecMode(recordedSpec) === layout.EXACTLY) return false
46
+ if (sizeAndState & layout.MEASURED_STATE_TOO_SMALL) return false
47
+ return layout.getMeasureSpecSize(spec) === (sizeAndState & layout.MEASURED_SIZE_MASK)
48
+ }
49
+
50
+ /** Whether a looser request on either axis returned its whole limit; for layouts that cannot tell. */
51
+ export function filledLimit(widthSpec: number, heightSpec: number, width: number, height: number) {
52
+ const filled = (spec: number, size: number) =>
53
+ layout.getMeasureSpecMode(spec) === layout.AT_MOST &&
54
+ (size & layout.MEASURED_SIZE_MASK) >= layout.getMeasureSpecSize(spec)
55
+ return filled(widthSpec, width) || filled(heightSpec, height)
56
+ }
57
+
58
+ /**
59
+ * Core measures a view again whenever its parent asks while a layout request is pending, and
60
+ * flex containers ask several times per pass, so nested containers measure their leaves an
61
+ * exponential number of times. While nothing in the subtree asked for layout, the recorded
62
+ * measurement answers a repeated request and the children are measured again from their records.
63
+ */
64
+ export function reuseMeasurement(view: Memoized, widthSpec: number, heightSpec: number) {
65
+ const record = view.measureRecord
66
+ const internals = view as unknown as Internals
67
+ if (!record || !internals.isLayoutRequested) return false
68
+ if (!matches(widthSpec, record, record.widthSpec, record.width)) return false
69
+ if (!matches(heightSpec, record, record.heightSpec, record.height)) return false
70
+ internals._setCurrentMeasureSpecs(widthSpec, heightSpec)
71
+ for (const child of record.children) {
72
+ const current = child.view as unknown as Internals
73
+ // A child still holding the recorded result was measured by this record's pass.
74
+ if (current._measuredWidth === child.width && current._measuredHeight === child.height) continue
75
+ child.view.measure(child.widthSpec, child.heightSpec)
76
+ }
77
+ view.setMeasuredDimension(record.width, record.height)
78
+ return true
79
+ }
80
+
81
+ /** Stores the measurement that just completed with the specs every child last received. */
82
+ export function recordMeasurement(
83
+ view: Memoized,
84
+ widthSpec: number,
85
+ heightSpec: number,
86
+ children: readonly View[] = [],
87
+ clamped = false,
88
+ ) {
89
+ const internals = view as unknown as Internals
90
+ view.measureRecord = {
91
+ widthSpec,
92
+ heightSpec,
93
+ width: internals._measuredWidth,
94
+ height: internals._measuredHeight,
95
+ percent: children.some((child) => isPercent(child.width) || isPercent(child.height)),
96
+ clamped,
97
+ children: children.map((child) => {
98
+ const specs = child as unknown as Internals
99
+ return {
100
+ view: child,
101
+ widthSpec: specs._currentWidthMeasureSpec,
102
+ heightSpec: specs._currentHeightMeasureSpec,
103
+ width: specs._measuredWidth,
104
+ height: specs._measuredHeight,
105
+ }
106
+ }),
107
+ }
108
+ }
109
+
110
+ export function layoutChildren(view: { eachLayoutChild(callback: (child: View) => void): void }) {
111
+ const children: View[] = []
112
+ view.eachLayoutChild((child) => {
113
+ children.push(child)
114
+ })
115
+ return children
116
+ }