Skip to content

Commit

Permalink
Merge branch 'ts-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed Apr 29, 2017
2 parents bfc9374 + d746352 commit 845aaa8
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 15 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -15,6 +15,7 @@ clean:
lint:
@$(BIN)/flow
@$(BIN)/eslint lib/* lib/utils/* specs/*
@$(BIN)/tsc -p typings

build: $(LIB) $(MIN)

Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -12,7 +12,7 @@
"build": "make clean build",
"lint": "make lint"
},
"typings": "./index.d.ts",
"typings": "./typings/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/mzabriskie/react-draggable.git"
Expand All @@ -29,6 +29,8 @@
},
"homepage": "https://github.com/mzabriskie/react-draggable",
"devDependencies": {
"@types/react": "^15.0.23",
"@types/react-dom": "^15.5.0",
"babel-cli": "^6.10.1",
"babel-core": "^6.10.4",
"babel-eslint": "^6.1.2",
Expand Down Expand Up @@ -64,6 +66,7 @@
"react-frame-component": "0.6.2",
"semver": "^5.3.0",
"static-server": "^2.0.3",
"typescript": "^2.3.2",
"uglify-js": "^2.7.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
Expand Down
9 changes: 7 additions & 2 deletions index.d.ts → typings/index.d.ts
@@ -1,5 +1,6 @@
declare module 'react-draggable' {
import * as React from 'react';

export interface DraggableBounds {
left: number
right: number
Expand Down Expand Up @@ -42,7 +43,11 @@ declare module 'react-draggable' {
onMouseDown: (e: MouseEvent) => void
}

export class Draggable extends React.Component<Partial<DraggableProps>, {}> {}
export default class Draggable extends React.Component<Partial<DraggableProps>, {}> {
static defaultProps : DraggableProps;
}

export class DraggableCore extends React.Component<Partial<DraggableCoreProps>, {}> {}
export class DraggableCore extends React.Component<Partial<DraggableCoreProps>, {}> {
static defaultProps : DraggableCoreProps;
}
}
64 changes: 64 additions & 0 deletions typings/test.tsx
@@ -0,0 +1,64 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Draggable, {DraggableCore} from 'react-draggable';

const root = document.getElementById('root')

function handleStart() {}
function handleDrag() {}
function handleStop() {}
function handleMouseDown() {}

ReactDOM.render(
<Draggable
axis="y"
handle=".handle"
cancel=".cancel"
grid={[10, 10]}
onStart={handleStart}
onDrag={handleDrag}
onStop={handleStop}
offsetParent={document.body}
allowAnyClick={true}
onMouseDown={handleMouseDown}
disabled={true}
enableUserSelectHack={false}
bounds={false}
defaultClassName={'draggable'}
defaultClassNameDragging={'dragging'}
defaultClassNameDragged={'dragged'}
defaultPosition={{x: 0, y: 0}}
position={{x: 50, y: 50}}>
<div className="foo bar">
<div className="handle"/>
<div className="cancel"/>
</div>
</Draggable>,
root
);

ReactDOM.render(
<DraggableCore
handle=".handle"
cancel=".cancel"
allowAnyClick={true}
disabled={true}
onMouseDown={handleMouseDown}
grid={[10, 10]}
onStart={handleStart}
onDrag={handleDrag}
onStop={handleStop}
offsetParent={document.body}
enableUserSelectHack={false}>
<div className="foo bar">
<div className="handle"/>
<div className="cancel"/>
</div>
</DraggableCore>,
root
);


ReactDOM.render(<Draggable><div/></Draggable>, root);

ReactDOM.render(<DraggableCore><div/></DraggableCore>, root);
11 changes: 11 additions & 0 deletions typings/tsconfig.json
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"noEmit": true,
"jsx": "preserve",
"strict": true
},
"files": [
"index.d.ts",
"test.tsx"
]
}
27 changes: 15 additions & 12 deletions yarn.lock
Expand Up @@ -2,6 +2,16 @@
# yarn lockfile v1


"@types/react-dom@^15.5.0":
version "15.5.0"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-15.5.0.tgz#7f4fb9613d4051141773242f7b6b5f1a46b34bd9"
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^15.0.23":
version "15.0.23"
resolved "https://registry.yarnpkg.com/@types/react/-/react-15.0.23.tgz#f3facbef5290610f54242f00308759d3a3c27346"

Base64@~0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/Base64/-/Base64-0.2.1.tgz#ba3a4230708e186705065e66babdd4c35cf60028"
Expand Down Expand Up @@ -1846,18 +1856,7 @@ faye-websocket@~0.11.0:
dependencies:
websocket-driver ">=0.5.1"

fbjs@^0.8.1, fbjs@^0.8.4:
version "0.8.6"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.6.tgz#7eb67d6986b2d5007a9b6e92e0e7cb6f75cad290"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
ua-parser-js "^0.7.9"

fbjs@^0.8.9:
fbjs@^0.8.1, fbjs@^0.8.4, fbjs@^0.8.9:
version "0.8.12"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
dependencies:
Expand Down Expand Up @@ -4013,6 +4012,10 @@ typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984"

ua-parser-js@^0.7.9:
version "0.7.12"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
Expand Down

0 comments on commit 845aaa8

Please sign in to comment.