forked from react-component/slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
229 lines (207 loc) · 6.78 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import * as React from "react";
import { RCTooltip } from 'rc-tooltip';
export interface Marks {
[number: number]:
| JSX.Element
| string
| { style: any; label: string | JSX.Element };
}
export interface CommonApiProps {
/**
* Additional CSS class for the root DOM node
* @default ''
*/
className?: string;
/**
* The minimum value of the slider
* @default 0
*/
min?: number;
/**
* The maximum value of the slider
* @default 100
*/
max?: number;
/**
* Marks on the slider. The key determines the position, and the value determines what will show.
* If you want to set the style of a specific mark point, the value should be an object which contains style and label properties.
* @default '{}' | {number: { style, label }}
*/
marks?: Marks;
/**
* Value to be added or subtracted on each step the slider makes. Must be greater than zero, and max - min should be evenly divisible by the step value.
* @default 1
*/
step?: number | null;
/**
* If vertical is true, the slider will be vertical.
* @default false
*/
vertical?: boolean;
/**
* A handle generator which could be used to customized handle.
*/
handle?(props: any): React.ReactNode;
/**
* If the value is true, it means a continuous value interval, otherwise, it is a independent value.
* @default true
*/
included?: boolean;
/**
* If true, handles can't be moved.
* @default false
*/
disabled?: boolean;
/**
* When the step value is greater than 1, you can set the dots to true if you want to render the slider with dots.
* @default false
*/
dots?: boolean;
/**
* @deprecated in version ^6.0.0. Use rc-tooltip
* Tooltip transition class name
*/
tipTransitionName?: string;
/**
* @deprecated in version ^6.0.0. Use rc-tooltip
* Tooltip formatter
*/
tipFormatter?: ((value: any) => any | undefined) | null;
/**
* The style used for the background and container. (both for slider(Object) and range(Array of Object), the array will be used for mutli handle follow element order)
*/
style?: React.CSSProperties[] | React.CSSProperties;
/**
* The style used for handle. (both for slider(Object) and range(Array of Object), the array will be used for mutli handle follow element order)
*/
handleStyle?: React.CSSProperties[] | React.CSSProperties;
/**
* The style used for track. (both for slider(Object) and range(Array of Object), the array will be used for mutli track follow element order)
*/
trackStyle?: React.CSSProperties[] | React.CSSProperties;
/**
* The style used for the track base color.
*/
railStyle?: React.CSSProperties;
/**
* The style used for the dots.
*/
dotStyle?: React.CSSProperties;
/**
* The style used for the active dots.
*/
activeDotStyle?: React.CSSProperties;
}
export interface SliderProps extends CommonApiProps {
/**
* onBeforeChange will be triggered when ontouchstart or onmousedown is triggered.
*/
onBeforeChange?(value: number): void;
/**
* onChange will be triggered while the value of Slider changing.
*/
onChange?(value: number): void;
/**
* onAfterChange will be triggered when ontouchend or onmouseup is triggered.
*/
onAfterChange?(value: number): void;
/**
* Set initial value of slider.
* @default 0
*/
defaultValue?: number;
/**
* Set current value of slider.
*/
value?: number;
}
export interface AddHandleProps {
offset: number;
value: number;
}
export type AddHandleComponent = React.FunctionComponent<AddHandleProps>;
export interface RangeProps extends CommonApiProps {
/**
* onBeforeChange will be triggered when ontouchstart or onmousedown is triggered.
* For prop (count = -1) type returned is [number, undefined]. Bug raised in rc-slider https://github.com/react-component/slider/issues/457
*/
onBeforeChange?(value: number[]): void;
/**
* onChange will be triggered while the value of Slider changing.
* For prop (count = -1) type returned is [number, undefined]. Bug raised in rc-slider https://github.com/react-component/slider/issues/457
*/
onChange?(value: number[]): void;
/**
* onAfterChange will be triggered when ontouchend or onmouseup is triggered.
* For prop (count = -1) type returned is [number, undefined]. Bug raised in rc-slider https://github.com/react-component/slider/issues/457
*/
onAfterChange?(value: number[]): void;
/**
* Set initial positions of handles.
* @default [0,0]
*/
defaultValue?: number[];
/**
* Set current positions of handles.
*/
value?: number[];
/**
* Determine how many ranges to render, and multiple handles will be rendered (number + 1).
* @default 1
*/
count?: number;
/**
* allowCross could be set as true to allow those handles to cross.
* @default true
*/
allowCross?: boolean;
/**
* pushable could be set as true to allow pushing of surrounding handles when moving an handle. When set to a number, the number will be the minimum ensured distance between handles.
* @default true
*/
pushable?: boolean | number;
/**
* function that returns add hadle element
*/
addHandle?: AddHandleComponent;
/**
* whether clicks on rail will be processed (click on rail => handle moves)
*/
isTrackDisabled?: boolean;
/**
* array of values, which handle representators won't move
*/
disabledHandles?: number[];
/**
* maximum possible value that can be added through addMode
*/
maxAddBound?: number;
/**
* addMode onAdd handler (will be called when item is added to slider via addMode)
*/
onAdd?: (value: number) => any;
}
export interface HandleProps extends CommonApiProps {
/**
* Class name
*/
className: string;
/**
* Styling if true, then bottom: {offset} else left: {offset}
* @default False
*/
vertical: boolean;
/**
* Styling option offset
*/
offset: number;
}
export interface WithTooltipProps {
tipFormatter?: (value: number) => React.ReactNode;
tipProps?: Partial<RCTooltip.Props>;
}
export default class Slider extends React.Component<SliderProps> { }
export class Range extends React.Component<RangeProps> { }
export class Handle extends React.Component<HandleProps> { }
export function createSliderWithTooltip(slider: typeof Slider): new() => React.Component<WithTooltipProps & SliderProps>;
export function createSliderWithTooltip(range: typeof Range): new() => React.Component<WithTooltipProps & RangeProps>;