Skip to content

Commit b792d7f

Browse files
authored
refactor(core): use shallowRef where possible (#1847)
Signed-off-by: braks <[email protected]>
1 parent e9ccaa4 commit b792d7f

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

packages/core/src/components/Nodes/DefaultNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const DefaultNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1313
isValidSourcePos,
1414
data,
1515
}) {
16-
const label = data.label || _label
16+
const label = data.label ?? _label
1717

1818
return [
1919
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),

packages/core/src/components/Nodes/InputNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const InputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1111
isValidSourcePos,
1212
data,
1313
}) {
14-
const label = data.label || _label
14+
const label = data.label ?? _label
1515

1616
return [
1717
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),

packages/core/src/components/Nodes/NodeWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const NodeWrapper = defineComponent({
8686

8787
const isFocusable = toRef(() => (typeof node.focusable === 'undefined' ? nodesFocusable.value : node.focusable))
8888

89-
const hasPointerEvents = toRef(
89+
const hasPointerEvents = computed(
9090
() =>
9191
isSelectable.value ||
9292
isDraggable.value ||

packages/core/src/components/Nodes/OutputNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const OutputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1111
isValidTargetPos,
1212
data,
1313
}) {
14-
const label = data.label || _label
14+
const label = data.label ?? _label
1515

1616
return [
1717
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),

packages/core/src/composables/useDrag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { D3DragEvent, DragBehavior, SubjectPosition } from 'd3-drag'
22
import { drag } from 'd3-drag'
33
import { select } from 'd3-selection'
44
import type { MaybeRefOrGetter, Ref } from 'vue'
5-
import { ref, toValue, watch } from 'vue'
5+
import { shallowRef, toValue, watch } from 'vue'
66
import type { MouseTouchEvent, NodeDragEvent, NodeDragItem, XYPosition } from '../types'
77
import {
88
calcAutoPan,
@@ -62,7 +62,7 @@ export function useDrag(params: UseDragParams) {
6262

6363
const { onStart, onDrag, onStop, onClick, el, disabled, id, selectable, dragHandle } = params
6464

65-
const dragging = ref(false)
65+
const dragging = shallowRef(false)
6666

6767
let dragItems: NodeDragItem[] = []
6868

packages/core/src/container/Viewport/Viewport.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { D3ZoomEvent, ZoomTransform } from 'd3-zoom'
33
import { zoom, zoomIdentity } from 'd3-zoom'
44
import { pointer, select } from 'd3-selection'
5-
import { onMounted, ref, toRef, watch } from 'vue'
5+
import { onMounted, shallowRef, toRef, watch } from 'vue'
66
import type { CoordinateExtent, D3ZoomHandler, ViewportTransform } from '../../types'
77
import { PanOnScrollMode } from '../../types'
88
import { useKeyPress } from '../../composables/useKeyPress'
@@ -44,9 +44,9 @@ const {
4444
4545
useResizeHandler(viewportRef)
4646
47-
const isZoomingOrPanning = ref(false)
47+
const isZoomingOrPanning = shallowRef(false)
4848
49-
const isPanScrolling = ref(false)
49+
const isPanScrolling = shallowRef(false)
5050
5151
let panScrollTimeout: ReturnType<typeof setTimeout> | null = null
5252

0 commit comments

Comments
 (0)