();
const $flow = useFlowCanvas();
if (!$flow.data || !$flow.name) return "no flow";
useEffect(() => {
// get width and height of ref object
console.log("ref", ref.current?.getBoundingClientRect());
setRect(ref.current?.getBoundingClientRect());
}, []);
const nodes = flowToNodes($flow.data, $flow.name);
const edges = flowToEdges($flow.data) as any;
console.log("nodes", nodes);
console.log("edges", edges);
const triggerHeight = 260;
const offset = 50;
const viewport = {
zoom: 1,
x: rect?.width ? rect.width * 0.1 : 0,
y: rect?.height ? rect.height / 2 - triggerHeight / 2 - offset : 0
};
return (
{rect && (
<>
>
)}
);
}
function FlowPanels() {
const state = useFlowSelector((s) => pick(s, ["name", "dirty"]));
const [navigate] = useNavigate();
const { goBack } = useGoBack(() => navigate(routes.flows.flows.list()));
return (
{state.name} {state.dirty ? "*" : ""}
);
}
/*
function PanelsOld() {
//console.log("Panels");
const state = useFlowSelector((s) => pick(s, ["name", "dirty"]));
const [navigate] = useNavigate();
const { goBack } = useGoBack(() => navigate(routes.flows.flows.list()));
const [minimap, setMinimap] = useState(false);
const reactFlow = useReactFlow();
const { zoom, x, y } = useViewport();
const percent = Math.round(zoom * 100);
const handleZoomIn = async () => await reactFlow.zoomIn();
const handleZoomReset = async () => reactFlow.zoomTo(1);
const handleZoomOut = async () => await reactFlow.zoomOut();
function toggleMinimap() {
setMinimap((p) => !p);
}
return (
<>
{state.name} {state.dirty ? "*" : ""}
{x.toFixed(2)},{y.toFixed(2)}
{percent}%
{minimap && }
>
);
}*/
type DebuggerTabProps = {
tab: string | null;
store?: Record;
};
const debuggerTabAtom = atomWithStorage("__dev_flow_debugger_tab", { tab: null });
const Debugger = () => {
const [_state, _setState] = useAtom(debuggerTabAtom);
const $flow = useFlowCanvas();
const state = useFlowCanvasState();
function handleTabChange(tab: string | null) {
_setState((prev) => ({ ...prev, tab: prev.tab === tab ? null : tab }));
}
const expand = _state.store?.expand || 3;
return (
_setState((prev) => ({
...prev,
store: { ...prev.store, expand: n }
})),
250
)}
/>
Store
);
};