UNPKG

@haiilo/ngx-intl

Version:

Standalone Angular pipes using the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting.

62 lines (61 loc) 2.54 kB
import { ChangeDetectorRef, InjectionToken, NgZone, OnDestroy, PipeTransform } from '@angular/core'; import { IntlDateGlobalOptions, IntlDateLocalOptions } from './intl-date.pipe'; import * as i0 from "@angular/core"; /** A preconfigured option preset for the IntlTimeagoPipe. */ export interface IntlTimeagoOptions extends Intl.RelativeTimeFormatOptions { reference?: Date | number; units?: Intl.RelativeTimeFormatUnit[]; now?: string; minRelative?: number; maxRelative?: number; dateOptions?: string | IntlDateLocalOptions; } /** Global options and presets for the IntlTimeagoPipe. */ export interface IntlTimeagoGlobalOptions { presets?: { [key: string]: IntlTimeagoOptions; }; defaultPreset?: string; units?: Intl.RelativeTimeFormatUnit[]; now?: string; minRelative?: number; maxRelative?: number; dateOptions?: string | IntlDateLocalOptions; } /** Options for a transform call of the IntlTimeagoPipe. */ export interface IntlTimeagoLocalOptions extends IntlTimeagoOptions { preset?: string; } export declare const INTL_TIMEAGO_OPTIONS: InjectionToken<IntlTimeagoGlobalOptions>; export declare const INTL_TIMEAGO_PRESET_SHORT: IntlTimeagoOptions; export declare const INTL_TIMEAGO_PRESET_LONG: IntlTimeagoOptions; /** * A pipe that formats a date value to a human-readable relative-timeago string * using the Intl.RelativeTimeFormat API. */ export declare class IntlTimeagoPipe implements PipeTransform, OnDestroy { private cdRef; private ngZone; private readonly locale; private readonly options; private readonly intlDatePipe; private static readonly DEFAULT_OPTIONS; private lastValue?; private lastOptions?; private lastLocales; private text; private timer?; private update?; constructor(cdRef: ChangeDetectorRef, ngZone: NgZone, locale: string, options: IntlTimeagoGlobalOptions | null, dateOptions: IntlDateGlobalOptions | null, dateTimezone: string | null); ngOnDestroy(): void; transform(value?: Date | string | number | null, options?: string | IntlTimeagoLocalOptions, ...locales: string[]): string | null; private process; private getUnit; private getDiff; private getLocales; private getOptions; private createTimer; private removeTimer; static ɵfac: i0.ɵɵFactoryDeclaration<IntlTimeagoPipe, [null, null, null, { optional: true; }, { optional: true; }, { optional: true; }]>; static ɵpipe: i0.ɵɵPipeDeclaration<IntlTimeagoPipe, "intlTimeago", true>; }