2026-07-15 16:30:17 +00:00
|
|
|
<script lang="ts">
|
2026-09-26 07:50:26 +00:00
|
|
|
import type {HTMLInputAttributes} from "svelte/elements"
|
2026-07-15 16:30:17 +00:00
|
|
|
|
2026-09-26 07:50:26 +00:00
|
|
|
type Props = Omit<HTMLInputAttributes, "checked" | "onchange" | "type"> & {
|
2026-07-15 16:30:17 +00:00
|
|
|
checked?: boolean
|
|
|
|
|
onchange?: (checked: boolean) => void
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-26 07:50:26 +00:00
|
|
|
let {checked = $bindable(), onchange, ...restProps}: Props = $props()
|
2026-07-15 16:30:17 +00:00
|
|
|
|
|
|
|
|
const onInput = (event: Event & {currentTarget: HTMLInputElement}) =>
|
|
|
|
|
onchange?.(event.currentTarget.checked)
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-09-26 07:50:26 +00:00
|
|
|
<input {...restProps} type="checkbox" class="toggle" bind:checked onchange={onInput} />
|