react-controlfacades
Advanced tools
Comparing version
@@ -27,3 +27,3 @@ var ControlFacadeMixin, PropTypes, React, div, input, merge, span, _ref; | ||
_render: function() { | ||
var wrapperProps, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; | ||
var value, wrapperProps, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; | ||
wrapperProps = merge(this._getWrapperProps(), { | ||
@@ -35,8 +35,22 @@ style: merge(this.props.style, { | ||
}); | ||
value = (_ref1 = (_ref2 = this.props.value) != null ? _ref2 : this.state.value) != null ? _ref1 : this.props.defaultValue; | ||
return this.props.wrapper(wrapperProps, this.props.facade({ | ||
checked: (_ref1 = (_ref2 = this.props.checked) != null ? _ref2 : this.state.checked) != null ? _ref1 : this.props.defaultChecked, | ||
selected: (_ref3 = (_ref4 = this.props.selected) != null ? _ref4 : this.state.selected) != null ? _ref3 : this.props.defaultSelected, | ||
value: (_ref5 = (_ref6 = this.props.value) != null ? _ref6 : this.state.value) != null ? _ref5 : this.props.defaultValue | ||
checked: (_ref3 = (_ref4 = this.props.checked) != null ? _ref4 : this.state.checked) != null ? _ref3 : this.props.defaultChecked, | ||
selected: (_ref5 = (_ref6 = this.props.selected) != null ? _ref6 : this.state.selected) != null ? _ref5 : this.props.defaultSelected, | ||
value: value, | ||
label: this.getLabel(value) | ||
}), this.props.control(this._getControlProps(), this.props.children)); | ||
}, | ||
getLabel: function(value) { | ||
var child, _i, _len, _ref1, _ref2; | ||
if (this.props.children) { | ||
_ref1 = this.props.children; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
child = _ref1[_i]; | ||
if (child.props.value === value) { | ||
return (_ref2 = child.props.children) != null ? _ref2.toString() : void 0; | ||
} | ||
} | ||
} | ||
}, | ||
_getWrapperProps: function() { | ||
@@ -43,0 +57,0 @@ var props; |
@@ -1,7 +0,10 @@ | ||
var CFCheckbox; | ||
var CFCheckbox, CFSelect; | ||
CFCheckbox = require('./CFCheckbox'); | ||
CFSelect = require('./CFSelect'); | ||
module.exports = { | ||
CFCheckbox: CFCheckbox | ||
CFCheckbox: CFCheckbox, | ||
CFSelect: CFSelect | ||
}; |
{ | ||
"name": "react-controlfacades", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Style form controls but use their default behavior", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -40,7 +40,7 @@ react-controlfacades | ||
border: '2px solid black', | ||
backgroundColor: props.isChecked ? 'black': 'white' | ||
backgroundColor: props.checked ? 'black': 'white' | ||
}; | ||
return ( | ||
<div style={ style } /> | ||
<div style={ style } /> | ||
); | ||
@@ -51,3 +51,23 @@ } | ||
The facade will recieve the following props: | ||
<table> | ||
<tr> | ||
<td><code>checked</code></td> | ||
<td>For checkboxes, indicates whether the box is checked or not.</td> | ||
</tr> | ||
<tr> | ||
<td><code>value</code></td> | ||
<td>The value of the control.</td> | ||
</tr> | ||
<tr> | ||
<td><code>label</code></td> | ||
<td> | ||
For select boxes, the option string that corresponds to the selected | ||
value. | ||
</td> | ||
</tr> | ||
</table> | ||
[jquery.icbiacontrol]: https://github.com/matthewwithanm/jquery-icbiacontrol |
10454
19.09%10
11.11%141
38.24%72
38.46%