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-09-07 10:20:47 +00:00
|
|
|
import ComboBox from '.';
|
|
|
|
import { Icons } from '../icons';
|
|
|
|
import Button from '../button';
|
|
|
|
import RadioButton from '../radio-button';
|
|
|
|
import DropDownItem from '../drop-down-item'
|
2019-07-18 08:00:54 +00:00
|
|
|
import Section from '../../../.storybook/decorators/section';
|
|
|
|
|
2019-08-12 08:19:52 +00:00
|
|
|
const iconNames = Object.keys(Icons);
|
|
|
|
const sizeOptions = ['base', 'middle', 'big', 'huge', 'content'];
|
|
|
|
|
|
|
|
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);
|
2019-09-18 13:24:14 +00:00
|
|
|
const dropDownMaxHeight = needScrollDropDown ? number('dropDownMaxHeight', 200) : null;
|
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 =
|
|
|
|
<>
|
2019-09-06 13:51:44 +00:00
|
|
|
<DropDownItem key='1' noHover>
|
2019-08-30 13:44:04 +00:00
|
|
|
<RadioButton value='asc' name='first' label='A-Z' isChecked={true} />
|
|
|
|
</DropDownItem>
|
2019-09-06 13:51:44 +00:00
|
|
|
<DropDownItem key='2' noHover>
|
2019-08-30 13:44:04 +00:00
|
|
|
<RadioButton value='desc' name='first' label='Z-A' />
|
|
|
|
</DropDownItem>
|
2019-09-05 13:11:37 +00:00
|
|
|
<DropDownItem key='3' isSeparator />
|
2019-09-06 13:51:44 +00:00
|
|
|
<DropDownItem key='4' noHover>
|
2019-08-30 13:44:04 +00:00
|
|
|
<RadioButton value='first' name='second' label='First name' />
|
|
|
|
</DropDownItem>
|
2019-09-06 13:51:44 +00:00
|
|
|
<DropDownItem key='5' noHover>
|
2019-08-30 13:44:04 +00:00
|
|
|
<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-12-05 11:15:03 +00:00
|
|
|
<table style={{ width: 584, borderCollapse: "separate", textAlign: "left" }}>
|
2019-08-30 13:44:04 +00:00
|
|
|
<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,
|
2019-12-27 10:53:39 +00:00
|
|
|
label: 'Select',
|
|
|
|
default: true
|
2019-08-30 13:44:04 +00:00
|
|
|
}}
|
|
|
|
isDisabled={boolean('isDisabled', false)}
|
|
|
|
noBorder={boolean('noBorder', false)}
|
|
|
|
dropDownMaxHeight={dropDownMaxHeight}
|
|
|
|
scaled={boolean('scaled', false)}
|
2019-09-18 13:24:14 +00:00
|
|
|
scaledOptions={boolean('scaledOptions', false)}
|
2019-08-30 13:44:04 +00:00
|
|
|
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,
|
2019-12-27 10:53:39 +00:00
|
|
|
label: 'Select',
|
|
|
|
default: true
|
2019-08-30 13:44:04 +00:00
|
|
|
}}
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
});
|