react-flatpickr
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _reactDom = require('react-dom'); | ||
var _flatpickr = require('flatpickr'); | ||
@@ -34,23 +36,8 @@ | ||
function DateTimePicker() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, DateTimePicker); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DateTimePicker.__proto__ || Object.getPrototypeOf(DateTimePicker)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
id: '' | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return _possibleConstructorReturn(this, (DateTimePicker.__proto__ || Object.getPrototypeOf(DateTimePicker)).apply(this, arguments)); | ||
} | ||
_createClass(DateTimePicker, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
setDefaultId.call(this); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
@@ -65,6 +52,3 @@ value: function componentWillReceiveProps(props) { | ||
value: function componentDidMount() { | ||
var id = this.state.id; | ||
var node = document.getElementById(id); | ||
var node = (0, _reactDom.findDOMNode)(this.refs.input); | ||
var options = _extends({}, this.props.options, { | ||
@@ -80,2 +64,3 @@ onChange: this.props.onChange | ||
// ignore onChange, options | ||
// eslint-disable-next-line no-unused-vars | ||
var _props = this.props, | ||
@@ -88,5 +73,3 @@ onChange = _props.onChange, | ||
var id = this.state.id; | ||
return _react2.default.createElement('input', _extends({}, props, { id: id, defaultValue: defaultValue || value })); | ||
return _react2.default.createElement('input', _extends({}, props, { defaultValue: defaultValue || value, ref: 'input' })); | ||
} | ||
@@ -99,4 +82,3 @@ }]); | ||
DateTimePicker.propTypes = { | ||
options: _react.PropTypes.object, | ||
id: _react.PropTypes.string | ||
options: _react.PropTypes.object | ||
}; | ||
@@ -106,28 +88,2 @@ DateTimePicker.defaultProps = { | ||
}; | ||
exports.default = DateTimePicker; | ||
/** | ||
* private | ||
*/ | ||
function randomId() { | ||
var length = 16; | ||
var hexDigits = '0123456789abcdef'; | ||
var s = parseInt(String(Math.random()).slice(2)).toString('16').split('').slice(0, length); | ||
s[length - 3] = hexDigits.substr(s[length - 3] & 0x3 | 0x8, 1); | ||
return s.join(''); | ||
} | ||
function setDefaultId() { | ||
var pid = this.props.id; | ||
if (!this.state.id) { | ||
if (pid) { | ||
this.setState({ id: pid }); | ||
} else { | ||
this.setState({ id: randomId() }); | ||
} | ||
} | ||
} | ||
exports.default = DateTimePicker; |
import React, { Component, PropTypes } from 'react' | ||
import { findDOMNode } from 'react-dom' | ||
import Flatpickr from 'flatpickr' | ||
@@ -9,3 +10,2 @@ | ||
options: PropTypes.object, | ||
id: PropTypes.string | ||
} | ||
@@ -17,10 +17,2 @@ | ||
state = { | ||
id: '' | ||
} | ||
componentWillMount() { | ||
this::setDefaultId() | ||
} | ||
componentWillReceiveProps(props) { | ||
@@ -33,5 +25,3 @@ if (props.value) { | ||
componentDidMount() { | ||
const { id } = this.state | ||
const node = document.getElementById(id) | ||
const node = findDOMNode(this.refs.input) | ||
const options = { | ||
@@ -47,6 +37,6 @@ ...this.props.options, | ||
// ignore onChange, options | ||
// eslint-disable-next-line no-unused-vars | ||
const { onChange, options, defaultValue, value, ...props } = this.props | ||
const { id } = this.state | ||
return ( | ||
<input {...props} id={id} defaultValue={defaultValue || value}/> | ||
<input {...props} defaultValue={defaultValue || value} ref='input' /> | ||
) | ||
@@ -57,31 +47,1 @@ } | ||
export default DateTimePicker | ||
/** | ||
* private | ||
*/ | ||
function randomId() { | ||
let length = 16 | ||
let hexDigits = '0123456789abcdef' | ||
let s = parseInt(String(Math.random()) | ||
.slice(2)) | ||
.toString('16') | ||
.split('') | ||
.slice(0, length) | ||
s[length - 3] = hexDigits.substr((s[length - 3] & 0x3) | 0x8, 1) | ||
return s.join('') | ||
} | ||
function setDefaultId() { | ||
const pid = this.props.id | ||
if (!this.state.id) { | ||
if (pid) { | ||
this.setState({id: pid}) | ||
} else { | ||
this.setState({id: randomId()}) | ||
} | ||
} | ||
} |
{ | ||
"name": "react-flatpickr", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "flatpickr for React", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1779119
20758