@getcortexlabs/mavis 0.1.0-rc.14 → 0.1.0-rc.16
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.
- package/README.md +7 -5
- package/dist/components/bindings.d.ts +14 -0
- package/dist/components/bindings.d.ts.map +1 -0
- package/dist/components/bindings.js +21 -0
- package/dist/components/bindings.js.map +1 -0
- package/dist/components/contracts.d.ts +28 -0
- package/dist/components/contracts.d.ts.map +1 -0
- package/dist/components/contracts.js +27 -0
- package/dist/components/contracts.js.map +1 -0
- package/dist/components/controller.d.ts +56 -0
- package/dist/components/controller.d.ts.map +1 -0
- package/dist/components/controller.js +508 -0
- package/dist/components/controller.js.map +1 -0
- package/dist/components/index.d.ts +53 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +95 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/style.d.ts +52 -0
- package/dist/components/style.d.ts.map +1 -0
- package/dist/components/style.js +68 -0
- package/dist/components/style.js.map +1 -0
- package/dist/components/theme.d.ts +12 -0
- package/dist/components/theme.d.ts.map +1 -0
- package/dist/components/theme.js +29 -0
- package/dist/components/theme.js.map +1 -0
- package/dist/native/box.ios.d.ts +1 -0
- package/dist/native/box.ios.d.ts.map +1 -1
- package/dist/native/box.ios.js +21 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/collection-motion.d.ts.map +1 -1
- package/dist/native/collection-motion.js +7 -4
- package/dist/native/collection-motion.js.map +1 -1
- package/dist/native/motion-binding.d.ts +11 -0
- package/dist/native/motion-binding.d.ts.map +1 -0
- package/dist/native/motion-binding.js +132 -0
- package/dist/native/motion-binding.js.map +1 -0
- package/dist/native/motion-surface.d.ts +1 -1
- package/dist/native/motion-surface.d.ts.map +1 -1
- package/dist/native/motion-surface.js +20 -5
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/navigation.d.ts +4 -0
- package/dist/native/navigation.d.ts.map +1 -0
- package/dist/native/navigation.js +16 -0
- package/dist/native/navigation.js.map +1 -0
- package/dist/native/pointer-availability.d.ts +7 -0
- package/dist/native/pointer-availability.d.ts.map +1 -0
- package/dist/native/pointer-availability.js +43 -0
- package/dist/native/pointer-availability.js.map +1 -0
- package/dist/native/scroll-motion.d.ts +1 -1
- package/dist/native/section-scroll.d.ts +1 -1
- package/dist/native/sheet.android.d.ts +2 -0
- package/dist/native/sheet.android.d.ts.map +1 -1
- package/dist/native/sheet.android.js +18 -0
- package/dist/native/sheet.android.js.map +1 -1
- package/dist/native/sheet.d.ts +1 -0
- package/dist/native/sheet.d.ts.map +1 -1
- package/dist/native/sheet.ios.d.ts +1 -0
- package/dist/native/sheet.ios.d.ts.map +1 -1
- package/dist/native/sheet.ios.js +1 -0
- package/dist/native/sheet.ios.js.map +1 -1
- package/dist/native/sheet.js +1 -0
- package/dist/native/sheet.js.map +1 -1
- package/dist/native/visual-effects.d.ts.map +1 -1
- package/dist/native/visual-effects.js +7 -1
- package/dist/native/visual-effects.js.map +1 -1
- package/dist/vue/components/ChoiceControl.d.ts +3 -3
- package/dist/vue/components/DateCalendar.d.ts +1 -1
- package/dist/vue/components/LoadingDecoration.d.ts +5 -5
- package/dist/vue/components/MAccordion.d.ts +3 -3
- package/dist/vue/components/MAlert.d.ts +4 -4
- package/dist/vue/components/MAvatar.d.ts +4 -4
- package/dist/vue/components/MBadge.d.ts +3 -3
- package/dist/vue/components/MButton.d.ts +20 -20
- package/dist/vue/components/MCard.d.ts +11 -11
- package/dist/vue/components/MCheckbox.d.ts +3 -3
- package/dist/vue/components/MChip.d.ts +4 -4
- package/dist/vue/components/MCombobox.d.ts +5 -5
- package/dist/vue/components/MDatePicker.d.ts +104 -104
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MDialog.d.ts +3 -3
- package/dist/vue/components/MEmptyState.d.ts +3 -3
- package/dist/vue/components/MFilePicker.d.ts +1 -1
- package/dist/vue/components/MGrid.d.ts +7 -7
- package/dist/vue/components/MGrid.d.ts.map +1 -1
- package/dist/vue/components/MGrid.js +5 -1
- package/dist/vue/components/MGrid.js.map +1 -1
- package/dist/vue/components/MIcon.d.ts +2 -2
- package/dist/vue/components/MImage.d.ts +7 -7
- package/dist/vue/components/MImageCompare.d.ts +1 -1
- package/dist/vue/components/MImageViewer.d.ts.map +1 -1
- package/dist/vue/components/MImageViewer.js +11 -2
- package/dist/vue/components/MImageViewer.js.map +1 -1
- package/dist/vue/components/MInput.d.ts +20 -20
- package/dist/vue/components/MLink.d.ts +5 -5
- package/dist/vue/components/MListItem.d.ts +5 -5
- package/dist/vue/components/MPinInput.d.ts +1 -1
- package/dist/vue/components/MPopover.d.ts +3 -3
- package/dist/vue/components/MProgress.d.ts +5 -5
- package/dist/vue/components/MRadioGroup.d.ts +3 -3
- package/dist/vue/components/MRangeSlider.d.ts +3 -3
- package/dist/vue/components/MResizablePanels.d.ts +3 -3
- package/dist/vue/components/MReveal.d.ts +17 -17
- package/dist/vue/components/MScreen.d.ts +3 -3
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +11 -1
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSegmentedControl.d.ts +3 -3
- package/dist/vue/components/MSelect.d.ts +4 -4
- package/dist/vue/components/MSheet.d.ts +7 -7
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MSheet.js +66 -10
- package/dist/vue/components/MSheet.js.map +1 -1
- package/dist/vue/components/MSkeleton.d.ts +3 -3
- package/dist/vue/components/MSlider.d.ts +2 -2
- package/dist/vue/components/MStack.d.ts +19 -19
- package/dist/vue/components/MStack.d.ts.map +1 -1
- package/dist/vue/components/MStack.js +12 -2
- package/dist/vue/components/MStack.js.map +1 -1
- package/dist/vue/components/MSwitch.d.ts +3 -3
- package/dist/vue/components/MTabs.d.ts +3 -3
- package/dist/vue/components/MText.d.ts +8 -8
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +4 -1
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/MTimePicker.d.ts +40 -40
- package/dist/vue/components/MTimePicker.d.ts.map +1 -1
- package/dist/vue/components/MTooltip.d.ts +2 -2
- package/dist/vue/components/advanced.d.ts +34 -34
- package/dist/vue/components/configurator.d.ts +36 -36
- package/dist/vue/components/creative.d.ts +21 -21
- package/dist/vue/components/dashboard.d.ts +13 -13
- package/dist/vue/components/dashboard.d.ts.map +1 -1
- package/dist/vue/components/dashboard.js +21 -6
- package/dist/vue/components/dashboard.js.map +1 -1
- package/dist/vue/components/discovery.d.ts +11 -11
- package/dist/vue/components/interactive.d.ts +6 -6
- package/dist/vue/components/layout.d.ts +45 -45
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +8 -2
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/navigation.d.ts +4 -4
- package/dist/vue/components/screen-components.d.ts +192 -21
- package/dist/vue/components/screen-components.d.ts.map +1 -1
- package/dist/vue/components/screen-components.js +18 -1
- package/dist/vue/components/screen-components.js.map +1 -1
- package/dist/vue/components/wayfinding.d.ts +10 -10
- package/dist/vue/components/workflows.d.ts +3 -3
- package/dist/vue/index.d.ts +3 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +5 -2
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layout-context.d.ts +4 -0
- package/dist/vue/layout-context.d.ts.map +1 -0
- package/dist/vue/layout-context.js +3 -0
- package/dist/vue/layout-context.js.map +1 -0
- package/dist/vue/navigation.d.ts +1 -3
- package/dist/vue/navigation.d.ts.map +1 -1
- package/dist/vue/navigation.js +1 -15
- package/dist/vue/navigation.js.map +1 -1
- package/dist/vue/screen-overlay.d.ts +9 -0
- package/dist/vue/screen-overlay.d.ts.map +1 -0
- package/dist/vue/screen-overlay.js +17 -0
- package/dist/vue/screen-overlay.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +2 -3
- package/dist/vue/use-motion-surface.d.ts.map +1 -1
- package/dist/vue/use-motion-surface.js +9 -128
- package/dist/vue/use-motion-surface.js.map +1 -1
- package/package.json +8 -4
- package/platforms/android/java/com/mavis/ui/Box.java +31 -0
- package/src/components/bindings.ts +32 -0
- package/src/components/contracts.ts +60 -0
- package/src/components/controller.ts +542 -0
- package/src/components/index.ts +136 -0
- package/src/components/style.ts +84 -0
- package/src/components/theme.ts +25 -0
- package/src/native/box.ios.ts +31 -1
- package/src/native/collection-motion.ts +6 -4
- package/src/native/motion-binding.ts +143 -0
- package/src/native/motion-surface.ts +19 -5
- package/src/native/navigation.ts +15 -0
- package/src/native/pointer-availability.ts +44 -0
- package/src/native/sheet.android.ts +19 -0
- package/src/native/sheet.ios.ts +2 -0
- package/src/native/sheet.ts +2 -0
- package/src/native/visual-effects.ts +6 -2
- package/src/vue/components/MGrid.ts +10 -1
- package/src/vue/components/MImageViewer.ts +10 -2
- package/src/vue/components/MScreen.ts +12 -1
- package/src/vue/components/MSheet.ts +89 -19
- package/src/vue/components/MStack.ts +17 -2
- package/src/vue/components/MText.ts +4 -1
- package/src/vue/components/dashboard.ts +23 -5
- package/src/vue/components/layout.ts +8 -0
- package/src/vue/components/screen-components.ts +20 -0
- package/src/vue/index.ts +10 -0
- package/src/vue/layout-context.ts +4 -0
- package/src/vue/navigation.ts +1 -15
- package/src/vue/screen-overlay.ts +20 -0
- package/src/vue/use-motion-surface.ts +10 -133
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { Utils, isAndroid, type EventData, type View } from '@nativescript/core'
|
|
2
1
|
import { inject, onBeforeUnmount, watch } from 'nativescript-vue'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
bindMotionSurface,
|
|
6
|
-
motionChannels,
|
|
7
|
-
motionKeyframes,
|
|
8
|
-
type MotionFrames,
|
|
9
|
-
type MotionSurface,
|
|
10
|
-
} from '@getcortexlabs/mavis-core/experimental'
|
|
11
|
-
import { nativeContinuousSurface } from '../native/motion-surface.js'
|
|
12
|
-
import { nativeMotionOwner } from '../native/motion-owner.js'
|
|
2
|
+
import type { MotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
3
|
+
import { createNativeMotionSurface } from '../native/motion-binding.js'
|
|
13
4
|
import { perspectiveKey } from './perspective.js'
|
|
14
|
-
import { takeShadow } from '../native/moved-shadow.js'
|
|
15
5
|
|
|
16
6
|
export function useMotionSurface(
|
|
17
7
|
surface: () => MotionSurface | undefined,
|
|
@@ -19,128 +9,15 @@ export function useMotionSurface(
|
|
|
19
9
|
plainText: () => boolean = () => false,
|
|
20
10
|
afterLayout = false,
|
|
21
11
|
) {
|
|
22
|
-
let view: View | undefined
|
|
23
|
-
let unbind: (() => void) | undefined
|
|
24
|
-
let offPreference: (() => void) | undefined
|
|
25
|
-
let continuous: ReturnType<typeof nativeContinuousSurface> | undefined
|
|
26
|
-
const active = new Map<ReturnType<typeof animate>, MotionFrames>()
|
|
27
|
-
let layoutView: View | undefined
|
|
28
|
-
let layoutQueued = false
|
|
29
12
|
const perspective = inject(perspectiveKey, undefined)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
}
|
|
43
|
-
const clearLayout = () => {
|
|
44
|
-
layoutView?.off('layoutChanged', laidOut)
|
|
45
|
-
layoutView = undefined
|
|
46
|
-
}
|
|
47
|
-
const release = () => {
|
|
48
|
-
unbind?.()
|
|
49
|
-
unbind = undefined
|
|
50
|
-
continuous = undefined
|
|
51
|
-
offPreference?.()
|
|
52
|
-
offPreference = undefined
|
|
53
|
-
for (const handle of active.keys()) handle.stop()
|
|
54
|
-
active.clear()
|
|
55
|
-
project()
|
|
56
|
-
}
|
|
57
|
-
const bind = () => {
|
|
58
|
-
release()
|
|
59
|
-
const target = view
|
|
60
|
-
const reference = surface()
|
|
61
|
-
if (!target || !reference) return
|
|
62
|
-
if (
|
|
63
|
-
afterLayout &&
|
|
64
|
-
(!target.isLayoutValid ||
|
|
65
|
-
target.getActualSize().width <= 0 ||
|
|
66
|
-
target.getActualSize().height <= 0)
|
|
67
|
-
) {
|
|
68
|
-
if (layoutView !== target) {
|
|
69
|
-
clearLayout()
|
|
70
|
-
layoutView = target
|
|
71
|
-
target.on('layoutChanged', laidOut)
|
|
72
|
-
}
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
clearLayout()
|
|
76
|
-
continuous = nativeContinuousSurface(target, enabled, plainText)
|
|
77
|
-
unbind = bindMotionSurface(
|
|
78
|
-
reference,
|
|
79
|
-
nativeMotionOwner(
|
|
80
|
-
{
|
|
81
|
-
...continuous.adapter,
|
|
82
|
-
animate(values, options) {
|
|
83
|
-
continuous?.interrupt(motionChannels(values))
|
|
84
|
-
const handle = animate(target, motionKeyframes(values), options)
|
|
85
|
-
takeShadow(target, values)
|
|
86
|
-
active.set(handle, values)
|
|
87
|
-
void handle.finished.then(() => active.delete(handle))
|
|
88
|
-
return handle
|
|
89
|
-
},
|
|
90
|
-
set: (values) => {
|
|
91
|
-
continuous?.interrupt(Object.keys(values))
|
|
92
|
-
const handle = animate(target, values, { duration: 0 })
|
|
93
|
-
takeShadow(target, values)
|
|
94
|
-
return handle
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
target,
|
|
98
|
-
),
|
|
99
|
-
)
|
|
100
|
-
project()
|
|
101
|
-
offPreference = onReducedMotion((reduced) => {
|
|
102
|
-
if (!reduced) return
|
|
103
|
-
// Set only spatial channels: opacity and shadow paint can keep their timelines.
|
|
104
|
-
const values: Record<string, number> = {}
|
|
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
|
-
})
|
|
112
|
-
for (const [property, value] of Object.entries(frames)) {
|
|
113
|
-
if (property === 'opacity' || property.startsWith('shadow')) continue
|
|
114
|
-
const final = Array.isArray(value) ? value.at(-1) : value
|
|
115
|
-
if (typeof final === 'number') values[property] = final
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (Object.keys(values).length) set(target, values)
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
const laidOut = () => {
|
|
122
|
-
if (layoutQueued) return
|
|
123
|
-
layoutQueued = true
|
|
124
|
-
void Promise.resolve().then(() => {
|
|
125
|
-
layoutQueued = false
|
|
126
|
-
if (view) bind()
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
const unloaded = () => {
|
|
130
|
-
clearLayout()
|
|
131
|
-
release()
|
|
132
|
-
view = undefined
|
|
133
|
-
}
|
|
134
|
-
watch(surface, bind, { flush: 'post' })
|
|
135
|
-
if (perspective) watch(perspective, project, { flush: 'post' })
|
|
136
|
-
watch(enabled, () => continuous?.refresh(), { flush: 'sync' })
|
|
137
|
-
onBeforeUnmount(unloaded)
|
|
13
|
+
const binding = createNativeMotionSurface(surface, enabled, plainText, afterLayout, perspective)
|
|
14
|
+
watch(surface, binding.refresh, { flush: 'post' })
|
|
15
|
+
if (perspective) watch(perspective, binding.refreshPerspective, { flush: 'post' })
|
|
16
|
+
watch(enabled, binding.refreshEnabled, { flush: 'sync' })
|
|
17
|
+
onBeforeUnmount(binding.onUnloaded)
|
|
138
18
|
return {
|
|
139
|
-
allowsActivation:
|
|
140
|
-
onLoaded
|
|
141
|
-
|
|
142
|
-
bind()
|
|
143
|
-
},
|
|
144
|
-
onUnloaded: unloaded,
|
|
19
|
+
allowsActivation: binding.allowsActivation,
|
|
20
|
+
onLoaded: binding.onLoaded,
|
|
21
|
+
onUnloaded: binding.onUnloaded,
|
|
145
22
|
}
|
|
146
23
|
}
|