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

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

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

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

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

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

export const Basic = Template.bind({})
Basic.args = { label:'Biography',placeholder:'Write a biography here',jsonSchema, name:'biography' }