1
0
Fork 0
mirror of synced 2024-09-28 15:21:28 +12:00
budibase/packages/standard-components/src/forms/MultiFieldSelect.svelte

50 lines
1,012 B
Svelte
Raw Normal View History

<script>
import { Multiselect } from "@budibase/bbui"
import Field from "./Field.svelte"
import { getOptions } from "./optionsParser"
export let field
export let label
export let placeholder
export let disabled = false
export let validation
export let defaultValue
export let optionsSource = "schema"
export let dataProvider
export let labelColumn
export let valueColumn
export let customOptions
let fieldState
let fieldApi
let fieldSchema
$: flatOptions = optionsSource == null || optionsSource === "schema"
$: options = getOptions(
optionsSource,
fieldSchema,
dataProvider,
labelColumn,
valueColumn,
customOptions
)
</script>
<Field
{field}
{label}
{disabled}
{validation}
{defaultValue}
type="array"
bind:fieldState
bind:fieldApi
bind:fieldSchema
>
<Multiselect
getOptionLabel={flatOptions ? x => x : x => x.label}
getOptionValue={flatOptions ? x => x : x => x.value}
{placeholder}
{options}
/>
</Field>