Merge pull request #4972 from Magiczne/calendar-types-update

Fixes #3609 - Update Calendar typings to be precise
pull/5482/head
Tuğçe Küçükoğlu 2024-03-25 13:18:02 +03:00 committed by GitHub
commit b9774c4182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 56 additions and 15 deletions

View File

@ -126,7 +126,7 @@ export interface CalendarBlurEvent {
/** /**
* Custom passthrough(pt) options. * Custom passthrough(pt) options.
* @see {@link CalendarProps.pt} * @see {@link BaseCalendarProps.pt}
*/ */
export interface CalendarPassThroughOptions { 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 { interface BaseCalendarProps {
/**
* 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;
/** /**
* Format of the date. Defaults to PrimeVue Locale configuration. * Format of the date. Defaults to PrimeVue Locale configuration.
*/ */
@ -796,6 +786,57 @@ export interface CalendarProps {
*/ */
unstyled?: boolean; 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<Date | null> | 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<Date> | 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. * Defines valid options of the date slot in Calendar component.
*/ */
@ -938,9 +979,9 @@ export interface CalendarSlots {
export interface CalendarEmits { export interface CalendarEmits {
/** /**
* Emitted when the value changes. * Emitted when the value changes.
* @param {string | Date | string[] | Date[] | undefined} value - New value. * @param {Date | Array<Date | null> | null} value - New value.
*/ */
'update:modelValue'(value: string | Date | string[] | Date[] | undefined): void; 'update:modelValue'(value: Date | Array<Date | null> | null): void;
/** /**
* Callback to invoke when input field is being typed. * Callback to invoke when input field is being typed.
* @param {Event} event - Browser event * @param {Event} event - Browser event