UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

18 lines (17 loc) 658 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSliderValue = getSliderValue; var _clamp = require("../../utils/clamp"); var _replaceArrayItemAtIndex = require("./replaceArrayItemAtIndex"); function getSliderValue(valueInput, index, min, max, range, values) { let newValue = valueInput; newValue = (0, _clamp.clamp)(newValue, min, max); if (range) { newValue = (0, _replaceArrayItemAtIndex.replaceArrayItemAtIndex)(values, index, // Bound the new value to the thumb's neighbours. (0, _clamp.clamp)(newValue, values[index - 1] || -Infinity, values[index + 1] || Infinity)); } return newValue; }