Skip to content

Commit

Permalink
feat(calendar): add slots type (tusen-ai#6599)
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Dec 7, 2024
1 parent 1ef779c commit f1eb605
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/calendar/src/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import type { ThemeProps } from '../../_mixins'
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import type { CalendarTheme } from '../styles'
import type { DateItem, OnPanelChange, OnUpdateValue } from './interface'
import type {
CalendarDefaultSlotOptions,
CalendarHeaderSlotOptions,
DateItem,
OnPanelChange,
OnUpdateValue
} from './interface'
import {
addMonths,
format,
Expand All @@ -19,6 +25,7 @@ import {
h,
type PropType,
ref,
type SlotsType,
toRef
} from 'vue'
import { NBaseIcon } from '../../_internal'
Expand Down Expand Up @@ -46,9 +53,15 @@ export const calendarProps = {

export type CalendarProps = ExtractPublicPropTypes<typeof calendarProps>

export interface CalendarSlots {
default?: (props: CalendarDefaultSlotOptions) => any
header?: (props: CalendarHeaderSlotOptions) => any
}

export default defineComponent({
name: 'Calendar',
props: calendarProps,
slots: Object as SlotsType<CalendarSlots>,
setup(props) {
const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props)
const themeRef = useTheme(
Expand Down
11 changes: 11 additions & 0 deletions src/calendar/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ export interface DateItem {
}

export type OnPanelChange = (info: { year: number, month: number }) => void

export interface CalendarDefaultSlotOptions {
year: number
month: number
date: number
}

export interface CalendarHeaderSlotOptions {
year: number
month: number
}

0 comments on commit f1eb605

Please sign in to comment.