2019-07-15 12:53:12 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import { StringValue } from 'react-values';
|
|
|
|
import { withKnobs, boolean, text, select, number } from '@storybook/addon-knobs/react';
|
|
|
|
import withReadme from 'storybook-readme/with-readme';
|
|
|
|
import Readme from './README.md';
|
2019-08-08 09:45:00 +00:00
|
|
|
import { SearchInput, Button } from 'asc-web-components';
|
2019-07-15 12:53:12 +00:00
|
|
|
import Section from '../../../.storybook/decorators/section';
|
|
|
|
|
|
|
|
const sizeOptions = ['base', 'middle', 'big', 'huge'];
|
2019-08-08 09:45:00 +00:00
|
|
|
|
2019-07-15 12:53:12 +00:00
|
|
|
function getData() {
|
|
|
|
return [
|
|
|
|
{ key: 'filter-status', group: 'filter-status', label: 'Status', isHeader: true },
|
2019-08-19 13:35:39 +00:00
|
|
|
{ key: '0', group: 'filter-status', label: 'Active' },
|
|
|
|
{ key: '1', group: 'filter-status', label: 'Disabled' },
|
2019-07-15 12:53:12 +00:00
|
|
|
{ key: 'filter-type', group: 'filter-type', label: 'Type', isHeader: true },
|
2019-08-19 13:35:39 +00:00
|
|
|
{ key: '0', group: 'filter-type', label: 'Folders' },
|
|
|
|
{ key: 'filter-other', group: 'filter-other', label: 'Other', isHeader: true },
|
2019-08-20 11:30:29 +00:00
|
|
|
{ key: '0', group: 'filter-other', subgroup: 'filter-groups', defaultSelectLabel: 'Select', label: 'Groups' },
|
2019-08-19 13:35:39 +00:00
|
|
|
{ key: '0', inSubgroup: true, group: 'filter-groups', label: 'Administration'},
|
2019-08-20 13:16:03 +00:00
|
|
|
{ key: '1', group: 'filter-other', subgroup: 'filter-empty', defaultSelectLabel: 'Select', label: 'Empty' },
|
|
|
|
{ key: '2', group: 'filter-other', subgroup: 'filter-test', defaultSelectLabel: 'Select', label: 'Test' },
|
2019-08-19 13:35:39 +00:00
|
|
|
{ key: '0', inSubgroup: true, group: 'filter-test', label: 'test1'},
|
|
|
|
{ key: '1', inSubgroup: true, group: 'filter-test', label: 'test2'},
|
|
|
|
|
2019-07-15 12:53:12 +00:00
|
|
|
];
|
2019-08-08 09:45:00 +00:00
|
|
|
}
|
|
|
|
class SearchStory extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2019-08-20 13:16:03 +00:00
|
|
|
selectedFilterData: []
|
2019-08-08 09:45:00 +00:00
|
|
|
};
|
|
|
|
this.buttonClick = this.buttonClick.bind(this);
|
2019-07-15 12:53:12 +00:00
|
|
|
}
|
2019-08-08 09:45:00 +00:00
|
|
|
buttonClick(){
|
|
|
|
this.setState({ selectedFilterData:[
|
|
|
|
{key: "1", group: "filter-status"},
|
2019-08-20 11:30:29 +00:00
|
|
|
{key: "-1", group: "filter-groups"}
|
2019-08-08 09:45:00 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
render(){
|
|
|
|
return(
|
|
|
|
<Section>
|
2019-07-15 12:53:12 +00:00
|
|
|
<StringValue
|
2019-08-27 08:54:38 +00:00
|
|
|
onChange={value => {
|
|
|
|
action('onChange')(value);
|
2019-07-15 12:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{({ value, set }) => (
|
|
|
|
<Section>
|
2019-08-08 09:45:00 +00:00
|
|
|
<div style={{marginBottom: '20px'}}>
|
|
|
|
<Button
|
|
|
|
label="Change props"
|
|
|
|
onClick={this.buttonClick}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-07-15 12:53:12 +00:00
|
|
|
<SearchInput
|
|
|
|
id={text('id', '')}
|
|
|
|
isDisabled={boolean('isDisabled', false)}
|
|
|
|
size={select('size', sizeOptions, 'base')}
|
|
|
|
scale={boolean('scale', false)}
|
|
|
|
placeholder={text('placeholder', 'Search')}
|
|
|
|
value={value}
|
2019-08-27 08:54:38 +00:00
|
|
|
onChange={value => {
|
|
|
|
set(value);
|
2019-07-15 12:53:12 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
)}
|
|
|
|
</StringValue>
|
2019-08-08 09:45:00 +00:00
|
|
|
</Section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
storiesOf('Components|Input', module)
|
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
|
|
|
.add('search', () => (
|
|
|
|
<SearchStory />
|
2019-07-15 12:53:12 +00:00
|
|
|
));
|