Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

[removed] Remove lodash dependency and hardcoded label #89

Merged
merged 1 commit into from
May 25, 2016
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
6 changes: 2 additions & 4 deletions examples/async-data/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ let App = React.createClass({
return (
<div>
<h1>Async Data</h1>

<p>
Autocomplete works great with async data by allowing you to pass in
items. The <code>onChange</code> event provides you the value to make
a server request with, then change state and pass in new items, it will
attempt to autocomplete the first one.
</p>

<label htmlFor="states-autocomplete">Choose a state from the US</label>
<Autocomplete
labelText="Choose a state from the US"
inputProps={{name: "US state"}}
inputProps={{name: "US state", id: "states-autocomplete"}}
ref="autocomplete"
value={this.state.value}
items={this.state.unitedStates}
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-menu/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ let App = React.createClass({
look as well as the rendering of it. In this case we put headers for each
letter of the alphabet.
</p>
<label htmlFor="states-autocomplete">Choose a state from the US</label>
<Autocomplete
value={this.state.value}
labelText="Choose a state from the US"
inputProps={{name: "US state"}}
inputProps={{name: "US state", id: "states-autocomplete"}}
items={this.state.unitedStates}
getItemValue={(item) => item.name}
onSelect={value => this.setState({ value, unitedStates: [] }) }
Expand Down
6 changes: 2 additions & 4 deletions examples/static-data/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ let App = React.createClass({
return (
<div>
<h1>Basic Example with Static Data</h1>

<p>
When using static data, you use the client to sort and filter the items,
so <code>Autocomplete</code> has methods baked in to help.
</p>

<label htmlFor="states-autocomplete">Choose a state from the US</label>
<Autocomplete
value={this.state.value}
labelText="Choose a state from the US"
inputProps={{name: "US state"}}
inputProps={{name: "US state", id: "states-autocomplete"}}
items={getStates()}
getItemValue={(item) => item.name}
shouldItemRender={matchStateToTerm}
Expand Down
9 changes: 1 addition & 8 deletions lib/Autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const React = require('react')
const lodash = require('lodash')
const scrollIntoView = require('dom-scroll-into-view')

let _debugStates = []
Expand All @@ -14,7 +13,6 @@ let Autocomplete = React.createClass({
renderItem: React.PropTypes.func.isRequired,
menuStyle: React.PropTypes.object,
inputProps: React.PropTypes.object,
labelText: React.PropTypes.string,
wrapperProps: React.PropTypes.object,
wrapperStyle: React.PropTypes.object
},
Expand All @@ -27,7 +25,6 @@ let Autocomplete = React.createClass({
display: 'inline-block'
},
inputProps: {},
labelText: '',
onChange () {},
onSelect (value, item) {},
renderMenu (items, value, style) {
Expand Down Expand Up @@ -55,7 +52,6 @@ let Autocomplete = React.createClass({
},

componentWillMount () {
this.id = lodash.uniqueId('autocomplete-');
this._ignoreBlur = false
this._performAutoCompleteOnUpdate = false
this._performAutoCompleteOnKeyUp = false
Expand Down Expand Up @@ -313,11 +309,9 @@ let Autocomplete = React.createClass({
state: this.state
})
}

return (
<div style={{...this.props.wrapperStyle}} {...this.props.wrapperProps}>
<label htmlFor={this.id} ref="label">
{this.props.labelText}
</label>
<input
{...this.props.inputProps}
role="combobox"
Expand All @@ -330,7 +324,6 @@ let Autocomplete = React.createClass({
onKeyUp={(event) => this.handleKeyUp(event)}
onClick={this.handleInputClick}
value={this.props.value}
id={this.id}
/>
{this.state.isOpen && this.renderMenu()}
{this.props.debug && (
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"dependencies": {
"babel-preset-es2015": "^6.5.0",
"dom-scroll-into-view": "1.0.1",
"lodash": "^4.5.0",
"react": "^0.14.7",
"react-dom": "^0.14.7"
}
Expand Down