@getcortexlabs/mavis 0.1.0-alpha.6 → 0.1.0-alpha.8
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 -5
- 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/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-owner.d.ts.map +1 -1
- package/dist/native/motion-owner.js +1 -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 +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 +55 -2
- 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/press.d.ts +2 -0
- 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/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/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/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/MBadge.d.ts +1 -1
- package/dist/vue/components/MButton.d.ts +36 -14
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +29 -2
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +6 -6
- package/dist/vue/components/MChip.d.ts +3 -3
- package/dist/vue/components/MCombobox.d.ts +2 -2
- package/dist/vue/components/MDatePicker.d.ts +16 -16
- package/dist/vue/components/MDialog.d.ts +4 -1
- package/dist/vue/components/MDialog.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.d.ts +2 -2
- package/dist/vue/components/MFilePicker.d.ts +2 -2
- package/dist/vue/components/MIcon.d.ts +19 -1
- 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 +203 -0
- package/dist/vue/components/MImage.d.ts.map +1 -0
- package/dist/vue/components/MImage.js +157 -0
- package/dist/vue/components/MImage.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +4 -4
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +9 -5
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MLink.d.ts +3 -3
- package/dist/vue/components/MListItem.d.ts +1 -1
- package/dist/vue/components/MProgress.d.ts +2 -2
- package/dist/vue/components/MReveal.d.ts +11 -11
- 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 +4 -4
- package/dist/vue/components/MSkeleton.d.ts +11 -0
- 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 +11 -11
- 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.d.ts +15 -4
- 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 +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 +35 -24
- 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/components/workflows.d.ts +1 -1
- package/dist/vue/index.d.ts +3 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +6 -1
- package/dist/vue/index.js.map +1 -1
- 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-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 +3 -3
- package/src/native/collection-motion.ts +166 -0
- package/src/native/image-effects.ts +71 -0
- package/src/native/motion-owner.ts +1 -0
- package/src/native/motion-region.ts +7 -2
- package/src/native/motion-surface.ts +63 -3
- package/src/native/platform-motion.ts +103 -0
- package/src/native/press.ts +6 -0
- package/src/native/surface-effects.ts +33 -0
- package/src/native/visual-effects.ts +147 -0
- package/src/vue/components/ChoiceControl.ts +25 -5
- package/src/vue/components/LoadingDecoration.ts +38 -0
- package/src/vue/components/MButton.ts +33 -2
- package/src/vue/components/MIcon.ts +14 -2
- package/src/vue/components/MImage.ts +181 -0
- package/src/vue/components/MInput.ts +9 -5
- package/src/vue/components/MScreen.ts +31 -3
- package/src/vue/components/MSkeleton.ts +5 -3
- package/src/vue/components/MSwitch.ts +16 -3
- package/src/vue/components/MText.ts +7 -0
- package/src/vue/components/configurator.ts +27 -0
- package/src/vue/components/layout.ts +3 -0
- package/src/vue/index.ts +8 -0
- package/src/vue/use-choice-paint.ts +39 -0
- package/src/vue/use-motion-surface.ts +32 -1
- 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 -58
- package/dist/vue/reveal-motion.js.map +0 -1
|
@@ -39,8 +39,11 @@ import { useMotionSurface } from '../use-motion-surface.js'
|
|
|
39
39
|
import { usePressFeedback } from '../use-press.js'
|
|
40
40
|
import { MavisButton } from '../../native/button'
|
|
41
41
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
42
|
+
import { LoadingDecoration } from './LoadingDecoration.js'
|
|
43
|
+
import { ReorderHandle } from '@rafaelaugusto/jolt/reorder'
|
|
42
44
|
|
|
43
45
|
registerElement('MavisButton', () => MavisButton)
|
|
46
|
+
registerElement('MavisReorderHandle', () => ReorderHandle)
|
|
44
47
|
|
|
45
48
|
export const MButton = defineComponent({
|
|
46
49
|
name: 'MButton',
|
|
@@ -76,6 +79,18 @@ export const MButton = defineComponent({
|
|
|
76
79
|
void navigateNative(props).catch((error) => emit('error', error))
|
|
77
80
|
}
|
|
78
81
|
return () => {
|
|
82
|
+
if (
|
|
83
|
+
props.reorderHandle &&
|
|
84
|
+
(slots.leading ||
|
|
85
|
+
slots.trailing ||
|
|
86
|
+
props.icon ||
|
|
87
|
+
props.trailingIcon ||
|
|
88
|
+
props.href ||
|
|
89
|
+
props.loadingIndicator !== 'none')
|
|
90
|
+
)
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
'A reorder handle requires a plain-text MButton without navigation or adornments.',
|
|
93
|
+
)
|
|
79
94
|
if (props.href !== undefined) nativeDestination(props)
|
|
80
95
|
const { colors, control, radius } = theme.value
|
|
81
96
|
const tokens = theme.value.components.button
|
|
@@ -90,8 +105,12 @@ export const MButton = defineComponent({
|
|
|
90
105
|
: (props.text ?? textContent(slots.default?.()))
|
|
91
106
|
const leading = buttonContent(slots.leading?.())
|
|
92
107
|
const trailing = buttonContent(slots.trailing?.())
|
|
108
|
+
const indicator = props.loading && props.loadingIndicator !== 'none' && !isAndroid
|
|
93
109
|
const composed = Boolean(
|
|
94
|
-
slots.leading ||
|
|
110
|
+
slots.leading ||
|
|
111
|
+
slots.trailing ||
|
|
112
|
+
indicator ||
|
|
113
|
+
(isAndroid && (props.icon || props.trailingIcon)),
|
|
95
114
|
)
|
|
96
115
|
const hasIcon = Boolean(composed || props.icon || props.trailingIcon)
|
|
97
116
|
checkIconOnly(text, hasIcon, props.accessibilityLabel)
|
|
@@ -187,6 +206,18 @@ export const MButton = defineComponent({
|
|
|
187
206
|
{ hidden: true },
|
|
188
207
|
{
|
|
189
208
|
default: () => [
|
|
209
|
+
...(indicator
|
|
210
|
+
? [
|
|
211
|
+
h(LoadingDecoration, {
|
|
212
|
+
kind: props.loadingIndicator as 'dots' | 'bars' | 'ring',
|
|
213
|
+
width: iconSize,
|
|
214
|
+
height: iconSize,
|
|
215
|
+
size: iconSize,
|
|
216
|
+
color: primary ? colors.onPrimary : colors.text,
|
|
217
|
+
radius: 'none',
|
|
218
|
+
}),
|
|
219
|
+
]
|
|
220
|
+
: []),
|
|
190
221
|
slots.leading
|
|
191
222
|
? adornment(leading)
|
|
192
223
|
: props.icon
|
|
@@ -218,7 +249,7 @@ export const MButton = defineComponent({
|
|
|
218
249
|
)
|
|
219
250
|
}
|
|
220
251
|
return h(
|
|
221
|
-
'MavisButton',
|
|
252
|
+
props.reorderHandle ? 'MavisReorderHandle' : 'MavisButton',
|
|
222
253
|
mergeProps(
|
|
223
254
|
{
|
|
224
255
|
// Android builds the accessible description from the current text.
|
|
@@ -2,6 +2,8 @@ import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vu
|
|
|
2
2
|
import { iconProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { iconFontFamily, iconGlyph, resolveIconSize } from '@getcortexlabs/mavis-core'
|
|
4
4
|
import { MavisLabel } from '../../native/label'
|
|
5
|
+
import { isIOS } from '@nativescript/core'
|
|
6
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
5
7
|
|
|
6
8
|
registerElement('MavisIcon', () => MavisLabel)
|
|
7
9
|
|
|
@@ -11,14 +13,24 @@ export const MIcon = defineComponent({
|
|
|
11
13
|
props: iconProps,
|
|
12
14
|
setup(props, { attrs }) {
|
|
13
15
|
const { theme } = useMavisTheme()
|
|
16
|
+
const motion = useMotionSurface(() => props.motionSurface)
|
|
14
17
|
return () => {
|
|
15
18
|
const size = resolveIconSize(props.size)
|
|
16
19
|
return h(
|
|
17
|
-
'MavisIcon',
|
|
20
|
+
props.systemName && isIOS ? 'Image' : 'MavisIcon',
|
|
18
21
|
mergeProps(
|
|
22
|
+
{ onLoaded: motion.onLoaded, onUnloaded: motion.onUnloaded },
|
|
19
23
|
{
|
|
20
24
|
id: props.id,
|
|
21
|
-
|
|
25
|
+
key: props.systemName && isIOS ? props.systemName : 'glyph',
|
|
26
|
+
...(props.systemName && isIOS
|
|
27
|
+
? {
|
|
28
|
+
src: `sys://${props.systemName}`,
|
|
29
|
+
width: size,
|
|
30
|
+
height: size,
|
|
31
|
+
tintColor: theme.value.colors[props.tone],
|
|
32
|
+
}
|
|
33
|
+
: { text: iconGlyph(props.name) }),
|
|
22
34
|
textWrap: false,
|
|
23
35
|
accessible: Boolean(props.label),
|
|
24
36
|
accessibilityHidden: !props.label,
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
mergeProps,
|
|
5
|
+
nextTick,
|
|
6
|
+
onBeforeUnmount,
|
|
7
|
+
ref,
|
|
8
|
+
shallowRef,
|
|
9
|
+
watch,
|
|
10
|
+
} from 'nativescript-vue'
|
|
11
|
+
import type { EventData, View, ImageSource, Image } from '@nativescript/core'
|
|
12
|
+
import { imageProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
13
|
+
import { resolveRadius } from '@getcortexlabs/mavis-core'
|
|
14
|
+
import { loadAvatarImage } from '../../native/avatar-image'
|
|
15
|
+
import { MBox } from './layout.js'
|
|
16
|
+
import { MText } from './MText.js'
|
|
17
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
18
|
+
import { registerMotionImage } from '../../native/image-effects.js'
|
|
19
|
+
|
|
20
|
+
export const MImage = defineComponent({
|
|
21
|
+
name: 'MImage',
|
|
22
|
+
inheritAttrs: false,
|
|
23
|
+
props: imageProps,
|
|
24
|
+
emits: {
|
|
25
|
+
load: (_src: string) => true,
|
|
26
|
+
error: (_src: string) => true,
|
|
27
|
+
'update:src': (_src: string) => true,
|
|
28
|
+
},
|
|
29
|
+
setup(props, { attrs, emit }) {
|
|
30
|
+
const { theme } = useMavisTheme()
|
|
31
|
+
const image = shallowRef<ImageSource | null>(null)
|
|
32
|
+
const status = ref<'loading' | 'ready' | 'error'>('loading')
|
|
33
|
+
const width = ref(typeof props.width === 'number' ? props.width : 0)
|
|
34
|
+
let generation = 0,
|
|
35
|
+
loaded = false
|
|
36
|
+
let releaseImage: (() => void) | undefined,
|
|
37
|
+
committing: string | undefined,
|
|
38
|
+
currentImage: Image | undefined
|
|
39
|
+
const motion = useMotionSurface(
|
|
40
|
+
() => props.motionSurface,
|
|
41
|
+
() => true,
|
|
42
|
+
() => false,
|
|
43
|
+
true,
|
|
44
|
+
)
|
|
45
|
+
async function load() {
|
|
46
|
+
const current = ++generation,
|
|
47
|
+
src = props.src
|
|
48
|
+
image.value = null
|
|
49
|
+
status.value = src.trim() ? 'loading' : 'error'
|
|
50
|
+
if (!loaded || !src.trim()) return
|
|
51
|
+
try {
|
|
52
|
+
const result = await loadAvatarImage(src.trim())
|
|
53
|
+
if (current !== generation || !loaded) return
|
|
54
|
+
if (!result || result.width <= 0 || result.height <= 0)
|
|
55
|
+
throw new Error('Image could not be decoded.')
|
|
56
|
+
image.value = result
|
|
57
|
+
status.value = 'ready'
|
|
58
|
+
emit('load', src)
|
|
59
|
+
} catch {
|
|
60
|
+
if (current !== generation || !loaded) return
|
|
61
|
+
status.value = 'error'
|
|
62
|
+
emit('error', src)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function unload() {
|
|
66
|
+
motion.onUnloaded()
|
|
67
|
+
releaseImage?.()
|
|
68
|
+
releaseImage = undefined
|
|
69
|
+
currentImage = undefined
|
|
70
|
+
loaded = false
|
|
71
|
+
generation++
|
|
72
|
+
image.value = null
|
|
73
|
+
}
|
|
74
|
+
watch(
|
|
75
|
+
() => props.src,
|
|
76
|
+
() => {
|
|
77
|
+
if (props.src === committing) {
|
|
78
|
+
committing = undefined
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
void load()
|
|
82
|
+
},
|
|
83
|
+
{ flush: 'sync' },
|
|
84
|
+
)
|
|
85
|
+
onBeforeUnmount(unload)
|
|
86
|
+
return () => {
|
|
87
|
+
if (!Number.isFinite(props.aspectRatio) || props.aspectRatio <= 0)
|
|
88
|
+
throw new RangeError('aspectRatio must be finite and positive.')
|
|
89
|
+
const radius = resolveRadius(theme.value, props.radius)
|
|
90
|
+
return h(
|
|
91
|
+
MBox,
|
|
92
|
+
mergeProps(attrs, {
|
|
93
|
+
...props,
|
|
94
|
+
motionSurface: undefined,
|
|
95
|
+
width: props.width ?? '100%',
|
|
96
|
+
height: props.height ?? width.value / props.aspectRatio,
|
|
97
|
+
backgroundColor: props.backgroundColor || theme.value.colors.elevated,
|
|
98
|
+
accessible: Boolean(props.alt),
|
|
99
|
+
accessibilityRole: 'image',
|
|
100
|
+
accessibilityLabel: props.alt,
|
|
101
|
+
accessibilityHint:
|
|
102
|
+
status.value === 'ready'
|
|
103
|
+
? ''
|
|
104
|
+
: status.value === 'error'
|
|
105
|
+
? props.errorLabel
|
|
106
|
+
: props.loadingLabel,
|
|
107
|
+
accessibilityHidden: props.accessibilityHidden || !props.alt,
|
|
108
|
+
onLoaded: () => {
|
|
109
|
+
loaded = true
|
|
110
|
+
void load()
|
|
111
|
+
},
|
|
112
|
+
onUnloaded: unload,
|
|
113
|
+
onLayoutChanged: (event: EventData) => {
|
|
114
|
+
const next = (event.object as View).getActualSize().width
|
|
115
|
+
if (next > 0 && Math.abs(next - width.value) > 0.1) width.value = next
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
() =>
|
|
119
|
+
image.value
|
|
120
|
+
? [
|
|
121
|
+
h('Image', {
|
|
122
|
+
key: generation,
|
|
123
|
+
imageSource: image.value,
|
|
124
|
+
width: '100%',
|
|
125
|
+
height: '100%',
|
|
126
|
+
stretch: props.fit === 'cover' ? 'aspectFill' : 'aspectFit',
|
|
127
|
+
borderRadius: radius,
|
|
128
|
+
accessible: false,
|
|
129
|
+
accessibilityHidden: true,
|
|
130
|
+
onLoaded(event: EventData) {
|
|
131
|
+
const target = event.object as Image,
|
|
132
|
+
current = generation
|
|
133
|
+
currentImage = target
|
|
134
|
+
releaseImage?.()
|
|
135
|
+
releaseImage = registerMotionImage(target, {
|
|
136
|
+
current: () =>
|
|
137
|
+
loaded &&
|
|
138
|
+
current === generation &&
|
|
139
|
+
currentImage === target &&
|
|
140
|
+
target.isLoaded,
|
|
141
|
+
async commit(destination, prepared) {
|
|
142
|
+
if (!loaded || current !== generation) return false
|
|
143
|
+
const previous = image.value
|
|
144
|
+
image.value = prepared ?? null
|
|
145
|
+
committing = destination
|
|
146
|
+
emit('update:src', destination)
|
|
147
|
+
await nextTick()
|
|
148
|
+
const accepted =
|
|
149
|
+
loaded && current === generation && props.src === destination
|
|
150
|
+
committing = undefined
|
|
151
|
+
if (!accepted && current === generation) {
|
|
152
|
+
image.value = previous
|
|
153
|
+
if (previous) target.imageSource = previous
|
|
154
|
+
}
|
|
155
|
+
return accepted
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
motion.onLoaded(event)
|
|
159
|
+
},
|
|
160
|
+
onUnloaded(event: EventData) {
|
|
161
|
+
if (event.object !== currentImage) return
|
|
162
|
+
motion.onUnloaded()
|
|
163
|
+
releaseImage?.()
|
|
164
|
+
releaseImage = undefined
|
|
165
|
+
currentImage = undefined
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
]
|
|
169
|
+
: [
|
|
170
|
+
h(MText, {
|
|
171
|
+
text: status.value === 'error' ? props.errorLabel : props.loadingLabel,
|
|
172
|
+
tone: 'muted',
|
|
173
|
+
variant: 'caption',
|
|
174
|
+
accessibilityHidden: true,
|
|
175
|
+
style: { textAlignment: 'center', verticalAlignment: 'middle', padding: 16 },
|
|
176
|
+
}),
|
|
177
|
+
],
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
})
|
|
@@ -158,11 +158,15 @@ const Input = defineComponent({
|
|
|
158
158
|
returnKeyType: props.returnKey,
|
|
159
159
|
}),
|
|
160
160
|
keyboardType:
|
|
161
|
-
props.
|
|
162
|
-
? '
|
|
163
|
-
:
|
|
164
|
-
?
|
|
165
|
-
:
|
|
161
|
+
props.inputmode === 'decimal'
|
|
162
|
+
? 'decimal'
|
|
163
|
+
: props.inputmode === 'numeric'
|
|
164
|
+
? 'number'
|
|
165
|
+
: props.type === 'tel'
|
|
166
|
+
? 'phone'
|
|
167
|
+
: ['email', 'url'].includes(props.type)
|
|
168
|
+
? props.type
|
|
169
|
+
: undefined,
|
|
166
170
|
autocapitalizationType: capitalize === 'characters' ? 'allcharacters' : capitalize,
|
|
167
171
|
autocorrect: props.autocorrect ?? text,
|
|
168
172
|
maxLength: props.maxLength ?? Infinity,
|
|
@@ -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
|
)
|
|
@@ -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 {
|
|
@@ -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
|
? [
|
|
@@ -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
|
+
)
|
|
@@ -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,3 +1,5 @@
|
|
|
1
|
+
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
2
|
+
import { MImage } from './components/MImage.js'
|
|
1
3
|
import { MStack } from './components/MStack.js'
|
|
2
4
|
import { MLink } from './components/MLink.js'
|
|
3
5
|
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
@@ -81,6 +83,9 @@ export {
|
|
|
81
83
|
MSheet,
|
|
82
84
|
MDatePicker,
|
|
83
85
|
MDateRangePicker,
|
|
86
|
+
MNumberInput,
|
|
87
|
+
MMultiSelect,
|
|
88
|
+
MImage,
|
|
84
89
|
MCombobox,
|
|
85
90
|
MFilePicker,
|
|
86
91
|
MFormGroup,
|
|
@@ -159,6 +164,9 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
159
164
|
MSheet,
|
|
160
165
|
MDatePicker,
|
|
161
166
|
MDateRangePicker,
|
|
167
|
+
MNumberInput,
|
|
168
|
+
MMultiSelect,
|
|
169
|
+
MImage,
|
|
162
170
|
MCombobox,
|
|
163
171
|
MFilePicker,
|
|
164
172
|
MFormGroup,
|
|
@@ -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
|
+
}
|