/* eslint-disable react-hooks/rules-of-hooks */
import React, {useState} from 'react';
import {Meta, StoryObj} from '@storybook/react';

import {InputSearch} from './index';

const meta: Meta<typeof InputSearch> = {
  title: 'HuGo/Inputs/InputSearch',
  component: InputSearch,
  argTypes: {
    label: {type: 'string'},
    placeholder: {type: 'string'},
    helper: {type: 'string'},
    disabled: {type: 'boolean'},
    isError: {type: 'boolean'},
    isSuccess: {type: 'boolean'},
    size: {
      control: 'select',
      options: ['sm', 'lg'],
      defaultValue: 'lg',
    },
    variant: {
      control: 'select',
      options: ['default', 'secondary', 'custom', 'disabled'],
    },
  },
};

type Story = StoryObj<typeof InputSearch>;

export const InputSearchComponent: Story = {
  args: {
    label: 'Label',
    placeholder: 'Placeholder',
    helper: 'Helper',
    disabled: false,
    isError: false,
    isSuccess: false,
    size: 'lg',
  },
  render: args => {
    const [value, setValue] = useState('');
    return <InputSearch value={value} onChangeText={setValue} {...args} />;
  },
};

export const SmallInputSearch: Story = {
  args: {
    ...InputSearchComponent.args,
    size: 'sm',
    placeholder: 'Small search input',
  },
  render: InputSearchComponent.render,
};

export default meta;
