@getcortexlabs/mavis-web 0.1.0-alpha.9 → 0.1.0-rc.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/animated-number.d.ts +3 -0
- package/dist/animated-number.d.ts.map +1 -0
- package/dist/animated-number.js +61 -0
- package/dist/animated-number.js.map +1 -0
- package/dist/component-motion.d.ts +18 -0
- package/dist/component-motion.d.ts.map +1 -0
- package/dist/component-motion.js +156 -0
- package/dist/component-motion.js.map +1 -0
- package/dist/component-width.d.ts +6 -0
- package/dist/component-width.d.ts.map +1 -0
- package/dist/component-width.js +30 -0
- package/dist/component-width.js.map +1 -0
- package/dist/components/ChartPlot.d.ts +66 -0
- package/dist/components/ChartPlot.d.ts.map +1 -0
- package/dist/components/ChartPlot.js +254 -0
- package/dist/components/ChartPlot.js.map +1 -0
- package/dist/components/DateCalendar.d.ts +15 -0
- package/dist/components/DateCalendar.d.ts.map +1 -1
- package/dist/components/DateCalendar.js +58 -12
- package/dist/components/DateCalendar.js.map +1 -1
- package/dist/components/LoadingDecoration.d.ts +4 -4
- package/dist/components/MAccordion.d.ts +1 -1
- package/dist/components/MAlert.d.ts +4 -4
- package/dist/components/MAlert.d.ts.map +1 -1
- package/dist/components/MAlert.js +3 -0
- package/dist/components/MAlert.js.map +1 -1
- package/dist/components/MAvatar.d.ts +1 -1
- package/dist/components/MAvatar.d.ts.map +1 -1
- package/dist/components/MAvatar.js +4 -0
- package/dist/components/MAvatar.js.map +1 -1
- package/dist/components/MBadge.d.ts +1 -1
- package/dist/components/MBadge.d.ts.map +1 -1
- package/dist/components/MBadge.js +5 -1
- package/dist/components/MBadge.js.map +1 -1
- package/dist/components/MButton.d.ts +5 -5
- package/dist/components/MCard.d.ts +7 -7
- package/dist/components/MCheckbox.d.ts +1 -1
- package/dist/components/MChip.d.ts +2 -2
- package/dist/components/MChip.d.ts.map +1 -1
- package/dist/components/MChip.js +4 -2
- package/dist/components/MChip.js.map +1 -1
- package/dist/components/MCombobox.d.ts +5 -5
- package/dist/components/MCombobox.d.ts.map +1 -1
- package/dist/components/MCombobox.js +121 -92
- package/dist/components/MCombobox.js.map +1 -1
- package/dist/components/MDatePicker.d.ts +16 -16
- package/dist/components/MDialog.d.ts +4 -4
- package/dist/components/MDialog.d.ts.map +1 -1
- package/dist/components/MDialog.js +9 -4
- package/dist/components/MDialog.js.map +1 -1
- package/dist/components/MEmptyState.d.ts +2 -2
- package/dist/components/MEmptyState.d.ts.map +1 -1
- package/dist/components/MEmptyState.js +3 -0
- package/dist/components/MEmptyState.js.map +1 -1
- package/dist/components/MFilePicker.d.ts +4 -4
- package/dist/components/MFilePicker.d.ts.map +1 -1
- package/dist/components/MFilePicker.js +3 -1
- package/dist/components/MFilePicker.js.map +1 -1
- package/dist/components/MGrid.d.ts +16 -5
- package/dist/components/MGrid.d.ts.map +1 -1
- package/dist/components/MGrid.js +12 -2
- package/dist/components/MGrid.js.map +1 -1
- package/dist/components/MIcon.d.ts +2 -2
- package/dist/components/MImage.d.ts +5 -5
- package/dist/components/MImage.d.ts.map +1 -1
- package/dist/components/MImage.js +8 -1
- package/dist/components/MImage.js.map +1 -1
- package/dist/components/MImageCompare.d.ts +92 -0
- package/dist/components/MImageCompare.d.ts.map +1 -0
- package/dist/components/MImageCompare.js +177 -0
- package/dist/components/MImageCompare.js.map +1 -0
- package/dist/components/MImageViewer.d.ts +121 -0
- package/dist/components/MImageViewer.d.ts.map +1 -0
- package/dist/components/MImageViewer.js +490 -0
- package/dist/components/MImageViewer.js.map +1 -0
- package/dist/components/MInput.d.ts +7 -7
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +5 -0
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MListItem.d.ts +2 -2
- package/dist/components/MPopover.d.ts +105 -0
- package/dist/components/MPopover.d.ts.map +1 -0
- package/dist/components/MPopover.js +256 -0
- package/dist/components/MPopover.js.map +1 -0
- package/dist/components/MProgress.d.ts +3 -3
- package/dist/components/MProgress.d.ts.map +1 -1
- package/dist/components/MProgress.js +34 -11
- package/dist/components/MProgress.js.map +1 -1
- package/dist/components/MRadioGroup.d.ts +1 -1
- package/dist/components/MRangeSlider.d.ts +104 -0
- package/dist/components/MRangeSlider.d.ts.map +1 -0
- package/dist/components/MRangeSlider.js +125 -0
- package/dist/components/MRangeSlider.js.map +1 -0
- package/dist/components/MResizablePanels.d.ts +137 -0
- package/dist/components/MResizablePanels.d.ts.map +1 -0
- package/dist/components/MResizablePanels.js +174 -0
- package/dist/components/MResizablePanels.js.map +1 -0
- package/dist/components/MReveal.d.ts +14 -14
- package/dist/components/MSegmentedControl.d.ts +1 -1
- package/dist/components/MSegmentedControl.d.ts.map +1 -1
- package/dist/components/MSegmentedControl.js +6 -2
- package/dist/components/MSegmentedControl.js.map +1 -1
- package/dist/components/MSelect.d.ts +3 -3
- package/dist/components/MSeparator.d.ts +1 -1
- package/dist/components/MSheet.d.ts +6 -6
- package/dist/components/MSkeleton.d.ts +2 -2
- package/dist/components/MStack.d.ts +25 -14
- package/dist/components/MStack.d.ts.map +1 -1
- package/dist/components/MStack.js +5 -1
- package/dist/components/MStack.js.map +1 -1
- package/dist/components/MSwitch.d.ts +1 -1
- package/dist/components/MTabs.d.ts +1 -1
- package/dist/components/MTabs.d.ts.map +1 -1
- package/dist/components/MTabs.js +6 -3
- package/dist/components/MTabs.js.map +1 -1
- package/dist/components/MText.d.ts +3 -3
- package/dist/components/MTimePicker.d.ts +655 -0
- package/dist/components/MTimePicker.d.ts.map +1 -0
- package/dist/components/MTimePicker.js +81 -0
- package/dist/components/MTimePicker.js.map +1 -0
- package/dist/components/MToast.d.ts.map +1 -1
- package/dist/components/MToast.js +5 -1
- package/dist/components/MToast.js.map +1 -1
- package/dist/components/MTooltip.d.ts +65 -0
- package/dist/components/MTooltip.d.ts.map +1 -0
- package/dist/components/MTooltip.js +256 -0
- package/dist/components/MTooltip.js.map +1 -0
- package/dist/components/MVirtualList.d.ts +3 -0
- package/dist/components/MVirtualList.d.ts.map +1 -0
- package/dist/components/MVirtualList.js +118 -0
- package/dist/components/MVirtualList.js.map +1 -0
- package/dist/components/MotionRows.d.ts +26 -0
- package/dist/components/MotionRows.d.ts.map +1 -0
- package/dist/components/MotionRows.js +16 -0
- package/dist/components/MotionRows.js.map +1 -0
- package/dist/components/RangeHalo.d.ts +19 -0
- package/dist/components/RangeHalo.d.ts.map +1 -0
- package/dist/components/RangeHalo.js +29 -0
- package/dist/components/RangeHalo.js.map +1 -0
- package/dist/components/configurator.d.ts +2 -2
- package/dist/components/discovery.d.ts +282 -0
- package/dist/components/discovery.d.ts.map +1 -0
- package/dist/components/discovery.js +104 -0
- package/dist/components/discovery.js.map +1 -0
- package/dist/components/interactive.d.ts +163 -0
- package/dist/components/interactive.d.ts.map +1 -0
- package/dist/components/interactive.js +40 -0
- package/dist/components/interactive.js.map +1 -0
- package/dist/components/layout.d.ts +81 -48
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/components/layout.js +2 -1
- package/dist/components/layout.js.map +1 -1
- package/dist/components/navigation.d.ts +225 -0
- package/dist/components/navigation.d.ts.map +1 -0
- package/dist/components/navigation.js +41 -0
- package/dist/components/navigation.js.map +1 -0
- package/dist/components/wayfinding.d.ts +441 -0
- package/dist/components/wayfinding.d.ts.map +1 -0
- package/dist/components/wayfinding.js +58 -0
- package/dist/components/wayfinding.js.map +1 -0
- package/dist/components/workflows.d.ts +2 -2
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/motion-region.d.ts.map +1 -1
- package/dist/motion-region.js +4 -2
- package/dist/motion-region.js.map +1 -1
- package/dist/motion-surface.d.ts.map +1 -1
- package/dist/motion-surface.js +2 -0
- package/dist/motion-surface.js.map +1 -1
- package/dist/motion.js +1 -1
- package/dist/motion.js.map +1 -1
- package/dist/nuxt-navigation.d.ts +18 -0
- package/dist/nuxt-navigation.d.ts.map +1 -0
- package/dist/nuxt-navigation.js +23 -0
- package/dist/nuxt-navigation.js.map +1 -0
- package/dist/partition-pointer.d.ts +19 -0
- package/dist/partition-pointer.d.ts.map +1 -0
- package/dist/partition-pointer.js +78 -0
- package/dist/partition-pointer.js.map +1 -0
- package/dist/router-navigation.d.ts +31 -0
- package/dist/router-navigation.d.ts.map +1 -0
- package/dist/router-navigation.js +215 -0
- package/dist/router-navigation.js.map +1 -0
- package/dist/screen-viewport.d.ts.map +1 -1
- package/dist/screen-viewport.js +6 -4
- package/dist/screen-viewport.js.map +1 -1
- package/dist/section-scroll.d.ts +8 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +79 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +6 -2
- package/dist/services.js.map +1 -1
- package/package.json +4 -4
- package/src/animated-number.ts +59 -0
- package/src/base.css +126 -17
- package/src/component-motion.ts +176 -0
- package/src/component-width.ts +34 -0
- package/src/components/ChartPlot.ts +277 -0
- package/src/components/DateCalendar.ts +71 -11
- package/src/components/MAlert.ts +3 -0
- package/src/components/MAvatar.ts +4 -0
- package/src/components/MBadge.ts +10 -1
- package/src/components/MChip.ts +4 -2
- package/src/components/MCombobox.ts +136 -101
- package/src/components/MDialog.ts +9 -4
- package/src/components/MEmptyState.ts +3 -0
- package/src/components/MFilePicker.ts +3 -1
- package/src/components/MGrid.ts +25 -1
- package/src/components/MImage.ts +10 -1
- package/src/components/MImageCompare.ts +218 -0
- package/src/components/MImageViewer.ts +560 -0
- package/src/components/MInput.ts +5 -0
- package/src/components/MPopover.ts +300 -0
- package/src/components/MProgress.ts +36 -11
- package/src/components/MRangeSlider.ts +144 -0
- package/src/components/MResizablePanels.ts +208 -0
- package/src/components/MSegmentedControl.ts +6 -2
- package/src/components/MStack.ts +5 -0
- package/src/components/MTabs.ts +9 -3
- package/src/components/MTimePicker.ts +124 -0
- package/src/components/MToast.ts +5 -1
- package/src/components/MTooltip.ts +291 -0
- package/src/components/MVirtualList.ts +155 -0
- package/src/components/MotionRows.ts +16 -0
- package/src/components/RangeHalo.ts +34 -0
- package/src/components/discovery.ts +147 -0
- package/src/components/interactive.ts +60 -0
- package/src/components/layout.ts +2 -0
- package/src/components/navigation.ts +44 -0
- package/src/components/wayfinding.ts +70 -0
- package/src/index.ts +81 -1
- package/src/motion-region.ts +5 -2
- package/src/motion-surface.ts +10 -0
- package/src/motion.ts +1 -1
- package/src/nuxt-navigation.ts +29 -0
- package/src/partition-pointer.ts +88 -0
- package/src/router-navigation.ts +249 -0
- package/src/screen-viewport.ts +8 -4
- package/src/section-scroll.ts +101 -0
- package/src/services.ts +7 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { useMotionRegion } from '../motion-region.js'
|
|
3
|
+
import { useComponentTransition } from '../component-motion.js'
|
|
1
4
|
import {
|
|
2
5
|
defineComponent,
|
|
3
6
|
Teleport,
|
|
7
|
+
Transition,
|
|
4
8
|
shallowRef,
|
|
5
9
|
type CSSProperties,
|
|
6
10
|
h,
|
|
@@ -46,6 +50,22 @@ const Combobox = defineComponent({
|
|
|
46
50
|
useButtonAction()
|
|
47
51
|
const { theme } = useMavisTheme()
|
|
48
52
|
const combo = useCombobox(props, emit)
|
|
53
|
+
const resultLayout = useComponentLayout(
|
|
54
|
+
() => combo.state.value.options.map((option) => option.value),
|
|
55
|
+
false,
|
|
56
|
+
)
|
|
57
|
+
const resultMotion = useMotionRegion(() => resultLayout)
|
|
58
|
+
const popupMotion = {
|
|
59
|
+
...useComponentTransition(4),
|
|
60
|
+
onBeforeLeave: (element: Element) => {
|
|
61
|
+
element.setAttribute('inert', '')
|
|
62
|
+
element.setAttribute('aria-hidden', 'true')
|
|
63
|
+
},
|
|
64
|
+
onBeforeEnter: (element: Element) => {
|
|
65
|
+
element.removeAttribute('inert')
|
|
66
|
+
element.removeAttribute('aria-hidden')
|
|
67
|
+
},
|
|
68
|
+
}
|
|
49
69
|
const shrink = useLayoutShrink()
|
|
50
70
|
const generatedId = `m-combobox-${useId()}`
|
|
51
71
|
const root = ref<HTMLElement>()
|
|
@@ -391,120 +411,135 @@ const Combobox = defineComponent({
|
|
|
391
411
|
tone: 'primary',
|
|
392
412
|
})
|
|
393
413
|
: null,
|
|
394
|
-
|
|
395
|
-
? h(Teleport, { to: popupHost.value
|
|
396
|
-
h(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
ref: popup,
|
|
401
|
-
onFocusout: focusout,
|
|
402
|
-
style: {
|
|
403
|
-
position: 'fixed',
|
|
404
|
-
zIndex: 40,
|
|
405
|
-
boxSizing: 'border-box',
|
|
406
|
-
overflowY: 'auto',
|
|
407
|
-
overscrollBehavior: 'contain',
|
|
408
|
-
...placement.value,
|
|
409
|
-
border: `1px solid ${colors.border}`,
|
|
410
|
-
borderRadius: `${radius.md}px`,
|
|
411
|
-
padding: '4px',
|
|
412
|
-
backgroundColor: colors.surface,
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
[
|
|
416
|
-
h(
|
|
417
|
-
'div',
|
|
418
|
-
{
|
|
419
|
-
id: `${id}-results`,
|
|
420
|
-
role: 'listbox',
|
|
421
|
-
'aria-label': props.label,
|
|
422
|
-
'aria-busy':
|
|
423
|
-
state.status === 'loading' || state.status === 'debouncing',
|
|
424
|
-
style: { minHeight: 0 },
|
|
425
|
-
},
|
|
426
|
-
state.options.map((option) => {
|
|
427
|
-
const key = choiceKey(option.value)
|
|
428
|
-
const highlighted = combo.active.value === key
|
|
429
|
-
const checked = props.modelValue === option.value
|
|
430
|
-
return h(
|
|
414
|
+
popupHost.value
|
|
415
|
+
? h(Teleport, { to: popupHost.value }, [
|
|
416
|
+
h(Transition, popupMotion, {
|
|
417
|
+
default: () =>
|
|
418
|
+
open
|
|
419
|
+
? h(
|
|
431
420
|
'div',
|
|
432
421
|
{
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
'aria-selected': highlighted,
|
|
437
|
-
'aria-disabled': option.disabled || undefined,
|
|
438
|
-
'aria-label': option.label,
|
|
439
|
-
'data-selected': checked,
|
|
440
|
-
'data-active': highlighted,
|
|
441
|
-
ref: (element: unknown) => {
|
|
442
|
-
if (element) rows.set(key, element as HTMLElement)
|
|
443
|
-
else rows.delete(key)
|
|
444
|
-
},
|
|
422
|
+
class: 'm-combobox-popup',
|
|
423
|
+
ref: popup,
|
|
424
|
+
onFocusout: focusout,
|
|
445
425
|
style: {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
gap: '12px',
|
|
449
|
-
minHeight: '48px',
|
|
426
|
+
position: 'fixed',
|
|
427
|
+
zIndex: 40,
|
|
450
428
|
boxSizing: 'border-box',
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
opacity: option.disabled ? 0.45 : 1,
|
|
459
|
-
cursor: option.disabled ? 'default' : 'pointer',
|
|
460
|
-
},
|
|
461
|
-
onPointerdown: (event: PointerEvent) => {
|
|
462
|
-
if (event.button === 0) event.preventDefault()
|
|
429
|
+
overflowY: 'auto',
|
|
430
|
+
overscrollBehavior: 'contain',
|
|
431
|
+
...placement.value,
|
|
432
|
+
border: `1px solid ${colors.border}`,
|
|
433
|
+
borderRadius: `${radius.md}px`,
|
|
434
|
+
padding: '4px',
|
|
435
|
+
backgroundColor: colors.surface,
|
|
463
436
|
},
|
|
464
|
-
onClick: () => combo.choose(option),
|
|
465
437
|
},
|
|
466
438
|
[
|
|
467
439
|
h(
|
|
468
440
|
'div',
|
|
469
|
-
{
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
441
|
+
{
|
|
442
|
+
...resultMotion,
|
|
443
|
+
id: `${id}-results`,
|
|
444
|
+
role: 'listbox',
|
|
445
|
+
'aria-label': props.label,
|
|
446
|
+
'aria-busy':
|
|
447
|
+
state.status === 'loading' || state.status === 'debouncing',
|
|
448
|
+
style: { minHeight: 0 },
|
|
449
|
+
},
|
|
450
|
+
state.options.map((option) => {
|
|
451
|
+
const key = choiceKey(option.value)
|
|
452
|
+
const highlighted = combo.active.value === key
|
|
453
|
+
const checked = props.modelValue === option.value
|
|
454
|
+
return h(
|
|
455
|
+
'div',
|
|
456
|
+
{
|
|
457
|
+
key,
|
|
458
|
+
id: optionId(key),
|
|
459
|
+
role: 'option',
|
|
460
|
+
'aria-selected': highlighted,
|
|
461
|
+
'aria-disabled': option.disabled || undefined,
|
|
462
|
+
'aria-label': option.label,
|
|
463
|
+
'data-selected': checked,
|
|
464
|
+
'data-active': highlighted,
|
|
465
|
+
ref: (element: unknown) => {
|
|
466
|
+
if (element) rows.set(key, element as HTMLElement)
|
|
467
|
+
else rows.delete(key)
|
|
468
|
+
},
|
|
469
|
+
style: {
|
|
470
|
+
display: 'flex',
|
|
471
|
+
alignItems: 'center',
|
|
472
|
+
gap: '12px',
|
|
473
|
+
minHeight: '48px',
|
|
474
|
+
boxSizing: 'border-box',
|
|
475
|
+
padding: '10px 12px',
|
|
476
|
+
color: colors.text,
|
|
477
|
+
backgroundColor: highlighted
|
|
478
|
+
? colors.primarySoft
|
|
479
|
+
: 'transparent',
|
|
480
|
+
border: `2px solid ${highlighted ? colors.primary : 'transparent'}`,
|
|
481
|
+
borderRadius: `${radius.sm}px`,
|
|
482
|
+
opacity: option.disabled ? 0.45 : 1,
|
|
483
|
+
cursor: option.disabled ? 'default' : 'pointer',
|
|
484
|
+
},
|
|
485
|
+
onPointerdown: (event: PointerEvent) => {
|
|
486
|
+
if (event.button === 0) event.preventDefault()
|
|
487
|
+
},
|
|
488
|
+
onClick: () => combo.choose(option),
|
|
489
|
+
},
|
|
490
|
+
[
|
|
491
|
+
h(
|
|
492
|
+
'div',
|
|
493
|
+
{
|
|
494
|
+
style: {
|
|
495
|
+
minWidth: 0,
|
|
496
|
+
flex: 1,
|
|
497
|
+
overflowWrap: 'break-word',
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
[
|
|
501
|
+
h(MText, { text: option.label }),
|
|
502
|
+
option.helperText
|
|
503
|
+
? h(MText, {
|
|
504
|
+
text: option.helperText,
|
|
505
|
+
variant: 'caption',
|
|
506
|
+
tone: 'muted',
|
|
507
|
+
})
|
|
508
|
+
: null,
|
|
509
|
+
],
|
|
510
|
+
),
|
|
511
|
+
checked
|
|
512
|
+
? h(MIcon, { name: 'check', tone: 'primary' })
|
|
513
|
+
: null,
|
|
514
|
+
],
|
|
515
|
+
)
|
|
516
|
+
}),
|
|
517
|
+
),
|
|
518
|
+
h(
|
|
519
|
+
'div',
|
|
520
|
+
{ role: 'status', 'aria-live': 'polite' },
|
|
521
|
+
status
|
|
522
|
+
? h(MText, {
|
|
523
|
+
text: status,
|
|
524
|
+
tone: state.status === 'error' ? 'danger' : 'muted',
|
|
525
|
+
variant: 'caption',
|
|
526
|
+
style: { padding: '12px' },
|
|
527
|
+
})
|
|
528
|
+
: undefined,
|
|
480
529
|
),
|
|
481
|
-
|
|
530
|
+
state.status === 'error'
|
|
531
|
+
? h(MButton, {
|
|
532
|
+
text: props.retryLabel,
|
|
533
|
+
variant: 'ghost',
|
|
534
|
+
onPointerdown: (event: PointerEvent) =>
|
|
535
|
+
event.preventDefault(),
|
|
536
|
+
onClick: combo.retry,
|
|
537
|
+
})
|
|
538
|
+
: null,
|
|
482
539
|
],
|
|
483
540
|
)
|
|
484
|
-
}),
|
|
485
|
-
),
|
|
486
|
-
h(
|
|
487
|
-
'div',
|
|
488
|
-
{ role: 'status', 'aria-live': 'polite' },
|
|
489
|
-
status
|
|
490
|
-
? h(MText, {
|
|
491
|
-
text: status,
|
|
492
|
-
tone: state.status === 'error' ? 'danger' : 'muted',
|
|
493
|
-
variant: 'caption',
|
|
494
|
-
style: { padding: '12px' },
|
|
495
|
-
})
|
|
496
|
-
: undefined,
|
|
497
|
-
),
|
|
498
|
-
state.status === 'error'
|
|
499
|
-
? h(MButton, {
|
|
500
|
-
text: props.retryLabel,
|
|
501
|
-
variant: 'ghost',
|
|
502
|
-
onPointerdown: (event: PointerEvent) => event.preventDefault(),
|
|
503
|
-
onClick: combo.retry,
|
|
504
|
-
})
|
|
505
541
|
: null,
|
|
506
|
-
|
|
507
|
-
),
|
|
542
|
+
}),
|
|
508
543
|
])
|
|
509
544
|
: null,
|
|
510
545
|
],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useComponentTransition } from '../component-motion.js'
|
|
1
2
|
import {
|
|
2
3
|
defineComponent,
|
|
3
4
|
h,
|
|
@@ -48,6 +49,7 @@ export const MDialog = defineComponent({
|
|
|
48
49
|
emit,
|
|
49
50
|
)
|
|
50
51
|
const { theme } = useMavisTheme()
|
|
52
|
+
const transition = useComponentTransition(8)
|
|
51
53
|
const titleId = `m-dialog-${useId()}`
|
|
52
54
|
let current: HTMLDialogElement | undefined
|
|
53
55
|
let opener: HTMLElement | undefined
|
|
@@ -163,11 +165,13 @@ export const MDialog = defineComponent({
|
|
|
163
165
|
Transition,
|
|
164
166
|
{
|
|
165
167
|
name: 'm-dialog',
|
|
166
|
-
|
|
167
|
-
css: !props.interactive,
|
|
168
|
+
...transition,
|
|
168
169
|
onEnter: props.interactive
|
|
169
170
|
? (element: Element, done: () => void) => enter(element, done)
|
|
170
|
-
: (element: Element) =>
|
|
171
|
+
: (element: Element, done: () => void) => {
|
|
172
|
+
enter(element)
|
|
173
|
+
transition.onEnter(element, done)
|
|
174
|
+
},
|
|
171
175
|
onLeave: props.interactive
|
|
172
176
|
? (_element: Element, done: () => void) => {
|
|
173
177
|
left = done
|
|
@@ -176,8 +180,9 @@ export const MDialog = defineComponent({
|
|
|
176
180
|
done()
|
|
177
181
|
} else motion.close()
|
|
178
182
|
}
|
|
179
|
-
:
|
|
183
|
+
: transition.onLeave,
|
|
180
184
|
onAfterLeave: (element: Element) => {
|
|
185
|
+
transition.onAfterLeave(element)
|
|
181
186
|
release(element as HTMLDialogElement)
|
|
182
187
|
state.left()
|
|
183
188
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
|
|
1
2
|
import { defineComponent, h, mergeProps, type SlotsType, type VNode } from 'vue'
|
|
2
3
|
import { checkEmptyStateTitle } from '@getcortexlabs/mavis-core'
|
|
3
4
|
import { emptyStateProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
@@ -12,6 +13,7 @@ export const MEmptyState = defineComponent({
|
|
|
12
13
|
slots: Object as SlotsType<{ illustration?: () => VNode[]; actions?: () => VNode[] }>,
|
|
13
14
|
setup(props, { attrs, slots }) {
|
|
14
15
|
const { theme } = useMavisTheme()
|
|
16
|
+
const arrival = useComponentContent(() => props.title)
|
|
15
17
|
return () => {
|
|
16
18
|
checkEmptyStateTitle(props.title)
|
|
17
19
|
const { colors } = theme.value
|
|
@@ -23,6 +25,7 @@ export const MEmptyState = defineComponent({
|
|
|
23
25
|
{
|
|
24
26
|
width: size,
|
|
25
27
|
height: size,
|
|
28
|
+
motionSurface: arrival,
|
|
26
29
|
},
|
|
27
30
|
{
|
|
28
31
|
default: () => [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
|
|
1
2
|
import {
|
|
2
3
|
defineComponent,
|
|
3
4
|
h,
|
|
@@ -27,6 +28,7 @@ const FilePicker = defineComponent({
|
|
|
27
28
|
useButtonAction()
|
|
28
29
|
const root = ref<HTMLElement>()
|
|
29
30
|
const state = shallowRef(props.selection.state)
|
|
31
|
+
const layout = useComponentLayout(() => state.value.items.map((item) => item.id))
|
|
30
32
|
const picker = createWebFilePicker()
|
|
31
33
|
let mounted = false
|
|
32
34
|
let unsubscribe = () => {}
|
|
@@ -90,7 +92,7 @@ const FilePicker = defineComponent({
|
|
|
90
92
|
[
|
|
91
93
|
h(
|
|
92
94
|
MColumn,
|
|
93
|
-
{ gap: 'md' },
|
|
95
|
+
{ gap: 'md', motionRegion: layout },
|
|
94
96
|
{
|
|
95
97
|
default: () => [
|
|
96
98
|
h(MText, { text: props.label, weight: '600' }),
|
package/src/components/MGrid.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMotionRegion } from '../motion-region.js'
|
|
2
|
+
import { defineComponent, h, mergeProps, provide, shallowRef, watch } from 'vue'
|
|
2
3
|
import { gridColumns, resolveSpace } from '@getcortexlabs/mavis-core'
|
|
3
4
|
import {
|
|
4
5
|
gridProps,
|
|
5
6
|
layoutDirection,
|
|
6
7
|
useLayoutShrink,
|
|
7
8
|
useMavisTheme,
|
|
9
|
+
useComponentLayout,
|
|
8
10
|
viewAttrs,
|
|
9
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
10
12
|
import { boxStyle, webAttrs } from '../style.js'
|
|
@@ -20,6 +22,27 @@ export const MGrid = defineComponent({
|
|
|
20
22
|
provide(layoutDirection, 'column')
|
|
21
23
|
const element = shallowRef<HTMLElement>()
|
|
22
24
|
const width = useContentWidth(element, () => props.minColumnWidth !== undefined)
|
|
25
|
+
let measured = false
|
|
26
|
+
watch(
|
|
27
|
+
width,
|
|
28
|
+
() => {
|
|
29
|
+
measured = width.value !== undefined
|
|
30
|
+
},
|
|
31
|
+
{ flush: 'post' },
|
|
32
|
+
)
|
|
33
|
+
const automatic = useComponentLayout(
|
|
34
|
+
() =>
|
|
35
|
+
gridColumns(
|
|
36
|
+
props.columns,
|
|
37
|
+
props.minColumnWidth,
|
|
38
|
+
resolveSpace(theme.value, props.gap ?? 'none'),
|
|
39
|
+
width.value,
|
|
40
|
+
),
|
|
41
|
+
false,
|
|
42
|
+
// Establish the initial responsive layout before capturing animated changes.
|
|
43
|
+
() => props.minColumnWidth === undefined || measured,
|
|
44
|
+
)
|
|
45
|
+
const motion = useMotionRegion(() => props.motionRegion ?? automatic)
|
|
23
46
|
return () => {
|
|
24
47
|
const gap = resolveSpace(theme.value, props.gap ?? 'none')
|
|
25
48
|
const columns = gridColumns(props.columns, props.minColumnWidth, gap, width.value)
|
|
@@ -27,6 +50,7 @@ export const MGrid = defineComponent({
|
|
|
27
50
|
'div',
|
|
28
51
|
mergeProps(
|
|
29
52
|
{
|
|
53
|
+
...motion,
|
|
30
54
|
ref: element,
|
|
31
55
|
class: 'm-grid',
|
|
32
56
|
style: {
|
package/src/components/MImage.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { markRaw, onScopeDispose } from 'vue'
|
|
2
|
+
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
3
|
+
import { componentMotion } from '@getcortexlabs/mavis-core'
|
|
1
4
|
import { defineComponent, h, mergeProps, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
2
5
|
import { imageProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
6
|
import { resolveRadius, resolveDimension } from '@getcortexlabs/mavis-core'
|
|
@@ -16,6 +19,12 @@ export const MImage = defineComponent({
|
|
|
16
19
|
},
|
|
17
20
|
setup(props, { attrs, emit }) {
|
|
18
21
|
const { theme } = useMavisTheme()
|
|
22
|
+
const reveal = markRaw(createMotionSurface())
|
|
23
|
+
onScopeDispose(
|
|
24
|
+
reveal.use((owner) => {
|
|
25
|
+
owner.animate({ opacity: [0, 1] }, componentMotion(theme.value, 'overlay'))
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
19
28
|
const status = ref<'loading' | 'ready' | 'error'>('loading')
|
|
20
29
|
let generation = 0,
|
|
21
30
|
alive = true
|
|
@@ -23,7 +32,7 @@ export const MImage = defineComponent({
|
|
|
23
32
|
releaseImage: (() => void) | undefined,
|
|
24
33
|
committing: string | undefined
|
|
25
34
|
const motion = useMotionSurface(() =>
|
|
26
|
-
status.value === 'ready' ? props.motionSurface : undefined,
|
|
35
|
+
status.value === 'ready' ? (props.motionSurface ?? reveal) : undefined,
|
|
27
36
|
)
|
|
28
37
|
watch(
|
|
29
38
|
() => [props.src, props.srcset, props.sizes] as const,
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, ref, watch } from 'vue'
|
|
2
|
+
import { finiteRange, positiveSize } from '@getcortexlabs/mavis-core'
|
|
3
|
+
import { imageCompareProps, usePartition, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { useAnimatedNumber } from '../animated-number.js'
|
|
5
|
+
import { usePartitionPointer } from '../partition-pointer.js'
|
|
6
|
+
import { MImage } from './MImage.js'
|
|
7
|
+
|
|
8
|
+
export const MImageCompare = defineComponent({
|
|
9
|
+
name: 'MImageCompare',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: imageCompareProps,
|
|
12
|
+
emits: { 'update:modelValue': (_value: number) => true },
|
|
13
|
+
setup(props, { attrs, emit }) {
|
|
14
|
+
const { theme } = useMavisTheme()
|
|
15
|
+
const root = ref<HTMLElement>()
|
|
16
|
+
const state = usePartition(
|
|
17
|
+
() => finiteRange(props.modelValue, 0, 100),
|
|
18
|
+
() => ({ min: 0, max: 100, step: props.step, disabled: props.disabled }),
|
|
19
|
+
(value) => emit('update:modelValue', value),
|
|
20
|
+
)
|
|
21
|
+
const shown = useAnimatedNumber(
|
|
22
|
+
() => state.canonical.value,
|
|
23
|
+
() => state.dragging.value,
|
|
24
|
+
)
|
|
25
|
+
const vertical = () => props.orientation === 'vertical'
|
|
26
|
+
const gestures = usePartitionPointer(
|
|
27
|
+
{
|
|
28
|
+
...state,
|
|
29
|
+
value: () => state.canonical.value,
|
|
30
|
+
vertical,
|
|
31
|
+
direction: () => 1,
|
|
32
|
+
disabled: () => props.disabled,
|
|
33
|
+
bounds: () => root.value?.getBoundingClientRect(),
|
|
34
|
+
},
|
|
35
|
+
true,
|
|
36
|
+
)
|
|
37
|
+
watch(
|
|
38
|
+
() => props.orientation,
|
|
39
|
+
() => state.cancel(),
|
|
40
|
+
)
|
|
41
|
+
return () => {
|
|
42
|
+
const ratio = finiteRange(shown.value, 0, 100)
|
|
43
|
+
const labelStyle = {
|
|
44
|
+
position: 'absolute' as const,
|
|
45
|
+
top: '14px',
|
|
46
|
+
padding: '6px 12px',
|
|
47
|
+
background: theme.value.colors.surface,
|
|
48
|
+
color: theme.value.colors.text,
|
|
49
|
+
borderRadius: '8px',
|
|
50
|
+
pointerEvents: 'none' as const,
|
|
51
|
+
fontSize: '13px',
|
|
52
|
+
fontWeight: '600',
|
|
53
|
+
}
|
|
54
|
+
return h(
|
|
55
|
+
'figure',
|
|
56
|
+
mergeProps(attrs, {
|
|
57
|
+
class: 'm-image-compare',
|
|
58
|
+
style: { margin: 0 },
|
|
59
|
+
'aria-label': props.label,
|
|
60
|
+
}),
|
|
61
|
+
[
|
|
62
|
+
h(
|
|
63
|
+
'div',
|
|
64
|
+
{
|
|
65
|
+
ref: root,
|
|
66
|
+
style: {
|
|
67
|
+
position: 'relative',
|
|
68
|
+
overflow: 'hidden',
|
|
69
|
+
borderRadius: '16px',
|
|
70
|
+
aspectRatio: String(positiveSize(props.aspectRatio, 'aspectRatio')),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
[
|
|
74
|
+
h(MImage, {
|
|
75
|
+
src: props.after,
|
|
76
|
+
alt: props.afterLabel,
|
|
77
|
+
aspectRatio: props.aspectRatio,
|
|
78
|
+
radius: 'none',
|
|
79
|
+
}),
|
|
80
|
+
h(
|
|
81
|
+
'div',
|
|
82
|
+
{
|
|
83
|
+
style: {
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
inset: 0,
|
|
86
|
+
clipPath: vertical()
|
|
87
|
+
? `inset(0 0 ${100 - ratio}% 0)`
|
|
88
|
+
: `inset(0 ${100 - ratio}% 0 0)`,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
[
|
|
92
|
+
h(MImage, {
|
|
93
|
+
src: props.before,
|
|
94
|
+
alt: props.beforeLabel,
|
|
95
|
+
aspectRatio: props.aspectRatio,
|
|
96
|
+
radius: 'none',
|
|
97
|
+
}),
|
|
98
|
+
],
|
|
99
|
+
),
|
|
100
|
+
h('span', { style: { ...labelStyle, left: '14px' } }, props.beforeLabel),
|
|
101
|
+
h(
|
|
102
|
+
'span',
|
|
103
|
+
{
|
|
104
|
+
style: {
|
|
105
|
+
...labelStyle,
|
|
106
|
+
right: '14px',
|
|
107
|
+
...(vertical() ? { top: 'auto', bottom: '14px' } : {}),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
props.afterLabel,
|
|
111
|
+
),
|
|
112
|
+
h(
|
|
113
|
+
'div',
|
|
114
|
+
{
|
|
115
|
+
style: {
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
pointerEvents: 'none',
|
|
118
|
+
background: '#fff',
|
|
119
|
+
boxShadow: '0 0 0 1px #0002',
|
|
120
|
+
...(vertical()
|
|
121
|
+
? {
|
|
122
|
+
left: 0,
|
|
123
|
+
right: 0,
|
|
124
|
+
top: `${ratio}%`,
|
|
125
|
+
height: '2px',
|
|
126
|
+
transform: 'translateY(-50%)',
|
|
127
|
+
}
|
|
128
|
+
: {
|
|
129
|
+
top: 0,
|
|
130
|
+
bottom: 0,
|
|
131
|
+
left: `${ratio}%`,
|
|
132
|
+
width: '2px',
|
|
133
|
+
transform: 'translateX(-50%)',
|
|
134
|
+
}),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
[
|
|
138
|
+
h(
|
|
139
|
+
'span',
|
|
140
|
+
{
|
|
141
|
+
'aria-hidden': 'true',
|
|
142
|
+
style: {
|
|
143
|
+
position: 'absolute',
|
|
144
|
+
left: '50%',
|
|
145
|
+
top: '50%',
|
|
146
|
+
transform: 'translate(-50%,-50%)',
|
|
147
|
+
width: '42px',
|
|
148
|
+
height: '42px',
|
|
149
|
+
borderRadius: '50%',
|
|
150
|
+
display: 'grid',
|
|
151
|
+
placeItems: 'center',
|
|
152
|
+
background: theme.value.colors.surface,
|
|
153
|
+
color: theme.value.colors.text,
|
|
154
|
+
boxShadow: '0 4px 24px #0004',
|
|
155
|
+
fontSize: '22px',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
vertical() ? '↕' : '↔',
|
|
159
|
+
),
|
|
160
|
+
],
|
|
161
|
+
),
|
|
162
|
+
h('div', {
|
|
163
|
+
...gestures,
|
|
164
|
+
role: 'slider',
|
|
165
|
+
tabindex: props.disabled ? -1 : 0,
|
|
166
|
+
'aria-label': props.label,
|
|
167
|
+
'aria-orientation': props.orientation,
|
|
168
|
+
'aria-valuemin': 0,
|
|
169
|
+
'aria-valuemax': 100,
|
|
170
|
+
'aria-valuenow': state.canonical.value,
|
|
171
|
+
'aria-valuetext': `${props.beforeLabel}: ${Math.round(state.canonical.value)}%`,
|
|
172
|
+
'aria-disabled': props.disabled || undefined,
|
|
173
|
+
style: {
|
|
174
|
+
position: 'absolute',
|
|
175
|
+
inset: 0,
|
|
176
|
+
touchAction: vertical() ? 'none' : 'pan-y',
|
|
177
|
+
cursor: props.disabled ? 'default' : vertical() ? 'row-resize' : 'col-resize',
|
|
178
|
+
outlineOffset: '-4px',
|
|
179
|
+
},
|
|
180
|
+
onKeydown: (event: KeyboardEvent) => {
|
|
181
|
+
if (props.disabled || event.altKey || event.ctrlKey || event.metaKey) return
|
|
182
|
+
const delta = ['ArrowRight', 'ArrowDown'].includes(event.key)
|
|
183
|
+
? 1
|
|
184
|
+
: ['ArrowLeft', 'ArrowUp'].includes(event.key)
|
|
185
|
+
? -1
|
|
186
|
+
: 0
|
|
187
|
+
if (event.key === 'Escape') {
|
|
188
|
+
state.cancel()
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
if (!delta && !['Home', 'End', 'PageUp', 'PageDown'].includes(event.key)) return
|
|
192
|
+
event.preventDefault()
|
|
193
|
+
state.update(
|
|
194
|
+
event.key === 'Home'
|
|
195
|
+
? 0
|
|
196
|
+
: event.key === 'End'
|
|
197
|
+
? 100
|
|
198
|
+
: state.canonical.value +
|
|
199
|
+
(delta
|
|
200
|
+
? delta * props.step * (event.shiftKey ? 10 : 1)
|
|
201
|
+
: event.key === 'PageUp'
|
|
202
|
+
? 10
|
|
203
|
+
: -10),
|
|
204
|
+
)
|
|
205
|
+
},
|
|
206
|
+
}),
|
|
207
|
+
],
|
|
208
|
+
),
|
|
209
|
+
h(
|
|
210
|
+
'figcaption',
|
|
211
|
+
{ style: { marginTop: '10px', color: theme.value.colors.muted, fontSize: '13px' } },
|
|
212
|
+
`${props.label} · ${Math.round(state.canonical.value)}%`,
|
|
213
|
+
),
|
|
214
|
+
],
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
})
|