chore: lint

This commit is contained in:
braks
2023-05-25 20:48:26 +02:00
committed by Braks
parent 1d2cf7eaf4
commit 128b968168
5 changed files with 27 additions and 21 deletions
-1
View File
@@ -78,7 +78,6 @@ export default {
<template> <template>
<Panel class="vue-flow__controls" :position="position"> <Panel class="vue-flow__controls" :position="position">
<slot name="top" /> <slot name="top" />
<template v-if="showZoom"> <template v-if="showZoom">
<slot name="control-zoom-in"> <slot name="control-zoom-in">
<ControlButton class="vue-flow__controls-zoomin" :disabled="maxZoomReached" @click="onZoomInHandler"> <ControlButton class="vue-flow__controls-zoomin" :disabled="maxZoomReached" @click="onZoomInHandler">
@@ -61,7 +61,9 @@ export default {
<text v-bind="$attrs" ref="el" class="vue-flow__edge-text" :y="box.height / 2" dy="0.3em" :style="labelStyle"> <text v-bind="$attrs" ref="el" class="vue-flow__edge-text" :y="box.height / 2" dy="0.3em" :style="labelStyle">
<slot> <slot>
<component :is="label" v-if="!isString(label)" /> <component :is="label" v-if="!isString(label)" />
<template v-else> {{ label }} </template> <template v-else>
{{ label }}
</template>
</slot> </slot>
</text> </text>
</g> </g>
@@ -227,7 +227,7 @@ onMounted(() => {
if ( if (
event.button === 1 && event.button === 1 &&
event.type === 'mousedown' && event.type === 'mousedown' &&
((event.target as HTMLElement)?.closest(`.vue-flow__node`) || (event.target as HTMLElement)?.closest(`.vue-flow__edge`)) ((event.target as HTMLElement)?.closest('.vue-flow__node') || (event.target as HTMLElement)?.closest('.vue-flow__edge'))
) { ) {
return true return true
} }
+6 -1
View File
@@ -1,3 +1,6 @@
/**
* @deprecated; todo: remove this and use `PanelPositionType` instead
*/
export enum PanelPosition { export enum PanelPosition {
TopLeft = 'top-left', TopLeft = 'top-left',
TopCenter = 'top-center', TopCenter = 'top-center',
@@ -7,6 +10,8 @@ export enum PanelPosition {
BottomRight = 'bottom-right', BottomRight = 'bottom-right',
} }
type PanelPositionType = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
export interface PanelProps { export interface PanelProps {
position: PanelPosition position: PanelPosition | PanelPositionType
} }
+17 -17
View File
@@ -40,9 +40,9 @@ const contextNodeId = inject(NodeIdInjection, null)
const resizeControlRef = ref<HTMLDivElement>() const resizeControlRef = ref<HTMLDivElement>()
const startValues = ref<typeof initStartValues>(initStartValues) let startValues: typeof initStartValues = initStartValues
const prevValues = ref<typeof initPrevValues>(initPrevValues) let prevValues: typeof initPrevValues = initPrevValues
const id = computed(() => (typeof props.nodeId === 'string' ? props.nodeId : contextNodeId)) const id = computed(() => (typeof props.nodeId === 'string' ? props.nodeId : contextNodeId))
@@ -67,21 +67,21 @@ watchEffect((onCleanup) => {
const node = findNode(id.value!) const node = findNode(id.value!)
const { xSnapped, ySnapped } = getPointerPosition(event) const { xSnapped, ySnapped } = getPointerPosition(event)
prevValues.value = { prevValues = {
width: node?.dimensions.width ?? 0, width: node?.dimensions.width ?? 0,
height: node?.dimensions.height ?? 0, height: node?.dimensions.height ?? 0,
x: node?.position.x ?? 0, x: node?.position.x ?? 0,
y: node?.position.y ?? 0, y: node?.position.y ?? 0,
} }
startValues.value = { startValues = {
...prevValues.value, ...prevValues,
pointerX: xSnapped, pointerX: xSnapped,
pointerY: ySnapped, pointerY: ySnapped,
aspectRatio: prevValues.value.width / prevValues.value.height, aspectRatio: prevValues.width / prevValues.height,
} }
emits('resizeStart', { event, params: prevValues.value }) emits('resizeStart', { event, params: prevValues })
}) })
.on('drag', (event: ResizeDragEvent) => { .on('drag', (event: ResizeDragEvent) => {
const { xSnapped, ySnapped } = getPointerPosition(event) const { xSnapped, ySnapped } = getPointerPosition(event)
@@ -97,9 +97,9 @@ watchEffect((onCleanup) => {
x: startNodeX, x: startNodeX,
y: startNodeY, y: startNodeY,
aspectRatio: startAspectRatio, aspectRatio: startAspectRatio,
} = startValues.value } = startValues
const { x: prevX, y: prevY, width: prevWidth, height: prevHeight } = prevValues.value const { x: prevX, y: prevY, width: prevWidth, height: prevHeight } = prevValues
const distX = Math.floor(enableX ? xSnapped - startX : 0) const distX = Math.floor(enableX ? xSnapped - startX : 0)
const distY = Math.floor(enableY ? ySnapped - startY : 0) const distY = Math.floor(enableY ? ySnapped - startY : 0)
@@ -163,8 +163,8 @@ watchEffect((onCleanup) => {
changes.push(positionChange) changes.push(positionChange)
prevValues.value.x = positionChange.position!.x prevValues.x = positionChange.position!.x
prevValues.value.y = positionChange.position!.y prevValues.y = positionChange.position!.y
} }
} }
@@ -182,8 +182,8 @@ watchEffect((onCleanup) => {
changes.push(dimensionChange) changes.push(dimensionChange)
prevValues.value.width = width prevValues.width = width
prevValues.value.height = height prevValues.height = height
} }
if (changes.length === 0) { if (changes.length === 0) {
@@ -191,15 +191,15 @@ watchEffect((onCleanup) => {
} }
const direction = getDirection({ const direction = getDirection({
width: prevValues.value.width, width: prevValues.width,
prevWidth, prevWidth,
height: prevValues.value.height, height: prevValues.height,
prevHeight, prevHeight,
invertX, invertX,
invertY, invertY,
}) })
const nextValues = { ...prevValues.value, direction } const nextValues = { ...prevValues, direction }
const callResize = props.shouldResize?.(event, nextValues) const callResize = props.shouldResize?.(event, nextValues)
@@ -219,7 +219,7 @@ watchEffect((onCleanup) => {
resizing: false, resizing: false,
} }
emits('resizeEnd', { event, params: prevValues.value }) emits('resizeEnd', { event, params: prevValues })
triggerEmits.nodesChange([dimensionChange]) triggerEmits.nodesChange([dimensionChange])
}) })