mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-13 12:10:58 +01:00
Caught by driving the real browser, not jsdom: on awesome-mcp-explorer's star distribution the arrow keys did nothing at all. ~1500 of the ~2981 values are 0, so an index step landed inside the run of duplicates -- the index moved, the value did not, and the thumb, the readout and the filter all stayed put. steppedValue now walks to the next distinct value, so one arrow press is one visible change on any distribution, however lumpy. The regression test uses the shape that actually broke rather than the evenly-spaced fixture that hid it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U4Rj3s7K2qzrLNgJqqPhno
31 lines
1.6 KiB
TypeScript
31 lines
1.6 KiB
TypeScript
export interface RangeSliderProps {
|
|
/**
|
|
* Formats a value for the head readout. Omit it (with `label`) to render a
|
|
* bare track — dufs-cloud's wrappers draw their own labels and value notes,
|
|
* so a built-in head would duplicate them.
|
|
*/
|
|
readonly format?: (value: number) => string;
|
|
/** Current upper bound; equal to the distribution max when unconstrained. */
|
|
readonly hi: number;
|
|
/** Accessible name. Falls back to a generic one when omitted. */
|
|
readonly label?: string;
|
|
/** Current lower bound; equal to the distribution min when unconstrained. */
|
|
readonly lo: number;
|
|
/** Reports both thumb values (raw, clamped so lo <= hi) on every change. */
|
|
readonly onChange: (lo: number, hi: number) => void;
|
|
/** The full ascending distribution — not just its endpoints. */
|
|
readonly values: readonly number[];
|
|
}
|
|
/**
|
|
* Steps one thumb by `delta` positions through the distribution. Pure, so the
|
|
* keyboard contract is testable without layout.
|
|
*
|
|
* Steps to the next *distinct* value rather than the next index. Real
|
|
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
|
|
* duplicate zeros -- and an index step inside a run of equal values changes the
|
|
* index while leaving the value (and therefore the thumb, and the filter)
|
|
* exactly where it was. That reads as a dead arrow key.
|
|
*/
|
|
export declare function steppedValue(values: readonly number[], current: number, delta: number): number;
|
|
export declare function RangeSlider({ format, hi, label, lo, onChange, values, }: RangeSliderProps): null | React.JSX.Element;
|
|
//# sourceMappingURL=range-slider.d.ts.map
|