From c6d7d49ae42634cad83df3574f8a4a676d0e4f7e Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Wed, 19 Feb 2025 22:12:40 +1100 Subject: [PATCH] fix: enhance documentation in SingleDatePicker for props clarity and localization details --- src/components/SingleDatePicker.tsx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/SingleDatePicker.tsx b/src/components/SingleDatePicker.tsx index 5c00d4b..c601f49 100644 --- a/src/components/SingleDatePicker.tsx +++ b/src/components/SingleDatePicker.tsx @@ -4,12 +4,29 @@ import { useEffect, useState } from 'react' import { getCalendarDates, getL10Weekday } from '../utils' interface Props { + /** + * Control the selected + * date programmatically, including situations like provide a default value or control the selected + * date by parent component. + */ value?: Date | { year: number, month: number, day: number } + + /** + * A callback function that will be called when a date is selected inside the panel. + * @param date - The date user selected. + * @returns + */ onSelect?: (date: { year: number, month: number, day: number }) => void + /** + * The language code that will be used to localize the panel. + * Accept standard ISO 639-1 language code, such as 'zh-CN', 'en-US', 'ja-JP', etc. Default to the + * language of the user’s browser. Note that it will not effect to the screen reader, but the screen + * reader will still read the date in the user’s language. + */ localization?: string } @@ -18,16 +35,7 @@ interface Props { * * @component * - * @param {Object} props - * @param {Date | { year: number, month: number, day: number }} props.value - Control the selected - * date programmatically, including situations like provide a default value or control the selected - * date by parent component. - * @param {(date: { year: number, month: number, day: number }) => void} props.onSelect - A callback - * function that will be called when a date is selected inside the panel. - * @param {string} props.localization - The language code that will be used to localize the panel. - * Accept standard ISO 639-1 language code, such as 'zh-CN', 'en-US', 'ja-JP', etc. Default to the - * language of the user’s browser. Note that it will not effect to the screen reader, but the screen - * reader will still read the date in the user’s language. + * @param {Props} props */ export default ({ value, onSelect, localization }: Props) => { const [currentMonth, setCurrentMonth] = useState(new Date().getMonth())