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

Commit 0b622ed

Browse files
bfink13whichsteveyp
authored andcommitted
Remove lodash dependency and hardcoded label (#89)
1 parent 3cffb47 commit 0b622ed

File tree

5 files changed

+7
-19
lines changed

5 files changed

+7
-19
lines changed

examples/async-data/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ let App = React.createClass({
1616
return (
1717
<div>
1818
<h1>Async Data</h1>
19-
2019
<p>
2120
Autocomplete works great with async data by allowing you to pass in
2221
items. The <code>onChange</code> event provides you the value to make
2322
a server request with, then change state and pass in new items, it will
2423
attempt to autocomplete the first one.
2524
</p>
26-
25+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2726
<Autocomplete
28-
labelText="Choose a state from the US"
29-
inputProps={{name: "US state"}}
27+
inputProps={{name: "US state", id: "states-autocomplete"}}
3028
ref="autocomplete"
3129
value={this.state.value}
3230
items={this.state.unitedStates}

examples/custom-menu/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ let App = React.createClass({
2121
look as well as the rendering of it. In this case we put headers for each
2222
letter of the alphabet.
2323
</p>
24+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2425
<Autocomplete
2526
value={this.state.value}
26-
labelText="Choose a state from the US"
27-
inputProps={{name: "US state"}}
27+
inputProps={{name: "US state", id: "states-autocomplete"}}
2828
items={this.state.unitedStates}
2929
getItemValue={(item) => item.name}
3030
onSelect={value => this.setState({ value, unitedStates: [] }) }

examples/static-data/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ let App = React.createClass({
1010
return (
1111
<div>
1212
<h1>Basic Example with Static Data</h1>
13-
1413
<p>
1514
When using static data, you use the client to sort and filter the items,
1615
so <code>Autocomplete</code> has methods baked in to help.
1716
</p>
18-
17+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
1918
<Autocomplete
2019
value={this.state.value}
21-
labelText="Choose a state from the US"
22-
inputProps={{name: "US state"}}
20+
inputProps={{name: "US state", id: "states-autocomplete"}}
2321
items={getStates()}
2422
getItemValue={(item) => item.name}
2523
shouldItemRender={matchStateToTerm}

lib/Autocomplete.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const React = require('react')
2-
const lodash = require('lodash')
32
const scrollIntoView = require('dom-scroll-into-view')
43

54
let _debugStates = []
@@ -14,7 +13,6 @@ let Autocomplete = React.createClass({
1413
renderItem: React.PropTypes.func.isRequired,
1514
menuStyle: React.PropTypes.object,
1615
inputProps: React.PropTypes.object,
17-
labelText: React.PropTypes.string,
1816
wrapperProps: React.PropTypes.object,
1917
wrapperStyle: React.PropTypes.object
2018
},
@@ -27,7 +25,6 @@ let Autocomplete = React.createClass({
2725
display: 'inline-block'
2826
},
2927
inputProps: {},
30-
labelText: '',
3128
onChange () {},
3229
onSelect (value, item) {},
3330
renderMenu (items, value, style) {
@@ -55,7 +52,6 @@ let Autocomplete = React.createClass({
5552
},
5653

5754
componentWillMount () {
58-
this.id = lodash.uniqueId('autocomplete-');
5955
this._ignoreBlur = false
6056
this._performAutoCompleteOnUpdate = false
6157
this._performAutoCompleteOnKeyUp = false
@@ -313,11 +309,9 @@ let Autocomplete = React.createClass({
313309
state: this.state
314310
})
315311
}
312+
316313
return (
317314
<div style={{...this.props.wrapperStyle}} {...this.props.wrapperProps}>
318-
<label htmlFor={this.id} ref="label">
319-
{this.props.labelText}
320-
</label>
321315
<input
322316
{...this.props.inputProps}
323317
role="combobox"
@@ -330,7 +324,6 @@ let Autocomplete = React.createClass({
330324
onKeyUp={(event) => this.handleKeyUp(event)}
331325
onClick={this.handleInputClick}
332326
value={this.props.value}
333-
id={this.id}
334327
/>
335328
{this.state.isOpen && this.renderMenu()}
336329
{this.props.debug && (

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"dependencies": {
4949
"babel-preset-es2015": "^6.5.0",
5050
"dom-scroll-into-view": "1.0.1",
51-
"lodash": "^4.5.0",
5251
"react": "^0.14.7",
5352
"react-dom": "^0.14.7"
5453
}

0 commit comments

Comments
 (0)