35 lines
1.2 KiB
Vue
35 lines
1.2 KiB
Vue
<script setup lang="ts">
|
|
import type { SelectTriggerProps } from 'radix-vue'
|
|
import type { HTMLAttributes } from 'vue'
|
|
import { SelectIcon, SelectTrigger, useForwardProps } from 'radix-vue'
|
|
import { computed } from 'vue'
|
|
import { cn } from '~/lib/utils'
|
|
|
|
const props = defineProps<SelectTriggerProps & { class?: HTMLAttributes['class'], iconName?: string }>()
|
|
|
|
const delegatedProps = computed(() => {
|
|
const { class: _, ...delegated } = props
|
|
return delegated
|
|
})
|
|
|
|
const forwardedProps = useForwardProps(delegatedProps)
|
|
const iconName = computed(() => props.iconName || 'i-radix-icons-caret-sort')
|
|
</script>
|
|
|
|
<template>
|
|
<SelectTrigger
|
|
v-bind="forwardedProps"
|
|
:class="
|
|
cn(
|
|
'border-input ring-offset-background placeholder:text-muted-foreground relative flex h-9 md:h-8 xl:h-9 w-full rounded-md border border-gray-400 pl-3 pr-8 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:cursor-not-allowed disabled:opacity-50',
|
|
props.class,
|
|
)
|
|
"
|
|
>
|
|
<slot />
|
|
<SelectIcon as-child class="absolute right-3 top-1/2 -translate-y-1/2">
|
|
<Icon :name="iconName" class="h-4 w-4 opacity-50" />
|
|
</SelectIcon>
|
|
</SelectTrigger>
|
|
</template>
|