Skip to content

Commit 2663669

Browse files
author
luqin
committed
0.2.2
1 parent 81862d1 commit 2663669

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

lib/EnhancedSwitch.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ var EnhancedSwitch = (function (_React$Component) {
252252
value: function adjustStyle() {
253253
var inputContainer = this.refs.inputContainer;
254254

255-
if (inputContainer.style.position === 'static') {
255+
var _window$getComputedStyle = window.getComputedStyle(inputContainer);
256+
257+
var position = _window$getComputedStyle.position;
258+
259+
if (position === 'static') {
256260
inputContainer.style.position = 'relative';
257261
}
258262
}
@@ -313,6 +317,8 @@ var EnhancedSwitch = (function (_React$Component) {
313317
});
314318
}
315319

320+
event.preventDefault();
321+
event.stopPropagation();
316322
if (this.props.onChange && !this.props.label) {
317323
this.props.onChange(event, newChecked);
318324
}

lib/RadioGroup.js

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,39 @@ var RadioGroup = (function (_React$Component) {
3232
_createClass(RadioGroup, null, [{
3333
key: 'propTypes',
3434
value: {
35+
/**
36+
* The name that will be applied to all radio buttons inside it.
37+
*/
3538
name: _react2['default'].PropTypes.string.isRequired,
36-
value: _react2['default'].PropTypes.string,
39+
40+
/**
41+
* Sets the default radio button to be the one whose
42+
* value matches defaultValue (case-sensitive).
43+
* This will override any individual radio button with
44+
* the defaultChecked or checked property stated.
45+
*/
3746
defaultValue: _react2['default'].PropTypes.string,
47+
48+
/**
49+
* The value of the currently selected radio button.
50+
*/
51+
value: _react2['default'].PropTypes.string,
52+
53+
/**
54+
* Callback function that is fired when a radio button has
55+
* been clicked. Returns the event and the value of the radio
56+
* button that has been selected.
57+
*/
3858
onChange: _react2['default'].PropTypes.func,
59+
60+
/**
61+
* Should be used to pass `Radio` components.
62+
*/
3963
children: _react2['default'].PropTypes.node,
64+
65+
/**
66+
* The css class name of the root element.
67+
*/
4068
className: _react2['default'].PropTypes.string
4169
},
4270
enumerable: true
@@ -107,8 +135,8 @@ var RadioGroup = (function (_React$Component) {
107135
}
108136
}
109137
}, {
110-
key: 'handleRadioChange',
111-
value: function handleRadioChange(e /* TODO , newValue */) {
138+
key: 'handleChange',
139+
value: function handleChange(e /* TODO , newValue */) {
112140
var newValue = e.target.value;
113141

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

128-
var children = _react2['default'].Children.map(this.props.children, function (radio) {
129-
var _radio$props = radio.props;
130-
var name = _radio$props.name;
131-
var value = _radio$props.value;
132-
var label = _radio$props.label;
133-
var onChange = _radio$props.onChange;
156+
var options = _react2['default'].Children.map(this.props.children, function (option) {
157+
var _option$props = option.props;
158+
var name = _option$props.name;
159+
var value = _option$props.value;
160+
var label = _option$props.label;
161+
var onChange = _option$props.onChange;
134162

135-
var other = _objectWithoutProperties(_radio$props, ['name', 'value', 'label', 'onChange']);
163+
var other = _objectWithoutProperties(_option$props, ['name', 'value', 'label', 'onChange']);
136164

137165
return _react2['default'].createElement(_Radio2['default'], _extends({}, other, {
138-
ref: radio.props.value,
166+
ref: option.props.value,
139167
name: _this2.props.name,
140-
key: radio.props.value,
141-
value: radio.props.value,
142-
label: radio.props.label,
143-
onChange: _this2.handleRadioChange.bind(_this2),
144-
checked: radio.props.value === _this2.state.value
168+
key: option.props.value,
169+
value: option.props.value,
170+
label: option.props.label,
171+
onChange: _this2.handleChange.bind(_this2),
172+
checked: option.props.value === _this2.state.value
145173
}));
146174
}, this);
147175

148176
return _react2['default'].createElement(
149177
'div',
150-
{ className: this.props.className || '' },
151-
children
178+
{ className: this.props.className },
179+
options
152180
);
153181
}
154182
}]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-icheck",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "iCheck components built with React. Highly customizable checkboxes and radio buttons",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)