import { DescriptiveLocation } from '@repay/cactus-icons' import { Page } from 'puppeteer' import React from 'react' import { Select } from '../' import { Action, actions, HIDE_CONTROL, SPACE, Story, STRING } from '../helpers/storybook' import arizonaCities from '../storySupport/arizonaCities' import { SelectValueType } from './Select' const defaultMultiValue = arizonaCities.slice(6, 15).reverse() const disabledOptions = [ { label: "You can't select me", value: 0, disabled: true }, { label: "Can't select me either", value: 1, disabled: true }, { label: "I'm up for grabs", value: 2 }, { label: 'Pick me pick me', value: [3] }, { label: 'Nope', value: 4, disabled: true }, { label: '', value: undefined }, { label: 'Yep', value: { complex: 5 } }, ] export default { title: 'Select', component: Select, argTypes: { options: HIDE_CONTROL, id: HIDE_CONTROL, value: HIDE_CONTROL, className: HIDE_CONTROL, matchNotFoundText: STRING, extraLabel: STRING, noOptionsText: STRING, placeholder: STRING, status: { options: ['success', 'warning', 'error'] }, ...actions('onChange', 'onBlur', 'onFocus'), }, args: { id: 'select', name: 'select', disabled: false, multiple: false, comboBox: false, canCreateOption: true, }, parameters: { cactus: { overrides: { maxWidth: '500px' } } }, } as const type ChangeArg = { onChange: Action> } type BasicStory = Story export const BasicUsage: BasicStory = ({ showOptions, options, ...args }) => (
Scroll down and to the right
) CollisionsInLargeContainer.argTypes = { options: { control: 'array' }, margin: SPACE } CollisionsInLargeContainer.args = { options: ['name', 'other', 'three'], showOptions: true, margin: '2', } CollisionsInLargeContainer.storyName = 'Collisions in an over-sized container' CollisionsInLargeContainer.parameters = { cactus: { overrides: { height: '220vh', width: '220vw', maxWidth: '220vw', display: 'flex', justifyContent: 'center', alignItems: 'center', }, }, storyshots: false, } export const LongListOfOptions: Story = (args) => { const [value, setValue] = React.useState(arizonaCities[6]) return ( ) } LongOptionLabels.storyName = 'Long option labels' LongOptionLabels.parameters = { storyshots: false } export const WithMultiselect: Story = (args) => { const [value, setValue] = React.useState(defaultMultiValue) return ( ) } WithMultiselect.args = { multiple: true } type OptionAl = ChangeArg & { showOptions: boolean } export const WithComboBox: Story = ({ showOptions, onChange, ...args }) => { const [value, setValue] = React.useState(null) return ( ) } WithComboBox.args = { showOptions: true, comboBox: true } WithComboBox.storyName = 'With ComboBox' WithComboBox.parameters = { storyshots: false } export const WithMultiSelectComboBox: Story = (args) => { const [value, setValue] = React.useState([]) return ( ) } WithDisabledOptions.storyName = 'With Disabled Options' WithDisabledOptions.parameters = { beforeScreenshot: async (page: Page) => { await page.click('button[name="select"]') }, }