import { CSSProperties, ReactNode } from 'react'; import { Mark, SliderProps, SliderValue } from '../../slider/slider.types'; import { Axis } from '../types'; /** Soft cap for decorative tickmarks to avoid rendering excessive DOM. */ export declare const MAX_DECORATIVE_TICKMARK_COUNT = 100; /** A mark augmented with a stagger `level` for label collision avoidance. */ export interface MarkLevel { label?: ReactNode; /** The stagger row (0 = default row, 1+ = offset rows below). */ level: number; value: number; } /** Metadata for a single tickmark dot rendered on the slider rail. */ export interface TickmarkMeta { /** Whether this tick aligns with a user-defined mark (rendered larger). */ isMajor: boolean; /** Position of the tick as a percentage (0–100) along the track. */ percent: number; } /** Computed CSS-ready metrics for the active track segment. */ export interface TrackMetrics { /** Length of the active track as a percentage of the full range. */ leap: number; /** Start position of the active track as a percentage of the full range. */ offset: number; } /** Default value label formatter — returns the numeric value as-is. */ export declare const defaultValueLabelFormat: (x: number) => number; /** * Resolves the public `marks` prop into a concrete array of mark objects. * * - `marks={true}` generates marks from `min` to `max` using `step`. * - custom mark arrays are normalized into a stable ascending range order. * - when the generated step grid does not land exactly on `max`, the endpoint * is appended so the full range remains visibly represented. */ export declare const buildMarks: (marksProp: boolean | ReadonlyArray, min: number, max: number, step: null | number) => Mark[]; /** * Converts an absolute slider value to a percentage (0–100) within the [min, max] range. * * @param value - The absolute value. * @param min - The slider minimum. * @param max - The slider maximum. * @returns The percentage position, or 0 if range is zero/negative. */ export declare const toPercent: (value: number, min: number, max: number) => number; /** * Computes staggered label levels to avoid overlapping mark labels. * Returns marks augmented with a `level` property (0, 1, or 2). */ export declare const computeMarkLevels: (marksList: MarkEntry[], min: number, max: number) => Array; /** * Snaps a value to the nearest mark if within the threshold. */ /** * Snaps a single value to the nearest mark if the distance is within `threshold`. * If no mark is close enough the original value is returned unchanged. * * @param rawValue - The raw (unsnapped) slider value. * @param marksArr - The array of available marks. * @param threshold - Maximum distance (in slider units) for a snap to occur. * @returns The snapped value, or `rawValue` if no mark is close enough. */ export declare const snapToNearestMark: (rawValue: number, marksArr: Mark[], threshold: number) => number; /** * Applies snap-to-mark behavior to a slider value. Works with both single values * and arrays (range sliders), snapping each value independently. * * @param value - The current slider value (number or number[]). * @param marksArr - The available marks. * @param threshold - Snap distance threshold in slider units. * @returns The snapped slider value. */ export declare const applySnapToValue: (value: SliderValue, marksArr: Mark[], threshold: number) => SliderValue; export declare const resolveKeyboardSnapValue: ({ currentValue, marks, max, min, nextValue, snapThreshold, }: { currentValue: number; marks: Mark[]; max: number; min: number; nextValue: number; snapThreshold: number; }) => number; /** * Calculates the snap threshold in absolute slider units from the percentage-based * `snapToMarks` prop. When `snapToMarks` is `true`, uses the default 2%. * When it's a number, uses that as the percentage. * * @param snapEnabled - Whether snapping is active. * @param snapToMarks - The `snapToMarks` prop value (`true` or a custom percentage). * @param min - Slider minimum. * @param max - Slider maximum. * @returns The snap threshold in slider units (0 when snapping is disabled). */ export declare const getSnapThreshold: (snapEnabled: boolean, snapToMarks: SliderProps["snapToMarks"], min: number, max: number) => number; export declare const normalizeVisibleInputValue: ({ marks, max, min, snapThreshold, snapToMarks, step, value, }: { marks: Mark[]; max: number; min: number; snapThreshold?: number; snapToMarks?: boolean; step: null | number; value: number; }) => number; /** * Computes the CSS offset and length of the colored track segment. * Supports all track modes: `normal`, `inverted`, `center`, and `false`. * * - **normal**: track runs from `min` (or the lower thumb) to the value. * - **inverted**: the track colors the *remaining* portion instead. * - **center**: track runs from the midpoint of the range to the current value. * - **false**: no track rendered (returns zeros). * * @param values - The current thumb value(s). * @param range - Whether the slider is a range slider. * @param min - Slider minimum. * @param max - Slider maximum. * @param track - The track display mode. * @returns `{ offset, leap }` as percentages (0–100). */ export declare const getTrackMetrics: (values: number[], range: boolean, min: number, max: number, track?: SliderProps["track"]) => TrackMetrics; /** * Builds metadata for evenly-spaced tickmark dots along the slider rail. * Each tickmark is either a normal dot or a "major" dot (when it aligns with a * user-defined mark position within `MAJOR_TICK_THRESHOLD_PERCENT`). * * @param tickmarks - Total number of tickmarks to render. * @param marksArray - User-defined marks (used to identify major ticks). * @param min - Slider minimum. * @param max - Slider maximum. * @returns Array of `{ percent, isMajor }` for each tickmark. */ export declare const buildTickmarkMeta: (tickmarks: number, marksArray: Mark[] | undefined, min: number, max: number) => TickmarkMeta[]; /** * Determines whether a mark at a given percentage is within the active track region. * Used to style marks differently when they fall inside vs. outside the colored track. * * @param percent - The mark's position as a percentage (0–100). * @param range - Whether the slider is a range slider. * @param track - The track display mode. * @param trackOffset - The start of the active track (percentage). * @param trackLeap - The length of the active track (percentage). * @returns `true` if the mark is within the active track region. */ export declare const isMarkActive: (percent: number, range: boolean, track: SliderProps["track"], trackOffset: number, trackLeap: number) => boolean; /** * Generates a CSS `clip-path: inset(...)` value that clips the "active" tickmark * layer to only show ticks within the colored track region. The active layer is * rendered on top of the inactive layer and uses a different color. * * @param orientation - The slider orientation, used to choose horizontal vs. vertical clipping. * @param track - The track display mode. * @param range - Whether the slider is a range slider. * @param trackOffset - The start of the active track (percentage). * @param trackLeap - The length of the active track (percentage). * @returns One or more CSS `inset(...)` strings for the `clip-path` property. */ export declare const getTickmarkClipPaths: (orientation: SliderProps["orientation"], track: SliderProps["track"], range: boolean, trackOffset: number, trackLeap: number) => string[]; /** * Backwards-compatible helper returning the first clip-path segment. * Prefer `getTickmarkClipPaths()` for new code. */ export declare const getTickmarkClipPath: (track: SliderProps["track"], range: boolean, trackOffset: number, trackLeap: number) => string; /** * Returns inline styles for the slider root element. Applies `width` for horizontal * sliders and `height` for vertical sliders when a length is explicitly provided. * * @param length - The desired length along the main axis (number for px, or a CSS string). * @param orientation - The slider orientation. * @returns CSS properties object, or `undefined` if no styles are needed. */ export declare const getSliderStyle: (length: SliderProps["length"], orientation: SliderProps["orientation"]) => CSSProperties | undefined; /** * Returns a clamped CSS offset for a mark dot so that the full circle stays * within the rail bounds. Without clamping, marks at 0% and 100% would have * half the dot extending beyond the rail due to `translate(-50%)`. * * The position is clamped between `mark-size / 2` and `100% - mark-size / 2` * using the `--rbui-slider-mark-size` CSS custom property, so the dot never * overflows the rounded rail ends regardless of the component size variant. * * @param percent - The mark's position as a percentage (0–100) along the track. * @param axis - The resolved axis direction (`horizontal`, `horizontal-reverse`, or `vertical`). * @returns CSS properties with the clamped positional value for the appropriate axis. */ export declare const getClampedMarkOffset: (percent: number, axis: Axis) => CSSProperties;