mirror of https://github.com/Budibase/budibase.git
14 changed files with 103 additions and 23 deletions
@ -0,0 +1,5 @@ |
|||||
|
<script> |
||||
|
import FormFieldSelect from "./FormFieldSelect.svelte" |
||||
|
</script> |
||||
|
|
||||
|
<FormFieldSelect {...$$props} type="boolean" /> |
||||
@ -0,0 +1,50 @@ |
|||||
|
<script> |
||||
|
import { onMount } from "svelte" |
||||
|
import "@spectrum-css/checkbox/dist/index-vars.css" |
||||
|
import SpectrumField from "./SpectrumField.svelte" |
||||
|
|
||||
|
export let field |
||||
|
export let label |
||||
|
export let text |
||||
|
|
||||
|
let fieldState |
||||
|
let fieldApi |
||||
|
|
||||
|
const onChange = event => { |
||||
|
fieldApi.setValue(event.target.checked) |
||||
|
} |
||||
|
|
||||
|
// Ensure a valid boolean value is set |
||||
|
onMount(() => { |
||||
|
fieldApi.setValue($fieldState.value || false) |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<SpectrumField {label} {field} bind:fieldState bind:fieldApi> |
||||
|
{#if fieldState} |
||||
|
<div class="spectrum-FieldGroup spectrum-FieldGroup--horizontal"> |
||||
|
<label class="spectrum-Checkbox" class:is-invalid={!$fieldState.valid}> |
||||
|
<input |
||||
|
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} |
||||
|
</SpectrumField> |
||||
Loading…
Reference in new issue