2021-01-28 17:31:55 +01:00
|
|
|
<script>
|
|
|
|
import "@spectrum-css/checkbox/dist/index-vars.css"
|
2021-02-05 11:53:25 +01:00
|
|
|
import Field from "./Field.svelte"
|
2021-01-28 17:31:55 +01:00
|
|
|
|
|
|
|
export let field
|
|
|
|
export let label
|
|
|
|
export let text
|
|
|
|
|
|
|
|
let fieldState
|
|
|
|
let fieldApi
|
|
|
|
|
|
|
|
const onChange = event => {
|
|
|
|
fieldApi.setValue(event.target.checked)
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-02-05 11:53:25 +01:00
|
|
|
<Field
|
2021-02-01 12:14:24 +01:00
|
|
|
{label}
|
|
|
|
{field}
|
2021-02-05 11:53:25 +01:00
|
|
|
type="boolean"
|
2021-02-01 12:14:24 +01:00
|
|
|
bind:fieldState
|
|
|
|
bind:fieldApi
|
|
|
|
defaultValue={false}>
|
2021-01-28 17:31:55 +01:00
|
|
|
{#if fieldState}
|
|
|
|
<div class="spectrum-FieldGroup spectrum-FieldGroup--horizontal">
|
|
|
|
<label class="spectrum-Checkbox" class:is-invalid={!$fieldState.valid}>
|
|
|
|
<input
|
2021-02-01 12:14:24 +01:00
|
|
|
checked={$fieldState.value}
|
2021-01-28 17:31:55 +01:00
|
|
|
on:change={onChange}
|
|
|
|
type="checkbox"
|
|
|
|
class="spectrum-Checkbox-input"
|
|
|
|
id={$fieldState.fieldId} />
|
|
|
|
<span class="spectrum-Checkbox-box">
|
|
|
|
<svg
|
|
|
|
class="spectrum-Icon spectrum-UIIcon-Checkmark75 spectrum-Checkbox-checkmark"
|
|
|
|
focusable="false"
|
|
|
|
aria-hidden="true">
|
|
|
|
<use xlink:href="#spectrum-css-icon-Checkmark75" />
|
|
|
|
</svg>
|
|
|
|
<svg
|
|
|
|
class="spectrum-Icon spectrum-UIIcon-Dash75 spectrum-Checkbox-partialCheckmark"
|
|
|
|
focusable="false"
|
|
|
|
aria-hidden="true">
|
|
|
|
<use xlink:href="#spectrum-css-icon-Dash75" />
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
<span class="spectrum-Checkbox-label">{text || 'Checkbox'}</span>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2021-02-05 11:53:25 +01:00
|
|
|
</Field>
|
2021-02-10 20:23:53 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.spectrum-Checkbox {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|