updated the interfaces of the input fields to reduce dry code
This commit is contained in:
src/lib/components/refactor
@@ -105,6 +105,16 @@
|
||||
handleNext();
|
||||
}
|
||||
}
|
||||
let childInput;
|
||||
$: {
|
||||
childInput = {
|
||||
form,
|
||||
errors,
|
||||
validate,
|
||||
field: fields[$state.context.currentField],
|
||||
constraints
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="p-6">
|
||||
@@ -124,61 +134,19 @@
|
||||
</label>
|
||||
{/if}
|
||||
{#if fields[$state.context.currentField].type === 'text'}
|
||||
<TextInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<TextInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'email'}
|
||||
<TextInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<TextInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'textarea'}
|
||||
<TextAreaInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<TextAreaInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'select'}
|
||||
<SelectInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<SelectInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'slider'}
|
||||
<SliderInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<SliderInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'toggle'}
|
||||
<ToggleInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<ToggleInput {childInput} />
|
||||
{:else if fields[$state.context.currentField].type === 'number'}
|
||||
<NumberInput
|
||||
{form}
|
||||
{errors}
|
||||
{validate}
|
||||
field={fields[$state.context.currentField]}
|
||||
{constraints}
|
||||
/>
|
||||
<NumberInput {childInput} />
|
||||
{/if}
|
||||
</div>
|
||||
{#if $state.matches('submitting')}
|
||||
|
Reference in New Issue
Block a user