react-time-picker
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getAmPmLabels = exports.updateInputWidth = exports.max = exports.min = void 0; | ||
exports.callIfDefined = exports.getAmPmLabels = exports.updateInputWidth = exports.max = exports.min = void 0; | ||
@@ -98,3 +98,21 @@ var _dateFormatter = require("./dateFormatter"); | ||
}; | ||
/** | ||
* Calls a function, if it's defined, with specified arguments | ||
* @param {Function} fn | ||
* @param {Object} args | ||
*/ | ||
exports.getAmPmLabels = getAmPmLabels; | ||
exports.getAmPmLabels = getAmPmLabels; | ||
var callIfDefined = function callIfDefined(fn) { | ||
if (fn && typeof fn === 'function') { | ||
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
} | ||
fn.apply(void 0, args); | ||
} | ||
}; | ||
exports.callIfDefined = callIfDefined; |
@@ -26,2 +26,4 @@ "use strict"; | ||
var _utils = require("./shared/utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -163,2 +165,14 @@ | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps, prevState) { | ||
var isOpen = this.state.isOpen; | ||
var _this$props2 = this.props, | ||
onClockClose = _this$props2.onClockClose, | ||
onClockOpen = _this$props2.onClockOpen; | ||
if (isOpen !== prevState.isOpen) { | ||
(0, _utils.callIfDefined)(isOpen ? onClockOpen : onClockClose); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
@@ -172,15 +186,15 @@ value: function componentWillUnmount() { | ||
value: function renderInputs() { | ||
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; | ||
var _this$props3 = this.props, | ||
clearIcon = _this$props3.clearIcon, | ||
clockIcon = _this$props3.clockIcon, | ||
disableClock = _this$props3.disableClock, | ||
disabled = _this$props3.disabled, | ||
isOpen = _this$props3.isOpen, | ||
locale = _this$props3.locale, | ||
maxDetail = _this$props3.maxDetail, | ||
maxTime = _this$props3.maxTime, | ||
minTime = _this$props3.minTime, | ||
name = _this$props3.name, | ||
required = _this$props3.required, | ||
value = _this$props3.value; | ||
return _react.default.createElement("div", { | ||
@@ -226,8 +240,8 @@ className: "".concat(baseClassName, "__wrapper") | ||
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 _this$props4 = this.props, | ||
clockClassName = _this$props4.clockClassName, | ||
timePickerClassName = _this$props4.className, | ||
maxDetail = _this$props4.maxDetail, | ||
onChange = _this$props4.onChange, | ||
clockProps = _objectWithoutProperties(_this$props4, ["clockClassName", "className", "maxDetail", "onChange"]); | ||
@@ -249,5 +263,5 @@ var className = "".concat(baseClassName, "__clock"); | ||
var _this$props4 = this.props, | ||
className = _this$props4.className, | ||
disabled = _this$props4.disabled; | ||
var _this$props5 = this.props, | ||
className = _this$props5.className, | ||
disabled = _this$props5.disabled; | ||
var isOpen = this.state.isOpen; | ||
@@ -254,0 +268,0 @@ return _react.default.createElement("div", _extends({ |
{ | ||
"name": "react-time-picker", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "A time picker for your React app.", | ||
@@ -5,0 +5,0 @@ "main": "dist/entry.js", |
@@ -101,2 +101,4 @@ ![downloads](https://img.shields.io/npm/dt/react-time-picker.svg) ![build](https://img.shields.io/travis/wojtekmaj/react-time-picker/master.svg) ![dependencies](https://img.shields.io/david/wojtekmaj/react-time-picker.svg | ||
|onChange|Function called when the user picks a valid time.|`(value) => alert('New time is: ', value)`| | ||
|onClockClose|Function called when the clock closes.|`() => alert('Clock closed')`| | ||
|onClockOpen|Function called when the clock opens.|`() => alert('Clock opened')`| | ||
|required|Defines whether date input should be required. Defaults to false.|`true`| | ||
@@ -103,0 +105,0 @@ |value|Defines the value of the input.|<ul><li>Date: `new Date()`</li><li>String: `"22:15:00"`</li></ul>| |
@@ -41,1 +41,12 @@ import { getFormatter } from './dateFormatter'; | ||
}; | ||
/** | ||
* Calls a function, if it's defined, with specified arguments | ||
* @param {Function} fn | ||
* @param {Object} args | ||
*/ | ||
export const callIfDefined = (fn, ...args) => { | ||
if (fn && typeof fn === 'function') { | ||
fn(...args); | ||
} | ||
}; |
@@ -13,2 +13,3 @@ import React, { PureComponent } from 'react'; | ||
import { isTime } from './shared/propTypes'; | ||
import { callIfDefined } from './shared/utils'; | ||
@@ -36,3 +37,2 @@ const allViews = ['hour', 'minute', 'second']; | ||
componentDidMount() { | ||
@@ -43,2 +43,11 @@ document.addEventListener('mousedown', this.onOutsideAction); | ||
componentDidUpdate(prevProps, prevState) { | ||
const { isOpen } = this.state; | ||
const { onClockClose, onClockOpen } = this.props; | ||
if (isOpen !== prevState.isOpen) { | ||
callIfDefined(isOpen ? onClockOpen : onClockClose); | ||
} | ||
} | ||
componentWillUnmount() { | ||
@@ -45,0 +54,0 @@ document.removeEventListener('mousedown', this.onOutsideAction); |
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
175000
4388
128