// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import type { Meta, StoryObj } from "@storybook/react"; import { useState } from "react"; import { MultiLineInput } from "./multilineinput"; const meta: Meta = { title: "Elements/MultiLineInput", component: MultiLineInput, argTypes: { value: { description: "The value of the textarea.", control: "text", }, placeholder: { description: "The placeholder text for the textarea.", control: "text", defaultValue: "Type a message...", }, maxRows: { description: "Maximum number of rows the textarea can expand to.", control: "number", defaultValue: 5, }, rows: { description: "Initial number of rows for the textarea.", control: "number", defaultValue: 1, }, maxLength: { description: "The maximum number of characters allowed.", control: "number", defaultValue: 200, }, autoFocus: { description: "Autofocus the input when the component mounts.", control: "boolean", defaultValue: false, }, disabled: { description: "Disables the textarea if set to true.", control: "boolean", defaultValue: false, }, }, }; export default meta; type Story = StoryObj; // Default MultiLineInput Story export const DefaultMultiLineInput: Story = { render: (args) => { const [message, setMessage] = useState(""); const handleChange = (e: React.ChangeEvent) => { setMessage(e.target.value); }; return (
); }, args: { placeholder: "Type your message...", rows: 1, maxRows: 5, }, }; // MultiLineInput with long text export const MultiLineInputWithLongText: Story = { render: (args) => { const [message, setMessage] = useState("This is a long message that will expand the textarea."); const handleChange = (e: React.ChangeEvent) => { setMessage(e.target.value); }; return (
); }, args: { placeholder: "Type a long message...", rows: 1, maxRows: 10, }, };