@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useComponentPaint } from '../component-motion.js'
|
|
2
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
1
3
|
import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
2
4
|
import { calendarDayLabel, fontFamily, type CivilDate } from '@getcortexlabs/mavis-core'
|
|
3
5
|
import {
|
|
@@ -5,10 +7,47 @@ import {
|
|
|
5
7
|
dateCalendarEmits,
|
|
6
8
|
useDateCalendar,
|
|
7
9
|
useMavisTheme,
|
|
10
|
+
useCalendarMotion,
|
|
8
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
9
12
|
import { MButton } from './MButton.js'
|
|
10
13
|
import { MRow, MColumn } from './layout.js'
|
|
11
14
|
|
|
15
|
+
const CalendarDay = defineComponent({
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: { painted: Boolean },
|
|
18
|
+
setup(props, { attrs, slots }) {
|
|
19
|
+
const background = ref<HTMLElement>()
|
|
20
|
+
const { theme } = useMavisTheme()
|
|
21
|
+
useComponentPaint(background, () => ({
|
|
22
|
+
opacity: props.painted ? 1 : 0,
|
|
23
|
+
scale: props.painted ? 1 : 0.8,
|
|
24
|
+
}))
|
|
25
|
+
return () =>
|
|
26
|
+
h(
|
|
27
|
+
'button',
|
|
28
|
+
{
|
|
29
|
+
...attrs,
|
|
30
|
+
style: [attrs.style, { position: 'relative', backgroundColor: 'transparent' }],
|
|
31
|
+
},
|
|
32
|
+
[
|
|
33
|
+
h('span', {
|
|
34
|
+
ref: background,
|
|
35
|
+
'aria-hidden': 'true',
|
|
36
|
+
style: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
inset: 0,
|
|
39
|
+
borderRadius: 'inherit',
|
|
40
|
+
backgroundColor: theme.value.colors.primarySoft,
|
|
41
|
+
pointerEvents: 'none',
|
|
42
|
+
opacity: props.painted ? 1 : 0,
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
h('span', { style: { position: 'relative' } }, slots.default?.()),
|
|
46
|
+
],
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
|
|
12
51
|
/** @internal Month grid with one Tab stop; unavailable days remain readable and cannot commit. */
|
|
13
52
|
export const DateCalendar = defineComponent({
|
|
14
53
|
name: 'DateCalendar',
|
|
@@ -25,7 +64,9 @@ export const DateCalendar = defineComponent({
|
|
|
25
64
|
if (alive) days.get(props.activeDate)?.focus({ preventScroll: true })
|
|
26
65
|
})
|
|
27
66
|
}
|
|
28
|
-
onMounted(
|
|
67
|
+
onMounted(() => {
|
|
68
|
+
if (props.autofocus) focusDay()
|
|
69
|
+
})
|
|
29
70
|
onBeforeUnmount(() => {
|
|
30
71
|
alive = false
|
|
31
72
|
days.clear()
|
|
@@ -37,6 +78,8 @@ export const DateCalendar = defineComponent({
|
|
|
37
78
|
if (root.value?.querySelector('table')?.contains(document.activeElement)) focusDay()
|
|
38
79
|
},
|
|
39
80
|
)
|
|
81
|
+
const presentation = useCalendarMotion(() => props.activeDate)
|
|
82
|
+
const motion = useMotionSurface(() => presentation)
|
|
40
83
|
return () => {
|
|
41
84
|
const { colors, typography, radius } = theme.value
|
|
42
85
|
const cells = calendar.cells.value
|
|
@@ -57,7 +100,7 @@ export const DateCalendar = defineComponent({
|
|
|
57
100
|
icon: 'chevron-left',
|
|
58
101
|
variant: 'ghost',
|
|
59
102
|
accessibilityLabel: calendar.words.value.previous,
|
|
60
|
-
disabled: !calendar.canPage(-1),
|
|
103
|
+
disabled: props.disabled || !calendar.canPage(-1),
|
|
61
104
|
onClick: () => calendar.page(-1),
|
|
62
105
|
}),
|
|
63
106
|
h(
|
|
@@ -77,7 +120,7 @@ export const DateCalendar = defineComponent({
|
|
|
77
120
|
icon: 'chevron-right',
|
|
78
121
|
variant: 'ghost',
|
|
79
122
|
accessibilityLabel: calendar.words.value.next,
|
|
80
|
-
disabled: !calendar.canPage(1),
|
|
123
|
+
disabled: props.disabled || !calendar.canPage(1),
|
|
81
124
|
onClick: () => calendar.page(1),
|
|
82
125
|
}),
|
|
83
126
|
],
|
|
@@ -94,6 +137,7 @@ export const DateCalendar = defineComponent({
|
|
|
94
137
|
h(
|
|
95
138
|
'table',
|
|
96
139
|
{
|
|
140
|
+
...motion,
|
|
97
141
|
role: 'grid',
|
|
98
142
|
'aria-label': calendar.title.value,
|
|
99
143
|
style: {
|
|
@@ -101,12 +145,18 @@ export const DateCalendar = defineComponent({
|
|
|
101
145
|
borderSpacing: 0,
|
|
102
146
|
tableLayout: 'fixed',
|
|
103
147
|
width: '100%',
|
|
104
|
-
minWidth: '
|
|
148
|
+
minWidth: 'max(308px, 17.5em)',
|
|
105
149
|
fontFamily: fontFamily(typography.body.fontFamily, 'web'),
|
|
106
150
|
fontSize: `${typography.body.fontSize}px`,
|
|
107
151
|
},
|
|
108
152
|
onKeydown: (event: KeyboardEvent) => {
|
|
109
|
-
if (
|
|
153
|
+
if (
|
|
154
|
+
props.disabled ||
|
|
155
|
+
event.altKey ||
|
|
156
|
+
event.ctrlKey ||
|
|
157
|
+
event.metaKey ||
|
|
158
|
+
event.isComposing
|
|
159
|
+
)
|
|
110
160
|
return
|
|
111
161
|
if (
|
|
112
162
|
calendar.key(
|
|
@@ -145,18 +195,28 @@ export const DateCalendar = defineComponent({
|
|
|
145
195
|
{ key: index },
|
|
146
196
|
week.map((date, column) => {
|
|
147
197
|
if (!date) return h('td', { key: column })
|
|
148
|
-
const selected =
|
|
149
|
-
|
|
198
|
+
const selected =
|
|
199
|
+
date === props.selected ||
|
|
200
|
+
date === props.rangeStart ||
|
|
201
|
+
date === props.rangeEnd
|
|
202
|
+
const available =
|
|
203
|
+
!props.disabled && !props.readonly && calendar.available(date)
|
|
150
204
|
const active = date === props.activeDate
|
|
151
205
|
return h(
|
|
152
206
|
'td',
|
|
153
207
|
{ key: date, 'aria-selected': selected, style: { padding: '2px' } },
|
|
154
208
|
[
|
|
155
209
|
h(
|
|
156
|
-
|
|
210
|
+
CalendarDay,
|
|
157
211
|
{
|
|
212
|
+
painted: selected || calendar.inRange(date),
|
|
158
213
|
ref: (element: unknown) => {
|
|
159
|
-
if (element)
|
|
214
|
+
if (element)
|
|
215
|
+
days.set(
|
|
216
|
+
date,
|
|
217
|
+
((element as { $el?: HTMLButtonElement }).$el ??
|
|
218
|
+
element) as HTMLButtonElement,
|
|
219
|
+
)
|
|
160
220
|
else days.delete(date)
|
|
161
221
|
},
|
|
162
222
|
type: 'button',
|
|
@@ -190,10 +250,10 @@ export const DateCalendar = defineComponent({
|
|
|
190
250
|
if (props.activeDate !== date) emit('update:activeDate', date)
|
|
191
251
|
},
|
|
192
252
|
onClick: () => {
|
|
193
|
-
if (
|
|
253
|
+
if (available) emit('select', date)
|
|
194
254
|
},
|
|
195
255
|
},
|
|
196
|
-
String(Number(date.slice(8))),
|
|
256
|
+
() => String(Number(date.slice(8))),
|
|
197
257
|
),
|
|
198
258
|
],
|
|
199
259
|
)
|
package/src/components/MAlert.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
|
|
1
2
|
import { defineComponent, h, mergeProps } from 'vue'
|
|
2
3
|
import { alertProps, alertEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
4
|
import { alertAppearance, checkAlertLabels } from '@getcortexlabs/mavis-core'
|
|
@@ -13,6 +14,7 @@ export const MAlert = defineComponent({
|
|
|
13
14
|
emits: alertEmits,
|
|
14
15
|
setup(props, { attrs, slots, emit }) {
|
|
15
16
|
const { theme } = useMavisTheme()
|
|
17
|
+
const arrival = useComponentContent(() => props.title)
|
|
16
18
|
return () => {
|
|
17
19
|
checkAlertLabels(props.title, props.dismissible, props.closeLabel)
|
|
18
20
|
const { colors } = theme.value
|
|
@@ -52,6 +54,7 @@ export const MAlert = defineComponent({
|
|
|
52
54
|
{
|
|
53
55
|
width: 32,
|
|
54
56
|
height: 32,
|
|
57
|
+
motionSurface: arrival,
|
|
55
58
|
radius: 'sm',
|
|
56
59
|
shrink: 0,
|
|
57
60
|
backgroundColor: colors.elevated,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useComponentPaint } from '../component-motion.js'
|
|
1
2
|
import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
2
3
|
import { defineComponent, h, mergeProps, ref, watch } from 'vue'
|
|
3
4
|
import { avatarProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
@@ -12,6 +13,8 @@ export const MAvatar = defineComponent({
|
|
|
12
13
|
setup(props, { attrs }) {
|
|
13
14
|
const { theme } = useMavisTheme()
|
|
14
15
|
const ready = ref(false)
|
|
16
|
+
const photo = ref<HTMLElement>()
|
|
17
|
+
useComponentPaint(photo, () => ({ opacity: ready.value ? 1 : 0 }), 'overlay')
|
|
15
18
|
let revision = 0
|
|
16
19
|
watch(
|
|
17
20
|
() => props.src,
|
|
@@ -71,6 +74,7 @@ export const MAvatar = defineComponent({
|
|
|
71
74
|
'aria-hidden': 'true',
|
|
72
75
|
draggable: false,
|
|
73
76
|
ref: (element) => {
|
|
77
|
+
photo.value = (element as HTMLImageElement) || undefined
|
|
74
78
|
const image = element as HTMLImageElement | null
|
|
75
79
|
if (current === revision && image?.complete) ready.value = image.naturalWidth > 0
|
|
76
80
|
},
|
package/src/components/MBadge.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
1
2
|
import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
2
3
|
import { defineComponent, h, mergeProps } from 'vue'
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
badgeProps,
|
|
6
|
+
useMavisTheme,
|
|
7
|
+
useComponentContent,
|
|
8
|
+
viewAttrs,
|
|
9
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
4
10
|
import { badgeColors } from '@getcortexlabs/mavis-core'
|
|
5
11
|
import { webAttrs } from '../style.js'
|
|
6
12
|
|
|
@@ -10,10 +16,13 @@ export const MBadge = defineComponent({
|
|
|
10
16
|
props: badgeProps,
|
|
11
17
|
setup(props, { attrs }) {
|
|
12
18
|
const { theme } = useMavisTheme()
|
|
19
|
+
const content = useComponentContent(() => props.text, false)
|
|
20
|
+
const motion = useMotionSurface(() => content)
|
|
13
21
|
return () =>
|
|
14
22
|
h(
|
|
15
23
|
'span',
|
|
16
24
|
mergeProps(webAttrs({ ...attrs, ...viewAttrs(props) }), {
|
|
25
|
+
...motion,
|
|
17
26
|
class: 'm-badge',
|
|
18
27
|
role: props.accessibilityLabel ? 'img' : undefined,
|
|
19
28
|
style: {
|
package/src/components/MChip.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { fontFamily } from '@getcortexlabs/mavis-core'
|
|
|
2
2
|
import { defineComponent, h, mergeProps } from 'vue'
|
|
3
3
|
import { checkChipLabels, chipColors } from '@getcortexlabs/mavis-core'
|
|
4
4
|
import { useButtonAction, chipProps, chipEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
5
|
-
import {
|
|
5
|
+
import { usePressFeedback } from '../motion.js'
|
|
6
6
|
import { MRow } from './layout.js'
|
|
7
7
|
import { MIcon } from './MIcon.js'
|
|
8
8
|
import { MButton } from './MButton.js'
|
|
@@ -15,6 +15,7 @@ export const MChip = defineComponent({
|
|
|
15
15
|
setup(props, { attrs, emit }) {
|
|
16
16
|
useButtonAction()
|
|
17
17
|
const { theme } = useMavisTheme()
|
|
18
|
+
const feedback = usePressFeedback(() => props.selectable && !props.disabled, theme)
|
|
18
19
|
return () => {
|
|
19
20
|
checkChipLabels(props.label, props.removable, props.removeLabel)
|
|
20
21
|
const selected = props.selectable && props.modelValue
|
|
@@ -47,6 +48,7 @@ export const MChip = defineComponent({
|
|
|
47
48
|
h(
|
|
48
49
|
props.selectable ? 'button' : 'span',
|
|
49
50
|
{
|
|
51
|
+
...feedback,
|
|
50
52
|
class: 'm-chip-label',
|
|
51
53
|
...(props.selectable
|
|
52
54
|
? {
|
|
@@ -63,7 +65,7 @@ export const MChip = defineComponent({
|
|
|
63
65
|
color: colors.color,
|
|
64
66
|
fontFamily: fontFamily(theme.value.typography.body.fontFamily, 'web'),
|
|
65
67
|
fontSize: `${theme.value.typography.caption.fontSize}px`,
|
|
66
|
-
|
|
68
|
+
transition: 'none',
|
|
67
69
|
},
|
|
68
70
|
},
|
|
69
71
|
[
|
|
@@ -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' }),
|