diff --git a/api-generator/components/calendar.js b/api-generator/components/calendar.js index ba79c41d14..993f8b5748 100644 --- a/api-generator/components/calendar.js +++ b/api-generator/components/calendar.js @@ -359,6 +359,12 @@ const CalendarProps = [ default: 'null', description: 'Function that gets a date information and returns the cell content in datepicker.' }, + { + name: 'decadeTempate', + type: 'function', + default: 'null', + description: 'Function that gets a navigator information and returns the decade selections in the panel.' + }, { name: 'monthNavigatorTemplate', type: 'function', @@ -369,13 +375,25 @@ const CalendarProps = [ name: 'yearNavigatorTemplate', type: 'function', default: 'null', - description: 'Function that gets a navigator information and returns the novigator in header.' + description: 'Function that gets a navigator information and returns the navigator in header.' }, { name: 'transitionOptions', type: 'object', default: 'null', description: 'The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.' + }, + { + name: 'formatDateTime', + type: 'function', + default: 'null', + description: 'Function for overriding default behavior that formats a Date to the string representation.' + }, + { + name: 'parseDateTime', + type: 'function', + default: 'null', + description: 'Function for overriding default behavior that parses text into the Date.' } ]; diff --git a/components/doc/calendar/index.js b/components/doc/calendar/index.js index ec24cdb91c..f057bcd664 100644 --- a/components/doc/calendar/index.js +++ b/components/doc/calendar/index.js @@ -1,9 +1,9 @@ -import React, { memo } from 'react'; import Link from 'next/link'; -import { TabView, TabPanel } from '../../lib/tabview/TabView'; -import { useLiveEditorTabs } from '../common/liveeditor'; +import React, { memo } from 'react'; +import { TabPanel, TabView } from '../../lib/tabview/TabView'; import { CodeHighlight } from '../common/codehighlight'; import { DevelopmentSection } from '../common/developmentsection'; +import { useLiveEditorTabs } from '../common/liveeditor'; const CalendarDoc = memo(() => { const sources = { @@ -1221,6 +1221,12 @@ const monthNavigatorTemplate = (options) => { null Function that gets a date information and returns the cell content in datepicker. + + decadeTempate + function + null + Function that gets a navigator information and returns the decade selections in the panel. + monthNavigatorTemplate function @@ -1233,6 +1239,18 @@ const monthNavigatorTemplate = (options) => { null Function that gets a navigator information and returns the novigator in header. + + formatDateTime + function + null + Function for overriding default behavior that formats a Date to the string representation. + + + parseDateTime + function + null + Function for overriding default behavior that parses text into the Date. + transitionOptions object diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 1b9237c1ad..74b2324395 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -1997,6 +1997,10 @@ export const Calendar = React.memo( }; const formatDateTime = (date) => { + if (props.formatDateTime) { + return props.formatDateTime(date); + } + let formattedValue = null; if (date) { @@ -2173,6 +2177,10 @@ export const Calendar = React.memo( }; const parseDateTime = (text) => { + if (props.parseDateTime) { + return props.parseDateTime(text); + } + let date; let parts = text.split(' '); diff --git a/components/lib/calendar/calendar.d.ts b/components/lib/calendar/calendar.d.ts index d386087a3f..377080e6db 100644 --- a/components/lib/calendar/calendar.d.ts +++ b/components/lib/calendar/calendar.d.ts @@ -137,6 +137,8 @@ export interface CalendarProps { visible?: boolean; yearNavigator?: boolean; yearRange?: string; + formatDateTime?(date: Date): string; + parseDateTime?(text: string): Date; dateTemplate?(e: CalendarDateTemplateParams): React.ReactNode; decadeTempate?(yearValues: number[]): React.ReactNode; footerTemplate?(): React.ReactNode;