mirror of
https://github.com/bartvdbraak/omnidash.git
synced 2025-07-06 08:09:11 +00:00
24 lines
630 B
Svelte
24 lines
630 B
Svelte
<script lang="ts">
|
|
import { getFormField } from 'formsnap';
|
|
import type { Switch as SwitchPrimitive } from 'bits-ui';
|
|
import { Switch } from '$lib/components/ui/switch';
|
|
type $$Props = SwitchPrimitive.Props;
|
|
type $$Events = SwitchPrimitive.Events;
|
|
|
|
export let onCheckedChange: $$Props['onCheckedChange'] = undefined;
|
|
|
|
const { name, setValue, attrStore, value } = getFormField();
|
|
</script>
|
|
|
|
<Switch
|
|
{...$attrStore}
|
|
checked={typeof $value === 'boolean' ? $value : false}
|
|
onCheckedChange={(v) => {
|
|
onCheckedChange?.(v);
|
|
setValue(v);
|
|
}}
|
|
{...$$restProps}
|
|
on:click
|
|
on:keydown
|
|
/>
|
|
<input hidden {name} value={$value} />
|