@getcortexlabs/mavis 0.1.0-alpha.7 → 0.1.0-alpha.9
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/date-format.android.d.ts +5 -0
- package/dist/date-format.android.d.ts.map +1 -0
- package/dist/date-format.android.js +39 -0
- package/dist/date-format.android.js.map +1 -0
- package/dist/date-format.d.ts +3 -0
- package/dist/date-format.d.ts.map +1 -0
- package/dist/date-format.ios.d.ts +5 -0
- package/dist/date-format.ios.d.ts.map +1 -0
- package/dist/date-format.ios.js +29 -0
- package/dist/date-format.ios.js.map +1 -0
- package/dist/date-format.js +2 -0
- package/dist/date-format.js.map +1 -0
- package/dist/native/collection-motion.d.ts +5 -0
- package/dist/native/collection-motion.d.ts.map +1 -0
- package/dist/native/collection-motion.js +157 -0
- package/dist/native/collection-motion.js.map +1 -0
- package/dist/native/date-format.android.d.ts +5 -0
- package/dist/native/date-format.android.d.ts.map +1 -0
- package/dist/native/date-format.android.js +39 -0
- package/dist/native/date-format.android.js.map +1 -0
- package/dist/native/date-format.d.ts +6 -0
- package/dist/native/date-format.d.ts.map +1 -0
- package/dist/native/date-format.ios.d.ts +5 -0
- package/dist/native/date-format.ios.d.ts.map +1 -0
- package/dist/native/date-format.ios.js +29 -0
- package/dist/native/date-format.ios.js.map +1 -0
- package/dist/native/date-format.js +8 -0
- package/dist/native/date-format.js.map +1 -0
- package/dist/native/image-effects.d.ts +11 -0
- package/dist/native/image-effects.d.ts.map +1 -0
- package/dist/native/image-effects.js +61 -0
- package/dist/native/image-effects.js.map +1 -0
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +7 -2
- package/dist/native/motion-region.js.map +1 -1
- package/dist/native/motion-surface.d.ts +2 -2
- package/dist/native/motion-surface.d.ts.map +1 -1
- package/dist/native/motion-surface.js +44 -1
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/platform-motion.d.ts +5 -0
- package/dist/native/platform-motion.d.ts.map +1 -0
- package/dist/native/platform-motion.js +90 -0
- package/dist/native/platform-motion.js.map +1 -0
- package/dist/native/surface-effects.d.ts +4 -0
- package/dist/native/surface-effects.d.ts.map +1 -0
- package/dist/native/surface-effects.js +31 -0
- package/dist/native/surface-effects.js.map +1 -0
- package/dist/native/visual-effects.d.ts +5 -0
- package/dist/native/visual-effects.d.ts.map +1 -0
- package/dist/native/visual-effects.js +126 -0
- package/dist/native/visual-effects.js.map +1 -0
- package/dist/vue/components/DateCalendar.d.ts +1 -1
- package/dist/vue/components/LoadingDecoration.d.ts +116 -0
- package/dist/vue/components/LoadingDecoration.d.ts.map +1 -0
- package/dist/vue/components/LoadingDecoration.js +34 -0
- package/dist/vue/components/LoadingDecoration.js.map +1 -0
- package/dist/vue/components/MAlert.d.ts +1 -1
- package/dist/vue/components/MAvatar.d.ts +1 -1
- package/dist/vue/components/MButton.d.ts +32 -10
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +33 -5
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +4 -4
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +4 -3
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MChip.d.ts +1 -1
- package/dist/vue/components/MCombobox.d.ts +2 -2
- package/dist/vue/components/MDatePicker.d.ts +56 -8
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MDatePicker.js +4 -14
- package/dist/vue/components/MDatePicker.js.map +1 -1
- package/dist/vue/components/MDialog.d.ts +3 -0
- package/dist/vue/components/MDialog.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.d.ts +1 -1
- package/dist/vue/components/MGrid.d.ts +165 -0
- package/dist/vue/components/MGrid.d.ts.map +1 -0
- package/dist/vue/components/MGrid.js +52 -0
- package/dist/vue/components/MGrid.js.map +1 -0
- package/dist/vue/components/MIcon.d.ts +18 -0
- package/dist/vue/components/MIcon.d.ts.map +1 -1
- package/dist/vue/components/MIcon.js +13 -2
- package/dist/vue/components/MIcon.js.map +1 -1
- package/dist/vue/components/MImage.d.ts +57 -1
- package/dist/vue/components/MImage.d.ts.map +1 -1
- package/dist/vue/components/MImage.js +58 -3
- package/dist/vue/components/MImage.js.map +1 -1
- package/dist/vue/components/MInput.d.ts +6 -6
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +15 -0
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MLink.d.ts +2 -2
- package/dist/vue/components/MLink.d.ts.map +1 -1
- package/dist/vue/components/MLink.js +6 -11
- package/dist/vue/components/MLink.js.map +1 -1
- package/dist/vue/components/MListItem.d.ts +1 -1
- package/dist/vue/components/MReveal.d.ts +9 -9
- package/dist/vue/components/MScreen.d.ts +11 -1
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +26 -4
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSelect.d.ts +1 -1
- package/dist/vue/components/MSheet.d.ts +13 -4
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MSkeleton.d.ts +12 -1
- package/dist/vue/components/MSkeleton.d.ts.map +1 -1
- package/dist/vue/components/MSkeleton.js +5 -3
- package/dist/vue/components/MSkeleton.js.map +1 -1
- package/dist/vue/components/MStack.d.ts +9 -9
- package/dist/vue/components/MText.d.ts +11 -0
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +3 -1
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/configurator.d.ts +3 -3
- package/dist/vue/components/layout.d.ts +30 -19
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +3 -1
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/index.d.ts +11 -11
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +12 -12
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/services.d.ts +16 -0
- package/dist/vue/services.d.ts.map +1 -0
- package/dist/vue/services.js +18 -0
- package/dist/vue/services.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +1 -1
- package/dist/vue/use-motion-surface.d.ts.map +1 -1
- package/dist/vue/use-motion-surface.js +31 -2
- package/dist/vue/use-motion-surface.js.map +1 -1
- package/package.json +15 -4
- package/src/date-format.ts +2 -0
- package/src/native/collection-motion.ts +166 -0
- package/src/native/date-format.android.ts +72 -0
- package/src/native/date-format.ios.ts +54 -0
- package/src/native/date-format.ts +17 -0
- package/src/native/image-effects.ts +71 -0
- package/src/native/motion-region.ts +7 -2
- package/src/native/motion-surface.ts +51 -2
- package/src/native/platform-motion.ts +103 -0
- package/src/native/surface-effects.ts +33 -0
- package/src/native/visual-effects.ts +147 -0
- package/src/vue/components/LoadingDecoration.ts +38 -0
- package/src/vue/components/MButton.ts +37 -4
- package/src/vue/components/MCard.ts +4 -2
- package/src/vue/components/MDatePicker.ts +3 -11
- package/src/vue/components/MGrid.ts +86 -0
- package/src/vue/components/MIcon.ts +14 -2
- package/src/vue/components/MImage.ts +66 -2
- package/src/vue/components/MInput.ts +14 -3
- package/src/vue/components/MLink.ts +12 -9
- package/src/vue/components/MScreen.ts +31 -3
- package/src/vue/components/MSkeleton.ts +5 -3
- package/src/vue/components/MText.ts +7 -0
- package/src/vue/components/layout.ts +3 -0
- package/src/vue/index.ts +63 -69
- package/src/vue/services.ts +32 -0
- package/src/vue/use-motion-surface.ts +32 -1
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps, onBeforeUnmount, ref } from 'nativescript-vue'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { type EventData, type View } from '@nativescript/core'
|
|
3
|
+
import { nativeDestination, navigateNative } from '../navigation.js'
|
|
4
|
+
import {
|
|
5
|
+
linkProps,
|
|
6
|
+
linkEmits,
|
|
7
|
+
textContent,
|
|
8
|
+
useMavisTheme,
|
|
9
|
+
useNavigationOptions,
|
|
10
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
5
11
|
import { MRow } from './layout.js'
|
|
6
12
|
import { MText } from './MText.js'
|
|
7
13
|
import { ActionChildren, useNativeViewAttrs } from '../accessibility.js'
|
|
@@ -14,6 +20,7 @@ export const MLink = defineComponent({
|
|
|
14
20
|
emits: linkEmits,
|
|
15
21
|
setup(props, { attrs, slots, emit }) {
|
|
16
22
|
const { theme } = useMavisTheme()
|
|
23
|
+
const navigation = useNavigationOptions(props)
|
|
17
24
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
18
25
|
const focused = ref(false)
|
|
19
26
|
let release: (() => void) | undefined
|
|
@@ -25,19 +32,15 @@ export const MLink = defineComponent({
|
|
|
25
32
|
onBeforeUnmount(clear)
|
|
26
33
|
const activate = async () => {
|
|
27
34
|
if (props.disabled) return
|
|
28
|
-
const href = linkDestination(props.href)
|
|
29
35
|
emit('click')
|
|
30
36
|
try {
|
|
31
|
-
|
|
32
|
-
else if (!(await Utils.openUrl(href))) throw new Error(`The system could not open ${href}.`)
|
|
37
|
+
await navigateNative(navigation())
|
|
33
38
|
} catch (error) {
|
|
34
39
|
emit('error', error)
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
return () => {
|
|
38
|
-
|
|
39
|
-
if (!props.navigate && !/^[a-z][a-z\d+.-]*:/i.test(href))
|
|
40
|
-
throw new TypeError('Native MLink needs a navigate handler for in-app destinations.')
|
|
43
|
+
nativeDestination(navigation())
|
|
41
44
|
const text = props.text ?? textContent(slots.default?.())
|
|
42
45
|
const label = props.accessibilityLabel ?? text
|
|
43
46
|
if (!label.trim()) throw new TypeError('MLink requires a name.')
|
|
@@ -3,12 +3,15 @@ import { useAppToastHost } from '@getcortexlabs/mavis-core/vue'
|
|
|
3
3
|
import { MToast } from './MToast.js'
|
|
4
4
|
import {
|
|
5
5
|
defineComponent,
|
|
6
|
+
cloneVNode,
|
|
7
|
+
Fragment,
|
|
6
8
|
h,
|
|
7
9
|
mergeProps,
|
|
8
10
|
onBeforeUnmount,
|
|
9
11
|
provide,
|
|
10
12
|
registerElement,
|
|
11
13
|
watch,
|
|
14
|
+
type VNode,
|
|
12
15
|
} from 'nativescript-vue'
|
|
13
16
|
import { isIOS, type EventData, type View } from '@nativescript/core'
|
|
14
17
|
import { screenProps, useMavisTheme, layoutDirection } from '@getcortexlabs/mavis-core/vue'
|
|
@@ -19,6 +22,7 @@ import { dismissKeyboardOn } from '../../native/keyboard-dismiss'
|
|
|
19
22
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
20
23
|
import { provideLayerHost } from '../layers.js'
|
|
21
24
|
import { expandLayerHost } from '../../native/sheet'
|
|
25
|
+
import { useMotionRegion } from '../use-motion-region.js'
|
|
22
26
|
|
|
23
27
|
registerElement('MavisScreenScroll', () => MavisScreenScroll, {
|
|
24
28
|
// NSVViewFlags.CONTENT_VIEW; ScrollView owns one content view.
|
|
@@ -27,11 +31,29 @@ registerElement('MavisScreenScroll', () => MavisScreenScroll, {
|
|
|
27
31
|
// NSVViewFlags.LAYOUT_VIEW; the page container also puts the keyboard away.
|
|
28
32
|
registerElement('MavisScreen', () => MavisScreen, { viewFlags: 4 })
|
|
29
33
|
|
|
34
|
+
// Overlay children must remain siblings of the ScrollView for retained headers.
|
|
35
|
+
function placeOverlay(node: VNode, covered: boolean): VNode {
|
|
36
|
+
if (node.type !== Fragment)
|
|
37
|
+
return cloneVNode(node, {
|
|
38
|
+
iosOverflowSafeArea: false,
|
|
39
|
+
...(covered ? { accessibilityHidden: true } : {}),
|
|
40
|
+
})
|
|
41
|
+
const copy = cloneVNode(node)
|
|
42
|
+
if (Array.isArray(copy.children))
|
|
43
|
+
copy.children = copy.children.map((child) =>
|
|
44
|
+
child && typeof child === 'object' && 'type' in child
|
|
45
|
+
? placeOverlay(child as VNode, covered)
|
|
46
|
+
: child,
|
|
47
|
+
)
|
|
48
|
+
return copy
|
|
49
|
+
}
|
|
50
|
+
|
|
30
51
|
export const MScreen = defineComponent({
|
|
31
52
|
name: 'MScreen',
|
|
32
53
|
inheritAttrs: false,
|
|
33
54
|
props: screenProps,
|
|
34
55
|
setup(props, { attrs, slots }) {
|
|
56
|
+
const region = useMotionRegion(() => props.motionRegion)
|
|
35
57
|
const scrollMotion = useScrollMotion(() => props.motionScroll)
|
|
36
58
|
const { theme } = useMavisTheme()
|
|
37
59
|
const appToast = useAppToastHost()
|
|
@@ -60,7 +82,12 @@ export const MScreen = defineComponent({
|
|
|
60
82
|
// Page and ScrollView require one content view; the column also accepts multiple slot children.
|
|
61
83
|
const content = h(
|
|
62
84
|
MColumn,
|
|
63
|
-
{
|
|
85
|
+
{
|
|
86
|
+
accessibilityHidden: props.scroll ? undefined : covered,
|
|
87
|
+
// The retained scroll header reserves its spacer on this private host.
|
|
88
|
+
// Core's unset padding is not a numeric DIP value in every runtime.
|
|
89
|
+
style: { paddingTop: 0 },
|
|
90
|
+
},
|
|
64
91
|
{
|
|
65
92
|
default: () => [
|
|
66
93
|
slots.default?.(),
|
|
@@ -85,7 +112,7 @@ export const MScreen = defineComponent({
|
|
|
85
112
|
[
|
|
86
113
|
h(
|
|
87
114
|
'MavisScreen',
|
|
88
|
-
{
|
|
115
|
+
mergeProps(region, {
|
|
89
116
|
...(isIOS ? { clipToBounds: false } : {}),
|
|
90
117
|
onLoaded: (event: EventData) => {
|
|
91
118
|
container = event.object as View
|
|
@@ -96,7 +123,7 @@ export const MScreen = defineComponent({
|
|
|
96
123
|
release = undefined
|
|
97
124
|
container = undefined
|
|
98
125
|
},
|
|
99
|
-
},
|
|
126
|
+
}),
|
|
100
127
|
[
|
|
101
128
|
props.scroll
|
|
102
129
|
? h(
|
|
@@ -105,6 +132,7 @@ export const MScreen = defineComponent({
|
|
|
105
132
|
[content],
|
|
106
133
|
)
|
|
107
134
|
: content,
|
|
135
|
+
slots.overlay?.().map((node) => placeOverlay(node, covered)),
|
|
108
136
|
...notices.map((layer) =>
|
|
109
137
|
h(layer.component, { ...layer.props, covered, key: layer.key }),
|
|
110
138
|
),
|
|
@@ -3,6 +3,7 @@ import { Application, type EventData, type View } from '@nativescript/core'
|
|
|
3
3
|
import { animate, onReducedMotion, reducedMotion, set } from '@rafaelaugusto/jolt'
|
|
4
4
|
import { skeletonProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
5
5
|
import { MBox } from './layout.js'
|
|
6
|
+
import { LoadingDecoration } from './LoadingDecoration.js'
|
|
6
7
|
|
|
7
8
|
export const MSkeleton = defineComponent({
|
|
8
9
|
name: 'MSkeleton',
|
|
@@ -71,7 +72,7 @@ export const MSkeleton = defineComponent({
|
|
|
71
72
|
|
|
72
73
|
return () =>
|
|
73
74
|
h(
|
|
74
|
-
MBox,
|
|
75
|
+
props.effect === 'shimmer' ? LoadingDecoration : MBox,
|
|
75
76
|
mergeProps(
|
|
76
77
|
{
|
|
77
78
|
style: {
|
|
@@ -91,8 +92,9 @@ export const MSkeleton = defineComponent({
|
|
|
91
92
|
accessible: false,
|
|
92
93
|
accessibilityHidden: true,
|
|
93
94
|
isUserInteractionEnabled: false,
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
...(props.effect === 'shimmer'
|
|
96
|
+
? { kind: 'shimmer', animated: props.animated }
|
|
97
|
+
: { onLoaded: loaded, onUnloaded: release }),
|
|
96
98
|
},
|
|
97
99
|
),
|
|
98
100
|
)
|
|
@@ -9,6 +9,7 @@ import { fontFamily, nonNegative, validateWeight } from '@getcortexlabs/mavis-co
|
|
|
9
9
|
import { isAndroid } from '@nativescript/core'
|
|
10
10
|
import { MavisLabel } from '../../native/label'
|
|
11
11
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
12
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
12
13
|
|
|
13
14
|
registerElement('MavisLabel', () => MavisLabel)
|
|
14
15
|
|
|
@@ -20,6 +21,11 @@ export const MText = defineComponent({
|
|
|
20
21
|
const { theme } = useMavisTheme()
|
|
21
22
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
22
23
|
const shrink = useLayoutShrink()
|
|
24
|
+
const motion = useMotionSurface(
|
|
25
|
+
() => props.motionSurface,
|
|
26
|
+
() => true,
|
|
27
|
+
() => props.text !== undefined,
|
|
28
|
+
)
|
|
23
29
|
return () => {
|
|
24
30
|
const type = theme.value.typography[props.variant]
|
|
25
31
|
const runs =
|
|
@@ -52,6 +58,7 @@ export const MText = defineComponent({
|
|
|
52
58
|
},
|
|
53
59
|
nativeAttrs(),
|
|
54
60
|
attrs,
|
|
61
|
+
{ onLoaded: motion.onLoaded, onUnloaded: motion.onUnloaded },
|
|
55
62
|
),
|
|
56
63
|
formatted
|
|
57
64
|
? [
|
|
@@ -13,6 +13,7 @@ import { MavisFlexLayout } from '../../native/flex-layout'
|
|
|
13
13
|
import { MavisBox } from '../../native/box'
|
|
14
14
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
15
15
|
import { useMotionRegion } from '../use-motion-region.js'
|
|
16
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
16
17
|
|
|
17
18
|
export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
|
|
18
19
|
|
|
@@ -79,6 +80,7 @@ export const MBox = defineComponent({
|
|
|
79
80
|
props: motionBoxProps,
|
|
80
81
|
setup(props, { attrs, slots }) {
|
|
81
82
|
const region = useMotionRegion(() => props.motionRegion)
|
|
83
|
+
const surface = useMotionSurface(() => props.motionSurface)
|
|
82
84
|
const { theme } = useMavisTheme()
|
|
83
85
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
84
86
|
const shrink = useLayoutShrink()
|
|
@@ -90,6 +92,7 @@ export const MBox = defineComponent({
|
|
|
90
92
|
nativeAttrs(),
|
|
91
93
|
attrs,
|
|
92
94
|
region,
|
|
95
|
+
{ onLoaded: surface.onLoaded, onUnloaded: surface.onUnloaded },
|
|
93
96
|
),
|
|
94
97
|
slots.default?.(),
|
|
95
98
|
)
|
package/src/vue/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
2
2
|
import { MImage } from './components/MImage.js'
|
|
3
3
|
import { MStack } from './components/MStack.js'
|
|
4
|
+
import { MGrid } from './components/MGrid.js'
|
|
4
5
|
import { MLink } from './components/MLink.js'
|
|
5
6
|
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
6
7
|
import { MCombobox } from './components/MCombobox.js'
|
|
@@ -8,16 +9,11 @@ import { MFilePicker } from './components/MFilePicker.js'
|
|
|
8
9
|
import { MFormGroup, MFormErrors, MSteps, MPagination } from './components/workflows.js'
|
|
9
10
|
import { MChip } from './components/MChip.js'
|
|
10
11
|
import { MEmptyState } from './components/MEmptyState.js'
|
|
11
|
-
import type { App } from 'nativescript-vue'
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
installAppToast,
|
|
17
|
-
themeKey,
|
|
18
|
-
type ThemeContextOptions,
|
|
19
|
-
} from '@getcortexlabs/mavis-core/vue'
|
|
20
|
-
import { systemAppearance } from '../native/appearance'
|
|
12
|
+
import type { App, Component } from 'nativescript-vue'
|
|
13
|
+
import { createMavisServices, type MavisServiceOptions } from './services.js'
|
|
14
|
+
export { createMavisServices } from './services.js'
|
|
15
|
+
export type { MavisServiceOptions } from './services.js'
|
|
16
|
+
import { MThemeProvider, MSpan } from '@getcortexlabs/mavis-core/vue'
|
|
21
17
|
import { MScreen } from './components/MScreen.js'
|
|
22
18
|
import { MBox, MRow, MColumn } from './components/layout.js'
|
|
23
19
|
import { MCard } from './components/MCard.js'
|
|
@@ -44,7 +40,7 @@ import { MInput } from './components/MInput.js'
|
|
|
44
40
|
import { MIcon } from './components/MIcon.js'
|
|
45
41
|
import { MReveal } from './components/MReveal.js'
|
|
46
42
|
import { MSheet } from './components/MSheet.js'
|
|
47
|
-
import {
|
|
43
|
+
import type { ClaimSystemBack, SystemBackClaimant } from './system-back.js'
|
|
48
44
|
|
|
49
45
|
export {
|
|
50
46
|
MThemeProvider,
|
|
@@ -54,6 +50,7 @@ export {
|
|
|
54
50
|
MRow,
|
|
55
51
|
MColumn,
|
|
56
52
|
MStack,
|
|
53
|
+
MGrid,
|
|
57
54
|
MLink,
|
|
58
55
|
MCard,
|
|
59
56
|
MText,
|
|
@@ -99,6 +96,7 @@ export {
|
|
|
99
96
|
useFormController,
|
|
100
97
|
useFormField,
|
|
101
98
|
useFileSelection,
|
|
99
|
+
useMavisNavigation,
|
|
102
100
|
} from '@getcortexlabs/mavis-core/vue'
|
|
103
101
|
export type {
|
|
104
102
|
MavisThemeContext,
|
|
@@ -111,69 +109,65 @@ export type {} from '@getcortexlabs/mavis-core/vue'
|
|
|
111
109
|
|
|
112
110
|
export type { SystemBackClaimant, ClaimSystemBack }
|
|
113
111
|
|
|
114
|
-
export type MavisOptions =
|
|
115
|
-
toast?: { closeLabel?: string }
|
|
116
|
-
/** Lets a router hand the Android back press to an open sheet first, e.g. vue-router-ns `claimSystemBack`. */
|
|
117
|
-
claimSystemBack?: ClaimSystemBack
|
|
118
|
-
}
|
|
112
|
+
export type MavisOptions = MavisServiceOptions & { components?: false | Record<string, Component> }
|
|
119
113
|
|
|
120
114
|
/** Create one plugin per application; `system` appearance follows the device. Vue also resolves MButton as <m-button>. */
|
|
121
115
|
export function createMavis(options: MavisOptions = {}) {
|
|
122
116
|
return {
|
|
123
117
|
install(app: App) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
118
|
+
const { components, ...services } = options
|
|
119
|
+
createMavisServices(services).install(app)
|
|
120
|
+
if (components === false) return
|
|
121
|
+
for (const [name, component] of Object.entries(
|
|
122
|
+
components ?? {
|
|
123
|
+
MThemeProvider,
|
|
124
|
+
MSpan,
|
|
125
|
+
MScreen,
|
|
126
|
+
MBox,
|
|
127
|
+
MRow,
|
|
128
|
+
MColumn,
|
|
129
|
+
MStack,
|
|
130
|
+
MGrid,
|
|
131
|
+
MLink,
|
|
132
|
+
MCard,
|
|
133
|
+
MText,
|
|
134
|
+
MButton,
|
|
135
|
+
MSlider,
|
|
136
|
+
MSwitch,
|
|
137
|
+
MCheckbox,
|
|
138
|
+
MRadioGroup,
|
|
139
|
+
MSelect,
|
|
140
|
+
MToast,
|
|
141
|
+
MDialog,
|
|
142
|
+
MTabs,
|
|
143
|
+
MSkeleton,
|
|
144
|
+
MChip,
|
|
145
|
+
MEmptyState,
|
|
146
|
+
MProgress,
|
|
147
|
+
MAccordion,
|
|
148
|
+
MSegmentedControl,
|
|
149
|
+
MAlert,
|
|
150
|
+
MListItem,
|
|
151
|
+
MSeparator,
|
|
152
|
+
MAvatar,
|
|
153
|
+
MBadge,
|
|
154
|
+
MInput,
|
|
155
|
+
MIcon,
|
|
156
|
+
MReveal,
|
|
157
|
+
MSheet,
|
|
158
|
+
MDatePicker,
|
|
159
|
+
MDateRangePicker,
|
|
160
|
+
MNumberInput,
|
|
161
|
+
MMultiSelect,
|
|
162
|
+
MImage,
|
|
163
|
+
MCombobox,
|
|
164
|
+
MFilePicker,
|
|
165
|
+
MFormGroup,
|
|
166
|
+
MFormErrors,
|
|
167
|
+
MSteps,
|
|
168
|
+
MPagination,
|
|
169
|
+
},
|
|
170
|
+
)) {
|
|
177
171
|
app.component(name, component)
|
|
178
172
|
}
|
|
179
173
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { App } from 'nativescript-vue'
|
|
2
|
+
import type { MavisNavigation } from '@getcortexlabs/mavis-core'
|
|
3
|
+
import {
|
|
4
|
+
createThemeContext,
|
|
5
|
+
installAppToast,
|
|
6
|
+
themeKey,
|
|
7
|
+
navigationKey,
|
|
8
|
+
type ThemeContextOptions,
|
|
9
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
10
|
+
import { systemAppearance } from '../native/appearance'
|
|
11
|
+
import { systemBackKey, type ClaimSystemBack } from './system-back.js'
|
|
12
|
+
|
|
13
|
+
export type MavisServiceOptions = Omit<ThemeContextOptions, 'source'> & {
|
|
14
|
+
toast?: { closeLabel?: string }
|
|
15
|
+
claimSystemBack?: ClaimSystemBack
|
|
16
|
+
navigation?: MavisNavigation
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Application-owned services without global component registration. */
|
|
20
|
+
export function createMavisServices(options: MavisServiceOptions = {}) {
|
|
21
|
+
return {
|
|
22
|
+
install(app: App) {
|
|
23
|
+
installAppToast(app, options.toast)
|
|
24
|
+
const { toast: _toast, claimSystemBack, navigation, ...theme } = options
|
|
25
|
+
const context = createThemeContext({ ...theme, source: systemAppearance() })
|
|
26
|
+
app.provide(themeKey, context)
|
|
27
|
+
app.provide(systemBackKey, claimSystemBack)
|
|
28
|
+
app.provide(navigationKey, navigation)
|
|
29
|
+
app.onUnmount(() => context.dispose())
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -12,12 +12,20 @@ import { nativeMotionOwner } from '../native/motion-owner.js'
|
|
|
12
12
|
export function useMotionSurface(
|
|
13
13
|
surface: () => MotionSurface | undefined,
|
|
14
14
|
enabled: () => boolean = () => true,
|
|
15
|
+
plainText: () => boolean = () => false,
|
|
16
|
+
afterLayout = false,
|
|
15
17
|
) {
|
|
16
18
|
let view: View | undefined
|
|
17
19
|
let unbind: (() => void) | undefined
|
|
18
20
|
let offPreference: (() => void) | undefined
|
|
19
21
|
let continuous: ReturnType<typeof nativeContinuousSurface> | undefined
|
|
20
22
|
const active = new Map<ReturnType<typeof animate>, MotionFrames>()
|
|
23
|
+
let layoutView: View | undefined
|
|
24
|
+
let layoutQueued = false
|
|
25
|
+
const clearLayout = () => {
|
|
26
|
+
layoutView?.off('layoutChanged', laidOut)
|
|
27
|
+
layoutView = undefined
|
|
28
|
+
}
|
|
21
29
|
const release = () => {
|
|
22
30
|
unbind?.()
|
|
23
31
|
unbind = undefined
|
|
@@ -32,7 +40,21 @@ export function useMotionSurface(
|
|
|
32
40
|
const target = view
|
|
33
41
|
const reference = surface()
|
|
34
42
|
if (!target || !reference) return
|
|
35
|
-
|
|
43
|
+
if (
|
|
44
|
+
afterLayout &&
|
|
45
|
+
(!target.isLayoutValid ||
|
|
46
|
+
target.getActualSize().width <= 0 ||
|
|
47
|
+
target.getActualSize().height <= 0)
|
|
48
|
+
) {
|
|
49
|
+
if (layoutView !== target) {
|
|
50
|
+
clearLayout()
|
|
51
|
+
layoutView = target
|
|
52
|
+
target.on('layoutChanged', laidOut)
|
|
53
|
+
}
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
clearLayout()
|
|
57
|
+
continuous = nativeContinuousSurface(target, enabled, plainText)
|
|
36
58
|
unbind = bindMotionSurface(
|
|
37
59
|
reference,
|
|
38
60
|
nativeMotionOwner(
|
|
@@ -66,7 +88,16 @@ export function useMotionSurface(
|
|
|
66
88
|
if (Object.keys(values).length) set(target, values)
|
|
67
89
|
})
|
|
68
90
|
}
|
|
91
|
+
const laidOut = () => {
|
|
92
|
+
if (layoutQueued) return
|
|
93
|
+
layoutQueued = true
|
|
94
|
+
void Promise.resolve().then(() => {
|
|
95
|
+
layoutQueued = false
|
|
96
|
+
if (view) bind()
|
|
97
|
+
})
|
|
98
|
+
}
|
|
69
99
|
const unloaded = () => {
|
|
100
|
+
clearLayout()
|
|
70
101
|
release()
|
|
71
102
|
view = undefined
|
|
72
103
|
}
|