@getcortexlabs/mavis 0.1.0-rc.12.2 → 0.1.0-rc.14

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 (95) hide show
  1. package/README.md +5 -5
  2. package/dist/native/flex-layout.ios.d.ts.map +1 -1
  3. package/dist/native/flex-layout.ios.js +4 -0
  4. package/dist/native/flex-layout.ios.js.map +1 -1
  5. package/dist/native/motion-region.d.ts.map +1 -1
  6. package/dist/native/motion-region.js +1 -0
  7. package/dist/native/motion-region.js.map +1 -1
  8. package/dist/native/motion-surface.d.ts +1 -1
  9. package/dist/native/motion-surface.d.ts.map +1 -1
  10. package/dist/native/motion-surface.js +55 -14
  11. package/dist/native/motion-surface.js.map +1 -1
  12. package/dist/native/moved-shadow.d.ts +5 -0
  13. package/dist/native/moved-shadow.d.ts.map +1 -0
  14. package/dist/native/moved-shadow.js +23 -0
  15. package/dist/native/moved-shadow.js.map +1 -0
  16. package/dist/native/scroll-motion.d.ts +1 -1
  17. package/dist/native/scroll-motion.d.ts.map +1 -1
  18. package/dist/native/scroll-motion.js +55 -16
  19. package/dist/native/scroll-motion.js.map +1 -1
  20. package/dist/native/section-scroll.d.ts +1 -1
  21. package/dist/native/section-scroll.d.ts.map +1 -1
  22. package/dist/native/section-scroll.js +19 -6
  23. package/dist/native/section-scroll.js.map +1 -1
  24. package/dist/native/visual-effects.d.ts.map +1 -1
  25. package/dist/native/visual-effects.js +5 -0
  26. package/dist/native/visual-effects.js.map +1 -1
  27. package/dist/vue/card-input.d.ts +4 -0
  28. package/dist/vue/card-input.d.ts.map +1 -0
  29. package/dist/vue/card-input.js +37 -0
  30. package/dist/vue/card-input.js.map +1 -0
  31. package/dist/vue/components/ChoiceControl.d.ts +1 -1
  32. package/dist/vue/components/DateCalendar.d.ts +1 -1
  33. package/dist/vue/components/MButton.d.ts +6 -6
  34. package/dist/vue/components/MCard.d.ts.map +1 -1
  35. package/dist/vue/components/MCard.js +29 -8
  36. package/dist/vue/components/MCard.js.map +1 -1
  37. package/dist/vue/components/MChip.d.ts +1 -1
  38. package/dist/vue/components/MDatePicker.d.ts +96 -96
  39. package/dist/vue/components/MDatePicker.d.ts.map +1 -1
  40. package/dist/vue/components/MEmptyState.d.ts +1 -1
  41. package/dist/vue/components/MInput.d.ts +4 -4
  42. package/dist/vue/components/MPopover.d.ts +1 -1
  43. package/dist/vue/components/MProgress.d.ts +1 -1
  44. package/dist/vue/components/MRangeSlider.d.ts +2 -2
  45. package/dist/vue/components/MResizablePanels.d.ts +1 -1
  46. package/dist/vue/components/MReveal.d.ts +8 -8
  47. package/dist/vue/components/MSheet.d.ts +4 -4
  48. package/dist/vue/components/MSlider.d.ts +1 -1
  49. package/dist/vue/components/MStack.d.ts +8 -8
  50. package/dist/vue/components/MTimePicker.d.ts +40 -40
  51. package/dist/vue/components/MTimePicker.d.ts.map +1 -1
  52. package/dist/vue/components/MTooltip.d.ts +1 -1
  53. package/dist/vue/components/MVirtualList.d.ts.map +1 -1
  54. package/dist/vue/components/MVirtualList.js +88 -67
  55. package/dist/vue/components/MVirtualList.js.map +1 -1
  56. package/dist/vue/components/advanced.d.ts +34 -34
  57. package/dist/vue/components/configurator.d.ts +33 -33
  58. package/dist/vue/components/creative.d.ts +20 -20
  59. package/dist/vue/components/dashboard.d.ts +12 -12
  60. package/dist/vue/components/dashboard.d.ts.map +1 -1
  61. package/dist/vue/components/dashboard.js +167 -66
  62. package/dist/vue/components/dashboard.js.map +1 -1
  63. package/dist/vue/components/discovery.d.ts +10 -10
  64. package/dist/vue/components/interactive.d.ts +6 -6
  65. package/dist/vue/components/layout.d.ts +27 -16
  66. package/dist/vue/components/layout.d.ts.map +1 -1
  67. package/dist/vue/components/layout.js +3 -0
  68. package/dist/vue/components/layout.js.map +1 -1
  69. package/dist/vue/components/navigation.d.ts +4 -4
  70. package/dist/vue/components/screen-components.d.ts +23 -23
  71. package/dist/vue/components/wayfinding.d.ts +11 -11
  72. package/dist/vue/components/workflows.d.ts +5 -5
  73. package/dist/vue/perspective.d.ts +4 -0
  74. package/dist/vue/perspective.d.ts.map +1 -0
  75. package/dist/vue/perspective.js +3 -0
  76. package/dist/vue/perspective.js.map +1 -0
  77. package/dist/vue/use-motion-surface.d.ts +1 -1
  78. package/dist/vue/use-motion-surface.d.ts.map +1 -1
  79. package/dist/vue/use-motion-surface.js +40 -8
  80. package/dist/vue/use-motion-surface.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/native/flex-layout.ios.ts +4 -0
  83. package/src/native/motion-region.ts +1 -0
  84. package/src/native/motion-surface.ts +58 -13
  85. package/src/native/moved-shadow.ts +22 -0
  86. package/src/native/scroll-motion.ts +60 -19
  87. package/src/native/section-scroll.ts +16 -6
  88. package/src/native/visual-effects.ts +5 -0
  89. package/src/vue/card-input.ts +44 -0
  90. package/src/vue/components/MCard.ts +35 -9
  91. package/src/vue/components/MVirtualList.ts +104 -78
  92. package/src/vue/components/dashboard.ts +173 -68
  93. package/src/vue/components/layout.ts +3 -0
  94. package/src/vue/perspective.ts +4 -0
  95. package/src/vue/use-motion-surface.ts +39 -8
@@ -1,13 +1,17 @@
1
- import type { EventData, View } from '@nativescript/core'
2
- import { onBeforeUnmount, watch } from 'nativescript-vue'
1
+ import { Utils, isAndroid, type EventData, type View } from '@nativescript/core'
2
+ import { inject, onBeforeUnmount, watch } from 'nativescript-vue'
3
3
  import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt'
4
4
  import {
5
5
  bindMotionSurface,
6
+ motionChannels,
7
+ motionKeyframes,
6
8
  type MotionFrames,
7
9
  type MotionSurface,
8
10
  } from '@getcortexlabs/mavis-core/experimental'
9
11
  import { nativeContinuousSurface } from '../native/motion-surface.js'
10
12
  import { nativeMotionOwner } from '../native/motion-owner.js'
13
+ import { perspectiveKey } from './perspective.js'
14
+ import { takeShadow } from '../native/moved-shadow.js'
11
15
 
12
16
  export function useMotionSurface(
13
17
  surface: () => MotionSurface | undefined,
@@ -22,6 +26,20 @@ export function useMotionSurface(
22
26
  const active = new Map<ReturnType<typeof animate>, MotionFrames>()
23
27
  let layoutView: View | undefined
24
28
  let layoutQueued = false
29
+ const perspective = inject(perspectiveKey, undefined)
30
+ let flat: { view: View; perspective: number } | undefined
31
+ const project = () => {
32
+ const depth = perspective?.()
33
+ if (flat && (depth === undefined || flat.view !== view)) {
34
+ flat.view.perspective = flat.perspective
35
+ flat = undefined
36
+ }
37
+ if (!view || depth === undefined || !unbind) return
38
+ flat ??= { view, perspective: view.perspective }
39
+ // Core multiplies by the density for Android's camera distance, whose unit is not the
40
+ // CSS distance. This is the factor that draws the same projection as iOS and the Web.
41
+ view.perspective = isAndroid ? depth * Utils.layout.getDisplayDensity() * Math.sqrt(5) : depth
42
+ }
25
43
  const clearLayout = () => {
26
44
  layoutView?.off('layoutChanged', laidOut)
27
45
  layoutView = undefined
@@ -34,6 +52,7 @@ export function useMotionSurface(
34
52
  offPreference = undefined
35
53
  for (const handle of active.keys()) handle.stop()
36
54
  active.clear()
55
+ project()
37
56
  }
38
57
  const bind = () => {
39
58
  release()
@@ -61,30 +80,41 @@ export function useMotionSurface(
61
80
  {
62
81
  ...continuous.adapter,
63
82
  animate(values, options) {
64
- continuous?.interrupt(Object.keys(values))
65
- const handle = animate(target, values, options)
83
+ continuous?.interrupt(motionChannels(values))
84
+ const handle = animate(target, motionKeyframes(values), options)
85
+ takeShadow(target, values)
66
86
  active.set(handle, values)
67
87
  void handle.finished.then(() => active.delete(handle))
68
88
  return handle
69
89
  },
70
90
  set: (values) => {
71
91
  continuous?.interrupt(Object.keys(values))
72
- return animate(target, values, { duration: 0 })
92
+ const handle = animate(target, values, { duration: 0 })
93
+ takeShadow(target, values)
94
+ return handle
73
95
  },
74
96
  },
75
97
  target,
76
98
  ),
77
99
  )
100
+ project()
78
101
  offPreference = onReducedMotion((reduced) => {
79
102
  if (!reduced) return
80
- // Set only spatial channels: opacity can keep its existing timeline.
103
+ // Set only spatial channels: opacity and shadow paint can keep their timelines.
81
104
  const values: Record<string, number> = {}
82
- for (const frames of active.values())
105
+ for (const frames of active.values()) {
106
+ if (frames.path)
107
+ Object.assign(values, {
108
+ x: frames.path.end.x,
109
+ y: frames.path.end.y,
110
+ ...(frames.orient ? { rotate: frames.path.end.rotate } : {}),
111
+ })
83
112
  for (const [property, value] of Object.entries(frames)) {
84
- if (property === 'opacity') continue
113
+ if (property === 'opacity' || property.startsWith('shadow')) continue
85
114
  const final = Array.isArray(value) ? value.at(-1) : value
86
115
  if (typeof final === 'number') values[property] = final
87
116
  }
117
+ }
88
118
  if (Object.keys(values).length) set(target, values)
89
119
  })
90
120
  }
@@ -102,6 +132,7 @@ export function useMotionSurface(
102
132
  view = undefined
103
133
  }
104
134
  watch(surface, bind, { flush: 'post' })
135
+ if (perspective) watch(perspective, project, { flush: 'post' })
105
136
  watch(enabled, () => continuous?.refresh(), { flush: 'sync' })
106
137
  onBeforeUnmount(unloaded)
107
138
  return {