Skip to content

Commit 325f003

Browse files
budiadionooblador
authored andcommitted
Typescript Definitions (#84)
1 parent 838d8ef commit 325f003

2 files changed

Lines changed: 317 additions & 1 deletion

File tree

index.d.ts

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
declare module 'react-native-progress' {
2+
import React from 'react'
3+
import { ViewProperties } from 'react-native'
4+
5+
/**
6+
* Properties for all `Progress` components.
7+
*
8+
* @export
9+
* @interface DetaultPropTypes
10+
* @extends {ViewProperties}
11+
*/
12+
export interface DetaultPropTypes extends ViewProperties {
13+
/**
14+
* Whether or not to animate changes to progress.
15+
*
16+
* @type {boolean}
17+
* @memberof DetaultPropTypes
18+
* @default true
19+
*/
20+
animated?: boolean
21+
22+
/**
23+
* If set to true, the indicator will spin and progress prop will be ignored.
24+
*
25+
* @type {boolean}
26+
* @memberof DetaultPropTypes
27+
* @default false
28+
*/
29+
indeterminate?: boolean
30+
31+
/**
32+
* Progress of whatever the indicator is indicating. A number between `0` and `1`
33+
*
34+
* @type {(0 | 1)}
35+
* @memberof DetaultPropTypes
36+
* @default 0
37+
*/
38+
progress?: 0 | 1
39+
40+
/**
41+
* Fill color of the indicator.
42+
*
43+
* @type {string}
44+
* @memberof DetaultPropTypes
45+
* @default rgba(0, 122, 255, 1)
46+
*/
47+
color?: string
48+
49+
/**
50+
* Color of the remaining progress.
51+
*
52+
* @type {string}
53+
* @memberof DetaultPropTypes
54+
* @default None
55+
*/
56+
unfilledColor?: string
57+
58+
/**
59+
* Width of outer border, set to `0` to remove.
60+
*
61+
* @type {number}
62+
* @memberof DetaultPropTypes
63+
* @default 1
64+
*/
65+
borderWidth?: number
66+
67+
/**
68+
* Color of outer border.
69+
*
70+
* @type {string}
71+
* @memberof DetaultPropTypes
72+
* @default color
73+
*/
74+
borderColor?: string
75+
}
76+
77+
/**
78+
* Properties for `Bar` components
79+
*
80+
* @export
81+
* @interface BarPropTypes
82+
* @extends {DetaultPropTypes}
83+
*/
84+
export interface BarPropTypes extends DetaultPropTypes {
85+
/**
86+
* Full width of the progress bar, set to null to use automatic flexbox sizing.
87+
*
88+
* @type {number}
89+
* @memberof BarPropTypes
90+
* @default 150
91+
*/
92+
width?: number
93+
94+
/**
95+
* Height of the progress bar.
96+
*
97+
* @type {number}
98+
* @memberof BarPropTypes
99+
* @default 6
100+
*/
101+
height?: number
102+
103+
/**
104+
* Rounding of corners, set to `0` to disable.
105+
*
106+
* @type {number}
107+
* @memberof BarPropTypes
108+
* @default 4
109+
*/
110+
borderRadius?: number
111+
112+
/**
113+
* Use native driver for the animations.
114+
*
115+
* @type {boolean}
116+
* @memberof BarPropTypes
117+
* @default false
118+
*/
119+
useNativeDriver?: boolean
120+
121+
/**
122+
* Config that is passed into the Animated function
123+
*
124+
* @type {{}}
125+
* @memberof BarPropTypes
126+
* @default { bounciness: 0 }
127+
*/
128+
animationConfig?: {}
129+
130+
/**
131+
* Animation type to animate the progress, one of: `decay`, `timing`, `spring`
132+
*
133+
* @type {('decay' | 'timing' | 'spring')}
134+
* @memberof BarPropTypes
135+
* @default spring
136+
*/
137+
animationType?: 'decay' | 'timing' | 'spring'
138+
}
139+
140+
/**
141+
* Properties for `Circle` components
142+
*
143+
* @export
144+
* @interface CirclePropTypes
145+
* @extends {DetaultPropTypes}
146+
*/
147+
export interface CirclePropTypes extends DetaultPropTypes {
148+
149+
/**
150+
* Diameter of the circle.
151+
*
152+
* @type {number}
153+
* @memberof CirclePropTypes
154+
* @default 40
155+
*/
156+
size?: number
157+
158+
/**
159+
* Thickness of the inner circle.
160+
*
161+
* @type {number}
162+
* @memberof CirclePropTypes
163+
* @default 3
164+
*/
165+
thickness?: number
166+
167+
/**
168+
* Whether or not to show a text representation of current progress.
169+
*
170+
* @type {boolean}
171+
* @memberof CirclePropTypes
172+
* @default false
173+
*/
174+
showsText?: boolean
175+
176+
/**
177+
* A function returning a string to be displayed for the textual representation.
178+
*
179+
* @memberof CirclePropTypes
180+
* @default See source
181+
*/
182+
formatText?: (progress: number) => void
183+
184+
/**
185+
* Styles for progress text, defaults to a same `color` as circle and `fontSize` proportional to `size` prop.
186+
*
187+
* @type {string}
188+
* @memberof CirclePropTypes
189+
* @default None
190+
*/
191+
textStyle?: string
192+
193+
/**
194+
* Direction of the circle `clockwise` or `counter-clockwise`.
195+
*
196+
* @type {('clockwise' | 'counter-clockwise')}
197+
* @memberof CirclePropTypes
198+
* @default clockwise
199+
*/
200+
direction?: 'clockwise' | 'counter-clockwise'
201+
202+
/**
203+
* Stroke Cap style for the circle `butt`, `square` or `round`.
204+
*
205+
* @type {('butt' | 'square' | 'round')}
206+
* @memberof CirclePropTypes
207+
* @default butt
208+
*/
209+
strokeCap?: 'butt' | 'square' | 'round'
210+
}
211+
212+
/**
213+
* Properties for `PiePropTypes` components
214+
*
215+
* @export
216+
* @interface PiePropTypes
217+
* @extends {DetaultPropTypes}
218+
*/
219+
export interface PiePropTypes extends DetaultPropTypes {
220+
/**
221+
* Diameter of the pie.
222+
*
223+
* @type {number}
224+
* @memberof PiePropTypes
225+
* @default 40
226+
*/
227+
size?: number
228+
}
229+
230+
/**
231+
* Properties for `CircleSnailPropTypes` components
232+
*
233+
* @export
234+
* @interface CircleSnailPropTypes
235+
* @extends {DetaultPropTypes}
236+
*/
237+
export interface CircleSnailPropTypes extends DetaultPropTypes {
238+
/**
239+
* If the circle should animate.
240+
*
241+
* @type {boolean}
242+
* @memberof CircleSnailPropTypes
243+
* @default true
244+
*/
245+
animating: boolean
246+
247+
/**
248+
* If the circle should be removed when not animating.
249+
*
250+
* @type {boolean}
251+
* @memberof CircleSnailPropTypes
252+
* @default true
253+
*/
254+
hidesWhenStopped: boolean
255+
256+
/**
257+
* Diameter of the circle.
258+
*
259+
* @type {number}
260+
* @memberof CircleSnailPropTypes
261+
* @default 40
262+
*/
263+
size?: number
264+
265+
/**
266+
* Color of the circle, use an array of colors for rainbow effect.
267+
*
268+
* @type {string}
269+
* @memberof CircleSnailPropTypes
270+
* @default rgba(0, 122, 255, 1)
271+
*/
272+
color: string
273+
274+
/**
275+
* Thickness of the circle.
276+
*
277+
* @type {number}
278+
* @memberof CircleSnailPropTypes
279+
* @default 3
280+
*/
281+
thickness?: number
282+
283+
/**
284+
* Duration of animation.
285+
*
286+
* @type {number}
287+
* @memberof CircleSnailPropTypes
288+
* @default 1000
289+
*/
290+
duration: number
291+
292+
/**
293+
* Duration of spin (orbit) animation.
294+
*
295+
* @type {number}
296+
* @memberof CircleSnailPropTypes
297+
* @default 5000
298+
*/
299+
spinDuration: number
300+
301+
/**
302+
* Stroke Cap style for the circle `butt`, `square` or `round`
303+
*
304+
* @type {('butt' | 'square' | 'round')}
305+
* @memberof CircleSnailPropTypes
306+
* @default round
307+
*/
308+
strokeCap: 'butt' | 'square' | 'round'
309+
}
310+
311+
export class Bar extends React.Component<BarPropTypes> {}
312+
export class Circle extends React.Component<CirclePropTypes> {}
313+
export class Pie extends React.Component<PiePropTypes> {}
314+
export class CircleSnail extends React.Component<CircleSnailPropTypes> {}
315+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
},
4949
"dependencies": {
5050
"prop-types": "^15.5.8"
51-
}
51+
},
52+
"typings": "index.d.ts"
5253
}

0 commit comments

Comments
 (0)