import Header from '../Header'; import type { Locale } from '../../interface'; import type { GenerateConfig } from '../../generate'; import { useInjectPanel } from '../../PanelContext'; import { formatValue } from '../../utils/dateUtil'; import type { VueNode } from '../../../_util/type'; import useMergeProps from '../../hooks/useMergeProps'; export type DateHeaderProps = { prefixCls: string; viewDate: DateType; value?: DateType | null; locale: Locale; generateConfig: GenerateConfig; onPrevYear: () => void; onNextYear: () => void; onPrevMonth: () => void; onNextMonth: () => void; onYearClick: () => void; onMonthClick: () => void; }; function DateHeader(_props: DateHeaderProps) { const props = useMergeProps(_props); const { prefixCls, generateConfig, locale, viewDate, onNextMonth, onPrevMonth, onNextYear, onPrevYear, onYearClick, onMonthClick, } = props; const { hideHeader } = useInjectPanel(); if (hideHeader.value) { return null; } const headerPrefixCls = `${prefixCls}-header`; const monthsLocale: string[] = locale.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale.locale) : []); const month = generateConfig.getMonth(viewDate); // =================== Month & Year =================== const yearNode: VueNode = ( ); const monthNode: VueNode = ( ); const monthYearNodes = locale.monthBeforeYear ? [monthNode, yearNode] : [yearNode, monthNode]; return (
{monthYearNodes}
); } DateHeader.displayName = 'DateHeader'; DateHeader.inheritAttrs = false; export default DateHeader;