mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
Merge pull request #34718 from shawnkoon/feature/add-react-typist
Add react-typist type definition
This commit is contained in:
59
types/react-typist/index.d.ts
vendored
Normal file
59
types/react-typist/index.d.ts
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Type definitions for react-typist 2.0
|
||||
// Project: https://github.com/jstejada/react-typist#readme
|
||||
// Definitions by: Shawn Choi <https://github.com/shawnkoon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export namespace TreeView {
|
||||
interface CursorProps {
|
||||
show?: boolean;
|
||||
blink?: boolean;
|
||||
element?: string;
|
||||
hideWhenDone?: boolean;
|
||||
hideWhenDoneDelay?: number;
|
||||
}
|
||||
|
||||
interface CurrentTextProps {
|
||||
line: string;
|
||||
lineIdx: number;
|
||||
character: string;
|
||||
charIdx: number;
|
||||
defDelayGenerator: (
|
||||
mn: number,
|
||||
st: number
|
||||
) => (...params: any) => number;
|
||||
}
|
||||
|
||||
interface DelayProps {
|
||||
ms: number;
|
||||
}
|
||||
class Delay extends React.Component<DelayProps> {}
|
||||
|
||||
interface BackSpaceProps {
|
||||
count?: number;
|
||||
delay?: number;
|
||||
}
|
||||
class Backspace extends React.Component<BackSpaceProps> {}
|
||||
}
|
||||
|
||||
export interface TreeViewProps {
|
||||
className?: string;
|
||||
avgTypingDelay?: number;
|
||||
stdTypingDelay?: number;
|
||||
startDelay?: number;
|
||||
cursor?: TreeView.CursorProps;
|
||||
onCharacterTyped?: (char: string, charIndex: number) => void;
|
||||
onLineTyped?: (line: string, lineIndex: number) => void;
|
||||
onTypingDone?: () => void;
|
||||
delayGenerator?: (
|
||||
mean: number,
|
||||
std: number,
|
||||
current: TreeView.CurrentTextProps
|
||||
) => number;
|
||||
}
|
||||
|
||||
export class TreeView extends React.Component<TreeViewProps> {}
|
||||
|
||||
export default TreeView;
|
||||
59
types/react-typist/react-typist-tests.tsx
Normal file
59
types/react-typist/react-typist-tests.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import * as React from "react";
|
||||
import Typist from "react-typist";
|
||||
|
||||
class ReactTypist extends React.Component {
|
||||
state = {
|
||||
renderMsg: false
|
||||
};
|
||||
|
||||
onHeaderTyped = () => {
|
||||
this.setState({ renderMsg: true });
|
||||
}
|
||||
|
||||
render() {
|
||||
const docs = "//github.com/jstejada/react-typist";
|
||||
return (
|
||||
<div className="TypistExample">
|
||||
<Typist
|
||||
className="TypistExample-header"
|
||||
avgTypingDelay={40}
|
||||
startDelay={2000}
|
||||
onTypingDone={this.onHeaderTyped}
|
||||
>
|
||||
<a href={docs}>React Typist</a>
|
||||
</Typist>
|
||||
<div className="TypistExample-content">
|
||||
{this.state.renderMsg ? (
|
||||
<Typist
|
||||
className="TypistExample-message"
|
||||
cursor={{ hideWhenDone: true }}
|
||||
>
|
||||
* Easy to style
|
||||
<Typist.Delay ms={1250} />
|
||||
<br />
|
||||
* Easy to customize
|
||||
<Typist.Delay ms={1250} />
|
||||
<br />
|
||||
* Easy to use backp
|
||||
<Typist.Delay ms={500} />
|
||||
sace
|
||||
<Typist.Backspace count={5} delay={1000} />
|
||||
<Typist.Delay ms={750} />
|
||||
space
|
||||
<Typist.Delay ms={1250} />
|
||||
<br />
|
||||
<span>
|
||||
*{" "}
|
||||
<a href={docs} className="flash">
|
||||
docs
|
||||
</a>
|
||||
</span>
|
||||
<br />
|
||||
{""}
|
||||
</Typist>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-typist/tsconfig.json
Normal file
24
types/react-typist/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"jsx": "react",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-typist-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-typist/tslint.json
Normal file
1
types/react-typist/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user