update: types
* Add elements to flowoptions type * add window interface to custom shims
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { HTMLAttributes } from 'vue'
|
import { SVGAttributes } from 'vue'
|
||||||
import { BackgroundVariant } from '~/types'
|
import { BackgroundVariant } from '~/types'
|
||||||
import { useStore } from '~/composables'
|
import { useStore } from '~/composables'
|
||||||
|
|
||||||
export interface BackgroundProps extends HTMLAttributes {
|
export interface BackgroundProps extends SVGAttributes {
|
||||||
variant?: BackgroundVariant
|
variant?: BackgroundVariant
|
||||||
gap?: number
|
gap?: number
|
||||||
color?: string
|
color?: string
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const props = withDefaults(defineProps<ControlProps>(), {
|
|||||||
const store = useStore()
|
const store = useStore()
|
||||||
const { zoomIn, zoomOut, fitView } = useZoomPanHelper()
|
const { zoomIn, zoomOut, fitView } = useZoomPanHelper()
|
||||||
|
|
||||||
const isInteractive = store.nodesDraggable && store.nodesConnectable && store.elementsSelectable
|
const isInteractive = computed(() => store.nodesDraggable && store.nodesConnectable && store.elementsSelectable)
|
||||||
const mapClasses = ['vue-flow__controls']
|
const mapClasses = ['vue-flow__controls']
|
||||||
|
|
||||||
const onZoomInHandler = () => {
|
const onZoomInHandler = () => {
|
||||||
@@ -48,8 +48,8 @@ const onFitViewHandler = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onInteractiveChangeHandler = () => {
|
const onInteractiveChangeHandler = () => {
|
||||||
store.setInteractive?.(!isInteractive)
|
store.setInteractive?.(!isInteractive.value)
|
||||||
props.onInteractiveChange?.(!isInteractive)
|
props.onInteractiveChange?.(!isInteractive.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ const props = withDefaults(defineProps<MiniMapProps>(), {
|
|||||||
nodeStrokeWidth: 2,
|
nodeStrokeWidth: 2,
|
||||||
maskColor: 'rgb(240, 242, 243, 0.7)',
|
maskColor: 'rgb(240, 242, 243, 0.7)',
|
||||||
})
|
})
|
||||||
const attrs: any = useAttrs()
|
|
||||||
|
|
||||||
declare const window: any
|
const attrs: any = useAttrs()
|
||||||
|
|
||||||
const defaultWidth = 200
|
const defaultWidth = 200
|
||||||
const defaultHeight = 150
|
const defaultHeight = 150
|
||||||
@@ -67,6 +66,8 @@ const viewBox = computed(() => {
|
|||||||
height: viewHeight + offset * 2,
|
height: viewHeight + offset * 2,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const nodes = computed(() => store.nodes.filter((node) => !node.isHidden))
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<svg
|
<svg
|
||||||
@@ -75,10 +76,9 @@ const viewBox = computed(() => {
|
|||||||
:viewBox="`${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`"
|
:viewBox="`${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`"
|
||||||
class="vue-flow__minimap"
|
class="vue-flow__minimap"
|
||||||
>
|
>
|
||||||
<slot name="mini-map-nodes" :nodes="store.nodes" :view-box="viewBox">
|
<slot name="mini-map-nodes" :nodes="nodes" :view-box="viewBox">
|
||||||
<template v-for="(node, i) of store.nodes" :key="`mini-map-node-${i}`">
|
<template v-for="(node, i) of nodes" :key="`mini-map-node-${i}`">
|
||||||
<MiniMapNode
|
<MiniMapNode
|
||||||
v-if="!node.isHidden"
|
|
||||||
:x="node.__rf.position.x"
|
:x="node.__rf.position.x"
|
||||||
:y="node.__rf.position.y"
|
:y="node.__rf.position.y"
|
||||||
:width="node.__rf.width"
|
:width="node.__rf.width"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
KeyCode,
|
KeyCode,
|
||||||
TranslateExtent,
|
TranslateExtent,
|
||||||
NodeExtent,
|
NodeExtent,
|
||||||
|
FlowOptions,
|
||||||
} from '~/types'
|
} from '~/types'
|
||||||
import { DefaultNode, InputNode, OutputNode } from '~/components/Nodes'
|
import { DefaultNode, InputNode, OutputNode } from '~/components/Nodes'
|
||||||
import { BezierEdge, SmoothStepEdge, StepEdge, StraightEdge } from '~/components/Edges'
|
import { BezierEdge, SmoothStepEdge, StepEdge, StraightEdge } from '~/components/Edges'
|
||||||
@@ -23,7 +24,7 @@ import { createEdgeTypes } from '~/container/EdgeRenderer/utils'
|
|||||||
import { createNodeTypes } from '~/container/NodeRenderer/utils'
|
import { createNodeTypes } from '~/container/NodeRenderer/utils'
|
||||||
import { useHooks, useStore, createHooks } from '~/composables'
|
import { useHooks, useStore, createHooks } from '~/composables'
|
||||||
|
|
||||||
export interface FlowProps {
|
export interface FlowProps extends FlowOptions {
|
||||||
elements: Elements
|
elements: Elements
|
||||||
nodeTypes?: Record<string, NodeType>
|
nodeTypes?: Record<string, NodeType>
|
||||||
edgeTypes?: Record<string, EdgeType>
|
edgeTypes?: Record<string, EdgeType>
|
||||||
@@ -57,6 +58,8 @@ export interface FlowProps {
|
|||||||
panOnScrollMode?: PanOnScrollMode
|
panOnScrollMode?: PanOnScrollMode
|
||||||
zoomOnDoubleClick?: boolean
|
zoomOnDoubleClick?: boolean
|
||||||
edgeUpdaterRadius?: number
|
edgeUpdaterRadius?: number
|
||||||
|
edgeTypesId?: string
|
||||||
|
nodeTypesId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<FlowProps>(), {
|
const props = withDefaults(defineProps<FlowProps>(), {
|
||||||
|
|||||||
Vendored
+3
@@ -1,2 +1,5 @@
|
|||||||
declare const __VUE_FLOW_VERSION__: string
|
declare const __VUE_FLOW_VERSION__: string
|
||||||
declare const __ENV__: string
|
declare const __ENV__: string
|
||||||
|
declare interface Window {
|
||||||
|
chrome?: any
|
||||||
|
}
|
||||||
|
|||||||
+3
-2
@@ -91,6 +91,7 @@ export type OnLoadParams<T = any> = {
|
|||||||
export type OnLoadFunc<T = any> = (params: OnLoadParams<T>) => void
|
export type OnLoadFunc<T = any> = (params: OnLoadParams<T>) => void
|
||||||
|
|
||||||
export interface FlowOptions extends Omit<HTMLAttributes, 'onLoad'> {
|
export interface FlowOptions extends Omit<HTMLAttributes, 'onLoad'> {
|
||||||
|
elements: Elements
|
||||||
nodeTypes?: Record<string, NodeType>
|
nodeTypes?: Record<string, NodeType>
|
||||||
edgeTypes?: Record<string, EdgeType>
|
edgeTypes?: Record<string, EdgeType>
|
||||||
connectionMode?: ConnectionMode
|
connectionMode?: ConnectionMode
|
||||||
@@ -123,6 +124,6 @@ export interface FlowOptions extends Omit<HTMLAttributes, 'onLoad'> {
|
|||||||
panOnScrollMode?: PanOnScrollMode
|
panOnScrollMode?: PanOnScrollMode
|
||||||
zoomOnDoubleClick?: boolean
|
zoomOnDoubleClick?: boolean
|
||||||
edgeUpdaterRadius?: number
|
edgeUpdaterRadius?: number
|
||||||
// nodeTypesId?: string
|
nodeTypesId?: string
|
||||||
// edgeTypesId?: string / used by react-flow to detect a re-render of node components
|
edgeTypesId?: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user