This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Full ART types extracted from DefinitelyTyped #72
Open
steadicat
wants to merge
1
commit into
react-native-art:master
Choose a base branch
from
steadicat:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,259 @@ | ||
declare module '@react-native-community/art' { | ||
import {ViewStyle, StyleProp} from 'react-native'; | ||
import React from 'react'; | ||
type FlexAlignType = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'; | ||
|
||
export interface ARTNodeMixin { | ||
opacity?: number; | ||
originX?: number; | ||
originY?: number; | ||
/** | ||
* Flex Prop Types | ||
* @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes | ||
* @see LayoutPropTypes.js | ||
*/ | ||
interface FlexStyle { | ||
alignContent?: | ||
| 'flex-start' | ||
| 'flex-end' | ||
| 'center' | ||
| 'stretch' | ||
| 'space-between' | ||
| 'space-around'; | ||
alignItems?: FlexAlignType; | ||
alignSelf?: 'auto' | FlexAlignType; | ||
aspectRatio?: number; | ||
borderBottomWidth?: number; | ||
borderLeftWidth?: number; | ||
borderRightWidth?: number; | ||
borderTopWidth?: number; | ||
borderWidth?: number; | ||
bottom?: number | string; | ||
flex?: number; | ||
flexBasis?: number | string; | ||
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse'; | ||
flexGrow?: number; | ||
flexShrink?: number; | ||
flexWrap?: 'wrap' | 'nowrap'; | ||
height?: number | string; | ||
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around'; | ||
left?: number | string; | ||
margin?: number | string; | ||
marginBottom?: number | string; | ||
marginHorizontal?: number | string; | ||
marginLeft?: number | string; | ||
marginRight?: number | string; | ||
marginTop?: number | string; | ||
marginVertical?: number | string; | ||
maxHeight?: number | string; | ||
maxWidth?: number | string; | ||
minHeight?: number | string; | ||
minWidth?: number | string; | ||
overflow?: 'visible' | 'hidden' | 'scroll'; | ||
padding?: number | string; | ||
paddingBottom?: number | string; | ||
paddingHorizontal?: number | string; | ||
paddingLeft?: number | string; | ||
paddingRight?: number | string; | ||
paddingTop?: number | string; | ||
paddingVertical?: number | string; | ||
position?: 'absolute' | 'relative'; | ||
right?: number | string; | ||
top?: number | string; | ||
width?: number | string; | ||
zIndex?: number; | ||
|
||
/** | ||
* @platform ios | ||
*/ | ||
direction?: 'inherit' | 'ltr' | 'rtl'; | ||
} | ||
|
||
interface PerpectiveTransform { | ||
perspective: number; | ||
} | ||
|
||
interface RotateTransform { | ||
rotate: string; | ||
} | ||
|
||
interface RotateXTransform { | ||
rotateX: string; | ||
} | ||
|
||
interface RotateYTransform { | ||
rotateY: string; | ||
} | ||
|
||
interface RotateZTransform { | ||
rotateZ: string; | ||
} | ||
|
||
interface ScaleTransform { | ||
scale: number; | ||
} | ||
|
||
interface ScaleXTransform { | ||
scaleX: number; | ||
} | ||
|
||
interface ScaleYTransform { | ||
scaleY: number; | ||
} | ||
|
||
interface TranslateXTransform { | ||
translateX: number; | ||
} | ||
|
||
interface TranslateYTransform { | ||
translateY: number; | ||
} | ||
|
||
interface SkewXTransform { | ||
skewX: string; | ||
} | ||
|
||
interface SkewYTransform { | ||
skewY: string; | ||
} | ||
|
||
interface TransformsStyle { | ||
transform?: ( | ||
| PerpectiveTransform | ||
| RotateTransform | ||
| RotateXTransform | ||
| RotateYTransform | ||
| RotateZTransform | ||
| ScaleTransform | ||
| ScaleXTransform | ||
| ScaleYTransform | ||
| TranslateXTransform | ||
| TranslateYTransform | ||
| SkewXTransform | ||
| SkewYTransform | ||
)[]; | ||
transformMatrix?: Array<number>; | ||
rotation?: number; | ||
scaleX?: number; | ||
scaleY?: number; | ||
scale?: number; | ||
title?: string; | ||
x?: number; | ||
y?: number; | ||
visible?: boolean; | ||
translateX?: number; | ||
translateY?: number; | ||
} | ||
|
||
// @see https://facebook.github.io/react-native/docs/view.html#style | ||
interface ViewStyle extends FlexStyle, TransformsStyle { | ||
backfaceVisibility?: 'visible' | 'hidden'; | ||
backgroundColor?: string; | ||
borderBottomColor?: string; | ||
borderBottomLeftRadius?: number; | ||
borderBottomRightRadius?: number; | ||
borderBottomWidth?: number; | ||
borderColor?: string; | ||
borderLeftColor?: string; | ||
borderRadius?: number; | ||
borderRightColor?: string; | ||
borderRightWidth?: number; | ||
borderStyle?: 'solid' | 'dotted' | 'dashed'; | ||
borderTopColor?: string; | ||
borderTopLeftRadius?: number; | ||
borderTopRightRadius?: number; | ||
borderTopWidth?: number; | ||
display?: 'none' | 'flex'; | ||
opacity?: number; | ||
overflow?: 'visible' | 'hidden'; | ||
shadowColor?: string; | ||
shadowOffset?: {width: number; height: number}; | ||
shadowOpacity?: number; | ||
shadowColor?: string | number; | ||
shadowRadius?: number; | ||
shadowOffset?: { | ||
x: number, | ||
y: number, | ||
} | ||
elevation?: number; | ||
testID?: string; | ||
} | ||
|
||
export interface ARTGroupProps extends ARTNodeMixin { | ||
width?: number; | ||
height?: number; | ||
type Falsy = undefined | null | false; | ||
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {} | ||
/** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle<T>` and return `T`. */ | ||
type RegisteredStyle<T> = number & {__registeredStyleBrand: T}; | ||
type StyleProp<T> = | ||
| T | ||
| RegisteredStyle<T> | ||
| RecursiveArray<T | RegisteredStyle<T> | Falsy> | ||
| Falsy; | ||
|
||
export interface ARTShapeProps { | ||
d: string | PathStatic; | ||
strokeWidth?: number; | ||
strokeDash?: number[]; | ||
stroke?: string; | ||
fill?: string | LinearGradientStatic; | ||
strokeCap?: 'square' | 'butt' | 'round'; | ||
transform?: string | TransformStatic; | ||
} | ||
|
||
export interface ARTClippingRectangleProps extends ARTNodeMixin { | ||
width?: number; | ||
height?: number; | ||
export interface ARTSurfaceProps { | ||
style?: StyleProp<ViewStyle>; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
export interface ARTRenderableMixin extends ARTNodeMixin { | ||
export interface ARTTextProps { | ||
font: string; | ||
fill?: string; | ||
stroke?: string; | ||
strokeCap?: 'butt' | 'square' | 'round'; | ||
strokeDash?: number[]; | ||
strokeJoin?: 'bevel' | 'miter' | 'round'; | ||
strokeWidth?: number; | ||
x: number; | ||
y: number; | ||
alignment?: 'left' | 'center' | 'right'; | ||
} | ||
|
||
export interface ARTShapeProps extends ARTRenderableMixin { | ||
d: string; | ||
width?: number; | ||
height?: number; | ||
export interface ARTGroupProps { | ||
transform?: string | TransformStatic; | ||
} | ||
|
||
export interface ARTTextProps extends ARTRenderableMixin { | ||
font?: string; | ||
alignment?: string; | ||
interface ShapeStatic extends React.ComponentClass<ARTShapeProps> {} | ||
|
||
interface SurfaceStatic extends React.ComponentClass<ARTSurfaceProps> {} | ||
|
||
interface PathStatic { | ||
new (): PathStatic; | ||
move(dx: number, dy: number): PathStatic; | ||
moveTo(x: number, y: number): PathStatic; | ||
line(dx: number, dy: number): PathStatic; | ||
lineTo(x: number, y: number): PathStatic; | ||
arc(dx: number, dy: number, radius: number): PathStatic; | ||
arcTo(x: number, y: number, radius: number): PathStatic; | ||
close(): PathStatic; | ||
} | ||
|
||
export interface ARTSurfaceProps { | ||
style?: StyleProp<ViewStyle>; | ||
width: number; | ||
height: number; | ||
interface TransformStatic { | ||
new (): TransformStatic; | ||
move(dx: number, dy: number): TransformStatic; | ||
rotate(angle: number, cx?: number, cy?: number): TransformStatic; | ||
} | ||
|
||
export class ClippingRectangle extends React.Component<ARTClippingRectangleProps> {} | ||
export interface ARTTextStatic extends React.ComponentClass<ARTTextProps> {} | ||
|
||
export class Group extends React.Component<ARTGroupProps> {} | ||
interface GroupStatic extends React.ComponentClass<ARTGroupProps> {} | ||
|
||
export class Shape extends React.Component<ARTShapeProps> {} | ||
interface LinearGradientStatic extends React.ComponentClass<ARTGroupProps> { | ||
new ( | ||
stops: {[stop: string]: string}, | ||
x0: number, | ||
y0: number, | ||
x1: number, | ||
y1: number, | ||
): LinearGradientStatic; | ||
} | ||
|
||
export class Surface extends React.Component<ARTSurfaceProps> {} | ||
////////////////////////////////////////////////////////////////////////// | ||
// | ||
// R E - E X P O R T S | ||
// | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
export class Text extends React.Component<ARTTextProps> {} | ||
export var Shape: ShapeStatic; | ||
export type Shape = ShapeStatic; | ||
export var Surface: SurfaceStatic; | ||
export type Surface = SurfaceStatic; | ||
export var Text: ARTTextStatic; | ||
export type Text = ARTTextStatic; | ||
export var Path: PathStatic; | ||
export type Path = PathStatic; | ||
export var Group: GroupStatic; | ||
export type Group = GroupStatic; | ||
export var LinearGradient: LinearGradientStatic; | ||
export type LinearGradient = LinearGradientStatic; | ||
export var Transform: TransformStatic; | ||
export type Transform = TransformStatic; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this ugly comment? I don't think we need this in declarations.