import { Layout, Playground, Attributes } from 'lib/components'
import { Select, Spacer, Code } from 'components'

export const meta = {
  title: 'select',
  group: 'Data Entry',
}

## Select

Display a dropdown list of items.

<Playground
  desc="Basic usage."
  scope={{ Select }}
  code={`
() => {
  const handler = val => console.log(val)
  return (
    <Select placeholder="Choose one" onChange={handler}>
      <Select.Option value="1">Option 1</Select.Option>
      <Select.Option value="2">Option 2</Select.Option>
    </Select>
  )
}
`} />

<Playground
  title="Disabled"
  desc="Disable all options."
  scope={{ Select }}
  code={`
<Select placeholder="Choose one" disabled>
  <Select.Option value="1">Option 1</Select.Option>
  <Select.Option value="2">Option 2</Select.Option>
</Select>
`} />

<Playground
  title="Disabled Option"
  desc="disable specified options."
  scope={{ Select }}
  code={`
<Select placeholder="Choose one">
  <Select.Option value="1" disabled>Option 1</Select.Option>
  <Select.Option value="2">Option 2</Select.Option>
</Select>
`} />

<Playground
  title="Without Icon"
  desc="Hide icon on right."
  scope={{ Select }}
  code={`
<Select placeholder="Choose one" pure>
  <Select.Option value="1">Option 1</Select.Option>
  <Select.Option value="2">Option 2</Select.Option>
</Select>
`} />

<Playground
  title="Compose"
  desc="Use with other components."
  scope={{ Select, Code }}
  code={`
<Select placeholder="Choose one" initialValue="1">
  <Select.Option value="1"><Code>TypeScript</Code></Select.Option>
  <Select.Option value="2"><Code>JavaScript</Code></Select.Option>
</Select>
`} />


<Attributes edit="/pages/en-us/components/select.mdx">
<Attributes.Title>Select.Props</Attributes.Title>

| Attribute | Description | Type | Accepted values | Default
| ---------- | ---------- | ---- |  -------------- | ------ |
| **value** | selected value | `string` | - | - |
| **initialValue** | initial value | `string` | - | - |
| **placeholder** | placeholder string | `string` | - | - |
| **size** | select component size | `NormalSizes` | `'mini', 'small', 'medium', 'large'` | `medium` |
| **icon** | icon component | `ComponentType` | - | `SVG Component` |
| **pure** | remove icon component | `boolean` | - | `false` |
| **disabled** | disable current radio | `boolean` | - | `false` |
| **onChange** | selected value | `(val: string) => void` | - | - |
| **dropdownClassName** | className of dropdown menu | `string` | - | - |
| **dropdownStyle** | style of dropdown menu | `object` | - | - |
| ... | native props | `HTMLAttributes` | `'name', 'alt', 'className', ...` | - |

<Attributes.Title>Select.Option.Props</Attributes.Title>

| Attribute | Description | Type | Accepted values | Default
| ---------- | ---------- | ---- |  -------------- | ------ |
| **value**(required) | unique ident value | `string` | - | - |
| **disabled** | disable current option | `boolean` | - | `false` |
| ... | native props | `HTMLAttributes` | `'name', 'id', 'className', ...` | - |

</Attributes>

export default ({ children }) => <Layout meta={meta}>{children}</Layout>
