@getcortexlabs/mavis-web 0.1.0-alpha.9 → 0.1.0-rc.12
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 +3 -3
- 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 +6 -6
- 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 +2 -2
- 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 +3 -3
- 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/MLink.d.ts +1 -1
- package/dist/components/MListItem.d.ts +1 -1
- package/dist/components/MPinInput.d.ts +57 -0
- package/dist/components/MPinInput.d.ts.map +1 -0
- package/dist/components/MPinInput.js +159 -0
- package/dist/components/MPinInput.js.map +1 -0
- package/dist/components/MPopover.d.ts +105 -0
- package/dist/components/MPopover.d.ts.map +1 -0
- package/dist/components/MPopover.js +266 -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 +31 -20
- 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/creative.d.ts +614 -0
- package/dist/components/creative.d.ts.map +1 -0
- package/dist/components/creative.js +191 -0
- package/dist/components/creative.js.map +1 -0
- package/dist/components/dashboard.d.ts +474 -0
- package/dist/components/dashboard.d.ts.map +1 -0
- package/dist/components/dashboard.js +286 -0
- package/dist/components/dashboard.js.map +1 -0
- 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/screen-components.d.ts +502 -0
- package/dist/components/screen-components.d.ts.map +1 -0
- package/dist/components/screen-components.js +67 -0
- package/dist/components/screen-components.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 +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -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/dist/use-motion-surface.d.ts.map +1 -1
- package/dist/use-motion-surface.js +27 -8
- package/dist/use-motion-surface.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/MPinInput.ts +194 -0
- package/src/components/MPopover.ts +314 -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/creative.ts +240 -0
- package/src/components/dashboard.ts +353 -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/screen-components.ts +86 -0
- package/src/components/wayfinding.ts +70 -0
- package/src/index.ts +145 -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
- package/src/use-motion-surface.ts +40 -15
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { RangeHalo } from './RangeHalo.js'
|
|
2
|
+
import { computed, defineComponent, h, mergeProps, nextTick, useId, ref, watch } from 'vue'
|
|
3
|
+
import { moveRange, rangeValue, sliderScale, type RangeValue } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { rangeSliderProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
5
|
+
import { MColumn, MRow } from './layout.js'
|
|
6
|
+
import { MText } from './MText.js'
|
|
7
|
+
import { useHydrationEdit } from '../hydration.js'
|
|
8
|
+
export const MRangeSlider = defineComponent({
|
|
9
|
+
name: 'MRangeSlider',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: rangeSliderProps,
|
|
12
|
+
emits: { 'update:modelValue': (_value: RangeValue) => true },
|
|
13
|
+
setup(props, { attrs, emit }) {
|
|
14
|
+
const { theme } = useMavisTheme()
|
|
15
|
+
const id = `m-range-${useId()}`
|
|
16
|
+
const active = ref<number | null>(null)
|
|
17
|
+
watch(
|
|
18
|
+
() => props.disabled || props.readonly,
|
|
19
|
+
(blocked) => {
|
|
20
|
+
if (blocked) active.value = null
|
|
21
|
+
},
|
|
22
|
+
)
|
|
23
|
+
const pair = computed(() => rangeValue(props.modelValue, props.min, props.max, props.step))
|
|
24
|
+
const format = (value: number) => props.formatValue?.(value) ?? String(value)
|
|
25
|
+
const pending = useHydrationEdit(
|
|
26
|
+
(root) => {
|
|
27
|
+
if (props.disabled || props.readonly) return
|
|
28
|
+
const inputs = [...root.querySelectorAll<HTMLInputElement>('input[type="range"]')]
|
|
29
|
+
if (inputs.length !== 2) return
|
|
30
|
+
const scale = sliderScale(props.min, props.max, props.step)
|
|
31
|
+
if (
|
|
32
|
+
!inputs.every(
|
|
33
|
+
(input, thumb) => Number(input.defaultValue) === scale.toNative(pair.value[thumb]!),
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
return
|
|
37
|
+
if (inputs.every((input) => input.value === input.defaultValue)) return
|
|
38
|
+
const upper = scale.fromNative(inputs[1]!.valueAsNumber)
|
|
39
|
+
const value: [number, number] = [
|
|
40
|
+
Math.min(scale.fromNative(inputs[0]!.valueAsNumber), upper),
|
|
41
|
+
upper,
|
|
42
|
+
]
|
|
43
|
+
// Match the hydrated value attribute to the user's existing edit. Paint and
|
|
44
|
+
// accessible values update together after the owner accepts the pair.
|
|
45
|
+
inputs.forEach((input, thumb) => {
|
|
46
|
+
input.defaultValue = String(scale.toNative(value[thumb]!))
|
|
47
|
+
})
|
|
48
|
+
return value
|
|
49
|
+
},
|
|
50
|
+
(value) => emit('update:modelValue', value),
|
|
51
|
+
)
|
|
52
|
+
return () => {
|
|
53
|
+
const scale = sliderScale(props.min, props.max, props.step)
|
|
54
|
+
const shown = pending() ?? pair.value
|
|
55
|
+
const lower = scale.toNative(pair.value[0]),
|
|
56
|
+
upper = scale.toNative(pair.value[1])
|
|
57
|
+
return h(
|
|
58
|
+
MColumn,
|
|
59
|
+
mergeProps({ id: props.id, gap: 'sm' }, attrs, {
|
|
60
|
+
class: 'm-range-slider',
|
|
61
|
+
role: 'group',
|
|
62
|
+
'aria-labelledby': id,
|
|
63
|
+
style: {
|
|
64
|
+
'--m-range-color': theme.value.colors.primary,
|
|
65
|
+
'--m-range-track': theme.value.colors.border,
|
|
66
|
+
'--m-range-surface': theme.value.colors.surface,
|
|
67
|
+
'--m-range-from': `${(lower / scale.steps) * 100}%`,
|
|
68
|
+
'--m-range-to': `${(upper / scale.steps) * 100}%`,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
() => [
|
|
72
|
+
h(MRow, { justify: 'between', gap: 'md', wrap: true }, () => [
|
|
73
|
+
h(MText, { id, text: props.label, weight: '600' }),
|
|
74
|
+
h(MText, {
|
|
75
|
+
text: `${format(pair.value[0])} – ${format(pair.value[1])}`,
|
|
76
|
+
tone: 'muted',
|
|
77
|
+
}),
|
|
78
|
+
]),
|
|
79
|
+
h(
|
|
80
|
+
'div',
|
|
81
|
+
{ class: 'm-range-track' },
|
|
82
|
+
([0, 1] as const).flatMap((thumb) => [
|
|
83
|
+
h(RangeHalo, {
|
|
84
|
+
key: `halo:${thumb}`,
|
|
85
|
+
active: active.value === thumb && !props.disabled && !props.readonly,
|
|
86
|
+
position: scale.toNative(pair.value[thumb]) / scale.steps,
|
|
87
|
+
}),
|
|
88
|
+
h('input', {
|
|
89
|
+
key: thumb,
|
|
90
|
+
onFocus: () => {
|
|
91
|
+
active.value = thumb
|
|
92
|
+
},
|
|
93
|
+
onBlur: () => {
|
|
94
|
+
if (active.value === thumb) active.value = null
|
|
95
|
+
},
|
|
96
|
+
onPointerdown: () => {
|
|
97
|
+
active.value = thumb
|
|
98
|
+
},
|
|
99
|
+
onPointerup: () => {
|
|
100
|
+
active.value = null
|
|
101
|
+
},
|
|
102
|
+
onPointercancel: () => {
|
|
103
|
+
active.value = null
|
|
104
|
+
},
|
|
105
|
+
type: 'range',
|
|
106
|
+
min: 0,
|
|
107
|
+
max: scale.steps,
|
|
108
|
+
step: 1,
|
|
109
|
+
value: scale.toNative(shown[thumb]),
|
|
110
|
+
disabled: props.disabled,
|
|
111
|
+
'aria-readonly': props.readonly || undefined,
|
|
112
|
+
'aria-label': `${props.label}: ${thumb === 0 ? props.lowerLabel : props.upperLabel}`,
|
|
113
|
+
'aria-valuemin': thumb === 0 ? props.min : pair.value[0],
|
|
114
|
+
'aria-valuemax': thumb === 0 ? pair.value[1] : props.max,
|
|
115
|
+
'aria-valuenow': pair.value[thumb],
|
|
116
|
+
'aria-valuetext': format(pair.value[thumb]),
|
|
117
|
+
style: { zIndex: thumb === 0 && lower === scale.steps ? 3 : thumb + 1 },
|
|
118
|
+
onKeydown: (event: KeyboardEvent) => {
|
|
119
|
+
if (props.readonly) event.preventDefault()
|
|
120
|
+
},
|
|
121
|
+
onInput: (event: Event) => {
|
|
122
|
+
const input = event.target as HTMLInputElement
|
|
123
|
+
const next = moveRange(
|
|
124
|
+
pair.value,
|
|
125
|
+
thumb,
|
|
126
|
+
scale.fromNative(input.valueAsNumber),
|
|
127
|
+
props.min,
|
|
128
|
+
props.max,
|
|
129
|
+
props.step,
|
|
130
|
+
)
|
|
131
|
+
if (!props.disabled && !props.readonly && next[thumb] !== pair.value[thumb])
|
|
132
|
+
emit('update:modelValue', next)
|
|
133
|
+
void nextTick(() => {
|
|
134
|
+
input.value = String(scale.toNative(pair.value[thumb]))
|
|
135
|
+
})
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
]),
|
|
139
|
+
),
|
|
140
|
+
],
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
})
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { computed, defineComponent, h, mergeProps, ref, useId, watch } from 'vue'
|
|
2
|
+
import { panelValue, positiveSize } from '@getcortexlabs/mavis-core'
|
|
3
|
+
import { resizablePanelsProps, usePartition, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { useAnimatedNumber } from '../animated-number.js'
|
|
5
|
+
import { usePartitionPointer } from '../partition-pointer.js'
|
|
6
|
+
import { MButton } from './MButton.js'
|
|
7
|
+
|
|
8
|
+
export const MResizablePanels = defineComponent({
|
|
9
|
+
name: 'MResizablePanels',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: resizablePanelsProps,
|
|
12
|
+
emits: { 'update:modelValue': (_value: number) => true, resize: (_value: number) => true },
|
|
13
|
+
setup(props, { attrs, slots, emit }) {
|
|
14
|
+
const { theme } = useMavisTheme()
|
|
15
|
+
const root = ref<HTMLElement>()
|
|
16
|
+
const primaryId = `m-panel-${useId()}`
|
|
17
|
+
const value = computed(() =>
|
|
18
|
+
panelValue(props.modelValue, props.min, props.max, props.collapsible),
|
|
19
|
+
)
|
|
20
|
+
let remembered = Math.max(props.min, 40)
|
|
21
|
+
const state = usePartition(
|
|
22
|
+
() => value.value,
|
|
23
|
+
() => ({
|
|
24
|
+
min: props.collapsible ? 0 : props.min,
|
|
25
|
+
max: props.max,
|
|
26
|
+
step: props.step,
|
|
27
|
+
disabled: props.disabled,
|
|
28
|
+
}),
|
|
29
|
+
(next) =>
|
|
30
|
+
emit('update:modelValue', next === 0 && props.collapsible ? 0 : Math.max(props.min, next)),
|
|
31
|
+
)
|
|
32
|
+
const shown = useAnimatedNumber(
|
|
33
|
+
() => value.value,
|
|
34
|
+
() => state.dragging.value,
|
|
35
|
+
)
|
|
36
|
+
const vertical = () => props.orientation === 'vertical'
|
|
37
|
+
function finish() {
|
|
38
|
+
state.end()
|
|
39
|
+
const closest = props.snap
|
|
40
|
+
.filter((point) => Number.isFinite(point) && point >= props.min && point <= props.max)
|
|
41
|
+
.sort((a, b) => Math.abs(a - value.value) - Math.abs(b - value.value))[0]
|
|
42
|
+
if (closest !== undefined && Math.abs(closest - value.value) <= 3)
|
|
43
|
+
emit('update:modelValue', closest)
|
|
44
|
+
emit(
|
|
45
|
+
'resize',
|
|
46
|
+
closest !== undefined && Math.abs(closest - value.value) <= 3 ? closest : value.value,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
const gestures = usePartitionPointer({
|
|
50
|
+
...state,
|
|
51
|
+
value: () => value.value,
|
|
52
|
+
vertical,
|
|
53
|
+
direction: () => (props.direction === 'rtl' ? -1 : 1),
|
|
54
|
+
disabled: () => props.disabled,
|
|
55
|
+
bounds: () => {
|
|
56
|
+
const box = root.value?.getBoundingClientRect()
|
|
57
|
+
return box
|
|
58
|
+
? new DOMRect(
|
|
59
|
+
box.x,
|
|
60
|
+
box.y,
|
|
61
|
+
vertical() ? box.width : Math.max(1, box.width - 44),
|
|
62
|
+
vertical() ? Math.max(1, box.height - 44) : box.height,
|
|
63
|
+
)
|
|
64
|
+
: undefined
|
|
65
|
+
},
|
|
66
|
+
end: finish,
|
|
67
|
+
})
|
|
68
|
+
function toggle() {
|
|
69
|
+
if (!props.collapsible || props.disabled) return
|
|
70
|
+
if (value.value) {
|
|
71
|
+
remembered = value.value
|
|
72
|
+
emit('update:modelValue', 0)
|
|
73
|
+
} else emit('update:modelValue', Math.max(props.min, Math.min(props.max, remembered)))
|
|
74
|
+
}
|
|
75
|
+
watch(
|
|
76
|
+
() => [props.orientation, props.direction],
|
|
77
|
+
() => state.cancel(),
|
|
78
|
+
)
|
|
79
|
+
return () => {
|
|
80
|
+
const ratio = Math.max(0, Math.min(100, shown.value))
|
|
81
|
+
const tracks = `${ratio}fr 44px ${100 - ratio}fr`
|
|
82
|
+
return h(
|
|
83
|
+
'div',
|
|
84
|
+
mergeProps(attrs, {
|
|
85
|
+
class: 'm-resizable-panels',
|
|
86
|
+
role: 'group',
|
|
87
|
+
'aria-label': props.label,
|
|
88
|
+
}),
|
|
89
|
+
[
|
|
90
|
+
h(
|
|
91
|
+
'div',
|
|
92
|
+
{
|
|
93
|
+
ref: root,
|
|
94
|
+
dir: props.direction,
|
|
95
|
+
style: {
|
|
96
|
+
display: 'grid',
|
|
97
|
+
[vertical() ? 'gridTemplateRows' : 'gridTemplateColumns']: tracks,
|
|
98
|
+
height: `${positiveSize(props.height, 'height')}px`,
|
|
99
|
+
minWidth: 0,
|
|
100
|
+
overflow: 'hidden',
|
|
101
|
+
border: `1px solid ${theme.value.colors.border}`,
|
|
102
|
+
borderRadius: '16px',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
[
|
|
106
|
+
h(
|
|
107
|
+
'section',
|
|
108
|
+
{
|
|
109
|
+
id: primaryId,
|
|
110
|
+
tabindex: value.value === 0 ? -1 : 0,
|
|
111
|
+
'aria-label': props.primaryLabel,
|
|
112
|
+
inert: value.value === 0 ? true : undefined,
|
|
113
|
+
style: {
|
|
114
|
+
minWidth: 0,
|
|
115
|
+
minHeight: 0,
|
|
116
|
+
overflow: 'auto',
|
|
117
|
+
visibility: ratio < 0.01 ? 'hidden' : undefined,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
slots.primary?.(),
|
|
121
|
+
),
|
|
122
|
+
h(
|
|
123
|
+
'div',
|
|
124
|
+
{
|
|
125
|
+
...gestures,
|
|
126
|
+
role: 'separator',
|
|
127
|
+
tabindex: props.disabled ? -1 : 0,
|
|
128
|
+
'aria-label': props.label,
|
|
129
|
+
'aria-orientation': vertical() ? 'horizontal' : 'vertical',
|
|
130
|
+
'aria-valuemin': props.collapsible ? 0 : props.min,
|
|
131
|
+
'aria-valuemax': props.max,
|
|
132
|
+
'aria-valuenow': value.value,
|
|
133
|
+
'aria-valuetext': `${Math.round(value.value)}%`,
|
|
134
|
+
'aria-controls': primaryId,
|
|
135
|
+
'aria-disabled': props.disabled || undefined,
|
|
136
|
+
style: {
|
|
137
|
+
display: 'grid',
|
|
138
|
+
placeItems: 'center',
|
|
139
|
+
cursor: props.disabled ? 'default' : vertical() ? 'row-resize' : 'col-resize',
|
|
140
|
+
touchAction: 'none',
|
|
141
|
+
background: theme.value.colors.elevated,
|
|
142
|
+
outlineOffset: '-3px',
|
|
143
|
+
},
|
|
144
|
+
onDblclick: toggle,
|
|
145
|
+
onKeydown: (event: KeyboardEvent) => {
|
|
146
|
+
if (props.disabled || event.altKey || event.ctrlKey || event.metaKey) return
|
|
147
|
+
const key = event.key
|
|
148
|
+
let next: number | undefined
|
|
149
|
+
if (key === 'Home') next = props.min
|
|
150
|
+
if (key === 'End') next = props.max
|
|
151
|
+
if (key === 'Enter' && props.collapsible) {
|
|
152
|
+
event.preventDefault()
|
|
153
|
+
toggle()
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
if (key === 'Escape') {
|
|
157
|
+
state.cancel()
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
const delta = vertical()
|
|
161
|
+
? key === 'ArrowDown'
|
|
162
|
+
? 1
|
|
163
|
+
: key === 'ArrowUp'
|
|
164
|
+
? -1
|
|
165
|
+
: 0
|
|
166
|
+
: (key === 'ArrowRight' ? 1 : key === 'ArrowLeft' ? -1 : 0) *
|
|
167
|
+
(props.direction === 'rtl' ? -1 : 1)
|
|
168
|
+
if (delta) next = value.value + delta * props.step * (event.shiftKey ? 5 : 1)
|
|
169
|
+
if (next !== undefined) {
|
|
170
|
+
event.preventDefault()
|
|
171
|
+
state.update(next)
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
h('span', {
|
|
176
|
+
'aria-hidden': 'true',
|
|
177
|
+
style: {
|
|
178
|
+
width: vertical() ? '28px' : '4px',
|
|
179
|
+
height: vertical() ? '4px' : '28px',
|
|
180
|
+
borderRadius: '4px',
|
|
181
|
+
background: theme.value.colors.muted,
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
),
|
|
185
|
+
h(
|
|
186
|
+
'section',
|
|
187
|
+
{
|
|
188
|
+
tabindex: 0,
|
|
189
|
+
'aria-label': props.secondaryLabel,
|
|
190
|
+
style: { minWidth: 0, minHeight: 0, overflow: 'auto' },
|
|
191
|
+
},
|
|
192
|
+
slots.secondary?.(),
|
|
193
|
+
),
|
|
194
|
+
],
|
|
195
|
+
),
|
|
196
|
+
props.collapsible
|
|
197
|
+
? h(MButton, {
|
|
198
|
+
text: value.value ? props.collapseLabel : props.expandLabel,
|
|
199
|
+
variant: 'ghost',
|
|
200
|
+
disabled: props.disabled,
|
|
201
|
+
onClick: toggle,
|
|
202
|
+
})
|
|
203
|
+
: null,
|
|
204
|
+
],
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
})
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
segmentedEmits,
|
|
15
15
|
useMavisTheme,
|
|
16
16
|
} from '@getcortexlabs/mavis-core/vue'
|
|
17
|
+
import { useSelectionIndicator } from '../component-motion.js'
|
|
17
18
|
import { MColumn } from './layout.js'
|
|
18
19
|
|
|
19
20
|
export const MSegmentedControl = defineComponent({
|
|
@@ -25,6 +26,7 @@ export const MSegmentedControl = defineComponent({
|
|
|
25
26
|
useButtonAction()
|
|
26
27
|
const { theme } = useMavisTheme()
|
|
27
28
|
const controls = new Map<string, HTMLButtonElement>()
|
|
29
|
+
const indicator = useSelectionIndicator(() => controls.get(choiceKey(props.modelValue ?? '')))
|
|
28
30
|
let alive = true
|
|
29
31
|
onBeforeUnmount(() => {
|
|
30
32
|
alive = false
|
|
@@ -104,12 +106,14 @@ export const MSegmentedControl = defineComponent({
|
|
|
104
106
|
[
|
|
105
107
|
h('span', {
|
|
106
108
|
class: 'm-segmented-marker',
|
|
109
|
+
ref: indicator,
|
|
107
110
|
'aria-hidden': 'true',
|
|
108
111
|
style: {
|
|
109
112
|
background: colors.primarySoft,
|
|
110
113
|
visibility: index < 0 ? 'hidden' : 'visible',
|
|
111
|
-
width:
|
|
112
|
-
|
|
114
|
+
width: '100px',
|
|
115
|
+
transformOrigin: '0px 0px',
|
|
116
|
+
transition: 'none',
|
|
113
117
|
},
|
|
114
118
|
}),
|
|
115
119
|
...props.options.map((option) => {
|
package/src/components/MStack.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useMotionRegion } from '../motion-region.js'
|
|
1
2
|
import { computed, defineComponent, h, mergeProps, provide, shallowRef } from 'vue'
|
|
2
3
|
import { resolveSpace, stackLayout } from '@getcortexlabs/mavis-core'
|
|
3
4
|
import {
|
|
@@ -5,6 +6,7 @@ import {
|
|
|
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'
|
|
@@ -46,6 +48,8 @@ export const MStack = defineComponent({
|
|
|
46
48
|
width.value,
|
|
47
49
|
),
|
|
48
50
|
)
|
|
51
|
+
const automatic = useComponentLayout(() => JSON.stringify(layout.value), false)
|
|
52
|
+
const motion = useMotionRegion(() => props.motionRegion ?? automatic)
|
|
49
53
|
const direction = computed(() => layout.value.direction ?? props.direction)
|
|
50
54
|
provide(layoutDirection, direction)
|
|
51
55
|
return () =>
|
|
@@ -53,6 +57,7 @@ export const MStack = defineComponent({
|
|
|
53
57
|
'div',
|
|
54
58
|
mergeProps(
|
|
55
59
|
{
|
|
60
|
+
...motion,
|
|
56
61
|
ref: element,
|
|
57
62
|
class: 'm-stack',
|
|
58
63
|
style: {
|
package/src/components/MTabs.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
type TabPanelProps,
|
|
25
25
|
} from '@getcortexlabs/mavis-core'
|
|
26
26
|
import { useButtonAction, tabsProps, tabsEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
27
|
+
import { useSelectionIndicator } from '../component-motion.js'
|
|
27
28
|
import { MColumn } from './layout.js'
|
|
28
29
|
|
|
29
30
|
const TabPanel = defineComponent({
|
|
@@ -52,6 +53,9 @@ export const MTabs = defineComponent({
|
|
|
52
53
|
validateTabs(props.tabs, props.modelValue, props.label)
|
|
53
54
|
return props.tabs.find((tab) => tab.value === props.modelValue)
|
|
54
55
|
})
|
|
56
|
+
const indicator = useSelectionIndicator(
|
|
57
|
+
() => selected.value && controls.get(choiceKey(selected.value.value)),
|
|
58
|
+
)
|
|
55
59
|
let observer: ResizeObserver | undefined
|
|
56
60
|
let frame: number | undefined
|
|
57
61
|
let alive = false
|
|
@@ -216,12 +220,14 @@ export const MTabs = defineComponent({
|
|
|
216
220
|
),
|
|
217
221
|
h('span', {
|
|
218
222
|
class: 'm-tabs-indicator',
|
|
223
|
+
ref: indicator,
|
|
219
224
|
'aria-hidden': 'true',
|
|
220
225
|
style: {
|
|
221
226
|
backgroundColor: colors.primary,
|
|
222
|
-
|
|
223
|
-
width:
|
|
224
|
-
|
|
227
|
+
|
|
228
|
+
width: '100px',
|
|
229
|
+
transformOrigin: '0px 0px',
|
|
230
|
+
transition: 'none',
|
|
225
231
|
},
|
|
226
232
|
}),
|
|
227
233
|
],
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { createTimePicker, timePickerProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { localTime, timeMinutes, timeOptions } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { MInput } from './MInput.js'
|
|
5
|
+
import { MColumn, MRow } from './layout.js'
|
|
6
|
+
import { MButton } from './MButton.js'
|
|
7
|
+
import { MText } from './MText.js'
|
|
8
|
+
import { MSheet } from './MSheet.js'
|
|
9
|
+
|
|
10
|
+
const TimeFields = defineComponent({
|
|
11
|
+
props: timePickerProps,
|
|
12
|
+
emits: ['update:modelValue'],
|
|
13
|
+
setup(props, { emit }) {
|
|
14
|
+
const { theme } = useMavisTheme()
|
|
15
|
+
// Browser-native selects keep hour/minute selection within the current sheet.
|
|
16
|
+
function field(
|
|
17
|
+
label: string,
|
|
18
|
+
value: string | number,
|
|
19
|
+
options: { value: string | number; label: string }[],
|
|
20
|
+
change: (value: string) => void,
|
|
21
|
+
) {
|
|
22
|
+
const { colors, radius } = theme.value
|
|
23
|
+
return h(
|
|
24
|
+
'label',
|
|
25
|
+
{
|
|
26
|
+
class: 'm-time-part',
|
|
27
|
+
style: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: 'column',
|
|
30
|
+
gap: '8px',
|
|
31
|
+
flex: '1 1 80px',
|
|
32
|
+
minWidth: 0,
|
|
33
|
+
font: 'inherit',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
[
|
|
37
|
+
h('span', { style: { fontSize: '14px', fontWeight: 600 } }, label),
|
|
38
|
+
h(
|
|
39
|
+
'select',
|
|
40
|
+
{
|
|
41
|
+
value: String(value),
|
|
42
|
+
style: {
|
|
43
|
+
boxSizing: 'border-box',
|
|
44
|
+
width: '100%',
|
|
45
|
+
minHeight: '48px',
|
|
46
|
+
padding: '8px',
|
|
47
|
+
font: 'inherit',
|
|
48
|
+
background: colors.surface,
|
|
49
|
+
color: colors.text,
|
|
50
|
+
border: `1px solid ${colors.border}`,
|
|
51
|
+
borderRadius: `${radius.md}px`,
|
|
52
|
+
colorScheme: theme.value.appearance,
|
|
53
|
+
},
|
|
54
|
+
onChange: (event: Event) => change((event.target as HTMLSelectElement).value),
|
|
55
|
+
},
|
|
56
|
+
options.map((option) =>
|
|
57
|
+
h('option', { key: option.value, value: String(option.value) }, option.label),
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
],
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
const { cycle, step } = timeOptions(props)
|
|
65
|
+
const minutes = timeMinutes(props.modelValue ?? '00:00')
|
|
66
|
+
const hour = Math.floor(minutes / 60)
|
|
67
|
+
const twelve = cycle === 'h12'
|
|
68
|
+
return h(MRow, { gap: 'sm', wrap: true }, () => [
|
|
69
|
+
field(
|
|
70
|
+
props.hourLabel,
|
|
71
|
+
twelve ? hour % 12 || 12 : hour,
|
|
72
|
+
Array.from({ length: twelve ? 12 : 24 }, (_, i) => ({
|
|
73
|
+
value: twelve ? i + 1 : i,
|
|
74
|
+
label: String(twelve ? i + 1 : i).padStart(2, '0'),
|
|
75
|
+
})),
|
|
76
|
+
(value) =>
|
|
77
|
+
emit(
|
|
78
|
+
'update:modelValue',
|
|
79
|
+
localTime(
|
|
80
|
+
(twelve ? (Number(value) % 12) + (hour >= 12 ? 12 : 0) : Number(value)) * 60 +
|
|
81
|
+
(minutes % 60),
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
),
|
|
85
|
+
field(
|
|
86
|
+
props.minuteLabel,
|
|
87
|
+
minutes % 60,
|
|
88
|
+
Array.from({ length: 60 / step }, (_, i) => ({
|
|
89
|
+
value: i * step,
|
|
90
|
+
label: String(i * step).padStart(2, '0'),
|
|
91
|
+
})),
|
|
92
|
+
(value) => emit('update:modelValue', localTime(hour * 60 + Number(value))),
|
|
93
|
+
),
|
|
94
|
+
twelve
|
|
95
|
+
? field(
|
|
96
|
+
props.periodLabel,
|
|
97
|
+
hour >= 12 ? 'PM' : 'AM',
|
|
98
|
+
[
|
|
99
|
+
{ value: 'AM', label: 'AM' },
|
|
100
|
+
{ value: 'PM', label: 'PM' },
|
|
101
|
+
],
|
|
102
|
+
(value) =>
|
|
103
|
+
emit(
|
|
104
|
+
'update:modelValue',
|
|
105
|
+
localTime(((hour % 12) + (value === 'PM' ? 12 : 0)) * 60 + (minutes % 60)),
|
|
106
|
+
),
|
|
107
|
+
)
|
|
108
|
+
: null,
|
|
109
|
+
])
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
export const MTimePicker = createTimePicker(
|
|
114
|
+
{
|
|
115
|
+
Input: MInput,
|
|
116
|
+
Column: MColumn,
|
|
117
|
+
Row: MRow,
|
|
118
|
+
Button: MButton,
|
|
119
|
+
Text: MText,
|
|
120
|
+
Sheet: MSheet,
|
|
121
|
+
Picker: TimeFields,
|
|
122
|
+
},
|
|
123
|
+
'web',
|
|
124
|
+
)
|
package/src/components/MToast.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
useToastHost,
|
|
19
19
|
} from '@getcortexlabs/mavis-core/vue'
|
|
20
20
|
import type { IconName, ToastTone } from '@getcortexlabs/mavis-core'
|
|
21
|
+
import { useComponentTransition } from '../component-motion.js'
|
|
21
22
|
import { MIcon } from './MIcon.js'
|
|
22
23
|
|
|
23
24
|
const icons: Record<ToastTone, IconName> = {
|
|
@@ -35,6 +36,7 @@ export const MToast = defineComponent({
|
|
|
35
36
|
setup(props) {
|
|
36
37
|
useButtonAction()
|
|
37
38
|
const { theme } = useMavisTheme()
|
|
39
|
+
const transition = useComponentTransition(-8)
|
|
38
40
|
const host = useToastHost(() => props.controller)
|
|
39
41
|
const mounted = ref(false)
|
|
40
42
|
const covered = ref(false)
|
|
@@ -131,6 +133,7 @@ export const MToast = defineComponent({
|
|
|
131
133
|
h(
|
|
132
134
|
Transition,
|
|
133
135
|
{
|
|
136
|
+
...transition,
|
|
134
137
|
name: 'm-toast',
|
|
135
138
|
appear: true,
|
|
136
139
|
onBeforeEnter: () => {
|
|
@@ -157,7 +160,8 @@ export const MToast = defineComponent({
|
|
|
157
160
|
host.pause('hover', false)
|
|
158
161
|
host.pause('focus', false)
|
|
159
162
|
},
|
|
160
|
-
onAfterLeave: () => {
|
|
163
|
+
onAfterLeave: (element: Element) => {
|
|
164
|
+
transition.onAfterLeave(element)
|
|
161
165
|
if (message) host.left(message.id)
|
|
162
166
|
},
|
|
163
167
|
},
|