jcmcneal / react-step-wizard

A modern flexible step wizard component built for React.
MIT License
585 stars 127 forks source link

Wrong type definition for typescript when using instance #103

Open GeenCo86 opened 2 years ago

GeenCo86 commented 2 years ago

What is wrong:

StepWizard has the wrong type definition for the instance callback.

What I would expect:

interface StepWizardTransitionProps {
    enterRight?: string;
    enterLeft?: string;
    exitRight?: string;
    exitLeft?: string;
    intro?: string;
}
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: () => ReactElement[];
    firstStep: () => void;
    lastStep: () => void;
    nextStep: () => void;
    previousStep: () => void;
    goToStep: (step: number) => void;
    goToNamedStep: (stepName: string) => void;
    updateHash: (activeHash: string) => void;
}

instance: (wizard: StepWizardInstanceProps) => void

mptsonev commented 2 years ago

+1 on this, StepWizardInstanceProps should also have the state prop with active step etc. @jcmcneal I can contribute this change if you believe this to be a real issue :pray: