mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
added react-albus (#27300)
* added react-albus * react-albus: fix lint errors
This commit is contained in:
38
types/react-albus/index.d.ts
vendored
Normal file
38
types/react-albus/index.d.ts
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// Type definitions for react-albus 2.0
|
||||
// Project: https://github.com/americanexpress/react-albus#readme
|
||||
// Definitions by: Sindre Seppola <https://github.com/sseppola>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import * as React from "react";
|
||||
import { History } from "history";
|
||||
|
||||
export interface WizardStepObject {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface WizardContext {
|
||||
step: WizardStepObject;
|
||||
steps: WizardStepObject[];
|
||||
history: History;
|
||||
next: () => void;
|
||||
previous: () => void;
|
||||
go: (n: number) => void;
|
||||
push: (id?: string) => void;
|
||||
replace: (id?: string) => void;
|
||||
}
|
||||
|
||||
export const Wizard: React.ComponentType<{
|
||||
onNext?: (wizard: WizardContext) => void;
|
||||
render?: (wizard: WizardContext) => React.ReactNode;
|
||||
history?: History;
|
||||
}>;
|
||||
|
||||
export const Steps: React.ComponentType<{
|
||||
step?: WizardStepObject;
|
||||
}>;
|
||||
|
||||
export const Step: React.ComponentType<{
|
||||
id: string;
|
||||
render: (wizard: WizardContext) => React.ReactNode;
|
||||
}>;
|
||||
52
types/react-albus/react-albus-tests.tsx
Normal file
52
types/react-albus/react-albus-tests.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import * as React from "react";
|
||||
import { Wizard, Step, Steps } from "react-albus";
|
||||
|
||||
const Example = () => (
|
||||
<Wizard
|
||||
onNext={wiz => {
|
||||
wiz.go(0);
|
||||
const location = wiz.history.location;
|
||||
wiz.next();
|
||||
wiz.previous();
|
||||
wiz.push("merlin");
|
||||
wiz.replace(wiz.step.id);
|
||||
wiz.steps.map(step => {
|
||||
wiz.push(step.id);
|
||||
});
|
||||
}}
|
||||
render={wiz => (
|
||||
<Steps>
|
||||
<Step
|
||||
id="merlin"
|
||||
render={() => (
|
||||
<div>
|
||||
<h1>Merlin</h1>
|
||||
<button onClick={() => wiz.next()}>Next</button>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Step
|
||||
id="gandalf"
|
||||
render={stepWiz => (
|
||||
<div>
|
||||
<h1>Gandalf</h1>
|
||||
<button onClick={() => stepWiz.next()}>Next</button>
|
||||
<button onClick={() => stepWiz.previous()}>
|
||||
Previous
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Step
|
||||
id="dumbledore"
|
||||
render={({ previous }) => (
|
||||
<div>
|
||||
<h1>Dumbledore</h1>
|
||||
<button onClick={previous}>Previous</button>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</Steps>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
25
types/react-albus/tsconfig.json
Normal file
25
types/react-albus/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-albus-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-albus/tslint.json
Normal file
1
types/react-albus/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user