UNPKG

@angular/common

Version:

Angular - commonly needed directives and services

1,317 lines (1,300 loc) 138 kB
/** * @license Angular v19.2.3 * (c) 2010-2025 Google LLC. https://angular.io/ * License: MIT */ import * as i0 from '@angular/core'; import { ɵNavigation as _Navigation, ɵNavigationHistoryEntry as _NavigationHistoryEntry, ɵNavigationUpdateCurrentEntryOptions as _NavigationUpdateCurrentEntryOptions, ɵNavigationTransition as _NavigationTransition, ɵNavigationNavigateOptions as _NavigationNavigateOptions, ɵNavigationResult as _NavigationResult, ɵNavigationReloadOptions as _NavigationReloadOptions, ɵNavigationOptions as _NavigationOptions, ɵNavigateEvent as _NavigateEvent, ɵNavigationCurrentEntryChangeEvent as _NavigationCurrentEntryChangeEvent, InjectionToken, OnDestroy, DoCheck, ElementRef, Renderer2, OnChanges, Type, Injector, NgModuleFactory, ViewContainerRef, SimpleChanges, NgIterable, TrackByFunction, TemplateRef, IterableDiffers, KeyValueDiffers, PipeTransform, ChangeDetectorRef, Version, Provider, OnInit } from '@angular/core'; export { ɵIMAGE_CONFIG as IMAGE_CONFIG, ɵImageConfig as ImageConfig } from '@angular/core'; import { SubscriptionLike, Observable, Subscribable } from 'rxjs'; declare function getDOM(): DomAdapter; declare function setRootDomAdapter(adapter: DomAdapter): void; /** * Provides DOM operations in an environment-agnostic way. * * @security Tread carefully! Interacting with the DOM directly is dangerous and * can introduce XSS risks. */ declare abstract class DomAdapter { abstract dispatchEvent(el: any, evt: any): any; abstract readonly supportsDOMEvents: boolean; abstract remove(el: any): void; abstract createElement(tagName: any, doc?: any): HTMLElement; abstract createHtmlDocument(): Document; abstract getDefaultDocument(): Document; abstract isElementNode(node: any): boolean; abstract isShadowRoot(node: any): boolean; abstract onAndCancel(el: any, evt: any, listener: any, options?: any): Function; abstract getGlobalEventTarget(doc: Document, target: string): any; abstract getBaseHref(doc: Document): string | null; abstract resetBaseElement(): void; abstract getUserAgent(): string; abstract getCookie(name: string): string | null; } /** * This class wraps the platform Navigation API which allows server-specific and test * implementations. */ declare abstract class PlatformNavigation implements _Navigation { abstract entries(): _NavigationHistoryEntry[]; abstract currentEntry: _NavigationHistoryEntry | null; abstract updateCurrentEntry(options: _NavigationUpdateCurrentEntryOptions): void; abstract transition: _NavigationTransition | null; abstract canGoBack: boolean; abstract canGoForward: boolean; abstract navigate(url: string, options?: _NavigationNavigateOptions | undefined): _NavigationResult; abstract reload(options?: _NavigationReloadOptions | undefined): _NavigationResult; abstract traverseTo(key: string, options?: _NavigationOptions | undefined): _NavigationResult; abstract back(options?: _NavigationOptions | undefined): _NavigationResult; abstract forward(options?: _NavigationOptions | undefined): _NavigationResult; abstract onnavigate: ((this: _Navigation, ev: _NavigateEvent) => any) | null; abstract onnavigatesuccess: ((this: _Navigation, ev: Event) => any) | null; abstract onnavigateerror: ((this: _Navigation, ev: ErrorEvent) => any) | null; abstract oncurrententrychange: ((this: _Navigation, ev: _NavigationCurrentEntryChangeEvent) => any) | null; abstract addEventListener(type: unknown, listener: unknown, options?: unknown): void; abstract removeEventListener(type: unknown, listener: unknown, options?: unknown): void; abstract dispatchEvent(event: Event): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<PlatformNavigation, never>; static ɵprov: i0.ɵɵInjectableDeclaration<PlatformNavigation>; } /** * This class should not be used directly by an application developer. Instead, use * {@link Location}. * * `PlatformLocation` encapsulates all calls to DOM APIs, which allows the Router to be * platform-agnostic. * This means that we can have different implementation of `PlatformLocation` for the different * platforms that Angular supports. For example, `@angular/platform-browser` provides an * implementation specific to the browser environment, while `@angular/platform-server` provides * one suitable for use with server-side rendering. * * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy} * when they need to interact with the DOM APIs like pushState, popState, etc. * * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly * by the {@link /api/router/Router Router} in order to navigate between routes. Since all interactions between * {@link /api/router/Router Router} / * {@link Location} / {@link LocationStrategy} and DOM APIs flow through the `PlatformLocation` * class, they are all platform-agnostic. * * @publicApi */ declare abstract class PlatformLocation { abstract getBaseHrefFromDOM(): string; abstract getState(): unknown; /** * Returns a function that, when executed, removes the `popstate` event handler. */ abstract onPopState(fn: LocationChangeListener): VoidFunction; /** * Returns a function that, when executed, removes the `hashchange` event handler. */ abstract onHashChange(fn: LocationChangeListener): VoidFunction; abstract get href(): string; abstract get protocol(): string; abstract get hostname(): string; abstract get port(): string; abstract get pathname(): string; abstract get search(): string; abstract get hash(): string; abstract replaceState(state: any, title: string, url: string): void; abstract pushState(state: any, title: string, url: string): void; abstract forward(): void; abstract back(): void; historyGo?(relativePosition: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<PlatformLocation, never>; static ɵprov: i0.ɵɵInjectableDeclaration<PlatformLocation>; } /** * @description * Indicates when a location is initialized. * * @publicApi */ declare const LOCATION_INITIALIZED: InjectionToken<Promise<any>>; /** * @description * A serializable version of the event from `onPopState` or `onHashChange` * * @publicApi */ interface LocationChangeEvent { type: string; state: any; } /** * @publicApi */ interface LocationChangeListener { (event: LocationChangeEvent): any; } /** * `PlatformLocation` encapsulates all of the direct calls to platform APIs. * This class should not be used directly by an application developer. Instead, use * {@link Location}. * * @publicApi */ declare class BrowserPlatformLocation extends PlatformLocation { private _location; private _history; private _doc; constructor(); getBaseHrefFromDOM(): string; onPopState(fn: LocationChangeListener): VoidFunction; onHashChange(fn: LocationChangeListener): VoidFunction; get href(): string; get protocol(): string; get hostname(): string; get port(): string; get pathname(): string; get search(): string; get hash(): string; set pathname(newPath: string); pushState(state: any, title: string, url: string): void; replaceState(state: any, title: string, url: string): void; forward(): void; back(): void; historyGo(relativePosition?: number): void; getState(): unknown; static ɵfac: i0.ɵɵFactoryDeclaration<BrowserPlatformLocation, never>; static ɵprov: i0.ɵɵInjectableDeclaration<BrowserPlatformLocation>; } /** * Enables the `Location` service to read route state from the browser's URL. * Angular provides two strategies: * `HashLocationStrategy` and `PathLocationStrategy`. * * Applications should use the `Router` or `Location` services to * interact with application route state. * * For instance, `HashLocationStrategy` produces URLs like * <code class="no-auto-link">http://example.com/#/foo</code>, * and `PathLocationStrategy` produces * <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL. * * See these two classes for more. * * @publicApi */ declare abstract class LocationStrategy { abstract path(includeHash?: boolean): string; abstract prepareExternalUrl(internal: string): string; abstract getState(): unknown; abstract pushState(state: any, title: string, url: string, queryParams: string): void; abstract replaceState(state: any, title: string, url: string, queryParams: string): void; abstract forward(): void; abstract back(): void; historyGo?(relativePosition: number): void; abstract onPopState(fn: LocationChangeListener): void; abstract getBaseHref(): string; static ɵfac: i0.ɵɵFactoryDeclaration<LocationStrategy, never>; static ɵprov: i0.ɵɵInjectableDeclaration<LocationStrategy>; } /** * A predefined DI token for the base href * to be used with the `PathLocationStrategy`. * The base href is the URL prefix that should be preserved when generating * and recognizing URLs. * * @usageNotes * * The following example shows how to use this token to configure the root app injector * with a base href value, so that the DI framework can supply the dependency anywhere in the app. * * ```ts * import {NgModule} from '@angular/core'; * import {APP_BASE_HREF} from '@angular/common'; * * @NgModule({ * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}] * }) * class AppModule {} * ``` * * @publicApi */ declare const APP_BASE_HREF: InjectionToken<string>; /** * @description * A {@link LocationStrategy} used to configure the {@link Location} service to * represent its state in the * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the * browser's URL. * * If you're using `PathLocationStrategy`, you may provide a {@link APP_BASE_HREF} * or add a `<base href>` element to the document to override the default. * * For instance, if you provide an `APP_BASE_HREF` of `'/my/app/'` and call * `location.go('/foo')`, the browser's URL will become * `example.com/my/app/foo`. To ensure all relative URIs resolve correctly, * the `<base href>` and/or `APP_BASE_HREF` should end with a `/`. * * Similarly, if you add `<base href='/my/app/'/>` to the document and call * `location.go('/foo')`, the browser's URL will become * `example.com/my/app/foo`. * * Note that when using `PathLocationStrategy`, neither the query nor * the fragment in the `<base href>` will be preserved, as outlined * by the [RFC](https://tools.ietf.org/html/rfc3986#section-5.2.2). * * @usageNotes * * ### Example * * {@example common/location/ts/path_location_component.ts region='LocationComponent'} * * @publicApi */ declare class PathLocationStrategy extends LocationStrategy implements OnDestroy { private _platformLocation; private _baseHref; private _removeListenerFns; constructor(_platformLocation: PlatformLocation, href?: string); /** @nodoc */ ngOnDestroy(): void; onPopState(fn: LocationChangeListener): void; getBaseHref(): string; prepareExternalUrl(internal: string): string; path(includeHash?: boolean): string; pushState(state: any, title: string, url: string, queryParams: string): void; replaceState(state: any, title: string, url: string, queryParams: string): void; forward(): void; back(): void; getState(): unknown; historyGo(relativePosition?: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<PathLocationStrategy, [null, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<PathLocationStrategy>; } /** * @description * A {@link LocationStrategy} used to configure the {@link Location} service to * represent its state in the * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) * of the browser's URL. * * For instance, if you call `location.go('/foo')`, the browser's URL will become * `example.com#/foo`. * * @usageNotes * * ### Example * * {@example common/location/ts/hash_location_component.ts region='LocationComponent'} * * @publicApi */ declare class HashLocationStrategy extends LocationStrategy implements OnDestroy { private _platformLocation; private _baseHref; private _removeListenerFns; constructor(_platformLocation: PlatformLocation, _baseHref?: string); /** @nodoc */ ngOnDestroy(): void; onPopState(fn: LocationChangeListener): void; getBaseHref(): string; path(includeHash?: boolean): string; prepareExternalUrl(internal: string): string; pushState(state: any, title: string, path: string, queryParams: string): void; replaceState(state: any, title: string, path: string, queryParams: string): void; forward(): void; back(): void; getState(): unknown; historyGo(relativePosition?: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<HashLocationStrategy, [null, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<HashLocationStrategy>; } /** @publicApi */ interface PopStateEvent { pop?: boolean; state?: any; type?: string; url?: string; } /** * @description * * A service that applications can use to interact with a browser's URL. * * Depending on the `LocationStrategy` used, `Location` persists * to the URL's path or the URL's hash segment. * * @usageNotes * * It's better to use the `Router.navigate()` service to trigger route changes. Use * `Location` only if you need to interact with or create normalized URLs outside of * routing. * * `Location` is responsible for normalizing the URL against the application's base href. * A normalized URL is absolute from the URL host, includes the application's base href, and has no * trailing slash: * - `/my/app/user/123` is normalized * - `my/app/user/123` **is not** normalized * - `/my/app/user/123/` **is not** normalized * * ### Example * * {@example common/location/ts/path_location_component.ts region='LocationComponent'} * * @publicApi */ declare class Location implements OnDestroy { constructor(locationStrategy: LocationStrategy); /** @nodoc */ ngOnDestroy(): void; /** * Normalizes the URL path for this location. * * @param includeHash True to include an anchor fragment in the path. * * @returns The normalized URL path. */ path(includeHash?: boolean): string; /** * Reports the current state of the location history. * @returns The current value of the `history.state` object. */ getState(): unknown; /** * Normalizes the given path and compares to the current normalized path. * * @param path The given URL path. * @param query Query parameters. * * @returns True if the given URL path is equal to the current normalized path, false * otherwise. */ isCurrentPathEqualTo(path: string, query?: string): boolean; /** * Normalizes a URL path by stripping any trailing slashes. * * @param url String representing a URL. * * @returns The normalized URL string. */ normalize(url: string): string; /** * Normalizes an external URL path. * If the given URL doesn't begin with a leading slash (`'/'`), adds one * before normalizing. Adds a hash if `HashLocationStrategy` is * in use, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use. * * @param url String representing a URL. * * @returns A normalized platform-specific URL. */ prepareExternalUrl(url: string): string; /** * Changes the browser's URL to a normalized version of a given URL, and pushes a * new item onto the platform's history. * * @param path URL path to normalize. * @param query Query parameters. * @param state Location history state. * */ go(path: string, query?: string, state?: any): void; /** * Changes the browser's URL to a normalized version of the given URL, and replaces * the top item on the platform's history stack. * * @param path URL path to normalize. * @param query Query parameters. * @param state Location history state. */ replaceState(path: string, query?: string, state?: any): void; /** * Navigates forward in the platform's history. */ forward(): void; /** * Navigates back in the platform's history. */ back(): void; /** * Navigate to a specific page from session history, identified by its relative position to the * current page. * * @param relativePosition Position of the target page in the history relative to the current * page. * A negative value moves backwards, a positive value moves forwards, e.g. `location.historyGo(2)` * moves forward two pages and `location.historyGo(-2)` moves back two pages. When we try to go * beyond what's stored in the history session, we stay in the current page. Same behaviour occurs * when `relativePosition` equals 0. * @see https://developer.mozilla.org/en-US/docs/Web/API/History_API#Moving_to_a_specific_point_in_history */ historyGo(relativePosition?: number): void; /** * Registers a URL change listener. Use to catch updates performed by the Angular * framework that are not detectible through "popstate" or "hashchange" events. * * @param fn The change handler function, which take a URL and a location history state. * @returns A function that, when executed, unregisters a URL change listener. */ onUrlChange(fn: (url: string, state: unknown) => void): VoidFunction; /** * Subscribes to the platform's `popState` events. * * Note: `Location.go()` does not trigger the `popState` event in the browser. Use * `Location.onUrlChange()` to subscribe to URL changes instead. * * @param value Event that is triggered when the state history changes. * @param exception The exception to throw. * * @see [onpopstate](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate) * * @returns Subscribed events. */ subscribe(onNext: (value: PopStateEvent) => void, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike; /** * Normalizes URL parameters by prepending with `?` if needed. * * @param params String of URL parameters. * * @returns The normalized URL parameters string. */ static normalizeQueryParams: (params: string) => string; /** * Joins two parts of a URL with a slash if needed. * * @param start URL string * @param end URL string * * * @returns The joined URL string. */ static joinWithSlash: (start: string, end: string) => string; /** * Removes a trailing slash from a URL string if needed. * Looks for the first occurrence of either `#`, `?`, or the end of the * line as `/` characters and removes the trailing slash if one exists. * * @param url URL string. * * @returns The URL string, modified if needed. */ static stripTrailingSlash: (url: string) => string; static ɵfac: i0.ɵɵFactoryDeclaration<Location, never>; static ɵprov: i0.ɵɵInjectableDeclaration<Location>; } /** * @ngModule CommonModule * @description * * Formats a date according to locale rules. * * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch) * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime). * @param format The date-time components to include. See `DatePipe` for details. * @param locale A locale code for the locale format rules to use. * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`). * If not specified, uses host system settings. * * @returns The formatted date string. * * @see {@link DatePipe} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi */ declare function formatDate(value: string | number | Date, format: string, locale: string, timezone?: string): string; /** * @ngModule CommonModule * @description * * Formats a number as currency using locale rules. * * @param value The number to format. * @param locale A locale code for the locale format rules to use. * @param currency A string containing the currency symbol or its name, * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation * of the function. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) * currency code, such as `USD` for the US dollar and `EUR` for the euro. * Used to determine the number of digits in the decimal part. * @param digitsInfo Decimal representation options, specified by a string in the following format: * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. * * @returns The formatted currency value. * * @see {@link formatNumber} * @see {@link DecimalPipe} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi */ declare function formatCurrency(value: number, locale: string, currency: string, currencyCode?: string, digitsInfo?: string): string; /** * @ngModule CommonModule * @description * * Formats a number as a percentage according to locale rules. * * @param value The number to format. * @param locale A locale code for the locale format rules to use. * @param digitsInfo Decimal representation options, specified by a string in the following format: * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. * * @returns The formatted percentage value. * * @see {@link formatNumber} * @see {@link DecimalPipe} * @see [Internationalization (i18n) Guide](guide/i18n) * @publicApi * */ declare function formatPercent(value: number, locale: string, digitsInfo?: string): string; /** * @ngModule CommonModule * @description * * Formats a number as text, with group sizing, separator, and other * parameters based on the locale. * * @param value The number to format. * @param locale A locale code for the locale format rules to use. * @param digitsInfo Decimal representation options, specified by a string in the following format: * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. * * @returns The formatted text string. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi */ declare function formatNumber(value: number, locale: string, digitsInfo?: string): string; /** * @publicApi */ declare abstract class NgLocalization { abstract getPluralCategory(value: any, locale?: string): string; static ɵfac: i0.ɵɵFactoryDeclaration<NgLocalization, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NgLocalization>; } /** * Returns the plural case based on the locale * * @publicApi */ declare class NgLocaleLocalization extends NgLocalization { protected locale: string; constructor(locale: string); getPluralCategory(value: any, locale?: string): string; static ɵfac: i0.ɵɵFactoryDeclaration<NgLocaleLocalization, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NgLocaleLocalization>; } /** * Register global data to be used internally by Angular. See the * ["I18n guide"](guide/i18n/format-data-locale) to know how to import additional locale * data. * * The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1 * * @publicApi */ declare function registerLocaleData(data: any, localeId?: string | any, extraData?: any): void; /** * Format styles that can be used to represent numbers. * @see {@link getLocaleNumberFormat} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated `getLocaleNumberFormat` is deprecated */ declare enum NumberFormatStyle { Decimal = 0, Percent = 1, Currency = 2, Scientific = 3 } /** * Plurality cases used for translating plurals to different languages. * * @see {@link NgPlural} * @see {@link NgPluralCase} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated `getLocalePluralCase` is deprecated */ declare enum Plural { Zero = 0, One = 1, Two = 2, Few = 3, Many = 4, Other = 5 } /** * Context-dependant translation forms for strings. * Typically the standalone version is for the nominative form of the word, * and the format version is used for the genitive case. * @see [CLDR website](http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles) * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated locale data getters are deprecated */ declare enum FormStyle { Format = 0, Standalone = 1 } /** * String widths available for translations. * The specific character widths are locale-specific. * Examples are given for the word "Sunday" in English. * * @publicApi * * @deprecated locale data getters are deprecated */ declare enum TranslationWidth { /** 1 character for `en-US`. For example: 'S' */ Narrow = 0, /** 3 characters for `en-US`. For example: 'Sun' */ Abbreviated = 1, /** Full length for `en-US`. For example: "Sunday" */ Wide = 2, /** 2 characters for `en-US`, For example: "Su" */ Short = 3 } /** * String widths available for date-time formats. * The specific character widths are locale-specific. * Examples are given for `en-US`. * * @see {@link getLocaleDateFormat} * @see {@link getLocaleTimeFormat} * @see {@link getLocaleDateTimeFormat} * @see [Internationalization (i18n) Guide](guide/i18n) * @publicApi * * @deprecated Date locale data getters are deprecated */ declare enum FormatWidth { /** * For `en-US`, `'M/d/yy, h:mm a'` * (Example: `6/15/15, 9:03 AM`) */ Short = 0, /** * For `en-US`, `'MMM d, y, h:mm:ss a'` * (Example: `Jun 15, 2015, 9:03:01 AM`) */ Medium = 1, /** * For `en-US`, `'MMMM d, y, h:mm:ss a z'` * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`) */ Long = 2, /** * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'` * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`) */ Full = 3 } /** * Symbols that can be used to replace placeholders in number patterns. * Examples are based on `en-US` values. * * @see {@link getLocaleNumberSymbol} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated `getLocaleNumberSymbol` is deprecated * * @object-literal-as-enum */ declare const NumberSymbol: { /** * Decimal separator. * For `en-US`, the dot character. * Example: 2,345`.`67 */ readonly Decimal: 0; /** * Grouping separator, typically for thousands. * For `en-US`, the comma character. * Example: 2`,`345.67 */ readonly Group: 1; /** * List-item separator. * Example: "one, two, and three" */ readonly List: 2; /** * Sign for percentage (out of 100). * Example: 23.4% */ readonly PercentSign: 3; /** * Sign for positive numbers. * Example: +23 */ readonly PlusSign: 4; /** * Sign for negative numbers. * Example: -23 */ readonly MinusSign: 5; /** * Computer notation for exponential value (n times a power of 10). * Example: 1.2E3 */ readonly Exponential: 6; /** * Human-readable format of exponential. * Example: 1.2x103 */ readonly SuperscriptingExponent: 7; /** * Sign for permille (out of 1000). * Example: 23.4‰ */ readonly PerMille: 8; /** * Infinity, can be used with plus and minus. * Example: ∞, +∞, -∞ */ readonly Infinity: 9; /** * Not a number. * Example: NaN */ readonly NaN: 10; /** * Symbol used between time units. * Example: 10:52 */ readonly TimeSeparator: 11; /** * Decimal separator for currency values (fallback to `Decimal`). * Example: $2,345.67 */ readonly CurrencyDecimal: 12; /** * Group separator for currency values (fallback to `Group`). * Example: $2,345.67 */ readonly CurrencyGroup: 13; }; type NumberSymbol = (typeof NumberSymbol)[keyof typeof NumberSymbol]; /** * The value for each day of the week, based on the `en-US` locale * * @publicApi * * @deprecated Week locale getters are deprecated */ declare enum WeekDay { Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6 } /** * Retrieves the locale ID from the currently loaded locale. * The loaded locale could be, for example, a global one rather than a regional one. * @param locale A locale code, such as `fr-FR`. * @returns The locale code. For example, `fr`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * This function serves no purpose when relying on the `Intl` API. */ declare function getLocaleId(locale: string): string; /** * Retrieves day period strings for the given locale. * * @param locale A locale code for the locale format rules to use. * @param formStyle The required grammatical form. * @param width The required character width. * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleDayPeriods(locale: string, formStyle: FormStyle, width: TranslationWidth): Readonly<[string, string]>; /** * Retrieves days of the week for the given locale, using the Gregorian calendar. * * @param locale A locale code for the locale format rules to use. * @param formStyle The required grammatical form. * @param width The required character width. * @returns An array of localized name strings. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleDayNames(locale: string, formStyle: FormStyle, width: TranslationWidth): ReadonlyArray<string>; /** * Retrieves months of the year for the given locale, using the Gregorian calendar. * * @param locale A locale code for the locale format rules to use. * @param formStyle The required grammatical form. * @param width The required character width. * @returns An array of localized name strings. * For example, `[January, February, ...]` for `en-US`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleMonthNames(locale: string, formStyle: FormStyle, width: TranslationWidth): ReadonlyArray<string>; /** * Retrieves Gregorian-calendar eras for the given locale. * @param locale A locale code for the locale format rules to use. * @param width The required character width. * @returns An array of localized era strings. * For example, `[AD, BC]` for `en-US`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleEraNames(locale: string, width: TranslationWidth): Readonly<[string, string]>; /** * Retrieves the first day of the week for the given locale. * * @param locale A locale code for the locale format rules to use. * @returns A day index number, using the 0-based week-day index for `en-US` * (Sunday = 0, Monday = 1, ...). * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17). * You may want to rely on the following alternatives: * - Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (monday) if `getWeekInfo` is not supported. * - Other librairies like [`date-fns`](https://date-fns.org/), [`day.js`](https://day.js.org/en/) or [`weekstart`](https://www.npmjs.com/package/weekstart) library provide their own locale based data for the first day of the week. */ declare function getLocaleFirstDayOfWeek(locale: string): WeekDay; /** * Range of week days that are considered the week-end for the given locale. * * @param locale A locale code for the locale format rules to use. * @returns The range of day values, `[startDay, endDay]`. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17). * Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (Saturday+Sunday) if `getWeekInfo` is not supported . */ declare function getLocaleWeekEndRange(locale: string): [WeekDay, WeekDay]; /** * Retrieves a localized date-value formatting string. * * @param locale A locale code for the locale format rules to use. * @param width The format type. * @returns The localized formatting string. * @see {@link FormatWidth} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleDateFormat(locale: string, width: FormatWidth): string; /** * Retrieves a localized time-value formatting string. * * @param locale A locale code for the locale format rules to use. * @param width The format type. * @returns The localized formatting string. * @see {@link FormatWidth} * @see [Internationalization (i18n) Guide](guide/i18n) * @publicApi * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleTimeFormat(locale: string, width: FormatWidth): string; /** * Retrieves a localized date-time formatting string. * * @param locale A locale code for the locale format rules to use. * @param width The format type. * @returns The localized formatting string. * @see {@link FormatWidth} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.DateTimeFormat` for date formating instead. */ declare function getLocaleDateTimeFormat(locale: string, width: FormatWidth): string; /** * Retrieves a localized number symbol that can be used to replace placeholders in number formats. * @param locale The locale code. * @param symbol The symbol to localize. Must be one of `NumberSymbol`. * @returns The character for the localized symbol. * @see {@link NumberSymbol} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.NumberFormat` to format numbers instead. */ declare function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): string; /** * Retrieves a number format for a given locale. * * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00` * when used to format the number 12345.678 could result in "12'345,678". That would happen if the * grouping separator for your language is an apostrophe, and the decimal separator is a comma. * * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders * that stand for the decimal separator, and so on, and are NOT real characters. * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in * your language the decimal point is written with a comma. The symbols should be replaced by the * local equivalents, using the appropriate `NumberSymbol` for your language. * * Here are the special characters used in number patterns: * * | Symbol | Meaning | * |--------|---------| * | . | Replaced automatically by the character used for the decimal point. | * | , | Replaced by the "grouping" (thousands) separator. | * | 0 | Replaced by a digit (or zero if there aren't enough digits). | * | # | Replaced by a digit (or nothing if there aren't enough). | * | ¤ | Replaced by a currency symbol, such as $ or USD. | * | % | Marks a percent format. The % symbol may change position, but must be retained. | * | E | Marks a scientific format. The E symbol may change position, but must be retained. | * | ' | Special characters used as literal characters are quoted with ASCII single quotes. | * * @param locale A locale code for the locale format rules to use. * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.) * @returns The localized format string. * @see {@link NumberFormatStyle} * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns) * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Let `Intl.NumberFormat` determine the number format instead */ declare function getLocaleNumberFormat(locale: string, type: NumberFormatStyle): string; /** * Retrieves the symbol used to represent the currency for the main country * corresponding to a given locale. For example, '$' for `en-US`. * * @param locale A locale code for the locale format rules to use. * @returns The localized symbol character, * or `null` if the main country cannot be determined. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Use the `Intl` API to format a currency with from currency code */ declare function getLocaleCurrencySymbol(locale: string): string | null; /** * Retrieves the name of the currency for the main country corresponding * to a given locale. For example, 'US Dollar' for `en-US`. * @param locale A locale code for the locale format rules to use. * @returns The currency name, * or `null` if the main country cannot be determined. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Use the `Intl` API to format a currency with from currency code */ declare function getLocaleCurrencyName(locale: string): string | null; /** * Retrieves the default currency code for the given locale. * * The default is defined as the first currency which is still in use. * * @param locale The code of the locale whose currency code we want. * @returns The code of the default currency for the given locale. * * @publicApi * * @deprecated We recommend you create a map of locale to ISO 4217 currency codes. * Time relative currency data is provided by the CLDR project. See https://www.unicode.org/cldr/charts/44/supplemental/detailed_territory_currency_information.html */ declare function getLocaleCurrencyCode(locale: string): string | null; /** * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Use `Intl.PluralRules` instead */ declare const getLocalePluralCase: (locale: string) => (value: number) => Plural; /** * Retrieves locale-specific rules used to determine which day period to use * when more than one period is defined for a locale. * * There is a rule for each defined day period. The * first rule is applied to the first day period and so on. * Fall back to AM/PM when no rules are available. * * A rule can specify a period as time range, or as a single time value. * * This functionality is only available when you have loaded the full locale data. * See the ["I18n guide"](guide/i18n/format-data-locale). * * @param locale A locale code for the locale format rules to use. * @returns The rules for the locale, a single time value or array of *from-time, to-time*, * or null if no periods are available. * * @see {@link getLocaleExtraDayPeriods} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * Let `Intl.DateTimeFormat` determine the day period instead. */ declare function getLocaleExtraDayPeriodRules(locale: string): (Time | [Time, Time])[]; /** * Retrieves locale-specific day periods, which indicate roughly how a day is broken up * in different languages. * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight. * * This functionality is only available when you have loaded the full locale data. * See the ["I18n guide"](guide/i18n/format-data-locale). * * @param locale A locale code for the locale format rules to use. * @param formStyle The required grammatical form. * @param width The required character width. * @returns The translated day-period strings. * @see {@link getLocaleExtraDayPeriodRules} * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead. */ declare function getLocaleExtraDayPeriods(locale: string, formStyle: FormStyle, width: TranslationWidth): string[]; /** * Retrieves the writing direction of a specified locale * @param locale A locale code for the locale format rules to use. * @publicApi * @returns 'rtl' or 'ltr' * @see [Internationalization (i18n) Guide](guide/i18n) * * @deprecated Angular recommends relying on the `Intl` API for i18n. * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction. * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo). * has only partial support (Chromium M99 & Safari 17). * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue. */ declare function getLocaleDirection(locale: string): 'ltr' | 'rtl'; /** * Represents a time value with hours and minutes. * * @publicApi * * @deprecated Locale date getters are deprecated */ type Time = { hours: number; minutes: number; }; /** * Retrieves the currency symbol for a given currency code. * * For example, for the default `en-US` locale, the code `USD` can * be represented by the narrow symbol `$` or the wide symbol `US$`. * * @param code The currency code. * @param format The format, `wide` or `narrow`. * @param locale A locale code for the locale format rules to use. * * @returns The symbol, or the currency code if no symbol is available. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol. * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value` * returns `$` for USD currency code in the `en` locale. * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale. */ declare function getCurrencySymbol(code: string, format: 'wide' | 'narrow', locale?: string): string; /** * Reports the number of decimal digits for a given currency. * The value depends upon the presence of cents in that particular currency. * * @param code The currency code. * @returns The number of decimal digits, typically 0 or 2. * @see [Internationalization (i18n) Guide](guide/i18n) * * @publicApi * * @deprecated Angular recommends relying on the `Intl` API for i18n. * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency */ declare function getNumberOfCurrencyDigits(code: string): number; declare function parseCookieValue(cookieStr: string, name: string): string | null; /** * @ngModule CommonModule * * @usageNotes * ```html * <some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element> * * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element> * ``` * * For more simple use cases you can use the [class bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly. * It doesn't require importing a directive. * * ```html * <some-element [class]="'first second'">...</some-element> * * <some-element [class.expanded]="isExpanded">...</some-element> * * <some-element [class]="['first', 'second']">...</some-element> * * <some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element> * ``` * @description * * Adds and removes CSS classes on an HTML element. * * The CSS classes are updated as follows, depending on the type of the expression evaluation: * - `string` - the CSS classes listed in the string (space delimited) are added, * - `Array` - the CSS classes declared as Array elements are added, * - `Object` - keys are CSS classes that get added when the expression given in the value * evaluates to a truthy value, otherwise they are removed. * * * @see [Class bindings](/guide/templates/binding#css-class-and-style-property-bindings) * * @publicApi */ declare class NgClass implements DoCheck { private _ngEl; private _renderer; private initialClasses; private rawClass; private stateMap; constructor(_ngEl: ElementRef, _renderer: Renderer2); set klass(value: string); set ngClass(value: string | string[] | Set<string> | { [klass: string]: any; } | null | undefined); ngDoCheck(): void; private _updateState; private _applyStateDiff; private _toggleClass; static ɵfac: i0.ɵɵFactoryDeclaration<NgClass, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<NgClass, "[ngClass]", never, { "klass": { "alias": "class"; "required": false; }; "ngClass": { "alias": "ngClass"; "required": false; }; }, {}, never, never, true, never>; } /** * Instantiates a {@link /api/core/Component Component} type and inserts its Host View into the current View. * `NgComponentOutlet` provides a declarative approach for dynamic component creation. * * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and * any existing component will be destroyed. * * @usageNotes * * ### Fine tune control * * You can control the component creation process by using the following optional attributes: * * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the * component. * * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for * the Component. Defaults to the injector of the current view container. * * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content * section of the component, if it exists. * * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another * module dynamically, then loading a component from that module. * * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional * NgModule factory to allow loading another module dynamically, then loading a component from that * module. Use `ngComponentOutletNgModule` instead. * * ### Syntax * * Simple * ```html * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container> * ``` * * With inputs * ```html * <ng-container *ngComponentOutlet="componentTypeExpression; * inputs: inputsExpression;"> * </ng-container> * ``` * * Customized injector/content * ```html * <ng-container *ngComponentOutlet="componentTypeExpression; * injector: injectorExpression; * content: contentNodesExpression;"> * </ng-container> * ``` * * Customized NgModule reference * ```html * <ng-container *ngComponentOutlet="componentTypeExpression; * ngModule: ngModuleClass;"> * </ng-container> * ``` * * ### A simple example * * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'} * * A more complete example with additional options: * * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'} * * @publicApi * @ngModule CommonModule */ declare class NgComponentOutlet<T = any> implements OnChanges, DoCheck, OnDestroy { private _viewContainerRef; /** Component that should be rendered in the outlet. */ ngComponentOutlet: Type<any> | null; ngComponentOutletInputs?: Record<string, unknown>; ngComponentOutletInjector?: Injector; ngComponentOutletContent?: any[][]; ngComponentOutletNgModule?: Type<any>; /** * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead. */ ngComponentOutletNgModuleFactory?: NgModuleFactory<any>; private _componentRef; private _moduleRef; /** * A helper data structure that allows us to track inputs that were part of th