@getcortexlabs/mavis 0.1.0-alpha.8 → 0.1.0-rc.11.1

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 (257) hide show
  1. package/README.md +8 -6
  2. package/dist/date-format.d.ts +3 -0
  3. package/dist/date-format.d.ts.map +1 -0
  4. package/dist/date-format.js +2 -0
  5. package/dist/date-format.js.map +1 -0
  6. package/dist/native/date-format.android.d.ts +5 -0
  7. package/dist/native/date-format.android.d.ts.map +1 -0
  8. package/dist/native/date-format.android.js +39 -0
  9. package/dist/native/date-format.android.js.map +1 -0
  10. package/dist/native/date-format.d.ts +6 -0
  11. package/dist/native/date-format.d.ts.map +1 -0
  12. package/dist/native/date-format.ios.d.ts +5 -0
  13. package/dist/native/date-format.ios.d.ts.map +1 -0
  14. package/dist/native/date-format.ios.js +29 -0
  15. package/dist/native/date-format.ios.js.map +1 -0
  16. package/dist/native/date-format.js +8 -0
  17. package/dist/native/date-format.js.map +1 -0
  18. package/dist/native/motion-region.d.ts +1 -0
  19. package/dist/native/motion-region.d.ts.map +1 -1
  20. package/dist/native/motion-region.js +8 -1
  21. package/dist/native/motion-region.js.map +1 -1
  22. package/dist/native/motion-surface.d.ts +1 -1
  23. package/dist/native/motion-surface.d.ts.map +1 -1
  24. package/dist/native/motion-surface.js +17 -1
  25. package/dist/native/motion-surface.js.map +1 -1
  26. package/dist/native/number-flow-format.android.d.ts +3 -0
  27. package/dist/native/number-flow-format.android.d.ts.map +1 -0
  28. package/dist/native/number-flow-format.android.js +27 -0
  29. package/dist/native/number-flow-format.android.js.map +1 -0
  30. package/dist/native/number-flow-format.d.ts +4 -0
  31. package/dist/native/number-flow-format.d.ts.map +1 -0
  32. package/dist/native/number-flow-format.ios.d.ts +3 -0
  33. package/dist/native/number-flow-format.ios.d.ts.map +1 -0
  34. package/dist/native/number-flow-format.ios.js +24 -0
  35. package/dist/native/number-flow-format.ios.js.map +1 -0
  36. package/dist/native/number-flow-format.js +5 -0
  37. package/dist/native/number-flow-format.js.map +1 -0
  38. package/dist/native/section-scroll.d.ts +9 -0
  39. package/dist/native/section-scroll.d.ts.map +1 -0
  40. package/dist/native/section-scroll.js +69 -0
  41. package/dist/native/section-scroll.js.map +1 -0
  42. package/dist/native/segmented.d.ts.map +1 -1
  43. package/dist/native/segmented.js +4 -3
  44. package/dist/native/segmented.js.map +1 -1
  45. package/dist/vue/animated-number.d.ts +6 -0
  46. package/dist/vue/animated-number.d.ts.map +1 -0
  47. package/dist/vue/animated-number.js +52 -0
  48. package/dist/vue/animated-number.js.map +1 -0
  49. package/dist/vue/component-width.d.ts +7 -0
  50. package/dist/vue/component-width.d.ts.map +1 -0
  51. package/dist/vue/component-width.js +29 -0
  52. package/dist/vue/component-width.js.map +1 -0
  53. package/dist/vue/components/ChartPlot.d.ts +66 -0
  54. package/dist/vue/components/ChartPlot.d.ts.map +1 -0
  55. package/dist/vue/components/ChartPlot.js +236 -0
  56. package/dist/vue/components/ChartPlot.js.map +1 -0
  57. package/dist/vue/components/ChoiceControl.d.ts +3 -0
  58. package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
  59. package/dist/vue/components/ChoiceControl.js +29 -22
  60. package/dist/vue/components/ChoiceControl.js.map +1 -1
  61. package/dist/vue/components/DateCalendar.d.ts +17 -2
  62. package/dist/vue/components/DateCalendar.d.ts.map +1 -1
  63. package/dist/vue/components/DateCalendar.js +45 -10
  64. package/dist/vue/components/DateCalendar.js.map +1 -1
  65. package/dist/vue/components/LoadingDecoration.d.ts +1 -1
  66. package/dist/vue/components/MAccordion.d.ts +1 -1
  67. package/dist/vue/components/MAlert.d.ts +3 -3
  68. package/dist/vue/components/MAlert.d.ts.map +1 -1
  69. package/dist/vue/components/MAlert.js +3 -0
  70. package/dist/vue/components/MAlert.js.map +1 -1
  71. package/dist/vue/components/MAvatar.d.ts +1 -1
  72. package/dist/vue/components/MAvatar.d.ts.map +1 -1
  73. package/dist/vue/components/MAvatar.js +5 -1
  74. package/dist/vue/components/MAvatar.js.map +1 -1
  75. package/dist/vue/components/MBadge.d.ts +1 -1
  76. package/dist/vue/components/MBadge.d.ts.map +1 -1
  77. package/dist/vue/components/MBadge.js +3 -1
  78. package/dist/vue/components/MBadge.js.map +1 -1
  79. package/dist/vue/components/MButton.d.ts +6 -6
  80. package/dist/vue/components/MButton.d.ts.map +1 -1
  81. package/dist/vue/components/MButton.js +4 -3
  82. package/dist/vue/components/MButton.js.map +1 -1
  83. package/dist/vue/components/MCard.d.ts +3 -3
  84. package/dist/vue/components/MCard.d.ts.map +1 -1
  85. package/dist/vue/components/MCard.js +4 -3
  86. package/dist/vue/components/MCard.js.map +1 -1
  87. package/dist/vue/components/MChip.d.ts +2 -2
  88. package/dist/vue/components/MCombobox.d.ts +3 -3
  89. package/dist/vue/components/MCombobox.d.ts.map +1 -1
  90. package/dist/vue/components/MCombobox.js +3 -1
  91. package/dist/vue/components/MCombobox.js.map +1 -1
  92. package/dist/vue/components/MDatePicker.d.ts +72 -24
  93. package/dist/vue/components/MDatePicker.d.ts.map +1 -1
  94. package/dist/vue/components/MDatePicker.js +4 -14
  95. package/dist/vue/components/MDatePicker.js.map +1 -1
  96. package/dist/vue/components/MDialog.d.ts +3 -3
  97. package/dist/vue/components/MEmptyState.d.ts +2 -2
  98. package/dist/vue/components/MEmptyState.d.ts.map +1 -1
  99. package/dist/vue/components/MEmptyState.js +3 -0
  100. package/dist/vue/components/MEmptyState.js.map +1 -1
  101. package/dist/vue/components/MFilePicker.d.ts +4 -4
  102. package/dist/vue/components/MFilePicker.d.ts.map +1 -1
  103. package/dist/vue/components/MFilePicker.js +3 -0
  104. package/dist/vue/components/MFilePicker.js.map +1 -1
  105. package/dist/vue/components/MGrid.d.ts +176 -0
  106. package/dist/vue/components/MGrid.d.ts.map +1 -0
  107. package/dist/vue/components/MGrid.js +56 -0
  108. package/dist/vue/components/MGrid.js.map +1 -0
  109. package/dist/vue/components/MIcon.d.ts +3 -3
  110. package/dist/vue/components/MImage.d.ts +47 -2
  111. package/dist/vue/components/MImage.d.ts.map +1 -1
  112. package/dist/vue/components/MImage.js +8 -1
  113. package/dist/vue/components/MImage.js.map +1 -1
  114. package/dist/vue/components/MImageCompare.d.ts +92 -0
  115. package/dist/vue/components/MImageCompare.d.ts.map +1 -0
  116. package/dist/vue/components/MImageCompare.js +138 -0
  117. package/dist/vue/components/MImageCompare.js.map +1 -0
  118. package/dist/vue/components/MImageViewer.d.ts +121 -0
  119. package/dist/vue/components/MImageViewer.d.ts.map +1 -0
  120. package/dist/vue/components/MImageViewer.js +444 -0
  121. package/dist/vue/components/MImageViewer.js.map +1 -0
  122. package/dist/vue/components/MInput.d.ts +6 -6
  123. package/dist/vue/components/MInput.d.ts.map +1 -1
  124. package/dist/vue/components/MInput.js +18 -0
  125. package/dist/vue/components/MInput.js.map +1 -1
  126. package/dist/vue/components/MLink.d.ts.map +1 -1
  127. package/dist/vue/components/MLink.js +6 -11
  128. package/dist/vue/components/MLink.js.map +1 -1
  129. package/dist/vue/components/MListItem.d.ts +1 -1
  130. package/dist/vue/components/MPopover.d.ts +106 -0
  131. package/dist/vue/components/MPopover.d.ts.map +1 -0
  132. package/dist/vue/components/MPopover.js +247 -0
  133. package/dist/vue/components/MPopover.js.map +1 -0
  134. package/dist/vue/components/MProgress.d.ts +3 -3
  135. package/dist/vue/components/MProgress.d.ts.map +1 -1
  136. package/dist/vue/components/MProgress.js +5 -2
  137. package/dist/vue/components/MProgress.js.map +1 -1
  138. package/dist/vue/components/MRangeSlider.d.ts +105 -0
  139. package/dist/vue/components/MRangeSlider.d.ts.map +1 -0
  140. package/dist/vue/components/MRangeSlider.js +134 -0
  141. package/dist/vue/components/MRangeSlider.js.map +1 -0
  142. package/dist/vue/components/MResizablePanels.d.ts +137 -0
  143. package/dist/vue/components/MResizablePanels.d.ts.map +1 -0
  144. package/dist/vue/components/MResizablePanels.js +148 -0
  145. package/dist/vue/components/MResizablePanels.js.map +1 -0
  146. package/dist/vue/components/MReveal.d.ts +11 -11
  147. package/dist/vue/components/MSelect.d.ts +1 -1
  148. package/dist/vue/components/MSheet.d.ts +14 -5
  149. package/dist/vue/components/MSheet.d.ts.map +1 -1
  150. package/dist/vue/components/MStack.d.ts +22 -11
  151. package/dist/vue/components/MStack.d.ts.map +1 -1
  152. package/dist/vue/components/MStack.js +6 -1
  153. package/dist/vue/components/MStack.js.map +1 -1
  154. package/dist/vue/components/MTabs.d.ts.map +1 -1
  155. package/dist/vue/components/MTabs.js +6 -5
  156. package/dist/vue/components/MTabs.js.map +1 -1
  157. package/dist/vue/components/MText.d.ts +4 -4
  158. package/dist/vue/components/MTimePicker.d.ts +655 -0
  159. package/dist/vue/components/MTimePicker.d.ts.map +1 -0
  160. package/dist/vue/components/MTimePicker.js +50 -0
  161. package/dist/vue/components/MTimePicker.js.map +1 -0
  162. package/dist/vue/components/MTooltip.d.ts +65 -0
  163. package/dist/vue/components/MTooltip.d.ts.map +1 -0
  164. package/dist/vue/components/MTooltip.js +35 -0
  165. package/dist/vue/components/MTooltip.js.map +1 -0
  166. package/dist/vue/components/MVirtualList.d.ts +3 -0
  167. package/dist/vue/components/MVirtualList.d.ts.map +1 -0
  168. package/dist/vue/components/MVirtualList.js +106 -0
  169. package/dist/vue/components/MVirtualList.js.map +1 -0
  170. package/dist/vue/components/MotionRows.d.ts +15 -0
  171. package/dist/vue/components/MotionRows.d.ts.map +1 -0
  172. package/dist/vue/components/MotionRows.js +12 -0
  173. package/dist/vue/components/MotionRows.js.map +1 -0
  174. package/dist/vue/components/configurator.d.ts +5 -5
  175. package/dist/vue/components/discovery.d.ts +282 -0
  176. package/dist/vue/components/discovery.d.ts.map +1 -0
  177. package/dist/vue/components/discovery.js +65 -0
  178. package/dist/vue/components/discovery.js.map +1 -0
  179. package/dist/vue/components/interactive.d.ts +164 -0
  180. package/dist/vue/components/interactive.d.ts.map +1 -0
  181. package/dist/vue/components/interactive.js +33 -0
  182. package/dist/vue/components/interactive.js.map +1 -0
  183. package/dist/vue/components/layout.d.ts +47 -25
  184. package/dist/vue/components/layout.d.ts.map +1 -1
  185. package/dist/vue/components/layout.js +2 -1
  186. package/dist/vue/components/layout.js.map +1 -1
  187. package/dist/vue/components/navigation.d.ts +225 -0
  188. package/dist/vue/components/navigation.d.ts.map +1 -0
  189. package/dist/vue/components/navigation.js +16 -0
  190. package/dist/vue/components/navigation.js.map +1 -0
  191. package/dist/vue/components/wayfinding.d.ts +441 -0
  192. package/dist/vue/components/wayfinding.d.ts.map +1 -0
  193. package/dist/vue/components/wayfinding.js +39 -0
  194. package/dist/vue/components/wayfinding.js.map +1 -0
  195. package/dist/vue/components/workflows.d.ts +2 -2
  196. package/dist/vue/index.d.ts +22 -12
  197. package/dist/vue/index.d.ts.map +1 -1
  198. package/dist/vue/index.js +47 -12
  199. package/dist/vue/index.js.map +1 -1
  200. package/dist/vue/router-navigation.d.ts +25 -0
  201. package/dist/vue/router-navigation.d.ts.map +1 -0
  202. package/dist/vue/router-navigation.js +15 -0
  203. package/dist/vue/router-navigation.js.map +1 -0
  204. package/dist/vue/services.d.ts +16 -0
  205. package/dist/vue/services.d.ts.map +1 -0
  206. package/dist/vue/services.js +23 -0
  207. package/dist/vue/services.js.map +1 -0
  208. package/package.json +16 -5
  209. package/src/date-format.ts +2 -0
  210. package/src/native/date-format.android.ts +72 -0
  211. package/src/native/date-format.ios.ts +54 -0
  212. package/src/native/date-format.ts +17 -0
  213. package/src/native/motion-region.ts +14 -1
  214. package/src/native/motion-surface.ts +24 -1
  215. package/src/native/number-flow-format.android.ts +61 -0
  216. package/src/native/number-flow-format.ios.ts +40 -0
  217. package/src/native/number-flow-format.ts +9 -0
  218. package/src/native/section-scroll.ts +81 -0
  219. package/src/native/segmented.ts +4 -3
  220. package/src/vue/animated-number.ts +57 -0
  221. package/src/vue/component-width.ts +34 -0
  222. package/src/vue/components/ChartPlot.ts +267 -0
  223. package/src/vue/components/ChoiceControl.ts +32 -25
  224. package/src/vue/components/DateCalendar.ts +50 -9
  225. package/src/vue/components/MAlert.ts +3 -0
  226. package/src/vue/components/MAvatar.ts +5 -1
  227. package/src/vue/components/MBadge.ts +3 -1
  228. package/src/vue/components/MButton.ts +4 -2
  229. package/src/vue/components/MCard.ts +4 -2
  230. package/src/vue/components/MCombobox.ts +6 -1
  231. package/src/vue/components/MDatePicker.ts +3 -11
  232. package/src/vue/components/MEmptyState.ts +3 -0
  233. package/src/vue/components/MFilePicker.ts +3 -0
  234. package/src/vue/components/MGrid.ts +100 -0
  235. package/src/vue/components/MImage.ts +10 -1
  236. package/src/vue/components/MImageCompare.ts +162 -0
  237. package/src/vue/components/MImageViewer.ts +489 -0
  238. package/src/vue/components/MInput.ts +17 -3
  239. package/src/vue/components/MLink.ts +12 -9
  240. package/src/vue/components/MPopover.ts +305 -0
  241. package/src/vue/components/MProgress.ts +8 -2
  242. package/src/vue/components/MRangeSlider.ts +157 -0
  243. package/src/vue/components/MResizablePanels.ts +180 -0
  244. package/src/vue/components/MStack.ts +6 -0
  245. package/src/vue/components/MTabs.ts +10 -4
  246. package/src/vue/components/MTimePicker.ts +57 -0
  247. package/src/vue/components/MTooltip.ts +39 -0
  248. package/src/vue/components/MVirtualList.ts +140 -0
  249. package/src/vue/components/MotionRows.ts +17 -0
  250. package/src/vue/components/discovery.ts +91 -0
  251. package/src/vue/components/interactive.ts +43 -0
  252. package/src/vue/components/layout.ts +2 -0
  253. package/src/vue/components/navigation.ts +19 -0
  254. package/src/vue/components/wayfinding.ts +48 -0
  255. package/src/vue/index.ts +142 -69
  256. package/src/vue/router-navigation.ts +39 -0
  257. package/src/vue/services.ts +39 -0
@@ -1,3 +1,4 @@
1
+ import { useMotionSurface } from '../use-motion-surface.js'
1
2
  import {
2
3
  defineComponent,
3
4
  h,
@@ -7,7 +8,7 @@ import {
7
8
  watch,
8
9
  registerElement,
9
10
  } from 'nativescript-vue'
10
- import { avatarProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
11
+ import { avatarProps, useMavisTheme, useComponentContent } from '@getcortexlabs/mavis-core/vue'
11
12
  import { avatarSizes, avatarInitials, iconGlyph, iconFontFamily } from '@getcortexlabs/mavis-core'
12
13
  import type { ImageSource } from '@nativescript/core'
13
14
  import { loadAvatarImage } from '../../native/avatar-image'
@@ -23,6 +24,8 @@ export const MAvatar = defineComponent({
23
24
  props: avatarProps,
24
25
  setup(props, { attrs }) {
25
26
  const { theme } = useMavisTheme()
27
+ const reveal = useComponentContent()
28
+ const motion = useMotionSurface(() => reveal)
26
29
  const nativeAttrs = useNativeViewAttrs(props)
27
30
  const image = shallowRef<ImageSource | null>(null)
28
31
  let request = 0
@@ -70,6 +73,7 @@ export const MAvatar = defineComponent({
70
73
  image.value
71
74
  ? [
72
75
  h('Image', {
76
+ ...motion,
73
77
  imageSource: image.value,
74
78
  stretch: 'aspectFill',
75
79
  width: size,
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, h, mergeProps } from 'nativescript-vue'
2
- import { badgeProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
2
+ import { badgeProps, useMavisTheme, useComponentContent } from '@getcortexlabs/mavis-core/vue'
3
3
  import { badgeColors } from '@getcortexlabs/mavis-core'
4
4
  import { MText } from './MText.js'
5
5
 
@@ -9,12 +9,14 @@ export const MBadge = defineComponent({
9
9
  props: badgeProps,
10
10
  setup(props, { attrs }) {
11
11
  const { theme } = useMavisTheme()
12
+ const content = useComponentContent(() => props.text, false)
12
13
  return () =>
13
14
  h(
14
15
  MText,
15
16
  mergeProps(attrs, {
16
17
  id: props.id,
17
18
  text: String(props.text),
19
+ motionSurface: content,
18
20
  variant: 'caption',
19
21
  accessibilityLabel: props.accessibilityLabel,
20
22
  accessibilityHidden: props.accessibilityHidden,
@@ -20,6 +20,7 @@ import {
20
20
  buttonContent,
21
21
  ButtonAdornment,
22
22
  useMavisTheme,
23
+ useNavigationOptions,
23
24
  actionEmits,
24
25
  textContent,
25
26
  useLayoutShrink,
@@ -58,6 +59,7 @@ export const MButton = defineComponent({
58
59
  setup(props, { attrs, slots, emit }) {
59
60
  useButtonAction()
60
61
  const { theme } = useMavisTheme()
62
+ const navigation = useNavigationOptions(props)
61
63
  const nativeAttrs = useNativeViewAttrs(props)
62
64
  const shrink = useLayoutShrink()
63
65
  const enabled = () => !props.disabled && !props.loading
@@ -76,7 +78,7 @@ export const MButton = defineComponent({
76
78
  if (!enabled() || !allowsActivation()) return
77
79
  emit('click')
78
80
  if (props.href !== undefined)
79
- void navigateNative(props).catch((error) => emit('error', error))
81
+ void navigateNative(navigation()).catch((error) => emit('error', error))
80
82
  }
81
83
  return () => {
82
84
  if (
@@ -91,7 +93,7 @@ export const MButton = defineComponent({
91
93
  throw new TypeError(
92
94
  'A reorder handle requires a plain-text MButton without navigation or adornments.',
93
95
  )
94
- if (props.href !== undefined) nativeDestination(props)
96
+ if (props.href !== undefined) nativeDestination(navigation())
95
97
  const { colors, control, radius } = theme.value
96
98
  const tokens = theme.value.components.button
97
99
  const family = fontFamily(
@@ -6,6 +6,7 @@ import {
6
6
  useButtonAction,
7
7
  cardProps,
8
8
  useMavisTheme,
9
+ useNavigationOptions,
9
10
  actionEmits,
10
11
  } from '@getcortexlabs/mavis-core/vue'
11
12
  import { MColumn } from './layout.js'
@@ -20,6 +21,7 @@ export const MCard = defineComponent({
20
21
  setup(props, { attrs, slots, emit }) {
21
22
  useButtonAction(() => props.interactive || props.href !== undefined)
22
23
  const { theme } = useMavisTheme()
24
+ const navigation = useNavigationOptions(props)
23
25
  const enabled = () => (props.interactive || props.href !== undefined) && !props.disabled
24
26
  const lifecycle = usePressFeedback(enabled, theme)
25
27
  const { allowsActivation, ...surface } = useMotionSurface(
@@ -39,7 +41,7 @@ export const MCard = defineComponent({
39
41
  ...layout
40
42
  } = props
41
43
  const interactive = action || href !== undefined
42
- if (href !== undefined) nativeDestination(props)
44
+ if (href !== undefined) nativeDestination(navigation())
43
45
  const tokens = theme.value.components.card
44
46
  layout.padding ??= tokens.padding
45
47
  layout.radius ??= tokens.radius
@@ -71,7 +73,7 @@ export const MCard = defineComponent({
71
73
  if (enabled() && allowsActivation()) {
72
74
  emit('click')
73
75
  if (href !== undefined)
74
- void navigateNative(props).catch((error) => emit('error', error))
76
+ void navigateNative(navigation()).catch((error) => emit('error', error))
75
77
  }
76
78
  }
77
79
  : undefined,
@@ -1,3 +1,4 @@
1
+ import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
1
2
  import {
2
3
  defineComponent,
3
4
  h,
@@ -30,6 +31,10 @@ const Combobox = defineComponent({
30
31
  setup(props, { attrs, emit, expose }) {
31
32
  useButtonAction()
32
33
  const combo = useCombobox(props, emit)
34
+ const resultLayout = useComponentLayout(
35
+ () => combo.state.value.options.map((option) => option.value),
36
+ false,
37
+ )
33
38
  const input = ref<InputHandle>()
34
39
  let nativeEditor: TextField | undefined
35
40
  let compositionTimer: ReturnType<typeof setTimeout> | undefined
@@ -188,7 +193,7 @@ const Combobox = defineComponent({
188
193
  combo.open.value
189
194
  ? h(
190
195
  MColumn,
191
- { gap: 'xs' },
196
+ { gap: 'xs', motionRegion: resultLayout },
192
197
  {
193
198
  default: () => [
194
199
  ...state.options.map((option) =>
@@ -1,15 +1,13 @@
1
- import { Utils, isAndroid, type View } from '@nativescript/core'
1
+ import { Utils } from '@nativescript/core'
2
2
  import { createDatePickers } from '@getcortexlabs/mavis-core/vue'
3
3
  import { MInput } from './MInput.js'
4
4
  import { MButton } from './MButton.js'
5
5
  import { MColumn, MRow } from './layout.js'
6
6
  import { MSheet } from './MSheet.js'
7
7
  import { DateCalendar } from './DateCalendar.js'
8
- import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
9
8
 
10
9
  function focusOpener(opener: unknown) {
11
- const view = (opener as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView
12
- view?.focus()
10
+ ;(opener as { focusAction?: () => void } | undefined)?.focusAction?.()
13
11
  }
14
12
 
15
13
  export const { MDatePicker, MDateRangePicker } = createDatePickers({
@@ -23,11 +21,5 @@ export const { MDatePicker, MDateRangePicker } = createDatePickers({
23
21
  Utils.dismissKeyboard()
24
22
  focusOpener(opener)
25
23
  },
26
- afterClose: (opener) => {
27
- const view = (opener as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView
28
- if (!view?.isLoaded) return
29
- view.focus()
30
- if (isAndroid) view.android.performAccessibilityAction(64, null)
31
- else notifyAccessibilityLayout(view)
32
- },
24
+ afterClose: focusOpener,
33
25
  })
@@ -1,3 +1,4 @@
1
+ import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
1
2
  import { defineComponent, h, mergeProps, type SlotsType, type VNode } from 'nativescript-vue'
2
3
  import { checkEmptyStateTitle } from '@getcortexlabs/mavis-core'
3
4
  import { emptyStateProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
@@ -13,6 +14,7 @@ export const MEmptyState = defineComponent({
13
14
  slots: Object as SlotsType<{ illustration?: () => VNode[]; actions?: () => VNode[] }>,
14
15
  setup(props, { attrs, slots }) {
15
16
  const { theme } = useMavisTheme()
17
+ const arrival = useComponentContent(() => props.title)
16
18
  return () => {
17
19
  checkEmptyStateTitle(props.title)
18
20
  const { colors } = theme.value
@@ -24,6 +26,7 @@ export const MEmptyState = defineComponent({
24
26
  {
25
27
  width: size,
26
28
  height: size,
29
+ motionSurface: arrival,
27
30
  },
28
31
  {
29
32
  default: () => [
@@ -1,3 +1,4 @@
1
+ import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
1
2
  import {
2
3
  defineComponent,
3
4
  h,
@@ -25,6 +26,7 @@ const FilePicker = defineComponent({
25
26
  setup(props, { attrs, expose }) {
26
27
  useButtonAction()
27
28
  const state = shallowRef(props.selection.state)
29
+ const layout = useComponentLayout(() => state.value.items.map((item) => item.id))
28
30
  const picker = createNativeFilePicker()
29
31
  let chooseView: View | undefined
30
32
  let loaded = false
@@ -87,6 +89,7 @@ const FilePicker = defineComponent({
87
89
  MColumn,
88
90
  mergeProps(attrs, {
89
91
  gap: 'md',
92
+ motionRegion: layout,
90
93
  onLoaded: () => {
91
94
  loaded = true
92
95
  },
@@ -0,0 +1,100 @@
1
+ import { useMotionRegion } from '../use-motion-region.js'
2
+ import {
3
+ Comment,
4
+ Fragment,
5
+ Text,
6
+ createVNode,
7
+ defineComponent,
8
+ h,
9
+ mergeProps,
10
+ provide,
11
+ shallowRef,
12
+ type VNode,
13
+ } from 'nativescript-vue'
14
+ import type { EventData, View } from '@nativescript/core'
15
+ import { gridColumns, resolveSpace } from '@getcortexlabs/mavis-core'
16
+ import {
17
+ gridProps,
18
+ layoutDirection,
19
+ useLayoutShrink,
20
+ useMavisTheme,
21
+ useComponentLayout,
22
+ } from '@getcortexlabs/mavis-core/vue'
23
+ import { boxStyle } from '../props.js'
24
+ import { useNativeViewAttrs } from '../accessibility.js'
25
+ import './layout.js'
26
+
27
+ export const MGrid = defineComponent({
28
+ name: 'MGrid',
29
+ inheritAttrs: false,
30
+ props: gridProps,
31
+ setup(props, { attrs, slots }) {
32
+ const { theme } = useMavisTheme()
33
+ const shrink = useLayoutShrink()
34
+ const nativeAttrs = useNativeViewAttrs(props)
35
+ provide(layoutDirection, 'column')
36
+ const width = shallowRef<number>()
37
+ const automatic = useComponentLayout(
38
+ () =>
39
+ gridColumns(
40
+ props.columns,
41
+ props.minColumnWidth,
42
+ resolveSpace(theme.value, props.gap ?? 'none'),
43
+ width.value,
44
+ ),
45
+ false,
46
+ )
47
+ const motion = useMotionRegion(() => props.motionRegion ?? automatic)
48
+ return () => {
49
+ const gap = resolveSpace(theme.value, props.gap ?? 'none')
50
+ const count = gridColumns(props.columns, props.minColumnWidth, gap, width.value)
51
+ let index = 0
52
+ // Keep fragment boundaries so independently keyed slot groups retain their identity.
53
+ const place = (nodes: VNode[]): VNode[] =>
54
+ nodes.flatMap((child) => {
55
+ if (child.type === Fragment)
56
+ return [
57
+ createVNode(
58
+ Fragment,
59
+ { key: child.key ?? undefined },
60
+ place(child.children as VNode[]),
61
+ ),
62
+ ]
63
+ if (child.type === Comment || (child.type === Text && !String(child.children).trim()))
64
+ return []
65
+ const cell = index++
66
+ return [
67
+ h(
68
+ 'MavisBox',
69
+ {
70
+ key: child.key ?? cell,
71
+ col: (cell % count) * 2,
72
+ row: Math.floor(cell / count) * 2,
73
+ },
74
+ [child],
75
+ ),
76
+ ]
77
+ })
78
+ const children = place(slots.default?.() ?? [])
79
+ const rows = Math.ceil(index / count)
80
+ return h(
81
+ 'MavisBox',
82
+ mergeProps({ style: boxStyle(theme.value, props, shrink.value) }, nativeAttrs(), attrs),
83
+ [
84
+ h(
85
+ 'GridLayout',
86
+ {
87
+ ...motion,
88
+ columns: Array.from({ length: count }, () => '*').join(`,${gap},`),
89
+ rows: Array.from({ length: rows }, () => 'auto').join(`,${gap},`),
90
+ onLayoutChanged: (event: EventData) => {
91
+ width.value = (event.object as View).getActualSize().width
92
+ },
93
+ },
94
+ children,
95
+ ),
96
+ ],
97
+ )
98
+ }
99
+ },
100
+ })
@@ -1,3 +1,6 @@
1
+ import { markRaw, onScopeDispose } from 'nativescript-vue'
2
+ import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
3
+ import { componentMotion } from '@getcortexlabs/mavis-core'
1
4
  import {
2
5
  defineComponent,
3
6
  h,
@@ -28,6 +31,12 @@ export const MImage = defineComponent({
28
31
  },
29
32
  setup(props, { attrs, emit }) {
30
33
  const { theme } = useMavisTheme()
34
+ const reveal = markRaw(createMotionSurface())
35
+ onScopeDispose(
36
+ reveal.use((owner) => {
37
+ owner.animate({ opacity: [0, 1] }, componentMotion(theme.value, 'overlay'))
38
+ }),
39
+ )
31
40
  const image = shallowRef<ImageSource | null>(null)
32
41
  const status = ref<'loading' | 'ready' | 'error'>('loading')
33
42
  const width = ref(typeof props.width === 'number' ? props.width : 0)
@@ -37,7 +46,7 @@ export const MImage = defineComponent({
37
46
  committing: string | undefined,
38
47
  currentImage: Image | undefined
39
48
  const motion = useMotionSurface(
40
- () => props.motionSurface,
49
+ () => props.motionSurface ?? reveal,
41
50
  () => true,
42
51
  () => false,
43
52
  true,
@@ -0,0 +1,162 @@
1
+ import { defineComponent, h, mergeProps, ref, watch } from 'nativescript-vue'
2
+ import type { EventData, PanGestureEventData, View } from '@nativescript/core'
3
+ import { finiteRange, positiveSize } from '@getcortexlabs/mavis-core'
4
+ import { imageCompareProps, usePartition, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
5
+ import { useAnimatedNumber } from '../animated-number.js'
6
+ import { MColumn, MBox } from './layout.js'
7
+ import { MImage } from './MImage.js'
8
+ import { MText } from './MText.js'
9
+ import { MSlider } from './MSlider.js'
10
+
11
+ export const MImageCompare = defineComponent({
12
+ name: 'MImageCompare',
13
+ inheritAttrs: false,
14
+ props: imageCompareProps,
15
+ emits: { 'update:modelValue': (_value: number) => true },
16
+ setup(props, { attrs, emit }) {
17
+ const { theme } = useMavisTheme()
18
+ const width = ref(300)
19
+ const state = usePartition(
20
+ () => finiteRange(props.modelValue, 0, 100),
21
+ () => ({ min: 0, max: 100, step: props.step, disabled: props.disabled }),
22
+ (value) => emit('update:modelValue', value),
23
+ )
24
+ const motion = useAnimatedNumber(
25
+ () => state.canonical.value,
26
+ () => state.dragging.value,
27
+ )
28
+ let origin = 50
29
+ watch(
30
+ () => props.orientation,
31
+ () => state.cancel(),
32
+ )
33
+ return () => {
34
+ const vertical = props.orientation === 'vertical',
35
+ height = width.value / positiveSize(props.aspectRatio, 'aspectRatio'),
36
+ ratio = finiteRange(motion.shown.value, 0, 100) / 100
37
+ return h(MColumn, mergeProps(attrs, { gap: 'sm' }), () => [
38
+ h(
39
+ 'GridLayout',
40
+ {
41
+ onLoaded: motion.onLoaded,
42
+ onUnloaded: motion.onUnloaded,
43
+ height,
44
+ borderRadius: 16,
45
+ clipToBounds: true,
46
+ onLayoutChanged: (event: EventData) => {
47
+ const next = (event.object as View).getActualSize().width
48
+ if (next > 0 && next !== width.value) {
49
+ state.cancel()
50
+ width.value = next
51
+ }
52
+ },
53
+ },
54
+ [
55
+ h(MImage, {
56
+ src: props.after,
57
+ alt: props.afterLabel,
58
+ aspectRatio: props.aspectRatio,
59
+ width: width.value,
60
+ height,
61
+ radius: 'none',
62
+ }),
63
+ h(
64
+ 'GridLayout',
65
+ {
66
+ width: vertical ? width.value : ratio * width.value,
67
+ height: vertical ? ratio * height : height,
68
+ horizontalAlignment: 'left',
69
+ verticalAlignment: 'top',
70
+ clipToBounds: true,
71
+ },
72
+ [
73
+ h(MImage, {
74
+ src: props.before,
75
+ alt: props.beforeLabel,
76
+ aspectRatio: props.aspectRatio,
77
+ width: width.value,
78
+ height,
79
+ radius: 'none',
80
+ horizontalAlignment: 'left',
81
+ verticalAlignment: 'top',
82
+ }),
83
+ ],
84
+ ),
85
+ h('AbsoluteLayout', { accessibilityHidden: true }, [
86
+ h(MBox, {
87
+ left: vertical ? 0 : width.value * ratio - 1,
88
+ top: vertical ? height * ratio - 1 : 0,
89
+ width: vertical ? width.value : 2,
90
+ height: vertical ? 2 : height,
91
+ backgroundColor: '#ffffff',
92
+ }),
93
+ h(
94
+ MBox,
95
+ {
96
+ left: (vertical ? width.value / 2 : width.value * ratio) - 22,
97
+ top: (vertical ? height * ratio : height / 2) - 22,
98
+ width: 44,
99
+ height: 44,
100
+ radius: 'full',
101
+ backgroundColor: theme.value.colors.surface,
102
+ },
103
+ () =>
104
+ h(MText, {
105
+ text: vertical ? '↕' : '↔',
106
+ align: 'center',
107
+ variant: 'heading',
108
+ verticalAlignment: 'middle',
109
+ }),
110
+ ),
111
+ ]),
112
+ h(MBox, {
113
+ accessibilityHidden: true,
114
+ backgroundColor: '#00000000',
115
+ onPan: (event: PanGestureEventData) => {
116
+ if (props.disabled) return
117
+ if (event.state === 1) {
118
+ if (state.begin()) origin = state.canonical.value
119
+ }
120
+ if (event.state === 2 && state.dragging.value)
121
+ state.update(
122
+ origin + (vertical ? event.deltaY / height : event.deltaX / width.value) * 100,
123
+ )
124
+ if (event.state === 3) state.end()
125
+ if (event.state === 4) state.cancel()
126
+ },
127
+ }),
128
+ h(MText, {
129
+ text: props.beforeLabel,
130
+ variant: 'caption',
131
+ padding: theme.value.space.sm,
132
+ backgroundColor: theme.value.colors.surface,
133
+ horizontalAlignment: 'left',
134
+ verticalAlignment: 'top',
135
+ margin: 12,
136
+ isUserInteractionEnabled: false,
137
+ }),
138
+ h(MText, {
139
+ text: props.afterLabel,
140
+ variant: 'caption',
141
+ padding: theme.value.space.sm,
142
+ backgroundColor: theme.value.colors.surface,
143
+ horizontalAlignment: 'right',
144
+ verticalAlignment: vertical ? 'bottom' : 'top',
145
+ margin: 12,
146
+ isUserInteractionEnabled: false,
147
+ }),
148
+ ],
149
+ ),
150
+ h(MSlider, {
151
+ label: props.label,
152
+ modelValue: state.canonical.value,
153
+ min: 0,
154
+ max: 100,
155
+ step: props.step,
156
+ disabled: props.disabled,
157
+ 'onUpdate:modelValue': state.update,
158
+ }),
159
+ ])
160
+ }
161
+ },
162
+ })