@getcortexlabs/mavis 0.1.0-alpha.9 → 0.1.0-rc.12

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 (246) 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 +3 -3
  66. package/dist/vue/components/MCombobox.d.ts +4 -4
  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 +1 -1
  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 +3 -3
  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/MPinInput.d.ts +57 -0
  102. package/dist/vue/components/MPinInput.d.ts.map +1 -0
  103. package/dist/vue/components/MPinInput.js +128 -0
  104. package/dist/vue/components/MPinInput.js.map +1 -0
  105. package/dist/vue/components/MPopover.d.ts +106 -0
  106. package/dist/vue/components/MPopover.d.ts.map +1 -0
  107. package/dist/vue/components/MPopover.js +259 -0
  108. package/dist/vue/components/MPopover.js.map +1 -0
  109. package/dist/vue/components/MProgress.d.ts +3 -3
  110. package/dist/vue/components/MProgress.d.ts.map +1 -1
  111. package/dist/vue/components/MProgress.js +5 -2
  112. package/dist/vue/components/MProgress.js.map +1 -1
  113. package/dist/vue/components/MRangeSlider.d.ts +105 -0
  114. package/dist/vue/components/MRangeSlider.d.ts.map +1 -0
  115. package/dist/vue/components/MRangeSlider.js +134 -0
  116. package/dist/vue/components/MRangeSlider.js.map +1 -0
  117. package/dist/vue/components/MResizablePanels.d.ts +137 -0
  118. package/dist/vue/components/MResizablePanels.d.ts.map +1 -0
  119. package/dist/vue/components/MResizablePanels.js +148 -0
  120. package/dist/vue/components/MResizablePanels.js.map +1 -0
  121. package/dist/vue/components/MReveal.d.ts +11 -11
  122. package/dist/vue/components/MSelect.d.ts +1 -1
  123. package/dist/vue/components/MSheet.d.ts +6 -6
  124. package/dist/vue/components/MStack.d.ts +28 -17
  125. package/dist/vue/components/MStack.d.ts.map +1 -1
  126. package/dist/vue/components/MStack.js +6 -1
  127. package/dist/vue/components/MStack.js.map +1 -1
  128. package/dist/vue/components/MTabs.d.ts.map +1 -1
  129. package/dist/vue/components/MTabs.js +6 -5
  130. package/dist/vue/components/MTabs.js.map +1 -1
  131. package/dist/vue/components/MText.d.ts +4 -4
  132. package/dist/vue/components/MTimePicker.d.ts +655 -0
  133. package/dist/vue/components/MTimePicker.d.ts.map +1 -0
  134. package/dist/vue/components/MTimePicker.js +50 -0
  135. package/dist/vue/components/MTimePicker.js.map +1 -0
  136. package/dist/vue/components/MTooltip.d.ts +65 -0
  137. package/dist/vue/components/MTooltip.d.ts.map +1 -0
  138. package/dist/vue/components/MTooltip.js +35 -0
  139. package/dist/vue/components/MTooltip.js.map +1 -0
  140. package/dist/vue/components/MVirtualList.d.ts +3 -0
  141. package/dist/vue/components/MVirtualList.d.ts.map +1 -0
  142. package/dist/vue/components/MVirtualList.js +106 -0
  143. package/dist/vue/components/MVirtualList.js.map +1 -0
  144. package/dist/vue/components/MotionRows.d.ts +15 -0
  145. package/dist/vue/components/MotionRows.d.ts.map +1 -0
  146. package/dist/vue/components/MotionRows.js +12 -0
  147. package/dist/vue/components/MotionRows.js.map +1 -0
  148. package/dist/vue/components/configurator.d.ts +2 -2
  149. package/dist/vue/components/creative.d.ts +614 -0
  150. package/dist/vue/components/creative.d.ts.map +1 -0
  151. package/dist/vue/components/creative.js +185 -0
  152. package/dist/vue/components/creative.js.map +1 -0
  153. package/dist/vue/components/dashboard.d.ts +474 -0
  154. package/dist/vue/components/dashboard.d.ts.map +1 -0
  155. package/dist/vue/components/dashboard.js +193 -0
  156. package/dist/vue/components/dashboard.js.map +1 -0
  157. package/dist/vue/components/discovery.d.ts +282 -0
  158. package/dist/vue/components/discovery.d.ts.map +1 -0
  159. package/dist/vue/components/discovery.js +65 -0
  160. package/dist/vue/components/discovery.js.map +1 -0
  161. package/dist/vue/components/interactive.d.ts +164 -0
  162. package/dist/vue/components/interactive.d.ts.map +1 -0
  163. package/dist/vue/components/interactive.js +33 -0
  164. package/dist/vue/components/interactive.js.map +1 -0
  165. package/dist/vue/components/layout.d.ts +47 -25
  166. package/dist/vue/components/layout.d.ts.map +1 -1
  167. package/dist/vue/components/layout.js +2 -1
  168. package/dist/vue/components/layout.js.map +1 -1
  169. package/dist/vue/components/navigation.d.ts +225 -0
  170. package/dist/vue/components/navigation.d.ts.map +1 -0
  171. package/dist/vue/components/navigation.js +16 -0
  172. package/dist/vue/components/navigation.js.map +1 -0
  173. package/dist/vue/components/screen-components.d.ts +502 -0
  174. package/dist/vue/components/screen-components.d.ts.map +1 -0
  175. package/dist/vue/components/screen-components.js +46 -0
  176. package/dist/vue/components/screen-components.js.map +1 -0
  177. package/dist/vue/components/wayfinding.d.ts +441 -0
  178. package/dist/vue/components/wayfinding.d.ts.map +1 -0
  179. package/dist/vue/components/wayfinding.js +39 -0
  180. package/dist/vue/components/wayfinding.js.map +1 -0
  181. package/dist/vue/components/workflows.d.ts +2 -2
  182. package/dist/vue/index.d.ts +17 -4
  183. package/dist/vue/index.d.ts.map +1 -1
  184. package/dist/vue/index.js +60 -3
  185. package/dist/vue/index.js.map +1 -1
  186. package/dist/vue/router-navigation.d.ts +25 -0
  187. package/dist/vue/router-navigation.d.ts.map +1 -0
  188. package/dist/vue/router-navigation.js +15 -0
  189. package/dist/vue/router-navigation.js.map +1 -0
  190. package/dist/vue/services.d.ts.map +1 -1
  191. package/dist/vue/services.js +7 -2
  192. package/dist/vue/services.js.map +1 -1
  193. package/package.json +4 -4
  194. package/src/native/motion-region.ts +14 -1
  195. package/src/native/motion-surface.ts +24 -1
  196. package/src/native/number-flow-format.android.ts +61 -0
  197. package/src/native/number-flow-format.ios.ts +40 -0
  198. package/src/native/number-flow-format.ts +9 -0
  199. package/src/native/section-scroll.ts +81 -0
  200. package/src/native/segmented.ts +4 -3
  201. package/src/vue/animated-number.ts +57 -0
  202. package/src/vue/component-width.ts +34 -0
  203. package/src/vue/components/ChartPlot.ts +267 -0
  204. package/src/vue/components/ChoiceControl.ts +32 -25
  205. package/src/vue/components/DateCalendar.ts +50 -9
  206. package/src/vue/components/MAlert.ts +3 -0
  207. package/src/vue/components/MAvatar.ts +5 -1
  208. package/src/vue/components/MBadge.ts +3 -1
  209. package/src/vue/components/MCombobox.ts +6 -1
  210. package/src/vue/components/MEmptyState.ts +3 -0
  211. package/src/vue/components/MFilePicker.ts +3 -0
  212. package/src/vue/components/MGrid.ts +14 -0
  213. package/src/vue/components/MImage.ts +10 -1
  214. package/src/vue/components/MImageCompare.ts +162 -0
  215. package/src/vue/components/MImageViewer.ts +489 -0
  216. package/src/vue/components/MInput.ts +3 -0
  217. package/src/vue/components/MPinInput.ts +145 -0
  218. package/src/vue/components/MPopover.ts +314 -0
  219. package/src/vue/components/MProgress.ts +8 -2
  220. package/src/vue/components/MRangeSlider.ts +157 -0
  221. package/src/vue/components/MResizablePanels.ts +180 -0
  222. package/src/vue/components/MStack.ts +6 -0
  223. package/src/vue/components/MTabs.ts +10 -4
  224. package/src/vue/components/MTimePicker.ts +57 -0
  225. package/src/vue/components/MTooltip.ts +39 -0
  226. package/src/vue/components/MVirtualList.ts +140 -0
  227. package/src/vue/components/MotionRows.ts +17 -0
  228. package/src/vue/components/creative.ts +246 -0
  229. package/src/vue/components/dashboard.ts +249 -0
  230. package/src/vue/components/discovery.ts +91 -0
  231. package/src/vue/components/interactive.ts +43 -0
  232. package/src/vue/components/layout.ts +2 -0
  233. package/src/vue/components/navigation.ts +19 -0
  234. package/src/vue/components/screen-components.ts +61 -0
  235. package/src/vue/components/wayfinding.ts +48 -0
  236. package/src/vue/index.ts +144 -1
  237. package/src/vue/router-navigation.ts +39 -0
  238. package/src/vue/services.ts +8 -1
  239. package/dist/date-format.android.d.ts +0 -5
  240. package/dist/date-format.android.d.ts.map +0 -1
  241. package/dist/date-format.android.js +0 -39
  242. package/dist/date-format.android.js.map +0 -1
  243. package/dist/date-format.ios.d.ts +0 -5
  244. package/dist/date-format.ios.d.ts.map +0 -1
  245. package/dist/date-format.ios.js +0 -29
  246. package/dist/date-format.ios.js.map +0 -1
@@ -0,0 +1,267 @@
1
+ import {
2
+ animate,
3
+ motionValue,
4
+ set,
5
+ stop,
6
+ onReducedMotion,
7
+ reducedMotion,
8
+ type MotionValue,
9
+ } from '@rafaelaugusto/jolt'
10
+ import { defineComponent, h, ref, watch, nextTick, onBeforeUnmount } from 'nativescript-vue'
11
+ import type { EventData, TapGestureEventData, View } from '@nativescript/core'
12
+ import { chartPlotProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
13
+ import {
14
+ chartHitTest,
15
+ interpolateChart,
16
+ componentMotion,
17
+ type ChartGeometry,
18
+ type ChartPoint,
19
+ } from '@getcortexlabs/mavis-core'
20
+
21
+ /** Bounded native geometry, without a WebView or a second animation scheduler. */
22
+ export const ChartPlot = defineComponent({
23
+ name: 'MChartPlot',
24
+ props: chartPlotProps,
25
+ emits: { select: (_category: number, _series: number) => true },
26
+ setup(props, { emit }) {
27
+ const { theme } = useMavisTheme()
28
+ const width = ref(0)
29
+ let progress: MotionValue | undefined
30
+ let playback: ReturnType<typeof animate> | undefined
31
+ let off: (() => void) | undefined
32
+ let releaseReduced: (() => void) | undefined
33
+ let generation = 0
34
+ let loaded = false
35
+ const settle = () => {
36
+ if (reducedMotion() && progress) {
37
+ generation++
38
+ stop(progress)
39
+ set(progress, 1)
40
+ paint(destination)
41
+ }
42
+ }
43
+ let presentation: ChartGeometry | undefined
44
+ let origin: ChartGeometry | undefined
45
+ let destination = props.geometry
46
+ const marks = new Map<string, View>()
47
+ function paint(geometry: ChartGeometry) {
48
+ presentation = geometry
49
+ const height = props.height
50
+ const x = (point: ChartPoint) => point.x * width.value
51
+ const y = (point: ChartPoint) => 8 + point.y * (height - 16)
52
+ const zero = 8 + geometry.zero * (height - 16)
53
+ const group = (width.value / Math.max(1, geometry.series[0]?.points.length ?? 0)) * 0.7
54
+ const bar = group / Math.max(1, geometry.series.length)
55
+ const write = (key: string, values: Record<string, number>) => {
56
+ const view = marks.get(key)
57
+ if (view?.isLoaded) Object.assign(view, values)
58
+ }
59
+ geometry.series.forEach((series, seriesIndex) =>
60
+ series.points.forEach((point, index) => {
61
+ if (!point) return
62
+ if (props.type === 'bar')
63
+ write(`bar:${seriesIndex}:${index}`, {
64
+ left: x(point) - group / 2 + seriesIndex * bar,
65
+ top: Math.min(y(point), zero),
66
+ width: Math.max(1, bar * 0.82),
67
+ height: Math.max(1, Math.abs(zero - y(point))),
68
+ })
69
+ else {
70
+ const radius =
71
+ props.selected?.category === index && props.selected.series === seriesIndex ? 5 : 3
72
+ write(`point:${seriesIndex}:${index}`, {
73
+ left: x(point) - radius,
74
+ top: y(point) - radius,
75
+ })
76
+ const previous = series.points[index - 1]
77
+ if (previous) {
78
+ const dx = x(point) - x(previous),
79
+ dy = y(point) - y(previous)
80
+ const length = Math.hypot(dx, dy)
81
+ write(`line:${seriesIndex}:${index}`, {
82
+ left: (x(point) + x(previous)) / 2 - length / 2,
83
+ top: (y(point) + y(previous)) / 2 - 1.25,
84
+ width: length,
85
+ rotate: (Math.atan2(dy, dx) * 180) / Math.PI,
86
+ })
87
+ }
88
+ }
89
+ }),
90
+ )
91
+ }
92
+ function update() {
93
+ destination = props.geometry
94
+ if (!progress) {
95
+ presentation = destination
96
+ return
97
+ }
98
+ origin = presentation
99
+ const token = ++generation
100
+ if (reducedMotion()) {
101
+ settle()
102
+ return
103
+ }
104
+ playback?.stop()
105
+ set(progress, 0)
106
+ paint(interpolateChart(origin, destination, 0))
107
+ const current = animate(progress, 1, componentMotion(theme.value, 'data'))
108
+ playback = current
109
+ void current.finished.then((completed) => {
110
+ if (completed && playback === current && progress && token === generation)
111
+ paint(destination)
112
+ })
113
+ }
114
+ function connect() {
115
+ if (progress) return
116
+ progress = motionValue(0)
117
+ releaseReduced = onReducedMotion(settle)
118
+ off = progress.subscribe((value) => paint(interpolateChart(origin, destination, value)), {
119
+ immediate: false,
120
+ })
121
+ update()
122
+ }
123
+ function disconnect() {
124
+ generation++
125
+ releaseReduced?.()
126
+ releaseReduced = undefined
127
+ off?.()
128
+ off = undefined
129
+ playback?.stop()
130
+ playback = undefined
131
+ if (progress) stop(progress)
132
+ progress = undefined
133
+ presentation = props.geometry
134
+ }
135
+ watch(() => props.geometry, update, { flush: 'post' })
136
+ watch(
137
+ () => [props.height, props.type, props.selected],
138
+ () => {
139
+ if (presentation) paint(presentation)
140
+ },
141
+ { flush: 'post' },
142
+ )
143
+ onBeforeUnmount(() => {
144
+ loaded = false
145
+ disconnect()
146
+ })
147
+
148
+ return () => {
149
+ const height = props.height
150
+ const x = (point: ChartPoint) => point.x * width.value
151
+ const y = (point: ChartPoint) => 8 + point.y * (height - 16)
152
+ const zero = 8 + props.geometry.zero * (height - 16)
153
+ const count = props.geometry.series[0]?.points.length ?? 0
154
+ const groupWidth = (width.value / Math.max(1, count)) * 0.7
155
+ const barWidth = groupWidth / Math.max(1, props.geometry.series.length)
156
+ const shape = (key: string, values: Record<string, unknown>) =>
157
+ h('ContentView', {
158
+ key,
159
+ accessibilityHidden: true,
160
+ isUserInteractionEnabled: false,
161
+ ...values,
162
+ onLoaded: (event: EventData) => {
163
+ marks.set(key, event.object as View)
164
+ },
165
+ onUnloaded: () => marks.delete(key),
166
+ })
167
+ return h(
168
+ 'AbsoluteLayout',
169
+ {
170
+ class: 'm-chart-plot',
171
+ onLoaded: () => {
172
+ loaded = true
173
+ void nextTick(() => {
174
+ if (loaded) connect()
175
+ })
176
+ },
177
+ onUnloaded: () => {
178
+ loaded = false
179
+ disconnect()
180
+ },
181
+ height,
182
+ accessibilityHidden: true,
183
+ onLayoutChanged: (event: EventData) => {
184
+ const size = (event.object as View).getActualSize()
185
+ if (width.value !== size.width) {
186
+ width.value = size.width
187
+ void nextTick(() => {
188
+ if (presentation) paint(presentation)
189
+ })
190
+ }
191
+ },
192
+ onTap: (event: TapGestureEventData) => {
193
+ if (props.disabled || !width.value || !count) return
194
+ const hit = chartHitTest(
195
+ props.geometry,
196
+ props.type,
197
+ event.getX() / width.value,
198
+ (event.getY() - 8) / (height - 16),
199
+ )
200
+ if (hit) emit('select', hit.category, hit.series)
201
+ },
202
+ },
203
+ width.value <= 0
204
+ ? []
205
+ : [
206
+ ...props.geometry.ticks.map((_, i) =>
207
+ shape(`grid:${i}`, {
208
+ left: 0,
209
+ top: 8 + ((height - 16) * i) / 4,
210
+ width: width.value,
211
+ height: 1,
212
+ backgroundColor: theme.value.colors.border,
213
+ }),
214
+ ),
215
+ ...props.geometry.series.flatMap((series, seriesIndex) =>
216
+ series.points.flatMap((point, index) => {
217
+ if (!point) return []
218
+ const color = props.colors[seriesIndex]
219
+ const selected =
220
+ props.selected?.category === index && props.selected.series === seriesIndex
221
+ const previous = series.points[index - 1]
222
+ const line =
223
+ props.type === 'line' && previous
224
+ ? (() => {
225
+ const dx = x(point) - x(previous),
226
+ dy = y(point) - y(previous)
227
+ const length = Math.hypot(dx, dy)
228
+ return shape(`line:${seriesIndex}:${index}`, {
229
+ left: (x(point) + x(previous)) / 2 - length / 2,
230
+ top: (y(point) + y(previous)) / 2 - 1.25,
231
+ width: length,
232
+ height: 2.5,
233
+ rotate: (Math.atan2(dy, dx) * 180) / Math.PI,
234
+ backgroundColor: color,
235
+ borderRadius: 1.25,
236
+ })
237
+ })()
238
+ : null
239
+ const radius = selected ? 5 : 3
240
+ return [
241
+ line,
242
+ props.type === 'bar'
243
+ ? shape(`bar:${seriesIndex}:${index}`, {
244
+ left: x(point) - groupWidth / 2 + seriesIndex * barWidth,
245
+ top: Math.min(y(point), zero),
246
+ width: Math.max(1, barWidth * 0.82),
247
+ height: Math.max(1, Math.abs(zero - y(point))),
248
+ borderRadius: 3,
249
+ backgroundColor: color,
250
+ opacity: props.selected && !selected ? 0.45 : 1,
251
+ })
252
+ : shape(`point:${seriesIndex}:${index}`, {
253
+ left: x(point) - radius,
254
+ top: y(point) - radius,
255
+ width: radius * 2,
256
+ height: radius * 2,
257
+ borderRadius: radius,
258
+ backgroundColor: color,
259
+ }),
260
+ ]
261
+ }),
262
+ ),
263
+ ],
264
+ )
265
+ }
266
+ },
267
+ })
@@ -23,7 +23,12 @@ registerElement('MavisRadioButton', () => MavisButton)
23
23
  export const ChoiceControl = defineComponent({
24
24
  name: 'ChoiceControl',
25
25
  inheritAttrs: false,
26
- props: { ...checkboxProps, radio: Boolean, pressFeedback: { type: Boolean, default: true } },
26
+ props: {
27
+ ...checkboxProps,
28
+ radio: Boolean,
29
+ labelHidden: Boolean,
30
+ pressFeedback: { type: Boolean, default: true },
31
+ },
27
32
  emits: ['activate'],
28
33
  setup(props, { attrs, emit }) {
29
34
  const { theme } = useMavisTheme()
@@ -220,33 +225,35 @@ export const ChoiceControl = defineComponent({
220
225
  : null,
221
226
  },
222
227
  ),
223
- h(
224
- MColumn,
225
- {
226
- gap: 'xs',
227
- isUserInteractionEnabled: false,
228
- accessibilityHidden: true,
229
- },
230
- {
231
- default: () => [
232
- h(MText, {
233
- text: props.label,
234
- accessibilityHidden: true,
228
+ props.labelHidden
229
+ ? null
230
+ : h(
231
+ MColumn,
232
+ {
233
+ gap: 'xs',
235
234
  isUserInteractionEnabled: false,
236
- style: { fontWeight: '600' },
237
- }),
238
- props.helperText
239
- ? h(MText, {
240
- text: props.helperText,
241
- variant: 'caption',
242
- tone: 'muted',
235
+ accessibilityHidden: true,
236
+ },
237
+ {
238
+ default: () => [
239
+ h(MText, {
240
+ text: props.label,
243
241
  accessibilityHidden: true,
244
242
  isUserInteractionEnabled: false,
245
- })
246
- : null,
247
- ],
248
- },
249
- ),
243
+ style: { fontWeight: '600' },
244
+ }),
245
+ props.helperText
246
+ ? h(MText, {
247
+ text: props.helperText,
248
+ variant: 'caption',
249
+ tone: 'muted',
250
+ accessibilityHidden: true,
251
+ isUserInteractionEnabled: false,
252
+ })
253
+ : null,
254
+ ],
255
+ },
256
+ ),
250
257
  ],
251
258
  },
252
259
  ),
@@ -1,3 +1,4 @@
1
+ import { useMotionSurface } from '../use-motion-surface.js'
1
2
  import { defineComponent, h } from 'nativescript-vue'
2
3
  import { calendarDayLabel } from '@getcortexlabs/mavis-core'
3
4
  import {
@@ -5,10 +6,42 @@ import {
5
6
  dateCalendarEmits,
6
7
  useDateCalendar,
7
8
  useMavisTheme,
9
+ useCalendarMotion,
10
+ useComponentState,
8
11
  } from '@getcortexlabs/mavis-core/vue'
9
12
  import { MButton } from './MButton.js'
10
13
  import { MText } from './MText.js'
11
- import { MColumn, MRow } from './layout.js'
14
+ import { MColumn, MRow, MBox } from './layout.js'
15
+
16
+ const CalendarDay = defineComponent({
17
+ inheritAttrs: false,
18
+ props: { painted: Boolean },
19
+ setup(props, { attrs }) {
20
+ const { theme } = useMavisTheme()
21
+ const fill = useComponentState(() => ({
22
+ opacity: props.painted ? 1 : 0,
23
+ scale: props.painted ? 1 : 0.8,
24
+ }))
25
+ return () =>
26
+ h(MBox, { row: attrs.row, col: attrs.col }, () => [
27
+ h(MBox, {
28
+ width: '100%',
29
+ height: '100%',
30
+ radius: 'sm',
31
+ backgroundColor: theme.value.colors.primarySoft,
32
+ motionSurface: fill,
33
+ accessibilityHidden: true,
34
+ isUserInteractionEnabled: false,
35
+ }),
36
+ h(MButton, {
37
+ ...attrs,
38
+ row: undefined,
39
+ col: undefined,
40
+ style: [attrs.style, { backgroundColor: 'transparent' }],
41
+ }),
42
+ ])
43
+ },
44
+ })
12
45
 
13
46
  /** @internal Natural-size native buttons; horizontal scrolling preserves large text and targets. */
14
47
  export const DateCalendar = defineComponent({
@@ -18,6 +51,8 @@ export const DateCalendar = defineComponent({
18
51
  setup(props, { emit }) {
19
52
  const { theme } = useMavisTheme()
20
53
  const calendar = useDateCalendar(props, (value) => emit('update:activeDate', value))
54
+ const presentation = useCalendarMotion(() => props.activeDate)
55
+ const motion = useMotionSurface(() => presentation)
21
56
  return () => {
22
57
  const { colors, radius } = theme.value
23
58
  return h(
@@ -34,7 +69,7 @@ export const DateCalendar = defineComponent({
34
69
  icon: 'chevron-left',
35
70
  variant: 'ghost',
36
71
  accessibilityLabel: calendar.words.value.previous,
37
- disabled: !calendar.canPage(-1),
72
+ disabled: props.disabled || !calendar.canPage(-1),
38
73
  onClick: () => calendar.page(-1),
39
74
  }),
40
75
  h(MText, {
@@ -47,7 +82,7 @@ export const DateCalendar = defineComponent({
47
82
  icon: 'chevron-right',
48
83
  variant: 'ghost',
49
84
  accessibilityLabel: calendar.words.value.next,
50
- disabled: !calendar.canPage(1),
85
+ disabled: props.disabled || !calendar.canPage(1),
51
86
  onClick: () => calendar.page(1),
52
87
  }),
53
88
  ],
@@ -57,6 +92,7 @@ export const DateCalendar = defineComponent({
57
92
  h(
58
93
  'GridLayout',
59
94
  {
95
+ ...motion,
60
96
  columns: 'auto,auto,auto,auto,auto,auto,auto',
61
97
  rows: Array.from(
62
98
  { length: calendar.cells.value.length / 7 + 1 },
@@ -73,13 +109,17 @@ export const DateCalendar = defineComponent({
73
109
  variant: 'caption',
74
110
  tone: 'muted',
75
111
  accessibilityLabel: calendar.words.value.weekdays[weekday],
76
- style: { minWidth: 48, textAlignment: 'center', padding: 8 },
112
+ style: { minWidth: 44, textAlignment: 'center', padding: 8 },
77
113
  }),
78
114
  ),
79
115
  ...calendar.cells.value.map((date, index) => {
80
116
  if (!date) return null
81
- const selected = date === props.selected
82
- return h(MButton, {
117
+ const selected =
118
+ date === props.selected ||
119
+ date === props.rangeStart ||
120
+ date === props.rangeEnd
121
+ return h(CalendarDay, {
122
+ painted: selected || calendar.inRange(date),
83
123
  key: date,
84
124
  row: Math.floor(index / 7) + 1,
85
125
  col: index % 7,
@@ -87,9 +127,9 @@ export const DateCalendar = defineComponent({
87
127
  variant: 'ghost',
88
128
  accessibilityLabel: calendarDayLabel(date, props.locale),
89
129
  accessibilityValue: selected ? calendar.words.value.selected : '',
90
- disabled: !calendar.available(date),
130
+ disabled: props.disabled || props.readonly || !calendar.available(date),
91
131
  style: {
92
- minWidth: 48,
132
+ minWidth: 44,
93
133
  minHeight: 48,
94
134
  margin: 1,
95
135
  paddingLeft: 6,
@@ -102,7 +142,8 @@ export const DateCalendar = defineComponent({
102
142
  color: colors.text,
103
143
  },
104
144
  onClick: () => {
105
- if (calendar.available(date)) emit('select', date)
145
+ if (!props.disabled && !props.readonly && calendar.available(date))
146
+ emit('select', date)
106
147
  },
107
148
  })
108
149
  }),
@@ -1,3 +1,4 @@
1
+ import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
1
2
  import { defineComponent, h, mergeProps, onBeforeUnmount, watch } from 'nativescript-vue'
2
3
  import type { EventData, View } from '@nativescript/core'
3
4
  import { alertProps, alertEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
@@ -16,6 +17,7 @@ export const MAlert = defineComponent({
16
17
  emits: alertEmits,
17
18
  setup(props, { attrs, slots, emit }) {
18
19
  const { theme } = useMavisTheme()
20
+ const arrival = useComponentContent(() => props.title)
19
21
  const nativeAttrs = useNativeViewAttrs(props)
20
22
  let content: View | undefined
21
23
  let pending: ReturnType<typeof setTimeout> | undefined
@@ -83,6 +85,7 @@ export const MAlert = defineComponent({
83
85
  {
84
86
  width: 32,
85
87
  height: 32,
88
+ motionSurface: arrival,
86
89
  radius: 'sm',
87
90
  shrink: 0,
88
91
  backgroundColor: colors.elevated,
@@ -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,
@@ -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,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
  },
@@ -1,3 +1,4 @@
1
+ import { useMotionRegion } from '../use-motion-region.js'
1
2
  import {
2
3
  Comment,
3
4
  Fragment,
@@ -17,6 +18,7 @@ import {
17
18
  layoutDirection,
18
19
  useLayoutShrink,
19
20
  useMavisTheme,
21
+ useComponentLayout,
20
22
  } from '@getcortexlabs/mavis-core/vue'
21
23
  import { boxStyle } from '../props.js'
22
24
  import { useNativeViewAttrs } from '../accessibility.js'
@@ -32,6 +34,17 @@ export const MGrid = defineComponent({
32
34
  const nativeAttrs = useNativeViewAttrs(props)
33
35
  provide(layoutDirection, 'column')
34
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)
35
48
  return () => {
36
49
  const gap = resolveSpace(theme.value, props.gap ?? 'none')
37
50
  const count = gridColumns(props.columns, props.minColumnWidth, gap, width.value)
@@ -71,6 +84,7 @@ export const MGrid = defineComponent({
71
84
  h(
72
85
  'GridLayout',
73
86
  {
87
+ ...motion,
74
88
  columns: Array.from({ length: count }, () => '*').join(`,${gap},`),
75
89
  rows: Array.from({ length: rows }, () => 'auto').join(`,${gap},`),
76
90
  onLayoutChanged: (event: EventData) => {
@@ -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,