Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3609 - Update Calendar typings to be precise #4972

Merged
merged 1 commit into from
Mar 25, 2024
Merged
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
71 changes: 56 additions & 15 deletions components/lib/calendar/Calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export interface CalendarBlurEvent {

/**
* Custom passthrough(pt) options.
* @see {@link CalendarProps.pt}
* @see {@link BaseCalendarProps.pt}
*/
export interface CalendarPassThroughOptions {
/**
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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<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.
*/
Expand Down Expand Up @@ -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<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.
* @param {Event} event - Browser event
Expand Down
Loading