import { ValidatorFn, ControlValueAccessor } from '@angular/forms';
import * as _angular_core from '@angular/core';
import { OnInit, AfterViewInit, ElementRef, QueryList, Injector } from '@angular/core';
import { FormFieldControlBaseComponent, FormFieldControl } from '@talenra/ngx-base/form-field';
import { InputComponent } from '@talenra/ngx-base/input';
import { TLocale } from '@talenra/ngx-base/shared';
/**
* Type of date filter functions.
*
* ### Import
*
* ```typescript
* import { DateFilterFn } from '@talenra/ngx-base/date';
* ```
*
* @see {@link DateComponent}
*/
type DateFilterFn = (date: Date) => boolean;
/**
* Filter for days in the future (allowToday: true includes today)
* Only allows to select dates in the future and greys out other options in the overlay
*
* ```typescript
* // Component class
* import { dateInTheFuture } from '@talenra/ngx-base/date';
* ```
*
* ```html
*
*
* ```
*/
declare const dateInTheFutureFilter: (allowToday: boolean) => DateFilterFn;
/**
* Filter for days in the past (allowToday: true includes today)
* Only allows to select dates in the passt and greys out other options in the overlay
*
* ```typescript
* // Component class
* import { dateInThePastFilter } from '@talenra/ngx-base/date';
* ```
*
* ```html
*
*
* ```
*/
declare const dateInThePastFilter: (allowToday: boolean) => DateFilterFn;
/**
* Filter for first day of month.
* Only allows to select the first day of each month and greys out other options in the overlay
*
* ```typescript
* // Component class
* import { firstDayOfMonthFilter } from '@talenra/ngx-base/date';
* ```
*
* ```html
*
*
* ```
*/
declare const firstDayOfMonthFilter: DateFilterFn;
/**
* Filter for weekdays (Monday - Friday)
* Only allows to select weekdays and greys out other options in the overlay
*
* ```typescript
* // Component class
* import { weekdaysFilter } from '@talenra/ngx-base/date';
* ```
*
* ```html
*
*
* ```
*/
declare const weekdaysFilter: DateFilterFn;
/**
* Checks whether the date is valid. Only basic validation.
*
* ```typescript
* // Component class
* import { validateDate } from '@talenra/ngx-base/date';
*
* const form = new FormGroup({
* date: new FormControl('', validateDate())
* });
* ```
*
* ```html
*
*
*
*
*
* ```
*/
declare function validateDate(): ValidatorFn;
/**
* Checks whether the date is in the future. Often used in combination with `validateDate`.
*
* @param includesToday If true, the date is considered valid if it is today.
* @param includeTime If true, the time is taken into account for the comparison.
*
* ```typescript
* import { validateDate, validateDateIsInTheFuture } from '@talenra/ngx-base/date';
*
* const form = new FormGroup({
* date: new FormControl('', [validateDate(), validateDateIsInTheFuture())
* });
* ```
*
* ```html
*
*
*
* The date must be in the future.
*
*
* The date is invalid.
*
*
* ```
*/
declare function validateDateIsInTheFuture(includesToday?: boolean, includeTime?: boolean): ValidatorFn;
/**
* Checks whether the date is in the future.
*
* @param includesToday If true, the date is considered valid if it is today.
* @param includeTime If true, the time is taken into account for the comparison.
*
* ```typescript
* // Component class
* import { validateDate, validateDateIsInThePast } from '@talenra/ngx-base/date';
*
* const form = new FormGroup({
* date: new FormControl('', [validateDate(), validateDateIsInThePast())
* });
* ```
*
* ```html
*
*
*
*
* The date must be in the past.
*
*
* The date is invalid.
*
*
* ```
*/
declare function validateDateIsInThePast(includesToday?: boolean, includeTime?: boolean): ValidatorFn;
/**
* Checks if the start date is before the end date.
*
* @param startDateId Name of the form-control
* @param endDateId Name of the form-control
* @param allowSameDay Allows the end date to be on the same day as the start date, default is 'false'
*
* @returns Returns a function which in case of an error it returns `{ invalidDateOrder: true }` apart from that `null`.
*/
declare function validateStartDateIsBeforeEndDate(startDateId: string, endDateId: string, allowSameDay?: boolean): ValidatorFn;
/**
* Checks if a date's year is greater than or equal the threshold's year.
*
* @param threshold The minimum year
*
* @returns Returns a function which in case of an error it returns `{ invalidPeriodStartYear: true }` apart from that `null`.
*/
declare function validateYearIsEqualOrGreater(threshold: number): ValidatorFn;
/**
* Values accepted by `CalendarOverlay`'s `overlayMode` property.
*
* @internal
*/
declare const OverlayMode: {
readonly Day: "day";
readonly Month: "month";
readonly Year: "year";
};
/**
* Type of values accepted by `CalendarOverlay`'s `overlayMode` property.
*
* @internal
*/
type TOverlayMode = (typeof OverlayMode)[keyof typeof OverlayMode];
/**
* Interface to store focus state of date/time inputs.
*
* @internal
*/
interface IFocusItem {
date: boolean;
time: boolean;
}
/**
* The Date component allows users to enter a date either through text input or by choosing from a calendar overlay. It
* provides an optional field to enter a time.
*
* ```html
*
*
*
*
*
*
*
*
*
*
*
* ```
*
* ### Import
*
* ```typescript
* import { DateComponent } from '@talenra/ngx-base/date';
* ```
*
* ../../#date
*/
declare class DateComponent extends FormFieldControlBaseComponent implements OnInit, AfterViewInit, ControlValueAccessor, FormFieldControl {
/**
* Function to filter dates in the calendar overlay.
*
* @see {@link DateFilterFn}
* @see {@link firstDayOfMonthFilter}
* @see {@link weekdaysFilter}
*
* ```html
*
* ```
*/
dateFilterFn?: DateFilterFn;
/**
* Determines whether the time input is shown.
*
* ```html
*
* ```
*/
showTime: boolean;
/**
* Label displayed for the time input (optional).
*
* ```html
*
* ```
*/
timeLabel: string;
/**
* Date the calendar overlay opens with if the control has no value.
*
* ```typescript
* protected calendarInitialDate = new Date('2020-06-30');
* ```
*
* ```html
*
* ```
*/
calendarInitialDate: _angular_core.InputSignal;
/**
* Mode the calendar overlay opens with if the control has no value.
*
* ```html
*
* ```
*
* @see {@link OverlayMode}
*/
calendarInitialMode: _angular_core.InputSignal;
/**
* Locale to dynamically overwrite the app's locale.
* Allowed values, see: Locale
*
* ```html
*
* ```
*
* @see {@link Locale}
* @see {@link TLocale}
*/
dynamicLocale: TLocale | null;
/**
* Determines whether the date is a birth date. Enforces the date to be today or in the past.
*
* ```html
*
* ```
*/
isBirthDate: boolean;
/**
* Determines whether the control is disabled/enabled.
*
* ```html
*
* ```
*/
get disabled(): boolean;
/** Set the control's disabled state. */
set disabled(value: boolean);
/** @internal */
_disabled: boolean;
/**
* Determines whether the control is read-only.
*
* ```html
*
* ```
*/
get readonly(): boolean;
/** Set the control's read-only state */
set readonly(value: boolean);
/** @internal */
_readonly: boolean;
/** Handle label, foucus etc. within the control, not in FormField */
hasControlContainer: boolean;
/** Stores focus state of the date/time inputs. */
protected itemHasFocus: IFocusItem;
/** Stores focus state of date/time inputs _and_ its children. */
protected itemHasFocusWithin: IFocusItem;
/** The date value of the control. */
private date;
/** Date string as it is displayed in the input field. */
protected dateString: string;
/** Time string as it is displayed in the input field. */
protected timeString: string;
/** Reference to the overlay used for the calendar. */
private overlayRef;
/** @internal */
inputDate: ElementRef;
/** @internal */
inputComponents: QueryList;
private get hostClass();
protected readonly injector: Injector;
private readonly appLocale;
private readonly overlay;
private readonly viewContainerRef;
private readonly dateInputPipe;
private readonly destroyRef;
/** @internal */
ngOnInit(): void;
/** @internal */
ngAfterViewInit(): void;
/** @internal */
registerOnChange(fn: never): void;
/** @internal */
registerOnTouched(fn: never): void;
/** @internal */
writeValue(date: Date | string): void;
/** @internal */
openCalendarOverlay(event: Event): void;
/** @internal */
overlayValueSelected(date: Date): void;
/** @internal */
timeChanged(timeString: string): void;
/** @internal */
dateChanged(dateString: string): void;
private parseDate;
private isValidDate;
/** Set the focus to the date input. */
focus(): void;
/** Determines whether clear button is visible. */
showClearButton(item: 'date' | 'time'): boolean;
/**
* Clear the value and focus the input element. Triggered by the clear button in ControlContainers.
*
* @internal
*/
clearValue(): void;
/**
* Handle focus events (focus, blur)
*
* @internal
*/
onFocusChange(event: FocusEvent): void;
/**
* Catch keydown event of spacebar. We need to prevent the default behaviour of spacebar's keydown event
* (scroll page down) as we want to open the calendar overlay on _keyup_.
*
* @internal
*/
onSpaceDown(event: Event): void;
/** @internal */
get isEmpty(): boolean;
/** Returns the locale actually used by the component (dynamic or app locale). */
get locale(): string;
private getDate;
private isDateStringWithTimezone;
private isSimpleDateString;
static ɵfac: _angular_core.ɵɵFactoryDeclaration;
static ɵcmp: _angular_core.ɵɵComponentDeclaration;
static ngAcceptInputType_showTime: unknown;
static ngAcceptInputType_isBirthDate: unknown;
static ngAcceptInputType_disabled: unknown;
static ngAcceptInputType_readonly: unknown;
}
/**
* Locale values that can be used to overwrite the current apps's locale.
*
* ```html
*
* ```
*
* ```typescript
* import { DateLocale, TDateLocale } from '@talenra/ngx-base/date';
* const locale: TDateLocale = DateLocale['fr-CH'];
* ```
*
* ### Import
*
* ```typescript
* import { DateLocale } from '@talenra/ngx-base/date';
* ```
*
* @see {@link DateComponent}
* @deprecated Use `Locale` from `@talenra/ngx-base/shared` instead.
*/
declare const DateLocale: {
readonly 'de-CH': "de-CH";
readonly 'fr-CH': "fr-CH";
readonly 'it-CH': "it-CH";
};
/**
* Type of locale values that can be used to overwrite the current apps's locale.
*
* ### Import
*
* ```typescript
* import { TDateLocale } from '@talenra/ngx-base/date';
* ```
*
* @see {@link DateComponent}
* @deprecated Use `TLocale` from `@talenra/ngx-base/shared` instead.
*/
type TDateLocale = (typeof DateLocale)[keyof typeof DateLocale];
export { DateComponent, DateLocale, dateInTheFutureFilter, dateInThePastFilter, firstDayOfMonthFilter, validateDate, validateDateIsInTheFuture, validateDateIsInThePast, validateStartDateIsBeforeEndDate, validateYearIsEqualOrGreater, weekdaysFilter };
export type { DateFilterFn, TDateLocale };