1
|
/**
|
2
|
* @license Angular v4.4.6
|
3
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
4
|
* License: MIT
|
5
|
*/
|
6
|
(function (global, factory) {
|
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
|
8
|
typeof define === 'function' && define.amd ? define(['exports', '@angular/core'], factory) :
|
9
|
(factory((global.ng = global.ng || {}, global.ng.common = global.ng.common || {}),global.ng.core));
|
10
|
}(this, (function (exports,_angular_core) { 'use strict';
|
11
|
|
12
|
/*! *****************************************************************************
|
13
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
14
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
15
|
this file except in compliance with the License. You may obtain a copy of the
|
16
|
License at http://www.apache.org/licenses/LICENSE-2.0
|
17
|
|
18
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
19
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
20
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
21
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
22
|
|
23
|
See the Apache Version 2.0 License for specific language governing permissions
|
24
|
and limitations under the License.
|
25
|
***************************************************************************** */
|
26
|
/* global Reflect, Promise */
|
27
|
|
28
|
var extendStatics = Object.setPrototypeOf ||
|
29
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
30
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
31
|
|
32
|
function __extends(d, b) {
|
33
|
extendStatics(d, b);
|
34
|
function __() { this.constructor = d; }
|
35
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* @license Angular v4.4.6
|
40
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
41
|
* License: MIT
|
42
|
*/
|
43
|
/**
|
44
|
* @license
|
45
|
* Copyright Google Inc. All Rights Reserved.
|
46
|
*
|
47
|
* Use of this source code is governed by an MIT-style license that can be
|
48
|
* found in the LICENSE file at https://angular.io/license
|
49
|
*/
|
50
|
/**
|
51
|
* This class should not be used directly by an application developer. Instead, use
|
52
|
* {\@link Location}.
|
53
|
*
|
54
|
* `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
|
55
|
* agnostic.
|
56
|
* This means that we can have different implementation of `PlatformLocation` for the different
|
57
|
* platforms that angular supports. For example, `\@angular/platform-browser` provides an
|
58
|
* implementation specific to the browser environment, while `\@angular/platform-webworker` provides
|
59
|
* one suitable for use with web workers.
|
60
|
*
|
61
|
* The `PlatformLocation` class is used directly by all implementations of {\@link LocationStrategy}
|
62
|
* when they need to interact with the DOM apis like pushState, popState, etc...
|
63
|
*
|
64
|
* {\@link LocationStrategy} in turn is used by the {\@link Location} service which is used directly
|
65
|
* by the {\@link Router} in order to navigate between routes. Since all interactions between {\@link
|
66
|
* Router} /
|
67
|
* {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
|
68
|
* class they are all platform independent.
|
69
|
*
|
70
|
* \@stable
|
71
|
* @abstract
|
72
|
*/
|
73
|
var PlatformLocation = (function () {
|
74
|
function PlatformLocation() {
|
75
|
}
|
76
|
/**
|
77
|
* @abstract
|
78
|
* @return {?}
|
79
|
*/
|
80
|
PlatformLocation.prototype.getBaseHrefFromDOM = function () { };
|
81
|
/**
|
82
|
* @abstract
|
83
|
* @param {?} fn
|
84
|
* @return {?}
|
85
|
*/
|
86
|
PlatformLocation.prototype.onPopState = function (fn) { };
|
87
|
/**
|
88
|
* @abstract
|
89
|
* @param {?} fn
|
90
|
* @return {?}
|
91
|
*/
|
92
|
PlatformLocation.prototype.onHashChange = function (fn) { };
|
93
|
/**
|
94
|
* @abstract
|
95
|
* @return {?}
|
96
|
*/
|
97
|
PlatformLocation.prototype.pathname = function () { };
|
98
|
/**
|
99
|
* @abstract
|
100
|
* @return {?}
|
101
|
*/
|
102
|
PlatformLocation.prototype.search = function () { };
|
103
|
/**
|
104
|
* @abstract
|
105
|
* @return {?}
|
106
|
*/
|
107
|
PlatformLocation.prototype.hash = function () { };
|
108
|
/**
|
109
|
* @abstract
|
110
|
* @param {?} state
|
111
|
* @param {?} title
|
112
|
* @param {?} url
|
113
|
* @return {?}
|
114
|
*/
|
115
|
PlatformLocation.prototype.replaceState = function (state, title, url) { };
|
116
|
/**
|
117
|
* @abstract
|
118
|
* @param {?} state
|
119
|
* @param {?} title
|
120
|
* @param {?} url
|
121
|
* @return {?}
|
122
|
*/
|
123
|
PlatformLocation.prototype.pushState = function (state, title, url) { };
|
124
|
/**
|
125
|
* @abstract
|
126
|
* @return {?}
|
127
|
*/
|
128
|
PlatformLocation.prototype.forward = function () { };
|
129
|
/**
|
130
|
* @abstract
|
131
|
* @return {?}
|
132
|
*/
|
133
|
PlatformLocation.prototype.back = function () { };
|
134
|
return PlatformLocation;
|
135
|
}());
|
136
|
/**
|
137
|
* \@whatItDoes indicates when a location is initialized
|
138
|
* \@experimental
|
139
|
*/
|
140
|
var LOCATION_INITIALIZED = new _angular_core.InjectionToken('Location Initialized');
|
141
|
/**
|
142
|
* @license
|
143
|
* Copyright Google Inc. All Rights Reserved.
|
144
|
*
|
145
|
* Use of this source code is governed by an MIT-style license that can be
|
146
|
* found in the LICENSE file at https://angular.io/license
|
147
|
*/
|
148
|
/**
|
149
|
* `LocationStrategy` is responsible for representing and reading route state
|
150
|
* from the browser's URL. Angular provides two strategies:
|
151
|
* {\@link HashLocationStrategy} and {\@link PathLocationStrategy}.
|
152
|
*
|
153
|
* This is used under the hood of the {\@link Location} service.
|
154
|
*
|
155
|
* Applications should use the {\@link Router} or {\@link Location} services to
|
156
|
* interact with application route state.
|
157
|
*
|
158
|
* For instance, {\@link HashLocationStrategy} produces URLs like
|
159
|
* `http://example.com#/foo`, and {\@link PathLocationStrategy} produces
|
160
|
* `http://example.com/foo` as an equivalent URL.
|
161
|
*
|
162
|
* See these two classes for more.
|
163
|
*
|
164
|
* \@stable
|
165
|
* @abstract
|
166
|
*/
|
167
|
var LocationStrategy = (function () {
|
168
|
function LocationStrategy() {
|
169
|
}
|
170
|
/**
|
171
|
* @abstract
|
172
|
* @param {?=} includeHash
|
173
|
* @return {?}
|
174
|
*/
|
175
|
LocationStrategy.prototype.path = function (includeHash) { };
|
176
|
/**
|
177
|
* @abstract
|
178
|
* @param {?} internal
|
179
|
* @return {?}
|
180
|
*/
|
181
|
LocationStrategy.prototype.prepareExternalUrl = function (internal) { };
|
182
|
/**
|
183
|
* @abstract
|
184
|
* @param {?} state
|
185
|
* @param {?} title
|
186
|
* @param {?} url
|
187
|
* @param {?} queryParams
|
188
|
* @return {?}
|
189
|
*/
|
190
|
LocationStrategy.prototype.pushState = function (state, title, url, queryParams) { };
|
191
|
/**
|
192
|
* @abstract
|
193
|
* @param {?} state
|
194
|
* @param {?} title
|
195
|
* @param {?} url
|
196
|
* @param {?} queryParams
|
197
|
* @return {?}
|
198
|
*/
|
199
|
LocationStrategy.prototype.replaceState = function (state, title, url, queryParams) { };
|
200
|
/**
|
201
|
* @abstract
|
202
|
* @return {?}
|
203
|
*/
|
204
|
LocationStrategy.prototype.forward = function () { };
|
205
|
/**
|
206
|
* @abstract
|
207
|
* @return {?}
|
208
|
*/
|
209
|
LocationStrategy.prototype.back = function () { };
|
210
|
/**
|
211
|
* @abstract
|
212
|
* @param {?} fn
|
213
|
* @return {?}
|
214
|
*/
|
215
|
LocationStrategy.prototype.onPopState = function (fn) { };
|
216
|
/**
|
217
|
* @abstract
|
218
|
* @return {?}
|
219
|
*/
|
220
|
LocationStrategy.prototype.getBaseHref = function () { };
|
221
|
return LocationStrategy;
|
222
|
}());
|
223
|
/**
|
224
|
* The `APP_BASE_HREF` token represents the base href to be used with the
|
225
|
* {\@link PathLocationStrategy}.
|
226
|
*
|
227
|
* If you're using {\@link PathLocationStrategy}, you must provide a provider to a string
|
228
|
* representing the URL prefix that should be preserved when generating and recognizing
|
229
|
* URLs.
|
230
|
*
|
231
|
* ### Example
|
232
|
*
|
233
|
* ```typescript
|
234
|
* import {Component, NgModule} from '\@angular/core';
|
235
|
* import {APP_BASE_HREF} from '\@angular/common';
|
236
|
*
|
237
|
* \@NgModule({
|
238
|
* providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
|
239
|
* })
|
240
|
* class AppModule {}
|
241
|
* ```
|
242
|
*
|
243
|
* \@stable
|
244
|
*/
|
245
|
var APP_BASE_HREF = new _angular_core.InjectionToken('appBaseHref');
|
246
|
/**
|
247
|
* @license
|
248
|
* Copyright Google Inc. All Rights Reserved.
|
249
|
*
|
250
|
* Use of this source code is governed by an MIT-style license that can be
|
251
|
* found in the LICENSE file at https://angular.io/license
|
252
|
*/
|
253
|
/**
|
254
|
* \@whatItDoes `Location` is a service that applications can use to interact with a browser's URL.
|
255
|
* \@description
|
256
|
* Depending on which {\@link LocationStrategy} is used, `Location` will either persist
|
257
|
* to the URL's path or the URL's hash segment.
|
258
|
*
|
259
|
* Note: it's better to use {\@link Router#navigate} service to trigger route changes. Use
|
260
|
* `Location` only if you need to interact with or create normalized URLs outside of
|
261
|
* routing.
|
262
|
*
|
263
|
* `Location` is responsible for normalizing the URL against the application's base href.
|
264
|
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
|
265
|
* trailing slash:
|
266
|
* - `/my/app/user/123` is normalized
|
267
|
* - `my/app/user/123` **is not** normalized
|
268
|
* - `/my/app/user/123/` **is not** normalized
|
269
|
*
|
270
|
* ### Example
|
271
|
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
|
272
|
* \@stable
|
273
|
*/
|
274
|
var Location = (function () {
|
275
|
/**
|
276
|
* @param {?} platformStrategy
|
277
|
*/
|
278
|
function Location(platformStrategy) {
|
279
|
var _this = this;
|
280
|
/**
|
281
|
* \@internal
|
282
|
*/
|
283
|
this._subject = new _angular_core.EventEmitter();
|
284
|
this._platformStrategy = platformStrategy;
|
285
|
var browserBaseHref = this._platformStrategy.getBaseHref();
|
286
|
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
|
287
|
this._platformStrategy.onPopState(function (ev) {
|
288
|
_this._subject.emit({
|
289
|
'url': _this.path(true),
|
290
|
'pop': true,
|
291
|
'type': ev.type,
|
292
|
});
|
293
|
});
|
294
|
}
|
295
|
/**
|
296
|
* @param {?=} includeHash
|
297
|
* @return {?}
|
298
|
*/
|
299
|
Location.prototype.path = function (includeHash) {
|
300
|
if (includeHash === void 0) { includeHash = false; }
|
301
|
return this.normalize(this._platformStrategy.path(includeHash));
|
302
|
};
|
303
|
/**
|
304
|
* Normalizes the given path and compares to the current normalized path.
|
305
|
* @param {?} path
|
306
|
* @param {?=} query
|
307
|
* @return {?}
|
308
|
*/
|
309
|
Location.prototype.isCurrentPathEqualTo = function (path, query) {
|
310
|
if (query === void 0) { query = ''; }
|
311
|
return this.path() == this.normalize(path + Location.normalizeQueryParams(query));
|
312
|
};
|
313
|
/**
|
314
|
* Given a string representing a URL, returns the normalized URL path without leading or
|
315
|
* trailing slashes.
|
316
|
* @param {?} url
|
317
|
* @return {?}
|
318
|
*/
|
319
|
Location.prototype.normalize = function (url) {
|
320
|
return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
|
321
|
};
|
322
|
/**
|
323
|
* Given a string representing a URL, returns the platform-specific external URL path.
|
324
|
* If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
|
325
|
* before normalizing. This method will also add a hash if `HashLocationStrategy` is
|
326
|
* used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
|
327
|
* @param {?} url
|
328
|
* @return {?}
|
329
|
*/
|
330
|
Location.prototype.prepareExternalUrl = function (url) {
|
331
|
if (url && url[0] !== '/') {
|
332
|
url = '/' + url;
|
333
|
}
|
334
|
return this._platformStrategy.prepareExternalUrl(url);
|
335
|
};
|
336
|
/**
|
337
|
* Changes the browsers URL to the normalized version of the given URL, and pushes a
|
338
|
* new item onto the platform's history.
|
339
|
* @param {?} path
|
340
|
* @param {?=} query
|
341
|
* @return {?}
|
342
|
*/
|
343
|
Location.prototype.go = function (path, query) {
|
344
|
if (query === void 0) { query = ''; }
|
345
|
this._platformStrategy.pushState(null, '', path, query);
|
346
|
};
|
347
|
/**
|
348
|
* Changes the browsers URL to the normalized version of the given URL, and replaces
|
349
|
* the top item on the platform's history stack.
|
350
|
* @param {?} path
|
351
|
* @param {?=} query
|
352
|
* @return {?}
|
353
|
*/
|
354
|
Location.prototype.replaceState = function (path, query) {
|
355
|
if (query === void 0) { query = ''; }
|
356
|
this._platformStrategy.replaceState(null, '', path, query);
|
357
|
};
|
358
|
/**
|
359
|
* Navigates forward in the platform's history.
|
360
|
* @return {?}
|
361
|
*/
|
362
|
Location.prototype.forward = function () { this._platformStrategy.forward(); };
|
363
|
/**
|
364
|
* Navigates back in the platform's history.
|
365
|
* @return {?}
|
366
|
*/
|
367
|
Location.prototype.back = function () { this._platformStrategy.back(); };
|
368
|
/**
|
369
|
* Subscribe to the platform's `popState` events.
|
370
|
* @param {?} onNext
|
371
|
* @param {?=} onThrow
|
372
|
* @param {?=} onReturn
|
373
|
* @return {?}
|
374
|
*/
|
375
|
Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
|
376
|
return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
|
377
|
};
|
378
|
/**
|
379
|
* Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as
|
380
|
* is.
|
381
|
* @param {?} params
|
382
|
* @return {?}
|
383
|
*/
|
384
|
Location.normalizeQueryParams = function (params) {
|
385
|
return params && params[0] !== '?' ? '?' + params : params;
|
386
|
};
|
387
|
/**
|
388
|
* Given 2 parts of a url, join them with a slash if needed.
|
389
|
* @param {?} start
|
390
|
* @param {?} end
|
391
|
* @return {?}
|
392
|
*/
|
393
|
Location.joinWithSlash = function (start, end) {
|
394
|
if (start.length == 0) {
|
395
|
return end;
|
396
|
}
|
397
|
if (end.length == 0) {
|
398
|
return start;
|
399
|
}
|
400
|
var /** @type {?} */ slashes = 0;
|
401
|
if (start.endsWith('/')) {
|
402
|
slashes++;
|
403
|
}
|
404
|
if (end.startsWith('/')) {
|
405
|
slashes++;
|
406
|
}
|
407
|
if (slashes == 2) {
|
408
|
return start + end.substring(1);
|
409
|
}
|
410
|
if (slashes == 1) {
|
411
|
return start + end;
|
412
|
}
|
413
|
return start + '/' + end;
|
414
|
};
|
415
|
/**
|
416
|
* If url has a trailing slash, remove it, otherwise return url as is. This
|
417
|
* method looks for the first occurence of either #, ?, or the end of the
|
418
|
* line as `/` characters after any of these should not be replaced.
|
419
|
* @param {?} url
|
420
|
* @return {?}
|
421
|
*/
|
422
|
Location.stripTrailingSlash = function (url) {
|
423
|
var /** @type {?} */ match = url.match(/#|\?|$/);
|
424
|
var /** @type {?} */ pathEndIdx = match && match.index || url.length;
|
425
|
var /** @type {?} */ droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
|
426
|
return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
|
427
|
};
|
428
|
return Location;
|
429
|
}());
|
430
|
Location.decorators = [
|
431
|
{ type: _angular_core.Injectable },
|
432
|
];
|
433
|
/**
|
434
|
* @nocollapse
|
435
|
*/
|
436
|
Location.ctorParameters = function () { return [
|
437
|
{ type: LocationStrategy, },
|
438
|
]; };
|
439
|
/**
|
440
|
* @param {?} baseHref
|
441
|
* @param {?} url
|
442
|
* @return {?}
|
443
|
*/
|
444
|
function _stripBaseHref(baseHref, url) {
|
445
|
return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
|
446
|
}
|
447
|
/**
|
448
|
* @param {?} url
|
449
|
* @return {?}
|
450
|
*/
|
451
|
function _stripIndexHtml(url) {
|
452
|
return url.replace(/\/index.html$/, '');
|
453
|
}
|
454
|
/**
|
455
|
* @license
|
456
|
* Copyright Google Inc. All Rights Reserved.
|
457
|
*
|
458
|
* Use of this source code is governed by an MIT-style license that can be
|
459
|
* found in the LICENSE file at https://angular.io/license
|
460
|
*/
|
461
|
/**
|
462
|
* \@whatItDoes Use URL hash for storing application location data.
|
463
|
* \@description
|
464
|
* `HashLocationStrategy` is a {\@link LocationStrategy} used to configure the
|
465
|
* {\@link Location} service to represent its state in the
|
466
|
* [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
|
467
|
* of the browser's URL.
|
468
|
*
|
469
|
* For instance, if you call `location.go('/foo')`, the browser's URL will become
|
470
|
* `example.com#/foo`.
|
471
|
*
|
472
|
* ### Example
|
473
|
*
|
474
|
* {\@example common/location/ts/hash_location_component.ts region='LocationComponent'}
|
475
|
*
|
476
|
* \@stable
|
477
|
*/
|
478
|
var HashLocationStrategy = (function (_super) {
|
479
|
__extends(HashLocationStrategy, _super);
|
480
|
/**
|
481
|
* @param {?} _platformLocation
|
482
|
* @param {?=} _baseHref
|
483
|
*/
|
484
|
function HashLocationStrategy(_platformLocation, _baseHref) {
|
485
|
var _this = _super.call(this) || this;
|
486
|
_this._platformLocation = _platformLocation;
|
487
|
_this._baseHref = '';
|
488
|
if (_baseHref != null) {
|
489
|
_this._baseHref = _baseHref;
|
490
|
}
|
491
|
return _this;
|
492
|
}
|
493
|
/**
|
494
|
* @param {?} fn
|
495
|
* @return {?}
|
496
|
*/
|
497
|
HashLocationStrategy.prototype.onPopState = function (fn) {
|
498
|
this._platformLocation.onPopState(fn);
|
499
|
this._platformLocation.onHashChange(fn);
|
500
|
};
|
501
|
/**
|
502
|
* @return {?}
|
503
|
*/
|
504
|
HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
|
505
|
/**
|
506
|
* @param {?=} includeHash
|
507
|
* @return {?}
|
508
|
*/
|
509
|
HashLocationStrategy.prototype.path = function (includeHash) {
|
510
|
if (includeHash === void 0) { includeHash = false; }
|
511
|
// the hash value is always prefixed with a `#`
|
512
|
// and if it is empty then it will stay empty
|
513
|
var /** @type {?} */ path = this._platformLocation.hash;
|
514
|
if (path == null)
|
515
|
path = '#';
|
516
|
return path.length > 0 ? path.substring(1) : path;
|
517
|
};
|
518
|
/**
|
519
|
* @param {?} internal
|
520
|
* @return {?}
|
521
|
*/
|
522
|
HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
|
523
|
var /** @type {?} */ url = Location.joinWithSlash(this._baseHref, internal);
|
524
|
return url.length > 0 ? ('#' + url) : url;
|
525
|
};
|
526
|
/**
|
527
|
* @param {?} state
|
528
|
* @param {?} title
|
529
|
* @param {?} path
|
530
|
* @param {?} queryParams
|
531
|
* @return {?}
|
532
|
*/
|
533
|
HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) {
|
534
|
var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
|
535
|
if (url.length == 0) {
|
536
|
url = this._platformLocation.pathname;
|
537
|
}
|
538
|
this._platformLocation.pushState(state, title, url);
|
539
|
};
|
540
|
/**
|
541
|
* @param {?} state
|
542
|
* @param {?} title
|
543
|
* @param {?} path
|
544
|
* @param {?} queryParams
|
545
|
* @return {?}
|
546
|
*/
|
547
|
HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) {
|
548
|
var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
|
549
|
if (url.length == 0) {
|
550
|
url = this._platformLocation.pathname;
|
551
|
}
|
552
|
this._platformLocation.replaceState(state, title, url);
|
553
|
};
|
554
|
/**
|
555
|
* @return {?}
|
556
|
*/
|
557
|
HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
|
558
|
/**
|
559
|
* @return {?}
|
560
|
*/
|
561
|
HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
|
562
|
return HashLocationStrategy;
|
563
|
}(LocationStrategy));
|
564
|
HashLocationStrategy.decorators = [
|
565
|
{ type: _angular_core.Injectable },
|
566
|
];
|
567
|
/**
|
568
|
* @nocollapse
|
569
|
*/
|
570
|
HashLocationStrategy.ctorParameters = function () { return [
|
571
|
{ type: PlatformLocation, },
|
572
|
{ type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [APP_BASE_HREF,] },] },
|
573
|
]; };
|
574
|
/**
|
575
|
* @license
|
576
|
* Copyright Google Inc. All Rights Reserved.
|
577
|
*
|
578
|
* Use of this source code is governed by an MIT-style license that can be
|
579
|
* found in the LICENSE file at https://angular.io/license
|
580
|
*/
|
581
|
/**
|
582
|
* \@whatItDoes Use URL for storing application location data.
|
583
|
* \@description
|
584
|
* `PathLocationStrategy` is a {\@link LocationStrategy} used to configure the
|
585
|
* {\@link Location} service to represent its state in the
|
586
|
* [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
|
587
|
* browser's URL.
|
588
|
*
|
589
|
* If you're using `PathLocationStrategy`, you must provide a {\@link APP_BASE_HREF}
|
590
|
* or add a base element to the document. This URL prefix that will be preserved
|
591
|
* when generating and recognizing URLs.
|
592
|
*
|
593
|
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
|
594
|
* `location.go('/foo')`, the browser's URL will become
|
595
|
* `example.com/my/app/foo`.
|
596
|
*
|
597
|
* Similarly, if you add `<base href='/my/app'/>` to the document and call
|
598
|
* `location.go('/foo')`, the browser's URL will become
|
599
|
* `example.com/my/app/foo`.
|
600
|
*
|
601
|
* ### Example
|
602
|
*
|
603
|
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
|
604
|
*
|
605
|
* \@stable
|
606
|
*/
|
607
|
var PathLocationStrategy = (function (_super) {
|
608
|
__extends(PathLocationStrategy, _super);
|
609
|
/**
|
610
|
* @param {?} _platformLocation
|
611
|
* @param {?=} href
|
612
|
*/
|
613
|
function PathLocationStrategy(_platformLocation, href) {
|
614
|
var _this = _super.call(this) || this;
|
615
|
_this._platformLocation = _platformLocation;
|
616
|
if (href == null) {
|
617
|
href = _this._platformLocation.getBaseHrefFromDOM();
|
618
|
}
|
619
|
if (href == null) {
|
620
|
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.");
|
621
|
}
|
622
|
_this._baseHref = href;
|
623
|
return _this;
|
624
|
}
|
625
|
/**
|
626
|
* @param {?} fn
|
627
|
* @return {?}
|
628
|
*/
|
629
|
PathLocationStrategy.prototype.onPopState = function (fn) {
|
630
|
this._platformLocation.onPopState(fn);
|
631
|
this._platformLocation.onHashChange(fn);
|
632
|
};
|
633
|
/**
|
634
|
* @return {?}
|
635
|
*/
|
636
|
PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
|
637
|
/**
|
638
|
* @param {?} internal
|
639
|
* @return {?}
|
640
|
*/
|
641
|
PathLocationStrategy.prototype.prepareExternalUrl = function (internal) {
|
642
|
return Location.joinWithSlash(this._baseHref, internal);
|
643
|
};
|
644
|
/**
|
645
|
* @param {?=} includeHash
|
646
|
* @return {?}
|
647
|
*/
|
648
|
PathLocationStrategy.prototype.path = function (includeHash) {
|
649
|
if (includeHash === void 0) { includeHash = false; }
|
650
|
var /** @type {?} */ pathname = this._platformLocation.pathname +
|
651
|
Location.normalizeQueryParams(this._platformLocation.search);
|
652
|
var /** @type {?} */ hash = this._platformLocation.hash;
|
653
|
return hash && includeHash ? "" + pathname + hash : pathname;
|
654
|
};
|
655
|
/**
|
656
|
* @param {?} state
|
657
|
* @param {?} title
|
658
|
* @param {?} url
|
659
|
* @param {?} queryParams
|
660
|
* @return {?}
|
661
|
*/
|
662
|
PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) {
|
663
|
var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
|
664
|
this._platformLocation.pushState(state, title, externalUrl);
|
665
|
};
|
666
|
/**
|
667
|
* @param {?} state
|
668
|
* @param {?} title
|
669
|
* @param {?} url
|
670
|
* @param {?} queryParams
|
671
|
* @return {?}
|
672
|
*/
|
673
|
PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) {
|
674
|
var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
|
675
|
this._platformLocation.replaceState(state, title, externalUrl);
|
676
|
};
|
677
|
/**
|
678
|
* @return {?}
|
679
|
*/
|
680
|
PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
|
681
|
/**
|
682
|
* @return {?}
|
683
|
*/
|
684
|
PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
|
685
|
return PathLocationStrategy;
|
686
|
}(LocationStrategy));
|
687
|
PathLocationStrategy.decorators = [
|
688
|
{ type: _angular_core.Injectable },
|
689
|
];
|
690
|
/**
|
691
|
* @nocollapse
|
692
|
*/
|
693
|
PathLocationStrategy.ctorParameters = function () { return [
|
694
|
{ type: PlatformLocation, },
|
695
|
{ type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [APP_BASE_HREF,] },] },
|
696
|
]; };
|
697
|
/**
|
698
|
* @license
|
699
|
* Copyright Google Inc. All Rights Reserved.
|
700
|
*
|
701
|
* Use of this source code is governed by an MIT-style license that can be
|
702
|
* found in the LICENSE file at https://angular.io/license
|
703
|
*/
|
704
|
/**
|
705
|
* @license
|
706
|
* Copyright Google Inc. All Rights Reserved.
|
707
|
*
|
708
|
* Use of this source code is governed by an MIT-style license that can be
|
709
|
* found in the LICENSE file at https://angular.io/license
|
710
|
*/
|
711
|
/**
|
712
|
* \@experimental
|
713
|
* @abstract
|
714
|
*/
|
715
|
var NgLocalization = (function () {
|
716
|
function NgLocalization() {
|
717
|
}
|
718
|
/**
|
719
|
* @abstract
|
720
|
* @param {?} value
|
721
|
* @return {?}
|
722
|
*/
|
723
|
NgLocalization.prototype.getPluralCategory = function (value) { };
|
724
|
return NgLocalization;
|
725
|
}());
|
726
|
/**
|
727
|
* Returns the plural category for a given value.
|
728
|
* - "=value" when the case exists,
|
729
|
* - the plural category otherwise
|
730
|
*
|
731
|
* \@internal
|
732
|
* @param {?} value
|
733
|
* @param {?} cases
|
734
|
* @param {?} ngLocalization
|
735
|
* @return {?}
|
736
|
*/
|
737
|
function getPluralCategory(value, cases, ngLocalization) {
|
738
|
var /** @type {?} */ key = "=" + value;
|
739
|
if (cases.indexOf(key) > -1) {
|
740
|
return key;
|
741
|
}
|
742
|
key = ngLocalization.getPluralCategory(value);
|
743
|
if (cases.indexOf(key) > -1) {
|
744
|
return key;
|
745
|
}
|
746
|
if (cases.indexOf('other') > -1) {
|
747
|
return 'other';
|
748
|
}
|
749
|
throw new Error("No plural message found for value \"" + value + "\"");
|
750
|
}
|
751
|
/**
|
752
|
* Returns the plural case based on the locale
|
753
|
*
|
754
|
* \@experimental
|
755
|
*/
|
756
|
var NgLocaleLocalization = (function (_super) {
|
757
|
__extends(NgLocaleLocalization, _super);
|
758
|
/**
|
759
|
* @param {?} locale
|
760
|
*/
|
761
|
function NgLocaleLocalization(locale) {
|
762
|
var _this = _super.call(this) || this;
|
763
|
_this.locale = locale;
|
764
|
return _this;
|
765
|
}
|
766
|
/**
|
767
|
* @param {?} value
|
768
|
* @return {?}
|
769
|
*/
|
770
|
NgLocaleLocalization.prototype.getPluralCategory = function (value) {
|
771
|
var /** @type {?} */ plural = getPluralCase(this.locale, value);
|
772
|
switch (plural) {
|
773
|
case Plural.Zero:
|
774
|
return 'zero';
|
775
|
case Plural.One:
|
776
|
return 'one';
|
777
|
case Plural.Two:
|
778
|
return 'two';
|
779
|
case Plural.Few:
|
780
|
return 'few';
|
781
|
case Plural.Many:
|
782
|
return 'many';
|
783
|
default:
|
784
|
return 'other';
|
785
|
}
|
786
|
};
|
787
|
return NgLocaleLocalization;
|
788
|
}(NgLocalization));
|
789
|
NgLocaleLocalization.decorators = [
|
790
|
{ type: _angular_core.Injectable },
|
791
|
];
|
792
|
/**
|
793
|
* @nocollapse
|
794
|
*/
|
795
|
NgLocaleLocalization.ctorParameters = function () { return [
|
796
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID,] },] },
|
797
|
]; };
|
798
|
var Plural = {};
|
799
|
Plural.Zero = 0;
|
800
|
Plural.One = 1;
|
801
|
Plural.Two = 2;
|
802
|
Plural.Few = 3;
|
803
|
Plural.Many = 4;
|
804
|
Plural.Other = 5;
|
805
|
Plural[Plural.Zero] = "Zero";
|
806
|
Plural[Plural.One] = "One";
|
807
|
Plural[Plural.Two] = "Two";
|
808
|
Plural[Plural.Few] = "Few";
|
809
|
Plural[Plural.Many] = "Many";
|
810
|
Plural[Plural.Other] = "Other";
|
811
|
/**
|
812
|
* Returns the plural case based on the locale
|
813
|
*
|
814
|
* \@experimental
|
815
|
* @param {?} locale
|
816
|
* @param {?} nLike
|
817
|
* @return {?}
|
818
|
*/
|
819
|
function getPluralCase(locale, nLike) {
|
820
|
// TODO(vicb): lazy compute
|
821
|
if (typeof nLike === 'string') {
|
822
|
nLike = parseInt(/** @type {?} */ (nLike), 10);
|
823
|
}
|
824
|
var /** @type {?} */ n = (nLike);
|
825
|
var /** @type {?} */ nDecimal = n.toString().replace(/^[^.]*\.?/, '');
|
826
|
var /** @type {?} */ i = Math.floor(Math.abs(n));
|
827
|
var /** @type {?} */ v = nDecimal.length;
|
828
|
var /** @type {?} */ f = parseInt(nDecimal, 10);
|
829
|
var /** @type {?} */ t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
|
830
|
var /** @type {?} */ lang = locale.split('-')[0].toLowerCase();
|
831
|
switch (lang) {
|
832
|
case 'af':
|
833
|
case 'asa':
|
834
|
case 'az':
|
835
|
case 'bem':
|
836
|
case 'bez':
|
837
|
case 'bg':
|
838
|
case 'brx':
|
839
|
case 'ce':
|
840
|
case 'cgg':
|
841
|
case 'chr':
|
842
|
case 'ckb':
|
843
|
case 'ee':
|
844
|
case 'el':
|
845
|
case 'eo':
|
846
|
case 'es':
|
847
|
case 'eu':
|
848
|
case 'fo':
|
849
|
case 'fur':
|
850
|
case 'gsw':
|
851
|
case 'ha':
|
852
|
case 'haw':
|
853
|
case 'hu':
|
854
|
case 'jgo':
|
855
|
case 'jmc':
|
856
|
case 'ka':
|
857
|
case 'kk':
|
858
|
case 'kkj':
|
859
|
case 'kl':
|
860
|
case 'ks':
|
861
|
case 'ksb':
|
862
|
case 'ky':
|
863
|
case 'lb':
|
864
|
case 'lg':
|
865
|
case 'mas':
|
866
|
case 'mgo':
|
867
|
case 'ml':
|
868
|
case 'mn':
|
869
|
case 'nb':
|
870
|
case 'nd':
|
871
|
case 'ne':
|
872
|
case 'nn':
|
873
|
case 'nnh':
|
874
|
case 'nyn':
|
875
|
case 'om':
|
876
|
case 'or':
|
877
|
case 'os':
|
878
|
case 'ps':
|
879
|
case 'rm':
|
880
|
case 'rof':
|
881
|
case 'rwk':
|
882
|
case 'saq':
|
883
|
case 'seh':
|
884
|
case 'sn':
|
885
|
case 'so':
|
886
|
case 'sq':
|
887
|
case 'ta':
|
888
|
case 'te':
|
889
|
case 'teo':
|
890
|
case 'tk':
|
891
|
case 'tr':
|
892
|
case 'ug':
|
893
|
case 'uz':
|
894
|
case 'vo':
|
895
|
case 'vun':
|
896
|
case 'wae':
|
897
|
case 'xog':
|
898
|
if (n === 1)
|
899
|
return Plural.One;
|
900
|
return Plural.Other;
|
901
|
case 'ak':
|
902
|
case 'ln':
|
903
|
case 'mg':
|
904
|
case 'pa':
|
905
|
case 'ti':
|
906
|
if (n === Math.floor(n) && n >= 0 && n <= 1)
|
907
|
return Plural.One;
|
908
|
return Plural.Other;
|
909
|
case 'am':
|
910
|
case 'as':
|
911
|
case 'bn':
|
912
|
case 'fa':
|
913
|
case 'gu':
|
914
|
case 'hi':
|
915
|
case 'kn':
|
916
|
case 'mr':
|
917
|
case 'zu':
|
918
|
if (i === 0 || n === 1)
|
919
|
return Plural.One;
|
920
|
return Plural.Other;
|
921
|
case 'ar':
|
922
|
if (n === 0)
|
923
|
return Plural.Zero;
|
924
|
if (n === 1)
|
925
|
return Plural.One;
|
926
|
if (n === 2)
|
927
|
return Plural.Two;
|
928
|
if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
|
929
|
return Plural.Few;
|
930
|
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
|
931
|
return Plural.Many;
|
932
|
return Plural.Other;
|
933
|
case 'ast':
|
934
|
case 'ca':
|
935
|
case 'de':
|
936
|
case 'en':
|
937
|
case 'et':
|
938
|
case 'fi':
|
939
|
case 'fy':
|
940
|
case 'gl':
|
941
|
case 'it':
|
942
|
case 'nl':
|
943
|
case 'sv':
|
944
|
case 'sw':
|
945
|
case 'ur':
|
946
|
case 'yi':
|
947
|
if (i === 1 && v === 0)
|
948
|
return Plural.One;
|
949
|
return Plural.Other;
|
950
|
case 'be':
|
951
|
if (n % 10 === 1 && !(n % 100 === 11))
|
952
|
return Plural.One;
|
953
|
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
|
954
|
!(n % 100 >= 12 && n % 100 <= 14))
|
955
|
return Plural.Few;
|
956
|
if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
|
957
|
n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
|
958
|
return Plural.Many;
|
959
|
return Plural.Other;
|
960
|
case 'br':
|
961
|
if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
|
962
|
return Plural.One;
|
963
|
if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
|
964
|
return Plural.Two;
|
965
|
if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
|
966
|
!(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
|
967
|
n % 100 >= 90 && n % 100 <= 99))
|
968
|
return Plural.Few;
|
969
|
if (!(n === 0) && n % 1e6 === 0)
|
970
|
return Plural.Many;
|
971
|
return Plural.Other;
|
972
|
case 'bs':
|
973
|
case 'hr':
|
974
|
case 'sr':
|
975
|
if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
|
976
|
return Plural.One;
|
977
|
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
|
978
|
!(i % 100 >= 12 && i % 100 <= 14) ||
|
979
|
f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
|
980
|
!(f % 100 >= 12 && f % 100 <= 14))
|
981
|
return Plural.Few;
|
982
|
return Plural.Other;
|
983
|
case 'cs':
|
984
|
case 'sk':
|
985
|
if (i === 1 && v === 0)
|
986
|
return Plural.One;
|
987
|
if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
|
988
|
return Plural.Few;
|
989
|
if (!(v === 0))
|
990
|
return Plural.Many;
|
991
|
return Plural.Other;
|
992
|
case 'cy':
|
993
|
if (n === 0)
|
994
|
return Plural.Zero;
|
995
|
if (n === 1)
|
996
|
return Plural.One;
|
997
|
if (n === 2)
|
998
|
return Plural.Two;
|
999
|
if (n === 3)
|
1000
|
return Plural.Few;
|
1001
|
if (n === 6)
|
1002
|
return Plural.Many;
|
1003
|
return Plural.Other;
|
1004
|
case 'da':
|
1005
|
if (n === 1 || !(t === 0) && (i === 0 || i === 1))
|
1006
|
return Plural.One;
|
1007
|
return Plural.Other;
|
1008
|
case 'dsb':
|
1009
|
case 'hsb':
|
1010
|
if (v === 0 && i % 100 === 1 || f % 100 === 1)
|
1011
|
return Plural.One;
|
1012
|
if (v === 0 && i % 100 === 2 || f % 100 === 2)
|
1013
|
return Plural.Two;
|
1014
|
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
|
1015
|
f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
|
1016
|
return Plural.Few;
|
1017
|
return Plural.Other;
|
1018
|
case 'ff':
|
1019
|
case 'fr':
|
1020
|
case 'hy':
|
1021
|
case 'kab':
|
1022
|
if (i === 0 || i === 1)
|
1023
|
return Plural.One;
|
1024
|
return Plural.Other;
|
1025
|
case 'fil':
|
1026
|
if (v === 0 && (i === 1 || i === 2 || i === 3) ||
|
1027
|
v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
|
1028
|
!(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
|
1029
|
return Plural.One;
|
1030
|
return Plural.Other;
|
1031
|
case 'ga':
|
1032
|
if (n === 1)
|
1033
|
return Plural.One;
|
1034
|
if (n === 2)
|
1035
|
return Plural.Two;
|
1036
|
if (n === Math.floor(n) && n >= 3 && n <= 6)
|
1037
|
return Plural.Few;
|
1038
|
if (n === Math.floor(n) && n >= 7 && n <= 10)
|
1039
|
return Plural.Many;
|
1040
|
return Plural.Other;
|
1041
|
case 'gd':
|
1042
|
if (n === 1 || n === 11)
|
1043
|
return Plural.One;
|
1044
|
if (n === 2 || n === 12)
|
1045
|
return Plural.Two;
|
1046
|
if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
|
1047
|
return Plural.Few;
|
1048
|
return Plural.Other;
|
1049
|
case 'gv':
|
1050
|
if (v === 0 && i % 10 === 1)
|
1051
|
return Plural.One;
|
1052
|
if (v === 0 && i % 10 === 2)
|
1053
|
return Plural.Two;
|
1054
|
if (v === 0 &&
|
1055
|
(i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
|
1056
|
return Plural.Few;
|
1057
|
if (!(v === 0))
|
1058
|
return Plural.Many;
|
1059
|
return Plural.Other;
|
1060
|
case 'he':
|
1061
|
if (i === 1 && v === 0)
|
1062
|
return Plural.One;
|
1063
|
if (i === 2 && v === 0)
|
1064
|
return Plural.Two;
|
1065
|
if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
|
1066
|
return Plural.Many;
|
1067
|
return Plural.Other;
|
1068
|
case 'is':
|
1069
|
if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
|
1070
|
return Plural.One;
|
1071
|
return Plural.Other;
|
1072
|
case 'ksh':
|
1073
|
if (n === 0)
|
1074
|
return Plural.Zero;
|
1075
|
if (n === 1)
|
1076
|
return Plural.One;
|
1077
|
return Plural.Other;
|
1078
|
case 'kw':
|
1079
|
case 'naq':
|
1080
|
case 'se':
|
1081
|
case 'smn':
|
1082
|
if (n === 1)
|
1083
|
return Plural.One;
|
1084
|
if (n === 2)
|
1085
|
return Plural.Two;
|
1086
|
return Plural.Other;
|
1087
|
case 'lag':
|
1088
|
if (n === 0)
|
1089
|
return Plural.Zero;
|
1090
|
if ((i === 0 || i === 1) && !(n === 0))
|
1091
|
return Plural.One;
|
1092
|
return Plural.Other;
|
1093
|
case 'lt':
|
1094
|
if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
|
1095
|
return Plural.One;
|
1096
|
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
|
1097
|
!(n % 100 >= 11 && n % 100 <= 19))
|
1098
|
return Plural.Few;
|
1099
|
if (!(f === 0))
|
1100
|
return Plural.Many;
|
1101
|
return Plural.Other;
|
1102
|
case 'lv':
|
1103
|
case 'prg':
|
1104
|
if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
|
1105
|
v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
|
1106
|
return Plural.Zero;
|
1107
|
if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
|
1108
|
!(v === 2) && f % 10 === 1)
|
1109
|
return Plural.One;
|
1110
|
return Plural.Other;
|
1111
|
case 'mk':
|
1112
|
if (v === 0 && i % 10 === 1 || f % 10 === 1)
|
1113
|
return Plural.One;
|
1114
|
return Plural.Other;
|
1115
|
case 'mt':
|
1116
|
if (n === 1)
|
1117
|
return Plural.One;
|
1118
|
if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
|
1119
|
return Plural.Few;
|
1120
|
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
|
1121
|
return Plural.Many;
|
1122
|
return Plural.Other;
|
1123
|
case 'pl':
|
1124
|
if (i === 1 && v === 0)
|
1125
|
return Plural.One;
|
1126
|
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
|
1127
|
!(i % 100 >= 12 && i % 100 <= 14))
|
1128
|
return Plural.Few;
|
1129
|
if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
|
1130
|
v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
|
1131
|
v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
|
1132
|
return Plural.Many;
|
1133
|
return Plural.Other;
|
1134
|
case 'pt':
|
1135
|
if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
|
1136
|
return Plural.One;
|
1137
|
return Plural.Other;
|
1138
|
case 'ro':
|
1139
|
if (i === 1 && v === 0)
|
1140
|
return Plural.One;
|
1141
|
if (!(v === 0) || n === 0 ||
|
1142
|
!(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
|
1143
|
return Plural.Few;
|
1144
|
return Plural.Other;
|
1145
|
case 'ru':
|
1146
|
case 'uk':
|
1147
|
if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
|
1148
|
return Plural.One;
|
1149
|
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
|
1150
|
!(i % 100 >= 12 && i % 100 <= 14))
|
1151
|
return Plural.Few;
|
1152
|
if (v === 0 && i % 10 === 0 ||
|
1153
|
v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
|
1154
|
v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
|
1155
|
return Plural.Many;
|
1156
|
return Plural.Other;
|
1157
|
case 'shi':
|
1158
|
if (i === 0 || n === 1)
|
1159
|
return Plural.One;
|
1160
|
if (n === Math.floor(n) && n >= 2 && n <= 10)
|
1161
|
return Plural.Few;
|
1162
|
return Plural.Other;
|
1163
|
case 'si':
|
1164
|
if (n === 0 || n === 1 || i === 0 && f === 1)
|
1165
|
return Plural.One;
|
1166
|
return Plural.Other;
|
1167
|
case 'sl':
|
1168
|
if (v === 0 && i % 100 === 1)
|
1169
|
return Plural.One;
|
1170
|
if (v === 0 && i % 100 === 2)
|
1171
|
return Plural.Two;
|
1172
|
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
|
1173
|
return Plural.Few;
|
1174
|
return Plural.Other;
|
1175
|
case 'tzm':
|
1176
|
if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
|
1177
|
return Plural.One;
|
1178
|
return Plural.Other;
|
1179
|
// When there is no specification, the default is always "other"
|
1180
|
// Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
|
1181
|
// > other (required—general plural form — also used if the language only has a single form)
|
1182
|
default:
|
1183
|
return Plural.Other;
|
1184
|
}
|
1185
|
}
|
1186
|
/**
|
1187
|
* @license
|
1188
|
* Copyright Google Inc. All Rights Reserved.
|
1189
|
*
|
1190
|
* Use of this source code is governed by an MIT-style license that can be
|
1191
|
* found in the LICENSE file at https://angular.io/license
|
1192
|
* @param {?} cookieStr
|
1193
|
* @param {?} name
|
1194
|
* @return {?}
|
1195
|
*/
|
1196
|
function parseCookieValue(cookieStr, name) {
|
1197
|
name = encodeURIComponent(name);
|
1198
|
for (var _i = 0, _a = cookieStr.split(';'); _i < _a.length; _i++) {
|
1199
|
var cookie = _a[_i];
|
1200
|
var /** @type {?} */ eqIndex = cookie.indexOf('=');
|
1201
|
var _b = eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)], cookieName = _b[0], cookieValue = _b[1];
|
1202
|
if (cookieName.trim() === name) {
|
1203
|
return decodeURIComponent(cookieValue);
|
1204
|
}
|
1205
|
}
|
1206
|
return null;
|
1207
|
}
|
1208
|
/**
|
1209
|
* @license
|
1210
|
* Copyright Google Inc. All Rights Reserved.
|
1211
|
*
|
1212
|
* Use of this source code is governed by an MIT-style license that can be
|
1213
|
* found in the LICENSE file at https://angular.io/license
|
1214
|
*/
|
1215
|
/**
|
1216
|
* \@ngModule CommonModule
|
1217
|
*
|
1218
|
* \@whatItDoes Adds and removes CSS classes on an HTML element.
|
1219
|
*
|
1220
|
* \@howToUse
|
1221
|
* ```
|
1222
|
* <some-element [ngClass]="'first second'">...</some-element>
|
1223
|
*
|
1224
|
* <some-element [ngClass]="['first', 'second']">...</some-element>
|
1225
|
*
|
1226
|
* <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
|
1227
|
*
|
1228
|
* <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
|
1229
|
*
|
1230
|
* <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
|
1231
|
* ```
|
1232
|
*
|
1233
|
* \@description
|
1234
|
*
|
1235
|
* The CSS classes are updated as follows, depending on the type of the expression evaluation:
|
1236
|
* - `string` - the CSS classes listed in the string (space delimited) are added,
|
1237
|
* - `Array` - the CSS classes declared as Array elements are added,
|
1238
|
* - `Object` - keys are CSS classes that get added when the expression given in the value
|
1239
|
* evaluates to a truthy value, otherwise they are removed.
|
1240
|
*
|
1241
|
* \@stable
|
1242
|
*/
|
1243
|
var NgClass = (function () {
|
1244
|
/**
|
1245
|
* @param {?} _iterableDiffers
|
1246
|
* @param {?} _keyValueDiffers
|
1247
|
* @param {?} _ngEl
|
1248
|
* @param {?} _renderer
|
1249
|
*/
|
1250
|
function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
|
1251
|
this._iterableDiffers = _iterableDiffers;
|
1252
|
this._keyValueDiffers = _keyValueDiffers;
|
1253
|
this._ngEl = _ngEl;
|
1254
|
this._renderer = _renderer;
|
1255
|
this._initialClasses = [];
|
1256
|
}
|
1257
|
Object.defineProperty(NgClass.prototype, "klass", {
|
1258
|
/**
|
1259
|
* @param {?} v
|
1260
|
* @return {?}
|
1261
|
*/
|
1262
|
set: function (v) {
|
1263
|
this._applyInitialClasses(true);
|
1264
|
this._initialClasses = typeof v === 'string' ? v.split(/\s+/) : [];
|
1265
|
this._applyInitialClasses(false);
|
1266
|
this._applyClasses(this._rawClass, false);
|
1267
|
},
|
1268
|
enumerable: true,
|
1269
|
configurable: true
|
1270
|
});
|
1271
|
Object.defineProperty(NgClass.prototype, "ngClass", {
|
1272
|
/**
|
1273
|
* @param {?} v
|
1274
|
* @return {?}
|
1275
|
*/
|
1276
|
set: function (v) {
|
1277
|
this._cleanupClasses(this._rawClass);
|
1278
|
this._iterableDiffer = null;
|
1279
|
this._keyValueDiffer = null;
|
1280
|
this._rawClass = typeof v === 'string' ? v.split(/\s+/) : v;
|
1281
|
if (this._rawClass) {
|
1282
|
if (_angular_core.ɵisListLikeIterable(this._rawClass)) {
|
1283
|
this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
|
1284
|
}
|
1285
|
else {
|
1286
|
this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
|
1287
|
}
|
1288
|
}
|
1289
|
},
|
1290
|
enumerable: true,
|
1291
|
configurable: true
|
1292
|
});
|
1293
|
/**
|
1294
|
* @return {?}
|
1295
|
*/
|
1296
|
NgClass.prototype.ngDoCheck = function () {
|
1297
|
if (this._iterableDiffer) {
|
1298
|
var /** @type {?} */ iterableChanges = this._iterableDiffer.diff(/** @type {?} */ (this._rawClass));
|
1299
|
if (iterableChanges) {
|
1300
|
this._applyIterableChanges(iterableChanges);
|
1301
|
}
|
1302
|
}
|
1303
|
else if (this._keyValueDiffer) {
|
1304
|
var /** @type {?} */ keyValueChanges = this._keyValueDiffer.diff(/** @type {?} */ (this._rawClass));
|
1305
|
if (keyValueChanges) {
|
1306
|
this._applyKeyValueChanges(keyValueChanges);
|
1307
|
}
|
1308
|
}
|
1309
|
};
|
1310
|
/**
|
1311
|
* @param {?} rawClassVal
|
1312
|
* @return {?}
|
1313
|
*/
|
1314
|
NgClass.prototype._cleanupClasses = function (rawClassVal) {
|
1315
|
this._applyClasses(rawClassVal, true);
|
1316
|
this._applyInitialClasses(false);
|
1317
|
};
|
1318
|
/**
|
1319
|
* @param {?} changes
|
1320
|
* @return {?}
|
1321
|
*/
|
1322
|
NgClass.prototype._applyKeyValueChanges = function (changes) {
|
1323
|
var _this = this;
|
1324
|
changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
|
1325
|
changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
|
1326
|
changes.forEachRemovedItem(function (record) {
|
1327
|
if (record.previousValue) {
|
1328
|
_this._toggleClass(record.key, false);
|
1329
|
}
|
1330
|
});
|
1331
|
};
|
1332
|
/**
|
1333
|
* @param {?} changes
|
1334
|
* @return {?}
|
1335
|
*/
|
1336
|
NgClass.prototype._applyIterableChanges = function (changes) {
|
1337
|
var _this = this;
|
1338
|
changes.forEachAddedItem(function (record) {
|
1339
|
if (typeof record.item === 'string') {
|
1340
|
_this._toggleClass(record.item, true);
|
1341
|
}
|
1342
|
else {
|
1343
|
throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + _angular_core.ɵstringify(record.item));
|
1344
|
}
|
1345
|
});
|
1346
|
changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); });
|
1347
|
};
|
1348
|
/**
|
1349
|
* @param {?} isCleanup
|
1350
|
* @return {?}
|
1351
|
*/
|
1352
|
NgClass.prototype._applyInitialClasses = function (isCleanup) {
|
1353
|
var _this = this;
|
1354
|
this._initialClasses.forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
|
1355
|
};
|
1356
|
/**
|
1357
|
* @param {?} rawClassVal
|
1358
|
* @param {?} isCleanup
|
1359
|
* @return {?}
|
1360
|
*/
|
1361
|
NgClass.prototype._applyClasses = function (rawClassVal, isCleanup) {
|
1362
|
var _this = this;
|
1363
|
if (rawClassVal) {
|
1364
|
if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
|
1365
|
((rawClassVal)).forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
|
1366
|
}
|
1367
|
else {
|
1368
|
Object.keys(rawClassVal).forEach(function (klass) {
|
1369
|
if (rawClassVal[klass] != null)
|
1370
|
_this._toggleClass(klass, !isCleanup);
|
1371
|
});
|
1372
|
}
|
1373
|
}
|
1374
|
};
|
1375
|
/**
|
1376
|
* @param {?} klass
|
1377
|
* @param {?} enabled
|
1378
|
* @return {?}
|
1379
|
*/
|
1380
|
NgClass.prototype._toggleClass = function (klass, enabled) {
|
1381
|
var _this = this;
|
1382
|
klass = klass.trim();
|
1383
|
if (klass) {
|
1384
|
klass.split(/\s+/g).forEach(function (klass) { _this._renderer.setElementClass(_this._ngEl.nativeElement, klass, !!enabled); });
|
1385
|
}
|
1386
|
};
|
1387
|
return NgClass;
|
1388
|
}());
|
1389
|
NgClass.decorators = [
|
1390
|
{ type: _angular_core.Directive, args: [{ selector: '[ngClass]' },] },
|
1391
|
];
|
1392
|
/**
|
1393
|
* @nocollapse
|
1394
|
*/
|
1395
|
NgClass.ctorParameters = function () { return [
|
1396
|
{ type: _angular_core.IterableDiffers, },
|
1397
|
{ type: _angular_core.KeyValueDiffers, },
|
1398
|
{ type: _angular_core.ElementRef, },
|
1399
|
{ type: _angular_core.Renderer, },
|
1400
|
]; };
|
1401
|
NgClass.propDecorators = {
|
1402
|
'klass': [{ type: _angular_core.Input, args: ['class',] },],
|
1403
|
'ngClass': [{ type: _angular_core.Input },],
|
1404
|
};
|
1405
|
/**
|
1406
|
* @license
|
1407
|
* Copyright Google Inc. All Rights Reserved.
|
1408
|
*
|
1409
|
* Use of this source code is governed by an MIT-style license that can be
|
1410
|
* found in the LICENSE file at https://angular.io/license
|
1411
|
*/
|
1412
|
/**
|
1413
|
* Instantiates a single {\@link Component} type and inserts its Host View into current View.
|
1414
|
* `NgComponentOutlet` provides a declarative approach for dynamic component creation.
|
1415
|
*
|
1416
|
* `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
|
1417
|
* any existing component will get destroyed.
|
1418
|
*
|
1419
|
* ### Fine tune control
|
1420
|
*
|
1421
|
* You can control the component creation process by using the following optional attributes:
|
1422
|
*
|
1423
|
* * `ngComponentOutletInjector`: Optional custom {\@link Injector} that will be used as parent for
|
1424
|
* the Component. Defaults to the injector of the current view container.
|
1425
|
*
|
1426
|
* * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
|
1427
|
* section of the component, if exists.
|
1428
|
*
|
1429
|
* * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
|
1430
|
* module, then load a component from that module.
|
1431
|
*
|
1432
|
* ### Syntax
|
1433
|
*
|
1434
|
* Simple
|
1435
|
* ```
|
1436
|
* <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
|
1437
|
* ```
|
1438
|
*
|
1439
|
* Customized injector/content
|
1440
|
* ```
|
1441
|
* <ng-container *ngComponentOutlet="componentTypeExpression;
|
1442
|
* injector: injectorExpression;
|
1443
|
* content: contentNodesExpression;">
|
1444
|
* </ng-container>
|
1445
|
* ```
|
1446
|
*
|
1447
|
* Customized ngModuleFactory
|
1448
|
* ```
|
1449
|
* <ng-container *ngComponentOutlet="componentTypeExpression;
|
1450
|
* ngModuleFactory: moduleFactory;">
|
1451
|
* </ng-container>
|
1452
|
* ```
|
1453
|
* ## Example
|
1454
|
*
|
1455
|
* {\@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
|
1456
|
*
|
1457
|
* A more complete example with additional options:
|
1458
|
*
|
1459
|
* {\@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
|
1460
|
* A more complete example with ngModuleFactory:
|
1461
|
*
|
1462
|
* {\@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'}
|
1463
|
*
|
1464
|
* \@experimental
|
1465
|
*/
|
1466
|
var NgComponentOutlet = (function () {
|
1467
|
/**
|
1468
|
* @param {?} _viewContainerRef
|
1469
|
*/
|
1470
|
function NgComponentOutlet(_viewContainerRef) {
|
1471
|
this._viewContainerRef = _viewContainerRef;
|
1472
|
this._componentRef = null;
|
1473
|
this._moduleRef = null;
|
1474
|
}
|
1475
|
/**
|
1476
|
* @param {?} changes
|
1477
|
* @return {?}
|
1478
|
*/
|
1479
|
NgComponentOutlet.prototype.ngOnChanges = function (changes) {
|
1480
|
this._viewContainerRef.clear();
|
1481
|
this._componentRef = null;
|
1482
|
if (this.ngComponentOutlet) {
|
1483
|
var /** @type {?} */ elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
|
1484
|
if (changes['ngComponentOutletNgModuleFactory']) {
|
1485
|
if (this._moduleRef)
|
1486
|
this._moduleRef.destroy();
|
1487
|
if (this.ngComponentOutletNgModuleFactory) {
|
1488
|
var /** @type {?} */ parentModule = elInjector.get(_angular_core.NgModuleRef);
|
1489
|
this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
|
1490
|
}
|
1491
|
else {
|
1492
|
this._moduleRef = null;
|
1493
|
}
|
1494
|
}
|
1495
|
var /** @type {?} */ componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
|
1496
|
elInjector.get(_angular_core.ComponentFactoryResolver);
|
1497
|
var /** @type {?} */ componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
|
1498
|
this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
|
1499
|
}
|
1500
|
};
|
1501
|
/**
|
1502
|
* @return {?}
|
1503
|
*/
|
1504
|
NgComponentOutlet.prototype.ngOnDestroy = function () {
|
1505
|
if (this._moduleRef)
|
1506
|
this._moduleRef.destroy();
|
1507
|
};
|
1508
|
return NgComponentOutlet;
|
1509
|
}());
|
1510
|
NgComponentOutlet.decorators = [
|
1511
|
{ type: _angular_core.Directive, args: [{ selector: '[ngComponentOutlet]' },] },
|
1512
|
];
|
1513
|
/**
|
1514
|
* @nocollapse
|
1515
|
*/
|
1516
|
NgComponentOutlet.ctorParameters = function () { return [
|
1517
|
{ type: _angular_core.ViewContainerRef, },
|
1518
|
]; };
|
1519
|
NgComponentOutlet.propDecorators = {
|
1520
|
'ngComponentOutlet': [{ type: _angular_core.Input },],
|
1521
|
'ngComponentOutletInjector': [{ type: _angular_core.Input },],
|
1522
|
'ngComponentOutletContent': [{ type: _angular_core.Input },],
|
1523
|
'ngComponentOutletNgModuleFactory': [{ type: _angular_core.Input },],
|
1524
|
};
|
1525
|
/**
|
1526
|
* @license
|
1527
|
* Copyright Google Inc. All Rights Reserved.
|
1528
|
*
|
1529
|
* Use of this source code is governed by an MIT-style license that can be
|
1530
|
* found in the LICENSE file at https://angular.io/license
|
1531
|
*/
|
1532
|
/**
|
1533
|
* \@stable
|
1534
|
*/
|
1535
|
var NgForOfContext = (function () {
|
1536
|
/**
|
1537
|
* @param {?} $implicit
|
1538
|
* @param {?} ngForOf
|
1539
|
* @param {?} index
|
1540
|
* @param {?} count
|
1541
|
*/
|
1542
|
function NgForOfContext($implicit, ngForOf, index, count) {
|
1543
|
this.$implicit = $implicit;
|
1544
|
this.ngForOf = ngForOf;
|
1545
|
this.index = index;
|
1546
|
this.count = count;
|
1547
|
}
|
1548
|
Object.defineProperty(NgForOfContext.prototype, "first", {
|
1549
|
/**
|
1550
|
* @return {?}
|
1551
|
*/
|
1552
|
get: function () { return this.index === 0; },
|
1553
|
enumerable: true,
|
1554
|
configurable: true
|
1555
|
});
|
1556
|
Object.defineProperty(NgForOfContext.prototype, "last", {
|
1557
|
/**
|
1558
|
* @return {?}
|
1559
|
*/
|
1560
|
get: function () { return this.index === this.count - 1; },
|
1561
|
enumerable: true,
|
1562
|
configurable: true
|
1563
|
});
|
1564
|
Object.defineProperty(NgForOfContext.prototype, "even", {
|
1565
|
/**
|
1566
|
* @return {?}
|
1567
|
*/
|
1568
|
get: function () { return this.index % 2 === 0; },
|
1569
|
enumerable: true,
|
1570
|
configurable: true
|
1571
|
});
|
1572
|
Object.defineProperty(NgForOfContext.prototype, "odd", {
|
1573
|
/**
|
1574
|
* @return {?}
|
1575
|
*/
|
1576
|
get: function () { return !this.even; },
|
1577
|
enumerable: true,
|
1578
|
configurable: true
|
1579
|
});
|
1580
|
return NgForOfContext;
|
1581
|
}());
|
1582
|
/**
|
1583
|
* The `NgForOf` directive instantiates a template once per item from an iterable. The context
|
1584
|
* for each instantiated template inherits from the outer context with the given loop variable
|
1585
|
* set to the current item from the iterable.
|
1586
|
*
|
1587
|
* ### Local Variables
|
1588
|
*
|
1589
|
* `NgForOf` provides several exported values that can be aliased to local variables:
|
1590
|
*
|
1591
|
* - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
|
1592
|
* - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
|
1593
|
* more complex then a property access, for example when using the async pipe (`userStreams |
|
1594
|
* async`).
|
1595
|
* - `index: number`: The index of the current item in the iterable.
|
1596
|
* - `first: boolean`: True when the item is the first item in the iterable.
|
1597
|
* - `last: boolean`: True when the item is the last item in the iterable.
|
1598
|
* - `even: boolean`: True when the item has an even index in the iterable.
|
1599
|
* - `odd: boolean`: True when the item has an odd index in the iterable.
|
1600
|
*
|
1601
|
* ```
|
1602
|
* <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
|
1603
|
* {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
|
1604
|
* </li>
|
1605
|
* ```
|
1606
|
*
|
1607
|
* ### Change Propagation
|
1608
|
*
|
1609
|
* When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
|
1610
|
*
|
1611
|
* * When an item is added, a new instance of the template is added to the DOM.
|
1612
|
* * When an item is removed, its template instance is removed from the DOM.
|
1613
|
* * When items are reordered, their respective templates are reordered in the DOM.
|
1614
|
* * Otherwise, the DOM element for that item will remain the same.
|
1615
|
*
|
1616
|
* Angular uses object identity to track insertions and deletions within the iterator and reproduce
|
1617
|
* those changes in the DOM. This has important implications for animations and any stateful
|
1618
|
* controls (such as `<input>` elements which accept user input) that are present. Inserted rows can
|
1619
|
* be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
|
1620
|
* such as user input.
|
1621
|
*
|
1622
|
* It is possible for the identities of elements in the iterator to change while the data does not.
|
1623
|
* This can happen, for example, if the iterator produced from an RPC to the server, and that
|
1624
|
* RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
|
1625
|
* different identities, and Angular will tear down the entire DOM and rebuild it (as if all old
|
1626
|
* elements were deleted and all new elements inserted). This is an expensive operation and should
|
1627
|
* be avoided if possible.
|
1628
|
*
|
1629
|
* To customize the default tracking algorithm, `NgForOf` supports `trackBy` option.
|
1630
|
* `trackBy` takes a function which has two arguments: `index` and `item`.
|
1631
|
* If `trackBy` is given, Angular tracks changes by the return value of the function.
|
1632
|
*
|
1633
|
* ### Syntax
|
1634
|
*
|
1635
|
* - `<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>`
|
1636
|
* - `<li template="ngFor let item of items; index as i; trackBy: trackByFn">...</li>`
|
1637
|
*
|
1638
|
* With `<ng-template>` element:
|
1639
|
*
|
1640
|
* ```
|
1641
|
* <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
|
1642
|
* <li>...</li>
|
1643
|
* </ng-template>
|
1644
|
* ```
|
1645
|
*
|
1646
|
* ### Example
|
1647
|
*
|
1648
|
* See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
|
1649
|
* example.
|
1650
|
*
|
1651
|
* \@stable
|
1652
|
*/
|
1653
|
var NgForOf = (function () {
|
1654
|
/**
|
1655
|
* @param {?} _viewContainer
|
1656
|
* @param {?} _template
|
1657
|
* @param {?} _differs
|
1658
|
*/
|
1659
|
function NgForOf(_viewContainer, _template, _differs) {
|
1660
|
this._viewContainer = _viewContainer;
|
1661
|
this._template = _template;
|
1662
|
this._differs = _differs;
|
1663
|
this._differ = null;
|
1664
|
}
|
1665
|
Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
|
1666
|
/**
|
1667
|
* @return {?}
|
1668
|
*/
|
1669
|
get: function () { return this._trackByFn; },
|
1670
|
/**
|
1671
|
* @param {?} fn
|
1672
|
* @return {?}
|
1673
|
*/
|
1674
|
set: function (fn) {
|
1675
|
if (_angular_core.isDevMode() && fn != null && typeof fn !== 'function') {
|
1676
|
// TODO(vicb): use a log service once there is a public one available
|
1677
|
if ((console) && (console.warn)) {
|
1678
|
console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " +
|
1679
|
"See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
|
1680
|
}
|
1681
|
}
|
1682
|
this._trackByFn = fn;
|
1683
|
},
|
1684
|
enumerable: true,
|
1685
|
configurable: true
|
1686
|
});
|
1687
|
Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
|
1688
|
/**
|
1689
|
* @param {?} value
|
1690
|
* @return {?}
|
1691
|
*/
|
1692
|
set: function (value) {
|
1693
|
// TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
|
1694
|
// The current type is too restrictive; a template that just uses index, for example,
|
1695
|
// should be acceptable.
|
1696
|
if (value) {
|
1697
|
this._template = value;
|
1698
|
}
|
1699
|
},
|
1700
|
enumerable: true,
|
1701
|
configurable: true
|
1702
|
});
|
1703
|
/**
|
1704
|
* @param {?} changes
|
1705
|
* @return {?}
|
1706
|
*/
|
1707
|
NgForOf.prototype.ngOnChanges = function (changes) {
|
1708
|
if ('ngForOf' in changes) {
|
1709
|
// React on ngForOf changes only once all inputs have been initialized
|
1710
|
var /** @type {?} */ value = changes['ngForOf'].currentValue;
|
1711
|
if (!this._differ && value) {
|
1712
|
try {
|
1713
|
this._differ = this._differs.find(value).create(this.ngForTrackBy);
|
1714
|
}
|
1715
|
catch (e) {
|
1716
|
throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeNameForDebugging(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
|
1717
|
}
|
1718
|
}
|
1719
|
}
|
1720
|
};
|
1721
|
/**
|
1722
|
* @return {?}
|
1723
|
*/
|
1724
|
NgForOf.prototype.ngDoCheck = function () {
|
1725
|
if (this._differ) {
|
1726
|
var /** @type {?} */ changes = this._differ.diff(this.ngForOf);
|
1727
|
if (changes)
|
1728
|
this._applyChanges(changes);
|
1729
|
}
|
1730
|
};
|
1731
|
/**
|
1732
|
* @param {?} changes
|
1733
|
* @return {?}
|
1734
|
*/
|
1735
|
NgForOf.prototype._applyChanges = function (changes) {
|
1736
|
var _this = this;
|
1737
|
var /** @type {?} */ insertTuples = [];
|
1738
|
changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
|
1739
|
if (item.previousIndex == null) {
|
1740
|
var /** @type {?} */ view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(/** @type {?} */ ((null)), _this.ngForOf, -1, -1), currentIndex);
|
1741
|
var /** @type {?} */ tuple = new RecordViewTuple(item, view);
|
1742
|
insertTuples.push(tuple);
|
1743
|
}
|
1744
|
else if (currentIndex == null) {
|
1745
|
_this._viewContainer.remove(adjustedPreviousIndex);
|
1746
|
}
|
1747
|
else {
|
1748
|
var /** @type {?} */ view = ((_this._viewContainer.get(adjustedPreviousIndex)));
|
1749
|
_this._viewContainer.move(view, currentIndex);
|
1750
|
var /** @type {?} */ tuple = new RecordViewTuple(item, /** @type {?} */ (view));
|
1751
|
insertTuples.push(tuple);
|
1752
|
}
|
1753
|
});
|
1754
|
for (var /** @type {?} */ i = 0; i < insertTuples.length; i++) {
|
1755
|
this._perViewChange(insertTuples[i].view, insertTuples[i].record);
|
1756
|
}
|
1757
|
for (var /** @type {?} */ i = 0, /** @type {?} */ ilen = this._viewContainer.length; i < ilen; i++) {
|
1758
|
var /** @type {?} */ viewRef = (this._viewContainer.get(i));
|
1759
|
viewRef.context.index = i;
|
1760
|
viewRef.context.count = ilen;
|
1761
|
}
|
1762
|
changes.forEachIdentityChange(function (record) {
|
1763
|
var /** @type {?} */ viewRef = (_this._viewContainer.get(record.currentIndex));
|
1764
|
viewRef.context.$implicit = record.item;
|
1765
|
});
|
1766
|
};
|
1767
|
/**
|
1768
|
* @param {?} view
|
1769
|
* @param {?} record
|
1770
|
* @return {?}
|
1771
|
*/
|
1772
|
NgForOf.prototype._perViewChange = function (view, record) {
|
1773
|
view.context.$implicit = record.item;
|
1774
|
};
|
1775
|
return NgForOf;
|
1776
|
}());
|
1777
|
NgForOf.decorators = [
|
1778
|
{ type: _angular_core.Directive, args: [{ selector: '[ngFor][ngForOf]' },] },
|
1779
|
];
|
1780
|
/**
|
1781
|
* @nocollapse
|
1782
|
*/
|
1783
|
NgForOf.ctorParameters = function () { return [
|
1784
|
{ type: _angular_core.ViewContainerRef, },
|
1785
|
{ type: _angular_core.TemplateRef, },
|
1786
|
{ type: _angular_core.IterableDiffers, },
|
1787
|
]; };
|
1788
|
NgForOf.propDecorators = {
|
1789
|
'ngForOf': [{ type: _angular_core.Input },],
|
1790
|
'ngForTrackBy': [{ type: _angular_core.Input },],
|
1791
|
'ngForTemplate': [{ type: _angular_core.Input },],
|
1792
|
};
|
1793
|
var RecordViewTuple = (function () {
|
1794
|
/**
|
1795
|
* @param {?} record
|
1796
|
* @param {?} view
|
1797
|
*/
|
1798
|
function RecordViewTuple(record, view) {
|
1799
|
this.record = record;
|
1800
|
this.view = view;
|
1801
|
}
|
1802
|
return RecordViewTuple;
|
1803
|
}());
|
1804
|
/**
|
1805
|
* @deprecated from v4.0.0 - Use NgForOf instead.
|
1806
|
*/
|
1807
|
var NgFor = NgForOf;
|
1808
|
/**
|
1809
|
* @param {?} type
|
1810
|
* @return {?}
|
1811
|
*/
|
1812
|
function getTypeNameForDebugging(type) {
|
1813
|
return type['name'] || typeof type;
|
1814
|
}
|
1815
|
/**
|
1816
|
* @license
|
1817
|
* Copyright Google Inc. All Rights Reserved.
|
1818
|
*
|
1819
|
* Use of this source code is governed by an MIT-style license that can be
|
1820
|
* found in the LICENSE file at https://angular.io/license
|
1821
|
*/
|
1822
|
/**
|
1823
|
* Conditionally includes a template based on the value of an `expression`.
|
1824
|
*
|
1825
|
* `ngIf` evaluates the `expression` and then renders the `then` or `else` template in its place
|
1826
|
* when expression is truthy or falsy respectively. Typically the:
|
1827
|
* - `then` template is the inline template of `ngIf` unless bound to a different value.
|
1828
|
* - `else` template is blank unless it is bound.
|
1829
|
*
|
1830
|
* ## Most common usage
|
1831
|
*
|
1832
|
* The most common usage of the `ngIf` directive is to conditionally show the inline template as
|
1833
|
* seen in this example:
|
1834
|
* {\@example common/ngIf/ts/module.ts region='NgIfSimple'}
|
1835
|
*
|
1836
|
* ## Showing an alternative template using `else`
|
1837
|
*
|
1838
|
* If it is necessary to display a template when the `expression` is falsy use the `else` template
|
1839
|
* binding as shown. Note that the `else` binding points to a `<ng-template>` labeled `#elseBlock`.
|
1840
|
* The template can be defined anywhere in the component view but is typically placed right after
|
1841
|
* `ngIf` for readability.
|
1842
|
*
|
1843
|
* {\@example common/ngIf/ts/module.ts region='NgIfElse'}
|
1844
|
*
|
1845
|
* ## Using non-inlined `then` template
|
1846
|
*
|
1847
|
* Usually the `then` template is the inlined template of the `ngIf`, but it can be changed using
|
1848
|
* a binding (just like `else`). Because `then` and `else` are bindings, the template references can
|
1849
|
* change at runtime as shown in this example.
|
1850
|
*
|
1851
|
* {\@example common/ngIf/ts/module.ts region='NgIfThenElse'}
|
1852
|
*
|
1853
|
* ## Storing conditional result in a variable
|
1854
|
*
|
1855
|
* A common pattern is that we need to show a set of properties from the same object. If the
|
1856
|
* object is undefined, then we have to use the safe-traversal-operator `?.` to guard against
|
1857
|
* dereferencing a `null` value. This is especially the case when waiting on async data such as
|
1858
|
* when using the `async` pipe as shown in following example:
|
1859
|
*
|
1860
|
* ```
|
1861
|
* Hello {{ (userStream|async)?.last }}, {{ (userStream|async)?.first }}!
|
1862
|
* ```
|
1863
|
*
|
1864
|
* There are several inefficiencies in the above example:
|
1865
|
* - We create multiple subscriptions on `userStream`. One for each `async` pipe, or two in the
|
1866
|
* example above.
|
1867
|
* - We cannot display an alternative screen while waiting for the data to arrive asynchronously.
|
1868
|
* - We have to use the safe-traversal-operator `?.` to access properties, which is cumbersome.
|
1869
|
* - We have to place the `async` pipe in parenthesis.
|
1870
|
*
|
1871
|
* A better way to do this is to use `ngIf` and store the result of the condition in a local
|
1872
|
* variable as shown in the the example below:
|
1873
|
*
|
1874
|
* {\@example common/ngIf/ts/module.ts region='NgIfAs'}
|
1875
|
*
|
1876
|
* Notice that:
|
1877
|
* - We use only one `async` pipe and hence only one subscription gets created.
|
1878
|
* - `ngIf` stores the result of the `userStream|async` in the local variable `user`.
|
1879
|
* - The local `user` can then be bound repeatedly in a more efficient way.
|
1880
|
* - No need to use the safe-traversal-operator `?.` to access properties as `ngIf` will only
|
1881
|
* display the data if `userStream` returns a value.
|
1882
|
* - We can display an alternative template while waiting for the data.
|
1883
|
*
|
1884
|
* ### Syntax
|
1885
|
*
|
1886
|
* Simple form:
|
1887
|
* - `<div *ngIf="condition">...</div>`
|
1888
|
* - `<div template="ngIf condition">...</div>`
|
1889
|
* - `<ng-template [ngIf]="condition"><div>...</div></ng-template>`
|
1890
|
*
|
1891
|
* Form with an else block:
|
1892
|
* ```
|
1893
|
* <div *ngIf="condition; else elseBlock">...</div>
|
1894
|
* <ng-template #elseBlock>...</ng-template>
|
1895
|
* ```
|
1896
|
*
|
1897
|
* Form with a `then` and `else` block:
|
1898
|
* ```
|
1899
|
* <div *ngIf="condition; then thenBlock else elseBlock"></div>
|
1900
|
* <ng-template #thenBlock>...</ng-template>
|
1901
|
* <ng-template #elseBlock>...</ng-template>
|
1902
|
* ```
|
1903
|
*
|
1904
|
* Form with storing the value locally:
|
1905
|
* ```
|
1906
|
* <div *ngIf="condition as value; else elseBlock">{{value}}</div>
|
1907
|
* <ng-template #elseBlock>...</ng-template>
|
1908
|
* ```
|
1909
|
*
|
1910
|
* \@stable
|
1911
|
*/
|
1912
|
var NgIf = (function () {
|
1913
|
/**
|
1914
|
* @param {?} _viewContainer
|
1915
|
* @param {?} templateRef
|
1916
|
*/
|
1917
|
function NgIf(_viewContainer, templateRef) {
|
1918
|
this._viewContainer = _viewContainer;
|
1919
|
this._context = new NgIfContext();
|
1920
|
this._thenTemplateRef = null;
|
1921
|
this._elseTemplateRef = null;
|
1922
|
this._thenViewRef = null;
|
1923
|
this._elseViewRef = null;
|
1924
|
this._thenTemplateRef = templateRef;
|
1925
|
}
|
1926
|
Object.defineProperty(NgIf.prototype, "ngIf", {
|
1927
|
/**
|
1928
|
* @param {?} condition
|
1929
|
* @return {?}
|
1930
|
*/
|
1931
|
set: function (condition) {
|
1932
|
this._context.$implicit = this._context.ngIf = condition;
|
1933
|
this._updateView();
|
1934
|
},
|
1935
|
enumerable: true,
|
1936
|
configurable: true
|
1937
|
});
|
1938
|
Object.defineProperty(NgIf.prototype, "ngIfThen", {
|
1939
|
/**
|
1940
|
* @param {?} templateRef
|
1941
|
* @return {?}
|
1942
|
*/
|
1943
|
set: function (templateRef) {
|
1944
|
this._thenTemplateRef = templateRef;
|
1945
|
this._thenViewRef = null; // clear previous view if any.
|
1946
|
this._updateView();
|
1947
|
},
|
1948
|
enumerable: true,
|
1949
|
configurable: true
|
1950
|
});
|
1951
|
Object.defineProperty(NgIf.prototype, "ngIfElse", {
|
1952
|
/**
|
1953
|
* @param {?} templateRef
|
1954
|
* @return {?}
|
1955
|
*/
|
1956
|
set: function (templateRef) {
|
1957
|
this._elseTemplateRef = templateRef;
|
1958
|
this._elseViewRef = null; // clear previous view if any.
|
1959
|
this._updateView();
|
1960
|
},
|
1961
|
enumerable: true,
|
1962
|
configurable: true
|
1963
|
});
|
1964
|
/**
|
1965
|
* @return {?}
|
1966
|
*/
|
1967
|
NgIf.prototype._updateView = function () {
|
1968
|
if (this._context.$implicit) {
|
1969
|
if (!this._thenViewRef) {
|
1970
|
this._viewContainer.clear();
|
1971
|
this._elseViewRef = null;
|
1972
|
if (this._thenTemplateRef) {
|
1973
|
this._thenViewRef =
|
1974
|
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
|
1975
|
}
|
1976
|
}
|
1977
|
}
|
1978
|
else {
|
1979
|
if (!this._elseViewRef) {
|
1980
|
this._viewContainer.clear();
|
1981
|
this._thenViewRef = null;
|
1982
|
if (this._elseTemplateRef) {
|
1983
|
this._elseViewRef =
|
1984
|
this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
|
1985
|
}
|
1986
|
}
|
1987
|
}
|
1988
|
};
|
1989
|
return NgIf;
|
1990
|
}());
|
1991
|
NgIf.decorators = [
|
1992
|
{ type: _angular_core.Directive, args: [{ selector: '[ngIf]' },] },
|
1993
|
];
|
1994
|
/**
|
1995
|
* @nocollapse
|
1996
|
*/
|
1997
|
NgIf.ctorParameters = function () { return [
|
1998
|
{ type: _angular_core.ViewContainerRef, },
|
1999
|
{ type: _angular_core.TemplateRef, },
|
2000
|
]; };
|
2001
|
NgIf.propDecorators = {
|
2002
|
'ngIf': [{ type: _angular_core.Input },],
|
2003
|
'ngIfThen': [{ type: _angular_core.Input },],
|
2004
|
'ngIfElse': [{ type: _angular_core.Input },],
|
2005
|
};
|
2006
|
/**
|
2007
|
* \@stable
|
2008
|
*/
|
2009
|
var NgIfContext = (function () {
|
2010
|
function NgIfContext() {
|
2011
|
this.$implicit = null;
|
2012
|
this.ngIf = null;
|
2013
|
}
|
2014
|
return NgIfContext;
|
2015
|
}());
|
2016
|
/**
|
2017
|
* @license
|
2018
|
* Copyright Google Inc. All Rights Reserved.
|
2019
|
*
|
2020
|
* Use of this source code is governed by an MIT-style license that can be
|
2021
|
* found in the LICENSE file at https://angular.io/license
|
2022
|
*/
|
2023
|
var SwitchView = (function () {
|
2024
|
/**
|
2025
|
* @param {?} _viewContainerRef
|
2026
|
* @param {?} _templateRef
|
2027
|
*/
|
2028
|
function SwitchView(_viewContainerRef, _templateRef) {
|
2029
|
this._viewContainerRef = _viewContainerRef;
|
2030
|
this._templateRef = _templateRef;
|
2031
|
this._created = false;
|
2032
|
}
|
2033
|
/**
|
2034
|
* @return {?}
|
2035
|
*/
|
2036
|
SwitchView.prototype.create = function () {
|
2037
|
this._created = true;
|
2038
|
this._viewContainerRef.createEmbeddedView(this._templateRef);
|
2039
|
};
|
2040
|
/**
|
2041
|
* @return {?}
|
2042
|
*/
|
2043
|
SwitchView.prototype.destroy = function () {
|
2044
|
this._created = false;
|
2045
|
this._viewContainerRef.clear();
|
2046
|
};
|
2047
|
/**
|
2048
|
* @param {?} created
|
2049
|
* @return {?}
|
2050
|
*/
|
2051
|
SwitchView.prototype.enforceState = function (created) {
|
2052
|
if (created && !this._created) {
|
2053
|
this.create();
|
2054
|
}
|
2055
|
else if (!created && this._created) {
|
2056
|
this.destroy();
|
2057
|
}
|
2058
|
};
|
2059
|
return SwitchView;
|
2060
|
}());
|
2061
|
/**
|
2062
|
* \@ngModule CommonModule
|
2063
|
*
|
2064
|
* \@whatItDoes Adds / removes DOM sub-trees when the nest match expressions matches the switch
|
2065
|
* expression.
|
2066
|
*
|
2067
|
* \@howToUse
|
2068
|
* ```
|
2069
|
* <container-element [ngSwitch]="switch_expression">
|
2070
|
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
|
2071
|
* <some-element *ngSwitchCase="match_expression_2">...</some-element>
|
2072
|
* <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
|
2073
|
* <ng-container *ngSwitchCase="match_expression_3">
|
2074
|
* <!-- use a ng-container to group multiple root nodes -->
|
2075
|
* <inner-element></inner-element>
|
2076
|
* <inner-other-element></inner-other-element>
|
2077
|
* </ng-container>
|
2078
|
* <some-element *ngSwitchDefault>...</some-element>
|
2079
|
* </container-element>
|
2080
|
* ```
|
2081
|
* \@description
|
2082
|
*
|
2083
|
* `NgSwitch` stamps out nested views when their match expression value matches the value of the
|
2084
|
* switch expression.
|
2085
|
*
|
2086
|
* In other words:
|
2087
|
* - you define a container element (where you place the directive with a switch expression on the
|
2088
|
* `[ngSwitch]="..."` attribute)
|
2089
|
* - you define inner views inside the `NgSwitch` and place a `*ngSwitchCase` attribute on the view
|
2090
|
* root elements.
|
2091
|
*
|
2092
|
* Elements within `NgSwitch` but outside of a `NgSwitchCase` or `NgSwitchDefault` directives will
|
2093
|
* be preserved at the location.
|
2094
|
*
|
2095
|
* The `ngSwitchCase` directive informs the parent `NgSwitch` of which view to display when the
|
2096
|
* expression is evaluated.
|
2097
|
* When no matching expression is found on a `ngSwitchCase` view, the `ngSwitchDefault` view is
|
2098
|
* stamped out.
|
2099
|
*
|
2100
|
* \@stable
|
2101
|
*/
|
2102
|
var NgSwitch = (function () {
|
2103
|
function NgSwitch() {
|
2104
|
this._defaultUsed = false;
|
2105
|
this._caseCount = 0;
|
2106
|
this._lastCaseCheckIndex = 0;
|
2107
|
this._lastCasesMatched = false;
|
2108
|
}
|
2109
|
Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
|
2110
|
/**
|
2111
|
* @param {?} newValue
|
2112
|
* @return {?}
|
2113
|
*/
|
2114
|
set: function (newValue) {
|
2115
|
this._ngSwitch = newValue;
|
2116
|
if (this._caseCount === 0) {
|
2117
|
this._updateDefaultCases(true);
|
2118
|
}
|
2119
|
},
|
2120
|
enumerable: true,
|
2121
|
configurable: true
|
2122
|
});
|
2123
|
/**
|
2124
|
* \@internal
|
2125
|
* @return {?}
|
2126
|
*/
|
2127
|
NgSwitch.prototype._addCase = function () { return this._caseCount++; };
|
2128
|
/**
|
2129
|
* \@internal
|
2130
|
* @param {?} view
|
2131
|
* @return {?}
|
2132
|
*/
|
2133
|
NgSwitch.prototype._addDefault = function (view) {
|
2134
|
if (!this._defaultViews) {
|
2135
|
this._defaultViews = [];
|
2136
|
}
|
2137
|
this._defaultViews.push(view);
|
2138
|
};
|
2139
|
/**
|
2140
|
* \@internal
|
2141
|
* @param {?} value
|
2142
|
* @return {?}
|
2143
|
*/
|
2144
|
NgSwitch.prototype._matchCase = function (value) {
|
2145
|
var /** @type {?} */ matched = value == this._ngSwitch;
|
2146
|
this._lastCasesMatched = this._lastCasesMatched || matched;
|
2147
|
this._lastCaseCheckIndex++;
|
2148
|
if (this._lastCaseCheckIndex === this._caseCount) {
|
2149
|
this._updateDefaultCases(!this._lastCasesMatched);
|
2150
|
this._lastCaseCheckIndex = 0;
|
2151
|
this._lastCasesMatched = false;
|
2152
|
}
|
2153
|
return matched;
|
2154
|
};
|
2155
|
/**
|
2156
|
* @param {?} useDefault
|
2157
|
* @return {?}
|
2158
|
*/
|
2159
|
NgSwitch.prototype._updateDefaultCases = function (useDefault) {
|
2160
|
if (this._defaultViews && useDefault !== this._defaultUsed) {
|
2161
|
this._defaultUsed = useDefault;
|
2162
|
for (var /** @type {?} */ i = 0; i < this._defaultViews.length; i++) {
|
2163
|
var /** @type {?} */ defaultView = this._defaultViews[i];
|
2164
|
defaultView.enforceState(useDefault);
|
2165
|
}
|
2166
|
}
|
2167
|
};
|
2168
|
return NgSwitch;
|
2169
|
}());
|
2170
|
NgSwitch.decorators = [
|
2171
|
{ type: _angular_core.Directive, args: [{ selector: '[ngSwitch]' },] },
|
2172
|
];
|
2173
|
/**
|
2174
|
* @nocollapse
|
2175
|
*/
|
2176
|
NgSwitch.ctorParameters = function () { return []; };
|
2177
|
NgSwitch.propDecorators = {
|
2178
|
'ngSwitch': [{ type: _angular_core.Input },],
|
2179
|
};
|
2180
|
/**
|
2181
|
* \@ngModule CommonModule
|
2182
|
*
|
2183
|
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgSwitch} when the
|
2184
|
* given expression evaluate to respectively the same/different value as the switch
|
2185
|
* expression.
|
2186
|
*
|
2187
|
* \@howToUse
|
2188
|
* ```
|
2189
|
* <container-element [ngSwitch]="switch_expression">
|
2190
|
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
|
2191
|
* </container-element>
|
2192
|
* ```
|
2193
|
* \@description
|
2194
|
*
|
2195
|
* Insert the sub-tree when the expression evaluates to the same value as the enclosing switch
|
2196
|
* expression.
|
2197
|
*
|
2198
|
* If multiple match expressions match the switch expression value, all of them are displayed.
|
2199
|
*
|
2200
|
* See {\@link NgSwitch} for more details and example.
|
2201
|
*
|
2202
|
* \@stable
|
2203
|
*/
|
2204
|
var NgSwitchCase = (function () {
|
2205
|
/**
|
2206
|
* @param {?} viewContainer
|
2207
|
* @param {?} templateRef
|
2208
|
* @param {?} ngSwitch
|
2209
|
*/
|
2210
|
function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
|
2211
|
this.ngSwitch = ngSwitch;
|
2212
|
ngSwitch._addCase();
|
2213
|
this._view = new SwitchView(viewContainer, templateRef);
|
2214
|
}
|
2215
|
/**
|
2216
|
* @return {?}
|
2217
|
*/
|
2218
|
NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); };
|
2219
|
return NgSwitchCase;
|
2220
|
}());
|
2221
|
NgSwitchCase.decorators = [
|
2222
|
{ type: _angular_core.Directive, args: [{ selector: '[ngSwitchCase]' },] },
|
2223
|
];
|
2224
|
/**
|
2225
|
* @nocollapse
|
2226
|
*/
|
2227
|
NgSwitchCase.ctorParameters = function () { return [
|
2228
|
{ type: _angular_core.ViewContainerRef, },
|
2229
|
{ type: _angular_core.TemplateRef, },
|
2230
|
{ type: NgSwitch, decorators: [{ type: _angular_core.Host },] },
|
2231
|
]; };
|
2232
|
NgSwitchCase.propDecorators = {
|
2233
|
'ngSwitchCase': [{ type: _angular_core.Input },],
|
2234
|
};
|
2235
|
/**
|
2236
|
* \@ngModule CommonModule
|
2237
|
* \@whatItDoes Creates a view that is added to the parent {\@link NgSwitch} when no case expressions
|
2238
|
* match the
|
2239
|
* switch expression.
|
2240
|
*
|
2241
|
* \@howToUse
|
2242
|
* ```
|
2243
|
* <container-element [ngSwitch]="switch_expression">
|
2244
|
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
|
2245
|
* <some-other-element *ngSwitchDefault>...</some-other-element>
|
2246
|
* </container-element>
|
2247
|
* ```
|
2248
|
*
|
2249
|
* \@description
|
2250
|
*
|
2251
|
* Insert the sub-tree when no case expressions evaluate to the same value as the enclosing switch
|
2252
|
* expression.
|
2253
|
*
|
2254
|
* See {\@link NgSwitch} for more details and example.
|
2255
|
*
|
2256
|
* \@stable
|
2257
|
*/
|
2258
|
var NgSwitchDefault = (function () {
|
2259
|
/**
|
2260
|
* @param {?} viewContainer
|
2261
|
* @param {?} templateRef
|
2262
|
* @param {?} ngSwitch
|
2263
|
*/
|
2264
|
function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
|
2265
|
ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
|
2266
|
}
|
2267
|
return NgSwitchDefault;
|
2268
|
}());
|
2269
|
NgSwitchDefault.decorators = [
|
2270
|
{ type: _angular_core.Directive, args: [{ selector: '[ngSwitchDefault]' },] },
|
2271
|
];
|
2272
|
/**
|
2273
|
* @nocollapse
|
2274
|
*/
|
2275
|
NgSwitchDefault.ctorParameters = function () { return [
|
2276
|
{ type: _angular_core.ViewContainerRef, },
|
2277
|
{ type: _angular_core.TemplateRef, },
|
2278
|
{ type: NgSwitch, decorators: [{ type: _angular_core.Host },] },
|
2279
|
]; };
|
2280
|
/**
|
2281
|
* @license
|
2282
|
* Copyright Google Inc. All Rights Reserved.
|
2283
|
*
|
2284
|
* Use of this source code is governed by an MIT-style license that can be
|
2285
|
* found in the LICENSE file at https://angular.io/license
|
2286
|
*/
|
2287
|
/**
|
2288
|
* \@ngModule CommonModule
|
2289
|
*
|
2290
|
* \@whatItDoes Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
|
2291
|
*
|
2292
|
* \@howToUse
|
2293
|
* ```
|
2294
|
* <some-element [ngPlural]="value">
|
2295
|
* <ng-template ngPluralCase="=0">there is nothing</ng-template>
|
2296
|
* <ng-template ngPluralCase="=1">there is one</ng-template>
|
2297
|
* <ng-template ngPluralCase="few">there are a few</ng-template>
|
2298
|
* </some-element>
|
2299
|
* ```
|
2300
|
*
|
2301
|
* \@description
|
2302
|
*
|
2303
|
* Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
|
2304
|
* that match the switch expression's pluralization category.
|
2305
|
*
|
2306
|
* To use this directive you must provide a container element that sets the `[ngPlural]` attribute
|
2307
|
* to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
|
2308
|
* expression:
|
2309
|
* - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
|
2310
|
* matches the switch expression exactly,
|
2311
|
* - otherwise, the view will be treated as a "category match", and will only display if exact
|
2312
|
* value matches aren't found and the value maps to its category for the defined locale.
|
2313
|
*
|
2314
|
* See http://cldr.unicode.org/index/cldr-spec/plural-rules
|
2315
|
*
|
2316
|
* \@experimental
|
2317
|
*/
|
2318
|
var NgPlural = (function () {
|
2319
|
/**
|
2320
|
* @param {?} _localization
|
2321
|
*/
|
2322
|
function NgPlural(_localization) {
|
2323
|
this._localization = _localization;
|
2324
|
this._caseViews = {};
|
2325
|
}
|
2326
|
Object.defineProperty(NgPlural.prototype, "ngPlural", {
|
2327
|
/**
|
2328
|
* @param {?} value
|
2329
|
* @return {?}
|
2330
|
*/
|
2331
|
set: function (value) {
|
2332
|
this._switchValue = value;
|
2333
|
this._updateView();
|
2334
|
},
|
2335
|
enumerable: true,
|
2336
|
configurable: true
|
2337
|
});
|
2338
|
/**
|
2339
|
* @param {?} value
|
2340
|
* @param {?} switchView
|
2341
|
* @return {?}
|
2342
|
*/
|
2343
|
NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; };
|
2344
|
/**
|
2345
|
* @return {?}
|
2346
|
*/
|
2347
|
NgPlural.prototype._updateView = function () {
|
2348
|
this._clearViews();
|
2349
|
var /** @type {?} */ cases = Object.keys(this._caseViews);
|
2350
|
var /** @type {?} */ key = getPluralCategory(this._switchValue, cases, this._localization);
|
2351
|
this._activateView(this._caseViews[key]);
|
2352
|
};
|
2353
|
/**
|
2354
|
* @return {?}
|
2355
|
*/
|
2356
|
NgPlural.prototype._clearViews = function () {
|
2357
|
if (this._activeView)
|
2358
|
this._activeView.destroy();
|
2359
|
};
|
2360
|
/**
|
2361
|
* @param {?} view
|
2362
|
* @return {?}
|
2363
|
*/
|
2364
|
NgPlural.prototype._activateView = function (view) {
|
2365
|
if (view) {
|
2366
|
this._activeView = view;
|
2367
|
this._activeView.create();
|
2368
|
}
|
2369
|
};
|
2370
|
return NgPlural;
|
2371
|
}());
|
2372
|
NgPlural.decorators = [
|
2373
|
{ type: _angular_core.Directive, args: [{ selector: '[ngPlural]' },] },
|
2374
|
];
|
2375
|
/**
|
2376
|
* @nocollapse
|
2377
|
*/
|
2378
|
NgPlural.ctorParameters = function () { return [
|
2379
|
{ type: NgLocalization, },
|
2380
|
]; };
|
2381
|
NgPlural.propDecorators = {
|
2382
|
'ngPlural': [{ type: _angular_core.Input },],
|
2383
|
};
|
2384
|
/**
|
2385
|
* \@ngModule CommonModule
|
2386
|
*
|
2387
|
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgPlural} when the
|
2388
|
* given expression matches the plural expression according to CLDR rules.
|
2389
|
*
|
2390
|
* \@howToUse
|
2391
|
* ```
|
2392
|
* <some-element [ngPlural]="value">
|
2393
|
* <ng-template ngPluralCase="=0">...</ng-template>
|
2394
|
* <ng-template ngPluralCase="other">...</ng-template>
|
2395
|
* </some-element>
|
2396
|
* ```
|
2397
|
*
|
2398
|
* See {\@link NgPlural} for more details and example.
|
2399
|
*
|
2400
|
* \@experimental
|
2401
|
*/
|
2402
|
var NgPluralCase = (function () {
|
2403
|
/**
|
2404
|
* @param {?} value
|
2405
|
* @param {?} template
|
2406
|
* @param {?} viewContainer
|
2407
|
* @param {?} ngPlural
|
2408
|
*/
|
2409
|
function NgPluralCase(value, template, viewContainer, ngPlural) {
|
2410
|
this.value = value;
|
2411
|
var isANumber = !isNaN(Number(value));
|
2412
|
ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
|
2413
|
}
|
2414
|
return NgPluralCase;
|
2415
|
}());
|
2416
|
NgPluralCase.decorators = [
|
2417
|
{ type: _angular_core.Directive, args: [{ selector: '[ngPluralCase]' },] },
|
2418
|
];
|
2419
|
/**
|
2420
|
* @nocollapse
|
2421
|
*/
|
2422
|
NgPluralCase.ctorParameters = function () { return [
|
2423
|
{ type: undefined, decorators: [{ type: _angular_core.Attribute, args: ['ngPluralCase',] },] },
|
2424
|
{ type: _angular_core.TemplateRef, },
|
2425
|
{ type: _angular_core.ViewContainerRef, },
|
2426
|
{ type: NgPlural, decorators: [{ type: _angular_core.Host },] },
|
2427
|
]; };
|
2428
|
/**
|
2429
|
* @license
|
2430
|
* Copyright Google Inc. All Rights Reserved.
|
2431
|
*
|
2432
|
* Use of this source code is governed by an MIT-style license that can be
|
2433
|
* found in the LICENSE file at https://angular.io/license
|
2434
|
*/
|
2435
|
/**
|
2436
|
* \@ngModule CommonModule
|
2437
|
*
|
2438
|
* \@whatItDoes Update an HTML element styles.
|
2439
|
*
|
2440
|
* \@howToUse
|
2441
|
* ```
|
2442
|
* <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
|
2443
|
*
|
2444
|
* <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
|
2445
|
*
|
2446
|
* <some-element [ngStyle]="objExp">...</some-element>
|
2447
|
* ```
|
2448
|
*
|
2449
|
* \@description
|
2450
|
*
|
2451
|
* The styles are updated according to the value of the expression evaluation:
|
2452
|
* - keys are style names with an optional `.<unit>` suffix (ie 'top.px', 'font-style.em'),
|
2453
|
* - values are the values assigned to those properties (expressed in the given unit).
|
2454
|
*
|
2455
|
* \@stable
|
2456
|
*/
|
2457
|
var NgStyle = (function () {
|
2458
|
/**
|
2459
|
* @param {?} _differs
|
2460
|
* @param {?} _ngEl
|
2461
|
* @param {?} _renderer
|
2462
|
*/
|
2463
|
function NgStyle(_differs, _ngEl, _renderer) {
|
2464
|
this._differs = _differs;
|
2465
|
this._ngEl = _ngEl;
|
2466
|
this._renderer = _renderer;
|
2467
|
}
|
2468
|
Object.defineProperty(NgStyle.prototype, "ngStyle", {
|
2469
|
/**
|
2470
|
* @param {?} v
|
2471
|
* @return {?}
|
2472
|
*/
|
2473
|
set: function (v) {
|
2474
|
this._ngStyle = v;
|
2475
|
if (!this._differ && v) {
|
2476
|
this._differ = this._differs.find(v).create();
|
2477
|
}
|
2478
|
},
|
2479
|
enumerable: true,
|
2480
|
configurable: true
|
2481
|
});
|
2482
|
/**
|
2483
|
* @return {?}
|
2484
|
*/
|
2485
|
NgStyle.prototype.ngDoCheck = function () {
|
2486
|
if (this._differ) {
|
2487
|
var /** @type {?} */ changes = this._differ.diff(this._ngStyle);
|
2488
|
if (changes) {
|
2489
|
this._applyChanges(changes);
|
2490
|
}
|
2491
|
}
|
2492
|
};
|
2493
|
/**
|
2494
|
* @param {?} changes
|
2495
|
* @return {?}
|
2496
|
*/
|
2497
|
NgStyle.prototype._applyChanges = function (changes) {
|
2498
|
var _this = this;
|
2499
|
changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); });
|
2500
|
changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
|
2501
|
changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
|
2502
|
};
|
2503
|
/**
|
2504
|
* @param {?} nameAndUnit
|
2505
|
* @param {?} value
|
2506
|
* @return {?}
|
2507
|
*/
|
2508
|
NgStyle.prototype._setStyle = function (nameAndUnit, value) {
|
2509
|
var _a = nameAndUnit.split('.'), name = _a[0], unit = _a[1];
|
2510
|
value = value != null && unit ? "" + value + unit : value;
|
2511
|
this._renderer.setElementStyle(this._ngEl.nativeElement, name, /** @type {?} */ (value));
|
2512
|
};
|
2513
|
return NgStyle;
|
2514
|
}());
|
2515
|
NgStyle.decorators = [
|
2516
|
{ type: _angular_core.Directive, args: [{ selector: '[ngStyle]' },] },
|
2517
|
];
|
2518
|
/**
|
2519
|
* @nocollapse
|
2520
|
*/
|
2521
|
NgStyle.ctorParameters = function () { return [
|
2522
|
{ type: _angular_core.KeyValueDiffers, },
|
2523
|
{ type: _angular_core.ElementRef, },
|
2524
|
{ type: _angular_core.Renderer, },
|
2525
|
]; };
|
2526
|
NgStyle.propDecorators = {
|
2527
|
'ngStyle': [{ type: _angular_core.Input },],
|
2528
|
};
|
2529
|
/**
|
2530
|
* @license
|
2531
|
* Copyright Google Inc. All Rights Reserved.
|
2532
|
*
|
2533
|
* Use of this source code is governed by an MIT-style license that can be
|
2534
|
* found in the LICENSE file at https://angular.io/license
|
2535
|
*/
|
2536
|
/**
|
2537
|
* \@ngModule CommonModule
|
2538
|
*
|
2539
|
* \@whatItDoes Inserts an embedded view from a prepared `TemplateRef`
|
2540
|
*
|
2541
|
* \@howToUse
|
2542
|
* ```
|
2543
|
* <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
|
2544
|
* ```
|
2545
|
*
|
2546
|
* \@description
|
2547
|
*
|
2548
|
* You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
|
2549
|
* `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
|
2550
|
* by the local template `let` declarations.
|
2551
|
*
|
2552
|
* Note: using the key `$implicit` in the context object will set it's value as default.
|
2553
|
*
|
2554
|
* ## Example
|
2555
|
*
|
2556
|
* {\@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
|
2557
|
*
|
2558
|
* \@experimental
|
2559
|
*/
|
2560
|
var NgTemplateOutlet = (function () {
|
2561
|
/**
|
2562
|
* @param {?} _viewContainerRef
|
2563
|
*/
|
2564
|
function NgTemplateOutlet(_viewContainerRef) {
|
2565
|
this._viewContainerRef = _viewContainerRef;
|
2566
|
}
|
2567
|
Object.defineProperty(NgTemplateOutlet.prototype, "ngOutletContext", {
|
2568
|
/**
|
2569
|
* @deprecated v4.0.0 - Renamed to ngTemplateOutletContext.
|
2570
|
* @param {?} context
|
2571
|
* @return {?}
|
2572
|
*/
|
2573
|
set: function (context) { this.ngTemplateOutletContext = context; },
|
2574
|
enumerable: true,
|
2575
|
configurable: true
|
2576
|
});
|
2577
|
/**
|
2578
|
* @param {?} changes
|
2579
|
* @return {?}
|
2580
|
*/
|
2581
|
NgTemplateOutlet.prototype.ngOnChanges = function (changes) {
|
2582
|
if (this._viewRef) {
|
2583
|
this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
|
2584
|
}
|
2585
|
if (this.ngTemplateOutlet) {
|
2586
|
this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
|
2587
|
}
|
2588
|
};
|
2589
|
return NgTemplateOutlet;
|
2590
|
}());
|
2591
|
NgTemplateOutlet.decorators = [
|
2592
|
{ type: _angular_core.Directive, args: [{ selector: '[ngTemplateOutlet]' },] },
|
2593
|
];
|
2594
|
/**
|
2595
|
* @nocollapse
|
2596
|
*/
|
2597
|
NgTemplateOutlet.ctorParameters = function () { return [
|
2598
|
{ type: _angular_core.ViewContainerRef, },
|
2599
|
]; };
|
2600
|
NgTemplateOutlet.propDecorators = {
|
2601
|
'ngTemplateOutletContext': [{ type: _angular_core.Input },],
|
2602
|
'ngTemplateOutlet': [{ type: _angular_core.Input },],
|
2603
|
'ngOutletContext': [{ type: _angular_core.Input },],
|
2604
|
};
|
2605
|
/**
|
2606
|
* @license
|
2607
|
* Copyright Google Inc. All Rights Reserved.
|
2608
|
*
|
2609
|
* Use of this source code is governed by an MIT-style license that can be
|
2610
|
* found in the LICENSE file at https://angular.io/license
|
2611
|
*/
|
2612
|
/**
|
2613
|
* A collection of Angular directives that are likely to be used in each and every Angular
|
2614
|
* application.
|
2615
|
*/
|
2616
|
var COMMON_DIRECTIVES = [
|
2617
|
NgClass,
|
2618
|
NgComponentOutlet,
|
2619
|
NgForOf,
|
2620
|
NgIf,
|
2621
|
NgTemplateOutlet,
|
2622
|
NgStyle,
|
2623
|
NgSwitch,
|
2624
|
NgSwitchCase,
|
2625
|
NgSwitchDefault,
|
2626
|
NgPlural,
|
2627
|
NgPluralCase,
|
2628
|
];
|
2629
|
/**
|
2630
|
* A collection of deprecated directives that are no longer part of the core module.
|
2631
|
*/
|
2632
|
/**
|
2633
|
* @license
|
2634
|
* Copyright Google Inc. All Rights Reserved.
|
2635
|
*
|
2636
|
* Use of this source code is governed by an MIT-style license that can be
|
2637
|
* found in the LICENSE file at https://angular.io/license
|
2638
|
*/
|
2639
|
/**
|
2640
|
* @param {?} type
|
2641
|
* @param {?} value
|
2642
|
* @return {?}
|
2643
|
*/
|
2644
|
function invalidPipeArgumentError(type, value) {
|
2645
|
return Error("InvalidPipeArgument: '" + value + "' for pipe '" + _angular_core.ɵstringify(type) + "'");
|
2646
|
}
|
2647
|
/**
|
2648
|
* @license
|
2649
|
* Copyright Google Inc. All Rights Reserved.
|
2650
|
*
|
2651
|
* Use of this source code is governed by an MIT-style license that can be
|
2652
|
* found in the LICENSE file at https://angular.io/license
|
2653
|
*/
|
2654
|
var ObservableStrategy = (function () {
|
2655
|
function ObservableStrategy() {
|
2656
|
}
|
2657
|
/**
|
2658
|
* @param {?} async
|
2659
|
* @param {?} updateLatestValue
|
2660
|
* @return {?}
|
2661
|
*/
|
2662
|
ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
|
2663
|
return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } });
|
2664
|
};
|
2665
|
/**
|
2666
|
* @param {?} subscription
|
2667
|
* @return {?}
|
2668
|
*/
|
2669
|
ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); };
|
2670
|
/**
|
2671
|
* @param {?} subscription
|
2672
|
* @return {?}
|
2673
|
*/
|
2674
|
ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); };
|
2675
|
return ObservableStrategy;
|
2676
|
}());
|
2677
|
var PromiseStrategy = (function () {
|
2678
|
function PromiseStrategy() {
|
2679
|
}
|
2680
|
/**
|
2681
|
* @param {?} async
|
2682
|
* @param {?} updateLatestValue
|
2683
|
* @return {?}
|
2684
|
*/
|
2685
|
PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
|
2686
|
return async.then(updateLatestValue, function (e) { throw e; });
|
2687
|
};
|
2688
|
/**
|
2689
|
* @param {?} subscription
|
2690
|
* @return {?}
|
2691
|
*/
|
2692
|
PromiseStrategy.prototype.dispose = function (subscription) { };
|
2693
|
/**
|
2694
|
* @param {?} subscription
|
2695
|
* @return {?}
|
2696
|
*/
|
2697
|
PromiseStrategy.prototype.onDestroy = function (subscription) { };
|
2698
|
return PromiseStrategy;
|
2699
|
}());
|
2700
|
var _promiseStrategy = new PromiseStrategy();
|
2701
|
var _observableStrategy = new ObservableStrategy();
|
2702
|
/**
|
2703
|
* \@ngModule CommonModule
|
2704
|
* \@whatItDoes Unwraps a value from an asynchronous primitive.
|
2705
|
* \@howToUse `observable_or_promise_expression | async`
|
2706
|
* \@description
|
2707
|
* The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
|
2708
|
* emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
|
2709
|
* changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
|
2710
|
* potential memory leaks.
|
2711
|
*
|
2712
|
*
|
2713
|
* ## Examples
|
2714
|
*
|
2715
|
* This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
|
2716
|
* promise.
|
2717
|
*
|
2718
|
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
|
2719
|
*
|
2720
|
* It's also possible to use `async` with Observables. The example below binds the `time` Observable
|
2721
|
* to the view. The Observable continuously updates the view with the current time.
|
2722
|
*
|
2723
|
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
|
2724
|
*
|
2725
|
* \@stable
|
2726
|
*/
|
2727
|
var AsyncPipe = (function () {
|
2728
|
/**
|
2729
|
* @param {?} _ref
|
2730
|
*/
|
2731
|
function AsyncPipe(_ref) {
|
2732
|
this._ref = _ref;
|
2733
|
this._latestValue = null;
|
2734
|
this._latestReturnedValue = null;
|
2735
|
this._subscription = null;
|
2736
|
this._obj = null;
|
2737
|
this._strategy = ((null));
|
2738
|
}
|
2739
|
/**
|
2740
|
* @return {?}
|
2741
|
*/
|
2742
|
AsyncPipe.prototype.ngOnDestroy = function () {
|
2743
|
if (this._subscription) {
|
2744
|
this._dispose();
|
2745
|
}
|
2746
|
};
|
2747
|
/**
|
2748
|
* @param {?} obj
|
2749
|
* @return {?}
|
2750
|
*/
|
2751
|
AsyncPipe.prototype.transform = function (obj) {
|
2752
|
if (!this._obj) {
|
2753
|
if (obj) {
|
2754
|
this._subscribe(obj);
|
2755
|
}
|
2756
|
this._latestReturnedValue = this._latestValue;
|
2757
|
return this._latestValue;
|
2758
|
}
|
2759
|
if (obj !== this._obj) {
|
2760
|
this._dispose();
|
2761
|
return this.transform(/** @type {?} */ (obj));
|
2762
|
}
|
2763
|
if (this._latestValue === this._latestReturnedValue) {
|
2764
|
return this._latestReturnedValue;
|
2765
|
}
|
2766
|
this._latestReturnedValue = this._latestValue;
|
2767
|
return _angular_core.WrappedValue.wrap(this._latestValue);
|
2768
|
};
|
2769
|
/**
|
2770
|
* @param {?} obj
|
2771
|
* @return {?}
|
2772
|
*/
|
2773
|
AsyncPipe.prototype._subscribe = function (obj) {
|
2774
|
var _this = this;
|
2775
|
this._obj = obj;
|
2776
|
this._strategy = this._selectStrategy(obj);
|
2777
|
this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
|
2778
|
};
|
2779
|
/**
|
2780
|
* @param {?} obj
|
2781
|
* @return {?}
|
2782
|
*/
|
2783
|
AsyncPipe.prototype._selectStrategy = function (obj) {
|
2784
|
if (_angular_core.ɵisPromise(obj)) {
|
2785
|
return _promiseStrategy;
|
2786
|
}
|
2787
|
if (_angular_core.ɵisObservable(obj)) {
|
2788
|
return _observableStrategy;
|
2789
|
}
|
2790
|
throw invalidPipeArgumentError(AsyncPipe, obj);
|
2791
|
};
|
2792
|
/**
|
2793
|
* @return {?}
|
2794
|
*/
|
2795
|
AsyncPipe.prototype._dispose = function () {
|
2796
|
this._strategy.dispose(/** @type {?} */ ((this._subscription)));
|
2797
|
this._latestValue = null;
|
2798
|
this._latestReturnedValue = null;
|
2799
|
this._subscription = null;
|
2800
|
this._obj = null;
|
2801
|
};
|
2802
|
/**
|
2803
|
* @param {?} async
|
2804
|
* @param {?} value
|
2805
|
* @return {?}
|
2806
|
*/
|
2807
|
AsyncPipe.prototype._updateLatestValue = function (async, value) {
|
2808
|
if (async === this._obj) {
|
2809
|
this._latestValue = value;
|
2810
|
this._ref.markForCheck();
|
2811
|
}
|
2812
|
};
|
2813
|
return AsyncPipe;
|
2814
|
}());
|
2815
|
AsyncPipe.decorators = [
|
2816
|
{ type: _angular_core.Pipe, args: [{ name: 'async', pure: false },] },
|
2817
|
];
|
2818
|
/**
|
2819
|
* @nocollapse
|
2820
|
*/
|
2821
|
AsyncPipe.ctorParameters = function () { return [
|
2822
|
{ type: _angular_core.ChangeDetectorRef, },
|
2823
|
]; };
|
2824
|
/**
|
2825
|
* @license
|
2826
|
* Copyright Google Inc. All Rights Reserved.
|
2827
|
*
|
2828
|
* Use of this source code is governed by an MIT-style license that can be
|
2829
|
* found in the LICENSE file at https://angular.io/license
|
2830
|
*/
|
2831
|
/**
|
2832
|
* Transforms text to lowercase.
|
2833
|
*
|
2834
|
* {\@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe' }
|
2835
|
*
|
2836
|
* \@stable
|
2837
|
*/
|
2838
|
var LowerCasePipe = (function () {
|
2839
|
function LowerCasePipe() {
|
2840
|
}
|
2841
|
/**
|
2842
|
* @param {?} value
|
2843
|
* @return {?}
|
2844
|
*/
|
2845
|
LowerCasePipe.prototype.transform = function (value) {
|
2846
|
if (!value)
|
2847
|
return value;
|
2848
|
if (typeof value !== 'string') {
|
2849
|
throw invalidPipeArgumentError(LowerCasePipe, value);
|
2850
|
}
|
2851
|
return value.toLowerCase();
|
2852
|
};
|
2853
|
return LowerCasePipe;
|
2854
|
}());
|
2855
|
LowerCasePipe.decorators = [
|
2856
|
{ type: _angular_core.Pipe, args: [{ name: 'lowercase' },] },
|
2857
|
];
|
2858
|
/**
|
2859
|
* @nocollapse
|
2860
|
*/
|
2861
|
LowerCasePipe.ctorParameters = function () { return []; };
|
2862
|
/**
|
2863
|
* Helper method to transform a single word to titlecase.
|
2864
|
*
|
2865
|
* \@stable
|
2866
|
* @param {?} word
|
2867
|
* @return {?}
|
2868
|
*/
|
2869
|
function titleCaseWord(word) {
|
2870
|
if (!word)
|
2871
|
return word;
|
2872
|
return word[0].toUpperCase() + word.substr(1).toLowerCase();
|
2873
|
}
|
2874
|
/**
|
2875
|
* Transforms text to titlecase.
|
2876
|
*
|
2877
|
* \@stable
|
2878
|
*/
|
2879
|
var TitleCasePipe = (function () {
|
2880
|
function TitleCasePipe() {
|
2881
|
}
|
2882
|
/**
|
2883
|
* @param {?} value
|
2884
|
* @return {?}
|
2885
|
*/
|
2886
|
TitleCasePipe.prototype.transform = function (value) {
|
2887
|
if (!value)
|
2888
|
return value;
|
2889
|
if (typeof value !== 'string') {
|
2890
|
throw invalidPipeArgumentError(TitleCasePipe, value);
|
2891
|
}
|
2892
|
return value.split(/\b/g).map(function (word) { return titleCaseWord(word); }).join('');
|
2893
|
};
|
2894
|
return TitleCasePipe;
|
2895
|
}());
|
2896
|
TitleCasePipe.decorators = [
|
2897
|
{ type: _angular_core.Pipe, args: [{ name: 'titlecase' },] },
|
2898
|
];
|
2899
|
/**
|
2900
|
* @nocollapse
|
2901
|
*/
|
2902
|
TitleCasePipe.ctorParameters = function () { return []; };
|
2903
|
/**
|
2904
|
* Transforms text to uppercase.
|
2905
|
*
|
2906
|
* \@stable
|
2907
|
*/
|
2908
|
var UpperCasePipe = (function () {
|
2909
|
function UpperCasePipe() {
|
2910
|
}
|
2911
|
/**
|
2912
|
* @param {?} value
|
2913
|
* @return {?}
|
2914
|
*/
|
2915
|
UpperCasePipe.prototype.transform = function (value) {
|
2916
|
if (!value)
|
2917
|
return value;
|
2918
|
if (typeof value !== 'string') {
|
2919
|
throw invalidPipeArgumentError(UpperCasePipe, value);
|
2920
|
}
|
2921
|
return value.toUpperCase();
|
2922
|
};
|
2923
|
return UpperCasePipe;
|
2924
|
}());
|
2925
|
UpperCasePipe.decorators = [
|
2926
|
{ type: _angular_core.Pipe, args: [{ name: 'uppercase' },] },
|
2927
|
];
|
2928
|
/**
|
2929
|
* @nocollapse
|
2930
|
*/
|
2931
|
UpperCasePipe.ctorParameters = function () { return []; };
|
2932
|
var NumberFormatStyle = {};
|
2933
|
NumberFormatStyle.Decimal = 0;
|
2934
|
NumberFormatStyle.Percent = 1;
|
2935
|
NumberFormatStyle.Currency = 2;
|
2936
|
NumberFormatStyle[NumberFormatStyle.Decimal] = "Decimal";
|
2937
|
NumberFormatStyle[NumberFormatStyle.Percent] = "Percent";
|
2938
|
NumberFormatStyle[NumberFormatStyle.Currency] = "Currency";
|
2939
|
var NumberFormatter = (function () {
|
2940
|
function NumberFormatter() {
|
2941
|
}
|
2942
|
/**
|
2943
|
* @param {?} num
|
2944
|
* @param {?} locale
|
2945
|
* @param {?} style
|
2946
|
* @param {?=} opts
|
2947
|
* @return {?}
|
2948
|
*/
|
2949
|
NumberFormatter.format = function (num, locale, style, opts) {
|
2950
|
if (opts === void 0) { opts = {}; }
|
2951
|
var minimumIntegerDigits = opts.minimumIntegerDigits, minimumFractionDigits = opts.minimumFractionDigits, maximumFractionDigits = opts.maximumFractionDigits, currency = opts.currency, _a = opts.currencyAsSymbol, currencyAsSymbol = _a === void 0 ? false : _a;
|
2952
|
var /** @type {?} */ options = {
|
2953
|
minimumIntegerDigits: minimumIntegerDigits,
|
2954
|
minimumFractionDigits: minimumFractionDigits,
|
2955
|
maximumFractionDigits: maximumFractionDigits,
|
2956
|
style: NumberFormatStyle[style].toLowerCase()
|
2957
|
};
|
2958
|
if (style == NumberFormatStyle.Currency) {
|
2959
|
options.currency = typeof currency == 'string' ? currency : undefined;
|
2960
|
options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
|
2961
|
}
|
2962
|
return new Intl.NumberFormat(locale, options).format(num);
|
2963
|
};
|
2964
|
return NumberFormatter;
|
2965
|
}());
|
2966
|
var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
|
2967
|
var PATTERN_ALIASES = {
|
2968
|
// Keys are quoted so they do not get renamed during closure compilation.
|
2969
|
'yMMMdjms': datePartGetterFactory(combine([
|
2970
|
digitCondition('year', 1),
|
2971
|
nameCondition('month', 3),
|
2972
|
digitCondition('day', 1),
|
2973
|
digitCondition('hour', 1),
|
2974
|
digitCondition('minute', 1),
|
2975
|
digitCondition('second', 1),
|
2976
|
])),
|
2977
|
'yMdjm': datePartGetterFactory(combine([
|
2978
|
digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
|
2979
|
digitCondition('hour', 1), digitCondition('minute', 1)
|
2980
|
])),
|
2981
|
'yMMMMEEEEd': datePartGetterFactory(combine([
|
2982
|
digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
|
2983
|
digitCondition('day', 1)
|
2984
|
])),
|
2985
|
'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
|
2986
|
'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
|
2987
|
'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
|
2988
|
'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
|
2989
|
'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
|
2990
|
};
|
2991
|
var DATE_FORMATS = {
|
2992
|
// Keys are quoted so they do not get renamed.
|
2993
|
'yyyy': datePartGetterFactory(digitCondition('year', 4)),
|
2994
|
'yy': datePartGetterFactory(digitCondition('year', 2)),
|
2995
|
'y': datePartGetterFactory(digitCondition('year', 1)),
|
2996
|
'MMMM': datePartGetterFactory(nameCondition('month', 4)),
|
2997
|
'MMM': datePartGetterFactory(nameCondition('month', 3)),
|
2998
|
'MM': datePartGetterFactory(digitCondition('month', 2)),
|
2999
|
'M': datePartGetterFactory(digitCondition('month', 1)),
|
3000
|
'LLLL': datePartGetterFactory(nameCondition('month', 4)),
|
3001
|
'L': datePartGetterFactory(nameCondition('month', 1)),
|
3002
|
'dd': datePartGetterFactory(digitCondition('day', 2)),
|
3003
|
'd': datePartGetterFactory(digitCondition('day', 1)),
|
3004
|
'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
|
3005
|
'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
|
3006
|
'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
|
3007
|
'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
3008
|
'jj': datePartGetterFactory(digitCondition('hour', 2)),
|
3009
|
'j': datePartGetterFactory(digitCondition('hour', 1)),
|
3010
|
'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
|
3011
|
'm': datePartGetterFactory(digitCondition('minute', 1)),
|
3012
|
'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
|
3013
|
's': datePartGetterFactory(digitCondition('second', 1)),
|
3014
|
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
|
3015
|
// we can be just safely rely on using `sss` since we currently don't support single or two digit
|
3016
|
// fractions
|
3017
|
'sss': datePartGetterFactory(digitCondition('second', 3)),
|
3018
|
'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
|
3019
|
'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
|
3020
|
'EE': datePartGetterFactory(nameCondition('weekday', 2)),
|
3021
|
'E': datePartGetterFactory(nameCondition('weekday', 1)),
|
3022
|
'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
3023
|
'Z': timeZoneGetter('short'),
|
3024
|
'z': timeZoneGetter('long'),
|
3025
|
'ww': datePartGetterFactory({}),
|
3026
|
// first Thursday of the year. not support ?
|
3027
|
'w': datePartGetterFactory({}),
|
3028
|
// of the year not support ?
|
3029
|
'G': datePartGetterFactory(nameCondition('era', 1)),
|
3030
|
'GG': datePartGetterFactory(nameCondition('era', 2)),
|
3031
|
'GGG': datePartGetterFactory(nameCondition('era', 3)),
|
3032
|
'GGGG': datePartGetterFactory(nameCondition('era', 4))
|
3033
|
};
|
3034
|
/**
|
3035
|
* @param {?} inner
|
3036
|
* @return {?}
|
3037
|
*/
|
3038
|
function digitModifier(inner) {
|
3039
|
return function (date, locale) {
|
3040
|
var /** @type {?} */ result = inner(date, locale);
|
3041
|
return result.length == 1 ? '0' + result : result;
|
3042
|
};
|
3043
|
}
|
3044
|
/**
|
3045
|
* @param {?} inner
|
3046
|
* @return {?}
|
3047
|
*/
|
3048
|
function hourClockExtractor(inner) {
|
3049
|
return function (date, locale) { return inner(date, locale).split(' ')[1]; };
|
3050
|
}
|
3051
|
/**
|
3052
|
* @param {?} inner
|
3053
|
* @return {?}
|
3054
|
*/
|
3055
|
function hourExtractor(inner) {
|
3056
|
return function (date, locale) { return inner(date, locale).split(' ')[0]; };
|
3057
|
}
|
3058
|
/**
|
3059
|
* @param {?} date
|
3060
|
* @param {?} locale
|
3061
|
* @param {?} options
|
3062
|
* @return {?}
|
3063
|
*/
|
3064
|
function intlDateFormat(date, locale, options) {
|
3065
|
return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
|
3066
|
}
|
3067
|
/**
|
3068
|
* @param {?} timezone
|
3069
|
* @return {?}
|
3070
|
*/
|
3071
|
function timeZoneGetter(timezone) {
|
3072
|
// To workaround `Intl` API restriction for single timezone let format with 24 hours
|
3073
|
var /** @type {?} */ options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
|
3074
|
return function (date, locale) {
|
3075
|
var /** @type {?} */ result = intlDateFormat(date, locale, options);
|
3076
|
// Then extract first 3 letters that related to hours
|
3077
|
return result ? result.substring(3) : '';
|
3078
|
};
|
3079
|
}
|
3080
|
/**
|
3081
|
* @param {?} options
|
3082
|
* @param {?} value
|
3083
|
* @return {?}
|
3084
|
*/
|
3085
|
function hour12Modify(options, value) {
|
3086
|
options.hour12 = value;
|
3087
|
return options;
|
3088
|
}
|
3089
|
/**
|
3090
|
* @param {?} prop
|
3091
|
* @param {?} len
|
3092
|
* @return {?}
|
3093
|
*/
|
3094
|
function digitCondition(prop, len) {
|
3095
|
var /** @type {?} */ result = {};
|
3096
|
result[prop] = len === 2 ? '2-digit' : 'numeric';
|
3097
|
return result;
|
3098
|
}
|
3099
|
/**
|
3100
|
* @param {?} prop
|
3101
|
* @param {?} len
|
3102
|
* @return {?}
|
3103
|
*/
|
3104
|
function nameCondition(prop, len) {
|
3105
|
var /** @type {?} */ result = {};
|
3106
|
if (len < 4) {
|
3107
|
result[prop] = len > 1 ? 'short' : 'narrow';
|
3108
|
}
|
3109
|
else {
|
3110
|
result[prop] = 'long';
|
3111
|
}
|
3112
|
return result;
|
3113
|
}
|
3114
|
/**
|
3115
|
* @param {?} options
|
3116
|
* @return {?}
|
3117
|
*/
|
3118
|
function combine(options) {
|
3119
|
return options.reduce(function (merged, opt) { return (Object.assign({}, merged, opt)); }, {});
|
3120
|
}
|
3121
|
/**
|
3122
|
* @param {?} ret
|
3123
|
* @return {?}
|
3124
|
*/
|
3125
|
function datePartGetterFactory(ret) {
|
3126
|
return function (date, locale) { return intlDateFormat(date, locale, ret); };
|
3127
|
}
|
3128
|
var DATE_FORMATTER_CACHE = new Map();
|
3129
|
/**
|
3130
|
* @param {?} format
|
3131
|
* @param {?} date
|
3132
|
* @param {?} locale
|
3133
|
* @return {?}
|
3134
|
*/
|
3135
|
function dateFormatter(format, date, locale) {
|
3136
|
var /** @type {?} */ fn = PATTERN_ALIASES[format];
|
3137
|
if (fn)
|
3138
|
return fn(date, locale);
|
3139
|
var /** @type {?} */ cacheKey = format;
|
3140
|
var /** @type {?} */ parts = DATE_FORMATTER_CACHE.get(cacheKey);
|
3141
|
if (!parts) {
|
3142
|
parts = [];
|
3143
|
var /** @type {?} */ match = void 0;
|
3144
|
DATE_FORMATS_SPLIT.exec(format);
|
3145
|
var /** @type {?} */ _format = format;
|
3146
|
while (_format) {
|
3147
|
match = DATE_FORMATS_SPLIT.exec(_format);
|
3148
|
if (match) {
|
3149
|
parts = parts.concat(match.slice(1));
|
3150
|
_format = ((parts.pop()));
|
3151
|
}
|
3152
|
else {
|
3153
|
parts.push(_format);
|
3154
|
_format = null;
|
3155
|
}
|
3156
|
}
|
3157
|
DATE_FORMATTER_CACHE.set(cacheKey, parts);
|
3158
|
}
|
3159
|
return parts.reduce(function (text, part) {
|
3160
|
var /** @type {?} */ fn = DATE_FORMATS[part];
|
3161
|
return text + (fn ? fn(date, locale) : partToTime(part));
|
3162
|
}, '');
|
3163
|
}
|
3164
|
/**
|
3165
|
* @param {?} part
|
3166
|
* @return {?}
|
3167
|
*/
|
3168
|
function partToTime(part) {
|
3169
|
return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
|
3170
|
}
|
3171
|
var DateFormatter = (function () {
|
3172
|
function DateFormatter() {
|
3173
|
}
|
3174
|
/**
|
3175
|
* @param {?} date
|
3176
|
* @param {?} locale
|
3177
|
* @param {?} pattern
|
3178
|
* @return {?}
|
3179
|
*/
|
3180
|
DateFormatter.format = function (date, locale, pattern) {
|
3181
|
return dateFormatter(pattern, date, locale);
|
3182
|
};
|
3183
|
return DateFormatter;
|
3184
|
}());
|
3185
|
/**
|
3186
|
* @license
|
3187
|
* Copyright Google Inc. All Rights Reserved.
|
3188
|
*
|
3189
|
* Use of this source code is governed by an MIT-style license that can be
|
3190
|
* found in the LICENSE file at https://angular.io/license
|
3191
|
*/
|
3192
|
var _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
|
3193
|
/**
|
3194
|
* @param {?} pipe
|
3195
|
* @param {?} locale
|
3196
|
* @param {?} value
|
3197
|
* @param {?} style
|
3198
|
* @param {?=} digits
|
3199
|
* @param {?=} currency
|
3200
|
* @param {?=} currencyAsSymbol
|
3201
|
* @return {?}
|
3202
|
*/
|
3203
|
function formatNumber(pipe, locale, value, style, digits, currency, currencyAsSymbol) {
|
3204
|
if (currency === void 0) { currency = null; }
|
3205
|
if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
|
3206
|
if (value == null)
|
3207
|
return null;
|
3208
|
// Convert strings to numbers
|
3209
|
value = typeof value === 'string' && isNumeric(value) ? +value : value;
|
3210
|
if (typeof value !== 'number') {
|
3211
|
throw invalidPipeArgumentError(pipe, value);
|
3212
|
}
|
3213
|
var /** @type {?} */ minInt = undefined;
|
3214
|
var /** @type {?} */ minFraction = undefined;
|
3215
|
var /** @type {?} */ maxFraction = undefined;
|
3216
|
if (style !== NumberFormatStyle.Currency) {
|
3217
|
// rely on Intl default for currency
|
3218
|
minInt = 1;
|
3219
|
minFraction = 0;
|
3220
|
maxFraction = 3;
|
3221
|
}
|
3222
|
if (digits) {
|
3223
|
var /** @type {?} */ parts = digits.match(_NUMBER_FORMAT_REGEXP);
|
3224
|
if (parts === null) {
|
3225
|
throw new Error(digits + " is not a valid digit info for number pipes");
|
3226
|
}
|
3227
|
if (parts[1] != null) {
|
3228
|
minInt = parseIntAutoRadix(parts[1]);
|
3229
|
}
|
3230
|
if (parts[3] != null) {
|
3231
|
minFraction = parseIntAutoRadix(parts[3]);
|
3232
|
}
|
3233
|
if (parts[5] != null) {
|
3234
|
maxFraction = parseIntAutoRadix(parts[5]);
|
3235
|
}
|
3236
|
}
|
3237
|
return NumberFormatter.format(/** @type {?} */ (value), locale, style, {
|
3238
|
minimumIntegerDigits: minInt,
|
3239
|
minimumFractionDigits: minFraction,
|
3240
|
maximumFractionDigits: maxFraction,
|
3241
|
currency: currency,
|
3242
|
currencyAsSymbol: currencyAsSymbol,
|
3243
|
});
|
3244
|
}
|
3245
|
/**
|
3246
|
* \@ngModule CommonModule
|
3247
|
* \@whatItDoes Formats a number according to locale rules.
|
3248
|
* \@howToUse `number_expression | number[:digitInfo]`
|
3249
|
*
|
3250
|
* Formats a number as text. Group sizing and separator and other locale-specific
|
3251
|
* configurations are based on the active locale.
|
3252
|
*
|
3253
|
* where `expression` is a number:
|
3254
|
* - `digitInfo` is a `string` which has a following format: <br>
|
3255
|
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
|
3256
|
* - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
|
3257
|
* - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
|
3258
|
* - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
|
3259
|
*
|
3260
|
* For more information on the acceptable range for each of these numbers and other
|
3261
|
* details see your native internationalization library.
|
3262
|
*
|
3263
|
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
|
3264
|
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
|
3265
|
*
|
3266
|
* ### Example
|
3267
|
*
|
3268
|
* {\@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
|
3269
|
*
|
3270
|
* \@stable
|
3271
|
*/
|
3272
|
var DecimalPipe = (function () {
|
3273
|
/**
|
3274
|
* @param {?} _locale
|
3275
|
*/
|
3276
|
function DecimalPipe(_locale) {
|
3277
|
this._locale = _locale;
|
3278
|
}
|
3279
|
/**
|
3280
|
* @param {?} value
|
3281
|
* @param {?=} digits
|
3282
|
* @return {?}
|
3283
|
*/
|
3284
|
DecimalPipe.prototype.transform = function (value, digits) {
|
3285
|
return formatNumber(DecimalPipe, this._locale, value, NumberFormatStyle.Decimal, digits);
|
3286
|
};
|
3287
|
return DecimalPipe;
|
3288
|
}());
|
3289
|
DecimalPipe.decorators = [
|
3290
|
{ type: _angular_core.Pipe, args: [{ name: 'number' },] },
|
3291
|
];
|
3292
|
/**
|
3293
|
* @nocollapse
|
3294
|
*/
|
3295
|
DecimalPipe.ctorParameters = function () { return [
|
3296
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID,] },] },
|
3297
|
]; };
|
3298
|
/**
|
3299
|
* \@ngModule CommonModule
|
3300
|
* \@whatItDoes Formats a number as a percentage according to locale rules.
|
3301
|
* \@howToUse `number_expression | percent[:digitInfo]`
|
3302
|
*
|
3303
|
* \@description
|
3304
|
*
|
3305
|
* Formats a number as percentage.
|
3306
|
*
|
3307
|
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
|
3308
|
*
|
3309
|
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
|
3310
|
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
|
3311
|
*
|
3312
|
* ### Example
|
3313
|
*
|
3314
|
* {\@example common/pipes/ts/number_pipe.ts region='PercentPipe'}
|
3315
|
*
|
3316
|
* \@stable
|
3317
|
*/
|
3318
|
var PercentPipe = (function () {
|
3319
|
/**
|
3320
|
* @param {?} _locale
|
3321
|
*/
|
3322
|
function PercentPipe(_locale) {
|
3323
|
this._locale = _locale;
|
3324
|
}
|
3325
|
/**
|
3326
|
* @param {?} value
|
3327
|
* @param {?=} digits
|
3328
|
* @return {?}
|
3329
|
*/
|
3330
|
PercentPipe.prototype.transform = function (value, digits) {
|
3331
|
return formatNumber(PercentPipe, this._locale, value, NumberFormatStyle.Percent, digits);
|
3332
|
};
|
3333
|
return PercentPipe;
|
3334
|
}());
|
3335
|
PercentPipe.decorators = [
|
3336
|
{ type: _angular_core.Pipe, args: [{ name: 'percent' },] },
|
3337
|
];
|
3338
|
/**
|
3339
|
* @nocollapse
|
3340
|
*/
|
3341
|
PercentPipe.ctorParameters = function () { return [
|
3342
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID,] },] },
|
3343
|
]; };
|
3344
|
/**
|
3345
|
* \@ngModule CommonModule
|
3346
|
* \@whatItDoes Formats a number as currency using locale rules.
|
3347
|
* \@howToUse `number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]`
|
3348
|
* \@description
|
3349
|
*
|
3350
|
* Use `currency` to format a number as currency.
|
3351
|
*
|
3352
|
* - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
|
3353
|
* as `USD` for the US dollar and `EUR` for the euro.
|
3354
|
* - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
|
3355
|
* - `true`: use symbol (e.g. `$`).
|
3356
|
* - `false`(default): use code (e.g. `USD`).
|
3357
|
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
|
3358
|
*
|
3359
|
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
|
3360
|
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
|
3361
|
*
|
3362
|
* ### Example
|
3363
|
*
|
3364
|
* {\@example common/pipes/ts/number_pipe.ts region='CurrencyPipe'}
|
3365
|
*
|
3366
|
* \@stable
|
3367
|
*/
|
3368
|
var CurrencyPipe = (function () {
|
3369
|
/**
|
3370
|
* @param {?} _locale
|
3371
|
*/
|
3372
|
function CurrencyPipe(_locale) {
|
3373
|
this._locale = _locale;
|
3374
|
}
|
3375
|
/**
|
3376
|
* @param {?} value
|
3377
|
* @param {?=} currencyCode
|
3378
|
* @param {?=} symbolDisplay
|
3379
|
* @param {?=} digits
|
3380
|
* @return {?}
|
3381
|
*/
|
3382
|
CurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) {
|
3383
|
if (currencyCode === void 0) { currencyCode = 'USD'; }
|
3384
|
if (symbolDisplay === void 0) { symbolDisplay = false; }
|
3385
|
return formatNumber(CurrencyPipe, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
|
3386
|
};
|
3387
|
return CurrencyPipe;
|
3388
|
}());
|
3389
|
CurrencyPipe.decorators = [
|
3390
|
{ type: _angular_core.Pipe, args: [{ name: 'currency' },] },
|
3391
|
];
|
3392
|
/**
|
3393
|
* @nocollapse
|
3394
|
*/
|
3395
|
CurrencyPipe.ctorParameters = function () { return [
|
3396
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID,] },] },
|
3397
|
]; };
|
3398
|
/**
|
3399
|
* @param {?} text
|
3400
|
* @return {?}
|
3401
|
*/
|
3402
|
function parseIntAutoRadix(text) {
|
3403
|
var /** @type {?} */ result = parseInt(text);
|
3404
|
if (isNaN(result)) {
|
3405
|
throw new Error('Invalid integer literal when parsing ' + text);
|
3406
|
}
|
3407
|
return result;
|
3408
|
}
|
3409
|
/**
|
3410
|
* @param {?} value
|
3411
|
* @return {?}
|
3412
|
*/
|
3413
|
function isNumeric(value) {
|
3414
|
return !isNaN(value - parseFloat(value));
|
3415
|
}
|
3416
|
/**
|
3417
|
* @license
|
3418
|
* Copyright Google Inc. All Rights Reserved.
|
3419
|
*
|
3420
|
* Use of this source code is governed by an MIT-style license that can be
|
3421
|
* found in the LICENSE file at https://angular.io/license
|
3422
|
*/
|
3423
|
var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
|
3424
|
/**
|
3425
|
* \@ngModule CommonModule
|
3426
|
* \@whatItDoes Formats a date according to locale rules.
|
3427
|
* \@howToUse `date_expression | date[:format]`
|
3428
|
* \@description
|
3429
|
*
|
3430
|
* Where:
|
3431
|
* - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
|
3432
|
* (https://www.w3.org/TR/NOTE-datetime).
|
3433
|
* - `format` indicates which date/time components to include. The format can be predefined as
|
3434
|
* shown below or custom as shown in the table.
|
3435
|
* - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
|
3436
|
* - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
|
3437
|
* - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
|
3438
|
* - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
|
3439
|
* - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
|
3440
|
* - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
|
3441
|
* - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
|
3442
|
* - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
|
3443
|
*
|
3444
|
*
|
3445
|
* | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
|
3446
|
* |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
|
3447
|
* | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
|
3448
|
* | year | y | - | - | - | y (2015) | yy (15) |
|
3449
|
* | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
|
3450
|
* | day | d | - | - | - | d (3) | dd (03) |
|
3451
|
* | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
|
3452
|
* | hour | j | - | - | - | j (1 PM) | jj (1 PM) |
|
3453
|
* | hour12 | h | - | - | - | h (1) | hh (01) |
|
3454
|
* | hour24 | H | - | - | - | H (13) | HH (13) |
|
3455
|
* | minute | m | - | - | - | m (5) | mm (05) |
|
3456
|
* | second | s | - | - | - | s (9) | ss (09) |
|
3457
|
* | timezone | z | - | - | z (Pacific Standard Time)| - | - |
|
3458
|
* | timezone | Z | - | Z (GMT-8:00) | - | - | - |
|
3459
|
* | timezone | a | - | a (PM) | - | - | - |
|
3460
|
*
|
3461
|
* In javascript, only the components specified will be respected (not the ordering,
|
3462
|
* punctuations, ...) and details of the formatting will be dependent on the locale.
|
3463
|
*
|
3464
|
* Timezone of the formatted text will be the local system timezone of the end-user's machine.
|
3465
|
*
|
3466
|
* When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
|
3467
|
* applied and the formatted text will have the same day, month and year of the expression.
|
3468
|
*
|
3469
|
* WARNINGS:
|
3470
|
* - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
|
3471
|
* Instead users should treat the date as an immutable object and change the reference when the
|
3472
|
* pipe needs to re-run (this is to avoid reformatting the date on every change detection run
|
3473
|
* which would be an expensive operation).
|
3474
|
* - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
|
3475
|
* browsers.
|
3476
|
*
|
3477
|
* ### Examples
|
3478
|
*
|
3479
|
* Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
|
3480
|
* in the _local_ time and locale is 'en-US':
|
3481
|
*
|
3482
|
* ```
|
3483
|
* {{ dateObj | date }} // output is 'Jun 15, 2015'
|
3484
|
* {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
|
3485
|
* {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
|
3486
|
* {{ dateObj | date:'mmss' }} // output is '43:11'
|
3487
|
* ```
|
3488
|
*
|
3489
|
* {\@example common/pipes/ts/date_pipe.ts region='DatePipe'}
|
3490
|
*
|
3491
|
* \@stable
|
3492
|
*/
|
3493
|
var DatePipe = (function () {
|
3494
|
/**
|
3495
|
* @param {?} _locale
|
3496
|
*/
|
3497
|
function DatePipe(_locale) {
|
3498
|
this._locale = _locale;
|
3499
|
}
|
3500
|
/**
|
3501
|
* @param {?} value
|
3502
|
* @param {?=} pattern
|
3503
|
* @return {?}
|
3504
|
*/
|
3505
|
DatePipe.prototype.transform = function (value, pattern) {
|
3506
|
if (pattern === void 0) { pattern = 'mediumDate'; }
|
3507
|
var /** @type {?} */ date;
|
3508
|
if (isBlank(value) || value !== value)
|
3509
|
return null;
|
3510
|
if (typeof value === 'string') {
|
3511
|
value = value.trim();
|
3512
|
}
|
3513
|
if (isDate(value)) {
|
3514
|
date = value;
|
3515
|
}
|
3516
|
else if (isNumeric(value)) {
|
3517
|
date = new Date(parseFloat(value));
|
3518
|
}
|
3519
|
else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
|
3520
|
/**
|
3521
|
* For ISO Strings without time the day, month and year must be extracted from the ISO String
|
3522
|
* before Date creation to avoid time offset and errors in the new Date.
|
3523
|
* If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
|
3524
|
* date, some browsers (e.g. IE 9) will throw an invalid Date error
|
3525
|
* If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
|
3526
|
* is applied
|
3527
|
* Note: ISO months are 0 for January, 1 for February, ...
|
3528
|
*/
|
3529
|
var _a = value.split('-').map(function (val) { return parseInt(val, 10); }), y = _a[0], m = _a[1], d = _a[2];
|
3530
|
date = new Date(y, m - 1, d);
|
3531
|
}
|
3532
|
else {
|
3533
|
date = new Date(value);
|
3534
|
}
|
3535
|
if (!isDate(date)) {
|
3536
|
var /** @type {?} */ match = void 0;
|
3537
|
if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
|
3538
|
date = isoStringToDate(match);
|
3539
|
}
|
3540
|
else {
|
3541
|
throw invalidPipeArgumentError(DatePipe, value);
|
3542
|
}
|
3543
|
}
|
3544
|
return DateFormatter.format(date, this._locale, DatePipe._ALIASES[pattern] || pattern);
|
3545
|
};
|
3546
|
return DatePipe;
|
3547
|
}());
|
3548
|
/**
|
3549
|
* \@internal
|
3550
|
*/
|
3551
|
DatePipe._ALIASES = {
|
3552
|
'medium': 'yMMMdjms',
|
3553
|
'short': 'yMdjm',
|
3554
|
'fullDate': 'yMMMMEEEEd',
|
3555
|
'longDate': 'yMMMMd',
|
3556
|
'mediumDate': 'yMMMd',
|
3557
|
'shortDate': 'yMd',
|
3558
|
'mediumTime': 'jms',
|
3559
|
'shortTime': 'jm'
|
3560
|
};
|
3561
|
DatePipe.decorators = [
|
3562
|
{ type: _angular_core.Pipe, args: [{ name: 'date', pure: true },] },
|
3563
|
];
|
3564
|
/**
|
3565
|
* @nocollapse
|
3566
|
*/
|
3567
|
DatePipe.ctorParameters = function () { return [
|
3568
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID,] },] },
|
3569
|
]; };
|
3570
|
/**
|
3571
|
* @param {?} obj
|
3572
|
* @return {?}
|
3573
|
*/
|
3574
|
function isBlank(obj) {
|
3575
|
return obj == null || obj === '';
|
3576
|
}
|
3577
|
/**
|
3578
|
* @param {?} obj
|
3579
|
* @return {?}
|
3580
|
*/
|
3581
|
function isDate(obj) {
|
3582
|
return obj instanceof Date && !isNaN(obj.valueOf());
|
3583
|
}
|
3584
|
/**
|
3585
|
* @param {?} match
|
3586
|
* @return {?}
|
3587
|
*/
|
3588
|
function isoStringToDate(match) {
|
3589
|
var /** @type {?} */ date = new Date(0);
|
3590
|
var /** @type {?} */ tzHour = 0;
|
3591
|
var /** @type {?} */ tzMin = 0;
|
3592
|
var /** @type {?} */ dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
|
3593
|
var /** @type {?} */ timeSetter = match[8] ? date.setUTCHours : date.setHours;
|
3594
|
if (match[9]) {
|
3595
|
tzHour = toInt(match[9] + match[10]);
|
3596
|
tzMin = toInt(match[9] + match[11]);
|
3597
|
}
|
3598
|
dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
|
3599
|
var /** @type {?} */ h = toInt(match[4] || '0') - tzHour;
|
3600
|
var /** @type {?} */ m = toInt(match[5] || '0') - tzMin;
|
3601
|
var /** @type {?} */ s = toInt(match[6] || '0');
|
3602
|
var /** @type {?} */ ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
|
3603
|
timeSetter.call(date, h, m, s, ms);
|
3604
|
return date;
|
3605
|
}
|
3606
|
/**
|
3607
|
* @param {?} str
|
3608
|
* @return {?}
|
3609
|
*/
|
3610
|
function toInt(str) {
|
3611
|
return parseInt(str, 10);
|
3612
|
}
|
3613
|
/**
|
3614
|
* @license
|
3615
|
* Copyright Google Inc. All Rights Reserved.
|
3616
|
*
|
3617
|
* Use of this source code is governed by an MIT-style license that can be
|
3618
|
* found in the LICENSE file at https://angular.io/license
|
3619
|
*/
|
3620
|
var _INTERPOLATION_REGEXP = /#/g;
|
3621
|
/**
|
3622
|
* \@ngModule CommonModule
|
3623
|
* \@whatItDoes Maps a value to a string that pluralizes the value according to locale rules.
|
3624
|
* \@howToUse `expression | i18nPlural:mapping`
|
3625
|
* \@description
|
3626
|
*
|
3627
|
* Where:
|
3628
|
* - `expression` is a number.
|
3629
|
* - `mapping` is an object that mimics the ICU format, see
|
3630
|
* http://userguide.icu-project.org/formatparse/messages
|
3631
|
*
|
3632
|
* ## Example
|
3633
|
*
|
3634
|
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
|
3635
|
*
|
3636
|
* \@experimental
|
3637
|
*/
|
3638
|
var I18nPluralPipe = (function () {
|
3639
|
/**
|
3640
|
* @param {?} _localization
|
3641
|
*/
|
3642
|
function I18nPluralPipe(_localization) {
|
3643
|
this._localization = _localization;
|
3644
|
}
|
3645
|
/**
|
3646
|
* @param {?} value
|
3647
|
* @param {?} pluralMap
|
3648
|
* @return {?}
|
3649
|
*/
|
3650
|
I18nPluralPipe.prototype.transform = function (value, pluralMap) {
|
3651
|
if (value == null)
|
3652
|
return '';
|
3653
|
if (typeof pluralMap !== 'object' || pluralMap === null) {
|
3654
|
throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
|
3655
|
}
|
3656
|
var /** @type {?} */ key = getPluralCategory(value, Object.keys(pluralMap), this._localization);
|
3657
|
return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
|
3658
|
};
|
3659
|
return I18nPluralPipe;
|
3660
|
}());
|
3661
|
I18nPluralPipe.decorators = [
|
3662
|
{ type: _angular_core.Pipe, args: [{ name: 'i18nPlural', pure: true },] },
|
3663
|
];
|
3664
|
/**
|
3665
|
* @nocollapse
|
3666
|
*/
|
3667
|
I18nPluralPipe.ctorParameters = function () { return [
|
3668
|
{ type: NgLocalization, },
|
3669
|
]; };
|
3670
|
/**
|
3671
|
* @license
|
3672
|
* Copyright Google Inc. All Rights Reserved.
|
3673
|
*
|
3674
|
* Use of this source code is governed by an MIT-style license that can be
|
3675
|
* found in the LICENSE file at https://angular.io/license
|
3676
|
*/
|
3677
|
/**
|
3678
|
* \@ngModule CommonModule
|
3679
|
* \@whatItDoes Generic selector that displays the string that matches the current value.
|
3680
|
* \@howToUse `expression | i18nSelect:mapping`
|
3681
|
* \@description
|
3682
|
*
|
3683
|
* Where `mapping` is an object that indicates the text that should be displayed
|
3684
|
* for different values of the provided `expression`.
|
3685
|
* If none of the keys of the mapping match the value of the `expression`, then the content
|
3686
|
* of the `other` key is returned when present, otherwise an empty string is returned.
|
3687
|
*
|
3688
|
* ## Example
|
3689
|
*
|
3690
|
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
|
3691
|
*
|
3692
|
* \@experimental
|
3693
|
*/
|
3694
|
var I18nSelectPipe = (function () {
|
3695
|
function I18nSelectPipe() {
|
3696
|
}
|
3697
|
/**
|
3698
|
* @param {?} value
|
3699
|
* @param {?} mapping
|
3700
|
* @return {?}
|
3701
|
*/
|
3702
|
I18nSelectPipe.prototype.transform = function (value, mapping) {
|
3703
|
if (value == null)
|
3704
|
return '';
|
3705
|
if (typeof mapping !== 'object' || typeof value !== 'string') {
|
3706
|
throw invalidPipeArgumentError(I18nSelectPipe, mapping);
|
3707
|
}
|
3708
|
if (mapping.hasOwnProperty(value)) {
|
3709
|
return mapping[value];
|
3710
|
}
|
3711
|
if (mapping.hasOwnProperty('other')) {
|
3712
|
return mapping['other'];
|
3713
|
}
|
3714
|
return '';
|
3715
|
};
|
3716
|
return I18nSelectPipe;
|
3717
|
}());
|
3718
|
I18nSelectPipe.decorators = [
|
3719
|
{ type: _angular_core.Pipe, args: [{ name: 'i18nSelect', pure: true },] },
|
3720
|
];
|
3721
|
/**
|
3722
|
* @nocollapse
|
3723
|
*/
|
3724
|
I18nSelectPipe.ctorParameters = function () { return []; };
|
3725
|
/**
|
3726
|
* @license
|
3727
|
* Copyright Google Inc. All Rights Reserved.
|
3728
|
*
|
3729
|
* Use of this source code is governed by an MIT-style license that can be
|
3730
|
* found in the LICENSE file at https://angular.io/license
|
3731
|
*/
|
3732
|
/**
|
3733
|
* \@ngModule CommonModule
|
3734
|
* \@whatItDoes Converts value into JSON string.
|
3735
|
* \@howToUse `expression | json`
|
3736
|
* \@description
|
3737
|
*
|
3738
|
* Converts value into string using `JSON.stringify`. Useful for debugging.
|
3739
|
*
|
3740
|
* ### Example
|
3741
|
* {\@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
|
3742
|
*
|
3743
|
* \@stable
|
3744
|
*/
|
3745
|
var JsonPipe = (function () {
|
3746
|
function JsonPipe() {
|
3747
|
}
|
3748
|
/**
|
3749
|
* @param {?} value
|
3750
|
* @return {?}
|
3751
|
*/
|
3752
|
JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); };
|
3753
|
return JsonPipe;
|
3754
|
}());
|
3755
|
JsonPipe.decorators = [
|
3756
|
{ type: _angular_core.Pipe, args: [{ name: 'json', pure: false },] },
|
3757
|
];
|
3758
|
/**
|
3759
|
* @nocollapse
|
3760
|
*/
|
3761
|
JsonPipe.ctorParameters = function () { return []; };
|
3762
|
/**
|
3763
|
* @license
|
3764
|
* Copyright Google Inc. All Rights Reserved.
|
3765
|
*
|
3766
|
* Use of this source code is governed by an MIT-style license that can be
|
3767
|
* found in the LICENSE file at https://angular.io/license
|
3768
|
*/
|
3769
|
/**
|
3770
|
* \@ngModule CommonModule
|
3771
|
* \@whatItDoes Creates a new List or String containing a subset (slice) of the elements.
|
3772
|
* \@howToUse `array_or_string_expression | slice:start[:end]`
|
3773
|
* \@description
|
3774
|
*
|
3775
|
* Where the input expression is a `List` or `String`, and:
|
3776
|
* - `start`: The starting index of the subset to return.
|
3777
|
* - **a positive integer**: return the item at `start` index and all items after
|
3778
|
* in the list or string expression.
|
3779
|
* - **a negative integer**: return the item at `start` index from the end and all items after
|
3780
|
* in the list or string expression.
|
3781
|
* - **if positive and greater than the size of the expression**: return an empty list or string.
|
3782
|
* - **if negative and greater than the size of the expression**: return entire list or string.
|
3783
|
* - `end`: The ending index of the subset to return.
|
3784
|
* - **omitted**: return all items until the end.
|
3785
|
* - **if positive**: return all items before `end` index of the list or string.
|
3786
|
* - **if negative**: return all items before `end` index from the end of the list or string.
|
3787
|
*
|
3788
|
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
|
3789
|
* and `String.prototype.slice()`.
|
3790
|
*
|
3791
|
* When operating on a [List], the returned list is always a copy even when all
|
3792
|
* the elements are being returned.
|
3793
|
*
|
3794
|
* When operating on a blank value, the pipe returns the blank value.
|
3795
|
*
|
3796
|
* ## List Example
|
3797
|
*
|
3798
|
* This `ngFor` example:
|
3799
|
*
|
3800
|
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
|
3801
|
*
|
3802
|
* produces the following:
|
3803
|
*
|
3804
|
* <li>b</li>
|
3805
|
* <li>c</li>
|
3806
|
*
|
3807
|
* ## String Examples
|
3808
|
*
|
3809
|
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
|
3810
|
*
|
3811
|
* \@stable
|
3812
|
*/
|
3813
|
var SlicePipe = (function () {
|
3814
|
function SlicePipe() {
|
3815
|
}
|
3816
|
/**
|
3817
|
* @param {?} value
|
3818
|
* @param {?} start
|
3819
|
* @param {?=} end
|
3820
|
* @return {?}
|
3821
|
*/
|
3822
|
SlicePipe.prototype.transform = function (value, start, end) {
|
3823
|
if (value == null)
|
3824
|
return value;
|
3825
|
if (!this.supports(value)) {
|
3826
|
throw invalidPipeArgumentError(SlicePipe, value);
|
3827
|
}
|
3828
|
return value.slice(start, end);
|
3829
|
};
|
3830
|
/**
|
3831
|
* @param {?} obj
|
3832
|
* @return {?}
|
3833
|
*/
|
3834
|
SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
|
3835
|
return SlicePipe;
|
3836
|
}());
|
3837
|
SlicePipe.decorators = [
|
3838
|
{ type: _angular_core.Pipe, args: [{ name: 'slice', pure: false },] },
|
3839
|
];
|
3840
|
/**
|
3841
|
* @nocollapse
|
3842
|
*/
|
3843
|
SlicePipe.ctorParameters = function () { return []; };
|
3844
|
/**
|
3845
|
* @license
|
3846
|
* Copyright Google Inc. All Rights Reserved.
|
3847
|
*
|
3848
|
* Use of this source code is governed by an MIT-style license that can be
|
3849
|
* found in the LICENSE file at https://angular.io/license
|
3850
|
*/
|
3851
|
/**
|
3852
|
* @module
|
3853
|
* @description
|
3854
|
* This module provides a set of common Pipes.
|
3855
|
*/
|
3856
|
/**
|
3857
|
* A collection of Angular pipes that are likely to be used in each and every application.
|
3858
|
*/
|
3859
|
var COMMON_PIPES = [
|
3860
|
AsyncPipe,
|
3861
|
UpperCasePipe,
|
3862
|
LowerCasePipe,
|
3863
|
JsonPipe,
|
3864
|
SlicePipe,
|
3865
|
DecimalPipe,
|
3866
|
PercentPipe,
|
3867
|
TitleCasePipe,
|
3868
|
CurrencyPipe,
|
3869
|
DatePipe,
|
3870
|
I18nPluralPipe,
|
3871
|
I18nSelectPipe,
|
3872
|
];
|
3873
|
/**
|
3874
|
* @license
|
3875
|
* Copyright Google Inc. All Rights Reserved.
|
3876
|
*
|
3877
|
* Use of this source code is governed by an MIT-style license that can be
|
3878
|
* found in the LICENSE file at https://angular.io/license
|
3879
|
*/
|
3880
|
/**
|
3881
|
* The module that includes all the basic Angular directives like {\@link NgIf}, {\@link NgForOf}, ...
|
3882
|
*
|
3883
|
* \@stable
|
3884
|
*/
|
3885
|
var CommonModule = (function () {
|
3886
|
function CommonModule() {
|
3887
|
}
|
3888
|
return CommonModule;
|
3889
|
}());
|
3890
|
CommonModule.decorators = [
|
3891
|
{ type: _angular_core.NgModule, args: [{
|
3892
|
declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
|
3893
|
exports: [COMMON_DIRECTIVES, COMMON_PIPES],
|
3894
|
providers: [
|
3895
|
{ provide: NgLocalization, useClass: NgLocaleLocalization },
|
3896
|
],
|
3897
|
},] },
|
3898
|
];
|
3899
|
/**
|
3900
|
* @nocollapse
|
3901
|
*/
|
3902
|
CommonModule.ctorParameters = function () { return []; };
|
3903
|
/**
|
3904
|
* I18N pipes are being changed to move away from using the JS Intl API.
|
3905
|
*
|
3906
|
* The former pipes relying on the Intl API will be moved to this module while the `CommonModule`
|
3907
|
* will contain the new pipes that do not rely on Intl.
|
3908
|
*
|
3909
|
* As a first step this module is created empty to ease the migration.
|
3910
|
*
|
3911
|
* see https://github.com/angular/angular/pull/18284
|
3912
|
*
|
3913
|
* @deprecated from v5
|
3914
|
*/
|
3915
|
var DeprecatedI18NPipesModule = (function () {
|
3916
|
function DeprecatedI18NPipesModule() {
|
3917
|
}
|
3918
|
return DeprecatedI18NPipesModule;
|
3919
|
}());
|
3920
|
DeprecatedI18NPipesModule.decorators = [
|
3921
|
{ type: _angular_core.NgModule, args: [{ declarations: [], exports: [] },] },
|
3922
|
];
|
3923
|
/**
|
3924
|
* @nocollapse
|
3925
|
*/
|
3926
|
DeprecatedI18NPipesModule.ctorParameters = function () { return []; };
|
3927
|
/**
|
3928
|
* @license
|
3929
|
* Copyright Google Inc. All Rights Reserved.
|
3930
|
*
|
3931
|
* Use of this source code is governed by an MIT-style license that can be
|
3932
|
* found in the LICENSE file at https://angular.io/license
|
3933
|
*/
|
3934
|
/**
|
3935
|
* A DI Token representing the main rendering context. In a browser this is the DOM Document.
|
3936
|
*
|
3937
|
* Note: Document might not be available in the Application Context when Application and Rendering
|
3938
|
* Contexts are not the same (e.g. when running the application into a Web Worker).
|
3939
|
*
|
3940
|
* \@stable
|
3941
|
*/
|
3942
|
var DOCUMENT = new _angular_core.InjectionToken('DocumentToken');
|
3943
|
/**
|
3944
|
* @license
|
3945
|
* Copyright Google Inc. All Rights Reserved.
|
3946
|
*
|
3947
|
* Use of this source code is governed by an MIT-style license that can be
|
3948
|
* found in the LICENSE file at https://angular.io/license
|
3949
|
*/
|
3950
|
var PLATFORM_BROWSER_ID = 'browser';
|
3951
|
var PLATFORM_SERVER_ID = 'server';
|
3952
|
var PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
|
3953
|
var PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
|
3954
|
/**
|
3955
|
* Returns whether a platform id represents a browser platform.
|
3956
|
* \@experimental
|
3957
|
* @param {?} platformId
|
3958
|
* @return {?}
|
3959
|
*/
|
3960
|
function isPlatformBrowser(platformId) {
|
3961
|
return platformId === PLATFORM_BROWSER_ID;
|
3962
|
}
|
3963
|
/**
|
3964
|
* Returns whether a platform id represents a server platform.
|
3965
|
* \@experimental
|
3966
|
* @param {?} platformId
|
3967
|
* @return {?}
|
3968
|
*/
|
3969
|
function isPlatformServer(platformId) {
|
3970
|
return platformId === PLATFORM_SERVER_ID;
|
3971
|
}
|
3972
|
/**
|
3973
|
* Returns whether a platform id represents a web worker app platform.
|
3974
|
* \@experimental
|
3975
|
* @param {?} platformId
|
3976
|
* @return {?}
|
3977
|
*/
|
3978
|
function isPlatformWorkerApp(platformId) {
|
3979
|
return platformId === PLATFORM_WORKER_APP_ID;
|
3980
|
}
|
3981
|
/**
|
3982
|
* Returns whether a platform id represents a web worker UI platform.
|
3983
|
* \@experimental
|
3984
|
* @param {?} platformId
|
3985
|
* @return {?}
|
3986
|
*/
|
3987
|
function isPlatformWorkerUi(platformId) {
|
3988
|
return platformId === PLATFORM_WORKER_UI_ID;
|
3989
|
}
|
3990
|
/**
|
3991
|
* @license
|
3992
|
* Copyright Google Inc. All Rights Reserved.
|
3993
|
*
|
3994
|
* Use of this source code is governed by an MIT-style license that can be
|
3995
|
* found in the LICENSE file at https://angular.io/license
|
3996
|
*/
|
3997
|
/**
|
3998
|
* @module
|
3999
|
* @description
|
4000
|
* Entry point for all public APIs of the common package.
|
4001
|
*/
|
4002
|
/**
|
4003
|
* \@stable
|
4004
|
*/
|
4005
|
var VERSION = new _angular_core.Version('4.4.6');
|
4006
|
|
4007
|
exports.NgLocaleLocalization = NgLocaleLocalization;
|
4008
|
exports.NgLocalization = NgLocalization;
|
4009
|
exports.ɵparseCookieValue = parseCookieValue;
|
4010
|
exports.CommonModule = CommonModule;
|
4011
|
exports.DeprecatedI18NPipesModule = DeprecatedI18NPipesModule;
|
4012
|
exports.NgClass = NgClass;
|
4013
|
exports.NgFor = NgFor;
|
4014
|
exports.NgForOf = NgForOf;
|
4015
|
exports.NgForOfContext = NgForOfContext;
|
4016
|
exports.NgIf = NgIf;
|
4017
|
exports.NgIfContext = NgIfContext;
|
4018
|
exports.NgPlural = NgPlural;
|
4019
|
exports.NgPluralCase = NgPluralCase;
|
4020
|
exports.NgStyle = NgStyle;
|
4021
|
exports.NgSwitch = NgSwitch;
|
4022
|
exports.NgSwitchCase = NgSwitchCase;
|
4023
|
exports.NgSwitchDefault = NgSwitchDefault;
|
4024
|
exports.NgTemplateOutlet = NgTemplateOutlet;
|
4025
|
exports.NgComponentOutlet = NgComponentOutlet;
|
4026
|
exports.DOCUMENT = DOCUMENT;
|
4027
|
exports.AsyncPipe = AsyncPipe;
|
4028
|
exports.DatePipe = DatePipe;
|
4029
|
exports.I18nPluralPipe = I18nPluralPipe;
|
4030
|
exports.I18nSelectPipe = I18nSelectPipe;
|
4031
|
exports.JsonPipe = JsonPipe;
|
4032
|
exports.LowerCasePipe = LowerCasePipe;
|
4033
|
exports.CurrencyPipe = CurrencyPipe;
|
4034
|
exports.DecimalPipe = DecimalPipe;
|
4035
|
exports.PercentPipe = PercentPipe;
|
4036
|
exports.SlicePipe = SlicePipe;
|
4037
|
exports.UpperCasePipe = UpperCasePipe;
|
4038
|
exports.TitleCasePipe = TitleCasePipe;
|
4039
|
exports.ɵPLATFORM_BROWSER_ID = PLATFORM_BROWSER_ID;
|
4040
|
exports.ɵPLATFORM_SERVER_ID = PLATFORM_SERVER_ID;
|
4041
|
exports.ɵPLATFORM_WORKER_APP_ID = PLATFORM_WORKER_APP_ID;
|
4042
|
exports.ɵPLATFORM_WORKER_UI_ID = PLATFORM_WORKER_UI_ID;
|
4043
|
exports.isPlatformBrowser = isPlatformBrowser;
|
4044
|
exports.isPlatformServer = isPlatformServer;
|
4045
|
exports.isPlatformWorkerApp = isPlatformWorkerApp;
|
4046
|
exports.isPlatformWorkerUi = isPlatformWorkerUi;
|
4047
|
exports.VERSION = VERSION;
|
4048
|
exports.PlatformLocation = PlatformLocation;
|
4049
|
exports.LOCATION_INITIALIZED = LOCATION_INITIALIZED;
|
4050
|
exports.LocationStrategy = LocationStrategy;
|
4051
|
exports.APP_BASE_HREF = APP_BASE_HREF;
|
4052
|
exports.HashLocationStrategy = HashLocationStrategy;
|
4053
|
exports.PathLocationStrategy = PathLocationStrategy;
|
4054
|
exports.Location = Location;
|
4055
|
exports.ɵa = COMMON_DIRECTIVES;
|
4056
|
exports.ɵb = COMMON_PIPES;
|
4057
|
|
4058
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4059
|
|
4060
|
})));
|
4061
|
//# sourceMappingURL=common.umd.js.map
|