import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; export interface RangeSliderChangeDetail { value: number; valueUpper: number } export type ActiveHandle = "lower" | "upper"; export type RangeSliderFocusDetail = RangeSliderChangeDetail & { handle: ActiveHandle }; type $RestProps = SvelteHTMLElements["div"]; type $Props = { /** * Specify the lower bound value of the slider. * Kept when the owning form resets. * @default 0 */ value?: number; /** * Set the size of the number input. * Inherits `"xs"` from a parent `Form`. */ size?: "xs" | undefined; /** * Specify the upper bound value of the slider. * Kept when the owning form resets. * @default 100 */ valueUpper?: number; /** * Set the maximum slider value * @default 100 */ max?: number; /** * Specify the label for the max value * @default "" */ maxLabel?: string; /** * Set the minimum slider value * @default 0 */ min?: number; /** * Specify the label for the min value * @default "" */ minLabel?: string; /** * Format displayed values for range labels and `aria-valuetext`. * Does not change the numeric model; the text inputs stay numeric. */ formatValue?: undefined | ((value: number) => string); /** * Set the step value * @default 1 */ step?: number; /** * Show tick marks along the track. * Set to `true` to place a tick at every `step`, or pass an array of * `{ value, label? }` for specific stops with optional labels below the track. * A label is also announced in `aria-valuetext` while a handle sits on its mark. * Snapping follows `step` unless `snapToMarks` is set. * @default false */ marks?: boolean | ReadonlyArray<{ value: number; label?: string }>; /** * Set to `true` to snap drag, click, and arrow key navigation to the configured `marks` * instead of `step`. A handle only lands on marks that keep `minGap` from the other. * Has no effect when `marks` is not set. * @default false */ snapToMarks?: boolean; /** * Snap drags and clicks to a mark when the pointer comes within this many pixels * of it, so meaningful values are easy to hit while other values stay reachable * by `step`. Keyboard navigation is unaffected. Set to `0` to disable. * Has no effect when `marks` is not set or `snapToMarks` is set. * @default 0 */ markSnapDistance?: number; /** * Set the step multiplier value * @default 4 */ stepMultiplier?: number; /** * Set the minimum allowed distance between `value` and `valueUpper` * @default 0 */ minGap?: number; /** * Set what a drag that starts on the track, not on a handle, does. * `"handle"` moves the nearer handle to the pointer. * `"range"` drags both handles together when the press lands inside the * selected range, keeping its width; elsewhere it behaves like `"handle"`. * `"brush"` also drags the range from inside it, and a drag that starts * outside it paints a new range from the press point. * Moving the whole range follows `step` even when `snapToMarks` is set. * @default "handle" */ trackDrag?: "handle" | "range" | "brush"; /** * Set to `true` to require a value * @default false */ required?: boolean; /** * Specify the input type * @default "number" */ inputType?: string; /** * Set to `true` to disable the slider * @default false */ disabled?: boolean; /** * Set to `true` to use the read-only variant * @default false */ readonly?: boolean; /** * Specify the assistive text announced to screen readers when read-only. * Exposed because VoiceOver does not announce `aria-readonly`. * @default "Read-only" */ readonlyText?: string; /** * Set to `true` to hide the text inputs * @default false */ hideTextInput?: boolean; /** * Set to `true` to hide the min and max labels beside the track, * as when a readout elsewhere already shows the range. * @default false */ hideRangeLabels?: boolean; /** * Set to `true` for the slider to span * the full width of its containing element. * @default false */ fullWidth?: boolean; /** * Set to "vertical" to lay out the slider along the vertical axis * @default "horizontal" */ orientation?: "horizontal" | "vertical"; /** * Set an id for the slider div element * @default uniqueId() */ id?: string; /** * Set to `true` to indicate an invalid state * @default false */ invalid?: boolean; /** * Specify the invalid state text * @default "" */ invalidText?: string; /** * Set to `true` to indicate a warning state * @default false */ warn?: boolean; /** * Specify the warning state text * @default "" */ warnText?: string; /** * Specify the helper text * @default "" */ helperText?: string; /** * Specify the label text. * Alternatively, use the "labelChildren" slot. * @example * ```svelte * * Custom Label * * ``` * @default "" */ labelText?: string; /** * Set to `true` to visually hide the label text * @default false */ hideLabel?: boolean; /** * Set a name for the lower bound input element * @default "" */ name?: string; /** * Set a name for the upper bound input element * @default "" */ nameUpper?: string; /** * Specify the id of a form element outside the component to associate * the lower and upper value inputs with. */ form?: string | undefined; /** * Specify the `aria-label` for the lower bound input and handle * @default "Lower bound" */ ariaLabelInput?: string; /** * Specify the `aria-label` for the upper bound input and handle * @default "Upper bound" */ ariaLabelInputUpper?: string; /** * Obtain a reference to the HTML element. * @default null */ ref?: null | HTMLDivElement; /** * Set to `true` to select a text input's text when it receives focus * @default false */ selectTextOnFocus?: boolean; labelChildren?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type RangeSliderProps = Omit<$RestProps, keyof $Props> & $Props; export default class RangeSlider extends SvelteComponentTyped< RangeSliderProps, { blur: CustomEvent<{ value: number; valueUpper: number; handle: "lower" | "upper" }>; change: CustomEvent<{ value: number; valueUpper: number }>; click: WindowEventMap["click"]; focus: CustomEvent<{ value: number; valueUpper: number; handle: "lower" | "upper" }>; input: CustomEvent<{ value: number; valueUpper: number }>; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; mouseover: WindowEventMap["mouseover"]; }, { labelChildren: Record } > {}