import { KbqDatetimeModule } from '@koobiq/components/datetime';

KbqDatetime

componentCopy link to KbqDatetime

A date and a time in one form field: a date input with a calendar and a time input that share one value.

The value is a date of the date adapter, and it is null until both parts are filled in.

@Component({ selector: 'kbq-datetime', exportAs: 'kbqDatetime' })
class KbqDatetime<D> implements KbqFormFieldControl<D>, ControlValueAccessor, Validator {
    readonly errorStateMatcher = input<ErrorStateMatcher>();
    readonly required = input<boolean>(false);
    readonly id = input<string | undefined>();
    readonly disabled = input<boolean>(false);
    readonly format = input<TimeFormats>(DEFAULT_TIME_FORMAT);
    readonly min = input<D | null>(null);
    readonly max = input<D | null>(null);
    readonly value: Signal<D | null>;
    readonly datepicker: Signal<KbqDatepicker<D>>;
    focus(options?: FocusOptions): void;
    open(): void;
    close(): void;
}
errorStateMatcherinputCopy link to errorStateMatcherErrorStateMatcher

Object used to control when error messages are shown.

requiredinputCopy link to requiredboolean

Whether the control is required. Defaults to false.

idinputCopy link to idstring | undefined

Unique id of the element, generated when not provided.

disabledinputCopy link to disabledboolean

Whether the control is disabled. Also set by the bound form control. Defaults to false.

formatinputCopy link to formatTimeFormats

Time format the time part parses and renders. Defaults to TimeFormats.HHmm.

mininputCopy link to minD | null

Earliest date and time the control accepts, reported as kbqDatetimeMin. The calendar disables the days before it. Defaults to null.

maxinputCopy link to maxD | null

Latest date and time the control accepts, reported as kbqDatetimeMax. The calendar disables the days after it. Defaults to null.

valueCopy link to valueSignal<D | null>

The date and time the control holds, null until both parts are filled in.

datepickerCopy link to datepickerSignal<KbqDatepicker<D>>

The calendar of the date part, for a kbq-datepicker-toggle-icon placed in the form field.

focus()Copy link to focus()void

Focuses the first part left empty, the date part when there is none.

open()Copy link to open()void

Opens the calendar.

close()Copy link to close()void

Closes the calendar.

KBQ_DATETIME_MAX_ERROR

constCopy link to KBQ_DATETIME_MAX_ERROR

Key of the error KbqDatetime reports for a value after its max.

const KBQ_DATETIME_MAX_ERROR: string;

KBQ_DATETIME_MIN_ERROR

constCopy link to KBQ_DATETIME_MIN_ERROR

Key of the error KbqDatetime reports for a value before its min.

const KBQ_DATETIME_MIN_ERROR: string;

KBQ_DATETIME_PARSE_ERROR

constCopy link to KBQ_DATETIME_PARSE_ERROR

Key of the error KbqDatetime reports for a text that is not a date and time, or for a single part filled in.

const KBQ_DATETIME_PARSE_ERROR: string;
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.