import { Orchestrator, OrchestratorMeta, type OrchestratorStory, } from './utils/Orchestrator'; import { Meta } from '@storybook/react'; import { type ComponentProps, type FormEventHandler, useMemo } from 'react'; import { useLocalStorage } from '../hooks/useLocalStorage'; import type { LunaticSource } from '../type.source'; const meta: Meta = { title: 'Paste', ...OrchestratorMeta, }; export default meta; export const Default: OrchestratorStory = { args: {}, render(args) { return ; }, }; function PasteOrchestrator( props: Readonly> ) { const [source, setSource, sourceAsString] = useLocalStorage('story-source'); const extraTabs = useMemo(() => { return [ { label: 'Source', children: ( ), }, ]; }, [sourceAsString, setSource]); if (!source) { return extraTabs[0].children; } return (
); } function FormForSource( props: Readonly<{ source: string; onChange: (source: string) => void; }> ) { const onSubmit: FormEventHandler = (e) => { e.preventDefault(); const data = new FormData(e.currentTarget); if (data.has('source')) { props.onChange(data.get('source') as string); } }; return (
Paste the source.json