budibase/packages/bbui/src/Form/Toggle.svelte

23 lines
577 B
Svelte
Raw Normal View History

2021-03-31 11:59:07 +02:00
<script>
2021-04-16 18:12:22 +02:00
import Field from "./Field.svelte"
import Switch from "./Core/Switch.svelte"
import { createEventDispatcher } from "svelte"
export let value = null
export let label = null
export let labelPosition = "above"
export let text = null
2021-03-31 11:59:07 +02:00
export let disabled = false
2021-04-16 18:12:22 +02:00
export let error = null
2021-03-31 11:59:07 +02:00
2021-04-16 18:12:22 +02:00
const dispatch = createEventDispatcher()
const onChange = e => {
dispatch("change", e.detail)
value = e.detail
2021-03-31 11:59:07 +02:00
}
2021-04-16 18:12:22 +02:00
</script>
2021-03-31 11:59:07 +02:00
2021-04-16 18:12:22 +02:00
<Field {label} {labelPosition} {disabled} {error}>
<Switch {error} {disabled} {text} {value} on:change={onChange} />
</Field>