import React, { useState } from 'react'; import { Meta, StoryObj } from '@storybook/react'; import Autocomplete, { Option } from './Autocomplete'; const meta: Meta = { title: 'Components/Autocomplete', component: Autocomplete, parameters: { layout: 'centered', }, tags: ['autodocs'], }; type Story = StoryObj; const defaultArgs = { options: [ { id: 1, label: 'Option1' }, { id: 2, label: 'Option2' }, { id: 3, label: 'Option3' }, { id: 4, label: 'Option4' }, { id: 5, label: 'Option5' }, { id: 6, label: 'Option6' }, ], placeholder: 'Search and select file name', showLabel: false, }; export const BasicAutocomplete: Story = { args: { ...defaultArgs, }, }; export const ControlledAutocomplete: Story = { render: () => { const [value, setValue] = useState(undefined); const onChangeHandler = (option: Option) => { setValue(option.label); }; const onClear = () => { setValue(undefined); }; return (
{['Autocomplete (Controlled)', 'Error Select', 'Read Only'].map( (label, index) => (
) )}
); }, }; export const AutocompleteWithNoBorder: Story = { args: { ...defaultArgs, labelProps: { label: 'Autocomplete with no border' }, showBorder: false, showLabel: true, disabled: true, }, }; export const AutocompleteBorderOnHover: Story = { args: { ...defaultArgs, labelProps: { label: 'Border on Hover' }, showBorderOnHover: false, showLabel: true, }, }; export const AutocompleteWithNoOptions: Story = { args: { ...defaultArgs, options: [], labelProps: { label: 'Autocomplete with no options' }, showLabel: true, }, }; export default meta;