From 334c888710c049fcef0a362b3993e24fb3cffd36 Mon Sep 17 00:00:00 2001 From: Jonas Kugelmann Date: Wed, 5 Dec 2018 11:09:31 +0100 Subject: [PATCH 1/2] Made StepProps augmentable according to docs --- types/react-albus/index.d.ts | 13 ++++++++++++- types/react-albus/react-albus-tests.tsx | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/types/react-albus/index.d.ts b/types/react-albus/index.d.ts index be546011d4..371a50cca7 100644 --- a/types/react-albus/index.d.ts +++ b/types/react-albus/index.d.ts @@ -47,8 +47,19 @@ export interface StepsProps { export const Steps: React.ComponentType; -export type StepProps = { id: string } & ( +export type StepProps = WizardStepObject & ( | { render?: (wizard: WizardContext) => React.ReactNode } | { children: (wizard: WizardContext) => React.ReactNode }); +/** + * In addition to id, any additional props added to will be available on each step object. + * This can be used to add names, descriptions, or other metadata to each step. + * To use this feature generally you need to augment the WizardStepObject + * @example + * declare module "react-albus" { + * interface WizardStepObject { + * propName: string; + * } + * } + */ export const Step: React.ComponentType; diff --git a/types/react-albus/react-albus-tests.tsx b/types/react-albus/react-albus-tests.tsx index 2f31733b1d..f03e57cc2e 100644 --- a/types/react-albus/react-albus-tests.tsx +++ b/types/react-albus/react-albus-tests.tsx @@ -1,6 +1,12 @@ import * as React from "react"; import { Wizard, Step, Steps, withWizard } from "react-albus"; +declare module "react-albus" { + interface WizardStepObject { + quote?: string; + } +} + const Example = () => ( ( (

Merlin

@@ -28,6 +35,7 @@ const Example = () => ( /> (

Gandalf

From 3458e059eb3bc46ae19f6486e2899bbb93edbdf0 Mon Sep 17 00:00:00 2001 From: Jonas Kugelmann Date: Thu, 6 Dec 2018 09:18:05 +0100 Subject: [PATCH 2/2] Adjusted naming of WizardStepObject to StepObject --- types/react-albus/index.d.ts | 14 +++++++------- types/react-albus/react-albus-tests.tsx | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/types/react-albus/index.d.ts b/types/react-albus/index.d.ts index 371a50cca7..ccc0ac8582 100644 --- a/types/react-albus/index.d.ts +++ b/types/react-albus/index.d.ts @@ -9,13 +9,13 @@ import * as React from "react"; import { History } from "history"; -export interface WizardStepObject { +export interface StepObject { id: string; } export interface WizardContext { - step: WizardStepObject; - steps: WizardStepObject[]; + step: StepObject; + steps: StepObject[]; history: History; next: () => void; previous: () => void; @@ -42,22 +42,22 @@ export interface WizardProps { export const Wizard: React.ComponentType; export interface StepsProps { - step?: WizardStepObject; + step?: StepObject; } export const Steps: React.ComponentType; -export type StepProps = WizardStepObject & ( +export type StepProps = StepObject & ( | { render?: (wizard: WizardContext) => React.ReactNode } | { children: (wizard: WizardContext) => React.ReactNode }); /** * In addition to id, any additional props added to will be available on each step object. * This can be used to add names, descriptions, or other metadata to each step. - * To use this feature generally you need to augment the WizardStepObject + * To use this feature globally in your project you need to augment the StepObject * @example * declare module "react-albus" { - * interface WizardStepObject { + * interface StepObject { * propName: string; * } * } diff --git a/types/react-albus/react-albus-tests.tsx b/types/react-albus/react-albus-tests.tsx index f03e57cc2e..57fe8147d1 100644 --- a/types/react-albus/react-albus-tests.tsx +++ b/types/react-albus/react-albus-tests.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { Wizard, Step, Steps, withWizard } from "react-albus"; declare module "react-albus" { - interface WizardStepObject { + interface StepObject { quote?: string; } }