@prefecthq/prefect-design
Version:
A collection of low-level Vue components.
45 lines (44 loc) • 1.3 kB
TypeScript
import { Ref, ComputedRef } from 'vue';
export type WizardStepValidator = () => boolean | Promise<boolean>;
export type ValidationState = {
index: number;
valid: boolean;
};
export type WizardStep = {
title: string;
key?: string;
validate?: WizardStepValidator;
};
export type WizardNavigation = {
success: boolean;
newIndex: number;
};
export type UseWizard = {
steps: Ref<WizardStep[]>;
currentStepIndex: Ref<number>;
currentStep: Ref<WizardStep | undefined>;
furthestStepIndex: Ref<number>;
loading: Ref<boolean>;
next: () => Promise<WizardNavigation>;
previous: () => Promise<WizardNavigation>;
goto: {
(key: string): Promise<WizardNavigation>;
(index: number): Promise<WizardNavigation>;
(step: WizardStep): Promise<WizardNavigation>;
};
getStepIndex: {
(key: string): number;
(step: WizardStep): number;
};
getStep: {
(key: string): WizardStep | undefined;
(index: number): WizardStep | undefined;
};
setStep: (key: string, step: WizardStep) => void;
isValid: (index?: number) => Promise<boolean>;
};
export type UseWizardStep = {
wizard: UseWizard;
step: ComputedRef<WizardStep>;
defineValidate: (validate: WizardStepValidator) => void;
};