import * as i0 from '@angular/core'; import { EventEmitter, OnChanges, PipeTransform, OnInit, OnDestroy, AfterViewInit } from '@angular/core'; import * as rxjs from 'rxjs'; import { Observable } from 'rxjs'; import * as _odx_angular_components_calendar from '@odx/angular/components/calendar'; import * as _odx_angular_utils from '@odx/angular/utils'; import { NgChanges } from '@odx/angular/utils'; declare enum CalendarView { Month = "month", Year = "year", Years = "years" } type DateFilter = (date: Date) => boolean; type DateType = Date | number | string; interface DateTypeRange { start: DateType | null; end: DateType | null; } interface DateRange { start: Date | null; end: Date | null; } declare enum DateRangeSelectionState { NothingSelected = "NothingSelected", StartSelected = "StartSelected", EndSelected = "EndSelected" } interface DateRangeState { selectionState: DateRangeSelectionState; dateRange: DateRange; } type DateValidator = (date1: Date, date2: Date) => boolean; interface DateSelectEvent { date: Date | null; options: DateSelectOptions; } interface DateSelectOptions { skipDaterangeUpdate?: boolean; emitOutside?: boolean; } declare const dateSelectOptionsDefaults: DateSelectOptions; declare enum CalendarSelectionMode { Date = 0, DateRange = 1 } /** * Manages the state and functionality related to a calendar, such as tracking the active date, * hovered date, current calendar view, and handling date selections. It provides observable streams * that components can subscribe to in order to react to changes in the calendar's state. */ declare class CalendarService { private readonly activeDate$$; private readonly hoveredDate$$; private readonly calendarView$$; private readonly dateSelectEvents$$; /** * Currently selected date to external subscribers, particularly useful for two-way binding. * * @emits {Date | null} The currently selected date or null if no date is selected. */ readonly outputDate$: EventEmitter; /** * An observable of the current calendar view state, allowing subscribers to adjust UI components * based on the view (e.g., month, year, multi-year). * * @emits {CalendarView} The current calendar view state. */ readonly calendarView$: rxjs.Observable; /** * Streams date select events which include the selected date and any associated options. * * @emits {DateSelectEvent} The date selection event, including the selected date and options. */ readonly dateSelectEvents$: rxjs.Observable; /** * Streams the last selected date, enabling components to update based on the latest date selection. * * @emits {Date | null} The last selected date or null if no date has been selected. */ readonly selectedDate$: rxjs.Observable; /** * Streams the active date which reflects the date that is being focused, either through UI interactions * like clicking or using arrow keys. * * @emits {Date | null} The active date or null if no date is active. */ readonly activeDate$: rxjs.Observable; /** * Combines streams of active and hovered dates to provide a merged view of preview dates. * * @emits {Date | null} The preview date or null if no date is being previewed. */ readonly previewDate$: rxjs.Observable; /** * Updates the active date state with a new date, parsed from various input types. * * @param {DateType | null} value - The new date or null to clear the active date. */ setActiveDate(value: DateType | null): void; /** * Sets a date as hovered, which can be used to preview date ranges or effects in the UI. * * @param {DateType | null} value - The date being hovered or null to clear the hovered state. */ setHoveredDate(value: DateType | null): void; /** * Selects a date and updates relevant states and options. Can emit the selected date externally * if specified in the options. * * @param {DateType | null} value - The date to select. * @param {DateSelectOptions} [options] - Optional settings for the date selection, such as whether * to emit the date change externally. */ selectDate(value: DateType | null, options?: DateSelectOptions): void; /** * Changes the calendar view to the specified view, updating the internal state and notifying subscribers. * * @param {CalendarView} view - The new view to set for the calendar. */ changeView(view: CalendarView): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service for managing date range selection. */ declare class DaterangeService { private readonly calendar; private readonly dateRangeState$$; /** * An event emitter for outputting the selected date range. * * @emits {DateRange | null} outputDateRange$ - The selected date range or null if no range is selected. */ readonly outputDateRange$: EventEmitter; /** * An observable that emits the current date range state. * The date range state represents the current selection state and the selected date range. * * @emits {DateRangeState} dateRangeState$ - The current date range state. */ readonly dateRangeState$: Observable; /** * Sets the selected date range. * * @param {DateTypeRange} value - The selected date range. */ setDateRange(value: DateTypeRange): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * A component for selecting a date or date range. It provides a calendar interface for selecting dates and date ranges, * and supports various configuration options for customizing the appearance and behavior of the calendar. */ declare class CalendarComponent implements OnChanges { private readonly config; protected readonly calendar: CalendarService; protected readonly daterange: DaterangeService; protected readonly CalendarView: typeof CalendarView; protected readonly vm$: rxjs.Observable<{ activeDate: Date; calendarView: CalendarView; selectedDate: Date | null; selectedDateRange: _odx_angular_components_calendar.DateRangeState; previewDate: Date; }>; readonly element: i0.ElementRef; /** * Represents the selected date in the calendar component. * It can be of type `DateType` or `null` if no date is selected. * * @type {DateType | null} * @default null */ selectedDate: DateType | null; /** * Represents the selected date range in the calendar component. * It can be of type `DateTypeRange` or `null` if no date range is selected. * * @type {DateTypeRange | null} * @default null */ selectedDateRange?: DateTypeRange | null; /** * The minimum selectable date for the calendar component. * If set to null, there is no minimum date restriction. * * @type {Date | null} * @default null */ minDate?: Date | null; /** * The maximum selectable date for the calendar component. * If set to null, there is no maximum date restriction. * * @type {Date | null} * @default null */ maxDate?: Date | null; /** * The filter function used to determine which dates are selectable in the calendar. * If set to `null`, all dates will be selectable. * * @type {DateFilter | null} * @default null * * @example * ```ts * // Filter out weekends * const filterFn: DateFilter = (date) => date.getDay() !== 0 && date.getDay() !== 6; * ``` */ filterFn?: DateFilter | null; /** * Emits an event whenever the selected date changes. * The event payload is either a Date object representing the selected date or null * if no date is selected. * * @emits {Date | null} */ selectedDateChange: EventEmitter; /** * Emits an event whenever the selected date range changes. * The event payload is either a DateRange object representing the selected date range * or null if no date range is selected. * * @emits {DateRange | null} */ selectedDateRangeChange: EventEmitter; constructor(); ngOnChanges(changes: NgChanges): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } interface CalendarConfig { /** * Displays the adjacent days in month calendar view. * * @default true */ displayAdjacentDays: boolean; /** * Switches between single selection and a daterange selection. * * @default CalendarSelectionMode.Date */ selectionMode: CalendarSelectionMode; /** * Configuration for the year view. * * @typedef {Object} YearViewConfig * @property {number} itemsPerRow - Number of items to display per row in the year view. * @default 3 */ /** * Configuration options for the calendar's year view. * * @type {YearViewConfig} */ yearView: { itemsPerRow: number; }; /** * Configuration for the years view. * * @typedef {Object} YearsViewConfig * @property {number} itemsPerRow - Number of items to display per row in the years view. * @property {number} [padding=100] - The number of year items before and after the current year * @default * itemsPerRow: 3, * padding: 100 */ /** * Configuration options for the calendar's years view. * * @type {YearsViewConfig} */ yearsView: { itemsPerRow: number; padding: number; }; } /** * Tools for customizing configuration for the calendar component * * @example * ```ts * @Component({ * ... * providers: [provideCalendarConfig({ selectionMode: CalendarSelectionMode.DateRange, locale: new BehaviorSubject(deDE)})] * }) * export class MyDateRangepickerComponent {} * ``` * * @example * ```ts * constructor(@Inject(CalendarConfig) private readonly calendarConfig: CalendarConfig) {} * ``` */ declare const CalendarConfig: i0.InjectionToken>; declare const CalendarDefaultConfig: { displayAdjacentDays: boolean; selectionMode: CalendarSelectionMode; yearView: { itemsPerRow: number; }; yearsView: { itemsPerRow: number; padding: number; }; }; declare const injectCalendarConfig: () => { displayAdjacentDays: boolean; selectionMode: CalendarSelectionMode; yearView: { itemsPerRow: number; }; yearsView: { itemsPerRow: number; padding: number; }; }; declare const provideCalendarConfig: >>(config: _odx_angular_utils.ConfigProvider, D>) => i0.FactoryProvider | i0.ValueProvider; /** * Represents the header component of the calendar. */ declare class CalendarHeaderComponent implements OnChanges { protected isPreviousDisabled: boolean; protected isNextDisabled: boolean; readonly element: i0.ElementRef; /** * The active date of the calendar. * * @type {Date} */ activeDate: Date; /** * The current view of the calendar. * * @type {CalendarView} */ calendarView: CalendarView; /** * The minimum selectable date in the calendar. * * @type {Date | null} * @default null */ minDate?: Date | null; /** * The maximum selectable date in the calendar. * * @type {Date | null} * @default null */ maxDate?: Date | null; /** * Event emitted when the previous button is clicked. * * @emits {MouseEvent} */ previous: EventEmitter; /** * Event emitted when the next button is clicked. * * @emits {MouseEvent} */ next: EventEmitter; /** * Event emitted when the view is changed. * * @emits {void} */ changeView: EventEmitter; ngOnChanges(changes: NgChanges): void; protected previousClicked(event: MouseEvent): void; protected nextClicked(event: MouseEvent): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Transforms a given date into a formatted string based on the provided date format string. * The transformation utilizes the `format` function from date-fns library and considers the locale * from the global calendar configuration to ensure the date is represented in a locale-appropriate format. * * @param {Date | null} value - The date to format. * @param {Intl.DateTimeFormatOptions} formatOptions - The format options to apply to the date. * @returns {string} - The formatted date string. */ declare class DateLabelPipe implements PipeTransform { private readonly localizationService; private readonly windowRef; private readonly cdr; private lastValue; private lastFormatOptions; private formattedValue; transform(value: Date | null, formatOptions: Intl.DateTimeFormatOptions): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } /** * Represents a directive for a cell in the calendar view. */ declare class CalendarCellDirective implements OnChanges, OnInit, OnDestroy { private readonly disabledController; private readonly eventManager; private readonly calendarService; private registeredEventId; protected readonly config: { displayAdjacentDays: boolean; selectionMode: CalendarSelectionMode; yearView: { itemsPerRow: number; }; yearsView: { itemsPerRow: number; padding: number; }; }; protected readonly dateLabelPipe: DateLabelPipe; protected isActive: boolean; protected isSelected: boolean; protected isHidden: boolean; protected ariaLabel: string; protected get isDisabled(): boolean; protected isCurrent: boolean; protected adjacent: boolean; protected isInRange: boolean; protected isRangeStart: boolean; protected isRangeEnd: boolean; protected isInPreviewRange: boolean; protected isPreviewRangeStart: boolean; protected isPreviewRangeEnd: boolean; readonly element: i0.ElementRef; /** * Represents the date associated with a calendar cell. * The date is used to determine the date displayed in the cell. * * @type {Date} */ date: Date; /** * Represents the calendar view of the cell. * The calendar view determines how the cell is displayed in the calendar. * * @type {CalendarView} */ calendarView: CalendarView; /** * Represents the active date in the calendar view. * * @type {Date | null} * @default null */ activeDate: Date | null; /** * Represents the selected date in the calendar view. * * @type {Date | null} * @default null */ selectedDate?: Date | null; /** * Represents the selected date range in the calendar view. * * @type {DateRangeState | null} * @default null */ selectedDateRange?: DateRangeState | null; /** * Represents the preview date for the calendar view. * This property represents the date that is currently being previewed in the calendar view. * It can be set to a specific date or null if no date is being previewed. * * @type {Date | null} * @default null */ previewDate?: Date | null; ngOnChanges(changes: NgChanges): void; ngOnInit(): void; ngOnDestroy(): void; private registerEvents; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Represents an abstract directive for a calendar view. */ declare abstract class CalendarViewDirective { protected readonly takeUntilDestroyed: () => rxjs.MonoTypeOperatorFunction; protected readonly calendar: CalendarService; protected readonly config: { displayAdjacentDays: boolean; selectionMode: _odx_angular_components_calendar.CalendarSelectionMode; yearView: { itemsPerRow: number; }; yearsView: { itemsPerRow: number; padding: number; }; }; protected abstract readonly currentView: CalendarView; protected abstract readonly nextView: CalendarView; readonly element: i0.ElementRef; /** * The active date for the calendar view. * * @type {Date} */ activeDate: Date; /** * The selected date in the calendar view. * * @type {Date | null} * @default null */ selectedDate?: Date | null; /** * The selected date range in the calendar view. * * @type {DateRangeState | null} * @default null */ selectedDateRange?: DateRangeState | null; /** * The preview date for the calendar view. * This property represents the date that is currently being previewed in the calendar view. * It can be set to a specific date or null if no date is being previewed. * * @type {Date | null} * @default null */ previewDate?: Date | null; /** * The minimum selectable date in the calendar view. * If set, dates before this minimum date will be disabled for selection. * * @type {Date | null} * @default null */ minDate?: Date | null; /** * The maximum selectable date in the calendar view. * If set, dates after this maximum date will be disabled for selection. * * @type {Date | null} * @default null */ maxDate?: Date | null; /** * The filter function used to determine if a date should be displayed in the calendar view. * If set to `null`, no filtering will be applied. * * @type {DateFilter | null} * @default null * * @remarks * The filter function should accept a `Date` object as its parameter and return a boolean value. * If the function returns `true`, the date will be displayed; if it returns `false`, the date will be hidden. * * @example * ```ts * // Filter out weekends * const filterFn: DateFilter = (date) => date.getDay() !== 0 && date.getDay() !== 6; * ``` */ filterFn?: DateFilter | null; protected isDateDisabled(value: Date): boolean; protected changeView(): void; protected updateActiveDate(event: Event, date: Date): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** @internal */ declare class CalendarMonthService { private readonly calendar; private readonly weeksInView; readonly weekDays$: rxjs.Observable; readonly weeks$: rxjs.Observable; private generateWeekDays; private generateWeeks; private generateDaysForWeek; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** @internal */ declare class CalendarYearService { private readonly config; private readonly calendar; readonly seasons$: rxjs.Observable; private generateSeasons; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** @internal */ declare class CalendarYearsService { private readonly config; readonly years$: rxjs.Observable; private generateYears; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Represents a calendar month component. * This component extends the `CalendarViewDirective` class and provides functionality for managing the calendar month. * * @see {CalendarViewDirective} */ declare class CalendarMonthComponent extends CalendarViewDirective { protected readonly calendarMonth: CalendarMonthService; protected readonly nextView = CalendarView.Years; protected readonly currentView = CalendarView.Month; protected previousDay(event: Event): void; protected nextDay(event: Event): void; protected previousWeek(event: Event): void; protected nextWeek(event: Event): void; protected previousMonth(event: Event): void; protected nextMonth(event: Event): void; protected selectDate(value: Date): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Represents a component for displaying a calendar year view. * Extends the `CalendarViewDirective` class. * * @see {CalendarViewDirective} */ declare class CalendarYearComponent extends CalendarViewDirective { protected readonly calendarYear: CalendarYearService; protected readonly nextView = CalendarView.Month; protected readonly currentView = CalendarView.Year; protected previousMonth(event: Event): void; protected nextMonth(event: Event): void; protected previousSeason(event: Event): void; protected nextSeason(event: Event): void; protected previousYear(event: Event): void; protected nextYear(event: Event): void; protected selectDate(value: Date): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Represents the component for displaying the years view in a calendar. * Extends the `CalendarViewDirective` class and implements the `AfterViewInit` interface. * * @see {CalendarViewDirective} */ declare class CalendarYearsComponent extends CalendarViewDirective implements AfterViewInit { private readonly document; protected readonly calendarYears: CalendarYearsService; protected readonly nextView = CalendarView.Year; protected readonly currentView = CalendarView.Years; ngAfterViewInit(): void; protected previousYear(event: Event): void; protected nextYear(event: Event): void; protected previousRow(event: Event): void; protected nextRow(event: Event): void; protected selectDate(value: Date): void; private scrollCurrentYearIntoView; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** @internal */ declare function checkIdenticalDate(currentDate: Date, date: Date, calendarView: CalendarView): boolean; /** @internal */ declare function getA11yLabel(calendarView: CalendarView): Intl.DateTimeFormatOptions; /** @internal */ declare function isDateDisabled(date: Date, calendarView: CalendarView, minDate?: Date | null, maxDate?: Date | null, filterFn?: DateFilter | null): boolean; /** @internal */ declare function parseDate(value: DateType): Date; /** @internal */ declare function validateDaterange(start: Date, end: Date): boolean; /** @internal */ declare function validateMaxDate(maxDate: Date, date: Date, calendarView: CalendarView): boolean; /** @internal */ declare function validateMinDate(maxDate: Date, date: Date, calendarView: CalendarView): boolean; /** @internal */ declare function validateNextDateSet(maxDate: Date, date: Date, calendarView: CalendarView): boolean; /** @internal */ declare function validatePreviousDateSet(minDate: Date, date: Date, calendarView: CalendarView): boolean; export { CalendarCellDirective, CalendarComponent, CalendarConfig, CalendarDefaultConfig, CalendarHeaderComponent, CalendarMonthComponent, CalendarMonthService, CalendarSelectionMode, CalendarService, CalendarView, CalendarViewDirective, CalendarYearComponent, CalendarYearService, CalendarYearsComponent, CalendarYearsService, DateLabelPipe, DateRangeSelectionState, checkIdenticalDate, dateSelectOptionsDefaults, getA11yLabel, injectCalendarConfig, isDateDisabled, parseDate, provideCalendarConfig, validateDaterange, validateMaxDate, validateMinDate, validateNextDateSet, validatePreviousDateSet }; export type { DateFilter, DateRange, DateRangeState, DateSelectEvent, DateSelectOptions, DateType, DateTypeRange, DateValidator };