2021-01-29 14:22:38 +01:00
|
|
|
<script>
|
|
|
|
import SpectrumField from "./SpectrumField.svelte"
|
|
|
|
import Dropzone from "../attachments/Dropzone.svelte"
|
2021-02-01 12:14:24 +01:00
|
|
|
import { onMount } from "svelte"
|
2021-01-29 14:22:38 +01:00
|
|
|
|
|
|
|
export let field
|
|
|
|
export let label
|
|
|
|
|
|
|
|
let fieldState
|
|
|
|
let fieldApi
|
2021-02-01 12:14:24 +01:00
|
|
|
|
|
|
|
// Update form value from bound value after we've mounted
|
|
|
|
let value
|
|
|
|
let mounted = false
|
|
|
|
$: mounted && fieldApi?.setValue(value)
|
|
|
|
|
|
|
|
// Get the fields initial value after initialising
|
|
|
|
onMount(() => {
|
|
|
|
value = $fieldState?.value
|
|
|
|
mounted = true
|
|
|
|
})
|
2021-01-29 14:22:38 +01:00
|
|
|
</script>
|
|
|
|
|
2021-02-01 12:14:24 +01:00
|
|
|
<SpectrumField {label} {field} bind:fieldState bind:fieldApi defaultValue={[]}>
|
|
|
|
{#if mounted}
|
|
|
|
<Dropzone bind:files={value} />
|
2021-01-29 14:22:38 +01:00
|
|
|
{/if}
|
|
|
|
</SpectrumField>
|