2019-08-12 08:19:52 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import { withKnobs, boolean, select, number } from '@storybook/addon-knobs/react';
|
|
|
|
import { optionsKnob as options } from '@storybook/addon-knobs';
|
2019-07-18 08:00:54 +00:00
|
|
|
import withReadme from 'storybook-readme/with-readme';
|
|
|
|
import Readme from './README.md';
|
2019-08-30 13:44:04 +00:00
|
|
|
import { ComboBox, Icons, Button, RadioButton, DropDownItem } from 'asc-web-components'
|
2019-07-18 08:00:54 +00:00
|
|
|
import Section from '../../../.storybook/decorators/section';
|
2019-08-30 13:44:04 +00:00
|
|
|
import styled from 'styled-components'
|
2019-07-18 08:00:54 +00:00
|
|
|
|
2019-08-12 08:19:52 +00:00
|
|
|
const iconNames = Object.keys(Icons);
|
|
|
|
const sizeOptions = ['base', 'middle', 'big', 'huge', 'content'];
|
|
|
|
|
2019-08-30 13:44:04 +00:00
|
|
|
const RadioButtonWrapper = styled.div`
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
label {
|
|
|
|
white-space: nowrap;
|
|
|
|
padding: 8px 16px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2019-08-12 08:19:52 +00:00
|
|
|
iconNames.push("NONE");
|
|
|
|
|
|
|
|
storiesOf('Components|Input', module)
|
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
|
|
|
.add('combo box', () => {
|
|
|
|
|
|
|
|
const comboOptions = [
|
|
|
|
{
|
2019-08-08 11:14:25 +00:00
|
|
|
key: 1,
|
|
|
|
icon: 'CatalogEmployeeIcon',
|
|
|
|
label: 'Option 1'
|
2019-08-12 08:19:52 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-08 11:14:25 +00:00
|
|
|
key: 2,
|
|
|
|
icon: 'CatalogGuestIcon',
|
|
|
|
label: 'Option 2',
|
2019-08-12 08:19:52 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-08 11:14:25 +00:00
|
|
|
key: 3,
|
2019-08-29 12:54:19 +00:00
|
|
|
disabled: true,
|
2019-08-08 11:14:25 +00:00
|
|
|
label: 'Option 3'
|
2019-08-12 08:19:52 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-08 11:14:25 +00:00
|
|
|
key: 4,
|
|
|
|
label: 'Option 4'
|
2019-08-12 08:19:52 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-08 11:14:25 +00:00
|
|
|
key: 5,
|
|
|
|
icon: 'CopyIcon',
|
|
|
|
label: 'Option 5'
|
2019-08-14 12:53:05 +00:00
|
|
|
},
|
2019-08-12 08:19:52 +00:00
|
|
|
{
|
2019-08-14 12:53:05 +00:00
|
|
|
key: 6,
|
|
|
|
label: 'Option 6'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 7,
|
|
|
|
label: 'Option 7'
|
2019-08-12 08:19:52 +00:00
|
|
|
}
|
2019-08-14 12:53:05 +00:00
|
|
|
];
|
2019-08-12 08:19:52 +00:00
|
|
|
|
|
|
|
const needScrollDropDown = boolean('Need scroll dropdown', false);
|
|
|
|
const dropDownMaxHeight = needScrollDropDown && number('dropDownMaxHeight', 200);
|
2019-08-14 12:53:05 +00:00
|
|
|
const optionsMultiSelect = options('children',
|
2019-08-12 08:19:52 +00:00
|
|
|
{
|
|
|
|
button: 'button',
|
|
|
|
icon: 'icon'
|
|
|
|
},
|
2019-08-14 12:53:05 +00:00
|
|
|
[],
|
2019-08-12 08:19:52 +00:00
|
|
|
{
|
|
|
|
display: 'multi-select',
|
|
|
|
});
|
|
|
|
|
|
|
|
let children = [];
|
|
|
|
optionsMultiSelect.forEach(function (item, i) {
|
|
|
|
switch (item) {
|
|
|
|
case "button":
|
2019-08-14 12:53:05 +00:00
|
|
|
children.push(<Button label="button" key={i} />);
|
2019-08-12 08:19:52 +00:00
|
|
|
break;
|
|
|
|
case "icon":
|
2019-08-14 12:53:05 +00:00
|
|
|
children.push(<Icons.NavLogoIcon size="medium" key={i} />);
|
2019-08-12 08:19:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-30 13:44:04 +00:00
|
|
|
const advancedOptions =
|
|
|
|
<>
|
|
|
|
<DropDownItem>
|
|
|
|
<RadioButton value='asc' name='first' label='A-Z' isChecked={true} />
|
|
|
|
</DropDownItem>
|
|
|
|
<DropDownItem >
|
|
|
|
<RadioButton value='desc' name='first' label='Z-A' />
|
|
|
|
</DropDownItem>
|
|
|
|
<DropDownItem isSeparator />
|
|
|
|
<DropDownItem>
|
|
|
|
<RadioButton value='first' name='second' label='First name' />
|
|
|
|
</DropDownItem>
|
|
|
|
<DropDownItem>
|
|
|
|
<RadioButton value='last' name='second' label='Last name' isChecked={true} />
|
|
|
|
</DropDownItem>
|
|
|
|
</>;
|
|
|
|
|
|
|
|
const childrenItems = children.length > 0 ? children : null;
|
|
|
|
|
2019-08-12 08:19:52 +00:00
|
|
|
return (
|
|
|
|
<Section>
|
2019-08-30 13:44:04 +00:00
|
|
|
<table style={{ width: 584, borderCollapse: "separate" }}>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Default</th>
|
|
|
|
<th>Advanced</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td style={{ paddingBottom: 20 }}>
|
|
|
|
<ComboBox
|
|
|
|
options={comboOptions}
|
|
|
|
onSelect={option => action("Selected option")(option)}
|
|
|
|
selectedOption={{
|
|
|
|
key: 0,
|
|
|
|
label: 'Select'
|
|
|
|
}}
|
|
|
|
isDisabled={boolean('isDisabled', false)}
|
|
|
|
noBorder={boolean('noBorder', false)}
|
|
|
|
dropDownMaxHeight={dropDownMaxHeight}
|
|
|
|
scaled={boolean('scaled', false)}
|
|
|
|
size={select('size', sizeOptions, 'content')}
|
|
|
|
>
|
|
|
|
{childrenItems}
|
|
|
|
</ComboBox>
|
|
|
|
</td>
|
|
|
|
<td style={{ paddingBottom: 20 }}>
|
|
|
|
<ComboBox
|
|
|
|
options={[]}
|
|
|
|
advancedOptions={advancedOptions}
|
|
|
|
onSelect={option => action("Selected option")(option)}
|
|
|
|
selectedOption={{
|
|
|
|
key: 0,
|
|
|
|
label: 'Select'
|
|
|
|
}}
|
|
|
|
isDisabled={boolean('isDisabled', false)}
|
|
|
|
scaled={false}
|
|
|
|
size='content'
|
|
|
|
directionX='right'
|
|
|
|
>
|
|
|
|
<Icons.NavLogoIcon size="medium" key='comboIcon' />
|
|
|
|
</ComboBox>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2019-08-12 08:19:52 +00:00
|
|
|
</Section>
|
|
|
|
);
|
|
|
|
});
|