From 86d18e980e319982e4a3f6b0a4ecb76f957b5a37 Mon Sep 17 00:00:00 2001 From: Eugenio Date: Thu, 20 Jan 2022 15:34:49 +0100 Subject: [PATCH 1/4] (change type definition): add type definition interface for transition, so it can be used multiple times (change type definition): add type definition for StepWizard instance --- src/index.d.ts | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index fe1ec7a..f35f7c1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,13 +1,41 @@ // Initial typings by dmk99 - https://github.com/jcmcneal/react-step-wizard/issues/31#issuecomment-505399131 import * as React from "react" +export interface StepWizardTransitionProps { + enterRight?: string; + enterLeft?: string; + exitRight?: string; + exitLeft?: string; + intro?: string; +} + + +export interface StepWizardInstanceProps { + getHash: () => string; + getTransitions: () => StepWizardTransitionProps; + onHashChange: () => void; + isInvalidStep: (next: number) => boolean; + setActiveStep: (next: number) => void; + // do we need onStepChange ?? + currentStep: number; + totalSteps: number; + getSteps: () => JSX.Element[] | React.ReactElement[]; + firstStep: () => void; + lastStep: () => void; + nextStep: () => void; + previousStep: () => void; + goToStep: (step: number) => void; + goToNamedStep: (stepName: string) => void; + updateHash: (activeHash: string) => void; +} + export type StepWizardProps = Partial<{ className: string hashKey: string stepName: string initialStep: number - instance: (wizard: StepWizardProps) => void + instance: (wizard: StepWizardTransitionProps) => void isHashEnabled: boolean isLazyMount: boolean nav: JSX.Element @@ -17,13 +45,7 @@ export type StepWizardProps = Partial<{ activeStep: number }) => void - transitions: { - enterRight?: string - enterLeft?: string - exitRight?: string - exitLeft?: string - intro?: string - } + transitions: StepWizardInstanceProps; children: JSX.Element | JSX.Element[] | React.ReactElement }> From b5a7b1371960aab7b16c71a3ec577348e582dcb6 Mon Sep 17 00:00:00 2001 From: GeenCon40 <32361804+GeenCo86@users.noreply.github.com> Date: Thu, 20 Jan 2022 15:37:29 +0100 Subject: [PATCH 2/4] removed unnecessary comment --- src/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index f35f7c1..5c885fa 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -16,7 +16,6 @@ export interface StepWizardInstanceProps { onHashChange: () => void; isInvalidStep: (next: number) => boolean; setActiveStep: (next: number) => void; - // do we need onStepChange ?? currentStep: number; totalSteps: number; getSteps: () => JSX.Element[] | React.ReactElement[]; From e2f675eac47dc96ce24dc57c14a470959f446c6c Mon Sep 17 00:00:00 2001 From: GeenCon40 <32361804+GeenCo86@users.noreply.github.com> Date: Thu, 20 Jan 2022 15:38:38 +0100 Subject: [PATCH 3/4] fixed wrong type for transitions --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 5c885fa..334667e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -44,7 +44,7 @@ export type StepWizardProps = Partial<{ activeStep: number }) => void - transitions: StepWizardInstanceProps; + transitions: StepWizardTransitionProps; children: JSX.Element | JSX.Element[] | React.ReactElement }> From 3e0abfbf11dd9d70f4e5e91997b13cfda6cde6c1 Mon Sep 17 00:00:00 2001 From: GeenCon40 <32361804+GeenCo86@users.noreply.github.com> Date: Thu, 20 Jan 2022 15:39:55 +0100 Subject: [PATCH 4/4] fixed wrong type for instance --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 334667e..5113e30 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -34,7 +34,7 @@ export type StepWizardProps = Partial<{ hashKey: string stepName: string initialStep: number - instance: (wizard: StepWizardTransitionProps) => void + instance: (wizard: StepWizardInstanceProps) => void isHashEnabled: boolean isLazyMount: boolean nav: JSX.Element