33 lines
1.6 KiB
Vue
33 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import type { SelectTriggerProps } from "reka-ui"
|
|
import type { HTMLAttributes } from "vue"
|
|
import { reactiveOmit } from "@vueuse/core"
|
|
import { IconChevronDown } from "@tabler/icons-vue"
|
|
import { SelectIcon, SelectTrigger, useForwardProps } from "reka-ui"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
const props = withDefaults(
|
|
defineProps<SelectTriggerProps & { class?: HTMLAttributes["class"], size?: "sm" | "default" }>(),
|
|
{ size: "default" },
|
|
)
|
|
|
|
const delegatedProps = reactiveOmit(props, "class", "size")
|
|
const forwardedProps = useForwardProps(delegatedProps)
|
|
</script>
|
|
|
|
<template>
|
|
<SelectTrigger
|
|
data-slot="select-trigger"
|
|
:data-size="size"
|
|
v-bind="forwardedProps"
|
|
:class="cn(
|
|
'border-2 border-foreground data-[placeholder]:text-foreground/50 [&_svg:not([class*=\'text-\'])]:text-foreground/60 focus-visible:ring-foreground/20 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-lg bg-card px-3.5 py-2 text-sm font-medium text-foreground whitespace-nowrap shadow-2xs transition-shadow outline-none focus:shadow-xs focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-10 data-[size=sm]:h-9 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
|
|
props.class,
|
|
)"
|
|
>
|
|
<slot />
|
|
<SelectIcon as-child>
|
|
<IconChevronDown class="size-4 opacity-50" />
|
|
</SelectIcon>
|
|
</SelectTrigger>
|
|
</template>
|