69 lines
1.7 KiB
Vue
69 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import type { FormErrors } from '~/types/error'
|
|
import Select from '~/components/pub/my-ui/form/select.vue'
|
|
import { cn } from '~/lib/utils'
|
|
|
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
|
|
|
const props = defineProps<{
|
|
fieldName: string
|
|
label: string
|
|
isDisabled?: boolean
|
|
isRequired?: boolean
|
|
placeholder?: string
|
|
errors?: FormErrors
|
|
class?: string
|
|
selectClass?: string
|
|
fieldGroupClass?: string
|
|
}>()
|
|
|
|
const { errors, class: containerClass, selectClass, fieldGroupClass } = props
|
|
|
|
const opts = [
|
|
{ label: 'General', value: 'general' },
|
|
{ label: 'Regional', value: 'regional' },
|
|
{ label: 'Local', value: 'local' },
|
|
]
|
|
</script>
|
|
|
|
<template>
|
|
<DE.Cell :class="cn('select-field-group', fieldGroupClass, containerClass)">
|
|
<DE.Label
|
|
label-for="fieldName"
|
|
:is-required="isRequired"
|
|
>
|
|
{{ label }}
|
|
</DE.Label>
|
|
<DE.Field
|
|
:id="fieldName"
|
|
:errors="errors"
|
|
:class="cn('select-field-wrapper')"
|
|
>
|
|
<FormField
|
|
v-slot="{ componentField }"
|
|
:name="fieldName"
|
|
>
|
|
<FormItem>
|
|
<FormControl>
|
|
<Select
|
|
:id="fieldName"
|
|
:is-disabled="isDisabled"
|
|
v-bind="componentField"
|
|
:items="opts"
|
|
:placeholder="placeholder"
|
|
:preserve-order="false"
|
|
:class="
|
|
cn(
|
|
'text-sm transition-all duration-200 focus:outline-none focus:ring-1 focus:ring-black focus:ring-offset-0',
|
|
selectClass,
|
|
)
|
|
"
|
|
/>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
</FormField>
|
|
</DE.Field>
|
|
</DE.Cell>
|
|
</template>
|