@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,246 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ mergeProps,
5
+ nextTick,
6
+ onBeforeUnmount,
7
+ onDeactivated,
8
+ watch,
9
+ type PropType,
10
+ } from 'nativescript-vue'
11
+ import {
12
+ Application,
13
+ ScrollView,
14
+ isAndroid,
15
+ isIOS,
16
+ type View,
17
+ type EventData,
18
+ } from '@nativescript/core'
19
+ import { reducedMotion, onReducedMotion } from '@rafaelaugusto/jolt'
20
+ import {
21
+ createColorPicker,
22
+ createGauge,
23
+ createSwipeDeck,
24
+ createTransferList,
25
+ createTour,
26
+ createMarquee,
27
+ tourHostProps,
28
+ marqueeHostProps,
29
+ } from '@getcortexlabs/mavis-core/vue'
30
+ import type { gaugeGeometry } from '@getcortexlabs/mavis-core'
31
+ import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
32
+ import { MBox, MColumn, MRow } from './layout.js'
33
+ import { MStack } from './MStack.js'
34
+ import { MCard } from './MCard.js'
35
+ import { MText } from './MText.js'
36
+ import { MInput } from './MInput.js'
37
+ import { MImage } from './MImage.js'
38
+ import { MButton } from './MButton.js'
39
+ import { MSlider } from './MSlider.js'
40
+ import { MCheckbox } from './MCheckbox.js'
41
+ import { MNumberFlow } from './interactive.js'
42
+ import { MPopover } from './MPopover.js'
43
+
44
+ const GaugeFallback = defineComponent({
45
+ props: {
46
+ geometry: Object as PropType<ReturnType<typeof gaugeGeometry>>,
47
+ size: Number,
48
+ strokeWidth: Number,
49
+ color: String,
50
+ track: String,
51
+ hidden: Boolean,
52
+ },
53
+ setup() {
54
+ return () => h('GridLayout', { accessible: false, isUserInteractionEnabled: false })
55
+ },
56
+ })
57
+ interface FocusView {
58
+ readonly isFirstResponder: boolean
59
+ readonly subviews: { count: number; objectAtIndex(index: number): FocusView }
60
+ readonly window?: FocusView
61
+ becomeFirstResponder(): boolean
62
+ }
63
+ const TourHost = defineComponent({
64
+ inheritAttrs: false,
65
+ props: tourHostProps,
66
+ setup(props, { attrs, slots }) {
67
+ let root: View | undefined,
68
+ restore = () => {}
69
+ function capture() {
70
+ if (!root?.isLoaded) return
71
+ if (isAndroid) {
72
+ const focused = root.page?.android?.findFocus?.()
73
+ restore = () => focused?.requestFocus?.()
74
+ } else if (isIOS) {
75
+ const find = (view: FocusView): FocusView | undefined => {
76
+ if (view.isFirstResponder) return view
77
+ for (let i = 0; i < view.subviews.count; i++) {
78
+ const result = find(view.subviews.objectAtIndex(i))
79
+ if (result) return result
80
+ }
81
+ }
82
+ const window = (root.ios as FocusView)?.window
83
+ const focused = window ? find(window) : undefined
84
+ restore = () => {
85
+ if (focused?.window) focused.becomeFirstResponder()
86
+ }
87
+ }
88
+ }
89
+ watch(
90
+ () => props.active,
91
+ (active) => {
92
+ if (active) capture()
93
+ else
94
+ void nextTick(() => {
95
+ if (root?.isLoaded && !props.active && props.restoreFocus) restore()
96
+ restore = () => {}
97
+ })
98
+ },
99
+ )
100
+ return () =>
101
+ h(
102
+ 'StackLayout',
103
+ mergeProps(attrs, {
104
+ onLoaded: (event: EventData) => {
105
+ root = event.object as View
106
+ if (props.active) capture()
107
+ },
108
+ onUnloaded: () => {
109
+ root = undefined
110
+ restore = () => {}
111
+ },
112
+ }),
113
+ slots.default?.(),
114
+ )
115
+ },
116
+ })
117
+ const TargetHost = defineComponent({
118
+ inheritAttrs: false,
119
+ props: tourHostProps,
120
+ setup(props, { attrs, slots }) {
121
+ let root: View | undefined
122
+ function reveal() {
123
+ if (!props.active || !root?.isLoaded) return
124
+ for (
125
+ let parent = root.parent as View | undefined;
126
+ parent;
127
+ parent = parent.parent as View | undefined
128
+ ) {
129
+ if (parent instanceof ScrollView) {
130
+ const location = root.getLocationRelativeTo(parent)
131
+ if (location) {
132
+ const size = root.getActualSize(),
133
+ viewport = parent.getActualSize()
134
+ if (location.y < 0)
135
+ parent.scrollToVerticalOffset(Math.max(0, parent.verticalOffset + location.y), false)
136
+ else if (location.y + size.height > viewport.height)
137
+ parent.scrollToVerticalOffset(
138
+ Math.max(0, parent.verticalOffset + location.y + size.height - viewport.height),
139
+ false,
140
+ )
141
+ }
142
+ break
143
+ }
144
+ }
145
+ notifyAccessibilityLayout(root)
146
+ }
147
+ watch(
148
+ () => props.active,
149
+ () => void nextTick(reveal),
150
+ { flush: 'post' },
151
+ )
152
+ return () =>
153
+ h(
154
+ 'GridLayout',
155
+ mergeProps(attrs, {
156
+ onLoaded: (event: EventData) => {
157
+ root = event.object as View
158
+ void nextTick(reveal)
159
+ },
160
+ onUnloaded: () => {
161
+ root = undefined
162
+ },
163
+ }),
164
+ slots.default?.(),
165
+ )
166
+ },
167
+ })
168
+ const MarqueeHost = defineComponent({
169
+ inheritAttrs: false,
170
+ props: marqueeHostProps,
171
+ emits: ['environment'],
172
+ setup(_props, { attrs, slots, emit }) {
173
+ let root: View | undefined,
174
+ suspended = false,
175
+ attached = false,
176
+ release = () => {}
177
+ const update = () =>
178
+ emit('environment', {
179
+ reduced: reducedMotion(),
180
+ paused: !attached || suspended,
181
+ width: root?.getActualSize().width ?? 0,
182
+ })
183
+ const suspend = () => {
184
+ suspended = true
185
+ update()
186
+ },
187
+ resume = () => {
188
+ suspended = false
189
+ update()
190
+ }
191
+ function detach() {
192
+ attached = false
193
+ release()
194
+ Application.off(Application.suspendEvent, suspend)
195
+ Application.off(Application.resumeEvent, resume)
196
+ update()
197
+ }
198
+ onBeforeUnmount(detach)
199
+ onDeactivated(detach)
200
+ return () =>
201
+ h(
202
+ 'GridLayout',
203
+ mergeProps(attrs, {
204
+ clipToBounds: true,
205
+ width: '100%',
206
+ onLoaded: (event: EventData) => {
207
+ root = event.object as View
208
+ if (attached) return
209
+ attached = true
210
+ release = onReducedMotion(update)
211
+ Application.on(Application.suspendEvent, suspend)
212
+ Application.on(Application.resumeEvent, resume)
213
+ update()
214
+ },
215
+ onUnloaded: detach,
216
+ onLayoutChanged: update,
217
+ }),
218
+ slots.default?.(),
219
+ )
220
+ },
221
+ })
222
+ const ui = {
223
+ Box: MBox,
224
+ Column: MColumn,
225
+ Row: MRow,
226
+ Stack: MStack,
227
+ Card: MCard,
228
+ Text: MText,
229
+ Input: MInput,
230
+ Image: MImage,
231
+ Button: MButton,
232
+ Slider: MSlider,
233
+ Checkbox: MCheckbox,
234
+ NumberFlow: MNumberFlow,
235
+ GaugeFallback,
236
+ MarqueeHost,
237
+ }
238
+ export const MColorPicker = createColorPicker(ui, 'native')
239
+ export const MGauge = createGauge(ui, 'native')
240
+ export const MSwipeDeck = createSwipeDeck(ui, 'native')
241
+ export const MTransferList = createTransferList(ui, 'native')
242
+ export const MMarquee = createMarquee(ui, 'native')
243
+ export const { MTour, MTourTarget } = createTour(
244
+ { ...ui, Popover: MPopover, Host: TourHost, TargetHost },
245
+ 'native',
246
+ )
@@ -0,0 +1,249 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ inject,
5
+ markRaw,
6
+ mergeProps,
7
+ onBeforeUnmount,
8
+ onDeactivated,
9
+ onScopeDispose,
10
+ watch,
11
+ } from 'nativescript-vue'
12
+ import {
13
+ Application,
14
+ type View,
15
+ type EventData,
16
+ type PanGestureEventData,
17
+ } from '@nativescript/core'
18
+ import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
19
+ import { reducedMotion, onReducedMotion } from '@rafaelaugusto/jolt'
20
+ import {
21
+ createDashboardShape,
22
+ createDonutChart,
23
+ createSparkline,
24
+ createDashboardEffects,
25
+ createKanban,
26
+ dashboardEnvironmentProps,
27
+ dashboardPlotProps,
28
+ kanbanRegistryKey,
29
+ kanbanZoneProps,
30
+ kanbanDragProps,
31
+ } from '@getcortexlabs/mavis-core/vue'
32
+ import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
33
+ import { MBox, MColumn, MRow } from './layout.js'
34
+ import { MStack } from './MStack.js'
35
+ import { MText } from './MText.js'
36
+ import { MButton } from './MButton.js'
37
+ import { MNumberFlow } from './interactive.js'
38
+ import { MMenu } from './navigation.js'
39
+
40
+ const Fallback = defineComponent({
41
+ setup: () => () => h('GridLayout', { accessible: false, isUserInteractionEnabled: false }),
42
+ })
43
+ const Environment = defineComponent({
44
+ inheritAttrs: false,
45
+ props: dashboardEnvironmentProps,
46
+ emits: ['environment'],
47
+ setup(_props, { attrs, slots, emit }) {
48
+ let attached = false,
49
+ suspended = false,
50
+ release = () => {}
51
+ const update = () =>
52
+ emit('environment', { reduced: reducedMotion(), paused: !attached || suspended })
53
+ const suspend = () => {
54
+ suspended = true
55
+ update()
56
+ },
57
+ resume = () => {
58
+ suspended = false
59
+ update()
60
+ }
61
+ function detach() {
62
+ attached = false
63
+ release()
64
+ release = () => {}
65
+ Application.off(Application.suspendEvent, suspend)
66
+ Application.off(Application.resumeEvent, resume)
67
+ update()
68
+ }
69
+ function attach() {
70
+ if (attached) return
71
+ attached = true
72
+ release = onReducedMotion(update)
73
+ Application.on(Application.suspendEvent, suspend)
74
+ Application.on(Application.resumeEvent, resume)
75
+ update()
76
+ }
77
+ onBeforeUnmount(detach)
78
+ onDeactivated(detach)
79
+ return () =>
80
+ h(
81
+ 'GridLayout',
82
+ mergeProps(attrs, { width: '100%', onLoaded: attach, onUnloaded: detach }),
83
+ slots.default?.(),
84
+ )
85
+ },
86
+ })
87
+ function rect(view?: View) {
88
+ if (!view?.isLoaded) return
89
+ const p = view.getLocationOnScreen(),
90
+ size = view.getActualSize()
91
+ return p ? { ...p, ...size } : undefined
92
+ }
93
+ const Zone = defineComponent({
94
+ inheritAttrs: false,
95
+ props: kanbanZoneProps,
96
+ setup(props, { attrs, slots }) {
97
+ const registry = inject(kanbanRegistryKey)!
98
+ let view: View | undefined
99
+ onBeforeUnmount(() => registry.zones.delete(props.column))
100
+ return () =>
101
+ h(
102
+ 'GridLayout',
103
+ mergeProps(attrs, {
104
+ onLoaded: (e: EventData) => {
105
+ view = e.object as View
106
+ registry.zones.set(props.column, () => rect(view))
107
+ },
108
+ onUnloaded: () => {
109
+ view = undefined
110
+ registry.zones.delete(props.column)
111
+ },
112
+ }),
113
+ slots.default?.(),
114
+ )
115
+ },
116
+ })
117
+ const Drag = defineComponent({
118
+ inheritAttrs: false,
119
+ props: kanbanDragProps,
120
+ setup(props, { attrs, slots }) {
121
+ const registry = inject(kanbanRegistryKey)!,
122
+ surface = markRaw(createMotionSurface())
123
+ let view: View | undefined,
124
+ anchor: ReturnType<typeof rect>,
125
+ dragging = false
126
+ function end(commit = false) {
127
+ const was = dragging
128
+ dragging = false
129
+ if (surface.available) {
130
+ if (props.animated && !commit)
131
+ surface.animate({ x: 0, y: 0, scale: 1 }, { type: 'spring', duration: 280, bounce: 0.12 })
132
+ else surface.set({ x: 0, y: 0, scale: 1 })
133
+ }
134
+ if (view) view.style.zIndex = 0
135
+ if (was) registry.finish(commit)
136
+ }
137
+ const cancel = () => end(false)
138
+ onBeforeUnmount(() => {
139
+ cancel()
140
+ registry.cards.delete(props.cardId)
141
+ registry.focus.delete(props.cardId)
142
+ })
143
+ onDeactivated(cancel)
144
+ onScopeDispose(surface.use(() => cancel))
145
+ watch(
146
+ () => props.disabled,
147
+ (value) => {
148
+ if (value) cancel()
149
+ },
150
+ )
151
+ return () =>
152
+ h(
153
+ 'GridLayout',
154
+ mergeProps(attrs, {
155
+ onLoaded: (e: EventData) => {
156
+ view = e.object as View
157
+ registry.cards.set(props.cardId, () => rect(view))
158
+ registry.focus.set(props.cardId, () => {
159
+ if (view) notifyAccessibilityLayout(view)
160
+ })
161
+ },
162
+ onUnloaded: () => {
163
+ cancel()
164
+ view = undefined
165
+ registry.cards.delete(props.cardId)
166
+ registry.focus.delete(props.cardId)
167
+ },
168
+ }),
169
+ [
170
+ h(MBox, { motionSurface: surface }, () =>
171
+ h(MColumn, { gap: 'xs' }, () => [
172
+ h(
173
+ MBox,
174
+ {
175
+ height: 36,
176
+ accessibilityHidden: true,
177
+ accessibilityLabel: props.label,
178
+ opacity: props.disabled ? 0.4 : 0.65,
179
+ onPan: (e: PanGestureEventData) => {
180
+ if (props.disabled) return
181
+ if (e.state === 1) {
182
+ anchor = rect(view)
183
+ dragging = registry.begin(props.cardId, cancel)
184
+ if (dragging && view) view.style.zIndex = 20
185
+ }
186
+ if (e.state === 2 && dragging && surface.available) {
187
+ const current = rect(view)
188
+ surface.set({
189
+ x: e.deltaX + (anchor && current ? anchor.x - current.x : 0),
190
+ y: e.deltaY + (anchor && current ? anchor.y - current.y : 0),
191
+ scale: 1.02,
192
+ })
193
+ registry.move(e.deltaX, e.deltaY)
194
+ }
195
+ if (e.state === 3) end(true)
196
+ if (e.state === 4) cancel()
197
+ },
198
+ },
199
+ () => h(MText, { text: '⠿', textAlignment: 'center' }),
200
+ ),
201
+ ...(slots.default?.() ?? []),
202
+ ]),
203
+ ),
204
+ ],
205
+ )
206
+ },
207
+ })
208
+ const Plot = defineComponent({
209
+ inheritAttrs: false,
210
+ props: dashboardPlotProps,
211
+ emits: ['width'],
212
+ setup(props, { attrs, slots, emit }) {
213
+ const measure = (event: EventData) =>
214
+ emit('width', (event.object as View).getActualSize().width)
215
+ return () =>
216
+ h(
217
+ 'GridLayout',
218
+ mergeProps(attrs, {
219
+ height: props.height,
220
+ width: '100%',
221
+ clipToBounds: true,
222
+ accessible: false,
223
+ isUserInteractionEnabled: false,
224
+ onLoaded: measure,
225
+ onLayoutChanged: measure,
226
+ }),
227
+ slots.default?.(),
228
+ )
229
+ },
230
+ })
231
+ const ui = {
232
+ Box: MBox,
233
+ Column: MColumn,
234
+ Row: MRow,
235
+ Stack: MStack,
236
+ Text: MText,
237
+ Button: MButton,
238
+ NumberFlow: MNumberFlow,
239
+ Shape: createDashboardShape(MBox, Fallback, 'native'),
240
+ Environment,
241
+ Plot,
242
+ }
243
+ export const MDonutChart = createDonutChart(ui, 'native')
244
+ export const MSparkline = createSparkline(ui, 'native')
245
+ export const { MGradientBackground, MParticleField, MConfetti } = createDashboardEffects(
246
+ ui,
247
+ 'native',
248
+ )
249
+ export const MKanban = createKanban({ ...ui, Zone, Drag, Menu: MMenu }, 'native')
@@ -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
+ })