@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
26 lines • 743 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.keyLeftMove = exports.keyRightMove = void 0;
const keyRightMove = (pills) => (prevFocus) => {
let newFocus = Math.max(prevFocus, 0);
if (prevFocus >= 0) {
newFocus += 1;
}
if (prevFocus >= pills.length - 1) {
newFocus = 0;
}
return newFocus;
};
exports.keyRightMove = keyRightMove;
const keyLeftMove = (pills) => (prevFocus) => {
let newFocus = Math.max(prevFocus, 0);
if (prevFocus <= pills.length - 1) {
newFocus -= 1;
}
if (prevFocus === 0) {
newFocus = pills.length - 1;
}
return newFocus;
};
exports.keyLeftMove = keyLeftMove;
//# sourceMappingURL=pillSelector.utils.js.map