UNPKG

@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

37 lines 1.24 kB
const YEARS_IN_ROW = 4; export const firstYear = (yearList) => { return yearList.findIndex(year => year === yearList[0]); }; export const lastYear = (yearList) => { return yearList.findIndex(year => year === yearList[yearList.length - 1]); }; export const keyLeftMove = (yearList) => { return previous => { return previous === firstYear(yearList) ? lastYear(yearList) : previous - 1; }; }; export const keyRightMove = (yearList) => { return previous => { return previous === lastYear(yearList) ? firstYear(yearList) : previous + 1; }; }; export const keyUpMove = (yearList) => { return previous => { if (previous === firstYear(yearList)) { return lastYear(yearList); } return previous <= YEARS_IN_ROW ? firstYear(yearList) : previous - YEARS_IN_ROW; }; }; export const keyDownMove = (yearList) => { return previous => { if (previous === lastYear(yearList)) { return firstYear(yearList); } return previous >= lastYear(yearList) - YEARS_IN_ROW ? lastYear(yearList) : previous + YEARS_IN_ROW; }; }; export const keyTabMove = (previous) => previous; //# sourceMappingURL=yearSelector.utils.js.map