UNPKG

ng-material-date-range-picker

Version:
91 lines (90 loc) 3.74 kB
import { DateRange, MatCalendar } from '@angular/material/datepicker'; import { DATE_OPTION_TYPE } from '../constant/date-filter-const'; import { ISelectDateOption } from '../model/select-date-option.model'; import { ChangeDetectorRef } from '@angular/core'; import { ActiveDate } from '../model/active-date.model'; /** * Resets the selection state for all options * and marks the given option as selected if provided. * * @param options - List of date options * @param selectedOption - Option to be marked as selected */ export declare function resetOptionSelection(options: ISelectDateOption[], selectedOption?: ISelectDateOption): void; /** * Marks the custom date option as selected. * * @param options - List of date options */ export declare function selectCustomOption(options: ISelectDateOption[]): void; /** * Returns a new date with the given year offset applied. * * @param offset - Number of years to add (negative for past years) * @returns Date object with updated year */ export declare function getDateWithOffset(offset: number): Date; /** * Creates a deep clone of the provided object or array. * * @param data - Data to be cloned * @returns A deep copy of the data */ export declare function getClone<T>(data: T): T; /** * Formats a date object into a string using Angular DatePipe. * * @param date - Date to be formatted * @param dateFormat - Desired date format (e.g., 'dd/MM/yyyy') * @returns Formatted date string */ export declare function getDateString(date: Date, dateFormat: string): string; /** * Formats a date range into a string with start and end dates. * * @param range - Date range with start and end * @param dateFormat - Desired date format * @returns Formatted range string (e.g., '01/01/2023 - 07/01/2023') */ export declare function getFormattedDateString(range: DateRange<Date>, dateFormat: string): string; /** * Creates a standardized date option object for dropdowns. * * @param label - Display label for the option * @param key - Option key from DEFAULT_DATE_OPTION_ENUM * @param dateDiff - Offset in days from current date (default: 0) * @param isVisible - Whether the option is visible (default: true) * @returns ISelectDateOption object */ export declare function createOption(label: string, key: DATE_OPTION_TYPE, dateDiff?: number, isVisible?: boolean): ISelectDateOption; /** * Returns the date of the next month based on the given date. * * @param currDate - Current date * @returns A new Date object incremented by one month */ export declare function getDateOfNextMonth(currDate: Date): Date; /** * Returns the first day of the month following the given date. * * @param currDate - The current date * @returns A Date object set to the first day of the next month */ export declare function getFirstDateOfNextMonth(currDate: Date): Date; /** * Returns the number of days in the month of the given date. * * @param date The date to calculate the days for. * @returns Number of days in the month. */ export declare function getDaysInMonth(date: Date): number; /** * Overrides the `activeDate` setter for a MatCalendar instance, injecting custom handler logic * while preserving the original setter behavior. Useful for reacting to internal date navigation * events (e.g., month changes) in Angular Material's calendar. * * @param calendar - Instance of MatCalendar whose `activeDate` setter will be overridden. * @param cdref - ChangeDetectorRef to trigger view updates after the setter runs. * @param handler - Custom callback function executed whenever `activeDate` is set. */ export declare function overrideActiveDateSetter(calendar: MatCalendar<Date>, cdref: ChangeDetectorRef, handler: (date: ActiveDate) => void): void;