UNPKG

@base-ui/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.

12 lines 458 B
import { clamp } from "../../internals/clamp.mjs"; import { asc } from "./asc.mjs"; export function getSliderValue(valueInput, index, min, max, range, values) { const clamped = clamp(valueInput, min, max); if (!range) { return clamped; } const output = values.slice(); // Bound the new value to the thumb's neighbours. output[index] = clamp(clamped, values[index - 1] ?? -Infinity, values[index + 1] ?? Infinity); return output.sort(asc); }