@m3-moretv/react-code-input
Version:
Typescript implementation of some code/pin-code input
25 lines (24 loc) • 706 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c, r) =>
// tslint:disable-next-line
('x' === c ? (r = (Math.random() * 16) | 0) : (r & 0x3) | 0x8).toString(16));
exports.moveToNewTarget = newTarget => {
if (newTarget.current) {
newTarget.current.focus();
newTarget.current.select();
}
};
exports.updateFocus = target => {
setTimeout(() => {
if (target.current) {
target.current.focus();
}
}, 10);
};
exports.defaultOnFocus = event => {
event.target.select();
};
exports.fillEmptyArray = size => {
return Array(size).fill('');
};