2023-05-17 03:13:40 -04:00
|
|
|
import { Select } from '../js/shared/components/select'
|
|
|
|
|
|
|
|
const items = [1, 2, 3, 4].map(index => ({
|
|
|
|
key: index,
|
|
|
|
value: `Demo item ${index}`,
|
|
|
|
group: index >= 3 ? 'Large numbers' : undefined,
|
|
|
|
}))
|
|
|
|
|
|
|
|
export const Base = () => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
items={items}
|
|
|
|
itemToString={x => String(x?.value)}
|
|
|
|
itemToKey={x => String(x.key)}
|
|
|
|
defaultText="Choose an item"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const WithSubtitles = () => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
items={items}
|
|
|
|
itemToString={x => String(x?.value)}
|
|
|
|
itemToKey={x => String(x.key)}
|
|
|
|
itemToSubtitle={x => x?.group ?? ''}
|
|
|
|
defaultText="Choose an item"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-06-25 02:08:24 -04:00
|
|
|
export const WithSelectedIcon = () => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
items={items}
|
|
|
|
itemToString={x => String(x?.value)}
|
|
|
|
itemToKey={x => String(x.key)}
|
|
|
|
itemToSubtitle={x => x?.group ?? ''}
|
|
|
|
defaultText="Choose an item"
|
|
|
|
selectedIcon
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const WithDisabledItem = () => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
items={items}
|
|
|
|
itemToString={x => String(x?.value)}
|
|
|
|
itemToKey={x => String(x.key)}
|
|
|
|
itemToDisabled={x => x?.key === 1}
|
|
|
|
itemToSubtitle={x => x?.group ?? ''}
|
|
|
|
defaultText="Choose an item"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-05-17 03:13:40 -04:00
|
|
|
export default {
|
|
|
|
title: 'Shared / Components / Select',
|
|
|
|
component: Select,
|
|
|
|
}
|