"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var getNextIndex_1 = __importDefault(require("../array/getNextIndex"));
var isFunc_1 = __importDefault(require("../validators/isFunc"));
/**
* Scroll to the next select option
* @category reactDom
* @module moveToNextSelectOption
*/
var moveToNextSelectOption = function (_a) {
var direction = _a.direction, prevIndex = _a.prevIndex, totalLength = _a.totalLength, nodeRefs = _a.nodeRefs, listScrollableRef = _a.listScrollableRef;
var nextIndex = (0, getNextIndex_1.default)(prevIndex, totalLength, direction);
var foundOptionNode = nodeRefs.current[nextIndex];
if (foundOptionNode
&& listScrollableRef.current
&& (0, isFunc_1.default)(listScrollableRef.current.scrollTo))
listScrollableRef.current.scrollTo({ top: foundOptionNode.offsetTop });
return nextIndex;
};
exports.default = moveToNextSelectOption;
Source