83 lines
2.2 KiB
Vue
83 lines
2.2 KiB
Vue
<script setup lang="ts">
|
|
import type { FormErrors } from '~/types/error'
|
|
import FieldGroup from '~/components/pub/my-ui/form/field-group.vue'
|
|
import Field from '~/components/pub/my-ui/form/field.vue'
|
|
import Label from '~/components/pub/my-ui/form/label.vue'
|
|
import Select from '~/components/pub/my-ui/form/select.vue'
|
|
import { cn } from '~/lib/utils'
|
|
|
|
const props = defineProps<{
|
|
fieldName?: string
|
|
label?: string
|
|
placeholder?: string
|
|
errors?: FormErrors
|
|
class?: string
|
|
selectClass?: string
|
|
fieldGroupClass?: string
|
|
labelClass?: string
|
|
isRequired?: boolean
|
|
}>()
|
|
|
|
const {
|
|
fieldName = 'language',
|
|
label = 'Bahasa',
|
|
placeholder = 'Pilih preferensi bahasa',
|
|
errors,
|
|
class: containerClass,
|
|
selectClass,
|
|
fieldGroupClass,
|
|
labelClass,
|
|
} = props
|
|
|
|
const langOptions = [
|
|
{ label: 'Bahasa Indonesia', value: 'id', priority: 1 },
|
|
{ label: 'Bahasa Jawa', value: 'jawa' },
|
|
{ label: 'Bahasa Sunda', value: 'sunda' },
|
|
{ label: 'Bahasa Bali', value: 'bali' },
|
|
{ label: 'Bahasa Jaksel', value: 'jaksel' },
|
|
{ label: 'Bahasa Inggris', value: 'en' },
|
|
{ label: 'Tidak Diketahui', value: 'unknown', priority: 100 },
|
|
]
|
|
</script>
|
|
|
|
<template>
|
|
<FieldGroup :class="cn('select-field-group', fieldGroupClass, containerClass)">
|
|
<Label
|
|
:label-for="fieldName"
|
|
:class="cn('select-field-label', labelClass)"
|
|
:is-required="isRequired"
|
|
>
|
|
{{ label }}
|
|
</Label>
|
|
<Field
|
|
:id="fieldName"
|
|
:errors="errors"
|
|
:class="cn('select-field-wrapper')"
|
|
>
|
|
<FormField
|
|
v-slot="{ componentField }"
|
|
:name="fieldName"
|
|
>
|
|
<FormItem>
|
|
<FormControl>
|
|
<Select
|
|
:id="fieldName"
|
|
v-bind="componentField"
|
|
:items="langOptions"
|
|
: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>
|
|
</Field>
|
|
</FieldGroup>
|
|
</template>
|