-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathindex.d.ts
164 lines (140 loc) · 3.82 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
import * as React from "react";
export interface ReactSwitchProps {
/**
* The checked state of the switch. If true, the switch is set to checked. If false, it is not checked.
*/
checked: boolean;
/**
* Invoked when the user clicks or drags the switch.
*
* **checked** describes the presumed future state of the checked prop.
*
* **event** is a native MouseEvent when the handle is clicked or dragged, and a SyntheticEvent at all other times.
*
* **id** is the ID prop of the switch.
*
* @param {boolean} checked
* @param {object} event
* @param {string} id
*/
onChange: (
checked: boolean,
event: React.SyntheticEvent<MouseEvent | KeyboardEvent> | MouseEvent,
id: string
) => void;
/**
* When true, the switch will no longer be interactive and its colors will be greyed out.
*/
disabled?: boolean;
/**
* The switch will take on this color when it is **not** checked. Only accepts 3 or 6 digit hex colors, e.g., #888, #45abcd.
*
* Defaults to #888.
*/
offColor?: string;
/** The switch will take on this color when it is checked. Only accepts 3 or 6 digit hex colors, e.g., #080, #45abcd.
*
* Defaults to #080.
*/
onColor?: string;
/**
* The color of the handle of the switch when **not** checked. Only accepts 3 or 6 digit hex colors, e.g., #fff, #45abcd.
*
* Defaults to #fff.
*/
offHandleColor?: string;
/**
* The color of the handle of the switch when checked. Only accepts 3 or 6 digit hex colors, e.g., #fff, #45abcd.
*
* Defaults to #fff.
*/
onHandleColor?: string;
/**
* The diameter of the handle, measured in pixels. By default it will be slightly smaller than the height of the switch.
*
* Defaults to undefined.
*/
handleDiameter?: number;
/**
* Icon to display on the handle while switch is unchecked.
*
* Defaults to undefined.
*/
uncheckedHandleIcon?: JSX.Element;
/**
* Icon to display on the handle while switch is checked.
*
* Defaults to undefined.
*/
checkedHandleIcon?: JSX.Element;
/**
* An icon that will be shown on the switch when it is **not** checked. Set to false to show no icon.
*
* Defaults to an x icon.
*/
uncheckedIcon?: JSX.Element | boolean;
/**
* An icon that will be shown on the switch when it is checked. Set to false to show no icon.
*
* Defaults to a checked icon.
*/
checkedIcon?: JSX.Element | boolean;
/**
* The box-shadow of the handle of the switch.
*
* Defaults to undefined.
* */
boxShadow?: string;
/** The box-shadow of the handle of the switch when it is active or focused. **Do not set this to null as it is important for accessibility.**
*
* Defaults to '0px 0px 2px 3px #33bbff'.
*/
activeBoxShadow?: string;
/**
* The height of the background of the switch, measured in pixels.
*
* Defaults to 28.
*/
height?: number;
/**
* The width of the background of the switch, measured in pixels.
*
* Defaults to 56.
*/
width?: number;
/**
* Border radius of the switch _and_ the handle.
*
* Defaults to undefined.
*/
borderRadius?: number;
/**
* The className of the outer shell of the switch.
*
* Defaults to undefined.
*/
className?: string;
/**
* The id of the embedded checkbox.
*
* Defaults to undefined.
*/
id?: string;
}
type Omit<T, U> = Pick<T, Exclude<keyof T, U>>;
type htmlInputProps = React.DetailedHTMLProps<
React.InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
>;
type excludedHTMLInputProps =
| "onFocus"
| "onBlur"
| "onKeyUp"
| "onChange"
| "ref"
| keyof ReactSwitchProps;
type allowedHTMLinputProps = Omit<htmlInputProps, excludedHTMLInputProps>;
declare class ReactSwitch extends React.Component<
ReactSwitchProps & allowedHTMLinputProps
> {}
export default ReactSwitch;