react-intl 5.6.5 → 5.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_validate_dist_options.optionsvalid.d.ts → _validate_dist-base_options.optionsvalid.d.ts} +1 -1
- package/_validate_dist-esm_options.optionsvalid.d.ts +1 -1
- package/lib/src/components/injectIntl.js +1 -1
- package/lib/src/components/relative.js +1 -1
- package/lib/src/formatters/message.js +1 -1
- package/lib/src/formatters/plural.d.ts +1 -1
- package/lib/src/formatters/plural.d.ts.map +1 -1
- package/lib/src/utils.js +1 -1
- package/package.json +9 -9
- package/react-intl-no-parser.umd.js +108 -1432
- package/react-intl-no-parser.umd.min.js +2 -2
- package/react-intl.umd.js +5531 -6597
- package/react-intl.umd.min.js +9 -9
- package/src/components/createFormattedComponent.js +20 -1
- package/src/components/injectIntl.js +25 -3
- package/src/components/message.js +21 -2
- package/src/components/plural.js +24 -2
- package/src/components/provider.js +21 -2
- package/src/components/relative.js +22 -3
- package/src/components/useIntl.js +20 -1
- package/src/formatters/message.js +22 -3
- package/src/formatters/plural.d.ts +1 -1
- package/src/formatters/plural.d.ts.map +1 -1
- package/src/utils.js +23 -4
|
@@ -155,321 +155,6 @@
|
|
|
155
155
|
exports.createNumberElement = createNumberElement;
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
var skeleton = createCommonjsModule(function (module, exports) {
|
|
159
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
160
|
-
__assign = Object.assign || function(t) {
|
|
161
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
162
|
-
s = arguments[i];
|
|
163
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
164
|
-
t[p] = s[p];
|
|
165
|
-
}
|
|
166
|
-
return t;
|
|
167
|
-
};
|
|
168
|
-
return __assign.apply(this, arguments);
|
|
169
|
-
};
|
|
170
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
171
|
-
exports.convertNumberSkeletonToNumberFormatOptions = exports.parseDateTimeSkeleton = void 0;
|
|
172
|
-
/**
|
|
173
|
-
* https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
174
|
-
* Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
|
|
175
|
-
* with some tweaks
|
|
176
|
-
*/
|
|
177
|
-
var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
|
|
178
|
-
/**
|
|
179
|
-
* Parse Date time skeleton into Intl.DateTimeFormatOptions
|
|
180
|
-
* Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
181
|
-
* @public
|
|
182
|
-
* @param skeleton skeleton string
|
|
183
|
-
*/
|
|
184
|
-
function parseDateTimeSkeleton(skeleton) {
|
|
185
|
-
var result = {};
|
|
186
|
-
skeleton.replace(DATE_TIME_REGEX, function (match) {
|
|
187
|
-
var len = match.length;
|
|
188
|
-
switch (match[0]) {
|
|
189
|
-
// Era
|
|
190
|
-
case 'G':
|
|
191
|
-
result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
|
|
192
|
-
break;
|
|
193
|
-
// Year
|
|
194
|
-
case 'y':
|
|
195
|
-
result.year = len === 2 ? '2-digit' : 'numeric';
|
|
196
|
-
break;
|
|
197
|
-
case 'Y':
|
|
198
|
-
case 'u':
|
|
199
|
-
case 'U':
|
|
200
|
-
case 'r':
|
|
201
|
-
throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
|
|
202
|
-
// Quarter
|
|
203
|
-
case 'q':
|
|
204
|
-
case 'Q':
|
|
205
|
-
throw new RangeError('`q/Q` (quarter) patterns are not supported');
|
|
206
|
-
// Month
|
|
207
|
-
case 'M':
|
|
208
|
-
case 'L':
|
|
209
|
-
result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
|
|
210
|
-
break;
|
|
211
|
-
// Week
|
|
212
|
-
case 'w':
|
|
213
|
-
case 'W':
|
|
214
|
-
throw new RangeError('`w/W` (week) patterns are not supported');
|
|
215
|
-
case 'd':
|
|
216
|
-
result.day = ['numeric', '2-digit'][len - 1];
|
|
217
|
-
break;
|
|
218
|
-
case 'D':
|
|
219
|
-
case 'F':
|
|
220
|
-
case 'g':
|
|
221
|
-
throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
|
|
222
|
-
// Weekday
|
|
223
|
-
case 'E':
|
|
224
|
-
result.weekday = len === 4 ? 'short' : len === 5 ? 'narrow' : 'short';
|
|
225
|
-
break;
|
|
226
|
-
case 'e':
|
|
227
|
-
if (len < 4) {
|
|
228
|
-
throw new RangeError('`e..eee` (weekday) patterns are not supported');
|
|
229
|
-
}
|
|
230
|
-
result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
|
|
231
|
-
break;
|
|
232
|
-
case 'c':
|
|
233
|
-
if (len < 4) {
|
|
234
|
-
throw new RangeError('`c..ccc` (weekday) patterns are not supported');
|
|
235
|
-
}
|
|
236
|
-
result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
|
|
237
|
-
break;
|
|
238
|
-
// Period
|
|
239
|
-
case 'a': // AM, PM
|
|
240
|
-
result.hour12 = true;
|
|
241
|
-
break;
|
|
242
|
-
case 'b': // am, pm, noon, midnight
|
|
243
|
-
case 'B': // flexible day periods
|
|
244
|
-
throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
|
|
245
|
-
// Hour
|
|
246
|
-
case 'h':
|
|
247
|
-
result.hourCycle = 'h12';
|
|
248
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
249
|
-
break;
|
|
250
|
-
case 'H':
|
|
251
|
-
result.hourCycle = 'h23';
|
|
252
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
253
|
-
break;
|
|
254
|
-
case 'K':
|
|
255
|
-
result.hourCycle = 'h11';
|
|
256
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
257
|
-
break;
|
|
258
|
-
case 'k':
|
|
259
|
-
result.hourCycle = 'h24';
|
|
260
|
-
result.hour = ['numeric', '2-digit'][len - 1];
|
|
261
|
-
break;
|
|
262
|
-
case 'j':
|
|
263
|
-
case 'J':
|
|
264
|
-
case 'C':
|
|
265
|
-
throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
|
|
266
|
-
// Minute
|
|
267
|
-
case 'm':
|
|
268
|
-
result.minute = ['numeric', '2-digit'][len - 1];
|
|
269
|
-
break;
|
|
270
|
-
// Second
|
|
271
|
-
case 's':
|
|
272
|
-
result.second = ['numeric', '2-digit'][len - 1];
|
|
273
|
-
break;
|
|
274
|
-
case 'S':
|
|
275
|
-
case 'A':
|
|
276
|
-
throw new RangeError('`S/A` (second) pattenrs are not supported, use `s` instead');
|
|
277
|
-
// Zone
|
|
278
|
-
case 'z': // 1..3, 4: specific non-location format
|
|
279
|
-
result.timeZoneName = len < 4 ? 'short' : 'long';
|
|
280
|
-
break;
|
|
281
|
-
case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
|
|
282
|
-
case 'O': // 1, 4: miliseconds in day short, long
|
|
283
|
-
case 'v': // 1, 4: generic non-location format
|
|
284
|
-
case 'V': // 1, 2, 3, 4: time zone ID or city
|
|
285
|
-
case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
|
|
286
|
-
case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
|
|
287
|
-
throw new RangeError('`Z/O/v/V/X/x` (timeZone) pattenrs are not supported, use `z` instead');
|
|
288
|
-
}
|
|
289
|
-
return '';
|
|
290
|
-
});
|
|
291
|
-
return result;
|
|
292
|
-
}
|
|
293
|
-
exports.parseDateTimeSkeleton = parseDateTimeSkeleton;
|
|
294
|
-
function icuUnitToEcma(unit) {
|
|
295
|
-
return unit.replace(/^(.*?)-/, '');
|
|
296
|
-
}
|
|
297
|
-
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
|
|
298
|
-
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
|
|
299
|
-
function parseSignificantPrecision(str) {
|
|
300
|
-
var result = {};
|
|
301
|
-
str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
|
|
302
|
-
// @@@ case
|
|
303
|
-
if (typeof g2 !== 'string') {
|
|
304
|
-
result.minimumSignificantDigits = g1.length;
|
|
305
|
-
result.maximumSignificantDigits = g1.length;
|
|
306
|
-
}
|
|
307
|
-
// @@@+ case
|
|
308
|
-
else if (g2 === '+') {
|
|
309
|
-
result.minimumSignificantDigits = g1.length;
|
|
310
|
-
}
|
|
311
|
-
// .### case
|
|
312
|
-
else if (g1[0] === '#') {
|
|
313
|
-
result.maximumSignificantDigits = g1.length;
|
|
314
|
-
}
|
|
315
|
-
// .@@## or .@@@ case
|
|
316
|
-
else {
|
|
317
|
-
result.minimumSignificantDigits = g1.length;
|
|
318
|
-
result.maximumSignificantDigits =
|
|
319
|
-
g1.length + (typeof g2 === 'string' ? g2.length : 0);
|
|
320
|
-
}
|
|
321
|
-
return '';
|
|
322
|
-
});
|
|
323
|
-
return result;
|
|
324
|
-
}
|
|
325
|
-
function parseSign(str) {
|
|
326
|
-
switch (str) {
|
|
327
|
-
case 'sign-auto':
|
|
328
|
-
return {
|
|
329
|
-
signDisplay: 'auto',
|
|
330
|
-
};
|
|
331
|
-
case 'sign-accounting':
|
|
332
|
-
return {
|
|
333
|
-
currencySign: 'accounting',
|
|
334
|
-
};
|
|
335
|
-
case 'sign-always':
|
|
336
|
-
return {
|
|
337
|
-
signDisplay: 'always',
|
|
338
|
-
};
|
|
339
|
-
case 'sign-accounting-always':
|
|
340
|
-
return {
|
|
341
|
-
signDisplay: 'always',
|
|
342
|
-
currencySign: 'accounting',
|
|
343
|
-
};
|
|
344
|
-
case 'sign-except-zero':
|
|
345
|
-
return {
|
|
346
|
-
signDisplay: 'exceptZero',
|
|
347
|
-
};
|
|
348
|
-
case 'sign-accounting-except-zero':
|
|
349
|
-
return {
|
|
350
|
-
signDisplay: 'exceptZero',
|
|
351
|
-
currencySign: 'accounting',
|
|
352
|
-
};
|
|
353
|
-
case 'sign-never':
|
|
354
|
-
return {
|
|
355
|
-
signDisplay: 'never',
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
function parseNotationOptions(opt) {
|
|
360
|
-
var result = {};
|
|
361
|
-
var signOpts = parseSign(opt);
|
|
362
|
-
if (signOpts) {
|
|
363
|
-
return signOpts;
|
|
364
|
-
}
|
|
365
|
-
return result;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
|
|
369
|
-
*/
|
|
370
|
-
function convertNumberSkeletonToNumberFormatOptions(tokens) {
|
|
371
|
-
var result = {};
|
|
372
|
-
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
373
|
-
var token = tokens_1[_i];
|
|
374
|
-
switch (token.stem) {
|
|
375
|
-
case 'percent':
|
|
376
|
-
result.style = 'percent';
|
|
377
|
-
continue;
|
|
378
|
-
case 'currency':
|
|
379
|
-
result.style = 'currency';
|
|
380
|
-
result.currency = token.options[0];
|
|
381
|
-
continue;
|
|
382
|
-
case 'group-off':
|
|
383
|
-
result.useGrouping = false;
|
|
384
|
-
continue;
|
|
385
|
-
case 'precision-integer':
|
|
386
|
-
case '.':
|
|
387
|
-
result.maximumFractionDigits = 0;
|
|
388
|
-
continue;
|
|
389
|
-
case 'measure-unit':
|
|
390
|
-
result.style = 'unit';
|
|
391
|
-
result.unit = icuUnitToEcma(token.options[0]);
|
|
392
|
-
continue;
|
|
393
|
-
case 'compact-short':
|
|
394
|
-
result.notation = 'compact';
|
|
395
|
-
result.compactDisplay = 'short';
|
|
396
|
-
continue;
|
|
397
|
-
case 'compact-long':
|
|
398
|
-
result.notation = 'compact';
|
|
399
|
-
result.compactDisplay = 'long';
|
|
400
|
-
continue;
|
|
401
|
-
case 'scientific':
|
|
402
|
-
result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
|
|
403
|
-
continue;
|
|
404
|
-
case 'engineering':
|
|
405
|
-
result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
|
|
406
|
-
continue;
|
|
407
|
-
case 'notation-simple':
|
|
408
|
-
result.notation = 'standard';
|
|
409
|
-
continue;
|
|
410
|
-
// https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
|
|
411
|
-
case 'unit-width-narrow':
|
|
412
|
-
result.currencyDisplay = 'narrowSymbol';
|
|
413
|
-
result.unitDisplay = 'narrow';
|
|
414
|
-
continue;
|
|
415
|
-
case 'unit-width-short':
|
|
416
|
-
result.currencyDisplay = 'code';
|
|
417
|
-
result.unitDisplay = 'short';
|
|
418
|
-
continue;
|
|
419
|
-
case 'unit-width-full-name':
|
|
420
|
-
result.currencyDisplay = 'name';
|
|
421
|
-
result.unitDisplay = 'long';
|
|
422
|
-
continue;
|
|
423
|
-
case 'unit-width-iso-code':
|
|
424
|
-
result.currencyDisplay = 'symbol';
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
// Precision
|
|
428
|
-
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
|
|
429
|
-
// precision-integer case
|
|
430
|
-
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
|
|
431
|
-
if (token.options.length > 1) {
|
|
432
|
-
throw new RangeError('Fraction-precision stems only accept a single optional option');
|
|
433
|
-
}
|
|
434
|
-
token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
|
|
435
|
-
// .000* case (before ICU67 it was .000+)
|
|
436
|
-
if (g2 === '*') {
|
|
437
|
-
result.minimumFractionDigits = g1.length;
|
|
438
|
-
}
|
|
439
|
-
// .### case
|
|
440
|
-
else if (g3 && g3[0] === '#') {
|
|
441
|
-
result.maximumFractionDigits = g3.length;
|
|
442
|
-
}
|
|
443
|
-
// .00## case
|
|
444
|
-
else if (g4 && g5) {
|
|
445
|
-
result.minimumFractionDigits = g4.length;
|
|
446
|
-
result.maximumFractionDigits = g4.length + g5.length;
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
result.minimumFractionDigits = g1.length;
|
|
450
|
-
result.maximumFractionDigits = g1.length;
|
|
451
|
-
}
|
|
452
|
-
return '';
|
|
453
|
-
});
|
|
454
|
-
if (token.options.length) {
|
|
455
|
-
result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
|
|
456
|
-
}
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
|
|
460
|
-
result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
var signOpts = parseSign(token.stem);
|
|
464
|
-
if (signOpts) {
|
|
465
|
-
result = __assign(__assign({}, result), signOpts);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return result;
|
|
469
|
-
}
|
|
470
|
-
exports.convertNumberSkeletonToNumberFormatOptions = convertNumberSkeletonToNumberFormatOptions;
|
|
471
|
-
});
|
|
472
|
-
|
|
473
158
|
var dummy = createCommonjsModule(function (module, exports) {
|
|
474
159
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
475
160
|
if (k2 === undefined) k2 = k;
|
|
@@ -484,7 +169,6 @@
|
|
|
484
169
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
485
170
|
exports.parse = void 0;
|
|
486
171
|
__exportStar(types, exports);
|
|
487
|
-
__exportStar(skeleton, exports);
|
|
488
172
|
function parse() {
|
|
489
173
|
throw new Error("You're trying to format an uncompiled message with react-intl without parser, please import from 'react-int' instead");
|
|
490
174
|
}
|
|
@@ -642,8 +326,7 @@
|
|
|
642
326
|
strategies: strategies
|
|
643
327
|
}));
|
|
644
328
|
|
|
645
|
-
var
|
|
646
|
-
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
329
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
647
330
|
var extendStatics = function (d, b) {
|
|
648
331
|
extendStatics = Object.setPrototypeOf ||
|
|
649
332
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -656,8 +339,6 @@
|
|
|
656
339
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
657
340
|
};
|
|
658
341
|
})();
|
|
659
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
660
|
-
exports.MissingValueError = exports.InvalidValueTypeError = exports.InvalidValueError = exports.FormatError = exports.ErrorCode = void 0;
|
|
661
342
|
var ErrorCode;
|
|
662
343
|
(function (ErrorCode) {
|
|
663
344
|
// When we have a placeholder but no value to format
|
|
@@ -666,7 +347,7 @@
|
|
|
666
347
|
ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
|
|
667
348
|
// When we need specific Intl API but it's not available
|
|
668
349
|
ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
|
|
669
|
-
})(ErrorCode
|
|
350
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
670
351
|
var FormatError = /** @class */ (function (_super) {
|
|
671
352
|
__extends(FormatError, _super);
|
|
672
353
|
function FormatError(msg, code, originalMessage) {
|
|
@@ -680,7 +361,6 @@
|
|
|
680
361
|
};
|
|
681
362
|
return FormatError;
|
|
682
363
|
}(Error));
|
|
683
|
-
exports.FormatError = FormatError;
|
|
684
364
|
var InvalidValueError = /** @class */ (function (_super) {
|
|
685
365
|
__extends(InvalidValueError, _super);
|
|
686
366
|
function InvalidValueError(variableId, value, options, originalMessage) {
|
|
@@ -688,7 +368,6 @@
|
|
|
688
368
|
}
|
|
689
369
|
return InvalidValueError;
|
|
690
370
|
}(FormatError));
|
|
691
|
-
exports.InvalidValueError = InvalidValueError;
|
|
692
371
|
var InvalidValueTypeError = /** @class */ (function (_super) {
|
|
693
372
|
__extends(InvalidValueTypeError, _super);
|
|
694
373
|
function InvalidValueTypeError(value, type, originalMessage) {
|
|
@@ -696,7 +375,6 @@
|
|
|
696
375
|
}
|
|
697
376
|
return InvalidValueTypeError;
|
|
698
377
|
}(FormatError));
|
|
699
|
-
exports.InvalidValueTypeError = InvalidValueTypeError;
|
|
700
378
|
var MissingValueError = /** @class */ (function (_super) {
|
|
701
379
|
__extends(MissingValueError, _super);
|
|
702
380
|
function MissingValueError(variableId, originalMessage) {
|
|
@@ -704,19 +382,12 @@
|
|
|
704
382
|
}
|
|
705
383
|
return MissingValueError;
|
|
706
384
|
}(FormatError));
|
|
707
|
-
exports.MissingValueError = MissingValueError;
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
var formatters = createCommonjsModule(function (module, exports) {
|
|
711
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
712
|
-
exports.formatToParts = exports.isFormatXMLElementFn = exports.PART_TYPE = void 0;
|
|
713
|
-
|
|
714
385
|
|
|
715
386
|
var PART_TYPE;
|
|
716
387
|
(function (PART_TYPE) {
|
|
717
388
|
PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
|
|
718
389
|
PART_TYPE[PART_TYPE["object"] = 1] = "object";
|
|
719
|
-
})(PART_TYPE
|
|
390
|
+
})(PART_TYPE || (PART_TYPE = {}));
|
|
720
391
|
function mergeLiteral(parts) {
|
|
721
392
|
if (parts.length < 2) {
|
|
722
393
|
return parts;
|
|
@@ -737,7 +408,6 @@
|
|
|
737
408
|
function isFormatXMLElementFn(el) {
|
|
738
409
|
return typeof el === 'function';
|
|
739
410
|
}
|
|
740
|
-
exports.isFormatXMLElementFn = isFormatXMLElementFn;
|
|
741
411
|
// TODO(skeleton): add skeleton support
|
|
742
412
|
function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
|
|
743
413
|
// For debugging
|
|
@@ -776,7 +446,7 @@
|
|
|
776
446
|
var varName = el.value;
|
|
777
447
|
// Enforce that all required values are provided by the caller.
|
|
778
448
|
if (!(values && varName in values)) {
|
|
779
|
-
throw new
|
|
449
|
+
throw new MissingValueError(varName, originalMessage);
|
|
780
450
|
}
|
|
781
451
|
var value = values[varName];
|
|
782
452
|
if (dummy.isArgumentElement(el)) {
|
|
@@ -799,7 +469,7 @@
|
|
|
799
469
|
var style = typeof el.style === 'string'
|
|
800
470
|
? formats.date[el.style]
|
|
801
471
|
: dummy.isDateTimeSkeleton(el.style)
|
|
802
|
-
?
|
|
472
|
+
? el.style.parsedOptions
|
|
803
473
|
: undefined;
|
|
804
474
|
result.push({
|
|
805
475
|
type: 0 /* literal */,
|
|
@@ -813,7 +483,7 @@
|
|
|
813
483
|
var style = typeof el.style === 'string'
|
|
814
484
|
? formats.time[el.style]
|
|
815
485
|
: dummy.isDateTimeSkeleton(el.style)
|
|
816
|
-
?
|
|
486
|
+
? el.style.parsedOptions
|
|
817
487
|
: undefined;
|
|
818
488
|
result.push({
|
|
819
489
|
type: 0 /* literal */,
|
|
@@ -827,7 +497,7 @@
|
|
|
827
497
|
var style = typeof el.style === 'string'
|
|
828
498
|
? formats.number[el.style]
|
|
829
499
|
: dummy.isNumberSkeleton(el.style)
|
|
830
|
-
?
|
|
500
|
+
? el.style.parsedOptions
|
|
831
501
|
: undefined;
|
|
832
502
|
result.push({
|
|
833
503
|
type: 0 /* literal */,
|
|
@@ -841,7 +511,7 @@
|
|
|
841
511
|
var children = el.children, value_1 = el.value;
|
|
842
512
|
var formatFn = values[value_1];
|
|
843
513
|
if (!isFormatXMLElementFn(formatFn)) {
|
|
844
|
-
throw new
|
|
514
|
+
throw new InvalidValueTypeError(value_1, 'function', originalMessage);
|
|
845
515
|
}
|
|
846
516
|
var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
|
|
847
517
|
var chunks = formatFn(parts.map(function (p) { return p.value; }));
|
|
@@ -858,7 +528,7 @@
|
|
|
858
528
|
if (dummy.isSelectElement(el)) {
|
|
859
529
|
var opt = el.options[value] || el.options.other;
|
|
860
530
|
if (!opt) {
|
|
861
|
-
throw new
|
|
531
|
+
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
862
532
|
}
|
|
863
533
|
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
|
|
864
534
|
continue;
|
|
@@ -867,7 +537,7 @@
|
|
|
867
537
|
var opt = el.options["=" + value];
|
|
868
538
|
if (!opt) {
|
|
869
539
|
if (!Intl.PluralRules) {
|
|
870
|
-
throw new
|
|
540
|
+
throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", "MISSING_INTL_API" /* MISSING_INTL_API */, originalMessage);
|
|
871
541
|
}
|
|
872
542
|
var rule = formatters
|
|
873
543
|
.getPluralRules(locales, { type: el.pluralType })
|
|
@@ -875,7 +545,7 @@
|
|
|
875
545
|
opt = el.options[rule] || el.options.other;
|
|
876
546
|
}
|
|
877
547
|
if (!opt) {
|
|
878
|
-
throw new
|
|
548
|
+
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
879
549
|
}
|
|
880
550
|
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
|
|
881
551
|
continue;
|
|
@@ -883,16 +553,13 @@
|
|
|
883
553
|
}
|
|
884
554
|
return mergeLiteral(result);
|
|
885
555
|
}
|
|
886
|
-
exports.formatToParts = formatToParts;
|
|
887
|
-
});
|
|
888
556
|
|
|
889
|
-
var core = createCommonjsModule(function (module, exports) {
|
|
890
557
|
/*
|
|
891
558
|
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
892
559
|
Copyrights licensed under the New BSD License.
|
|
893
560
|
See the accompanying LICENSE file for terms.
|
|
894
561
|
*/
|
|
895
|
-
var __assign = (
|
|
562
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
896
563
|
__assign = Object.assign || function(t) {
|
|
897
564
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
898
565
|
s = arguments[i];
|
|
@@ -903,18 +570,13 @@
|
|
|
903
570
|
};
|
|
904
571
|
return __assign.apply(this, arguments);
|
|
905
572
|
};
|
|
906
|
-
var __spreadArrays = (
|
|
573
|
+
var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
|
|
907
574
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
908
575
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
909
576
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
910
577
|
r[k] = a[j];
|
|
911
578
|
return r;
|
|
912
579
|
};
|
|
913
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
914
|
-
exports.IntlMessageFormat = void 0;
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
580
|
// -- MessageFormat --------------------------------------------------------
|
|
919
581
|
function mergeConfig(c1, c2) {
|
|
920
582
|
if (!c2) {
|
|
@@ -952,7 +614,7 @@
|
|
|
952
614
|
};
|
|
953
615
|
}
|
|
954
616
|
// @ts-ignore this is to deal with rollup's default import shenanigans
|
|
955
|
-
var _memoizeIntl = src
|
|
617
|
+
var _memoizeIntl = src || memoize$1;
|
|
956
618
|
var memoizeIntl = _memoizeIntl;
|
|
957
619
|
function createDefaultFormatters(cache) {
|
|
958
620
|
if (cache === void 0) { cache = {
|
|
@@ -1028,7 +690,7 @@
|
|
|
1028
690
|
return result;
|
|
1029
691
|
};
|
|
1030
692
|
this.formatToParts = function (values) {
|
|
1031
|
-
return
|
|
693
|
+
return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
|
|
1032
694
|
};
|
|
1033
695
|
this.resolvedOptions = function () { return ({
|
|
1034
696
|
locale: Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
|
|
@@ -1132,1001 +794,19 @@
|
|
|
1132
794
|
};
|
|
1133
795
|
return IntlMessageFormat;
|
|
1134
796
|
}());
|
|
1135
|
-
exports.IntlMessageFormat = IntlMessageFormat;
|
|
1136
|
-
});
|
|
1137
|
-
|
|
1138
|
-
var intlMessageformat = createCommonjsModule(function (module, exports) {
|
|
1139
|
-
/*
|
|
1140
|
-
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
1141
|
-
Copyrights licensed under the New BSD License.
|
|
1142
|
-
See the accompanying LICENSE file for terms.
|
|
1143
|
-
*/
|
|
1144
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1145
|
-
if (k2 === undefined) k2 = k;
|
|
1146
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1147
|
-
}) : (function(o, m, k, k2) {
|
|
1148
|
-
if (k2 === undefined) k2 = k;
|
|
1149
|
-
o[k2] = m[k];
|
|
1150
|
-
}));
|
|
1151
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
1152
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
1153
|
-
};
|
|
1154
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1155
|
-
|
|
1156
|
-
__exportStar(formatters, exports);
|
|
1157
|
-
__exportStar(core, exports);
|
|
1158
|
-
__exportStar(error, exports);
|
|
1159
|
-
exports.default = core.IntlMessageFormat;
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
var diff = createCommonjsModule(function (module, exports) {
|
|
1163
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
1164
|
-
__assign = Object.assign || function(t) {
|
|
1165
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1166
|
-
s = arguments[i];
|
|
1167
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1168
|
-
t[p] = s[p];
|
|
1169
|
-
}
|
|
1170
|
-
return t;
|
|
1171
|
-
};
|
|
1172
|
-
return __assign.apply(this, arguments);
|
|
1173
|
-
};
|
|
1174
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1175
|
-
exports.DEFAULT_THRESHOLDS = exports.selectUnit = void 0;
|
|
1176
|
-
var MS_PER_SECOND = 1e3;
|
|
1177
|
-
var SECS_PER_MIN = 60;
|
|
1178
|
-
var SECS_PER_HOUR = SECS_PER_MIN * 60;
|
|
1179
|
-
var SECS_PER_DAY = SECS_PER_HOUR * 24;
|
|
1180
|
-
var SECS_PER_WEEK = SECS_PER_DAY * 7;
|
|
1181
|
-
function selectUnit(from, to, thresholds) {
|
|
1182
|
-
if (to === void 0) { to = Date.now(); }
|
|
1183
|
-
if (thresholds === void 0) { thresholds = {}; }
|
|
1184
|
-
var resolvedThresholds = __assign(__assign({}, exports.DEFAULT_THRESHOLDS), (thresholds || {}));
|
|
1185
|
-
var secs = (+from - +to) / MS_PER_SECOND;
|
|
1186
|
-
if (Math.abs(secs) < resolvedThresholds.second) {
|
|
1187
|
-
return {
|
|
1188
|
-
value: Math.round(secs),
|
|
1189
|
-
unit: 'second',
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
var mins = secs / SECS_PER_MIN;
|
|
1193
|
-
if (Math.abs(mins) < resolvedThresholds.minute) {
|
|
1194
|
-
return {
|
|
1195
|
-
value: Math.round(mins),
|
|
1196
|
-
unit: 'minute',
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
var hours = secs / SECS_PER_HOUR;
|
|
1200
|
-
if (Math.abs(hours) < resolvedThresholds.hour) {
|
|
1201
|
-
return {
|
|
1202
|
-
value: Math.round(hours),
|
|
1203
|
-
unit: 'hour',
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
var days = secs / SECS_PER_DAY;
|
|
1207
|
-
if (Math.abs(days) < resolvedThresholds.day) {
|
|
1208
|
-
return {
|
|
1209
|
-
value: Math.round(days),
|
|
1210
|
-
unit: 'day',
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
var fromDate = new Date(from);
|
|
1214
|
-
var toDate = new Date(to);
|
|
1215
|
-
var years = fromDate.getFullYear() - toDate.getFullYear();
|
|
1216
|
-
if (Math.round(Math.abs(years)) > 0) {
|
|
1217
|
-
return {
|
|
1218
|
-
value: Math.round(years),
|
|
1219
|
-
unit: 'year',
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
var months = years * 12 + fromDate.getMonth() - toDate.getMonth();
|
|
1223
|
-
if (Math.round(Math.abs(months)) > 0) {
|
|
1224
|
-
return {
|
|
1225
|
-
value: Math.round(months),
|
|
1226
|
-
unit: 'month',
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
var weeks = secs / SECS_PER_WEEK;
|
|
1230
|
-
return {
|
|
1231
|
-
value: Math.round(weeks),
|
|
1232
|
-
unit: 'week',
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
exports.selectUnit = selectUnit;
|
|
1236
|
-
exports.DEFAULT_THRESHOLDS = {
|
|
1237
|
-
second: 45,
|
|
1238
|
-
minute: 45,
|
|
1239
|
-
hour: 22,
|
|
1240
|
-
day: 5,
|
|
1241
|
-
};
|
|
1242
|
-
});
|
|
1243
|
-
|
|
1244
|
-
var invariant_1 = createCommonjsModule(function (module, exports) {
|
|
1245
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1246
|
-
exports.invariant = void 0;
|
|
1247
|
-
function invariant(condition, message, Err) {
|
|
1248
|
-
if (Err === void 0) { Err = Error; }
|
|
1249
|
-
if (!condition) {
|
|
1250
|
-
throw new Err(message);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
exports.invariant = invariant;
|
|
1254
|
-
});
|
|
1255
|
-
|
|
1256
|
-
var units = createCommonjsModule(function (module, exports) {
|
|
1257
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1258
|
-
exports.removeUnitNamespace = exports.SANCTIONED_UNITS = void 0;
|
|
1259
|
-
// https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
|
|
1260
|
-
exports.SANCTIONED_UNITS = [
|
|
1261
|
-
'angle-degree',
|
|
1262
|
-
'area-acre',
|
|
1263
|
-
'area-hectare',
|
|
1264
|
-
'concentr-percent',
|
|
1265
|
-
'digital-bit',
|
|
1266
|
-
'digital-byte',
|
|
1267
|
-
'digital-gigabit',
|
|
1268
|
-
'digital-gigabyte',
|
|
1269
|
-
'digital-kilobit',
|
|
1270
|
-
'digital-kilobyte',
|
|
1271
|
-
'digital-megabit',
|
|
1272
|
-
'digital-megabyte',
|
|
1273
|
-
'digital-petabyte',
|
|
1274
|
-
'digital-terabit',
|
|
1275
|
-
'digital-terabyte',
|
|
1276
|
-
'duration-day',
|
|
1277
|
-
'duration-hour',
|
|
1278
|
-
'duration-millisecond',
|
|
1279
|
-
'duration-minute',
|
|
1280
|
-
'duration-month',
|
|
1281
|
-
'duration-second',
|
|
1282
|
-
'duration-week',
|
|
1283
|
-
'duration-year',
|
|
1284
|
-
'length-centimeter',
|
|
1285
|
-
'length-foot',
|
|
1286
|
-
'length-inch',
|
|
1287
|
-
'length-kilometer',
|
|
1288
|
-
'length-meter',
|
|
1289
|
-
'length-mile-scandinavian',
|
|
1290
|
-
'length-mile',
|
|
1291
|
-
'length-millimeter',
|
|
1292
|
-
'length-yard',
|
|
1293
|
-
'mass-gram',
|
|
1294
|
-
'mass-kilogram',
|
|
1295
|
-
'mass-ounce',
|
|
1296
|
-
'mass-pound',
|
|
1297
|
-
'mass-stone',
|
|
1298
|
-
'temperature-celsius',
|
|
1299
|
-
'temperature-fahrenheit',
|
|
1300
|
-
'volume-fluid-ounce',
|
|
1301
|
-
'volume-gallon',
|
|
1302
|
-
'volume-liter',
|
|
1303
|
-
'volume-milliliter',
|
|
1304
|
-
];
|
|
1305
|
-
// In CLDR, the unit name always follows the form `namespace-unit` pattern.
|
|
1306
|
-
// For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
|
|
1307
|
-
function removeUnitNamespace(unit) {
|
|
1308
|
-
return unit.replace(/^(.*?)-/, '');
|
|
1309
|
-
}
|
|
1310
|
-
exports.removeUnitNamespace = removeUnitNamespace;
|
|
1311
|
-
});
|
|
1312
|
-
|
|
1313
|
-
var polyfillUtils = createCommonjsModule(function (module, exports) {
|
|
1314
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1315
|
-
exports.defineProperty = exports.isWellFormedUnitIdentifier = exports.getMagnitude = exports.repeat = exports.toRawPrecision = exports.toRawFixed = exports.formatNumericToString = exports.isWellFormedCurrencyCode = exports.objectIs = exports.setNumberFormatDigitOptions = exports.partitionPattern = exports.isLiteralPart = exports.getMultiInternalSlots = exports.getInternalSlot = exports.setMultiInternalSlots = exports.setInternalSlot = exports.getNumberOption = exports.defaultNumberOption = exports.getOption = exports.toString = exports.toObject = exports.hasOwnProperty = void 0;
|
|
1316
797
|
|
|
1317
|
-
|
|
1318
|
-
function hasOwnProperty(o, key) {
|
|
1319
|
-
return Object.prototype.hasOwnProperty.call(o, key);
|
|
1320
|
-
}
|
|
1321
|
-
exports.hasOwnProperty = hasOwnProperty;
|
|
1322
|
-
/**
|
|
1323
|
-
* https://tc39.es/ecma262/#sec-toobject
|
|
1324
|
-
* @param arg
|
|
1325
|
-
*/
|
|
1326
|
-
function toObject(arg) {
|
|
1327
|
-
if (arg == null) {
|
|
1328
|
-
throw new TypeError('undefined/null cannot be converted to object');
|
|
1329
|
-
}
|
|
1330
|
-
return Object(arg);
|
|
1331
|
-
}
|
|
1332
|
-
exports.toObject = toObject;
|
|
1333
|
-
/**
|
|
1334
|
-
* https://tc39.es/ecma262/#sec-tostring
|
|
1335
|
-
*/
|
|
1336
|
-
function toString(o) {
|
|
1337
|
-
// Only symbol is irregular...
|
|
1338
|
-
if (typeof o === 'symbol') {
|
|
1339
|
-
throw TypeError('Cannot convert a Symbol value to a string');
|
|
1340
|
-
}
|
|
1341
|
-
return String(o);
|
|
1342
|
-
}
|
|
1343
|
-
exports.toString = toString;
|
|
1344
|
-
/**
|
|
1345
|
-
* https://tc39.es/ecma402/#sec-getoption
|
|
1346
|
-
* @param opts
|
|
1347
|
-
* @param prop
|
|
1348
|
-
* @param type
|
|
1349
|
-
* @param values
|
|
1350
|
-
* @param fallback
|
|
1351
|
-
*/
|
|
1352
|
-
function getOption(opts, prop, type, values, fallback) {
|
|
1353
|
-
// const descriptor = Object.getOwnPropertyDescriptor(opts, prop);
|
|
1354
|
-
var value = opts[prop];
|
|
1355
|
-
if (value !== undefined) {
|
|
1356
|
-
if (type !== 'boolean' && type !== 'string') {
|
|
1357
|
-
throw new TypeError('invalid type');
|
|
1358
|
-
}
|
|
1359
|
-
if (type === 'boolean') {
|
|
1360
|
-
value = Boolean(value);
|
|
1361
|
-
}
|
|
1362
|
-
if (type === 'string') {
|
|
1363
|
-
value = toString(value);
|
|
1364
|
-
}
|
|
1365
|
-
if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
|
|
1366
|
-
throw new RangeError(value + " is not within " + values.join(', '));
|
|
1367
|
-
}
|
|
1368
|
-
return value;
|
|
1369
|
-
}
|
|
1370
|
-
return fallback;
|
|
1371
|
-
}
|
|
1372
|
-
exports.getOption = getOption;
|
|
1373
|
-
/**
|
|
1374
|
-
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
1375
|
-
* @param val
|
|
1376
|
-
* @param min
|
|
1377
|
-
* @param max
|
|
1378
|
-
* @param fallback
|
|
1379
|
-
*/
|
|
1380
|
-
function defaultNumberOption(val, min, max, fallback) {
|
|
1381
|
-
if (val !== undefined) {
|
|
1382
|
-
val = Number(val);
|
|
1383
|
-
if (isNaN(val) || val < min || val > max) {
|
|
1384
|
-
throw new RangeError(val + " is outside of range [" + min + ", " + max + "]");
|
|
1385
|
-
}
|
|
1386
|
-
return Math.floor(val);
|
|
1387
|
-
}
|
|
1388
|
-
return fallback;
|
|
1389
|
-
}
|
|
1390
|
-
exports.defaultNumberOption = defaultNumberOption;
|
|
1391
|
-
/**
|
|
1392
|
-
* https://tc39.es/ecma402/#sec-getnumberoption
|
|
1393
|
-
* @param options
|
|
1394
|
-
* @param property
|
|
1395
|
-
* @param min
|
|
1396
|
-
* @param max
|
|
1397
|
-
* @param fallback
|
|
1398
|
-
*/
|
|
1399
|
-
function getNumberOption(options, property, minimum, maximum, fallback) {
|
|
1400
|
-
var val = options[property];
|
|
1401
|
-
return defaultNumberOption(val, minimum, maximum, fallback);
|
|
1402
|
-
}
|
|
1403
|
-
exports.getNumberOption = getNumberOption;
|
|
1404
|
-
function setInternalSlot(map, pl, field, value) {
|
|
1405
|
-
if (!map.get(pl)) {
|
|
1406
|
-
map.set(pl, Object.create(null));
|
|
1407
|
-
}
|
|
1408
|
-
var slots = map.get(pl);
|
|
1409
|
-
slots[field] = value;
|
|
1410
|
-
}
|
|
1411
|
-
exports.setInternalSlot = setInternalSlot;
|
|
1412
|
-
function setMultiInternalSlots(map, pl, props) {
|
|
1413
|
-
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
1414
|
-
var k = _a[_i];
|
|
1415
|
-
setInternalSlot(map, pl, k, props[k]);
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
exports.setMultiInternalSlots = setMultiInternalSlots;
|
|
1419
|
-
function getInternalSlot(map, pl, field) {
|
|
1420
|
-
return getMultiInternalSlots(map, pl, field)[field];
|
|
1421
|
-
}
|
|
1422
|
-
exports.getInternalSlot = getInternalSlot;
|
|
1423
|
-
function getMultiInternalSlots(map, pl) {
|
|
1424
|
-
var fields = [];
|
|
1425
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1426
|
-
fields[_i - 2] = arguments[_i];
|
|
1427
|
-
}
|
|
1428
|
-
var slots = map.get(pl);
|
|
1429
|
-
if (!slots) {
|
|
1430
|
-
throw new TypeError(pl + " InternalSlot has not been initialized");
|
|
1431
|
-
}
|
|
1432
|
-
return fields.reduce(function (all, f) {
|
|
1433
|
-
all[f] = slots[f];
|
|
1434
|
-
return all;
|
|
1435
|
-
}, Object.create(null));
|
|
1436
|
-
}
|
|
1437
|
-
exports.getMultiInternalSlots = getMultiInternalSlots;
|
|
1438
|
-
function isLiteralPart(patternPart) {
|
|
1439
|
-
return patternPart.type === 'literal';
|
|
1440
|
-
}
|
|
1441
|
-
exports.isLiteralPart = isLiteralPart;
|
|
1442
|
-
function partitionPattern(pattern) {
|
|
1443
|
-
var result = [];
|
|
1444
|
-
var beginIndex = pattern.indexOf('{');
|
|
1445
|
-
var endIndex = 0;
|
|
1446
|
-
var nextIndex = 0;
|
|
1447
|
-
var length = pattern.length;
|
|
1448
|
-
while (beginIndex < pattern.length && beginIndex > -1) {
|
|
1449
|
-
endIndex = pattern.indexOf('}', beginIndex);
|
|
1450
|
-
invariant_1.invariant(endIndex > beginIndex, "Invalid pattern " + pattern);
|
|
1451
|
-
if (beginIndex > nextIndex) {
|
|
1452
|
-
result.push({
|
|
1453
|
-
type: 'literal',
|
|
1454
|
-
value: pattern.substring(nextIndex, beginIndex),
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
result.push({
|
|
1458
|
-
type: pattern.substring(beginIndex + 1, endIndex),
|
|
1459
|
-
value: undefined,
|
|
1460
|
-
});
|
|
1461
|
-
nextIndex = endIndex + 1;
|
|
1462
|
-
beginIndex = pattern.indexOf('{', nextIndex);
|
|
1463
|
-
}
|
|
1464
|
-
if (nextIndex < length) {
|
|
1465
|
-
result.push({
|
|
1466
|
-
type: 'literal',
|
|
1467
|
-
value: pattern.substring(nextIndex, length),
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
return result;
|
|
1471
|
-
}
|
|
1472
|
-
exports.partitionPattern = partitionPattern;
|
|
1473
|
-
/**
|
|
1474
|
-
* https://tc39.es/ecma402/#sec-setnfdigitoptions
|
|
1475
|
-
*/
|
|
1476
|
-
function setNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
|
|
1477
|
-
var mnid = getNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1);
|
|
1478
|
-
var mnfd = opts.minimumFractionDigits;
|
|
1479
|
-
var mxfd = opts.maximumFractionDigits;
|
|
1480
|
-
var mnsd = opts.minimumSignificantDigits;
|
|
1481
|
-
var mxsd = opts.maximumSignificantDigits;
|
|
1482
|
-
internalSlots.minimumIntegerDigits = mnid;
|
|
1483
|
-
if (mnsd !== undefined || mxsd !== undefined) {
|
|
1484
|
-
internalSlots.roundingType = 'significantDigits';
|
|
1485
|
-
mnsd = defaultNumberOption(mnsd, 1, 21, 1);
|
|
1486
|
-
mxsd = defaultNumberOption(mxsd, mnsd, 21, 21);
|
|
1487
|
-
internalSlots.minimumSignificantDigits = mnsd;
|
|
1488
|
-
internalSlots.maximumSignificantDigits = mxsd;
|
|
1489
|
-
}
|
|
1490
|
-
else if (mnfd !== undefined || mxfd !== undefined) {
|
|
1491
|
-
internalSlots.roundingType = 'fractionDigits';
|
|
1492
|
-
mnfd = defaultNumberOption(mnfd, 0, 20, mnfdDefault);
|
|
1493
|
-
var mxfdActualDefault = Math.max(mnfd, mxfdDefault);
|
|
1494
|
-
mxfd = defaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault);
|
|
1495
|
-
internalSlots.minimumFractionDigits = mnfd;
|
|
1496
|
-
internalSlots.maximumFractionDigits = mxfd;
|
|
1497
|
-
}
|
|
1498
|
-
else if (notation === 'compact') {
|
|
1499
|
-
internalSlots.roundingType = 'compactRounding';
|
|
1500
|
-
}
|
|
1501
|
-
else {
|
|
1502
|
-
internalSlots.roundingType = 'fractionDigits';
|
|
1503
|
-
internalSlots.minimumFractionDigits = mnfdDefault;
|
|
1504
|
-
internalSlots.maximumFractionDigits = mxfdDefault;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
exports.setNumberFormatDigitOptions = setNumberFormatDigitOptions;
|
|
1508
|
-
function objectIs(x, y) {
|
|
1509
|
-
if (Object.is) {
|
|
1510
|
-
return Object.is(x, y);
|
|
1511
|
-
}
|
|
1512
|
-
// SameValue algorithm
|
|
1513
|
-
if (x === y) {
|
|
1514
|
-
// Steps 1-5, 7-10
|
|
1515
|
-
// Steps 6.b-6.e: +0 != -0
|
|
1516
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
1517
|
-
}
|
|
1518
|
-
// Step 6.a: NaN == NaN
|
|
1519
|
-
return x !== x && y !== y;
|
|
1520
|
-
}
|
|
1521
|
-
exports.objectIs = objectIs;
|
|
1522
|
-
var NOT_A_Z_REGEX = /[^A-Z]/;
|
|
1523
|
-
/**
|
|
1524
|
-
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
1525
|
-
* @param str string to convert
|
|
1526
|
-
*/
|
|
1527
|
-
function toUpperCase(str) {
|
|
1528
|
-
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
|
|
1532
|
-
*/
|
|
1533
|
-
function isWellFormedCurrencyCode(currency) {
|
|
1534
|
-
currency = toUpperCase(currency);
|
|
1535
|
-
if (currency.length !== 3) {
|
|
1536
|
-
return false;
|
|
1537
|
-
}
|
|
1538
|
-
if (NOT_A_Z_REGEX.test(currency)) {
|
|
1539
|
-
return false;
|
|
1540
|
-
}
|
|
1541
|
-
return true;
|
|
1542
|
-
}
|
|
1543
|
-
exports.isWellFormedCurrencyCode = isWellFormedCurrencyCode;
|
|
1544
|
-
/**
|
|
1545
|
-
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
1546
|
-
* TODO: dedup with intl-pluralrules
|
|
1547
|
-
*/
|
|
1548
|
-
function formatNumericToString(internalSlots, x) {
|
|
1549
|
-
var isNegative = x < 0 || objectIs(x, -0);
|
|
1550
|
-
if (isNegative) {
|
|
1551
|
-
x = -x;
|
|
1552
|
-
}
|
|
1553
|
-
var result;
|
|
1554
|
-
var rourndingType = internalSlots.roundingType;
|
|
1555
|
-
switch (rourndingType) {
|
|
1556
|
-
case 'significantDigits':
|
|
1557
|
-
result = toRawPrecision(x, internalSlots.minimumSignificantDigits, internalSlots.maximumSignificantDigits);
|
|
1558
|
-
break;
|
|
1559
|
-
case 'fractionDigits':
|
|
1560
|
-
result = toRawFixed(x, internalSlots.minimumFractionDigits, internalSlots.maximumFractionDigits);
|
|
1561
|
-
break;
|
|
1562
|
-
default:
|
|
1563
|
-
result = toRawPrecision(x, 1, 2);
|
|
1564
|
-
if (result.integerDigitsCount > 1) {
|
|
1565
|
-
result = toRawFixed(x, 0, 0);
|
|
1566
|
-
}
|
|
1567
|
-
break;
|
|
1568
|
-
}
|
|
1569
|
-
x = result.roundedNumber;
|
|
1570
|
-
var string = result.formattedString;
|
|
1571
|
-
var int = result.integerDigitsCount;
|
|
1572
|
-
var minInteger = internalSlots.minimumIntegerDigits;
|
|
1573
|
-
if (int < minInteger) {
|
|
1574
|
-
var forwardZeros = repeat('0', minInteger - int);
|
|
1575
|
-
string = forwardZeros + string;
|
|
1576
|
-
}
|
|
1577
|
-
if (isNegative) {
|
|
1578
|
-
x = -x;
|
|
1579
|
-
}
|
|
1580
|
-
return { roundedNumber: x, formattedString: string };
|
|
1581
|
-
}
|
|
1582
|
-
exports.formatNumericToString = formatNumericToString;
|
|
1583
|
-
/**
|
|
1584
|
-
* TODO: dedup with intl-pluralrules and support BigInt
|
|
1585
|
-
* https://tc39.es/ecma402/#sec-torawfixed
|
|
1586
|
-
* @param x a finite non-negative Number or BigInt
|
|
1587
|
-
* @param minFraction and integer between 0 and 20
|
|
1588
|
-
* @param maxFraction and integer between 0 and 20
|
|
1589
|
-
*/
|
|
1590
|
-
function toRawFixed(x, minFraction, maxFraction) {
|
|
1591
|
-
var f = maxFraction;
|
|
1592
|
-
var n = Math.round(x * Math.pow(10, f));
|
|
1593
|
-
var xFinal = n / Math.pow(10, f);
|
|
1594
|
-
// n is a positive integer, but it is possible to be greater than 1e21.
|
|
1595
|
-
// In such case we will go the slow path.
|
|
1596
|
-
// See also: https://tc39.es/ecma262/#sec-numeric-types-number-tostring
|
|
1597
|
-
var m;
|
|
1598
|
-
if (n < 1e21) {
|
|
1599
|
-
m = n.toString();
|
|
1600
|
-
}
|
|
1601
|
-
else {
|
|
1602
|
-
m = n.toString();
|
|
1603
|
-
var _a = m.split('e'), mantissa = _a[0], exponent = _a[1];
|
|
1604
|
-
m = mantissa.replace('.', '');
|
|
1605
|
-
m = m + repeat('0', Math.max(+exponent - m.length + 1, 0));
|
|
1606
|
-
}
|
|
1607
|
-
var int;
|
|
1608
|
-
if (f !== 0) {
|
|
1609
|
-
var k = m.length;
|
|
1610
|
-
if (k <= f) {
|
|
1611
|
-
var z = repeat('0', f + 1 - k);
|
|
1612
|
-
m = z + m;
|
|
1613
|
-
k = f + 1;
|
|
1614
|
-
}
|
|
1615
|
-
var a = m.slice(0, k - f);
|
|
1616
|
-
var b = m.slice(k - f);
|
|
1617
|
-
m = a + "." + b;
|
|
1618
|
-
int = a.length;
|
|
1619
|
-
}
|
|
1620
|
-
else {
|
|
1621
|
-
int = m.length;
|
|
1622
|
-
}
|
|
1623
|
-
var cut = maxFraction - minFraction;
|
|
1624
|
-
while (cut > 0 && m[m.length - 1] === '0') {
|
|
1625
|
-
m = m.slice(0, -1);
|
|
1626
|
-
cut--;
|
|
1627
|
-
}
|
|
1628
|
-
if (m[m.length - 1] === '.') {
|
|
1629
|
-
m = m.slice(0, -1);
|
|
1630
|
-
}
|
|
1631
|
-
return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
|
|
1632
|
-
}
|
|
1633
|
-
exports.toRawFixed = toRawFixed;
|
|
1634
|
-
// https://tc39.es/ecma402/#sec-torawprecision
|
|
1635
|
-
function toRawPrecision(x, minPrecision, maxPrecision) {
|
|
1636
|
-
var p = maxPrecision;
|
|
1637
|
-
var m;
|
|
1638
|
-
var e;
|
|
1639
|
-
var xFinal;
|
|
1640
|
-
if (x === 0) {
|
|
1641
|
-
m = repeat('0', p);
|
|
1642
|
-
e = 0;
|
|
1643
|
-
xFinal = 0;
|
|
1644
|
-
}
|
|
1645
|
-
else {
|
|
1646
|
-
var xToString = x.toString();
|
|
1647
|
-
// If xToString is formatted as scientific notation, the number is either very small or very
|
|
1648
|
-
// large. If the precision of the formatted string is lower that requested max precision, we
|
|
1649
|
-
// should still infer them from the formatted string, otherwise the formatted result might have
|
|
1650
|
-
// precision loss (e.g. 1e41 will not have 0 in every trailing digits).
|
|
1651
|
-
var xToStringExponentIndex = xToString.indexOf('e');
|
|
1652
|
-
var _a = xToString.split('e'), xToStringMantissa = _a[0], xToStringExponent = _a[1];
|
|
1653
|
-
var xToStringMantissaWithoutDecimalPoint = xToStringMantissa.replace('.', '');
|
|
1654
|
-
if (xToStringExponentIndex >= 0 &&
|
|
1655
|
-
xToStringMantissaWithoutDecimalPoint.length <= p) {
|
|
1656
|
-
e = +xToStringExponent;
|
|
1657
|
-
m =
|
|
1658
|
-
xToStringMantissaWithoutDecimalPoint +
|
|
1659
|
-
repeat('0', p - xToStringMantissaWithoutDecimalPoint.length);
|
|
1660
|
-
xFinal = x;
|
|
1661
|
-
}
|
|
1662
|
-
else {
|
|
1663
|
-
e = getMagnitude(x);
|
|
1664
|
-
var decimalPlaceOffset = e - p + 1;
|
|
1665
|
-
// n is the integer containing the required precision digits. To derive the formatted string,
|
|
1666
|
-
// we will adjust its decimal place in the logic below.
|
|
1667
|
-
var n = Math.round(adjustDecimalPlace(x, decimalPlaceOffset));
|
|
1668
|
-
// The rounding caused the change of magnitude, so we should increment `e` by 1.
|
|
1669
|
-
if (adjustDecimalPlace(n, p - 1) >= 10) {
|
|
1670
|
-
e = e + 1;
|
|
1671
|
-
// Divide n by 10 to swallow one precision.
|
|
1672
|
-
n = Math.floor(n / 10);
|
|
1673
|
-
}
|
|
1674
|
-
m = n.toString();
|
|
1675
|
-
// Equivalent of n * 10 ** (e - p + 1)
|
|
1676
|
-
xFinal = adjustDecimalPlace(n, p - 1 - e);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
var int;
|
|
1680
|
-
if (e >= p - 1) {
|
|
1681
|
-
m = m + repeat('0', e - p + 1);
|
|
1682
|
-
int = e + 1;
|
|
1683
|
-
}
|
|
1684
|
-
else if (e >= 0) {
|
|
1685
|
-
m = m.slice(0, e + 1) + "." + m.slice(e + 1);
|
|
1686
|
-
int = e + 1;
|
|
1687
|
-
}
|
|
1688
|
-
else {
|
|
1689
|
-
m = "0." + repeat('0', -e - 1) + m;
|
|
1690
|
-
int = 1;
|
|
1691
|
-
}
|
|
1692
|
-
if (m.indexOf('.') >= 0 && maxPrecision > minPrecision) {
|
|
1693
|
-
var cut = maxPrecision - minPrecision;
|
|
1694
|
-
while (cut > 0 && m[m.length - 1] === '0') {
|
|
1695
|
-
m = m.slice(0, -1);
|
|
1696
|
-
cut--;
|
|
1697
|
-
}
|
|
1698
|
-
if (m[m.length - 1] === '.') {
|
|
1699
|
-
m = m.slice(0, -1);
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
|
|
1703
|
-
// x / (10 ** magnitude), but try to preserve as much floating point precision as possible.
|
|
1704
|
-
function adjustDecimalPlace(x, magnitude) {
|
|
1705
|
-
return magnitude < 0 ? x * Math.pow(10, -magnitude) : x / Math.pow(10, magnitude);
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
exports.toRawPrecision = toRawPrecision;
|
|
1709
|
-
function repeat(s, times) {
|
|
1710
|
-
if (typeof s.repeat === 'function') {
|
|
1711
|
-
return s.repeat(times);
|
|
1712
|
-
}
|
|
1713
|
-
var arr = new Array(times);
|
|
1714
|
-
for (var i = 0; i < arr.length; i++) {
|
|
1715
|
-
arr[i] = s;
|
|
1716
|
-
}
|
|
1717
|
-
return arr.join('');
|
|
1718
|
-
}
|
|
1719
|
-
exports.repeat = repeat;
|
|
1720
798
|
/**
|
|
1721
799
|
* Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
|
|
1722
800
|
* @param x number
|
|
1723
801
|
*/
|
|
1724
|
-
function
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1729
|
-
exports.getMagnitude = getMagnitude;
|
|
1730
|
-
/**
|
|
1731
|
-
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
1732
|
-
* @param str string to convert
|
|
1733
|
-
*/
|
|
1734
|
-
function toLowerCase(str) {
|
|
1735
|
-
return str.replace(/([A-Z])/g, function (_, c) { return c.toLowerCase(); });
|
|
1736
|
-
}
|
|
1737
|
-
var SHORTENED_SACTION_UNITS = units.SANCTIONED_UNITS.map(function (unit) {
|
|
1738
|
-
return unit.replace(/^(.*?)-/, '');
|
|
1739
|
-
});
|
|
1740
|
-
/**
|
|
1741
|
-
* https://tc39.es/ecma402/#sec-iswellformedunitidentifier
|
|
1742
|
-
* @param unit
|
|
1743
|
-
*/
|
|
1744
|
-
function isWellFormedUnitIdentifier(unit) {
|
|
1745
|
-
unit = toLowerCase(unit);
|
|
1746
|
-
if (SHORTENED_SACTION_UNITS.indexOf(unit) > -1) {
|
|
1747
|
-
return true;
|
|
1748
|
-
}
|
|
1749
|
-
var units = unit.split('-per-');
|
|
1750
|
-
if (units.length !== 2) {
|
|
1751
|
-
return false;
|
|
1752
|
-
}
|
|
1753
|
-
if (SHORTENED_SACTION_UNITS.indexOf(units[0]) < 0 ||
|
|
1754
|
-
SHORTENED_SACTION_UNITS.indexOf(units[1]) < 0) {
|
|
1755
|
-
return false;
|
|
1756
|
-
}
|
|
1757
|
-
return true;
|
|
1758
|
-
}
|
|
1759
|
-
exports.isWellFormedUnitIdentifier = isWellFormedUnitIdentifier;
|
|
1760
|
-
/*
|
|
1761
|
-
17 ECMAScript Standard Built-in Objects:
|
|
1762
|
-
Every built-in Function object, including constructors, that is not
|
|
1763
|
-
identified as an anonymous function has a name property whose value
|
|
1764
|
-
is a String.
|
|
1765
|
-
|
|
1766
|
-
Unless otherwise specified, the name property of a built-in Function
|
|
1767
|
-
object, if it exists, has the attributes { [[Writable]]: false,
|
|
1768
|
-
[[Enumerable]]: false, [[Configurable]]: true }.
|
|
1769
|
-
*/
|
|
1770
|
-
function defineProperty(target, name, _a) {
|
|
1771
|
-
var value = _a.value;
|
|
1772
|
-
Object.defineProperty(target, name, {
|
|
1773
|
-
configurable: true,
|
|
1774
|
-
enumerable: false,
|
|
1775
|
-
writable: true,
|
|
1776
|
-
value: value,
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1779
|
-
exports.defineProperty = defineProperty;
|
|
1780
|
-
});
|
|
1781
|
-
|
|
1782
|
-
var resolveLocale = createCommonjsModule(function (module, exports) {
|
|
1783
|
-
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
1784
|
-
var extendStatics = function (d, b) {
|
|
1785
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1786
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1787
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
1788
|
-
return extendStatics(d, b);
|
|
1789
|
-
};
|
|
1790
|
-
return function (d, b) {
|
|
1791
|
-
extendStatics(d, b);
|
|
1792
|
-
function __() { this.constructor = d; }
|
|
1793
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1794
|
-
};
|
|
1795
|
-
})();
|
|
1796
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
1797
|
-
__assign = Object.assign || function(t) {
|
|
1798
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1799
|
-
s = arguments[i];
|
|
1800
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1801
|
-
t[p] = s[p];
|
|
1802
|
-
}
|
|
1803
|
-
return t;
|
|
1804
|
-
};
|
|
1805
|
-
return __assign.apply(this, arguments);
|
|
1806
|
-
};
|
|
1807
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1808
|
-
exports.unpackData = exports.isMissingLocaleDataError = exports.supportedLocales = exports.getLocaleHierarchy = exports.createResolveLocale = void 0;
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
function createResolveLocale(getDefaultLocale) {
|
|
1812
|
-
var lookupMatcher = createLookupMatcher(getDefaultLocale);
|
|
1813
|
-
var bestFitMatcher = createBestFitMatcher(getDefaultLocale);
|
|
1814
|
-
/**
|
|
1815
|
-
* https://tc39.es/ecma402/#sec-resolvelocale
|
|
1816
|
-
*/
|
|
1817
|
-
return function resolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) {
|
|
1818
|
-
var matcher = options.localeMatcher;
|
|
1819
|
-
var r;
|
|
1820
|
-
if (matcher === 'lookup') {
|
|
1821
|
-
r = lookupMatcher(availableLocales, requestedLocales);
|
|
1822
|
-
}
|
|
1823
|
-
else {
|
|
1824
|
-
r = bestFitMatcher(availableLocales, requestedLocales);
|
|
1825
|
-
}
|
|
1826
|
-
var foundLocale = r.locale;
|
|
1827
|
-
var result = { locale: '', dataLocale: foundLocale };
|
|
1828
|
-
var supportedExtension = '-u';
|
|
1829
|
-
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
1830
|
-
var key = relevantExtensionKeys_1[_i];
|
|
1831
|
-
var foundLocaleData = localeData[foundLocale];
|
|
1832
|
-
invariant_1.invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
1833
|
-
var keyLocaleData = foundLocaleData[key];
|
|
1834
|
-
invariant_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
1835
|
-
var value = keyLocaleData[0];
|
|
1836
|
-
invariant_1.invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
1837
|
-
var supportedExtensionAddition = '';
|
|
1838
|
-
if (r.extension) {
|
|
1839
|
-
var requestedValue = unicodeExtensionValue(r.extension, key);
|
|
1840
|
-
if (requestedValue !== undefined) {
|
|
1841
|
-
if (requestedValue !== '') {
|
|
1842
|
-
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
1843
|
-
value = requestedValue;
|
|
1844
|
-
supportedExtensionAddition = "-" + key + "-" + value;
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
else if (~requestedValue.indexOf('true')) {
|
|
1848
|
-
value = 'true';
|
|
1849
|
-
supportedExtensionAddition = "-" + key;
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
if (key in options) {
|
|
1854
|
-
var optionsValue = options[key];
|
|
1855
|
-
invariant_1.invariant(typeof optionsValue === 'string' ||
|
|
1856
|
-
typeof optionsValue === 'undefined' ||
|
|
1857
|
-
optionsValue === null, 'optionsValue must be String, Undefined or Null');
|
|
1858
|
-
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
1859
|
-
if (optionsValue !== value) {
|
|
1860
|
-
value = optionsValue;
|
|
1861
|
-
supportedExtensionAddition = '';
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
result[key] = value;
|
|
1866
|
-
supportedExtension += supportedExtensionAddition;
|
|
1867
|
-
}
|
|
1868
|
-
if (supportedExtension.length > 2) {
|
|
1869
|
-
var privateIndex = foundLocale.indexOf('-x-');
|
|
1870
|
-
if (privateIndex === -1) {
|
|
1871
|
-
foundLocale = foundLocale + supportedExtension;
|
|
1872
|
-
}
|
|
1873
|
-
else {
|
|
1874
|
-
var preExtension = foundLocale.slice(0, privateIndex);
|
|
1875
|
-
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
1876
|
-
foundLocale = preExtension + supportedExtension + postExtension;
|
|
1877
|
-
}
|
|
1878
|
-
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
|
1879
|
-
}
|
|
1880
|
-
result.locale = foundLocale;
|
|
1881
|
-
return result;
|
|
1882
|
-
};
|
|
1883
|
-
}
|
|
1884
|
-
exports.createResolveLocale = createResolveLocale;
|
|
1885
|
-
/**
|
|
1886
|
-
* https://tc39.es/ecma402/#sec-unicodeextensionvalue
|
|
1887
|
-
* @param extension
|
|
1888
|
-
* @param key
|
|
1889
|
-
*/
|
|
1890
|
-
function unicodeExtensionValue(extension, key) {
|
|
1891
|
-
invariant_1.invariant(key.length === 2, 'key must have 2 elements');
|
|
1892
|
-
var size = extension.length;
|
|
1893
|
-
var searchValue = "-" + key + "-";
|
|
1894
|
-
var pos = extension.indexOf(searchValue);
|
|
1895
|
-
if (pos !== -1) {
|
|
1896
|
-
var start = pos + 4;
|
|
1897
|
-
var end = start;
|
|
1898
|
-
var k = start;
|
|
1899
|
-
var done = false;
|
|
1900
|
-
while (!done) {
|
|
1901
|
-
var e = extension.indexOf('-', k);
|
|
1902
|
-
var len = void 0;
|
|
1903
|
-
if (e === -1) {
|
|
1904
|
-
len = size - k;
|
|
1905
|
-
}
|
|
1906
|
-
else {
|
|
1907
|
-
len = e - k;
|
|
1908
|
-
}
|
|
1909
|
-
if (len === 2) {
|
|
1910
|
-
done = true;
|
|
1911
|
-
}
|
|
1912
|
-
else if (e === -1) {
|
|
1913
|
-
end = size;
|
|
1914
|
-
done = true;
|
|
1915
|
-
}
|
|
1916
|
-
else {
|
|
1917
|
-
end = e;
|
|
1918
|
-
k = e + 1;
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
return extension.slice(start, end);
|
|
1922
|
-
}
|
|
1923
|
-
searchValue = "-" + key;
|
|
1924
|
-
pos = extension.indexOf(searchValue);
|
|
1925
|
-
if (pos !== -1 && pos + 3 === size) {
|
|
1926
|
-
return '';
|
|
1927
|
-
}
|
|
1928
|
-
return undefined;
|
|
1929
|
-
}
|
|
1930
|
-
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
1931
|
-
/**
|
|
1932
|
-
* https://tc39.es/ecma402/#sec-bestavailablelocale
|
|
1933
|
-
* @param availableLocales
|
|
1934
|
-
* @param locale
|
|
1935
|
-
*/
|
|
1936
|
-
function bestAvailableLocale(availableLocales, locale) {
|
|
1937
|
-
var candidate = locale;
|
|
1938
|
-
while (true) {
|
|
1939
|
-
if (~availableLocales.indexOf(candidate)) {
|
|
1940
|
-
return candidate;
|
|
1941
|
-
}
|
|
1942
|
-
var pos = candidate.lastIndexOf('-');
|
|
1943
|
-
if (!~pos) {
|
|
1944
|
-
return undefined;
|
|
1945
|
-
}
|
|
1946
|
-
if (pos >= 2 && candidate[pos - 2] === '-') {
|
|
1947
|
-
pos -= 2;
|
|
1948
|
-
}
|
|
1949
|
-
candidate = candidate.slice(0, pos);
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
function createLookupMatcher(getDefaultLocale) {
|
|
1953
|
-
/**
|
|
1954
|
-
* https://tc39.es/ecma402/#sec-lookupmatcher
|
|
1955
|
-
*/
|
|
1956
|
-
return function lookupMatcher(availableLocales, requestedLocales) {
|
|
1957
|
-
var result = { locale: '' };
|
|
1958
|
-
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
1959
|
-
var locale = requestedLocales_1[_i];
|
|
1960
|
-
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
|
|
1961
|
-
var availableLocale = bestAvailableLocale(availableLocales, noExtensionLocale);
|
|
1962
|
-
if (availableLocale) {
|
|
1963
|
-
result.locale = availableLocale;
|
|
1964
|
-
if (locale !== noExtensionLocale) {
|
|
1965
|
-
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
|
|
1966
|
-
}
|
|
1967
|
-
return result;
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
result.locale = getDefaultLocale();
|
|
1971
|
-
return result;
|
|
1972
|
-
};
|
|
1973
|
-
}
|
|
1974
|
-
function createBestFitMatcher(getDefaultLocale) {
|
|
1975
|
-
return function bestFitMatcher(availableLocales, requestedLocales) {
|
|
1976
|
-
var result = { locale: '' };
|
|
1977
|
-
for (var _i = 0, requestedLocales_2 = requestedLocales; _i < requestedLocales_2.length; _i++) {
|
|
1978
|
-
var locale = requestedLocales_2[_i];
|
|
1979
|
-
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
|
|
1980
|
-
var availableLocale = bestAvailableLocale(availableLocales, noExtensionLocale);
|
|
1981
|
-
if (availableLocale) {
|
|
1982
|
-
result.locale = availableLocale;
|
|
1983
|
-
if (locale !== noExtensionLocale) {
|
|
1984
|
-
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
|
|
1985
|
-
}
|
|
1986
|
-
return result;
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
result.locale = getDefaultLocale();
|
|
1990
|
-
return result;
|
|
1991
|
-
};
|
|
1992
|
-
}
|
|
1993
|
-
function getLocaleHierarchy(locale) {
|
|
1994
|
-
var results = [locale];
|
|
1995
|
-
var localeParts = locale.split('-');
|
|
1996
|
-
for (var i = localeParts.length; i > 1; i--) {
|
|
1997
|
-
results.push(localeParts.slice(0, i - 1).join('-'));
|
|
1998
|
-
}
|
|
1999
|
-
return results;
|
|
2000
|
-
}
|
|
2001
|
-
exports.getLocaleHierarchy = getLocaleHierarchy;
|
|
2002
|
-
function lookupSupportedLocales(availableLocales, requestedLocales) {
|
|
2003
|
-
var subset = [];
|
|
2004
|
-
for (var _i = 0, requestedLocales_3 = requestedLocales; _i < requestedLocales_3.length; _i++) {
|
|
2005
|
-
var locale = requestedLocales_3[_i];
|
|
2006
|
-
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
|
|
2007
|
-
var availableLocale = bestAvailableLocale(availableLocales, noExtensionLocale);
|
|
2008
|
-
if (availableLocale) {
|
|
2009
|
-
subset.push(availableLocale);
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
return subset;
|
|
2013
|
-
}
|
|
2014
|
-
function supportedLocales(availableLocales, requestedLocales, options) {
|
|
2015
|
-
var matcher = 'best fit';
|
|
2016
|
-
if (options !== undefined) {
|
|
2017
|
-
options = polyfillUtils.toObject(options);
|
|
2018
|
-
matcher = polyfillUtils.getOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
2019
|
-
}
|
|
2020
|
-
if (matcher === 'best fit') {
|
|
2021
|
-
return lookupSupportedLocales(availableLocales, requestedLocales);
|
|
802
|
+
function invariant(condition, message, Err) {
|
|
803
|
+
if (Err === void 0) { Err = Error; }
|
|
804
|
+
if (!condition) {
|
|
805
|
+
throw new Err(message);
|
|
2022
806
|
}
|
|
2023
|
-
return lookupSupportedLocales(availableLocales, requestedLocales);
|
|
2024
807
|
}
|
|
2025
|
-
exports.supportedLocales = supportedLocales;
|
|
2026
|
-
var MissingLocaleDataError = /** @class */ (function (_super) {
|
|
2027
|
-
__extends(MissingLocaleDataError, _super);
|
|
2028
|
-
function MissingLocaleDataError() {
|
|
2029
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
2030
|
-
_this.type = 'MISSING_LOCALE_DATA';
|
|
2031
|
-
return _this;
|
|
2032
|
-
}
|
|
2033
|
-
return MissingLocaleDataError;
|
|
2034
|
-
}(Error));
|
|
2035
|
-
function isMissingLocaleDataError(e) {
|
|
2036
|
-
return e.type === 'MISSING_LOCALE_DATA';
|
|
2037
|
-
}
|
|
2038
|
-
exports.isMissingLocaleDataError = isMissingLocaleDataError;
|
|
2039
|
-
function unpackData(locale, localeData,
|
|
2040
|
-
/** By default shallow merge the dictionaries. */
|
|
2041
|
-
reducer) {
|
|
2042
|
-
if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; }
|
|
2043
|
-
var localeHierarchy = getLocaleHierarchy(locale);
|
|
2044
|
-
var dataToMerge = localeHierarchy
|
|
2045
|
-
.map(function (l) { return localeData.data[l]; })
|
|
2046
|
-
.filter(Boolean);
|
|
2047
|
-
if (!dataToMerge.length) {
|
|
2048
|
-
throw new MissingLocaleDataError("Missing locale data for \"" + locale + "\", lookup hierarchy: " + localeHierarchy.join(', '));
|
|
2049
|
-
}
|
|
2050
|
-
dataToMerge.reverse();
|
|
2051
|
-
return dataToMerge.reduce(reducer, {});
|
|
2052
|
-
}
|
|
2053
|
-
exports.unpackData = unpackData;
|
|
2054
|
-
});
|
|
2055
|
-
|
|
2056
|
-
var relativeTimeTypes = createCommonjsModule(function (module, exports) {
|
|
2057
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2058
|
-
});
|
|
2059
|
-
|
|
2060
|
-
var listTypes = createCommonjsModule(function (module, exports) {
|
|
2061
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2062
|
-
});
|
|
2063
808
|
|
|
2064
|
-
var
|
|
2065
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2066
|
-
});
|
|
2067
|
-
|
|
2068
|
-
var numberTypes = createCommonjsModule(function (module, exports) {
|
|
2069
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2070
|
-
});
|
|
2071
|
-
|
|
2072
|
-
var displaynamesTypes = createCommonjsModule(function (module, exports) {
|
|
2073
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2074
|
-
});
|
|
2075
|
-
|
|
2076
|
-
var intlUtils = createCommonjsModule(function (module, exports) {
|
|
2077
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2078
|
-
if (k2 === undefined) k2 = k;
|
|
2079
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
2080
|
-
}) : (function(o, m, k, k2) {
|
|
2081
|
-
if (k2 === undefined) k2 = k;
|
|
2082
|
-
o[k2] = m[k];
|
|
2083
|
-
}));
|
|
2084
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
2085
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
2086
|
-
};
|
|
2087
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2088
|
-
|
|
2089
|
-
Object.defineProperty(exports, "selectUnit", { enumerable: true, get: function () { return diff.selectUnit; } });
|
|
2090
|
-
|
|
2091
|
-
Object.defineProperty(exports, "defaultNumberOption", { enumerable: true, get: function () { return polyfillUtils.defaultNumberOption; } });
|
|
2092
|
-
Object.defineProperty(exports, "getInternalSlot", { enumerable: true, get: function () { return polyfillUtils.getInternalSlot; } });
|
|
2093
|
-
Object.defineProperty(exports, "getMultiInternalSlots", { enumerable: true, get: function () { return polyfillUtils.getMultiInternalSlots; } });
|
|
2094
|
-
Object.defineProperty(exports, "getNumberOption", { enumerable: true, get: function () { return polyfillUtils.getNumberOption; } });
|
|
2095
|
-
Object.defineProperty(exports, "getOption", { enumerable: true, get: function () { return polyfillUtils.getOption; } });
|
|
2096
|
-
Object.defineProperty(exports, "isLiteralPart", { enumerable: true, get: function () { return polyfillUtils.isLiteralPart; } });
|
|
2097
|
-
Object.defineProperty(exports, "partitionPattern", { enumerable: true, get: function () { return polyfillUtils.partitionPattern; } });
|
|
2098
|
-
Object.defineProperty(exports, "setInternalSlot", { enumerable: true, get: function () { return polyfillUtils.setInternalSlot; } });
|
|
2099
|
-
Object.defineProperty(exports, "setMultiInternalSlots", { enumerable: true, get: function () { return polyfillUtils.setMultiInternalSlots; } });
|
|
2100
|
-
Object.defineProperty(exports, "setNumberFormatDigitOptions", { enumerable: true, get: function () { return polyfillUtils.setNumberFormatDigitOptions; } });
|
|
2101
|
-
Object.defineProperty(exports, "toObject", { enumerable: true, get: function () { return polyfillUtils.toObject; } });
|
|
2102
|
-
Object.defineProperty(exports, "objectIs", { enumerable: true, get: function () { return polyfillUtils.objectIs; } });
|
|
2103
|
-
Object.defineProperty(exports, "isWellFormedCurrencyCode", { enumerable: true, get: function () { return polyfillUtils.isWellFormedCurrencyCode; } });
|
|
2104
|
-
Object.defineProperty(exports, "toString", { enumerable: true, get: function () { return polyfillUtils.toString; } });
|
|
2105
|
-
Object.defineProperty(exports, "formatNumericToString", { enumerable: true, get: function () { return polyfillUtils.formatNumericToString; } });
|
|
2106
|
-
Object.defineProperty(exports, "toRawFixed", { enumerable: true, get: function () { return polyfillUtils.toRawFixed; } });
|
|
2107
|
-
Object.defineProperty(exports, "toRawPrecision", { enumerable: true, get: function () { return polyfillUtils.toRawPrecision; } });
|
|
2108
|
-
Object.defineProperty(exports, "getMagnitude", { enumerable: true, get: function () { return polyfillUtils.getMagnitude; } });
|
|
2109
|
-
Object.defineProperty(exports, "repeat", { enumerable: true, get: function () { return polyfillUtils.repeat; } });
|
|
2110
|
-
Object.defineProperty(exports, "hasOwnProperty", { enumerable: true, get: function () { return polyfillUtils.hasOwnProperty; } });
|
|
2111
|
-
Object.defineProperty(exports, "isWellFormedUnitIdentifier", { enumerable: true, get: function () { return polyfillUtils.isWellFormedUnitIdentifier; } });
|
|
2112
|
-
Object.defineProperty(exports, "defineProperty", { enumerable: true, get: function () { return polyfillUtils.defineProperty; } });
|
|
2113
|
-
|
|
2114
|
-
Object.defineProperty(exports, "createResolveLocale", { enumerable: true, get: function () { return resolveLocale.createResolveLocale; } });
|
|
2115
|
-
Object.defineProperty(exports, "getLocaleHierarchy", { enumerable: true, get: function () { return resolveLocale.getLocaleHierarchy; } });
|
|
2116
|
-
Object.defineProperty(exports, "supportedLocales", { enumerable: true, get: function () { return resolveLocale.supportedLocales; } });
|
|
2117
|
-
Object.defineProperty(exports, "unpackData", { enumerable: true, get: function () { return resolveLocale.unpackData; } });
|
|
2118
|
-
Object.defineProperty(exports, "isMissingLocaleDataError", { enumerable: true, get: function () { return resolveLocale.isMissingLocaleDataError; } });
|
|
2119
|
-
__exportStar(units, exports);
|
|
2120
|
-
__exportStar(relativeTimeTypes, exports);
|
|
2121
|
-
__exportStar(listTypes, exports);
|
|
2122
|
-
__exportStar(pluralRulesTypes, exports);
|
|
2123
|
-
__exportStar(numberTypes, exports);
|
|
2124
|
-
__exportStar(displaynamesTypes, exports);
|
|
2125
|
-
|
|
2126
|
-
Object.defineProperty(exports, "invariant", { enumerable: true, get: function () { return invariant_1.invariant; } });
|
|
2127
|
-
});
|
|
2128
|
-
|
|
2129
|
-
var __extends = (undefined && undefined.__extends) || (function () {
|
|
809
|
+
var __extends$1 = (undefined && undefined.__extends) || (function () {
|
|
2130
810
|
var extendStatics = function (d, b) {
|
|
2131
811
|
extendStatics = Object.setPrototypeOf ||
|
|
2132
812
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -2147,7 +827,7 @@
|
|
|
2147
827
|
ReactIntlErrorCode["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
|
|
2148
828
|
})(exports.ReactIntlErrorCode || (exports.ReactIntlErrorCode = {}));
|
|
2149
829
|
var ReactIntlError = /** @class */ (function (_super) {
|
|
2150
|
-
__extends(ReactIntlError, _super);
|
|
830
|
+
__extends$1(ReactIntlError, _super);
|
|
2151
831
|
function ReactIntlError(code, message, exception) {
|
|
2152
832
|
var _this = _super.call(this, "[React Intl Error " + code + "] " + message + " \n" + (exception ? "\n" + exception.message + "\n" + exception.stack : '')) || this;
|
|
2153
833
|
_this.code = code;
|
|
@@ -2159,28 +839,28 @@
|
|
|
2159
839
|
return ReactIntlError;
|
|
2160
840
|
}(Error));
|
|
2161
841
|
var UnsupportedFormatterError = /** @class */ (function (_super) {
|
|
2162
|
-
__extends(UnsupportedFormatterError, _super);
|
|
842
|
+
__extends$1(UnsupportedFormatterError, _super);
|
|
2163
843
|
function UnsupportedFormatterError(message, exception) {
|
|
2164
844
|
return _super.call(this, "UNSUPPORTED_FORMATTER" /* UNSUPPORTED_FORMATTER */, message, exception) || this;
|
|
2165
845
|
}
|
|
2166
846
|
return UnsupportedFormatterError;
|
|
2167
847
|
}(ReactIntlError));
|
|
2168
848
|
var InvalidConfigError = /** @class */ (function (_super) {
|
|
2169
|
-
__extends(InvalidConfigError, _super);
|
|
849
|
+
__extends$1(InvalidConfigError, _super);
|
|
2170
850
|
function InvalidConfigError(message, exception) {
|
|
2171
851
|
return _super.call(this, "INVALID_CONFIG" /* INVALID_CONFIG */, message, exception) || this;
|
|
2172
852
|
}
|
|
2173
853
|
return InvalidConfigError;
|
|
2174
854
|
}(ReactIntlError));
|
|
2175
855
|
var MissingDataError = /** @class */ (function (_super) {
|
|
2176
|
-
__extends(MissingDataError, _super);
|
|
856
|
+
__extends$1(MissingDataError, _super);
|
|
2177
857
|
function MissingDataError(message, exception) {
|
|
2178
858
|
return _super.call(this, "MISSING_DATA" /* MISSING_DATA */, message, exception) || this;
|
|
2179
859
|
}
|
|
2180
860
|
return MissingDataError;
|
|
2181
861
|
}(ReactIntlError));
|
|
2182
862
|
var MessageFormatError = /** @class */ (function (_super) {
|
|
2183
|
-
__extends(MessageFormatError, _super);
|
|
863
|
+
__extends$1(MessageFormatError, _super);
|
|
2184
864
|
function MessageFormatError(message, locale, descriptor, exception) {
|
|
2185
865
|
var _this = _super.call(this, "FORMAT_ERROR" /* FORMAT_ERROR */, message + " \nLocale: " + locale + "\nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", exception) || this;
|
|
2186
866
|
_this.descriptor = descriptor;
|
|
@@ -2189,7 +869,7 @@
|
|
|
2189
869
|
return MessageFormatError;
|
|
2190
870
|
}(ReactIntlError));
|
|
2191
871
|
var MissingTranslationError = /** @class */ (function (_super) {
|
|
2192
|
-
__extends(MissingTranslationError, _super);
|
|
872
|
+
__extends$1(MissingTranslationError, _super);
|
|
2193
873
|
function MissingTranslationError(descriptor, locale) {
|
|
2194
874
|
var _this = _super.call(this, "MISSING_TRANSLATION" /* MISSING_TRANSLATION */, "Missing message: \"" + descriptor.id + "\" for locale \"" + locale + "\", using " + (descriptor.defaultMessage ? 'default message' : 'id') + " as fallback.") || this;
|
|
2195
875
|
_this.descriptor = descriptor;
|
|
@@ -2208,8 +888,8 @@
|
|
|
2208
888
|
This source code is licensed under the BSD-style license found in the LICENSE
|
|
2209
889
|
file in the root directory of React's source tree.
|
|
2210
890
|
*/
|
|
2211
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
2212
|
-
__assign = Object.assign || function(t) {
|
|
891
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
892
|
+
__assign$1 = Object.assign || function(t) {
|
|
2213
893
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2214
894
|
s = arguments[i];
|
|
2215
895
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -2217,9 +897,9 @@
|
|
|
2217
897
|
}
|
|
2218
898
|
return t;
|
|
2219
899
|
};
|
|
2220
|
-
return __assign.apply(this, arguments);
|
|
900
|
+
return __assign$1.apply(this, arguments);
|
|
2221
901
|
};
|
|
2222
|
-
var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
|
|
902
|
+
var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
|
|
2223
903
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2224
904
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2225
905
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
@@ -2239,7 +919,7 @@
|
|
|
2239
919
|
}, {});
|
|
2240
920
|
}
|
|
2241
921
|
function invariantIntlContext(intl) {
|
|
2242
|
-
|
|
922
|
+
invariant(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
2243
923
|
'<IntlProvider> needs to exist in the component ancestry.');
|
|
2244
924
|
}
|
|
2245
925
|
var defaultErrorHandler = function (error) {
|
|
@@ -2264,7 +944,7 @@
|
|
|
2264
944
|
displayNames: {},
|
|
2265
945
|
};
|
|
2266
946
|
}
|
|
2267
|
-
function createFastMemoizeCache(store) {
|
|
947
|
+
function createFastMemoizeCache$1(store) {
|
|
2268
948
|
return {
|
|
2269
949
|
create: function () {
|
|
2270
950
|
return {
|
|
@@ -2282,8 +962,8 @@
|
|
|
2282
962
|
};
|
|
2283
963
|
}
|
|
2284
964
|
// @ts-ignore this is to deal with rollup's default import shenanigans
|
|
2285
|
-
var _memoizeIntl = src || memoize$1;
|
|
2286
|
-
var memoizeIntl = _memoizeIntl;
|
|
965
|
+
var _memoizeIntl$1 = src || memoize$1;
|
|
966
|
+
var memoizeIntl$1 = _memoizeIntl$1;
|
|
2287
967
|
/**
|
|
2288
968
|
* Create intl formatters and populate cache
|
|
2289
969
|
* @param cache explicit cache to prevent leaking memory
|
|
@@ -2293,82 +973,82 @@
|
|
|
2293
973
|
var RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
2294
974
|
var ListFormat = Intl.ListFormat;
|
|
2295
975
|
var DisplayNames = Intl.DisplayNames;
|
|
2296
|
-
var getDateTimeFormat = memoizeIntl(function () {
|
|
976
|
+
var getDateTimeFormat = memoizeIntl$1(function () {
|
|
2297
977
|
var _a;
|
|
2298
978
|
var args = [];
|
|
2299
979
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2300
980
|
args[_i] = arguments[_i];
|
|
2301
981
|
}
|
|
2302
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArrays([void 0], args)))();
|
|
982
|
+
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArrays$1([void 0], args)))();
|
|
2303
983
|
}, {
|
|
2304
|
-
cache: createFastMemoizeCache(cache.dateTime),
|
|
2305
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
984
|
+
cache: createFastMemoizeCache$1(cache.dateTime),
|
|
985
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2306
986
|
});
|
|
2307
|
-
var getNumberFormat = memoizeIntl(function () {
|
|
987
|
+
var getNumberFormat = memoizeIntl$1(function () {
|
|
2308
988
|
var _a;
|
|
2309
989
|
var args = [];
|
|
2310
990
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2311
991
|
args[_i] = arguments[_i];
|
|
2312
992
|
}
|
|
2313
|
-
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArrays([void 0], args)))();
|
|
993
|
+
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArrays$1([void 0], args)))();
|
|
2314
994
|
}, {
|
|
2315
|
-
cache: createFastMemoizeCache(cache.number),
|
|
2316
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
995
|
+
cache: createFastMemoizeCache$1(cache.number),
|
|
996
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2317
997
|
});
|
|
2318
|
-
var getPluralRules = memoizeIntl(function () {
|
|
998
|
+
var getPluralRules = memoizeIntl$1(function () {
|
|
2319
999
|
var _a;
|
|
2320
1000
|
var args = [];
|
|
2321
1001
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2322
1002
|
args[_i] = arguments[_i];
|
|
2323
1003
|
}
|
|
2324
|
-
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArrays([void 0], args)))();
|
|
1004
|
+
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArrays$1([void 0], args)))();
|
|
2325
1005
|
}, {
|
|
2326
|
-
cache: createFastMemoizeCache(cache.pluralRules),
|
|
2327
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
1006
|
+
cache: createFastMemoizeCache$1(cache.pluralRules),
|
|
1007
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2328
1008
|
});
|
|
2329
1009
|
return {
|
|
2330
1010
|
getDateTimeFormat: getDateTimeFormat,
|
|
2331
1011
|
getNumberFormat: getNumberFormat,
|
|
2332
|
-
getMessageFormat: memoizeIntl(function (message, locales, overrideFormats, opts) {
|
|
2333
|
-
return new
|
|
1012
|
+
getMessageFormat: memoizeIntl$1(function (message, locales, overrideFormats, opts) {
|
|
1013
|
+
return new IntlMessageFormat(message, locales, overrideFormats, __assign$1({ formatters: {
|
|
2334
1014
|
getNumberFormat: getNumberFormat,
|
|
2335
1015
|
getDateTimeFormat: getDateTimeFormat,
|
|
2336
1016
|
getPluralRules: getPluralRules,
|
|
2337
1017
|
} }, (opts || {})));
|
|
2338
1018
|
}, {
|
|
2339
|
-
cache: createFastMemoizeCache(cache.message),
|
|
2340
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
1019
|
+
cache: createFastMemoizeCache$1(cache.message),
|
|
1020
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2341
1021
|
}),
|
|
2342
|
-
getRelativeTimeFormat: memoizeIntl(function () {
|
|
1022
|
+
getRelativeTimeFormat: memoizeIntl$1(function () {
|
|
2343
1023
|
var args = [];
|
|
2344
1024
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2345
1025
|
args[_i] = arguments[_i];
|
|
2346
1026
|
}
|
|
2347
|
-
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArrays([void 0], args)))();
|
|
1027
|
+
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArrays$1([void 0], args)))();
|
|
2348
1028
|
}, {
|
|
2349
|
-
cache: createFastMemoizeCache(cache.relativeTime),
|
|
2350
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
1029
|
+
cache: createFastMemoizeCache$1(cache.relativeTime),
|
|
1030
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2351
1031
|
}),
|
|
2352
1032
|
getPluralRules: getPluralRules,
|
|
2353
|
-
getListFormat: memoizeIntl(function () {
|
|
1033
|
+
getListFormat: memoizeIntl$1(function () {
|
|
2354
1034
|
var args = [];
|
|
2355
1035
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2356
1036
|
args[_i] = arguments[_i];
|
|
2357
1037
|
}
|
|
2358
|
-
return new (ListFormat.bind.apply(ListFormat, __spreadArrays([void 0], args)))();
|
|
1038
|
+
return new (ListFormat.bind.apply(ListFormat, __spreadArrays$1([void 0], args)))();
|
|
2359
1039
|
}, {
|
|
2360
|
-
cache: createFastMemoizeCache(cache.list),
|
|
2361
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
1040
|
+
cache: createFastMemoizeCache$1(cache.list),
|
|
1041
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2362
1042
|
}),
|
|
2363
|
-
getDisplayNames: memoizeIntl(function () {
|
|
1043
|
+
getDisplayNames: memoizeIntl$1(function () {
|
|
2364
1044
|
var args = [];
|
|
2365
1045
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2366
1046
|
args[_i] = arguments[_i];
|
|
2367
1047
|
}
|
|
2368
|
-
return new (DisplayNames.bind.apply(DisplayNames, __spreadArrays([void 0], args)))();
|
|
1048
|
+
return new (DisplayNames.bind.apply(DisplayNames, __spreadArrays$1([void 0], args)))();
|
|
2369
1049
|
}, {
|
|
2370
|
-
cache: createFastMemoizeCache(cache.displayNames),
|
|
2371
|
-
strategy: memoizeIntl.strategies.variadic,
|
|
1050
|
+
cache: createFastMemoizeCache$1(cache.displayNames),
|
|
1051
|
+
strategy: memoizeIntl$1.strategies.variadic,
|
|
2372
1052
|
}),
|
|
2373
1053
|
};
|
|
2374
1054
|
}
|
|
@@ -2549,12 +1229,8 @@
|
|
|
2549
1229
|
|
|
2550
1230
|
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
2551
1231
|
|
|
2552
|
-
var
|
|
2553
|
-
|
|
2554
|
-
}));
|
|
2555
|
-
|
|
2556
|
-
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
2557
|
-
__assign$1 = Object.assign || function(t) {
|
|
1232
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
1233
|
+
__assign$2 = Object.assign || function(t) {
|
|
2558
1234
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2559
1235
|
s = arguments[i];
|
|
2560
1236
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -2562,13 +1238,13 @@
|
|
|
2562
1238
|
}
|
|
2563
1239
|
return t;
|
|
2564
1240
|
};
|
|
2565
|
-
return __assign$
|
|
1241
|
+
return __assign$2.apply(this, arguments);
|
|
2566
1242
|
};
|
|
2567
1243
|
// Since rollup cannot deal with namespace being a function,
|
|
2568
1244
|
// this is to interop with TypeScript since `invariant`
|
|
2569
1245
|
// does not export a default
|
|
2570
1246
|
// https://github.com/rollup/rollup/issues/1267
|
|
2571
|
-
var hoistNonReactStatics$1 = hoistNonReactStatics_cjs ||
|
|
1247
|
+
var hoistNonReactStatics$1 = hoistNonReactStatics_cjs.default || hoistNonReactStatics_cjs;
|
|
2572
1248
|
function getDisplayName(Component) {
|
|
2573
1249
|
return Component.displayName || Component.name || 'Component';
|
|
2574
1250
|
}
|
|
@@ -2585,12 +1261,12 @@
|
|
|
2585
1261
|
invariantIntlContext(intl);
|
|
2586
1262
|
}
|
|
2587
1263
|
var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
|
|
2588
|
-
return (React.createElement(WrappedComponent, __assign$
|
|
1264
|
+
return (React.createElement(WrappedComponent, __assign$2({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
|
|
2589
1265
|
})); };
|
|
2590
1266
|
WithIntl.displayName = "injectIntl(" + getDisplayName(WrappedComponent) + ")";
|
|
2591
1267
|
WithIntl.WrappedComponent = WrappedComponent;
|
|
2592
1268
|
if (forwardRef) {
|
|
2593
|
-
return hoistNonReactStatics$1(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign$
|
|
1269
|
+
return hoistNonReactStatics$1(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign$2({}, props, { forwardedRef: ref }))); }), WrappedComponent);
|
|
2594
1270
|
}
|
|
2595
1271
|
return hoistNonReactStatics$1(WithIntl, WrappedComponent);
|
|
2596
1272
|
}
|
|
@@ -2733,7 +1409,7 @@
|
|
|
2733
1409
|
}
|
|
2734
1410
|
var RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
2735
1411
|
if (!RelativeTimeFormat) {
|
|
2736
|
-
config.onError(new
|
|
1412
|
+
config.onError(new FormatError("Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-relativetimeformat\"\n", "MISSING_INTL_API" /* MISSING_INTL_API */));
|
|
2737
1413
|
}
|
|
2738
1414
|
try {
|
|
2739
1415
|
return getFormatter$1(config, getRelativeTimeFormat, options).format(value, unit);
|
|
@@ -2749,8 +1425,8 @@
|
|
|
2749
1425
|
* Copyrights licensed under the New BSD License.
|
|
2750
1426
|
* See the accompanying LICENSE file for terms.
|
|
2751
1427
|
*/
|
|
2752
|
-
var __assign$
|
|
2753
|
-
__assign$
|
|
1428
|
+
var __assign$3 = (undefined && undefined.__assign) || function () {
|
|
1429
|
+
__assign$3 = Object.assign || function(t) {
|
|
2754
1430
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2755
1431
|
s = arguments[i];
|
|
2756
1432
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -2758,7 +1434,7 @@
|
|
|
2758
1434
|
}
|
|
2759
1435
|
return t;
|
|
2760
1436
|
};
|
|
2761
|
-
return __assign$
|
|
1437
|
+
return __assign$3.apply(this, arguments);
|
|
2762
1438
|
};
|
|
2763
1439
|
var DATE_TIME_FORMAT_OPTIONS = [
|
|
2764
1440
|
'localeMatcher',
|
|
@@ -2786,14 +1462,14 @@
|
|
|
2786
1462
|
var locale = _a.locale, formats = _a.formats, onError = _a.onError, timeZone = _a.timeZone;
|
|
2787
1463
|
if (options === void 0) { options = {}; }
|
|
2788
1464
|
var format = options.format;
|
|
2789
|
-
var defaults = __assign$
|
|
1465
|
+
var defaults = __assign$3(__assign$3({}, (timeZone && { timeZone: timeZone })), (format && getNamedFormat(formats, type, format, onError)));
|
|
2790
1466
|
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults);
|
|
2791
1467
|
if (type === 'time' &&
|
|
2792
1468
|
!filteredOptions.hour &&
|
|
2793
1469
|
!filteredOptions.minute &&
|
|
2794
1470
|
!filteredOptions.second) {
|
|
2795
1471
|
// Add default formatting options if hour, minute, or second isn't defined.
|
|
2796
|
-
filteredOptions = __assign$
|
|
1472
|
+
filteredOptions = __assign$3(__assign$3({}, filteredOptions), { hour: 'numeric', minute: 'numeric' });
|
|
2797
1473
|
}
|
|
2798
1474
|
return getDateTimeFormat(locale, filteredOptions);
|
|
2799
1475
|
}
|
|
@@ -2850,7 +1526,7 @@
|
|
|
2850
1526
|
var locale = _a.locale, onError = _a.onError;
|
|
2851
1527
|
if (options === void 0) { options = {}; }
|
|
2852
1528
|
if (!Intl.PluralRules) {
|
|
2853
|
-
onError(new
|
|
1529
|
+
onError(new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", "MISSING_INTL_API" /* MISSING_INTL_API */));
|
|
2854
1530
|
}
|
|
2855
1531
|
var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
2856
1532
|
try {
|
|
@@ -2867,8 +1543,8 @@
|
|
|
2867
1543
|
* Copyrights licensed under the New BSD License.
|
|
2868
1544
|
* See the accompanying LICENSE file for terms.
|
|
2869
1545
|
*/
|
|
2870
|
-
var __assign$
|
|
2871
|
-
__assign$
|
|
1546
|
+
var __assign$4 = (undefined && undefined.__assign) || function () {
|
|
1547
|
+
__assign$4 = Object.assign || function(t) {
|
|
2872
1548
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2873
1549
|
s = arguments[i];
|
|
2874
1550
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -2876,9 +1552,9 @@
|
|
|
2876
1552
|
}
|
|
2877
1553
|
return t;
|
|
2878
1554
|
};
|
|
2879
|
-
return __assign$
|
|
1555
|
+
return __assign$4.apply(this, arguments);
|
|
2880
1556
|
};
|
|
2881
|
-
var __spreadArrays$
|
|
1557
|
+
var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
|
|
2882
1558
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2883
1559
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2884
1560
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
@@ -2887,14 +1563,14 @@
|
|
|
2887
1563
|
};
|
|
2888
1564
|
function setTimeZoneInOptions(opts, timeZone) {
|
|
2889
1565
|
return Object.keys(opts).reduce(function (all, k) {
|
|
2890
|
-
all[k] = __assign$
|
|
1566
|
+
all[k] = __assign$4({ timeZone: timeZone }, opts[k]);
|
|
2891
1567
|
return all;
|
|
2892
1568
|
}, {});
|
|
2893
1569
|
}
|
|
2894
1570
|
function deepMergeOptions(opts1, opts2) {
|
|
2895
|
-
var keys = Object.keys(__assign$
|
|
1571
|
+
var keys = Object.keys(__assign$4(__assign$4({}, opts1), opts2));
|
|
2896
1572
|
return keys.reduce(function (all, k) {
|
|
2897
|
-
all[k] = __assign$
|
|
1573
|
+
all[k] = __assign$4(__assign$4({}, (opts1[k] || {})), (opts2[k] || {}));
|
|
2898
1574
|
return all;
|
|
2899
1575
|
}, {});
|
|
2900
1576
|
}
|
|
@@ -2902,13 +1578,13 @@
|
|
|
2902
1578
|
if (!timeZone) {
|
|
2903
1579
|
return f1;
|
|
2904
1580
|
}
|
|
2905
|
-
var mfFormats =
|
|
2906
|
-
return __assign$
|
|
1581
|
+
var mfFormats = IntlMessageFormat.formats;
|
|
1582
|
+
return __assign$4(__assign$4(__assign$4({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
|
|
2907
1583
|
}
|
|
2908
1584
|
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
2909
1585
|
return Object.keys(values).reduce(function (acc, k) {
|
|
2910
1586
|
var v = values[k];
|
|
2911
|
-
acc[k] =
|
|
1587
|
+
acc[k] = isFormatXMLElementFn(v)
|
|
2912
1588
|
? assignUniqueKeysToParts(v)
|
|
2913
1589
|
: v;
|
|
2914
1590
|
return acc;
|
|
@@ -2916,14 +1592,14 @@
|
|
|
2916
1592
|
}
|
|
2917
1593
|
function prepareIntlMessageFormatHtmlOutput(chunks, shouldWrap) {
|
|
2918
1594
|
return Array.isArray(chunks) && shouldWrap
|
|
2919
|
-
? React.createElement.apply(React__namespace, __spreadArrays$
|
|
1595
|
+
? React.createElement.apply(React__namespace, __spreadArrays$2([React.Fragment, null], chunks)) : chunks;
|
|
2920
1596
|
}
|
|
2921
1597
|
function formatMessage(_a, state, messageDescriptor, values) {
|
|
2922
1598
|
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, wrapRichTextChunksInFragment = _a.wrapRichTextChunksInFragment, defaultRichTextElements = _a.defaultRichTextElements;
|
|
2923
1599
|
if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }
|
|
2924
1600
|
var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
|
|
2925
1601
|
// `id` is a required field of a Message Descriptor.
|
|
2926
|
-
|
|
1602
|
+
invariant(!!msgId, '[React Intl] An `id` must be provided to format a message.');
|
|
2927
1603
|
var id = String(msgId);
|
|
2928
1604
|
var message =
|
|
2929
1605
|
// In case messages is Object.create(null)
|
|
@@ -2951,7 +1627,7 @@
|
|
|
2951
1627
|
!defaultRichTextElements) {
|
|
2952
1628
|
return message.replace(/'\{(.*?)\}'/gi, "{$1}");
|
|
2953
1629
|
}
|
|
2954
|
-
var patchedValues = assignUniqueKeysToFormatXMLElementFnArgument(__assign$
|
|
1630
|
+
var patchedValues = assignUniqueKeysToFormatXMLElementFnArgument(__assign$4(__assign$4({}, defaultRichTextElements), (values || {})));
|
|
2955
1631
|
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
|
2956
1632
|
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
|
2957
1633
|
if (!message) {
|
|
@@ -3044,7 +1720,7 @@
|
|
|
3044
1720
|
if (options === void 0) { options = {}; }
|
|
3045
1721
|
var ListFormat = Intl.ListFormat;
|
|
3046
1722
|
if (!ListFormat) {
|
|
3047
|
-
onError(new
|
|
1723
|
+
onError(new FormatError("Intl.ListFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-listformat\"\n", "MISSING_INTL_API" /* MISSING_INTL_API */));
|
|
3048
1724
|
}
|
|
3049
1725
|
var filteredOptions = filterProps(options, LIST_FORMAT_OPTIONS);
|
|
3050
1726
|
try {
|
|
@@ -3092,7 +1768,7 @@
|
|
|
3092
1768
|
if (options === void 0) { options = {}; }
|
|
3093
1769
|
var DisplayNames = Intl.DisplayNames;
|
|
3094
1770
|
if (!DisplayNames) {
|
|
3095
|
-
onError(new
|
|
1771
|
+
onError(new FormatError("Intl.DisplayNames is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-displaynames\"\n", "MISSING_INTL_API" /* MISSING_INTL_API */));
|
|
3096
1772
|
}
|
|
3097
1773
|
var filteredOptions = filterProps(options, DISPLAY_NAMES_OPTONS);
|
|
3098
1774
|
try {
|
|
@@ -3108,7 +1784,7 @@
|
|
|
3108
1784
|
* Copyrights licensed under the New BSD License.
|
|
3109
1785
|
* See the accompanying LICENSE file for terms.
|
|
3110
1786
|
*/
|
|
3111
|
-
var __extends$
|
|
1787
|
+
var __extends$2 = (undefined && undefined.__extends) || (function () {
|
|
3112
1788
|
var extendStatics = function (d, b) {
|
|
3113
1789
|
extendStatics = Object.setPrototypeOf ||
|
|
3114
1790
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -3121,8 +1797,8 @@
|
|
|
3121
1797
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3122
1798
|
};
|
|
3123
1799
|
})();
|
|
3124
|
-
var __assign$
|
|
3125
|
-
__assign$
|
|
1800
|
+
var __assign$5 = (undefined && undefined.__assign) || function () {
|
|
1801
|
+
__assign$5 = Object.assign || function(t) {
|
|
3126
1802
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3127
1803
|
s = arguments[i];
|
|
3128
1804
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -3130,7 +1806,7 @@
|
|
|
3130
1806
|
}
|
|
3131
1807
|
return t;
|
|
3132
1808
|
};
|
|
3133
|
-
return __assign$
|
|
1809
|
+
return __assign$5.apply(this, arguments);
|
|
3134
1810
|
};
|
|
3135
1811
|
var shallowEquals = objects || shallowEquals_;
|
|
3136
1812
|
function processIntlConfig(config) {
|
|
@@ -3154,7 +1830,7 @@
|
|
|
3154
1830
|
*/
|
|
3155
1831
|
function createIntl(config, cache) {
|
|
3156
1832
|
var formatters = createFormatters(cache);
|
|
3157
|
-
var resolvedConfig = __assign$
|
|
1833
|
+
var resolvedConfig = __assign$5(__assign$5({}, DEFAULT_INTL_CONFIG), config);
|
|
3158
1834
|
var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
|
|
3159
1835
|
if (!locale) {
|
|
3160
1836
|
if (onError) {
|
|
@@ -3174,10 +1850,10 @@
|
|
|
3174
1850
|
onError) {
|
|
3175
1851
|
onError(new MissingDataError("Missing locale data for locale: \"" + locale + "\" in Intl.DateTimeFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details"));
|
|
3176
1852
|
}
|
|
3177
|
-
return __assign$
|
|
1853
|
+
return __assign$5(__assign$5({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
|
|
3178
1854
|
}
|
|
3179
1855
|
var IntlProvider$1 = /** @class */ (function (_super) {
|
|
3180
|
-
__extends$
|
|
1856
|
+
__extends$2(IntlProvider, _super);
|
|
3181
1857
|
function IntlProvider() {
|
|
3182
1858
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
3183
1859
|
_this.cache = createIntlCache();
|
|
@@ -3208,7 +1884,7 @@
|
|
|
3208
1884
|
return IntlProvider;
|
|
3209
1885
|
}(React.PureComponent));
|
|
3210
1886
|
|
|
3211
|
-
var __extends$
|
|
1887
|
+
var __extends$3 = (undefined && undefined.__extends) || (function () {
|
|
3212
1888
|
var extendStatics = function (d, b) {
|
|
3213
1889
|
extendStatics = Object.setPrototypeOf ||
|
|
3214
1890
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -3221,8 +1897,8 @@
|
|
|
3221
1897
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3222
1898
|
};
|
|
3223
1899
|
})();
|
|
3224
|
-
var __assign$
|
|
3225
|
-
__assign$
|
|
1900
|
+
var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
1901
|
+
__assign$6 = Object.assign || function(t) {
|
|
3226
1902
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3227
1903
|
s = arguments[i];
|
|
3228
1904
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -3230,7 +1906,7 @@
|
|
|
3230
1906
|
}
|
|
3231
1907
|
return t;
|
|
3232
1908
|
};
|
|
3233
|
-
return __assign$
|
|
1909
|
+
return __assign$6.apply(this, arguments);
|
|
3234
1910
|
};
|
|
3235
1911
|
var MINUTE = 60;
|
|
3236
1912
|
var HOUR = 60 * 60;
|
|
@@ -3279,7 +1955,7 @@
|
|
|
3279
1955
|
return INCREMENTABLE_UNITS.includes(unit);
|
|
3280
1956
|
}
|
|
3281
1957
|
var FormattedRelativeTime = /** @class */ (function (_super) {
|
|
3282
|
-
__extends$
|
|
1958
|
+
__extends$3(FormattedRelativeTime, _super);
|
|
3283
1959
|
function FormattedRelativeTime(props) {
|
|
3284
1960
|
var _this = _super.call(this, props) || this;
|
|
3285
1961
|
// Public for testing
|
|
@@ -3291,7 +1967,7 @@
|
|
|
3291
1967
|
? valueToSeconds(_this.props.value, _this.props.unit)
|
|
3292
1968
|
: 0,
|
|
3293
1969
|
};
|
|
3294
|
-
|
|
1970
|
+
invariant(!props.updateIntervalInSeconds ||
|
|
3295
1971
|
!!(props.updateIntervalInSeconds && canIncrement(props.unit)), 'Cannot schedule update with unit longer than hour');
|
|
3296
1972
|
return _this;
|
|
3297
1973
|
}
|
|
@@ -3363,7 +2039,7 @@
|
|
|
3363
2039
|
var unitDuration = getDurationInSeconds(currentUnit);
|
|
3364
2040
|
currentValue = Math.round(currentValueInSeconds / unitDuration);
|
|
3365
2041
|
}
|
|
3366
|
-
var formattedRelativeTime = formatRelativeTime(currentValue, currentUnit, __assign$
|
|
2042
|
+
var formattedRelativeTime = formatRelativeTime(currentValue, currentUnit, __assign$6({}, _this.props));
|
|
3367
2043
|
if (typeof children === 'function') {
|
|
3368
2044
|
return children(formattedRelativeTime);
|
|
3369
2045
|
}
|
|
@@ -3412,7 +2088,7 @@
|
|
|
3412
2088
|
* Copyrights licensed under the New BSD License.
|
|
3413
2089
|
* See the accompanying LICENSE file for terms.
|
|
3414
2090
|
*/
|
|
3415
|
-
var __extends$
|
|
2091
|
+
var __extends$4 = (undefined && undefined.__extends) || (function () {
|
|
3416
2092
|
var extendStatics = function (d, b) {
|
|
3417
2093
|
extendStatics = Object.setPrototypeOf ||
|
|
3418
2094
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -3436,7 +2112,7 @@
|
|
|
3436
2112
|
}
|
|
3437
2113
|
return t;
|
|
3438
2114
|
};
|
|
3439
|
-
var __spreadArrays$
|
|
2115
|
+
var __spreadArrays$3 = (undefined && undefined.__spreadArrays) || function () {
|
|
3440
2116
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3441
2117
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
3442
2118
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
@@ -3445,7 +2121,7 @@
|
|
|
3445
2121
|
};
|
|
3446
2122
|
var shallowEquals$1 = objects || shallowEquals_;
|
|
3447
2123
|
var FormattedMessage = /** @class */ (function (_super) {
|
|
3448
|
-
__extends$
|
|
2124
|
+
__extends$4(FormattedMessage, _super);
|
|
3449
2125
|
function FormattedMessage() {
|
|
3450
2126
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3451
2127
|
}
|
|
@@ -3472,7 +2148,7 @@
|
|
|
3472
2148
|
if (Component) {
|
|
3473
2149
|
// Needs to use `createElement()` instead of JSX, otherwise React will
|
|
3474
2150
|
// warn about a missing `key` prop with rich-text message formatting.
|
|
3475
|
-
return React.createElement.apply(React__namespace, __spreadArrays$
|
|
2151
|
+
return React.createElement.apply(React__namespace, __spreadArrays$3([Component, null], nodes));
|
|
3476
2152
|
}
|
|
3477
2153
|
return nodes;
|
|
3478
2154
|
}));
|