UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

24 lines (23 loc) 1.02 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 export { getFirstIndex, getNextIndex, getPreviousIndex }; //# sourceMappingURL=get-virtualized-index.mjs.map