-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5ae6a4
commit 29c6df1
Showing
25 changed files
with
688 additions
and
883 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script lang="ts" setup> | ||
import Header from './Header.vue' | ||
</script> | ||
<template> | ||
<Header /> | ||
<router-view /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
<script lang="ts" setup> | ||
import { ConnectionLineComponentProps } from '~/index' | ||
interface ConnectionLineProps extends ConnectionLineComponentProps { | ||
sourceX: number | ||
sourceY: number | ||
targetX: number | ||
targetY: number | ||
} | ||
const props = defineProps<ConnectionLineProps>() | ||
</script> | ||
<template> | ||
<g> | ||
<path | ||
class="animated" | ||
fill="none" | ||
stroke="#222" | ||
:stroke-width="1.5" | ||
:d="`M${sourceX},${sourceY} C ${sourceX} ${targetY} ${sourceX} ${targetY} ${targetX},${targetY}`" | ||
:d="`M${props.sourceX},${props.sourceY} C ${props.sourceX} ${props.targetY} ${props.sourceX} ${props.targetY} ${props.targetX},${props.targetY}`" | ||
/> | ||
<circle :cx="targetX" :cy="targetY" fill="#fff" :r="3" stroke="#222" :stroke-width="1.5" /> | ||
<circle :cx="props.targetX" :cy="props.targetY" fill="#fff" :r="3" stroke="#222" :stroke-width="1.5" /> | ||
</g> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent, PropType } from 'vue'; | ||
import { ConnectionLineComponentProps } from '../../src'; | ||
export default defineComponent({ | ||
props: { | ||
sourceX: { | ||
type: Number as PropType<ConnectionLineComponentProps['sourceX']>, | ||
required: true | ||
}, | ||
sourceY: { | ||
type: Number as PropType<ConnectionLineComponentProps['sourceY']>, | ||
required: true | ||
}, | ||
targetX: { | ||
type: Number as PropType<ConnectionLineComponentProps['targetX']>, | ||
required: true | ||
}, | ||
targetY: { | ||
type: Number as PropType<ConnectionLineComponentProps['targetY']>, | ||
required: true | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,21 @@ | ||
<template> | ||
<RevueFlow | ||
v-model="elements" | ||
:connection-line-component="ConnectionLine" | ||
@elementsRemove="onElementsRemove" | ||
@connect="onConnect" | ||
> | ||
<Background :variant="bgVariant" /> | ||
</RevueFlow> | ||
</template> | ||
<script lang="ts"> | ||
import RevueFlow, { removeElements, addEdge, Background, BackgroundVariant, Elements, Connection, Edge } from '../../src'; | ||
import ConnectionLine from './ConnectionLine.vue'; | ||
import { defineComponent, ref } from 'vue'; | ||
<script lang="ts" setup> | ||
import ConnectionLine from './ConnectionLine.vue' | ||
import Flow, { removeElements, addEdge, Background, BackgroundVariant, Elements, Connection, Edge } from '~/index' | ||
export default defineComponent({ | ||
components: { RevueFlow, Background }, | ||
setup() { | ||
const elements = ref<Elements>([ | ||
{ | ||
id: '1', | ||
type: 'input', | ||
data: { label: 'Node 1' }, | ||
position: { x: 250, y: 5 } | ||
} | ||
] as Elements); | ||
const onElementsRemove = (elementsToRemove: Elements) => | ||
(elements.value = removeElements(elementsToRemove, elements.value as Elements)); | ||
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value as Elements)); | ||
return { | ||
ConnectionLine, | ||
elements, | ||
onElementsRemove, | ||
onConnect, | ||
bgVariant: BackgroundVariant.Lines | ||
}; | ||
} | ||
}); | ||
const elements = ref<Elements>([ | ||
{ | ||
id: '1', | ||
type: 'input', | ||
data: { label: 'Node 1' }, | ||
position: { x: 250, y: 5 }, | ||
}, | ||
] as Elements) | ||
const onElementsRemove = (elementsToRemove: Elements) => | ||
(elements.value = removeElements(elementsToRemove, elements.value as Elements)) | ||
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value as Elements)) | ||
</script> | ||
<template> | ||
<Flow :elements="elements" :custom-connection-line="ConnectionLine" @elementsRemove="onElementsRemove" @connect="onConnect"> | ||
<Background :variant="BackgroundVariant.Lines" /> | ||
</Flow> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
<script lang="ts" setup> | ||
import { CSSProperties } from 'vue' | ||
import { Handle, Position, Connection, Edge, NodeProps } from '~/index' | ||
interface ColorSelectorNodeProps extends NodeProps { | ||
data: { | ||
color: string | ||
onChange: (event: any) => void | ||
} | ||
type: string | ||
selected?: boolean | ||
connectable?: boolean | ||
xPos?: number | ||
yPos?: number | ||
targetPosition?: Position | ||
sourcePosition?: Position | ||
dragging?: boolean | ||
} | ||
const props = defineProps<ColorSelectorNodeProps>() | ||
const targetHandleStyle: CSSProperties = { background: '#555' } | ||
const sourceHandleStyleA: CSSProperties = { ...targetHandleStyle, top: '10px' } | ||
const sourceHandleStyleB: CSSProperties = { ...targetHandleStyle, bottom: '10px', top: 'auto' } | ||
const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params) | ||
</script> | ||
<template> | ||
<Handle type="target" :position="Position.Left" :style="targetHandleStyle" :onConnect="onConnect" /> | ||
<Handle type="target" :position="Position.Left" :style="targetHandleStyle" :on-connect="onConnect" /> | ||
<div> | ||
Custom Color Picker Node: <strong>{{ data.color }}</strong> | ||
</div> | ||
<input class="nodrag" type="color" :value="data.color" @input="onChange" /> | ||
<input class="nodrag" type="color" :value="data.color" @input="props.data.onChange" /> | ||
<Handle id="a" type="source" :position="Position.Right" :style="sourceHandleStyleA" /> | ||
<Handle id="b" type="source" :position="Position.Right" :style="sourceHandleStyleB" /> | ||
</template> | ||
<script lang="ts"> | ||
import { CSSProperties, defineComponent, PropType } from 'vue'; | ||
import { Handle, Position, Connection, Edge } from '../../src'; | ||
const ColorSelectorNode = defineComponent({ | ||
components: { Handle }, | ||
inheritAttrs: false, | ||
props: { | ||
data: { | ||
type: Object as PropType<{ color: string; onChange: (event: any) => any }>, | ||
required: false, | ||
default: () => {} | ||
} | ||
}, | ||
setup(props) { | ||
const targetHandleStyle: CSSProperties = { background: '#555' }; | ||
const sourceHandleStyleA: CSSProperties = { ...targetHandleStyle, top: '10px' }; | ||
const sourceHandleStyleB: CSSProperties = { ...targetHandleStyle, bottom: '10px', top: 'auto' }; | ||
const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params); | ||
return { | ||
Position, | ||
targetHandleStyle, | ||
sourceHandleStyleA, | ||
sourceHandleStyleB, | ||
onConnect, | ||
onChange: props.data.onChange | ||
}; | ||
} | ||
}); | ||
export default ColorSelectorNode; | ||
</script> |
Oops, something went wrong.