/* eslint-disable react-perf/jsx-no-new-object-as-prop */ /* eslint-disable react-perf/jsx-no-new-function-as-prop */ /* eslint-disable react-hooks/rules-of-hooks */ import type { Meta, StoryObj } from '@storybook/react'; import { useCreateElement } from './use-create-element'; import { makeRootDocumentation, makeStory } from '@joint/react/src/stories/utils/make-story'; import { getAPILink } from '@joint/react/src/stories/utils/get-api-documentation-link'; import type { SimpleElement } from '../../.storybook/decorators/with-simple-data'; import { HTMLNode, SimpleGraphDecorator } from '../../.storybook/decorators/with-simple-data'; import '../stories/examples/index.css'; import { Paper } from '../components'; import { BUTTON_CLASSNAME, PAPER_CLASSNAME } from 'storybook-config/theme'; const API_URL = getAPILink('useCreateElement'); export type Story = StoryObj; const meta: Meta = { title: 'Hooks/useCreateElement', component: Hook, decorators: [SimpleGraphDecorator], render: () => { const addElement = useCreateElement(); return (
); }, parameters: makeRootDocumentation({ apiURL: API_URL, description: `\`useCreateElement\` is a hook to add elements to the graph. It returns a function to add an element. It must be used inside the GraphProvider.`, code: `import { useCreateElement } from '@joint/react' function Component() { const addElement = useCreateElement(); return ; }`, }), }; export default meta; function Hook({ label }: SimpleElement) { return {label}; } export const Default: Story = makeStory({ args: {}, code: `import { useCreateElement } from '@joint/react' function Hook() { const addElement = useCreateElement(); return (
); }`, description: 'Add elements to the graph.', });