Skip to content

Commit ab792c7

Browse files
committed
feat: added flow-typings
1 parent 7d21cc5 commit ab792c7

2 files changed

Lines changed: 117 additions & 7 deletions

File tree

flow-typed/index.js.flow

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// @flow
2+
import * as React from 'react';
3+
import type { ViewStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet';
4+
5+
///////////////////////////////
6+
// types.ts
7+
///////////////////////////////
8+
9+
export type SharedElementNode = {
10+
ref: any,
11+
nodeHandle: number,
12+
isParent: boolean,
13+
parentInstance: any,
14+
};
15+
16+
export type SharedElementAnimation = 'move' | 'fade' | 'fade-in' | 'fade-out';
17+
18+
export type SharedElementResize = 'auto' | 'stretch' | 'clip' | 'none';
19+
20+
export type SharedElementAlign =
21+
| 'auto'
22+
| 'left-top'
23+
| 'left-center'
24+
| 'left-bottom'
25+
| 'right-top'
26+
| 'right-center'
27+
| 'right-bottom'
28+
| 'center-top'
29+
| 'center-center'
30+
| 'center-bottom';
31+
32+
export type SharedElementNodeType =
33+
| 'startNode'
34+
| 'endNode'
35+
| 'startAncestor'
36+
| 'endAncestor';
37+
38+
export type SharedElementContentType =
39+
| 'none'
40+
| 'snapshotView'
41+
| 'snapshotImage'
42+
| 'image';
43+
44+
///////////////////////////////
45+
// SharedElement.tsx
46+
///////////////////////////////
47+
48+
export type SharedElementProps = {
49+
style?: ViewStyleProp,
50+
children: React.Node,
51+
onNode: (node: SharedElementNode | null) => void,
52+
};
53+
54+
declare export function nodeFromRef(
55+
ref: any,
56+
isParent?: boolean,
57+
parentInstance?: any
58+
): SharedElementNode | null;
59+
60+
declare export class SharedElement extends React.Component<SharedElementProps> {}
61+
62+
///////////////////////////////
63+
// SharedElementTransition.tsx
64+
///////////////////////////////
65+
66+
export type SharedElementMeasureData = {
67+
node: SharedElementNodeType,
68+
layout: {
69+
x: number,
70+
y: number,
71+
width: number,
72+
height: number,
73+
visibleX: number,
74+
visibleY: number,
75+
visibleWidth: number,
76+
visibleHeight: number,
77+
contentX: number,
78+
contentY: number,
79+
contentWidth: number,
80+
contentHeight: number,
81+
},
82+
contentType: SharedElementContentType,
83+
style: {
84+
borderRadius: number,
85+
},
86+
};
87+
88+
export type SharedElementOnMeasureEvent = {
89+
nativeEvent: SharedElementMeasureData,
90+
};
91+
92+
export type SharedElementTransitionProps = {
93+
start: {
94+
node: SharedElementNode | null,
95+
ancestor: SharedElementNode | null,
96+
},
97+
end: {
98+
node: SharedElementNode | null,
99+
ancestor: SharedElementNode | null,
100+
},
101+
position: number | any | void,
102+
animation: SharedElementAnimation,
103+
resize?: SharedElementResize,
104+
align?: SharedElementAlign,
105+
debug?: boolean,
106+
style?: any,
107+
onMeasure?: (event: SharedElementOnMeasureEvent) => void,
108+
SharedElementComponent?: any,
109+
};
110+
111+
declare export class SharedElementTransition extends React.Component<SharedElementTransitionProps> {}

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
"/*.podspec"
3030
],
3131
"scripts": {
32-
"test": "yarn lint && yarn flow && yarn jest",
32+
"test": "yarn lint && yarn jest",
3333
"lint": "eslint --ext .js,.ts,.tsx ./src",
3434
"typescript": "tsc --noEmit",
3535
"jest": "jest src/",
36-
"prepare": "bob build",
37-
"yalc": "bob build && yalc push",
36+
"copy-flow-typings": "cp ./flow-typed/index.js.flow ./lib/module/index.js.flow && cp ./flow-typed/index.js.flow ./lib/commonjs/index.js.flow",
37+
"build": "bob build && yarn copy-flow-typings",
38+
"prepare": "yarn build",
39+
"yalc": "yarn build && yalc push",
3840
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
3941
},
4042
"publishConfig": {
@@ -66,10 +68,7 @@
6668
"output": "lib",
6769
"targets": [
6870
[
69-
"commonjs",
70-
{
71-
"flow": true
72-
}
71+
"commonjs"
7372
],
7473
"module",
7574
"typescript"

0 commit comments

Comments
 (0)