UNPKG

9.84 kBTypeScriptView Raw
1import * as React from 'react';
2import * as ReactNative from 'react-native';
3
4// Common props
5type NumberProp = string | number;
6
7export type FillRule = 'evenodd' | 'nonzero';
8export type Units = 'userSpaceOnUse' | 'objectBoundingBox';
9
10export type TextAnchor = 'start' | 'middle' | 'end';
11export type FontStyle = 'normal' | 'italic' | 'oblique';
12export type FontVariant = 'normal' | 'small-caps';
13export type FontWeight =
14 | 'normal'
15 | 'bold'
16 | 'bolder'
17 | 'lighter'
18 | '100'
19 | '200'
20 | '300'
21 | '400'
22 | '500'
23 | '600'
24 | '700'
25 | '800'
26 | '900'
27 ;
28export type FontStretch =
29 | 'normal'
30 | 'wider'
31 | 'narrower'
32 | 'ultra-condensed'
33 | 'extra-condensed'
34 | 'condensed'
35 | 'semi-condensed'
36 | 'semi-expanded'
37 | 'expanded'
38 | 'extra-expanded'
39 | 'ultra-expanded'
40 ;
41export type TextDecoration = 'none' | 'underline' | 'overline' | 'line-through' | 'blink';
42export type FontVariantLigatures = 'normal' | 'none';
43export type AlignmentBaseline =
44 | 'baseline'
45 | 'text-bottom'
46 | 'alphabetic'
47 | 'ideographic'
48 | 'middle'
49 | 'central'
50 | 'mathematical'
51 | 'text-top'
52 | 'bottom'
53 | 'center'
54 | 'top'
55 | 'text-before-edge'
56 | 'text-after-edge'
57 | 'before-edge'
58 | 'after-edge'
59 | 'hanging'
60 ;
61export type BaselineShift = 'sub' | 'super' | 'baseline' | ReadonlyArray<NumberProp> | NumberProp;
62export type LengthAdjust = 'spacing' | 'spacingAndGlyphs';
63
64export type TextPathMethod = 'align' | 'stretch';
65export type TextPathSpacing = 'auto' | 'exact';
66export type TextPathMidLine = 'sharp' | 'smooth';
67
68export type Linecap = 'butt' | 'square' | 'round';
69export type Linejoin = 'miter' | 'bevel' | 'round';
70
71export interface TouchableProps {
72 disabled?: boolean,
73 onPress?: (event: any) => any,
74 onPressIn?: (event: any) => any,
75 onPressOut?: (event: any) => any,
76 onLongPress?: (event: any) => any,
77 delayPressIn?: number,
78 delayPressOut?: number,
79 delayLongPress?: number
80}
81
82export interface ResponderProps extends ReactNative.GestureResponderHandlers {
83 pointerEvents?: "box-none" | "none" | "box-only" | "auto",
84}
85
86// rgba values inside range 0 to 1 inclusive
87// rgbaArray = [r, g, b, a]
88type rgbaArray = ReadonlyArray<number>
89
90// argb values inside range 0x00 to 0xff inclusive
91// int32ARGBColor = 0xaarrggbb
92type int32ARGBColor = number
93
94export interface FillProps {
95 fill?: int32ARGBColor | rgbaArray | string,
96 fillOpacity?: NumberProp,
97 fillRule?: FillRule,
98}
99
100export interface ClipProps {
101 clipRule?: FillRule,
102 clipPath?: string
103}
104
105interface VectorEffectProps {
106 vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri";
107}
108
109export interface DefinitionProps {
110 id?: string,
111}
112
113export interface StrokeProps {
114 stroke?: int32ARGBColor | rgbaArray | string,
115 strokeWidth?: NumberProp,
116 strokeOpacity?: NumberProp,
117 strokeDasharray?: ReadonlyArray<NumberProp> | NumberProp,
118 strokeDashoffset?: NumberProp,
119 strokeLinecap?: Linecap,
120 strokeLinejoin?: Linejoin,
121 strokeMiterlimit?: NumberProp,
122}
123
124export interface FontObject {
125 fontStyle?: FontStyle,
126 fontVariant?: FontVariant,
127 fontWeight?: FontWeight,
128 fontStretch?: FontStretch,
129 fontSize?: NumberProp,
130 fontFamily?: string,
131 textAnchor?: TextAnchor,
132 textDecoration?: TextDecoration,
133 letterSpacing?: NumberProp,
134 wordSpacing?: NumberProp,
135 kerning?: NumberProp,
136 fontVariantLigatures?: FontVariantLigatures,
137}
138
139export interface FontProps extends FontObject {
140 font?: FontObject,
141}
142
143export interface TransformObject {
144 scale?: NumberProp,
145 scaleX?: NumberProp,
146 scaleY?: NumberProp,
147 rotate?: NumberProp,
148 rotation?: NumberProp,
149 translate?: NumberProp,
150 translateX?: NumberProp,
151 translateY?: NumberProp,
152 x?: NumberProp,
153 y?: NumberProp,
154 origin?: NumberProp,
155 originX?: NumberProp,
156 originY?: NumberProp,
157 skew?: NumberProp,
158 skewX?: NumberProp,
159 skewY?: NumberProp,
160}
161
162/*
163
164 ColumnMajorTransformMatrix
165
166 [a, b, c, d, tx, ty]
167
168 This matrix can be visualized as:
169
170 ╔═ ═╗
171 ║ a c tx ║
172 ║ b d ty ║
173 ║ 0 0 1 ║
174 ╚═ ═╝
175
176*/
177type ColumnMajorTransformMatrix = ReadonlyArray<number>;
178
179export interface TransformProps extends TransformObject {
180 transform?: ColumnMajorTransformMatrix | string | TransformObject,
181}
182
183export interface CommonMaskProps {
184 mask?: string;
185}
186
187export interface CommonPathProps extends FillProps, StrokeProps, ClipProps, TransformProps, VectorEffectProps, ResponderProps, TouchableProps, DefinitionProps, CommonMaskProps {}
188
189// Element props
190export interface CircleProps extends CommonPathProps {
191 cx?: NumberProp,
192 cy?: NumberProp,
193 opacity?: NumberProp,
194 r?: NumberProp,
195}
196export const Circle: React.ComponentClass<CircleProps>;
197
198export interface ClipPathProps {
199 id: string,
200}
201export const ClipPath: React.ComponentClass<ClipPathProps>;
202
203export const Defs: React.ComponentClass<{}>;
204
205export interface EllipseProps extends CommonPathProps {
206 cx?: NumberProp,
207 cy?: NumberProp,
208 opacity?: NumberProp,
209 rx?: NumberProp,
210 ry?: NumberProp,
211}
212export const Ellipse: React.ComponentClass<EllipseProps>;
213
214export interface GProps extends CommonPathProps {
215 opacity?: NumberProp,
216}
217export const G: React.ComponentClass<GProps>;
218
219export interface ImageProps extends ResponderProps, CommonMaskProps, ClipProps, TouchableProps {
220 x?: NumberProp,
221 y?: NumberProp,
222 width?: NumberProp,
223 height?: NumberProp,
224 xlinkHref?: ReactNative.ImageProperties['source'],
225 href: ReactNative.ImageProperties['source'],
226 preserveAspectRatio?: string,
227 opacity?: NumberProp,
228}
229export const Image: React.ComponentClass<ImageProps>;
230
231export interface LineProps extends CommonPathProps {
232 opacity?: NumberProp,
233 x1?: NumberProp,
234 x2?: NumberProp,
235 y1?: NumberProp,
236 y2?: NumberProp,
237}
238export const Line: React.ComponentClass<LineProps>;
239
240export interface LinearGradientProps {
241 x1?: NumberProp,
242 x2?: NumberProp,
243 y1?: NumberProp,
244 y2?: NumberProp,
245 gradientUnits?: Units,
246 id: string,
247}
248export const LinearGradient: React.ComponentClass<LinearGradientProps>;
249
250export interface PathProps extends CommonPathProps {
251 d: string,
252 opacity?: NumberProp,
253}
254export const Path: React.ComponentClass<PathProps>;
255
256export interface PatternProps {
257 id: string,
258 x?: NumberProp,
259 y?: NumberProp,
260 width?: NumberProp,
261 height?: NumberProp,
262 patternTransform?: ColumnMajorTransformMatrix | string,
263 patternUnits?: Units,
264 patternContentUnits?: Units,
265 viewBox?: string,
266 preserveAspectRatio?: string
267}
268export const Pattern: React.ComponentClass<PatternProps>;
269
270export interface PolygonProps extends CommonPathProps {
271 opacity?: NumberProp,
272 points: string | ReadonlyArray<NumberProp>,
273}
274export const Polygon: React.ComponentClass<PolygonProps>;
275
276export interface PolylineProps extends CommonPathProps {
277 opacity?: NumberProp,
278 points: string | ReadonlyArray<NumberProp>,
279}
280export const Polyline: React.ComponentClass<PolylineProps>;
281
282export interface RadialGradientProps {
283 fx?: NumberProp,
284 fy?: NumberProp,
285 rx?: NumberProp,
286 ry?: NumberProp,
287 cx?: NumberProp,
288 cy?: NumberProp,
289 r?: NumberProp,
290 gradientUnits?: Units,
291 id: string,
292}
293export const RadialGradient: React.ComponentClass<RadialGradientProps>;
294
295export interface RectProps extends CommonPathProps {
296 x?: NumberProp,
297 y?: NumberProp,
298 width?: NumberProp,
299 height?: NumberProp,
300 rx?: NumberProp,
301 ry?: NumberProp,
302 opacity?: NumberProp,
303}
304export const Rect: React.ComponentClass<RectProps>;
305
306export interface StopProps {
307 stopColor?: int32ARGBColor | rgbaArray | string,
308 stopOpacity?: NumberProp,
309 offset?: NumberProp,
310}
311export const Stop: React.ComponentClass<StopProps>;
312
313export interface SvgProps extends GProps, ReactNative.ViewProperties {
314 width?: NumberProp,
315 height?: NumberProp,
316 viewBox?: string,
317 preserveAspectRatio?: string,
318 color?: int32ARGBColor | rgbaArray | string,
319 title?: string,
320}
321
322// Svg is both regular and default exported
323export const Svg: React.ComponentClass<SvgProps>;
324export default Svg;
325
326export interface SymbolProps {
327 id: string,
328 viewBox?: string,
329 preserveAspectRatio?: string,
330 opacity?: NumberProp,
331}
332export const Symbol: React.ComponentClass<SymbolProps>;
333
334export interface TSpanProps extends CommonPathProps, FontProps {
335 dx?: NumberProp,
336 dy?: NumberProp,
337}
338export const TSpan: React.ComponentClass<TSpanProps>;
339
340export interface TextSpecificProps extends CommonPathProps, FontProps {
341 alignmentBaseline?: AlignmentBaseline,
342 baselineShift?: BaselineShift,
343 verticalAlign?: NumberProp,
344 lengthAdjust?: LengthAdjust,
345 textLength?: NumberProp,
346 fontData?: null | { [name: string]: any },
347 fontFeatureSettings?: string,
348}
349
350export interface TextProps extends TextSpecificProps {
351 dx?: NumberProp,
352 dy?: NumberProp,
353 opacity?: NumberProp,
354}
355export const Text: React.ComponentClass<TextProps>;
356
357export interface TextPathProps extends TextSpecificProps {
358 xlinkHref?: string,
359 href: string,
360 startOffset?: NumberProp,
361 method?: TextPathMethod,
362 spacing?: TextPathSpacing,
363 midLine: TextPathMidLine,
364}
365export const TextPath: React.ComponentClass<TextPathProps>;
366
367export interface UseProps extends CommonPathProps {
368 xlinkHref?: string,
369 href: string,
370 width?: NumberProp,
371 height?: NumberProp,
372 x?: NumberProp,
373 y?: NumberProp,
374 opacity?: NumberProp,
375}
376export const Use: React.ComponentClass<UseProps>;
377
378
379export enum EMaskUnits {
380 USER_SPACE_ON_USE = 'userSpaceOnUse',
381 OBJECT_BOUNDING_BOX = 'objectBoundingBox',
382}
383
384export type TMaskUnits =
385 | EMaskUnits.USER_SPACE_ON_USE
386 | EMaskUnits.OBJECT_BOUNDING_BOX;
387
388export interface MaskProps extends CommonPathProps {
389 id: string,
390 x?: NumberProp,
391 y?: NumberProp,
392 width?: NumberProp,
393 height?: NumberProp,
394 maskTransform?: ColumnMajorTransformMatrix | string,
395 maskUnits?: TMaskUnits,
396 maskContentUnits?: TMaskUnits,
397}
398export const Mask: React.ComponentClass<MaskProps>;