General approach not suitable at the component level. Backing out change
This commit is contained in:
parent
e44dd44fad
commit
b3c2cfea44
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import Picker from "./Picker.svelte"
|
import Picker from "./Picker.svelte"
|
||||||
import { createEventDispatcher, onMount } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let value = []
|
export let value = []
|
||||||
export let id = null
|
export let id = null
|
||||||
|
@ -16,29 +16,6 @@
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const parseValues = value => {
|
|
||||||
return Array.isArray(value)
|
|
||||||
? value.reduce((acc, entry) => {
|
|
||||||
if (typeof ele === "string" && entry.trim() === "") {
|
|
||||||
return acc
|
|
||||||
}
|
|
||||||
let processedOption = String(entry)
|
|
||||||
if (options.indexOf(processedOption) > -1) {
|
|
||||||
acc.push(processedOption)
|
|
||||||
}
|
|
||||||
return acc
|
|
||||||
}, [])
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
let loaded = false
|
|
||||||
|
|
||||||
$: combinedValues = value ? [...value].concat(options) : []
|
|
||||||
$: superSet = new Set(combinedValues)
|
|
||||||
|
|
||||||
$: if (loaded && options.length != superSet.size) {
|
|
||||||
// ensure that the values being pushed in are valid.
|
|
||||||
dispatch("change", parseValues(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
$: selectedLookupMap = getSelectedLookupMap(value)
|
$: selectedLookupMap = getSelectedLookupMap(value)
|
||||||
$: optionLookupMap = getOptionLookupMap(options)
|
$: optionLookupMap = getOptionLookupMap(options)
|
||||||
|
@ -95,10 +72,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
loaded = true
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Picker
|
<Picker
|
||||||
|
|
Loading…
Reference in New Issue