Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-typeahead",
"version": "1.1.9",
"version": "2.0.0",
"description": "React-based typeahead and typeahead-tokenizer",
"keywords": [
"react",
Expand Down Expand Up @@ -33,10 +33,11 @@
},
"dependencies": {
"classnames": "^1.2.0",
"fuzzy": "^0.1.0"
"fuzzy": "^0.1.0",
"react": "^15.0.1"
},
"peerDependencies": {
"react": ">= 0.14.0"
"react": ">= 0.14"
},
"main": "lib/react-typeahead.js",
"devDependencies": {
Expand All @@ -51,8 +52,6 @@
"literalify": "^0.4.0",
"lodash": "^2.4.1",
"mocha": "^1.21.4",
"react-addons-test-utils": "^0.14.2",
"react-dom": "^0.14.2",
"react-tools": "^0.13.3",
"sinon": "^1.10.3",
"watchify": "^2.2.1"
Expand All @@ -63,6 +62,11 @@
"build-test": "browserify test/main.js -t [ babelify --presets [ react ] ] -o test/bundle.js",
"build": "browserify ./src/react-typeahead.js -t [ babelify --presets [ react ] ] -t literalify -x react -s ReactTypeahead -o ./dist/react-typeahead.js",
"watchify": "watchify ./src/react-typeahead.js -t [ babelify --presets [ react ] ] -t literalify -x react -s ReactTypeahead -o ./dist/react-typeahead.js",
"react:14": "npm i react@0.14 react-dom@0.14 react-addons-test-utils@0.14",
"react:15": "npm i react@15 react-dom@15 react-addons-test-utils@15",
"test:react:14": "npm run react:14 && npm test",
"test:react:15": "npm run react:15 && npm test",
"test:all": "npm run test:react:14 && npm run test:react:15",
"lib": "gulp build",
"prepublish": "npm run lib"
},
Expand Down
6 changes: 3 additions & 3 deletions src/tokenizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var TypeaheadTokenizer = React.createClass({
customClasses: React.PropTypes.object,
allowCustomValues: React.PropTypes.number,
defaultSelected: React.PropTypes.array,
defaultValue: React.PropTypes.string,
initialValue: React.PropTypes.string,
placeholder: React.PropTypes.string,
disabled: React.PropTypes.bool,
inputProps: React.PropTypes.object,
Expand Down Expand Up @@ -69,7 +69,7 @@ var TypeaheadTokenizer = React.createClass({
defaultSelected: [],
customClasses: {},
allowCustomValues: 0,
defaultValue: "",
initialValue: "",
placeholder: "",
disabled: false,
inputProps: {},
Expand Down Expand Up @@ -195,7 +195,7 @@ var TypeaheadTokenizer = React.createClass({
allowCustomValues={this.props.allowCustomValues}
customClasses={this.props.customClasses}
options={this._getOptionsForTypeahead()}
defaultValue={this.props.defaultValue}
initialValue={this.props.initialValue}
maxVisible={this.props.maxVisible}
onOptionSelected={this._addTokenForValue}
onKeyDown={this._onKeyDown}
Expand Down
14 changes: 6 additions & 8 deletions src/typeahead/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Typeahead = React.createClass({
maxVisible: React.PropTypes.number,
options: React.PropTypes.array,
allowCustomValues: React.PropTypes.number,
defaultValue: React.PropTypes.string,
initialValue: React.PropTypes.string,
value: React.PropTypes.string,
placeholder: React.PropTypes.string,
disabled: React.PropTypes.bool,
Expand Down Expand Up @@ -56,8 +56,8 @@ var Typeahead = React.createClass({
options: [],
customClasses: {},
allowCustomValues: 0,
defaultValue: "",
value: null,
initialValue: "",
value: "",
placeholder: "",
disabled: false,
textarea: false,
Expand All @@ -79,10 +79,10 @@ var Typeahead = React.createClass({
getInitialState: function() {
return {
// The currently visible set of options
visible: this.getOptionsForValue(this.props.defaultValue, this.props.options),
visible: this.getOptionsForValue(this.props.initialValue, this.props.options),

// This should be called something else, "entryValue"
entryValue: this.props.value || this.props.defaultValue,
entryValue: this.props.value || this.props.initialValue,

// A valid typeahead value
selection: this.props.value,
Expand Down Expand Up @@ -189,7 +189,7 @@ var Typeahead = React.createClass({
_onTextEntryUpdated: function() {
var value = this.refs.entry.value;
this.setState({visible: this.getOptionsForValue(value, this.props.options),
selection: null,
selection: '',
entryValue: value});
},

Expand Down Expand Up @@ -305,7 +305,6 @@ var Typeahead = React.createClass({
var classList = classNames(classes);

var InputElement = this.props.textarea ? 'textarea' : 'input';

return (
<div className={classList}>
{ this._renderHiddenInput() }
Expand All @@ -315,7 +314,6 @@ var Typeahead = React.createClass({
placeholder={this.props.placeholder}
className={inputClassList}
value={this.state.entryValue}
defaultValue={this.props.defaultValue}
onChange={this._onChange}
onKeyDown={this._onKeyDown}
onKeyPress={this.props.onKeyPress}
Expand Down
4 changes: 2 additions & 2 deletions test/typeahead-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ describe('Typeahead Component', function() {
});
});

context('defaultValue', function() {
context('initialValue', function() {
it('should perform an initial search if a default value is provided', function() {
var component = TestUtils.renderIntoDocument(<Typeahead
options={ BEATLES }
defaultValue={ 'o' }
initialValue={ 'o' }
/>);

var results = TestUtils.scryRenderedComponentsWithType(component, TypeaheadOption);
Expand Down