react-intl 8.0.8 → 8.0.10

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-intl",
3
3
  "description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
4
- "version": "8.0.8",
4
+ "version": "8.0.10",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Eric Ferraiuolo <edf@ericf.me>",
7
7
  "type": "module",
@@ -14,10 +14,10 @@
14
14
  "@types/hoist-non-react-statics": "^3.3.1",
15
15
  "hoist-non-react-statics": "^3.3.2",
16
16
  "tslib": "^2.8.0",
17
- "@formatjs/icu-messageformat-parser": "3.1.1",
18
- "@formatjs/ecma402-abstract": "3.0.5",
19
- "@formatjs/intl": "4.0.6",
20
- "intl-messageformat": "11.0.6"
17
+ "@formatjs/ecma402-abstract": "3.0.7",
18
+ "@formatjs/intl": "4.0.8",
19
+ "@formatjs/icu-messageformat-parser": "3.2.1",
20
+ "intl-messageformat": "11.0.8"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@types/react": "19",
@@ -1443,6 +1443,12 @@ var ReactIntl = (() => {
1443
1443
  "hb",
1444
1444
  "hB"
1445
1445
  ],
1446
+ "GS": [
1447
+ "H",
1448
+ "h",
1449
+ "hb",
1450
+ "hB"
1451
+ ],
1446
1452
  "GT": [
1447
1453
  "h",
1448
1454
  "H",
@@ -2355,6 +2361,10 @@ var ReactIntl = (() => {
2355
2361
  "h",
2356
2362
  "H"
2357
2363
  ],
2364
+ "ku-SY": [
2365
+ "H",
2366
+ "hB"
2367
+ ],
2358
2368
  "ml-IN": [
2359
2369
  "hB",
2360
2370
  "h",
@@ -3318,8 +3328,8 @@ var ReactIntl = (() => {
3318
3328
  }
3319
3329
  var value = values[varName];
3320
3330
  if (isArgumentElement(el)) {
3321
- if (!value || typeof value === "string" || typeof value === "number") {
3322
- value = typeof value === "string" || typeof value === "number" ? String(value) : "";
3331
+ if (!value || typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
3332
+ value = typeof value === "string" || typeof value === "number" || typeof value === "bigint" ? String(value) : "";
3323
3333
  }
3324
3334
  result.push({
3325
3335
  type: typeof value === "string" ? PART_TYPE.literal : PART_TYPE.object,
@@ -3346,7 +3356,15 @@ var ReactIntl = (() => {
3346
3356
  if (isNumberElement(el)) {
3347
3357
  var style = typeof el.style === "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
3348
3358
  if (style && style.scale) {
3349
- value = value * (style.scale || 1);
3359
+ var scale = style.scale || 1;
3360
+ if (typeof value === "bigint") {
3361
+ if (!Number.isInteger(scale)) {
3362
+ throw new TypeError("Cannot apply fractional scale ".concat(scale, " to bigint value. Scale must be an integer when formatting bigint."));
3363
+ }
3364
+ value = value * BigInt(scale);
3365
+ } else {
3366
+ value = value * scale;
3367
+ }
3350
3368
  }
3351
3369
  result.push({
3352
3370
  type: PART_TYPE.literal,
@@ -3375,7 +3393,8 @@ var ReactIntl = (() => {
3375
3393
  }));
3376
3394
  }
3377
3395
  if (isSelectElement(el)) {
3378
- var opt = el.options[value] || el.options.other;
3396
+ var key = value;
3397
+ var opt = (Object.prototype.hasOwnProperty.call(el.options, key) ? el.options[key] : void 0) || el.options.other;
3379
3398
  if (!opt) {
3380
3399
  throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
3381
3400
  }
@@ -3383,18 +3402,21 @@ var ReactIntl = (() => {
3383
3402
  continue;
3384
3403
  }
3385
3404
  if (isPluralElement(el)) {
3386
- var opt = el.options["=".concat(value)];
3405
+ var exactKey = "=".concat(value);
3406
+ var opt = Object.prototype.hasOwnProperty.call(el.options, exactKey) ? el.options[exactKey] : void 0;
3387
3407
  if (!opt) {
3388
3408
  if (!Intl.PluralRules) {
3389
3409
  throw new FormatError('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n', ErrorCode.MISSING_INTL_API, originalMessage);
3390
3410
  }
3391
- var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
3392
- opt = el.options[rule] || el.options.other;
3411
+ var numericValue_1 = typeof value === "bigint" ? Number(value) : value;
3412
+ var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(numericValue_1 - (el.offset || 0));
3413
+ opt = (Object.prototype.hasOwnProperty.call(el.options, rule) ? el.options[rule] : void 0) || el.options.other;
3393
3414
  }
3394
3415
  if (!opt) {
3395
3416
  throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
3396
3417
  }
3397
- result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
3418
+ var numericValue = typeof value === "bigint" ? Number(value) : value;
3419
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, numericValue - (el.offset || 0)));
3398
3420
  continue;
3399
3421
  }
3400
3422
  }
@@ -1,4 +1,5 @@
1
1
  import { __rest } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import * as React from 'react';
3
4
  import useIntl from './useIntl.js';
4
5
  var DisplayName;
@@ -55,7 +56,7 @@ export function createFormattedComponent(name) {
55
56
  return children(formattedValue);
56
57
  }
57
58
  var Text = intl.textComponent || React.Fragment;
58
- return React.createElement(Text, null, formattedValue);
59
+ return _jsx(Text, { children: formattedValue });
59
60
  };
60
61
  Component.displayName = DisplayName[name];
61
62
  return Component;
@@ -1,4 +1,5 @@
1
1
  import { __rest } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import * as React from 'react';
3
4
  import useIntl from './useIntl.js';
4
5
  var FormattedDateTimeRange = function (props) {
@@ -9,7 +10,7 @@ var FormattedDateTimeRange = function (props) {
9
10
  return children(formattedValue);
10
11
  }
11
12
  var Text = intl.textComponent || React.Fragment;
12
- return React.createElement(Text, null, formattedValue);
13
+ return _jsx(Text, { children: formattedValue });
13
14
  };
14
15
  FormattedDateTimeRange.displayName = 'FormattedDateTimeRange';
15
16
  export default FormattedDateTimeRange;
@@ -1,5 +1,6 @@
1
1
  var _a;
2
2
  import { __assign } from "tslib";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
3
4
  import * as hoistNonReactStaticsNs from 'hoist-non-react-statics';
4
5
  import * as React from 'react';
5
6
  import { invariantIntlContext } from '../utils.js';
@@ -18,20 +19,20 @@ export var Provider = IntlProvider;
18
19
  export var Context = IntlContext;
19
20
  export default function injectIntl(WrappedComponent, options) {
20
21
  var _a = options || {}, _b = _a.intlPropName, intlPropName = _b === void 0 ? 'intl' : _b, _c = _a.forwardRef, forwardRef = _c === void 0 ? false : _c, _d = _a.enforceContext, enforceContext = _d === void 0 ? true : _d;
21
- var WithIntl = function (props) { return (React.createElement(IntlConsumer, null, function (intl) {
22
- var _a;
23
- if (enforceContext) {
24
- invariantIntlContext(intl);
25
- }
26
- var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
27
- return (React.createElement(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
28
- })); };
22
+ var WithIntl = function (props) { return (_jsx(IntlConsumer, { children: function (intl) {
23
+ var _a;
24
+ if (enforceContext) {
25
+ invariantIntlContext(intl);
26
+ }
27
+ var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
28
+ return (_jsx(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
29
+ } })); };
29
30
  WithIntl.displayName = "injectIntl(".concat(getDisplayName(WrappedComponent), ")");
30
31
  WithIntl.WrappedComponent = WrappedComponent;
31
32
  if (forwardRef) {
32
33
  return hoistNonReactStatics(
33
34
  // @ts-expect-error
34
- React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
35
+ React.forwardRef(function (props, ref) { return (_jsx(WithIntl, __assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
35
36
  }
36
37
  return hoistNonReactStatics(WithIntl, WrappedComponent);
37
38
  }
@@ -1,9 +1,5 @@
1
- /*
2
- * Copyright 2015, Yahoo Inc.
3
- * Copyrights licensed under the New BSD License.
4
- * See the accompanying LICENSE file for terms.
5
- */
6
1
  import { __rest } from "tslib";
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
7
3
  import * as React from 'react';
8
4
  import { shallowEqual } from '../utils.js';
9
5
  import useIntl from './useIntl.js';
@@ -25,9 +21,9 @@ function FormattedMessage(props) {
25
21
  return children(Array.isArray(nodes) ? nodes : [nodes]);
26
22
  }
27
23
  if (Component) {
28
- return React.createElement(Component, null, nodes);
24
+ return _jsx(Component, { children: nodes });
29
25
  }
30
- return React.createElement(React.Fragment, null, nodes);
26
+ return _jsx(_Fragment, { children: nodes });
31
27
  }
32
28
  FormattedMessage.displayName = 'FormattedMessage';
33
29
  var MemoizedFormattedMessage = React.memo(FormattedMessage, areEqual);
@@ -1,9 +1,4 @@
1
- /*
2
- * Copyright 2015, Yahoo Inc.
3
- * Copyrights licensed under the New BSD License.
4
- * See the accompanying LICENSE file for terms.
5
- */
6
- import * as React from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
7
2
  import useIntl from './useIntl.js';
8
3
  var FormattedPlural = function (props) {
9
4
  var _a = useIntl(), formatPlural = _a.formatPlural, Text = _a.textComponent;
@@ -14,7 +9,7 @@ var FormattedPlural = function (props) {
14
9
  return children(formattedPlural);
15
10
  }
16
11
  if (Text) {
17
- return React.createElement(Text, null, formattedPlural);
12
+ return _jsx(Text, { children: formattedPlural });
18
13
  }
19
14
  // Work around @types/react where React.FC cannot return string
20
15
  return formattedPlural;
@@ -1,9 +1,10 @@
1
+ import { __extends } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
1
3
  /*
2
4
  * Copyright 2015, Yahoo Inc.
3
5
  * Copyrights licensed under the New BSD License.
4
6
  * See the accompanying LICENSE file for terms.
5
7
  */
6
- import { __extends } from "tslib";
7
8
  import { createIntlCache } from '@formatjs/intl';
8
9
  import * as React from 'react';
9
10
  import { DEFAULT_INTL_CONFIG, invariantIntlContext, shallowEqual, } from '../utils.js';
@@ -50,7 +51,7 @@ var IntlProvider = /** @class */ (function (_super) {
50
51
  };
51
52
  IntlProvider.prototype.render = function () {
52
53
  invariantIntlContext(this.state.intl);
53
- return React.createElement(Provider, { value: this.state.intl }, this.props.children);
54
+ return _jsx(Provider, { value: this.state.intl, children: this.props.children });
54
55
  };
55
56
  IntlProvider.displayName = 'IntlProvider';
56
57
  IntlProvider.defaultProps = DEFAULT_INTL_CONFIG;
@@ -1,4 +1,5 @@
1
1
  import { __assign, __rest } from "tslib";
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  /*
3
4
  * Copyright 2015, Yahoo Inc.
4
5
  * Copyrights licensed under the New BSD License.
@@ -65,9 +66,9 @@ var SimpleFormattedRelativeTime = function (props) {
65
66
  return children(formattedRelativeTime);
66
67
  }
67
68
  if (Text) {
68
- return React.createElement(Text, null, formattedRelativeTime);
69
+ return _jsx(Text, { children: formattedRelativeTime });
69
70
  }
70
- return React.createElement(React.Fragment, null, formattedRelativeTime);
71
+ return _jsx(_Fragment, { children: formattedRelativeTime });
71
72
  };
72
73
  var FormattedRelativeTime = function (_a) {
73
74
  var _b = _a.value, value = _b === void 0 ? 0 : _b, _c = _a.unit, unit = _c === void 0 ? 'second' : _c, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = __rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
@@ -119,7 +120,7 @@ var FormattedRelativeTime = function (_a) {
119
120
  var unitDuration = getDurationInSeconds(currentUnit);
120
121
  currentValue = Math.round(currentValueInSeconds / unitDuration);
121
122
  }
122
- return (React.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
123
+ return (_jsx(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
123
124
  };
124
125
  FormattedRelativeTime.displayName = 'FormattedRelativeTime';
125
126
  export default FormattedRelativeTime;
package/src/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { __assign } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import * as React from 'react';
3
4
  import { DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG } from '@formatjs/intl';
4
5
  export function invariant(condition, message, Err) {
@@ -28,7 +29,7 @@ export var toKeyedReactNodeArray = function (children) {
28
29
  // For React elements, wrap in a keyed Fragment
29
30
  // This creates a new element with a key rather than trying to add one after creation
30
31
  if (React.isValidElement(child)) {
31
- return React.createElement(React.Fragment, { key: index }, child);
32
+ return _jsx(React.Fragment, { children: child }, index);
32
33
  }
33
34
  return child;
34
35
  });