59 lines
1.2 KiB
Vue
59 lines
1.2 KiB
Vue
<template>
|
|
<button class="field-value picker-trigger" type="button" @click="openSheet">
|
|
{{ displayValue }}
|
|
</button>
|
|
<TimePickerSheet
|
|
:model-value="modelValue"
|
|
:open="sheetOpen"
|
|
:title="title"
|
|
@update:model-value="updateValue"
|
|
@update:open="updateOpen"
|
|
@confirm="confirmValue"
|
|
/>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, ref } from 'vue'
|
|
import TimePickerSheet from '@/components/TimePickerSheet.vue'
|
|
|
|
const props = defineProps<{
|
|
modelValue: string
|
|
placeholder: string
|
|
title: string
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
'update:modelValue': [value: string]
|
|
confirm: [value: string]
|
|
}>()
|
|
|
|
const sheetOpen = ref(false)
|
|
const displayValue = computed(() => props.modelValue || props.placeholder)
|
|
|
|
const openSheet = (): void => {
|
|
sheetOpen.value = true
|
|
}
|
|
|
|
const updateOpen = (value: boolean): void => {
|
|
sheetOpen.value = value
|
|
}
|
|
|
|
const updateValue = (value: string): void => {
|
|
emit('update:modelValue', value)
|
|
}
|
|
|
|
const confirmValue = (value: string): void => {
|
|
emit('confirm', value)
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.picker-trigger {
|
|
display: flex;
|
|
align-items: center;
|
|
min-height: 40px;
|
|
padding: 0;
|
|
text-align: left;
|
|
}
|
|
</style>
|