@getcortexlabs/mavis-web 0.1.0-alpha.7 → 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.
Files changed (129) hide show
  1. package/README.md +4 -4
  2. package/dist/collection-motion.d.ts +4 -0
  3. package/dist/collection-motion.d.ts.map +1 -0
  4. package/dist/collection-motion.js +97 -0
  5. package/dist/collection-motion.js.map +1 -0
  6. package/dist/components/LoadingDecoration.d.ts +116 -0
  7. package/dist/components/LoadingDecoration.d.ts.map +1 -0
  8. package/dist/components/LoadingDecoration.js +35 -0
  9. package/dist/components/LoadingDecoration.js.map +1 -0
  10. package/dist/components/MAccordion.d.ts +1 -1
  11. package/dist/components/MAlert.d.ts +1 -1
  12. package/dist/components/MAvatar.d.ts +2 -2
  13. package/dist/components/MButton.d.ts +33 -11
  14. package/dist/components/MButton.d.ts.map +1 -1
  15. package/dist/components/MButton.js +15 -1
  16. package/dist/components/MButton.js.map +1 -1
  17. package/dist/components/MCard.d.ts +4 -4
  18. package/dist/components/MCheckbox.d.ts +1 -1
  19. package/dist/components/MChip.d.ts +2 -2
  20. package/dist/components/MCombobox.d.ts +1 -1
  21. package/dist/components/MCombobox.d.ts.map +1 -1
  22. package/dist/components/MCombobox.js +10 -0
  23. package/dist/components/MCombobox.js.map +1 -1
  24. package/dist/components/MDialog.d.ts +3 -0
  25. package/dist/components/MDialog.d.ts.map +1 -1
  26. package/dist/components/MDialog.js +69 -4
  27. package/dist/components/MDialog.js.map +1 -1
  28. package/dist/components/MEmptyState.d.ts +2 -2
  29. package/dist/components/MIcon.d.ts +18 -0
  30. package/dist/components/MIcon.d.ts.map +1 -1
  31. package/dist/components/MIcon.js +6 -2
  32. package/dist/components/MIcon.js.map +1 -1
  33. package/dist/components/MImage.d.ts +13 -2
  34. package/dist/components/MImage.d.ts.map +1 -1
  35. package/dist/components/MImage.js +57 -6
  36. package/dist/components/MImage.js.map +1 -1
  37. package/dist/components/MInput.d.ts +6 -6
  38. package/dist/components/MLink.d.ts +2 -2
  39. package/dist/components/MListItem.d.ts +1 -1
  40. package/dist/components/MProgress.d.ts +1 -1
  41. package/dist/components/MRadioGroup.d.ts +1 -1
  42. package/dist/components/MReveal.d.ts +10 -10
  43. package/dist/components/MScreen.d.ts +9 -0
  44. package/dist/components/MScreen.d.ts.map +1 -1
  45. package/dist/components/MScreen.js +37 -24
  46. package/dist/components/MScreen.js.map +1 -1
  47. package/dist/components/MSegmentedControl.d.ts +1 -1
  48. package/dist/components/MSelect.d.ts +1 -1
  49. package/dist/components/MSelect.d.ts.map +1 -1
  50. package/dist/components/MSelect.js +6 -0
  51. package/dist/components/MSelect.js.map +1 -1
  52. package/dist/components/MSheet.d.ts +6 -6
  53. package/dist/components/MSheet.d.ts.map +1 -1
  54. package/dist/components/MSheet.js +20 -13
  55. package/dist/components/MSheet.js.map +1 -1
  56. package/dist/components/MSkeleton.d.ts +12 -1
  57. package/dist/components/MSkeleton.d.ts.map +1 -1
  58. package/dist/components/MSkeleton.js +10 -4
  59. package/dist/components/MSkeleton.js.map +1 -1
  60. package/dist/components/MStack.d.ts +11 -11
  61. package/dist/components/MSwitch.d.ts +1 -1
  62. package/dist/components/MTabs.d.ts +1 -1
  63. package/dist/components/MText.d.ts +14 -3
  64. package/dist/components/MText.d.ts.map +1 -1
  65. package/dist/components/MText.js +8 -3
  66. package/dist/components/MText.js.map +1 -1
  67. package/dist/components/layout.d.ts +43 -32
  68. package/dist/components/layout.d.ts.map +1 -1
  69. package/dist/components/layout.js +3 -1
  70. package/dist/components/layout.js.map +1 -1
  71. package/dist/experimental.d.ts +2 -0
  72. package/dist/experimental.d.ts.map +1 -1
  73. package/dist/experimental.js +4 -0
  74. package/dist/experimental.js.map +1 -1
  75. package/dist/image-effects.d.ts +11 -0
  76. package/dist/image-effects.d.ts.map +1 -0
  77. package/dist/image-effects.js +65 -0
  78. package/dist/image-effects.js.map +1 -0
  79. package/dist/motion-region.d.ts.map +1 -1
  80. package/dist/motion-region.js +10 -1
  81. package/dist/motion-region.js.map +1 -1
  82. package/dist/motion-surface.d.ts +1 -1
  83. package/dist/motion-surface.d.ts.map +1 -1
  84. package/dist/motion-surface.js +45 -2
  85. package/dist/motion-surface.js.map +1 -1
  86. package/dist/platform-motion.d.ts +4 -0
  87. package/dist/platform-motion.d.ts.map +1 -0
  88. package/dist/platform-motion.js +23 -0
  89. package/dist/platform-motion.js.map +1 -0
  90. package/dist/sheet-motion.d.ts +6 -2
  91. package/dist/sheet-motion.d.ts.map +1 -1
  92. package/dist/sheet-motion.js +56 -155
  93. package/dist/sheet-motion.js.map +1 -1
  94. package/dist/surface-effects.d.ts +4 -0
  95. package/dist/surface-effects.d.ts.map +1 -0
  96. package/dist/surface-effects.js +28 -0
  97. package/dist/surface-effects.js.map +1 -0
  98. package/dist/use-motion-surface.d.ts +8 -0
  99. package/dist/use-motion-surface.d.ts.map +1 -0
  100. package/dist/use-motion-surface.js +33 -0
  101. package/dist/use-motion-surface.js.map +1 -0
  102. package/dist/visual-effects.d.ts +4 -0
  103. package/dist/visual-effects.d.ts.map +1 -0
  104. package/dist/visual-effects.js +120 -0
  105. package/dist/visual-effects.js.map +1 -0
  106. package/package.json +3 -3
  107. package/src/collection-motion.ts +107 -0
  108. package/src/components/LoadingDecoration.ts +39 -0
  109. package/src/components/MButton.ts +15 -1
  110. package/src/components/MCombobox.ts +10 -0
  111. package/src/components/MDialog.ts +78 -4
  112. package/src/components/MIcon.ts +10 -1
  113. package/src/components/MImage.ts +65 -5
  114. package/src/components/MScreen.ts +26 -2
  115. package/src/components/MSelect.ts +5 -0
  116. package/src/components/MSheet.ts +29 -18
  117. package/src/components/MSkeleton.ts +13 -4
  118. package/src/components/MText.ts +11 -2
  119. package/src/components/layout.ts +3 -0
  120. package/src/experimental.ts +8 -0
  121. package/src/image-effects.ts +78 -0
  122. package/src/motion-region.ts +10 -1
  123. package/src/motion-surface.ts +47 -1
  124. package/src/platform-motion.ts +36 -0
  125. package/src/sheet-motion.ts +51 -152
  126. package/src/style.css +24 -5
  127. package/src/surface-effects.ts +33 -0
  128. package/src/use-motion-surface.ts +43 -0
  129. package/src/visual-effects.ts +139 -0
@@ -0,0 +1,120 @@
1
+ import { webSurfaceEffects } from './surface-effects.js';
2
+ import { mapGradientBindings, } from '@getcortexlabs/mavis-core/experimental';
3
+ const circles = new WeakMap();
4
+ export function webVisualEffects(owner, target, sources, plainText) {
5
+ const text = () => {
6
+ if (!plainText())
7
+ throw new TypeError('Declare a motionSurface on MText with an explicit text prop; rich/slotted text is unsupported.');
8
+ return target;
9
+ };
10
+ return {
11
+ ...webSurfaceEffects(owner, target),
12
+ supports: (effect) => effect === 'text'
13
+ ? plainText()
14
+ : effect === 'image' || effect === 'liquid'
15
+ ? target.tagName === 'IMG'
16
+ : true,
17
+ gradient(options) {
18
+ const paint = owner.gradient(target, options);
19
+ return {
20
+ type: paint.type,
21
+ get suspended() {
22
+ return paint.suspended;
23
+ },
24
+ animate: (values, options) => paint.animate(values, options),
25
+ set: (values) => paint.set(values),
26
+ stop: () => paint.stop(),
27
+ suspend: () => paint.suspend(),
28
+ resume: () => paint.resume(),
29
+ bind(values) {
30
+ const dispose = paint.bind(mapGradientBindings(values, (value) => sources.get(value) ?? value, (value) => value));
31
+ return { dispose };
32
+ },
33
+ dispose: () => paint.dispose(),
34
+ };
35
+ },
36
+ shimmer(options) {
37
+ const effect = owner.shimmer(target, options);
38
+ return { supported: true, dispose: () => effect.dispose() };
39
+ },
40
+ loader(options) {
41
+ const effect = owner.loader(target, options);
42
+ return { supported: true, dispose: () => effect.dispose() };
43
+ },
44
+ animateText: (options) => owner.animateText(text(), options),
45
+ rollTo: (value, options) => owner.rollTo(text(), value, options),
46
+ circular() {
47
+ circles.get(target)?.dispose();
48
+ const inert = target.getAttribute('inert'), hidden = target.getAttribute('aria-hidden');
49
+ const visibility = target.style.visibility;
50
+ let locked = false, active, generation = 0, disposed = false;
51
+ let writtenVisibility;
52
+ const unlock = () => {
53
+ if (!locked)
54
+ return;
55
+ locked = false;
56
+ if (target.getAttribute('inert') === '') {
57
+ if (inert === null)
58
+ target.removeAttribute('inert');
59
+ else
60
+ target.setAttribute('inert', inert);
61
+ }
62
+ if (target.getAttribute('aria-hidden') === 'true') {
63
+ if (hidden === null)
64
+ target.removeAttribute('aria-hidden');
65
+ else
66
+ target.setAttribute('aria-hidden', hidden);
67
+ }
68
+ };
69
+ const run = (open, options = {}) => {
70
+ if (!open && target.contains(target.ownerDocument.activeElement))
71
+ throw new Error('Move focus outside the circular surface before conceal().');
72
+ // Jolt validates options before replacing the active circle.
73
+ const handle = open
74
+ ? owner.reveal(target, { from: options.origin, duration: options.duration })
75
+ : owner.conceal(target, { to: options.origin, duration: options.duration });
76
+ const token = ++generation;
77
+ active = handle;
78
+ writtenVisibility = target.style.visibility;
79
+ if (open)
80
+ unlock();
81
+ else {
82
+ locked = true;
83
+ target.setAttribute('inert', '');
84
+ target.setAttribute('aria-hidden', 'true');
85
+ }
86
+ void handle.finished.then((completed) => {
87
+ if (token !== generation || disposed)
88
+ return;
89
+ active = undefined;
90
+ if (completed)
91
+ writtenVisibility = target.style.visibility;
92
+ if (!completed && target.style.visibility !== 'hidden')
93
+ unlock();
94
+ });
95
+ return handle;
96
+ };
97
+ const control = {
98
+ supported: true,
99
+ reveal: (options) => run(true, options),
100
+ conceal: (options) => run(false, options),
101
+ dispose() {
102
+ if (disposed)
103
+ return;
104
+ disposed = true;
105
+ generation++;
106
+ active?.stop();
107
+ unlock();
108
+ if (circles.get(target) === control) {
109
+ circles.delete(target);
110
+ if (writtenVisibility !== undefined && target.style.visibility === writtenVisibility)
111
+ target.style.visibility = visibility;
112
+ }
113
+ },
114
+ };
115
+ circles.set(target, control);
116
+ return control;
117
+ },
118
+ };
119
+ }
120
+ //# sourceMappingURL=visual-effects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visual-effects.js","sourceRoot":"","sources":["../src/visual-effects.ts"],"names":[],"mappings":"AAMA,OAAO,EA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AA;oBACZ,MAAM,EAAE,IAAI,EAAE,CAAA;oBACd,MAAM,EAAE,CAAA;oBACR,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,OAAO,EAAE,CAAC;wBACpC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;wBACtB,IAAI,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,iBAAiB;4BAClF,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU,CAAA;oBACxC,CAAC;gBACH,CAAC;aACF,CAAA;YACD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAC5B,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getcortexlabs/mavis-web",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "Mavis components for Vue Web.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -30,11 +30,11 @@
30
30
  "build": "tsc -p tsconfig.build.json"
31
31
  },
32
32
  "dependencies": {
33
- "@getcortexlabs/mavis-core": "0.1.0-alpha.7"
33
+ "@getcortexlabs/mavis-core": "0.1.0-alpha.8"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "vue": "^3.5.42",
37
- "@rafaelaugusto/jolt": "^0.1.0-rc.9"
37
+ "@rafaelaugusto/jolt": "^0.1.0-rc.10"
38
38
  },
39
39
  "license": "MIT",
40
40
  "author": "Rafael Augusto",
@@ -0,0 +1,107 @@
1
+ import type { WebRuntime } from '@rafaelaugusto/jolt/web'
2
+ import {
3
+ mapMotionItems,
4
+ type MotionRegionAdapter,
5
+ type MotionSurfaceAdapter,
6
+ } from '@getcortexlabs/mavis-core/experimental'
7
+ import { webScrollElement } from './scroll-motion.js'
8
+
9
+ export function webCollectionMotion(
10
+ runtime: WebRuntime,
11
+ target: HTMLElement,
12
+ resolve: (surface: MotionSurfaceAdapter) => HTMLElement,
13
+ ): Pick<MotionRegionAdapter, 'scrollHeader' | 'reorder'> {
14
+ return {
15
+ scrollHeader(source, options) {
16
+ const scroll = webScrollElement(source)
17
+ if (!target.contains(scroll))
18
+ throw new TypeError('Declare MScreen inside the header motion region.')
19
+ const { header, artwork, title, toolbar, toolbarTitle, section, items, ...rest } = options
20
+ const headerElement = resolve(header),
21
+ sectionElement = resolve(section)
22
+ const originalMargin = sectionElement.style.marginTop
23
+ let writtenMargin: string | undefined
24
+ const restoreSection = () => {
25
+ if (sectionElement.style.marginTop === writtenMargin)
26
+ sectionElement.style.marginTop = originalMargin
27
+ }
28
+ let control
29
+ try {
30
+ control = runtime.scrollHeader(scroll, {
31
+ ...rest,
32
+ header: headerElement,
33
+ artwork: resolve(artwork),
34
+ title: resolve(title),
35
+ toolbarTitle: resolve(toolbarTitle),
36
+ section: sectionElement,
37
+ // Native owns the section's absolute offset; Web translates its resting layout.
38
+ // Reuse Jolt's geometry reads so resizing never needs another observer or clock.
39
+ expanded: () => {
40
+ const height = options.expanded ?? headerElement.offsetHeight
41
+ if (writtenMargin === undefined || sectionElement.style.marginTop === writtenMargin) {
42
+ writtenMargin = `${height}px`
43
+ sectionElement.style.marginTop = writtenMargin
44
+ }
45
+ return height
46
+ },
47
+ minimum: options.minimum ?? (() => resolve(toolbar).getBoundingClientRect().height),
48
+ items: () => mapMotionItems(items(), resolve),
49
+ })
50
+ } catch (error) {
51
+ restoreSection()
52
+ throw error
53
+ }
54
+ return {
55
+ ready: true,
56
+ get state() {
57
+ return { offset: control.state.offset, refreshing: control.state.refreshing }
58
+ },
59
+ refresh: () => control.refresh(),
60
+ cancelRefresh: () => control.cancelRefresh(),
61
+ remeasure: async () => {
62
+ control.remeasure()
63
+ },
64
+ preserveAnchor: async (change) => {
65
+ await control.preserveAnchor(change)
66
+ },
67
+ scrollToItem: (key, animated = true) =>
68
+ control.scrollToItem(key, { behavior: animated ? 'smooth' : 'instant' }),
69
+ scrollToTop: (animated = true) =>
70
+ control.scrollToTop({ behavior: animated ? 'smooth' : 'instant' }),
71
+ pause: () => control.pause(),
72
+ play: () => control.play(),
73
+ dispose: () => {
74
+ try {
75
+ control.dispose()
76
+ } finally {
77
+ restoreSection()
78
+ }
79
+ },
80
+ }
81
+ },
82
+ reorder(options) {
83
+ const { container, scroll, items, accessibility, ...rest } = options
84
+ const read = () => mapMotionItems(items(), resolve)
85
+ const control = runtime.reorder(resolve(container), {
86
+ ...rest,
87
+ items: read,
88
+ scrollContainer: webScrollElement(scroll),
89
+ handle: (row) => read().find((item) => item.target === row)?.handle ?? row,
90
+ accessibility: { label: accessibility?.label, announcement: accessibility?.announcement },
91
+ })
92
+ return {
93
+ get activeKey() {
94
+ return control.activeKey
95
+ },
96
+ move: (key, before) => control.move(key, before),
97
+ moveUp: (key) => control.moveUp(key),
98
+ moveDown: (key) => control.moveDown(key),
99
+ refresh: () => control.refresh(),
100
+ cancel: () => control.cancel(),
101
+ pause: () => control.pause(),
102
+ play: () => control.play(),
103
+ dispose: () => control.dispose(),
104
+ }
105
+ },
106
+ }
107
+ }
@@ -0,0 +1,39 @@
1
+ import { defineComponent, h, mergeProps, type PropType } from 'vue'
2
+ import { skeletonProps, useLoadingDecoration } from '@getcortexlabs/mavis-core/vue'
3
+ import { MBox } from './layout.js'
4
+
5
+ export const LoadingDecoration = defineComponent({
6
+ name: 'MavisLoadingDecoration',
7
+ inheritAttrs: false,
8
+ props: {
9
+ ...skeletonProps,
10
+ kind: { type: String as PropType<'shimmer' | 'dots' | 'bars' | 'ring'>, required: true },
11
+ color: { type: String, default: undefined },
12
+ size: { type: Number, default: 24 },
13
+ },
14
+ setup(props, { attrs }) {
15
+ const surface = useLoadingDecoration(() => ({
16
+ kind: props.kind,
17
+ animated: props.animated,
18
+ size: props.size,
19
+ color: props.color,
20
+ }))
21
+ return () =>
22
+ h(
23
+ MBox,
24
+ mergeProps(attrs, {
25
+ id: props.id,
26
+ width: props.width,
27
+ height: props.height,
28
+ radius: props.radius,
29
+ grow: props.grow,
30
+ shrink: props.shrink,
31
+ motionSurface: surface,
32
+ accessibilityHidden: true,
33
+ inert: '',
34
+ 'aria-hidden': 'true',
35
+ style: { pointerEvents: 'none' },
36
+ }),
37
+ )
38
+ },
39
+ })
@@ -23,6 +23,7 @@ import {
23
23
  import { webAttrs } from '../style.js'
24
24
  import { usePressFeedback } from '../motion.js'
25
25
  import { navigationAttrs } from '../navigation.js'
26
+ import { LoadingDecoration } from './LoadingDecoration.js'
26
27
 
27
28
  export const MButton = defineComponent({
28
29
  name: 'MButton',
@@ -55,7 +56,8 @@ export const MButton = defineComponent({
55
56
  const leading = buttonContent(slots.leading?.())
56
57
  const trailing = buttonContent(slots.trailing?.())
57
58
  const composed = Boolean(slots.leading || slots.trailing)
58
- const hasIcon = Boolean(composed || props.icon || props.trailingIcon)
59
+ const indicator = props.loading && props.loadingIndicator !== 'none'
60
+ const hasIcon = Boolean(composed || props.icon || props.trailingIcon || indicator)
59
61
  checkIconOnly(text, hasIcon, props.accessibilityLabel)
60
62
  const iconSize = iconSizes[props.size]
61
63
  const paddingX = hasIcon && !text ? Math.round((size.height - iconSize) / 2) : size.padding
@@ -146,6 +148,18 @@ export const MButton = defineComponent({
146
148
  ),
147
149
  hasIcon
148
150
  ? [
151
+ ...(indicator
152
+ ? [
153
+ h(LoadingDecoration, {
154
+ kind: props.loadingIndicator as 'dots' | 'bars' | 'ring',
155
+ width: iconSize,
156
+ height: iconSize,
157
+ size: iconSize,
158
+ color: primary ? colors.onPrimary : colors.text,
159
+ radius: 'none',
160
+ }),
161
+ ]
162
+ : []),
149
163
  slots.leading
150
164
  ? h('span', { class: 'm-button-adornment', 'aria-hidden': 'true', inert: '' }, [
151
165
  h(ButtonAdornment, {}, { default: () => leading }),
@@ -55,6 +55,7 @@ const Combobox = defineComponent({
55
55
  const popupHost = shallowRef<HTMLElement>()
56
56
  const placement = shallowRef<CSSProperties>({ visibility: 'hidden' })
57
57
  let placementObserver: ResizeObserver | undefined
58
+ let placementMotion: MutationObserver | undefined
58
59
  function ownsFocus(target: EventTarget | null) {
59
60
  return (
60
61
  target instanceof Node && (root.value?.contains(target) || popup.value?.contains(target))
@@ -91,6 +92,8 @@ const Combobox = defineComponent({
91
92
  function releasePlacement() {
92
93
  placementObserver?.disconnect()
93
94
  placementObserver = undefined
95
+ placementMotion?.disconnect()
96
+ placementMotion = undefined
94
97
  if (typeof window === 'undefined') return
95
98
  window.removeEventListener('resize', positionPopup)
96
99
  document.removeEventListener('scroll', positionPopup, true)
@@ -113,6 +116,13 @@ const Combobox = defineComponent({
113
116
  placementObserver = new ResizeObserver(positionPopup)
114
117
  placementObserver.observe(root.value)
115
118
  }
119
+ // A sheet transform changes screen coordinates without resizing the editor.
120
+ // Observe its presentation while the popup is open; Jolt still owns all motion.
121
+ const sheet = editor.value?.closest('.m-sheet-panel')
122
+ if (sheet && typeof MutationObserver !== 'undefined') {
123
+ placementMotion = new MutationObserver(positionPopup)
124
+ placementMotion.observe(sheet, { attributes: true, attributeFilter: ['style'] })
125
+ }
116
126
  },
117
127
  { flush: 'post' },
118
128
  )
@@ -1,4 +1,18 @@
1
- import { defineComponent, h, onBeforeUnmount, onDeactivated, Transition, useId, watch } from 'vue'
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 (!dialog.open) dialog.showModal()
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
- onEnter: enter,
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')
@@ -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
- iconGlyph(props.name),
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
  },
@@ -1,21 +1,37 @@
1
- import { defineComponent, h, mergeProps, onBeforeUnmount, ref, watch } from 'vue'
1
+ import { defineComponent, h, mergeProps, nextTick, onBeforeUnmount, ref, watch } from 'vue'
2
2
  import { imageProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
3
3
  import { resolveRadius, resolveDimension } from '@getcortexlabs/mavis-core'
4
4
  import { boxStyle, webAttrs, length } from '../style.js'
5
+ import { useMotionSurface } from '../use-motion-surface.js'
6
+ import { registerMotionImage } from '../image-effects.js'
5
7
 
6
8
  export const MImage = defineComponent({
7
9
  name: 'MImage',
8
10
  inheritAttrs: false,
9
11
  props: imageProps,
10
- emits: { load: (_src: string) => true, error: (_src: string) => true },
12
+ emits: {
13
+ load: (_src: string) => true,
14
+ error: (_src: string) => true,
15
+ 'update:src': (_src: string) => true,
16
+ },
11
17
  setup(props, { attrs, emit }) {
12
18
  const { theme } = useMavisTheme()
13
19
  const status = ref<'loading' | 'ready' | 'error'>('loading')
14
20
  let generation = 0,
15
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
+ )
16
28
  watch(
17
29
  () => props.src,
18
30
  () => {
31
+ if (props.src === committing) {
32
+ committing = undefined
33
+ return
34
+ }
19
35
  generation++
20
36
  status.value = props.src.trim() ? 'loading' : 'error'
21
37
  },
@@ -24,6 +40,7 @@ export const MImage = defineComponent({
24
40
  onBeforeUnmount(() => {
25
41
  alive = false
26
42
  generation++
43
+ releaseImage?.()
27
44
  })
28
45
  return () => {
29
46
  if (!Number.isFinite(props.aspectRatio) || props.aspectRatio <= 0)
@@ -62,14 +79,57 @@ export const MImage = defineComponent({
62
79
  [
63
80
  src.trim()
64
81
  ? h('img', {
65
- key: `${current}:${src}`,
82
+ key: current,
66
83
  src,
67
84
  alt: props.alt,
68
- onLoad: () => settle(true),
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
+ },
69
94
  onError: () => settle(false),
70
95
  onVnodeMounted: (node) => {
71
96
  const image = node.el as HTMLImageElement
72
- if (image.complete) settle(image.naturalWidth > 0)
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
73
133
  },
74
134
  style: {
75
135
  position: 'absolute',