checkbox: support undefined state
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/Button.svelte';
|
||||
import Checkbox from '$lib/Checkbox.svelte';
|
||||
import Checkbox, { type CheckboxState } from '$lib/Checkbox.svelte';
|
||||
import Combobox from '$lib/Combobox.svelte';
|
||||
import DateInput from '$lib/DateInput.svelte';
|
||||
import Dialog from '$lib/Dialog.svelte';
|
||||
@@ -18,6 +18,7 @@
|
||||
import ToggleSelect from '$lib/ToggleSelect.svelte';
|
||||
|
||||
let dateInputValue = $state<Date | undefined>(undefined);
|
||||
let checkboxValue = $state<CheckboxState>('indeterminate');
|
||||
let dialogOpen = $state(false);
|
||||
</script>
|
||||
|
||||
@@ -68,13 +69,17 @@
|
||||
<div class="component">
|
||||
<p class="title">Checkbox</p>
|
||||
|
||||
<Checkbox
|
||||
name="example-checkbox"
|
||||
value={'indeterminate'}
|
||||
onchange={(value) => console.log('Checkbox value:', value)}
|
||||
>
|
||||
Agree to terms and conditions
|
||||
</Checkbox>
|
||||
<div class="flex items-center gap-4">
|
||||
<Checkbox
|
||||
name="example-checkbox"
|
||||
bind:value={checkboxValue}
|
||||
onchange={(value) => console.log('Checkbox value:', value)}
|
||||
>
|
||||
Agree to terms and conditions
|
||||
</Checkbox>
|
||||
<span>Checkbox is {checkboxValue}</span>
|
||||
<Button onclick={() => (checkboxValue = 'indeterminate')}>Set Indeterminate</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="component">
|
||||
|
||||
Reference in New Issue
Block a user