Values or defaults passed to the picker are parsed to ensure only valid options are marked/added to the component.
This commit is contained in:
parent
bf6d99e20c
commit
bb4ee20bd6
|
@ -15,12 +15,28 @@
|
|||
export let sort = false
|
||||
export let autoWidth = false
|
||||
|
||||
$: streamed = Array.isArray(value)
|
||||
? value.reduce((acc, ele) => {
|
||||
if (typeof ele === "string") {
|
||||
let temp = ele.trim()
|
||||
if (!temp) {
|
||||
return acc
|
||||
}
|
||||
}
|
||||
let processedOpt = ele.toString()
|
||||
if (options.indexOf(processedOpt) > -1) {
|
||||
acc.push(ele.toString())
|
||||
}
|
||||
return acc
|
||||
}, [])
|
||||
: []
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
$: selectedLookupMap = getSelectedLookupMap(value)
|
||||
$: selectedLookupMap = getSelectedLookupMap(streamed)
|
||||
$: optionLookupMap = getOptionLookupMap(options)
|
||||
$: fieldText = getFieldText(value, optionLookupMap, placeholder)
|
||||
$: fieldText = getFieldText(streamed, optionLookupMap, placeholder)
|
||||
$: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
|
||||
$: toggleOption = makeToggleOption(selectedLookupMap, value)
|
||||
$: toggleOption = makeToggleOption(selectedLookupMap, streamed)
|
||||
|
||||
const getFieldText = (value, map, placeholder) => {
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
|
|
|
@ -247,7 +247,7 @@
|
|||
return
|
||||
}
|
||||
hoverTarget = {
|
||||
title: binding.display?.name || binding.fieldSchema.name,
|
||||
title: binding.display?.name || binding.fieldSchema?.name,
|
||||
description: binding.description,
|
||||
}
|
||||
popover.show()
|
||||
|
|
Loading…
Reference in New Issue