UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

26 lines (25 loc) 1.08 kB
"use client"; //#region packages/@mantine/core/src/components/Combobox/use-combobox/get-index/get-virtualized-index.ts function getPreviousIndex({ currentIndex, isOptionDisabled, totalOptionsCount, loop }) { for (let i = currentIndex - 1; i >= 0; i -= 1) if (!isOptionDisabled(i)) return i; if (loop) { for (let i = totalOptionsCount - 1; i > -1; i -= 1) if (!isOptionDisabled(i)) return i; } return currentIndex; } function getNextIndex({ currentIndex, isOptionDisabled, totalOptionsCount, loop }) { for (let i = currentIndex + 1; i < totalOptionsCount; i += 1) if (!isOptionDisabled(i)) return i; if (loop) { for (let i = 0; i < totalOptionsCount; i += 1) if (!isOptionDisabled(i)) return i; } return currentIndex; } function getFirstIndex({ totalOptionsCount, isOptionDisabled }) { for (let i = 0; i < totalOptionsCount; i += 1) if (!isOptionDisabled(i)) return i; return -1; } //#endregion exports.getFirstIndex = getFirstIndex; exports.getNextIndex = getNextIndex; exports.getPreviousIndex = getPreviousIndex; //# sourceMappingURL=get-virtualized-index.cjs.map