@getcortexlabs/mavis 0.1.0-alpha.8 → 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 +4 -2
- 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/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/vue/components/DateCalendar.d.ts +1 -1
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +4 -3
- package/dist/vue/components/MButton.js.map +1 -1
- 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/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/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/MImage.d.ts +45 -0
- package/dist/vue/components/MImage.d.ts.map +1 -1
- package/dist/vue/components/MInput.d.ts +2 -2
- 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.map +1 -1
- package/dist/vue/components/MLink.js +6 -11
- package/dist/vue/components/MLink.js.map +1 -1
- package/dist/vue/components/MSheet.d.ts +9 -0
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/configurator.d.ts +3 -3
- 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/package.json +14 -3
- package/src/date-format.ts +2 -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/vue/components/MButton.ts +4 -2
- 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/MInput.ts +14 -3
- package/src/vue/components/MLink.ts +12 -9
- package/src/vue/index.ts +63 -69
- package/src/vue/services.ts +32 -0
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useButtonAction,
|
|
7
7
|
cardProps,
|
|
8
8
|
useMavisTheme,
|
|
9
|
+
useNavigationOptions,
|
|
9
10
|
actionEmits,
|
|
10
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
11
12
|
import { MColumn } from './layout.js'
|
|
@@ -20,6 +21,7 @@ export const MCard = defineComponent({
|
|
|
20
21
|
setup(props, { attrs, slots, emit }) {
|
|
21
22
|
useButtonAction(() => props.interactive || props.href !== undefined)
|
|
22
23
|
const { theme } = useMavisTheme()
|
|
24
|
+
const navigation = useNavigationOptions(props)
|
|
23
25
|
const enabled = () => (props.interactive || props.href !== undefined) && !props.disabled
|
|
24
26
|
const lifecycle = usePressFeedback(enabled, theme)
|
|
25
27
|
const { allowsActivation, ...surface } = useMotionSurface(
|
|
@@ -39,7 +41,7 @@ export const MCard = defineComponent({
|
|
|
39
41
|
...layout
|
|
40
42
|
} = props
|
|
41
43
|
const interactive = action || href !== undefined
|
|
42
|
-
if (href !== undefined) nativeDestination(
|
|
44
|
+
if (href !== undefined) nativeDestination(navigation())
|
|
43
45
|
const tokens = theme.value.components.card
|
|
44
46
|
layout.padding ??= tokens.padding
|
|
45
47
|
layout.radius ??= tokens.radius
|
|
@@ -71,7 +73,7 @@ export const MCard = defineComponent({
|
|
|
71
73
|
if (enabled() && allowsActivation()) {
|
|
72
74
|
emit('click')
|
|
73
75
|
if (href !== undefined)
|
|
74
|
-
void navigateNative(
|
|
76
|
+
void navigateNative(navigation()).catch((error) => emit('error', error))
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
: undefined,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { Utils
|
|
1
|
+
import { Utils } from '@nativescript/core'
|
|
2
2
|
import { createDatePickers } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { MInput } from './MInput.js'
|
|
4
4
|
import { MButton } from './MButton.js'
|
|
5
5
|
import { MColumn, MRow } from './layout.js'
|
|
6
6
|
import { MSheet } from './MSheet.js'
|
|
7
7
|
import { DateCalendar } from './DateCalendar.js'
|
|
8
|
-
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
9
8
|
|
|
10
9
|
function focusOpener(opener: unknown) {
|
|
11
|
-
|
|
12
|
-
view?.focus()
|
|
10
|
+
;(opener as { focusAction?: () => void } | undefined)?.focusAction?.()
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export const { MDatePicker, MDateRangePicker } = createDatePickers({
|
|
@@ -23,11 +21,5 @@ export const { MDatePicker, MDateRangePicker } = createDatePickers({
|
|
|
23
21
|
Utils.dismissKeyboard()
|
|
24
22
|
focusOpener(opener)
|
|
25
23
|
},
|
|
26
|
-
afterClose:
|
|
27
|
-
const view = (opener as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView
|
|
28
|
-
if (!view?.isLoaded) return
|
|
29
|
-
view.focus()
|
|
30
|
-
if (isAndroid) view.android.performAccessibilityAction(64, null)
|
|
31
|
-
else notifyAccessibilityLayout(view)
|
|
32
|
-
},
|
|
24
|
+
afterClose: focusOpener,
|
|
33
25
|
})
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Comment,
|
|
3
|
+
Fragment,
|
|
4
|
+
Text,
|
|
5
|
+
createVNode,
|
|
6
|
+
defineComponent,
|
|
7
|
+
h,
|
|
8
|
+
mergeProps,
|
|
9
|
+
provide,
|
|
10
|
+
shallowRef,
|
|
11
|
+
type VNode,
|
|
12
|
+
} from 'nativescript-vue'
|
|
13
|
+
import type { EventData, View } from '@nativescript/core'
|
|
14
|
+
import { gridColumns, resolveSpace } from '@getcortexlabs/mavis-core'
|
|
15
|
+
import {
|
|
16
|
+
gridProps,
|
|
17
|
+
layoutDirection,
|
|
18
|
+
useLayoutShrink,
|
|
19
|
+
useMavisTheme,
|
|
20
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
21
|
+
import { boxStyle } from '../props.js'
|
|
22
|
+
import { useNativeViewAttrs } from '../accessibility.js'
|
|
23
|
+
import './layout.js'
|
|
24
|
+
|
|
25
|
+
export const MGrid = defineComponent({
|
|
26
|
+
name: 'MGrid',
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
props: gridProps,
|
|
29
|
+
setup(props, { attrs, slots }) {
|
|
30
|
+
const { theme } = useMavisTheme()
|
|
31
|
+
const shrink = useLayoutShrink()
|
|
32
|
+
const nativeAttrs = useNativeViewAttrs(props)
|
|
33
|
+
provide(layoutDirection, 'column')
|
|
34
|
+
const width = shallowRef<number>()
|
|
35
|
+
return () => {
|
|
36
|
+
const gap = resolveSpace(theme.value, props.gap ?? 'none')
|
|
37
|
+
const count = gridColumns(props.columns, props.minColumnWidth, gap, width.value)
|
|
38
|
+
let index = 0
|
|
39
|
+
// Keep fragment boundaries so independently keyed slot groups retain their identity.
|
|
40
|
+
const place = (nodes: VNode[]): VNode[] =>
|
|
41
|
+
nodes.flatMap((child) => {
|
|
42
|
+
if (child.type === Fragment)
|
|
43
|
+
return [
|
|
44
|
+
createVNode(
|
|
45
|
+
Fragment,
|
|
46
|
+
{ key: child.key ?? undefined },
|
|
47
|
+
place(child.children as VNode[]),
|
|
48
|
+
),
|
|
49
|
+
]
|
|
50
|
+
if (child.type === Comment || (child.type === Text && !String(child.children).trim()))
|
|
51
|
+
return []
|
|
52
|
+
const cell = index++
|
|
53
|
+
return [
|
|
54
|
+
h(
|
|
55
|
+
'MavisBox',
|
|
56
|
+
{
|
|
57
|
+
key: child.key ?? cell,
|
|
58
|
+
col: (cell % count) * 2,
|
|
59
|
+
row: Math.floor(cell / count) * 2,
|
|
60
|
+
},
|
|
61
|
+
[child],
|
|
62
|
+
),
|
|
63
|
+
]
|
|
64
|
+
})
|
|
65
|
+
const children = place(slots.default?.() ?? [])
|
|
66
|
+
const rows = Math.ceil(index / count)
|
|
67
|
+
return h(
|
|
68
|
+
'MavisBox',
|
|
69
|
+
mergeProps({ style: boxStyle(theme.value, props, shrink.value) }, nativeAttrs(), attrs),
|
|
70
|
+
[
|
|
71
|
+
h(
|
|
72
|
+
'GridLayout',
|
|
73
|
+
{
|
|
74
|
+
columns: Array.from({ length: count }, () => '*').join(`,${gap},`),
|
|
75
|
+
rows: Array.from({ length: rows }, () => 'auto').join(`,${gap},`),
|
|
76
|
+
onLayoutChanged: (event: EventData) => {
|
|
77
|
+
width.value = (event.object as View).getActualSize().width
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
children,
|
|
81
|
+
),
|
|
82
|
+
],
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
})
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
resolveDimension,
|
|
26
26
|
iconSizes,
|
|
27
27
|
inputActionSize,
|
|
28
|
-
type
|
|
28
|
+
type InputActionHandle,
|
|
29
29
|
} from '@getcortexlabs/mavis-core'
|
|
30
30
|
import { isAndroid } from '@nativescript/core'
|
|
31
31
|
import type { EventData, PropertyChangeData, TextField, TextView, View } from '@nativescript/core'
|
|
@@ -36,6 +36,7 @@ import { MIcon } from './MIcon.js'
|
|
|
36
36
|
import { MButton } from './MButton.js'
|
|
37
37
|
import { keepEditingOn } from '../../native/input-action'
|
|
38
38
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
39
|
+
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
39
40
|
|
|
40
41
|
registerElement('MavisTextField', () => MavisTextField)
|
|
41
42
|
registerElement('MavisTextView', () => MavisTextView)
|
|
@@ -52,6 +53,7 @@ const Input = defineComponent({
|
|
|
52
53
|
provide(layoutDirection, 'column')
|
|
53
54
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
54
55
|
const editor = shallowRef<{ nativeView: TextField | TextView }>()
|
|
56
|
+
const actionButton = shallowRef<{ $el?: { nativeView?: View } }>()
|
|
55
57
|
const focused = ref(false)
|
|
56
58
|
let focusFeedback: ReturnType<typeof setTimeout> | undefined
|
|
57
59
|
function cancelFocusFeedback() {
|
|
@@ -79,11 +81,19 @@ const Input = defineComponent({
|
|
|
79
81
|
},
|
|
80
82
|
)
|
|
81
83
|
expose({
|
|
84
|
+
focusAction: () => {
|
|
85
|
+
if (props.disabled || props.readonly || props.trailingAction?.disabled) return
|
|
86
|
+
const view = actionButton.value?.$el?.nativeView
|
|
87
|
+
if (!view?.isLoaded) return
|
|
88
|
+
view.focus()
|
|
89
|
+
if (isAndroid) view.android?.performAccessibilityAction(64, null)
|
|
90
|
+
else notifyAccessibilityLayout(view)
|
|
91
|
+
},
|
|
82
92
|
focus: () => {
|
|
83
93
|
if (!props.disabled && !props.readonly) editor.value?.nativeView.focus()
|
|
84
94
|
},
|
|
85
95
|
blur,
|
|
86
|
-
} satisfies
|
|
96
|
+
} satisfies InputActionHandle)
|
|
87
97
|
|
|
88
98
|
return () => {
|
|
89
99
|
validateInput(props)
|
|
@@ -238,6 +248,7 @@ const Input = defineComponent({
|
|
|
238
248
|
icon(props.trailingIcon, true),
|
|
239
249
|
action
|
|
240
250
|
? h(MButton, {
|
|
251
|
+
ref: actionButton,
|
|
241
252
|
row: 1,
|
|
242
253
|
icon: action.icon,
|
|
243
254
|
accessibilityLabel: action.label,
|
|
@@ -282,5 +293,5 @@ const Input = defineComponent({
|
|
|
282
293
|
|
|
283
294
|
// Keep the constructor declaration aligned with the portable handle exposed above.
|
|
284
295
|
export const MInput = Input as typeof Input & {
|
|
285
|
-
new (): InstanceType<typeof Input> &
|
|
296
|
+
new (): InstanceType<typeof Input> & InputActionHandle
|
|
286
297
|
}
|
|
@@ -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.')
|
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
|
+
}
|