refactor: update default

This commit is contained in:
Sadegh Barati 2024-01-19 02:15:56 +03:30
parent 8f3f52b99f
commit e994656db0
97 changed files with 483 additions and 380 deletions

View File

@ -15,14 +15,9 @@ const delegatedProps = computed(() => {
<template> <template>
<AccordionContent <AccordionContent
v-bind="delegatedProps" v-bind="delegatedProps"
:class=" class="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
cn(
'overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',
props.class,
)
"
> >
<div class="pb-4 pt-0"> <div :class="cn('pb-4 pt-0', props.class)">
<slot /> <slot />
</div> </div>
</AccordionContent> </AccordionContent>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { AccordionItem, type AccordionItemProps } from 'radix-vue' import { AccordionItem, type AccordionItemProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<AccordionItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<AccordionItemProps & { class?: HTMLAttributes['class'] }>()
@ -10,11 +10,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<AccordionItem <AccordionItem
v-bind="delegatedProps" v-bind="forwardedProps"
:class="cn('border-b', props.class)" :class="cn('border-b', props.class)"
> >
<slot /> <slot />

View File

@ -18,20 +18,22 @@ const delegatedProps = computed(() => {
</script> </script>
<template> <template>
<AccordionHeader class="flex" as="div"> <AccordionHeader class="flex">
<AccordionTrigger <AccordionTrigger
v-bind="delegatedProps" v-bind="delegatedProps"
:class=" :class="
cn( cn(
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180', 'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
props.class, props.class,
) )
" "
> >
<slot /> <slot />
<slot name="icon">
<ChevronDown <ChevronDown
class="h-4 w-4 shrink-0 transition-transform duration-200" class="h-4 w-4 shrink-0 transition-transform duration-200"
/> />
</slot>
</AccordionTrigger> </AccordionTrigger>
</AccordionHeader> </AccordionHeader>
</template> </template>

View File

@ -6,7 +6,7 @@ import {
type AlertDialogContentProps, type AlertDialogContentProps,
AlertDialogOverlay, AlertDialogOverlay,
AlertDialogPortal, AlertDialogPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,18 +18,20 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<AlertDialogPortal> <AlertDialogPortal>
<AlertDialogOverlay <AlertDialogOverlay
class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" class="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
/> />
<AlertDialogContent <AlertDialogContent
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class=" :class="
cn( cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full', 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
props.class, props.class,
) )
" "

View File

@ -18,7 +18,7 @@ const delegatedProps = computed(() => {
<template> <template>
<AlertDialogDescription <AlertDialogDescription
v-bind="delegatedProps" v-bind="delegatedProps"
:class="cn('text-muted-foreground text-sm', props.class)" :class="cn('text-sm text-muted-foreground', props.class)"
> >
<slot /> <slot />
</AlertDialogDescription> </AlertDialogDescription>

View File

@ -11,7 +11,7 @@ const props = defineProps<{
<div <div
:class=" :class="
cn( cn(
'flex flex-col space-y-2 sm:space-y-0 mt-3.5 sm:flex-row sm:justify-end sm:space-x-2', 'flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-x-2',
props.class, props.class,
) )
" "

View File

@ -9,7 +9,7 @@ const props = defineProps<{
<template> <template>
<div <div
:class="cn('flex flex-col space-y-2 text-center sm:text-left', props.class)" :class="cn('flex flex-col gap-y-2 text-center sm:text-left', props.class)"
> >
<slot /> <slot />
</div> </div>

View File

@ -15,7 +15,7 @@ const delegatedProps = computed(() => {
<template> <template>
<AlertDialogTitle <AlertDialogTitle
v-bind="delegatedProps" v-bind="delegatedProps"
:class="cn('text-lg text-foreground font-semibold', props.class)" :class="cn('text-lg font-semibold', props.class)"
> >
<slot /> <slot />
</AlertDialogTitle> </AlertDialogTitle>

View File

@ -10,7 +10,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<div :class="cn(alertVariants({ variant }), props.class)"> <div :class="cn(alertVariants({ variant }), props.class)" role="alert">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -8,11 +8,11 @@ export const badgeVariants = cva(
variants: { variants: {
variant: { variant: {
default: default:
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80', 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
secondary: secondary:
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
destructive: destructive:
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80', 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
outline: 'text-foreground', outline: 'text-foreground',
}, },
}, },

View File

@ -3,25 +3,25 @@ import { type VariantProps, cva } from 'class-variance-authority'
export { default as Button } from './Button.vue' export { default as Button } from './Button.vue'
export const buttonVariants = cva( export const buttonVariants = cva(
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{ {
variants: { variants: {
variant: { variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90', default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
destructive: destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90', 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
outline: outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground', 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
secondary: secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80', 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground', ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline', link: 'text-primary underline-offset-4 hover:underline',
}, },
size: { size: {
default: 'h-10 px-4 py-2', default: 'h-9 px-4 py-2',
sm: 'h-9 rounded-md px-3', sm: 'h-8 rounded-md px-3 text-xs',
lg: 'h-11 rounded-md px-8', lg: 'h-10 rounded-md px-8',
icon: 'h-10 w-10', icon: 'h-9 w-9',
}, },
}, },
defaultVariants: { defaultVariants: {

View File

@ -28,8 +28,7 @@ interface SimpleDateParts {
defineOptions({ defineOptions({
inheritAttrs: false, inheritAttrs: false,
}) })
const props = withDefaults(defineProps< {
const props = withDefaults(defineProps<{
modelValue?: string | number | Date | DatePickerModel modelValue?: string | number | Date | DatePickerModel
modelModifiers?: object modelModifiers?: object
columns?: number columns?: number
@ -79,8 +78,8 @@ onMounted(async () => {
<DatePicker <DatePicker
ref="datePicker" ref="datePicker"
v-model="modelValue"
v-bind="$attrs" v-bind="$attrs"
v-model="modelValue"
:model-modifiers="modelModifiers" :model-modifiers="modelModifiers"
class="calendar" class="calendar"
trim-weeks trim-weeks
@ -110,7 +109,7 @@ onMounted(async () => {
@apply flex; @apply flex;
} }
.calendar .vc-weekday { .calendar .vc-weekday {
@apply text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]; @apply text-muted-foreground rounded-md w-8 font-normal text-[0.8rem];
} }
.calendar .vc-weeks { .calendar .vc-weeks {
@apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7; @apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7;
@ -131,7 +130,7 @@ onMounted(async () => {
@apply rounded-md; @apply rounded-md;
} }
.calendar .vc-day-content { .calendar .vc-day-content {
@apply text-center text-sm p-0 relative focus-within:relative focus-within:z-20 inline-flex items-center justify-center ring-offset-background hover:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hover:bg-accent hover:text-accent-foreground h-9 w-9 font-normal aria-selected:opacity-100 select-none; @apply text-center text-sm p-0 relative focus-within:relative focus-within:z-20 inline-flex items-center justify-center ring-offset-background hover:transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hover:bg-accent hover:text-accent-foreground h-8 w-8 font-normal aria-selected:opacity-100 select-none;
} }
.calendar .vc-day-content:not(.vc-highlight-content-light) { .calendar .vc-day-content:not(.vc-highlight-content-light) {
@apply rounded-md; @apply rounded-md;
@ -157,6 +156,7 @@ onMounted(async () => {
--vc-slide-duration: 0.15s; --vc-slide-duration: 0.15s;
--vc-slide-timing: ease; --vc-slide-timing: ease;
} }
.calendar .vc-fade-enter-active, .calendar .vc-fade-enter-active,
.calendar .vc-fade-leave-active, .calendar .vc-fade-leave-active,
.calendar .vc-slide-left-enter-active, .calendar .vc-slide-left-enter-active,
@ -183,6 +183,7 @@ onMounted(async () => {
backface-visibility: hidden; backface-visibility: hidden;
pointer-events: none; pointer-events: none;
} }
.calendar .vc-none-leave-active, .calendar .vc-none-leave-active,
.calendar .vc-fade-leave-active, .calendar .vc-fade-leave-active,
.calendar .vc-slide-left-leave-active, .calendar .vc-slide-left-leave-active,
@ -192,6 +193,7 @@ onMounted(async () => {
position: absolute !important; position: absolute !important;
width: 100%; width: 100%;
} }
.calendar .vc-none-enter-from, .calendar .vc-none-enter-from,
.calendar .vc-none-leave-to, .calendar .vc-none-leave-to,
.calendar .vc-fade-enter-from, .calendar .vc-fade-enter-from,
@ -208,6 +210,7 @@ onMounted(async () => {
.calendar .vc-slide-fade-leave-to { .calendar .vc-slide-fade-leave-to {
opacity: 0; opacity: 0;
} }
.calendar .vc-slide-left-enter-from, .calendar .vc-slide-left-enter-from,
.calendar .vc-slide-right-leave-to, .calendar .vc-slide-right-leave-to,
.calendar .vc-slide-fade-enter-from.direction-left, .calendar .vc-slide-fade-enter-from.direction-left,
@ -215,6 +218,7 @@ onMounted(async () => {
-webkit-transform: translateX(var(--vc-slide-translate)); -webkit-transform: translateX(var(--vc-slide-translate));
transform: translateX(var(--vc-slide-translate)); transform: translateX(var(--vc-slide-translate));
} }
.calendar .vc-slide-right-enter-from, .calendar .vc-slide-right-enter-from,
.calendar .vc-slide-left-leave-to, .calendar .vc-slide-left-leave-to,
.calendar .vc-slide-fade-enter-from.direction-right, .calendar .vc-slide-fade-enter-from.direction-right,
@ -222,6 +226,7 @@ onMounted(async () => {
-webkit-transform: translateX(calc(-1 * var(--vc-slide-translate))); -webkit-transform: translateX(calc(-1 * var(--vc-slide-translate)));
transform: translateX(calc(-1 * var(--vc-slide-translate))); transform: translateX(calc(-1 * var(--vc-slide-translate)));
} }
.calendar .vc-slide-up-enter-from, .calendar .vc-slide-up-enter-from,
.calendar .vc-slide-down-leave-to, .calendar .vc-slide-down-leave-to,
.calendar .vc-slide-fade-enter-from.direction-top, .calendar .vc-slide-fade-enter-from.direction-top,
@ -229,6 +234,7 @@ onMounted(async () => {
-webkit-transform: translateY(var(--vc-slide-translate)); -webkit-transform: translateY(var(--vc-slide-translate));
transform: translateY(var(--vc-slide-translate)); transform: translateY(var(--vc-slide-translate));
} }
.calendar .vc-slide-down-enter-from, .calendar .vc-slide-down-enter-from,
.calendar .vc-slide-up-leave-to, .calendar .vc-slide-up-leave-to,
.calendar .vc-slide-fade-enter-from.direction-bottom, .calendar .vc-slide-fade-enter-from.direction-bottom,

View File

@ -8,7 +8,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<div :class="cn('p-6 pt-0', props.class)"> <div :class="cn('flex items-center p-6 pt-0', props.class)">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -8,7 +8,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<div :class="cn('flex flex-col space-y-1.5 p-6', props.class)"> <div :class="cn('flex flex-col gap-y-1.5 p-6', props.class)">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -10,7 +10,7 @@ const props = defineProps<{
<template> <template>
<h3 <h3
:class=" :class="
cn('text-2xl font-semibold leading-none tracking-tighter', props.class) cn('font-semibold leading-none tracking-tight', props.class)
" "
> >
<slot /> <slot />

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { WithClassAsProps } from './interface'
import { useCarousel } from './useCarousel' import { useCarousel } from './useCarousel'
import type { WithClassAsProps } from './interface'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
defineOptions({ defineOptions({

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { WithClassAsProps } from './interface'
import { useCarousel } from './useCarousel' import { useCarousel } from './useCarousel'
import type { WithClassAsProps } from './interface'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<WithClassAsProps>() const props = defineProps<WithClassAsProps>()

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ChevronRight } from 'lucide-vue-next' import { ArrowRight } from 'lucide-vue-next'
import { useCarousel } from './useCarousel' import { useCarousel } from './useCarousel'
import type { WithClassAsProps } from './interface' import type { WithClassAsProps } from './interface'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -24,7 +24,7 @@ const { orientation, canScrollNext, scrollNext } = useCarousel()
@click="scrollNext" @click="scrollNext"
> >
<slot> <slot>
<ChevronRight class="h-4 w-4 text-current" /> <ArrowRight class="h-4 w-4 text-current" />
</slot> </slot>
</Button> </Button>
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ChevronLeft } from 'lucide-vue-next' import { ArrowLeft } from 'lucide-vue-next'
import { useCarousel } from './useCarousel' import { useCarousel } from './useCarousel'
import type { WithClassAsProps } from './interface' import type { WithClassAsProps } from './interface'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -24,7 +24,7 @@ const { orientation, canScrollPrev, scrollPrev } = useCarousel()
@click="scrollPrev" @click="scrollPrev"
> >
<slot> <slot>
<ChevronLeft class="h-4 w-4 text-current" /> <ArrowLeft class="h-4 w-4 text-current" />
</slot> </slot>
</Button> </Button>
</template> </template>

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import type { CheckboxRootEmits, CheckboxRootProps } from 'radix-vue' import type { CheckboxRootEmits, CheckboxRootProps } from 'radix-vue'
import { CheckboxIndicator, CheckboxRoot, useEmitAsProps } from 'radix-vue' import { CheckboxIndicator, CheckboxRoot, useForwardPropsEmits } from 'radix-vue'
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -13,20 +13,21 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<CheckboxRoot <CheckboxRoot
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class=" :class="
cn('peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', cn('peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
props.class)" props.class)"
> >
<CheckboxIndicator class="flex h-full w-full items-center justify-center text-current"> <CheckboxIndicator class="flex h-full w-full items-center justify-center text-current">
<slot>
<Check class="h-4 w-4" /> <Check class="h-4 w-4" />
</slot>
</CheckboxIndicator> </CheckboxIndicator>
</CheckboxRoot> </CheckboxRoot>
</template> </template>

View File

@ -1,13 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import type { ComboboxRootEmits, ComboboxRootProps } from 'radix-vue' import type { ComboboxRootEmits, ComboboxRootProps } from 'radix-vue'
import { ComboboxRoot, useEmitAsProps } from 'radix-vue' import { ComboboxRoot, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<ComboboxRootProps & { class?: HTMLAttributes['class'] }>(), { const props = withDefaults(defineProps<ComboboxRootProps & { class?: HTMLAttributes['class'] }>(), {
open: true, open: true,
modelValue: '', modelValue: '',
}) })
const emits = defineEmits<ComboboxRootEmits>() const emits = defineEmits<ComboboxRootEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -15,14 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ComboboxRoot <ComboboxRoot
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="cn('flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground', props.class)" :class="cn('flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground', props.class)"
> >
<slot /> <slot />

View File

@ -12,7 +12,7 @@ const forwarded = useForwardPropsEmits(props, emits)
<template> <template>
<Dialog v-bind="forwarded"> <Dialog v-bind="forwarded">
<DialogContent class="p-0 overflow-hidden shadow-lg"> <DialogContent class="overflow-hidden p-0 shadow-lg">
<Command class="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"> <Command class="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
<slot /> <slot />
</Command> </Command>

View File

@ -19,7 +19,7 @@ const delegatedProps = computed(() => {
<template> <template>
<ComboboxGroup <ComboboxGroup
v-bind="delegatedProps" v-bind="delegatedProps"
:class="cn('overflow-hidden p-1 text-foreground', props.class)" :class="cn('overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground', props.class)"
> >
<ComboboxLabel v-if="heading" class="px-2 py-1.5 text-xs font-medium text-muted-foreground"> <ComboboxLabel v-if="heading" class="px-2 py-1.5 text-xs font-medium text-muted-foreground">
{{ heading }} {{ heading }}

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { Search } from 'lucide-vue-next' import { Search } from 'lucide-vue-next'
import { ComboboxInput, type ComboboxInputProps } from 'radix-vue' import { ComboboxInput, type ComboboxInputProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
defineOptions({ defineOptions({
@ -17,13 +17,15 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<div class="flex items-center border-b px-3" cmdk-input-wrapper> <div class="flex items-center border-b px-3" cmdk-input-wrapper>
<Search class="mr-2 h-4 w-4 shrink-0 opacity-50" /> <Search class="mr-2 h-4 w-4 shrink-0 opacity-50" />
<ComboboxInput <ComboboxInput
v-bind="{ ...delegatedProps, ...$attrs }" v-bind="{ ...forwardedProps, ...$attrs }"
auto-focus auto-focus
:class="cn('flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50', props.class)" :class="cn('flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50', props.class)"
/> />

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import type { ComboboxItemEmits, ComboboxItemProps } from 'radix-vue' import type { ComboboxItemEmits, ComboboxItemProps } from 'radix-vue'
import { ComboboxItem, useEmitAsProps } from 'radix-vue' import { ComboboxItem, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ComboboxItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<ComboboxItemProps & { class?: HTMLAttributes['class'] }>()
@ -12,12 +12,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ComboboxItem <ComboboxItem
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class="cn('relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', props.class)" :class="cn('relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', props.class)"
@select.prevent @select.prevent
> >
<slot /> <slot />

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import type { ComboboxContentEmits, ComboboxContentProps } from 'radix-vue' import type { ComboboxContentEmits, ComboboxContentProps } from 'radix-vue'
import { ComboboxContent, useEmitAsProps } from 'radix-vue' import { ComboboxContent, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ComboboxContentProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<ComboboxContentProps & { class?: HTMLAttributes['class'] }>()
@ -12,10 +12,12 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ComboboxContent v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" :class="cn('max-h-[300px] overflow-y-auto overflow-x-hidden', props.class)"> <ComboboxContent v-bind="forwarded" :class="cn('max-h-[300px] overflow-y-auto overflow-x-hidden', props.class)">
<div role="presentation"> <div role="presentation">
<slot /> <slot />
</div> </div>

View File

@ -5,7 +5,7 @@ import {
type ContextMenuCheckboxItemEmits, type ContextMenuCheckboxItemEmits,
type ContextMenuCheckboxItemProps, type ContextMenuCheckboxItemProps,
ContextMenuItemIndicator, ContextMenuItemIndicator,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,23 +18,21 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ContextMenuCheckboxItem <ContextMenuCheckboxItem
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class="[ :class="cn(
cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
props.class, props.class,
), )"
]"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<ContextMenuItemIndicator <ContextMenuItemIndicator>
class="absolute left-1.5 inline-flex w-4 h-4 items-center justify-center" <Check class="h-4 w-4" />
>
<Check class="h-4 h-w" />
</ContextMenuItemIndicator> </ContextMenuItemIndicator>
</span> </span>
<slot /> <slot />

View File

@ -5,7 +5,7 @@ import {
type ContextMenuContentEmits, type ContextMenuContentEmits,
type ContextMenuContentProps, type ContextMenuContentProps,
ContextMenuPortal, ContextMenuPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -17,15 +17,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ContextMenuPortal> <ContextMenuPortal>
<ContextMenuContent <ContextMenuContent
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="[ :class="[
cn( cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',

View File

@ -4,7 +4,7 @@ import {
ContextMenuItem, ContextMenuItem,
type ContextMenuItemEmits, type ContextMenuItemEmits,
type ContextMenuItemProps, type ContextMenuItemProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,11 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ContextMenuItem <ContextMenuItem
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class="[ :class="[
cn( cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',

View File

@ -5,7 +5,7 @@ import {
ContextMenuRadioItem, ContextMenuRadioItem,
type ContextMenuRadioItemEmits, type ContextMenuRadioItemEmits,
type ContextMenuRadioItemProps, type ContextMenuRadioItemProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Circle } from 'lucide-vue-next' import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,14 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ContextMenuRadioItem <ContextMenuRadioItem
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="[ :class="[
cn( cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',

View File

@ -4,7 +4,7 @@ import {
ContextMenuSubContent, ContextMenuSubContent,
type DropdownMenuSubContentEmits, type DropdownMenuSubContentEmits,
type DropdownMenuSubContentProps, type DropdownMenuSubContentProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,14 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ContextMenuSubContent <ContextMenuSubContent
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class=" :class="
cn( cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',

View File

@ -3,6 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { import {
ContextMenuSubTrigger, ContextMenuSubTrigger,
type ContextMenuSubTriggerProps, type ContextMenuSubTriggerProps,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { ChevronRight } from 'lucide-vue-next' import { ChevronRight } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -14,11 +15,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<ContextMenuSubTrigger <ContextMenuSubTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class="[ :class="[
cn( cn(
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground', 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',

View File

@ -1,11 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { ContextMenuTrigger, type ContextMenuTriggerProps } from 'radix-vue' import { ContextMenuTrigger, type ContextMenuTriggerProps, useForwardProps } from 'radix-vue'
const props = defineProps<ContextMenuTriggerProps>() const props = defineProps<ContextMenuTriggerProps>()
const forwardedProps = useForwardProps(props)
</script> </script>
<template> <template>
<ContextMenuTrigger v-bind="props"> <ContextMenuTrigger v-bind="forwardedProps">
<slot /> <slot />
</ContextMenuTrigger> </ContextMenuTrigger>
</template> </template>

View File

@ -7,7 +7,7 @@ import {
type DialogContentProps, type DialogContentProps,
DialogOverlay, DialogOverlay,
DialogPortal, DialogPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { X } from 'lucide-vue-next' import { X } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -20,25 +20,27 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DialogPortal> <DialogPortal>
<DialogOverlay <DialogOverlay
class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" class="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
/> />
<DialogContent <DialogContent
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class=" :class="
cn( cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full', 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
props.class, props.class,
)" )"
> >
<slot /> <slot />
<DialogClose <DialogClose
class="absolute top-3 right-3 p-0.5 transition-colors rounded-md hover:bg-secondary" class="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
> >
<X class="w-4 h-4" /> <X class="w-4 h-4" />
<span class="sr-only">Close</span> <span class="sr-only">Close</span>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { DialogDescription, type DialogDescriptionProps } from 'radix-vue' import { DialogDescription, type DialogDescriptionProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DialogDescriptionProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DialogDescriptionProps & { class?: HTMLAttributes['class'] }>()
@ -10,12 +10,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<DialogDescription <DialogDescription
v-bind="delegatedProps" v-bind="forwardedProps"
:class="cn('text-muted-foreground text-sm', props.class)" :class="cn('text-sm text-muted-foreground', props.class)"
> >
<slot /> <slot />
</DialogDescription> </DialogDescription>

View File

@ -9,7 +9,7 @@ const props = defineProps<{ class?: HTMLAttributes['class'] }>()
<div <div
:class=" :class="
cn( cn(
'flex flex-col space-y-2 sm:space-y-0 mt-1.5 sm:flex-row sm:justify-end sm:space-x-2', 'flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-x-2',
props.class, props.class,
) )
" "

View File

@ -9,7 +9,7 @@ const props = defineProps<{
<template> <template>
<div <div
:class="cn('flex flex-col space-y-2 text-center sm:text-left', props.class)" :class="cn('flex flex-col gap-y-1.5 text-center sm:text-left', props.class)"
> >
<slot /> <slot />
</div> </div>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { DialogTitle, type DialogTitleProps } from 'radix-vue' import { DialogTitle, type DialogTitleProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DialogTitleProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<DialogTitleProps & { class?: HTMLAttributes['class'] }>()
@ -10,14 +10,16 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<DialogTitle <DialogTitle
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'text-lg text-foreground font-semibold leading-none tracking-tight', 'text-lg font-semibold leading-none tracking-tight',
props.class, props.class,
) )
" "

View File

@ -5,7 +5,7 @@ import {
type DropdownMenuCheckboxItemEmits, type DropdownMenuCheckboxItemEmits,
type DropdownMenuCheckboxItemProps, type DropdownMenuCheckboxItemProps,
DropdownMenuItemIndicator, DropdownMenuItemIndicator,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,11 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DropdownMenuCheckboxItem <DropdownMenuCheckboxItem
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class=" cn( :class=" cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
props.class, props.class,

View File

@ -5,7 +5,7 @@ import {
type DropdownMenuContentEmits, type DropdownMenuContentEmits,
type DropdownMenuContentProps, type DropdownMenuContentProps,
DropdownMenuPortal, DropdownMenuPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -22,21 +22,15 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DropdownMenuPortal> <DropdownMenuPortal>
<DropdownMenuContent <DropdownMenuContent
v-bind="{ v-bind="forwarded"
...delegatedProps, :class="cn('z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)"
...useEmitAsProps(emits),
}"
:class="[
cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
props.class,
),
]"
> >
<slot /> <slot />
</DropdownMenuContent> </DropdownMenuContent>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { DropdownMenuItem, type DropdownMenuItemProps } from 'radix-vue' import { DropdownMenuItem, type DropdownMenuItemProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuItemProps & { class?: HTMLAttributes['class']; inset?: boolean }>() const props = defineProps<DropdownMenuItemProps & { class?: HTMLAttributes['class']; inset?: boolean }>()
@ -10,11 +10,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<DropdownMenuItem <DropdownMenuItem
v-bind="delegatedProps" v-bind="forwardedProps"
:class="[ :class="[
cn( cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { DropdownMenuLabel, type DropdownMenuLabelProps } from 'radix-vue' import { DropdownMenuLabel, type DropdownMenuLabelProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuLabelProps & { class?: HTMLAttributes['class']; inset?: boolean }>() const props = defineProps<DropdownMenuLabelProps & { class?: HTMLAttributes['class']; inset?: boolean }>()
@ -10,11 +10,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<DropdownMenuLabel <DropdownMenuLabel
v-bind="delegatedProps" v-bind="forwardedProps"
:class="cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', props.class)" :class="cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', props.class)"
> >
<slot /> <slot />

View File

@ -5,7 +5,7 @@ import {
DropdownMenuRadioItem, DropdownMenuRadioItem,
type DropdownMenuRadioItemEmits, type DropdownMenuRadioItemEmits,
type DropdownMenuRadioItemProps, type DropdownMenuRadioItemProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Circle } from 'lucide-vue-next' import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -19,18 +19,19 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DropdownMenuRadioItem <DropdownMenuRadioItem
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class="cn( :class="cn(
'flex relative items-center rounded-md transition-colors data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-outline-hover pl-7 py-1.5 text-sm outline-none select-none cursor-default', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
props.class, props.class,
)" )"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuItemIndicator> <DropdownMenuItemIndicator>
<Circle class="h-2 w-2 fill-current" /> <Circle class="h-2 w-2 fill-current" />
</DropdownMenuItemIndicator> </DropdownMenuItemIndicator>

View File

@ -1,12 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { import {
DropdownMenuSeparator, DropdownMenuSeparator,
type DropdownMenuSeparatorProps, type DropdownMenuSeparatorProps,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<DropdownMenuSeparatorProps>() const props = defineProps<DropdownMenuSeparatorProps & {
class?: HTMLAttributes['class']
}>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<DropdownMenuSeparator v-bind="props" class="-mx-1 my-1 h-px bg-muted" /> <DropdownMenuSeparator v-bind="delegatedProps" :class="cn('-mx-1 my-1 h-px bg-muted', props.class)" />
</template> </template>

View File

@ -4,7 +4,7 @@ import {
DropdownMenuSubContent, DropdownMenuSubContent,
type DropdownMenuSubContentEmits, type DropdownMenuSubContentEmits,
type DropdownMenuSubContentProps, type DropdownMenuSubContentProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,14 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DropdownMenuSubContent <DropdownMenuSubContent
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="cn('z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)" :class="cn('z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)"
> >
<slot /> <slot />

View File

@ -3,6 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { import {
DropdownMenuSubTrigger, DropdownMenuSubTrigger,
type DropdownMenuSubTriggerProps, type DropdownMenuSubTriggerProps,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { ChevronRight } from 'lucide-vue-next' import { ChevronRight } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -14,11 +15,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<DropdownMenuSubTrigger <DropdownMenuSubTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class="[ :class="[
cn( cn(
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent', 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',

View File

@ -1,11 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { DropdownMenuTrigger, type DropdownMenuTriggerProps } from 'radix-vue' import { DropdownMenuTrigger, type DropdownMenuTriggerProps, useForwardProps } from 'radix-vue'
const props = defineProps<DropdownMenuTriggerProps>() const props = defineProps<DropdownMenuTriggerProps>()
const forwardedProps = useForwardProps(props)
</script> </script>
<template> <template>
<DropdownMenuTrigger class="outline-none" v-bind="props"> <DropdownMenuTrigger class="outline-none" v-bind="forwardedProps">
<slot /> <slot />
</DropdownMenuTrigger> </DropdownMenuTrigger>
</template> </template>

View File

@ -1,12 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { HTMLAttributes } from 'vue' import type { HTMLAttributes } from 'vue'
import { Label, type LabelProps } from 'radix-vue' import type { LabelProps } from 'radix-vue'
import { useFormField } from './useFormField' import { useFormField } from './useFormField'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { Label } from '@/lib/registry/default/ui/label'
defineOptions({
inheritAttrs: false,
})
const props = defineProps<LabelProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<LabelProps & { class?: HTMLAttributes['class'] }>()
const { error, formItemId } = useFormField() const { error, formItemId } = useFormField()
@ -15,7 +13,6 @@ const { error, formItemId } = useFormField()
<template> <template>
<Label <Label
:class="cn( :class="cn(
'block text-sm tracking-tight font-medium text-foreground text-left',
error && 'text-destructive', error && 'text-destructive',
props.class, props.class,
)" )"

View File

@ -2,11 +2,12 @@
import { HoverCardRoot, type HoverCardRootProps, useForwardProps } from 'radix-vue' import { HoverCardRoot, type HoverCardRootProps, useForwardProps } from 'radix-vue'
const props = defineProps<HoverCardRootProps>() const props = defineProps<HoverCardRootProps>()
const forwarded = useForwardProps(props)
const forwardedProps = useForwardProps(props)
</script> </script>
<template> <template>
<HoverCardRoot v-bind="forwarded"> <HoverCardRoot v-bind="forwardedProps">
<slot /> <slot />
</HoverCardRoot> </HoverCardRoot>
</template> </template>

View File

@ -4,6 +4,7 @@ import {
HoverCardContent, HoverCardContent,
type HoverCardContentProps, type HoverCardContentProps,
HoverCardPortal, HoverCardPortal,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -19,15 +20,17 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<HoverCardPortal> <HoverCardPortal>
<HoverCardContent <HoverCardContent
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'z-50 w-64 rounded-md bg-background border border-border p-4 text-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
props.class, props.class,
) )
" "

View File

@ -17,7 +17,7 @@ const delegatedProps = computed(() => {
v-bind="delegatedProps" v-bind="delegatedProps"
:class=" :class="
cn( cn(
'block text-sm tracking-tight font-medium text-foreground text-left', 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
props.class, props.class,
) )
" "

View File

@ -4,7 +4,7 @@ import {
MenubarRoot, MenubarRoot,
type MenubarRootEmits, type MenubarRootEmits,
type MenubarRootProps, type MenubarRootProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,17 +16,16 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<MenubarRoot <MenubarRoot
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class=" :class="
cn( cn(
'flex h-10 items-center space-x-1 rounded-md border border-border p-1', 'flex h-10 items-center gap-x-1 rounded-md border bg-background p-1',
props.class, props.class,
) )
" "

View File

@ -5,13 +5,12 @@ import {
type MenubarCheckboxItemEmits, type MenubarCheckboxItemEmits,
type MenubarCheckboxItemProps, type MenubarCheckboxItemProps,
MenubarItemIndicator, MenubarItemIndicator,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<MenubarCheckboxItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<MenubarCheckboxItemProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<MenubarCheckboxItemEmits>() const emits = defineEmits<MenubarCheckboxItemEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -19,26 +18,23 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<MenubarCheckboxItem <MenubarCheckboxItem
v-bind="{ v-bind="forwarded"
...delegatedProps, :class="cn(
...useEmitAsProps(emits),
}"
:class="[
cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
props.class, props.class,
), )"
]"
>
<MenubarItemIndicator
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<MenubarItemIndicator>
<Check class="w-4 h-4" /> <Check class="w-4 h-4" />
</MenubarItemIndicator> </MenubarItemIndicator>
</span>
<slot /> <slot />
</MenubarCheckboxItem> </MenubarCheckboxItem>
</template> </template>

View File

@ -4,6 +4,7 @@ import {
MenubarContent, MenubarContent,
type MenubarContentProps, type MenubarContentProps,
MenubarPortal, MenubarPortal,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -21,12 +22,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<MenubarPortal> <MenubarPortal>
<MenubarContent <MenubarContent
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',

View File

@ -4,7 +4,7 @@ import {
MenubarItem, MenubarItem,
type MenubarItemEmits, type MenubarItemEmits,
type MenubarItemProps, type MenubarItemProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -17,14 +17,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<MenubarItem <MenubarItem
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="[ :class="[
cn( cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',

View File

@ -5,7 +5,7 @@ import {
MenubarRadioItem, MenubarRadioItem,
type MenubarRadioItemEmits, type MenubarRadioItemEmits,
type MenubarRadioItemProps, type MenubarRadioItemProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { Circle } from 'lucide-vue-next' import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,27 +18,23 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<MenubarRadioItem <MenubarRadioItem
v-bind="{ v-bind="forwarded"
...delegatedProps, :class="cn(
...useEmitAsProps(emits),
}"
:class="[
cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
props.class, props.class,
), )"
]"
>
<MenubarItemIndicator
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
> >
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<MenubarItemIndicator>
<Circle class="h-2 w-2 fill-curren" /> <Circle class="h-2 w-2 fill-curren" />
</MenubarItemIndicator> </MenubarItemIndicator>
</span>
<slot /> <slot />
</MenubarRadioItem> </MenubarRadioItem>
</template> </template>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { MenubarSeparator, type MenubarSeparatorProps } from 'radix-vue' import { MenubarSeparator, type MenubarSeparatorProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<MenubarSeparatorProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<MenubarSeparatorProps & { class?: HTMLAttributes['class'] }>()
@ -10,8 +10,10 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<MenubarSeparator :class=" cn('-mx-1 my-1 h-px bg-secondary', props.class)" v-bind="delegatedProps" /> <MenubarSeparator :class=" cn('-mx-1 my-1 h-px bg-muted', props.class)" v-bind="forwardedProps" />
</template> </template>

View File

@ -8,7 +8,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<span :class="cn('text-xxs ml-auto tracking-widest opacity-50', props.class)"> <span :class="cn('ml-auto text-xs tracking-widest text-muted-foreground', props.class)">
<slot /> <slot />
</span> </span>
</template> </template>

View File

@ -5,7 +5,7 @@ import {
MenubarSubContent, MenubarSubContent,
type MenubarSubContentEmits, type MenubarSubContentEmits,
type MenubarSubContentProps, type MenubarSubContentProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -24,15 +24,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<MenubarPortal> <MenubarPortal>
<MenubarSubContent <MenubarSubContent
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class=" :class="
cn( cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { MenubarSubTrigger, type MenubarSubTriggerProps } from 'radix-vue' import { MenubarSubTrigger, type MenubarSubTriggerProps, useForwardProps } from 'radix-vue'
import { ChevronRight } from 'lucide-vue-next' import { ChevronRight } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -11,11 +11,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<MenubarSubTrigger <MenubarSubTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class="[ :class="[
cn( cn(
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground', 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { MenubarTrigger, type MenubarTriggerProps } from 'radix-vue' import { MenubarTrigger, type MenubarTriggerProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<MenubarTriggerProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<MenubarTriggerProps & { class?: HTMLAttributes['class'] }>()
@ -10,11 +10,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<MenubarTrigger <MenubarTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground', 'flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',

View File

@ -4,7 +4,7 @@ import {
NavigationMenuRoot, NavigationMenuRoot,
type NavigationMenuRootEmits, type NavigationMenuRootEmits,
type NavigationMenuRootProps, type NavigationMenuRootProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import NavigationMenuViewport from './NavigationMenuViewport.vue' import NavigationMenuViewport from './NavigationMenuViewport.vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -18,14 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<NavigationMenuRoot <NavigationMenuRoot
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="cn('relative z-10 flex max-w-max flex-1 items-center justify-center', props.class)" :class="cn('relative z-10 flex max-w-max flex-1 items-center justify-center', props.class)"
> >
<slot /> <slot />

View File

@ -4,7 +4,7 @@ import {
NavigationMenuContent, NavigationMenuContent,
type NavigationMenuContentEmits, type NavigationMenuContentEmits,
type NavigationMenuContentProps, type NavigationMenuContentProps,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -17,17 +17,17 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<NavigationMenuContent <NavigationMenuContent
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class=" :class="cn(
cn( 'left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto',
'left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ',
props.class, props.class,
) )"
"
> >
<slot /> <slot />
</NavigationMenuContent> </NavigationMenuContent>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { NavigationMenuIndicator, type NavigationMenuIndicatorProps } from 'radix-vue' import { NavigationMenuIndicator, type NavigationMenuIndicatorProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<NavigationMenuIndicatorProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<NavigationMenuIndicatorProps & { class?: HTMLAttributes['class'] }>()
@ -10,11 +10,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<NavigationMenuIndicator <NavigationMenuIndicator
v-bind="delegatedProps" v-bind="forwardedProps"
:class="cn('top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in', props.class)" :class="cn('top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in', props.class)"
> >
<div class="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" /> <div class="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { NavigationMenuList, type NavigationMenuListProps } from 'radix-vue' import { NavigationMenuList, type NavigationMenuListProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<NavigationMenuListProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<NavigationMenuListProps & { class?: HTMLAttributes['class'] }>()
@ -10,14 +10,16 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<NavigationMenuList <NavigationMenuList
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'group flex flex-1 list-none items-center justify-center space-x-1', 'group flex flex-1 list-none items-center justify-center gap-x-1',
props.class, props.class,
) )
" "

View File

@ -3,6 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { import {
NavigationMenuTrigger, NavigationMenuTrigger,
type NavigationMenuTriggerProps, type NavigationMenuTriggerProps,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { ChevronDown } from 'lucide-vue-next' import { ChevronDown } from 'lucide-vue-next'
import { navigationMenuTriggerStyle } from '.' import { navigationMenuTriggerStyle } from '.'
@ -15,16 +16,18 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<NavigationMenuTrigger <NavigationMenuTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class="cn(navigationMenuTriggerStyle(), 'group', props.class)" :class="cn(navigationMenuTriggerStyle(), 'group', props.class)"
> >
<slot /> <slot />
<ChevronDown <ChevronDown
class="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180" class="relative top-px ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180"
aria-hidden="true" aria-hidden="true"
/> />
</NavigationMenuTrigger> </NavigationMenuTrigger>

View File

@ -3,6 +3,7 @@ import { type HTMLAttributes, computed } from 'vue'
import { import {
NavigationMenuViewport, NavigationMenuViewport,
type NavigationMenuViewportProps, type NavigationMenuViewportProps,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -13,12 +14,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<div class="absolute left-0 top-full flex justify-center"> <div class="absolute left-0 top-full flex justify-center">
<NavigationMenuViewport <NavigationMenuViewport
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]', 'origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]',

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { PaginationLast, type PaginationLastProps, useForwardProps } from 'radix-vue' import { PaginationLast, type PaginationLastProps } from 'radix-vue'
import { ChevronsRight } from 'lucide-vue-next' import { ChevronsRight } from 'lucide-vue-next'
import { import {
Button, Button,

View File

@ -5,7 +5,7 @@ import {
type PopoverContentEmits, type PopoverContentEmits,
type PopoverContentProps, type PopoverContentProps,
PopoverPortal, PopoverPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,6 +16,7 @@ defineOptions({
const props = withDefaults( const props = withDefaults(
defineProps<PopoverContentProps & { class?: HTMLAttributes['class'] }>(), defineProps<PopoverContentProps & { class?: HTMLAttributes['class'] }>(),
{ {
align: 'center',
sideOffset: 4, sideOffset: 4,
}, },
) )
@ -26,12 +27,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<PopoverPortal> <PopoverPortal>
<PopoverContent <PopoverContent
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits), ...$attrs }" v-bind="{ ...forwarded, ...$attrs }"
:class=" :class="
cn( cn(
'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',

View File

@ -10,7 +10,6 @@ import { cn } from '@/lib/utils'
const props = withDefaults( const props = withDefaults(
defineProps<ProgressRootProps & { class?: HTMLAttributes['class'] }>(), defineProps<ProgressRootProps & { class?: HTMLAttributes['class'] }>(),
{ {
class: '',
modelValue: 0, modelValue: 0,
}, },
) )
@ -33,7 +32,7 @@ const delegatedProps = computed(() => {
" "
> >
<ProgressIndicator <ProgressIndicator
class="h-full w-full flex-1 duration-300 bg-foreground transition-all" class="h-full w-full flex-1 bg-primary transition-all"
:style="`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`" :style="`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`"
/> />
</ProgressRoot> </ProgressRoot>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { RadioGroupRoot, type RadioGroupRootEmits, type RadioGroupRootProps, useEmitAsProps } from 'radix-vue' import { RadioGroupRoot, type RadioGroupRootEmits, type RadioGroupRootProps, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<RadioGroupRootProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<RadioGroupRootProps & { class?: HTMLAttributes['class'] }>()
@ -11,15 +11,14 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<RadioGroupRoot <RadioGroupRoot
:class="cn('grid gap-2', props.class)" :class="cn('grid gap-2', props.class)"
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
> >
<slot /> <slot />
</RadioGroupRoot> </RadioGroupRoot>

View File

@ -4,6 +4,7 @@ import {
RadioGroupIndicator, RadioGroupIndicator,
RadioGroupItem, RadioGroupItem,
type RadioGroupItemProps, type RadioGroupItemProps,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { Circle } from 'lucide-vue-next' import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -15,14 +16,16 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<RadioGroupItem <RadioGroupItem
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'aspect-square h-4 w-4 rounded-full cursor-pointer flex justify-center items-center border border-primary disabled:cursor-not-allowed disabled:opacity-50', 'aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
props.class, props.class,
) )
" "
@ -30,7 +33,7 @@ const delegatedProps = computed(() => {
<RadioGroupIndicator <RadioGroupIndicator
class="flex items-center justify-center" class="flex items-center justify-center"
> >
<Circle class="w-2.5 h-2.5 text-foreground" /> <Circle class="h-2.5 w-2.5 fill-current text-current" />
</RadioGroupIndicator> </RadioGroupIndicator>
</RadioGroupItem> </RadioGroupItem>
</template> </template>

View File

@ -6,8 +6,9 @@ import {
type SelectContentProps, type SelectContentProps,
SelectPortal, SelectPortal,
SelectViewport, SelectViewport,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { SelectScrollDownButton, SelectScrollUpButton } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
defineOptions({ defineOptions({
@ -27,26 +28,26 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<SelectPortal> <SelectPortal>
<SelectContent <SelectContent
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits), ...$attrs }" :class="cn( v-bind="{ ...forwarded, ...$attrs }" :class="cn(
'relative z-50 min-w-[10rem] overflow-hidden rounded-md bg-background border border-border text-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
position === 'popper' position === 'popper'
&& 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', && 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
props.class, props.class,
) )
" "
> >
<SelectViewport <SelectScrollUpButton />
:class="cn('p-1', <SelectViewport :class="cn('p-1', position === 'popper' && 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]')">
position === 'popper'
&& 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]')"
>
<slot /> <slot />
</SelectViewport> </SelectViewport>
<SelectScrollDownButton />
</SelectContent> </SelectContent>
</SelectPortal> </SelectPortal>
</template> </template>

View File

@ -5,6 +5,7 @@ import {
SelectItemIndicator, SelectItemIndicator,
type SelectItemProps, type SelectItemProps,
SelectItemText, SelectItemText,
useForwardProps,
} from 'radix-vue' } from 'radix-vue'
import { Check } from 'lucide-vue-next' import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -16,11 +17,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<SelectItem <SelectItem
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="
cn( cn(
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',

View File

@ -0,0 +1,24 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { SelectScrollDownButton, type SelectScrollDownButtonProps, useForwardProps } from 'radix-vue'
import { ChevronDown } from 'lucide-vue-next'
import { cn } from '@/lib/utils'
const props = defineProps<SelectScrollDownButtonProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps.value)
</script>
<template>
<SelectScrollDownButton v-bind="forwardedProps" :class="cn('flex cursor-default items-center justify-center py-1', props.class)">
<slot>
<ChevronDown class="h-4 w-4" />
</slot>
</SelectScrollDownButton>
</template>

View File

@ -0,0 +1,24 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { SelectScrollUpButton, type SelectScrollUpButtonProps, useForwardProps } from 'radix-vue'
import { ChevronUp } from 'lucide-vue-next'
import { cn } from '@/lib/utils'
const props = defineProps<SelectScrollUpButtonProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps.value)
</script>
<template>
<SelectScrollUpButton v-bind="forwardedProps" :class="cn('flex cursor-default items-center justify-center py-1', props.class)">
<slot>
<ChevronUp class="h-4 w-4" />
</slot>
</SelectScrollUpButton>
</template>

View File

@ -1,36 +1,27 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { SelectIcon, SelectTrigger, type SelectTriggerProps } from 'radix-vue' import { SelectIcon, SelectTrigger, type SelectTriggerProps, useForwardProps } from 'radix-vue'
import { ChevronDown } from 'lucide-vue-next' import { ChevronDown } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = withDefaults( const props = defineProps<SelectTriggerProps & { class?: HTMLAttributes['class'] }>()
defineProps<SelectTriggerProps & { class?: HTMLAttributes['class']; invalid?: boolean }>(),
{
class: '',
invalid: false,
},
)
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, invalid, ...delegated } = props const { class: _, ...delegated } = props
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<SelectTrigger <SelectTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class="[ :class="cn(
cn( 'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
props.class, props.class,
), )"
props.invalid
? '!ring-destructive ring-2 placeholder:!text-destructive'
: '',
]"
> >
<slot /> <slot />
<SelectIcon as-child> <SelectIcon as-child>

View File

@ -7,3 +7,5 @@ export { default as SelectItem } from './SelectItem.vue'
export { default as SelectItemText } from './SelectItemText.vue' export { default as SelectItemText } from './SelectItemText.vue'
export { default as SelectLabel } from './SelectLabel.vue' export { default as SelectLabel } from './SelectLabel.vue'
export { default as SelectSeparator } from './SelectSeparator.vue' export { default as SelectSeparator } from './SelectSeparator.vue'
export { default as SelectScrollUpButton } from './SelectScrollUpButton.vue'
export { default as SelectScrollDownButton } from './SelectScrollDownButton.vue'

View File

@ -1,13 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { Separator, type SeparatorProps } from 'radix-vue' import { Separator, type SeparatorProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SeparatorProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<SeparatorProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<Separator <Separator
v-bind="delegatedProps"
:class="[ :class="[
cn('shrink-0 bg-secondary', props.class), cn('shrink-0 bg-secondary', props.class),
props.orientation === 'vertical' ? 'w-px h-full' : 'h-px w-full', props.orientation === 'vertical' ? 'w-px h-full' : 'h-px w-full',

View File

@ -7,59 +7,47 @@ import {
type DialogContentProps, type DialogContentProps,
DialogOverlay, DialogOverlay,
DialogPortal, DialogPortal,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { X } from 'lucide-vue-next' import { X } from 'lucide-vue-next'
import { cva } from 'class-variance-authority' import { type SheetVariants, sheetVariants } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface SheetContentProps extends DialogContentProps { interface SheetContentProps extends DialogContentProps {
side?: 'left' | 'right' | 'top' | 'bottom'
class?: HTMLAttributes['class'] class?: HTMLAttributes['class']
side?: SheetVariants['side']
} }
const props = defineProps<SheetContentProps>() defineOptions({
const emits = defineEmits<DialogContentEmits>() inheritAttrs: false,
})
const sheetVariants = cva( const props = defineProps<SheetContentProps>()
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
{ const emits = defineEmits<DialogContentEmits>()
variants: {
side: {
top: 'inset-x-0 top-0 border-b border-border data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
bottom:
'inset-x-0 bottom-0 border-t border-border data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
left: 'inset-y-0 left-0 h-full w-3/4 border-r border-border data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
right:
'inset-y-0 right-0 h-full w-3/4 border-l border-border data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
},
},
defaultVariants: {
side: 'right',
},
},
)
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, side, ...delegated } = props const { class: _, side, ...delegated } = props
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<DialogPortal> <DialogPortal>
<DialogOverlay <DialogOverlay
class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" class="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
/> />
<DialogContent <DialogContent
:class="cn(sheetVariants({ side }), props.class)" :class="cn(sheetVariants({ side }), props.class)"
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="{ ...forwarded, ...$attrs }"
> >
<slot /> <slot />
<DialogClose <DialogClose
class="absolute top-4 right-4 p-0.5 transition-colors rounded-md hover:bg-secondary" class="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"
> >
<X class="w-4 h-4 text-muted-foreground" /> <X class="w-4 h-4 text-muted-foreground" />
</DialogClose> </DialogClose>

View File

@ -9,7 +9,7 @@ const props = defineProps<{ class?: HTMLAttributes['class'] }>()
<div <div
:class=" :class="
cn( cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', 'flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-x-2',
props.class, props.class,
) )
" "

View File

@ -8,7 +8,7 @@ const props = defineProps<{ class?: HTMLAttributes['class'] }>()
<template> <template>
<div <div
:class=" :class="
cn('flex flex-col space-y-2 text-center sm:text-left', props.class) cn('flex flex-col gap-y-2 text-center sm:text-left', props.class)
" "
> >
<slot /> <slot />

View File

@ -1,3 +1,5 @@
import { type VariantProps, cva } from 'class-variance-authority'
export { default as Sheet } from './Sheet.vue' export { default as Sheet } from './Sheet.vue'
export { default as SheetTrigger } from './SheetTrigger.vue' export { default as SheetTrigger } from './SheetTrigger.vue'
export { default as SheetClose } from './SheetClose.vue' export { default as SheetClose } from './SheetClose.vue'
@ -6,3 +8,24 @@ export { default as SheetHeader } from './SheetHeader.vue'
export { default as SheetTitle } from './SheetTitle.vue' export { default as SheetTitle } from './SheetTitle.vue'
export { default as SheetDescription } from './SheetDescription.vue' export { default as SheetDescription } from './SheetDescription.vue'
export { default as SheetFooter } from './SheetFooter.vue' export { default as SheetFooter } from './SheetFooter.vue'
export const sheetVariants = cva(
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
{
variants: {
side: {
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
bottom:
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
right:
'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
},
},
defaultVariants: {
side: 'right',
},
},
)
export type SheetVariants = VariantProps<typeof sheetVariants>

View File

@ -10,5 +10,5 @@ const props = defineProps<SkeletonProps>()
</script> </script>
<template> <template>
<div :class="cn('animate-pulse rounded-md bg-secondary', props.class)" /> <div :class="cn('animate-pulse rounded-md bg-muted', props.class)" />
</template> </template>

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import type { SliderRootEmits, SliderRootProps } from 'radix-vue' import type { SliderRootEmits, SliderRootProps } from 'radix-vue'
import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useEmitAsProps } from 'radix-vue' import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SliderRootProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<SliderRootProps & { class?: HTMLAttributes['class'] }>()
@ -12,6 +12,8 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
@ -20,7 +22,7 @@ const delegatedProps = computed(() => {
'relative flex w-full touch-none select-none items-center', 'relative flex w-full touch-none select-none items-center',
props.class, props.class,
)" )"
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
> >
<SliderTrack class="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary"> <SliderTrack class="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
<SliderRange class="absolute h-full bg-primary" /> <SliderRange class="absolute h-full bg-primary" />

View File

@ -5,11 +5,12 @@ import {
type SwitchRootEmits, type SwitchRootEmits,
type SwitchRootProps, type SwitchRootProps,
SwitchThumb, SwitchThumb,
useEmitAsProps, useForwardPropsEmits,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SwitchRootProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<SwitchRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<SwitchRootEmits>() const emits = defineEmits<SwitchRootEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -17,27 +18,20 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<SwitchRoot <SwitchRoot
v-bind="{ v-bind="forwarded"
...delegatedProps, :class="cn(
...useEmitAsProps(emits), 'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
}"
:class="
cn(
'peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
props.class, props.class,
) )"
"
> >
<SwitchThumb <SwitchThumb
:class=" :class="cn('pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0')"
cn(
'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0',
)
"
/> />
</SwitchRoot> </SwitchRoot>
</template> </template>

View File

@ -8,7 +8,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<div class="w-full overflow-auto"> <div class="relative w-full overflow-auto">
<table :class="cn('w-full caption-bottom text-sm', props.class)"> <table :class="cn('w-full caption-bottom text-sm', props.class)">
<slot /> <slot />
</table> </table>

View File

@ -8,7 +8,7 @@ const props = defineProps<{
</script> </script>
<template> <template>
<tfoot :class="cn('bg-primary font-medium text-primary-foreground', props.class)"> <tfoot :class="cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', props.class)">
<slot /> <slot />
</tfoot> </tfoot>
</template> </template>

View File

@ -15,12 +15,10 @@ const delegatedProps = computed(() => {
<template> <template>
<TabsList <TabsList
v-bind="delegatedProps" v-bind="delegatedProps"
:class=" :class="cn(
cn(
'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground', 'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
props.class, props.class,
) )"
"
> >
<slot /> <slot />
</TabsList> </TabsList>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { TabsTrigger, type TabsTriggerProps } from 'radix-vue' import { TabsTrigger, type TabsTriggerProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<TabsTriggerProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<TabsTriggerProps & { class?: HTMLAttributes['class'] }>()
@ -10,17 +10,17 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwardedProps = useForwardProps(delegatedProps.value)
</script> </script>
<template> <template>
<TabsTrigger <TabsTrigger
v-bind="delegatedProps" v-bind="forwardedProps"
:class=" :class="cn(
cn(
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm', 'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
props.class, props.class,
) )"
"
> >
<slot /> <slot />
</TabsTrigger> </TabsTrigger>

View File

@ -1,24 +1,11 @@
<script lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import type { ToastRootEmits, ToastRootProps } from 'radix-vue'
import type { VariantProps } from 'class-variance-authority'
interface ToastVariantProps extends VariantProps<typeof toastVariants> {}
export interface ToastProps extends ToastRootProps {
class?: HTMLAttributes['class']
variant?: ToastVariantProps['variant']
'onOpenChange'?: ((value: boolean) => void) | undefined
};
</script>
<script setup lang="ts"> <script setup lang="ts">
import { ToastRoot, useEmitAsProps } from 'radix-vue' import { computed } from 'vue'
import { ToastRoot, type ToastRootEmits, useForwardPropsEmits } from 'radix-vue'
import { toastVariants } from '.' import { type ToastProps, toastVariants } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastProps>() const props = defineProps<ToastProps>()
const emits = defineEmits<ToastRootEmits>() const emits = defineEmits<ToastRootEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -26,11 +13,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<ToastRoot <ToastRoot
v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" v-bind="forwarded"
:class="cn(toastVariants({ variant }), props.class)" :class="cn(toastVariants({ variant }), props.class)"
@update:open="onOpenChange" @update:open="onOpenChange"
> >

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { ToastClose, type ToastCloseProps } from 'radix-vue' import { ToastClose, type ToastCloseProps } from 'radix-vue'
import { XIcon } from 'lucide-vue-next' import { X } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastCloseProps & { const props = defineProps<ToastCloseProps & {
@ -17,6 +17,6 @@ const delegatedProps = computed(() => {
<template> <template>
<ToastClose v-bind="delegatedProps" :class="cn('absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600', props.class)"> <ToastClose v-bind="delegatedProps" :class="cn('absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600', props.class)">
<XIcon class="h-4 w-4" /> <X class="h-4 w-4" />
</ToastClose> </ToastClose>
</template> </template>

View File

@ -1,3 +1,6 @@
import type { ToastRootProps } from 'radix-vue'
import type { HTMLAttributes } from 'vue'
export { default as Toaster } from './Toaster.vue' export { default as Toaster } from './Toaster.vue'
export { default as Toast } from './Toast.vue' export { default as Toast } from './Toast.vue'
export { default as ToastViewport } from './ToastViewport.vue' export { default as ToastViewport } from './ToastViewport.vue'
@ -8,7 +11,7 @@ export { default as ToastDescription } from './ToastDescription.vue'
export { default as ToastProvider } from './ToastProvider.vue' export { default as ToastProvider } from './ToastProvider.vue'
export { toast, useToast } from './use-toast' export { toast, useToast } from './use-toast'
import { cva } from 'class-variance-authority' import { type VariantProps, cva } from 'class-variance-authority'
export const toastVariants = cva( export const toastVariants = cva(
'group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full', 'group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full',
@ -25,3 +28,11 @@ export const toastVariants = cva(
}, },
}, },
) )
type ToastVariants = VariantProps<typeof toastVariants>
export interface ToastProps extends ToastRootProps {
class?: HTMLAttributes['class']
variant?: ToastVariants['variant']
'onOpenChange'?: ((value: boolean) => void) | undefined
}

View File

@ -1,6 +1,6 @@
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import type { Component, VNode } from 'vue' import type { Component, VNode } from 'vue'
import type { ToastProps } from './Toast.vue' import type { ToastProps } from '.'
const TOAST_LIMIT = 1 const TOAST_LIMIT = 1
const TOAST_REMOVE_DELAY = 1000000 const TOAST_REMOVE_DELAY = 1000000

View File

@ -1,25 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ToggleEmits, ToggleProps } from 'radix-vue'
import { Toggle, useEmitAsProps } from 'radix-vue'
import type { VariantProps } from 'class-variance-authority'
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { toggleVariants } from '.' import { Toggle, type ToggleEmits, type ToggleProps, useForwardPropsEmits } from 'radix-vue'
import { type ToggleVariants, toggleVariants } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface ToggleVariantProps extends VariantProps<typeof toggleVariants> {} const props = withDefaults(defineProps<ToggleProps & {
interface Props extends ToggleProps {
class?: HTMLAttributes['class'] class?: HTMLAttributes['class']
variant?: ToggleVariantProps['variant'] variant?: ToggleVariants['variant']
size?: ToggleVariantProps['size'] size?: ToggleVariants['size']
disabled?: boolean }>(), {
}
const props = withDefaults(defineProps<Props>(), {
variant: 'default', variant: 'default',
size: 'default', size: 'default',
disabled: false, disabled: false,
}) })
const emits = defineEmits<ToggleEmits>() const emits = defineEmits<ToggleEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -27,14 +21,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<Toggle <Toggle
v-bind="{ v-bind="forwarded"
...delegatedProps,
...useEmitAsProps(emits),
}"
:class="cn(toggleVariants({ variant, size }), props.class)" :class="cn(toggleVariants({ variant, size }), props.class)"
> >
<slot /> <slot />

View File

@ -1,4 +1,4 @@
import { cva } from 'class-variance-authority' import { type VariantProps, cva } from 'class-variance-authority'
export { default as Toggle } from './Toggle.vue' export { default as Toggle } from './Toggle.vue'
@ -23,3 +23,5 @@ export const toggleVariants = cva(
}, },
}, },
) )
export type ToggleVariants = VariantProps<typeof toggleVariants>

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal, useEmitAsProps } from 'radix-vue' import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
defineOptions({ defineOptions({
@ -18,11 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const forwarded = useForwardPropsEmits(delegatedProps.value, emits)
</script> </script>
<template> <template>
<TooltipPortal> <TooltipPortal>
<TooltipContent v-bind="{ ...delegatedProps, ...useEmitAsProps(emits), ...$attrs }" :class="cn('z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)"> <TooltipContent v-bind="{ ...forwarded, ...$attrs }" :class="cn('z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)">
<slot /> <slot />
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>