/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ // import React, { FC, useRef, useState } from "react"; // import Button from "../buttons/Button"; // import { useForm } from "react-hook-form"; // import { SubmitButton } from "../buttons"; // import { storiesOf } from "@storybook/react"; // import { MemoryRouter } from "react-router-dom"; // import Select from "./Select"; // // const Ref: FC = () => { // const ref = useRef(null); // const [selected, setSelected] = useState("false"); // return ( // <> // // // //
{JSON.stringify(value)}
// // ); // }; // // const AddNoExistingValue: FC = () => { // const [value, setValue] = useState("uscss-prometheus"); // // return ( // <> // //
{value}
// // ); // }; // // storiesOf("Forms/Select", module) // .addDecorator((storyFn) => {storyFn()}) // .add("Add no existing value", () => ) // .add("Ref", () => ) // .add("Legacy Events", () => ) // .add("ReactHookForm", () => ) // .add("Preselect option", () => ); import React, { FC, useRef, useState } from "react"; import { MemoryRouter } from "react-router-dom"; import { useForm } from "react-hook-form"; import styled from "styled-components"; import type { Meta, StoryObj } from "@storybook/react"; import Select from "./Select"; import Button from "../buttons/Button"; import { SubmitButton } from "../buttons"; // --- Helper Components & Styles (preserved from your original story) --- const Decorator = styled.div` padding: 2rem; max-width: 30rem; display: flex; flex-direction: column; gap: 1rem; `; const RefExample: FC = () => { const ref = useRef(null); const [selected, setSelected] = useState("false"); return ( <>
Selected value: {JSON.stringify(value)}
); }; const AddNoExistingValueExample: FC = () => { const [value, setValue] = useState("uscss-prometheus"); return ( <>
Selected value: {value}
); }; // --- Storybook Metadata --- const meta: Meta = { title: "Forms/Select", component: Select, decorators: [(Story) => {Story()}, (Story) => {Story()}], argTypes: { onChange: { action: "changed" }, }, tags: ["autodocs"], }; export default meta; // --- Story Definitions --- type Story = StoryObj; // A new, simple story to show the basic component and enable Controls export const Default: Story = { args: { label: "Starship", options: [ { label: "Millennium Falcon", value: "millennium-falcon" }, { label: "Razor Crest", value: "razor-crest" }, ], }, }; export const AddNoExistingValue: Story = { render: () => , }; export const UsingRefs: Story = { render: () => , }; export const HandlingOnChange: Story = { render: () => , }; export const WithReactHookForm: Story = { render: () => , }; export const PreselectingAnOption: Story = { render: () => , };