refactor(core): use shallowRef where possible (#1847)

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2025-05-19 13:56:01 +02:00
committed by GitHub
parent e9ccaa49ea
commit b792d7f536
6 changed files with 9 additions and 9 deletions
@@ -13,7 +13,7 @@ const DefaultNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
isValidSourcePos, isValidSourcePos,
data, data,
}) { }) {
const label = data.label || _label const label = data.label ?? _label
return [ return [
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }), h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
@@ -11,7 +11,7 @@ const InputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
isValidSourcePos, isValidSourcePos,
data, data,
}) { }) {
const label = data.label || _label const label = data.label ?? _label
return [ return [
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]), typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
@@ -86,7 +86,7 @@ const NodeWrapper = defineComponent({
const isFocusable = toRef(() => (typeof node.focusable === 'undefined' ? nodesFocusable.value : node.focusable)) const isFocusable = toRef(() => (typeof node.focusable === 'undefined' ? nodesFocusable.value : node.focusable))
const hasPointerEvents = toRef( const hasPointerEvents = computed(
() => () =>
isSelectable.value || isSelectable.value ||
isDraggable.value || isDraggable.value ||
@@ -11,7 +11,7 @@ const OutputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
isValidTargetPos, isValidTargetPos,
data, data,
}) { }) {
const label = data.label || _label const label = data.label ?? _label
return [ return [
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }), h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
+2 -2
View File
@@ -2,7 +2,7 @@ import type { D3DragEvent, DragBehavior, SubjectPosition } from 'd3-drag'
import { drag } from 'd3-drag' import { drag } from 'd3-drag'
import { select } from 'd3-selection' import { select } from 'd3-selection'
import type { MaybeRefOrGetter, Ref } from 'vue' import type { MaybeRefOrGetter, Ref } from 'vue'
import { ref, toValue, watch } from 'vue' import { shallowRef, toValue, watch } from 'vue'
import type { MouseTouchEvent, NodeDragEvent, NodeDragItem, XYPosition } from '../types' import type { MouseTouchEvent, NodeDragEvent, NodeDragItem, XYPosition } from '../types'
import { import {
calcAutoPan, calcAutoPan,
@@ -62,7 +62,7 @@ export function useDrag(params: UseDragParams) {
const { onStart, onDrag, onStop, onClick, el, disabled, id, selectable, dragHandle } = params const { onStart, onDrag, onStop, onClick, el, disabled, id, selectable, dragHandle } = params
const dragging = ref(false) const dragging = shallowRef(false)
let dragItems: NodeDragItem[] = [] let dragItems: NodeDragItem[] = []
@@ -2,7 +2,7 @@
import type { D3ZoomEvent, ZoomTransform } from 'd3-zoom' import type { D3ZoomEvent, ZoomTransform } from 'd3-zoom'
import { zoom, zoomIdentity } from 'd3-zoom' import { zoom, zoomIdentity } from 'd3-zoom'
import { pointer, select } from 'd3-selection' import { pointer, select } from 'd3-selection'
import { onMounted, ref, toRef, watch } from 'vue' import { onMounted, shallowRef, toRef, watch } from 'vue'
import type { CoordinateExtent, D3ZoomHandler, ViewportTransform } from '../../types' import type { CoordinateExtent, D3ZoomHandler, ViewportTransform } from '../../types'
import { PanOnScrollMode } from '../../types' import { PanOnScrollMode } from '../../types'
import { useKeyPress } from '../../composables/useKeyPress' import { useKeyPress } from '../../composables/useKeyPress'
@@ -44,9 +44,9 @@ const {
useResizeHandler(viewportRef) useResizeHandler(viewportRef)
const isZoomingOrPanning = ref(false) const isZoomingOrPanning = shallowRef(false)
const isPanScrolling = ref(false) const isPanScrolling = shallowRef(false)
let panScrollTimeout: ReturnType<typeof setTimeout> | null = null let panScrollTimeout: ReturnType<typeof setTimeout> | null = null