Skip to content

Commit

Permalink
Implement type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ragalie committed Dec 31, 2018
1 parent 2879dd9 commit 3b0be56
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"test-ci": "npm run test && npm run coveralls",
"coveralls": "npm run test-coverage && cat ./coverage/lcov.info | coveralls"
},
"typings": "./src/ReactCursorPosition.d.ts",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
Expand Down Expand Up @@ -83,6 +84,7 @@
"react": "~0.14.9 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"@types/react": "^16.7.18",
"object-assign": "^4.1.1",
"object.omit": "^3.0.0",
"prop-types": "^15.6.0"
Expand Down
56 changes: 56 additions & 0 deletions src/ReactCursorPosition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { ReactPropTypes } from 'react';

interface DetectedEnvironment {
isMouseDetected: boolean;
isTouchDetected: boolean;
}

interface ElementDimensions {
width: number;
height: number;
}

interface Position {
x: number;
y: number;
}

interface CursorPositionGeneratedProps {
detectedEnvironment: DetectedEnvironment;
elementDimensions: ElementDimensions;
isActive: boolean;
isPositionOutside: boolean;
position: Position;
}

interface CursorPositionOptionsProps {
// TODO: Make these more specific
activationInteractionMouse?: string;
activationInteractionTouch?: string;
children: (CursorPositionOutputProps) => React.ReactElement<any> | null;
className?: string;
hoverDelayInMs?: number;
isEnabled?: boolean;
mapChildProps?: (CursorPositionGeneratedProps) => object;
onActivationChanged?: ({isActive: boolean}) => void;
onDetectedEnvironmentChanged?: (DetectedEnvironment) => void;
onPositionChanged?: (CursorPositionGeneratedProps) => void;
pressDurationInMs?: number;
pressMoveThreshold?: number;
shouldDecorateChildren?: boolean;
shouldStopTouchMovePropagation?: boolean;
style?: object;
tapDurationInMs?: number;
tapMoveThreshold?: number;
}

export interface CursorPositionOutputProps extends CursorPositionGeneratedProps {
[property:string]: any;
}

export interface CursorPositionInputProps extends CursorPositionOptionsProps {
[property:string]: any;
}

export declare class ReactCursorPosition extends React.Component<CursorPositionInputProps, any> {
}

0 comments on commit 3b0be56

Please sign in to comment.