Skip to content

Commit

Permalink
fix erikras#293 add lib/ dir to git.
Browse files Browse the repository at this point in the history
  • Loading branch information
ytkj committed Oct 6, 2019
1 parent ff728dc commit 3c01d62
Show file tree
Hide file tree
Showing 17 changed files with 916 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ node_modules
coverage
dist
es
lib
npm-debug.log
.DS_Store
37 changes: 37 additions & 0 deletions lib/Checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

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 _Checkbox = require('@material-ui/core/Checkbox');

var _Checkbox2 = _interopRequireDefault(_Checkbox);

var _createComponent = require('./createComponent');

var _createComponent2 = _interopRequireDefault(_createComponent);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

exports.default = (0, _createComponent2.default)(_Checkbox2.default, function (_ref) {
var _ref$input = _ref.input,
_onChange = _ref$input.onChange,
value = _ref$input.value,
inputProps = _objectWithoutProperties(_ref$input, ['onChange', 'value']),
meta = _ref.meta,
ignoredOnChange = _ref.onChange,
defaultChecked = _ref.defaultChecked,
props = _objectWithoutProperties(_ref, ['input', 'meta', 'onChange', 'defaultChecked']);

return _extends({}, inputProps, props, {
checked: value ? true : false,
onChange: function onChange(event, isInputChecked) {
_onChange(isInputChecked);
}
});
});
39 changes: 39 additions & 0 deletions lib/RadioGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

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 _RadioGroup = require('@material-ui/core/RadioGroup');

var _RadioGroup2 = _interopRequireDefault(_RadioGroup);

var _createComponent = require('./createComponent');

var _createComponent2 = _interopRequireDefault(_createComponent);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

exports.default = (0, _createComponent2.default)(_RadioGroup2.default, function (_ref) {
var _ref$input = _ref.input,
_onChange = _ref$input.onChange,
value = _ref$input.value,
inputProps = _objectWithoutProperties(_ref$input, ['onChange', 'value']),
meta = _ref.meta,
onChangeFromField = _ref.onChange,
props = _objectWithoutProperties(_ref, ['input', 'meta', 'onChange']);

return _extends({}, inputProps, props, {
value: value,
onChange: function onChange(event, value) {
_onChange(value);
if (onChangeFromField) {
onChangeFromField(value);
}
}
});
});
47 changes: 47 additions & 0 deletions lib/Select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

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 _Select = require('@material-ui/core/Select');

var _Select2 = _interopRequireDefault(_Select);

var _createComponent = require('./createComponent');

var _createComponent2 = _interopRequireDefault(_createComponent);

var _mapError = require('./mapError');

var _mapError2 = _interopRequireDefault(_mapError);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

exports.default = (0, _createComponent2.default)(_Select2.default, function (_ref) {
var _ref$input = _ref.input,
_onChange = _ref$input.onChange,
value = _ref$input.value,
_onBlur = _ref$input.onBlur,
inputProps = _objectWithoutProperties(_ref$input, ['onChange', 'value', 'onBlur']),
onChangeFromField = _ref.onChange,
defaultValue = _ref.defaultValue,
props = _objectWithoutProperties(_ref, ['input', 'onChange', 'defaultValue']);

return _extends({}, (0, _mapError2.default)(_extends({}, props, { hasHelperText: false })), inputProps, {
value: value,
onChange: function onChange(event) {
_onChange(event.target.value);
if (onChangeFromField) {
onChangeFromField(event.target.value);
}
},
onBlur: function onBlur() {
return _onBlur(value);
}
});
});
34 changes: 34 additions & 0 deletions lib/Switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

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 _Switch = require('@material-ui/core/Switch');

var _Switch2 = _interopRequireDefault(_Switch);

var _createComponent = require('./createComponent');

var _createComponent2 = _interopRequireDefault(_createComponent);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

exports.default = (0, _createComponent2.default)(_Switch2.default, function (_ref) {
var _ref$input = _ref.input,
onChange = _ref$input.onChange,
value = _ref$input.value,
inputProps = _objectWithoutProperties(_ref$input, ['onChange', 'value']),
checked = _ref.checked,
meta = _ref.meta,
props = _objectWithoutProperties(_ref, ['input', 'checked', 'meta']);

return _extends({}, inputProps, props, {
onChange: onChange,
checked: !!value
});
});
30 changes: 30 additions & 0 deletions lib/TextField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

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 _TextField = require('@material-ui/core/TextField');

var _TextField2 = _interopRequireDefault(_TextField);

var _createComponent = require('./createComponent');

var _createComponent2 = _interopRequireDefault(_createComponent);

var _mapError = require('./mapError');

var _mapError2 = _interopRequireDefault(_mapError);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

exports.default = (0, _createComponent2.default)(_TextField2.default, function (_ref) {
var defaultValue = _ref.defaultValue,
props = _objectWithoutProperties(_ref, ['defaultValue']);

return _extends({}, (0, _mapError2.default)(props));
});
74 changes: 74 additions & 0 deletions lib/__tests__/Checkbox.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

var _expect = require('expect');

var _expect2 = _interopRequireDefault(_expect);

var _expectJsx = require('expect-jsx');

var _expectJsx2 = _interopRequireDefault(_expectJsx);

var _lodash = require('lodash.noop');

var _lodash2 = _interopRequireDefault(_lodash);

var _Checkbox = require('@material-ui/core/Checkbox');

var _Checkbox2 = _interopRequireDefault(_Checkbox);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _Checkbox3 = require('../Checkbox');

var _Checkbox4 = _interopRequireDefault(_Checkbox3);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_expect2.default.extend(_expectJsx2.default);

describe('Checkbox', function () {
it('has a display name', function () {
(0, _expect2.default)(_Checkbox4.default.displayName).toBe('ReduxFormMaterialUIWithStyles');
});

it('renders an unchecked Checkbox', function () {
(0, _expect2.default)(new _Checkbox4.default({
input: {
name: 'myCheckbox',
onChange: _lodash2.default
}
}).render()).toEqualJSX(_react2.default.createElement(_Checkbox2.default, {
name: 'myCheckbox',
checked: false,
onChange: _lodash2.default,
ref: function ref() {}
}));
});

it('renders a checked Checkbox', function () {
(0, _expect2.default)(new _Checkbox4.default({
input: {
name: 'myCheckbox',
onChange: _lodash2.default,
value: true
}
}).render()).toEqualJSX(_react2.default.createElement(_Checkbox2.default, {
name: 'myCheckbox',
checked: true,
onChange: _lodash2.default,
ref: function ref() {}
}));
});

it('should ignore defaultChecked', function () {
(0, _expect2.default)(new _Checkbox4.default({
input: {
name: 'myCheckbox',
onChange: _lodash2.default
},
defaultChecked: true
}).render()).toEqualJSX(_react2.default.createElement(_Checkbox2.default, { name: 'myCheckbox', onChange: _lodash2.default, ref: function ref() {} }));
});
});
59 changes: 59 additions & 0 deletions lib/__tests__/RadioGroup.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

var _expect = require('expect');

var _expect2 = _interopRequireDefault(_expect);

var _expectJsx = require('expect-jsx');

var _expectJsx2 = _interopRequireDefault(_expectJsx);

var _RadioGroup = require('@material-ui/core/RadioGroup');

var _RadioGroup2 = _interopRequireDefault(_RadioGroup);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _lodash = require('lodash.noop');

var _lodash2 = _interopRequireDefault(_lodash);

var _testUtils = require('react-dom/test-utils');

var _testUtils2 = _interopRequireDefault(_testUtils);

var _RadioGroup3 = require('../RadioGroup');

var _RadioGroup4 = _interopRequireDefault(_RadioGroup3);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_expect2.default.extend(_expectJsx2.default);

describe('RadioGroup', function () {
it('has a display name', function () {
(0, _expect2.default)(_RadioGroup4.default.displayName).toBe('ReduxFormMaterialUIRadioGroup');
});

it('renders a RadioGroup', function () {
(0, _expect2.default)(new _RadioGroup4.default({
input: {
name: 'myRadio',
value: 'Foo',
onChange: { noop: _lodash2.default }
}
}).render()).toEqualJSX(_react2.default.createElement(_RadioGroup2.default, { name: 'myRadio', value: 'Foo', onChange: _lodash2.default, ref: function ref() {} }));
});

it('provides getRenderedComponent', function () {
var dom = _testUtils2.default.renderIntoDocument(_react2.default.createElement(_RadioGroup4.default, {
input: { name: 'myRadio', value: 'Foo' }
}));

var element = _testUtils2.default.findRenderedComponentWithType(dom, _RadioGroup4.default);
(0, _expect2.default)(element.getRenderedComponent).toBeA('function');
(0, _expect2.default)(element.getRenderedComponent()).toExist();
});
});
Loading

0 comments on commit 3c01d62

Please sign in to comment.