mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
react-swipeable: Provides its own types (#39529)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
01bc818649
commit
fb88a23ec0
@@ -3906,6 +3906,12 @@
|
||||
"sourceRepoURL": "https://github.com/tanem/react-svg",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-swipeable",
|
||||
"typingsPackageName": "react-swipeable",
|
||||
"sourceRepoURL": "https://github.com/dogfessional/react-swipeable",
|
||||
"asOfVersion": "5.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-toastify",
|
||||
"typingsPackageName": "react-toastify",
|
||||
|
||||
Vendored
-46
@@ -1,46 +0,0 @@
|
||||
// Type definitions for react-swipeable 4.3
|
||||
// Project: https://github.com/dogfessional/react-swipeable
|
||||
// Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
|
||||
// Konstantin Vasilev <https://github.com/mctep>
|
||||
// Hiroki Horiuchi <https://github.com/horiuchi>
|
||||
// Adam Bowles <https://github.com/adambowles>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
declare class ReactSwipeable<T extends Element = HTMLElement> extends React.Component<ReactSwipeable.SwipeableProps<T>> {}
|
||||
|
||||
declare namespace ReactSwipeable {
|
||||
type OnSwipingCallback<T extends Element = HTMLElement> = (event: React.TouchEvent<T>, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number) => void;
|
||||
type OnSwipedCallback<T extends Element = HTMLElement> = (event: React.TouchEvent<T>, deltaX: number, deltaY: number, isFlick: boolean, velocity: number) => void;
|
||||
type OnSwipedDirectionCallback<T extends Element = HTMLElement> = (event: React.TouchEvent<T>, delta: number, isFlick: boolean) => void;
|
||||
type OnSwipingDirectionCallback<T extends Element = HTMLElement> = (event: React.TouchEvent<T>, delta: number) => void;
|
||||
type OnTapCallback<T extends Element = HTMLElement> = (event: React.TouchEvent<T>) => void;
|
||||
|
||||
interface SwipeableProps<T extends Element = HTMLElement> extends React.ClassAttributes<ReactSwipeable<T>>, React.HTMLAttributes<T> {
|
||||
onSwiped?: OnSwipedCallback<T>;
|
||||
onSwiping?: OnSwipingCallback<T>;
|
||||
onSwipingUp?: OnSwipingDirectionCallback<T>;
|
||||
onSwipingRight?: OnSwipingDirectionCallback<T>;
|
||||
onSwipingDown?: OnSwipingDirectionCallback<T>;
|
||||
onSwipingLeft?: OnSwipingDirectionCallback<T>;
|
||||
onSwipedUp?: OnSwipedDirectionCallback<T>;
|
||||
onSwipedRight?: OnSwipedDirectionCallback<T>;
|
||||
onSwipedDown?: OnSwipedDirectionCallback<T>;
|
||||
onSwipedLeft?: OnSwipedDirectionCallback<T>;
|
||||
onTap?: OnTapCallback<T>;
|
||||
flickThreshold?: number;
|
||||
delta?: number;
|
||||
preventDefaultTouchmoveEvent?: boolean;
|
||||
stopPropagation?: boolean;
|
||||
nodeName?: string;
|
||||
trackMouse?: boolean;
|
||||
disabled?: boolean;
|
||||
rotationAngle?: number;
|
||||
innerRef?: React.Ref<T>;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
}
|
||||
|
||||
export = ReactSwipeable;
|
||||
@@ -1,63 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Swipeable = require('react-swipeable');
|
||||
|
||||
class SampleComponent extends React.PureComponent<Swipeable.SwipeableProps> {
|
||||
private readonly handleSwiped: Swipeable.OnSwipedCallback = () => {};
|
||||
private readonly handleSwiping: Swipeable.OnSwipingCallback = () => {};
|
||||
private readonly handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleTap: Swipeable.OnTapCallback = () => {};
|
||||
private readonly handleClick = () => {};
|
||||
private readonly swipeRef = React.createRef<HTMLElement>();
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Swipeable
|
||||
onSwiped={this.handleSwiped}
|
||||
onSwiping={this.handleSwiping}
|
||||
onSwipingUp={this.handleSwipingUp}
|
||||
onSwipingRight={this.handleSwipingRight}
|
||||
onSwipingDown={this.handleSwipingDown}
|
||||
onSwipingLeft={this.handleSwipingLeft}
|
||||
onSwipedUp={this.handleSwipedUp}
|
||||
onSwipedRight={this.handleSwipedRight}
|
||||
onSwipedDown={this.handleSwipedDown}
|
||||
onSwipedLeft={this.handleSwipedLeft}
|
||||
onTap={this.handleTap}
|
||||
flickThreshold={10}
|
||||
delta={10}
|
||||
preventDefaultTouchmoveEvent
|
||||
stopPropagation
|
||||
nodeName="swipe"
|
||||
trackMouse
|
||||
disabled
|
||||
innerRef={this.swipeRef}
|
||||
onClick={this.handleClick}
|
||||
rotationAngle={0}
|
||||
>
|
||||
<div>
|
||||
This element can be swiped
|
||||
</div>
|
||||
</Swipeable>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DivSwipeable extends Swipeable<HTMLDivElement> {}
|
||||
const TestComponent: React.StatelessComponent = (_) => {
|
||||
const handleSwiped = (event: React.TouchEvent<HTMLDivElement>) => {};
|
||||
return (
|
||||
<DivSwipeable
|
||||
nodeName="div"
|
||||
onSwiped={handleSwiped}
|
||||
>
|
||||
<div>this is sample code.</div>
|
||||
</DivSwipeable>
|
||||
);
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-swipeable-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user