Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration to material-ui-pickers 2.x #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "airbnb",
"rules": {
"react/jsx-filename-extension": 0,
"react/forbid-prop-types": 0
}
}
"extends": "airbnb",
"rules": {
"react/jsx-filename-extension": 0,
"react/forbid-prop-types": 0
},
"env": { "es6": true },
"parser": "babel-eslint"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js text eol=lf
35 changes: 17 additions & 18 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ var _raCore = require('ra-core');

var _materialUiPickers = require('material-ui-pickers');

var _dateFnsUtils = require('material-ui-pickers/utils/date-fns-utils');
var _dateFns = require('@date-io/date-fns');

var _dateFnsUtils2 = _interopRequireDefault(_dateFnsUtils);

var _MuiPickersUtilsProvider = require('material-ui-pickers/utils/MuiPickersUtilsProvider');

var _MuiPickersUtilsProvider2 = _interopRequireDefault(_MuiPickersUtilsProvider);
var _dateFns2 = _interopRequireDefault(_dateFns);

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

Expand All @@ -42,18 +38,23 @@ var makePicker = function makePicker(PickerComponent) {
_inherits(_makePicker, _Component);

function _makePicker() {
var _ref;

var _temp, _this, _ret;

_classCallCheck(this, _makePicker);

return _possibleConstructorReturn(this, (_makePicker.__proto__ || Object.getPrototypeOf(_makePicker)).apply(this, arguments));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = _makePicker.__proto__ || Object.getPrototypeOf(_makePicker)).call.apply(_ref, [this].concat(args))), _this), _this.onChange = function (date) {
_this.props.input.onChange(date);
_this.props.input.onBlur();
}, _temp), _possibleConstructorReturn(_this, _ret);
}

_createClass(_makePicker, [{
key: 'onChange',
value: function onChange(date) {
this.props.input.onChange(date);
this.props.input.onBlur();
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
Expand All @@ -76,7 +77,7 @@ var makePicker = function makePicker(PickerComponent) {
'div',
{ className: 'picker' },
_react2.default.createElement(
_MuiPickersUtilsProvider2.default,
_materialUiPickers.MuiPickersUtilsProvider,
providerOptions,
_react2.default.createElement(PickerComponent, _extends({}, options, {
label: _react2.default.createElement(_raCore.FieldTitle, {
Expand All @@ -93,9 +94,7 @@ var makePicker = function makePicker(PickerComponent) {
},
className: className,
value: input.value ? input.value : null,
onChange: function onChange(date) {
return _this2.onChange(date);
}
onChange: this.onChange
}))
)
);
Expand Down Expand Up @@ -132,7 +131,7 @@ var makePicker = function makePicker(PickerComponent) {
labelTime: '',
className: '',
providerOptions: {
utils: _dateFnsUtils2.default,
utils: _dateFns2.default,
locale: undefined
}
};
Expand Down
201 changes: 123 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-admin-date-inputs",
"version": "1.0.21",
"version": "1.1.0",
"description": "react-admin-date-inputs",
"main": "lib/index.js",
"author": "vascofg",
Expand Down Expand Up @@ -46,10 +46,11 @@
"peerDependencies": {
"react": "^16.3.0",
"prop-types": "^15.6.0",
"react-admin": "^2.1.0"
"react-admin": "^2.6.0"
},
"dependencies": {
"date-fns": "2.0.0-alpha.16",
"material-ui-pickers": "1.0.0-rc.17"
"@date-io/date-fns": "^1.0.1",
"date-fns": "2.0.0-alpha.25",
"material-ui-pickers": "^2.1.1"
}
}
Loading