formsy-material-ui
Advanced tools
Comparing version
## Changelog | ||
* HEAD Lint jsx files - fix linting errors in same | ||
* 0.5.0 Lint jsx files - fix linting errors in same | ||
Accepts Formsy.Form.reset() (@Mokto)q | ||
Fix text input values, and form reset (@reebalazs) | ||
Fixes React 15.2 unknown props warnings (@jayalfredprufrock) | ||
@@ -5,0 +8,0 @@ * 0.4.2 Fix controlled / uncontrolled conflicts |
@@ -34,3 +34,6 @@ 'use strict'; | ||
name: _react2.default.PropTypes.string.isRequired, | ||
onChange: _react2.default.PropTypes.func | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]) | ||
}, | ||
@@ -54,4 +57,10 @@ | ||
var defaultChecked = _props.defaultChecked; | ||
var // eslint-disable-line no-unused-vars | ||
validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var rest = _objectWithoutProperties(_props, ['defaultChecked']); | ||
var rest = _objectWithoutProperties(_props, ['defaultChecked', 'validations', 'validationErrors', 'validationError']); | ||
@@ -58,0 +67,0 @@ var value = this.getValue(); |
@@ -35,2 +35,5 @@ 'use strict'; | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]), | ||
value: _react2.default.PropTypes.object | ||
@@ -61,4 +64,10 @@ }, | ||
var defaultDate = _props.defaultDate; | ||
var // eslint-disable-line no-unused-vars | ||
validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var rest = _objectWithoutProperties(_props, ['defaultDate']); | ||
var rest = _objectWithoutProperties(_props, ['defaultDate', 'validations', 'validationErrors', 'validationError']); | ||
@@ -65,0 +74,0 @@ return _react2.default.createElement(_DatePicker2.default, _extends({}, rest, { |
@@ -23,2 +23,4 @@ 'use strict'; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
var FormsyRadioGroup = _react2.default.createClass({ | ||
@@ -31,3 +33,6 @@ displayName: 'FormsyRadioGroup', | ||
name: _react2.default.PropTypes.string.isRequired, | ||
onChange: _react2.default.PropTypes.func | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]) | ||
}, | ||
@@ -49,9 +54,34 @@ | ||
render: function render() { | ||
var _props = this.props; | ||
var validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var rest = _objectWithoutProperties(_props, ['validations', 'validationError', 'validationErrors']); | ||
// remove unknown props from children | ||
var children = _react2.default.Children.map(this.props.children, function (radio) { | ||
var _radio$props = radio.props; | ||
var validations = _radio$props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _radio$props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _radio$props.validationErrors; | ||
var rest = _objectWithoutProperties(_radio$props, ['validations', 'validationError', 'validationErrors']); | ||
return _react2.default.createElement(_RadioButton.RadioButton, rest); | ||
}); | ||
return _react2.default.createElement( | ||
_RadioButton.RadioButtonGroup, | ||
_extends({}, this.props, { | ||
_extends({}, rest, { | ||
ref: this.setMuiComponentAndMaybeFocus, | ||
onChange: this.handleValueChange | ||
}), | ||
this.props.children | ||
children | ||
); | ||
@@ -58,0 +88,0 @@ } |
@@ -35,2 +35,5 @@ 'use strict'; | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]), | ||
value: _react2.default.PropTypes.any | ||
@@ -60,6 +63,11 @@ }, | ||
render: function render() { | ||
var value = this.props.value; | ||
var _props = this.props; | ||
var value = _props.value; | ||
var validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var rest = _objectWithoutProperties(_props, ['value']); | ||
var rest = _objectWithoutProperties(_props, ['validations', 'validationError', 'validationErrors']); | ||
@@ -66,0 +74,0 @@ value = this.state.hasChanged ? this.getValue() : value; |
@@ -42,2 +42,5 @@ 'use strict'; | ||
onKeyDown: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]), | ||
value: _react2.default.PropTypes.any | ||
@@ -49,11 +52,34 @@ }, | ||
getInitialState: function getInitialState() { | ||
return { | ||
value: this.props.defaultValue || this.props.value || '' | ||
}; | ||
return { value: this.controlledValue() }; | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.setValue(this.props.defaultValue || this.props.value || ''); | ||
this.setValue(this.controlledValue()); | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
var isValueChanging = nextProps.value !== this.props.value; | ||
if (isValueChanging || nextProps.defaultValue !== this.props.defaultValue) { | ||
var value = this.controlledValue(nextProps); | ||
if (isValueChanging || this.props.defaultValue === this.getValue()) { | ||
this.setState({ value: value }); | ||
this.setValue(value); | ||
} | ||
} | ||
}, | ||
componentWillUpdate: function componentWillUpdate(nextProps, nextState) { | ||
if (nextState._isPristine && // eslint-disable-line no-underscore-dangle | ||
nextState._isPristine !== this.state._isPristine) { | ||
// eslint-disable-line no-underscore-dangle | ||
// Calling state here is valid, as it cannot cause infinite recursion. | ||
var value = this.controlledValue(nextProps); | ||
this.setValue(value); | ||
this.setState({ value: value }); | ||
} | ||
}, | ||
controlledValue: function controlledValue() { | ||
var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0]; | ||
return props.value || props.defaultValue || ''; | ||
}, | ||
handleBlur: function handleBlur(event) { | ||
@@ -82,6 +108,12 @@ this.setValue(event.currentTarget.value); | ||
var // eslint-disable-line no-unused-vars | ||
validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var // eslint-disable-line no-unused-vars | ||
onFocus = _props.onFocus; | ||
var value = _props.value; | ||
var rest = _objectWithoutProperties(_props, ['defaultValue', 'onFocus', 'value']); | ||
var rest = _objectWithoutProperties(_props, ['defaultValue', 'validations', 'validationError', 'validationErrors', 'onFocus', 'value']); | ||
@@ -88,0 +120,0 @@ return _react2.default.createElement(_TextField2.default, _extends({}, rest, { |
@@ -35,2 +35,5 @@ 'use strict'; | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]), | ||
value: _react2.default.PropTypes.object | ||
@@ -61,4 +64,10 @@ }, | ||
var defaultTime = _props.defaultTime; | ||
var // eslint-disable-line no-unused-vars | ||
validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var rest = _objectWithoutProperties(_props, ['defaultTime']); | ||
var rest = _objectWithoutProperties(_props, ['defaultTime', 'validations', 'validationError', 'validationErrors']); | ||
@@ -65,0 +74,0 @@ return _react2.default.createElement(_TimePicker2.default, _extends({}, rest, { |
@@ -34,3 +34,6 @@ 'use strict'; | ||
name: _react2.default.PropTypes.string.isRequired, | ||
onChange: _react2.default.PropTypes.func | ||
onChange: _react2.default.PropTypes.func, | ||
validationError: _react2.default.PropTypes.string, | ||
validationErrors: _react2.default.PropTypes.object, | ||
validations: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.object]) | ||
}, | ||
@@ -54,4 +57,9 @@ | ||
var defaultToggled = _props.defaultToggled; | ||
var validations = _props.validations; | ||
var // eslint-disable-line no-unused-vars | ||
validationError = _props.validationError; | ||
var // eslint-disable-line no-unused-vars | ||
validationErrors = _props.validationErrors; | ||
var rest = _objectWithoutProperties(_props, ['defaultToggled']); | ||
var rest = _objectWithoutProperties(_props, ['defaultToggled', 'validations', 'validationError', 'validationErrors']); | ||
@@ -58,0 +66,0 @@ var value = this.getValue(); |
{ | ||
"name": "formsy-material-ui", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "A formsy-react compatibility wrapper for Material-UI form components.", | ||
@@ -58,3 +58,3 @@ "main": "./lib/index.js", | ||
"karma-webpack": "^1.7.0", | ||
"material-ui": "0.15.0-beta.1", | ||
"material-ui": "^0.15.0", | ||
"mocha": "^2.4.5", | ||
@@ -61,0 +61,0 @@ "phantomjs-prebuilt": "^2.1.4", |
@@ -12,2 +12,5 @@ import React from 'react'; | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
}, | ||
@@ -29,3 +32,8 @@ | ||
render() { | ||
const { defaultChecked, ...rest } = this.props; | ||
const { | ||
defaultChecked, // eslint-disable-line no-unused-vars | ||
validations, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
...rest } = this.props; | ||
let value = this.getValue(); | ||
@@ -32,0 +40,0 @@ |
@@ -12,2 +12,5 @@ import React from 'react'; | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
value: React.PropTypes.object, | ||
@@ -36,5 +39,7 @@ }, | ||
const { | ||
defaultDate, // eslint-disable-line no-unused-vars | ||
...rest, | ||
} = this.props; | ||
defaultDate, // eslint-disable-line no-unused-vars | ||
validations, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
...rest } = this.props; | ||
@@ -41,0 +46,0 @@ return ( |
import React from 'react'; | ||
import Formsy from 'formsy-react'; | ||
import { RadioButtonGroup } from 'material-ui/RadioButton'; | ||
import { RadioButtonGroup, RadioButton } from 'material-ui/RadioButton'; | ||
import { setMuiComponentAndMaybeFocus } from './utils'; | ||
@@ -12,2 +12,5 @@ | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
}, | ||
@@ -29,9 +32,26 @@ | ||
render() { | ||
const { | ||
validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
...rest } = this.props; | ||
// remove unknown props from children | ||
const children = React.Children.map(this.props.children, (radio) => { | ||
const { | ||
validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
...rest } = radio.props; | ||
return React.createElement(RadioButton, rest); | ||
}); | ||
return ( | ||
<RadioButtonGroup | ||
{...this.props} | ||
{...rest} | ||
ref={this.setMuiComponentAndMaybeFocus} | ||
onChange={this.handleValueChange} | ||
> | ||
{this.props.children} | ||
{children} | ||
</RadioButtonGroup> | ||
@@ -38,0 +58,0 @@ ); |
@@ -12,2 +12,5 @@ import React from 'react'; | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
value: React.PropTypes.any, | ||
@@ -37,3 +40,9 @@ }, | ||
render() { | ||
let { value, ...rest } = this.props; | ||
let { value } = this.props; | ||
const { validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
...rest } = this.props; | ||
value = this.state.hasChanged ? this.getValue() : value; | ||
@@ -40,0 +49,0 @@ |
@@ -16,2 +16,5 @@ import React from 'react'; | ||
onKeyDown: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
value: React.PropTypes.any, | ||
@@ -22,12 +25,36 @@ }, | ||
getInitialState() { | ||
return { | ||
value: this.props.defaultValue || this.props.value || '', | ||
}; | ||
return { value: this.controlledValue() }; | ||
}, | ||
componentWillMount() { | ||
this.setValue(this.props.defaultValue || this.props.value || ''); | ||
this.setValue(this.controlledValue()); | ||
}, | ||
componentWillReceiveProps(nextProps) { | ||
const isValueChanging = nextProps.value !== this.props.value; | ||
if (isValueChanging || nextProps.defaultValue !== this.props.defaultValue) { | ||
const value = this.controlledValue(nextProps); | ||
if (isValueChanging || this.props.defaultValue === this.getValue()) { | ||
this.setState({ value }); | ||
this.setValue(value); | ||
} | ||
} | ||
}, | ||
componentWillUpdate(nextProps, nextState) { | ||
if (nextState._isPristine && // eslint-disable-line no-underscore-dangle | ||
nextState._isPristine !== this.state._isPristine) { // eslint-disable-line no-underscore-dangle | ||
// Calling state here is valid, as it cannot cause infinite recursion. | ||
const value = this.controlledValue(nextProps); | ||
this.setValue(value); | ||
this.setState({ value }); | ||
} | ||
}, | ||
controlledValue(props = this.props) { | ||
return props.value || props.defaultValue || ''; | ||
}, | ||
handleBlur: function handleBlur(event) { | ||
@@ -55,2 +82,5 @@ this.setValue(event.currentTarget.value); | ||
defaultValue, // eslint-disable-line no-unused-vars | ||
validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
onFocus, | ||
@@ -57,0 +87,0 @@ value, // eslint-disable-line no-unused-vars |
@@ -12,2 +12,5 @@ import React from 'react'; | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
value: React.PropTypes.object, | ||
@@ -37,2 +40,5 @@ }, | ||
defaultTime, // eslint-disable-line no-unused-vars | ||
validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
...rest, | ||
@@ -39,0 +45,0 @@ } = this.props; |
@@ -12,2 +12,5 @@ import React from 'react'; | ||
onChange: React.PropTypes.func, | ||
validationError: React.PropTypes.string, | ||
validationErrors: React.PropTypes.object, | ||
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]), | ||
}, | ||
@@ -29,3 +32,9 @@ | ||
render() { | ||
const { defaultToggled, ...rest } = this.props; | ||
const { | ||
defaultToggled, | ||
validations, // eslint-disable-line no-unused-vars | ||
validationError, // eslint-disable-line no-unused-vars | ||
validationErrors, // eslint-disable-line no-unused-vars | ||
...rest } = this.props; | ||
let value = this.getValue(); | ||
@@ -32,0 +41,0 @@ |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
46487
37.21%24
4.35%890
24.13%1
-50%78
Infinity%