Consolidate keys and values with proptype.any

old
Javi Jimenez Villar 2015-07-13 21:15:03 +07:00
parent 5775ab405b
commit d227181cc5
4 changed files with 9 additions and 9 deletions

View File

@ -83,14 +83,14 @@ module.exports = React.createClass
<ul data-role="values" data-flex="horizontal wrap" onClick={@onDelete}> <ul data-role="values" data-flex="horizontal wrap" onClick={@onDelete}>
{ {
for key, label of @state.values for key, label of @state.values
<li ref={key} id={key} style={backgroundColor: @props.colors[key]}>{label}</li> <li key={key} id={key} style={backgroundColor: @props.colors[key]}>{label}</li>
} }
</ul> </ul>
} }
<Input {...@props} value="" ref="input" onFocus={@onFocus} <Input {...@props} value="" ref="input" onFocus={@onFocus}
onChange={@onChange} onKeyPress={@onKeyPress} onBlur={@onBlur}/> onChange={@onChange} onKeyPress={@onKeyPress} onBlur={@onBlur}/>
<ul ref="suggestions" data-role="suggestions" onClick={@onSelect}> <ul ref="suggestions" data-role="suggestions" onClick={@onSelect}>
{<li ref={key} id={key}>{label}</li> for key, label of @state.suggestions} {<li key={key} id={key}>{label}</li> for key, label of @state.suggestions}
</ul> </ul>
</div> </div>

View File

@ -71,7 +71,7 @@ module.exports = React.createClass
<ul ref="values" style={stylesheet} onClick={@onItem}> <ul ref="values" style={stylesheet} onClick={@onItem}>
{ {
for item, index in @props.dataSource for item, index in @props.dataSource
<li id={item.value} ref={index} className={"selected" if item.value is @state.selected.value}> <li id={item.value} key={index} className={"selected" if item.value is @state.selected.value}>
{ if @props.template then @props.template item else item.label } { if @props.template then @props.template item else item.label }
{ <Ripple origin={@state.ripple}/> if item.value is @state.selected.value } { <Ripple origin={@state.ripple}/> if item.value is @state.selected.value }
</li> </li>

View File

@ -59,15 +59,15 @@ module.exports = React.createClass
{ {
for attribute, index in @state.attributes for attribute, index in @state.attributes
if attribute.type is "submit" if attribute.type is "submit"
<Button {...attribute} type="square" ref="submit" onClick={@onSubmit}/> <Button key={index} {...attribute} type="square" ref="submit" onClick={@onSubmit}/>
else if attribute.type is "autocomplete" else if attribute.type is "autocomplete"
<Autocomplete {...attribute} onChange={@onChange}/> <Autocomplete key={index} {...attribute} onChange={@onChange}/>
else if attribute.type is "dropdown" else if attribute.type is "dropdown"
<Dropdown {...attribute} onChange={@onChange}/> <Dropdown key={index} {...attribute} onChange={@onChange}/>
else if attribute.type is "switch" else if attribute.type is "switch"
<Switch {...attribute} onChange={@onChange}/> <Switch key={index} {...attribute} onChange={@onChange}/>
else else
<Input {...attribute} /> <Input key={index} {...attribute} />
} }
{ @props.children } { @props.children }
</form> </form>

View File

@ -16,7 +16,7 @@ module.exports = React.createClass
onBlur : React.PropTypes.func onBlur : React.PropTypes.func
required : React.PropTypes.bool required : React.PropTypes.bool
type : React.PropTypes.string type : React.PropTypes.string
value : React.PropTypes.string value : React.PropTypes.any
getDefaultProps: -> getDefaultProps: ->
className : '' className : ''