budibase/packages/builder/src/common/Dropdown.svelte

40 lines
1.1 KiB
Svelte
Raw Normal View History

2019-07-13 11:35:57 +02:00
<script>
import {createEventDispatcher} from "svelte";
export let selected;
export let label;
export let options;
export let valueMember;
export let textMember;
export let multiple=false;
export let width = "medium";
export let size = "small";
2019-07-13 11:35:57 +02:00
const dispatch =createEventDispatcher();
</script>
<div class="uk-margin">
<label class="uk-form-label">{label}</label>
<div class="uk-form-controls">
{#if multiple}
<select class="uk-select uk-form-width-{width} uk-form-{size}" multiple bind:value={selected} on:change>
{#each options as option}
<option value={!valueMember ? option : valueMember(option)}>{!textMember ? option : textMember(option)}</option>
{/each}
</select>
{:else}
<select class="uk-select uk-form-width-{width} uk-form-{size}" bind:value={selected} on:change>
{#each options as option}
<option value={!valueMember ? option : valueMember(option)}>{!textMember ? option : textMember(option)}</option>
{/each}
</select>
{/if}
</div>
2019-07-13 11:35:57 +02:00
</div>