Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

react-date-picker

Package Overview
Dependencies
28
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.0 to 9.1.0

258

dist/DateInput.js
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -9,79 +8,40 @@ value: true

exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _Divider = _interopRequireDefault(require("./Divider"));
var _DayInput = _interopRequireDefault(require("./DateInput/DayInput"));
var _MonthInput = _interopRequireDefault(require("./DateInput/MonthInput"));
var _MonthSelect = _interopRequireDefault(require("./DateInput/MonthSelect"));
var _YearInput = _interopRequireDefault(require("./DateInput/YearInput"));
var _NativeInput = _interopRequireDefault(require("./DateInput/NativeInput"));
var _dateFormatter = require("./shared/dateFormatter");
var _dates = require("./shared/dates");
var _propTypes2 = require("./shared/propTypes");
var _utils = require("./shared/utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var getFormatterOptionsCache = {};

@@ -94,3 +54,2 @@ var defaultMinDate = new Date();

var allValueTypes = [].concat(_toConsumableArray(allViews.slice(1)), ['day']);
function toDate(value) {

@@ -100,18 +59,14 @@ if (value instanceof Date) {

}
return new Date(value);
}
function datesAreDifferent(date1, date2) {
return date1 && !date2 || !date1 && date2 || date1 && date2 && date1.getTime() !== date2.getTime();
}
/**
* Returns value type that can be returned with currently applied settings.
*/
function getValueType(maxDetail) {
return allValueTypes[allViews.indexOf(maxDetail)];
}
function getValue(value, index) {

@@ -121,29 +76,21 @@ if (!value) {

}
var rawValue = Array.isArray(value) && value.length === 2 ? value[index] : value;
if (!rawValue) {
return null;
}
var valueDate = toDate(rawValue);
if (isNaN(valueDate.getTime())) {
throw new Error("Invalid date: ".concat(value));
}
return valueDate;
}
function getDetailValue(_ref, index) {
var value = _ref.value,
minDate = _ref.minDate,
maxDate = _ref.maxDate,
maxDetail = _ref.maxDetail;
minDate = _ref.minDate,
maxDate = _ref.maxDate,
maxDetail = _ref.maxDetail;
var valuePiece = getValue(value, index);
if (!valuePiece) {
return null;
}
var valueType = getValueType(maxDetail);

@@ -153,18 +100,13 @@ var detailValueFrom = [_dates.getBegin, _dates.getEnd][index](valueType, valuePiece);

}
var getDetailValueFrom = function getDetailValueFrom(args) {
return getDetailValue(args, 0);
};
var getDetailValueTo = function getDetailValueTo(args) {
return getDetailValue(args, 1);
};
var getDetailValueArray = function getDetailValueArray(args) {
var value = args.value;
if (Array.isArray(value)) {
return value;
}
return [getDetailValueFrom, getDetailValueTo].map(function (fn) {

@@ -174,17 +116,12 @@ return fn(args);

};
function isInternalInput(element) {
return element.dataset.input === 'true';
}
function findInput(element, property) {
var nextElement = element;
do {
nextElement = nextElement[property];
} while (nextElement && !isInternalInput(nextElement));
return nextElement;
}
function focus(element) {

@@ -195,3 +132,2 @@ if (element) {

}
function _renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances) {

@@ -210,6 +146,4 @@ var usedFunctions = [];

}, element);
var res = [].concat(_toConsumableArray(arr), [divider]);
var currentMatch = matches && matches[index];
if (currentMatch) {

@@ -219,3 +153,2 @@ var renderFunction = elementFunctions[currentMatch] || elementFunctions[Object.keys(elementFunctions).find(function (elementFunction) {

})];
if (!allowMultipleInstances && usedFunctions.includes(renderFunction)) {

@@ -228,23 +161,15 @@ res.push(currentMatch);

}
return res;
}, []);
}
var DateInput = /*#__PURE__*/function (_PureComponent) {
_inherits(DateInput, _PureComponent);
var _super = _createSuper(DateInput);
function DateInput() {
var _this;
_classCallCheck(this, DateInput);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "state", {

@@ -255,9 +180,5 @@ year: null,

});
_defineProperty(_assertThisInitialized(_this), "dayInput", /*#__PURE__*/(0, _react.createRef)());
_defineProperty(_assertThisInitialized(_this), "monthInput", /*#__PURE__*/(0, _react.createRef)());
_defineProperty(_assertThisInitialized(_this), "yearInput", /*#__PURE__*/(0, _react.createRef)());
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {

@@ -270,3 +191,2 @@ if (event.target === event.currentTarget) {

});
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {

@@ -285,18 +205,15 @@ switch (event.key) {

}
default:
}
});
_defineProperty(_assertThisInitialized(_this), "onKeyUp", function (event) {
var key = event.key,
input = event.target;
input = event.target;
var isNumberKey = !isNaN(parseInt(key, 10));
if (!isNumberKey) {
return;
}
var value = input.value;
var max = input.getAttribute('max');
/**

@@ -308,3 +225,2 @@ * Given 1, the smallest possible number the user could type by adding another digit is 10.

*/
if (value * 10 > max || value.length >= max.length) {

@@ -316,19 +232,14 @@ var property = 'nextElementSibling';

});
_defineProperty(_assertThisInitialized(_this), "onChange", function (event) {
var _event$target = event.target,
name = _event$target.name,
value = _event$target.value;
name = _event$target.name,
value = _event$target.value;
_this.setState(_defineProperty({}, name, value), _this.onChangeExternal);
});
_defineProperty(_assertThisInitialized(_this), "onChangeNative", function (event) {
var onChange = _this.props.onChange;
var value = event.target.value;
if (!onChange) {
return;
}
var processedValue = function () {

@@ -338,9 +249,7 @@ if (!value) {

}
var _value$split = value.split('-'),
_value$split2 = _slicedToArray(_value$split, 3),
yearString = _value$split2[0],
monthString = _value$split2[1],
dayString = _value$split2[2];
_value$split2 = _slicedToArray(_value$split, 3),
yearString = _value$split2[0],
monthString = _value$split2[1],
dayString = _value$split2[2];
var year = parseInt(yearString, 10);

@@ -354,13 +263,9 @@ var monthIndex = parseInt(monthString, 10) - 1 || 0;

}();
onChange(processedValue, false);
});
_defineProperty(_assertThisInitialized(_this), "onChangeExternal", function () {
var onChange = _this.props.onChange;
if (!onChange) {
return;
}
var formElements = [_this.dayInput.current, _this.monthInput.current, _this.yearInput.current].filter(Boolean);

@@ -371,3 +276,2 @@ var values = {};

});
if (formElements.every(function (formElement) {

@@ -386,24 +290,19 @@ return !formElement.value;

proposedValue.setHours(0, 0, 0, 0);
var processedValue = _this.getProcessedValue(proposedValue);
onChange(processedValue, false);
}
});
_defineProperty(_assertThisInitialized(_this), "renderDay", function (currentMatch, index) {
var _this$props = _this.props,
autoFocus = _this$props.autoFocus,
dayAriaLabel = _this$props.dayAriaLabel,
dayPlaceholder = _this$props.dayPlaceholder,
showLeadingZeros = _this$props.showLeadingZeros;
autoFocus = _this$props.autoFocus,
dayAriaLabel = _this$props.dayAriaLabel,
dayPlaceholder = _this$props.dayPlaceholder,
showLeadingZeros = _this$props.showLeadingZeros;
var _this$state = _this.state,
day = _this$state.day,
month = _this$state.month,
year = _this$state.year;
day = _this$state.day,
month = _this$state.month,
year = _this$state.year;
if (currentMatch && currentMatch.length > 2) {
throw new Error("Unsupported token: ".concat(currentMatch));
}
var showLeadingZerosFromFormat = currentMatch && currentMatch.length === 2;

@@ -413,3 +312,4 @@ return /*#__PURE__*/_react["default"].createElement(_DayInput["default"], _extends({

}, _this.commonInputProps, {
ariaLabel: dayAriaLabel // eslint-disable-next-line jsx-a11y/no-autofocus
ariaLabel: dayAriaLabel
// eslint-disable-next-line jsx-a11y/no-autofocus
,

@@ -425,18 +325,15 @@ autoFocus: index === 0 && autoFocus,

});
_defineProperty(_assertThisInitialized(_this), "renderMonth", function (currentMatch, index) {
var _this$props2 = _this.props,
autoFocus = _this$props2.autoFocus,
locale = _this$props2.locale,
monthAriaLabel = _this$props2.monthAriaLabel,
monthPlaceholder = _this$props2.monthPlaceholder,
showLeadingZeros = _this$props2.showLeadingZeros;
autoFocus = _this$props2.autoFocus,
locale = _this$props2.locale,
monthAriaLabel = _this$props2.monthAriaLabel,
monthPlaceholder = _this$props2.monthPlaceholder,
showLeadingZeros = _this$props2.showLeadingZeros;
var _this$state2 = _this.state,
month = _this$state2.month,
year = _this$state2.year;
month = _this$state2.month,
year = _this$state2.year;
if (currentMatch && currentMatch.length > 4) {
throw new Error("Unsupported token: ".concat(currentMatch));
}
if (currentMatch.length > 2) {

@@ -446,3 +343,4 @@ return /*#__PURE__*/_react["default"].createElement(_MonthSelect["default"], _extends({

}, _this.commonInputProps, {
ariaLabel: monthAriaLabel // eslint-disable-next-line jsx-a11y/no-autofocus
ariaLabel: monthAriaLabel
// eslint-disable-next-line jsx-a11y/no-autofocus
,

@@ -458,3 +356,2 @@ autoFocus: index === 0 && autoFocus,

}
var showLeadingZerosFromFormat = currentMatch && currentMatch.length === 2;

@@ -464,3 +361,4 @@ return /*#__PURE__*/_react["default"].createElement(_MonthInput["default"], _extends({

}, _this.commonInputProps, {
ariaLabel: monthAriaLabel // eslint-disable-next-line jsx-a11y/no-autofocus
ariaLabel: monthAriaLabel
// eslint-disable-next-line jsx-a11y/no-autofocus
,

@@ -475,8 +373,7 @@ autoFocus: index === 0 && autoFocus,

});
_defineProperty(_assertThisInitialized(_this), "renderYear", function (currentMatch, index) {
var _this$props3 = _this.props,
autoFocus = _this$props3.autoFocus,
yearAriaLabel = _this$props3.yearAriaLabel,
yearPlaceholder = _this$props3.yearPlaceholder;
autoFocus = _this$props3.autoFocus,
yearAriaLabel = _this$props3.yearAriaLabel,
yearPlaceholder = _this$props3.yearPlaceholder;
var year = _this.state.year;

@@ -486,3 +383,4 @@ return /*#__PURE__*/_react["default"].createElement(_YearInput["default"], _extends({

}, _this.commonInputProps, {
ariaLabel: yearAriaLabel // eslint-disable-next-line jsx-a11y/no-autofocus
ariaLabel: yearAriaLabel
// eslint-disable-next-line jsx-a11y/no-autofocus
,

@@ -496,6 +394,4 @@ autoFocus: index === 0 && autoFocus,

});
return _this;
}
_createClass(DateInput, [{

@@ -506,3 +402,2 @@ key: "formatDate",

var level = allViews.indexOf(maxDetail);
var formatterOptions = getFormatterOptionsCache[level] || function () {

@@ -512,21 +407,17 @@ var options = {

};
if (level >= 2) {
options.month = 'numeric';
}
if (level >= 3) {
options.day = 'numeric';
}
getFormatterOptionsCache[level] = options;
return options;
}();
return (0, _dateFormatter.getFormatter)(formatterOptions);
}
/**
* Gets current value in a desired format.
*/
}, {

@@ -536,7 +427,6 @@ key: "getProcessedValue",

var _this$props4 = this.props,
minDate = _this$props4.minDate,
maxDate = _this$props4.maxDate,
maxDetail = _this$props4.maxDetail,
returnValue = _this$props4.returnValue;
minDate = _this$props4.minDate,
maxDate = _this$props4.maxDate,
maxDetail = _this$props4.maxDetail,
returnValue = _this$props4.returnValue;
var processFunction = function () {

@@ -546,9 +436,6 @@ switch (returnValue) {

return getDetailValueFrom;
case 'end':
return getDetailValueTo;
case 'range':
return getDetailValueArray;
default:

@@ -558,3 +445,2 @@ throw new Error('Invalid returnValue.');

}();
return processFunction({

@@ -577,9 +463,7 @@ value: value,

var _this$props5 = this.props,
format = _this$props5.format,
locale = _this$props5.locale;
format = _this$props5.format,
locale = _this$props5.locale;
if (format) {
return format;
}
var year = 2017;

@@ -592,3 +476,2 @@ var monthIndex = 11;

var datePieceReplacements = ['y', 'M', 'd'];
function formatDatePiece(name, dateToFormat) {

@@ -599,10 +482,7 @@ var formatterOptions = getFormatterOptionsCache[name] || function () {

}, name, 'numeric');
getFormatterOptionsCache[name] = options;
return options;
}();
return (0, _dateFormatter.getFormatter)(formatterOptions)(locale, dateToFormat).match(/\d{1,}/);
}
var placeholder = formattedDate;

@@ -613,4 +493,4 @@ datePieces.forEach(function (datePiece, index) {

placeholder = placeholder.replace(formattedDatePiece, datePieceReplacement);
}); // See: https://github.com/wojtekmaj/react-date-picker/issues/396
});
// See: https://github.com/wojtekmaj/react-date-picker/issues/396
placeholder = placeholder.replace('17', 'y');

@@ -623,8 +503,8 @@ return placeholder;

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

@@ -665,8 +545,8 @@ className: className,

var _this$props7 = this.props,
disabled = _this$props7.disabled,
maxDate = _this$props7.maxDate,
minDate = _this$props7.minDate,
name = _this$props7.name,
nativeInputAriaLabel = _this$props7.nativeInputAriaLabel,
required = _this$props7.required;
disabled = _this$props7.disabled,
maxDate = _this$props7.maxDate,
minDate = _this$props7.minDate,
name = _this$props7.name,
nativeInputAriaLabel = _this$props7.nativeInputAriaLabel,
required = _this$props7.required;
var value = this.state.value;

@@ -703,5 +583,6 @@ return /*#__PURE__*/_react["default"].createElement(_NativeInput["default"], {

var minDate = nextProps.minDate,
maxDate = nextProps.maxDate,
maxDetail = nextProps.maxDetail;
maxDate = nextProps.maxDate,
maxDetail = nextProps.maxDetail;
var nextState = {};
/**

@@ -711,6 +592,6 @@ * If isCalendarOpen flag has changed, we have to update it.

*/
if (nextProps.isCalendarOpen !== prevState.isCalendarOpen) {
nextState.isCalendarOpen = nextProps.isCalendarOpen;
}
/**

@@ -721,4 +602,2 @@ * If the next value is different from the current one (with an exception of situation in

*/
var nextValue = getDetailValueFrom({

@@ -731,5 +610,6 @@ value: nextProps.value,

var values = [nextValue, prevState.value];
if ( // Toggling calendar visibility resets values
nextState.isCalendarOpen || // Flag was toggled
if (
// Toggling calendar visibility resets values
nextState.isCalendarOpen ||
// Flag was toggled
datesAreDifferent.apply(void 0, _toConsumableArray(values.map(function (value) {

@@ -759,13 +639,9 @@ return getDetailValueFrom({

}
nextState.value = nextValue;
}
return nextState;
}
}]);
return DateInput;
}(_react.PureComponent);
exports["default"] = DateInput;

@@ -777,5 +653,3 @@ DateInput.defaultProps = {

};
var isValue = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].instanceOf(Date)]);
DateInput.propTypes = {

@@ -782,0 +656,0 @@ autoFocus: _propTypes["default"].bool,

@@ -7,32 +7,19 @@ "use strict";

exports["default"] = DayInput;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _Input = _interopRequireDefault(require("./Input"));
var _propTypes2 = require("../shared/propTypes");
var _utils = require("../shared/utils");
var _excluded = ["maxDate", "minDate", "month", "year"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
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; }
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; }
function DayInput(_ref) {
var maxDate = _ref.maxDate,
minDate = _ref.minDate,
month = _ref.month,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
minDate = _ref.minDate,
month = _ref.month,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
var currentMonthMaxDays = function () {

@@ -42,10 +29,7 @@ if (!month) {

}
return (0, _dateUtils.getDaysInMonth)(new Date(year, month - 1, 1));
}();
function isSameMonth(date) {
return date && year === (0, _dateUtils.getYear)(date).toString() && month === (0, _dateUtils.getMonthHuman)(date).toString();
}
var maxDay = (0, _utils.safeMin)(currentMonthMaxDays, isSameMonth(maxDate) && (0, _dateUtils.getDate)(maxDate));

@@ -59,3 +43,2 @@ var minDay = (0, _utils.safeMax)(1, isSameMonth(minDate) && (0, _dateUtils.getDate)(minDate));

}
DayInput.propTypes = {

@@ -62,0 +45,0 @@ ariaLabel: _propTypes["default"].string,

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -9,26 +8,16 @@ value: true

exports["default"] = Input;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _mergeClassNames = _interopRequireDefault(require("merge-class-names"));
var _clsx = _interopRequireDefault(require("clsx"));
var _updateInputWidth = _interopRequireWildcard(require("update-input-width"));
var _propTypes2 = require("../shared/propTypes");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/* eslint-disable jsx-a11y/no-autofocus */
/* eslint-disable jsx-a11y/no-autofocus */
var isIEOrEdgeLegacy = typeof window !== 'undefined' && /(MSIE|Trident\/|Edge\/)/.test(window.navigator.userAgent);
var isFirefox = typeof window !== 'undefined' && /Firefox/.test(window.navigator.userAgent);
function onFocus(event) {
var target = event.target;
if (isIEOrEdgeLegacy) {

@@ -42,3 +31,2 @@ requestAnimationFrame(function () {

}
function updateInputWidthOnLoad(element) {

@@ -48,10 +36,7 @@ if (document.readyState === 'complete') {

}
function onLoad() {
(0, _updateInputWidth["default"])(element);
}
window.addEventListener('load', onLoad);
}
function updateInputWidthOnFontLoad(element) {

@@ -61,22 +46,15 @@ if (!document.fonts) {

}
var font = (0, _updateInputWidth.getFontShorthand)(element);
if (!font) {
return;
}
var isFontLoaded = document.fonts.check(font);
if (isFontLoaded) {
return;
}
function onLoadingDone() {
(0, _updateInputWidth["default"])(element);
}
document.fonts.addEventListener('loadingdone', onLoadingDone);
}
function getSelectionString(input) {

@@ -90,10 +68,7 @@ /**

}
if ('getSelection' in window) {
return window.getSelection().toString();
}
return null;
}
function makeOnKeyPress(maxLength) {

@@ -109,9 +84,7 @@ /**

}
var key = event.key,
input = event.target;
input = event.target;
var value = input.value;
var isNumberKey = key.length === 1 && /\d/.test(key);
var selection = getSelectionString(input);
if (!isNumberKey || !(selection || value.length < maxLength)) {

@@ -122,22 +95,21 @@ event.preventDefault();

}
function Input(_ref) {
var ariaLabel = _ref.ariaLabel,
autoFocus = _ref.autoFocus,
className = _ref.className,
disabled = _ref.disabled,
inputRef = _ref.inputRef,
max = _ref.max,
min = _ref.min,
name = _ref.name,
nameForClass = _ref.nameForClass,
onChange = _ref.onChange,
onKeyDown = _ref.onKeyDown,
_onKeyUp = _ref.onKeyUp,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '--' : _ref$placeholder,
required = _ref.required,
showLeadingZeros = _ref.showLeadingZeros,
step = _ref.step,
value = _ref.value;
autoFocus = _ref.autoFocus,
className = _ref.className,
disabled = _ref.disabled,
inputRef = _ref.inputRef,
max = _ref.max,
min = _ref.min,
name = _ref.name,
nameForClass = _ref.nameForClass,
onChange = _ref.onChange,
onKeyDown = _ref.onKeyDown,
_onKeyUp = _ref.onKeyUp,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '--' : _ref$placeholder,
required = _ref.required,
showLeadingZeros = _ref.showLeadingZeros,
step = _ref.step,
value = _ref.value;
(0, _react.useLayoutEffect)(function () {

@@ -147,3 +119,2 @@ if (!inputRef || !inputRef.current) {

}
(0, _updateInputWidth["default"])(inputRef.current);

@@ -163,3 +134,3 @@ updateInputWidthOnLoad(inputRef.current);

autoFocus: autoFocus,
className: (0, _mergeClassNames["default"])("".concat(className, "__input"), "".concat(className, "__").concat(nameForClass || name), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")),
className: (0, _clsx["default"])("".concat(className, "__input"), "".concat(className, "__").concat(nameForClass || name), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")),
"data-input": "true",

@@ -177,3 +148,2 @@ disabled: disabled,

(0, _updateInputWidth["default"])(event.target);
if (_onKeyUp) {

@@ -191,3 +161,2 @@ _onKeyUp(event);

}
Input.propTypes = {

@@ -194,0 +163,0 @@ ariaLabel: _propTypes["default"].string,

@@ -7,35 +7,21 @@ "use strict";

exports["default"] = MonthInput;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _Input = _interopRequireDefault(require("./Input"));
var _propTypes2 = require("../shared/propTypes");
var _utils = require("../shared/utils");
var _excluded = ["maxDate", "minDate", "year"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
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; }
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; }
function MonthInput(_ref) {
var maxDate = _ref.maxDate,
minDate = _ref.minDate,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
minDate = _ref.minDate,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
function isSameYear(date) {
return date && year === (0, _dateUtils.getYear)(date).toString();
}
var maxMonth = (0, _utils.safeMin)(12, isSameYear(maxDate) && (0, _dateUtils.getMonthHuman)(maxDate));

@@ -49,3 +35,2 @@ var minMonth = (0, _utils.safeMax)(1, isSameYear(minDate) && (0, _dateUtils.getMonthHuman)(minDate));

}
MonthInput.propTypes = {

@@ -52,0 +37,0 @@ ariaLabel: _propTypes["default"].string,

@@ -7,64 +7,41 @@ "use strict";

exports["default"] = MonthSelect;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _mergeClassNames = _interopRequireDefault(require("merge-class-names"));
var _clsx = _interopRequireDefault(require("clsx"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _dateFormatter = require("../shared/dateFormatter");
var _propTypes2 = require("../shared/propTypes");
var _utils = require("../shared/utils");
var _excluded = ["ariaLabel", "className", "inputRef", "locale", "maxDate", "minDate", "placeholder", "short", "value", "year"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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; }
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; }
function MonthSelect(_ref) {
var ariaLabel = _ref.ariaLabel,
className = _ref.className,
inputRef = _ref.inputRef,
locale = _ref.locale,
maxDate = _ref.maxDate,
minDate = _ref.minDate,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '--' : _ref$placeholder,
_short = _ref["short"],
value = _ref.value,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
className = _ref.className,
inputRef = _ref.inputRef,
locale = _ref.locale,
maxDate = _ref.maxDate,
minDate = _ref.minDate,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '--' : _ref$placeholder,
_short = _ref["short"],
value = _ref.value,
year = _ref.year,
otherProps = _objectWithoutProperties(_ref, _excluded);
function isSameYear(date) {
return date && year === (0, _dateUtils.getYear)(date).toString();
}
var maxMonth = (0, _utils.safeMin)(12, isSameYear(maxDate) && (0, _dateUtils.getMonthHuman)(maxDate));
var minMonth = (0, _utils.safeMax)(1, isSameYear(minDate) && (0, _dateUtils.getMonthHuman)(minDate));
var dates = _toConsumableArray(Array(12)).map(function (el, index) {
return new Date(2019, index, 1);
});
var name = 'month';

@@ -74,3 +51,3 @@ var formatter = _short ? _dateFormatter.formatShortMonth : _dateFormatter.formatMonth;

"aria-label": ariaLabel,
className: (0, _mergeClassNames["default"])("".concat(className, "__input"), "".concat(className, "__").concat(name)),
className: (0, _clsx["default"])("".concat(className, "__input"), "".concat(className, "__").concat(name)),
"data-input": "true",

@@ -93,3 +70,2 @@ "data-select": "true",

}
MonthSelect.propTypes = {

@@ -96,0 +72,0 @@ ariaLabel: _propTypes["default"].string,

@@ -7,24 +7,17 @@ "use strict";

exports["default"] = NativeInput;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _propTypes2 = require("../shared/propTypes");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function NativeInput(_ref) {
var ariaLabel = _ref.ariaLabel,
disabled = _ref.disabled,
maxDate = _ref.maxDate,
minDate = _ref.minDate,
name = _ref.name,
onChange = _ref.onChange,
required = _ref.required,
value = _ref.value,
valueType = _ref.valueType;
disabled = _ref.disabled,
maxDate = _ref.maxDate,
minDate = _ref.minDate,
name = _ref.name,
onChange = _ref.onChange,
required = _ref.required,
value = _ref.value,
valueType = _ref.valueType;
var nativeInputType = function () {

@@ -35,9 +28,6 @@ switch (valueType) {

return 'number';
case 'month':
return 'month';
case 'day':
return 'date';
default:

@@ -47,3 +37,2 @@ throw new Error('Invalid valueType.');

}();
var nativeValueParser = function () {

@@ -55,9 +44,6 @@ switch (valueType) {

return _dateUtils.getYear;
case 'month':
return _dateUtils.getISOLocalMonth;
case 'day':
return _dateUtils.getISOLocalDate;
default:

@@ -67,7 +53,5 @@ throw new Error('Invalid valueType.');

}();
function stopPropagation(event) {
event.stopPropagation();
}
return /*#__PURE__*/_react["default"].createElement("input", {

@@ -91,3 +75,2 @@ "aria-label": ariaLabel,

}
NativeInput.propTypes = {

@@ -94,0 +77,0 @@ ariaLabel: _propTypes["default"].string,

@@ -7,36 +7,22 @@ "use strict";

exports["default"] = YearInput;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dateUtils = require("@wojtekmaj/date-utils");
var _Input = _interopRequireDefault(require("./Input"));
var _propTypes2 = require("../shared/propTypes");
var _utils = require("../shared/utils");
var _excluded = ["maxDate", "minDate", "placeholder", "valueType"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
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; }
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; }
function YearInput(_ref) {
var maxDate = _ref.maxDate,
minDate = _ref.minDate,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '----' : _ref$placeholder,
valueType = _ref.valueType,
otherProps = _objectWithoutProperties(_ref, _excluded);
minDate = _ref.minDate,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '----' : _ref$placeholder,
valueType = _ref.valueType,
otherProps = _objectWithoutProperties(_ref, _excluded);
var maxYear = (0, _utils.safeMin)(275760, maxDate && (0, _dateUtils.getYear)(maxDate));
var minYear = (0, _utils.safeMax)(1, minDate && (0, _dateUtils.getYear)(minDate));
var yearStep = function () {

@@ -46,6 +32,4 @@ if (valueType === 'century') {

}
return 1;
}();
return /*#__PURE__*/_react["default"].createElement(_Input["default"], _extends({

@@ -59,3 +43,2 @@ max: maxYear,

}
YearInput.propTypes = {

@@ -62,0 +45,0 @@ ariaLabel: _propTypes["default"].string,

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -9,104 +8,59 @@ value: true

exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactDom = require("react-dom");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _makeEventProps = _interopRequireDefault(require("make-event-props"));
var _mergeClassNames = _interopRequireDefault(require("merge-class-names"));
var _clsx = _interopRequireDefault(require("clsx"));
var _reactCalendar = _interopRequireDefault(require("react-calendar"));
var _reactFit = _interopRequireDefault(require("react-fit"));
var _DateInput = _interopRequireDefault(require("./DateInput"));
var _propTypes2 = require("./shared/propTypes");
var _excluded = ["calendarClassName", "className", "onChange", "portalContainer", "value"],
_excluded2 = ["onChange"];
_excluded2 = ["onChange"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
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; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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 outsideActionEvents = ['mousedown', 'focusin', 'touchstart'];
var allViews = ['century', 'decade', 'year', 'month'];
var DatePicker = /*#__PURE__*/function (_PureComponent) {
_inherits(DatePicker, _PureComponent);
var _super = _createSuper(DatePicker);
function DatePicker() {
var _this;
_classCallCheck(this, DatePicker);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "state", {});
_defineProperty(_assertThisInitialized(_this), "wrapper", /*#__PURE__*/(0, _react.createRef)());
_defineProperty(_assertThisInitialized(_this), "calendarWrapper", /*#__PURE__*/(0, _react.createRef)());
_defineProperty(_assertThisInitialized(_this), "onOutsideAction", function (event) {
var _assertThisInitialize = _assertThisInitialized(_this),
wrapper = _assertThisInitialize.wrapper,
calendarWrapper = _assertThisInitialize.calendarWrapper; // Try event.composedPath first to handle clicks inside a Shadow DOM.
wrapper = _assertThisInitialize.wrapper,
calendarWrapper = _assertThisInitialize.calendarWrapper;
// Try event.composedPath first to handle clicks inside a Shadow DOM.
var target = 'composedPath' in event ? event.composedPath()[0] : event.target;
if (wrapper.current && !wrapper.current.contains(target) && (!calendarWrapper.current || !calendarWrapper.current.contains(target))) {

@@ -116,11 +70,8 @@ _this.closeCalendar();

});
_defineProperty(_assertThisInitialized(_this), "onChange", function (value) {
var closeCalendar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.closeCalendar;
var onChange = _this.props.onChange;
if (closeCalendar) {
_this.closeCalendar();
}
if (onChange) {

@@ -130,18 +81,15 @@ onChange(value);

});
_defineProperty(_assertThisInitialized(_this), "onFocus", function (event) {
var _this$props = _this.props,
disabled = _this$props.disabled,
onFocus = _this$props.onFocus,
openCalendarOnFocus = _this$props.openCalendarOnFocus;
disabled = _this$props.disabled,
onFocus = _this$props.onFocus,
openCalendarOnFocus = _this$props.openCalendarOnFocus;
if (onFocus) {
onFocus(event);
} // Internet Explorer still fires onFocus on disabled elements
}
// Internet Explorer still fires onFocus on disabled elements
if (disabled) {
return;
}
if (openCalendarOnFocus) {

@@ -151,7 +99,5 @@ if (event.target.dataset.select === 'true') {

}
_this.openCalendar();
}
});
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {

@@ -162,3 +108,2 @@ if (event.key === 'Escape') {

});
_defineProperty(_assertThisInitialized(_this), "openCalendar", function () {

@@ -169,3 +114,2 @@ _this.setState({

});
_defineProperty(_assertThisInitialized(_this), "closeCalendar", function () {

@@ -176,3 +120,2 @@ _this.setState(function (prevState) {

}
return {

@@ -183,3 +126,2 @@ isOpen: false

});
_defineProperty(_assertThisInitialized(_this), "toggleCalendar", function () {

@@ -192,14 +134,10 @@ _this.setState(function (prevState) {

});
_defineProperty(_assertThisInitialized(_this), "stopPropagation", function (event) {
return event.stopPropagation();
});
_defineProperty(_assertThisInitialized(_this), "clear", function () {
return _this.onChange(null);
});
return _this;
}
_createClass(DatePicker, [{

@@ -215,5 +153,4 @@ key: "componentDidMount",

var _this$props2 = this.props,
onCalendarClose = _this$props2.onCalendarClose,
onCalendarOpen = _this$props2.onCalendarOpen;
onCalendarClose = _this$props2.onCalendarClose,
onCalendarOpen = _this$props2.onCalendarOpen;
if (isOpen !== prevState.isOpen) {

@@ -239,3 +176,2 @@ this.handleOutsideActionListeners();

var _this2 = this;
var isOpen = this.state.isOpen;

@@ -253,32 +189,30 @@ var shouldListenWithFallback = typeof shouldListen !== 'undefined' ? shouldListen : isOpen;

var _this$props3 = this.props,
autoFocus = _this$props3.autoFocus,
calendarAriaLabel = _this$props3.calendarAriaLabel,
calendarIcon = _this$props3.calendarIcon,
clearAriaLabel = _this$props3.clearAriaLabel,
clearIcon = _this$props3.clearIcon,
dayAriaLabel = _this$props3.dayAriaLabel,
dayPlaceholder = _this$props3.dayPlaceholder,
disableCalendar = _this$props3.disableCalendar,
disabled = _this$props3.disabled,
format = _this$props3.format,
locale = _this$props3.locale,
maxDate = _this$props3.maxDate,
maxDetail = _this$props3.maxDetail,
minDate = _this$props3.minDate,
monthAriaLabel = _this$props3.monthAriaLabel,
monthPlaceholder = _this$props3.monthPlaceholder,
name = _this$props3.name,
nativeInputAriaLabel = _this$props3.nativeInputAriaLabel,
required = _this$props3.required,
returnValue = _this$props3.returnValue,
showLeadingZeros = _this$props3.showLeadingZeros,
value = _this$props3.value,
yearAriaLabel = _this$props3.yearAriaLabel,
yearPlaceholder = _this$props3.yearPlaceholder;
autoFocus = _this$props3.autoFocus,
calendarAriaLabel = _this$props3.calendarAriaLabel,
calendarIcon = _this$props3.calendarIcon,
clearAriaLabel = _this$props3.clearAriaLabel,
clearIcon = _this$props3.clearIcon,
dayAriaLabel = _this$props3.dayAriaLabel,
dayPlaceholder = _this$props3.dayPlaceholder,
disableCalendar = _this$props3.disableCalendar,
disabled = _this$props3.disabled,
format = _this$props3.format,
locale = _this$props3.locale,
maxDate = _this$props3.maxDate,
maxDetail = _this$props3.maxDetail,
minDate = _this$props3.minDate,
monthAriaLabel = _this$props3.monthAriaLabel,
monthPlaceholder = _this$props3.monthPlaceholder,
name = _this$props3.name,
nativeInputAriaLabel = _this$props3.nativeInputAriaLabel,
required = _this$props3.required,
returnValue = _this$props3.returnValue,
showLeadingZeros = _this$props3.showLeadingZeros,
value = _this$props3.value,
yearAriaLabel = _this$props3.yearAriaLabel,
yearPlaceholder = _this$props3.yearPlaceholder;
var isOpen = this.state.isOpen;
var _concat = [].concat(value),
_concat2 = _slicedToArray(_concat, 1),
valueFrom = _concat2[0];
_concat2 = _slicedToArray(_concat, 1),
valueFrom = _concat2[0];
var ariaLabelProps = {

@@ -335,21 +269,16 @@ dayAriaLabel: dayAriaLabel,

var _this3 = this;
var disableCalendar = this.props.disableCalendar;
var isOpen = this.state.isOpen;
if (isOpen === null || disableCalendar) {
return null;
}
var _this$props4 = this.props,
calendarClassName = _this$props4.calendarClassName,
datePickerClassName = _this$props4.className,
onChange = _this$props4.onChange,
portalContainer = _this$props4.portalContainer,
value = _this$props4.value,
calendarProps = _objectWithoutProperties(_this$props4, _excluded);
calendarClassName = _this$props4.calendarClassName,
datePickerClassName = _this$props4.className,
onChange = _this$props4.onChange,
portalContainer = _this$props4.portalContainer,
value = _this$props4.value,
calendarProps = _objectWithoutProperties(_this$props4, _excluded);
var className = "".concat(baseClassName, "__calendar");
var classNames = (0, _mergeClassNames["default"])(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
var classNames = (0, _clsx["default"])(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
var calendar = /*#__PURE__*/_react["default"].createElement(_reactCalendar["default"], _extends({

@@ -362,3 +291,2 @@ className: calendarClassName,

}, calendarProps));
return portalContainer ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react["default"].createElement("div", {

@@ -381,11 +309,9 @@ ref: this.calendarWrapper,

var _this$props5 = this.props,
className = _this$props5.className,
disabled = _this$props5.disabled;
className = _this$props5.className,
disabled = _this$props5.disabled;
var isOpen = this.state.isOpen;
var onChange = eventProps.onChange,
eventPropsWithoutOnChange = _objectWithoutProperties(eventProps, _excluded2);
eventPropsWithoutOnChange = _objectWithoutProperties(eventProps, _excluded2);
return /*#__PURE__*/_react["default"].createElement("div", _extends({
className: (0, _mergeClassNames["default"])(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className)
className: (0, _clsx["default"])(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className)
}, eventPropsWithoutOnChange, {

@@ -405,10 +331,7 @@ onFocus: this.onFocus,

}
return null;
}
}]);
return DatePicker;
}(_react.PureComponent);
exports["default"] = DatePicker;

@@ -423,3 +346,2 @@ var iconProps = {

};
var CalendarIcon = /*#__PURE__*/_react["default"].createElement("svg", _extends({}, iconProps, {

@@ -444,3 +366,2 @@ className: "".concat(baseClassName, "__calendar-button__icon ").concat(baseClassName, "__button__icon")

}));
var ClearIcon = /*#__PURE__*/_react["default"].createElement("svg", _extends({}, iconProps, {

@@ -459,3 +380,2 @@ className: "".concat(baseClassName, "__clear-button__icon ").concat(baseClassName, "__button__icon")

}));
DatePicker.defaultProps = {

@@ -469,5 +389,3 @@ calendarIcon: CalendarIcon,

};
var isValue = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].instanceOf(Date)]);
DatePicker.propTypes = {

@@ -474,0 +392,0 @@ autoFocus: _propTypes["default"].bool,

@@ -7,9 +7,5 @@ "use strict";

exports["default"] = Divider;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function Divider(_ref) {

@@ -21,5 +17,4 @@ var children = _ref.children;

}
Divider.propTypes = {
children: _propTypes["default"].node
};

@@ -7,11 +7,6 @@ "use strict";

exports["default"] = void 0;
require("react-calendar/dist/Calendar.css");
var _DatePicker = _interopRequireDefault(require("./DatePicker"));
require("./DatePicker.css");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// File is created during build phase and placed in dist directory

@@ -18,0 +13,0 @@ // eslint-disable-next-line import/no-unresolved

@@ -7,8 +7,5 @@ "use strict";

exports["default"] = void 0;
var _DatePicker = _interopRequireDefault(require("./DatePicker"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = _DatePicker["default"];
exports["default"] = _default;

@@ -8,26 +8,19 @@ "use strict";

exports.getFormatter = getFormatter;
var _getUserLocale = _interopRequireDefault(require("get-user-locale"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var formatterCache = new Map();
function getFormatter(options) {
return function (locale, date) {
var localeWithDefault = locale || (0, _getUserLocale["default"])();
if (!formatterCache.has(localeWithDefault)) {
formatterCache.set(localeWithDefault, new Map());
}
var formatterCacheLocale = formatterCache.get(localeWithDefault);
if (!formatterCacheLocale.has(options)) {
formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault, options).format);
}
return formatterCacheLocale.get(options)(date);
};
}
/**

@@ -42,4 +35,2 @@ * Changes the hour in a Date to ensure right date formatting even if DST is messed up.

*/
function toSafeHour(date) {

@@ -49,3 +40,2 @@ var safeDate = new Date(date);

}
function getSafeFormatter(options) {

@@ -56,3 +46,2 @@ return function (locale, date) {

}
var formatMonthOptions = {

@@ -59,0 +48,0 @@ month: 'long'

@@ -8,5 +8,3 @@ "use strict";

exports.getEnd = getEnd;
var _dateUtils = require("@wojtekmaj/date-utils");
/**

@@ -22,15 +20,10 @@ * Returns the beginning of a given range.

return (0, _dateUtils.getCenturyStart)(date);
case 'decade':
return (0, _dateUtils.getDecadeStart)(date);
case 'year':
return (0, _dateUtils.getYearStart)(date);
case 'month':
return (0, _dateUtils.getMonthStart)(date);
case 'day':
return (0, _dateUtils.getDayStart)(date);
default:

@@ -40,2 +33,3 @@ throw new Error("Invalid rangeType: ".concat(rangeType));

}
/**

@@ -47,4 +41,2 @@ * Returns the end of a given range.

*/
function getEnd(rangeType, date) {

@@ -54,15 +46,10 @@ switch (rangeType) {

return (0, _dateUtils.getCenturyEnd)(date);
case 'decade':
return (0, _dateUtils.getDecadeEnd)(date);
case 'year':
return (0, _dateUtils.getYearEnd)(date);
case 'month':
return (0, _dateUtils.getMonthEnd)(date);
case 'day':
return (0, _dateUtils.getDayEnd)(date);
default:

@@ -69,0 +56,0 @@ throw new Error("Invalid rangeType: ".concat(rangeType));

@@ -7,76 +7,48 @@ "use strict";

exports.isValueType = exports.isRef = exports.isMinDate = exports.isMaxDate = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var allViews = ['century', 'decade', 'year', 'month'];
var allValueTypes = [].concat(_toConsumableArray(allViews.slice(1)), ['day']);
var isValueType = _propTypes["default"].oneOf(allValueTypes);
exports.isValueType = isValueType;
var isMinDate = function isMinDate(props, propName, componentName) {
var minDate = props[propName];
if (!minDate) {
return null;
}
if (!(minDate instanceof Date)) {
return new Error("Invalid prop `".concat(propName, "` of type `").concat(_typeof(minDate), "` supplied to `").concat(componentName, "`, expected instance of `Date`."));
}
var maxDate = props.maxDate;
if (maxDate && minDate > maxDate) {
return new Error("Invalid prop `".concat(propName, "` of type `").concat(_typeof(minDate), "` supplied to `").concat(componentName, "`, minDate cannot be larger than maxDate."));
}
return null;
};
exports.isMinDate = isMinDate;
var isMaxDate = function isMaxDate(props, propName, componentName) {
var maxDate = props[propName];
if (!maxDate) {
return null;
}
if (!(maxDate instanceof Date)) {
return new Error("Invalid prop `".concat(propName, "` of type `").concat(_typeof(maxDate), "` supplied to `").concat(componentName, "`, expected instance of `Date`."));
}
var minDate = props.minDate;
if (minDate && maxDate < minDate) {
return new Error("Invalid prop `".concat(propName, "` of type `").concat(_typeof(maxDate), "` supplied to `").concat(componentName, "`, maxDate cannot be smaller than minDate."));
}
return null;
};
exports.isMaxDate = isMaxDate;
var isRef = _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].shape({
current: _propTypes["default"].any
})]);
exports.isRef = isRef;

@@ -9,15 +9,8 @@ "use strict";

exports.safeMin = safeMin;
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/**

@@ -34,14 +27,10 @@ * Returns a value no smaller than min and no larger than max.

}
if (max && max < value) {
return max;
}
return value;
}
function isValidNumber(num) {
return num !== null && num !== false && !Number.isNaN(Number(num));
}
function safeMin() {

@@ -51,6 +40,4 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

}
return Math.min.apply(Math, _toConsumableArray(args.filter(isValidNumber)));
}
function safeMax() {

@@ -60,4 +47,3 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
return Math.max.apply(Math, _toConsumableArray(args.filter(isValidNumber)));
}
{
"name": "react-date-picker",
"version": "9.0.0",
"version": "9.1.0",
"description": "A date picker for your React app.",

@@ -16,5 +16,6 @@ "main": "dist/entry.js",

"jest": "jest",
"lint": "eslint sample/ src/ test/ --ext .jsx,.js",
"lint": "eslint sample src test --ext .jsx,.js",
"prepack": "yarn clean && yarn build",
"test": "yarn lint && yarn jest"
"prettier": "prettier --check . --cache",
"test": "yarn lint && yarn prettier && yarn jest"
},

@@ -32,34 +33,2 @@ "keywords": [

},
"contributors": [
{
"name": "Andrzej Kopeć",
"email": "andrzej.kopec@outlook.com"
},
{
"name": "Joe Bourne",
"email": "josephbourne14@gmail.com"
},
{
"name": "Juan Caicedo",
"email": "juan.caicedo@alumni.ubc.ca"
},
{
"name": "Pier-Luc Gendreau"
},
{
"name": "Kevin Kipp",
"email": "kevin.kipp@gmail.com"
},
{
"name": "Linus Marco"
},
{
"name": "Marco Fugaro",
"email": "marco.fugaro@gmail.com"
},
{
"name": "Matt Gandley",
"email": "mgandley@gmail.com"
}
],
"license": "MIT",

@@ -69,7 +38,7 @@ "dependencies": {

"@wojtekmaj/date-utils": "^1.0.3",
"clsx": "^1.2.1",
"get-user-locale": "^1.2.0",
"make-event-props": "^1.1.0",
"merge-class-names": "^1.1.1",
"prop-types": "^15.6.0",
"react-calendar": "^3.7.0",
"react-calendar": "^4.0.0",
"react-fit": "^1.4.0",

@@ -84,5 +53,5 @@ "update-input-width": "^1.2.2"

"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^12.1.0",
"eslint": "^8.5.0",
"eslint-config-wojtekmaj": "^0.6.5",
"@testing-library/react": "^13.4.0",
"eslint": "^8.26.0",
"eslint-config-wojtekmaj": "^0.7.1",
"husky": "^8.0.0",

@@ -92,6 +61,6 @@ "jest": "^29.0.0",

"less": "^4.0.0",
"prettier": "^2.5.0",
"prettier": "^2.7.0",
"pretty-quick": "^3.1.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.0"

@@ -98,0 +67,0 @@ },

@@ -113,2 +113,3 @@ [![npm](https://img.shields.io/npm/v/react-date-picker.svg)](https://www.npmjs.com/package/react-date-picker) ![downloads](https://img.shields.io/npm/dt/react-date-picker.svg) [![CI](https://github.com/wojtekmaj/react-date-picker/workflows/CI/badge.svg)](https://github.com/wojtekmaj/react-date-picker/actions) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)

| onChange | Function called when the user picks a valid date. If any of the fields were excluded using custom `format`, `new Date(y, 0, 1, 0, 0, 0)`, where `y` is the current year, is going to serve as a "base". | n/a | `(value) => alert('New date is: ', value)` |
| onFocus | Function called when the focuses an input. | n/a | `(event) => alert('Focused input: ', event.target.name)` |
| openCalendarOnFocus | Whether to open the calendar on input focus. | `true` | `false` |

@@ -115,0 +116,0 @@ | portalContainer | Element to render the calendar in using portal. | n/a | `document.getElementById('my-div')` |

@@ -21,6 +21,6 @@ import React from 'react';

const keyCodes = {
ArrowLeft: 37,
ArrowUp: 38,
ArrowRight: 39,
ArrowDown: 40,
'ArrowLeft': 37,
'ArrowUp': 38,
'ArrowRight': 39,
'ArrowDown': 40,
'-': 189,

@@ -357,3 +357,3 @@ '.': 190,

it('jumps to the next field when right arrow is pressed', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -375,3 +375,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('jumps to the next field when separator key is pressed', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -395,3 +395,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('does not jump to the next field when right arrow is pressed when the last input is focused', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -412,3 +412,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('jumps to the previous field when left arrow is pressed', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -430,3 +430,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('does not jump to the previous field when left arrow is pressed when the first input is focused', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -447,3 +447,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it("jumps to the next field when a value which can't be extended to another valid value is entered", () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -463,3 +463,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('jumps to the next field when a value as long as the length of maximum value is entered', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -479,3 +479,3 @@ const customInputs = container.querySelectorAll('input[data-input]');

it('does not jump the next field when a value which can be extended to another valid value is entered', () => {
const { container } = render(<DateInput {...defaultProps} />, { attachTo: container });
const { container } = render(<DateInput {...defaultProps} />);

@@ -482,0 +482,0 @@ const customInputs = container.querySelectorAll('input[data-input]');

import React, { useLayoutEffect } from 'react';
import PropTypes from 'prop-types';
import mergeClassNames from 'merge-class-names';
import clsx from 'clsx';
import updateInputWidth, { getFontShorthand } from 'update-input-width';

@@ -144,3 +144,3 @@

autoFocus={autoFocus}
className={mergeClassNames(
className={clsx(
`${className}__input`,

@@ -147,0 +147,0 @@ `${className}__${nameForClass || name}`,

import React from 'react';
import PropTypes from 'prop-types';
import mergeClassNames from 'merge-class-names';
import clsx from 'clsx';
import { getYear, getMonthHuman } from '@wojtekmaj/date-utils';

@@ -36,3 +36,3 @@

aria-label={ariaLabel}
className={mergeClassNames(`${className}__input`, `${className}__${name}`)}
className={clsx(`${className}__input`, `${className}__${name}`)}
data-input="true"

@@ -39,0 +39,0 @@ data-select="true"

@@ -5,3 +5,3 @@ import React, { createRef, PureComponent } from 'react';

import makeEventProps from 'make-event-props';
import mergeClassNames from 'merge-class-names';
import clsx from 'clsx';
import Calendar from 'react-calendar';

@@ -257,3 +257,3 @@ import Fit from 'react-fit';

const className = `${baseClassName}__calendar`;
const classNames = mergeClassNames(className, `${className}--${isOpen ? 'open' : 'closed'}`);
const classNames = clsx(className, `${className}--${isOpen ? 'open' : 'closed'}`);

@@ -301,3 +301,3 @@ const calendar = (

<div
className={mergeClassNames(
className={clsx(
baseClassName,

@@ -304,0 +304,0 @@ `${baseClassName}--${isOpen ? 'open' : 'closed'}`,

@@ -132,2 +132,10 @@ import React, { createRef } from 'react';

it('applies "--open" className to its wrapper when given isOpen flag', () => {
const { container } = render(<DatePicker isOpen />);
const wrapper = container.firstChild;
expect(wrapper).toHaveClass('react-date-picker--open');
});
it('applies calendarClassName to the calendar when given a string', () => {

@@ -134,0 +142,0 @@ const calendarClassName = 'testClassName';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc