react-time-picker-input
Advanced tools
Comparing version 2.1.31 to 2.1.32
@@ -79,3 +79,6 @@ import "core-js/modules/es.symbol.description.js"; | ||
reference: inputRef | ||
}, /*#__PURE__*/React.createElement("input", _extends({}, getSameInputProps(propsAndState), { | ||
}, (onKeyDown, onKeyUp) => /*#__PURE__*/React.createElement("input", _extends({ | ||
onKeyDown: onKeyDown, | ||
onKeyUp: onKeyUp | ||
}, getSameInputProps(propsAndState), { | ||
value: amPm, | ||
@@ -82,0 +85,0 @@ type: "text" |
@@ -186,3 +186,6 @@ import "core-js/modules/es.symbol.description.js"; | ||
reference: inputRef | ||
}, /*#__PURE__*/React.createElement("input", _extends({}, getSameInputProps(propsAndState), { | ||
}, (onKeyDown, onKeyUp) => /*#__PURE__*/React.createElement("input", _extends({ | ||
onKeyDown: onKeyDown, | ||
onKeyUp: onKeyUp | ||
}, getSameInputProps(propsAndState), { | ||
onFocus: () => { | ||
@@ -189,0 +192,0 @@ setFirstFocus(true); |
@@ -1,5 +0,3 @@ | ||
import "core-js/modules/es.parse-int.js"; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import "core-js/modules/es.string.match.js"; | ||
import React, { useEffect, useRef } from "react"; | ||
import { useEffect, useRef } from "react"; | ||
import { isChrome51OrLower } from "../../../dist/components/actions"; | ||
var keydownInterruptedRef = false; | ||
@@ -14,48 +12,35 @@ var KeyDown = props => { | ||
}, [onKeyDown]); | ||
var handleKeyDown = event => { | ||
var _onKeyDownRef$current; | ||
keydownInterruptedRef = true; | ||
onKeyDownRef === null || onKeyDownRef === void 0 || (_onKeyDownRef$current = onKeyDownRef.current) === null || _onKeyDownRef$current === void 0 ? void 0 : _onKeyDownRef$current.call(onKeyDownRef, event); | ||
}; | ||
var handleKeyUp = event => { | ||
var _onKeyDownRef$current2; | ||
if (!keydownInterruptedRef) onKeyDownRef === null || onKeyDownRef === void 0 || (_onKeyDownRef$current2 = onKeyDownRef.current) === null || _onKeyDownRef$current2 === void 0 ? void 0 : _onKeyDownRef$current2.call(onKeyDownRef, event); | ||
keydownInterruptedRef = false; | ||
}; | ||
var isOldChrome = isChrome51OrLower(); | ||
useEffect(() => { | ||
onKeyDownRef.current = onKeyDown; | ||
var element = reference === null || reference === void 0 ? void 0 : reference.current; | ||
var handleKeyDown = event => { | ||
var _onKeyDownRef$current; | ||
keydownInterruptedRef = true; | ||
onKeyDownRef === null || onKeyDownRef === void 0 || (_onKeyDownRef$current = onKeyDownRef.current) === null || _onKeyDownRef$current === void 0 ? void 0 : _onKeyDownRef$current.call(onKeyDownRef, event); | ||
}; | ||
var handleKeyUp = event => { | ||
var _onKeyDownRef$current2; | ||
if (!keydownInterruptedRef) onKeyDownRef === null || onKeyDownRef === void 0 || (_onKeyDownRef$current2 = onKeyDownRef.current) === null || _onKeyDownRef$current2 === void 0 ? void 0 : _onKeyDownRef$current2.call(onKeyDownRef, event); | ||
keydownInterruptedRef = false; | ||
}; | ||
if (element) { | ||
if (isChrome51OrLower()) { | ||
element.addEventListener("keydown", handleKeyDown); | ||
element.addEventListener("keyup", handleKeyUp); | ||
} else { | ||
element.addEventListener("keydown", handleKeyDown, { | ||
if (element && !isOldChrome) { | ||
element.addEventListener("keydown", handleKeyDown, { | ||
capture: true | ||
}); | ||
element.addEventListener("keyup", handleKeyUp, { | ||
capture: true | ||
}); | ||
return () => { | ||
element.removeEventListener("keydown", handleKeyDown, { | ||
capture: true | ||
}); | ||
element.addEventListener("keyup", handleKeyUp, { | ||
element.removeEventListener("keyup", handleKeyUp, { | ||
capture: true | ||
}); | ||
} | ||
return () => { | ||
if (isChrome51OrLower()) { | ||
element.removeEventListener("keydown", handleKeyDown); | ||
element.removeEventListener("keyup", handleKeyUp); | ||
} else { | ||
element.removeEventListener("keydown", handleKeyDown, { | ||
capture: true | ||
}); | ||
element.removeEventListener("keyup", handleKeyUp, { | ||
capture: true | ||
}); | ||
} | ||
}; | ||
} | ||
}, []); | ||
var isChrome51OrLower = () => { | ||
var chromeVersion = parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]); | ||
return chromeVersion <= 51; | ||
}; | ||
return children; | ||
return children(isOldChrome ? handleKeyDown : undefined, isOldChrome ? handleKeyUp : undefined); | ||
}; | ||
export default KeyDown; |
@@ -34,3 +34,3 @@ { | ||
], | ||
"version": "2.1.31", | ||
"version": "2.1.32", | ||
"private": false, | ||
@@ -37,0 +37,0 @@ "main": "dist/index.js", |
58902
1074