chore: lint files
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -25,7 +25,9 @@ const {
|
||||
const sourceNode = controlledComputed(
|
||||
() => connectionStartHandle?.nodeId,
|
||||
() => {
|
||||
if (connectionStartHandle?.nodeId) return findNode(connectionStartHandle.nodeId)
|
||||
if (connectionStartHandle?.nodeId) {
|
||||
return findNode(connectionStartHandle.nodeId)
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
@@ -74,7 +76,9 @@ function getType(type?: string, template?: GraphEdge['template']) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (edgeType && typeof edgeType !== 'string') return edgeType
|
||||
if (edgeType && typeof edgeType !== 'string') {
|
||||
return edgeType
|
||||
}
|
||||
|
||||
const slot = slots?.[`edge-${name}`]
|
||||
if (!slot) {
|
||||
|
||||
@@ -12,8 +12,11 @@ const markers = computed(() => {
|
||||
if (marker) {
|
||||
const markerId = getMarkerId(marker, vueFlowId)
|
||||
if (!ids.includes(markerId)) {
|
||||
if (typeof marker === 'object') markers.push({ ...marker, id: markerId, color: marker.color || defaultColor })
|
||||
else markers.push({ id: markerId, color: defaultColor, type: marker as MarkerType })
|
||||
if (typeof marker === 'object') {
|
||||
markers.push({ ...marker, id: markerId, color: marker.color || defaultColor })
|
||||
} else {
|
||||
markers.push({ id: markerId, color: defaultColor, type: marker as MarkerType })
|
||||
}
|
||||
ids.push(markerId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,9 @@ function getType(type?: string, template?: GraphNode['template']) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof nodeType !== 'string') return nodeType
|
||||
if (typeof nodeType !== 'string') {
|
||||
return nodeType
|
||||
}
|
||||
|
||||
const slot = slots?.[`node-${name}`]
|
||||
if (!slot) {
|
||||
|
||||
@@ -42,7 +42,9 @@ const containerBounds = ref<DOMRect>()
|
||||
const hasActiveSelection = computed(() => elementsSelectable.value && (isSelecting || userSelectionActive.value))
|
||||
|
||||
useKeyPress(deleteKeyCode, (keyPressed) => {
|
||||
if (!keyPressed) return
|
||||
if (!keyPressed) {
|
||||
return
|
||||
}
|
||||
|
||||
const nodesToRemove = getNodes.value.reduce<GraphNode[]>((res, node) => {
|
||||
if (!node.selected && node.parentNode && res.find((n) => n.id === node.parentNode)) {
|
||||
@@ -82,7 +84,9 @@ function resetUserSelection() {
|
||||
}
|
||||
|
||||
function onClick(event: MouseEvent) {
|
||||
if (event.target !== container.value || hasActiveSelection.value) return
|
||||
if (event.target !== container.value || hasActiveSelection.value) {
|
||||
return
|
||||
}
|
||||
|
||||
emits.paneClick(event)
|
||||
|
||||
@@ -92,7 +96,9 @@ function onClick(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onContextMenu(event: MouseEvent) {
|
||||
if (event.target !== container.value) return
|
||||
if (event.target !== container.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Array.isArray(panOnDrag.value) && panOnDrag.value?.includes(2)) {
|
||||
event.preventDefault()
|
||||
@@ -103,7 +109,9 @@ function onContextMenu(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onWheel(event: WheelEvent) {
|
||||
if (event.target !== container.value) return
|
||||
if (event.target !== container.value) {
|
||||
return
|
||||
}
|
||||
|
||||
emits.paneScroll(event)
|
||||
}
|
||||
@@ -141,11 +149,19 @@ function onMouseDown(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onMouseMove(event: MouseEvent) {
|
||||
if (!isSelecting || !containerBounds.value || !userSelectionRect.value) return
|
||||
if (!hasActiveSelection.value) return emits.paneMouseMove(event)
|
||||
if (!isSelecting || !containerBounds.value || !userSelectionRect.value) {
|
||||
return
|
||||
}
|
||||
if (!hasActiveSelection.value) {
|
||||
return emits.paneMouseMove(event)
|
||||
}
|
||||
|
||||
if (!userSelectionActive.value) userSelectionActive.value = true
|
||||
if (nodesSelectionActive.value) nodesSelectionActive.value = false
|
||||
if (!userSelectionActive.value) {
|
||||
userSelectionActive.value = true
|
||||
}
|
||||
if (nodesSelectionActive.value) {
|
||||
nodesSelectionActive.value = false
|
||||
}
|
||||
|
||||
const mousePos = getMousePosition(event, containerBounds.value)
|
||||
const startX = userSelectionRect.value.startX ?? 0
|
||||
@@ -177,9 +193,13 @@ function onMouseMove(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onMouseUp(event: MouseEvent) {
|
||||
if (!hasActiveSelection.value) return
|
||||
if (!hasActiveSelection.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.button !== 0) return
|
||||
if (event.button !== 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// We only want to trigger click functions when in selection mode if
|
||||
// the user did not move the mouse.
|
||||
@@ -195,7 +215,9 @@ function onMouseUp(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onMouseLeave(event: MouseEvent) {
|
||||
if (!hasActiveSelection.value) return emits.paneMouseLeave(event)
|
||||
if (!hasActiveSelection.value) {
|
||||
return emits.paneMouseLeave(event)
|
||||
}
|
||||
|
||||
if (userSelectionActive.value) {
|
||||
nodesSelectionActive.value = prevSelectedNodesCount.value > 0
|
||||
@@ -206,7 +228,9 @@ function onMouseLeave(event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onMouseEnter(event: MouseEvent) {
|
||||
if (hasActiveSelection.value) return
|
||||
if (hasActiveSelection.value) {
|
||||
return
|
||||
}
|
||||
|
||||
emits.paneMouseEnter(event)
|
||||
}
|
||||
|
||||
@@ -118,7 +118,9 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
d3Zoom.on('start', (event: D3ZoomEvent<HTMLDivElement, any>) => {
|
||||
if (!event.sourceEvent) return null
|
||||
if (!event.sourceEvent) {
|
||||
return null
|
||||
}
|
||||
|
||||
// we need to remember it here, because it's always 0 in the "zoom" event
|
||||
mouseButton = event.sourceEvent.button
|
||||
@@ -138,7 +140,9 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
d3Zoom.on('end', (event: D3ZoomEvent<HTMLDivElement, any>) => {
|
||||
if (!event.sourceEvent) return null
|
||||
if (!event.sourceEvent) {
|
||||
return null
|
||||
}
|
||||
|
||||
isZoomingOrPanning = false
|
||||
|
||||
@@ -223,27 +227,43 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
// if all interactions are disabled, we prevent all zoom events
|
||||
if (!panOnDrag && !zoomScroll && !panOnScroll && !zoomOnDoubleClick && !zoomOnPinch) return false
|
||||
if (!panOnDrag && !zoomScroll && !panOnScroll && !zoomOnDoubleClick && !zoomOnPinch) {
|
||||
return false
|
||||
}
|
||||
|
||||
// during a selection we prevent all other interactions
|
||||
if (userSelectionActive) return false
|
||||
if (userSelectionActive) {
|
||||
return false
|
||||
}
|
||||
|
||||
// if zoom on double click is disabled, we prevent the double click event
|
||||
if (!zoomOnDoubleClick && event.type === 'dblclick') return false
|
||||
if (!zoomOnDoubleClick && event.type === 'dblclick') {
|
||||
return false
|
||||
}
|
||||
|
||||
// if the target element is inside an element with the nowheel class, we prevent zooming
|
||||
if (isWrappedWithClass(event, noWheelClassName) && event.type === 'wheel') return false
|
||||
if (isWrappedWithClass(event, noWheelClassName) && event.type === 'wheel') {
|
||||
return false
|
||||
}
|
||||
|
||||
// if the target element is inside an element with the nopan class, we prevent panning
|
||||
if (isWrappedWithClass(event, noPanClassName) && event.type !== 'wheel') return false
|
||||
if (isWrappedWithClass(event, noPanClassName) && event.type !== 'wheel') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!zoomOnPinch && event.ctrlKey && event.type === 'wheel') return false
|
||||
if (!zoomOnPinch && event.ctrlKey && event.type === 'wheel') {
|
||||
return false
|
||||
}
|
||||
|
||||
// when there is no scroll handling enabled, we prevent all wheel events
|
||||
if (!zoomScroll && !panOnScroll && !pinchZoom && event.type === 'wheel') return false
|
||||
if (!zoomScroll && !panOnScroll && !pinchZoom && event.type === 'wheel') {
|
||||
return false
|
||||
}
|
||||
|
||||
// if the pane is not movable, we prevent dragging it with mousestart or touchstart
|
||||
if (!panOnDrag && (event.type === 'mousedown' || event.type === 'touchstart')) return false
|
||||
if (!panOnDrag && (event.type === 'mousedown' || event.type === 'touchstart')) {
|
||||
return false
|
||||
}
|
||||
|
||||
// if the pane is only movable using allowed clicks
|
||||
if (
|
||||
@@ -283,7 +303,9 @@ function eventToFlowTransform(eventTransform: ZoomTransform): ViewportTransform
|
||||
}
|
||||
|
||||
function setDimensions() {
|
||||
if (!viewportEl.value) return
|
||||
if (!viewportEl.value) {
|
||||
return
|
||||
}
|
||||
|
||||
const { width, height } = getDimensions(viewportEl.value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user