diff --git a/examples/App.tsx b/examples/App.tsx deleted file mode 100644 index 81c3fbf9..00000000 --- a/examples/App.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { computed, defineComponent } from 'vue' -import Header from './Header' -import { useRoute } from 'vue-router' - -export default defineComponent({ - name: 'App', - components: { - Header - }, - setup() { - const route = useRoute() - const key = computed(() => route.fullPath) - return () => ( - <> - - - > - ) - } -}) diff --git a/examples/App.vue b/examples/App.vue new file mode 100644 index 00000000..7452d696 --- /dev/null +++ b/examples/App.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/Basic/Basic.vue b/examples/Basic/Basic.vue index 03668b50..6be7e039 100644 --- a/examples/Basic/Basic.vue +++ b/examples/Basic/Basic.vue @@ -1,30 +1,5 @@ - - - - - - - reset transform - change pos - toggle classnames - toObject - - - - + + + + + + + reset transform + change pos + toggle classnames + toObject + + + diff --git a/examples/CustomConnectionLine/ConnectionLine.vue b/examples/CustomConnectionLine/ConnectionLine.vue index e241f302..e9c4f854 100644 --- a/examples/CustomConnectionLine/ConnectionLine.vue +++ b/examples/CustomConnectionLine/ConnectionLine.vue @@ -1,3 +1,14 @@ + - + - diff --git a/examples/CustomConnectionLine/CustomConnectionLine.vue b/examples/CustomConnectionLine/CustomConnectionLine.vue index b5e2111c..064d4ead 100644 --- a/examples/CustomConnectionLine/CustomConnectionLine.vue +++ b/examples/CustomConnectionLine/CustomConnectionLine.vue @@ -1,41 +1,21 @@ - - - - - - + + + + + diff --git a/examples/CustomNode/ColorSelectorNode.vue b/examples/CustomNode/ColorSelectorNode.vue index 474f0f28..a0823f2f 100644 --- a/examples/CustomNode/ColorSelectorNode.vue +++ b/examples/CustomNode/ColorSelectorNode.vue @@ -1,43 +1,35 @@ + - + Custom Color Picker Node: {{ data.color }} - + - diff --git a/examples/CustomNode/CustomNode.vue b/examples/CustomNode/CustomNode.vue index 512bdc49..beb69089 100644 --- a/examples/CustomNode/CustomNode.vue +++ b/examples/CustomNode/CustomNode.vue @@ -1,25 +1,6 @@ - - - - - - - + + + + + + diff --git a/examples/DragNDrop/DnD.vue b/examples/DragNDrop/DnD.vue index 3af29134..52e5e9e7 100644 --- a/examples/DragNDrop/DnD.vue +++ b/examples/DragNDrop/DnD.vue @@ -1,86 +1,58 @@ + - + - + - diff --git a/examples/DragNDrop/Sidebar.tsx b/examples/DragNDrop/Sidebar.tsx deleted file mode 100644 index 1288a373..00000000 --- a/examples/DragNDrop/Sidebar.tsx +++ /dev/null @@ -1,25 +0,0 @@ -const onDragStart = (event: DragEvent, nodeType: string) => { - if (event.dataTransfer) { - event.dataTransfer.setData('application/revueflow', nodeType) - event.dataTransfer.effectAllowed = 'move' - } -} - -const Sidebar = () => { - return ( - - ) -} - -export default Sidebar diff --git a/examples/DragNDrop/Sidebar.vue b/examples/DragNDrop/Sidebar.vue new file mode 100644 index 00000000..6e8be2be --- /dev/null +++ b/examples/DragNDrop/Sidebar.vue @@ -0,0 +1,22 @@ + + + + diff --git a/examples/EdgeTypes/EdgeTypesExample.vue b/examples/EdgeTypes/EdgeTypesExample.vue new file mode 100644 index 00000000..23cacca1 --- /dev/null +++ b/examples/EdgeTypes/EdgeTypesExample.vue @@ -0,0 +1,19 @@ + + + + diff --git a/examples/EdgeTypes/index.tsx b/examples/EdgeTypes/index.tsx deleted file mode 100644 index ed804335..00000000 --- a/examples/EdgeTypes/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Example for checking the different edge types and source and target positions - */ -import RevueFlow, { - removeElements, - addEdge, - MiniMap, - Controls, - Background, - OnLoadParams, - Connection, - Edge, - Elements -} from '../../src' -import { getElements } from './utils' -import { defineComponent, ref } from 'vue' - -const onLoad = (reactFlowInstance: OnLoadParams) => { - reactFlowInstance.fitView() - console.log(reactFlowInstance.getElements()) -} - -const initialElements = getElements() - -const EdgeTypesFlow = defineComponent({ - setup() { - const elements = ref(initialElements) - const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value)) - const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) - - return () => ( - - ) - } -}) - -export default EdgeTypesFlow diff --git a/examples/EdgeWithButton/ButtonEdge.vue b/examples/EdgeWithButton/ButtonEdge.vue index cc3c52a9..c119bfd7 100644 --- a/examples/EdgeWithButton/ButtonEdge.vue +++ b/examples/EdgeWithButton/ButtonEdge.vue @@ -59,12 +59,12 @@ const center = computed(() => ) - + diff --git a/examples/EdgeWithButton/EdgeWithButton.vue b/examples/EdgeWithButton/EdgeWithButton.vue index 0fa23d0a..6c4bb8d3 100644 --- a/examples/EdgeWithButton/EdgeWithButton.vue +++ b/examples/EdgeWithButton/EdgeWithButton.vue @@ -1,7 +1,47 @@ + - - + - diff --git a/examples/Empty/EmptyExample.vue b/examples/Empty/EmptyExample.vue new file mode 100644 index 00000000..24ebdde9 --- /dev/null +++ b/examples/Empty/EmptyExample.vue @@ -0,0 +1,53 @@ + + + + + + + + add node + + diff --git a/examples/Empty/index.tsx b/examples/Empty/index.tsx deleted file mode 100644 index 4cf46688..00000000 --- a/examples/Empty/index.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import RevueFlow, { - removeElements, - addEdge, - MiniMap, - Controls, - Background, - OnLoadParams, - Elements, - ElementId, - Node, - FlowElement, - BackgroundVariant, - Connection, - Edge -} from '../../src' -import { CSSProperties, defineComponent, ref } from 'vue' - -const onLoad = (reactFlowInstance: OnLoadParams) => console.log('flow loaded:', reactFlowInstance) -const onElementClick = (_: MouseEvent, element: FlowElement) => console.log('click', element) -const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node) - -const buttonStyle: CSSProperties = { position: 'absolute', left: '10px', top: '10px', zIndex: 4 } - -const EmptyFlow = defineComponent({ - setup() { - { - const elements = ref([]) - const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value)) - const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) - - const addRandomNode = () => { - const nodeId: ElementId = (elements.value.length + 1).toString() - const newNode: Node = { - id: nodeId, - data: { label: `Node: ${nodeId}` }, - position: { x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight } - } as Node - elements.value = [...elements.value, newNode] - } - - return () => ( - onConnect(p)} - onNodeDragStop={onNodeDragStop} - onlyRenderVisibleElements={false} - > - - - - - - add node - - - ) - } - } -}) - -export default EmptyFlow diff --git a/examples/Header.tsx b/examples/Header.tsx deleted file mode 100644 index 2188a635..00000000 --- a/examples/Header.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { defineComponent } from 'vue' -import { routes } from './router' -import { useRoute, useRouter } from 'vue-router' - -const Header = defineComponent({ - setup() { - const router = useRouter() - const route = useRoute() - const onChange = async (event: any) => { - await router.push(event.target.value) - } - - return () => ( - - - Revue Flow Dev - - - {routes.map((route) => - route.path !== '/' ? ( - - {route.path.substr(1, route.path.length)} - - ) : null - )} - - - ) - } -}) - -export default Header diff --git a/examples/Header.vue b/examples/Header.vue new file mode 100644 index 00000000..64df4ee0 --- /dev/null +++ b/examples/Header.vue @@ -0,0 +1,22 @@ + + + + Revue Flow Dev + + + + {{ r.path.substr(1, r.path.length) }} + + + + + diff --git a/examples/Hidden/HiddenExample.vue b/examples/Hidden/HiddenExample.vue new file mode 100644 index 00000000..14b41698 --- /dev/null +++ b/examples/Hidden/HiddenExample.vue @@ -0,0 +1,45 @@ + + + + + + + + + + isHidden + + + + + + diff --git a/examples/Hidden/index.tsx b/examples/Hidden/index.tsx deleted file mode 100644 index 82616ec4..00000000 --- a/examples/Hidden/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import RevueFlow, { addEdge, MiniMap, Controls, Connection, Edge, Elements } from '../../src' -import { defineComponent, ref, watchEffect } from 'vue' - -const initialElements: Elements = [ - { id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } }, - { id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } }, - { id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 } }, - { id: '4', data: { label: 'Node 4' }, position: { x: 400, y: 200 } }, - { id: 'e1-2', source: '1', target: '2' }, - { id: 'e1-3', source: '1', target: '3' }, - { id: 'e3-4', source: '3', target: '4' } -] as Elements - -const HiddenFlow = defineComponent({ - setup() { - const elements = ref(initialElements) - const isHidden = ref(false) - const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) - - watchEffect(() => { - console.log(isHidden.value) - elements.value = elements.value.map((e) => { - e.isHidden = isHidden.value - return e - }) - }) - - const toggle = (event) => { - console.log(event.target) - isHidden.value = event.target?.checked - } - - return () => ( - - - - - - - - isHidden - - - - - - ) - } -}) - -export default HiddenFlow diff --git a/examples/Interaction/InteractionExample.vue b/examples/Interaction/InteractionExample.vue new file mode 100644 index 00000000..48bc27f6 --- /dev/null +++ b/examples/Interaction/InteractionExample.vue @@ -0,0 +1,156 @@ + + + + + + + + + + nodesDraggable + + + + + + nodesConnectable + + + + + + elementsSelectable + + + + + + zoomOnScroll + + + + + + zoomOnPinch + + + + + + panOnScroll + + + + + + panOnScrollMode + + free + horizontal + vertical + + + + + + zoomOnDoubleClick + + + + + + paneMoveable + + + + + + capture onPaneClick + + + + + + capture onPaneScroll + + + + + + capture onElementClick + + + + + + diff --git a/examples/Interaction/index.tsx b/examples/Interaction/index.tsx deleted file mode 100644 index 17fd377e..00000000 --- a/examples/Interaction/index.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import RevueFlow, { - addEdge, - MiniMap, - Controls, - Elements, - Node, - FlowElement, - Connection, - Edge, - PanOnScrollMode, - FlowTransform -} from '../../src' -import { defineComponent, ref } from 'vue' - -const initialElements: Elements = [ - { id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } }, - { id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } }, - { id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 } }, - { id: '4', data: { label: 'Node 4' }, position: { x: 400, y: 200 } }, - { id: 'e1-2', source: '1', target: '2', animated: true }, - { id: 'e1-3', source: '1', target: '3' } -] as Elements - -const onNodeDragStart = (_: MouseEvent, node: Node) => console.log('drag start', node) -const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node) -const onElementClick = (_: MouseEvent, element: FlowElement) => console.log('click', element) -const onPaneClick = (event: MouseEvent) => console.log('onPaneClick', event) -const onPaneScroll = (event?: WheelEvent) => console.log('onPaneScroll', event) -const onPaneContextMenu = (event: MouseEvent) => console.log('onPaneContextMenu', event) -const onMoveEnd = (flowTranasform?: FlowTransform) => console.log('onMoveEnd', flowTranasform) - -const InteractionFlow = defineComponent({ - setup() { - const elements = ref(initialElements) - const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) - - const isSelectable = ref(false) - const isDraggable = ref(false) - const isConnectable = ref(false) - const zoomOnScroll = ref(false) - const zoomOnPinch = ref(false) - const panOnScroll = ref(false) - const panOnScrollMode = ref(PanOnScrollMode.Free) - const zoomOnDoubleClick = ref(false) - const paneMoveable = ref(true) - const captureZoomClick = ref(false) - const captureZoomScroll = ref(false) - const captureElementClick = ref(false) - - return () => ( - - - - - - - - nodesDraggable - - - - - - nodesConnectable - - - - - - elementsSelectable - - - - - - zoomOnScroll - - - - - - zoomOnPinch - - - - - - panOnScroll - - - - - - panOnScrollMode - - free - horizontal - vertical - - - - - - zoomOnDoubleClick - - - - - - paneMoveable - - - - - - capture onPaneClick - - - - - - capture onPaneScroll - - - - - - capture onElementClick - - - - - - ) - } -}) - -export default InteractionFlow diff --git a/examples/main.ts b/examples/main.ts index e4abb9de..d3366a00 100644 --- a/examples/main.ts +++ b/examples/main.ts @@ -1,9 +1,9 @@ import { createApp } from 'vue' import './index.css' -import App from './App' -import { router } from './router' import { createPinia } from 'pinia' import { DraggablePlugin } from '@braks/revue-draggable' +import App from './App.vue' +import { router } from './router' const app = createApp(App) diff --git a/examples/router.ts b/examples/router.ts index c874ea22..45f1215c 100644 --- a/examples/router.ts +++ b/examples/router.ts @@ -31,19 +31,19 @@ export const routes: RouterOptions['routes'] = [ }, { path: '/edge-types', - component: () => import('./EdgeTypes'), + component: () => import('./EdgeTypes/EdgeTypesExample.vue'), }, { path: '/empty', - component: () => import('./Empty'), + component: () => import('./Empty/EmptyExample.vue'), }, { path: '/hidden', - component: () => import('./Hidden'), + component: () => import('./Hidden/HiddenExample.vue'), }, { path: '/interaction', - component: () => import('./Interaction'), + component: () => import('./Interaction/InteractionExample.vue'), }, { path: '/super-flow', diff --git a/src/container/Flow/Flow.vue b/src/container/Flow/Flow.vue index 5ddb4c0d..75e1259c 100644 --- a/src/container/Flow/Flow.vue +++ b/src/container/Flow/Flow.vue @@ -1,7 +1,7 @@