/* eslint-disable react-perf/jsx-no-new-function-as-prop */ /* eslint-disable react-perf/jsx-no-new-object-as-prop */ import '../index.css'; import { useCallback, type PropsWithChildren } from 'react'; import { createElements, createLinks, GraphProvider, MeasuredNode, Paper, type InferElement, type OnSetSize, type RenderElement, } from '@joint/react'; import { PAPER_CLASSNAME, PRIMARY } from 'storybook-config/theme'; const initialElements = createElements([ { id: '1', label: 'Node 1', x: 100, y: 0 }, { id: '2', label: 'Node 2 with longer text', x: 250, y: 150 }, ]); const initialEdges = createLinks([ { id: 'e1-2', source: '1', target: '2', attrs: { line: { stroke: PRIMARY, }, }, }, ]); type BaseElementWithData = InferElement; function Card({ children, width, height }: PropsWithChildren) { const gap = 10; const imageWidth = 50; const imageHeight = height - 2 * gap; const iconURL = `https://placehold.co/${imageWidth}x${imageHeight}`; const foWidth = width - 2 * gap - imageWidth - gap; const foHeight = height - 2 * gap; const setCardSize: OnSetSize = ({ element, size }) => { const w = gap + imageWidth + gap + size.width + gap; const h = gap + Math.max(size.height, imageWidth) + gap; element.size(w, h); }; return ( <>
{children}
); } function Main() { const renderElement: RenderElement = useCallback((element) => { return {element.label}; }, []); return ( ); } export default function App() { return (
); }