source: trip-planner-front/node_modules/@angular/compiler/src/ml_parser/icu_ast_expander.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 18.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8(function (factory) {
9 if (typeof module === "object" && typeof module.exports === "object") {
10 var v = factory(require, exports);
11 if (v !== undefined) module.exports = v;
12 }
13 else if (typeof define === "function" && define.amd) {
14 define("@angular/compiler/src/ml_parser/icu_ast_expander", ["require", "exports", "tslib", "@angular/compiler/src/parse_util", "@angular/compiler/src/ml_parser/ast"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.ExpansionError = exports.ExpansionResult = exports.expandNodes = void 0;
20 var tslib_1 = require("tslib");
21 var parse_util_1 = require("@angular/compiler/src/parse_util");
22 var html = require("@angular/compiler/src/ml_parser/ast");
23 // http://cldr.unicode.org/index/cldr-spec/plural-rules
24 var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other'];
25 /**
26 * Expands special forms into elements.
27 *
28 * For example,
29 *
30 * ```
31 * { messages.length, plural,
32 * =0 {zero}
33 * =1 {one}
34 * other {more than one}
35 * }
36 * ```
37 *
38 * will be expanded into
39 *
40 * ```
41 * <ng-container [ngPlural]="messages.length">
42 * <ng-template ngPluralCase="=0">zero</ng-template>
43 * <ng-template ngPluralCase="=1">one</ng-template>
44 * <ng-template ngPluralCase="other">more than one</ng-template>
45 * </ng-container>
46 * ```
47 */
48 function expandNodes(nodes) {
49 var expander = new _Expander();
50 return new ExpansionResult(html.visitAll(expander, nodes), expander.isExpanded, expander.errors);
51 }
52 exports.expandNodes = expandNodes;
53 var ExpansionResult = /** @class */ (function () {
54 function ExpansionResult(nodes, expanded, errors) {
55 this.nodes = nodes;
56 this.expanded = expanded;
57 this.errors = errors;
58 }
59 return ExpansionResult;
60 }());
61 exports.ExpansionResult = ExpansionResult;
62 var ExpansionError = /** @class */ (function (_super) {
63 tslib_1.__extends(ExpansionError, _super);
64 function ExpansionError(span, errorMsg) {
65 return _super.call(this, span, errorMsg) || this;
66 }
67 return ExpansionError;
68 }(parse_util_1.ParseError));
69 exports.ExpansionError = ExpansionError;
70 /**
71 * Expand expansion forms (plural, select) to directives
72 *
73 * @internal
74 */
75 var _Expander = /** @class */ (function () {
76 function _Expander() {
77 this.isExpanded = false;
78 this.errors = [];
79 }
80 _Expander.prototype.visitElement = function (element, context) {
81 return new html.Element(element.name, element.attrs, html.visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
82 };
83 _Expander.prototype.visitAttribute = function (attribute, context) {
84 return attribute;
85 };
86 _Expander.prototype.visitText = function (text, context) {
87 return text;
88 };
89 _Expander.prototype.visitComment = function (comment, context) {
90 return comment;
91 };
92 _Expander.prototype.visitExpansion = function (icu, context) {
93 this.isExpanded = true;
94 return icu.type === 'plural' ? _expandPluralForm(icu, this.errors) :
95 _expandDefaultForm(icu, this.errors);
96 };
97 _Expander.prototype.visitExpansionCase = function (icuCase, context) {
98 throw new Error('Should not be reached');
99 };
100 return _Expander;
101 }());
102 // Plural forms are expanded to `NgPlural` and `NgPluralCase`s
103 function _expandPluralForm(ast, errors) {
104 var children = ast.cases.map(function (c) {
105 if (PLURAL_CASES.indexOf(c.value) === -1 && !c.value.match(/^=\d+$/)) {
106 errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=<number>\" or one of " + PLURAL_CASES.join(', ')));
107 }
108 var expansionResult = expandNodes(c.expression);
109 errors.push.apply(errors, tslib_1.__spreadArray([], tslib_1.__read(expansionResult.errors)));
110 return new html.Element("ng-template", [new html.Attribute('ngPluralCase', "" + c.value, c.valueSourceSpan, undefined /* keySpan */, undefined /* valueSpan */, undefined /* valueTokens */, undefined /* i18n */)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
111 });
112 var switchAttr = new html.Attribute('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan, undefined /* keySpan */, undefined /* valueSpan */, undefined /* valueTokens */, undefined /* i18n */);
113 return new html.Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
114 }
115 // ICU messages (excluding plural form) are expanded to `NgSwitch` and `NgSwitchCase`s
116 function _expandDefaultForm(ast, errors) {
117 var children = ast.cases.map(function (c) {
118 var expansionResult = expandNodes(c.expression);
119 errors.push.apply(errors, tslib_1.__spreadArray([], tslib_1.__read(expansionResult.errors)));
120 if (c.value === 'other') {
121 // other is the default case when no values match
122 return new html.Element("ng-template", [new html.Attribute('ngSwitchDefault', '', c.valueSourceSpan, undefined /* keySpan */, undefined /* valueSpan */, undefined /* valueTokens */, undefined /* i18n */)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
123 }
124 return new html.Element("ng-template", [new html.Attribute('ngSwitchCase', "" + c.value, c.valueSourceSpan, undefined /* keySpan */, undefined /* valueSpan */, undefined /* valueTokens */, undefined /* i18n */)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
125 });
126 var switchAttr = new html.Attribute('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan, undefined /* keySpan */, undefined /* valueSpan */, undefined /* valueTokens */, undefined /* i18n */);
127 return new html.Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
128 }
129});
130//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWN1X2FzdF9leHBhbmRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9tbF9wYXJzZXIvaWN1X2FzdF9leHBhbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTU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gLyogaTE4biAqLyldLFxuICAgICAgICBleHBhbnNpb25SZXN1bHQubm9kZXMsIGMuc291cmNlU3BhbiwgYy5zb3VyY2VTcGFuLCBjLnNvdXJjZVNwYW4pO1xuICB9KTtcbiAgY29uc3Qgc3dpdGNoQXR0ciA9IG5ldyBodG1sLkF0dHJpYnV0ZShcbiAgICAgICdbbmdTd2l0Y2hdJywgYXN0LnN3aXRjaFZhbHVlLCBhc3Quc3dpdGNoVmFsdWVTb3VyY2VTcGFuLCB1bmRlZmluZWQgLyoga2V5U3BhbiAqLyxcbiAgICAgIHVuZGVmaW5lZCAvKiB2YWx1ZVNwYW4gKi8sIHVuZGVmaW5lZCAvKiB2YWx1ZVRva2VucyAqLywgdW5kZWZpbmVkIC8qIGkxOG4gKi8pO1xuICByZXR1cm4gbmV3IGh0bWwuRWxlbWVudChcbiAgICAgICduZy1jb250YWluZXInLCBbc3dpdGNoQXR0cl0sIGNoaWxkcmVuLCBhc3Quc291cmNlU3BhbiwgYXN0LnNvdXJjZVNwYW4sIGFzdC5zb3VyY2VTcGFuKTtcbn1cbiJdfQ==
Note: See TracBrowser for help on using the repository browser.