Skip to content

Commit

Permalink
0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
luqin committed Feb 20, 2016
1 parent 81862d1 commit 2663669
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
8 changes: 7 additions & 1 deletion lib/EnhancedSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ var EnhancedSwitch = (function (_React$Component) {
value: function adjustStyle() {
var inputContainer = this.refs.inputContainer;

if (inputContainer.style.position === 'static') {
var _window$getComputedStyle = window.getComputedStyle(inputContainer);

var position = _window$getComputedStyle.position;

if (position === 'static') {
inputContainer.style.position = 'relative';
}
}
Expand Down Expand Up @@ -313,6 +317,8 @@ var EnhancedSwitch = (function (_React$Component) {
});
}

event.preventDefault();
event.stopPropagation();
if (this.props.onChange && !this.props.label) {
this.props.onChange(event, newChecked);
}
Expand Down
64 changes: 46 additions & 18 deletions lib/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,39 @@ var RadioGroup = (function (_React$Component) {
_createClass(RadioGroup, null, [{
key: 'propTypes',
value: {
/**
* The name that will be applied to all radio buttons inside it.
*/
name: _react2['default'].PropTypes.string.isRequired,
value: _react2['default'].PropTypes.string,

/**
* Sets the default radio button to be the one whose
* value matches defaultValue (case-sensitive).
* This will override any individual radio button with
* the defaultChecked or checked property stated.
*/
defaultValue: _react2['default'].PropTypes.string,

/**
* The value of the currently selected radio button.
*/
value: _react2['default'].PropTypes.string,

/**
* Callback function that is fired when a radio button has
* been clicked. Returns the event and the value of the radio
* button that has been selected.
*/
onChange: _react2['default'].PropTypes.func,

/**
* Should be used to pass `Radio` components.
*/
children: _react2['default'].PropTypes.node,

/**
* The css class name of the root element.
*/
className: _react2['default'].PropTypes.string
},
enumerable: true
Expand Down Expand Up @@ -107,8 +135,8 @@ var RadioGroup = (function (_React$Component) {
}
}
}, {
key: 'handleRadioChange',
value: function handleRadioChange(e /* TODO , newValue */) {
key: 'handleChange',
value: function handleChange(e /* TODO , newValue */) {
var newValue = e.target.value;

this.updateRadioButtons(newValue);
Expand All @@ -125,30 +153,30 @@ var RadioGroup = (function (_React$Component) {
value: function render() {
var _this2 = this;

var children = _react2['default'].Children.map(this.props.children, function (radio) {
var _radio$props = radio.props;
var name = _radio$props.name;
var value = _radio$props.value;
var label = _radio$props.label;
var onChange = _radio$props.onChange;
var options = _react2['default'].Children.map(this.props.children, function (option) {
var _option$props = option.props;
var name = _option$props.name;
var value = _option$props.value;
var label = _option$props.label;
var onChange = _option$props.onChange;

var other = _objectWithoutProperties(_radio$props, ['name', 'value', 'label', 'onChange']);
var other = _objectWithoutProperties(_option$props, ['name', 'value', 'label', 'onChange']);

return _react2['default'].createElement(_Radio2['default'], _extends({}, other, {
ref: radio.props.value,
ref: option.props.value,
name: _this2.props.name,
key: radio.props.value,
value: radio.props.value,
label: radio.props.label,
onChange: _this2.handleRadioChange.bind(_this2),
checked: radio.props.value === _this2.state.value
key: option.props.value,
value: option.props.value,
label: option.props.label,
onChange: _this2.handleChange.bind(_this2),
checked: option.props.value === _this2.state.value
}));
}, this);

return _react2['default'].createElement(
'div',
{ className: this.props.className || '' },
children
{ className: this.props.className },
options
);
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-icheck",
"version": "0.2.1",
"version": "0.2.2",
"description": "iCheck components built with React. Highly customizable checkboxes and radio buttons",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 2663669

Please sign in to comment.