@getcortexlabs/mavis 0.1.0-alpha.5 → 0.1.0-alpha.7
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 +5 -7
- package/dist/app-icons.d.ts +26 -0
- package/dist/app-icons.d.ts.map +1 -0
- package/dist/app-icons.js +9 -0
- package/dist/app-icons.js.map +1 -0
- package/dist/native/app-icons.android.d.ts +4 -0
- package/dist/native/app-icons.android.d.ts.map +1 -0
- package/dist/native/app-icons.android.js +67 -0
- package/dist/native/app-icons.android.js.map +1 -0
- package/dist/native/app-icons.d.ts +4 -0
- package/dist/native/app-icons.d.ts.map +1 -0
- package/dist/native/app-icons.ios.d.ts +4 -0
- package/dist/native/app-icons.ios.d.ts.map +1 -0
- package/dist/native/app-icons.ios.js +45 -0
- package/dist/native/app-icons.ios.js.map +1 -0
- package/dist/native/app-icons.js +9 -0
- package/dist/native/app-icons.js.map +1 -0
- package/dist/native/motion-owner.d.ts.map +1 -1
- package/dist/native/motion-owner.js +5 -0
- package/dist/native/motion-owner.js.map +1 -1
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +39 -1
- package/dist/native/motion-region.js.map +1 -1
- 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 +36 -3
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/press.d.ts +5 -2
- package/dist/native/press.d.ts.map +1 -1
- package/dist/native/press.js +6 -0
- package/dist/native/press.js.map +1 -1
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
- package/dist/vue/components/ChoiceControl.js +20 -5
- package/dist/vue/components/ChoiceControl.js.map +1 -1
- package/dist/vue/components/DateCalendar.d.ts +3 -3
- package/dist/vue/components/MButton.d.ts +49 -3
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +20 -13
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +47 -1
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +12 -5
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MChip.d.ts +2 -2
- package/dist/vue/components/MDatePicker.d.ts +72 -24
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MDialog.d.ts +1 -1
- package/dist/vue/components/MEmptyState.d.ts +1 -1
- package/dist/vue/components/MFilePicker.d.ts +2 -2
- package/dist/vue/components/MImage.d.ts +192 -0
- package/dist/vue/components/MImage.d.ts.map +1 -0
- package/dist/vue/components/MImage.js +102 -0
- package/dist/vue/components/MImage.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +3 -3
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +12 -8
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MLink.d.ts +120 -0
- package/dist/vue/components/MLink.d.ts.map +1 -0
- package/dist/vue/components/MLink.js +81 -0
- package/dist/vue/components/MLink.js.map +1 -0
- package/dist/vue/components/MListItem.d.ts +2 -0
- package/dist/vue/components/MListItem.d.ts.map +1 -1
- package/dist/vue/components/MProgress.d.ts +1 -1
- package/dist/vue/components/MReveal.d.ts +2 -2
- package/dist/vue/components/MReveal.d.ts.map +1 -1
- package/dist/vue/components/MReveal.js +80 -35
- package/dist/vue/components/MReveal.js.map +1 -1
- package/dist/vue/components/MSheet.d.ts +1 -1
- package/dist/vue/components/MStack.d.ts +199 -0
- package/dist/vue/components/MStack.d.ts.map +1 -0
- package/dist/vue/components/MStack.js +62 -0
- package/dist/vue/components/MStack.js.map +1 -0
- package/dist/vue/components/MSwitch.d.ts.map +1 -1
- package/dist/vue/components/MSwitch.js +13 -3
- package/dist/vue/components/MSwitch.js.map +1 -1
- package/dist/vue/components/MText.js +3 -3
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/configurator.d.ts +541 -0
- package/dist/vue/components/configurator.d.ts.map +1 -0
- package/dist/vue/components/configurator.js +24 -0
- package/dist/vue/components/configurator.js.map +1 -0
- package/dist/vue/components/layout.d.ts +3 -3
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +5 -5
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/workflows.d.ts +1 -1
- package/dist/vue/index.d.ts +5 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +10 -1
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/navigation.d.ts +4 -0
- package/dist/vue/navigation.d.ts.map +1 -0
- package/dist/vue/navigation.js +16 -0
- package/dist/vue/navigation.js.map +1 -0
- package/dist/vue/use-choice-paint.d.ts +9 -0
- package/dist/vue/use-choice-paint.d.ts.map +1 -0
- package/dist/vue/use-choice-paint.js +32 -0
- package/dist/vue/use-choice-paint.js.map +1 -0
- package/dist/vue/use-press.js +3 -3
- package/dist/vue/use-press.js.map +1 -1
- package/package.json +7 -3
- package/src/app-icons.ts +21 -0
- package/src/native/app-icons.android.ts +95 -0
- package/src/native/app-icons.ios.ts +74 -0
- package/src/native/app-icons.ts +12 -0
- package/src/native/motion-owner.ts +7 -0
- package/src/native/motion-region.ts +63 -1
- package/src/native/motion-surface.ts +41 -2
- package/src/native/press.ts +9 -3
- package/src/vue/components/ChoiceControl.ts +25 -5
- package/src/vue/components/MButton.ts +20 -10
- package/src/vue/components/MCard.ts +22 -5
- package/src/vue/components/MImage.ts +117 -0
- package/src/vue/components/MInput.ts +12 -8
- package/src/vue/components/MLink.ts +96 -0
- package/src/vue/components/MReveal.ts +89 -47
- package/src/vue/components/MStack.ts +83 -0
- package/src/vue/components/MSwitch.ts +16 -3
- package/src/vue/components/MText.ts +3 -3
- package/src/vue/components/configurator.ts +27 -0
- package/src/vue/components/layout.ts +10 -5
- package/src/vue/index.ts +14 -0
- package/src/vue/navigation.ts +15 -0
- package/src/vue/use-choice-paint.ts +39 -0
- package/src/vue/use-press.ts +3 -3
- package/dist/vue/reveal-motion.d.ts +0 -13
- package/dist/vue/reveal-motion.d.ts.map +0 -1
- package/dist/vue/reveal-motion.js +0 -55
- package/dist/vue/reveal-motion.js.map +0 -1
- package/src/vue/reveal-motion.ts +0 -61
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineComponent, h, mergeProps
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { defineComponent, h, mergeProps } from 'nativescript-vue'
|
|
2
|
+
import { animate, animateSize } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { motionRecipe } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { revealProps, useMavisTheme, useRevealState } from '@getcortexlabs/mavis-core/vue'
|
|
5
|
+
import { MColumn, MBox } from './layout.js'
|
|
6
|
+
import { isAndroid, type EventData, type View } from '@nativescript/core'
|
|
6
7
|
import { focusedView } from '../accessibility.js'
|
|
7
8
|
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
8
9
|
|
|
@@ -11,51 +12,92 @@ export const MReveal = defineComponent({
|
|
|
11
12
|
inheritAttrs: false,
|
|
12
13
|
props: revealProps,
|
|
13
14
|
setup(props, { attrs, slots }) {
|
|
14
|
-
const
|
|
15
|
+
const { theme } = useMavisTheme()
|
|
16
|
+
const state = useRevealState(() => props.show)
|
|
15
17
|
let trigger: WeakRef<View> | undefined
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
restore = false
|
|
52
|
-
},
|
|
18
|
+
function activeView(root: View): View | undefined {
|
|
19
|
+
if (
|
|
20
|
+
isAndroid
|
|
21
|
+
? root.android?.hasFocus?.() && !root.android?.getFocusedChild?.()
|
|
22
|
+
: root.ios?.isFirstResponder
|
|
23
|
+
)
|
|
24
|
+
return root
|
|
25
|
+
let found: View | undefined
|
|
26
|
+
root.eachChildView((child) => {
|
|
27
|
+
found = activeView(child)
|
|
28
|
+
return !found
|
|
29
|
+
})
|
|
30
|
+
return found
|
|
31
|
+
}
|
|
32
|
+
function currentFocus(view: View) {
|
|
33
|
+
return view.page && (activeView(view.page) ?? focusedView(view.page))
|
|
34
|
+
}
|
|
35
|
+
function attach(view: View) {
|
|
36
|
+
const focusability = isAndroid ? view.android.getDescendantFocusability() : undefined
|
|
37
|
+
return state.attach({
|
|
38
|
+
animate(open, fromClosed) {
|
|
39
|
+
if (fromClosed) {
|
|
40
|
+
view.height = 0
|
|
41
|
+
view.opacity = 0
|
|
42
|
+
}
|
|
43
|
+
const recipe = motionRecipe(theme.value, open ? 'enter' : 'exit')
|
|
44
|
+
const size = animateSize(view, { height: open ? 'auto' : 0 }, recipe.transition)
|
|
45
|
+
const opacity = animate(view, { opacity: open ? 1 : 0 }, recipe.transition)
|
|
46
|
+
return {
|
|
47
|
+
finished: size.finished,
|
|
48
|
+
stop() {
|
|
49
|
+
size.stop({ restore: true })
|
|
50
|
+
opacity.stop()
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
53
|
},
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
interactive(enabled) {
|
|
55
|
+
view.accessibilityHidden = !enabled || Boolean(props.accessibilityHidden)
|
|
56
|
+
view.isUserInteractionEnabled = enabled
|
|
57
|
+
if (isAndroid) view.android.setDescendantFocusability(enabled ? focusability : 393216)
|
|
57
58
|
},
|
|
58
|
-
|
|
59
|
+
captureFocus() {
|
|
60
|
+
const active = currentFocus(view)
|
|
61
|
+
let ancestor = active
|
|
62
|
+
while (ancestor && ancestor !== view) ancestor = ancestor.parent as View | undefined
|
|
63
|
+
if (active && !ancestor) trigger = new WeakRef(active)
|
|
64
|
+
},
|
|
65
|
+
restoreFocus() {
|
|
66
|
+
const focused = currentFocus(view)
|
|
67
|
+
let active = focused
|
|
68
|
+
while (active && active !== view) active = active.parent as View | undefined
|
|
69
|
+
const target = trigger?.deref()
|
|
70
|
+
if (active === view && target?.isLoaded) {
|
|
71
|
+
;(focused as View & { dismissSoftInput?(): void })?.dismissSoftInput?.()
|
|
72
|
+
target.focus()
|
|
73
|
+
if (isAndroid) target.android.performAccessibilityAction(64, null)
|
|
74
|
+
else notifyAccessibilityLayout(target)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
release() {
|
|
78
|
+
view.height = 'auto'
|
|
79
|
+
view.opacity = 1
|
|
80
|
+
if (isAndroid && view.android) view.android.setDescendantFocusability(focusability)
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
return () => {
|
|
85
|
+
const { show, grow, shrink, width, id, ...content } = props
|
|
86
|
+
return state.present.value
|
|
87
|
+
? h(MBox, mergeProps({ grow, shrink, width, id }, attrs), {
|
|
88
|
+
default: () =>
|
|
89
|
+
h(
|
|
90
|
+
MBox,
|
|
91
|
+
{
|
|
92
|
+
clipToBounds: true,
|
|
93
|
+
accessibilityHidden: !show || props.accessibilityHidden,
|
|
94
|
+
onLoaded: (event: EventData) => attach(event.object as View),
|
|
95
|
+
onUnloaded: state.detach,
|
|
96
|
+
},
|
|
97
|
+
{ default: () => h(MColumn, content, slots) },
|
|
98
|
+
),
|
|
99
|
+
})
|
|
100
|
+
: null
|
|
59
101
|
}
|
|
60
102
|
},
|
|
61
103
|
})
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { computed, defineComponent, h, mergeProps, provide, shallowRef } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, View } from '@nativescript/core'
|
|
3
|
+
import { resolveSpace, stackLayout } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import {
|
|
5
|
+
stackProps,
|
|
6
|
+
layoutDirection,
|
|
7
|
+
useLayoutShrink,
|
|
8
|
+
useMavisTheme,
|
|
9
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
10
|
+
import { boxStyle } from '../props.js'
|
|
11
|
+
import { useNativeViewAttrs } from '../accessibility.js'
|
|
12
|
+
import './layout.js'
|
|
13
|
+
|
|
14
|
+
const align = {
|
|
15
|
+
start: 'flex-start',
|
|
16
|
+
end: 'flex-end',
|
|
17
|
+
center: 'center',
|
|
18
|
+
stretch: 'stretch',
|
|
19
|
+
} as const
|
|
20
|
+
const justify = {
|
|
21
|
+
start: 'flex-start',
|
|
22
|
+
end: 'flex-end',
|
|
23
|
+
center: 'center',
|
|
24
|
+
between: 'space-between',
|
|
25
|
+
around: 'space-around',
|
|
26
|
+
} as const
|
|
27
|
+
|
|
28
|
+
export const MStack = defineComponent({
|
|
29
|
+
name: 'MStack',
|
|
30
|
+
inheritAttrs: false,
|
|
31
|
+
props: stackProps,
|
|
32
|
+
setup(props, { attrs, slots }) {
|
|
33
|
+
const { theme } = useMavisTheme()
|
|
34
|
+
const nativeAttrs = useNativeViewAttrs(props)
|
|
35
|
+
const shrink = useLayoutShrink()
|
|
36
|
+
const width = shallowRef<number>()
|
|
37
|
+
const layout = computed(() =>
|
|
38
|
+
stackLayout(
|
|
39
|
+
{
|
|
40
|
+
direction: props.direction,
|
|
41
|
+
gap: props.gap,
|
|
42
|
+
align: props.align,
|
|
43
|
+
justify: props.justify,
|
|
44
|
+
wrap: props.wrap,
|
|
45
|
+
},
|
|
46
|
+
props.responsive,
|
|
47
|
+
width.value,
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
const direction = computed(() => layout.value.direction ?? props.direction)
|
|
51
|
+
provide(layoutDirection, direction)
|
|
52
|
+
const measure = (event: EventData) => {
|
|
53
|
+
const view = event.object as View
|
|
54
|
+
const size = view.getActualSize().width
|
|
55
|
+
// The inner layout occupies the outer Box's content area, after padding.
|
|
56
|
+
if (size > 0 && size !== width.value) width.value = size
|
|
57
|
+
}
|
|
58
|
+
return () =>
|
|
59
|
+
h(
|
|
60
|
+
'MavisBox',
|
|
61
|
+
mergeProps({ style: boxStyle(theme.value, props, shrink.value) }, nativeAttrs(), attrs),
|
|
62
|
+
[
|
|
63
|
+
h(
|
|
64
|
+
'MavisFlexLayout',
|
|
65
|
+
{
|
|
66
|
+
onLayoutChanged: measure,
|
|
67
|
+
onUnloaded: () => {
|
|
68
|
+
width.value = undefined
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
flexDirection: direction.value,
|
|
72
|
+
alignItems: align[layout.value.align ?? props.align],
|
|
73
|
+
justifyContent: justify[layout.value.justify ?? props.justify],
|
|
74
|
+
flexWrap: layout.value.wrap ? 'wrap' : 'nowrap',
|
|
75
|
+
gap: resolveSpace(theme.value, layout.value.gap ?? 'none'),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
slots.default?.(),
|
|
79
|
+
),
|
|
80
|
+
],
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useChoicePaint } from '../use-choice-paint.js'
|
|
1
2
|
import { isAndroid } from '@nativescript/core'
|
|
2
3
|
import { defineComponent, h, mergeProps, nextTick, onBeforeUnmount } from 'nativescript-vue'
|
|
3
4
|
import type {
|
|
@@ -26,6 +27,12 @@ export const MSwitch = defineComponent({
|
|
|
26
27
|
useButtonAction()
|
|
27
28
|
const { theme } = useMavisTheme()
|
|
28
29
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
30
|
+
const paint = useChoicePaint(
|
|
31
|
+
() => ({
|
|
32
|
+
backgroundColor: isAndroid ? theme.value.colors.primarySoft : theme.value.colors.primary,
|
|
33
|
+
}),
|
|
34
|
+
theme,
|
|
35
|
+
)
|
|
29
36
|
const feedback = usePressFeedback(() => !props.disabled, theme)
|
|
30
37
|
let control: Switch | undefined
|
|
31
38
|
let restoring = false
|
|
@@ -40,7 +47,8 @@ export const MSwitch = defineComponent({
|
|
|
40
47
|
start = undefined
|
|
41
48
|
verticalDrag = false
|
|
42
49
|
}
|
|
43
|
-
function touch(
|
|
50
|
+
function touch(data: EventData) {
|
|
51
|
+
const event = data as TouchGestureEventData
|
|
44
52
|
if (event.action === 'down') {
|
|
45
53
|
resetTouch()
|
|
46
54
|
start = { x: event.getX(), y: event.getY() }
|
|
@@ -62,6 +70,8 @@ export const MSwitch = defineComponent({
|
|
|
62
70
|
|
|
63
71
|
function release() {
|
|
64
72
|
resetTouch()
|
|
73
|
+
control?.off('touch', touch)
|
|
74
|
+
paint.onUnloaded()
|
|
65
75
|
control = undefined
|
|
66
76
|
revision++
|
|
67
77
|
}
|
|
@@ -153,6 +163,8 @@ export const MSwitch = defineComponent({
|
|
|
153
163
|
accessibilityHint: props.helperText || undefined,
|
|
154
164
|
// Android's thumb extends beyond the narrow track: a light
|
|
155
165
|
// thumb disappears against a light settings surface.
|
|
166
|
+
style: paint.style,
|
|
167
|
+
// Switch.color is a platform thumb tint, not Jolt's text-color channel.
|
|
156
168
|
color: isAndroid
|
|
157
169
|
? props.modelValue
|
|
158
170
|
? colors.primary
|
|
@@ -160,13 +172,14 @@ export const MSwitch = defineComponent({
|
|
|
160
172
|
: props.modelValue
|
|
161
173
|
? colors.onPrimary
|
|
162
174
|
: colors.surface,
|
|
163
|
-
backgroundColor: isAndroid ? colors.primarySoft : colors.primary,
|
|
164
175
|
offBackgroundColor: isAndroid ? colors.border : colors.muted,
|
|
165
176
|
margin: 0,
|
|
166
|
-
onTouch: touch,
|
|
167
177
|
onCheckedChange: change,
|
|
168
178
|
onLoaded: (event: EventData) => {
|
|
179
|
+
release()
|
|
169
180
|
control = event.object as Switch
|
|
181
|
+
control.on('touch', touch)
|
|
182
|
+
paint.onLoaded(event)
|
|
170
183
|
// A retained page can unload before a pending restoration.
|
|
171
184
|
restoring = true
|
|
172
185
|
try {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
textProps,
|
|
4
4
|
useMavisTheme,
|
|
5
5
|
inlineContent,
|
|
6
|
-
|
|
6
|
+
useLayoutShrink,
|
|
7
7
|
} from '@getcortexlabs/mavis-core/vue'
|
|
8
8
|
import { fontFamily, nonNegative, validateWeight } from '@getcortexlabs/mavis-core'
|
|
9
9
|
import { isAndroid } from '@nativescript/core'
|
|
@@ -19,7 +19,7 @@ export const MText = defineComponent({
|
|
|
19
19
|
setup(props, { attrs, slots }) {
|
|
20
20
|
const { theme } = useMavisTheme()
|
|
21
21
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
22
|
-
const shrink =
|
|
22
|
+
const shrink = useLayoutShrink()
|
|
23
23
|
return () => {
|
|
24
24
|
const type = theme.value.typography[props.variant]
|
|
25
25
|
const runs =
|
|
@@ -46,7 +46,7 @@ export const MText = defineComponent({
|
|
|
46
46
|
color: theme.value.colors[props.tone],
|
|
47
47
|
textAlignment: props.align,
|
|
48
48
|
flexGrow: nonNegative(props.grow, 'grow'),
|
|
49
|
-
flexShrink: nonNegative(props.shrink ?? shrink, 'shrink'),
|
|
49
|
+
flexShrink: nonNegative(props.shrink ?? shrink.value, 'shrink'),
|
|
50
50
|
minWidth: 0,
|
|
51
51
|
},
|
|
52
52
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Utils, type View } from '@nativescript/core'
|
|
2
|
+
import { createConfiguratorControls } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { MText } from './MText.js'
|
|
4
|
+
import { MButton } from './MButton.js'
|
|
5
|
+
import { MInput } from './MInput.js'
|
|
6
|
+
import { MChip } from './MChip.js'
|
|
7
|
+
import { MCheckbox } from './MCheckbox.js'
|
|
8
|
+
import { MSheet } from './MSheet.js'
|
|
9
|
+
import { MColumn, MRow } from './layout.js'
|
|
10
|
+
|
|
11
|
+
export const { MNumberInput, MMultiSelect } = createConfiguratorControls(
|
|
12
|
+
{
|
|
13
|
+
Column: MColumn,
|
|
14
|
+
Row: MRow,
|
|
15
|
+
Text: MText,
|
|
16
|
+
Button: MButton,
|
|
17
|
+
Input: MInput,
|
|
18
|
+
Chip: MChip,
|
|
19
|
+
Checkbox: MCheckbox,
|
|
20
|
+
Sheet: MSheet,
|
|
21
|
+
focusTrigger: (component) => {
|
|
22
|
+
Utils.dismissKeyboard()
|
|
23
|
+
;(component as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView?.focus()
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
'native',
|
|
27
|
+
)
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
columnProps,
|
|
4
4
|
useMavisTheme,
|
|
5
5
|
layoutDirection,
|
|
6
|
-
|
|
6
|
+
useLayoutShrink,
|
|
7
7
|
motionBoxProps,
|
|
8
8
|
} from '@getcortexlabs/mavis-core/vue'
|
|
9
9
|
import { defineComponent, h, mergeProps, provide, registerElement } from 'nativescript-vue'
|
|
@@ -44,7 +44,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
|
|
|
44
44
|
setup(props, { attrs, slots }) {
|
|
45
45
|
const { theme } = useMavisTheme()
|
|
46
46
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
47
|
-
const shrink =
|
|
47
|
+
const shrink = useLayoutShrink()
|
|
48
48
|
provide(layoutDirection, direction)
|
|
49
49
|
return () =>
|
|
50
50
|
h(
|
|
@@ -52,7 +52,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
|
|
|
52
52
|
mergeProps(
|
|
53
53
|
{
|
|
54
54
|
style: {
|
|
55
|
-
...boxStyle(theme.value, props, shrink),
|
|
55
|
+
...boxStyle(theme.value, props, shrink.value),
|
|
56
56
|
flexDirection: direction,
|
|
57
57
|
alignItems: alignment[props.align],
|
|
58
58
|
justifyContent: distribution[props.justify],
|
|
@@ -81,11 +81,16 @@ export const MBox = defineComponent({
|
|
|
81
81
|
const region = useMotionRegion(() => props.motionRegion)
|
|
82
82
|
const { theme } = useMavisTheme()
|
|
83
83
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
84
|
-
const shrink =
|
|
84
|
+
const shrink = useLayoutShrink()
|
|
85
85
|
return () =>
|
|
86
86
|
h(
|
|
87
87
|
'MavisBox',
|
|
88
|
-
mergeProps(
|
|
88
|
+
mergeProps(
|
|
89
|
+
{ style: boxStyle(theme.value, props, shrink.value) },
|
|
90
|
+
nativeAttrs(),
|
|
91
|
+
attrs,
|
|
92
|
+
region,
|
|
93
|
+
),
|
|
89
94
|
slots.default?.(),
|
|
90
95
|
)
|
|
91
96
|
},
|
package/src/vue/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
2
|
+
import { MImage } from './components/MImage.js'
|
|
3
|
+
import { MStack } from './components/MStack.js'
|
|
4
|
+
import { MLink } from './components/MLink.js'
|
|
1
5
|
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
2
6
|
import { MCombobox } from './components/MCombobox.js'
|
|
3
7
|
import { MFilePicker } from './components/MFilePicker.js'
|
|
@@ -49,6 +53,8 @@ export {
|
|
|
49
53
|
MBox,
|
|
50
54
|
MRow,
|
|
51
55
|
MColumn,
|
|
56
|
+
MStack,
|
|
57
|
+
MLink,
|
|
52
58
|
MCard,
|
|
53
59
|
MText,
|
|
54
60
|
MButton,
|
|
@@ -77,6 +83,9 @@ export {
|
|
|
77
83
|
MSheet,
|
|
78
84
|
MDatePicker,
|
|
79
85
|
MDateRangePicker,
|
|
86
|
+
MNumberInput,
|
|
87
|
+
MMultiSelect,
|
|
88
|
+
MImage,
|
|
80
89
|
MCombobox,
|
|
81
90
|
MFilePicker,
|
|
82
91
|
MFormGroup,
|
|
@@ -125,6 +134,8 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
125
134
|
MBox,
|
|
126
135
|
MRow,
|
|
127
136
|
MColumn,
|
|
137
|
+
MStack,
|
|
138
|
+
MLink,
|
|
128
139
|
MCard,
|
|
129
140
|
MText,
|
|
130
141
|
MButton,
|
|
@@ -153,6 +164,9 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
153
164
|
MSheet,
|
|
154
165
|
MDatePicker,
|
|
155
166
|
MDateRangePicker,
|
|
167
|
+
MNumberInput,
|
|
168
|
+
MMultiSelect,
|
|
169
|
+
MImage,
|
|
156
170
|
MCombobox,
|
|
157
171
|
MFilePicker,
|
|
158
172
|
MFormGroup,
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { onBeforeUnmount, watch, type Ref } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, View } from '@nativescript/core'
|
|
3
|
+
import { animate } from '@rafaelaugusto/jolt'
|
|
4
|
+
import { choiceMotion, type ChoicePaint, type MavisTheme } from '@getcortexlabs/mavis-core'
|
|
5
|
+
|
|
6
|
+
export function useChoicePaint(
|
|
7
|
+
paint: () => ChoicePaint,
|
|
8
|
+
theme: Readonly<Ref<Readonly<MavisTheme>>>,
|
|
9
|
+
) {
|
|
10
|
+
const initial = paint()
|
|
11
|
+
let target: View | undefined
|
|
12
|
+
let playback: ReturnType<typeof animate> | undefined
|
|
13
|
+
function update(instant = false) {
|
|
14
|
+
if (!target?.isLoaded) return
|
|
15
|
+
const previous = playback
|
|
16
|
+
playback = animate(target, paint(), instant ? { duration: 0 } : choiceMotion(theme.value))
|
|
17
|
+
previous?.stop()
|
|
18
|
+
}
|
|
19
|
+
function unload() {
|
|
20
|
+
playback?.stop()
|
|
21
|
+
playback = undefined
|
|
22
|
+
target = undefined
|
|
23
|
+
}
|
|
24
|
+
watch(
|
|
25
|
+
() => [paint(), theme.value.motion],
|
|
26
|
+
() => update(),
|
|
27
|
+
{ deep: true, flush: 'post' },
|
|
28
|
+
)
|
|
29
|
+
onBeforeUnmount(unload)
|
|
30
|
+
return {
|
|
31
|
+
style: initial,
|
|
32
|
+
onLoaded: (event: EventData) => {
|
|
33
|
+
unload()
|
|
34
|
+
target = event.object as View
|
|
35
|
+
update(true)
|
|
36
|
+
},
|
|
37
|
+
onUnloaded: unload,
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/vue/use-press.ts
CHANGED
|
@@ -17,15 +17,15 @@ export function usePressFeedback(
|
|
|
17
17
|
}
|
|
18
18
|
const refresh = () => {
|
|
19
19
|
if (view && enabled()) {
|
|
20
|
-
if (remove) remove.update(theme.value.motion
|
|
21
|
-
else remove = attachPressFeedback(view, theme.value.motion
|
|
20
|
+
if (remove) remove.update(theme.value.motion)
|
|
21
|
+
else remove = attachPressFeedback(view, theme.value.motion)
|
|
22
22
|
} else release()
|
|
23
23
|
}
|
|
24
24
|
const unloaded = () => {
|
|
25
25
|
release()
|
|
26
26
|
view = undefined
|
|
27
27
|
}
|
|
28
|
-
watch([enabled, () => theme.value.motion
|
|
28
|
+
watch([enabled, () => theme.value.motion], refresh, { flush: 'post' })
|
|
29
29
|
if (keyboard) watch(keyboard, (pressed) => remove?.press(pressed), { flush: 'sync' })
|
|
30
30
|
onBeforeUnmount(unloaded)
|
|
31
31
|
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { View } from '@nativescript/core';
|
|
2
|
-
type Element = {
|
|
3
|
-
nativeView: View;
|
|
4
|
-
};
|
|
5
|
-
/** Each transition owns its completion; an interrupted leave cannot finish a new entry. */
|
|
6
|
-
export declare function useRevealMotion(): {
|
|
7
|
-
onEnter: (element: Element, done: () => void) => void;
|
|
8
|
-
onLeave: (element: Element, done: () => void) => void;
|
|
9
|
-
onEnterCancelled: ({ nativeView: view }: Element) => void;
|
|
10
|
-
onLeaveCancelled: ({ nativeView: view }: Element) => void;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=reveal-motion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reveal-motion.d.ts","sourceRoot":"","sources":["../../src/vue/reveal-motion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAI9C,KAAK,OAAO,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,CAAA;AAEnC,2FAA2F;AAC3F,wBAAgB,eAAe;uBAauB,OAAO,QAAQ,MAAM,IAAI;uBAAzB,OAAO,QAAQ,MAAM,IAAI;6CAPvC,OAAO;6CAAP,OAAO;EA8C9C"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount } from 'nativescript-vue';
|
|
2
|
-
import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt';
|
|
3
|
-
import { revealMotion } from '@getcortexlabs/mavis-core';
|
|
4
|
-
/** Each transition owns its completion; an interrupted leave cannot finish a new entry. */
|
|
5
|
-
export function useRevealMotion() {
|
|
6
|
-
const entered = new WeakSet();
|
|
7
|
-
const active = new Map();
|
|
8
|
-
const cancel = ({ nativeView: view }) => {
|
|
9
|
-
const operation = active.get(view);
|
|
10
|
-
if (!operation)
|
|
11
|
-
return;
|
|
12
|
-
active.delete(view);
|
|
13
|
-
operation.remove();
|
|
14
|
-
operation.handle.stop();
|
|
15
|
-
};
|
|
16
|
-
const run = (phase) => (element, done) => {
|
|
17
|
-
const view = element.nativeView;
|
|
18
|
-
cancel(element);
|
|
19
|
-
if (phase === 'enter' && !entered.has(view)) {
|
|
20
|
-
entered.add(view);
|
|
21
|
-
set(view, { opacity: revealMotion.enter[0].opacity[0], y: revealMotion.enter[0].y[0] });
|
|
22
|
-
}
|
|
23
|
-
const handle = animate(view, phase === 'enter' ? { opacity: 1, y: 0 } : revealMotion.leave[0], revealMotion[phase][1]);
|
|
24
|
-
const unloaded = () => cancel(element);
|
|
25
|
-
const operation = { handle, phase, remove: () => view.off('unloaded', unloaded) };
|
|
26
|
-
active.set(view, operation);
|
|
27
|
-
view.on('unloaded', unloaded);
|
|
28
|
-
void handle.finished.then(() => {
|
|
29
|
-
if (active.get(view) !== operation)
|
|
30
|
-
return;
|
|
31
|
-
active.delete(view);
|
|
32
|
-
operation.remove();
|
|
33
|
-
done();
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
const offPreference = onReducedMotion((reduced) => {
|
|
37
|
-
if (reduced)
|
|
38
|
-
for (const [view, operation] of active) {
|
|
39
|
-
if (operation.phase === 'enter')
|
|
40
|
-
set(view, { y: 0 });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
onBeforeUnmount(() => {
|
|
44
|
-
offPreference();
|
|
45
|
-
for (const view of active.keys())
|
|
46
|
-
cancel({ nativeView: view });
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
onEnter: run('enter'),
|
|
50
|
-
onLeave: run('leave'),
|
|
51
|
-
onEnterCancelled: cancel,
|
|
52
|
-
onLeaveCancelled: cancel,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=reveal-motion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reveal-motion.js","sourceRoot":"","sources":["../../src/vue/reveal-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EA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EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;IACF,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;QACrB,gBAAgB,EAAE,MAAM;QACxB,gBAAgB,EAAE,MAAM;KACzB,CAAA;AACH,CAAC"}
|
package/src/vue/reveal-motion.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount } from 'nativescript-vue'
|
|
2
|
-
import type { View } from '@nativescript/core'
|
|
3
|
-
import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
4
|
-
import { revealMotion } from '@getcortexlabs/mavis-core'
|
|
5
|
-
|
|
6
|
-
type Element = { nativeView: View }
|
|
7
|
-
|
|
8
|
-
/** Each transition owns its completion; an interrupted leave cannot finish a new entry. */
|
|
9
|
-
export function useRevealMotion() {
|
|
10
|
-
const entered = new WeakSet<View>()
|
|
11
|
-
const active = new Map<
|
|
12
|
-
View,
|
|
13
|
-
{ handle: ReturnType<typeof animate>; phase: 'enter' | 'leave'; remove: () => void }
|
|
14
|
-
>()
|
|
15
|
-
const cancel = ({ nativeView: view }: Element) => {
|
|
16
|
-
const operation = active.get(view)
|
|
17
|
-
if (!operation) return
|
|
18
|
-
active.delete(view)
|
|
19
|
-
operation.remove()
|
|
20
|
-
operation.handle.stop()
|
|
21
|
-
}
|
|
22
|
-
const run = (phase: 'enter' | 'leave') => (element: Element, done: () => void) => {
|
|
23
|
-
const view = element.nativeView
|
|
24
|
-
cancel(element)
|
|
25
|
-
if (phase === 'enter' && !entered.has(view)) {
|
|
26
|
-
entered.add(view)
|
|
27
|
-
set(view, { opacity: revealMotion.enter[0].opacity[0], y: revealMotion.enter[0].y[0] })
|
|
28
|
-
}
|
|
29
|
-
const handle = animate(
|
|
30
|
-
view,
|
|
31
|
-
phase === 'enter' ? { opacity: 1, y: 0 } : revealMotion.leave[0],
|
|
32
|
-
revealMotion[phase][1],
|
|
33
|
-
)
|
|
34
|
-
const unloaded = () => cancel(element)
|
|
35
|
-
const operation = { handle, phase, remove: () => view.off('unloaded', unloaded) }
|
|
36
|
-
active.set(view, operation)
|
|
37
|
-
view.on('unloaded', unloaded)
|
|
38
|
-
void handle.finished.then(() => {
|
|
39
|
-
if (active.get(view) !== operation) return
|
|
40
|
-
active.delete(view)
|
|
41
|
-
operation.remove()
|
|
42
|
-
done()
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
const offPreference = onReducedMotion((reduced) => {
|
|
46
|
-
if (reduced)
|
|
47
|
-
for (const [view, operation] of active) {
|
|
48
|
-
if (operation.phase === 'enter') set(view, { y: 0 })
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
onBeforeUnmount(() => {
|
|
52
|
-
offPreference()
|
|
53
|
-
for (const view of active.keys()) cancel({ nativeView: view })
|
|
54
|
-
})
|
|
55
|
-
return {
|
|
56
|
-
onEnter: run('enter'),
|
|
57
|
-
onLeave: run('leave'),
|
|
58
|
-
onEnterCancelled: cancel,
|
|
59
|
-
onLeaveCancelled: cancel,
|
|
60
|
-
}
|
|
61
|
-
}
|