From fa96e1d7a3d536e69b460a6c01a7e0627fcfda99 Mon Sep 17 00:00:00 2001 From: Sindre Date: Sun, 15 Jul 2018 21:31:54 +0200 Subject: [PATCH] added react-albus (#27300) * added react-albus * react-albus: fix lint errors --- types/react-albus/index.d.ts | 38 ++++++++++++++++++ types/react-albus/react-albus-tests.tsx | 52 +++++++++++++++++++++++++ types/react-albus/tsconfig.json | 25 ++++++++++++ types/react-albus/tslint.json | 1 + 4 files changed, 116 insertions(+) create mode 100644 types/react-albus/index.d.ts create mode 100644 types/react-albus/react-albus-tests.tsx create mode 100644 types/react-albus/tsconfig.json create mode 100644 types/react-albus/tslint.json diff --git a/types/react-albus/index.d.ts b/types/react-albus/index.d.ts new file mode 100644 index 0000000000..dabdb4b81a --- /dev/null +++ b/types/react-albus/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for react-albus 2.0 +// Project: https://github.com/americanexpress/react-albus#readme +// Definitions by: Sindre Seppola +// 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; +}>; diff --git a/types/react-albus/react-albus-tests.tsx b/types/react-albus/react-albus-tests.tsx new file mode 100644 index 0000000000..3654845923 --- /dev/null +++ b/types/react-albus/react-albus-tests.tsx @@ -0,0 +1,52 @@ +import * as React from "react"; +import { Wizard, Step, Steps } from "react-albus"; + +const Example = () => ( + { + 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 => ( + + ( +
+

Merlin

+ +
+ )} + /> + ( +
+

Gandalf

+ + +
+ )} + /> + ( +
+

Dumbledore

+ +
+ )} + /> +
+ )} + /> +); diff --git a/types/react-albus/tsconfig.json b/types/react-albus/tsconfig.json new file mode 100644 index 0000000000..23dcedc16b --- /dev/null +++ b/types/react-albus/tsconfig.json @@ -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" + ] +} diff --git a/types/react-albus/tslint.json b/types/react-albus/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-albus/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }