Skip to content

Commit

Permalink
#3609 more precise typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Magiczne committed Jan 20, 2024
1 parent 4fd8a64 commit c84f936
Showing 1 changed file with 54 additions and 13 deletions.
67 changes: 54 additions & 13 deletions components/lib/calendar/Calendar.d.ts
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, string | null] | [Date, Date | null] | 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?: [Date, 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

0 comments on commit c84f936

Please sign in to comment.