UNPKG

wix-style-react

Version:
46 lines (40 loc) 2.04 kB
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } import React from 'react'; import CodeExample from 'wix-storybook-utils/CodeExample'; import ExampleStandard from './ExampleStandard'; import ExampleStandardRaw from '!raw-loader!./ExampleStandard'; import MultiSelectCheckbox from '../../src/MultiSelectCheckbox'; var options = [{ value: 'Alabama', id: 'Alabama' }, { value: 'Alaska', id: 'Alaska' }, { value: 'Arkansas', id: 'Arkansas' }, { value: 'California', id: 'California' }, { value: 'California2', id: 'California2' }, { value: 'California3', id: 'California3' }, { value: 'California4', id: 'California4' }, { value: 'California5', id: 'California5' }, { value: 'California6', id: 'California6' }, { value: 'California7', id: 'California7' }, { value: 'Two words', id: 'Two words' }]; export default { category: '4. Selection', storyName: '4.1 + MultiSelectCheckbox', component: MultiSelectCheckbox, componentPath: '../../src/MultiSelectCheckbox', componentProps: function componentProps(setState, getState) { return { options: options, selectedOptions: [], onDeselect: function onDeselect(selectedOption) { setState({ selectedOptions: getState().selectedOptions.filter(function (val) { return val !== selectedOption; }) }); }, onSelect: function onSelect(selectedOption) { setState({ selectedOptions: [].concat(_toConsumableArray(getState().selectedOptions), [selectedOption]) }); }, dataHook: 'multi-select-checkbox' }; }, exampleProps: { options: [{ label: 'One option', value: [{ id: 0, value: 'Just me here' }] }, { label: options.length + ' options', value: options }] }, examples: React.createElement( CodeExample, { title: 'Standard', code: ExampleStandardRaw }, React.createElement(ExampleStandard, null) ) };