import * as i0 from '@angular/core'; import { OnInit, AfterViewInit, OnDestroy, OnChanges, DoCheck, ComponentRef, TemplateRef, ElementRef, EventEmitter, SimpleChanges, Injector } from '@angular/core'; import { ControlValueAccessor, FormControl, ValidatorFn } from '@angular/forms'; import { MatDatepicker, MatCalendarCellClassFunction, MatDatepickerInputEvent } from '@angular/material/datepicker'; import { BooleanInput } from '@angular/cdk/coercion'; import { Moment } from 'moment'; import { EuiTimepickerComponent } from '@eui/components/eui-timepicker'; import * as i1 from '@eui/components/shared'; import { BaseStatesDirective } from '@eui/components/shared'; declare const DEFAULT_FORMATS: { parse: { dateInput: string; }; display: { dateInput: string; monthYearLabel: string; dateA11yLabel: string; monthYearA11yLabel: string; }; }; /** * A comprehensive date and datetime picker component that wraps Angular Material's datepicker with enhanced functionality. * Supports date-only, month, year, and datetime selection modes with optional timepicker integration. * Implements ControlValueAccessor for seamless integration with Angular reactive and template-driven forms. * * Use cases: * - Standard date selection with calendar popup * - Month or year-only selection for period-based inputs * - Combined date and time selection with integrated timepicker * - Date range validation with min/max constraints * - Custom date filtering and styling * - Responsive layouts with block-level display option * - Read-only and disabled states for display-only scenarios * * @usageNotes * ### Basic Date Picker * ```html * * * ``` * * ### DateTime Picker * ```html * * * ``` * * ### Month/Year Picker * ```html * * * ``` * * ### With Validation * ```typescript * // Component * dateControl = new FormControl(null, Validators.required); * minDate = new Date(2024, 0, 1); * maxDate = new Date(2024, 11, 31); * * // Template * * * ``` * * ### Accessibility * - Provides proper ARIA labels and roles for calendar navigation * - Keyboard navigation: Arrow keys for date selection, Enter to confirm, Escape to close * - Clear button is keyboard accessible when enabled * - Required state communicated via `aria-required` attribute * - Date format is announced to screen readers via placeholder * - Toggle button has accessible label via `togglerLabel` input * * ### Notes * - Use `dateOutputFormat` to control the format of emitted values (e.g., 'YYYY-MM-DD') * - `restrictToRegex` can limit input characters for format enforcement * - `datepickerFilter` enables custom date validation (e.g., disable weekends) * - `dateClass` allows styling specific dates (holidays, events) * - Time picker integrates seamlessly when `isDatetimepicker` is true * - `isDatepickerBlock` makes component responsive for mobile layouts * - `isReadOnly` allows calendar selection but prevents manual typing */ declare class EuiDatepickerComponent implements OnInit, AfterViewInit, ControlValueAccessor, OnDestroy, OnChanges, DoCheck { baseStatesDirective: BaseStatesDirective; euiLetterFormat: EuiLetterFormatDirective; get cssClasses(): string; e2eAttr: string; inputFormControl: FormControl; breakpointsValue: any; showDateButton: boolean; timePickerInstance: EuiTimepickerComponent; timePickerComponentRef: ComponentRef; calendar: MatDatepicker; templatePortalRef: TemplateRef; inputRef: ElementRef; euiActionButtons: EuiActionButtonsDirective; /** * Emitted when the input field value changes through user typing or programmatic updates. * Payload contains the formatted date string (if dateOutputFormat is set) or Moment object, or null if cleared. * Triggers on every input change, including manual text entry and clear actions. */ inputChange: EventEmitter; /** * Emitted when a date is selected from the calendar popup or through date/time adjustments. * Payload contains the formatted date string (if dateOutputFormat is set) or Moment object, or null if cleared. * Does not trigger on manual text input, only on calendar interactions and programmatic selections. */ dateSelect: EventEmitter; /** * The initial or current date value displayed in the input field. * Accepts Moment objects, Date objects, or date strings compatible with the configured date adapter. * When dateOutputFormat is specified, the internal value is formatted accordingly. */ value: any; /** * The SVG icon name displayed on the calendar toggle button. * Must be a valid eui-icon identifier. */ togglerIconSvg: string; /** * Accessible label text for the calendar toggle button. * Used for screen readers and accessibility compliance. */ togglerLabel: string; /** * Placeholder text displayed in the input field when empty. * If not provided, defaults to translated placeholders based on the calendar type (regular, month, or year). */ placeholder: string; /** * Determines the selection granularity and calendar behavior. * 'regular' allows full date selection, 'month' selects month/year only, 'year' selects year only. * Affects the calendar view, input format, and selection behavior. */ type: 'year' | 'month' | 'regular'; /** * The initial view displayed when the calendar popup opens. * 'month' shows the day grid, 'year' shows month selection, 'multi-year' shows year range selection. * If not specified, defaults based on the type property. */ startView: 'month' | 'year' | 'multi-year'; /** * The earliest selectable date in the calendar. * Dates before this value are disabled and cannot be selected. * Accepts Moment objects, Date objects, or date strings compatible with the date adapter. */ minDate: any; /** * The latest selectable date in the calendar. * Dates after this value are disabled and cannot be selected. * Accepts Moment objects, Date objects, or date strings compatible with the date adapter. */ maxDate: any; /** * Custom filter function to enable or disable specific dates in the calendar. * Receives each date as a parameter and should return true to enable the date, false to disable it. * Useful for implementing business rules like disabling weekends or holidays. */ datepickerFilter: (d: any) => boolean; /** * Moment.js format string for the output value emitted through form control and events. * When specified, all emitted values are formatted strings instead of Moment objects. * Example: 'YYYY-MM-DD' or 'DD/MM/YYYY HH:mm:ss'. */ dateOutputFormat: string; /** * Custom component class to replace the default calendar header. * Must be a valid Angular component that implements the Material datepicker header interface. * Allows complete customization of the calendar header appearance and behavior. */ customHeader: any; /** * Function that returns CSS class names to apply to specific calendar date cells. * Receives each date as a parameter and returns a string or array of class names. * Enables visual styling of specific dates like holidays, events, or special occasions. */ dateClass: MatCalendarCellClassFunction; /** * Increment/decrement step for hour adjustments in the timepicker. * Only applicable when isDatetimepicker is true. * Determines how many hours are added or subtracted with each button click. */ stepHours: number; /** * Increment/decrement step for minute adjustments in the timepicker. * Only applicable when isDatetimepicker is true. * Determines how many minutes are added or subtracted with each button click. */ stepMinutes: number; /** * Increment/decrement step for second adjustments in the timepicker. * Only applicable when isDatetimepicker is true and hasSeconds is true. * Determines how many seconds are added or subtracted with each button click. */ stepSeconds: number; /** * Unique identifier for the input element. * Used for label association, form integration, and testing selectors. * Auto-generated if not provided. */ inputId: string; /** * Custom CSS class or classes applied to the calendar popup panel. * Accepts a single class name string or an array of class names. * Useful for theme customization or specific styling requirements. */ customPanelClass: string | string[] | null; /** * Enables datetime selection mode with an integrated timepicker in the calendar popup. * When true, displays hour, minute, and optionally second selectors below the calendar. * Changes the component behavior to handle both date and time values. */ isDatetimepicker: boolean; /** * Displays seconds selector in the timepicker. * Only applicable when isDatetimepicker is true. * When false, only hours and minutes are selectable. */ hasSeconds: boolean; /** * Renders the timepicker with a single combined input field instead of separate hour/minute/second inputs. * Only applicable when isDatetimepicker is true. * Provides a more compact timepicker interface. */ isOneInputField: boolean; /** * Hides the calendar toggle button, leaving only the input field visible. * Users can still open the calendar by clicking the input field if isShownOnInputClick is true. * Useful for minimalist layouts or when calendar access should be input-driven only. */ hasNoButton: boolean; /** * Applies block-level display styling to make the component fill its container width. * Enables responsive behavior for mobile and tablet layouts. * When true, the input and button stretch to 100% width. */ isDatepickerBlock: boolean; /** * Makes the input field read-only, preventing manual text entry. * Users can still select dates from the calendar popup. * Automatically disables the clear button when true. */ isReadOnly: boolean; /** * Disables the entire component including input field, toggle button, and calendar popup. * When true, no user interaction is possible and the component appears visually disabled. * Integrates with Angular forms disabled state. */ isDisabled: boolean; /** * Disables only the input field while keeping the calendar toggle button enabled. * Users can select dates from the calendar but cannot type manually. * Useful for enforcing calendar-only date selection. */ isInputDisabled: boolean; /** * Disables only the calendar toggle button while keeping the input field enabled. * Users can type dates manually but cannot open the calendar popup. * Useful for keyboard-only or text-based date entry scenarios. */ isButtonDisabled: boolean; /** * Disables the calendar popup functionality while keeping the input field enabled. * Prevents the calendar from opening through any interaction method. * Similar to isButtonDisabled but also blocks input-click calendar opening. */ isPickerDisabled: boolean; /** * Controls whether clicking the input field opens the calendar popup. * When false, the calendar only opens via the toggle button. * Useful when the input should be primarily for manual text entry. */ isShownOnInputClick: boolean; /** * Displays a clear button in the input field to reset the value to null. * Automatically disabled when isReadOnly is true. * Clicking the clear button emits null through inputChange and dateSelect events. */ get isClearable(): boolean; set isClearable(value: BooleanInput); private _isClearable; /** * Regular expression pattern to restrict which characters can be typed in the input field. * Accepts a RegExp object or a string that will be converted to RegExp. * Each keypress is validated against this pattern; non-matching keys are blocked. * Useful for enforcing numeric-only input or specific date format characters. */ get restrictToRegex(): RegExp; set restrictToRegex(value: string | RegExp); private _restrictToRegex; /** * Returns an array of CSS classes to apply to the mat-datepicker panel. * Combines internal classes with user-provided customPanelClass. */ get mergedPanelClass(): string[]; protected hasAriaRequiredAttribute: boolean; private destroy$; private format; private portalHost; private portal; private templatePortal; private isNull; private adapter; private translateService; private localeService; private EuiAppShellService; private injector; private appRef; private viewContainerRef; private control; private momentAdapterOptions; constructor(); ngOnInit(): void; ngAfterViewInit(): void; ngDoCheck(): void; ngOnChanges(changes: SimpleChanges): void; /** * Creates an injector for the timepicker component. * @param data - The data to be passed to the timepicker component. * @return {Injector} - The created injector. */ createInjector(data: any): Injector; /** * Opens the calendar if read-only is false, listens to the keydown event when isDatetimepicker or euiActionButtons used * and creates the time config passed to the timepicker component. */ openCalendar(): void; ngOnDestroy(): void; /** * When calendar opens and isDatetimepicker or eui-action-buttons directive used, it closes the calendar when clicking outside of the * overlay. If eui-action-buttons directive is used it registers the template portal where the user can add projected content as a * footer. */ onOpened(): void; /** * Retrieves the event path for a given event. This method provides a fallback * for browsers that do not support the `event.path` property by constructing * the path manually. * * @param event - The event object of type `KeyboardEvent`. * @returns An array representing the event path, starting from the event target * and traversing up through its ancestors, ending with the `document` * and `window` objects. */ getEventPath(event: KeyboardEvent): EventTarget[]; /** * Fires when the type of the calendar is either month or year, * formats the date if dateOutputFormat used * emits and propagates the selected date value * and closes the calendar. * @param normalizedDate - The selected date in the calendar. * @param calendar - The MatDatepicker instance. */ chosenDateHandler(normalizedDate: any, calendar: MatDatepicker): void; /** * Method which returns true in order to mark the date as valid. * @returns {boolean} - Returns true if the date is valid. */ datepickerFiltering(): boolean; /** * Method which fires when the datepicker input value changes and applies logic when isDatetimepicker is false. * @param e - The MatDatepickerInputEvent object containing the new value. */ onDateInput(e: MatDatepickerInputEvent): void; /** * Method which fires when there is a date change from the calendar popup, * formats, emits and propagates the new value also when isDatetimepicker true. * @param e - The MatDatepickerInputEvent object containing the new value. */ onDateChange(e: MatDatepickerInputEvent): void; /** * Method which fires when the input value changes and applies logic when isDatetimepicker true. * @param e - The new value of the input field. */ changedInput(e: string | Event): void; /** * Method which fires when clearing the input field and emits/propagates the null value. */ onClear(): void; /** * Method which fires upon keypress and opens the calendar if isShownOnInputClick is true and the Enter key is pressed. * Also if there is a restrictToRegex, it prevents the default action if the key is not matching the regex. * @param e - The KeyboardEvent object. */ onKeypress(e: KeyboardEvent): void; /** * Selects today's date */ selectToday(): void; /** * Closes the calendar when isDatetimepicker or eui-action-buttons used and removes the applied footer when eui-action-buttons used */ closeCalendar(): void; /** * When eui-action-buttons used, it applies the date selection and closes the calendar */ onDateSelectApply(): void; writeValue(value: any): void; registerOnChange(fn: () => void): void; registerOnTouched(fn: () => void): void; /** * Converts the type of the calendar to the corresponding start view. * @param type - The type of the calendar. * @returns {('year' | 'month' | 'multi-year')} - The start view of the calendar. */ convTypeToStartView(type: string): 'year' | 'month' | 'multi-year'; /** * Sets the disabled state of the component based on the boolean value passed. * @param isDisabled - The boolean value indicating whether the component should be disabled or not. */ setDisabledState?(isDisabled: boolean): void; /** * Marks the form field as touched when focusing out to trigger validation */ protected onFocusOut(): void; /** * Checks the validity of the time picker based on the minDate and maxDate properties. * If the value is outside the range, it adjusts the time picker values accordingly. */ private checkTimePickerValidity; /** * Compares two dates and checks if they are the same. * @param date1 - The first date to compare. * @param date2 - The second date to compare. * @returns {boolean} - Returns true if the dates are the same, otherwise false. */ private areSameDates; private propagateChange; private propagateTouched; /** * Updates the `aria-required` attribute on the input element. * @private */ private updateInputAriaRequiredAttribute; /** * Validates and corrects the date to ensure it falls within the specified minDate and maxDate range. * If the date is before minDate, returns minDate. If the date is after maxDate, returns maxDate. * Otherwise, returns the original date unchanged. * * @param date - The date to validate (can be Moment, Date, or string) * @returns The validated date as a Moment object within the allowed range */ private validateDateRange; /** * Updates the disabled state of the timepicker based on whether a date is selected. * @private */ private updateTimePickerDisabledState; /** * Converts a date from any adapter format to Moment formats used with dateOutputFormat property. * @private * @param date - The date to convert, can be of any type supported by the adapter. * @returns The converted date as a Moment object. */ private adapterToMoment; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_isDatetimepicker: unknown; static ngAcceptInputType_hasSeconds: unknown; static ngAcceptInputType_isOneInputField: unknown; static ngAcceptInputType_hasNoButton: unknown; static ngAcceptInputType_isDatepickerBlock: unknown; static ngAcceptInputType_isReadOnly: unknown; static ngAcceptInputType_isDisabled: unknown; static ngAcceptInputType_isInputDisabled: unknown; static ngAcceptInputType_isButtonDisabled: unknown; static ngAcceptInputType_isPickerDisabled: unknown; static ngAcceptInputType_isShownOnInputClick: unknown; } declare const LETTER_FORMAT: { parse: { dateInput: string; }; display: { dateInput: string; monthYearLabel: string; }; }; declare const YEAR_FORMAT: { parse: { dateInput: string; }; display: { dateInput: string; monthYearLabel: string; dateA11yLabel: string; monthYearA11yLabel: string; }; }; declare const MONTH_YEAR_FORMAT: { parse: { dateInput: string; }; display: { dateInput: string; monthYearLabel: string; dateA11yLabel: string; monthYearA11yLabel: string; }; }; declare class EuiLetterFormatDirective { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class EuiYearFormatDirective { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class EuiMonthYearFormatDirective { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class EuiActionButtonsDirective { class: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * @description * Validator that validates the date based on the provided format. * * @usageNotes * If the user types a value in the input field that is not aligned with the provided format the component propagates a null value that * can be used to validate the input field. * * @returns An error map with the * `invalidDate` if the validation check fails, otherwise `null`. */ declare const dateInputValidator: ValidatorFn; declare const EUI_DATEPICKER: readonly [typeof EuiDatepickerComponent, typeof EuiLetterFormatDirective, typeof EuiYearFormatDirective, typeof EuiMonthYearFormatDirective, typeof EuiActionButtonsDirective]; export { DEFAULT_FORMATS, EUI_DATEPICKER, EuiActionButtonsDirective, EuiDatepickerComponent, EuiLetterFormatDirective, EuiMonthYearFormatDirective, EuiYearFormatDirective, LETTER_FORMAT, MONTH_YEAR_FORMAT, YEAR_FORMAT, dateInputValidator }; //# sourceMappingURL=eui-components-eui-datepicker.d.ts.map