@getcortexlabs/mavis 0.1.0-alpha.9 → 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 (227) hide show
  1. package/README.md +6 -6
  2. package/dist/native/motion-region.d.ts +1 -0
  3. package/dist/native/motion-region.d.ts.map +1 -1
  4. package/dist/native/motion-region.js +8 -1
  5. package/dist/native/motion-region.js.map +1 -1
  6. package/dist/native/motion-surface.d.ts +1 -1
  7. package/dist/native/motion-surface.d.ts.map +1 -1
  8. package/dist/native/motion-surface.js +17 -1
  9. package/dist/native/motion-surface.js.map +1 -1
  10. package/dist/native/number-flow-format.android.d.ts +3 -0
  11. package/dist/native/number-flow-format.android.d.ts.map +1 -0
  12. package/dist/native/number-flow-format.android.js +27 -0
  13. package/dist/native/number-flow-format.android.js.map +1 -0
  14. package/dist/native/number-flow-format.d.ts +4 -0
  15. package/dist/native/number-flow-format.d.ts.map +1 -0
  16. package/dist/native/number-flow-format.ios.d.ts +3 -0
  17. package/dist/native/number-flow-format.ios.d.ts.map +1 -0
  18. package/dist/native/number-flow-format.ios.js +24 -0
  19. package/dist/native/number-flow-format.ios.js.map +1 -0
  20. package/dist/native/number-flow-format.js +5 -0
  21. package/dist/native/number-flow-format.js.map +1 -0
  22. package/dist/native/section-scroll.d.ts +9 -0
  23. package/dist/native/section-scroll.d.ts.map +1 -0
  24. package/dist/native/section-scroll.js +69 -0
  25. package/dist/native/section-scroll.js.map +1 -0
  26. package/dist/native/segmented.d.ts.map +1 -1
  27. package/dist/native/segmented.js +4 -3
  28. package/dist/native/segmented.js.map +1 -1
  29. package/dist/vue/animated-number.d.ts +6 -0
  30. package/dist/vue/animated-number.d.ts.map +1 -0
  31. package/dist/vue/animated-number.js +52 -0
  32. package/dist/vue/animated-number.js.map +1 -0
  33. package/dist/vue/component-width.d.ts +7 -0
  34. package/dist/vue/component-width.d.ts.map +1 -0
  35. package/dist/vue/component-width.js +29 -0
  36. package/dist/vue/component-width.js.map +1 -0
  37. package/dist/vue/components/ChartPlot.d.ts +66 -0
  38. package/dist/vue/components/ChartPlot.d.ts.map +1 -0
  39. package/dist/vue/components/ChartPlot.js +236 -0
  40. package/dist/vue/components/ChartPlot.js.map +1 -0
  41. package/dist/vue/components/ChoiceControl.d.ts +3 -0
  42. package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
  43. package/dist/vue/components/ChoiceControl.js +29 -22
  44. package/dist/vue/components/ChoiceControl.js.map +1 -1
  45. package/dist/vue/components/DateCalendar.d.ts +16 -1
  46. package/dist/vue/components/DateCalendar.d.ts.map +1 -1
  47. package/dist/vue/components/DateCalendar.js +45 -10
  48. package/dist/vue/components/DateCalendar.js.map +1 -1
  49. package/dist/vue/components/LoadingDecoration.d.ts +1 -1
  50. package/dist/vue/components/MAccordion.d.ts +1 -1
  51. package/dist/vue/components/MAlert.d.ts +3 -3
  52. package/dist/vue/components/MAlert.d.ts.map +1 -1
  53. package/dist/vue/components/MAlert.js +3 -0
  54. package/dist/vue/components/MAlert.js.map +1 -1
  55. package/dist/vue/components/MAvatar.d.ts +1 -1
  56. package/dist/vue/components/MAvatar.d.ts.map +1 -1
  57. package/dist/vue/components/MAvatar.js +5 -1
  58. package/dist/vue/components/MAvatar.js.map +1 -1
  59. package/dist/vue/components/MBadge.d.ts +1 -1
  60. package/dist/vue/components/MBadge.d.ts.map +1 -1
  61. package/dist/vue/components/MBadge.js +3 -1
  62. package/dist/vue/components/MBadge.js.map +1 -1
  63. package/dist/vue/components/MButton.d.ts +6 -6
  64. package/dist/vue/components/MCard.d.ts +3 -3
  65. package/dist/vue/components/MChip.d.ts +2 -2
  66. package/dist/vue/components/MCombobox.d.ts +3 -3
  67. package/dist/vue/components/MCombobox.d.ts.map +1 -1
  68. package/dist/vue/components/MCombobox.js +3 -1
  69. package/dist/vue/components/MCombobox.js.map +1 -1
  70. package/dist/vue/components/MDatePicker.d.ts +16 -16
  71. package/dist/vue/components/MDialog.d.ts +3 -3
  72. package/dist/vue/components/MEmptyState.d.ts +2 -2
  73. package/dist/vue/components/MEmptyState.d.ts.map +1 -1
  74. package/dist/vue/components/MEmptyState.js +3 -0
  75. package/dist/vue/components/MEmptyState.js.map +1 -1
  76. package/dist/vue/components/MFilePicker.d.ts +4 -4
  77. package/dist/vue/components/MFilePicker.d.ts.map +1 -1
  78. package/dist/vue/components/MFilePicker.js +3 -0
  79. package/dist/vue/components/MFilePicker.js.map +1 -1
  80. package/dist/vue/components/MGrid.d.ts +13 -2
  81. package/dist/vue/components/MGrid.d.ts.map +1 -1
  82. package/dist/vue/components/MGrid.js +5 -1
  83. package/dist/vue/components/MGrid.js.map +1 -1
  84. package/dist/vue/components/MIcon.d.ts +3 -3
  85. package/dist/vue/components/MImage.d.ts +2 -2
  86. package/dist/vue/components/MImage.d.ts.map +1 -1
  87. package/dist/vue/components/MImage.js +8 -1
  88. package/dist/vue/components/MImage.js.map +1 -1
  89. package/dist/vue/components/MImageCompare.d.ts +92 -0
  90. package/dist/vue/components/MImageCompare.d.ts.map +1 -0
  91. package/dist/vue/components/MImageCompare.js +138 -0
  92. package/dist/vue/components/MImageCompare.js.map +1 -0
  93. package/dist/vue/components/MImageViewer.d.ts +121 -0
  94. package/dist/vue/components/MImageViewer.d.ts.map +1 -0
  95. package/dist/vue/components/MImageViewer.js +444 -0
  96. package/dist/vue/components/MImageViewer.js.map +1 -0
  97. package/dist/vue/components/MInput.d.ts +4 -4
  98. package/dist/vue/components/MInput.d.ts.map +1 -1
  99. package/dist/vue/components/MInput.js +3 -0
  100. package/dist/vue/components/MInput.js.map +1 -1
  101. package/dist/vue/components/MListItem.d.ts +1 -1
  102. package/dist/vue/components/MPopover.d.ts +106 -0
  103. package/dist/vue/components/MPopover.d.ts.map +1 -0
  104. package/dist/vue/components/MPopover.js +247 -0
  105. package/dist/vue/components/MPopover.js.map +1 -0
  106. package/dist/vue/components/MProgress.d.ts +3 -3
  107. package/dist/vue/components/MProgress.d.ts.map +1 -1
  108. package/dist/vue/components/MProgress.js +5 -2
  109. package/dist/vue/components/MProgress.js.map +1 -1
  110. package/dist/vue/components/MRangeSlider.d.ts +105 -0
  111. package/dist/vue/components/MRangeSlider.d.ts.map +1 -0
  112. package/dist/vue/components/MRangeSlider.js +134 -0
  113. package/dist/vue/components/MRangeSlider.js.map +1 -0
  114. package/dist/vue/components/MResizablePanels.d.ts +137 -0
  115. package/dist/vue/components/MResizablePanels.d.ts.map +1 -0
  116. package/dist/vue/components/MResizablePanels.js +148 -0
  117. package/dist/vue/components/MResizablePanels.js.map +1 -0
  118. package/dist/vue/components/MReveal.d.ts +11 -11
  119. package/dist/vue/components/MSelect.d.ts +1 -1
  120. package/dist/vue/components/MSheet.d.ts +6 -6
  121. package/dist/vue/components/MStack.d.ts +22 -11
  122. package/dist/vue/components/MStack.d.ts.map +1 -1
  123. package/dist/vue/components/MStack.js +6 -1
  124. package/dist/vue/components/MStack.js.map +1 -1
  125. package/dist/vue/components/MTabs.d.ts.map +1 -1
  126. package/dist/vue/components/MTabs.js +6 -5
  127. package/dist/vue/components/MTabs.js.map +1 -1
  128. package/dist/vue/components/MText.d.ts +4 -4
  129. package/dist/vue/components/MTimePicker.d.ts +655 -0
  130. package/dist/vue/components/MTimePicker.d.ts.map +1 -0
  131. package/dist/vue/components/MTimePicker.js +50 -0
  132. package/dist/vue/components/MTimePicker.js.map +1 -0
  133. package/dist/vue/components/MTooltip.d.ts +65 -0
  134. package/dist/vue/components/MTooltip.d.ts.map +1 -0
  135. package/dist/vue/components/MTooltip.js +35 -0
  136. package/dist/vue/components/MTooltip.js.map +1 -0
  137. package/dist/vue/components/MVirtualList.d.ts +3 -0
  138. package/dist/vue/components/MVirtualList.d.ts.map +1 -0
  139. package/dist/vue/components/MVirtualList.js +106 -0
  140. package/dist/vue/components/MVirtualList.js.map +1 -0
  141. package/dist/vue/components/MotionRows.d.ts +15 -0
  142. package/dist/vue/components/MotionRows.d.ts.map +1 -0
  143. package/dist/vue/components/MotionRows.js +12 -0
  144. package/dist/vue/components/MotionRows.js.map +1 -0
  145. package/dist/vue/components/configurator.d.ts +2 -2
  146. package/dist/vue/components/discovery.d.ts +282 -0
  147. package/dist/vue/components/discovery.d.ts.map +1 -0
  148. package/dist/vue/components/discovery.js +65 -0
  149. package/dist/vue/components/discovery.js.map +1 -0
  150. package/dist/vue/components/interactive.d.ts +164 -0
  151. package/dist/vue/components/interactive.d.ts.map +1 -0
  152. package/dist/vue/components/interactive.js +33 -0
  153. package/dist/vue/components/interactive.js.map +1 -0
  154. package/dist/vue/components/layout.d.ts +47 -25
  155. package/dist/vue/components/layout.d.ts.map +1 -1
  156. package/dist/vue/components/layout.js +2 -1
  157. package/dist/vue/components/layout.js.map +1 -1
  158. package/dist/vue/components/navigation.d.ts +225 -0
  159. package/dist/vue/components/navigation.d.ts.map +1 -0
  160. package/dist/vue/components/navigation.js +16 -0
  161. package/dist/vue/components/navigation.js.map +1 -0
  162. package/dist/vue/components/wayfinding.d.ts +441 -0
  163. package/dist/vue/components/wayfinding.d.ts.map +1 -0
  164. package/dist/vue/components/wayfinding.js +39 -0
  165. package/dist/vue/components/wayfinding.js.map +1 -0
  166. package/dist/vue/components/workflows.d.ts +2 -2
  167. package/dist/vue/index.d.ts +14 -4
  168. package/dist/vue/index.d.ts.map +1 -1
  169. package/dist/vue/index.js +38 -3
  170. package/dist/vue/index.js.map +1 -1
  171. package/dist/vue/router-navigation.d.ts +25 -0
  172. package/dist/vue/router-navigation.d.ts.map +1 -0
  173. package/dist/vue/router-navigation.js +15 -0
  174. package/dist/vue/router-navigation.js.map +1 -0
  175. package/dist/vue/services.d.ts.map +1 -1
  176. package/dist/vue/services.js +7 -2
  177. package/dist/vue/services.js.map +1 -1
  178. package/package.json +4 -4
  179. package/src/native/motion-region.ts +14 -1
  180. package/src/native/motion-surface.ts +24 -1
  181. package/src/native/number-flow-format.android.ts +61 -0
  182. package/src/native/number-flow-format.ios.ts +40 -0
  183. package/src/native/number-flow-format.ts +9 -0
  184. package/src/native/section-scroll.ts +81 -0
  185. package/src/native/segmented.ts +4 -3
  186. package/src/vue/animated-number.ts +57 -0
  187. package/src/vue/component-width.ts +34 -0
  188. package/src/vue/components/ChartPlot.ts +267 -0
  189. package/src/vue/components/ChoiceControl.ts +32 -25
  190. package/src/vue/components/DateCalendar.ts +50 -9
  191. package/src/vue/components/MAlert.ts +3 -0
  192. package/src/vue/components/MAvatar.ts +5 -1
  193. package/src/vue/components/MBadge.ts +3 -1
  194. package/src/vue/components/MCombobox.ts +6 -1
  195. package/src/vue/components/MEmptyState.ts +3 -0
  196. package/src/vue/components/MFilePicker.ts +3 -0
  197. package/src/vue/components/MGrid.ts +14 -0
  198. package/src/vue/components/MImage.ts +10 -1
  199. package/src/vue/components/MImageCompare.ts +162 -0
  200. package/src/vue/components/MImageViewer.ts +489 -0
  201. package/src/vue/components/MInput.ts +3 -0
  202. package/src/vue/components/MPopover.ts +305 -0
  203. package/src/vue/components/MProgress.ts +8 -2
  204. package/src/vue/components/MRangeSlider.ts +157 -0
  205. package/src/vue/components/MResizablePanels.ts +180 -0
  206. package/src/vue/components/MStack.ts +6 -0
  207. package/src/vue/components/MTabs.ts +10 -4
  208. package/src/vue/components/MTimePicker.ts +57 -0
  209. package/src/vue/components/MTooltip.ts +39 -0
  210. package/src/vue/components/MVirtualList.ts +140 -0
  211. package/src/vue/components/MotionRows.ts +17 -0
  212. package/src/vue/components/discovery.ts +91 -0
  213. package/src/vue/components/interactive.ts +43 -0
  214. package/src/vue/components/layout.ts +2 -0
  215. package/src/vue/components/navigation.ts +19 -0
  216. package/src/vue/components/wayfinding.ts +48 -0
  217. package/src/vue/index.ts +80 -1
  218. package/src/vue/router-navigation.ts +39 -0
  219. package/src/vue/services.ts +8 -1
  220. package/dist/date-format.android.d.ts +0 -5
  221. package/dist/date-format.android.d.ts.map +0 -1
  222. package/dist/date-format.android.js +0 -39
  223. package/dist/date-format.android.js.map +0 -1
  224. package/dist/date-format.ios.d.ts +0 -5
  225. package/dist/date-format.ios.d.ts.map +0 -1
  226. package/dist/date-format.ios.js +0 -29
  227. package/dist/date-format.ios.js.map +0 -1
@@ -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
+ )
package/src/vue/index.ts CHANGED
@@ -1,3 +1,25 @@
1
+ import {
2
+ MImageViewer,
3
+ MNumberFlow,
4
+ MSortableList,
5
+ MSwipeActions,
6
+ MResizablePanels,
7
+ MImageCompare,
8
+ } from './components/interactive.js'
9
+ import {
10
+ MCommandPalette,
11
+ MNavigationRail,
12
+ MBreadcrumb,
13
+ MTimeline,
14
+ MChart,
15
+ } from './components/wayfinding.js'
16
+ import { MTooltip } from './components/MTooltip.js'
17
+ import { MDataTable, MCarousel, MCalendar, MRating, MTreeView } from './components/discovery.js'
18
+ import { MRangeSlider } from './components/MRangeSlider.js'
19
+ import { MPopover } from './components/MPopover.js'
20
+ import { MMenu, MAppBar, MTabBar } from './components/navigation.js'
21
+ import { MTimePicker } from './components/MTimePicker.js'
22
+ import { MVirtualList } from './components/MVirtualList.js'
1
23
  import { MNumberInput, MMultiSelect } from './components/configurator.js'
2
24
  import { MImage } from './components/MImage.js'
3
25
  import { MStack } from './components/MStack.js'
@@ -13,7 +35,7 @@ import type { App, Component } from 'nativescript-vue'
13
35
  import { createMavisServices, type MavisServiceOptions } from './services.js'
14
36
  export { createMavisServices } from './services.js'
15
37
  export type { MavisServiceOptions } from './services.js'
16
- import { MThemeProvider, MSpan } from '@getcortexlabs/mavis-core/vue'
38
+ import { MThemeProvider, MSpan, MPlatform } from '@getcortexlabs/mavis-core/vue'
17
39
  import { MScreen } from './components/MScreen.js'
18
40
  import { MBox, MRow, MColumn } from './components/layout.js'
19
41
  import { MCard } from './components/MCard.js'
@@ -43,7 +65,14 @@ import { MSheet } from './components/MSheet.js'
43
65
  import type { ClaimSystemBack, SystemBackClaimant } from './system-back.js'
44
66
 
45
67
  export {
68
+ MImageViewer,
69
+ MNumberFlow,
70
+ MSortableList,
71
+ MSwipeActions,
72
+ MResizablePanels,
73
+ MImageCompare,
46
74
  MThemeProvider,
75
+ MPlatform,
47
76
  MSpan,
48
77
  MScreen,
49
78
  MBox,
@@ -89,9 +118,29 @@ export {
89
118
  MFormErrors,
90
119
  MSteps,
91
120
  MPagination,
121
+ MPopover,
122
+ MMenu,
123
+ MAppBar,
124
+ MTabBar,
125
+ MTimePicker,
126
+ MVirtualList,
127
+ MDataTable,
128
+ MCarousel,
129
+ MRangeSlider,
130
+ MCalendar,
131
+ MRating,
132
+ MTreeView,
133
+ MCommandPalette,
134
+ MNavigationRail,
135
+ MBreadcrumb,
136
+ MTooltip,
137
+ MTimeline,
138
+ MChart,
92
139
  }
93
140
  export {
94
141
  useMavisTheme,
142
+ useMavisPlatform,
143
+ useMavisListMotion,
95
144
  useToast,
96
145
  useFormController,
97
146
  useFormField,
@@ -100,6 +149,9 @@ export {
100
149
  } from '@getcortexlabs/mavis-core/vue'
101
150
  export type {
102
151
  MavisThemeContext,
152
+ MavisPlatform,
153
+ MavisPlatformTarget,
154
+ MavisPlatformContext,
103
155
  Appearance,
104
156
  AppearanceMode,
105
157
  AppearanceSource,
@@ -120,7 +172,14 @@ export function createMavis(options: MavisOptions = {}) {
120
172
  if (components === false) return
121
173
  for (const [name, component] of Object.entries(
122
174
  components ?? {
175
+ MImageViewer,
176
+ MNumberFlow,
177
+ MSortableList,
178
+ MSwipeActions,
179
+ MResizablePanels,
180
+ MImageCompare,
123
181
  MThemeProvider,
182
+ MPlatform,
124
183
  MSpan,
125
184
  MScreen,
126
185
  MBox,
@@ -166,6 +225,24 @@ export function createMavis(options: MavisOptions = {}) {
166
225
  MFormErrors,
167
226
  MSteps,
168
227
  MPagination,
228
+ MPopover,
229
+ MMenu,
230
+ MAppBar,
231
+ MTabBar,
232
+ MTimePicker,
233
+ MVirtualList,
234
+ MDataTable,
235
+ MCarousel,
236
+ MRangeSlider,
237
+ MCalendar,
238
+ MRating,
239
+ MTreeView,
240
+ MCommandPalette,
241
+ MNavigationRail,
242
+ MBreadcrumb,
243
+ MTooltip,
244
+ MTimeline,
245
+ MChart,
169
246
  },
170
247
  )) {
171
248
  app.component(name, component)
@@ -175,3 +252,5 @@ export function createMavis(options: MavisOptions = {}) {
175
252
  }
176
253
 
177
254
  export * from '../files.js'
255
+
256
+ export { createMavisNavigation } from './router-navigation.js'