@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 { useMotionRegion } from '../use-motion-region.js'
1
2
  import { computed, defineComponent, h, mergeProps, provide, shallowRef } from 'nativescript-vue'
2
3
  import type { EventData, View } from '@nativescript/core'
3
4
  import { resolveSpace, stackLayout } from '@getcortexlabs/mavis-core'
@@ -6,6 +7,7 @@ import {
6
7
  layoutDirection,
7
8
  useLayoutShrink,
8
9
  useMavisTheme,
10
+ useComponentLayout,
9
11
  } from '@getcortexlabs/mavis-core/vue'
10
12
  import { boxStyle } from '../props.js'
11
13
  import { useNativeViewAttrs } from '../accessibility.js'
@@ -47,6 +49,8 @@ export const MStack = defineComponent({
47
49
  width.value,
48
50
  ),
49
51
  )
52
+ const automatic = useComponentLayout(() => JSON.stringify(layout.value), false)
53
+ const motion = useMotionRegion(() => props.motionRegion ?? automatic)
50
54
  const direction = computed(() => layout.value.direction ?? props.direction)
51
55
  provide(layoutDirection, direction)
52
56
  const measure = (event: EventData) => {
@@ -63,8 +67,10 @@ export const MStack = defineComponent({
63
67
  h(
64
68
  'MavisFlexLayout',
65
69
  {
70
+ ...motion,
66
71
  onLayoutChanged: measure,
67
72
  onUnloaded: () => {
73
+ motion.onUnloaded()
68
74
  width.value = undefined
69
75
  },
70
76
  style: {
@@ -13,6 +13,7 @@ import {
13
13
  import type { EventData, ScrollView, View } from '@nativescript/core'
14
14
  import { animate, onReducedMotion, set } from '@rafaelaugusto/jolt'
15
15
  import {
16
+ componentMotion,
16
17
  canChoose,
17
18
  choiceKey,
18
19
  tabFocusTarget,
@@ -85,11 +86,16 @@ export const MTabs = defineComponent({
85
86
  if (changed) {
86
87
  motion?.stop()
87
88
  motion = undefined
88
- indicator.width = width
89
+ indicator.width = 100
90
+ indicator.originX = 0
89
91
  indicator.opacity = 1
90
92
  if (previous && animateNext)
91
- motion = animate(indicator, { x: point.x }, { type: 'spring', duration: 240, bounce: 0 })
92
- else set(indicator, { x: point.x })
93
+ motion = animate(
94
+ indicator,
95
+ { x: point.x, scaleX: width / 100 },
96
+ componentMotion(theme.value, 'selection'),
97
+ )
98
+ else set(indicator, { x: point.x, scaleX: width / 100 })
93
99
  }
94
100
  previous = { key, x: point.x, width }
95
101
  animateNext = false
@@ -163,7 +169,7 @@ export const MTabs = defineComponent({
163
169
  if (value && indicator && previous) {
164
170
  motion?.stop()
165
171
  motion = undefined
166
- set(indicator, { x: previous.x })
172
+ set(indicator, { x: previous.x, scaleX: previous.width / 100 })
167
173
  }
168
174
  })
169
175
  schedule()
@@ -0,0 +1,57 @@
1
+ import { defineComponent, h } from 'nativescript-vue'
2
+ import { Utils, isAndroid, type EventData, type TimePicker } from '@nativescript/core'
3
+ import { createTimePicker, timePickerProps } from '@getcortexlabs/mavis-core/vue'
4
+ import { localTime, timeMinutes, timeOptions } from '@getcortexlabs/mavis-core'
5
+ import { MInput } from './MInput.js'
6
+ import { MColumn, MRow } from './layout.js'
7
+ import { MButton } from './MButton.js'
8
+ import { MText } from './MText.js'
9
+ import { MSheet } from './MSheet.js'
10
+
11
+ declare const NSLocale: { alloc(): { initWithLocaleIdentifier(locale: string): unknown } }
12
+ declare const java: { lang: { Boolean: { valueOf(value: boolean): unknown } } }
13
+
14
+ const TimeWheel = defineComponent({
15
+ props: timePickerProps,
16
+ emits: ['update:modelValue'],
17
+ setup(props, { emit }) {
18
+ return () => {
19
+ const minutes = timeMinutes(props.modelValue ?? '00:00')
20
+ const { cycle, step } = timeOptions(props)
21
+ return h('TimePicker', {
22
+ // A Date is only the native widget transport. The public model remains HH:mm.
23
+ key: `${props.locale}:${cycle}:${step}`,
24
+ time: new Date(2000, 0, 1, Math.floor(minutes / 60), minutes % 60),
25
+ minuteInterval: step,
26
+ iosPreferredDatePickerStyle: 1,
27
+ accessibilityLabel: props.label,
28
+ onLoaded: (event: EventData) => {
29
+ const picker = event.object as TimePicker
30
+ if (isAndroid) picker.android.setIs24HourView(java.lang.Boolean.valueOf(cycle === 'h23'))
31
+ else
32
+ picker.ios.locale = NSLocale.alloc().initWithLocaleIdentifier(
33
+ `${props.locale.replace('-', '_')}@hours=${cycle}`,
34
+ )
35
+ },
36
+ onTimeChange: (event: EventData) => {
37
+ const picker = event.object as TimePicker
38
+ if (picker.isLoaded)
39
+ emit('update:modelValue', localTime(picker.hour * 60 + picker.minute))
40
+ },
41
+ })
42
+ }
43
+ },
44
+ })
45
+ export const MTimePicker = createTimePicker(
46
+ {
47
+ Input: MInput,
48
+ Column: MColumn,
49
+ Row: MRow,
50
+ Button: MButton,
51
+ Text: MText,
52
+ Sheet: MSheet,
53
+ Picker: TimeWheel,
54
+ beforeOpen: () => Utils.dismissKeyboard(),
55
+ },
56
+ 'native',
57
+ )
@@ -0,0 +1,39 @@
1
+ import { defineComponent, h, ref } from 'nativescript-vue'
2
+ import { tooltipProps } from '@getcortexlabs/mavis-core/vue'
3
+ import { MPopover } from './MPopover.js'
4
+ import { MText } from './MText.js'
5
+
6
+ /** Native help uses an explicit touch/assistive trigger; it never depends on hover or long press. */
7
+ export const MTooltip = defineComponent({
8
+ name: 'MTooltip',
9
+ inheritAttrs: false,
10
+ props: tooltipProps,
11
+ setup(props, { attrs }) {
12
+ const open = ref(false)
13
+ return () => {
14
+ if (!props.text.trim() || !props.triggerLabel.trim())
15
+ throw new TypeError('Tooltip requires text and a trigger label.')
16
+ if (!Number.isFinite(props.delay) || props.delay < 0)
17
+ throw new RangeError('Tooltip delay must be nonnegative and finite.')
18
+ return h(
19
+ MPopover,
20
+ {
21
+ ...attrs,
22
+ id: props.id,
23
+ open: open.value,
24
+ label: props.triggerLabel,
25
+ triggerLabel: props.triggerLabel,
26
+ icon: props.icon,
27
+ variant: props.variant,
28
+ disabled: props.disabled,
29
+ placement: props.placement,
30
+ width: 280,
31
+ 'onUpdate:open': (value: boolean) => {
32
+ open.value = value
33
+ },
34
+ },
35
+ () => h(MText, { text: props.text }),
36
+ )
37
+ }
38
+ },
39
+ })
@@ -0,0 +1,140 @@
1
+ import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
2
+ import { useMotionSurface } from '../use-motion-surface.js'
3
+ import type { VirtualListComponent } from '@getcortexlabs/mavis-core/vue'
4
+ import {
5
+ computed,
6
+ defineComponent,
7
+ h,
8
+ ListView,
9
+ mergeProps,
10
+ nextTick,
11
+ shallowRef,
12
+ ref,
13
+ watch,
14
+ } from 'nativescript-vue'
15
+ import { isAndroid, type EventData, type ListView as NativeList } from '@nativescript/core'
16
+ import { virtualListProps } from '@getcortexlabs/mavis-core/vue'
17
+ import {
18
+ choiceKey,
19
+ virtualKeys,
20
+ virtualWindow,
21
+ type VirtualItemSlot,
22
+ type VirtualListHandle,
23
+ } from '@getcortexlabs/mavis-core'
24
+ import { MText } from './MText.js'
25
+
26
+ // A recycled cell never inherits the previous item's presentation. Only a data
27
+ // revision on an already loaded logical item plays; ordinary scrolling stays still.
28
+ const RealizedContent = defineComponent({
29
+ props: { revision: Number, height: Number },
30
+ setup(props, { slots }) {
31
+ const feedback = useComponentContent(() => props.revision, false)
32
+ const motion = useMotionSurface(() => feedback)
33
+ return () => h('GridLayout', { ...motion, height: props.height }, slots.default?.())
34
+ },
35
+ })
36
+
37
+ const VirtualList = defineComponent({
38
+ name: 'MVirtualList',
39
+ inheritAttrs: false,
40
+ props: virtualListProps,
41
+ setup(props, { attrs, slots, expose }) {
42
+ const keys = computed(() => virtualKeys(props.items, props.itemKey))
43
+ const list = shallowRef<NativeList>()
44
+ const revision = ref(0)
45
+ let requested = props.initialIndex
46
+ function scrollToIndex(index: number) {
47
+ if (!Number.isInteger(index) || index < 0 || index >= props.items.length)
48
+ throw new RangeError('List index is out of range.')
49
+ requested = index
50
+ list.value?.scrollToIndex(index)
51
+ }
52
+ expose({ scrollToIndex } satisfies VirtualListHandle)
53
+ watch(
54
+ keys,
55
+ (next, previous) => {
56
+ revision.value++
57
+ const view = list.value
58
+ const first = view
59
+ ? isAndroid
60
+ ? view.android?.getFirstVisiblePosition()
61
+ : view.ios?.indexPathsForVisibleRows?.firstObject?.row
62
+ : requested
63
+ const key = previous[Math.max(0, first ?? requested)]
64
+ const index = key === undefined ? -1 : next.indexOf(key)
65
+ requested = Math.max(0, Math.min(index < 0 ? requested : index, next.length - 1))
66
+ void nextTick(() => {
67
+ if (next.length && view?.isLoaded) view.scrollToIndex(requested)
68
+ })
69
+ },
70
+ { flush: 'pre' },
71
+ )
72
+ return () => {
73
+ virtualWindow(props.items.length, props.rowHeight, props.height, 0, props.overscan)
74
+ void keys.value
75
+ if (!props.label.trim()) throw new TypeError('Virtual lists require a label.')
76
+ if (!Number.isInteger(props.initialIndex) || props.initialIndex < 0)
77
+ throw new RangeError('initialIndex must be a nonnegative integer.')
78
+ if (!props.items.length)
79
+ return h(
80
+ 'GridLayout',
81
+ mergeProps(attrs, {
82
+ id: props.id,
83
+ height: props.height,
84
+ accessibilityLabel: props.label,
85
+ }),
86
+ slots.empty?.() ?? [h(MText, { text: props.emptyLabel, tone: 'muted' })],
87
+ )
88
+ const content = h(
89
+ ListView,
90
+ mergeProps(attrs, {
91
+ id: props.id,
92
+ items: props.items,
93
+ rowHeight: props.rowHeight,
94
+ height: props.height,
95
+ separatorColor: 'transparent',
96
+ accessibilityLabel: props.label,
97
+ onLoaded: (event: EventData) => {
98
+ list.value = event.object as NativeList
99
+ // Core iOS coerces a pre-mount rowHeight to auto. Reapply it once the
100
+ // UITableView exists so its delegate and scroll geometry use fixed rows.
101
+ if (!isAndroid) {
102
+ list.value.rowHeight = 'auto'
103
+ list.value.rowHeight = props.rowHeight
104
+ }
105
+ void nextTick(() => {
106
+ if (list.value?.isLoaded)
107
+ list.value.scrollToIndex(Math.min(requested, props.items.length - 1))
108
+ })
109
+ },
110
+ onUnloaded: () => {
111
+ list.value = undefined
112
+ },
113
+ }),
114
+ {
115
+ default: ({ item, index }: VirtualItemSlot) =>
116
+ h('GridLayout', { height: props.rowHeight }, [
117
+ // NativeScript owns cell reuse. A keyed child remounts local state when its logical item changes.
118
+ h(
119
+ RealizedContent,
120
+ {
121
+ key: choiceKey(keys.value[index]!),
122
+ height: props.rowHeight,
123
+ revision: revision.value,
124
+ },
125
+ () => slots.default?.({ item, index, itemKey: keys.value[index]! }),
126
+ ),
127
+ ]),
128
+ },
129
+ )
130
+ // A flex parent's intrinsic/exact passes alternate width measure modes.
131
+ // Core iOS reloads UITableView when that spec changes, losing its scroll
132
+ // offset during cell reuse. The bounded grid gives the list one exact width.
133
+ return isAndroid
134
+ ? content
135
+ : h('GridLayout', { rows: '*', columns: '*', height: props.height }, [content])
136
+ }
137
+ },
138
+ })
139
+
140
+ export const MVirtualList = VirtualList as unknown as VirtualListComponent
@@ -0,0 +1,17 @@
1
+ import { defineComponent, h, type PropType, type VNode } from 'nativescript-vue'
2
+ import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
3
+ import { useMotionRegion } from '../use-motion-region.js'
4
+
5
+ export const MotionRows = defineComponent({
6
+ props: { nodes: { type: Array as PropType<VNode[]>, required: true } },
7
+ setup(props) {
8
+ const region = useComponentLayout(() => props.nodes.map((node) => node.key))
9
+ const hooks = useMotionRegion(() => region)
10
+ return () =>
11
+ h(
12
+ 'StackLayout',
13
+ { ...hooks, verticalAlignment: 'top', horizontalAlignment: 'left' },
14
+ props.nodes,
15
+ )
16
+ },
17
+ })
@@ -0,0 +1,91 @@
1
+ import { MotionRows } from './MotionRows.js'
2
+ import { h, type Component } from 'nativescript-vue'
3
+ import {
4
+ createDiscoveryControls,
5
+ createCarousel,
6
+ createTreeView,
7
+ createDataTable,
8
+ } from '@getcortexlabs/mavis-core/vue'
9
+ import { MRow, MColumn, MBox } from './layout.js'
10
+ import { MText } from './MText.js'
11
+ import { MButton } from './MButton.js'
12
+ import { MIcon } from './MIcon.js'
13
+ import { MSlider } from './MSlider.js'
14
+ import { MCheckbox } from './MCheckbox.js'
15
+ import { MProgress } from './MProgress.js'
16
+ import { MReveal } from './MReveal.js'
17
+ import { DateCalendar } from './DateCalendar.js'
18
+ const ui = {
19
+ Row: MRow,
20
+ Column: MColumn,
21
+ Box: MBox,
22
+ Text: MText,
23
+ Button: MButton,
24
+ Icon: MIcon,
25
+ Slider: MSlider,
26
+ Checkbox: MCheckbox,
27
+ Progress: MProgress,
28
+ Reveal: MReveal,
29
+ Calendar: DateCalendar,
30
+ }
31
+ export const { MCalendar, MRating } = createDiscoveryControls(ui, 'native')
32
+ export const MTreeView = createTreeView(ui, 'native')
33
+ export const MCarousel = createCarousel(
34
+ {
35
+ ...ui,
36
+ gestures: () => ({}),
37
+ },
38
+ 'native',
39
+ )
40
+ export const MDataTable = createDataTable(
41
+ {
42
+ ...ui,
43
+ Checkbox: (props: Record<string, unknown>) =>
44
+ h(MCheckbox as Component, { ...props, labelHidden: true }),
45
+ table: (columns, header, rows, label) =>
46
+ h('ScrollView', { orientation: 'horizontal', accessibilityLabel: label }, [
47
+ h(MotionRows, {
48
+ nodes: [
49
+ h(
50
+ 'GridLayout',
51
+ {
52
+ columns: columns.map((column) => column.width ?? 160).join(','),
53
+ rows: 'auto',
54
+ padding: 8,
55
+ },
56
+ header.map((content, index) =>
57
+ h('StackLayout', { col: index, padding: 8, verticalAlignment: 'middle' }, [
58
+ content,
59
+ ]),
60
+ ),
61
+ ),
62
+ ...rows.map((row) =>
63
+ h(
64
+ 'GridLayout',
65
+ {
66
+ key: row.key,
67
+ columns: columns.map((column) => column.width ?? 160).join(','),
68
+ rows: 'auto',
69
+ padding: 8,
70
+ },
71
+ row.cells.map((content, index) =>
72
+ h('StackLayout', { col: index, padding: 8, verticalAlignment: 'middle' }, [
73
+ columns[index]!.label
74
+ ? h(MText, {
75
+ text: columns[index]!.label,
76
+ variant: 'caption',
77
+ tone: 'muted',
78
+ align: columns[index]!.align === 'end' ? 'right' : 'left',
79
+ })
80
+ : null,
81
+ content,
82
+ ]),
83
+ ),
84
+ ),
85
+ ),
86
+ ],
87
+ }),
88
+ ]),
89
+ },
90
+ 'native',
91
+ )
@@ -0,0 +1,43 @@
1
+ import { defineComponent, h, type PropType } from 'nativescript-vue'
2
+ import {
3
+ createNumberFlow,
4
+ createSortableList,
5
+ createSwipeActions,
6
+ sortableScrollProps,
7
+ } from '@getcortexlabs/mavis-core/vue'
8
+ import type { MotionSurface } from '@getcortexlabs/mavis-core/experimental'
9
+ import { numberFlowFormatter } from '../../native/number-flow-format'
10
+ import { useScrollMotion } from '../use-scroll-motion.js'
11
+ import { useMotionSurface } from '../use-motion-surface.js'
12
+ import { MBox, MColumn, MRow } from './layout.js'
13
+ import { MText } from './MText.js'
14
+ import { MButton } from './MButton.js'
15
+ import { MMenu } from './navigation.js'
16
+
17
+ const SortableScroll = defineComponent({
18
+ name: 'MSortableScroll',
19
+ props: sortableScrollProps,
20
+ setup(props, { slots }) {
21
+ const motion = useScrollMotion(() => props.source)
22
+ return () => h('ScrollView', { ...motion, height: props.height }, slots.default?.())
23
+ },
24
+ })
25
+ const SortableBody = defineComponent({
26
+ name: 'MSortableBody',
27
+ props: { motionSurface: Object as PropType<MotionSurface> },
28
+ setup(props, { slots }) {
29
+ const motion = useMotionSurface(() => props.motionSurface)
30
+ return () => h('StackLayout', { ...motion, padding: 6 }, slots.default?.())
31
+ },
32
+ })
33
+ const ui = { Box: MBox, Column: MColumn, Row: MRow, Text: MText, Button: MButton, Menu: MMenu }
34
+ export const MNumberFlow = createNumberFlow(MText, 'native', numberFlowFormatter)
35
+ export const MSortableList = createSortableList(
36
+ { ...ui, Scroll: SortableScroll, ListBody: SortableBody },
37
+ 'native',
38
+ )
39
+ export const MSwipeActions = createSwipeActions(ui, 'native')
40
+ export { MResizablePanels } from './MResizablePanels.js'
41
+ export { MImageCompare } from './MImageCompare.js'
42
+
43
+ export { MImageViewer } from './MImageViewer.js'
@@ -43,6 +43,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
43
43
  inheritAttrs: false,
44
44
  props: direction === 'row' ? rowProps : columnProps,
45
45
  setup(props, { attrs, slots }) {
46
+ const region = useMotionRegion(() => props.motionRegion)
46
47
  const { theme } = useMavisTheme()
47
48
  const nativeAttrs = useNativeViewAttrs(props)
48
49
  const shrink = useLayoutShrink()
@@ -63,6 +64,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
63
64
  },
64
65
  nativeAttrs(),
65
66
  attrs,
67
+ region,
66
68
  ),
67
69
  slots.default?.(),
68
70
  )
@@ -0,0 +1,19 @@
1
+ import { createMenu, createNavigationControls } from '@getcortexlabs/mavis-core/vue'
2
+ import { MPopover } from './MPopover.js'
3
+ import { MRow, MColumn, MBox } from './layout.js'
4
+ import { MButton } from './MButton.js'
5
+ import { MText } from './MText.js'
6
+ import { MBadge } from './MBadge.js'
7
+ import { MSeparator } from './MSeparator.js'
8
+
9
+ export const { MAppBar, MTabBar } = createNavigationControls(
10
+ { Box: MBox, Row: MRow, Column: MColumn, Text: MText, Button: MButton, Badge: MBadge },
11
+ 'native',
12
+ )
13
+ export const MMenu = createMenu({
14
+ Popover: MPopover,
15
+ Column: MColumn,
16
+ Text: MText,
17
+ Button: MButton,
18
+ Separator: MSeparator,
19
+ })
@@ -0,0 +1,48 @@
1
+ import { useComponentWidth } from '../component-width.js'
2
+ import {
3
+ createChart,
4
+ createCommandPalette,
5
+ createWayfindingControls,
6
+ } from '@getcortexlabs/mavis-core/vue'
7
+ import type { View } from '@nativescript/core'
8
+ import { MRow, MColumn, MBox } from './layout.js'
9
+ import { MText } from './MText.js'
10
+ import { MButton } from './MButton.js'
11
+ import { MLink } from './MLink.js'
12
+ import { MIcon } from './MIcon.js'
13
+ import { MBadge } from './MBadge.js'
14
+ import { MSeparator } from './MSeparator.js'
15
+ import { MSheet } from './MSheet.js'
16
+ import { MInput } from './MInput.js'
17
+ import { MSelect } from './MSelect.js'
18
+ import { MReveal } from './MReveal.js'
19
+ import { ChartPlot } from './ChartPlot.js'
20
+ const ui = {
21
+ railWidth: useComponentWidth,
22
+ focus: (component: unknown) =>
23
+ (component as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView?.focus(),
24
+ Row: MRow,
25
+ Column: MColumn,
26
+ Box: MBox,
27
+ Text: MText,
28
+ Button: MButton,
29
+ Link: MLink,
30
+ Icon: MIcon,
31
+ Badge: MBadge,
32
+ Separator: MSeparator,
33
+ Sheet: MSheet,
34
+ Input: MInput,
35
+ Select: MSelect,
36
+ Reveal: MReveal,
37
+ Plot: ChartPlot,
38
+ }
39
+ export const { MNavigationRail, MBreadcrumb, MTimeline } = createWayfindingControls(ui, 'native')
40
+ export const MChart = createChart(ui, 'native')
41
+ export const MCommandPalette = createCommandPalette(
42
+ {
43
+ ...ui,
44
+ focus: (component) =>
45
+ (component as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView?.focus(),
46
+ },
47
+ 'native',
48
+ )