refactor: default style finish

This commit is contained in:
Sadegh Barati 2024-01-08 23:17:12 +03:30
parent a10731b8a0
commit 470ed45a3f
56 changed files with 256 additions and 159 deletions

View File

@ -13,8 +13,6 @@ import { cn } from '@/lib/utils'
const props = defineProps<AlertDialogContentProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<AlertDialogContentProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<AlertDialogContentEmits>() const emits = defineEmits<AlertDialogContentEmits>()
const emitsAsProps = useEmitAsProps(emits)
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props
@ -28,7 +26,7 @@ const delegatedProps = computed(() => {
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-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"
/> />
<AlertDialogContent <AlertDialogContent
v-bind="{ ...delegatedProps, ...emitsAsProps }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
: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 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',

View File

@ -3,16 +3,14 @@ import type { HTMLAttributes } from 'vue'
import { type AlertVariants, alertVariants } from '.' import { type AlertVariants, alertVariants } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface Props { const props = defineProps<{
variant?: AlertVariants['variant']
class?: HTMLAttributes['class'] class?: HTMLAttributes['class']
} variant?: AlertVariants['variant']
}>()
const props = defineProps<Props>()
</script> </script>
<template> <template>
<div :class="cn(alertVariants({ variant: props.variant }), props.class)"> <div :class="cn(alertVariants({ variant }), props.class)">
<slot /> <slot />
</div> </div>
</template> </template>

View File

@ -4,13 +4,11 @@ import { AvatarRoot } from 'radix-vue'
import { type AvatarVariants, avatarVariant } from '.' import { type AvatarVariants, avatarVariant } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface Props { const props = withDefaults(defineProps<{
class?: HTMLAttributes['class']
size?: AvatarVariants['size'] size?: AvatarVariants['size']
shape?: AvatarVariants['shape'] shape?: AvatarVariants['shape']
class?: HTMLAttributes['class'] }>(), {
}
const props = withDefaults(defineProps<Props>(), {
size: 'sm', size: 'sm',
shape: 'circle', shape: 'circle',
}) })

View File

@ -8,8 +8,6 @@ import { cn } from '@/lib/utils'
const props = defineProps<CheckboxRootProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<CheckboxRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<CheckboxRootEmits>() const emits = defineEmits<CheckboxRootEmits>()
const emitAsProps = useEmitAsProps(emits)
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props
@ -21,7 +19,7 @@ const delegatedProps = computed(() => {
<CheckboxRoot <CheckboxRoot
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
emitAsProps, ...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',

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 { ComboboxRootEmits, ComboboxRootProps } from 'radix-vue' import type { ComboboxRootEmits, ComboboxRootProps } from 'radix-vue'
import { ComboboxRoot, useEmitAsProps, useForwardPropsEmits } from 'radix-vue' import { ComboboxRoot, useEmitAsProps } 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'] }>(), {
@ -15,15 +15,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<ComboboxRoot <ComboboxRoot
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...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)"
> >

View File

@ -5,8 +5,8 @@ import { ComboboxGroup, ComboboxLabel } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ComboboxGroupProps & { const props = defineProps<ComboboxGroupProps & {
heading?: string
class?: HTMLAttributes['class'] class?: HTMLAttributes['class']
heading?: string
}>() }>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {

View File

@ -7,8 +7,6 @@ import { cn } from '@/lib/utils'
const props = defineProps<ComboboxItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<ComboboxItemProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<ComboboxItemEmits>() const emits = defineEmits<ComboboxItemEmits>()
const emitsAsProps = useEmitAsProps(emits)
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
const { class: _, ...delegated } = props const { class: _, ...delegated } = props
@ -18,7 +16,7 @@ const delegatedProps = computed(() => {
<template> <template>
<ComboboxItem <ComboboxItem
v-bind="{ ...delegatedProps, ...emitsAsProps }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
: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 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', props.class)"
@select.prevent @select.prevent
> >

View File

@ -12,12 +12,10 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<ComboboxContent v-bind="{ ...delegatedProps, ...emitsAsProps }" :class="cn('max-h-[300px] overflow-y-auto overflow-x-hidden', props.class)"> <ComboboxContent v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }" :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

@ -17,8 +17,6 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
@ -26,7 +24,7 @@ const emitsAsProps = useEmitAsProps(emits)
<ContextMenuContent <ContextMenuContent
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -18,15 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<ContextMenuRadioItem <ContextMenuRadioItem
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -16,15 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<ContextMenuSubContent <ContextMenuSubContent
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class=" :class="
cn( cn(

View File

@ -1,9 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { DialogRoot } from 'radix-vue' import { DialogRoot, type DialogRootEmits, type DialogRootProps, useForwardPropsEmits } from 'radix-vue'
const props = defineProps<DialogRootProps>()
const emits = defineEmits<DialogRootEmits>()
const forwarded = useForwardPropsEmits(props, emits)
</script> </script>
<template> <template>
<DialogRoot> <DialogRoot v-bind="forwarded">
<slot /> <slot />
</DialogRoot> </DialogRoot>
</template> </template>

View File

@ -20,8 +20,6 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
@ -30,7 +28,7 @@ const emitsAsProps = useEmitAsProps(emits)
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-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"
/> />
<DialogContent <DialogContent
v-bind="{ ...delegatedProps, ...emitsAsProps }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
: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 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',

View File

@ -22,8 +22,6 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
@ -31,7 +29,7 @@ const emitsAsProps = useEmitAsProps(emits)
<DropdownMenuContent <DropdownMenuContent
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -16,15 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<DropdownMenuSubContent <DropdownMenuSubContent
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...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)"
> >

View File

@ -16,15 +16,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<MenubarRoot <MenubarRoot
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class=" :class="
cn( cn(

View File

@ -19,15 +19,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<MenubarCheckboxItem <MenubarCheckboxItem
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -17,15 +17,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<MenubarItem <MenubarItem
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -11,7 +11,6 @@ import { Circle } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<MenubarRadioItemProps & { class?: HTMLAttributes['class'] }>() const props = defineProps<MenubarRadioItemProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<MenubarRadioItemEmits>() const emits = defineEmits<MenubarRadioItemEmits>()
const delegatedProps = computed(() => { const delegatedProps = computed(() => {
@ -19,15 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<MenubarRadioItem <MenubarRadioItem
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class="[ :class="[
cn( cn(

View File

@ -24,8 +24,6 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
@ -33,7 +31,7 @@ const emitsAsProps = useEmitAsProps(emits)
<MenubarSubContent <MenubarSubContent
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
:class=" :class="
cn( cn(

View File

@ -18,15 +18,13 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<NavigationMenuRoot <NavigationMenuRoot
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...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)"
> >

View File

@ -26,14 +26,12 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<PopoverPortal> <PopoverPortal>
<PopoverContent <PopoverContent
v-bind="{ ...delegatedProps, ...emitsAsProps, ...$attrs }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits), ...$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

@ -11,8 +11,6 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
@ -20,7 +18,7 @@ const emitsAsProps = useEmitAsProps(emits)
:class="cn('grid gap-2', props.class)" :class="cn('grid gap-2', props.class)"
v-bind="{ v-bind="{
...delegatedProps, ...delegatedProps,
...emitsAsProps, ...useEmitAsProps(emits),
}" }"
> >
<slot /> <slot />

View File

@ -27,14 +27,12 @@ const delegatedProps = computed(() => {
return delegated return delegated
}) })
const emitsAsProps = useEmitAsProps(emits)
</script> </script>
<template> <template>
<SelectPortal> <SelectPortal>
<SelectContent <SelectContent
v-bind="{ ...delegatedProps, ...emitsAsProps, ...$attrs }" :class="cn( v-bind="{ ...delegatedProps, ...useEmitAsProps(emits), ...$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 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',
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',

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { SelectLabel, type SelectLabelProps } from 'radix-vue' import { SelectLabel, type SelectLabelProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SelectLabelProps & { class?: string }>() const props = defineProps<SelectLabelProps & { class?: HTMLAttributes['class'] }>()
</script> </script>
<template> <template>

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } 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?: string }>() const props = defineProps<SeparatorProps & { class?: HTMLAttributes['class'] }>()
</script> </script>
<template> <template>

View File

@ -1,9 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { DialogRoot } from 'radix-vue' import { DialogRoot, type DialogRootEmits, type DialogRootProps, useForwardPropsEmits } from 'radix-vue'
const props = defineProps<DialogRootProps>()
const emits = defineEmits<DialogRootEmits>()
const forwarded = useForwardPropsEmits(props, emits)
</script> </script>
<template> <template>
<DialogRoot> <DialogRoot v-bind="forwarded">
<slot /> <slot />
</DialogRoot> </DialogRoot>
</template> </template>

View File

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { import {
DialogClose, DialogClose,
DialogContent, DialogContent,
@ -14,15 +15,12 @@ import { cn } from '@/lib/utils'
interface SheetContentProps extends DialogContentProps { interface SheetContentProps extends DialogContentProps {
side?: 'left' | 'right' | 'top' | 'bottom' side?: 'left' | 'right' | 'top' | 'bottom'
class?: string class?: HTMLAttributes['class']
} }
const props = defineProps<SheetContentProps>() const props = defineProps<SheetContentProps>()
const emits = defineEmits<DialogContentEmits>() const emits = defineEmits<DialogContentEmits>()
const emitsAsProps = useEmitAsProps(emits)
const sheetVariants = cva( 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', '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',
{ {
@ -41,6 +39,12 @@ const sheetVariants = cva(
}, },
}, },
) )
const delegatedProps = computed(() => {
const { class: _, side, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
@ -49,8 +53,8 @@ const sheetVariants = cva(
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-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"
/> />
<DialogContent <DialogContent
:class="cn(sheetVariants({ side: props.side }), props.class)" :class="cn(sheetVariants({ side }), props.class)"
v-bind="{ ...props, ...emitsAsProps }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
> >
<slot /> <slot />

View File

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

View File

@ -1,7 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{ class?: HTMLAttributes['class'] }>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{ class?: HTMLAttributes['class'] }>()
</script> </script>
<template> <template>

View File

@ -1,14 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { DialogTitle, type DialogTitleProps } from 'radix-vue' import { DialogTitle, type DialogTitleProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<DialogTitleProps & { class?: string }>() const props = defineProps<DialogTitleProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<DialogTitle <DialogTitle
:class="cn('text-lg font-semibold text-foreground', props.class)" :class="cn('text-lg font-semibold text-foreground', props.class)"
v-bind="props" v-bind="delegatedProps"
> >
<slot /> <slot />
</DialogTitle> </DialogTitle>

View File

@ -1,8 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface SkeletonProps { interface SkeletonProps {
class?: string class?: HTMLAttributes['class']
} }
const props = defineProps<SkeletonProps>() const props = defineProps<SkeletonProps>()

View File

@ -1,21 +1,26 @@
<script setup lang="ts"> <script setup lang="ts">
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, useEmitAsProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SliderRootProps>() const props = defineProps<SliderRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<SliderRootEmits>() const emits = defineEmits<SliderRootEmits>()
const emitsAsProps = useEmitAsProps(emits) const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<SliderRoot <SliderRoot
:class="cn( :class="cn(
'relative flex w-full touch-none select-none items-center', 'relative flex w-full touch-none select-none items-center',
$attrs.class ?? '', props.class,
)" )"
v-bind="{ ...props, ...emitsAsProps }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
> >
<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

@ -1,22 +1,30 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { import {
SwitchRoot, SwitchRoot,
type SwitchRootEmits, type SwitchRootEmits,
type SwitchRootProps, type SwitchRootProps,
SwitchThumb, SwitchThumb,
useForwardPropsEmits, useEmitAsProps,
} from 'radix-vue' } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<SwitchRootProps & { class?: string }>() const props = defineProps<SwitchRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<SwitchRootEmits>() const emits = defineEmits<SwitchRootEmits>()
const forwarded = useForwardPropsEmits(props, emits) const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<SwitchRoot <SwitchRoot
v-bind="forwarded" v-bind="{
...delegatedProps,
...useEmitAsProps(emits),
}"
:class=" :class="
cn( 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', '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',

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,17 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import TableRow from './TableRow.vue' import TableRow from './TableRow.vue'
import TableCell from './TableCell.vue' import TableCell from './TableCell.vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface Props { const props = withDefaults(defineProps<{
class?: string class?: HTMLAttributes['class']
colspan?: number colspan?: number
} }>(), {
const props = withDefaults(defineProps<Props>(), {
class: '',
colspan: 1, colspan: 1,
}) })
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
@ -23,7 +27,7 @@ const props = withDefaults(defineProps<Props>(), {
props.class, props.class,
) )
" "
:colspan="props.colspan" v-bind="delegatedProps"
> >
<div class="flex items-center justify-center py-10"> <div class="flex items-center justify-center py-10">
<slot /> <slot />

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,7 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ class?: string }>() const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script> </script>
<template> <template>

View File

@ -1,14 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { TabsContent, type TabsContentProps } from 'radix-vue' import { TabsContent, type TabsContentProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<TabsContentProps & { class?: string }>() const props = defineProps<TabsContentProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<TabsContent <TabsContent
:class="cn('mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2', props.class)" :class="cn('mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2', props.class)"
v-bind="props" v-bind="delegatedProps"
> >
<slot /> <slot />
</TabsContent> </TabsContent>

View File

@ -1,13 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { TabsList, type TabsListProps } from 'radix-vue' import { TabsList, type TabsListProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<TabsListProps & { class?: string }>() const props = defineProps<TabsListProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<TabsList <TabsList
v-bind="props" 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',

View File

@ -1,13 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { TabsTrigger, type TabsTriggerProps } from 'radix-vue' import { TabsTrigger, type TabsTriggerProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<TabsTriggerProps & { class?: string }>() const props = defineProps<TabsTriggerProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<TabsTrigger <TabsTrigger
v-bind="props" v-bind="delegatedProps"
: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',

View File

@ -1,8 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { useVModel } from '@vueuse/core' import { useVModel } from '@vueuse/core'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ const props = defineProps<{
class?: HTMLAttributes['class']
defaultValue?: string | number defaultValue?: string | number
modelValue?: string | number modelValue?: string | number
}>() }>()
@ -18,5 +20,5 @@ const modelValue = useVModel(props, 'modelValue', emits, {
</script> </script>
<template> <template>
<textarea v-model="modelValue" :class="cn('flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', $attrs.class ?? '')" /> <textarea v-model="modelValue" :class="cn('flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)" />
</template> </template>

View File

@ -1,11 +1,12 @@
<script lang="ts"> <script lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import type { ToastRootEmits, ToastRootProps } from 'radix-vue' import type { ToastRootEmits, ToastRootProps } from 'radix-vue'
import type { VariantProps } from 'class-variance-authority' import type { VariantProps } from 'class-variance-authority'
interface ToastVariantProps extends VariantProps<typeof toastVariants> {} interface ToastVariantProps extends VariantProps<typeof toastVariants> {}
export interface ToastProps extends ToastRootProps { export interface ToastProps extends ToastRootProps {
class?: string class?: HTMLAttributes['class']
variant?: ToastVariantProps['variant'] variant?: ToastVariantProps['variant']
'onOpenChange'?: ((value: boolean) => void) | undefined 'onOpenChange'?: ((value: boolean) => void) | undefined
}; };
@ -19,12 +20,18 @@ 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 { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastRoot <ToastRoot
v-bind="{ ...props, ...useEmitAsProps(emits) }" v-bind="{ ...delegatedProps, ...useEmitAsProps(emits) }"
:class="cn(toastVariants({ variant: props.variant }), props.class)" :class="cn(toastVariants({ variant }), props.class)"
@update:open="onOpenChange" @update:open="onOpenChange"
> >
<slot /> <slot />

View File

@ -1,12 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { ToastAction, type ToastActionProps } from 'radix-vue' import { ToastAction, type ToastActionProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastActionProps & { class?: string }>() const props = defineProps<ToastActionProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastAction v-bind="props" :class="cn('inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive', props.class)"> <ToastAction v-bind="delegatedProps" :class="cn('inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive', props.class)">
<slot /> <slot />
</ToastAction> </ToastAction>
</template> </template>

View File

@ -1,15 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
import { ToastClose } from 'radix-vue' import { type HTMLAttributes, computed } from 'vue'
import { ToastClose, type ToastCloseProps } from 'radix-vue'
import { XIcon } from 'lucide-vue-next' import { XIcon } from 'lucide-vue-next'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<{ const props = defineProps<ToastCloseProps & {
class?: string class?: HTMLAttributes['class']
}>() }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastClose v-bind="props" :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" /> <XIcon class="h-4 w-4" />
</ToastClose> </ToastClose>
</template> </template>

View File

@ -1,12 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { ToastDescription, type ToastDescriptionProps } from 'radix-vue' import { ToastDescription, type ToastDescriptionProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastDescriptionProps & { class?: string }>() const props = defineProps<ToastDescriptionProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastDescription :class="cn('text-sm opacity-90', props.class)" v-bind="props"> <ToastDescription :class="cn('text-sm opacity-90', props.class)" v-bind="delegatedProps">
<slot /> <slot />
</ToastDescription> </ToastDescription>
</template> </template>

View File

@ -1,12 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { ToastTitle, type ToastTitleProps } from 'radix-vue' import { ToastTitle, type ToastTitleProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastTitleProps & { class?: string }>() const props = defineProps<ToastTitleProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastTitle v-bind="props" :class="cn('text-sm font-semibold', props.class)"> <ToastTitle v-bind="delegatedProps" :class="cn('text-sm font-semibold', props.class)">
<slot /> <slot />
</ToastTitle> </ToastTitle>
</template> </template>

View File

@ -1,10 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { ToastViewport, type ToastViewportProps } from 'radix-vue' import { ToastViewport, type ToastViewportProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = defineProps<ToastViewportProps & { class?: string }>() const props = defineProps<ToastViewportProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<ToastViewport v-bind="props" :class="cn('fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]', props.class)" /> <ToastViewport v-bind="delegatedProps" :class="cn('fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]', props.class)" />
</template> </template>

View File

@ -1,23 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ToggleEmits, ToggleProps } from 'radix-vue' import type { ToggleEmits, ToggleProps } from 'radix-vue'
import { Toggle, useForwardPropsEmits } from 'radix-vue' import { Toggle, useEmitAsProps } from 'radix-vue'
import type { VariantProps } from 'class-variance-authority' import type { VariantProps } from 'class-variance-authority'
import { computed, useAttrs } from 'vue' import { type HTMLAttributes, computed } from 'vue'
import { toggleVariants } from '.' import { toggleVariants } from '.'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
interface ToggleVariantProps extends VariantProps<typeof toggleVariants> {} interface ToggleVariantProps extends VariantProps<typeof toggleVariants> {}
interface Props extends ToggleProps { interface Props extends ToggleProps {
class?: HTMLAttributes['class']
variant?: ToggleVariantProps['variant'] variant?: ToggleVariantProps['variant']
size?: ToggleVariantProps['size'] size?: ToggleVariantProps['size']
disabled?: boolean disabled?: boolean
} }
defineOptions({
inheritAttrs: false,
})
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
variant: 'default', variant: 'default',
size: 'default', size: 'default',
@ -25,24 +22,20 @@ const props = withDefaults(defineProps<Props>(), {
}) })
const emits = defineEmits<ToggleEmits>() const emits = defineEmits<ToggleEmits>()
const toggleProps = computed(() => { const delegatedProps = computed(() => {
// eslint-disable-next-line unused-imports/no-unused-vars const { class: _, size, variant, ...delegated } = props
const { variant, size, disabled, ...otherProps } = props
return otherProps
})
const { class: className, ...rest } = useAttrs() return delegated
const forwarded = useForwardPropsEmits(toggleProps.value, emits) })
</script> </script>
<template> <template>
<Toggle <Toggle
v-bind="{ v-bind="{
...forwarded, ...delegatedProps,
...rest, ...useEmitAsProps(emits),
}" }"
:class="cn(toggleVariants({ variant, size }), className ?? '')" :class="cn(toggleVariants({ variant, size }), props.class)"
:disabled="props.disabled"
> >
<slot /> <slot />
</Toggle> </Toggle>

View File

@ -1,18 +1,28 @@
<script setup lang="ts"> <script setup lang="ts">
import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal, useForwardPropsEmits } from 'radix-vue' import { type HTMLAttributes, computed } from 'vue'
import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal, useEmitAsProps } from 'radix-vue'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<TooltipContentProps>(), { defineOptions({
inheritAttrs: false,
})
const props = withDefaults(defineProps<TooltipContentProps & { class?: HTMLAttributes['class'] }>(), {
sideOffset: 4, sideOffset: 4,
}) })
const emits = defineEmits<TooltipContentEmits>() const emits = defineEmits<TooltipContentEmits>()
const forwarded = useForwardPropsEmits(props, emits) const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script> </script>
<template> <template>
<TooltipPortal> <TooltipPortal>
<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', $attrs.class ?? '')"> <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)">
<slot /> <slot />
</TooltipContent> </TooltipContent>
</TooltipPortal> </TooltipPortal>