@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { shallowRef, computed, watch } from 'vue';
|
|
2
|
+
import { bindMotionSurface } from '@getcortexlabs/mavis-core/experimental';
|
|
3
|
+
import { useConnectedMotion } from './connected-motion.js';
|
|
4
|
+
import { useMotionContext } from './motion-context.js';
|
|
5
|
+
import { webMotionSurface } from './motion-surface.js';
|
|
6
|
+
/** A declared non-press surface; Jolt owns connection and KeepAlive observation. */
|
|
7
|
+
export function useMotionSurface(surface, plainText = () => false) {
|
|
8
|
+
const element = shallowRef();
|
|
9
|
+
const connected = computed(() => (surface() ? element.value : undefined));
|
|
10
|
+
useConnectedMotion(connected, useMotionContext(), (runtime, target) => {
|
|
11
|
+
let release;
|
|
12
|
+
const stop = watch(surface, (reference) => {
|
|
13
|
+
release?.();
|
|
14
|
+
release = undefined;
|
|
15
|
+
if (reference)
|
|
16
|
+
release = bindMotionSurface(reference, webMotionSurface(runtime, target, () => true, runtime, undefined, undefined, plainText)
|
|
17
|
+
.adapter);
|
|
18
|
+
}, { immediate: true, flush: 'post' });
|
|
19
|
+
return () => {
|
|
20
|
+
stop();
|
|
21
|
+
release?.();
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
onVnodeMounted: (vnode) => {
|
|
26
|
+
element.value = vnode.el;
|
|
27
|
+
},
|
|
28
|
+
onVnodeBeforeUnmount: () => {
|
|
29
|
+
element.value = undefined;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=use-motion-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-motion-surface.js","sourceRoot":"","sources":["../src/use-motion-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAc,MAAM,KAAK,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAsB,MAAM,wCAAwC,CAAA;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,oFAAoF;AACpF,MAAM,UAAU,gBAAgB,CAC9B,OAAwC,EACxC,YAA2B,GAAG,EAAE,CAAC,KAAK;IAEtC,MAAM,OAAO,GAAG,UAAU,EAAe,CAAA;IACzC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACzE,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpE,IAAI,OAAiC,CAAA;QACrC,MAAM,IAAI,GAAG,KAAK,CAChB,OAAO,EACP,CAAC,SAAS,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE,CAAA;YACX,OAAO,GAAG,SAAS,CAAA;YACnB,IAAI,SAAS;gBACX,OAAO,GAAG,iBAAiB,CACzB,SAAS,EACT,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;qBACpF,OAAO,CACX,CAAA;QACL,CAAC,EACD,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CACnC,CAAA;QACD,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,CAAA;YACN,OAAO,EAAE,EAAE,CAAA;QACb,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO;QACL,cAAc,EAAE,CAAC,KAAY,EAAE,EAAE;YAC/B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,EAAiB,CAAA;QACzC,CAAC;QACD,oBAAoB,EAAE,GAAG,EAAE;YACzB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebRuntime, WebMotionScope, WebReadableValue } from '@rafaelaugusto/jolt/web';
|
|
2
|
+
import { type MotionVisualAdapter } from '@getcortexlabs/mavis-core/experimental';
|
|
3
|
+
export declare function webVisualEffects(owner: WebRuntime | WebMotionScope, target: HTMLElement, sources: WeakMap<object, WebReadableValue>, plainText: () => boolean): MotionVisualAdapter;
|
|
4
|
+
//# sourceMappingURL=visual-effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-effects.d.ts","sourceRoot":"","sources":["../src/visual-effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAEjB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,wCAAwC,CAAA;AAG/C,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,GAAG,cAAc,EAClC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC1C,SAAS,EAAE,MAAM,OAAO,GACvB,mBAAmB,CAsHrB"}
|
|
@@ -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,E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AAA;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.
|
|
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.
|
|
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.
|
|
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,96 @@
|
|
|
1
|
+
import { defineComponent, h, ref, watch, type PropType } from 'vue'
|
|
2
|
+
import { choiceMotion, type ChoicePaint } from '@getcortexlabs/mavis-core'
|
|
3
|
+
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { useConnectedMotion } from '../connected-motion.js'
|
|
5
|
+
import { useMotionContext } from '../motion-context.js'
|
|
6
|
+
|
|
7
|
+
/** One paint owner per decorative surface; native control semantics remain in the parent. */
|
|
8
|
+
export const ChoicePaintSurface = defineComponent({
|
|
9
|
+
name: 'MavisChoicePaint',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: { paint: { type: Object as PropType<ChoicePaint>, required: true } },
|
|
12
|
+
setup(props, { slots, attrs }) {
|
|
13
|
+
const element = ref<HTMLElement>()
|
|
14
|
+
const { theme } = useMavisTheme()
|
|
15
|
+
const forcedColors = ref(false)
|
|
16
|
+
const initial = {
|
|
17
|
+
position: 'absolute' as const,
|
|
18
|
+
inset: 'calc(-1 * var(--m-choice-border, 0px))',
|
|
19
|
+
border: 'inherit',
|
|
20
|
+
borderRadius: 'inherit',
|
|
21
|
+
boxSizing: 'border-box' as const,
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
...props.paint,
|
|
26
|
+
}
|
|
27
|
+
useConnectedMotion(element, useMotionContext(), (runtime, target) => {
|
|
28
|
+
const forced = target.ownerDocument.defaultView!.matchMedia('(forced-colors: active)')
|
|
29
|
+
let playback: ReturnType<typeof runtime.animate> | undefined
|
|
30
|
+
let geometry: ReturnType<typeof runtime.observeGeometry> | undefined
|
|
31
|
+
function update(instant = false) {
|
|
32
|
+
forcedColors.value = forced.matches
|
|
33
|
+
if (forced.matches) {
|
|
34
|
+
playback?.stop()
|
|
35
|
+
playback = undefined
|
|
36
|
+
runtime.release(target)
|
|
37
|
+
geometry?.dispose()
|
|
38
|
+
geometry = undefined
|
|
39
|
+
for (const key of ['background-color', 'border-color', 'color'])
|
|
40
|
+
target.style.removeProperty(key)
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
if (!geometry) {
|
|
44
|
+
runtime.set(target, props.paint)
|
|
45
|
+
geometry = runtime.observeGeometry(target)
|
|
46
|
+
}
|
|
47
|
+
const previous = playback
|
|
48
|
+
playback = runtime.animate(
|
|
49
|
+
target,
|
|
50
|
+
props.paint,
|
|
51
|
+
instant ? { duration: 0 } : choiceMotion(theme.value),
|
|
52
|
+
)
|
|
53
|
+
previous?.stop()
|
|
54
|
+
}
|
|
55
|
+
const changed = () => update(true)
|
|
56
|
+
forced.addEventListener('change', changed)
|
|
57
|
+
update(true)
|
|
58
|
+
const unwatch = watch(
|
|
59
|
+
() => [props.paint, theme.value.motion],
|
|
60
|
+
() => update(),
|
|
61
|
+
{ deep: true, flush: 'post' },
|
|
62
|
+
)
|
|
63
|
+
return () => {
|
|
64
|
+
unwatch()
|
|
65
|
+
forced.removeEventListener('change', changed)
|
|
66
|
+
playback?.stop()
|
|
67
|
+
runtime.release(target)
|
|
68
|
+
geometry?.dispose()
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
return () =>
|
|
72
|
+
h('span', { ...attrs, 'aria-hidden': 'true' }, [
|
|
73
|
+
h(
|
|
74
|
+
'span',
|
|
75
|
+
{
|
|
76
|
+
ref: element,
|
|
77
|
+
style: {
|
|
78
|
+
...initial,
|
|
79
|
+
// Vue patches style objects on slot updates. Preserve the paint written by Jolt.
|
|
80
|
+
...Object.fromEntries(
|
|
81
|
+
Object.keys(props.paint).map((key) => [
|
|
82
|
+
key,
|
|
83
|
+
forcedColors.value
|
|
84
|
+
? undefined
|
|
85
|
+
: element.value?.style?.[key as 'backgroundColor'] ||
|
|
86
|
+
initial[key as keyof typeof initial],
|
|
87
|
+
]),
|
|
88
|
+
),
|
|
89
|
+
},
|
|
90
|
+
'data-m-choice-paint': '',
|
|
91
|
+
},
|
|
92
|
+
slots.default?.(),
|
|
93
|
+
),
|
|
94
|
+
])
|
|
95
|
+
},
|
|
96
|
+
})
|
|
@@ -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
|
|
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 }),
|
package/src/components/MCard.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveSpace, resolveRadius, shadowStyle } from '@getcortexlabs/mavis-core'
|
|
2
|
-
import { defineComponent, h, mergeProps } from 'vue'
|
|
2
|
+
import { defineComponent, h, mergeProps, shallowRef, type VNode } from 'vue'
|
|
3
|
+
import { preserveBoundPaint } from '../motion-surface.js'
|
|
3
4
|
import {
|
|
4
5
|
useButtonAction,
|
|
5
6
|
cardProps,
|
|
@@ -20,6 +21,7 @@ export const MCard = defineComponent({
|
|
|
20
21
|
setup(props, { attrs, slots, emit }) {
|
|
21
22
|
useButtonAction(() => props.interactive || props.href !== undefined)
|
|
22
23
|
const { theme } = useMavisTheme()
|
|
24
|
+
const element = shallowRef<HTMLElement>()
|
|
23
25
|
const lifecycle = usePressFeedback(
|
|
24
26
|
() => (props.interactive || props.href !== undefined) && !props.disabled,
|
|
25
27
|
theme,
|
|
@@ -83,6 +85,12 @@ export const MCard = defineComponent({
|
|
|
83
85
|
},
|
|
84
86
|
},
|
|
85
87
|
attrs,
|
|
88
|
+
{
|
|
89
|
+
onVnodeMounted: (node: VNode) => {
|
|
90
|
+
element.value = node.el as HTMLElement
|
|
91
|
+
},
|
|
92
|
+
style: preserveBoundPaint(element.value),
|
|
93
|
+
},
|
|
86
94
|
href !== undefined
|
|
87
95
|
? navigationAttrs(props, disabled, activate, (error) => emit('error', error))
|
|
88
96
|
: interactive
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChoicePaintSurface } from './ChoicePaint.js'
|
|
1
2
|
import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
2
3
|
import { defineComponent, h, mergeProps, nextTick, onBeforeUnmount, useId } from 'vue'
|
|
3
4
|
import {
|
|
@@ -110,9 +111,19 @@ export const MCheckbox = defineComponent({
|
|
|
110
111
|
})
|
|
111
112
|
},
|
|
112
113
|
}),
|
|
113
|
-
h(
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
h(
|
|
115
|
+
ChoicePaintSurface,
|
|
116
|
+
{
|
|
117
|
+
class: 'm-checkbox-box',
|
|
118
|
+
paint: {
|
|
119
|
+
backgroundColor:
|
|
120
|
+
props.modelValue || props.indeterminate ? colors.primary : colors.surface,
|
|
121
|
+
borderColor:
|
|
122
|
+
props.modelValue || props.indeterminate ? colors.primary : colors.muted,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
() => [h('span', { class: 'm-checkbox-mark' })],
|
|
126
|
+
),
|
|
116
127
|
h(
|
|
117
128
|
'span',
|
|
118
129
|
{
|
|
@@ -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
|
)
|