diff --git a/src/Picker.tsx b/src/Picker.tsx index 11b717bdc..68d96e64d 100644 --- a/src/Picker.tsx +++ b/src/Picker.tsx @@ -57,7 +57,10 @@ export type PickerSharedProps = { // Value format?: string | CustomFormat | (string | CustomFormat)[]; - + + // cell tittle + htmlTitle?: boolean | { format?: string | CustomFormat }; + // Render suffixIcon?: React.ReactNode; clearIcon?: React.ReactNode; diff --git a/src/PickerPanel.tsx b/src/PickerPanel.tsx index 9c7224691..c77e3cdf3 100644 --- a/src/PickerPanel.tsx +++ b/src/PickerPanel.tsx @@ -38,6 +38,7 @@ import RangeContext from './RangeContext'; import getExtraFooter from './utils/getExtraFooter'; import getRanges from './utils/getRanges'; import { getLowerBoundTime, setDateTime, setTime } from './utils/timeUtil'; +import type { CustomFormat } from './interface'; export type PickerPanelSharedProps = { prefixCls?: string; @@ -83,6 +84,8 @@ export type PickerPanelSharedProps = { /** @private Internal usage. Do not use in your production env */ components?: Components; + + htmlTitle?: boolean | { format?: string | CustomFormat }; }; export type PickerPanelBaseProps = { diff --git a/src/interface.ts b/src/interface.ts index ef362e223..5f3b0d0af 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -79,6 +79,8 @@ export type PanelSharedProps = { onSelect: OnSelect; onViewDateChange: (value: DateType) => void; onPanelChange: (mode: PanelMode | null, viewValue: DateType) => void; + + htmlTitle?: boolean | { format?: string | CustomFormat; useCustomFormat?: boolean }; }; export type DisabledTimes = { diff --git a/src/panels/DatePanel/DateBody.tsx b/src/panels/DatePanel/DateBody.tsx index d0df6788b..c2ba01e4a 100644 --- a/src/panels/DatePanel/DateBody.tsx +++ b/src/panels/DatePanel/DateBody.tsx @@ -11,6 +11,7 @@ import type { Locale } from '../../interface'; import RangeContext from '../../RangeContext'; import useCellClassName from '../../hooks/useCellClassName'; import PanelBody from '../PanelBody'; +import type { CustomFormat } from '../../interface'; export type DateRender = (currentDate: DateType, today: DateType) => React.ReactNode; @@ -31,6 +32,7 @@ export type DateBodyProps = { locale: Locale; rowCount: number; onSelect: (value: DateType) => void; + htmlTitle?: boolean | { format?: string | CustomFormat }; } & DateBodyPassProps; function DateBody(props: DateBodyProps) { @@ -43,6 +45,7 @@ function DateBody(props: DateBodyProps) { viewDate, value, dateRender, + htmlTitle, } = props; const { rangedValue, hoverRangedValue } = React.useContext(RangeContext); @@ -92,12 +95,15 @@ function DateBody(props: DateBodyProps) { getCellText={generateConfig.getDate} getCellClassName={getCellClassName} getCellDate={generateConfig.addDate} - titleCell={date => - formatValue(date, { - locale, - format: 'YYYY-MM-DD', - generateConfig, - }) + titleCell={ + typeof htmlTitle === 'boolean' && !htmlTitle + ? undefined + : (date) => + formatValue(date, { + locale, + format: typeof htmlTitle !== 'boolean' && (htmlTitle?.format ?? 'YYYY-MM-DD'), + generateConfig, + }) } headerCells={headerCells} />