From 08bbceeb62f2bef7e39c4e7bf80424471e1c6136 Mon Sep 17 00:00:00 2001 From: Vignesh Rajendran Date: Fri, 11 Dec 2015 02:13:52 +0530 Subject: [PATCH 1/2] Adds Allow create functionality Pending: Test Cases are failing need to fix that --- examples/src/app.js | 5 +-- examples/src/components/AllowCreate.js | 61 ++++++++++++++++++++++++++ src/Option.js | 4 +- src/Select.js | 17 ++++++- test/Async-test.js | 2 +- test/Select-test.js | 26 +++-------- 6 files changed, 87 insertions(+), 28 deletions(-) create mode 100644 examples/src/components/AllowCreate.js diff --git a/examples/src/app.js b/examples/src/app.js index ed588679f0..5123bbde78 100644 --- a/examples/src/app.js +++ b/examples/src/app.js @@ -10,6 +10,7 @@ import CustomRender from './components/CustomRender'; import Multiselect from './components/Multiselect'; import NumericSelect from './components/NumericSelect'; import States from './components/States'; +import AllowCreate from './components/AllowCreate'; ReactDOM.render(
@@ -19,9 +20,7 @@ ReactDOM.render( - {/* - - */} +
, document.getElementById('example') ); diff --git a/examples/src/components/AllowCreate.js b/examples/src/components/AllowCreate.js new file mode 100644 index 0000000000..161d09dd44 --- /dev/null +++ b/examples/src/components/AllowCreate.js @@ -0,0 +1,61 @@ +import React from 'react'; +import Select from 'react-select'; + +const FLAVOURS = [ + { label: 'Chocolate', value: 'chocolate' }, + { label: 'Vanilla', value: 'vanilla' }, + { label: 'Strawberry', value: 'strawberry' }, + { label: 'Caramel', value: 'caramel' }, + { label: 'Cookies and Cream', value: 'cookiescream' }, + { label: 'Peppermint', value: 'peppermint' }, +]; + +var AllowCreate = React.createClass({ + displayName: 'AllowCreate', + + propTypes: { + allowCreate: React.PropTypes.bool, + label: React.PropTypes.string, + }, + + getInitialState () { + return { + disabled: false, + crazy: false, + options: FLAVOURS, + value: [], + }; + }, + + onLabelClick (data, event) { + console.log(data, event); + }, + + handleSelectChange (value){ + this.setState({ value }); + }, + + renderHint () { + return ( +
Create options in tag mode
+ ); + }, + + render () { + return ( +
+

{this.props.label}

+