diff --git a/apps/www/src/lib/registry/default/ui/calendar/Calendar.vue b/apps/www/src/lib/registry/default/ui/calendar/Calendar.vue index 64f8cf3f..cc888792 100644 --- a/apps/www/src/lib/registry/default/ui/calendar/Calendar.vue +++ b/apps/www/src/lib/registry/default/ui/calendar/Calendar.vue @@ -3,7 +3,8 @@ import { useVModel } from '@vueuse/core' import type { Calendar } from 'v-calendar' import { DatePicker } from 'v-calendar' import { ChevronLeft, ChevronRight } from 'lucide-vue-next' -import { computed, nextTick, onMounted, ref } from 'vue' +import { computed, nextTick, onMounted, ref, useSlots } from 'vue' +import { isVCalendarSlot } from '.' import { buttonVariants } from '@/lib/registry/default/ui/button' import { cn } from '@/lib/utils' @@ -64,6 +65,16 @@ onMounted(async () => { if (modelValue.value instanceof Date && calendarRef.value) calendarRef.value.focusDate(modelValue.value) }) + +const $slots = useSlots() +const vCalendarSlots = computed(() => { + return Object.keys($slots) + .filter(name => isVCalendarSlot(name)) + .reduce((obj: Record, key: string) => { + obj[key] = $slots[key] + return obj + }, {}) +}) diff --git a/apps/www/src/lib/registry/default/ui/calendar/index.ts b/apps/www/src/lib/registry/default/ui/calendar/index.ts index 50f21114..d17d00f2 100644 --- a/apps/www/src/lib/registry/default/ui/calendar/index.ts +++ b/apps/www/src/lib/registry/default/ui/calendar/index.ts @@ -1 +1,22 @@ export { default as Calendar } from './Calendar.vue' +import type { CalendarSlotName } from 'v-calendar/dist/types/src/components/Calendar/CalendarSlot.vue.d.ts' + +export function isVCalendarSlot(slotName: string): slotName is CalendarSlotName { + const validSlots: CalendarSlotName[] = [ + 'day-content', + 'day-popover', + 'dp-footer', + 'footer', + 'header-title-wrapper', + 'header-title', + 'header-prev-button', + 'header-next-button', + 'nav', + 'nav-prev-button', + 'nav-next-button', + 'page', + 'time-header', + ] + + return validSlots.includes(slotName as CalendarSlotName) +} diff --git a/apps/www/src/lib/registry/new-york/ui/calendar/Calendar.vue b/apps/www/src/lib/registry/new-york/ui/calendar/Calendar.vue index 409b07f7..5dada0e1 100644 --- a/apps/www/src/lib/registry/new-york/ui/calendar/Calendar.vue +++ b/apps/www/src/lib/registry/new-york/ui/calendar/Calendar.vue @@ -3,7 +3,8 @@ import { useVModel } from '@vueuse/core' import type { Calendar } from 'v-calendar' import { DatePicker } from 'v-calendar' import { ChevronLeftIcon, ChevronRightIcon } from '@radix-icons/vue' -import { computed, nextTick, onMounted, ref } from 'vue' +import { computed, nextTick, onMounted, ref, useSlots } from 'vue' +import { isVCalendarSlot } from '.' import { buttonVariants } from '@/lib/registry/new-york/ui/button' import { cn } from '@/lib/utils' @@ -63,6 +64,16 @@ onMounted(async () => { if (modelValue.value instanceof Date && calendarRef.value) calendarRef.value.focusDate(modelValue.value) }) + +const $slots = useSlots() +const vCalendarSlots = computed(() => { + return Object.keys($slots) + .filter(name => isVCalendarSlot(name)) + .reduce((obj: Record, key: string) => { + obj[key] = $slots[key] + return obj + }, {}) +}) diff --git a/apps/www/src/lib/registry/new-york/ui/calendar/index.ts b/apps/www/src/lib/registry/new-york/ui/calendar/index.ts index 50f21114..d17d00f2 100644 --- a/apps/www/src/lib/registry/new-york/ui/calendar/index.ts +++ b/apps/www/src/lib/registry/new-york/ui/calendar/index.ts @@ -1 +1,22 @@ export { default as Calendar } from './Calendar.vue' +import type { CalendarSlotName } from 'v-calendar/dist/types/src/components/Calendar/CalendarSlot.vue.d.ts' + +export function isVCalendarSlot(slotName: string): slotName is CalendarSlotName { + const validSlots: CalendarSlotName[] = [ + 'day-content', + 'day-popover', + 'dp-footer', + 'footer', + 'header-title-wrapper', + 'header-title', + 'header-prev-button', + 'header-next-button', + 'nav', + 'nav-prev-button', + 'nav-next-button', + 'page', + 'time-header', + ] + + return validSlots.includes(slotName as CalendarSlotName) +}