import { KbqTimeRangeModule } from '@koobiq/components/time-range';

KbqTimeRange

componentCopy link to KbqTimeRange
@Component({ selector: 'kbq-time-range' })
class KbqTimeRange<T> implements ControlValueAccessor {
    readonly minDate = input<T>();
    readonly maxDate = input<T>();
    readonly defaultRangeValue = input<KbqRangeValue<T>>();
    readonly availableTimeRangeTypes = input<KbqTimeRangeType[]>(
        this.timeRangeService.providedDefaultTimeRangeTypes
    );
    readonly titleTemplate = input<TemplateRef<KbqTimeRangeCustomizableTitleContext>>();
    readonly optionTemplate = input<TemplateRef<KbqTimeRangeOptionContext>>();
    readonly arrow = input<boolean>(true);
    readonly showRangeAsDefault = input<boolean>(true);
    readonly nonNullable = input<boolean>(true);
    readonly valueCorrected = output<KbqTimeRangeRange>();
    readonly value: Signal<KbqTimeRangeRange | null>;
    readonly disabled: Signal<boolean>;
    onVisibleChange(isVisible: boolean): void;
}
minDateinputCopy link to minDateT

The earliest date the calendars offer and the validation accepts.

maxDateinputCopy link to maxDateT

The latest date the calendars offer and the validation accepts.

defaultRangeValueinputCopy link to defaultRangeValueKbqRangeValue<T>

Seeds the from/to pair of the manual range.

availableTimeRangeTypesinputCopy link to availableTimeRangeTypesKbqTimeRangeType[]

The options the editor offers, in order. The first one is selected by default.

titleTemplateinputCopy link to titleTemplateTemplateRef<KbqTimeRangeCustomizableTitleContext>

Replaces the built-in trigger.

optionTemplateinputCopy link to optionTemplateTemplateRef<KbqTimeRangeOptionContext>

Replaces the built-in rendering of an option in the editor.

arrowinputCopy link to arrowboolean

Whether the popover is drawn with an arrow.

showRangeAsDefaultinputCopy link to showRangeAsDefaultboolean

Keeps the manual range visible even when range is not in availableTimeRangeTypes.

nonNullableinputCopy link to nonNullableboolean

Falls back to a default value instead of holding null.

localeOverridesinputCopy link to localeOverridesKbqPartialLocaleData | undefined

Localized strings for this element and its subtree, keyed by locale section. Every key is optional at every depth.

valueCorrectedoutputCopy link to valueCorrectedKbqTimeRangeRange

Emits the corrected value when the provided one could not be used as is.

valueCopy link to valueSignal<KbqTimeRangeRange | null>

The applied time range, or null when the component is nullable and holds no value.

This is what the trigger renders, so it lags the editor until Apply.

disabledCopy link to disabledSignal<boolean>

Whether the control is disabled through the forms layer.

KbqTimeRangeTitleAsControl

componentCopy link to KbqTimeRangeTitleAsControl

Component simulates KbqFormFieldControl allowing to provide custom content inside KbqFormField

@Component({ selector: 'kbq-time-range-title-as-control' })
class KbqTimeRangeTitleAsControl implements KbqFormFieldControl<KbqTimeRangeRange> {}

KbqTimeRangeTitlePlaceholder

directiveCopy link to KbqTimeRangeTitlePlaceholder

Directive for easy using styles of time-range placeholder publicly.

@Directive({ selector: '[kbqTimeRangeTitlePlaceholder]' })
class KbqTimeRangeTitlePlaceholder {}

KbqCustomTimeRangeType

typeCopy link to KbqCustomTimeRangeType
type KbqCustomTimeRangeType = {
    type: KbqTimeRangeType | string;
    units: KbqTimeRangeUnits;
    translationType: KbqTimeRangeTranslationType;
    range?: KbqRange;
};
typeCopy link to typeKbqTimeRangeType | string

time range identifier. Used as config key

translationTypeCopy link to translationTypeKbqTimeRangeTranslationType

Property representing duration output unit

rangeoptionalCopy link to rangeKbqRange

Custom range of start/end date-times

KbqRange

typeCopy link to KbqRange

Represents a time range with optional start and end date-time values. Used as a range value by default.

type KbqRange = {
    startDateTime?: string;
    endDateTime?: string;
};

KbqRangeValue

interfaceCopy link to KbqRangeValue

Represents a time range with optional start and end date-time values. Used as a form value when range in popover change.

interface KbqRangeValue<T> {
    fromTime?: T;
    fromDate?: T;
    toTime?: T;
    toDate?: T;
}

KbqTimeRangeCustomizableTitleContext

typeCopy link to KbqTimeRangeCustomizableTitleContext

Context for a time range trigger customization, combining meta information.

type KbqTimeRangeCustomizableTitleContext = Partial<KbqTimeRangeTitleContext> & {
    $implicit: Partial<KbqTimeRangeTitleContext> & { formattedDate: string; popover: KbqPopoverTrigger };
} & { formattedDate: string; popover: KbqPopoverTrigger };

KbqTimeRangeOptionContext

typeCopy link to KbqTimeRangeOptionContext

Context for a time range option customization, combining meta information.

type KbqTimeRangeOptionContext = KbqTimeRangeTypeContext & KbqTimeRangeUnits & {
    translationType: KbqTimeRangeTranslationType;
    formattedValue: string;
};

KbqTimeRangeRange

typeCopy link to KbqTimeRangeRange

Main range information. Used for a popover date range selection, when selected type is range, and for trigger information calculation.

type KbqTimeRangeRange = KbqRange & KbqTimeRangeTypeContext;

KbqTimeRangeTitleContext

typeCopy link to KbqTimeRangeTitleContext

Context for a time range trigger, combining range info and type.

type KbqTimeRangeTitleContext = KbqTimeRangeRange & KbqTimeRangeUnits;

KbqTimeRangeTranslationType

typeCopy link to KbqTimeRangeTranslationType

Property representing duration output unit

type KbqTimeRangeTranslationType = Exclude<DurationUnit, 'quarters' | 'milliseconds'> | 'other';

KbqTimeRangeType

typeCopy link to KbqTimeRangeType

Default accepted “time‑range” identifiers.

type KbqTimeRangeType = | 'lastMinute'
    | 'last5Minutes'
    | 'last15Minutes'
    | 'last30Minutes'
    | 'lastHour'
    | 'last24Hours'
    | 'last3Days'
    | 'last7Days'
    | 'last14Days'
    | 'last30Days'
    | 'last3Months'
    | 'last12Months'
    | 'allTime'
    | 'currentQuarter'
    | 'currentYear'
    | 'range';

KbqTimeRangeTypeContext

typeCopy link to KbqTimeRangeTypeContext

Range type selected

type KbqTimeRangeTypeContext = {
    type: KbqTimeRangeType;
};

KbqTimeRangeUnits

interfaceCopy link to KbqTimeRangeUnits

Configuration for a custom time range with duration metadata. Defines a time range with its identifier, duration units, and optional fixed date range.

interface KbqTimeRangeUnits extends DurationObjectUnits {
    years?: number;
    quarters?: number;
    months?: number;
    weeks?: number;
    days?: number;
    hours?: number;
    minutes?: number;
    seconds?: number;
    milliseconds?: number;
}

defaultTimeRangeTypes

constCopy link to defaultTimeRangeTypes

Time range types in range editor if nothing provided

const defaultTimeRangeTypes: KbqTimeRangeType[];

KBQ_CUSTOM_TIME_RANGE_TYPES

constCopy link to KBQ_CUSTOM_TIME_RANGE_TYPES

Preset of custom time ranges, provided by DI.

const KBQ_CUSTOM_TIME_RANGE_TYPES: InjectionToken<KbqCustomTimeRangeType[]>;

KBQ_DEFAULT_TIME_RANGE_TYPES

constCopy link to KBQ_DEFAULT_TIME_RANGE_TYPES

Preset of selectable time ranges, provided by DI.

const KBQ_DEFAULT_TIME_RANGE_TYPES: InjectionToken<KbqTimeRangeType[]>;

KBQ_TIME_RANGE_LOCALE_CONFIGURATION

constCopy link to KBQ_TIME_RANGE_LOCALE_CONFIGURATION

Localization configuration provider.

const KBQ_TIME_RANGE_LOCALE_CONFIGURATION: InjectionToken<KbqTimeRangeLocaleConfiguration>;

kbqTimeRangeLocaleConfigurationProvider

constCopy link to kbqTimeRangeLocaleConfigurationProvider

Utility provider for KBQ_TIME_RANGE_LOCALE_CONFIGURATION. Only the strings you pass are overridden; the rest keep following the active locale.

const kbqTimeRangeLocaleConfigurationProvider: (
    configuration: KbqDeepPartial<KbqTimeRangeLocaleConfiguration>
) => Provider;

rangeValidator

constCopy link to rangeValidator

Validates that the 'from' date-time is not greater than the 'to' date-time in a range form. Returns an error if the start date-time occurs after the end date-time.

const rangeValidator: <T>(
    timeRangeService: KbqTimeRangeService<T>
) => ValidatorFn;
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.