UNPKG

@react-md/form

Version:

This package is for creating all the different form input types.

43 lines (42 loc) 1.75 kB
import type { DefinedSliderValueOptions, SliderControls, SliderDefaultValue, SliderValue, SliderStepOptions } from "./types"; /** * @remarks \@since 2.5.0 */ export interface SliderRequiredProps extends SliderControls, DefinedSliderValueOptions { /** * The current value of the slider. */ value: SliderValue; } /** * @remarks \@since 2.5.0 */ export declare type SliderValueReturnType = readonly [SliderValue, SliderRequiredProps]; /** * @remarks \@since 2.5.0 */ export interface UseSliderOptions extends SliderStepOptions { /** * An optional callback that will be triggered when the value has changed when * the `updateOn` behavior is set to `"blur"`. When the `updateOn` behavior is * set to `"change"` (default), this will do nothing since the return value * from the hook will always be the latest value. */ onChange?(value: SliderValue): void; } /** * This hook is used to control the value and behavior of the `Slider` * component. The first argument will contain the current slider value while * the second argument will be all the props required to control the `Slider` * component. * * @param defaultValue - An optional default value to use for the slider. This * will default to the `min` option when undefined. * @param options - An object containing the `min` and `max` values allowed for * the slider as well as a `step` to indicate valid values between the `min` and * `max`. * @returns an ordered list containing the current value followed by the * `Slider` props * @remarks \@since 2.5.0 */ export declare function useSlider(defaultValue?: SliderDefaultValue, { min, max, step, jump: propJump, updateOn, onChange, }?: UseSliderOptions): SliderValueReturnType;