Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export type PickerSharedProps<DateType> = {

// Value
format?: string | CustomFormat<DateType> | (string | CustomFormat<DateType>)[];


// cell tittle
htmlTitle?: boolean | { format?: string | CustomFormat<DateType> };

// Render
suffixIcon?: React.ReactNode;
clearIcon?: React.ReactNode;
Expand Down
3 changes: 3 additions & 0 deletions src/PickerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateType> = {
prefixCls?: string;
Expand Down Expand Up @@ -83,6 +84,8 @@ export type PickerPanelSharedProps<DateType> = {

/** @private Internal usage. Do not use in your production env */
components?: Components;

htmlTitle?: boolean | { format?: string | CustomFormat<DateType> };
};

export type PickerPanelBaseProps<DateType> = {
Expand Down
2 changes: 2 additions & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export type PanelSharedProps<DateType> = {
onSelect: OnSelect<DateType>;
onViewDateChange: (value: DateType) => void;
onPanelChange: (mode: PanelMode | null, viewValue: DateType) => void;

htmlTitle?: boolean | { format?: string | CustomFormat<DateType>; useCustomFormat?: boolean };
};

export type DisabledTimes = {
Expand Down
18 changes: 12 additions & 6 deletions src/panels/DatePanel/DateBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateType> = (currentDate: DateType, today: DateType) => React.ReactNode;

Expand All @@ -31,6 +32,7 @@ export type DateBodyProps<DateType> = {
locale: Locale;
rowCount: number;
onSelect: (value: DateType) => void;
htmlTitle?: boolean | { format?: string | CustomFormat<DateType> };
} & DateBodyPassProps<DateType>;

function DateBody<DateType>(props: DateBodyProps<DateType>) {
Expand All @@ -43,6 +45,7 @@ function DateBody<DateType>(props: DateBodyProps<DateType>) {
viewDate,
value,
dateRender,
htmlTitle,
} = props;

const { rangedValue, hoverRangedValue } = React.useContext(RangeContext);
Expand Down Expand Up @@ -92,12 +95,15 @@ function DateBody<DateType>(props: DateBodyProps<DateType>) {
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}
/>
Expand Down