From 21e8c83f9d105cd3cf6263f7950b3ce111c888c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kleszczy=C5=84ski?= Date: Sat, 20 Jan 2024 10:02:43 +0100 Subject: [PATCH] Fixes #3609 - Update Calendar typings to be precise --- components/lib/calendar/Calendar.d.ts | 71 +++++++++++++++++++++------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/components/lib/calendar/Calendar.d.ts b/components/lib/calendar/Calendar.d.ts index c7eb93421..afc404088 100755 --- a/components/lib/calendar/Calendar.d.ts +++ b/components/lib/calendar/Calendar.d.ts @@ -126,7 +126,7 @@ export interface CalendarBlurEvent { /** * Custom passthrough(pt) options. - * @see {@link CalendarProps.pt} + * @see {@link BaseCalendarProps.pt} */ export interface CalendarPassThroughOptions { /** @@ -494,19 +494,9 @@ export interface CalendarYearOptions { } /** - * Defines valid properties in Calendar component. + * Defines valid base properties in Calendar component. */ -export interface CalendarProps { - /** - * Value of the component. - * @defaultValue null - */ - modelValue?: string | Date | string[] | Date[] | undefined | null; - /** - * Defines the quantity of the selection. - * @defaultValue single - */ - selectionMode?: 'single' | 'multiple' | 'range' | undefined; +interface BaseCalendarProps { /** * Format of the date. Defaults to PrimeVue Locale configuration. */ @@ -786,6 +776,57 @@ export interface CalendarProps { */ unstyled?: boolean; } + +/** + * Defines valid single selection properties in Calendar component. + */ +interface CalendarPropsSingle extends BaseCalendarProps { + /** + * Value of the component. + * @defaultValue null + */ + modelValue?: Date | undefined | null; + /** + * Defines the quantity of the selection. + * @defaultValue single + */ + selectionMode?: 'single' | undefined; +} + +/** + * Defines valid range selection properties in Calendar component. + */ +interface CalendarPropsRange extends BaseCalendarProps { + /** + * Value of the component. + * @defaultValue null + */ + modelValue?: Array | undefined | null; + /** + * Defines the quantity of the selection. + * @defaultValue single + */ + selectionMode?: 'range'; +} + +/** + * Defines valid multiple selection properties in Calendar component. + */ +interface CalendarPropsMultiple extends BaseCalendarProps { + /** + * Value of the component. + * @defaultValue null + */ + modelValue?: Array | undefined | null; + /** + * Defines the quantity of the selection. + * @defaultValue single + */ + selectionMode?: 'multiple'; +} + +export type CalendarProps = CalendarPropsSingle | CalendarPropsRange | CalendarPropsMultiple + /** * Defines valid options of the date slot in Calendar component. */ @@ -928,9 +969,9 @@ export interface CalendarSlots { export interface CalendarEmits { /** * Emitted when the value changes. - * @param {string | Date | string[] | Date[] | undefined} value - New value. + * @param {Date | Array | null} value - New value. */ - 'update:modelValue'(value: string | Date | string[] | Date[] | undefined): void; + 'update:modelValue'(value: Date | Array | null): void; /** * Callback to invoke when input field is being typed. * @param {Event} event - Browser event