@getcortexlabs/mavis 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (155) hide show
  1. package/README.md +7 -5
  2. package/dist/files.d.ts +4 -0
  3. package/dist/files.d.ts.map +1 -0
  4. package/dist/files.js +3 -0
  5. package/dist/files.js.map +1 -0
  6. package/dist/native/combobox-editor.android.d.ts +3 -0
  7. package/dist/native/combobox-editor.android.d.ts.map +1 -0
  8. package/dist/native/combobox-editor.android.js +5 -0
  9. package/dist/native/combobox-editor.android.js.map +1 -0
  10. package/dist/native/combobox-editor.d.ts +4 -0
  11. package/dist/native/combobox-editor.d.ts.map +1 -0
  12. package/dist/native/combobox-editor.js +5 -0
  13. package/dist/native/combobox-editor.js.map +1 -0
  14. package/dist/native/file-access.d.ts +23 -0
  15. package/dist/native/file-access.d.ts.map +1 -0
  16. package/dist/native/file-access.js +55 -0
  17. package/dist/native/file-access.js.map +1 -0
  18. package/dist/native/file-picker.android.d.ts +3 -0
  19. package/dist/native/file-picker.android.d.ts.map +1 -0
  20. package/dist/native/file-picker.android.js +147 -0
  21. package/dist/native/file-picker.android.js.map +1 -0
  22. package/dist/native/file-picker.d.ts +4 -0
  23. package/dist/native/file-picker.d.ts.map +1 -0
  24. package/dist/native/file-picker.ios.d.ts +3 -0
  25. package/dist/native/file-picker.ios.d.ts.map +1 -0
  26. package/dist/native/file-picker.ios.js +152 -0
  27. package/dist/native/file-picker.ios.js.map +1 -0
  28. package/dist/native/file-picker.js +7 -0
  29. package/dist/native/file-picker.js.map +1 -0
  30. package/dist/native/motion-owner.d.ts +5 -0
  31. package/dist/native/motion-owner.d.ts.map +1 -0
  32. package/dist/native/motion-owner.js +53 -0
  33. package/dist/native/motion-owner.js.map +1 -0
  34. package/dist/native/motion-region.d.ts +6 -0
  35. package/dist/native/motion-region.d.ts.map +1 -0
  36. package/dist/native/motion-region.js +199 -0
  37. package/dist/native/motion-region.js.map +1 -0
  38. package/dist/native/motion-surface.d.ts +1 -1
  39. package/dist/native/motion-surface.d.ts.map +1 -1
  40. package/dist/native/motion-surface.js +18 -0
  41. package/dist/native/motion-surface.js.map +1 -1
  42. package/dist/native/scroll-motion.d.ts +1 -0
  43. package/dist/native/scroll-motion.d.ts.map +1 -1
  44. package/dist/native/scroll-motion.js +6 -0
  45. package/dist/native/scroll-motion.js.map +1 -1
  46. package/dist/vue/components/ChoiceControl.d.ts +21 -11
  47. package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
  48. package/dist/vue/components/DateCalendar.d.ts +94 -0
  49. package/dist/vue/components/DateCalendar.d.ts.map +1 -0
  50. package/dist/vue/components/DateCalendar.js +96 -0
  51. package/dist/vue/components/DateCalendar.js.map +1 -0
  52. package/dist/vue/components/MAccordion.d.ts +19 -9
  53. package/dist/vue/components/MAccordion.d.ts.map +1 -1
  54. package/dist/vue/components/MAlert.d.ts +21 -11
  55. package/dist/vue/components/MAlert.d.ts.map +1 -1
  56. package/dist/vue/components/MAvatar.d.ts +12 -6
  57. package/dist/vue/components/MAvatar.d.ts.map +1 -1
  58. package/dist/vue/components/MBadge.d.ts +13 -7
  59. package/dist/vue/components/MBadge.d.ts.map +1 -1
  60. package/dist/vue/components/MButton.d.ts +81 -39
  61. package/dist/vue/components/MButton.d.ts.map +1 -1
  62. package/dist/vue/components/MCard.d.ts +46 -18
  63. package/dist/vue/components/MCard.d.ts.map +1 -1
  64. package/dist/vue/components/MCheckbox.d.ts +20 -10
  65. package/dist/vue/components/MCheckbox.d.ts.map +1 -1
  66. package/dist/vue/components/MChip.d.ts +23 -13
  67. package/dist/vue/components/MChip.d.ts.map +1 -1
  68. package/dist/vue/components/MCombobox.d.ts +279 -0
  69. package/dist/vue/components/MCombobox.d.ts.map +1 -0
  70. package/dist/vue/components/MCombobox.js +234 -0
  71. package/dist/vue/components/MCombobox.js.map +1 -0
  72. package/dist/vue/components/MDatePicker.d.ts +1254 -0
  73. package/dist/vue/components/MDatePicker.d.ts.map +1 -0
  74. package/dist/vue/components/MDatePicker.js +35 -0
  75. package/dist/vue/components/MDatePicker.js.map +1 -0
  76. package/dist/vue/components/MDialog.d.ts +7 -5
  77. package/dist/vue/components/MDialog.d.ts.map +1 -1
  78. package/dist/vue/components/MEmptyState.d.ts +20 -10
  79. package/dist/vue/components/MEmptyState.d.ts.map +1 -1
  80. package/dist/vue/components/MFilePicker.d.ts +112 -0
  81. package/dist/vue/components/MFilePicker.d.ts.map +1 -0
  82. package/dist/vue/components/MFilePicker.js +196 -0
  83. package/dist/vue/components/MFilePicker.js.map +1 -0
  84. package/dist/vue/components/MIcon.d.ts +5 -3
  85. package/dist/vue/components/MIcon.d.ts.map +1 -1
  86. package/dist/vue/components/MInput.d.ts +131 -59
  87. package/dist/vue/components/MInput.d.ts.map +1 -1
  88. package/dist/vue/components/MListItem.d.ts +24 -12
  89. package/dist/vue/components/MListItem.d.ts.map +1 -1
  90. package/dist/vue/components/MProgress.d.ts +19 -9
  91. package/dist/vue/components/MProgress.d.ts.map +1 -1
  92. package/dist/vue/components/MRadioGroup.d.ts +19 -9
  93. package/dist/vue/components/MRadioGroup.d.ts.map +1 -1
  94. package/dist/vue/components/MReveal.d.ts +73 -37
  95. package/dist/vue/components/MReveal.d.ts.map +1 -1
  96. package/dist/vue/components/MScreen.d.ts +12 -6
  97. package/dist/vue/components/MScreen.d.ts.map +1 -1
  98. package/dist/vue/components/MSegmentedControl.d.ts +19 -9
  99. package/dist/vue/components/MSegmentedControl.d.ts.map +1 -1
  100. package/dist/vue/components/MSelect.d.ts +21 -11
  101. package/dist/vue/components/MSelect.d.ts.map +1 -1
  102. package/dist/vue/components/MSeparator.d.ts +4 -2
  103. package/dist/vue/components/MSeparator.d.ts.map +1 -1
  104. package/dist/vue/components/MSheet.d.ts +19 -13
  105. package/dist/vue/components/MSheet.d.ts.map +1 -1
  106. package/dist/vue/components/MSkeleton.d.ts +17 -9
  107. package/dist/vue/components/MSkeleton.d.ts.map +1 -1
  108. package/dist/vue/components/MSlider.d.ts +9 -5
  109. package/dist/vue/components/MSlider.d.ts.map +1 -1
  110. package/dist/vue/components/MSwitch.d.ts +19 -9
  111. package/dist/vue/components/MSwitch.d.ts.map +1 -1
  112. package/dist/vue/components/MTabs.d.ts +19 -9
  113. package/dist/vue/components/MTabs.d.ts.map +1 -1
  114. package/dist/vue/components/MText.d.ts +46 -30
  115. package/dist/vue/components/MText.d.ts.map +1 -1
  116. package/dist/vue/components/layout.d.ts +200 -91
  117. package/dist/vue/components/layout.d.ts.map +1 -1
  118. package/dist/vue/components/layout.js +6 -4
  119. package/dist/vue/components/layout.js.map +1 -1
  120. package/dist/vue/components/workflows.d.ts +251 -0
  121. package/dist/vue/components/workflows.d.ts.map +1 -0
  122. package/dist/vue/components/workflows.js +35 -0
  123. package/dist/vue/components/workflows.js.map +1 -0
  124. package/dist/vue/index.d.ts +7 -2
  125. package/dist/vue/index.d.ts.map +1 -1
  126. package/dist/vue/index.js +15 -2
  127. package/dist/vue/index.js.map +1 -1
  128. package/dist/vue/use-motion-region.d.ts +7 -0
  129. package/dist/vue/use-motion-region.d.ts.map +1 -0
  130. package/dist/vue/use-motion-region.js +28 -0
  131. package/dist/vue/use-motion-region.js.map +1 -0
  132. package/dist/vue/use-motion-surface.d.ts.map +1 -1
  133. package/dist/vue/use-motion-surface.js +3 -2
  134. package/dist/vue/use-motion-surface.js.map +1 -1
  135. package/package.json +3 -3
  136. package/src/files.ts +3 -0
  137. package/src/native/combobox-editor.android.ts +11 -0
  138. package/src/native/combobox-editor.ts +6 -0
  139. package/src/native/file-access.ts +71 -0
  140. package/src/native/file-picker.android.ts +191 -0
  141. package/src/native/file-picker.ios.ts +230 -0
  142. package/src/native/file-picker.ts +8 -0
  143. package/src/native/motion-owner.ts +59 -0
  144. package/src/native/motion-region.ts +213 -0
  145. package/src/native/motion-surface.ts +26 -1
  146. package/src/native/scroll-motion.ts +5 -0
  147. package/src/vue/components/DateCalendar.ts +117 -0
  148. package/src/vue/components/MCombobox.ts +257 -0
  149. package/src/vue/components/MDatePicker.ts +33 -0
  150. package/src/vue/components/MFilePicker.ts +226 -0
  151. package/src/vue/components/layout.ts +6 -3
  152. package/src/vue/components/workflows.ts +38 -0
  153. package/src/vue/index.ts +29 -1
  154. package/src/vue/use-motion-region.ts +29 -0
  155. package/src/vue/use-motion-surface.ts +21 -14
@@ -4,13 +4,15 @@ import {
4
4
  useMavisTheme,
5
5
  layoutDirection,
6
6
  useDefaultShrink,
7
+ motionBoxProps,
7
8
  } from '@getcortexlabs/mavis-core/vue'
8
9
  import { defineComponent, h, mergeProps, provide, registerElement } from 'nativescript-vue'
9
10
  import { resolveSpace } from '@getcortexlabs/mavis-core'
10
- import { boxProps, boxStyle } from '../props.js'
11
+ import { boxStyle } from '../props.js'
11
12
  import { MavisFlexLayout } from '../../native/flex-layout'
12
13
  import { MavisBox } from '../../native/box'
13
14
  import { useNativeViewAttrs } from '../accessibility.js'
15
+ import { useMotionRegion } from '../use-motion-region.js'
14
16
 
15
17
  export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
16
18
 
@@ -74,15 +76,16 @@ export const MColumn = createLayout('MColumn', 'column')
74
76
  export const MBox = defineComponent({
75
77
  name: 'MBox',
76
78
  inheritAttrs: false,
77
- props: boxProps,
79
+ props: motionBoxProps,
78
80
  setup(props, { attrs, slots }) {
81
+ const region = useMotionRegion(() => props.motionRegion)
79
82
  const { theme } = useMavisTheme()
80
83
  const nativeAttrs = useNativeViewAttrs(props)
81
84
  const shrink = useDefaultShrink()
82
85
  return () =>
83
86
  h(
84
87
  'MavisBox',
85
- mergeProps({ style: boxStyle(theme.value, props, shrink) }, nativeAttrs(), attrs),
88
+ mergeProps({ style: boxStyle(theme.value, props, shrink) }, nativeAttrs(), attrs, region),
86
89
  slots.default?.(),
87
90
  )
88
91
  },
@@ -0,0 +1,38 @@
1
+ import { createWorkflows } from '@getcortexlabs/mavis-core/vue'
2
+ import { MColumn, MRow } from './layout.js'
3
+ import { MText } from './MText.js'
4
+ import { MButton } from './MButton.js'
5
+
6
+ import { isAndroid, type View } from '@nativescript/core'
7
+
8
+ function focused(root: View): View | undefined {
9
+ if (isAndroid ? root.android?.isFocused() : root.ios?.isFirstResponder) return root
10
+ let match: View | undefined
11
+ root.eachChildView((child) => {
12
+ match = focused(child)
13
+ return !match
14
+ })
15
+ return match
16
+ }
17
+ function preserveFocus(instance: unknown, currentId: string) {
18
+ const root = (instance as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView
19
+ const previous = root && focused(root)
20
+ if (!root || !previous) return () => {}
21
+ return () => {
22
+ if (!root.isLoaded || (previous.isLoaded && previous.isEnabled)) return
23
+ const page = root.page
24
+ if (
25
+ !page ||
26
+ page.frame?.currentPage !== page ||
27
+ (!isAndroid && page.ios?.presentedViewController)
28
+ )
29
+ return
30
+ const active = focused(page)
31
+ if (!active || active === previous) root.getViewById<View>(currentId)?.focus()
32
+ }
33
+ }
34
+
35
+ export const { MFormGroup, MFormErrors, MSteps, MPagination } = createWorkflows(
36
+ { Column: MColumn, Row: MRow, Text: MText, Button: MButton, preserveFocus },
37
+ 'native',
38
+ )
package/src/vue/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
2
+ import { MCombobox } from './components/MCombobox.js'
3
+ import { MFilePicker } from './components/MFilePicker.js'
4
+ import { MFormGroup, MFormErrors, MSteps, MPagination } from './components/workflows.js'
1
5
  import { MChip } from './components/MChip.js'
2
6
  import { MEmptyState } from './components/MEmptyState.js'
3
7
  import type { App } from 'nativescript-vue'
@@ -71,8 +75,22 @@ export {
71
75
  MIcon,
72
76
  MReveal,
73
77
  MSheet,
78
+ MDatePicker,
79
+ MDateRangePicker,
80
+ MCombobox,
81
+ MFilePicker,
82
+ MFormGroup,
83
+ MFormErrors,
84
+ MSteps,
85
+ MPagination,
74
86
  }
75
- export { useMavisTheme, useToast } from '@getcortexlabs/mavis-core/vue'
87
+ export {
88
+ useMavisTheme,
89
+ useToast,
90
+ useFormController,
91
+ useFormField,
92
+ useFileSelection,
93
+ } from '@getcortexlabs/mavis-core/vue'
76
94
  export type {
77
95
  MavisThemeContext,
78
96
  Appearance,
@@ -133,9 +151,19 @@ export function createMavis(options: MavisOptions = {}) {
133
151
  MIcon,
134
152
  MReveal,
135
153
  MSheet,
154
+ MDatePicker,
155
+ MDateRangePicker,
156
+ MCombobox,
157
+ MFilePicker,
158
+ MFormGroup,
159
+ MFormErrors,
160
+ MSteps,
161
+ MPagination,
136
162
  })) {
137
163
  app.component(name, component)
138
164
  }
139
165
  },
140
166
  }
141
167
  }
168
+
169
+ export * from '../files.js'
@@ -0,0 +1,29 @@
1
+ import { onBeforeUnmount, watch } from 'nativescript-vue'
2
+ import type { EventData, View } from '@nativescript/core'
3
+ import type { MotionRegion } from '@getcortexlabs/mavis-core/experimental'
4
+ import { attachNativeMotionRegion } from '../native/motion-region.js'
5
+
6
+ export function useMotionRegion(reference: () => MotionRegion | undefined) {
7
+ let target: View | undefined, release: (() => void) | undefined
8
+ const clear = () => {
9
+ release?.()
10
+ release = undefined
11
+ }
12
+ const attach = () => {
13
+ clear()
14
+ const region = reference()
15
+ if (region && target?.isLoaded) release = attachNativeMotionRegion(region, target)
16
+ }
17
+ watch(reference, attach, { flush: 'post' })
18
+ onBeforeUnmount(clear)
19
+ return {
20
+ onLoaded(event: EventData) {
21
+ target = event.object as View
22
+ attach()
23
+ },
24
+ onUnloaded() {
25
+ clear()
26
+ target = undefined
27
+ },
28
+ }
29
+ }
@@ -7,6 +7,7 @@ import {
7
7
  type MotionSurface,
8
8
  } from '@getcortexlabs/mavis-core/experimental'
9
9
  import { nativeContinuousSurface } from '../native/motion-surface.js'
10
+ import { nativeMotionOwner } from '../native/motion-owner.js'
10
11
 
11
12
  export function useMotionSurface(
12
13
  surface: () => MotionSurface | undefined,
@@ -32,20 +33,26 @@ export function useMotionSurface(
32
33
  const reference = surface()
33
34
  if (!target || !reference) return
34
35
  continuous = nativeContinuousSurface(target, enabled)
35
- unbind = bindMotionSurface(reference, {
36
- ...continuous.adapter,
37
- animate(values, options) {
38
- continuous?.interrupt(Object.keys(values))
39
- const handle = animate(target, values, options)
40
- active.set(handle, values)
41
- void handle.finished.then(() => active.delete(handle))
42
- return handle
43
- },
44
- set: (values) => {
45
- continuous?.interrupt(Object.keys(values))
46
- return animate(target, values, { duration: 0 })
47
- },
48
- })
36
+ unbind = bindMotionSurface(
37
+ reference,
38
+ nativeMotionOwner(
39
+ {
40
+ ...continuous.adapter,
41
+ animate(values, options) {
42
+ continuous?.interrupt(Object.keys(values))
43
+ const handle = animate(target, values, options)
44
+ active.set(handle, values)
45
+ void handle.finished.then(() => active.delete(handle))
46
+ return handle
47
+ },
48
+ set: (values) => {
49
+ continuous?.interrupt(Object.keys(values))
50
+ return animate(target, values, { duration: 0 })
51
+ },
52
+ },
53
+ target,
54
+ ),
55
+ )
49
56
  offPreference = onReducedMotion((reduced) => {
50
57
  if (!reduced) return
51
58
  // Set only spatial channels: opacity can keep its existing timeline.