/* eslint-disable max-lines */ import { useState } from "react"; import { fn } from "@storybook/test"; import { Dialog, Flex, Select, Tabs } from ".."; import { Text } from "../text"; import { Button } from "../button"; import { commonProps } from "../../utils/storybook"; import { Box } from "../box"; import { Icons } from "../icons"; import { InputDeviceProvider } from "../../utils"; import type { StoryObj, Meta } from "@storybook/react"; const mockSelectItems = [ { value: "apple", label: "Apple", }, { value: "banana", label: "Banana", }, { value: "blueberry", label: "Blueberry", }, { value: "really long label", label: "reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy reallyyyyyyy long label", }, { value: "cherry", label: "Cherry", }, { value: "date", label: "Date", }, { value: "elderberry", label: "Elderberry", }, { value: "fig", label: "Fig", }, { value: "grape", label: "Grape", }, { value: "honeydew", label: "Honeydew", }, { value: "kiwi", label: "Kiwi", }, { value: "lemon", label: "Lemon", }, { value: "mango", label: "Mango", }, { value: "nectarine", label: "Nectarine", }, { value: "orange", label: "Orange", }, { value: "pear", label: "Pear", }, { value: "quince", label: "Quince", }, { value: "raspberry", label: "Raspberry", }, { value: "strawberry", label: "Strawberry", }, { value: "tangerine", label: "Tangerine", }, { value: "watermelon", label: "Watermelon", }, ]; const meta: Meta = { title: "Select", component: Select, tags: ["autodocs"], argTypes: { error: { control: { type: "boolean" }, }, rightElement: { control: false, }, ...commonProps, }, args: { label: "label", placeholder: "placeholder", options: mockSelectItems, error: false, info: "extra message", rightElement: , onLastElementReached: fn(), }, }; export default meta; type Story = StoryObj; export const Uncontrolled: Story = { render: (args) => ( ), }; export const Controlled: Story = { render: (args) => { const [value, setValue] = useState(""); return ( ), }; WithPerOptionProps.args = { options: [ { value: "apple", label: "Apple", css: { bg: "green" }, }, { value: "banana", label: "Banana", css: { bg: "yellow" }, }, { value: "blueberry", label: "Blueberry", css: { bg: "blue" }, }, ], }; export const Scrollable: Story = { render: (args) => ( ), }; WithLongOptions.args = { options: [ { label: "Pneumonoultramicroscopicsilicovolcanoconiosis", value: "1" }, { label: "0x3a1b8c9e2d4f6a70b5e3d8c7a1b4e9f4d6c7a0b5e3d8c7a1b4e9f4d6c7a0b5e3 - 0x3a1b8c9e2d4f6a70b5e3d8c7a1b4e9f4d6c7a0b5e3d8c7a1b4e9f4d6c7a0b5e3", value: "2", }, { value: "3", label: "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu", }, { label: "0x1e2d3c4b5a6f7e8d9c0b1a2b3c4d5e6f7e8d9c0b1a2b3c4d5e6f7e8d9c0b1a2", value: "4" }, { label: "Short option 2", value: "5" }, { label: "0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2", value: "6" }, { label: "Short Option 3", value: "7" }, ], }; export const WithExtra: Story = { render: (args) => (
Open modal}>