import { Mark, SliderProps, SliderValue } from '../../slider/slider.types'; import type * as React from 'react'; /** * Number of pointer-move events that must fire before a drag is considered intentional. * Prevents accidental drags from triggering the dragging visual state on click. */ export declare const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2; /** * CSS property mappings for each slider axis orientation. * Each axis defines how to position an element (`offset`) and size the track (`leap`) * using the appropriate CSS properties for that direction. */ export declare const AXIS_PROPS: { readonly horizontal: { readonly leap: (percent: number) => { width: string; }; readonly offset: (percent: number) => { left: string; }; }; readonly 'horizontal-reverse': { readonly leap: (percent: number) => { width: string; }; readonly offset: (percent: number) => { right: string; }; }; readonly vertical: { readonly leap: (percent: number) => { height: string; }; readonly offset: (percent: number) => { bottom: string; }; }; }; /** Identity function used as the default `scale` transform. */ export declare const identity: (value: number) => number; /** * Clamps a value between a minimum and maximum bound. * * @param value - The value to clamp. * @param min - Lower bound (defaults to `Number.MIN_SAFE_INTEGER`). * @param max - Upper bound (defaults to `Number.MAX_SAFE_INTEGER`). * @returns The clamped value. */ export declare const clamp: (value: number, min?: number, max?: number) => number; /** Comparator for sorting numbers in ascending order. */ export declare const asc: (a: number, b: number) => number; /** * Finds the index of the value closest to `currentValue` in a sorted array. * When two values are equidistant, the later index wins (useful for range sliders * so that the higher thumb is preferred when clicking exactly between two thumbs). * * @param values - Array of numeric values to search. * @param currentValue - The target value to find the closest match for. * @returns The index of the closest value. */ export declare const findClosest: (values: number[], currentValue: number) => number; /** * Normalizes the `step` prop to a safe runtime value. * * - `step={null}` is only valid when an explicit non-empty `marks` array is provided. * - Non-positive or non-finite values fall back to `1`. */ export declare const normalizeStep: (step: null | number, marks: boolean | ReadonlyArray) => null | number; /** * Normalizes `shiftStep` to a positive finite number. */ export declare const normalizeShiftStep: (shiftStep: number) => number; /** * Normalizes `minDistance` to a non-negative finite number. */ export declare const normalizeMinDistance: (minDistance: number) => number; /** * Normalizes `snapToMarks` to a safe runtime value. */ export declare const normalizeSnapToMarks: (snapToMarks: SliderProps["snapToMarks"]) => SliderProps["snapToMarks"]; /** * Resolves track variants that are not supported for the current slider shape. * Center-origin track rendering only works for single-thumb sliders. */ export declare const resolveTrackMode: (track: SliderProps["track"], range: boolean) => SliderProps["track"]; /** * Extracts the (x, y) coordinates of a pointer from a mouse or touch event. * For touch events, it matches the finger by `touchId` to support multi-touch correctly. * * @param event - The mouse or touch event. * @param touchId - Ref holding the tracked touch identifier. * @returns The finger coordinates, or `false` if the tracked touch was not found. */ export declare const trackFinger: (event: MouseEvent | React.MouseEvent | TouchEvent, touchId: React.RefObject) => false | { x: number; y: number; }; /** * Converts a percentage (0–1) back to an absolute value within the slider range. * * @param percent - A value between 0 and 1 representing position on the track. * @param min - The slider minimum. * @param max - The slider maximum. * @returns The corresponding absolute value. */ export declare const percentToValue: (percent: number, min: number, max: number) => number; /** * Determines the number of decimal digits needed to represent a number without * floating-point rounding artifacts. Handles small numbers expressed in * scientific notation (e.g. `0.001` → `1e-3` → 3 decimal places). * * @param num - The number to inspect. * @returns The decimal precision (number of digits after the decimal point). */ export declare const getDecimalPrecision: (num: number) => number; /** * Rounds a value to the nearest step increment relative to `min`. * Uses `getDecimalPrecision` to avoid floating-point rounding errors * (e.g. `0.1 + 0.2 !== 0.3`). * * @param value - The raw value to round. * @param step - The step increment. * @param min - The slider minimum (the step grid origin). * @returns The value snapped to the nearest step. */ export declare const roundValueToStep: (value: number, step: number, min: number) => number; /** * Returns a new sorted array with the value at `index` replaced by `newValue`. * Used to update one thumb in a range slider while keeping the array sorted. * * @param values - The current thumb values. * @param newValue - The new value for the thumb at `index`. * @param index - The thumb index to update. * @returns A new sorted array of thumb values. */ export declare const setValueIndex: (values: number[], newValue: number, index: number) => number[]; /** * Normalizes initial range values so they satisfy `minDistance` on first render. * When the requested minimum gap cannot fit inside the slider range, the values * are spread evenly across the available range. */ export declare const normalizeInitialRangeValues: (values: number[], { max, min, minDistance, }: { max?: number; min?: number; minDistance?: number; }) => number[]; /** * Normalizes the initial slider value so the component never mounts in an * invalid state. Marks-only sliders snap to the nearest mark, range values are * coerced to exactly two thumbs, and initial range values are adjusted to * satisfy `minDistance`. */ export declare const normalizeSliderValue: (value: SliderValue | undefined, { marks, max, min, minDistance, step, }: { marks: Mark[]; max?: number; min?: number; minDistance?: number; step?: null | number; }) => SliderValue | undefined; /** * Logs a console warning in development if `min >= max`, which would produce * a broken slider with zero or negative range. */ export declare const validateSliderRange: (min: number, max: number) => void; export declare const constrainRangeValue: (values: number[], newValue: number, index: number, { disableSwap, max, min, minDistance, }: { disableSwap?: boolean; max?: number; min?: number; minDistance?: number; }) => { activeIndex: number; value: number[]; }; /** * Produces a new slider value with one thumb updated. For single-value sliders * it simply returns the new number; for range sliders it returns a new array. * * @param currentValue - The current slider value (number or number[]). * @param thumbIndex - Index of the thumb to update. * @param nextValue - The new value for the thumb. * @returns The updated slider value. */ export declare const updateThumbValue: (currentValue: SliderValue, thumbIndex: number, nextValue: number) => SliderValue; export declare const focusThumb: ({ activeIndex, setActive, sliderRef, }: { activeIndex: number; setActive?: (index: number) => void; sliderRef: React.RefObject; }) => void; /** * Shallow-compares two arrays element by element. * * @param array1 - First array. * @param array2 - Second array. * @param itemComparer - Optional comparator (defaults to strict equality). * @returns `true` if both arrays have the same length and all elements match. */ export declare const areArraysEqual: (array1: ReadonlyArray, array2: ReadonlyArray, itemComparer?: (a: Item, b: Item) => boolean) => boolean; /** * Compares two slider values for equality. Handles both single-value (number) * and range (number[]) slider variants. * * @param newValue - The new slider value. * @param oldValue - The previous slider value. * @returns `true` if the values are semantically equal. */ export declare const areValuesEqual: (newValue: number | number[], oldValue: number | ReadonlyArray) => boolean; /** * Creates a cloned native Event with a synthetic `target` containing the slider's * `name` and current `value`. This mimics the behavior of native `` change * events so that form libraries (e.g. Formik, React Hook Form) can read the value * from `event.target.value`. * * @param event - The original browser or React event that triggered the change. * @param value - The new slider value. * @param name - The slider's `name` attribute. * @returns A cloned Event with `target.value` and `target.name` set. */ export declare const createChangeEvent: (event: Event | React.SyntheticEvent, value: number | number[], name?: string) => Event; /** * Detects whether the browser supports `touch-action: none`. * The result is cached after the first call for performance. * * When supported, touch events can use `passive: true` listeners because * `touch-action: none` on the element already prevents scrolling. * When not supported, touch handlers must call `preventDefault()` manually. */ export declare const doesSupportTouchActionNone: () => boolean;