2021-08-21 02:56:11 +12:00
|
|
|
<script>
|
|
|
|
import { Multiselect } from "@budibase/bbui"
|
|
|
|
import Field from "./Field.svelte"
|
2021-08-25 03:14:38 +12:00
|
|
|
import { getOptions } from "./optionsParser"
|
2021-08-21 02:56:11 +12:00
|
|
|
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
|
2021-08-25 03:14:38 +12:00
|
|
|
|
2021-08-21 02:56:11 +12:00
|
|
|
let fieldState
|
|
|
|
let fieldApi
|
|
|
|
let fieldSchema
|
2021-08-25 03:14:38 +12:00
|
|
|
|
|
|
|
$: flatOptions = optionsSource == null || optionsSource === "schema"
|
2021-08-21 02:56:11 +12:00
|
|
|
$: options = getOptions(
|
|
|
|
optionsSource,
|
|
|
|
fieldSchema,
|
|
|
|
dataProvider,
|
|
|
|
labelColumn,
|
2021-08-25 03:14:38 +12:00
|
|
|
valueColumn,
|
|
|
|
customOptions
|
2021-08-21 02:56:11 +12:00
|
|
|
)
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<Field
|
|
|
|
{field}
|
|
|
|
{label}
|
|
|
|
{disabled}
|
|
|
|
{validation}
|
|
|
|
{defaultValue}
|
|
|
|
type="array"
|
|
|
|
bind:fieldState
|
|
|
|
bind:fieldApi
|
|
|
|
bind:fieldSchema
|
|
|
|
>
|
2021-08-25 03:14:38 +12:00
|
|
|
<Multiselect
|
|
|
|
getOptionLabel={flatOptions ? x => x : x => x.label}
|
|
|
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
|
|
|
{placeholder}
|
|
|
|
{options}
|
|
|
|
/>
|
2021-08-21 02:56:11 +12:00
|
|
|
</Field>
|