commit
21a95bd999
|
@ -7,7 +7,7 @@ module.exports = React.createClass
|
||||||
active : React.PropTypes.bool
|
active : React.PropTypes.bool
|
||||||
className : React.PropTypes.string
|
className : React.PropTypes.string
|
||||||
hideable : React.PropTypes.bool
|
hideable : React.PropTypes.bool
|
||||||
type : React.PropTypes.string.required
|
type : React.PropTypes.string
|
||||||
|
|
||||||
getDefaultProps: ->
|
getDefaultProps: ->
|
||||||
className : ""
|
className : ""
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = React.createClass
|
||||||
propTypes:
|
propTypes:
|
||||||
className : React.PropTypes.string
|
className : React.PropTypes.string
|
||||||
colors : React.PropTypes.object
|
colors : React.PropTypes.object
|
||||||
dataSource : React.PropTypes.object
|
dataSource : React.PropTypes.any
|
||||||
disabled : React.PropTypes.bool
|
disabled : React.PropTypes.bool
|
||||||
error : React.PropTypes.string
|
error : React.PropTypes.string
|
||||||
exact : React.PropTypes.bool
|
exact : React.PropTypes.bool
|
||||||
|
@ -16,7 +16,7 @@ module.exports = React.createClass
|
||||||
onChange : React.PropTypes.func
|
onChange : 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 : ""
|
||||||
|
@ -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 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 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>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = React.createClass
|
||||||
propTypes:
|
propTypes:
|
||||||
className : React.PropTypes.string
|
className : React.PropTypes.string
|
||||||
dataSource : React.PropTypes.array
|
dataSource : React.PropTypes.array
|
||||||
disabled : React.PropTypes.disabled
|
disabled : React.PropTypes.bool
|
||||||
label : React.PropTypes.string
|
label : React.PropTypes.string
|
||||||
onChange : React.PropTypes.func
|
onChange : React.PropTypes.func
|
||||||
template : React.PropTypes.func
|
template : React.PropTypes.func
|
||||||
|
@ -25,6 +25,7 @@ module.exports = React.createClass
|
||||||
dataSource : []
|
dataSource : []
|
||||||
disabled : false
|
disabled : false
|
||||||
type : "normal"
|
type : "normal"
|
||||||
|
value : undefined
|
||||||
|
|
||||||
getInitialState: ->
|
getInitialState: ->
|
||||||
active : false
|
active : false
|
||||||
|
@ -69,8 +70,8 @@ module.exports = React.createClass
|
||||||
{ <label>{@props.label}</label> if @props.label }
|
{ <label>{@props.label}</label> if @props.label }
|
||||||
<ul ref="values" style={stylesheet} onClick={@onItem}>
|
<ul ref="values" style={stylesheet} onClick={@onItem}>
|
||||||
{
|
{
|
||||||
for item in @props.dataSource
|
for item, index in @props.dataSource
|
||||||
<li id={item.value} 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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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 : ''
|
||||||
|
@ -30,8 +30,14 @@ module.exports = React.createClass
|
||||||
error : @props.error
|
error : @props.error
|
||||||
touch : @props.type in ['checkbox', 'radio']
|
touch : @props.type in ['checkbox', 'radio']
|
||||||
value : @props.value
|
value : @props.value
|
||||||
|
focus : false
|
||||||
|
valid : false
|
||||||
|
|
||||||
# -- Events
|
# -- Events
|
||||||
|
onBlur: (event) ->
|
||||||
|
@setState focus: false
|
||||||
|
@props.onBlur? event, @
|
||||||
|
|
||||||
onChange: (event) ->
|
onChange: (event) ->
|
||||||
if @state.touch
|
if @state.touch
|
||||||
@setState checked: event.target.checked, error: undefined
|
@setState checked: event.target.checked, error: undefined
|
||||||
|
@ -39,29 +45,40 @@ module.exports = React.createClass
|
||||||
@setState value: event.target.value, error: undefined
|
@setState value: event.target.value, error: undefined
|
||||||
@props.onChange? event, @
|
@props.onChange? event, @
|
||||||
|
|
||||||
|
onFocus: (event) ->
|
||||||
|
@setState focus: true
|
||||||
|
@props.onFocus? event, @
|
||||||
|
|
||||||
|
onKeyPress: (event) ->
|
||||||
|
@setState focus: true
|
||||||
|
@props.onKeyPress? event, @
|
||||||
|
|
||||||
# -- Render
|
# -- Render
|
||||||
render: ->
|
render: ->
|
||||||
className = @props.className
|
className = @props.className
|
||||||
|
className += ' checked' if @state.checked
|
||||||
className += ' disabled' if @props.disabled
|
className += ' disabled' if @props.disabled
|
||||||
className += ' error' if @state.error
|
className += ' error' if @state.error
|
||||||
|
className += ' focus' if @state.focus
|
||||||
className += ' touch' if @state.touch
|
className += ' touch' if @state.touch
|
||||||
className += ' radio' if @props.type is 'radio'
|
className += ' radio' if @props.type is 'radio'
|
||||||
className += ' checked' if @state.checked
|
className += ' valid' if @state.value? and @state.value.length > 0
|
||||||
|
|
||||||
<div data-component-input={@props.type} className={className}>
|
<div data-component-input={@props.type} className={className}>
|
||||||
{
|
{
|
||||||
if @props.multiline
|
if @props.multiline
|
||||||
<textarea ref='input' {...@props} value={@state.value}
|
<textarea ref='input' {...@props} value={@state.value}
|
||||||
|
onBlur={@onBlur}
|
||||||
onChange={@onChange}
|
onChange={@onChange}
|
||||||
onKeyPress={@props.onKeyPress}
|
onFocus={@onFocus}
|
||||||
onFocus={@props.onFocus}
|
onKeyPress={@onKeyPress} />
|
||||||
onBlur={@props.onBlur}>{@state.value}</textarea>
|
|
||||||
else
|
else
|
||||||
<input ref='input' {...@props} value={@state.value} checked={@state.checked}
|
<input ref='input' {...@props} value={@state.value}
|
||||||
|
checked={@state.checked}
|
||||||
|
onBlur={@onBlur}
|
||||||
onChange={@onChange}
|
onChange={@onChange}
|
||||||
onKeyPress={@props.onKeyPress}
|
onFocus={@onFocus}
|
||||||
onFocus={@props.onFocus}
|
onKeyPress={@onKeyPress} />
|
||||||
onBlur={@props.onBlur}/>
|
|
||||||
}
|
}
|
||||||
<span className='bar'></span>
|
<span className='bar'></span>
|
||||||
{ <label>{@props.label}</label> if @props.label }
|
{ <label>{@props.label}</label> if @props.label }
|
||||||
|
|
|
@ -77,6 +77,38 @@
|
||||||
transform scale(1)
|
transform scale(1)
|
||||||
|
|
||||||
&:not(.touch)
|
&:not(.touch)
|
||||||
|
|
||||||
|
// -- Stylesheets
|
||||||
|
&.focus
|
||||||
|
input, textarea
|
||||||
|
outline : none
|
||||||
|
~ .bar:before, ~ .bar:after
|
||||||
|
width : 50%
|
||||||
|
&:invalid
|
||||||
|
& ~ label
|
||||||
|
color : CANCEL
|
||||||
|
& ~ .bar:before, & ~ .bar:after
|
||||||
|
background-color : CANCEL
|
||||||
|
&.focus , &.valid
|
||||||
|
input, textarea
|
||||||
|
& ~ label
|
||||||
|
top : -(SPACE / 2)
|
||||||
|
font-size : FONT_SIZE_TINY
|
||||||
|
color : THEME
|
||||||
|
input[type="date"]
|
||||||
|
& ~ label
|
||||||
|
top : -(SPACE / 2)
|
||||||
|
font-size : FONT_SIZE_TINY
|
||||||
|
color : THEME
|
||||||
|
&:not(.focus)
|
||||||
|
input, textarea
|
||||||
|
&:invalid:not(:required)
|
||||||
|
border-bottom-color : CANCEL
|
||||||
|
&.error
|
||||||
|
input, textarea
|
||||||
|
border-bottom-color : CANCEL
|
||||||
|
|
||||||
|
// -- Children
|
||||||
input, textarea
|
input, textarea
|
||||||
display : block
|
display : block
|
||||||
padding : (SPACE / 2) 0
|
padding : (SPACE / 2) 0
|
||||||
|
@ -86,24 +118,9 @@
|
||||||
border : none
|
border : none
|
||||||
border-bottom : 1px solid FORM_BORDER_COLOR
|
border-bottom : 1px solid FORM_BORDER_COLOR
|
||||||
// -- Attributes
|
// -- Attributes
|
||||||
&:focus
|
|
||||||
outline : none
|
|
||||||
~ .bar:before, ~ .bar:after
|
|
||||||
width : 50%
|
|
||||||
&:focus ~ label, &:valid ~ label
|
|
||||||
top : -(SPACE / 2)
|
|
||||||
font-size : FONT_SIZE_TINY
|
|
||||||
// color : THEME
|
|
||||||
&:disabled
|
&:disabled
|
||||||
color : FORM_BORDER_COLOR
|
color : FORM_BORDER_COLOR
|
||||||
border-bottom-style : dotted
|
border-bottom-style : dotted
|
||||||
&:invalid
|
|
||||||
&:not(:required):not(:focus)
|
|
||||||
border-bottom-color : CANCEL
|
|
||||||
&:focus ~ label
|
|
||||||
color : CANCEL
|
|
||||||
~ .bar:before, ~ .bar:after
|
|
||||||
background-color : CANCEL
|
|
||||||
|
|
||||||
label
|
label
|
||||||
position : absolute
|
position : absolute
|
||||||
|
@ -113,6 +130,7 @@
|
||||||
transition-property top, font-size, color
|
transition-property top, font-size, color
|
||||||
transition-duration ANIMATION_DURATION
|
transition-duration ANIMATION_DURATION
|
||||||
transition-timing-function ANIMATION_EASE
|
transition-timing-function ANIMATION_EASE
|
||||||
|
|
||||||
.bar
|
.bar
|
||||||
position : relative
|
position : relative
|
||||||
display : block
|
display : block
|
||||||
|
@ -132,12 +150,6 @@
|
||||||
&:after
|
&:after
|
||||||
right : 50%
|
right : 50%
|
||||||
|
|
||||||
&.error
|
|
||||||
input, textarea
|
|
||||||
border-bottom-color : CANCEL
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -- Children
|
// -- Children
|
||||||
label
|
label
|
||||||
pointer-events : none
|
pointer-events : none
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = React.createClass
|
||||||
# -- States & Properties
|
# -- States & Properties
|
||||||
propTypes:
|
propTypes:
|
||||||
className : React.PropTypes.string
|
className : React.PropTypes.string
|
||||||
dataSource : React.PropTypes.Array
|
dataSource : React.PropTypes.array
|
||||||
ItemFactory : React.PropTypes.func
|
ItemFactory : React.PropTypes.func
|
||||||
onClick : React.PropTypes.func
|
onClick : React.PropTypes.func
|
||||||
type : React.PropTypes.string
|
type : React.PropTypes.string
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = React.createClass
|
||||||
# -- Render
|
# -- Render
|
||||||
render: ->
|
render: ->
|
||||||
<nav data-component-navigation={@props.type}>
|
<nav data-component-navigation={@props.type}>
|
||||||
{ <Link {...route} /> for route in @props.routes }
|
{ <Link key={index} {...route} /> for route, index in @props.routes }
|
||||||
{ <Button {...action} /> for action in @props.actions }
|
{ <Button key={index} {...action} /> for action, index in @props.actions }
|
||||||
{ @props.children }
|
{ @props.children }
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in New Issue