UNPKG

wix-style-react

Version:
64 lines (55 loc) 1.83 kB
import React from 'react'; import Search from 'wix-style-react/Search'; import CodeExample from 'wix-storybook-utils/CodeExample'; import ExpandableExampleRaw from '!raw-loader!./expandable.example'; import ExpandableSearchExample from './expandable.example'; var createOption = function createOption(value) { var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; return { id: id, value: value }; }; var options = ['The quick', 'brown', 'fox', 'jumps over', 'the lazy', 'dog', 'Option1', 'Option2', 'Option3', 'Option4', 'Option5', 'last Option'].map(createOption); var settings = { category: '3. Inputs', storyName: '3.9 Search', dataHook: 'storybook-search', options: options }; export default { category: settings.category, storyName: settings.storyName, component: Search, componentPath: '../../src/Search', componentProps: function componentProps(setState) { return { dataHook: settings.dataHook, value: '', options: settings.options, showOptionsIfEmptyInput: false, closeOnSelect: false, onChange: function onChange(e) { return setState({ value: e.target.value }); }, onSelect: function onSelect(option) { return setState({ value: option.value }); } }; }, exampleProps: { onSelect: function onSelect(option) { return option.value; }, onChange: function onChange(e) { return e.target.value; }, options: [{ label: 'One option', value: [createOption('Just me :)')] }, { label: options.length + ' options', value: options }] }, examples: React.createElement( 'div', null, React.createElement( CodeExample, { title: 'Expandable', code: ExpandableExampleRaw }, React.createElement(ExpandableSearchExample, null) ) ) };