UNPKG

ngx-timeago

Version:

Live updating timestamps in Angular 6+.

170 lines (162 loc) 6.09 kB
import * as i0 from '@angular/core'; import { OnChanges, OnDestroy, ElementRef, ChangeDetectorRef, NgZone, PipeTransform, Provider, ModuleWithProviders } from '@angular/core'; import { Observable, Subject } from 'rxjs'; declare abstract class TimeagoClock { abstract tick(then: number): Observable<any>; } declare class TimeagoDefaultClock extends TimeagoClock { private platformId; constructor(platformId: Object); tick(then: number): Observable<any>; private browserTick; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoDefaultClock, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TimeagoDefaultClock>; } interface IL10nsStrings { prefixAgo?: StringOrFn; prefixFromNow?: StringOrFn; suffixAgo?: StringOrFn; suffixFromNow?: StringOrFn; second?: StringOrFn; seconds?: StringOrFn; minute?: StringOrFn; minutes?: StringOrFn; hour?: StringOrFn; hours?: StringOrFn; day?: StringOrFn; days?: StringOrFn; week?: StringOrFn; weeks?: StringOrFn; month?: StringOrFn; months?: StringOrFn; year?: StringOrFn; years?: StringOrFn; wordSeparator?: string; numbers?: NumberArray; } /** * To modify the text displayed, create a new instance of TimeagoIntl and * include it in a custom provider */ declare class TimeagoIntl { strings: IL10nsStrings; /** * Stream that emits whenever the l10n strings are changed * Use this to notify directives if the l10n strings have changed after initialization. */ readonly changes: Subject<void>; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoIntl, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TimeagoIntl>; } type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; type Suffix = 'ago' | 'from now'; type StringOrFn = ((value: number, millisDelta: number) => string) | string; type NumberArray = [ string, string, string, string, string, string, string, string, string, string ]; declare abstract class TimeagoFormatter { abstract format(then: number): string; } declare class TimeagoDefaultFormatter extends TimeagoFormatter { format(then: number): string; private parse; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoDefaultFormatter, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TimeagoDefaultFormatter>; } declare class TimeagoCustomFormatter extends TimeagoFormatter { private intl; constructor(intl: TimeagoIntl); format(then: number): string; private parse; /** * If the numbers array is present, format numbers with it, * otherwise just cast the number to a string and return it */ private normalizeNumber; /** * Take a string or a function that takes number of days and returns a string * and provide a uniform API to create string parts */ private normalizeFn; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoCustomFormatter, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TimeagoCustomFormatter>; } declare class TimeagoDirective implements OnChanges, OnDestroy { private cd; private clock; private ngZone; private intlSubscription; private clockSubscription; /** * Emits on: * - Input change * - Intl change * - Clock tick */ stateChanges: Subject<void>; /** The Date to display. An actual Date object or something that can be fed to new Date. */ get date(): any; set date(date: any); private _date; /** If the directive should update itself over time */ get live(): boolean; set live(live: boolean); private _live; constructor(intl: TimeagoIntl, formatter: TimeagoFormatter, element: ElementRef, cd: ChangeDetectorRef, clock: TimeagoClock, ngZone: NgZone); ngOnChanges(): void; setContent(node: any, content: string): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoDirective, [{ optional: true; }, null, null, null, null, null]>; static ɵdir: i0.ɵɵDirectiveDeclaration<TimeagoDirective, "[timeago]", ["timeago"], { "date": { "alias": "date"; "required": false; }; "live": { "alias": "live"; "required": false; }; }, {}, never, never, false, never>; } declare class TimeagoPipe implements PipeTransform, OnDestroy { private clock; private ngZone; private intlSubscription; private clockSubscription; private date; private value; private live; /** * Emits on: * - Input change * - Intl change * - Clock tick */ stateChanges: Subject<void>; constructor(intl: TimeagoIntl, cd: ChangeDetectorRef, formatter: TimeagoFormatter, clock: TimeagoClock, ngZone: NgZone); transform(date: any, ...args: any[]): string; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoPipe, [{ optional: true; }, null, null, null, null]>; static ɵpipe: i0.ɵɵPipeDeclaration<TimeagoPipe, "timeago", false>; static ɵprov: i0.ɵɵInjectableDeclaration<TimeagoPipe>; } interface TimeagoModuleConfig { clock?: Provider; intl?: Provider; formatter?: Provider; } declare class TimeagoModule { /** * Use this method in your root module to provide the TimeagoModule */ static forRoot(config?: TimeagoModuleConfig): ModuleWithProviders<TimeagoModule>; /** * Use this method in your other (non root) modules to import the directive/pipe */ static forChild(config?: TimeagoModuleConfig): ModuleWithProviders<TimeagoModule>; static ɵfac: i0.ɵɵFactoryDeclaration<TimeagoModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<TimeagoModule, [typeof TimeagoDirective, typeof TimeagoPipe], never, [typeof TimeagoDirective, typeof TimeagoPipe]>; static ɵinj: i0.ɵɵInjectorDeclaration<TimeagoModule>; } export { TimeagoClock, TimeagoCustomFormatter, TimeagoDefaultClock, TimeagoDefaultFormatter, TimeagoDirective, TimeagoFormatter, TimeagoIntl, TimeagoModule, TimeagoPipe }; export type { IL10nsStrings, NumberArray, StringOrFn, Suffix, TimeagoModuleConfig, Unit };