Update wizard to support additional action buttons

This commit is contained in:
Steven Nguyen
2024-01-18 18:18:50 -08:00
committed by Torsten Dittmann
parent 7aea1633d9
commit 5fefbf956d
+13 -1
View File
@@ -6,6 +6,10 @@
component: typeof SvelteComponent<unknown>;
optional?: boolean;
disabled?: boolean;
actions?: {
label: string;
onClick: () => Promise<void>;
}[];
}
>;
</script>
@@ -128,6 +132,7 @@
$: sortedSteps = [...steps].sort(([a], [b]) => (a > b ? 1 : -1));
$: isLastStep = $wizard.step === steps.size;
$: currentStep = steps.get($wizard.step);
</script>
<svelte:window on:keydown={handleKeydown} />
@@ -176,7 +181,7 @@
{/each}
<div class="form-footer">
<div class="u-flex u-main-end u-gap-12">
{#if !isLastStep && sortedSteps[$wizard.step - 1]?.[1]?.optional}
{#if !isLastStep && currentStep?.optional}
<Button text on:click={() => dispatch('finish')}>
Skip optional steps
</Button>
@@ -188,6 +193,13 @@
<Button secondary on:click={previousStep}>Back</Button>
{/if}
{#if currentStep?.actions}
{#each currentStep.actions as action}
<Button secondary on:click={action.onClick}>
{action.label}</Button>
{/each}
{/if}
<Button submit disabled={$wizard.nextDisabled}>
{isLastStep ? finalAction : 'Next'}
</Button>