react-time-picker
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -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-time-picker__inputGroup__divider' }, | ||
children | ||
); | ||
return _react.default.createElement("span", { | ||
className: "react-time-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-clock/dist/Clock.css'); | ||
require("react-clock/dist/Clock.css"); | ||
var _TimePicker = require('./TimePicker'); | ||
var _TimePicker = _interopRequireDefault(require("./TimePicker")); | ||
var _TimePicker2 = _interopRequireDefault(_TimePicker); | ||
require("./TimePicker.css"); | ||
require('./TimePicker.css'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _TimePicker2.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 = _TimePicker.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 _TimePicker = require('./TimePicker'); | ||
var _TimePicker = _interopRequireDefault(require("./TimePicker")); | ||
var _TimePicker2 = _interopRequireDefault(_TimePicker); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _TimePicker2.default; | ||
var _default = _TimePicker.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,10 +6,25 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.convert24to12 = exports.convert12to24 = exports.getHoursMinutesSeconds = exports.getHoursMinutes = exports.getSeconds = exports.getMinutes = exports.getHours = undefined; | ||
Object.defineProperty(exports, "getHours", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dates.getHours; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getMinutes", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dates.getMinutes; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getSeconds", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dates.getSeconds; | ||
} | ||
}); | ||
exports.convert24to12 = exports.convert12to24 = exports.getHoursMinutesSeconds = exports.getHoursMinutes = void 0; | ||
var _dates = require('react-clock/dist/shared/dates'); | ||
var _dates = require("react-clock/dist/shared/dates"); | ||
exports.getHours = _dates.getHours; | ||
exports.getMinutes = _dates.getMinutes; | ||
exports.getSeconds = _dates.getSeconds; | ||
var getHoursMinutes = exports.getHoursMinutes = function getHoursMinutes(date) { | ||
var getHoursMinutes = function getHoursMinutes(date) { | ||
if (!date) { | ||
@@ -19,9 +34,10 @@ return date; | ||
var hours = ('0' + (0, _dates.getHours)(date)).slice(-2); | ||
var minutes = ('0' + (0, _dates.getMinutes)(date)).slice(-2); | ||
return hours + ':' + minutes; | ||
var hours = "0".concat((0, _dates.getHours)(date)).slice(-2); | ||
var minutes = "0".concat((0, _dates.getMinutes)(date)).slice(-2); | ||
return "".concat(hours, ":").concat(minutes); | ||
}; | ||
var getHoursMinutesSeconds = exports.getHoursMinutesSeconds = function getHoursMinutesSeconds(date) { | ||
exports.getHoursMinutes = getHoursMinutes; | ||
var getHoursMinutesSeconds = function getHoursMinutesSeconds(date) { | ||
if (!date) { | ||
@@ -31,10 +47,11 @@ return date; | ||
var hours = ('0' + (0, _dates.getHours)(date)).slice(-2); | ||
var minutes = ('0' + (0, _dates.getMinutes)(date)).slice(-2); | ||
var seconds = ('0' + (0, _dates.getSeconds)(date)).slice(-2); | ||
return hours + ':' + minutes + ':' + seconds; | ||
var hours = "0".concat((0, _dates.getHours)(date)).slice(-2); | ||
var minutes = "0".concat((0, _dates.getMinutes)(date)).slice(-2); | ||
var seconds = "0".concat((0, _dates.getSeconds)(date)).slice(-2); | ||
return "".concat(hours, ":").concat(minutes, ":").concat(seconds); | ||
}; | ||
var convert12to24 = exports.convert12to24 = function convert12to24(hour12, amPm) { | ||
exports.getHoursMinutesSeconds = getHoursMinutesSeconds; | ||
var convert12to24 = function convert12to24(hour12, amPm) { | ||
var hour24 = parseInt(hour12, 10); | ||
@@ -51,6 +68,9 @@ | ||
var convert24to12 = exports.convert24to12 = function convert24to12(hour24) { | ||
exports.convert12to24 = convert12to24; | ||
var convert24to12 = function convert24to12(hour24) { | ||
var hour12 = hour24 % 12 || 12; | ||
return [hour12, hour24 < 12 ? 'am' : 'pm']; | ||
}; | ||
return [hour12, hour24 < 12 ? 'am' : 'pm']; | ||
}; | ||
exports.convert24to12 = convert24to12; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,31 +6,31 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.isValueType = exports.isTime = undefined; | ||
exports.isValueType = exports.isTime = void 0; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = require('prop-types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _propTypes2 = _interopRequireDefault(_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 }; } | ||
var allViews = ['hour', 'minute', 'second']; | ||
var allValueTypes = [].concat(allViews); | ||
var hourOptionalSecondsRegExp = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/; | ||
var isTime = exports.isTime = function isTime(props, propName, componentName) { | ||
var isTime = function isTime(props, propName, componentName) { | ||
var time = props[propName]; | ||
if (time) { | ||
if (!hourOptionalSecondsRegExp.test(time)) { | ||
return new Error('Invalid prop `' + propName + '` of type `' + (typeof minDate === 'undefined' ? 'undefined' : _typeof(minDate)) + '` supplied to `' + componentName + '`, expected time in HH:mm(:ss) format.'); | ||
return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof minDate === "undefined" ? "undefined" : _typeof(minDate), "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format.")); | ||
} | ||
} | ||
} // Everything is fine | ||
// Everything is fine | ||
return null; | ||
}; | ||
var isValueType = exports.isValueType = _propTypes2.default.oneOf(allValueTypes); | ||
exports.isTime = isTime; | ||
var isValueType = _propTypes.default.oneOf(allValueTypes); | ||
exports.isValueType = isValueType; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,10 +6,22 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.getAmPmLabels = exports.updateInputWidth = exports.max = exports.min = undefined; | ||
exports.getAmPmLabels = exports.updateInputWidth = exports.max = exports.min = void 0; | ||
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 _dateFormatter = require("./dateFormatter"); | ||
var _dateFormatter = require('./dateFormatter'); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
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 _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
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 _arrayWithHoles(arr) { if (Array.isArray(arr)) return 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 isValidNumber = function isValidNumber(a) { | ||
@@ -19,4 +31,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]; | ||
@@ -27,4 +39,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]; | ||
@@ -36,8 +51,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); | ||
@@ -48,9 +63,12 @@ | ||
element.style.width = Math.ceil(width) + 'px'; | ||
element.style.width = "".concat(Math.ceil(width), "px"); | ||
container.removeChild(span); | ||
}; | ||
var getAmPmLabels = exports.getAmPmLabels = function getAmPmLabels(locale) { | ||
var amPmFormatter = (0, _dateFormatter.getFormatter)({ hour: 'numeric' }, locale); | ||
exports.updateInputWidth = updateInputWidth; | ||
var getAmPmLabels = function getAmPmLabels(locale) { | ||
var amPmFormatter = (0, _dateFormatter.getFormatter)(locale, { | ||
hour: 'numeric' | ||
}); | ||
var amString = amPmFormatter(new Date(2017, 0, 1, 9)); | ||
@@ -79,6 +97,8 @@ var pmString = amPmFormatter(new Date(2017, 0, 1, 21)); | ||
}); | ||
} | ||
} // Fallback | ||
// Fallback | ||
return ['am', 'pm']; | ||
}; | ||
}; | ||
exports.getAmPmLabels = getAmPmLabels; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,66 +6,73 @@ 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 _Hour12Input = _interopRequireDefault(require("./TimeInput/Hour12Input")); | ||
var _propTypes = require('prop-types'); | ||
var _Hour24Input = _interopRequireDefault(require("./TimeInput/Hour24Input")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _MinuteInput = _interopRequireDefault(require("./TimeInput/MinuteInput")); | ||
var _reactLifecyclesCompat = require('react-lifecycles-compat'); | ||
var _SecondInput = _interopRequireDefault(require("./TimeInput/SecondInput")); | ||
var _Divider = require('./Divider'); | ||
var _NativeInput = _interopRequireDefault(require("./TimeInput/NativeInput")); | ||
var _Divider2 = _interopRequireDefault(_Divider); | ||
var _AmPm = _interopRequireDefault(require("./TimeInput/AmPm")); | ||
var _Hour12Input = require('./TimeInput/Hour12Input'); | ||
var _dateFormatter = require("./shared/dateFormatter"); | ||
var _Hour12Input2 = _interopRequireDefault(_Hour12Input); | ||
var _dates = require("./shared/dates"); | ||
var _Hour24Input = require('./TimeInput/Hour24Input'); | ||
var _propTypes2 = require("./shared/propTypes"); | ||
var _Hour24Input2 = _interopRequireDefault(_Hour24Input); | ||
var _utils = require("./shared/utils"); | ||
var _MinuteInput = require('./TimeInput/MinuteInput'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _MinuteInput2 = _interopRequireDefault(_MinuteInput); | ||
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 _SecondInput = require('./TimeInput/SecondInput'); | ||
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 _SecondInput2 = _interopRequireDefault(_SecondInput); | ||
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('./TimeInput/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 _AmPm = require('./TimeInput/AmPm'); | ||
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 _AmPm2 = _interopRequireDefault(_AmPm); | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _dateFormatter = require('./shared/dateFormatter'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _dates = require('./shared/dates'); | ||
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); } } | ||
var _propTypes3 = require('./shared/propTypes'); | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var _utils = require('./shared/utils'); | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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; } } | ||
@@ -81,5 +88,7 @@ var allViews = ['hour', 'minute', 'second']; | ||
var previousElement = element.previousElementSibling; // Divider between inputs | ||
if (!previousElement) { | ||
return null; | ||
} | ||
return previousElement.previousElementSibling; // Actual input | ||
@@ -90,5 +99,7 @@ }; | ||
var nextElement = element.nextElementSibling; // Divider between inputs | ||
if (!nextElement) { | ||
return null; | ||
} | ||
return nextElement.nextElementSibling; // Actual input | ||
@@ -101,17 +112,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; | ||
@@ -121,17 +132,21 @@ }, []); | ||
var TimeInput = function (_PureComponent) { | ||
var TimeInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(TimeInput, _PureComponent); | ||
function TimeInput() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, TimeInput); | ||
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 = TimeInput.__proto__ || Object.getPrototypeOf(TimeInput)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TimeInput)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
amPm: null, | ||
@@ -141,11 +156,17 @@ hour: null, | ||
second: 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) { | ||
@@ -155,3 +176,2 @@ case 'ArrowLeft': | ||
event.preventDefault(); | ||
var input = event.target; | ||
@@ -162,2 +182,3 @@ var previousInput = findPreviousInput(input); | ||
} | ||
case 'ArrowRight': | ||
@@ -167,3 +188,2 @@ case _this.divider: | ||
event.preventDefault(); | ||
var _input = event.target; | ||
@@ -174,5 +194,8 @@ var nextInput = findNextInput(_input); | ||
} | ||
default: | ||
} | ||
}, _this.onChange = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (event) { | ||
var _event$target = event.target, | ||
@@ -182,3 +205,2 @@ name = _event$target.name, | ||
switch (name) { | ||
@@ -192,9 +214,15 @@ case 'hour12': | ||
}, _this.onChangeExternal); | ||
break; | ||
} | ||
case 'hour24': | ||
{ | ||
_this.setState({ hour: value ? parseInt(value, 10) : null }, _this.onChangeExternal); | ||
_this.setState({ | ||
hour: value ? parseInt(value, 10) : null | ||
}, _this.onChangeExternal); | ||
break; | ||
} | ||
default: | ||
@@ -205,7 +233,8 @@ { | ||
} | ||
}, _this.onChangeNative = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChangeNative", function (event) { | ||
var onChange = _this.props.onChange; | ||
var value = event.target.value; | ||
if (!onChange) { | ||
@@ -224,11 +253,15 @@ return; | ||
onChange(processedValue, false); | ||
}, _this.onChangeAmPm = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChangeAmPm", function (event) { | ||
var value = event.target.value; | ||
_this.setState({ | ||
amPm: value | ||
}, _this.onChangeExternal); | ||
}); | ||
_this.setState({ amPm: value }, _this.onChangeExternal); | ||
}, _this.onChangeExternal = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChangeExternal", function () { | ||
var onChange = _this.props.onChange; | ||
if (!onChange) { | ||
@@ -239,5 +272,3 @@ return; | ||
var formElements = [_this.hour12Input, _this.hour24Input, _this.minuteInput, _this.secondInput, _this.amPmInput].filter(Boolean); | ||
var formElementsWithoutSelect = formElements.slice(0, -1); | ||
var values = {}; | ||
@@ -255,28 +286,32 @@ formElements.forEach(function (formElement) { | ||
})) { | ||
var hour = ('0' + (values.hour24 || (0, _dates.convert12to24)(values.hour12, values.amPm))).slice(-2); | ||
var minute = ('0' + (values.minute || 0)).slice(-2); | ||
var second = ('0' + (values.second || 0)).slice(-2); | ||
var timeString = hour + ':' + minute + ':' + second; | ||
var hour = "0".concat(values.hour24 || (0, _dates.convert12to24)(values.hour12, values.amPm)).slice(-2); | ||
var minute = "0".concat(values.minute || 0).slice(-2); | ||
var second = "0".concat(values.second || 0).slice(-2); | ||
var timeString = "".concat(hour, ":").concat(minute, ":").concat(second); | ||
var processedValue = _this.getProcessedValue(timeString); | ||
onChange(processedValue, false); | ||
} | ||
}, _this.renderHour12 = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderHour12", function () { | ||
var hour = _this.state.hour; | ||
return _react2.default.createElement(_Hour12Input2.default, _extends({ | ||
key: 'hour12' | ||
return _react.default.createElement(_Hour12Input.default, _extends({ | ||
key: "hour12" | ||
}, _this.commonInputProps, { | ||
value: hour | ||
})); | ||
}, _this.renderHour24 = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderHour24", function () { | ||
var hour = _this.state.hour; | ||
return _react2.default.createElement(_Hour24Input2.default, _extends({ | ||
key: 'hour24' | ||
return _react.default.createElement(_Hour24Input.default, _extends({ | ||
key: "hour24" | ||
}, _this.commonInputProps, { | ||
value: hour | ||
})); | ||
}, _this.renderMinute = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderMinute", function () { | ||
var maxDetail = _this.props.maxDetail; | ||
@@ -286,6 +321,4 @@ var _this$state = _this.state, | ||
minute = _this$state.minute; | ||
return _react2.default.createElement(_MinuteInput2.default, _extends({ | ||
key: 'minute' | ||
return _react.default.createElement(_MinuteInput.default, _extends({ | ||
key: "minute" | ||
}, _this.commonInputProps, { | ||
@@ -296,3 +329,5 @@ hour: hour, | ||
})); | ||
}, _this.renderSecond = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderSecond", function () { | ||
var maxDetail = _this.props.maxDetail; | ||
@@ -303,6 +338,4 @@ var _this$state2 = _this.state, | ||
second = _this$state2.second; | ||
return _react2.default.createElement(_SecondInput2.default, _extends({ | ||
key: 'second' | ||
return _react.default.createElement(_SecondInput.default, _extends({ | ||
key: "second" | ||
}, _this.commonInputProps, { | ||
@@ -314,9 +347,9 @@ hour: hour, | ||
})); | ||
}, _this.renderAmPm = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderAmPm", function () { | ||
var amPm = _this.state.amPm; | ||
var locale = _this.props.locale; | ||
return _react2.default.createElement(_AmPm2.default, _extends({ | ||
key: 'ampm' | ||
return _react.default.createElement(_AmPm.default, _extends({ | ||
key: "ampm" | ||
}, _this.commonInputProps, { | ||
@@ -327,9 +360,10 @@ locale: locale, | ||
})); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(TimeInput, [{ | ||
key: 'getProcessedValue', | ||
key: "getProcessedValue", | ||
/** | ||
@@ -340,7 +374,4 @@ * Gets current value in a desired format. | ||
var nativeValueParser = this.nativeValueParser; | ||
return nativeValueParser(value); | ||
} | ||
/** | ||
@@ -351,6 +382,5 @@ * Returns value type that can be returned with currently applied settings. | ||
}, { | ||
key: 'renderCustomInputs', | ||
key: "renderCustomInputs", | ||
value: function renderCustomInputs() { | ||
var placeholder = this.placeholder; | ||
var elementFunctions = { | ||
@@ -363,19 +393,16 @@ 'hour-12': this.renderHour12, | ||
}; | ||
return _renderCustomInputs(placeholder, elementFunctions); | ||
} | ||
}, { | ||
key: 'renderNativeInput', | ||
key: "renderNativeInput", | ||
value: function renderNativeInput() { | ||
var _props = this.props, | ||
disabled = _props.disabled, | ||
maxTime = _props.maxTime, | ||
minTime = _props.minTime, | ||
name = _props.name, | ||
required = _props.required, | ||
value = _props.value; | ||
return _react2.default.createElement(_NativeInput2.default, { | ||
key: 'time', | ||
var _this$props = this.props, | ||
disabled = _this$props.disabled, | ||
maxTime = _this$props.maxTime, | ||
minTime = _this$props.minTime, | ||
name = _this$props.name, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
return _react.default.createElement(_NativeInput.default, { | ||
key: "time", | ||
disabled: disabled, | ||
@@ -392,31 +419,26 @@ maxTime: maxTime, | ||
}, { | ||
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: 'formatTime', | ||
key: "formatTime", | ||
get: function get() { | ||
var _props2 = this.props, | ||
locale = _props2.locale, | ||
maxDetail = _props2.maxDetail; | ||
var _this$props2 = this.props, | ||
locale = _this$props2.locale, | ||
maxDetail = _this$props2.maxDetail; | ||
var options = { | ||
hour: 'numeric' | ||
}; | ||
var level = allViews.indexOf(maxDetail); | ||
var options = { hour: 'numeric' }; | ||
var level = allViews.indexOf(maxDetail); | ||
if (level >= 1) { | ||
options.minute = 'numeric'; | ||
} | ||
if (level >= 2) { | ||
@@ -426,14 +448,21 @@ options.second = 'numeric'; | ||
return (0, _dateFormatter.getFormatter)(options, locale); | ||
return (0, _dateFormatter.getFormatter)(locale, options); | ||
} | ||
}, { | ||
key: 'valueType', | ||
key: "formatNumber", | ||
get: function get() { | ||
var locale = this.props.locale; | ||
var options = { | ||
useGrouping: false | ||
}; | ||
return (0, _dateFormatter.getFormatter)(locale, options); | ||
} | ||
}, { | ||
key: "valueType", | ||
get: function get() { | ||
var maxDetail = this.props.maxDetail; | ||
return maxDetail; | ||
} | ||
}, { | ||
key: 'nativeValueParser', | ||
key: "nativeValueParser", | ||
get: function get() { | ||
@@ -444,4 +473,6 @@ switch (this.valueType) { | ||
return _dates.getHoursMinutes; | ||
case 'second': | ||
return _dates.getHoursMinutesSeconds; | ||
default: | ||
@@ -452,31 +483,30 @@ throw new Error('Invalid valueType.'); | ||
}, { | ||
key: 'divider', | ||
key: "divider", | ||
get: function get() { | ||
var date = new Date(2017, 0, 1, 21, 12, 13); | ||
return this.formatTime(date).match(/[^0-9a-z]/i)[0]; | ||
} | ||
}, { | ||
key: 'placeholder', | ||
key: "placeholder", | ||
get: function get() { | ||
var locale = this.props.locale; | ||
var date = new Date(2017, 0, 1, 21, 13, 14); | ||
return this.formatTime(date).replace('21', 'hour-24').replace('9', 'hour-12').replace('13', 'minute').replace('14', 'second').replace(new RegExp((0, _utils.getAmPmLabels)(locale).join('|')), 'ampm'); | ||
var hour24 = 21; | ||
var hour12 = 9; | ||
var minute = 13; | ||
var second = 14; | ||
var date = new Date(2017, 0, 1, hour24, minute, second); | ||
return this.formatTime(date).replace(this.formatNumber(hour24), 'hour-24').replace(this.formatNumber(hour12), 'hour-12').replace(this.formatNumber(minute), 'minute').replace(this.formatNumber(second), 'second').replace(new RegExp((0, _utils.getAmPmLabels)(locale).join('|')), 'ampm'); | ||
} | ||
}, { | ||
key: 'commonInputProps', | ||
key: "commonInputProps", | ||
get: function get() { | ||
var _this2 = this; | ||
var _props3 = this.props, | ||
className = _props3.className, | ||
disabled = _props3.disabled, | ||
isClockOpen = _props3.isClockOpen, | ||
maxTime = _props3.maxTime, | ||
minTime = _props3.minTime, | ||
required = _props3.required; | ||
var _this$props3 = this.props, | ||
className = _this$props3.className, | ||
disabled = _this$props3.disabled, | ||
isClockOpen = _this$props3.isClockOpen, | ||
maxTime = _this$props3.maxTime, | ||
minTime = _this$props3.minTime, | ||
required = _this$props3.required; | ||
return { | ||
@@ -494,27 +524,10 @@ className: className, | ||
// Save a reference to each input field | ||
_this2[name + 'Input'] = ref; | ||
_this2["".concat(name, "Input")] = ref; | ||
} | ||
}; | ||
} | ||
/** | ||
* 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) { | ||
var nextState = {}; | ||
/** | ||
@@ -524,6 +537,6 @@ * If isClockOpen flag has changed, we have to update it. | ||
*/ | ||
if (nextProps.isClockOpen !== prevState.isClockOpen) { | ||
nextState.isClockOpen = nextProps.isClockOpen; | ||
} | ||
/** | ||
@@ -534,5 +547,7 @@ * If the next value is different from the current one (with an exception of situation in | ||
*/ | ||
var nextValue = nextProps.value; | ||
if ( | ||
// Toggling calendar visibility resets values | ||
if ( // Toggling calendar visibility resets values | ||
nextState.isClockOpen // Flag was toggled | ||
@@ -546,3 +561,2 @@ || hoursAreDifferent(nextValue, prevState.value)) { | ||
nextState.amPm = _convert24to2[1]; | ||
nextState.hour = (0, _dates.getHours)(nextValue); | ||
@@ -557,2 +571,3 @@ nextState.minute = (0, _dates.getMinutes)(nextValue); | ||
} | ||
nextState.value = nextValue; | ||
@@ -569,4 +584,2 @@ } | ||
exports.default = TimeInput; | ||
TimeInput.defaultProps = { | ||
@@ -576,17 +589,15 @@ maxDetail: 'minute', | ||
}; | ||
TimeInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
isClockOpen: _propTypes2.default.bool, | ||
locale: _propTypes2.default.string, | ||
maxDetail: _propTypes2.default.oneOf(allViews), | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
name: _propTypes2.default.string, | ||
onChange: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.oneOfType([_propTypes3.isTime, _propTypes2.default.instanceOf(Date)]) | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
isClockOpen: _propTypes.default.bool, | ||
locale: _propTypes.default.string, | ||
maxDetail: _propTypes.default.oneOf(allViews), | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
name: _propTypes.default.string, | ||
onChange: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.oneOfType([_propTypes2.isTime, _propTypes.default.instanceOf(Date)]) | ||
}; | ||
(0, _reactLifecyclesCompat.polyfill)(TimeInput); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,34 +6,49 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
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 _react = _interopRequireWildcard(require("react")); | ||
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 _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react = require('react'); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _dates = require("../shared/dates"); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = require("../shared/propTypes"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _utils = require("../shared/utils"); | ||
var _mergeClassNames = require('merge-class-names'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
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 _dates = require('../shared/dates'); | ||
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 _propTypes3 = require('../shared/propTypes'); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
var _utils = require('../shared/utils'); | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _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 _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 AmPm = function (_PureComponent) { | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } 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 _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 AmPm = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(AmPm, _PureComponent); | ||
@@ -44,18 +59,16 @@ | ||
return _possibleConstructorReturn(this, (AmPm.__proto__ || Object.getPrototypeOf(AmPm)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(AmPm).apply(this, arguments)); | ||
} | ||
_createClass(AmPm, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
locale = _props.locale, | ||
onChange = _props.onChange, | ||
required = _props.required, | ||
value = _props.value; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
locale = _this$props.locale, | ||
onChange = _this$props.onChange, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
var name = 'amPm'; | ||
@@ -68,48 +81,34 @@ | ||
return _react2.default.createElement( | ||
'select', | ||
{ | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__amPm'), | ||
disabled: disabled, | ||
name: name, | ||
onChange: onChange, | ||
ref: function ref(_ref) { | ||
if (itemRef) { | ||
itemRef(_ref, name); | ||
} | ||
}, | ||
required: required, | ||
value: value !== null ? value : '' | ||
return _react.default.createElement("select", { | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__amPm")), | ||
disabled: disabled, | ||
name: name, | ||
onChange: onChange, | ||
ref: function ref(_ref) { | ||
if (itemRef) { | ||
itemRef(_ref, name); | ||
} | ||
}, | ||
!value && _react2.default.createElement( | ||
'option', | ||
{ value: '' }, | ||
'--' | ||
), | ||
_react2.default.createElement( | ||
'option', | ||
{ disabled: this.amDisabled, value: 'am' }, | ||
amLabel | ||
), | ||
_react2.default.createElement( | ||
'option', | ||
{ disabled: this.pmDisabled, value: 'pm' }, | ||
pmLabel | ||
) | ||
); | ||
required: required, | ||
value: value !== null ? value : '' | ||
}, !value && _react.default.createElement("option", { | ||
value: "" | ||
}, "--"), _react.default.createElement("option", { | ||
disabled: this.amDisabled, | ||
value: "am" | ||
}, amLabel), _react.default.createElement("option", { | ||
disabled: this.pmDisabled, | ||
value: "pm" | ||
}, pmLabel)); | ||
} | ||
}, { | ||
key: 'amDisabled', | ||
key: "amDisabled", | ||
get: function get() { | ||
var minTime = this.props.minTime; | ||
return minTime && (0, _dates.convert24to12)((0, _dates.getHours)(minTime))[1] === 'pm'; | ||
} | ||
}, { | ||
key: 'pmDisabled', | ||
key: "pmDisabled", | ||
get: function get() { | ||
var maxTime = this.props.maxTime; | ||
return maxTime && (0, _dates.convert24to12)((0, _dates.getHours)(maxTime))[1] === 'am'; | ||
@@ -123,13 +122,13 @@ } | ||
AmPm.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
locale: _propTypes2.default.string, | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
onChange: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.oneOf(['am', 'pm']) | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
locale: _propTypes.default.string, | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
onChange: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.oneOf(['am', 'pm']) | ||
}; | ||
exports.default = AmPm; | ||
var _default = AmPm; | ||
exports.default = _default; |
@@ -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 Hour12Input = function (_PureComponent) { | ||
var Hour12Input = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(Hour12Input, _PureComponent); | ||
@@ -47,25 +56,23 @@ | ||
return _possibleConstructorReturn(this, (Hour12Input.__proto__ || Object.getPrototypeOf(Hour12Input)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Hour12Input).apply(this, arguments)); | ||
} | ||
_createClass(Hour12Input, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxHour = this.maxHour, | ||
minHour = this.minHour; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
value = _props.value; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
var name = 'hour12'; | ||
var value12 = value !== null && (0, _dates.convert24to12)(value)[0]; | ||
return _react2.default.createElement('input', { | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__hour'), | ||
return _react.default.createElement("input", { | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__hour")), | ||
disabled: disabled, | ||
@@ -83,3 +90,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -95,3 +102,3 @@ if (_ref) { | ||
required: required, | ||
type: 'number', | ||
type: "number", | ||
value: value12 !== null ? value12 : '' | ||
@@ -101,13 +108,11 @@ }); | ||
}, { | ||
key: 'maxHour', | ||
key: "maxHour", | ||
get: function get() { | ||
var maxTime = this.props.maxTime; | ||
return (0, _utils.min)(12, maxTime && (0, _dates.convert24to12)((0, _dates.getHours)(maxTime))[0]); | ||
} | ||
}, { | ||
key: 'minHour', | ||
key: "minHour", | ||
get: function get() { | ||
var minTime = this.props.minTime; | ||
return (0, _utils.max)(1, minTime && (0, _dates.convert24to12)((0, _dates.getHours)(minTime))[0]); | ||
@@ -121,14 +126,12 @@ } | ||
exports.default = Hour12Input; | ||
Hour12Input.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _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 Hour24Input = function (_PureComponent) { | ||
var Hour24Input = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(Hour24Input, _PureComponent); | ||
@@ -47,24 +56,22 @@ | ||
return _possibleConstructorReturn(this, (Hour24Input.__proto__ || Object.getPrototypeOf(Hour24Input)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Hour24Input).apply(this, arguments)); | ||
} | ||
_createClass(Hour24Input, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxHour = this.maxHour, | ||
minHour = this.minHour; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
value = _props.value; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
var name = 'hour24'; | ||
return _react2.default.createElement('input', { | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__hour'), | ||
return _react.default.createElement("input", { | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__hour")), | ||
disabled: disabled, | ||
@@ -82,3 +89,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -94,3 +101,3 @@ if (_ref) { | ||
required: required, | ||
type: 'number', | ||
type: "number", | ||
value: value !== null ? value : '' | ||
@@ -100,13 +107,11 @@ }); | ||
}, { | ||
key: 'maxHour', | ||
key: "maxHour", | ||
get: function get() { | ||
var maxTime = this.props.maxTime; | ||
return (0, _utils.min)(23, maxTime && (0, _dates.getHours)(maxTime)); | ||
} | ||
}, { | ||
key: 'minHour', | ||
key: "minHour", | ||
get: function get() { | ||
var minTime = this.props.minTime; | ||
return (0, _utils.max)(0, minTime && (0, _dates.getHours)(minTime)); | ||
@@ -120,14 +125,12 @@ } | ||
exports.default = Hour24Input; | ||
Hour24Input.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
itemRef: _propTypes2.default.func, | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
itemRef: _propTypes.default.func, | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _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 MinuteInput = function (_PureComponent) { | ||
var MinuteInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(MinuteInput, _PureComponent); | ||
@@ -47,30 +56,27 @@ | ||
return _possibleConstructorReturn(this, (MinuteInput.__proto__ || Object.getPrototypeOf(MinuteInput)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(MinuteInput).apply(this, arguments)); | ||
} | ||
_createClass(MinuteInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxMinute = this.maxMinute, | ||
minMinute = this.minMinute; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
value = _props.value; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
var name = 'minute'; | ||
var hasLeadingZero = value !== null && value < 10; | ||
return [hasLeadingZero && _react2.default.createElement( | ||
'span', | ||
{ key: 'leadingZero', className: className + '__leadingZero' }, | ||
'0' | ||
), _react2.default.createElement('input', { | ||
key: 'minute', | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__minute', hasLeadingZero && className + '__input--hasLeadingZero'), | ||
return [hasLeadingZero && _react.default.createElement("span", { | ||
key: "leadingZero", | ||
className: "".concat(className, "__leadingZero") | ||
}, "0"), _react.default.createElement("input", { | ||
key: "minute", | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__minute"), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), | ||
disabled: disabled, | ||
@@ -88,3 +94,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -100,3 +106,3 @@ if (_ref) { | ||
required: required, | ||
type: 'number', | ||
type: "number", | ||
value: value !== null ? value : '' | ||
@@ -106,17 +112,15 @@ })]; | ||
}, { | ||
key: 'maxMinute', | ||
key: "maxMinute", | ||
get: function get() { | ||
var _props2 = this.props, | ||
hour = _props2.hour, | ||
maxTime = _props2.maxTime; | ||
var _this$props2 = this.props, | ||
hour = _this$props2.hour, | ||
maxTime = _this$props2.maxTime; | ||
return (0, _utils.min)(59, maxTime && hour === (0, _dates.getHours)(maxTime) && (0, _dates.getMinutes)(maxTime)); | ||
} | ||
}, { | ||
key: 'minMinute', | ||
key: "minMinute", | ||
get: function get() { | ||
var _props3 = this.props, | ||
hour = _props3.hour, | ||
minTime = _props3.minTime; | ||
var _this$props3 = this.props, | ||
hour = _this$props3.hour, | ||
minTime = _this$props3.minTime; | ||
return (0, _utils.max)(0, minTime && hour === (0, _dates.getHours)(minTime) && (0, _dates.getMinutes)(minTime)); | ||
@@ -130,15 +134,13 @@ } | ||
exports.default = MinuteInput; | ||
MinuteInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
hour: _propTypes2.default.number, | ||
itemRef: _propTypes2.default.func, | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
hour: _propTypes.default.number, | ||
itemRef: _propTypes.default.func, | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.number | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,61 +6,76 @@ 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, | ||
step = this.step; | ||
var _props = this.props, | ||
disabled = _props.disabled, | ||
maxTime = _props.maxTime, | ||
minTime = _props.minTime, | ||
name = _props.name, | ||
onChange = _props.onChange, | ||
required = _props.required, | ||
value = _props.value; | ||
return _react2.default.createElement('input', { | ||
type: 'time', | ||
var _this$props = this.props, | ||
disabled = _this$props.disabled, | ||
maxTime = _this$props.maxTime, | ||
minTime = _this$props.minTime, | ||
name = _this$props.name, | ||
onChange = _this$props.onChange, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
return _react.default.createElement("input", { | ||
type: "time", | ||
disabled: disabled, | ||
@@ -84,16 +99,18 @@ max: maxTime ? nativeValueParser(maxTime) : null, | ||
}, { | ||
key: 'nativeValueParser', | ||
key: "nativeValueParser", | ||
get: function get() { | ||
var valueType = this.props.valueType; | ||
switch (valueType) { | ||
case 'hour': | ||
return function (value) { | ||
return (0, _dates.getHours)(value) + ':00'; | ||
return "".concat((0, _dates.getHours)(value), ":00"); | ||
}; | ||
case 'minute': | ||
return _dates.getHoursMinutes; | ||
case 'second': | ||
return _dates.getHoursMinutesSeconds; | ||
default: | ||
@@ -104,14 +121,16 @@ throw new Error('Invalid valueType.'); | ||
}, { | ||
key: 'step', | ||
key: "step", | ||
get: function get() { | ||
var valueType = this.props.valueType; | ||
switch (valueType) { | ||
case 'hour': | ||
return 3600; | ||
case 'minute': | ||
return 60; | ||
case 'second': | ||
return 1; | ||
default: | ||
@@ -127,13 +146,11 @@ throw new Error('Invalid valueType.'); | ||
exports.default = NativeInput; | ||
NativeInput.propTypes = { | ||
disabled: _propTypes2.default.bool, | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
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, | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
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 SecondInput = function (_PureComponent) { | ||
var SecondInput = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(SecondInput, _PureComponent); | ||
@@ -47,30 +56,27 @@ | ||
return _possibleConstructorReturn(this, (SecondInput.__proto__ || Object.getPrototypeOf(SecondInput)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(SecondInput).apply(this, arguments)); | ||
} | ||
_createClass(SecondInput, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
var maxSecond = this.maxSecond, | ||
minSecond = this.minSecond; | ||
var _props = this.props, | ||
className = _props.className, | ||
disabled = _props.disabled, | ||
itemRef = _props.itemRef, | ||
onChange = _props.onChange, | ||
onKeyDown = _props.onKeyDown, | ||
required = _props.required, | ||
value = _props.value; | ||
var _this$props = this.props, | ||
className = _this$props.className, | ||
disabled = _this$props.disabled, | ||
itemRef = _this$props.itemRef, | ||
onChange = _this$props.onChange, | ||
onKeyDown = _this$props.onKeyDown, | ||
required = _this$props.required, | ||
value = _this$props.value; | ||
var name = 'second'; | ||
var hasLeadingZero = value !== null && value < 10; | ||
return [hasLeadingZero && _react2.default.createElement( | ||
'span', | ||
{ key: 'leadingZero', className: className + '__leadingZero' }, | ||
'0' | ||
), _react2.default.createElement('input', { | ||
key: 'second', | ||
className: (0, _mergeClassNames2.default)(className + '__input', className + '__second', hasLeadingZero && className + '__input--hasLeadingZero'), | ||
return [hasLeadingZero && _react.default.createElement("span", { | ||
key: "leadingZero", | ||
className: "".concat(className, "__leadingZero") | ||
}, "0"), _react.default.createElement("input", { | ||
key: "second", | ||
autoComplete: "off", | ||
className: (0, _mergeClassNames.default)("".concat(className, "__input"), "".concat(className, "__second"), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), | ||
disabled: disabled, | ||
@@ -88,3 +94,3 @@ name: name, | ||
}, | ||
placeholder: '--', | ||
placeholder: "--", | ||
ref: function ref(_ref) { | ||
@@ -100,3 +106,3 @@ if (_ref) { | ||
required: required, | ||
type: 'number', | ||
type: "number", | ||
value: value !== null ? value : '' | ||
@@ -106,19 +112,17 @@ })]; | ||
}, { | ||
key: 'maxSecond', | ||
key: "maxSecond", | ||
get: function get() { | ||
var _props2 = this.props, | ||
hour = _props2.hour, | ||
minute = _props2.minute, | ||
maxTime = _props2.maxTime; | ||
var _this$props2 = this.props, | ||
hour = _this$props2.hour, | ||
minute = _this$props2.minute, | ||
maxTime = _this$props2.maxTime; | ||
return (0, _utils.min)(59, maxTime && hour === (0, _dates.getHours)(maxTime) && minute === (0, _dates.getMinutes)(maxTime) && (0, _dates.getSeconds)(maxTime)); | ||
} | ||
}, { | ||
key: 'minSecond', | ||
key: "minSecond", | ||
get: function get() { | ||
var _props3 = this.props, | ||
hour = _props3.hour, | ||
minute = _props3.minute, | ||
minTime = _props3.minTime; | ||
var _this$props3 = this.props, | ||
hour = _this$props3.hour, | ||
minute = _this$props3.minute, | ||
minTime = _this$props3.minTime; | ||
return (0, _utils.max)(0, minTime && hour === (0, _dates.getHours)(minTime) && minute === (0, _dates.getMinutes)(minTime) && (0, _dates.getSeconds)(minTime)); | ||
@@ -132,16 +136,14 @@ } | ||
exports.default = SecondInput; | ||
SecondInput.propTypes = { | ||
className: _propTypes2.default.string.isRequired, | ||
disabled: _propTypes2.default.bool, | ||
hour: _propTypes2.default.number, | ||
itemRef: _propTypes2.default.func, | ||
maxTime: _propTypes3.isTime, | ||
minute: _propTypes2.default.number, | ||
minTime: _propTypes3.isTime, | ||
onChange: _propTypes2.default.func, | ||
onKeyDown: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.number | ||
className: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
hour: _propTypes.default.number, | ||
itemRef: _propTypes.default.func, | ||
maxTime: _propTypes2.isTime, | ||
minute: _propTypes.default.number, | ||
minTime: _propTypes2.isTime, | ||
onChange: _propTypes.default.func, | ||
onKeyDown: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.number | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,69 +6,90 @@ 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 _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 _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react = require('react'); | ||
var _reactLifecyclesCompat = require("react-lifecycles-compat"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _makeEventProps = _interopRequireDefault(require("make-event-props")); | ||
var _propTypes = require('prop-types'); | ||
var _mergeClassNames = _interopRequireDefault(require("merge-class-names")); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _detectElementOverflow = _interopRequireDefault(require("detect-element-overflow")); | ||
var _reactLifecyclesCompat = require('react-lifecycles-compat'); | ||
var _entry = _interopRequireDefault(require("react-clock/dist/entry.nostyle")); | ||
var _makeEventProps = require('make-event-props'); | ||
var _TimeInput = _interopRequireDefault(require("./TimeInput")); | ||
var _makeEventProps2 = _interopRequireDefault(_makeEventProps); | ||
var _propTypes2 = require("./shared/propTypes"); | ||
var _mergeClassNames = require('merge-class-names'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _mergeClassNames2 = _interopRequireDefault(_mergeClassNames); | ||
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 _detectElementOverflow = require('detect-element-overflow'); | ||
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 _detectElementOverflow2 = _interopRequireDefault(_detectElementOverflow); | ||
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 _entry = require('react-clock/dist/entry.nostyle'); | ||
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 _entry2 = _interopRequireDefault(_entry); | ||
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 _TimeInput = require('./TimeInput'); | ||
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 _TimeInput2 = _interopRequireDefault(_TimeInput); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _propTypes3 = require('./shared/propTypes'); | ||
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 _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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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 _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 _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 _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 allViews = ['hour', 'minute', 'second']; | ||
var baseClassName = 'react-time-picker'; | ||
var TimePicker = function (_PureComponent) { | ||
var TimePicker = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(TimePicker, _PureComponent); | ||
function TimePicker() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, TimePicker); | ||
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 = TimePicker.__proto__ || Object.getPrototypeOf(TimePicker)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this.openClock = function () { | ||
_this.setState({ isOpen: true }); | ||
}, _this.closeClock = function () { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TimePicker)).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.closeClock(); | ||
} | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openClock", function () { | ||
_this.setState({ | ||
isOpen: true | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closeClock", function () { | ||
_this.setState(function (prevState) { | ||
@@ -79,9 +100,17 @@ if (!prevState.isOpen) { | ||
return { isOpen: false }; | ||
return { | ||
isOpen: false | ||
}; | ||
}); | ||
}, _this.toggleClock = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "toggleClock", 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 closeClock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
@@ -98,3 +127,5 @@ | ||
} | ||
}, _this.onFocus = function (event) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onFocus", function (event) { | ||
var _this$props = _this.props, | ||
@@ -104,8 +135,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) { | ||
@@ -116,86 +146,75 @@ return; | ||
_this.openClock(); | ||
}, _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.closeClock(); | ||
} | ||
}); | ||
}, _this.stopPropagation = function (event) { | ||
return event.stopPropagation(); | ||
}, _this.clear = function () { | ||
return _this.onChange(null); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return _this; | ||
} | ||
_createClass(TimePicker, [{ | ||
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, | ||
clearIcon = _props.clearIcon, | ||
clockIcon = _props.clockIcon, | ||
disableClock = _props.disableClock, | ||
disabled = _props.disabled, | ||
isOpen = _props.isOpen, | ||
locale = _props.locale, | ||
maxDetail = _props.maxDetail, | ||
maxTime = _props.maxTime, | ||
minTime = _props.minTime, | ||
name = _props.name, | ||
required = _props.required, | ||
value = _props.value; | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: baseClassName + '__wrapper' }, | ||
_react2.default.createElement(_TimeInput2.default, { | ||
className: baseClassName + '__inputGroup', | ||
disabled: disabled, | ||
locale: locale, | ||
isClockOpen: isOpen, | ||
maxDetail: maxDetail, | ||
maxTime: maxTime, | ||
minTime: minTime, | ||
name: name, | ||
onChange: this.onChange, | ||
placeholder: this.placeholder, | ||
required: required, | ||
value: value | ||
}), | ||
clearIcon !== null && _react2.default.createElement( | ||
'button', | ||
{ | ||
className: baseClassName + '__clear-button ' + baseClassName + '__button', | ||
disabled: disabled, | ||
onClick: this.clear, | ||
onFocus: this.stopPropagation, | ||
type: 'button' | ||
}, | ||
clearIcon | ||
), | ||
clockIcon !== null && !disableClock && _react2.default.createElement( | ||
'button', | ||
{ | ||
className: baseClassName + '__clock-button ' + baseClassName + '__button', | ||
disabled: disabled, | ||
onClick: this.toggleClock, | ||
onFocus: this.stopPropagation, | ||
onBlur: this.resetValue, | ||
type: 'button' | ||
}, | ||
clockIcon | ||
) | ||
); | ||
var _this$props2 = this.props, | ||
clearIcon = _this$props2.clearIcon, | ||
clockIcon = _this$props2.clockIcon, | ||
disableClock = _this$props2.disableClock, | ||
disabled = _this$props2.disabled, | ||
isOpen = _this$props2.isOpen, | ||
locale = _this$props2.locale, | ||
maxDetail = _this$props2.maxDetail, | ||
maxTime = _this$props2.maxTime, | ||
minTime = _this$props2.minTime, | ||
name = _this$props2.name, | ||
required = _this$props2.required, | ||
value = _this$props2.value; | ||
return _react.default.createElement("div", { | ||
className: "".concat(baseClassName, "__wrapper") | ||
}, _react.default.createElement(_TimeInput.default, { | ||
className: "".concat(baseClassName, "__inputGroup"), | ||
disabled: disabled, | ||
locale: locale, | ||
isClockOpen: isOpen, | ||
maxDetail: maxDetail, | ||
maxTime: maxTime, | ||
minTime: minTime, | ||
name: name, | ||
onChange: this.onChange, | ||
placeholder: this.placeholder, | ||
required: required, | ||
value: value | ||
}), 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), clockIcon !== null && !disableClock && _react.default.createElement("button", { | ||
className: "".concat(baseClassName, "__clock-button ").concat(baseClassName, "__button"), | ||
disabled: disabled, | ||
onClick: this.toggleClock, | ||
onFocus: this.stopPropagation, | ||
onBlur: this.resetValue, | ||
type: "button" | ||
}, clockIcon)); | ||
} | ||
}, { | ||
key: 'renderClock', | ||
key: "renderClock", | ||
value: function renderClock() { | ||
@@ -207,3 +226,2 @@ var _this2 = this; | ||
if (isOpen === null || disableClock) { | ||
@@ -213,80 +231,65 @@ return null; | ||
var _props2 = this.props, | ||
clockClassName = _props2.clockClassName, | ||
timePickerClassName = _props2.className, | ||
maxDetail = _props2.maxDetail, | ||
onChange = _props2.onChange, | ||
clockProps = _objectWithoutProperties(_props2, ['clockClassName', 'className', 'maxDetail', 'onChange']); | ||
var _this$props3 = this.props, | ||
clockClassName = _this$props3.clockClassName, | ||
timePickerClassName = _this$props3.className, | ||
maxDetail = _this$props3.maxDetail, | ||
onChange = _this$props3.onChange, | ||
clockProps = _objectWithoutProperties(_this$props3, ["clockClassName", "className", "maxDetail", "onChange"]); | ||
var className = baseClassName + '__clock'; | ||
var className = "".concat(baseClassName, "__clock"); | ||
var maxDetailIndex = allViews.indexOf(maxDetail); | ||
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: clockClassName, | ||
renderMinuteHand: maxDetailIndex > 0, | ||
renderSecondHand: maxDetailIndex > 1 | ||
}, clockProps)) | ||
); | ||
} | ||
}, _react.default.createElement(_entry.default, _extends({ | ||
className: clockClassName, | ||
renderMinuteHand: maxDetailIndex > 0, | ||
renderSecondHand: maxDetailIndex > 1 | ||
}, clockProps))); | ||
} | ||
}, { | ||
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.renderClock() | ||
); | ||
_this3.wrapper = _ref2; | ||
} | ||
}), this.renderInputs(), this.renderClock()); | ||
} | ||
}, { | ||
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) { | ||
@@ -309,25 +312,39 @@ if (nextProps.isOpen !== prevState.isOpenProps) { | ||
var ClockIcon = _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", | ||
fill: "none" | ||
}, _react.default.createElement("circle", { | ||
cx: "9.5", | ||
cy: "9.5", | ||
r: "7.5" | ||
}), _react.default.createElement("path", { | ||
d: "M9.5 4.5 v5 h4" | ||
}))); | ||
var ClockIcon = _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', fill: 'none' }, | ||
_react2.default.createElement('circle', { cx: '9.5', cy: '9.5', r: '7.5' }), | ||
_react2.default.createElement('path', { d: 'M9.5 4.5 v5 h4' }) | ||
) | ||
); | ||
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' }) | ||
) | ||
); | ||
TimePicker.defaultProps = { | ||
@@ -339,21 +356,19 @@ clearIcon: ClearIcon, | ||
}; | ||
TimePicker.propTypes = _extends({}, _entry2.default.propTypes, { | ||
clockClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]), | ||
clockIcon: _propTypes2.default.node, | ||
className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]), | ||
clearIcon: _propTypes2.default.node, | ||
disabled: _propTypes2.default.bool, | ||
disableClock: _propTypes2.default.bool, | ||
isOpen: _propTypes2.default.bool, | ||
locale: _propTypes2.default.string, | ||
maxDetail: _propTypes2.default.oneOf(allViews), | ||
maxTime: _propTypes3.isTime, | ||
minTime: _propTypes3.isTime, | ||
name: _propTypes2.default.string, | ||
onChange: _propTypes2.default.func, | ||
required: _propTypes2.default.bool, | ||
value: _propTypes2.default.oneOfType([_propTypes3.isTime, _propTypes2.default.instanceOf(Date)]) | ||
TimePicker.propTypes = _objectSpread({}, _entry.default.propTypes, { | ||
clockClassName: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]), | ||
clockIcon: _propTypes.default.node, | ||
className: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]), | ||
clearIcon: _propTypes.default.node, | ||
disabled: _propTypes.default.bool, | ||
disableClock: _propTypes.default.bool, | ||
isOpen: _propTypes.default.bool, | ||
locale: _propTypes.default.string, | ||
maxDetail: _propTypes.default.oneOf(allViews), | ||
maxTime: _propTypes2.isTime, | ||
minTime: _propTypes2.isTime, | ||
name: _propTypes.default.string, | ||
onChange: _propTypes.default.func, | ||
required: _propTypes.default.bool, | ||
value: _propTypes.default.oneOfType([_propTypes2.isTime, _propTypes.default.instanceOf(Date)]) | ||
}); | ||
(0, _reactLifecyclesCompat.polyfill)(TimePicker); |
{ | ||
"name": "react-time-picker", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "A time picker for your React app.", | ||
"main": "dist/entry.js", | ||
"es6": "src/entry.js", | ||
"source": "src/entry.js", | ||
"scripts": { | ||
"build": "yarn run build-js && yarn run copy-styles && yarn run build-styles", | ||
"build-js": "babel src -d dist --ignore __tests__", | ||
"build-js": "babel src -d dist --ignore **/__tests__", | ||
"build-styles": "lessc ./dist/TimePicker.less ./dist/TimePicker.css", | ||
@@ -49,13 +49,13 @@ "clean": "rimraf dist", | ||
"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", | ||
@@ -68,5 +68,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" | ||
@@ -73,0 +73,0 @@ }, |
@@ -166,11 +166,31 @@ import React from 'react'; | ||
it('closes Calendar component when focused outside', () => { | ||
it('closes Clock component when clicked outside', () => { | ||
const root = document.createElement('div'); | ||
document.body.appendChild(root); | ||
const component = mount( | ||
<TimePicker isOpen /> | ||
<TimePicker isOpen />, | ||
{ attachTo: root } | ||
); | ||
const customInputs = component.find('input[type="number"]'); | ||
const hourInput = customInputs.at(0); | ||
const event = document.createEvent('MouseEvent'); | ||
event.initEvent('mousedown', true, true); | ||
document.body.dispatchEvent(event); | ||
component.update(); | ||
hourInput.simulate('blur'); | ||
expect(component.state('isOpen')).toBe(false); | ||
}); | ||
it('closes Clock component when focused outside', () => { | ||
const root = document.createElement('div'); | ||
document.body.appendChild(root); | ||
const component = mount( | ||
<TimePicker isOpen />, | ||
{ attachTo: root } | ||
); | ||
const event = document.createEvent('FocusEvent'); | ||
event.initEvent('focusin', true, true); | ||
document.body.dispatchEvent(event); | ||
component.update(); | ||
@@ -181,3 +201,3 @@ | ||
it('does not close Calendar component when focused inside', () => { | ||
it('does not close Clock component when focused inside', () => { | ||
const component = mount( | ||
@@ -184,0 +204,0 @@ <TimePicker isOpen /> |
@@ -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 @@ |
@@ -23,3 +23,3 @@ import { getFormatter } from './dateFormatter'; | ||
export const getAmPmLabels = (locale) => { | ||
const amPmFormatter = getFormatter({ hour: 'numeric' }, locale); | ||
const amPmFormatter = getFormatter(locale, { hour: 'numeric' }); | ||
const amString = amPmFormatter(new Date(2017, 0, 1, 9)); | ||
@@ -26,0 +26,0 @@ const pmString = amPmFormatter(new Date(2017, 0, 1, 21)); |
@@ -64,3 +64,3 @@ import React, { PureComponent } from 'react'; | ||
const res = [...arr, divider]; | ||
if (matches[index]) { | ||
if (matches && matches[index]) { | ||
res.push(elementFunctions[matches[index]]()); | ||
@@ -131,5 +131,13 @@ } | ||
return getFormatter(options, locale); | ||
return getFormatter(locale, options); | ||
} | ||
get formatNumber() { | ||
const { locale } = this.props; | ||
const options = { useGrouping: false }; | ||
return getFormatter(locale, options); | ||
} | ||
/** | ||
@@ -173,10 +181,15 @@ * Gets current value in a desired format. | ||
const { locale } = this.props; | ||
const date = new Date(2017, 0, 1, 21, 13, 14); | ||
const hour24 = 21; | ||
const hour12 = 9; | ||
const minute = 13; | ||
const second = 14; | ||
const date = new Date(2017, 0, 1, hour24, minute, second); | ||
return ( | ||
this.formatTime(date) | ||
.replace('21', 'hour-24') | ||
.replace('9', 'hour-12') | ||
.replace('13', 'minute') | ||
.replace('14', 'second') | ||
.replace(this.formatNumber(hour24), 'hour-24') | ||
.replace(this.formatNumber(hour12), 'hour-12') | ||
.replace(this.formatNumber(minute), 'minute') | ||
.replace(this.formatNumber(second), 'second') | ||
.replace(new RegExp(getAmPmLabels(locale).join('|')), 'ampm') | ||
@@ -183,0 +196,0 @@ ); |
@@ -42,2 +42,3 @@ import React, { PureComponent } from 'react'; | ||
<input | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -44,0 +45,0 @@ `${className}__input`, |
@@ -38,2 +38,3 @@ import React, { PureComponent } from 'react'; | ||
<input | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -40,0 +41,0 @@ `${className}__input`, |
@@ -48,2 +48,3 @@ import React, { PureComponent } from 'react'; | ||
key="minute" | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -50,0 +51,0 @@ `${className}__input`, |
@@ -51,2 +51,3 @@ import React, { PureComponent } from 'react'; | ||
key="second" | ||
autoComplete="off" | ||
className={mergeClassNames( | ||
@@ -53,0 +54,0 @@ `${className}__input`, |
@@ -35,2 +35,19 @@ 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.closeClock(); | ||
} | ||
} | ||
openClock = () => { | ||
@@ -80,18 +97,2 @@ this.setState({ isOpen: true }); | ||
onBlur = () => { | ||
const { onBlur } = this.props; | ||
if (onBlur) { | ||
onBlur(event); | ||
} | ||
requestAnimationFrame(() => { | ||
const stillHasFocus = this.wrapper.querySelector(':focus'); | ||
if (!stillHasFocus) { | ||
this.closeClock(); | ||
} | ||
}); | ||
} | ||
stopPropagation = event => event.stopPropagation(); | ||
@@ -231,3 +232,2 @@ | ||
onFocus={this.onFocus} | ||
onBlur={this.onBlur} | ||
ref={(ref) => { | ||
@@ -234,0 +234,0 @@ if (!ref) { |
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
175057
4381