24 lines
1.3 KiB
Vue
24 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
import { useId } from "vue";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
|
|
defineProps<{ value: string; workflows: { id: string }[]; label: string; class?: string; editable?: boolean }>();
|
|
const listId = useId();
|
|
const emit = defineEmits<{ pick: [string] }>();
|
|
</script>
|
|
|
|
<template>
|
|
<template v-if="editable">
|
|
<Input :model-value="value" :list="listId" :aria-label="label" :class="$props.class" placeholder="Workflow id or {{ reference }}" @update:model-value="emit('pick', String($event))" />
|
|
<datalist :id="listId"><option v-for="entry in workflows" :key="entry.id" :value="entry.id" /></datalist>
|
|
</template>
|
|
<Select v-else :model-value="value || undefined" @update:model-value="emit('pick', String($event))">
|
|
<SelectTrigger :aria-label="label" :class="$props.class"><SelectValue placeholder="Choose workflow" /></SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem v-if="value && !workflows.some((entry) => entry.id === value)" :value="value" disabled>{{ value }} (unavailable)</SelectItem>
|
|
<SelectItem v-for="entry in workflows" :key="entry.id" :value="entry.id">{{ entry.id }}</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
</template>
|