UNPKG

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