Skip to content

Commit

Permalink
chore: upgrade to React Flow v12
Browse files Browse the repository at this point in the history
Signed-off-by: Drew Hess <[email protected]>
  • Loading branch information
dhess committed Apr 24, 2024
1 parent 48f40e9 commit b924210
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 146 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@tanstack/react-query": "^5.29.0",
"@tanstack/react-query-devtools": "^5.29.0",
"@types/deep-equal": "^1.0.4",
"@xyflow/react": "12.0.0-next.15",
"@zxch3n/tidy": "github:hackworthltd/tidy#e07fdef2ae7bf593701817113dd47b4cd56c7a97",
"axios": "^1.6.8",
"deep-equal": "^2.2.3",
Expand All @@ -41,7 +42,6 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.2",
"react-router-dom": "^6.22.3",
"reactflow": "^11.10.3",
"universal-cookie": "^7.1.4",
"uuid": "^9.0.1",
"zod": "^3.22.4"
Expand Down
161 changes: 31 additions & 130 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
useState,
} from "react";
import { useParams } from "react-router-dom";
import { ReactFlowProvider } from "reactflow";
import { ReactFlowProvider } from "@xyflow/react";
import {
useGetAvailableActions,
useGetProgram,
Expand Down
2 changes: 1 addition & 1 deletion src/components/EvalBoundedInterp/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { NodeChange, ReactFlowProvider, useReactFlow } from "reactflow";
import { NodeChange, ReactFlowProvider, useReactFlow } from "@xyflow/react";
import { EvalBoundedInterpResp, GlobalName, Level } from "@/primer-api";
import { SelectMenu, TreeReactFlowOne } from "@/components";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/EvalFull/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { NodeChange, ReactFlowProvider, useReactFlow } from "reactflow";
import { NodeChange, ReactFlowProvider, useReactFlow } from "@xyflow/react";
import { EvalFullResp, GlobalName, Level } from "@/primer-api";
import { SelectMenu, TreeReactFlowOne } from "@/components";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectionInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeChange, ReactFlowProvider, useReactFlow } from "reactflow";
import { NodeChange, ReactFlowProvider, useReactFlow } from "@xyflow/react";
import { Tree, Level, TypeOrKind } from "@/primer-api";
import { TreeReactFlowOne } from "@/components";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TreeReactFlow/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
NodeType,
} from "@/primer-api";
import { unzip } from "fp-ts/lib/Array";
import { Position } from "reactflow";
import { Position } from "@xyflow/react";
import { NodeFlavor } from "./Flavor";

/** A generic graph. */
Expand Down
2 changes: 1 addition & 1 deletion src/components/TreeReactFlow/ZoomBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useReactFlow, Panel } from "@reactflow/core";
import { useReactFlow, Panel } from "@xyflow/react";
import {
ArrowsPointingOutIcon,
MagnifyingGlassPlusIcon,
Expand Down
16 changes: 8 additions & 8 deletions src/components/TreeReactFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Level,
TypeDef,
} from "@/primer-api";
import type { NodeChange } from "reactflow";
import type { NodeChange } from "@xyflow/react";
import {
ReactFlow,
Node as RFNode,
Expand All @@ -23,7 +23,7 @@ import {
getBezierPath,
EdgeTypes,
useReactFlow,
} from "reactflow";
} from "@xyflow/react";
import "./reactflow.css";
import { MutableRefObject, PropsWithChildren, useId } from "react";
import classNames from "classnames";
Expand Down Expand Up @@ -462,7 +462,7 @@ const edgeTypes = {
targetX,
targetY,
targetPosition,
}: EdgeProps<unknown> & { data: PrimerEdgeProps }) => {
}: EdgeProps<PrimerEdge> & { data: PrimerEdgeProps }) => {
const [edgePath] = getBezierPath({
sourceX,
sourceY,
Expand Down Expand Up @@ -490,7 +490,7 @@ const edgeTypes = {
targetX,
targetY,
targetPosition,
}: EdgeProps<unknown>) => {
}: EdgeProps<PrimerEdge>) => {
const [edgePath] = getSmoothStepPath({
sourceX,
sourceY,
Expand Down Expand Up @@ -1378,19 +1378,19 @@ const SetTreeReactFlowCallbacks = ({
* check that we register its subtypes correctly with ReactFlow,
* and safely act on that type in handlers. */
export const ReactFlowSafe = <
N extends RFNode<unknown> & { type: string },
E extends RFEdge<unknown> & { type: string },
N extends RFNode & { type: string },
E extends RFEdge & { type: string },
>(
p: Omit<Parameters<typeof ReactFlow>[0], "onNodeClick" | "edgeTypes"> & {
nodes: N[];
nodeTypes: {
[T in N["type"]]: (
args: NodeProps<unknown> & N & { type: T }
args: NodeProps & N & { type: T }
) => JSX.Element;
};
edgeTypes: {
[T in E["type"]]: (
args: EdgeProps<unknown> & E & { type: T }
args: EdgeProps<PrimerEdge> & E & { type: T }
) => JSX.Element;
};
onNodeClick?: (e: React.MouseEvent<Element, MouseEvent>, n: N) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TreeReactFlow/reactflow.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "reactflow/dist/base.css";
@import "@xyflow/react/dist/base.css";

.react-flow__edge-path,
.react-flow__connection-path {
Expand Down

0 comments on commit b924210

Please sign in to comment.