react-native-autocomplete-input
Advanced tools
Comparing version 1.1.0 to 1.1.1
38
index.js
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
import React, { Component, PropTypes } from 'react'; | ||
@@ -9,3 +7,3 @@ import { | ||
TextInput, | ||
View, | ||
View | ||
} from 'react-native'; | ||
@@ -45,3 +43,3 @@ | ||
*/ | ||
onShowResults: PropTypes.func | ||
onShowResults: PropTypes.func | ||
}; | ||
@@ -57,9 +55,15 @@ | ||
super(props); | ||
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); | ||
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 }); | ||
this.state = { | ||
dataSource: ds.cloneWithRows(props.data), | ||
showResults: false | ||
showResults: props.data && props.data.length > 0 | ||
}; | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
const dataSource = this.state.dataSource.cloneWithRows(nextProps.data); | ||
this._showResults(dataSource.getRowCount() > 0); | ||
this.setState({ dataSource }); | ||
} | ||
/** | ||
@@ -69,3 +73,3 @@ * Proxy `blur()` to autocomplete's text input. | ||
blur() { | ||
const { textInput } = this.refs; | ||
const { textInput } = this; | ||
textInput && textInput.blur(); | ||
@@ -78,12 +82,6 @@ } | ||
focus() { | ||
const { textInput } = this.refs; | ||
const { textInput } = this; | ||
textInput && textInput.focus(); | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
const dataSource = this.state.dataSource.cloneWithRows(nextProps.data); | ||
this._showResults(dataSource.getRowCount() > 0); | ||
this.setState({dataSource}); | ||
} | ||
_renderItems() { | ||
@@ -107,6 +105,6 @@ const { listStyle, renderItem } = this.props; | ||
if (!showResults && show) { | ||
this.setState({showResults: true}); | ||
this.setState({ showResults: true }); | ||
onShowResults && onShowResults(true); | ||
} else if (showResults && !show) { | ||
this.setState({showResults: false}); | ||
this.setState({ showResults: false }); | ||
onShowResults && onShowResults(false); | ||
@@ -124,3 +122,3 @@ } | ||
style={[styles.input, style]} | ||
ref="textInput" | ||
ref={ref => (this.textInput = ref)} | ||
onEndEditing={e => | ||
@@ -151,3 +149,3 @@ this._showResults(false) || (onEndEditing && onEndEditing(e)) | ||
margin: 10, | ||
marginBottom: 0, | ||
marginBottom: 0 | ||
}, | ||
@@ -157,3 +155,3 @@ input: { | ||
height: 40, | ||
paddingLeft: 3, | ||
paddingLeft: 3 | ||
}, | ||
@@ -165,3 +163,3 @@ list: { | ||
margin: 10, | ||
marginTop: 0, | ||
marginTop: 0 | ||
} | ||
@@ -168,0 +166,0 @@ }); |
{ | ||
"name": "react-native-autocomplete-input", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Pure javascript autocomplete input for react-native", | ||
"main": "index.js", | ||
"options": { | ||
"mocha": "--require react-native-mock/mock.js --compilers js:babel-core/register ./__tests__/**/*.js" | ||
}, | ||
"scripts": { | ||
"coverage": "node_modules/.bin/nyc mocha $npm_package_options_mocha && node_modules/.bin/nyc report --reporter=lcov", | ||
"lint": "eslint ./*.js ./example/*.js", | ||
"test": "npm run lint" | ||
"test": "npm run lint && npm run testonly", | ||
"testonly": "mocha $npm_package_options_mocha" | ||
}, | ||
@@ -33,7 +38,39 @@ "repository": { | ||
"devDependencies": { | ||
"babel-eslint": "^5.0.0", | ||
"eslint": "^2.0.1", | ||
"eslint-plugin-babel": "^3.1.0", | ||
"eslint-plugin-react": "^3.16.1" | ||
"babel-eslint": "^6.1.0", | ||
"babel-plugin-transform-class-properties": "^6.10.2", | ||
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0", | ||
"babel-plugin-transform-es2015-destructuring": "^6.9.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.10.3", | ||
"babel-plugin-transform-object-rest-spread": "^6.8.0", | ||
"babel-plugin-transform-react-jsx": "^6.8.0", | ||
"babel-register": "^6.9.0", | ||
"chai": "^3.5.0", | ||
"enzyme": "^2.3.0", | ||
"eslint": "^3.2.2", | ||
"eslint-config-airbnb": "^10.0.0", | ||
"eslint-plugin-babel": "^3.3.0", | ||
"eslint-plugin-import": "^1.9.2", | ||
"eslint-plugin-jsx-a11y": "^2.0.1", | ||
"eslint-plugin-react": "^6.0.0", | ||
"estraverse-fb": "^1.3.1", | ||
"jest-cli": "^13.0.0", | ||
"mocha": "^2.5.3", | ||
"nyc": "^6.6.1", | ||
"react": "^15.2.1", | ||
"react-addons-test-utils": "^15.2.1", | ||
"react-dom": "^15.2.1", | ||
"react-native": "^0.31.0", | ||
"react-native-mock": "^0.2.3", | ||
"sinon": "^1.17.4" | ||
}, | ||
"babel": { | ||
"plugins": [ | ||
"transform-class-properties", | ||
"transform-es2015-arrow-functions", | ||
"transform-es2015-destructuring", | ||
"transform-es2015-modules-commonjs", | ||
"transform-object-rest-spread", | ||
"transform-react-jsx" | ||
] | ||
} | ||
} |
@@ -1,2 +0,5 @@ | ||
# react-native-autocomplete-input [![npm version](https://badge.fury.io/js/react-native-autocomplete-input.svg)](https://badge.fury.io/js/react-native-autocomplete-input) | ||
# react-native-autocomplete-input | ||
[![npm version](https://badge.fury.io/js/react-native-autocomplete-input.svg)](https://badge.fury.io/js/react-native-autocomplete-input) | ||
[![Build Status](https://travis-ci.org/l-urence/react-native-autocomplete-input.svg)](https://travis-ci.org/l-urence/react-native-autocomplete-input) | ||
This is a pure javascript react-native component to display autocomplete suggestions given an array of objects respective to the input text. | ||
@@ -3,0 +6,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9773
62
26
145