import React from 'react'
import { Meta } from '@storybook/react/types-6-0'
import { Story } from '@storybook/react'
import { TextInputProps,TextInput } from './TextInput'
import { useArgs } from '@storybook/client-api'
import { IJsonSchema } from '../../types/IJsonSchema'

export default {
  title:'Components/TextInput',
  component: TextInput,
  argTypes: {}
} as Meta

const jsonSchema:IJsonSchema= {
  type: 'string',
  format: 'email'
}

const Template: Story<TextInputProps> = (args) => {
  const [{ value },updateArgs] = useArgs()

  const handleChange = (value:string ) => {
    updateArgs({ value })
  }

  return (
    <TextInput 
      {...args}
      value={value}
      onChange={handleChange}
    />
  )
}

export const Basic = Template.bind({})
Basic.args = { label:'Email',placeholder:'Email',jsonSchema,name:'email' }
