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

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 (148) hide show
  1. package/README.md +7 -5
  2. package/dist/components/bindings.d.ts +14 -0
  3. package/dist/components/bindings.d.ts.map +1 -0
  4. package/dist/components/bindings.js +21 -0
  5. package/dist/components/bindings.js.map +1 -0
  6. package/dist/components/contracts.d.ts +28 -0
  7. package/dist/components/contracts.d.ts.map +1 -0
  8. package/dist/components/contracts.js +27 -0
  9. package/dist/components/contracts.js.map +1 -0
  10. package/dist/components/controller.d.ts +56 -0
  11. package/dist/components/controller.d.ts.map +1 -0
  12. package/dist/components/controller.js +508 -0
  13. package/dist/components/controller.js.map +1 -0
  14. package/dist/components/index.d.ts +53 -0
  15. package/dist/components/index.d.ts.map +1 -0
  16. package/dist/components/index.js +95 -0
  17. package/dist/components/index.js.map +1 -0
  18. package/dist/components/style.d.ts +52 -0
  19. package/dist/components/style.d.ts.map +1 -0
  20. package/dist/components/style.js +68 -0
  21. package/dist/components/style.js.map +1 -0
  22. package/dist/components/theme.d.ts +12 -0
  23. package/dist/components/theme.d.ts.map +1 -0
  24. package/dist/components/theme.js +29 -0
  25. package/dist/components/theme.js.map +1 -0
  26. package/dist/native/box.ios.d.ts +1 -0
  27. package/dist/native/box.ios.d.ts.map +1 -1
  28. package/dist/native/box.ios.js +21 -1
  29. package/dist/native/box.ios.js.map +1 -1
  30. package/dist/native/motion-binding.d.ts +11 -0
  31. package/dist/native/motion-binding.d.ts.map +1 -0
  32. package/dist/native/motion-binding.js +132 -0
  33. package/dist/native/motion-binding.js.map +1 -0
  34. package/dist/native/motion-surface.d.ts +1 -1
  35. package/dist/native/motion-surface.d.ts.map +1 -1
  36. package/dist/native/motion-surface.js +20 -5
  37. package/dist/native/motion-surface.js.map +1 -1
  38. package/dist/native/navigation.d.ts +4 -0
  39. package/dist/native/navigation.d.ts.map +1 -0
  40. package/dist/native/navigation.js +16 -0
  41. package/dist/native/navigation.js.map +1 -0
  42. package/dist/native/pointer-availability.d.ts +7 -0
  43. package/dist/native/pointer-availability.d.ts.map +1 -0
  44. package/dist/native/pointer-availability.js +43 -0
  45. package/dist/native/pointer-availability.js.map +1 -0
  46. package/dist/native/scroll-motion.d.ts +1 -1
  47. package/dist/native/section-scroll.d.ts +1 -1
  48. package/dist/vue/components/ChoiceControl.d.ts +3 -3
  49. package/dist/vue/components/DateCalendar.d.ts +1 -1
  50. package/dist/vue/components/LoadingDecoration.d.ts +5 -5
  51. package/dist/vue/components/MAccordion.d.ts +3 -3
  52. package/dist/vue/components/MAlert.d.ts +4 -4
  53. package/dist/vue/components/MAvatar.d.ts +4 -4
  54. package/dist/vue/components/MBadge.d.ts +3 -3
  55. package/dist/vue/components/MButton.d.ts +16 -16
  56. package/dist/vue/components/MCard.d.ts +11 -11
  57. package/dist/vue/components/MCheckbox.d.ts +3 -3
  58. package/dist/vue/components/MChip.d.ts +4 -4
  59. package/dist/vue/components/MCombobox.d.ts +5 -5
  60. package/dist/vue/components/MDialog.d.ts +3 -3
  61. package/dist/vue/components/MEmptyState.d.ts +3 -3
  62. package/dist/vue/components/MGrid.d.ts +7 -7
  63. package/dist/vue/components/MGrid.d.ts.map +1 -1
  64. package/dist/vue/components/MGrid.js +5 -1
  65. package/dist/vue/components/MGrid.js.map +1 -1
  66. package/dist/vue/components/MIcon.d.ts +2 -2
  67. package/dist/vue/components/MImage.d.ts +7 -7
  68. package/dist/vue/components/MImageCompare.d.ts +1 -1
  69. package/dist/vue/components/MInput.d.ts +20 -20
  70. package/dist/vue/components/MLink.d.ts +5 -5
  71. package/dist/vue/components/MListItem.d.ts +5 -5
  72. package/dist/vue/components/MPinInput.d.ts +1 -1
  73. package/dist/vue/components/MPopover.d.ts +3 -3
  74. package/dist/vue/components/MProgress.d.ts +5 -5
  75. package/dist/vue/components/MRadioGroup.d.ts +3 -3
  76. package/dist/vue/components/MRangeSlider.d.ts +3 -3
  77. package/dist/vue/components/MResizablePanels.d.ts +3 -3
  78. package/dist/vue/components/MReveal.d.ts +9 -9
  79. package/dist/vue/components/MScreen.d.ts +3 -3
  80. package/dist/vue/components/MScreen.d.ts.map +1 -1
  81. package/dist/vue/components/MScreen.js +11 -1
  82. package/dist/vue/components/MScreen.js.map +1 -1
  83. package/dist/vue/components/MSegmentedControl.d.ts +3 -3
  84. package/dist/vue/components/MSelect.d.ts +4 -4
  85. package/dist/vue/components/MSheet.d.ts +3 -3
  86. package/dist/vue/components/MSkeleton.d.ts +3 -3
  87. package/dist/vue/components/MSlider.d.ts +2 -2
  88. package/dist/vue/components/MStack.d.ts +11 -11
  89. package/dist/vue/components/MStack.d.ts.map +1 -1
  90. package/dist/vue/components/MStack.js +12 -2
  91. package/dist/vue/components/MStack.js.map +1 -1
  92. package/dist/vue/components/MSwitch.d.ts +3 -3
  93. package/dist/vue/components/MTabs.d.ts +3 -3
  94. package/dist/vue/components/MText.d.ts +8 -8
  95. package/dist/vue/components/MText.d.ts.map +1 -1
  96. package/dist/vue/components/MText.js +4 -1
  97. package/dist/vue/components/MText.js.map +1 -1
  98. package/dist/vue/components/MTooltip.d.ts +2 -2
  99. package/dist/vue/components/dashboard.d.ts.map +1 -1
  100. package/dist/vue/components/dashboard.js +21 -6
  101. package/dist/vue/components/dashboard.js.map +1 -1
  102. package/dist/vue/components/layout.d.ts +29 -29
  103. package/dist/vue/components/layout.d.ts.map +1 -1
  104. package/dist/vue/components/layout.js +8 -2
  105. package/dist/vue/components/layout.js.map +1 -1
  106. package/dist/vue/components/screen-components.d.ts.map +1 -1
  107. package/dist/vue/components/screen-components.js +15 -0
  108. package/dist/vue/components/screen-components.js.map +1 -1
  109. package/dist/vue/layout-context.d.ts +4 -0
  110. package/dist/vue/layout-context.d.ts.map +1 -0
  111. package/dist/vue/layout-context.js +3 -0
  112. package/dist/vue/layout-context.js.map +1 -0
  113. package/dist/vue/navigation.d.ts +1 -3
  114. package/dist/vue/navigation.d.ts.map +1 -1
  115. package/dist/vue/navigation.js +1 -15
  116. package/dist/vue/navigation.js.map +1 -1
  117. package/dist/vue/screen-overlay.d.ts +9 -0
  118. package/dist/vue/screen-overlay.d.ts.map +1 -0
  119. package/dist/vue/screen-overlay.js +17 -0
  120. package/dist/vue/screen-overlay.js.map +1 -0
  121. package/dist/vue/use-motion-surface.d.ts +2 -3
  122. package/dist/vue/use-motion-surface.d.ts.map +1 -1
  123. package/dist/vue/use-motion-surface.js +9 -128
  124. package/dist/vue/use-motion-surface.js.map +1 -1
  125. package/package.json +8 -4
  126. package/platforms/android/java/com/mavis/ui/Box.java +31 -0
  127. package/src/components/bindings.ts +32 -0
  128. package/src/components/contracts.ts +60 -0
  129. package/src/components/controller.ts +542 -0
  130. package/src/components/index.ts +136 -0
  131. package/src/components/style.ts +84 -0
  132. package/src/components/theme.ts +25 -0
  133. package/src/native/box.ios.ts +31 -1
  134. package/src/native/motion-binding.ts +143 -0
  135. package/src/native/motion-surface.ts +19 -5
  136. package/src/native/navigation.ts +15 -0
  137. package/src/native/pointer-availability.ts +44 -0
  138. package/src/vue/components/MGrid.ts +10 -1
  139. package/src/vue/components/MScreen.ts +12 -1
  140. package/src/vue/components/MStack.ts +17 -2
  141. package/src/vue/components/MText.ts +4 -1
  142. package/src/vue/components/dashboard.ts +23 -5
  143. package/src/vue/components/layout.ts +8 -0
  144. package/src/vue/components/screen-components.ts +14 -0
  145. package/src/vue/layout-context.ts +4 -0
  146. package/src/vue/navigation.ts +1 -15
  147. package/src/vue/screen-overlay.ts +20 -0
  148. package/src/vue/use-motion-surface.ts +10 -133
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
1
+ import { defineComponent, h, inject, mergeProps, registerElement } from 'nativescript-vue'
2
2
  import {
3
3
  textProps,
4
4
  useMavisTheme,
@@ -10,6 +10,7 @@ import { isAndroid } from '@nativescript/core'
10
10
  import { MavisLabel } from '../../native/label'
11
11
  import { useNativeViewAttrs } from '../accessibility.js'
12
12
  import { useMotionSurface } from '../use-motion-surface.js'
13
+ import { boxLayer } from '../layout-context.js'
13
14
 
14
15
  registerElement('MavisLabel', () => MavisLabel)
15
16
 
@@ -18,6 +19,7 @@ export const MText = defineComponent({
18
19
  inheritAttrs: false,
19
20
  props: textProps,
20
21
  setup(props, { attrs, slots }) {
22
+ const layered = inject(boxLayer, false)
21
23
  const { theme } = useMavisTheme()
22
24
  const nativeAttrs = useNativeViewAttrs(props)
23
25
  const shrink = useLayoutShrink()
@@ -44,6 +46,7 @@ export const MText = defineComponent({
44
46
  accessible: true,
45
47
  accessibilityRole: /^h[1-6]$/.test(props.as) ? 'header' : 'text',
46
48
  style: {
49
+ ...(layered ? { verticalAlignment: 'top' } : {}),
47
50
  ...type,
48
51
  fontFamily: fontFamily(type.fontFamily, isAndroid ? 'android' : 'ios'),
49
52
  fontWeight: props.weight ? validateWeight(props.weight) : type.fontWeight,
@@ -31,6 +31,7 @@ import {
31
31
  kanbanRegistryKey,
32
32
  kanbanZoneProps,
33
33
  kanbanDragProps,
34
+ useLayoutShrink,
34
35
  type KanbanRegistry,
35
36
  } from '@getcortexlabs/mavis-core/vue'
36
37
  import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
@@ -118,6 +119,7 @@ const Zone = defineComponent({
118
119
  inheritAttrs: false,
119
120
  props: kanbanZoneProps,
120
121
  setup(props, { attrs, slots }) {
122
+ const shrink = useLayoutShrink()
121
123
  const registry = inject(kanbanRegistryKey)! as KanbanRegistry<View>
122
124
  const leave = () => {
123
125
  if (registry.zones.delete(props.column)) registry.revision.value++
@@ -127,7 +129,10 @@ const Zone = defineComponent({
127
129
  h(
128
130
  'GridLayout',
129
131
  mergeProps(attrs, {
130
- zIndex: props.raised ? 20 : 0,
132
+ // Match the Web's equal zero-basis columns only in the horizontal stack.
133
+ width: shrink.value ? 0 : 'auto',
134
+ flexShrink: shrink.value,
135
+ style: { zIndex: props.raised ? 20 : 0 },
131
136
  onLoaded: (e: EventData) => {
132
137
  registry.zones.set(props.column, e.object as View)
133
138
  registry.revision.value++
@@ -171,11 +176,17 @@ const Drag = defineComponent({
171
176
  else surface.set({ x: 0, y: 0, scale: 1 })
172
177
  }
173
178
  function cancel() {
179
+ end(true)
180
+ }
181
+ function cancelImmediately() {
182
+ end(false)
183
+ }
184
+ function end(animated: boolean) {
174
185
  const was = live
175
186
  settle()
176
187
  zones?.cancel()
177
188
  if (!was) return
178
- rest(true)
189
+ rest(animated)
179
190
  registry.finish(props.cardId)
180
191
  }
181
192
  function release() {
@@ -238,7 +249,7 @@ const Drag = defineComponent({
238
249
  })
239
250
  }
240
251
  function unload() {
241
- cancel()
252
+ cancelImmediately()
242
253
  release()
243
254
  }
244
255
  onBeforeUnmount(() => {
@@ -247,8 +258,15 @@ const Drag = defineComponent({
247
258
  registry.cards.delete(props.cardId)
248
259
  registry.focus.delete(props.cardId)
249
260
  })
250
- onDeactivated(cancel)
251
- onScopeDispose(surface.use(() => cancel))
261
+ onDeactivated(cancelImmediately)
262
+ onScopeDispose(
263
+ surface.use(() => {
264
+ // A retained native view can reconnect after its return animation was
265
+ // stopped by unload. Start each presentation at the controlled position.
266
+ rest(false)
267
+ return cancelImmediately
268
+ }),
269
+ )
252
270
  watch(() => [registry.revision.value, props.disabled], schedule)
253
271
  // A plain GridLayout would take the column's whole height on iOS; a box keeps the card's own.
254
272
  return () =>
@@ -16,6 +16,8 @@ import { useNativeViewAttrs } from '../accessibility.js'
16
16
  import { useMotionRegion } from '../use-motion-region.js'
17
17
  import { useMotionSurface } from '../use-motion-surface.js'
18
18
  import { perspectiveKey } from '../perspective.js'
19
+ import { useOverlayLayout } from '../screen-overlay.js'
20
+ import { boxLayer } from '../layout-context.js'
19
21
 
20
22
  export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
21
23
 
@@ -45,6 +47,8 @@ function createLayout(name: string, direction: 'row' | 'column') {
45
47
  inheritAttrs: false,
46
48
  props: direction === 'row' ? rowProps : columnProps,
47
49
  setup(props, { attrs, slots }) {
50
+ const overlay = useOverlayLayout()
51
+ provide(boxLayer, false)
48
52
  const region = useMotionRegion(() => props.motionRegion)
49
53
  const { theme } = useMavisTheme()
50
54
  const nativeAttrs = useNativeViewAttrs(props)
@@ -54,6 +58,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
54
58
  h(
55
59
  'MavisFlexLayout',
56
60
  mergeProps(
61
+ overlay(attrs),
57
62
  {
58
63
  style: {
59
64
  ...boxStyle(theme.value, props, shrink.value),
@@ -83,6 +88,8 @@ export const MBox = defineComponent({
83
88
  inheritAttrs: false,
84
89
  props: motionBoxProps,
85
90
  setup(props, { attrs, slots }) {
91
+ const overlay = useOverlayLayout()
92
+ provide(boxLayer, true)
86
93
  const region = useMotionRegion(() => props.motionRegion)
87
94
  const surface = useMotionSurface(() => props.motionSurface)
88
95
  provide(perspectiveKey, () => resolvePerspective(props.perspective))
@@ -93,6 +100,7 @@ export const MBox = defineComponent({
93
100
  h(
94
101
  'MavisBox',
95
102
  mergeProps(
103
+ overlay(attrs),
96
104
  { style: boxStyle(theme.value, props, shrink.value) },
97
105
  nativeAttrs(),
98
106
  attrs,
@@ -1,4 +1,5 @@
1
1
  import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
2
+ import { isIOS, type EventData, type View } from '@nativescript/core'
2
3
  import { ScrollHeaderSurface } from '@rafaelaugusto/jolt'
3
4
  import {
4
5
  createAnimatedText,
@@ -19,6 +20,18 @@ import { MChip } from './MChip.js'
19
20
  import { MPopover } from './MPopover.js'
20
21
 
21
22
  registerElement('MavisRefreshFrame', () => ScrollHeaderSurface, { viewFlags: 4 })
23
+ const Clip = defineComponent({
24
+ name: 'MScrollHeaderClip',
25
+ inheritAttrs: false,
26
+ setup(_, { attrs, slots }) {
27
+ const loaded = ({ object }: EventData) => {
28
+ // Core defaults clipToBounds to true, so assigning true can skip its native
29
+ // setter. Enforce it once the UIView exists, independently of Jolt's header.
30
+ if (isIOS) (object as View).nativeViewProtected.clipsToBounds = true
31
+ }
32
+ return () => h(MBox, mergeProps(attrs, { clipToBounds: true, onLoaded: loaded }), slots)
33
+ },
34
+ })
22
35
  const Frame = defineComponent({
23
36
  name: 'MScrollFrameHost',
24
37
  inheritAttrs: false,
@@ -43,6 +56,7 @@ const Frame = defineComponent({
43
56
  })
44
57
  const ui = {
45
58
  Box: MBox,
59
+ Clip,
46
60
  Card: MCard,
47
61
  Column: MColumn,
48
62
  Row: MRow,
@@ -0,0 +1,4 @@
1
+ import type { InjectionKey } from 'nativescript-vue'
2
+
3
+ /** Text directly in a layered box starts at its top, like text in a CSS grid cell. */
4
+ export const boxLayer: InjectionKey<boolean> = Symbol('mavis.boxLayer')
@@ -1,15 +1 @@
1
- import { Utils } from '@nativescript/core'
2
- import { linkDestination, type NavigationOptions } from '@getcortexlabs/mavis-core'
3
-
4
- export function nativeDestination(options: NavigationOptions) {
5
- const href = linkDestination(options.href!)
6
- if (!options.navigate && !/^[a-z][a-z\d+.-]*:/i.test(href))
7
- throw new TypeError('Native navigation needs a navigate handler for in-app destinations.')
8
- return href
9
- }
10
-
11
- export async function navigateNative(options: NavigationOptions) {
12
- const href = nativeDestination(options)
13
- if (options.navigate) await options.navigate(href)
14
- else if (!(await Utils.openUrl(href))) throw new Error(`The system could not open ${href}.`)
15
- }
1
+ export { nativeDestination, navigateNative } from '../native/navigation.js'
@@ -0,0 +1,20 @@
1
+ import { inject, type InjectionKey } from 'nativescript-vue'
2
+
3
+ /** Only the screen's decorative slot inherits this; modal and toast hosts do not. */
4
+ export const screenOverlay: InjectionKey<boolean> = Symbol('mavis.screenOverlay')
5
+
6
+ export function useOverlayLayout() {
7
+ const overlay = inject(screenOverlay, false)
8
+ return (attrs: Record<string, unknown>) => {
9
+ if (!overlay) return {}
10
+ const style = attrs.style as { pointerEvents?: string } | undefined
11
+ // Explicit native gestures and the Web's pointer opt-in keep interactive
12
+ // layers usable. Plain nested layouts let their empty area pass through.
13
+ const interactive =
14
+ style?.pointerEvents === 'auto' ||
15
+ ['onTap', 'onTouch', 'onPan', 'onLongPress', 'onDoubleTap', 'onSwipe'].some(
16
+ (name) => attrs[name],
17
+ )
18
+ return { isPassThroughParentEnabled: !interactive }
19
+ }
20
+ }
@@ -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 { animate, set, onReducedMotion } from '@rafaelaugusto/jolt'
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
- 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
- }
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: () => continuous?.allowsActivation() ?? true,
140
- onLoaded(event: EventData) {
141
- view = event.object as View
142
- bind()
143
- },
144
- onUnloaded: unloaded,
19
+ allowsActivation: binding.allowsActivation,
20
+ onLoaded: binding.onLoaded,
21
+ onUnloaded: binding.onUnloaded,
145
22
  }
146
23
  }