@getcortexlabs/mavis-web 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 +4 -4
- package/dist/collection-motion.d.ts +4 -0
- package/dist/collection-motion.d.ts.map +1 -0
- package/dist/collection-motion.js +97 -0
- package/dist/collection-motion.js.map +1 -0
- package/dist/components/ChoicePaint.d.ts +17 -0
- package/dist/components/ChoicePaint.d.ts.map +1 -0
- package/dist/components/ChoicePaint.js +81 -0
- package/dist/components/ChoicePaint.js.map +1 -0
- package/dist/components/DateCalendar.d.ts +3 -3
- package/dist/components/LoadingDecoration.d.ts +116 -0
- package/dist/components/LoadingDecoration.d.ts.map +1 -0
- package/dist/components/LoadingDecoration.js +35 -0
- package/dist/components/LoadingDecoration.js.map +1 -0
- package/dist/components/MAccordion.d.ts +1 -1
- package/dist/components/MAlert.d.ts +1 -1
- package/dist/components/MAvatar.d.ts +2 -2
- package/dist/components/MBadge.d.ts +1 -1
- package/dist/components/MButton.d.ts +36 -14
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +15 -1
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +6 -5
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +9 -2
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +1 -1
- package/dist/components/MCheckbox.d.ts.map +1 -1
- package/dist/components/MCheckbox.js +8 -3
- package/dist/components/MCheckbox.js.map +1 -1
- package/dist/components/MChip.d.ts +3 -3
- package/dist/components/MCombobox.d.ts +1 -1
- package/dist/components/MCombobox.d.ts.map +1 -1
- package/dist/components/MCombobox.js +10 -0
- package/dist/components/MCombobox.js.map +1 -1
- package/dist/components/MDatePicker.d.ts +16 -16
- package/dist/components/MDialog.d.ts +4 -1
- package/dist/components/MDialog.d.ts.map +1 -1
- package/dist/components/MDialog.js +69 -4
- package/dist/components/MDialog.js.map +1 -1
- package/dist/components/MEmptyState.d.ts +2 -2
- package/dist/components/MFilePicker.d.ts +2 -2
- package/dist/components/MIcon.d.ts +19 -1
- package/dist/components/MIcon.d.ts.map +1 -1
- package/dist/components/MIcon.js +6 -2
- package/dist/components/MIcon.js.map +1 -1
- package/dist/components/MImage.d.ts +203 -0
- package/dist/components/MImage.d.ts.map +1 -0
- package/dist/components/MImage.js +148 -0
- package/dist/components/MImage.js.map +1 -0
- package/dist/components/MInput.d.ts +6 -6
- package/dist/components/MLink.d.ts +3 -3
- package/dist/components/MListItem.d.ts +1 -1
- package/dist/components/MProgress.d.ts +3 -3
- package/dist/components/MRadioGroup.d.ts +1 -1
- package/dist/components/MRadioGroup.d.ts.map +1 -1
- package/dist/components/MRadioGroup.js +5 -3
- package/dist/components/MRadioGroup.js.map +1 -1
- package/dist/components/MReveal.d.ts +11 -11
- package/dist/components/MScreen.d.ts +9 -0
- package/dist/components/MScreen.d.ts.map +1 -1
- package/dist/components/MScreen.js +37 -24
- package/dist/components/MScreen.js.map +1 -1
- package/dist/components/MSegmentedControl.d.ts +1 -1
- package/dist/components/MSelect.d.ts +1 -1
- package/dist/components/MSelect.d.ts.map +1 -1
- package/dist/components/MSelect.js +6 -0
- package/dist/components/MSelect.js.map +1 -1
- package/dist/components/MSeparator.d.ts +1 -1
- package/dist/components/MSheet.d.ts +5 -5
- package/dist/components/MSheet.d.ts.map +1 -1
- package/dist/components/MSheet.js +20 -13
- package/dist/components/MSheet.js.map +1 -1
- package/dist/components/MSkeleton.d.ts +12 -1
- package/dist/components/MSkeleton.d.ts.map +1 -1
- package/dist/components/MSkeleton.js +10 -4
- package/dist/components/MSkeleton.js.map +1 -1
- package/dist/components/MStack.d.ts +13 -13
- package/dist/components/MSwitch.d.ts +1 -1
- package/dist/components/MSwitch.d.ts.map +1 -1
- package/dist/components/MSwitch.js +9 -2
- package/dist/components/MSwitch.js.map +1 -1
- package/dist/components/MTabs.d.ts +1 -1
- package/dist/components/MText.d.ts +17 -6
- package/dist/components/MText.d.ts.map +1 -1
- package/dist/components/MText.js +8 -3
- package/dist/components/MText.js.map +1 -1
- package/dist/components/configurator.d.ts +541 -0
- package/dist/components/configurator.d.ts.map +1 -0
- package/dist/components/configurator.js +20 -0
- package/dist/components/configurator.js.map +1 -0
- package/dist/components/layout.d.ts +46 -35
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/components/layout.js +3 -1
- package/dist/components/layout.js.map +1 -1
- package/dist/components/workflows.d.ts +1 -1
- package/dist/experimental.d.ts +2 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +4 -0
- package/dist/experimental.js.map +1 -1
- package/dist/image-effects.d.ts +11 -0
- package/dist/image-effects.d.ts.map +1 -0
- package/dist/image-effects.js +65 -0
- package/dist/image-effects.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/motion-region.d.ts.map +1 -1
- package/dist/motion-region.js +10 -1
- package/dist/motion-region.js.map +1 -1
- package/dist/motion-surface.d.ts +5 -1
- package/dist/motion-surface.d.ts.map +1 -1
- package/dist/motion-surface.js +107 -4
- package/dist/motion-surface.js.map +1 -1
- package/dist/platform-motion.d.ts +4 -0
- package/dist/platform-motion.d.ts.map +1 -0
- package/dist/platform-motion.js +23 -0
- package/dist/platform-motion.js.map +1 -0
- package/dist/scroll-motion.d.ts.map +1 -1
- package/dist/scroll-motion.js +17 -4
- package/dist/scroll-motion.js.map +1 -1
- package/dist/sheet-motion.d.ts +6 -2
- package/dist/sheet-motion.d.ts.map +1 -1
- package/dist/sheet-motion.js +56 -155
- package/dist/sheet-motion.js.map +1 -1
- package/dist/surface-effects.d.ts +4 -0
- package/dist/surface-effects.d.ts.map +1 -0
- package/dist/surface-effects.js +28 -0
- package/dist/surface-effects.js.map +1 -0
- package/dist/use-motion-surface.d.ts +8 -0
- package/dist/use-motion-surface.d.ts.map +1 -0
- package/dist/use-motion-surface.js +33 -0
- package/dist/use-motion-surface.js.map +1 -0
- package/dist/visual-effects.d.ts +4 -0
- package/dist/visual-effects.d.ts.map +1 -0
- package/dist/visual-effects.js +120 -0
- package/dist/visual-effects.js.map +1 -0
- package/package.json +3 -3
- package/src/collection-motion.ts +107 -0
- package/src/components/ChoicePaint.ts +96 -0
- package/src/components/LoadingDecoration.ts +39 -0
- package/src/components/MButton.ts +15 -1
- package/src/components/MCard.ts +9 -1
- package/src/components/MCheckbox.ts +14 -3
- package/src/components/MCombobox.ts +10 -0
- package/src/components/MDialog.ts +78 -4
- package/src/components/MIcon.ts +10 -1
- package/src/components/MImage.ts +168 -0
- package/src/components/MRadioGroup.ts +9 -3
- package/src/components/MScreen.ts +26 -2
- package/src/components/MSelect.ts +5 -0
- package/src/components/MSheet.ts +29 -18
- package/src/components/MSkeleton.ts +13 -4
- package/src/components/MSwitch.ts +14 -3
- package/src/components/MText.ts +11 -2
- package/src/components/configurator.ts +24 -0
- package/src/components/layout.ts +3 -0
- package/src/experimental.ts +8 -0
- package/src/image-effects.ts +78 -0
- package/src/index.ts +8 -0
- package/src/motion-region.ts +10 -1
- package/src/motion-surface.ts +107 -4
- package/src/platform-motion.ts +36 -0
- package/src/scroll-motion.ts +15 -3
- package/src/sheet-motion.ts +51 -152
- package/src/style.css +31 -15
- package/src/surface-effects.ts +33 -0
- package/src/use-motion-surface.ts +43 -0
- package/src/visual-effects.ts +139 -0
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
nextTick,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onDeactivated,
|
|
7
|
+
Transition,
|
|
8
|
+
useId,
|
|
9
|
+
watch,
|
|
10
|
+
} from 'vue'
|
|
11
|
+
import {
|
|
12
|
+
createWebRuntime,
|
|
13
|
+
type WebRuntime,
|
|
14
|
+
type WebInteractiveModal,
|
|
15
|
+
} from '@rafaelaugusto/jolt/web'
|
|
2
16
|
import {
|
|
3
17
|
useButtonAction,
|
|
4
18
|
dialogProps,
|
|
@@ -39,7 +53,21 @@ export const MDialog = defineComponent({
|
|
|
39
53
|
let opener: HTMLElement | undefined
|
|
40
54
|
let overflow: string | undefined
|
|
41
55
|
let outside = false
|
|
56
|
+
let motion: WebInteractiveModal | undefined, runtime: WebRuntime | undefined
|
|
57
|
+
let entered: (() => void) | undefined, left: (() => void) | undefined
|
|
58
|
+
const releaseMotion = () => {
|
|
59
|
+
const control = motion
|
|
60
|
+
motion = undefined
|
|
61
|
+
control?.dispose()
|
|
62
|
+
runtime?.dispose()
|
|
63
|
+
runtime = undefined
|
|
64
|
+
entered?.()
|
|
65
|
+
entered = undefined
|
|
66
|
+
left?.()
|
|
67
|
+
left = undefined
|
|
68
|
+
}
|
|
42
69
|
function release(element: HTMLDialogElement) {
|
|
70
|
+
releaseMotion()
|
|
43
71
|
if (element.open) element.close()
|
|
44
72
|
if (current !== element || props.open) return
|
|
45
73
|
current = undefined
|
|
@@ -49,7 +77,7 @@ export const MDialog = defineComponent({
|
|
|
49
77
|
if (opener?.isConnected) opener.focus({ preventScroll: true })
|
|
50
78
|
opener = undefined
|
|
51
79
|
}
|
|
52
|
-
function enter(element: Element) {
|
|
80
|
+
function enter(element: Element, done?: () => void) {
|
|
53
81
|
const dialog = element as HTMLDialogElement
|
|
54
82
|
if (current !== dialog) {
|
|
55
83
|
opener = document.activeElement instanceof HTMLElement ? document.activeElement : undefined
|
|
@@ -57,7 +85,32 @@ export const MDialog = defineComponent({
|
|
|
57
85
|
}
|
|
58
86
|
current = dialog
|
|
59
87
|
document.body.style.overflow = 'hidden'
|
|
60
|
-
if (
|
|
88
|
+
if (props.interactive) {
|
|
89
|
+
entered = done
|
|
90
|
+
runtime = createWebRuntime(dialog.ownerDocument)
|
|
91
|
+
motion = runtime.interactiveModal(dialog, {
|
|
92
|
+
handle: dialog.querySelector<HTMLElement>('.m-dialog-title')!,
|
|
93
|
+
canBegin: () => props.open && props.dismissible && !props.loading,
|
|
94
|
+
onState(value) {
|
|
95
|
+
dialog.dataset.motionState = value
|
|
96
|
+
if (value === 'open') {
|
|
97
|
+
entered?.()
|
|
98
|
+
entered = undefined
|
|
99
|
+
}
|
|
100
|
+
if (value === 'closing' && props.open) {
|
|
101
|
+
state.request('swipe')
|
|
102
|
+
void nextTick(() => {
|
|
103
|
+
if (props.open) motion?.cancel()
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
if (value === 'closed') {
|
|
107
|
+
left?.()
|
|
108
|
+
left = undefined
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
motion.open()
|
|
113
|
+
} else if (!dialog.open) dialog.showModal()
|
|
61
114
|
const cancel = dialog.querySelector<HTMLButtonElement>('[data-dialog-cancel]')
|
|
62
115
|
const panel = dialog.querySelector<HTMLElement>('.m-dialog-panel')
|
|
63
116
|
;(cancel && !cancel.disabled ? cancel : panel)?.focus({ preventScroll: true })
|
|
@@ -90,6 +143,7 @@ export const MDialog = defineComponent({
|
|
|
90
143
|
},
|
|
91
144
|
)
|
|
92
145
|
const cleanup = () => {
|
|
146
|
+
releaseMotion()
|
|
93
147
|
if (current?.open) current.close()
|
|
94
148
|
if (overflow !== undefined && document.body.style.overflow === 'hidden')
|
|
95
149
|
document.body.style.overflow = overflow
|
|
@@ -110,7 +164,19 @@ export const MDialog = defineComponent({
|
|
|
110
164
|
{
|
|
111
165
|
name: 'm-dialog',
|
|
112
166
|
appear: true,
|
|
113
|
-
|
|
167
|
+
css: !props.interactive,
|
|
168
|
+
onEnter: props.interactive
|
|
169
|
+
? (element: Element, done: () => void) => enter(element, done)
|
|
170
|
+
: (element: Element) => enter(element),
|
|
171
|
+
onLeave: props.interactive
|
|
172
|
+
? (_element: Element, done: () => void) => {
|
|
173
|
+
left = done
|
|
174
|
+
if (!motion || motion.state === 'closed' || motion.state === 'disposed') {
|
|
175
|
+
left = undefined
|
|
176
|
+
done()
|
|
177
|
+
} else motion.close()
|
|
178
|
+
}
|
|
179
|
+
: undefined,
|
|
114
180
|
onAfterLeave: (element: Element) => {
|
|
115
181
|
release(element as HTMLDialogElement)
|
|
116
182
|
state.left()
|
|
@@ -134,6 +200,7 @@ export const MDialog = defineComponent({
|
|
|
134
200
|
},
|
|
135
201
|
onCancel: (event: Event) => {
|
|
136
202
|
event.preventDefault()
|
|
203
|
+
if (props.interactive) event.stopImmediatePropagation()
|
|
137
204
|
state.request('escape')
|
|
138
205
|
},
|
|
139
206
|
onClose: (event: Event) => {
|
|
@@ -144,6 +211,13 @@ export const MDialog = defineComponent({
|
|
|
144
211
|
onKeydown: trap,
|
|
145
212
|
onPointerdown: (event: Event) => {
|
|
146
213
|
outside = event.target === event.currentTarget
|
|
214
|
+
// Route gesture contacts to the title before Jolt observes them.
|
|
215
|
+
// Rejected contacts otherwise interrupt its entrance animation.
|
|
216
|
+
const inHandle =
|
|
217
|
+
event.target instanceof Element &&
|
|
218
|
+
Boolean(event.target.closest('.m-dialog-title'))
|
|
219
|
+
if (props.interactive && (!inHandle || !props.dismissible || props.loading))
|
|
220
|
+
event.stopImmediatePropagation()
|
|
147
221
|
},
|
|
148
222
|
onClick: (event: Event) => {
|
|
149
223
|
if (outside && event.target === event.currentTarget) state.request('backdrop')
|
package/src/components/MIcon.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineComponent, h, mergeProps } from 'vue'
|
|
|
2
2
|
import { iconProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { iconFontFamily, iconGlyph, resolveIconSize } from '@getcortexlabs/mavis-core'
|
|
4
4
|
import { webAttrs } from '../style.js'
|
|
5
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
5
6
|
|
|
6
7
|
export const MIcon = defineComponent({
|
|
7
8
|
name: 'MIcon',
|
|
@@ -9,11 +10,13 @@ export const MIcon = defineComponent({
|
|
|
9
10
|
props: iconProps,
|
|
10
11
|
setup(props, { attrs }) {
|
|
11
12
|
const { theme } = useMavisTheme()
|
|
13
|
+
const motion = useMotionSurface(() => props.motionSurface)
|
|
12
14
|
return () => {
|
|
13
15
|
const size = `${resolveIconSize(props.size)}px`
|
|
14
16
|
return h(
|
|
15
17
|
'span',
|
|
16
18
|
mergeProps(
|
|
19
|
+
motion,
|
|
17
20
|
{
|
|
18
21
|
class: 'm-icon',
|
|
19
22
|
style: {
|
|
@@ -32,7 +35,13 @@ export const MIcon = defineComponent({
|
|
|
32
35
|
webAttrs({ ...attrs, id: props.id }),
|
|
33
36
|
props.label ? { role: 'img', 'aria-label': props.label } : { 'aria-hidden': 'true' },
|
|
34
37
|
),
|
|
35
|
-
|
|
38
|
+
props.motionSurface
|
|
39
|
+
? h(
|
|
40
|
+
'span',
|
|
41
|
+
{ 'data-jolt-symbol-layer': '', 'aria-hidden': 'true' },
|
|
42
|
+
iconGlyph(props.name),
|
|
43
|
+
)
|
|
44
|
+
: iconGlyph(props.name),
|
|
36
45
|
)
|
|
37
46
|
}
|
|
38
47
|
},
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
2
|
+
import { imageProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { resolveRadius, resolveDimension } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { boxStyle, webAttrs, length } from '../style.js'
|
|
5
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
6
|
+
import { registerMotionImage } from '../image-effects.js'
|
|
7
|
+
|
|
8
|
+
export const MImage = defineComponent({
|
|
9
|
+
name: 'MImage',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: imageProps,
|
|
12
|
+
emits: {
|
|
13
|
+
load: (_src: string) => true,
|
|
14
|
+
error: (_src: string) => true,
|
|
15
|
+
'update:src': (_src: string) => true,
|
|
16
|
+
},
|
|
17
|
+
setup(props, { attrs, emit }) {
|
|
18
|
+
const { theme } = useMavisTheme()
|
|
19
|
+
const status = ref<'loading' | 'ready' | 'error'>('loading')
|
|
20
|
+
let generation = 0,
|
|
21
|
+
alive = true
|
|
22
|
+
let currentImage: HTMLImageElement | undefined,
|
|
23
|
+
releaseImage: (() => void) | undefined,
|
|
24
|
+
committing: string | undefined
|
|
25
|
+
const motion = useMotionSurface(() =>
|
|
26
|
+
status.value === 'ready' ? props.motionSurface : undefined,
|
|
27
|
+
)
|
|
28
|
+
watch(
|
|
29
|
+
() => props.src,
|
|
30
|
+
() => {
|
|
31
|
+
if (props.src === committing) {
|
|
32
|
+
committing = undefined
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
generation++
|
|
36
|
+
status.value = props.src.trim() ? 'loading' : 'error'
|
|
37
|
+
},
|
|
38
|
+
{ flush: 'sync', immediate: true },
|
|
39
|
+
)
|
|
40
|
+
onBeforeUnmount(() => {
|
|
41
|
+
alive = false
|
|
42
|
+
generation++
|
|
43
|
+
releaseImage?.()
|
|
44
|
+
})
|
|
45
|
+
return () => {
|
|
46
|
+
if (!Number.isFinite(props.aspectRatio) || props.aspectRatio <= 0)
|
|
47
|
+
throw new RangeError('aspectRatio must be finite and positive.')
|
|
48
|
+
const current = generation,
|
|
49
|
+
src = props.src
|
|
50
|
+
const settle = (success: boolean) => {
|
|
51
|
+
if (!alive || current !== generation || status.value !== 'loading') return
|
|
52
|
+
status.value = success ? 'ready' : 'error'
|
|
53
|
+
if (success) emit('load', src)
|
|
54
|
+
else emit('error', src)
|
|
55
|
+
}
|
|
56
|
+
const radius = resolveRadius(theme.value, props.radius)
|
|
57
|
+
return h(
|
|
58
|
+
'div',
|
|
59
|
+
mergeProps(webAttrs(attrs), {
|
|
60
|
+
id: props.id,
|
|
61
|
+
class: 'm-image',
|
|
62
|
+
'data-state': status.value,
|
|
63
|
+
'aria-hidden': props.accessibilityHidden || !props.alt || undefined,
|
|
64
|
+
role: status.value === 'ready' ? undefined : 'img',
|
|
65
|
+
'aria-label':
|
|
66
|
+
status.value === 'ready'
|
|
67
|
+
? undefined
|
|
68
|
+
: `${props.alt}: ${status.value === 'error' ? props.errorLabel : props.loadingLabel}`,
|
|
69
|
+
style: {
|
|
70
|
+
...boxStyle(theme.value, props),
|
|
71
|
+
position: 'relative',
|
|
72
|
+
overflow: 'hidden',
|
|
73
|
+
width: length(resolveDimension(props.width)) ?? '100%',
|
|
74
|
+
aspectRatio: String(props.aspectRatio),
|
|
75
|
+
borderRadius: `${radius}px`,
|
|
76
|
+
backgroundColor: props.backgroundColor || theme.value.colors.elevated,
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
[
|
|
80
|
+
src.trim()
|
|
81
|
+
? h('img', {
|
|
82
|
+
key: current,
|
|
83
|
+
src,
|
|
84
|
+
alt: props.alt,
|
|
85
|
+
onLoad: (event: Event) => {
|
|
86
|
+
const target = event.target as HTMLImageElement
|
|
87
|
+
if (target?.decode)
|
|
88
|
+
void target.decode().then(
|
|
89
|
+
() => settle(true),
|
|
90
|
+
() => settle(false),
|
|
91
|
+
)
|
|
92
|
+
else settle(true)
|
|
93
|
+
},
|
|
94
|
+
onError: () => settle(false),
|
|
95
|
+
onVnodeMounted: (node) => {
|
|
96
|
+
const image = node.el as HTMLImageElement
|
|
97
|
+
currentImage = image
|
|
98
|
+
releaseImage?.()
|
|
99
|
+
releaseImage = registerMotionImage(image, {
|
|
100
|
+
current: () => alive && current === generation && currentImage === image,
|
|
101
|
+
async commit(destination) {
|
|
102
|
+
if (!alive || current !== generation || currentImage !== image) return false
|
|
103
|
+
const previous = props.src
|
|
104
|
+
committing = destination
|
|
105
|
+
emit('update:src', destination)
|
|
106
|
+
await nextTick()
|
|
107
|
+
const accepted =
|
|
108
|
+
alive &&
|
|
109
|
+
current === generation &&
|
|
110
|
+
currentImage === image &&
|
|
111
|
+
props.src === destination
|
|
112
|
+
committing = undefined
|
|
113
|
+
if (!accepted && current === generation && currentImage === image)
|
|
114
|
+
image.src = previous
|
|
115
|
+
return accepted
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
motion.onVnodeMounted(node)
|
|
119
|
+
if (image.complete) {
|
|
120
|
+
if (image.naturalWidth && image.decode)
|
|
121
|
+
void image.decode().then(
|
|
122
|
+
() => settle(true),
|
|
123
|
+
() => settle(false),
|
|
124
|
+
)
|
|
125
|
+
else settle(image.naturalWidth > 0)
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
onVnodeBeforeUnmount: () => {
|
|
129
|
+
motion.onVnodeBeforeUnmount()
|
|
130
|
+
releaseImage?.()
|
|
131
|
+
releaseImage = undefined
|
|
132
|
+
currentImage = undefined
|
|
133
|
+
},
|
|
134
|
+
style: {
|
|
135
|
+
position: 'absolute',
|
|
136
|
+
inset: 0,
|
|
137
|
+
width: '100%',
|
|
138
|
+
height: '100%',
|
|
139
|
+
objectFit: props.fit,
|
|
140
|
+
opacity: status.value === 'ready' ? 1 : 0,
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
: null,
|
|
144
|
+
status.value !== 'ready'
|
|
145
|
+
? h(
|
|
146
|
+
'span',
|
|
147
|
+
{
|
|
148
|
+
'aria-hidden': 'true',
|
|
149
|
+
style: {
|
|
150
|
+
position: 'absolute',
|
|
151
|
+
inset: 0,
|
|
152
|
+
display: 'flex',
|
|
153
|
+
alignItems: 'center',
|
|
154
|
+
justifyContent: 'center',
|
|
155
|
+
padding: '16px',
|
|
156
|
+
color: theme.value.colors.muted,
|
|
157
|
+
fontSize: `${theme.value.typography.caption.fontSize}px`,
|
|
158
|
+
textAlign: 'center',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
status.value === 'error' ? props.errorLabel : props.loadingLabel,
|
|
162
|
+
)
|
|
163
|
+
: null,
|
|
164
|
+
],
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChoicePaintSurface } from './ChoicePaint.js'
|
|
1
2
|
import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
2
3
|
import { computed, defineComponent, h, mergeProps, nextTick, onBeforeUnmount, useId } from 'vue'
|
|
3
4
|
import { choiceKey, validateChoices, canChoose, type ChoiceOption } from '@getcortexlabs/mavis-core'
|
|
@@ -167,9 +168,14 @@ export const MRadioGroup = defineComponent({
|
|
|
167
168
|
onChange: () => request(option),
|
|
168
169
|
onKeydown: (event: KeyboardEvent) => keydown(event, option),
|
|
169
170
|
}),
|
|
170
|
-
h(
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
h(
|
|
172
|
+
ChoicePaintSurface,
|
|
173
|
+
{
|
|
174
|
+
class: 'm-radio-indicator',
|
|
175
|
+
paint: { borderColor: selected ? colors.primary : colors.muted },
|
|
176
|
+
},
|
|
177
|
+
() => [h('span', { class: 'm-radio-dot' })],
|
|
178
|
+
),
|
|
173
179
|
h(
|
|
174
180
|
'span',
|
|
175
181
|
{
|
|
@@ -11,12 +11,14 @@ import {
|
|
|
11
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
12
12
|
import { webAttrs } from '../style.js'
|
|
13
13
|
import { useScreenViewport } from '../screen-viewport.js'
|
|
14
|
+
import { useMotionRegion } from '../motion-region.js'
|
|
14
15
|
|
|
15
16
|
export const MScreen = defineComponent({
|
|
16
17
|
name: 'MScreen',
|
|
17
18
|
inheritAttrs: false,
|
|
18
19
|
props: screenProps,
|
|
19
20
|
setup(props, { attrs, slots }) {
|
|
21
|
+
const region = useMotionRegion(() => props.motionRegion)
|
|
20
22
|
const { theme } = useMavisTheme()
|
|
21
23
|
const appToast = useAppToastHost()
|
|
22
24
|
const element = useScreenViewport(() => props.scroll)
|
|
@@ -39,8 +41,8 @@ export const MScreen = defineComponent({
|
|
|
39
41
|
active.isContentEditable
|
|
40
42
|
if (editor) active.blur()
|
|
41
43
|
}
|
|
42
|
-
return () =>
|
|
43
|
-
h(
|
|
44
|
+
return () => {
|
|
45
|
+
const screen = h(
|
|
44
46
|
'main',
|
|
45
47
|
mergeProps(
|
|
46
48
|
{
|
|
@@ -63,6 +65,7 @@ export const MScreen = defineComponent({
|
|
|
63
65
|
},
|
|
64
66
|
},
|
|
65
67
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
68
|
+
slots.overlay ? {} : region,
|
|
66
69
|
),
|
|
67
70
|
[
|
|
68
71
|
slots.default?.(),
|
|
@@ -71,5 +74,26 @@ export const MScreen = defineComponent({
|
|
|
71
74
|
: null,
|
|
72
75
|
],
|
|
73
76
|
)
|
|
77
|
+
return slots.overlay
|
|
78
|
+
? h(
|
|
79
|
+
'div',
|
|
80
|
+
mergeProps(
|
|
81
|
+
{ class: 'm-screen-frame', style: { position: 'relative', overflow: 'clip' } },
|
|
82
|
+
region,
|
|
83
|
+
),
|
|
84
|
+
[
|
|
85
|
+
screen,
|
|
86
|
+
h(
|
|
87
|
+
'div',
|
|
88
|
+
{
|
|
89
|
+
class: 'm-screen-overlay',
|
|
90
|
+
style: { position: 'absolute', inset: 0, display: 'grid', pointerEvents: 'none' },
|
|
91
|
+
},
|
|
92
|
+
slots.overlay(),
|
|
93
|
+
),
|
|
94
|
+
],
|
|
95
|
+
)
|
|
96
|
+
: screen
|
|
97
|
+
}
|
|
74
98
|
},
|
|
75
99
|
})
|
|
@@ -299,6 +299,11 @@ export const MSelect = defineComponent({
|
|
|
299
299
|
backgroundColor: checked ? colors.primarySoft : 'transparent',
|
|
300
300
|
opacity: option.disabled ? 0.45 : 1,
|
|
301
301
|
},
|
|
302
|
+
// Keep focus on the listbox and let this option own activation.
|
|
303
|
+
// The enclosing sheet must not capture and retarget its click.
|
|
304
|
+
onPointerdown: (event: PointerEvent) => {
|
|
305
|
+
if (event.button === 0) event.preventDefault()
|
|
306
|
+
},
|
|
302
307
|
onClick: () => choose(option),
|
|
303
308
|
},
|
|
304
309
|
[
|
package/src/components/MSheet.ts
CHANGED
|
@@ -128,8 +128,12 @@ const Sheet = defineComponent({
|
|
|
128
128
|
motion = sheetMotion(
|
|
129
129
|
element,
|
|
130
130
|
panel.value!,
|
|
131
|
-
handle.value
|
|
132
|
-
() =>
|
|
131
|
+
handle.value!,
|
|
132
|
+
() => ({
|
|
133
|
+
dismissible: props.dismissible,
|
|
134
|
+
fullscreen: props.fullscreen,
|
|
135
|
+
label: checkSheetName(props.title, props.accessibilityLabel),
|
|
136
|
+
}),
|
|
133
137
|
() => {
|
|
134
138
|
if (props.open) return
|
|
135
139
|
motion?.dispose()
|
|
@@ -157,7 +161,7 @@ const Sheet = defineComponent({
|
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
watch(
|
|
160
|
-
() => props.dismissible,
|
|
164
|
+
() => [props.dismissible, props.fullscreen, props.title, props.accessibilityLabel],
|
|
161
165
|
() => motion?.refresh(),
|
|
162
166
|
)
|
|
163
167
|
|
|
@@ -281,27 +285,34 @@ const Sheet = defineComponent({
|
|
|
281
285
|
{
|
|
282
286
|
class: 'm-sheet-panel',
|
|
283
287
|
ref: panel,
|
|
284
|
-
style: {
|
|
285
|
-
padding: `${resolveSpace(theme.value, props.padding ?? 'lg')}px`,
|
|
286
|
-
gap: `${space.md}px`,
|
|
287
|
-
},
|
|
288
288
|
},
|
|
289
289
|
[
|
|
290
290
|
h(
|
|
291
291
|
'div',
|
|
292
292
|
{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
class: 'm-sheet-content',
|
|
294
|
+
style: {
|
|
295
|
+
padding: `${resolveSpace(theme.value, props.padding ?? 'lg')}px`,
|
|
296
|
+
gap: `${space.md}px`,
|
|
297
|
+
},
|
|
297
298
|
},
|
|
298
|
-
[
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
299
|
+
[
|
|
300
|
+
h(
|
|
301
|
+
'div',
|
|
302
|
+
{
|
|
303
|
+
ref: handle,
|
|
304
|
+
class: 'm-sheet-handle',
|
|
305
|
+
style: { display: props.dismissible ? undefined : 'none' },
|
|
306
|
+
},
|
|
307
|
+
[h('span')],
|
|
308
|
+
),
|
|
309
|
+
header,
|
|
310
|
+
h(
|
|
311
|
+
MColumn,
|
|
312
|
+
{ class: 'm-sheet-body', shrink: 1, gap: props.gap, align: props.align },
|
|
313
|
+
{ default: () => slots.default?.() },
|
|
314
|
+
),
|
|
315
|
+
],
|
|
305
316
|
),
|
|
306
317
|
],
|
|
307
318
|
),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { defineComponent, h, mergeProps, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
1
|
+
import { defineComponent, h, mergeProps, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
2
2
|
import { skeletonProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { MBox } from './layout.js'
|
|
4
|
+
import { LoadingDecoration } from './LoadingDecoration.js'
|
|
4
5
|
|
|
5
6
|
export const MSkeleton = defineComponent({
|
|
6
7
|
name: 'MSkeleton',
|
|
@@ -14,12 +15,19 @@ export const MSkeleton = defineComponent({
|
|
|
14
15
|
}
|
|
15
16
|
onMounted(() => {
|
|
16
17
|
visibility()
|
|
17
|
-
|
|
18
|
+
watch(
|
|
19
|
+
() => props.effect,
|
|
20
|
+
(effect) => {
|
|
21
|
+
document.removeEventListener('visibilitychange', visibility)
|
|
22
|
+
if (effect === 'pulse') document.addEventListener('visibilitychange', visibility)
|
|
23
|
+
},
|
|
24
|
+
{ immediate: true },
|
|
25
|
+
)
|
|
18
26
|
})
|
|
19
27
|
onBeforeUnmount(() => document.removeEventListener('visibilitychange', visibility))
|
|
20
28
|
return () =>
|
|
21
29
|
h(
|
|
22
|
-
MBox,
|
|
30
|
+
props.effect === 'shimmer' ? LoadingDecoration : MBox,
|
|
23
31
|
mergeProps(
|
|
24
32
|
{
|
|
25
33
|
style: {
|
|
@@ -37,7 +45,8 @@ export const MSkeleton = defineComponent({
|
|
|
37
45
|
shrink: props.shrink,
|
|
38
46
|
backgroundColor: theme.value.colors.border,
|
|
39
47
|
class: 'm-skeleton',
|
|
40
|
-
'data-animated': props.animated,
|
|
48
|
+
'data-animated': props.effect === 'pulse' && props.animated,
|
|
49
|
+
...(props.effect === 'shimmer' ? { kind: 'shimmer', animated: props.animated } : {}),
|
|
41
50
|
style: {
|
|
42
51
|
animationPlayState: hidden.value ? 'paused' : 'running',
|
|
43
52
|
pointerEvents: 'none',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChoicePaintSurface } from './ChoicePaint.js'
|
|
1
2
|
import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
2
3
|
import { defineComponent, h, mergeProps, useId } from 'vue'
|
|
3
4
|
import {
|
|
@@ -98,9 +99,19 @@ export const MSwitch = defineComponent({
|
|
|
98
99
|
: null,
|
|
99
100
|
],
|
|
100
101
|
),
|
|
101
|
-
h(
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
h(
|
|
103
|
+
ChoicePaintSurface,
|
|
104
|
+
{
|
|
105
|
+
class: 'm-switch-track',
|
|
106
|
+
paint: { backgroundColor: props.modelValue ? colors.primary : colors.muted },
|
|
107
|
+
},
|
|
108
|
+
() => [
|
|
109
|
+
h(ChoicePaintSurface, {
|
|
110
|
+
class: 'm-switch-thumb',
|
|
111
|
+
paint: { backgroundColor: props.modelValue ? colors.onPrimary : colors.surface },
|
|
112
|
+
}),
|
|
113
|
+
],
|
|
114
|
+
),
|
|
104
115
|
],
|
|
105
116
|
)
|
|
106
117
|
}
|
package/src/components/MText.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, mergeProps } from 'vue'
|
|
1
|
+
import { defineComponent, h, mergeProps, Text } from 'vue'
|
|
2
2
|
import {
|
|
3
3
|
textProps,
|
|
4
4
|
useMavisTheme,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@getcortexlabs/mavis-core/vue'
|
|
9
9
|
import { fontFamily, nonNegative, validateWeight } from '@getcortexlabs/mavis-core'
|
|
10
10
|
import { webAttrs } from '../style.js'
|
|
11
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
11
12
|
|
|
12
13
|
export const MText = defineComponent({
|
|
13
14
|
name: 'MText',
|
|
@@ -16,6 +17,10 @@ export const MText = defineComponent({
|
|
|
16
17
|
setup(props, { attrs, slots }) {
|
|
17
18
|
const { theme } = useMavisTheme()
|
|
18
19
|
const shrink = useLayoutShrink()
|
|
20
|
+
const motion = useMotionSurface(
|
|
21
|
+
() => props.motionSurface,
|
|
22
|
+
() => props.text !== undefined,
|
|
23
|
+
)
|
|
19
24
|
return () => {
|
|
20
25
|
const type = theme.value.typography[props.variant]
|
|
21
26
|
const runs =
|
|
@@ -27,6 +32,7 @@ export const MText = defineComponent({
|
|
|
27
32
|
class: 'm-text',
|
|
28
33
|
style: {
|
|
29
34
|
margin: 0,
|
|
35
|
+
display: props.motionSurface && props.as === 'span' ? 'inline-block' : undefined,
|
|
30
36
|
fontFamily: `var(--m-text-font-family, ${fontFamily(type.fontFamily, 'web')})`,
|
|
31
37
|
fontSize: `var(--m-text-font-size, ${type.fontSize}px)`,
|
|
32
38
|
fontWeight: props.weight
|
|
@@ -44,9 +50,12 @@ export const MText = defineComponent({
|
|
|
44
50
|
},
|
|
45
51
|
},
|
|
46
52
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
53
|
+
motion,
|
|
47
54
|
),
|
|
48
55
|
runs.every((run) => !run.weight && !run.tone && !run.strong && !run.italic)
|
|
49
|
-
?
|
|
56
|
+
? props.motionSurface
|
|
57
|
+
? [h(Text, null, runs.map((run) => run.text).join(''))]
|
|
58
|
+
: runs.map((run) => run.text).join('')
|
|
50
59
|
: runs.map((run) => {
|
|
51
60
|
if (!run.weight && !run.tone && !run.strong && !run.italic) return run.text
|
|
52
61
|
if (run.tone && !(run.tone in theme.value.colors))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createConfiguratorControls } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { MText } from './MText.js'
|
|
3
|
+
import { MButton } from './MButton.js'
|
|
4
|
+
import { MInput } from './MInput.js'
|
|
5
|
+
import { MChip } from './MChip.js'
|
|
6
|
+
import { MCheckbox } from './MCheckbox.js'
|
|
7
|
+
import { MSheet } from './MSheet.js'
|
|
8
|
+
import { MColumn, MRow } from './layout.js'
|
|
9
|
+
|
|
10
|
+
export const { MNumberInput, MMultiSelect } = createConfiguratorControls(
|
|
11
|
+
{
|
|
12
|
+
Column: MColumn,
|
|
13
|
+
Row: MRow,
|
|
14
|
+
Text: MText,
|
|
15
|
+
Button: MButton,
|
|
16
|
+
Input: MInput,
|
|
17
|
+
Chip: MChip,
|
|
18
|
+
Checkbox: MCheckbox,
|
|
19
|
+
Sheet: MSheet,
|
|
20
|
+
focusTrigger: (component) =>
|
|
21
|
+
(component as { $el?: HTMLElement } | undefined)?.$el?.focus({ preventScroll: true }),
|
|
22
|
+
},
|
|
23
|
+
'web',
|
|
24
|
+
)
|
package/src/components/layout.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { defineComponent, h, mergeProps, provide } from 'vue'
|
|
|
11
11
|
import { resolveSpace } from '@getcortexlabs/mavis-core'
|
|
12
12
|
import { boxStyle, webAttrs } from '../style.js'
|
|
13
13
|
import { useMotionRegion } from '../motion-region.js'
|
|
14
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
14
15
|
|
|
15
16
|
export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
|
|
16
17
|
|
|
@@ -68,6 +69,7 @@ export const MBox = defineComponent({
|
|
|
68
69
|
props: motionBoxProps,
|
|
69
70
|
setup(props, { attrs, slots }) {
|
|
70
71
|
const region = useMotionRegion(() => props.motionRegion)
|
|
72
|
+
const surface = useMotionSurface(() => props.motionSurface)
|
|
71
73
|
const { theme } = useMavisTheme()
|
|
72
74
|
const shrink = useLayoutShrink()
|
|
73
75
|
return () =>
|
|
@@ -80,6 +82,7 @@ export const MBox = defineComponent({
|
|
|
80
82
|
},
|
|
81
83
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
82
84
|
region,
|
|
85
|
+
surface,
|
|
83
86
|
),
|
|
84
87
|
slots.default?.(),
|
|
85
88
|
)
|