import * as React from "react"; import * as d from "../localData"; import { Meta, Story } from "@storybook/react"; import { imageValue, listValue, numberValue, oneLineTextValue, productValue, projectIdValue, sumValue, timeValue, typePartIdValue, } from "../client/editor/common"; import { listTypePart, listTypePartId, project1, project1Id, project2, project2Id, projectResource, resultTypePart, resultTypePartId, typePart, typePart1Id, typePartResource, } from "./mockData"; import { ArgType } from "@storybook/addons"; import { Editor } from "../client/ui/Editor"; import type { Item } from "../client/editor/product"; import { UseDefinyAppResult } from "../client/hook/useDefinyApp"; import { action } from "@storybook/addon-actions"; import { listItem } from "../client/editor/list"; type ControlAndActionProps = { language: d.Language; onJump: UseDefinyAppResult["jump"]; }; const argTypes: Record< keyof Pick, ArgType > = { language: { description: "storybook 用. 言語", }, onJump: { description: "storybook 用. ページ移動をリクエストする", action: "onJump", }, }; const meta: Meta = { title: "Editor", component: Editor, argTypes, args: { language: d.Language.Japanese, }, }; export default meta; export const Project: Story = (props) => ( ); Project.args = { language: d.Language.Japanese }; export const TypePart: Story = (props) => ( ); TypePart.args = { language: d.Language.Japanese }; export const Home: Story = (props) => ( ); Home.args = { language: d.Language.Japanese }; export const List: Story = () => ( ); List.args = { language: d.Language.Japanese }; export const NestProduct: Story = () => ( ); NestProduct.args = { language: d.Language.Japanese }; const valueList = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; const SumComponent: React.VFC> = () => { const [selectedIndex, setSelectedIndex] = React.useState(0); return ( ({ name: `${i}このタグ`, value: sumValue({ index: selectedIndex, tagList: valueList.slice(0, i).map((name, index) => ({ name, onSelect: () => { setSelectedIndex(index); }, })), value: oneLineTextValue({ text: valueList[selectedIndex] ?? "?", onChange: undefined, }), }), }) ), }} /> ); }; export const Sum: Story> = () => { return ; }; Sum.argTypes = {};