UNPKG

3.73 kBTypeScriptView Raw
1import React from 'react';
2import type { SliderProps as RcSliderProps } from 'rc-slider';
3import type { SliderRef } from 'rc-slider/lib/Slider';
4import type { AbstractTooltipProps, TooltipPlacement } from '../tooltip';
5export type SliderMarks = RcSliderProps['marks'];
6interface HandleGeneratorInfo {
7 value?: number;
8 dragging?: boolean;
9 index: number;
10}
11export type HandleGeneratorFn = (config: {
12 tooltipPrefixCls?: string;
13 prefixCls?: string;
14 info: HandleGeneratorInfo;
15}) => React.ReactElement;
16export type Formatter = ((value?: number) => React.ReactNode) | null;
17export interface SliderTooltipProps extends AbstractTooltipProps {
18 prefixCls?: string;
19 open?: boolean;
20 placement?: TooltipPlacement;
21 getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
22 formatter?: Formatter;
23 autoAdjustOverflow?: boolean;
24}
25export interface SliderBaseProps {
26 prefixCls?: string;
27 reverse?: boolean;
28 min?: number;
29 max?: number;
30 step?: null | number;
31 marks?: SliderMarks;
32 dots?: boolean;
33 included?: boolean;
34 disabled?: boolean;
35 keyboard?: boolean;
36 vertical?: boolean;
37 className?: string;
38 rootClassName?: string;
39 id?: string;
40 style?: React.CSSProperties;
41 tooltip?: SliderTooltipProps;
42 autoFocus?: boolean;
43 styles?: RcSliderProps['styles'];
44 classNames?: RcSliderProps['classNames'];
45 onFocus?: React.FocusEventHandler<HTMLDivElement>;
46 onBlur?: React.FocusEventHandler<HTMLDivElement>;
47 /** @deprecated `tooltipPrefixCls` is deprecated. Please use `tooltip.prefixCls` instead. */
48 tooltipPrefixCls?: string;
49 /** @deprecated `tipFormatter` is deprecated. Please use `tooltip.formatter` instead. */
50 tipFormatter?: Formatter;
51 /** @deprecated `tooltipVisible` is deprecated. Please use `tooltip.open` instead. */
52 tooltipVisible?: boolean;
53 /**
54 * @deprecated `getTooltipPopupContainer` is deprecated. Please use `tooltip.getPopupContainer`
55 * instead.
56 */
57 getTooltipPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
58 /** @deprecated `tooltipPlacement` is deprecated. Please use `tooltip.placement` instead. */
59 tooltipPlacement?: TooltipPlacement;
60}
61export interface SliderSingleProps extends SliderBaseProps {
62 range?: false;
63 value?: number;
64 defaultValue?: number;
65 onChange?: (value: number) => void;
66 /** @deprecated Please use `onChangeComplete` instead */
67 onAfterChange?: (value: number) => void;
68 onChangeComplete?: (value: number) => void;
69 /** @deprecated Please use `styles.handle` instead */
70 handleStyle?: React.CSSProperties;
71 /** @deprecated Please use `styles.track` instead */
72 trackStyle?: React.CSSProperties;
73 /** @deprecated Please use `styles.rail` instead */
74 railStyle?: React.CSSProperties;
75}
76export interface SliderRangeProps extends SliderBaseProps {
77 range: true | SliderRange;
78 value?: number[];
79 defaultValue?: number[];
80 onChange?: (value: number[]) => void;
81 /** @deprecated Please use `onChangeComplete` instead */
82 onAfterChange?: (value: number[]) => void;
83 onChangeComplete?: (value: number[]) => void;
84 /** @deprecated Please use `styles.handle` instead */
85 handleStyle?: React.CSSProperties[];
86 /** @deprecated Please use `styles.track` instead */
87 trackStyle?: React.CSSProperties[];
88 /** @deprecated Please use `styles.rail` instead */
89 railStyle?: React.CSSProperties;
90}
91interface SliderRange {
92 draggableTrack?: boolean;
93}
94export type Opens = {
95 [index: number]: boolean;
96};
97declare const Slider: React.ForwardRefExoticComponent<(SliderSingleProps | SliderRangeProps) & React.RefAttributes<SliderRef>>;
98export default Slider;