import * as i0 from '@angular/core'; import { OnInit, EventEmitter, AfterViewInit, OnDestroy, QueryList, InjectionToken } from '@angular/core'; import * as i1 from '@odx/angular'; import { DisabledController } from '@odx/angular'; import { OptionControl } from '@odx/angular/cdk/option-control'; import { InputControlDirective, CustomFormControl } from '@odx/angular/cdk/custom-form-control'; import * as i2 from 'ngx-mask'; import { NgxMaskDirective } from 'ngx-mask'; import * as rxjs from 'rxjs'; import { ActiveDescendantKeyManager } from '@angular/cdk/a11y'; import { DropdownDirective } from '@odx/angular/components/dropdown'; /** * Represents a selectable option within a timepicker component. This component allows for * individual time values to be selected from a dropdown menu as part of the timepicker interface. * It integrates with the timepicker's control to manage selection state and accessibility. * * @extends {OptionControl} */ declare class TimepickerOptionComponent extends OptionControl implements OnInit { private readonly timepicker; protected readonly disabledController: DisabledController | null; /** * Indicates whether this time option is currently selected. * @type {boolean} * @default false */ isSelected: boolean; /** * Indicates whether this time option is currently active (e.g., highlighted by keyboard navigation). * This is an override from the base `OptionControl`. * @type {boolean} * @default false */ isActive: boolean; /** * Whether the option is disabled. This is used to determine whether the option should be selectable. * * @type {boolean} */ get disabled(): boolean; /** * Emits an event when the option is selected, allowing the timepicker component to update its value * and close the dropdown. * * @emits {TimepickerOptionComponent} */ selected: EventEmitter; constructor(); ngOnInit(): void; /** * Sets the active styles for the option, typically indicating that it is * focused or highlighted via keyboard navigation. */ setActiveStyles(): void; protected selectOption(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Directive to enhance a standard input element for time picking, integrating mask functionality for time format. * It automatically adapts to locale settings provided by the enclosing `TimepickerComponent` to display time in the appropriate format. * * @extends {InputControlDirective} */ declare class TimepickerInputControlDirective extends InputControlDirective { private readonly timepicker; private readonly timepickerService; readonly ngxMaskDirective: NgxMaskDirective | null; /** * Returns the placeholder text for the input based on locale settings. * * @returns {string} The placeholder text for the input. */ get placeholder(): string; /** * Determines whether the timepicker input is readonly, based on the state of the parent timepicker component. * * @returns {boolean} `true` if the input should be readonly; otherwise, `false`. */ protected get isReadonly(): boolean; /** * Applies the time format mask to the input value, transforming and returning the masked value. * * @param {Event} event - The input event triggering the mask application. * @returns {string} The masked input value. */ applyMask(useLocale: boolean): void; /** * Updates the input value through ngx-mask directive. * * @param {string | null} value - The new value to set in the input. */ setMaskedValue(value: string | null): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Represents a time picker component allowing users to select a time from a dropdown list. * This component integrates with Angular forms and supports customization for locale, time range, and step intervals. * * @see {CustomFormControl} */ declare class TimepickerComponent extends CustomFormControl implements AfterViewInit, OnDestroy { private readonly timepickerService; private _useLocale; private openAnimationFrameId?; protected keyManager?: ActiveDescendantKeyManager>; protected readonly takeUntilDestroyed: () => rxjs.MonoTypeOperatorFunction; protected readonly dropdown?: DropdownDirective; protected options: QueryList; readonly element: i0.ElementRef; /** * Controls whether the timepicker should use locale-specific time formats AM/PM. * * @type {boolean} * @default false */ set useLocale(val: boolean); /** * Gets a boolean value indicating whether the locale is being used. * * @returns {boolean} A boolean value indicating whether the locale is being used. */ get useLocale(): boolean; /** * When set to true, the select will display a reset button. * * @type {boolean} * @default false */ clearable: i0.InputSignalWithTransform; /** * Controls the step interval between time options in minutes. * * @type {number} * @default 30 */ step: number; /** * Specifies the minimum time value that can be selected ('05:00' or '05:00 AM'). * * @type {string} * @default '00:00' */ min: string; /** * Specifies the maximum time value that can be selected ('22:00' or '10:00 PM'). * * @type {string} * @default '23:59' */ max: string; /** * The directive for the timepicker input control. * * @type {TimepickerInputControlDirective | undefined} */ dateField?: TimepickerInputControlDirective; constructor(); ngAfterViewInit(): void; ngOnDestroy(): void; /** * Checks if the given time option is selected. * * @param {TimepickerOptionComponent} option - The time option to check. * @returns {boolean} True if the option is selected, false otherwise. */ isTimeOptionSelected(option: TimepickerOptionComponent): boolean; /** * Handles the selection of a time option from the dropdown, updating the input field and closing the dropdown. * * @param {TimepickerOptionComponent | undefined} option - The selected time option component. */ timeSelected(option?: TimepickerOptionComponent): void; /** * Determines whether the specified time is within the allowed time range. * * @param {string} time - The time to check, in 'HH:mm' or 'HH:mm AM/PM' format. * @returns {boolean} True if the time is within the range; otherwise, false. */ inTimeRange(time: string): boolean; /** * Generates the list of time options based on the configured step interval and locale settings AM/PM. * * @returns {string[]} An array of time strings in 'HH:mm' format. */ get timeStampsList(): string[]; /** * @internal * Writes a new value to the element. * Part of the ControlValueAccessor interface. * @param {string | null} value - The new value. */ writeValue(value: string | null): void; protected onOpen(): void; protected handleControllerClick(): void; protected handleControllerKeydown(event: KeyboardEvent): void; protected handleDateFieldChanges(): void; protected resetValue(e: Event): void; private setActiveOptionBasedOnCurrentValue; private activateOption; private activateNearestTimeOption; private getActiveOption; private findNearestTimeOption; private updateInputValue; private scrollToActiveOption; private setOption; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_useLocale: unknown; static ngAcceptInputType_step: unknown; } declare class TimepickerModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * Service to provide utility functions for timepicker components, including validation, placeholder generation, and finding the closest time. * It also handles locale-based time formatting. */ declare class TimepickerService { private readonly windowRef; useLocale: i0.WritableSignal; /** * Validates if the given time is less than or equal to a maximum time constraint. * * @param {string} time - The time to validate. * @param {string} max - The maximum allowable time. * @returns {boolean} True if the time is valid (i.e., not after max), false otherwise. */ maxValidation(time: string, max: string): boolean; /** * Checks if the provided value is a valid time string in HH:mm or HH:mm AM/PM format. * This method also acts as a type guard. * * @param {unknown} time - The value to validate. * @returns {time is string} True if the value is a valid time string, false otherwise. */ isValidTime(time: unknown): time is string; is12HourFormat(value: string): boolean; /** * Validates if the given time is greater than or equal to a minimum time constraint. * * @param {string} time - The time to validate. * @param {string} min - The minimum allowable time. * @returns {boolean} True if the time is valid (i.e., not before min), false otherwise. */ minValidation(time: string, min: string): boolean; /** * Finds the closest time to a target time from a list of times. * * @param {string[]} timeStamps - The list of time strings to search through (e.g., ["10:00", "10:30", "11:00"]). * @param {string} targetTime - The target time string to find the closest match for (e.g., "10:35"). * @returns {string} The closest time string from the list to the target, formatted according to locale. */ findClosestDate(timeStamps: string[], targetTime: string): string; /** * Formats a time string to a localized time format using Intl.DateTimeFormat. * * @param {unknown} time - The time string to format (e.g., "14:30"). * @param {boolean} [hour12=false] - Specifies if the output should use 12-hour format with AM/PM notation. * @returns {string} The formatted time string, or an empty string if the input time is invalid. */ getLocalizedTimeFormat(time: unknown, hour12?: boolean): string; private convertToDates; private parseTimeString; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * An InjectionToken used for injecting an instance of TimepickerComponent. * This token facilitates the decoupling of the TimepickerComponent's implementation from its consumption, * allowing for more flexible and maintainable code, especially in scenarios requiring custom time picker * behavior or appearance. */ declare const TIMEPICKER_CONTROL: InjectionToken; /** * Generates an array of time stamps within a 24-hour period based on the specified step interval. * The time stamps can be formatted in 24-hour format or 12-hour format with AM/PM based on locale preference. * * @param {number} step - The interval, in minutes, between each time stamp. * @param {boolean} useLocale - Determines if the time stamps should use the 12-hour format with AM/PM (`true`) or the 24-hour format (`false`). * @returns {string[]} An array of formatted time stamps as strings. * @example * ```ts * // Generate time stamps every 30 minutes using 24-hour format * generateTimeStamps(30, false); * // Returns ["00:00", "00:30", "01:00", ..., "23:30"] * * // Generate time stamps every 60 minutes using 12-hour format with AM/PM * generateTimeStamps(60, true); * // Returns ["12:00 AM", "01:00 AM", ..., "11:00 PM"] * ``` */ declare function generateTimeStamps(step: number, useLocale: boolean): string[]; /** * Processes and formats a time input value based on specific rules. It adjusts the input for valid time format, * especially focusing on single-digit hour inputs, ensuring minute values start with 0 if the last digit is greater * than 5, and appending 'M' to AM/PM indicators. * * @param {string} value - The current input value of the time field. * @param {InputEvent} event - The input event triggered by the user's interaction with the field. * @returns {string} The processed and potentially reformatted value. * * @example * ```ts * // Prepend 0 to single-digit hours greater than 1 * processInputValue("2", { inputType: "insertText" }); // Returns "02" * * // Ensure minute values are within valid ranges * processInputValue("11:8", { inputType: "insertText" }); // Returns "11:08" * * // Append 'M' to AM/PM indicators * processInputValue("2 p", { inputType: "insertText" }); // Returns "2 PM" * ``` */ declare function processInputValue(value: string, event: InputEvent): string; export { TIMEPICKER_CONTROL, TimepickerComponent, TimepickerInputControlDirective, TimepickerModule, TimepickerOptionComponent, TimepickerService, generateTimeStamps, processInputValue };