Skip to content

Commit

Permalink
Replace CommonJS requires with ES2015 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Jan 9, 2016
1 parent 3219208 commit df4da56
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 88 deletions.
8 changes: 6 additions & 2 deletions lib/FormComponentMixin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
'use strict';

var React = require('react');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

module.exports = {

propTypes: {
name: React.PropTypes.string.isRequired
name: _react2['default'].PropTypes.string.isRequired
},

handleValueChange: function handleValueChange(event, value) {
Expand Down
27 changes: 20 additions & 7 deletions lib/FormsyCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var Checkbox = require('material-ui/lib/checkbox');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyCheckbox = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibCheckbox = require('material-ui/lib/checkbox');

var _materialUiLibCheckbox2 = _interopRequireDefault(_materialUiLibCheckbox);

var _FormComponentMixin = require('./FormComponentMixin');

var _FormComponentMixin2 = _interopRequireDefault(_FormComponentMixin);

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

mixins: [Formsy.Mixin, FormComponentMixin],
mixins: [_formsyReact2['default'].Mixin, _FormComponentMixin2['default']],

componentDidMount: function componentDidMount() {
this.setValue(this._checkbox.isChecked());
Expand All @@ -19,7 +32,7 @@ var FormsyCheckbox = React.createClass({
render: function render() {
var _this = this;

return React.createElement(Checkbox, _extends({}, this.props, {
return _react2['default'].createElement(_materialUiLibCheckbox2['default'], _extends({}, this.props, {
ref: function (c) {
return _this._checkbox = c;
},
Expand Down
27 changes: 20 additions & 7 deletions lib/FormsyDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var DatePicker = require('material-ui/lib/date-picker/date-picker');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyDate = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibDatePickerDatePicker = require('material-ui/lib/date-picker/date-picker');

var _materialUiLibDatePickerDatePicker2 = _interopRequireDefault(_materialUiLibDatePickerDatePicker);

var _FormComponentMixin = require('./FormComponentMixin');

var _FormComponentMixin2 = _interopRequireDefault(_FormComponentMixin);

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

mixins: [Formsy.Mixin, FormComponentMixin],
mixins: [_formsyReact2['default'].Mixin, _FormComponentMixin2['default']],

render: function render() {
return React.createElement(DatePicker,
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);
Expand Down
15 changes: 11 additions & 4 deletions lib/FormsyRadio.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
'use strict';

var React = require('react');
var Formsy = require('formsy-react');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyRadio = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

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

mixins: [Formsy.Mixin],
mixins: [_formsyReact2['default'].Mixin],

// Material-UI replaces any component inside RadioButtonGroup with RadioButton, so no need to render it here
render: function render() {}
Expand Down
29 changes: 21 additions & 8 deletions lib/FormsyRadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var RadioButtonGroup = require('material-ui/lib/radio-button-group');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyRadioGroup = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibRadioButtonGroup = require('material-ui/lib/radio-button-group');

var _materialUiLibRadioButtonGroup2 = _interopRequireDefault(_materialUiLibRadioButtonGroup);

var _FormComponentMixin = require('./FormComponentMixin');

var _FormComponentMixin2 = _interopRequireDefault(_FormComponentMixin);

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

mixins: [Formsy.Mixin, FormComponentMixin],
mixins: [_formsyReact2['default'].Mixin, _FormComponentMixin2['default']],

componentDidMount: function componentDidMount() {
this.setValue(this._radio.getSelectedValue());
Expand All @@ -19,8 +32,8 @@ var FormsyRadioGroup = React.createClass({
render: function render() {
var _this = this;

return React.createElement(
RadioButtonGroup,
return _react2['default'].createElement(
_materialUiLibRadioButtonGroup2['default'],
_extends({}, this.props, {
ref: function (c) {
return _this._radio = c;
Expand Down
25 changes: 17 additions & 8 deletions lib/FormsySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var SelectField = require('material-ui/lib/select-field');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsySelect = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibSelectField = require('material-ui/lib/select-field');

var _materialUiLibSelectField2 = _interopRequireDefault(_materialUiLibSelectField);

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

mixins: [Formsy.Mixin],
mixins: [_formsyReact2['default'].Mixin],

propTypes: {
name: React.PropTypes.string.isRequired
name: _react2['default'].PropTypes.string.isRequired
},

handleChange: function handleChange(event) {
this.setValue(event.target.value);
},

render: function render() {
return React.createElement(SelectField, _extends({}, this.props, {
return _react2['default'].createElement(_materialUiLibSelectField2['default'], _extends({}, this.props, {
onChange: this.handleChange,
errorText: this.getErrorMessage(),
value: this.getValue() }));
Expand Down
26 changes: 18 additions & 8 deletions lib/FormsyText.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var TextField = require('material-ui/lib/text-field');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyText = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibTextField = require('material-ui/lib/text-field');

var _materialUiLibTextField2 = _interopRequireDefault(_materialUiLibTextField);

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

mixins: [Formsy.Mixin],
mixins: [_formsyReact2['default'].Mixin],

propTypes: {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string
name: _react2['default'].PropTypes.string.isRequired,
value: _react2['default'].PropTypes.string
},

handleChange: function handleChange(event) {
Expand All @@ -40,7 +50,7 @@ var FormsyText = React.createClass({
},

render: function render() {
return React.createElement(TextField, _extends({}, this.props, {
return _react2['default'].createElement(_materialUiLibTextField2['default'], _extends({}, this.props, {
defaultValue: this.props.value,
onChange: this.handleChange,
onBlur: this.handleBlur,
Expand Down
27 changes: 20 additions & 7 deletions lib/FormsyTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var TimePicker = require('material-ui/lib/time-picker/time-picker');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyTime = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibTimePickerTimePicker = require('material-ui/lib/time-picker/time-picker');

var _materialUiLibTimePickerTimePicker2 = _interopRequireDefault(_materialUiLibTimePickerTimePicker);

var _FormComponentMixin = require('./FormComponentMixin');

var _FormComponentMixin2 = _interopRequireDefault(_FormComponentMixin);

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

mixins: [Formsy.Mixin, FormComponentMixin],
mixins: [_formsyReact2['default'].Mixin, _FormComponentMixin2['default']],

render: function render() {
return React.createElement(TimePicker, _extends({}, this.props, {
return _react2['default'].createElement(_materialUiLibTimePickerTimePicker2['default'], _extends({}, this.props, {
onChange: this.handleValueChange }));
}
});
Expand Down
27 changes: 20 additions & 7 deletions lib/FormsyToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var React = require('react');
var Formsy = require('formsy-react');
var Toggle = require('material-ui/lib/toggle');
var FormComponentMixin = require('./FormComponentMixin');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FormsyToggle = React.createClass({
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formsyReact = require('formsy-react');

var _formsyReact2 = _interopRequireDefault(_formsyReact);

var _materialUiLibToggle = require('material-ui/lib/toggle');

var _materialUiLibToggle2 = _interopRequireDefault(_materialUiLibToggle);

var _FormComponentMixin = require('./FormComponentMixin');

var _FormComponentMixin2 = _interopRequireDefault(_FormComponentMixin);

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

mixins: [Formsy.Mixin, FormComponentMixin],
mixins: [_formsyReact2['default'].Mixin, _FormComponentMixin2['default']],

componentDidMount: function componentDidMount() {
this.setValue(this._toggle.isToggled());
Expand All @@ -19,7 +32,7 @@ var FormsyToggle = React.createClass({
render: function render() {
var _this = this;

return React.createElement(Toggle, _extends({}, this.props, {
return _react2['default'].createElement(_materialUiLibToggle2['default'], _extends({}, this.props, {
ref: function (c) {
return _this._toggle = c;
},
Expand Down
2 changes: 1 addition & 1 deletion src/FormComponentMixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const React = require('react');
import React from 'react';

module.exports = {

Expand Down
8 changes: 4 additions & 4 deletions src/FormsyCheckbox.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react');
const Formsy = require('formsy-react');
const Checkbox = require('material-ui/lib/checkbox');
const FormComponentMixin = require('./FormComponentMixin');
import React from 'react';
import Formsy from 'formsy-react';
import Checkbox from 'material-ui/lib/checkbox';
import FormComponentMixin from './FormComponentMixin';

let FormsyCheckbox = React.createClass({
mixins: [ Formsy.Mixin, FormComponentMixin ],
Expand Down
8 changes: 4 additions & 4 deletions src/FormsyDate.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react');
const Formsy = require('formsy-react');
const DatePicker = require('material-ui/lib/date-picker/date-picker');
const FormComponentMixin = require('./FormComponentMixin');
import React from 'react';
import Formsy from 'formsy-react';
import DatePicker from 'material-ui/lib/date-picker/date-picker';
import FormComponentMixin from './FormComponentMixin';

let FormsyDate = React.createClass({
mixins: [ Formsy.Mixin, FormComponentMixin ],
Expand Down
4 changes: 2 additions & 2 deletions src/FormsyRadio.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const React = require('react');
const Formsy = require('formsy-react');
import React from 'react';
import Formsy from 'formsy-react';

let FormsyRadio = React.createClass({
mixins: [ Formsy.Mixin ],
Expand Down
8 changes: 4 additions & 4 deletions src/FormsyRadioGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react');
const Formsy = require('formsy-react');
const RadioButtonGroup = require('material-ui/lib/radio-button-group');
const FormComponentMixin = require('./FormComponentMixin');
import React from 'react';
import Formsy from 'formsy-react';
import RadioButtonGroup from 'material-ui/lib/radio-button-group';
import FormComponentMixin from './FormComponentMixin';

let FormsyRadioGroup = React.createClass({
mixins: [ Formsy.Mixin, FormComponentMixin ],
Expand Down
Loading

0 comments on commit df4da56

Please sign in to comment.