@getcortexlabs/mavis-web 0.1.0-alpha.8 → 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 +7 -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 +16 -1
- 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 +5 -5
- package/dist/components/MAccordion.d.ts +2 -2
- 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 +6 -6
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +14 -8
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +8 -8
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +3 -2
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +2 -2
- 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 +72 -24
- package/dist/components/MDatePicker.d.ts.map +1 -1
- package/dist/components/MDatePicker.js +2 -10
- package/dist/components/MDatePicker.js.map +1 -1
- 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 +3 -3
- 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 +174 -0
- package/dist/components/MGrid.d.ts.map +1 -0
- package/dist/components/MGrid.js +42 -0
- package/dist/components/MGrid.js.map +1 -0
- package/dist/components/MIcon.d.ts +2 -2
- package/dist/components/MIcon.d.ts.map +1 -1
- package/dist/components/MIcon.js +7 -4
- package/dist/components/MIcon.js.map +1 -1
- package/dist/components/MImage.d.ts +50 -5
- package/dist/components/MImage.d.ts.map +1 -1
- package/dist/components/MImage.js +31 -9
- 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 +11 -11
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +12 -0
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MLink.d.ts +1 -1
- package/dist/components/MLink.d.ts.map +1 -1
- package/dist/components/MLink.js +5 -33
- package/dist/components/MLink.js.map +1 -1
- package/dist/components/MListItem.d.ts +3 -3
- 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 +4 -4
- 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 +2 -2
- 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 +2 -2
- 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 +4 -4
- package/dist/components/MSeparator.d.ts +1 -1
- package/dist/components/MSheet.d.ts +16 -7
- package/dist/components/MSheet.d.ts.map +1 -1
- package/dist/components/MSheet.js +45 -14
- package/dist/components/MSheet.js.map +1 -1
- package/dist/components/MSkeleton.d.ts +3 -3
- package/dist/components/MStack.d.ts +25 -14
- package/dist/components/MStack.d.ts.map +1 -1
- package/dist/components/MStack.js +8 -14
- package/dist/components/MStack.js.map +1 -1
- package/dist/components/MSwitch.d.ts +2 -2
- package/dist/components/MTabs.d.ts +2 -2
- 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 +5 -5
- 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 +5 -5
- 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/content-width.d.ts +4 -0
- package/dist/content-width.d.ts.map +1 -0
- package/dist/content-width.js +62 -0
- package/dist/content-width.js.map +1 -0
- package/dist/date-format.d.ts +6 -0
- package/dist/date-format.d.ts.map +1 -0
- package/dist/date-format.js +23 -0
- package/dist/date-format.js.map +1 -0
- package/dist/icons.d.ts +14 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +23 -0
- package/dist/icons.js.map +1 -0
- package/dist/image-effects.d.ts.map +1 -1
- package/dist/image-effects.js +2 -0
- package/dist/image-effects.js.map +1 -1
- package/dist/index.d.ts +23 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -10
- 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 +16 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +22 -0
- package/dist/services.js.map +1 -0
- package/package.json +23 -5
- package/src/animated-number.ts +59 -0
- package/src/base.css +1101 -0
- 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/MButton.ts +28 -25
- package/src/components/MCard.ts +3 -1
- package/src/components/MChip.ts +4 -2
- package/src/components/MCombobox.ts +136 -101
- package/src/components/MDatePicker.ts +1 -9
- 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 +69 -0
- package/src/components/MIcon.ts +7 -8
- package/src/components/MImage.ts +36 -12
- package/src/components/MImageCompare.ts +218 -0
- package/src/components/MImageViewer.ts +560 -0
- package/src/components/MInput.ts +14 -3
- package/src/components/MLink.ts +10 -32
- 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/MSheet.ts +47 -14
- package/src/components/MStack.ts +8 -20
- 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/content-width.ts +70 -0
- package/src/date-format.ts +36 -0
- package/src/icons.css +7 -0
- package/src/icons.ts +28 -0
- package/src/image-effects.ts +2 -0
- package/src/index.ts +143 -63
- 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 +39 -0
- package/src/style.css +2 -1000
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
mergeProps,
|
|
6
|
+
nextTick,
|
|
7
|
+
onActivated,
|
|
8
|
+
onBeforeUnmount,
|
|
9
|
+
onDeactivated,
|
|
10
|
+
onMounted,
|
|
11
|
+
ref,
|
|
12
|
+
watch,
|
|
13
|
+
} from 'vue'
|
|
14
|
+
import type { WebZoomable, WebSharedLayout } from '@rafaelaugusto/jolt/web'
|
|
15
|
+
import {
|
|
16
|
+
choiceKey,
|
|
17
|
+
validateViewer,
|
|
18
|
+
type ChoiceValue,
|
|
19
|
+
type ViewerImage,
|
|
20
|
+
} from '@getcortexlabs/mavis-core'
|
|
21
|
+
import { imageViewerProps, useCachedActivity, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
22
|
+
import { useMotionContext } from '../motion-context.js'
|
|
23
|
+
import { MButton } from './MButton.js'
|
|
24
|
+
|
|
25
|
+
export const MImageViewer = defineComponent({
|
|
26
|
+
name: 'MImageViewer',
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
props: imageViewerProps,
|
|
29
|
+
emits: {
|
|
30
|
+
'update:modelValue': (_key: ChoiceValue) => true,
|
|
31
|
+
'update:open': (_open: boolean) => true,
|
|
32
|
+
close: (_reason: 'button' | 'escape' | 'gesture' | 'outside') => true,
|
|
33
|
+
error: (_image: ViewerImage) => true,
|
|
34
|
+
},
|
|
35
|
+
setup(props, { attrs, emit }) {
|
|
36
|
+
const { theme } = useMavisTheme()
|
|
37
|
+
const active = useCachedActivity()
|
|
38
|
+
const context = useMotionContext()
|
|
39
|
+
const selected = computed(() => {
|
|
40
|
+
validateViewer(props.images)
|
|
41
|
+
return props.images.find((image) => image.key === props.modelValue) ?? props.images[0]
|
|
42
|
+
})
|
|
43
|
+
const requested = computed(
|
|
44
|
+
() => props.open && !props.disabled && active.value && !!selected.value,
|
|
45
|
+
)
|
|
46
|
+
const presented = ref(false),
|
|
47
|
+
displayed = ref<ViewerImage>(),
|
|
48
|
+
loaded = ref(false),
|
|
49
|
+
failed = ref(false),
|
|
50
|
+
zoomReady = ref(false),
|
|
51
|
+
scale = ref(1)
|
|
52
|
+
const dialog = ref<HTMLDialogElement>(),
|
|
53
|
+
viewport = ref<HTMLElement>(),
|
|
54
|
+
photo = ref<HTMLImageElement>()
|
|
55
|
+
const thumbs = new Map<string, HTMLImageElement>(),
|
|
56
|
+
triggers = new Map<string, HTMLButtonElement>()
|
|
57
|
+
let lease: ReturnType<typeof context.acquire> | undefined,
|
|
58
|
+
shared: WebSharedLayout | undefined,
|
|
59
|
+
zoom: WebZoomable | undefined
|
|
60
|
+
let generation = 0,
|
|
61
|
+
flying = false,
|
|
62
|
+
pendingClose = false
|
|
63
|
+
let detachPhoto = () => {},
|
|
64
|
+
opener: HTMLElement | undefined,
|
|
65
|
+
pendingOpener: HTMLElement | undefined
|
|
66
|
+
let previousOverflow: string | undefined
|
|
67
|
+
function attachImage(element: HTMLImageElement | undefined) {
|
|
68
|
+
detachPhoto()
|
|
69
|
+
detachPhoto = () => {}
|
|
70
|
+
if (element && shared) detachPhoto = shared.attach(element, 'photo')
|
|
71
|
+
}
|
|
72
|
+
function releaseZoom() {
|
|
73
|
+
zoom?.dispose()
|
|
74
|
+
zoom = undefined
|
|
75
|
+
zoomReady.value = false
|
|
76
|
+
scale.value = 1
|
|
77
|
+
}
|
|
78
|
+
function startZoom() {
|
|
79
|
+
if (
|
|
80
|
+
!lease ||
|
|
81
|
+
!requested.value ||
|
|
82
|
+
!presented.value ||
|
|
83
|
+
!photo.value ||
|
|
84
|
+
!viewport.value ||
|
|
85
|
+
!loaded.value ||
|
|
86
|
+
flying ||
|
|
87
|
+
zoom
|
|
88
|
+
)
|
|
89
|
+
return
|
|
90
|
+
zoom = lease.runtime.zoomable(photo.value, {
|
|
91
|
+
viewport: viewport.value,
|
|
92
|
+
scale: [1, Math.max(1, props.maxZoom)],
|
|
93
|
+
doubleTap: Math.min(2.5, props.maxZoom),
|
|
94
|
+
dismiss: 'vertical',
|
|
95
|
+
onSettled(state) {
|
|
96
|
+
scale.value = state.scale
|
|
97
|
+
if (pendingClose && state.scale <= 1.001) finishClose()
|
|
98
|
+
},
|
|
99
|
+
onDismiss(intent) {
|
|
100
|
+
request('gesture')
|
|
101
|
+
void nextTick(() => {
|
|
102
|
+
if (requested.value) intent.cancel()
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
onError() {
|
|
106
|
+
if (displayed.value) emit('error', displayed.value)
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
zoomReady.value = zoom.ready
|
|
110
|
+
}
|
|
111
|
+
function restorePage() {
|
|
112
|
+
if (previousOverflow !== undefined && document.body.style.overflow === 'hidden')
|
|
113
|
+
document.body.style.overflow = previousOverflow
|
|
114
|
+
previousOverflow = undefined
|
|
115
|
+
}
|
|
116
|
+
function restoreFocus() {
|
|
117
|
+
const target = opener?.isConnected
|
|
118
|
+
? opener
|
|
119
|
+
: displayed.value
|
|
120
|
+
? triggers.get(choiceKey(displayed.value.key))
|
|
121
|
+
: undefined
|
|
122
|
+
if (
|
|
123
|
+
target?.isConnected &&
|
|
124
|
+
(!document.activeElement ||
|
|
125
|
+
document.activeElement === document.body ||
|
|
126
|
+
dialog.value?.contains(document.activeElement))
|
|
127
|
+
)
|
|
128
|
+
target.focus({ preventScroll: true })
|
|
129
|
+
opener = undefined
|
|
130
|
+
}
|
|
131
|
+
function finishClose() {
|
|
132
|
+
if (!presented.value || requested.value) {
|
|
133
|
+
pendingClose = false
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
pendingClose = false
|
|
137
|
+
releaseZoom()
|
|
138
|
+
const token = ++generation
|
|
139
|
+
flying = false
|
|
140
|
+
const thumb = displayed.value ? thumbs.get(choiceKey(displayed.value.key)) : undefined
|
|
141
|
+
const change = () => {
|
|
142
|
+
presented.value = false
|
|
143
|
+
if (dialog.value?.open) dialog.value.close()
|
|
144
|
+
attachImage(thumb)
|
|
145
|
+
restorePage()
|
|
146
|
+
}
|
|
147
|
+
const flight = shared?.transition(change)
|
|
148
|
+
if (!flight) change()
|
|
149
|
+
void (flight?.finished ?? Promise.resolve()).then(() => {
|
|
150
|
+
if (token === generation && !requested.value) restoreFocus()
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
function sync() {
|
|
154
|
+
if (!lease) return
|
|
155
|
+
if (!requested.value) {
|
|
156
|
+
if (presented.value && zoom && zoom.state.scale > 1.001) {
|
|
157
|
+
pendingClose = true
|
|
158
|
+
zoom.reset()
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
finishClose()
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
pendingClose = false
|
|
165
|
+
if (presented.value) {
|
|
166
|
+
if (
|
|
167
|
+
displayed.value?.key !== selected.value?.key ||
|
|
168
|
+
displayed.value?.src !== selected.value?.src
|
|
169
|
+
) {
|
|
170
|
+
++generation
|
|
171
|
+
shared?.cancel()
|
|
172
|
+
releaseZoom()
|
|
173
|
+
flying = false
|
|
174
|
+
loaded.value = failed.value = false
|
|
175
|
+
displayed.value = selected.value
|
|
176
|
+
void nextTick(() => {
|
|
177
|
+
attachImage(photo.value)
|
|
178
|
+
if (photo.value?.complete && photo.value.naturalWidth) {
|
|
179
|
+
loaded.value = true
|
|
180
|
+
startZoom()
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
const token = ++generation
|
|
187
|
+
displayed.value = selected.value
|
|
188
|
+
loaded.value = failed.value = false
|
|
189
|
+
opener =
|
|
190
|
+
pendingOpener ??
|
|
191
|
+
(document.activeElement instanceof HTMLElement ? document.activeElement : undefined)
|
|
192
|
+
pendingOpener = undefined
|
|
193
|
+
previousOverflow = document.body.style.overflow
|
|
194
|
+
document.body.style.overflow = 'hidden'
|
|
195
|
+
attachImage(displayed.value ? thumbs.get(choiceKey(displayed.value.key)) : undefined)
|
|
196
|
+
flying = true
|
|
197
|
+
const change = () => {
|
|
198
|
+
presented.value = true
|
|
199
|
+
void nextTick(() => {
|
|
200
|
+
if (token !== generation || !presented.value) return
|
|
201
|
+
dialog.value?.showModal()
|
|
202
|
+
attachImage(photo.value)
|
|
203
|
+
dialog.value
|
|
204
|
+
?.querySelector<HTMLButtonElement>('[data-viewer-close]')
|
|
205
|
+
?.focus({ preventScroll: true })
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
const flight = shared?.transition(change)
|
|
209
|
+
if (!flight) change()
|
|
210
|
+
void (flight?.finished ?? nextTick()).then(() => {
|
|
211
|
+
if (token === generation) {
|
|
212
|
+
flying = false
|
|
213
|
+
startZoom()
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
function request(reason: 'button' | 'escape' | 'gesture' | 'outside') {
|
|
218
|
+
if (!requested.value) return
|
|
219
|
+
emit('update:open', false)
|
|
220
|
+
emit('close', reason)
|
|
221
|
+
}
|
|
222
|
+
function move(delta: number) {
|
|
223
|
+
const index = props.images.findIndex((image) => image.key === selected.value?.key)
|
|
224
|
+
const next = props.images[index + delta]
|
|
225
|
+
if (next && !props.disabled) emit('update:modelValue', next.key)
|
|
226
|
+
}
|
|
227
|
+
function zoomBy(delta: number) {
|
|
228
|
+
if (zoom) zoom.zoomTo(Math.max(1, Math.min(props.maxZoom, zoom.state.scale + delta)))
|
|
229
|
+
}
|
|
230
|
+
function key(event: KeyboardEvent) {
|
|
231
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return
|
|
232
|
+
if (event.key === 'Tab' && dialog.value) {
|
|
233
|
+
const buttons = [
|
|
234
|
+
...dialog.value.querySelectorAll<HTMLButtonElement>('button:not(:disabled)'),
|
|
235
|
+
]
|
|
236
|
+
const first = buttons[0],
|
|
237
|
+
last = buttons[buttons.length - 1]
|
|
238
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
239
|
+
event.preventDefault()
|
|
240
|
+
last?.focus()
|
|
241
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
242
|
+
event.preventDefault()
|
|
243
|
+
first?.focus()
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (event.target instanceof HTMLButtonElement) return
|
|
247
|
+
if (
|
|
248
|
+
(zoom?.state.scale ?? 1) <= 1.001 &&
|
|
249
|
+
(event.key === 'ArrowRight' || event.key === 'ArrowLeft')
|
|
250
|
+
) {
|
|
251
|
+
event.preventDefault()
|
|
252
|
+
move(event.key === 'ArrowRight' ? 1 : -1)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function connect() {
|
|
256
|
+
if (lease) return
|
|
257
|
+
lease = context.acquire(document)
|
|
258
|
+
shared = lease.runtime.sharedLayout(document.body, {
|
|
259
|
+
transition: { type: 'spring', duration: 460, bounce: 0.06 },
|
|
260
|
+
})
|
|
261
|
+
sync()
|
|
262
|
+
}
|
|
263
|
+
function cleanup() {
|
|
264
|
+
++generation
|
|
265
|
+
pendingClose = flying = false
|
|
266
|
+
releaseZoom()
|
|
267
|
+
detachPhoto()
|
|
268
|
+
shared?.dispose()
|
|
269
|
+
shared = undefined
|
|
270
|
+
dialog.value?.close()
|
|
271
|
+
presented.value = false
|
|
272
|
+
if (typeof document !== 'undefined') {
|
|
273
|
+
restorePage()
|
|
274
|
+
restoreFocus()
|
|
275
|
+
}
|
|
276
|
+
lease?.release()
|
|
277
|
+
lease = undefined
|
|
278
|
+
}
|
|
279
|
+
watch([requested, selected], sync, { flush: 'post' })
|
|
280
|
+
watch(
|
|
281
|
+
() => props.maxZoom,
|
|
282
|
+
() => {
|
|
283
|
+
releaseZoom()
|
|
284
|
+
startZoom()
|
|
285
|
+
},
|
|
286
|
+
)
|
|
287
|
+
onMounted(connect)
|
|
288
|
+
onActivated(connect)
|
|
289
|
+
onDeactivated(cleanup)
|
|
290
|
+
onBeforeUnmount(cleanup)
|
|
291
|
+
return () => {
|
|
292
|
+
if (!Number.isFinite(props.maxZoom) || props.maxZoom < 1)
|
|
293
|
+
throw new RangeError('maxZoom must be at least 1.')
|
|
294
|
+
validateViewer(props.images)
|
|
295
|
+
const index = props.images.findIndex((image) => image.key === displayed.value?.key)
|
|
296
|
+
return h(
|
|
297
|
+
'div',
|
|
298
|
+
mergeProps(attrs, { class: 'm-image-viewer', role: 'group', 'aria-label': props.label }),
|
|
299
|
+
[
|
|
300
|
+
h(
|
|
301
|
+
'div',
|
|
302
|
+
{
|
|
303
|
+
style: {
|
|
304
|
+
display: 'grid',
|
|
305
|
+
gridTemplateColumns: 'repeat(auto-fit,minmax(min(100%,150px),1fr))',
|
|
306
|
+
gap: '12px',
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
props.images.map((image) =>
|
|
310
|
+
h(
|
|
311
|
+
'button',
|
|
312
|
+
{
|
|
313
|
+
key: choiceKey(image.key),
|
|
314
|
+
ref: (element: unknown) => {
|
|
315
|
+
if (element) triggers.set(choiceKey(image.key), element as HTMLButtonElement)
|
|
316
|
+
else triggers.delete(choiceKey(image.key))
|
|
317
|
+
},
|
|
318
|
+
type: 'button',
|
|
319
|
+
disabled: props.disabled,
|
|
320
|
+
'aria-label': image.alt,
|
|
321
|
+
'aria-haspopup': 'dialog',
|
|
322
|
+
style: {
|
|
323
|
+
padding: 0,
|
|
324
|
+
border: `1px solid ${theme.value.colors.border}`,
|
|
325
|
+
borderRadius: '14px',
|
|
326
|
+
overflow: 'hidden',
|
|
327
|
+
background: theme.value.colors.surface,
|
|
328
|
+
cursor: props.disabled ? 'default' : 'zoom-in',
|
|
329
|
+
},
|
|
330
|
+
onClick: (event: MouseEvent) => {
|
|
331
|
+
pendingOpener = event.currentTarget as HTMLElement
|
|
332
|
+
emit('update:modelValue', image.key)
|
|
333
|
+
emit('update:open', true)
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
[
|
|
337
|
+
h('img', {
|
|
338
|
+
ref: (element: unknown) => {
|
|
339
|
+
if (element) thumbs.set(choiceKey(image.key), element as HTMLImageElement)
|
|
340
|
+
else thumbs.delete(choiceKey(image.key))
|
|
341
|
+
},
|
|
342
|
+
src: image.thumbnail ?? image.src,
|
|
343
|
+
alt: '',
|
|
344
|
+
loading: 'lazy',
|
|
345
|
+
style: {
|
|
346
|
+
display: 'block',
|
|
347
|
+
width: '100%',
|
|
348
|
+
aspectRatio: String(image.aspectRatio ?? 1.5),
|
|
349
|
+
objectFit: 'cover',
|
|
350
|
+
},
|
|
351
|
+
}),
|
|
352
|
+
h(
|
|
353
|
+
'span',
|
|
354
|
+
{
|
|
355
|
+
style: {
|
|
356
|
+
display: 'block',
|
|
357
|
+
padding: '10px 12px',
|
|
358
|
+
color: theme.value.colors.text,
|
|
359
|
+
textAlign: 'start',
|
|
360
|
+
font: 'inherit',
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
image.alt,
|
|
364
|
+
),
|
|
365
|
+
],
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
),
|
|
369
|
+
h(
|
|
370
|
+
'dialog',
|
|
371
|
+
{
|
|
372
|
+
ref: dialog,
|
|
373
|
+
'aria-label': props.label,
|
|
374
|
+
onCancel: (event: Event) => {
|
|
375
|
+
event.preventDefault()
|
|
376
|
+
request('escape')
|
|
377
|
+
},
|
|
378
|
+
onClose: () => {
|
|
379
|
+
if (dialog.value?.open) return
|
|
380
|
+
if (requested.value) request('escape')
|
|
381
|
+
else restoreFocus()
|
|
382
|
+
},
|
|
383
|
+
onKeydown: key,
|
|
384
|
+
style: {
|
|
385
|
+
boxSizing: 'border-box',
|
|
386
|
+
width: '100vw',
|
|
387
|
+
height: '100dvh',
|
|
388
|
+
maxWidth: 'none',
|
|
389
|
+
maxHeight: 'none',
|
|
390
|
+
padding:
|
|
391
|
+
'max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))',
|
|
392
|
+
margin: 0,
|
|
393
|
+
border: 0,
|
|
394
|
+
background: theme.value.colors.background,
|
|
395
|
+
color: theme.value.colors.text,
|
|
396
|
+
overflow: 'hidden',
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
presented.value && displayed.value
|
|
400
|
+
? [
|
|
401
|
+
h(
|
|
402
|
+
'div',
|
|
403
|
+
{
|
|
404
|
+
style: {
|
|
405
|
+
display: 'grid',
|
|
406
|
+
gridTemplateRows: 'auto minmax(0,1fr) auto',
|
|
407
|
+
gap: '12px',
|
|
408
|
+
height: '100%',
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
[
|
|
412
|
+
h(
|
|
413
|
+
'div',
|
|
414
|
+
{
|
|
415
|
+
style: {
|
|
416
|
+
display: 'flex',
|
|
417
|
+
justifyContent: 'space-between',
|
|
418
|
+
alignItems: 'center',
|
|
419
|
+
gap: '12px',
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
[
|
|
423
|
+
h(
|
|
424
|
+
'span',
|
|
425
|
+
{ role: 'status', 'aria-live': 'polite' },
|
|
426
|
+
`${index + 1} / ${props.images.length} · ${displayed.value.alt}`,
|
|
427
|
+
),
|
|
428
|
+
h(MButton, {
|
|
429
|
+
'data-viewer-close': '',
|
|
430
|
+
text: props.closeLabel,
|
|
431
|
+
variant: 'secondary',
|
|
432
|
+
onClick: () => request('button'),
|
|
433
|
+
}),
|
|
434
|
+
],
|
|
435
|
+
),
|
|
436
|
+
h(
|
|
437
|
+
'div',
|
|
438
|
+
{
|
|
439
|
+
ref: viewport,
|
|
440
|
+
tabindex: 0,
|
|
441
|
+
'aria-label': displayed.value.alt,
|
|
442
|
+
style: {
|
|
443
|
+
position: 'relative',
|
|
444
|
+
minHeight: 0,
|
|
445
|
+
overflow: 'hidden',
|
|
446
|
+
touchAction: 'none',
|
|
447
|
+
display: 'grid',
|
|
448
|
+
placeItems: 'center',
|
|
449
|
+
borderRadius: '12px',
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
[
|
|
453
|
+
h('img', {
|
|
454
|
+
key: `${choiceKey(displayed.value.key)}:${displayed.value.src}`,
|
|
455
|
+
ref: photo,
|
|
456
|
+
src: displayed.value.src,
|
|
457
|
+
alt: displayed.value.alt,
|
|
458
|
+
draggable: false,
|
|
459
|
+
style: {
|
|
460
|
+
width: '100%',
|
|
461
|
+
height: '100%',
|
|
462
|
+
objectFit: 'contain',
|
|
463
|
+
display: 'block',
|
|
464
|
+
minHeight: 0,
|
|
465
|
+
},
|
|
466
|
+
onLoad: (event: Event) => {
|
|
467
|
+
if (event.currentTarget !== photo.value) return
|
|
468
|
+
loaded.value = true
|
|
469
|
+
failed.value = false
|
|
470
|
+
startZoom()
|
|
471
|
+
},
|
|
472
|
+
onError: (event: Event) => {
|
|
473
|
+
if (event.currentTarget !== photo.value) return
|
|
474
|
+
failed.value = true
|
|
475
|
+
loaded.value = false
|
|
476
|
+
if (displayed.value) emit('error', displayed.value)
|
|
477
|
+
},
|
|
478
|
+
}),
|
|
479
|
+
failed.value
|
|
480
|
+
? h(
|
|
481
|
+
'p',
|
|
482
|
+
{ role: 'status', style: { position: 'absolute' } },
|
|
483
|
+
props.errorLabel,
|
|
484
|
+
)
|
|
485
|
+
: null,
|
|
486
|
+
],
|
|
487
|
+
),
|
|
488
|
+
h(
|
|
489
|
+
'div',
|
|
490
|
+
{
|
|
491
|
+
style: {
|
|
492
|
+
display: 'flex',
|
|
493
|
+
flexWrap: 'wrap',
|
|
494
|
+
gap: '8px',
|
|
495
|
+
alignItems: 'center',
|
|
496
|
+
justifyContent: 'center',
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
[
|
|
500
|
+
h(MButton, {
|
|
501
|
+
icon: 'chevron-left',
|
|
502
|
+
accessibilityLabel: props.previousLabel,
|
|
503
|
+
variant: 'secondary',
|
|
504
|
+
disabled: index <= 0,
|
|
505
|
+
onClick: () => move(-1),
|
|
506
|
+
}),
|
|
507
|
+
h(MButton, {
|
|
508
|
+
icon: 'zoom-out',
|
|
509
|
+
accessibilityLabel: props.zoomOutLabel,
|
|
510
|
+
variant: 'ghost',
|
|
511
|
+
disabled: !zoomReady.value || scale.value <= 1,
|
|
512
|
+
onClick: () => zoomBy(-0.5),
|
|
513
|
+
}),
|
|
514
|
+
h(MButton, {
|
|
515
|
+
text: `${Math.round(scale.value * 100)}%`,
|
|
516
|
+
accessibilityLabel: `${Math.round(scale.value * 100)}% · ${props.resetLabel}`,
|
|
517
|
+
variant: 'ghost',
|
|
518
|
+
disabled: !zoomReady.value,
|
|
519
|
+
onClick: () => zoom?.reset(),
|
|
520
|
+
}),
|
|
521
|
+
h(MButton, {
|
|
522
|
+
icon: 'zoom-in',
|
|
523
|
+
accessibilityLabel: props.zoomInLabel,
|
|
524
|
+
variant: 'ghost',
|
|
525
|
+
disabled: !zoomReady.value || scale.value >= props.maxZoom,
|
|
526
|
+
onClick: () => zoomBy(0.5),
|
|
527
|
+
}),
|
|
528
|
+
h(MButton, {
|
|
529
|
+
icon: 'chevron-right',
|
|
530
|
+
accessibilityLabel: props.nextLabel,
|
|
531
|
+
variant: 'secondary',
|
|
532
|
+
disabled: index >= props.images.length - 1,
|
|
533
|
+
onClick: () => move(1),
|
|
534
|
+
}),
|
|
535
|
+
displayed.value.caption
|
|
536
|
+
? h(
|
|
537
|
+
'p',
|
|
538
|
+
{
|
|
539
|
+
style: {
|
|
540
|
+
flexBasis: '100%',
|
|
541
|
+
textAlign: 'center',
|
|
542
|
+
margin: 0,
|
|
543
|
+
color: theme.value.colors.muted,
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
displayed.value.caption,
|
|
547
|
+
)
|
|
548
|
+
: null,
|
|
549
|
+
],
|
|
550
|
+
),
|
|
551
|
+
],
|
|
552
|
+
),
|
|
553
|
+
]
|
|
554
|
+
: [],
|
|
555
|
+
),
|
|
556
|
+
],
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
})
|
package/src/components/MInput.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
2
|
+
import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
|
|
1
3
|
import {
|
|
2
4
|
defineComponent,
|
|
3
5
|
getCurrentInstance,
|
|
@@ -26,7 +28,7 @@ import {
|
|
|
26
28
|
validateInput,
|
|
27
29
|
iconSizes,
|
|
28
30
|
inputActionSize,
|
|
29
|
-
type
|
|
31
|
+
type InputActionHandle,
|
|
30
32
|
} from '@getcortexlabs/mavis-core'
|
|
31
33
|
import { length, webAttrs } from '../style.js'
|
|
32
34
|
import { MIcon } from './MIcon.js'
|
|
@@ -43,9 +45,12 @@ const Input = defineComponent({
|
|
|
43
45
|
useButtonAction()
|
|
44
46
|
const instance = getCurrentInstance()!
|
|
45
47
|
const { theme } = useMavisTheme()
|
|
48
|
+
const helper = useComponentContent(() => props.error || props.helperText, false)
|
|
49
|
+
const helperMotion = useMotionSurface(() => helper)
|
|
46
50
|
const shrink = useLayoutShrink()
|
|
47
51
|
const generatedId = `m-input-${useId()}`
|
|
48
52
|
const editor = ref<HTMLInputElement | HTMLTextAreaElement>()
|
|
53
|
+
const actionButton = ref<{ $el?: HTMLElement }>()
|
|
49
54
|
const focused = ref(false)
|
|
50
55
|
const hydrationEdit = useHydrationEdit(
|
|
51
56
|
(root) => {
|
|
@@ -141,11 +146,15 @@ const Input = defineComponent({
|
|
|
141
146
|
},
|
|
142
147
|
)
|
|
143
148
|
expose({
|
|
149
|
+
focusAction: () => {
|
|
150
|
+
if (props.disabled || props.readonly || props.trailingAction?.disabled) return
|
|
151
|
+
actionButton.value?.$el?.focus?.({ preventScroll: true })
|
|
152
|
+
},
|
|
144
153
|
focus: () => {
|
|
145
154
|
if (!props.disabled) editor.value?.focus()
|
|
146
155
|
},
|
|
147
156
|
blur: () => editor.value?.blur(),
|
|
148
|
-
} satisfies
|
|
157
|
+
} satisfies InputActionHandle)
|
|
149
158
|
|
|
150
159
|
return () => {
|
|
151
160
|
validateInput(props)
|
|
@@ -303,6 +312,7 @@ const Input = defineComponent({
|
|
|
303
312
|
icon(props.trailingIcon, true),
|
|
304
313
|
action
|
|
305
314
|
? h(MButton, {
|
|
315
|
+
ref: actionButton,
|
|
306
316
|
class: 'm-input-action',
|
|
307
317
|
type: 'button',
|
|
308
318
|
icon: action.icon,
|
|
@@ -333,6 +343,7 @@ const Input = defineComponent({
|
|
|
333
343
|
? h(
|
|
334
344
|
'p',
|
|
335
345
|
{
|
|
346
|
+
...helperMotion,
|
|
336
347
|
id: `${id}-message`,
|
|
337
348
|
style: {
|
|
338
349
|
margin: 0,
|
|
@@ -352,5 +363,5 @@ const Input = defineComponent({
|
|
|
352
363
|
|
|
353
364
|
// Vue's options overload does not infer setupContext.expose() in its constructor type.
|
|
354
365
|
export const MInput = Input as typeof Input & {
|
|
355
|
-
new (): InstanceType<typeof Input> &
|
|
366
|
+
new (): InstanceType<typeof Input> & InputActionHandle & { $props: InputEditorAttributes }
|
|
356
367
|
}
|
package/src/components/MLink.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps } from 'vue'
|
|
2
|
-
import { fontFamily,
|
|
2
|
+
import { fontFamily, nonNegative } from '@getcortexlabs/mavis-core'
|
|
3
3
|
import {
|
|
4
4
|
linkProps,
|
|
5
5
|
linkEmits,
|
|
6
6
|
textContent,
|
|
7
7
|
useLayoutShrink,
|
|
8
8
|
useMavisTheme,
|
|
9
|
+
useNavigationOptions,
|
|
9
10
|
viewAttrs,
|
|
10
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
11
12
|
import { webAttrs } from '../style.js'
|
|
13
|
+
import { navigationAttrs } from '../navigation.js'
|
|
12
14
|
|
|
13
15
|
export const MLink = defineComponent({
|
|
14
16
|
name: 'MLink',
|
|
@@ -18,8 +20,8 @@ export const MLink = defineComponent({
|
|
|
18
20
|
setup(props, { attrs, slots, emit }) {
|
|
19
21
|
const { theme } = useMavisTheme()
|
|
20
22
|
const shrink = useLayoutShrink()
|
|
23
|
+
const navigation = useNavigationOptions(props)
|
|
21
24
|
return () => {
|
|
22
|
-
const href = linkDestination(props.href)
|
|
23
25
|
const text = props.text ?? textContent(slots.default?.())
|
|
24
26
|
if (!(props.accessibilityLabel ?? text).trim()) throw new TypeError('MLink requires a name.')
|
|
25
27
|
const type = theme.value.typography.body
|
|
@@ -27,12 +29,6 @@ export const MLink = defineComponent({
|
|
|
27
29
|
'a',
|
|
28
30
|
mergeProps(webAttrs({ ...attrs, ...viewAttrs(props) }), {
|
|
29
31
|
class: 'm-link',
|
|
30
|
-
href: props.disabled ? undefined : href,
|
|
31
|
-
target: props.target,
|
|
32
|
-
rel: linkRel(props.target, props.rel),
|
|
33
|
-
role: 'link',
|
|
34
|
-
tabindex: props.disabled ? -1 : undefined,
|
|
35
|
-
'aria-disabled': props.disabled || undefined,
|
|
36
32
|
style: {
|
|
37
33
|
'--m-focus': theme.value.colors.primary,
|
|
38
34
|
display: props.inline ? 'inline' : 'inline-flex',
|
|
@@ -53,30 +49,12 @@ export const MLink = defineComponent({
|
|
|
53
49
|
flexShrink: nonNegative(props.shrink ?? shrink.value, 'shrink'),
|
|
54
50
|
minWidth: 0,
|
|
55
51
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
emit('click')
|
|
63
|
-
if (
|
|
64
|
-
!props.navigate ||
|
|
65
|
-
props.target !== '_self' ||
|
|
66
|
-
event.button !== 0 ||
|
|
67
|
-
event.metaKey ||
|
|
68
|
-
event.ctrlKey ||
|
|
69
|
-
event.shiftKey ||
|
|
70
|
-
event.altKey
|
|
71
|
-
)
|
|
72
|
-
return
|
|
73
|
-
event.preventDefault()
|
|
74
|
-
try {
|
|
75
|
-
Promise.resolve(props.navigate(href)).catch((error) => emit('error', error))
|
|
76
|
-
} catch (error) {
|
|
77
|
-
emit('error', error)
|
|
78
|
-
}
|
|
79
|
-
},
|
|
52
|
+
...navigationAttrs(
|
|
53
|
+
navigation(),
|
|
54
|
+
props.disabled,
|
|
55
|
+
() => emit('click'),
|
|
56
|
+
(error) => emit('error', error),
|
|
57
|
+
),
|
|
80
58
|
}),
|
|
81
59
|
text,
|
|
82
60
|
)
|