2023-03-28 05:13:48 +02:00
|
|
|
<script lang="ts">
|
2023-11-19 01:05:15 +01:00
|
|
|
import { UIEventSource } from "../../Logic/UIEventSource.js";
|
2023-03-28 05:13:48 +02:00
|
|
|
|
2023-11-19 01:05:15 +01:00
|
|
|
export let value: UIEventSource<any>
|
|
|
|
let i: any = value.data
|
|
|
|
let htmlElement : HTMLSelectElement
|
|
|
|
function selectAppropriateValue(){
|
|
|
|
if(!htmlElement){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const v = value.data
|
|
|
|
for (let option of htmlElement.getElementsByTagName("option")) {
|
|
|
|
if(option.value === v){
|
|
|
|
option.selected = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
value.addCallbackD(() => selectAppropriateValue())
|
|
|
|
$: {
|
|
|
|
if(htmlElement){
|
|
|
|
selectAppropriateValue()
|
|
|
|
}
|
|
|
|
}
|
2023-03-28 05:13:48 +02:00
|
|
|
</script>
|
|
|
|
|
2023-11-19 01:05:15 +01:00
|
|
|
<select bind:this={htmlElement} on:change={(e) => {value.setData(e.srcElement.value)}}>
|
2023-06-14 20:39:36 +02:00
|
|
|
<slot />
|
2023-03-28 05:13:48 +02:00
|
|
|
</select>
|