General approach not suitable at the component level. Backing out change

This commit is contained in:
Dean 2022-11-01 17:46:20 +00:00
parent 5dc6f6dfa0
commit 64c3f79dc9
1 changed files with 1 additions and 28 deletions

View File

@ -1,6 +1,6 @@
<script>
import Picker from "./Picker.svelte"
import { createEventDispatcher, onMount } from "svelte"
import { createEventDispatcher } from "svelte"
export let value = []
export let id = null
@ -16,29 +16,6 @@
export let autoWidth = false
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)
$: optionLookupMap = getOptionLookupMap(options)
@ -95,10 +72,6 @@
}
}
}
onMount(() => {
loaded = true
})
</script>
<Picker