2019-09-20 09:01:35 +02:00
|
|
|
<script>
|
2020-05-18 12:01:09 +02:00
|
|
|
import { backendUiStore } from "builderStore"
|
2020-02-03 10:50:30 +01:00
|
|
|
import IconButton from "../common/IconButton.svelte"
|
|
|
|
import Input from "../common/Input.svelte"
|
2020-02-21 19:02:02 +01:00
|
|
|
import PropertyCascader from "./PropertyCascader"
|
2020-02-03 10:50:30 +01:00
|
|
|
import { isBinding, getBinding, setBinding } from "../common/binding"
|
2020-04-29 16:49:51 +02:00
|
|
|
import Colorpicker from "../common/Colorpicker.svelte"
|
2020-02-03 10:50:30 +01:00
|
|
|
|
|
|
|
export let value = ""
|
|
|
|
export let onChanged = () => {}
|
|
|
|
export let type = ""
|
|
|
|
export let options = []
|
2020-04-27 12:26:34 +02:00
|
|
|
export let styleBindingProperty = ""
|
|
|
|
|
|
|
|
$: bindOptionToStyle = !!styleBindingProperty
|
2019-09-20 09:01:35 +02:00
|
|
|
</script>
|
|
|
|
|
2020-02-10 17:58:20 +01:00
|
|
|
<div class="unbound-container">
|
|
|
|
{#if type === 'bool'}
|
|
|
|
<div>
|
2020-02-03 10:50:30 +01:00
|
|
|
<IconButton
|
2020-02-10 17:58:20 +01:00
|
|
|
icon={value == true ? 'check-square' : 'square'}
|
|
|
|
size="19"
|
|
|
|
on:click={() => onChanged(!value)} />
|
2020-01-28 22:17:04 +01:00
|
|
|
</div>
|
2020-05-07 15:59:06 +02:00
|
|
|
{:else if type === 'models'}
|
|
|
|
<select
|
|
|
|
class="uk-select uk-form-small"
|
2020-05-07 23:15:09 +02:00
|
|
|
bind:value
|
2020-05-18 12:01:09 +02:00
|
|
|
on:change={() => {
|
2020-05-07 23:15:09 +02:00
|
|
|
onChanged(value)
|
|
|
|
}}>
|
2020-05-07 15:59:06 +02:00
|
|
|
{#each $backendUiStore.models || [] as option}
|
2020-05-07 23:15:09 +02:00
|
|
|
<option value={option}>{option.name}</option>
|
2020-05-07 15:59:06 +02:00
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
{:else if type === 'options' || type === 'models'}
|
2020-02-10 17:58:20 +01:00
|
|
|
<select
|
|
|
|
class="uk-select uk-form-small"
|
|
|
|
{value}
|
|
|
|
on:change={ev => onChanged(ev.target.value)}>
|
2020-02-25 16:21:23 +01:00
|
|
|
{#each options || [] as option}
|
2020-04-27 12:26:34 +02:00
|
|
|
{#if bindOptionToStyle}
|
|
|
|
<option style={`${styleBindingProperty}: ${option};`} value={option}>
|
|
|
|
{option}
|
|
|
|
</option>
|
|
|
|
{:else}
|
|
|
|
<option value={option}>{option}</option>
|
|
|
|
{/if}
|
2020-02-10 17:58:20 +01:00
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
{:else}
|
2020-02-10 18:11:22 +01:00
|
|
|
<PropertyCascader {onChanged} {value} />
|
2020-02-10 17:58:20 +01:00
|
|
|
{/if}
|
|
|
|
</div>
|
2019-09-20 09:01:35 +02:00
|
|
|
|
|
|
|
<style>
|
2020-02-03 10:50:30 +01:00
|
|
|
.unbound-container {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.bound-header > div:nth-child(1) {
|
|
|
|
flex: 1 0 auto;
|
|
|
|
width: 30px;
|
|
|
|
color: var(--secondary50);
|
|
|
|
padding-left: 5px;
|
|
|
|
}
|
2020-01-22 16:18:28 +01:00
|
|
|
</style>
|