2021-03-04 09:56:58 +00:00
|
|
|
<script lang="ts">
|
2021-03-06 07:09:29 +00:00
|
|
|
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
2021-03-04 09:56:58 +00:00
|
|
|
import { getFormContext } from './FormProviderCore.svelte';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
2021-10-14 08:56:11 +00:00
|
|
|
export let disabled = false;
|
2021-09-16 08:48:46 +00:00
|
|
|
|
2021-03-04 09:56:58 +00:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
const { submitActionRef } = getFormContext();
|
2021-03-04 14:20:08 +00:00
|
|
|
const { values } = getFormContext();
|
|
|
|
|
|
|
|
function handleClick() {
|
|
|
|
dispatch('click', $values);
|
|
|
|
}
|
|
|
|
|
2021-03-17 17:20:26 +00:00
|
|
|
submitActionRef.set(() => {
|
2021-09-16 08:48:46 +00:00
|
|
|
if (!disabled) {
|
|
|
|
handleClick();
|
|
|
|
}
|
2021-03-17 17:20:26 +00:00
|
|
|
});
|
2021-03-04 09:04:34 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-16 08:48:46 +00:00
|
|
|
<FormStyledButton type="submit" {disabled} on:click={handleClick} {...$$props} />
|