Skip to content

Commit 3b0be56

Browse files
committed
Implement type definitions
1 parent 2879dd9 commit 3b0be56

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"test-ci": "npm run test && npm run coveralls",
5252
"coveralls": "npm run test-coverage && cat ./coverage/lcov.info | coveralls"
5353
},
54+
"typings": "./src/ReactCursorPosition.d.ts",
5455
"devDependencies": {
5556
"babel-cli": "^6.26.0",
5657
"babel-core": "^6.26.0",
@@ -83,6 +84,7 @@
8384
"react": "~0.14.9 || ^15.0.0 || ^16.0.0"
8485
},
8586
"dependencies": {
87+
"@types/react": "^16.7.18",
8688
"object-assign": "^4.1.1",
8789
"object.omit": "^3.0.0",
8890
"prop-types": "^15.6.0"

src/ReactCursorPosition.d.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, { ReactPropTypes } from 'react';
2+
3+
interface DetectedEnvironment {
4+
isMouseDetected: boolean;
5+
isTouchDetected: boolean;
6+
}
7+
8+
interface ElementDimensions {
9+
width: number;
10+
height: number;
11+
}
12+
13+
interface Position {
14+
x: number;
15+
y: number;
16+
}
17+
18+
interface CursorPositionGeneratedProps {
19+
detectedEnvironment: DetectedEnvironment;
20+
elementDimensions: ElementDimensions;
21+
isActive: boolean;
22+
isPositionOutside: boolean;
23+
position: Position;
24+
}
25+
26+
interface CursorPositionOptionsProps {
27+
// TODO: Make these more specific
28+
activationInteractionMouse?: string;
29+
activationInteractionTouch?: string;
30+
children: (CursorPositionOutputProps) => React.ReactElement<any> | null;
31+
className?: string;
32+
hoverDelayInMs?: number;
33+
isEnabled?: boolean;
34+
mapChildProps?: (CursorPositionGeneratedProps) => object;
35+
onActivationChanged?: ({isActive: boolean}) => void;
36+
onDetectedEnvironmentChanged?: (DetectedEnvironment) => void;
37+
onPositionChanged?: (CursorPositionGeneratedProps) => void;
38+
pressDurationInMs?: number;
39+
pressMoveThreshold?: number;
40+
shouldDecorateChildren?: boolean;
41+
shouldStopTouchMovePropagation?: boolean;
42+
style?: object;
43+
tapDurationInMs?: number;
44+
tapMoveThreshold?: number;
45+
}
46+
47+
export interface CursorPositionOutputProps extends CursorPositionGeneratedProps {
48+
[property:string]: any;
49+
}
50+
51+
export interface CursorPositionInputProps extends CursorPositionOptionsProps {
52+
[property:string]: any;
53+
}
54+
55+
export declare class ReactCursorPosition extends React.Component<CursorPositionInputProps, any> {
56+
}

0 commit comments

Comments
 (0)