react-date-picker
Advanced tools
Comparing version 7.1.1 to 7.2.0
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,58 +6,69 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
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 = _interopRequireWildcard(require("react")); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _reactLifecyclesCompat = require("react-lifecycles-compat"); | ||
var _react = require('react'); | ||
var _Divider = _interopRequireDefault(require("./Divider")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _DayInput = _interopRequireDefault(require("./DateInput/DayInput")); | ||
var _propTypes = require('prop-types'); | ||
var _MonthInput = _interopRequireDefault(require("./DateInput/MonthInput")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _YearInput = _interopRequireDefault(require("./DateInput/YearInput")); | ||
var _reactLifecyclesCompat = require('react-lifecycles-compat'); | ||
var _NativeInput = _interopRequireDefault(require("./DateInput/NativeInput")); | ||
var _Divider = require('./Divider'); | ||
var _dateFormatter = require("./shared/dateFormatter"); | ||
var _Divider2 = _interopRequireDefault(_Divider); | ||
var _dates = require("./shared/dates"); | ||
var _DayInput = require('./DateInput/DayInput'); | ||
var _propTypes2 = require("./shared/propTypes"); | ||
var _DayInput2 = _interopRequireDefault(_DayInput); | ||
var _utils = require("./shared/utils"); | ||
var _MonthInput = require('./DateInput/MonthInput'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _MonthInput2 = _interopRequireDefault(_MonthInput); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _YearInput = require('./DateInput/YearInput'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _YearInput2 = _interopRequireDefault(_YearInput); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _NativeInput = require('./DateInput/NativeInput'); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
var _NativeInput2 = _interopRequireDefault(_NativeInput); | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
var _dateFormatter = require('./shared/dateFormatter'); | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
var _dates = require('./shared/dates'); | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _propTypes3 = require('./shared/propTypes'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _utils = require('./shared/utils'); | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
@@ -72,6 +83,7 @@ var defaultMinDate = new Date(-8.64e15); | ||
}; | ||
/** | ||
* Returns value type that can be returned with currently applied settings. | ||
*/ | ||
var getValueType = function getValueType(maxDetail) { | ||
@@ -95,3 +107,3 @@ return allValueTypes[allViews.indexOf(maxDetail)]; | ||
if (isNaN(valueFromDate.getTime())) { | ||
throw new Error('Invalid date: ' + value); | ||
throw new Error("Invalid date: ".concat(value)); | ||
} | ||
@@ -110,3 +122,2 @@ | ||
var detailValueFrom = (0, _dates.getBegin)(getValueType(maxDetail), valueFrom); | ||
return (0, _utils.between)(detailValueFrom, minDate, maxDate); | ||
@@ -129,3 +140,3 @@ }; | ||
if (isNaN(valueToDate.getTime())) { | ||
throw new Error('Invalid date: ' + value); | ||
throw new Error("Invalid date: ".concat(value)); | ||
} | ||
@@ -144,3 +155,2 @@ | ||
var detailValueTo = (0, _dates.getEnd)(getValueType(maxDetail), valueTo); | ||
return (0, _utils.between)(detailValueTo, minDate, maxDate); | ||
@@ -159,5 +169,7 @@ }; | ||
var previousElement = element.previousElementSibling; // Divider between inputs | ||
if (!previousElement) { | ||
return null; | ||
} | ||
return previousElement.previousElementSibling; // Actual input | ||
@@ -168,5 +180,7 @@ }; | ||
var nextElement = element.nextElementSibling; // Divider between inputs | ||
if (!nextElement) { | ||
return null; | ||
} | ||
return nextElement.nextElementSibling; // Actual input | ||
@@ -179,17 +193,17 @@ }; | ||
var _renderCustomInputs = function _renderCustomInputs(placeholder, elementFunctions) { | ||
var _renderCustomInputs = function renderCustomInputs(placeholder, elementFunctions) { | ||
var pattern = new RegExp(Object.keys(elementFunctions).join('|'), 'gi'); | ||
var matches = placeholder.match(pattern); | ||
return placeholder.split(pattern).reduce(function (arr, element, index) { | ||
var divider = element && | ||
// eslint-disable-next-line react/no-array-index-key | ||
_react2.default.createElement( | ||
_Divider2.default, | ||
{ key: 'separator_' + index }, | ||
element | ||
); | ||
var divider = element && // eslint-disable-next-line react/no-array-index-key | ||
_react.default.createElement(_Divider.default, { | ||
key: "separator_".concat(index) | ||
}, element); | ||
var res = [].concat(_toConsumableArray(arr), [divider]); | ||
if (matches[index]) { | ||
if (matches && matches[index]) { | ||
res.push(elementFunctions[matches[index]]()); | ||
} | ||
return res; | ||
@@ -199,29 +213,39 @@ }, []); | ||
var DateInput = function (_PureComponent) { | ||
var DateInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(DateInput, _PureComponent); | ||
function DateInput() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, DateInput); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DateInput.__proto__ || Object.getPrototypeOf(DateInput)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DateInput)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
year: null, | ||
month: null, | ||
day: null | ||
}, _this.onClick = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onClick", function (event) { | ||
if (event.target === event.currentTarget) { | ||
// Wrapper was directly clicked | ||
var _event$target$childre = _slicedToArray(event.target.children, 2), | ||
firstInput = _event$target$childre[1]; | ||
/* nativeInput */ | ||
firstInput = _event$target$childre[1]; | ||
focus(firstInput); | ||
} | ||
}, _this.onKeyDown = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKeyDown", function (event) { | ||
switch (event.key) { | ||
@@ -231,3 +255,2 @@ case 'ArrowLeft': | ||
event.preventDefault(); | ||
var input = event.target; | ||
@@ -238,2 +261,3 @@ var previousInput = findPreviousInput(input); | ||
} | ||
case 'ArrowRight': | ||
@@ -243,3 +267,2 @@ case _this.divider: | ||
event.preventDefault(); | ||
var _input = event.target; | ||
@@ -250,5 +273,8 @@ var nextInput = findNextInput(_input); | ||
} | ||
default: | ||
} | ||
}, _this.onChange = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (event) { | ||
var _event$target = event.target, | ||
@@ -258,9 +284,9 @@ name = _event$target.name, | ||
_this.setState(_defineProperty({}, name, value ? parseInt(value, 10) : null), _this.onChangeExternal); | ||
}); | ||
_this.setState(_defineProperty({}, name, value ? parseInt(value, 10) : null), _this.onChangeExternal); | ||
}, _this.onChangeNative = function (event) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChangeNative", function (event) { | ||
var onChange = _this.props.onChange; | ||
var value = event.target.value; | ||
if (!onChange) { | ||
@@ -284,3 +310,2 @@ return; | ||
var date = parseInt(dayString, 10) || 1; | ||
return new Date(year, monthIndex, date); | ||
@@ -290,6 +315,7 @@ }(); | ||
onChange(processedValue, false); | ||
}, _this.onChangeExternal = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChangeExternal", function () { | ||
var onChange = _this.props.onChange; | ||
if (!onChange) { | ||
@@ -300,3 +326,2 @@ return; | ||
var formElements = [_this.dayInput, _this.monthInput, _this.yearInput].filter(Boolean); | ||
var values = {}; | ||
@@ -315,6 +340,10 @@ formElements.forEach(function (formElement) { | ||
var proposedValue = new Date(values.year, (values.month || 1) - 1, values.day || 1); | ||
var processedValue = _this.getProcessedValue(proposedValue); | ||
onChange(processedValue, false); | ||
} | ||
}, _this.renderDay = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderDay", function () { | ||
var _this$props = _this.props, | ||
@@ -327,6 +356,4 @@ maxDetail = _this$props.maxDetail, | ||
year = _this$state.year; | ||
return _react2.default.createElement(_DayInput2.default, _extends({ | ||
key: 'day' | ||
return _react.default.createElement(_DayInput.default, _extends({ | ||
key: "day" | ||
}, _this.commonInputProps, { | ||
@@ -339,3 +366,5 @@ maxDetail: maxDetail, | ||
})); | ||
}, _this.renderMonth = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderMonth", function () { | ||
var _this$props2 = _this.props, | ||
@@ -347,6 +376,4 @@ maxDetail = _this$props2.maxDetail, | ||
year = _this$state2.year; | ||
return _react2.default.createElement(_MonthInput2.default, _extends({ | ||
key: 'month' | ||
return _react.default.createElement(_MonthInput.default, _extends({ | ||
key: "month" | ||
}, _this.commonInputProps, { | ||
@@ -358,8 +385,8 @@ maxDetail: maxDetail, | ||
})); | ||
}, _this.renderYear = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderYear", function () { | ||
var year = _this.state.year; | ||
return _react2.default.createElement(_YearInput2.default, _extends({ | ||
key: 'year' | ||
return _react.default.createElement(_YearInput.default, _extends({ | ||
key: "year" | ||
}, _this.commonInputProps, { | ||
@@ -369,9 +396,10 @@ value: year, | ||
})); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(DateInput, [{ | ||
key: 'getProcessedValue', | ||
key: "getProcessedValue", | ||
/** | ||
@@ -381,16 +409,18 @@ * Gets current value in a desired format. | ||
value: function getProcessedValue(value) { | ||
var _props = this.props, | ||
minDate = _props.minDate, | ||
maxDate = _props.maxDate, | ||
maxDetail = _props.maxDetail, | ||
returnValue = _props.returnValue; | ||
var _this$props3 = this.props, | ||
minDate = _this$props3.minDate, | ||
maxDate = _this$props3.maxDate, | ||
maxDetail = _this$props3.maxDetail, | ||
returnValue = _this$props3.returnValue; | ||
switch (returnValue) { | ||
case 'start': | ||
return getDetailValueFrom(value, minDate, maxDate, maxDetail); | ||
case 'end': | ||
return getDetailValueTo(value, minDate, maxDate, maxDetail); | ||
case 'range': | ||
return getDetailValueArray(value, minDate, maxDate, maxDetail); | ||
default: | ||
@@ -401,6 +431,5 @@ throw new Error('Invalid returnValue.'); | ||
}, { | ||
key: 'renderCustomInputs', | ||
key: "renderCustomInputs", | ||
value: function renderCustomInputs() { | ||
var placeholder = this.placeholder; | ||
var elementFunctions = { | ||
@@ -411,19 +440,16 @@ day: this.renderDay, | ||
}; | ||
return _renderCustomInputs(placeholder, elementFunctions); | ||
} | ||
}, { | ||
key: 'renderNativeInput', | ||
key: "renderNativeInput", | ||
value: function renderNativeInput() { | ||
var _props2 = this.props, | ||
disabled = _props2.disabled, | ||
maxDate = _props2.maxDate, | ||
minDate = _props2.minDate, | ||
name = _props2.name, | ||
required = _props2.required, | ||
value = _props2.value; | ||
return _react2.default.createElement(_NativeInput2.default, { | ||
key: 'date', | ||
var _this$props4 = this.props, | ||
disabled = _this$props4.disabled, | ||
maxDate = _this$props4.maxDate, | ||
minDate = _this$props4.minDate, | ||
name = _this$props4.name, | ||
required = _this$props4.required, | ||
value = _this$props4.value; | ||
return _react.default.createElement(_NativeInput.default, { | ||
key: "date", | ||
disabled: disabled, | ||
@@ -440,31 +466,26 @@ maxDate: maxDate || defaultMaxDate, | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var className = this.props.className; | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
className: className, | ||
onClick: this.onClick, | ||
role: 'presentation' | ||
}, | ||
this.renderNativeInput(), | ||
this.renderCustomInputs() | ||
); | ||
return _react.default.createElement("div", { | ||
className: className, | ||
onClick: this.onClick, | ||
role: "presentation" | ||
}, this.renderNativeInput(), this.renderCustomInputs()); | ||
} | ||
}, { | ||
key: 'formatDate', | ||
key: "formatDate", | ||
get: function get() { | ||
var _props3 = this.props, | ||
locale = _props3.locale, | ||
maxDetail = _props3.maxDetail; | ||
var _this$props5 = this.props, | ||
locale = _this$props5.locale, | ||
maxDetail = _this$props5.maxDetail; | ||
var options = { | ||
year: 'numeric' | ||
}; | ||
var level = allViews.indexOf(maxDetail); | ||
var options = { year: 'numeric' }; | ||
var level = allViews.indexOf(maxDetail); | ||
if (level >= 2) { | ||
options.month = 'numeric'; | ||
} | ||
if (level >= 3) { | ||
@@ -474,36 +495,40 @@ options.day = 'numeric'; | ||
return (0, _dateFormatter.getFormatter)(options, locale); | ||
return (0, _dateFormatter.getFormatter)(locale, options); | ||
} | ||
}, { | ||
key: 'divider', | ||
key: "formatNumber", | ||
get: function get() { | ||
var locale = this.props.locale; | ||
var date = new Date(2017, 11, 11); | ||
return this.formatDate(date, locale).match(/[^0-9]/)[0]; | ||
var options = { | ||
useGrouping: false | ||
}; | ||
return (0, _dateFormatter.getFormatter)(locale, options); | ||
} | ||
}, { | ||
key: 'placeholder', | ||
key: "divider", | ||
get: function get() { | ||
var locale = this.props.locale; | ||
var date = new Date(2017, 11, 11); | ||
return this.formatDate(date, locale).replace('2017', 'year').replace('12', 'month').replace('11', 'day'); | ||
return this.formatDate(date).match(/[^0-9]/)[0]; | ||
} | ||
}, { | ||
key: 'commonInputProps', | ||
key: "placeholder", | ||
get: function get() { | ||
var year = 2017; | ||
var monthIndex = 11; | ||
var day = 11; | ||
var date = new Date(year, monthIndex, day); | ||
return this.formatDate(date).replace(this.formatNumber(year), 'year').replace(this.formatNumber(monthIndex + 1), 'month').replace(this.formatNumber(day), 'day'); | ||
} | ||
}, { | ||
key: "commonInputProps", | ||
get: function get() { | ||
var _this2 = this; | ||
var _props4 = this.props, | ||
className = _props4.className, | ||
disabled = _props4.disabled, | ||
isCalendarOpen = _props4.isCalendarOpen, | ||
maxDate = _props4.maxDate, | ||
minDate = _props4.minDate, | ||
required = _props4.required; | ||
var _this$props6 = this.props, | ||
className = _this$props6.className, | ||
disabled = _this$props6.disabled, | ||
isCalendarOpen = _this$props6.isCalendarOpen, | ||
maxDate = _this$props6.maxDate, | ||
minDate = _this$props6.minDate, | ||
required = _this$props6.required; | ||
return { | ||
@@ -520,3 +545,3 @@ className: className, | ||
// Save a reference to each input field | ||
_this2[name + 'Input'] = ref; | ||
_this2["".concat(name, "Input")] = ref; | ||
} | ||
@@ -526,27 +551,9 @@ }; | ||
}, { | ||
key: 'valueType', | ||
key: "valueType", | ||
get: function get() { | ||
var maxDetail = this.props.maxDetail; | ||
return getValueType(maxDetail); | ||
} | ||
/** | ||
* Called when non-native date input is changed. | ||
*/ | ||
/** | ||
* Called when native date input is changed. | ||
*/ | ||
/** | ||
* Called after internal onChange. Checks input validity. If all fields are valid, | ||
* calls props.onChange. | ||
*/ | ||
}], [{ | ||
key: 'getDerivedStateFromProps', | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(nextProps, prevState) { | ||
@@ -556,6 +563,3 @@ var minDate = nextProps.minDate, | ||
maxDetail = nextProps.maxDetail; | ||
var nextState = {}; | ||
/** | ||
@@ -565,6 +569,6 @@ * If isCalendarOpen flag has changed, we have to update it. | ||
*/ | ||
if (nextProps.isCalendarOpen !== prevState.isCalendarOpen) { | ||
nextState.isCalendarOpen = nextProps.isCalendarOpen; | ||
} | ||
/** | ||
@@ -575,10 +579,12 @@ * If the next value is different from the current one (with an exception of situation in | ||
*/ | ||
var nextValue = getDetailValueFrom(nextProps.value, minDate, maxDate, maxDetail); | ||
var values = [nextValue, prevState.value]; | ||
if ( | ||
// Toggling calendar visibility resets values | ||
if ( // Toggling calendar visibility resets values | ||
nextState.isCalendarOpen // Flag was toggled | ||
|| datesAreDifferent.apply(undefined, _toConsumableArray(values.map(function (value) { | ||
|| datesAreDifferent.apply(void 0, _toConsumableArray(values.map(function (value) { | ||
return getDetailValueFrom(value, minDate, maxDate, maxDetail); | ||
}))) || datesAreDifferent.apply(undefined, _toConsumableArray(values.map(function (value) { | ||
}))) || datesAreDifferent.apply(void 0, _toConsumableArray(values.map(function (value) { | ||
return getDetailValueTo(value, minDate, maxDate, maxDetail); | ||
@@ -595,2 +601,3 @@ })))) { | ||
} | ||
nextState.value = nextValue; | ||
@@ -607,4 +614,2 @@ } | ||
exports.default = DateInput; | ||
DateInput.defaultProps = { | ||
@@ -615,19 +620,17 @@ maxDetail: 'month', | ||
}; | ||
DateInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
isCalendarOpen: _propTypes2.default.bool, | ||
locale: _propTypes2.default.string, | ||
maxDate: _propTypes3.isMaxDate, | ||
maxDetail: _propTypes2.default.oneOf(allViews), | ||
minDate: _propTypes3.isMinDate, | ||
name: _propTypes2.default.string, | ||
onChange: _propTypes2.default.func, | ||
returnValue: _propTypes2.default.oneOf(['start', 'end', 'range']), | ||
required: _propTypes2.default.bool, | ||
showLeadingZeros: _propTypes2.default.bool, | ||
value: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.instanceOf(Date)]) | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
isCalendarOpen: _propTypes.default.bool, | ||
locale: _propTypes.default.string, | ||
maxDate: _propTypes2.isMaxDate, | ||
maxDetail: _propTypes.default.oneOf(allViews), | ||
minDate: _propTypes2.isMinDate, | ||
name: _propTypes.default.string, | ||
onChange: _propTypes.default.func, | ||
returnValue: _propTypes.default.oneOf(['start', 'end', 'range']), | ||
required: _propTypes.default.bool, | ||
showLeadingZeros: _propTypes.default.bool, | ||
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.instanceOf(Date)]) | ||
}; | ||
(0, _reactLifecyclesCompat.polyfill)(DateInput); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,31 +6,38 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _propTypes = require('prop-types'); | ||
var _dates = require("../shared/dates"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _propTypes2 = require("../shared/propTypes"); | ||
var _mergeClassNames = require('merge-class-names'); | ||
var _utils = require("../shared/utils"); | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _dates = require('../shared/dates'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _propTypes3 = require('../shared/propTypes'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _utils = require('../shared/utils'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var select = function select(element) { | ||
@@ -40,3 +47,5 @@ return element && element.select(); | ||
var DayInput = function (_PureComponent) { | ||
var DayInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(DayInput, _PureComponent); | ||
@@ -47,31 +56,28 @@ | ||
return _possibleConstructorReturn(this, (DayInput.__proto__ || Object.getPrototypeOf(DayInput)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(DayInput).apply(this, arguments)); | ||
} | ||
_createClass(DayInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxDay = this.maxDay, | ||
minDay = this.minDay; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
value = _props.value, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
showLeadingZeros = _props.showLeadingZeros; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
value = _this$props.value, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
showLeadingZeros = _this$props.showLeadingZeros; | ||
var name = 'day'; | ||
var hasLeadingZero = showLeadingZeros && value !== null && value < 10; | ||
return [hasLeadingZero && _react2.default.createElement( | ||
'span', | ||
{ key: 'leadingZero', className: className + '__leadingZero' }, | ||
'0' | ||
), _react2.default.createElement('input', { | ||
key: 'day', | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__day', hasLeadingZero && className + '__input--hasLeadingZero'), | ||
return [hasLeadingZero && _react.default.createElement("span", { | ||
key: "leadingZero", | ||
className: "".concat(className, "__leadingZero") | ||
}, "0"), _react.default.createElement("input", { | ||
key: "day", | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__day"), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), | ||
disabled: disabled, | ||
@@ -89,3 +95,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -101,3 +107,3 @@ if (_ref) { | ||
required: required, | ||
type: 'number', | ||
type: "number", | ||
value: value !== null ? value : '' | ||
@@ -107,9 +113,8 @@ })]; | ||
}, { | ||
key: 'currentMonthMaxDays', | ||
key: "currentMonthMaxDays", | ||
get: function get() { | ||
var _props2 = this.props, | ||
year = _props2.year, | ||
month = _props2.month; | ||
var _this$props2 = this.props, | ||
year = _this$props2.year, | ||
month = _this$props2.month; | ||
if (!month) { | ||
@@ -122,19 +127,17 @@ return 31; | ||
}, { | ||
key: 'maxDay', | ||
key: "maxDay", | ||
get: function get() { | ||
var _props3 = this.props, | ||
maxDate = _props3.maxDate, | ||
month = _props3.month, | ||
year = _props3.year; | ||
var _this$props3 = this.props, | ||
maxDate = _this$props3.maxDate, | ||
month = _this$props3.month, | ||
year = _this$props3.year; | ||
return (0, _utils.min)(this.currentMonthMaxDays, maxDate && year === (0, _dates.getYear)(maxDate) && month === (0, _dates.getMonth)(maxDate) && (0, _dates.getDay)(maxDate)); | ||
} | ||
}, { | ||
key: 'minDay', | ||
key: "minDay", | ||
get: function get() { | ||
var _props4 = this.props, | ||
minDate = _props4.minDate, | ||
month = _props4.month, | ||
year = _props4.year; | ||
var _this$props4 = this.props, | ||
minDate = _this$props4.minDate, | ||
month = _this$props4.month, | ||
year = _this$props4.year; | ||
return (0, _utils.max)(1, minDate && year === (0, _dates.getYear)(minDate) && month === (0, _dates.getMonth)(minDate) && (0, _dates.getDay)(minDate)); | ||
@@ -148,17 +151,15 @@ } | ||
exports.default = DayInput; | ||
DayInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
maxDate: _propTypes3.isMaxDate, | ||
minDate: _propTypes3.isMinDate, | ||
month: _propTypes2.default.number, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
showLeadingZeros: _propTypes2.default.bool, | ||
value: _propTypes2.default.number, | ||
year: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
maxDate: _propTypes2.isMaxDate, | ||
minDate: _propTypes2.isMinDate, | ||
month: _propTypes.default.number, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
showLeadingZeros: _propTypes.default.bool, | ||
value: _propTypes.default.number, | ||
year: _propTypes.default.number | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,31 +6,38 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _propTypes = require('prop-types'); | ||
var _dates = require("../shared/dates"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _propTypes2 = require("../shared/propTypes"); | ||
var _mergeClassNames = require('merge-class-names'); | ||
var _utils = require("../shared/utils"); | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _dates = require('../shared/dates'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _propTypes3 = require('../shared/propTypes'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _utils = require('../shared/utils'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var select = function select(element) { | ||
@@ -40,3 +47,5 @@ return element && element.select(); | ||
var MonthInput = function (_PureComponent) { | ||
var MonthInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(MonthInput, _PureComponent); | ||
@@ -47,31 +56,28 @@ | ||
return _possibleConstructorReturn(this, (MonthInput.__proto__ || Object.getPrototypeOf(MonthInput)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(MonthInput).apply(this, arguments)); | ||
} | ||
_createClass(MonthInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxMonth = this.maxMonth, | ||
minMonth = this.minMonth; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
value = _props.value, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
showLeadingZeros = _props.showLeadingZeros; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
value = _this$props.value, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
showLeadingZeros = _this$props.showLeadingZeros; | ||
var name = 'month'; | ||
var hasLeadingZero = showLeadingZeros && value !== null && value < 10; | ||
return [hasLeadingZero && _react2.default.createElement( | ||
'span', | ||
{ key: 'leadingZero', className: className + '__leadingZero' }, | ||
'0' | ||
), _react2.default.createElement('input', { | ||
key: 'month', | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__month', hasLeadingZero && className + '__input--hasLeadingZero'), | ||
return [hasLeadingZero && _react.default.createElement("span", { | ||
key: "leadingZero", | ||
className: "".concat(className, "__leadingZero") | ||
}, "0"), _react.default.createElement("input", { | ||
key: "month", | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__month"), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), | ||
disabled: disabled, | ||
@@ -89,3 +95,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -100,3 +106,3 @@ if (_ref) { | ||
}, | ||
type: 'number', | ||
type: "number", | ||
required: required, | ||
@@ -107,17 +113,15 @@ value: value !== null ? value : '' | ||
}, { | ||
key: 'maxMonth', | ||
key: "maxMonth", | ||
get: function get() { | ||
var _props2 = this.props, | ||
maxDate = _props2.maxDate, | ||
year = _props2.year; | ||
var _this$props2 = this.props, | ||
maxDate = _this$props2.maxDate, | ||
year = _this$props2.year; | ||
return (0, _utils.min)(12, maxDate && year === (0, _dates.getYear)(maxDate) && (0, _dates.getMonth)(maxDate)); | ||
} | ||
}, { | ||
key: 'minMonth', | ||
key: "minMonth", | ||
get: function get() { | ||
var _props3 = this.props, | ||
minDate = _props3.minDate, | ||
year = _props3.year; | ||
var _this$props3 = this.props, | ||
minDate = _this$props3.minDate, | ||
year = _this$props3.year; | ||
return (0, _utils.max)(1, minDate && year === (0, _dates.getYear)(minDate) && (0, _dates.getMonth)(minDate)); | ||
@@ -131,16 +135,14 @@ } | ||
exports.default = MonthInput; | ||
MonthInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
maxDate: _propTypes3.isMaxDate, | ||
minDate: _propTypes3.isMinDate, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
showLeadingZeros: _propTypes2.default.bool, | ||
value: _propTypes2.default.number, | ||
year: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
maxDate: _propTypes2.isMaxDate, | ||
minDate: _propTypes2.isMinDate, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
showLeadingZeros: _propTypes.default.bool, | ||
value: _propTypes.default.number, | ||
year: _propTypes.default.number | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,59 +6,74 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _dates = require("../shared/dates"); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = require("../shared/propTypes"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _dates = require('../shared/dates'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _propTypes3 = require('../shared/propTypes'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var NativeInput = function (_PureComponent) { | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var NativeInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(NativeInput, _PureComponent); | ||
function NativeInput() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, NativeInput); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = NativeInput.__proto__ || Object.getPrototypeOf(NativeInput)).call.apply(_ref, [this].concat(args))), _this), _this.stopPropagation = function (event) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(NativeInput)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "stopPropagation", function (event) { | ||
return event.stopPropagation(); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(NativeInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var nativeValueParser = this.nativeValueParser; | ||
var _props = this.props, | ||
disabled = _props.disabled, | ||
maxDate = _props.maxDate, | ||
minDate = _props.minDate, | ||
name = _props.name, | ||
onChange = _props.onChange, | ||
required = _props.required, | ||
value = _props.value; | ||
return _react2.default.createElement('input', { | ||
var _this$props = this.props, | ||
disabled = _this$props.disabled, | ||
maxDate = _this$props.maxDate, | ||
minDate = _this$props.minDate, | ||
name = _this$props.name, | ||
onChange = _this$props.onChange, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
return _react.default.createElement("input", { | ||
type: this.nativeInputType, | ||
@@ -82,7 +97,6 @@ disabled: disabled, | ||
}, { | ||
key: 'nativeInputType', | ||
key: "nativeInputType", | ||
get: function get() { | ||
var valueType = this.props.valueType; | ||
switch (valueType) { | ||
@@ -92,6 +106,9 @@ case 'decade': | ||
return 'number'; | ||
case 'month': | ||
return 'month'; | ||
case 'day': | ||
return 'date'; | ||
default: | ||
@@ -102,7 +119,6 @@ throw new Error('Invalid valueType.'); | ||
}, { | ||
key: 'nativeValueParser', | ||
key: "nativeValueParser", | ||
get: function get() { | ||
var valueType = this.props.valueType; | ||
switch (valueType) { | ||
@@ -113,6 +129,9 @@ case 'century': | ||
return _dates.getYear; | ||
case 'month': | ||
return _dates.getISOLocalMonth; | ||
case 'day': | ||
return _dates.getISOLocalDate; | ||
default: | ||
@@ -128,13 +147,11 @@ throw new Error('Invalid valueType.'); | ||
exports.default = NativeInput; | ||
NativeInput.propTypes = { | ||
disabled: _propTypes2.default.bool, | ||
maxDate: _propTypes3.isMaxDate, | ||
minDate: _propTypes3.isMinDate, | ||
name: _propTypes2.default.string, | ||
onChange: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.instanceOf(Date)]), | ||
valueType: _propTypes3.isValueType | ||
disabled: _propTypes.default.bool, | ||
maxDate: _propTypes2.isMaxDate, | ||
minDate: _propTypes2.isMinDate, | ||
name: _propTypes.default.string, | ||
onChange: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.instanceOf(Date)]), | ||
valueType: _propTypes2.isValueType | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,31 +6,38 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _propTypes = require('prop-types'); | ||
var _dates = require("../shared/dates"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _propTypes2 = require("../shared/propTypes"); | ||
var _mergeClassNames = require('merge-class-names'); | ||
var _utils = require("../shared/utils"); | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _dates = require('../shared/dates'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _propTypes3 = require('../shared/propTypes'); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _utils = require('../shared/utils'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var select = function select(element) { | ||
@@ -40,3 +47,5 @@ return element && element.select(); | ||
var YearInput = function (_PureComponent) { | ||
var YearInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(YearInput, _PureComponent); | ||
@@ -47,7 +56,7 @@ | ||
return _possibleConstructorReturn(this, (YearInput.__proto__ || Object.getPrototypeOf(YearInput)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(YearInput).apply(this, arguments)); | ||
} | ||
_createClass(YearInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
@@ -57,16 +66,14 @@ var maxYear = this.maxYear, | ||
yearStep = this.yearStep; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
value = _props.value, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
value = _this$props.value, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required; | ||
var name = 'year'; | ||
return _react2.default.createElement('input', { | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__year'), | ||
return _react.default.createElement("input", { | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__year")), | ||
disabled: disabled, | ||
@@ -84,3 +91,3 @@ name: name, | ||
}, | ||
placeholder: '----', | ||
placeholder: "----", | ||
ref: function ref(_ref) { | ||
@@ -97,3 +104,3 @@ if (_ref) { | ||
step: yearStep, | ||
type: 'number', | ||
type: "number", | ||
value: value !== null ? value : '' | ||
@@ -103,24 +110,22 @@ }); | ||
}, { | ||
key: 'maxYear', | ||
key: "maxYear", | ||
get: function get() { | ||
var maxDate = this.props.maxDate; | ||
return (0, _utils.min)(275760, maxDate && (0, _dates.getYear)(maxDate)); | ||
} | ||
}, { | ||
key: 'minYear', | ||
key: "minYear", | ||
get: function get() { | ||
var minDate = this.props.minDate; | ||
return (0, _utils.max)(1000, minDate && (0, _dates.getYear)(minDate)); | ||
} | ||
}, { | ||
key: 'yearStep', | ||
key: "yearStep", | ||
get: function get() { | ||
var valueType = this.props.valueType; | ||
if (valueType === 'century') { | ||
return 10; | ||
} | ||
return 1; | ||
@@ -134,15 +139,13 @@ } | ||
exports.default = YearInput; | ||
YearInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
maxDate: _propTypes3.isMaxDate, | ||
minDate: _propTypes3.isMinDate, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.number, | ||
valueType: _propTypes3.isValueType | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
maxDate: _propTypes2.isMaxDate, | ||
minDate: _propTypes2.isMinDate, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.number, | ||
valueType: _propTypes2.isValueType | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,68 +6,95 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
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 = _interopRequireWildcard(require("react")); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _reactLifecyclesCompat = require("react-lifecycles-compat"); | ||
var _react = require('react'); | ||
var _makeEventProps = _interopRequireDefault(require("make-event-props")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _propTypes = require('prop-types'); | ||
var _detectElementOverflow = _interopRequireDefault(require("detect-element-overflow")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _entry = _interopRequireDefault(require("react-calendar/dist/entry.nostyle")); | ||
var _reactLifecyclesCompat = require('react-lifecycles-compat'); | ||
var _DateInput = _interopRequireDefault(require("./DateInput")); | ||
var _makeEventProps = require('make-event-props'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _makeEventProps2 = _interopRequireDefault(_makeEventProps); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _mergeClassNames = require('merge-class-names'); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _detectElementOverflow = require('detect-element-overflow'); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _detectElementOverflow2 = _interopRequireDefault(_detectElementOverflow); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
var _entry = require('react-calendar/dist/entry.nostyle'); | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var _entry2 = _interopRequireDefault(_entry); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
var _DateInput = require('./DateInput'); | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
var _DateInput2 = _interopRequireDefault(_DateInput); | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var baseClassName = 'react-date-picker'; | ||
var DatePicker = function (_PureComponent) { | ||
var DatePicker = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(DatePicker, _PureComponent); | ||
function DatePicker() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, DatePicker); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DatePicker.__proto__ || Object.getPrototypeOf(DatePicker)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this.openCalendar = function () { | ||
_this.setState({ isOpen: true }); | ||
}, _this.closeCalendar = function () { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DatePicker)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onOutsideAction", function (event) { | ||
if (_this.wrapper && !_this.wrapper.contains(event.target)) { | ||
_this.closeCalendar(); | ||
} | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openCalendar", function () { | ||
_this.setState({ | ||
isOpen: true | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closeCalendar", function () { | ||
_this.setState(function (prevState) { | ||
@@ -78,9 +105,17 @@ if (!prevState.isOpen) { | ||
return { isOpen: false }; | ||
return { | ||
isOpen: false | ||
}; | ||
}); | ||
}, _this.toggleCalendar = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "toggleCalendar", function () { | ||
_this.setState(function (prevState) { | ||
return { isOpen: !prevState.isOpen }; | ||
return { | ||
isOpen: !prevState.isOpen | ||
}; | ||
}); | ||
}, _this.onChange = function (value) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (value) { | ||
var closeCalendar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
@@ -97,3 +132,5 @@ | ||
} | ||
}, _this.onFocus = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onFocus", function (event) { | ||
var _this$props = _this.props, | ||
@@ -103,8 +140,7 @@ disabled = _this$props.disabled, | ||
if (onFocus) { | ||
onFocus(event); | ||
} | ||
} // Internet Explorer still fires onFocus on disabled elements | ||
// Internet Explorer still fires onFocus on disabled elements | ||
if (disabled) { | ||
@@ -115,40 +151,43 @@ return; | ||
_this.openCalendar(); | ||
}, _this.onBlur = function () { | ||
var onBlur = _this.props.onBlur; | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "stopPropagation", function (event) { | ||
return event.stopPropagation(); | ||
}); | ||
if (onBlur) { | ||
onBlur(event); | ||
} | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "clear", function () { | ||
return _this.onChange(null); | ||
}); | ||
requestAnimationFrame(function () { | ||
var stillHasFocus = _this.wrapper.querySelector(':focus'); | ||
if (!stillHasFocus) { | ||
_this.closeCalendar(); | ||
} | ||
}); | ||
}, _this.stopPropagation = function (event) { | ||
return event.stopPropagation(); | ||
}, _this.clear = function () { | ||
return _this.onChange(null); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return _this; | ||
} | ||
_createClass(DatePicker, [{ | ||
key: 'renderInputs', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
document.addEventListener('mousedown', this.onOutsideAction); | ||
document.addEventListener('focusin', this.onOutsideAction); | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
document.removeEventListener('mousedown', this.onOutsideAction); | ||
document.removeEventListener('focusin', this.onOutsideAction); | ||
} | ||
}, { | ||
key: "renderInputs", | ||
value: function renderInputs() { | ||
var _props = this.props, | ||
calendarIcon = _props.calendarIcon, | ||
clearIcon = _props.clearIcon, | ||
disabled = _props.disabled, | ||
locale = _props.locale, | ||
maxDate = _props.maxDate, | ||
maxDetail = _props.maxDetail, | ||
minDate = _props.minDate, | ||
name = _props.name, | ||
returnValue = _props.returnValue, | ||
required = _props.required, | ||
showLeadingZeros = _props.showLeadingZeros, | ||
value = _props.value; | ||
var _this$props2 = this.props, | ||
calendarIcon = _this$props2.calendarIcon, | ||
clearIcon = _this$props2.clearIcon, | ||
disabled = _this$props2.disabled, | ||
locale = _this$props2.locale, | ||
maxDate = _this$props2.maxDate, | ||
maxDetail = _this$props2.maxDetail, | ||
minDate = _this$props2.minDate, | ||
name = _this$props2.name, | ||
returnValue = _this$props2.returnValue, | ||
required = _this$props2.required, | ||
showLeadingZeros = _this$props2.showLeadingZeros, | ||
value = _this$props2.value; | ||
var isOpen = this.state.isOpen; | ||
@@ -160,47 +199,35 @@ | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: baseClassName + '__wrapper' }, | ||
_react2.default.createElement(_DateInput2.default, { | ||
className: baseClassName + '__inputGroup', | ||
disabled: disabled, | ||
locale: locale, | ||
isCalendarOpen: isOpen, | ||
maxDate: maxDate, | ||
maxDetail: maxDetail, | ||
minDate: minDate, | ||
name: name, | ||
onChange: this.onChange, | ||
returnValue: returnValue, | ||
required: required, | ||
showLeadingZeros: showLeadingZeros, | ||
value: valueFrom | ||
}), | ||
clearIcon !== null && _react2.default.createElement( | ||
'button', | ||
{ | ||
className: baseClassName + '__clear-button ' + baseClassName + '__button', | ||
disabled: disabled, | ||
onClick: this.clear, | ||
onFocus: this.stopPropagation, | ||
type: 'button' | ||
}, | ||
clearIcon | ||
), | ||
calendarIcon !== null && _react2.default.createElement( | ||
'button', | ||
{ | ||
className: baseClassName + '__calendar-button ' + baseClassName + '__button', | ||
disabled: disabled, | ||
onClick: this.toggleCalendar, | ||
onFocus: this.stopPropagation, | ||
onBlur: this.resetValue, | ||
type: 'button' | ||
}, | ||
calendarIcon | ||
) | ||
); | ||
return _react.default.createElement("div", { | ||
className: "".concat(baseClassName, "__wrapper") | ||
}, _react.default.createElement(_DateInput.default, { | ||
className: "".concat(baseClassName, "__inputGroup"), | ||
disabled: disabled, | ||
locale: locale, | ||
isCalendarOpen: isOpen, | ||
maxDate: maxDate, | ||
maxDetail: maxDetail, | ||
minDate: minDate, | ||
name: name, | ||
onChange: this.onChange, | ||
returnValue: returnValue, | ||
required: required, | ||
showLeadingZeros: showLeadingZeros, | ||
value: valueFrom | ||
}), clearIcon !== null && _react.default.createElement("button", { | ||
className: "".concat(baseClassName, "__clear-button ").concat(baseClassName, "__button"), | ||
disabled: disabled, | ||
onClick: this.clear, | ||
onFocus: this.stopPropagation, | ||
type: "button" | ||
}, clearIcon), calendarIcon !== null && _react.default.createElement("button", { | ||
className: "".concat(baseClassName, "__calendar-button ").concat(baseClassName, "__button"), | ||
disabled: disabled, | ||
onClick: this.toggleCalendar, | ||
onFocus: this.stopPropagation, | ||
onBlur: this.resetValue, | ||
type: "button" | ||
}, calendarIcon)); | ||
} | ||
}, { | ||
key: 'renderCalendar', | ||
key: "renderCalendar", | ||
value: function renderCalendar() { | ||
@@ -211,3 +238,2 @@ var _this2 = this; | ||
if (isOpen === null) { | ||
@@ -217,78 +243,64 @@ return null; | ||
var _props2 = this.props, | ||
calendarClassName = _props2.calendarClassName, | ||
datePickerClassName = _props2.className, | ||
onChange = _props2.onChange, | ||
value = _props2.value, | ||
calendarProps = _objectWithoutProperties(_props2, ['calendarClassName', 'className', 'onChange', 'value']); | ||
var _this$props3 = this.props, | ||
calendarClassName = _this$props3.calendarClassName, | ||
datePickerClassName = _this$props3.className, | ||
onChange = _this$props3.onChange, | ||
value = _this$props3.value, | ||
calendarProps = _objectWithoutProperties(_this$props3, ["calendarClassName", "className", "onChange", "value"]); | ||
var className = baseClassName + '__calendar'; | ||
var className = "".concat(baseClassName, "__calendar"); | ||
return _react.default.createElement("div", { | ||
className: (0, _mergeClassNames.default)(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed')), | ||
ref: function ref(_ref) { | ||
if (!_ref || !isOpen) { | ||
return; | ||
} | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
className: (0, _mergeClassNames2.default)(className, className + '--' + (isOpen ? 'open' : 'closed')), | ||
ref: function ref(_ref2) { | ||
if (!_ref2 || !isOpen) { | ||
return; | ||
} | ||
_ref.classList.remove("".concat(className, "--above-label")); | ||
_ref2.classList.remove(className + '--above-label'); | ||
var collisions = (0, _detectElementOverflow.default)(_ref, document.body); | ||
var collisions = (0, _detectElementOverflow2.default)(_ref2, document.body); | ||
if (collisions.collidedBottom) { | ||
var overflowTopAfterChange = collisions.overflowTop + _ref.clientHeight + _this2.wrapper.clientHeight; // If it's going to make situation any better, display the calendar above the input | ||
if (collisions.collidedBottom) { | ||
var overflowTopAfterChange = collisions.overflowTop + _ref2.clientHeight + _this2.wrapper.clientHeight; | ||
// If it's going to make situation any better, display the calendar above the input | ||
if (overflowTopAfterChange < collisions.overflowBottom) { | ||
_ref2.classList.add(className + '--above-label'); | ||
} | ||
if (overflowTopAfterChange < collisions.overflowBottom) { | ||
_ref.classList.add("".concat(className, "--above-label")); | ||
} | ||
} | ||
}, | ||
_react2.default.createElement(_entry2.default, _extends({ | ||
className: calendarClassName, | ||
onChange: this.onChange, | ||
value: value || null | ||
}, calendarProps)) | ||
); | ||
} | ||
}, _react.default.createElement(_entry.default, _extends({ | ||
className: calendarClassName, | ||
onChange: this.onChange, | ||
value: value || null | ||
}, calendarProps))); | ||
} | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _this3 = this; | ||
var _props3 = this.props, | ||
className = _props3.className, | ||
disabled = _props3.disabled; | ||
var _this$props4 = this.props, | ||
className = _this$props4.className, | ||
disabled = _this$props4.disabled; | ||
var isOpen = this.state.isOpen; | ||
return _react.default.createElement("div", _extends({ | ||
className: (0, _mergeClassNames.default)(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className) | ||
}, this.eventProps, { | ||
onFocus: this.onFocus, | ||
ref: function ref(_ref2) { | ||
if (!_ref2) { | ||
return; | ||
} | ||
return _react2.default.createElement( | ||
'div', | ||
_extends({ | ||
className: (0, _mergeClassNames2.default)(baseClassName, baseClassName + '--' + (isOpen ? 'open' : 'closed'), baseClassName + '--' + (disabled ? 'disabled' : 'enabled'), className) | ||
}, this.eventProps, { | ||
onFocus: this.onFocus, | ||
onBlur: this.onBlur, | ||
ref: function ref(_ref3) { | ||
if (!_ref3) { | ||
return; | ||
} | ||
_this3.wrapper = _ref3; | ||
} | ||
}), | ||
this.renderInputs(), | ||
this.renderCalendar() | ||
); | ||
_this3.wrapper = _ref2; | ||
} | ||
}), this.renderInputs(), this.renderCalendar()); | ||
} | ||
}, { | ||
key: 'eventProps', | ||
key: "eventProps", | ||
get: function get() { | ||
return (0, _makeEventProps2.default)(this.props); | ||
return (0, _makeEventProps.default)(this.props); | ||
} | ||
}], [{ | ||
key: 'getDerivedStateFromProps', | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(nextProps, prevState) { | ||
@@ -311,26 +323,48 @@ if (nextProps.isOpen !== prevState.isOpenProps) { | ||
var CalendarIcon = _react.default.createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
width: "19", | ||
height: "19", | ||
viewBox: "0 0 19 19" | ||
}, _react.default.createElement("g", { | ||
stroke: "black", | ||
strokeWidth: "2" | ||
}, _react.default.createElement("rect", { | ||
width: "15", | ||
height: "15", | ||
x: "2", | ||
y: "2", | ||
fill: "none" | ||
}), _react.default.createElement("line", { | ||
x1: "6", | ||
y1: "0", | ||
x2: "6", | ||
y2: "4" | ||
}), _react.default.createElement("line", { | ||
x1: "13", | ||
y1: "0", | ||
x2: "13", | ||
y2: "4" | ||
}))); | ||
var CalendarIcon = _react2.default.createElement( | ||
'svg', | ||
{ xmlns: 'http://www.w3.org/2000/svg', width: '19', height: '19', viewBox: '0 0 19 19' }, | ||
_react2.default.createElement( | ||
'g', | ||
{ stroke: 'black', strokeWidth: '2' }, | ||
_react2.default.createElement('rect', { width: '15', height: '15', x: '2', y: '2', fill: 'none' }), | ||
_react2.default.createElement('line', { x1: '6', y1: '0', x2: '6', y2: '4' }), | ||
_react2.default.createElement('line', { x1: '13', y1: '0', x2: '13', y2: '4' }) | ||
) | ||
); | ||
var ClearIcon = _react.default.createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
width: "19", | ||
height: "19", | ||
viewBox: "0 0 19 19" | ||
}, _react.default.createElement("g", { | ||
stroke: "black", | ||
strokeWidth: "2" | ||
}, _react.default.createElement("line", { | ||
x1: "4", | ||
y1: "4", | ||
x2: "15", | ||
y2: "15" | ||
}), _react.default.createElement("line", { | ||
x1: "15", | ||
y1: "4", | ||
x2: "4", | ||
y2: "15" | ||
}))); | ||
var ClearIcon = _react2.default.createElement( | ||
'svg', | ||
{ xmlns: 'http://www.w3.org/2000/svg', width: '19', height: '19', viewBox: '0 0 19 19' }, | ||
_react2.default.createElement( | ||
'g', | ||
{ stroke: 'black', strokeWidth: '2' }, | ||
_react2.default.createElement('line', { x1: '4', y1: '4', x2: '15', y2: '15' }), | ||
_react2.default.createElement('line', { x1: '15', y1: '4', x2: '4', y2: '15' }) | ||
) | ||
); | ||
DatePicker.defaultProps = { | ||
@@ -342,16 +376,14 @@ calendarIcon: CalendarIcon, | ||
}; | ||
DatePicker.propTypes = _extends({}, _entry2.default.propTypes, { | ||
calendarClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]), | ||
calendarIcon: _propTypes2.default.node, | ||
className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]), | ||
clearIcon: _propTypes2.default.node, | ||
disabled: _propTypes2.default.bool, | ||
isOpen: _propTypes2.default.bool, | ||
name: _propTypes2.default.string, | ||
returnValue: _propTypes2.default.oneOf(['start', 'end', 'range']), | ||
required: _propTypes2.default.bool, | ||
showLeadingZeros: _propTypes2.default.bool | ||
DatePicker.propTypes = _objectSpread({}, _entry.default.propTypes, { | ||
calendarClassName: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]), | ||
calendarIcon: _propTypes.default.node, | ||
className: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]), | ||
clearIcon: _propTypes.default.node, | ||
disabled: _propTypes.default.bool, | ||
isOpen: _propTypes.default.bool, | ||
name: _propTypes.default.string, | ||
returnValue: _propTypes.default.oneOf(['start', 'end', 'range']), | ||
required: _propTypes.default.bool, | ||
showLeadingZeros: _propTypes.default.bool | ||
}); | ||
(0, _reactLifecyclesCompat.polyfill)(DatePicker); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _react = require('react'); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,13 +17,11 @@ | ||
var children = _ref.children; | ||
return _react2.default.createElement( | ||
'span', | ||
{ className: 'react-date-picker__inputGroup__divider' }, | ||
children | ||
); | ||
return _react.default.createElement("span", { | ||
className: "react-date-picker__inputGroup__divider" | ||
}, children); | ||
}; | ||
Divider.propTypes = { | ||
children: _propTypes2.default.node | ||
children: _propTypes.default.node | ||
}; | ||
exports.default = Divider; | ||
var _default = Divider; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,16 +6,15 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
require('react-calendar/dist/Calendar.css'); | ||
require("react-calendar/dist/Calendar.css"); | ||
var _DatePicker = require('./DatePicker'); | ||
var _DatePicker = _interopRequireDefault(require("./DatePicker")); | ||
var _DatePicker2 = _interopRequireDefault(_DatePicker); | ||
require("./DatePicker.css"); | ||
require('./DatePicker.css'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _DatePicker2.default; | ||
// File is created during build phase and placed in dist directory | ||
// eslint-disable-next-line import/no-unresolved | ||
// eslint-disable-next-line import/no-unresolved | ||
var _default = _DatePicker.default; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _DatePicker = require('./DatePicker'); | ||
var _DatePicker = _interopRequireDefault(require("./DatePicker")); | ||
var _DatePicker2 = _interopRequireDefault(_DatePicker); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _DatePicker2.default; | ||
var _default = _DatePicker.default; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,12 +6,9 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.getFormatter = undefined; | ||
exports.getFormatter = void 0; | ||
var _getUserLocale = require('get-user-locale'); | ||
var _getUserLocale = _interopRequireDefault(require("get-user-locale")); | ||
var _getUserLocale2 = _interopRequireDefault(_getUserLocale); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var formatterCache = {}; | ||
/* eslint-disable import/prefer-default-export */ | ||
@@ -23,7 +20,8 @@ | ||
*/ | ||
var getFormatter = exports.getFormatter = function getFormatter(options, locale) { | ||
var getFormatter = function getFormatter(locale, options) { | ||
if (!locale) { | ||
// Default parameter is not enough as it does not protect us from null values | ||
// eslint-disable-next-line no-param-reassign | ||
locale = (0, _getUserLocale2.default)(); | ||
locale = (0, _getUserLocale.default)(); | ||
} | ||
@@ -38,6 +36,10 @@ | ||
if (!formatterCache[locale][stringifiedOptions]) { | ||
formatterCache[locale][stringifiedOptions] = new Intl.DateTimeFormat(locale, options).format; | ||
formatterCache[locale][stringifiedOptions] = function (n) { | ||
return n.toLocaleString(locale, options); | ||
}; | ||
} | ||
return formatterCache[locale][stringifiedOptions]; | ||
}; | ||
}; | ||
exports.getFormatter = getFormatter; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var _dates = require('react-calendar/dist/shared/dates'); | ||
Object.defineProperty(exports, 'getYear', { | ||
Object.defineProperty(exports, "getYear", { | ||
enumerable: true, | ||
@@ -16,3 +13,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getMonth', { | ||
Object.defineProperty(exports, "getMonth", { | ||
enumerable: true, | ||
@@ -23,3 +20,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getMonthIndex', { | ||
Object.defineProperty(exports, "getMonthIndex", { | ||
enumerable: true, | ||
@@ -30,3 +27,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getDay', { | ||
Object.defineProperty(exports, "getDay", { | ||
enumerable: true, | ||
@@ -37,3 +34,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getDaysInMonth', { | ||
Object.defineProperty(exports, "getDaysInMonth", { | ||
enumerable: true, | ||
@@ -44,3 +41,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getBegin', { | ||
Object.defineProperty(exports, "getBegin", { | ||
enumerable: true, | ||
@@ -51,3 +48,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getEnd', { | ||
Object.defineProperty(exports, "getEnd", { | ||
enumerable: true, | ||
@@ -58,3 +55,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getISOLocalMonth', { | ||
Object.defineProperty(exports, "getISOLocalMonth", { | ||
enumerable: true, | ||
@@ -65,3 +62,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, 'getISOLocalDate', { | ||
Object.defineProperty(exports, "getISOLocalDate", { | ||
enumerable: true, | ||
@@ -71,2 +68,4 @@ get: function get() { | ||
} | ||
}); | ||
}); | ||
var _dates = require("react-calendar/dist/shared/dates"); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,30 +6,35 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.isValueType = exports.isMinDate = exports.isMaxDate = undefined; | ||
var _propTypes = require('react-calendar/dist/shared/propTypes'); | ||
Object.defineProperty(exports, 'isMaxDate', { | ||
Object.defineProperty(exports, "isMaxDate", { | ||
enumerable: true, | ||
get: function get() { | ||
return _propTypes.isMaxDate; | ||
return _propTypes2.isMaxDate; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'isMinDate', { | ||
Object.defineProperty(exports, "isMinDate", { | ||
enumerable: true, | ||
get: function get() { | ||
return _propTypes.isMinDate; | ||
return _propTypes2.isMinDate; | ||
} | ||
}); | ||
exports.isValueType = void 0; | ||
var _propTypes2 = require('prop-types'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes3 = _interopRequireDefault(_propTypes2); | ||
var _propTypes2 = require("react-calendar/dist/shared/propTypes"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
var allViews = ['century', 'decade', 'year', 'month']; | ||
var allValueTypes = [].concat(_toConsumableArray(allViews.slice(1)), ['day']); | ||
var isValueType = exports.isValueType = _propTypes3.default.oneOf(allValueTypes); | ||
var isValueType = _propTypes.default.oneOf(allValueTypes); | ||
exports.isValueType = isValueType; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var _utils = require('react-calendar/dist/shared/utils'); | ||
Object.defineProperty(exports, 'between', { | ||
Object.defineProperty(exports, "between", { | ||
enumerable: true, | ||
@@ -16,5 +13,14 @@ get: function get() { | ||
}); | ||
exports.updateInputWidth = exports.max = exports.min = void 0; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var _utils = require("react-calendar/dist/shared/utils"); | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
var isValidNumber = function isValidNumber(a) { | ||
@@ -24,4 +30,4 @@ return typeof a === 'number' && !isNaN(a); | ||
var min = exports.min = function min() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
var min = function min() { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
@@ -32,4 +38,7 @@ } | ||
}; | ||
var max = exports.max = function max() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
exports.min = min; | ||
var max = function max() { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
@@ -41,8 +50,8 @@ } | ||
var updateInputWidth = exports.updateInputWidth = function updateInputWidth(element) { | ||
exports.max = max; | ||
var updateInputWidth = function updateInputWidth(element) { | ||
var span = document.createElement('span'); | ||
span.innerHTML = element.value || element.placeholder; | ||
var container = element.parentElement; | ||
container.appendChild(span); | ||
@@ -53,5 +62,6 @@ | ||
element.style.width = Math.ceil(width) + 'px'; | ||
element.style.width = "".concat(Math.ceil(width), "px"); | ||
container.removeChild(span); | ||
}; | ||
container.removeChild(span); | ||
}; | ||
exports.updateInputWidth = updateInputWidth; |
{ | ||
"name": "react-date-picker", | ||
"version": "7.1.1", | ||
"version": "7.2.0", | ||
"description": "A date picker for your React app.", | ||
"main": "dist/entry.js", | ||
"source": "src/entry.js", | ||
"types": "./index.d.ts", | ||
"es6": "src/entry.js", | ||
"scripts": { | ||
"build": "yarn run build-js && yarn run copy-styles && yarn run build-styles && yarn run copy-types", | ||
"build-js": "babel src -d dist --ignore __tests__", | ||
"build-js": "babel src -d dist --ignore **/__tests__", | ||
"build-styles": "lessc ./dist/DatePicker.less ./dist/DatePicker.css", | ||
@@ -74,17 +74,17 @@ "clean": "rimraf dist", | ||
"prop-types": "^15.6.0", | ||
"react-calendar": "^2.17.4", | ||
"react-calendar": "^2.18.0", | ||
"react-lifecycles-compat": "^3.0.4" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^9.0.0", | ||
"@babel/cli": "^7.1.0", | ||
"@babel/core": "^7.1.0", | ||
"@babel/plugin-proposal-class-properties": "^7.1.0", | ||
"@babel/preset-env": "^7.1.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "^10.0.0", | ||
"babel-jest": "^23.6.0", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-react": "^6.24.1", | ||
"enzyme": "^3.6.0", | ||
"enzyme-adapter-react-16": "^1.5.0", | ||
"eslint": "^5.5.0", | ||
"enzyme": "^3.8.0", | ||
"enzyme-adapter-react-16": "^1.7.1", | ||
"eslint": "^5.11.0", | ||
"eslint-config-airbnb": "^17.1.0", | ||
@@ -97,5 +97,5 @@ "eslint-plugin-import": "^2.14.0", | ||
"less": "^3.8.1", | ||
"react": "^16.5.0", | ||
"react-dom": "^16.5.0", | ||
"react-test-renderer": "^16.5.0", | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
"react-test-renderer": "^16.7.0", | ||
"rimraf": "^2.6.2" | ||
@@ -102,0 +102,0 @@ }, |
@@ -154,11 +154,31 @@ import React from 'react'; | ||
it('closes Calendar component when clicked outside', () => { | ||
const root = document.createElement('div'); | ||
document.body.appendChild(root); | ||
const component = mount( | ||
<DatePicker isOpen />, | ||
{ attachTo: root } | ||
); | ||
const event = document.createEvent('MouseEvent'); | ||
event.initEvent('mousedown', true, true); | ||
document.body.dispatchEvent(event); | ||
component.update(); | ||
expect(component.state('isOpen')).toBe(false); | ||
}); | ||
it('closes Calendar component when focused outside', () => { | ||
const root = document.createElement('div'); | ||
document.body.appendChild(root); | ||
const component = mount( | ||
<DatePicker isOpen /> | ||
<DatePicker isOpen />, | ||
{ attachTo: root } | ||
); | ||
const customInputs = component.find('input[type="number"]'); | ||
const dayInput = customInputs.at(0); | ||
dayInput.simulate('blur'); | ||
const event = document.createEvent('FocusEvent'); | ||
event.initEvent('focusin', true, true); | ||
document.body.dispatchEvent(event); | ||
component.update(); | ||
@@ -165,0 +185,0 @@ |
@@ -143,3 +143,3 @@ import React, { PureComponent } from 'react'; | ||
const res = [...arr, divider]; | ||
if (matches[index]) { | ||
if (matches && matches[index]) { | ||
res.push(elementFunctions[matches[index]]()); | ||
@@ -217,5 +217,13 @@ } | ||
return getFormatter(options, locale); | ||
return getFormatter(locale, options); | ||
} | ||
get formatNumber() { | ||
const { locale } = this.props; | ||
const options = { useGrouping: false }; | ||
return getFormatter(locale, options); | ||
} | ||
/** | ||
@@ -242,17 +250,19 @@ * Gets current value in a desired format. | ||
get divider() { | ||
const { locale } = this.props; | ||
const date = new Date(2017, 11, 11); | ||
return this.formatDate(date, locale).match(/[^0-9]/)[0]; | ||
return this.formatDate(date).match(/[^0-9]/)[0]; | ||
} | ||
get placeholder() { | ||
const { locale } = this.props; | ||
const date = new Date(2017, 11, 11); | ||
const year = 2017; | ||
const monthIndex = 11; | ||
const day = 11; | ||
const date = new Date(year, monthIndex, day); | ||
return ( | ||
this.formatDate(date, locale) | ||
.replace('2017', 'year') | ||
.replace('12', 'month') | ||
.replace('11', 'day') | ||
this.formatDate(date) | ||
.replace(this.formatNumber(year), 'year') | ||
.replace(this.formatNumber(monthIndex + 1), 'month') | ||
.replace(this.formatNumber(day), 'day') | ||
); | ||
@@ -259,0 +269,0 @@ } |
@@ -55,2 +55,3 @@ import React, { PureComponent } from 'react'; | ||
key="day" | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -57,0 +58,0 @@ `${className}__input`, |
@@ -38,2 +38,3 @@ import React, { PureComponent } from 'react'; | ||
key="month" | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -40,0 +41,0 @@ `${className}__input`, |
@@ -43,2 +43,3 @@ import React, { PureComponent } from 'react'; | ||
<input | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -45,0 +46,0 @@ `${className}__input`, |
@@ -32,2 +32,18 @@ import React, { PureComponent } from 'react'; | ||
componentDidMount() { | ||
document.addEventListener('mousedown', this.onOutsideAction); | ||
document.addEventListener('focusin', this.onOutsideAction); | ||
} | ||
componentWillUnmount() { | ||
document.removeEventListener('mousedown', this.onOutsideAction); | ||
document.removeEventListener('focusin', this.onOutsideAction); | ||
} | ||
onOutsideAction = (event) => { | ||
if (this.wrapper && !this.wrapper.contains(event.target)) { | ||
this.closeCalendar(); | ||
} | ||
} | ||
openCalendar = () => { | ||
@@ -77,18 +93,2 @@ this.setState({ isOpen: true }); | ||
onBlur = () => { | ||
const { onBlur } = this.props; | ||
if (onBlur) { | ||
onBlur(event); | ||
} | ||
requestAnimationFrame(() => { | ||
const stillHasFocus = this.wrapper.querySelector(':focus'); | ||
if (!stillHasFocus) { | ||
this.closeCalendar(); | ||
} | ||
}); | ||
} | ||
stopPropagation = event => event.stopPropagation(); | ||
@@ -229,3 +229,2 @@ | ||
onFocus={this.onFocus} | ||
onBlur={this.onBlur} | ||
ref={(ref) => { | ||
@@ -232,0 +231,0 @@ if (!ref) { |
@@ -11,3 +11,3 @@ import getUserLocale from 'get-user-locale'; | ||
*/ | ||
export const getFormatter = (options, locale) => { | ||
export const getFormatter = (locale, options) => { | ||
if (!locale) { | ||
@@ -26,3 +26,3 @@ // Default parameter is not enough as it does not protect us from null values | ||
if (!formatterCache[locale][stringifiedOptions]) { | ||
formatterCache[locale][stringifiedOptions] = new Intl.DateTimeFormat(locale, options).format; | ||
formatterCache[locale][stringifiedOptions] = n => n.toLocaleString(locale, options); | ||
} | ||
@@ -29,0 +29,0 @@ |
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
148594
3542
Updatedreact-calendar@^2.18.0