Skip to content

Commit

Permalink
update: types
Browse files Browse the repository at this point in the history
* Add elements to flowoptions type
* add window interface to custom shims
  • Loading branch information
bcakmakoglu committed Oct 20, 2021
1 parent 31c896e commit 77d2e01
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/additional-components/Background/Background.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts" setup>
import { HTMLAttributes } from 'vue'
import { SVGAttributes } from 'vue'
import { BackgroundVariant } from '~/types'
import { useStore } from '~/composables'
export interface BackgroundProps extends HTMLAttributes {
export interface BackgroundProps extends SVGAttributes {
variant?: BackgroundVariant
gap?: number
color?: string
Expand Down
6 changes: 3 additions & 3 deletions src/additional-components/Controls/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const props = withDefaults(defineProps<ControlProps>(), {
const store = useStore()
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 onZoomInHandler = () => {
Expand All @@ -48,8 +48,8 @@ const onFitViewHandler = () => {
}
const onInteractiveChangeHandler = () => {
store.setInteractive?.(!isInteractive)
props.onInteractiveChange?.(!isInteractive)
store.setInteractive?.(!isInteractive.value)
props.onInteractiveChange?.(!isInteractive.value)
}
</script>
<template>
Expand Down
10 changes: 5 additions & 5 deletions src/additional-components/MiniMap/MiniMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ const props = withDefaults(defineProps<MiniMapProps>(), {
nodeStrokeWidth: 2,
maskColor: 'rgb(240, 242, 243, 0.7)',
})
const attrs: any = useAttrs()
declare const window: any
const attrs: any = useAttrs()
const defaultWidth = 200
const defaultHeight = 150
Expand Down Expand Up @@ -67,6 +66,8 @@ const viewBox = computed(() => {
height: viewHeight + offset * 2,
}
})
const nodes = computed(() => store.nodes.filter((node) => !node.isHidden))
</script>
<template>
<svg
Expand All @@ -75,10 +76,9 @@ const viewBox = computed(() => {
:viewBox="`${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`"
class="vue-flow__minimap"
>
<slot name="mini-map-nodes" :nodes="store.nodes" :view-box="viewBox">
<template v-for="(node, i) of store.nodes" :key="`mini-map-node-${i}`">
<slot name="mini-map-nodes" :nodes="nodes" :view-box="viewBox">
<template v-for="(node, i) of nodes" :key="`mini-map-node-${i}`">
<MiniMapNode
v-if="!node.isHidden"
:x="node.__rf.position.x"
:y="node.__rf.position.y"
:width="node.__rf.width"
Expand Down
5 changes: 4 additions & 1 deletion src/container/Flow/Flow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import {
KeyCode,
TranslateExtent,
NodeExtent,
FlowOptions,
} from '~/types'
import { DefaultNode, InputNode, OutputNode } from '~/components/Nodes'
import { BezierEdge, SmoothStepEdge, StepEdge, StraightEdge } from '~/components/Edges'
import { createEdgeTypes } from '~/container/EdgeRenderer/utils'
import { createNodeTypes } from '~/container/NodeRenderer/utils'
import { useHooks, useStore, createHooks } from '~/composables'
export interface FlowProps {
export interface FlowProps extends FlowOptions {
elements: Elements
nodeTypes?: Record<string, NodeType>
edgeTypes?: Record<string, EdgeType>
Expand Down Expand Up @@ -57,6 +58,8 @@ export interface FlowProps {
panOnScrollMode?: PanOnScrollMode
zoomOnDoubleClick?: boolean
edgeUpdaterRadius?: number
edgeTypesId?: string
nodeTypesId?: string
}
const props = withDefaults(defineProps<FlowProps>(), {
Expand Down
3 changes: 3 additions & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
declare const __VUE_FLOW_VERSION__: string
declare const __ENV__: string
declare interface Window {
chrome?: any
}
5 changes: 3 additions & 2 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type OnLoadParams<T = any> = {
export type OnLoadFunc<T = any> = (params: OnLoadParams<T>) => void

export interface FlowOptions extends Omit<HTMLAttributes, 'onLoad'> {
elements: Elements
nodeTypes?: Record<string, NodeType>
edgeTypes?: Record<string, EdgeType>
connectionMode?: ConnectionMode
Expand Down Expand Up @@ -123,6 +124,6 @@ export interface FlowOptions extends Omit<HTMLAttributes, 'onLoad'> {
panOnScrollMode?: PanOnScrollMode
zoomOnDoubleClick?: boolean
edgeUpdaterRadius?: number
// nodeTypesId?: string
// edgeTypesId?: string / used by react-flow to detect a re-render of node components
nodeTypesId?: string
edgeTypesId?: string
}

1 comment on commit 77d2e01

@vercel
Copy link

@vercel vercel bot commented on 77d2e01 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.