react-intl 3.7.0 → 3.9.2
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/CHANGELOG.md +53 -9
- package/dist/components/plural.d.ts +1 -1
- package/dist/formatters/list.d.ts +1 -2
- package/dist/react-intl.api.md +3 -1
- package/dist/react-intl.d.ts +3 -7
- package/dist/react-intl.js +245 -8
- package/dist/react-intl.js.map +1 -1
- package/dist/react-intl.min.js +1 -1
- package/dist/react-intl.min.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/lib/components/plural.d.ts +1 -1
- package/lib/formatters/list.d.ts +1 -2
- package/lib/react-intl.d.ts +2 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +1 -0
- package/package.json +28 -27
- package/src/components/createFormattedComponent.tsx +114 -0
- package/src/components/html-message.tsx +68 -0
- package/src/components/injectIntl.tsx +111 -0
- package/src/components/message.tsx +120 -0
- package/src/components/plural.tsx +50 -0
- package/src/components/provider.tsx +183 -0
- package/src/components/relative.tsx +223 -0
- package/src/components/useIntl.ts +10 -0
- package/src/formatters/dateTime.ts +143 -0
- package/src/formatters/list.ts +72 -0
- package/src/formatters/message.ts +241 -0
- package/src/formatters/number.ts +77 -0
- package/src/formatters/plural.ts +31 -0
- package/src/formatters/relativeTime.ts +63 -0
- package/src/index.ts +52 -0
- package/src/tsconfig.cjs.json +8 -0
- package/src/tsconfig.json +8 -0
- package/src/types.ts +160 -0
- package/src/utils.ts +153 -0
- package/src/vendor.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,28 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### [3.9.2](https://github.com/formatjs/react-intl/compare/v3.9.1...v3.9.2) (2019-12-10)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
###
|
|
8
|
+
### Bug Fixes
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* add type overload for formatList, fix [#1537](https://github.com/formatjs/react-intl/issues/1537) ([6629899](https://github.com/formatjs/react-intl/commit/662989973c8d08f7972a3ba75f70b19abc507bb9))
|
|
11
|
+
* fix list formatter generation types ([0e5f205](https://github.com/formatjs/react-intl/commit/0e5f2058d7cba2d886693e219f58366582f0a6ac))
|
|
11
12
|
|
|
12
|
-
### [3.
|
|
13
|
+
### [3.9.1](https://github.com/formatjs/react-intl/compare/v3.9.0...v3.9.1) (2019-12-02)
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
### Bug Fixes
|
|
16
17
|
|
|
17
|
-
*
|
|
18
|
+
* Add src to packaged tar for sourcemap ([bce9bc7](https://github.com/formatjs/react-intl/commit/bce9bc7f6e014ec5ac1d67aa5daedc9214b75297))
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
## [3.9.0](https://github.com/formatjs/react-intl/compare/v3.8.0...v3.9.0) (2019-12-02)
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
###
|
|
23
|
+
### Features
|
|
23
24
|
|
|
24
|
-
*
|
|
25
|
-
* use `files` instead of .npmignore, update contributors ([b0c0fdb](https://github.com/formatjs/react-intl/commit/b0c0fdb1efa4dd9dfcf1d8c5709c5454bf242fce))
|
|
25
|
+
* Upgrade intl-messageformat-parser with support for unit-width in skeleton ([4b8f09f](https://github.com/formatjs/react-intl/commit/4b8f09f567ea09c5f5b576113ed963523832f942))
|
|
26
26
|
|
|
27
|
+
## [3.8.0](https://github.com/formatjs/react-intl/compare/v3.7.0...v3.8.0) (2019-12-01)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* Upgrade intl-messageformat-parser ([c12c99d](https://github.com/formatjs/react-intl/commit/c12c99dfdd8dfabf3d0103ce3c02e35b22d03be6))
|
|
33
|
+
|
|
34
|
+
Following our previous release with preliminary DateTimeFormat's
|
|
35
|
+
skeleton parser, this release comes with a subset of ICU NumberFormat's
|
|
36
|
+
skeleton parser. The full feature set can be found [here](unicode-org/icu:docs/userguide/format_parse/numbers/skeletons.md@master).
|
|
37
|
+
|
|
38
|
+
This, in combination with [intl-unified-numberformat](tc39/proposal-unified-intl-numberformat) allows you to write shorthand
|
|
39
|
+
NumberFormat in your messages like `{amount, number, ::currency/CAD .00}`
|
|
40
|
+
|
|
41
|
+
## [3.7.0](https://github.com/formatjs/react-intl/compare/v3.6.2...v3.7.0) (2019-11-25)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* Introduce support for DateTime skeleton ([568d013](https://github.com/formatjs/react-intl/commit/568d01342299135e9b049f9d4014193315fac41e))
|
|
47
|
+
|
|
48
|
+
This bumps the version of `intl-messageformat`, thus introducing a
|
|
49
|
+
subset of
|
|
50
|
+
[DateTime Skeleton](https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat-parser#supported-datetime-skeleton)
|
|
51
|
+
to react-intl.
|
|
52
|
+
The skeleton syntax per ICU is `today is {ts, time, ::yyyyMMdd}`.
|
|
53
|
+
Further documentation can be read at
|
|
54
|
+
http://userguide.icu-project.org/formatparse/datetime.
|
|
55
|
+
|
|
56
|
+
### [3.6.2](https://github.com/formatjs/react-intl/compare/v3.6.1...v3.6.2) (2019-11-21)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Bug Fixes
|
|
60
|
+
|
|
61
|
+
* fix main types file path in package.json ([14048bb](https://github.com/formatjs/react-intl/commit/14048bba41a7e02a8a0669ef14aa510acb089dc9))
|
|
62
|
+
|
|
63
|
+
### [3.6.1](https://github.com/formatjs/react-intl/compare/v3.6.0...v3.6.1) (2019-11-19)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Bug Fixes
|
|
67
|
+
|
|
68
|
+
* make `id` optional in MessageDescriptor ([15ca429](https://github.com/formatjs/react-intl/commit/15ca4292faf0fd82a392c024f027196393e52124))
|
|
69
|
+
* use `files` instead of .npmignore, update contributors ([b0c0fdb](https://github.com/formatjs/react-intl/commit/b0c0fdb1efa4dd9dfcf1d8c5709c5454bf242fce))
|
|
70
|
+
|
|
27
71
|
## [3.6.0](https://github.com/formatjs/react-intl/compare/v3.4.0...v3.6.0) (2019-11-12)
|
|
28
72
|
|
|
29
73
|
|
|
@@ -11,7 +11,7 @@ interface Props extends FormatPluralOptions {
|
|
|
11
11
|
many?: React.ReactNode;
|
|
12
12
|
children?(value: React.ReactNode): React.ReactElement | null;
|
|
13
13
|
}
|
|
14
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
14
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "type" | "format" | "value"> & {
|
|
15
15
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
16
16
|
} & React.RefAttributes<any>> & {
|
|
17
17
|
WrappedComponent: React.ComponentType<Props>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { IntlConfig, Formatters, IntlFormatters } from '../types';
|
|
3
|
-
export declare function formatList({ locale, onError }: Pick<IntlConfig, 'locale' | 'onError'>, getListFormat: Formatters['getListFormat'], values:
|
|
2
|
+
export declare function formatList({ locale, onError }: Pick<IntlConfig, 'locale' | 'onError'>, getListFormat: Formatters['getListFormat'], values: Array<string>, options: Parameters<IntlFormatters['formatList']>[1]): string;
|
package/dist/react-intl.api.md
CHANGED
|
@@ -116,7 +116,7 @@ export const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
|
|
|
116
116
|
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
|
|
117
117
|
//
|
|
118
118
|
// @public (undocumented)
|
|
119
|
-
export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
119
|
+
export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "type" | "format" | "value"> & {
|
|
120
120
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
121
121
|
} & React.RefAttributes<any>> & {
|
|
122
122
|
WrappedComponent: React.ComponentType<Props_2>;
|
|
@@ -245,6 +245,8 @@ export interface IntlFormatters {
|
|
|
245
245
|
// (undocumented)
|
|
246
246
|
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): React.ReactNode;
|
|
247
247
|
// (undocumented)
|
|
248
|
+
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
249
|
+
// (undocumented)
|
|
248
250
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
249
251
|
// (undocumented)
|
|
250
252
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
package/dist/react-intl.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
|
|
|
117
117
|
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
|
|
118
118
|
}>;
|
|
119
119
|
|
|
120
|
-
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "
|
|
120
|
+
export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "type" | "format" | "value"> & {
|
|
121
121
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
122
122
|
} & React.RefAttributes<any>> & {
|
|
123
123
|
WrappedComponent: React.ComponentType<Props_2>;
|
|
@@ -212,6 +212,7 @@ export declare interface IntlFormatters {
|
|
|
212
212
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string;
|
|
213
213
|
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | React.ReactElement | FormatXMLElementFn>): string | React.ReactNodeArray;
|
|
214
214
|
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): React.ReactNode;
|
|
215
|
+
formatList(values: Array<string>, opts?: FormatListOptions): string;
|
|
215
216
|
formatList(values: Array<string | React.ReactNode>, opts?: FormatListOptions): React.ReactNode;
|
|
216
217
|
}
|
|
217
218
|
|
|
@@ -413,11 +414,6 @@ declare interface LiteralPart_2 {
|
|
|
413
414
|
value: string;
|
|
414
415
|
}
|
|
415
416
|
|
|
416
|
-
declare interface LiteralPart_3 {
|
|
417
|
-
type: 'literal';
|
|
418
|
-
value: string;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
417
|
declare type Locale = string;
|
|
422
418
|
|
|
423
419
|
declare interface LocaleData<T> {
|
|
@@ -501,7 +497,7 @@ declare type ParseOptions = Options_2 & IParseOptions;
|
|
|
501
497
|
|
|
502
498
|
declare type Part = LiteralPart | RelativeTimeFormatNumberPart;
|
|
503
499
|
|
|
504
|
-
declare type Part_2 =
|
|
500
|
+
declare type Part_2 = LiteralPart | ElementPart;
|
|
505
501
|
|
|
506
502
|
declare const enum PART_TYPE {
|
|
507
503
|
literal = 0,
|
package/dist/react-intl.js
CHANGED
|
@@ -222,6 +222,11 @@
|
|
|
222
222
|
function isPluralElement(el) {
|
|
223
223
|
return el.type === TYPE.plural;
|
|
224
224
|
}
|
|
225
|
+
function isNumberSkeleton(el) {
|
|
226
|
+
return !!(el && _typeof(el) === 'object' && el.type === 0
|
|
227
|
+
/* number */
|
|
228
|
+
);
|
|
229
|
+
}
|
|
225
230
|
function isDateTimeSkeleton(el) {
|
|
226
231
|
return !!(el && _typeof(el) === 'object' && el.type === 1
|
|
227
232
|
/* dateTime */
|
|
@@ -3018,11 +3023,28 @@
|
|
|
3018
3023
|
});
|
|
3019
3024
|
}
|
|
3020
3025
|
|
|
3026
|
+
var __assign$1 = undefined && undefined.__assign || function () {
|
|
3027
|
+
__assign$1 = Object.assign || function (t) {
|
|
3028
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3029
|
+
s = arguments[i];
|
|
3030
|
+
|
|
3031
|
+
for (var p in s) {
|
|
3032
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
return t;
|
|
3037
|
+
};
|
|
3038
|
+
|
|
3039
|
+
return __assign$1.apply(this, arguments);
|
|
3040
|
+
};
|
|
3021
3041
|
/**
|
|
3022
3042
|
* https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
|
|
3023
3043
|
* Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
|
|
3024
3044
|
* with some tweaks
|
|
3025
3045
|
*/
|
|
3046
|
+
|
|
3047
|
+
|
|
3026
3048
|
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;
|
|
3027
3049
|
/**
|
|
3028
3050
|
* Parse Date time skeleton into Intl.DateTimeFormatOptions
|
|
@@ -3177,6 +3199,221 @@
|
|
|
3177
3199
|
return result;
|
|
3178
3200
|
}
|
|
3179
3201
|
|
|
3202
|
+
function icuUnitToEcma(unit) {
|
|
3203
|
+
return unit.replace(/^(.*?)-/, '');
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\+|#+)?)?$/g;
|
|
3207
|
+
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
|
|
3208
|
+
|
|
3209
|
+
function parseSignificantPrecision(str) {
|
|
3210
|
+
var result = {};
|
|
3211
|
+
str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
|
|
3212
|
+
// @@@ case
|
|
3213
|
+
if (typeof g2 !== 'string') {
|
|
3214
|
+
result.minimumSignificantDigits = g1.length;
|
|
3215
|
+
result.maximumSignificantDigits = g1.length;
|
|
3216
|
+
} // @@@+ case
|
|
3217
|
+
else if (g2 === '+') {
|
|
3218
|
+
result.minimumSignificantDigits = g1.length;
|
|
3219
|
+
} // .### case
|
|
3220
|
+
else if (g1[0] === '#') {
|
|
3221
|
+
result.maximumSignificantDigits = g1.length;
|
|
3222
|
+
} // .@@## or .@@@ case
|
|
3223
|
+
else {
|
|
3224
|
+
result.minimumSignificantDigits = g1.length;
|
|
3225
|
+
result.maximumSignificantDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
return '';
|
|
3229
|
+
});
|
|
3230
|
+
return result;
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
function parseSign(str) {
|
|
3234
|
+
switch (str) {
|
|
3235
|
+
case 'sign-auto':
|
|
3236
|
+
return {
|
|
3237
|
+
signDisplay: 'auto'
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
case 'sign-accounting':
|
|
3241
|
+
return {
|
|
3242
|
+
currencySign: 'accounting'
|
|
3243
|
+
};
|
|
3244
|
+
|
|
3245
|
+
case 'sign-always':
|
|
3246
|
+
return {
|
|
3247
|
+
signDisplay: 'always'
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
case 'sign-accounting-always':
|
|
3251
|
+
return {
|
|
3252
|
+
signDisplay: 'always',
|
|
3253
|
+
currencySign: 'accounting'
|
|
3254
|
+
};
|
|
3255
|
+
|
|
3256
|
+
case 'sign-except-zero':
|
|
3257
|
+
return {
|
|
3258
|
+
signDisplay: 'exceptZero'
|
|
3259
|
+
};
|
|
3260
|
+
|
|
3261
|
+
case 'sign-accounting-except-zero':
|
|
3262
|
+
return {
|
|
3263
|
+
signDisplay: 'exceptZero',
|
|
3264
|
+
currencySign: 'accounting'
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
case 'sign-never':
|
|
3268
|
+
return {
|
|
3269
|
+
signDisplay: 'never'
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
function parseNotationOptions(opt) {
|
|
3275
|
+
var result = {};
|
|
3276
|
+
var signOpts = parseSign(opt);
|
|
3277
|
+
|
|
3278
|
+
if (signOpts) {
|
|
3279
|
+
return signOpts;
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
return result;
|
|
3283
|
+
}
|
|
3284
|
+
/**
|
|
3285
|
+
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
|
|
3286
|
+
*/
|
|
3287
|
+
|
|
3288
|
+
|
|
3289
|
+
function convertNumberSkeletonToNumberFormatOptions(tokens) {
|
|
3290
|
+
var result = {};
|
|
3291
|
+
|
|
3292
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
3293
|
+
var token = tokens_1[_i];
|
|
3294
|
+
|
|
3295
|
+
switch (token.stem) {
|
|
3296
|
+
case 'percent':
|
|
3297
|
+
result.style = 'percent';
|
|
3298
|
+
continue;
|
|
3299
|
+
|
|
3300
|
+
case 'currency':
|
|
3301
|
+
result.style = 'currency';
|
|
3302
|
+
result.currency = token.options[0];
|
|
3303
|
+
continue;
|
|
3304
|
+
|
|
3305
|
+
case 'group-off':
|
|
3306
|
+
result.useGrouping = false;
|
|
3307
|
+
continue;
|
|
3308
|
+
|
|
3309
|
+
case 'precision-integer':
|
|
3310
|
+
result.maximumFractionDigits = 0;
|
|
3311
|
+
continue;
|
|
3312
|
+
|
|
3313
|
+
case 'measure-unit':
|
|
3314
|
+
result.style = 'unit';
|
|
3315
|
+
result.unit = icuUnitToEcma(token.options[0]);
|
|
3316
|
+
continue;
|
|
3317
|
+
|
|
3318
|
+
case 'compact-short':
|
|
3319
|
+
result.notation = 'compact';
|
|
3320
|
+
result.compactDisplay = 'short';
|
|
3321
|
+
continue;
|
|
3322
|
+
|
|
3323
|
+
case 'compact-long':
|
|
3324
|
+
result.notation = 'compact';
|
|
3325
|
+
result.compactDisplay = 'long';
|
|
3326
|
+
continue;
|
|
3327
|
+
|
|
3328
|
+
case 'scientific':
|
|
3329
|
+
result = __assign$1(__assign$1(__assign$1({}, result), {
|
|
3330
|
+
notation: 'scientific'
|
|
3331
|
+
}), token.options.reduce(function (all, opt) {
|
|
3332
|
+
return __assign$1(__assign$1({}, all), parseNotationOptions(opt));
|
|
3333
|
+
}, {}));
|
|
3334
|
+
continue;
|
|
3335
|
+
|
|
3336
|
+
case 'engineering':
|
|
3337
|
+
result = __assign$1(__assign$1(__assign$1({}, result), {
|
|
3338
|
+
notation: 'engineering'
|
|
3339
|
+
}), token.options.reduce(function (all, opt) {
|
|
3340
|
+
return __assign$1(__assign$1({}, all), parseNotationOptions(opt));
|
|
3341
|
+
}, {}));
|
|
3342
|
+
continue;
|
|
3343
|
+
|
|
3344
|
+
case 'notation-simple':
|
|
3345
|
+
result.notation = 'standard';
|
|
3346
|
+
continue;
|
|
3347
|
+
// https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
|
|
3348
|
+
|
|
3349
|
+
case 'unit-width-narrow':
|
|
3350
|
+
result.currencyDisplay = 'narrowSymbol';
|
|
3351
|
+
result.unitDisplay = 'narrow';
|
|
3352
|
+
continue;
|
|
3353
|
+
|
|
3354
|
+
case 'unit-width-short':
|
|
3355
|
+
result.currencyDisplay = 'code';
|
|
3356
|
+
result.unitDisplay = 'short';
|
|
3357
|
+
continue;
|
|
3358
|
+
|
|
3359
|
+
case 'unit-width-full-name':
|
|
3360
|
+
result.currencyDisplay = 'name';
|
|
3361
|
+
result.unitDisplay = 'long';
|
|
3362
|
+
continue;
|
|
3363
|
+
|
|
3364
|
+
case 'unit-width-iso-code':
|
|
3365
|
+
result.currencyDisplay = 'symbol';
|
|
3366
|
+
continue;
|
|
3367
|
+
} // Precision
|
|
3368
|
+
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
|
|
3372
|
+
if (token.options.length > 1) {
|
|
3373
|
+
throw new RangeError('Fraction-precision stems only accept a single optional option');
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
token.stem.replace(FRACTION_PRECISION_REGEX, function (match, g1, g2) {
|
|
3377
|
+
// precision-integer case
|
|
3378
|
+
if (match === '.') {
|
|
3379
|
+
result.maximumFractionDigits = 0;
|
|
3380
|
+
} // .000+ case
|
|
3381
|
+
else if (g2 === '+') {
|
|
3382
|
+
result.minimumFractionDigits = g2.length;
|
|
3383
|
+
} // .### case
|
|
3384
|
+
else if (g1[0] === '#') {
|
|
3385
|
+
result.maximumFractionDigits = g1.length;
|
|
3386
|
+
} // .00## or .000 case
|
|
3387
|
+
else {
|
|
3388
|
+
result.minimumFractionDigits = g1.length;
|
|
3389
|
+
result.maximumFractionDigits = g1.length + (typeof g2 === 'string' ? g2.length : 0);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
return '';
|
|
3393
|
+
});
|
|
3394
|
+
|
|
3395
|
+
if (token.options.length) {
|
|
3396
|
+
result = __assign$1(__assign$1({}, result), parseSignificantPrecision(token.options[0]));
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
continue;
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
|
|
3403
|
+
result = __assign$1(__assign$1({}, result), parseSignificantPrecision(token.stem));
|
|
3404
|
+
continue;
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
var signOpts = parseSign(token.stem);
|
|
3408
|
+
|
|
3409
|
+
if (signOpts) {
|
|
3410
|
+
result = __assign$1(__assign$1({}, result), signOpts);
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
return result;
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3180
3417
|
function parse(input, opts) {
|
|
3181
3418
|
var els = pegParse(input, opts);
|
|
3182
3419
|
|
|
@@ -3417,7 +3654,7 @@
|
|
|
3417
3654
|
}
|
|
3418
3655
|
|
|
3419
3656
|
if (isNumberElement(el)) {
|
|
3420
|
-
var style = typeof el.style === 'string' ? formats.number[el.style] : undefined;
|
|
3657
|
+
var style = typeof el.style === 'string' ? formats.number[el.style] : isNumberSkeleton(el.style) ? convertNumberSkeletonToNumberFormatOptions(el.style.tokens) : undefined;
|
|
3421
3658
|
result.push({
|
|
3422
3659
|
type: 0
|
|
3423
3660
|
/* literal */
|
|
@@ -3612,8 +3849,8 @@
|
|
|
3612
3849
|
Copyrights licensed under the New BSD License.
|
|
3613
3850
|
See the accompanying LICENSE file for terms.
|
|
3614
3851
|
*/
|
|
3615
|
-
var __assign$
|
|
3616
|
-
__assign$
|
|
3852
|
+
var __assign$2 = undefined && undefined.__assign || function () {
|
|
3853
|
+
__assign$2 = Object.assign || function (t) {
|
|
3617
3854
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3618
3855
|
s = arguments[i];
|
|
3619
3856
|
|
|
@@ -3625,7 +3862,7 @@
|
|
|
3625
3862
|
return t;
|
|
3626
3863
|
};
|
|
3627
3864
|
|
|
3628
|
-
return __assign$
|
|
3865
|
+
return __assign$2.apply(this, arguments);
|
|
3629
3866
|
};
|
|
3630
3867
|
|
|
3631
3868
|
function mergeConfig(c1, c2) {
|
|
@@ -3633,8 +3870,8 @@
|
|
|
3633
3870
|
return c1;
|
|
3634
3871
|
}
|
|
3635
3872
|
|
|
3636
|
-
return __assign$
|
|
3637
|
-
all[k] = __assign$
|
|
3873
|
+
return __assign$2(__assign$2(__assign$2({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function (all, k) {
|
|
3874
|
+
all[k] = __assign$2(__assign$2({}, c1[k]), c2[k] || {});
|
|
3638
3875
|
return all;
|
|
3639
3876
|
}, {}));
|
|
3640
3877
|
}
|
|
@@ -3647,7 +3884,7 @@
|
|
|
3647
3884
|
return Object.keys(defaultConfig).reduce(function (all, k) {
|
|
3648
3885
|
all[k] = mergeConfig(defaultConfig[k], configs[k]);
|
|
3649
3886
|
return all;
|
|
3650
|
-
}, __assign$
|
|
3887
|
+
}, __assign$2({}, defaultConfig));
|
|
3651
3888
|
}
|
|
3652
3889
|
|
|
3653
3890
|
function createDefaultFormatters(cache) {
|
|
@@ -4800,7 +5037,7 @@
|
|
|
4800
5037
|
for (var i = 0; i < len; i++) {
|
|
4801
5038
|
var key = aKeys[i];
|
|
4802
5039
|
|
|
4803
|
-
if (objA[key] !== objB[key]) {
|
|
5040
|
+
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
4804
5041
|
return false;
|
|
4805
5042
|
}
|
|
4806
5043
|
}
|