mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 09:26:00 +00:00
32 lines
793 B
Svelte
32 lines
793 B
Svelte
<script lang="ts">
|
|
import { getFormContext } from './FormProviderCore.svelte';
|
|
import FormCheckboxFieldRaw from './FormCheckboxFieldRaw.svelte';
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
export let label;
|
|
export let name;
|
|
export let disabled = false;
|
|
export let templateProps = {};
|
|
|
|
const { template, setFieldValue, values } = getFormContext();
|
|
const dispatch = createEventDispatcher();
|
|
</script>
|
|
|
|
<svelte:component
|
|
this={template}
|
|
type="checkbox"
|
|
{label}
|
|
{disabled}
|
|
{...templateProps}
|
|
labelProps={disabled
|
|
? { disabled: true }
|
|
: {
|
|
onClick: () => {
|
|
setFieldValue(name, !$values[name]);
|
|
dispatch('change');
|
|
},
|
|
}}
|
|
>
|
|
<FormCheckboxFieldRaw {name} {...$$restProps} {disabled} on:change />
|
|
</svelte:component>
|