Skip to content

Commit

Permalink
Release 0.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Feb 6, 2016
1 parent 3c8010d commit 173888f
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog

* 0.3.7 Expose a `.focus()` method (@py-in-the-sky)
* 0.3.6 Add custom onBlur and onFocus handler support (@Aweary)
* 0.3.5 Support composable SelctField (@rblakeley), update REDME SelectField example, remove mixin
* 0.3.4 Fix for #35 - Treat MUI Checkbox as a controlled component to address MUI 0.14.0-rc2 regression
Expand Down
12 changes: 6 additions & 6 deletions lib/FormsyCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibCheckbox = require('material-ui/lib/checkbox');

var _materialUiLibCheckbox2 = _interopRequireDefault(_materialUiLibCheckbox);

var _utils = require('./utils');

var FormsyCheckbox = _react2['default'].createClass({
displayName: 'FormsyCheckbox',

Expand All @@ -30,16 +32,14 @@ var FormsyCheckbox = _react2['default'].createClass({
},

componentDidMount: function componentDidMount() {
this.setValue(this._checkbox.isChecked());
this.setValue(this._muiComponent.isChecked());
},

render: function render() {
var _this = this;
_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(_materialUiLibCheckbox2['default'], _extends({}, this.props, {
ref: function (c) {
return _this._checkbox = c;
},
ref: this._setMuiComponentAndMaybeFocus,
onCheck: this.handleValueChange,
checked: this.getValue()
}));
Expand Down
5 changes: 5 additions & 0 deletions lib/FormsyDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibDatePickerDatePicker = require('material-ui/lib/date-picker/da

var _materialUiLibDatePickerDatePicker2 = _interopRequireDefault(_materialUiLibDatePickerDatePicker);

var _utils = require('./utils');

var FormsyDate = _react2['default'].createClass({
displayName: 'FormsyDate',

Expand All @@ -29,13 +31,16 @@ var FormsyDate = _react2['default'].createClass({
this.setValue(value);
},

_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(_materialUiLibDatePickerDatePicker2['default'],
// Sets the default date format to be ISO8601 (YYYY-MM-DD), accounting for current timezone
_extends({ formatDate: function (date) {
return new Date(date.toDateString() + " 12:00:00 +0000").toISOString().substring(0, 10);
}
}, this.props, {
ref: this._setMuiComponentAndMaybeFocus,
defaultValue: this.props.value,
onChange: this.handleValueChange,
errorText: this.getErrorMessage(),
Expand Down
12 changes: 6 additions & 6 deletions lib/FormsyRadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibRadioButtonGroup = require('material-ui/lib/radio-button-group

var _materialUiLibRadioButtonGroup2 = _interopRequireDefault(_materialUiLibRadioButtonGroup);

var _utils = require('./utils');

var FormsyRadioGroup = _react2['default'].createClass({
displayName: 'FormsyRadioGroup',

Expand All @@ -30,18 +32,16 @@ var FormsyRadioGroup = _react2['default'].createClass({
},

componentDidMount: function componentDidMount() {
this.setValue(this._radio.getSelectedValue());
this.setValue(this._muiComponent.getSelectedValue());
},

render: function render() {
var _this = this;
_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(
_materialUiLibRadioButtonGroup2['default'],
_extends({}, this.props, {
ref: function (c) {
return _this._radio = c;
},
ref: this._setMuiComponentAndMaybeFocus,
onChange: this.handleValueChange
}),
this.props.children
Expand Down
5 changes: 5 additions & 0 deletions lib/FormsySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibSelectField = require('material-ui/lib/select-field');

var _materialUiLibSelectField2 = _interopRequireDefault(_materialUiLibSelectField);

var _utils = require('./utils');

var FormsySelect = _react2['default'].createClass({
displayName: 'FormsySelect',

Expand All @@ -36,12 +38,15 @@ var FormsySelect = _react2['default'].createClass({
this.setState({ hasChanged: true });
},

_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
var value = this.state.hasChanged ? this.getValue() : this.props.value;

return _react2['default'].createElement(
_materialUiLibSelectField2['default'],
_extends({}, this.props, {
ref: this._setMuiComponentAndMaybeFocus,
onChange: this.handleChange,
errorText: this.getErrorMessage(),
value: value
Expand Down
5 changes: 5 additions & 0 deletions lib/FormsyText.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibTextField = require('material-ui/lib/text-field');

var _materialUiLibTextField2 = _interopRequireDefault(_materialUiLibTextField);

var _utils = require('./utils');

var FormsyText = _react2['default'].createClass({
displayName: 'FormsyText',

Expand Down Expand Up @@ -52,8 +54,11 @@ var FormsyText = _react2['default'].createClass({
this.setValue(event.currentTarget.value);
},

_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(_materialUiLibTextField2['default'], _extends({}, this.props, {
ref: this._setMuiComponentAndMaybeFocus,
defaultValue: this.props.value,
onChange: this.handleChange,
onBlur: this.handleBlur,
Expand Down
5 changes: 5 additions & 0 deletions lib/FormsyTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibTimePickerTimePicker = require('material-ui/lib/time-picker/ti

var _materialUiLibTimePickerTimePicker2 = _interopRequireDefault(_materialUiLibTimePickerTimePicker);

var _utils = require('./utils');

var FormsyTime = _react2['default'].createClass({
displayName: 'FormsyTime',

Expand All @@ -29,8 +31,11 @@ var FormsyTime = _react2['default'].createClass({
this.setValue(value);
},

_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(_materialUiLibTimePickerTimePicker2['default'], _extends({}, this.props, {
ref: this._setMuiComponentAndMaybeFocus,
onChange: this.handleValueChange
}));
}
Expand Down
12 changes: 6 additions & 6 deletions lib/FormsyToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _materialUiLibToggle = require('material-ui/lib/toggle');

var _materialUiLibToggle2 = _interopRequireDefault(_materialUiLibToggle);

var _utils = require('./utils');

var FormsyToggle = _react2['default'].createClass({
displayName: 'FormsyToggle',

Expand All @@ -30,16 +32,14 @@ var FormsyToggle = _react2['default'].createClass({
},

componentDidMount: function componentDidMount() {
this.setValue(this._toggle.isToggled());
this.setValue(this._muiComponent.isToggled());
},

render: function render() {
var _this = this;
_setMuiComponentAndMaybeFocus: _utils._setMuiComponentAndMaybeFocus,

render: function render() {
return _react2['default'].createElement(_materialUiLibToggle2['default'], _extends({}, this.props, {
ref: function (c) {
return _this._toggle = c;
},
ref: this._setMuiComponentAndMaybeFocus,
onToggle: this.handleValueChange
}));
}
Expand Down
20 changes: 20 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
exports._setMuiComponentAndMaybeFocus = _setMuiComponentAndMaybeFocus;

function _setMuiComponentAndMaybeFocus(c) {
if (c === this._muiComponent) return;

this._muiComponent = c;

if (c && typeof c.focus === 'function') {
this.focus = function () {
return c.focus();
};
} else if (this.hasOwnProperty('focus')) {
delete this.focus;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formsy-material-ui",
"version": "0.3.6",
"version": "0.3.7",
"description": "A formsy-react compatibility wrapper for Material-UI form components.",
"main": "./lib/index.js",
"scripts": {
Expand Down

0 comments on commit 173888f

Please sign in to comment.