UNPKG

@angular/common

Version:

Angular - commonly needed directives and services

1,583 lines (1,574 loc) 292 kB
/** * @license Angular v8.2.4 * (c) 2010-2019 Google LLC. https://angular.io/ * License: MIT */ import { InjectionToken, EventEmitter, Injectable, Optional, Inject, ɵfindLocaleData, ɵLocaleDataIndex, ɵgetLocalePluralCase, LOCALE_ID, ɵLOCALE_DATA, ɵisListLikeIterable, ɵstringify, IterableDiffers, KeyValueDiffers, ElementRef, Renderer2, ɵɵallocHostVars, ɵɵstyling, ɵɵclassMap, ɵɵstylingApply, ɵɵdefineDirective, Directive, Input, NgModuleRef, ComponentFactoryResolver, ViewContainerRef, isDevMode, TemplateRef, Host, Attribute, ɵɵstyleMap, Pipe, ɵlooseIdentical, WrappedValue, ɵisPromise, ɵisObservable, ChangeDetectorRef, NgModule, Version, ɵɵdefineInjectable, ɵɵinject, ErrorHandler } from '@angular/core'; /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * 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-webworker` provides * one suitable for use with web workers. * * 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 Router} in order to navigate between routes. Since all interactions between {\@link * Router} / * {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation` * class they are all platform independent. * * \@publicApi * @abstract */ class PlatformLocation { } if (false) { /** * @abstract * @return {?} */ PlatformLocation.prototype.getBaseHrefFromDOM = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.getState = function () { }; /** * @abstract * @param {?} fn * @return {?} */ PlatformLocation.prototype.onPopState = function (fn) { }; /** * @abstract * @param {?} fn * @return {?} */ PlatformLocation.prototype.onHashChange = function (fn) { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.href = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.protocol = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.hostname = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.port = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.pathname = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.search = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.hash = function () { }; /** * @abstract * @param {?} state * @param {?} title * @param {?} url * @return {?} */ PlatformLocation.prototype.replaceState = function (state, title, url) { }; /** * @abstract * @param {?} state * @param {?} title * @param {?} url * @return {?} */ PlatformLocation.prototype.pushState = function (state, title, url) { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.forward = function () { }; /** * @abstract * @return {?} */ PlatformLocation.prototype.back = function () { }; } /** * \@description * Indicates when a location is initialized. * * \@publicApi * @type {?} */ const LOCATION_INITIALIZED = new InjectionToken('Location Initialized'); /** * \@description * A serializable version of the event from `onPopState` or `onHashChange` * * \@publicApi * @record */ function LocationChangeEvent() { } if (false) { /** @type {?} */ LocationChangeEvent.prototype.type; /** @type {?} */ LocationChangeEvent.prototype.state; } /** * \@publicApi * @record */ function LocationChangeListener() { } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * 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 * @abstract */ class LocationStrategy { } if (false) { /** * @abstract * @param {?=} includeHash * @return {?} */ LocationStrategy.prototype.path = function (includeHash) { }; /** * @abstract * @param {?} internal * @return {?} */ LocationStrategy.prototype.prepareExternalUrl = function (internal) { }; /** * @abstract * @param {?} state * @param {?} title * @param {?} url * @param {?} queryParams * @return {?} */ LocationStrategy.prototype.pushState = function (state, title, url, queryParams) { }; /** * @abstract * @param {?} state * @param {?} title * @param {?} url * @param {?} queryParams * @return {?} */ LocationStrategy.prototype.replaceState = function (state, title, url, queryParams) { }; /** * @abstract * @return {?} */ LocationStrategy.prototype.forward = function () { }; /** * @abstract * @return {?} */ LocationStrategy.prototype.back = function () { }; /** * @abstract * @param {?} fn * @return {?} */ LocationStrategy.prototype.onPopState = function (fn) { }; /** * @abstract * @return {?} */ LocationStrategy.prototype.getBaseHref = function () { }; } /** * A predefined [DI token](guide/glossary#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. * * ```typescript * import {Component, NgModule} from '\@angular/core'; * import {APP_BASE_HREF} from '\@angular/common'; * * \@NgModule({ * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}] * }) * class AppModule {} * ``` * * \@publicApi * @type {?} */ const APP_BASE_HREF = new InjectionToken('appBaseHref'); /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * \@publicApi * @record */ function PopStateEvent() { } if (false) { /** @type {?|undefined} */ PopStateEvent.prototype.pop; /** @type {?|undefined} */ PopStateEvent.prototype.state; /** @type {?|undefined} */ PopStateEvent.prototype.type; /** @type {?|undefined} */ PopStateEvent.prototype.url; } /** * \@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 * * <code-example path='common/location/ts/path_location_component.ts' * region='LocationComponent'></code-example> * * \@publicApi */ class Location { /** * @param {?} platformStrategy * @param {?} platformLocation */ constructor(platformStrategy, platformLocation) { /** * \@internal */ this._subject = new EventEmitter(); /** * \@internal */ this._urlChangeListeners = []; this._platformStrategy = platformStrategy; /** @type {?} */ const browserBaseHref = this._platformStrategy.getBaseHref(); this._platformLocation = platformLocation; this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref)); this._platformStrategy.onPopState((/** * @param {?} ev * @return {?} */ (ev) => { this._subject.emit({ 'url': this.path(true), 'pop': true, 'state': ev.state, 'type': ev.type, }); })); } /** * Normalizes the URL path for this location. * * @param {?=} includeHash True to include an anchor fragment in the path. * * @return {?} The normalized URL path. */ // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is // removed. path(includeHash = false) { return this.normalize(this._platformStrategy.path(includeHash)); } /** * Reports the current state of the location history. * @return {?} The current value of the `history.state` object. */ getState() { return this._platformLocation.getState(); } /** * Normalizes the given path and compares to the current normalized path. * * @param {?} path The given URL path. * @param {?=} query Query parameters. * * @return {?} True if the given URL path is equal to the current normalized path, false * otherwise. */ isCurrentPathEqualTo(path, query = '') { return this.path() == this.normalize(path + Location.normalizeQueryParams(query)); } /** * Normalizes a URL path by stripping any trailing slashes. * * @param {?} url String representing a URL. * * @return {?} The normalized URL string. */ normalize(url) { return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url))); } /** * 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. * * @return {?} A normalized platform-specific URL. */ prepareExternalUrl(url) { if (url && url[0] !== '/') { url = '/' + url; } return this._platformStrategy.prepareExternalUrl(url); } // TODO: rename this method to pushState /** * 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. * * @return {?} */ go(path, query = '', state = null) { this._platformStrategy.pushState(state, '', path, query); this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location.normalizeQueryParams(query)), state); } /** * 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. * @return {?} */ replaceState(path, query = '', state = null) { this._platformStrategy.replaceState(state, '', path, query); this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location.normalizeQueryParams(query)), state); } /** * Navigates forward in the platform's history. * @return {?} */ forward() { this._platformStrategy.forward(); } /** * Navigates back in the platform's history. * @return {?} */ back() { this._platformStrategy.back(); } /** * 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. * @return {?} */ onUrlChange(fn) { this._urlChangeListeners.push(fn); this.subscribe((/** * @param {?} v * @return {?} */ v => { this._notifyUrlChangeListeners(v.url, v.state); })); } /** * \@internal * @param {?=} url * @param {?=} state * @return {?} */ _notifyUrlChangeListeners(url = '', state) { this._urlChangeListeners.forEach((/** * @param {?} fn * @return {?} */ fn => fn(url, state))); } /** * Subscribes to the platform's `popState` events. * * @param {?} onNext * @param {?=} onThrow * @param {?=} onReturn * @return {?} Subscribed events. */ subscribe(onNext, onThrow, onReturn) { return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn }); } /** * Normalizes URL parameters by prepending with `?` if needed. * * @param {?} params String of URL parameters. * * @return {?} The normalized URL parameters string. */ static normalizeQueryParams(params) { return params && params[0] !== '?' ? '?' + params : params; } /** * Joins two parts of a URL with a slash if needed. * * @param {?} start URL string * @param {?} end URL string * * * @return {?} The joined URL string. */ static joinWithSlash(start, end) { if (start.length == 0) { return end; } if (end.length == 0) { return start; } /** @type {?} */ let slashes = 0; if (start.endsWith('/')) { slashes++; } if (end.startsWith('/')) { slashes++; } if (slashes == 2) { return start + end.substring(1); } if (slashes == 1) { return start + end; } return start + '/' + end; } /** * 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. * * @return {?} The URL string, modified if needed. */ static stripTrailingSlash(url) { /** @type {?} */ const match = url.match(/#|\?|$/); /** @type {?} */ const pathEndIdx = match && match.index || url.length; /** @type {?} */ const droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0); return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx); } } Location.decorators = [ { type: Injectable } ]; /** @nocollapse */ Location.ctorParameters = () => [ { type: LocationStrategy }, { type: PlatformLocation } ]; if (false) { /** * \@internal * @type {?} */ Location.prototype._subject; /** * \@internal * @type {?} */ Location.prototype._baseHref; /** * \@internal * @type {?} */ Location.prototype._platformStrategy; /** * \@internal * @type {?} */ Location.prototype._platformLocation; /** * \@internal * @type {?} */ Location.prototype._urlChangeListeners; } /** * @param {?} baseHref * @param {?} url * @return {?} */ function _stripBaseHref(baseHref, url) { return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url; } /** * @param {?} url * @return {?} */ function _stripIndexHtml(url) { return url.replace(/\/index.html$/, ''); } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * \@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 */ class HashLocationStrategy extends LocationStrategy { /** * @param {?} _platformLocation * @param {?=} _baseHref */ constructor(_platformLocation, _baseHref) { super(); this._platformLocation = _platformLocation; this._baseHref = ''; if (_baseHref != null) { this._baseHref = _baseHref; } } /** * @param {?} fn * @return {?} */ onPopState(fn) { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); } /** * @return {?} */ getBaseHref() { return this._baseHref; } /** * @param {?=} includeHash * @return {?} */ path(includeHash = false) { // the hash value is always prefixed with a `#` // and if it is empty then it will stay empty /** @type {?} */ let path = this._platformLocation.hash; if (path == null) path = '#'; return path.length > 0 ? path.substring(1) : path; } /** * @param {?} internal * @return {?} */ prepareExternalUrl(internal) { /** @type {?} */ const url = Location.joinWithSlash(this._baseHref, internal); return url.length > 0 ? ('#' + url) : url; } /** * @param {?} state * @param {?} title * @param {?} path * @param {?} queryParams * @return {?} */ pushState(state, title, path, queryParams) { /** @type {?} */ let url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } this._platformLocation.pushState(state, title, url); } /** * @param {?} state * @param {?} title * @param {?} path * @param {?} queryParams * @return {?} */ replaceState(state, title, path, queryParams) { /** @type {?} */ let url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } this._platformLocation.replaceState(state, title, url); } /** * @return {?} */ forward() { this._platformLocation.forward(); } /** * @return {?} */ back() { this._platformLocation.back(); } } HashLocationStrategy.decorators = [ { type: Injectable } ]; /** @nocollapse */ HashLocationStrategy.ctorParameters = () => [ { type: PlatformLocation }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] }] } ]; if (false) { /** * @type {?} * @private */ HashLocationStrategy.prototype._baseHref; /** * @type {?} * @private */ HashLocationStrategy.prototype._platformLocation; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * \@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 must provide a {\@link APP_BASE_HREF} * or add a base element to the document. This URL prefix that will be preserved * when generating and recognizing URLs. * * 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`. * * 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`. * * \@usageNotes * * ### Example * * {\@example common/location/ts/path_location_component.ts region='LocationComponent'} * * \@publicApi */ class PathLocationStrategy extends LocationStrategy { /** * @param {?} _platformLocation * @param {?=} href */ constructor(_platformLocation, href) { super(); this._platformLocation = _platformLocation; if (href == null) { href = this._platformLocation.getBaseHrefFromDOM(); } if (href == null) { throw new Error(`No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.`); } this._baseHref = href; } /** * @param {?} fn * @return {?} */ onPopState(fn) { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); } /** * @return {?} */ getBaseHref() { return this._baseHref; } /** * @param {?} internal * @return {?} */ prepareExternalUrl(internal) { return Location.joinWithSlash(this._baseHref, internal); } /** * @param {?=} includeHash * @return {?} */ path(includeHash = false) { /** @type {?} */ const pathname = this._platformLocation.pathname + Location.normalizeQueryParams(this._platformLocation.search); /** @type {?} */ const hash = this._platformLocation.hash; return hash && includeHash ? `${pathname}${hash}` : pathname; } /** * @param {?} state * @param {?} title * @param {?} url * @param {?} queryParams * @return {?} */ pushState(state, title, url, queryParams) { /** @type {?} */ const externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.pushState(state, title, externalUrl); } /** * @param {?} state * @param {?} title * @param {?} url * @param {?} queryParams * @return {?} */ replaceState(state, title, url, queryParams) { /** @type {?} */ const externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.replaceState(state, title, externalUrl); } /** * @return {?} */ forward() { this._platformLocation.forward(); } /** * @return {?} */ back() { this._platformLocation.back(); } } PathLocationStrategy.decorators = [ { type: Injectable } ]; /** @nocollapse */ PathLocationStrategy.ctorParameters = () => [ { type: PlatformLocation }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] }] } ]; if (false) { /** * @type {?} * @private */ PathLocationStrategy.prototype._baseHref; /** * @type {?} * @private */ PathLocationStrategy.prototype._platformLocation; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // THIS CODE IS GENERATED - DO NOT MODIFY // See angular/tools/gulp-tasks/cldr/extract.js /** * \@internal * @type {?} */ const CURRENCIES_EN = { 'ADP': [undefined, undefined, 0], 'AFN': [undefined, undefined, 0], 'ALL': [undefined, undefined, 0], 'AMD': [undefined, undefined, 0], 'AOA': [undefined, 'Kz'], 'ARS': [undefined, '$'], 'AUD': ['A$', '$'], 'BAM': [undefined, 'KM'], 'BBD': [undefined, '$'], 'BDT': [undefined, '৳'], 'BHD': [undefined, undefined, 3], 'BIF': [undefined, undefined, 0], 'BMD': [undefined, '$'], 'BND': [undefined, '$'], 'BOB': [undefined, 'Bs'], 'BRL': ['R$'], 'BSD': [undefined, '$'], 'BWP': [undefined, 'P'], 'BYN': [undefined, 'р.', 2], 'BYR': [undefined, undefined, 0], 'BZD': [undefined, '$'], 'CAD': ['CA$', '$', 2], 'CHF': [undefined, undefined, 2], 'CLF': [undefined, undefined, 4], 'CLP': [undefined, '$', 0], 'CNY': ['CN¥', '¥'], 'COP': [undefined, '$', 0], 'CRC': [undefined, '₡', 2], 'CUC': [undefined, '$'], 'CUP': [undefined, '$'], 'CZK': [undefined, 'Kč', 2], 'DJF': [undefined, undefined, 0], 'DKK': [undefined, 'kr', 2], 'DOP': [undefined, '$'], 'EGP': [undefined, 'E£'], 'ESP': [undefined, '₧', 0], 'EUR': ['€'], 'FJD': [undefined, '$'], 'FKP': [undefined, '£'], 'GBP': ['£'], 'GEL': [undefined, '₾'], 'GIP': [undefined, '£'], 'GNF': [undefined, 'FG', 0], 'GTQ': [undefined, 'Q'], 'GYD': [undefined, '$', 0], 'HKD': ['HK$', '$'], 'HNL': [undefined, 'L'], 'HRK': [undefined, 'kn'], 'HUF': [undefined, 'Ft', 2], 'IDR': [undefined, 'Rp', 0], 'ILS': ['₪'], 'INR': ['₹'], 'IQD': [undefined, undefined, 0], 'IRR': [undefined, undefined, 0], 'ISK': [undefined, 'kr', 0], 'ITL': [undefined, undefined, 0], 'JMD': [undefined, '$'], 'JOD': [undefined, undefined, 3], 'JPY': ['¥', undefined, 0], 'KHR': [undefined, '៛'], 'KMF': [undefined, 'CF', 0], 'KPW': [undefined, '₩', 0], 'KRW': ['₩', undefined, 0], 'KWD': [undefined, undefined, 3], 'KYD': [undefined, '$'], 'KZT': [undefined, '₸'], 'LAK': [undefined, '₭', 0], 'LBP': [undefined, 'L£', 0], 'LKR': [undefined, 'Rs'], 'LRD': [undefined, '$'], 'LTL': [undefined, 'Lt'], 'LUF': [undefined, undefined, 0], 'LVL': [undefined, 'Ls'], 'LYD': [undefined, undefined, 3], 'MGA': [undefined, 'Ar', 0], 'MGF': [undefined, undefined, 0], 'MMK': [undefined, 'K', 0], 'MNT': [undefined, '₮', 0], 'MRO': [undefined, undefined, 0], 'MUR': [undefined, 'Rs', 0], 'MXN': ['MX$', '$'], 'MYR': [undefined, 'RM'], 'NAD': [undefined, '$'], 'NGN': [undefined, '₦'], 'NIO': [undefined, 'C$'], 'NOK': [undefined, 'kr', 2], 'NPR': [undefined, 'Rs'], 'NZD': ['NZ$', '$'], 'OMR': [undefined, undefined, 3], 'PHP': [undefined, '₱'], 'PKR': [undefined, 'Rs', 0], 'PLN': [undefined, 'zł'], 'PYG': [undefined, '₲', 0], 'RON': [undefined, 'lei'], 'RSD': [undefined, undefined, 0], 'RUB': [undefined, '₽'], 'RUR': [undefined, 'р.'], 'RWF': [undefined, 'RF', 0], 'SBD': [undefined, '$'], 'SEK': [undefined, 'kr', 2], 'SGD': [undefined, '$'], 'SHP': [undefined, '£'], 'SLL': [undefined, undefined, 0], 'SOS': [undefined, undefined, 0], 'SRD': [undefined, '$'], 'SSP': [undefined, '£'], 'STD': [undefined, undefined, 0], 'STN': [undefined, 'Db'], 'SYP': [undefined, '£', 0], 'THB': [undefined, '฿'], 'TMM': [undefined, undefined, 0], 'TND': [undefined, undefined, 3], 'TOP': [undefined, 'T$'], 'TRL': [undefined, undefined, 0], 'TRY': [undefined, '₺'], 'TTD': [undefined, '$'], 'TWD': ['NT$', '$', 2], 'TZS': [undefined, undefined, 0], 'UAH': [undefined, '₴'], 'UGX': [undefined, undefined, 0], 'USD': ['$'], 'UYI': [undefined, undefined, 0], 'UYU': [undefined, '$'], 'UZS': [undefined, undefined, 0], 'VEF': [undefined, 'Bs'], 'VND': ['₫', undefined, 0], 'VUV': [undefined, undefined, 0], 'XAF': ['FCFA', undefined, 0], 'XCD': ['EC$', '$'], 'XOF': ['CFA', undefined, 0], 'XPF': ['CFPF', undefined, 0], 'YER': [undefined, undefined, 0], 'ZAR': [undefined, 'R'], 'ZMK': [undefined, undefined, 0], 'ZMW': [undefined, 'ZK'], 'ZWD': [undefined, undefined, 0] }; /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @enum {number} */ const NumberFormatStyle = { Decimal: 0, Percent: 1, Currency: 2, Scientific: 3, }; NumberFormatStyle[NumberFormatStyle.Decimal] = 'Decimal'; NumberFormatStyle[NumberFormatStyle.Percent] = 'Percent'; NumberFormatStyle[NumberFormatStyle.Currency] = 'Currency'; NumberFormatStyle[NumberFormatStyle.Scientific] = 'Scientific'; /** @enum {number} */ const Plural = { Zero: 0, One: 1, Two: 2, Few: 3, Many: 4, Other: 5, }; Plural[Plural.Zero] = 'Zero'; Plural[Plural.One] = 'One'; Plural[Plural.Two] = 'Two'; Plural[Plural.Few] = 'Few'; Plural[Plural.Many] = 'Many'; Plural[Plural.Other] = 'Other'; /** @enum {number} */ const FormStyle = { Format: 0, Standalone: 1, }; FormStyle[FormStyle.Format] = 'Format'; FormStyle[FormStyle.Standalone] = 'Standalone'; /** @enum {number} */ const 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, }; TranslationWidth[TranslationWidth.Narrow] = 'Narrow'; TranslationWidth[TranslationWidth.Abbreviated] = 'Abbreviated'; TranslationWidth[TranslationWidth.Wide] = 'Wide'; TranslationWidth[TranslationWidth.Short] = 'Short'; /** @enum {number} */ const 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, }; FormatWidth[FormatWidth.Short] = 'Short'; FormatWidth[FormatWidth.Medium] = 'Medium'; FormatWidth[FormatWidth.Long] = 'Long'; FormatWidth[FormatWidth.Full] = 'Full'; /** @enum {number} */ const NumberSymbol = { /** * Decimal separator. * For `en-US`, the dot character. * Example : 2,345`.`67 */ Decimal: 0, /** * Grouping separator, typically for thousands. * For `en-US`, the comma character. * Example: 2`,`345.67 */ Group: 1, /** * List-item separator. * Example: "one, two, and three" */ List: 2, /** * Sign for percentage (out of 100). * Example: 23.4% */ PercentSign: 3, /** * Sign for positive numbers. * Example: +23 */ PlusSign: 4, /** * Sign for negative numbers. * Example: -23 */ MinusSign: 5, /** * Computer notation for exponential value (n times a power of 10). * Example: 1.2E3 */ Exponential: 6, /** * Human-readable format of exponential. * Example: 1.2x103 */ SuperscriptingExponent: 7, /** * Sign for permille (out of 1000). * Example: 23.4‰ */ PerMille: 8, /** * Infinity, can be used with plus and minus. * Example: ∞, +∞, -∞ */ Infinity: 9, /** * Not a number. * Example: NaN */ NaN: 10, /** * Symbol used between time units. * Example: 10:52 */ TimeSeparator: 11, /** * Decimal separator for currency values (fallback to `Decimal`). * Example: $2,345.67 */ CurrencyDecimal: 12, /** * Group separator for currency values (fallback to `Group`). * Example: $2,345.67 */ CurrencyGroup: 13, }; NumberSymbol[NumberSymbol.Decimal] = 'Decimal'; NumberSymbol[NumberSymbol.Group] = 'Group'; NumberSymbol[NumberSymbol.List] = 'List'; NumberSymbol[NumberSymbol.PercentSign] = 'PercentSign'; NumberSymbol[NumberSymbol.PlusSign] = 'PlusSign'; NumberSymbol[NumberSymbol.MinusSign] = 'MinusSign'; NumberSymbol[NumberSymbol.Exponential] = 'Exponential'; NumberSymbol[NumberSymbol.SuperscriptingExponent] = 'SuperscriptingExponent'; NumberSymbol[NumberSymbol.PerMille] = 'PerMille'; NumberSymbol[NumberSymbol.Infinity] = 'Infinity'; NumberSymbol[NumberSymbol.NaN] = 'NaN'; NumberSymbol[NumberSymbol.TimeSeparator] = 'TimeSeparator'; NumberSymbol[NumberSymbol.CurrencyDecimal] = 'CurrencyDecimal'; NumberSymbol[NumberSymbol.CurrencyGroup] = 'CurrencyGroup'; /** @enum {number} */ const WeekDay = { Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3, Thursday: 4, Friday: 5, Saturday: 6, }; WeekDay[WeekDay.Sunday] = 'Sunday'; WeekDay[WeekDay.Monday] = 'Monday'; WeekDay[WeekDay.Tuesday] = 'Tuesday'; WeekDay[WeekDay.Wednesday] = 'Wednesday'; WeekDay[WeekDay.Thursday] = 'Thursday'; WeekDay[WeekDay.Friday] = 'Friday'; WeekDay[WeekDay.Saturday] = 'Saturday'; /** * Retrieves the locale ID from the currently loaded locale. * The loaded locale could be, for example, a global one rather than a regional one. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code, such as `fr-FR`. * @return {?} The locale code. For example, `fr`. */ function getLocaleId(locale) { return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId]; } /** * Retrieves day period strings for the given locale. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} formStyle The required grammatical form. * @param {?} width The required character width. * @return {?} An array of localized period strings. For example, `[AM, PM]` for `en-US`. */ function getLocaleDayPeriods(locale, formStyle, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const amPmData = (/** @type {?} */ ([data[ɵLocaleDataIndex.DayPeriodsFormat], data[ɵLocaleDataIndex.DayPeriodsStandalone]])); /** @type {?} */ const amPm = getLastDefinedValue(amPmData, formStyle); return getLastDefinedValue(amPm, width); } /** * Retrieves days of the week for the given locale, using the Gregorian calendar. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} formStyle The required grammatical form. * @param {?} width The required character width. * @return {?} An array of localized name strings. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`. */ function getLocaleDayNames(locale, formStyle, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const daysData = (/** @type {?} */ ([data[ɵLocaleDataIndex.DaysFormat], data[ɵLocaleDataIndex.DaysStandalone]])); /** @type {?} */ const days = getLastDefinedValue(daysData, formStyle); return getLastDefinedValue(days, width); } /** * Retrieves months of the year for the given locale, using the Gregorian calendar. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} formStyle The required grammatical form. * @param {?} width The required character width. * @return {?} An array of localized name strings. * For example, `[January, February, ...]` for `en-US`. */ function getLocaleMonthNames(locale, formStyle, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const monthsData = (/** @type {?} */ ([data[ɵLocaleDataIndex.MonthsFormat], data[ɵLocaleDataIndex.MonthsStandalone]])); /** @type {?} */ const months = getLastDefinedValue(monthsData, formStyle); return getLastDefinedValue(months, width); } /** * Retrieves Gregorian-calendar eras for the given locale. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} width The required character width. * @return {?} An array of localized era strings. * For example, `[AD, BC]` for `en-US`. */ function getLocaleEraNames(locale, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const erasData = (/** @type {?} */ (data[ɵLocaleDataIndex.Eras])); return getLastDefinedValue(erasData, width); } /** * Retrieves the first day of the week for the given locale. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @return {?} 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. */ function getLocaleFirstDayOfWeek(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.FirstDayOfWeek]; } /** * Range of week days that are considered the week-end for the given locale. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @return {?} The range of day values, `[startDay, endDay]`. */ function getLocaleWeekEndRange(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.WeekendRange]; } /** * Retrieves a localized date-value formating string. * * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} width The format type. * @return {?} The localized formating string. */ function getLocaleDateFormat(locale, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width); } /** * Retrieves a localized time-value formatting string. * * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} width The format type. * @return {?} The localized formatting string. */ function getLocaleTimeFormat(locale, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width); } /** * Retrieves a localized date-time formatting string. * * @see `FormatWidth` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} width The format type. * @return {?} The localized formatting string. */ function getLocaleDateTimeFormat(locale, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const dateTimeFormatData = (/** @type {?} */ (data[ɵLocaleDataIndex.DateTimeFormat])); return getLastDefinedValue(dateTimeFormatData, width); } /** * Retrieves a localized number symbol that can be used to replace placeholders in number formats. * @see `NumberSymbol` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale The locale code. * @param {?} symbol The symbol to localize. * @return {?} The character for the localized symbol. */ function getLocaleNumberSymbol(locale, symbol) { /** @type {?} */ const data = ɵfindLocaleData(locale); /** @type {?} */ const res = data[ɵLocaleDataIndex.NumberSymbols][symbol]; if (typeof res === 'undefined') { if (symbol === NumberSymbol.CurrencyDecimal) { return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal]; } else if (symbol === NumberSymbol.CurrencyGroup) { return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group]; } } return res; } /** * 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. | * * @see `NumberFormatStyle` / [CLDR website](http://cldr.unicode.org/translation/number-patterns) / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @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`.) * @return {?} The localized format string. */ function getLocaleNumberFormat(locale, type) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.NumberFormats][type]; } /** * Retrieves the symbol used to represent the currency for the main country * corresponding to a given locale. For example, '$' for `en-US`. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @return {?} The localized symbol character, * or `null` if the main country cannot be determined. */ function getLocaleCurrencySymbol(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.CurrencySymbol] || null; } /** * Retrieves the name of the currency for the main country corresponding * to a given locale. For example, 'US Dollar' for `en-US`. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @return {?} The currency name, * or `null` if the main country cannot be determined. */ function getLocaleCurrencyName(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.CurrencyName] || null; } /** * Retrieves the currency values for a given locale. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * @param {?} locale A locale code for the locale format rules to use. * @return {?} The currency values. */ function getLocaleCurrencies(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); return data[ɵLocaleDataIndex.Currencies]; } /** * \@alias core/ɵgetLocalePluralCase * \@publicApi * @type {?} */ const getLocalePluralCase = ɵgetLocalePluralCase; /** * @param {?} data * @return {?} */ function checkFullData(data) { if (!data[ɵLocaleDataIndex.ExtraData]) { throw new Error(`Missing extra locale data for the locale "${data[ɵLocaleDataIndex.LocaleId]}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`); } } /** * 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#i18n-pipes). * * @see `getLocaleExtraDayPeriods()` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @return {?} The rules for the locale, a single time value or array of *from-time, to-time*, * or null if no periods are available. * */ function getLocaleExtraDayPeriodRules(locale) { /** @type {?} */ const data = ɵfindLocaleData(locale); checkFullData(data); /** @type {?} */ const rules = data[ɵLocaleDataIndex.ExtraData][2 /* ExtraDayPeriodsRules */] || []; return rules.map((/** * @param {?} rule * @return {?} */ (rule) => { if (typeof rule === 'string') { return extractTime(rule); } return [extractTime(rule[0]), extractTime(rule[1])]; })); } /** * 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#i18n-pipes). * * @see `getLocaleExtraDayPeriodRules()` / [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} locale A locale code for the locale format rules to use. * @param {?} formStyle The required grammatical form. * @param {?} width The required character width. * @return {?} The translated day-period strings. */ function getLocaleExtraDayPeriods(locale, formStyle, width) { /** @type {?} */ const data = ɵfindLocaleData(locale); checkFullData(data); /** @type {?} */ const dayPeriodsData = (/** @type {?} */ ([ data[ɵLocaleDataIndex.ExtraData][0 /* ExtraDayPeriodFormats */], data[ɵLocaleDataIndex.ExtraData][1 /* ExtraDayPeriodStandalone */] ])); /** @type {?} */ const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || []; return getLastDefinedValue(dayPeriods, width) || []; } /** * Retrieves the first value that is defined in an array, going backwards from an index position. * * To avoid repeating the same data (as when the "format" and "standalone" forms are the same) * add the first value to the locale data arrays, and add other values only if they are different. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @template T * @param {?} data The data array to retrieve from. * @param {?} index A 0-based index into the array to start from. * @return {?} The value immediately before the given index position. */ function getLastDefinedValue(data, index) { for (let i = index; i > -1; i--) { if (typeof data[i] !== 'undefined') { return data[i]; } } throw new Error('Locale data API: locale data undefined'); } /** * Extracts the hours and minutes from a string like "15:45" * @param {?} time * @return {?} */ function extractTime(time) { const [h, m] = time.split(':'); return { hours: +h, minutes: +m }; } /** * 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$`. * * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) * * \@publicApi * @param {?} code The currency code. * @param {?} format The format, `wide` or `narrow`. * @param {?=} locale A locale code for the locale format rules to use. * * @return {?} The symbol, or the currency code if no symbol is available.0 */ function g