react-intl 6.5.4 → 6.6.0

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/index.d.ts CHANGED
@@ -5,7 +5,8 @@ import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
5
5
  import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
6
6
  import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
7
7
  import useIntl from './src/components/useIntl';
8
- import IntlProvider, { createIntl } from './src/components/provider';
8
+ import IntlProvider from './src/components/provider';
9
+ import { createIntl } from './src/components/createIntl';
9
10
  import FormattedRelativeTime from './src/components/relative';
10
11
  import FormattedPlural from './src/components/plural';
11
12
  import FormattedMessage from './src/components/message';
package/index.js CHANGED
@@ -9,9 +9,10 @@ Object.defineProperty(exports, "RawIntlProvider", { enumerable: true, get: funct
9
9
  Object.defineProperty(exports, "IntlContext", { enumerable: true, get: function () { return injectIntl_1.Context; } });
10
10
  var useIntl_1 = tslib_1.__importDefault(require("./src/components/useIntl"));
11
11
  exports.useIntl = useIntl_1.default;
12
- var provider_1 = tslib_1.__importStar(require("./src/components/provider"));
12
+ var provider_1 = tslib_1.__importDefault(require("./src/components/provider"));
13
13
  exports.IntlProvider = provider_1.default;
14
- Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return provider_1.createIntl; } });
14
+ var createIntl_1 = require("./src/components/createIntl");
15
+ Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return createIntl_1.createIntl; } });
15
16
  var relative_1 = tslib_1.__importDefault(require("./src/components/relative"));
16
17
  exports.FormattedRelativeTime = relative_1.default;
17
18
  var plural_1 = tslib_1.__importDefault(require("./src/components/plural"));
package/lib/index.d.ts CHANGED
@@ -5,7 +5,8 @@ import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
5
5
  import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
6
6
  import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
7
7
  import useIntl from './src/components/useIntl';
8
- import IntlProvider, { createIntl } from './src/components/provider';
8
+ import IntlProvider from './src/components/provider';
9
+ import { createIntl } from './src/components/createIntl';
9
10
  import FormattedRelativeTime from './src/components/relative';
10
11
  import FormattedPlural from './src/components/plural';
11
12
  import FormattedMessage from './src/components/message';
package/lib/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { createFormattedComponent, createFormattedDateTimePartsComponent, } from './src/components/createFormattedComponent';
2
2
  import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, } from './src/components/injectIntl';
3
3
  import useIntl from './src/components/useIntl';
4
- import IntlProvider, { createIntl } from './src/components/provider';
4
+ import IntlProvider from './src/components/provider';
5
+ import { createIntl } from './src/components/createIntl';
5
6
  import FormattedRelativeTime from './src/components/relative';
6
7
  import FormattedPlural from './src/components/plural';
7
8
  import FormattedMessage from './src/components/message';
@@ -0,0 +1,9 @@
1
+ import { CreateIntlFn } from '@formatjs/intl';
2
+ import * as React from 'react';
3
+ import type { IntlConfig, IntlShape } from '../types';
4
+ /**
5
+ * Create intl object
6
+ * @param config intl config
7
+ * @param cache cache for formatter instances to prevent memory leak
8
+ */
9
+ export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
@@ -0,0 +1,63 @@
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 { __assign, __rest, __spreadArray } from "tslib";
7
+ import { createIntl as coreCreateIntl, formatMessage as coreFormatMessage, } from '@formatjs/intl';
8
+ import * as React from 'react';
9
+ import { DEFAULT_INTL_CONFIG, assignUniqueKeysToParts } from '../utils';
10
+ import { isFormatXMLElementFn, } from 'intl-messageformat';
11
+ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
12
+ if (!values) {
13
+ return values;
14
+ }
15
+ return Object.keys(values).reduce(function (acc, k) {
16
+ var v = values[k];
17
+ acc[k] = isFormatXMLElementFn(v)
18
+ ? assignUniqueKeysToParts(v)
19
+ : v;
20
+ return acc;
21
+ }, {});
22
+ }
23
+ var formatMessage = function (config, formatters, descriptor, rawValues) {
24
+ var rest = [];
25
+ for (var _i = 4; _i < arguments.length; _i++) {
26
+ rest[_i - 4] = arguments[_i];
27
+ }
28
+ var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
29
+ var chunks = coreFormatMessage.apply(void 0, __spreadArray([config,
30
+ formatters,
31
+ descriptor,
32
+ values], rest, false));
33
+ if (Array.isArray(chunks)) {
34
+ return React.Children.toArray(chunks);
35
+ }
36
+ return chunks;
37
+ };
38
+ /**
39
+ * Create intl object
40
+ * @param config intl config
41
+ * @param cache cache for formatter instances to prevent memory leak
42
+ */
43
+ export var createIntl = function (_a, cache) {
44
+ var rawDefaultRichTextElements = _a.defaultRichTextElements, config = __rest(_a, ["defaultRichTextElements"]);
45
+ var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
46
+ var coreIntl = coreCreateIntl(__assign(__assign(__assign({}, DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
47
+ var resolvedConfig = {
48
+ locale: coreIntl.locale,
49
+ timeZone: coreIntl.timeZone,
50
+ fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
51
+ formats: coreIntl.formats,
52
+ defaultLocale: coreIntl.defaultLocale,
53
+ defaultFormats: coreIntl.defaultFormats,
54
+ messages: coreIntl.messages,
55
+ onError: coreIntl.onError,
56
+ defaultRichTextElements: defaultRichTextElements,
57
+ };
58
+ return __assign(__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
59
+ // @ts-expect-error fix this
60
+ coreIntl.formatters),
61
+ // @ts-expect-error fix this
62
+ $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
63
+ };
@@ -19,8 +19,5 @@ var FormattedPlural = function (props) {
19
19
  // Work around @types/react where React.FC cannot return string
20
20
  return formattedPlural;
21
21
  };
22
- FormattedPlural.defaultProps = {
23
- type: 'cardinal',
24
- };
25
22
  FormattedPlural.displayName = 'FormattedPlural';
26
23
  export default FormattedPlural;
@@ -1,6 +1,6 @@
1
- import { CreateIntlFn, IntlCache } from '@formatjs/intl';
1
+ import { IntlCache } from '@formatjs/intl';
2
2
  import * as React from 'react';
3
- import type { IntlConfig, IntlShape, ResolvedIntlConfig } from '../types';
3
+ import type { IntlConfig, IntlShape } from '../types';
4
4
  interface State {
5
5
  /**
6
6
  * Explicit intl cache to prevent memory leaks
@@ -17,15 +17,9 @@ interface State {
17
17
  */
18
18
  prevConfig: IntlConfig;
19
19
  }
20
- /**
21
- * Create intl object
22
- * @param config intl config
23
- * @param cache cache for formatter instances to prevent memory leak
24
- */
25
- export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
26
20
  export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
27
21
  static displayName: string;
28
- static defaultProps: Pick<ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
22
+ static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
29
23
  private cache;
30
24
  state: State;
31
25
  static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
@@ -3,12 +3,12 @@
3
3
  * Copyrights licensed under the New BSD License.
4
4
  * See the accompanying LICENSE file for terms.
5
5
  */
6
- import { __assign, __extends, __rest, __spreadArray } from "tslib";
7
- import { createIntl as coreCreateIntl, formatMessage as coreFormatMessage, createIntlCache, } from '@formatjs/intl';
6
+ import { __extends } from "tslib";
7
+ import { createIntlCache } from '@formatjs/intl';
8
8
  import * as React from 'react';
9
- import { DEFAULT_INTL_CONFIG, assignUniqueKeysToParts, invariantIntlContext, shallowEqual, } from '../utils';
9
+ import { DEFAULT_INTL_CONFIG, invariantIntlContext, shallowEqual } from '../utils';
10
10
  import { Provider } from './injectIntl';
11
- import { isFormatXMLElementFn, } from 'intl-messageformat';
11
+ import { createIntl } from './createIntl';
12
12
  function processIntlConfig(config) {
13
13
  return {
14
14
  locale: config.locale,
@@ -25,59 +25,6 @@ function processIntlConfig(config) {
25
25
  defaultRichTextElements: config.defaultRichTextElements,
26
26
  };
27
27
  }
28
- function assignUniqueKeysToFormatXMLElementFnArgument(values) {
29
- if (!values) {
30
- return values;
31
- }
32
- return Object.keys(values).reduce(function (acc, k) {
33
- var v = values[k];
34
- acc[k] = isFormatXMLElementFn(v)
35
- ? assignUniqueKeysToParts(v)
36
- : v;
37
- return acc;
38
- }, {});
39
- }
40
- var formatMessage = function (config, formatters, descriptor, rawValues) {
41
- var rest = [];
42
- for (var _i = 4; _i < arguments.length; _i++) {
43
- rest[_i - 4] = arguments[_i];
44
- }
45
- var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
46
- var chunks = coreFormatMessage.apply(void 0, __spreadArray([config,
47
- formatters,
48
- descriptor,
49
- values], rest, false));
50
- if (Array.isArray(chunks)) {
51
- return React.Children.toArray(chunks);
52
- }
53
- return chunks;
54
- };
55
- /**
56
- * Create intl object
57
- * @param config intl config
58
- * @param cache cache for formatter instances to prevent memory leak
59
- */
60
- export var createIntl = function (_a, cache) {
61
- var rawDefaultRichTextElements = _a.defaultRichTextElements, config = __rest(_a, ["defaultRichTextElements"]);
62
- var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
63
- var coreIntl = coreCreateIntl(__assign(__assign(__assign({}, DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
64
- var resolvedConfig = {
65
- locale: coreIntl.locale,
66
- timeZone: coreIntl.timeZone,
67
- fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
68
- formats: coreIntl.formats,
69
- defaultLocale: coreIntl.defaultLocale,
70
- defaultFormats: coreIntl.defaultFormats,
71
- messages: coreIntl.messages,
72
- onError: coreIntl.onError,
73
- defaultRichTextElements: defaultRichTextElements,
74
- };
75
- return __assign(__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
76
- // @ts-expect-error fix this
77
- coreIntl.formatters),
78
- // @ts-expect-error fix this
79
- $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
80
- };
81
28
  var IntlProvider = /** @class */ (function (_super) {
82
29
  __extends(IntlProvider, _super);
83
30
  function IntlProvider() {
@@ -70,12 +70,12 @@ var SimpleFormattedRelativeTime = function (props) {
70
70
  return React.createElement(React.Fragment, null, formattedRelativeTime);
71
71
  };
72
72
  var FormattedRelativeTime = function (_a) {
73
- var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = __rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
73
+ 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"]);
74
74
  invariant(!updateIntervalInSeconds ||
75
75
  !!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
76
- var _b = React.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
77
- var _c = React.useState(0), prevValue = _c[0], setPrevValue = _c[1];
78
- var _d = React.useState(0), currentValueInSeconds = _d[0], setCurrentValueInSeconds = _d[1];
76
+ var _d = React.useState(), prevUnit = _d[0], setPrevUnit = _d[1];
77
+ var _e = React.useState(0), prevValue = _e[0], setPrevValue = _e[1];
78
+ var _f = React.useState(0), currentValueInSeconds = _f[0], setCurrentValueInSeconds = _f[1];
79
79
  var updateTimer;
80
80
  if (unit !== prevUnit || value !== prevValue) {
81
81
  setPrevValue(value || 0);
@@ -122,8 +122,4 @@ var FormattedRelativeTime = function (_a) {
122
122
  return (React.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
123
123
  };
124
124
  FormattedRelativeTime.displayName = 'FormattedRelativeTime';
125
- FormattedRelativeTime.defaultProps = {
126
- value: 0,
127
- unit: 'second',
128
- };
129
125
  export default FormattedRelativeTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intl",
3
- "version": "6.5.4",
3
+ "version": "6.6.0",
4
4
  "description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
5
5
  "keywords": [
6
6
  "intl",
@@ -132,20 +132,20 @@
132
132
  "@types/react": "16 || 17 || 18",
133
133
  "hoist-non-react-statics": "^3.3.2",
134
134
  "tslib": "^2.4.0",
135
- "@formatjs/intl-displaynames": "6.6.3",
136
- "@formatjs/intl": "2.9.8",
137
- "@formatjs/icu-messageformat-parser": "2.7.2",
138
- "@formatjs/ecma402-abstract": "1.17.4",
139
- "@formatjs/intl-listformat": "7.5.2",
140
- "intl-messageformat": "10.5.7"
135
+ "@formatjs/ecma402-abstract": "1.18.1",
136
+ "@formatjs/intl": "2.9.10",
137
+ "@formatjs/icu-messageformat-parser": "2.7.4",
138
+ "@formatjs/intl-displaynames": "6.6.5",
139
+ "intl-messageformat": "10.5.9",
140
+ "@formatjs/intl-listformat": "7.5.4"
141
141
  },
142
142
  "devDependencies": {
143
- "@formatjs/intl-numberformat": "8.8.2",
144
- "@formatjs/intl-relativetimeformat": "11.2.9"
143
+ "@formatjs/intl-numberformat": "8.9.1",
144
+ "@formatjs/intl-relativetimeformat": "11.2.11"
145
145
  },
146
146
  "peerDependencies": {
147
147
  "react": "^16.6.0 || 17 || 18",
148
- "typescript": "5"
148
+ "typescript": "^4.7 || 5"
149
149
  },
150
150
  "peerDependenciesMeta": {
151
151
  "typescript": {
@@ -4548,23 +4548,10 @@ var ReactIntl = (() => {
4548
4548
  }
4549
4549
 
4550
4550
  // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/provider.js
4551
+ var React6 = __toESM(window.React);
4552
+
4553
+ // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/createIntl.js
4551
4554
  var React5 = __toESM(window.React);
4552
- function processIntlConfig(config) {
4553
- return {
4554
- locale: config.locale,
4555
- timeZone: config.timeZone,
4556
- fallbackOnEmptyString: config.fallbackOnEmptyString,
4557
- formats: config.formats,
4558
- textComponent: config.textComponent,
4559
- messages: config.messages,
4560
- defaultLocale: config.defaultLocale,
4561
- defaultFormats: config.defaultFormats,
4562
- onError: config.onError,
4563
- onWarn: config.onWarn,
4564
- wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
4565
- defaultRichTextElements: config.defaultRichTextElements
4566
- };
4567
- }
4568
4555
  function assignUniqueKeysToFormatXMLElementFnArgument(values) {
4569
4556
  if (!values) {
4570
4557
  return values;
@@ -4618,6 +4605,24 @@ var ReactIntl = (() => {
4618
4605
  $t: formatMessage2.bind(null, resolvedConfig, coreIntl.formatters)
4619
4606
  });
4620
4607
  };
4608
+
4609
+ // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/provider.js
4610
+ function processIntlConfig(config) {
4611
+ return {
4612
+ locale: config.locale,
4613
+ timeZone: config.timeZone,
4614
+ fallbackOnEmptyString: config.fallbackOnEmptyString,
4615
+ formats: config.formats,
4616
+ textComponent: config.textComponent,
4617
+ messages: config.messages,
4618
+ defaultLocale: config.defaultLocale,
4619
+ defaultFormats: config.defaultFormats,
4620
+ onError: config.onError,
4621
+ onWarn: config.onWarn,
4622
+ wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
4623
+ defaultRichTextElements: config.defaultRichTextElements
4624
+ };
4625
+ }
4621
4626
  var IntlProvider2 = (
4622
4627
  /** @class */
4623
4628
  function(_super) {
@@ -4645,17 +4650,17 @@ var ReactIntl = (() => {
4645
4650
  };
4646
4651
  IntlProvider3.prototype.render = function() {
4647
4652
  invariantIntlContext(this.state.intl);
4648
- return React5.createElement(Provider, { value: this.state.intl }, this.props.children);
4653
+ return React6.createElement(Provider, { value: this.state.intl }, this.props.children);
4649
4654
  };
4650
4655
  IntlProvider3.displayName = "IntlProvider";
4651
4656
  IntlProvider3.defaultProps = DEFAULT_INTL_CONFIG2;
4652
4657
  return IntlProvider3;
4653
- }(React5.PureComponent)
4658
+ }(React6.PureComponent)
4654
4659
  );
4655
4660
  var provider_default = IntlProvider2;
4656
4661
 
4657
4662
  // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/relative.js
4658
- var React6 = __toESM(window.React);
4663
+ var React7 = __toESM(window.React);
4659
4664
  var MINUTE = 60;
4660
4665
  var HOUR = 60 * 60;
4661
4666
  var DAY = 60 * 60 * 24;
@@ -4716,23 +4721,23 @@ var ReactIntl = (() => {
4716
4721
  return children(formattedRelativeTime);
4717
4722
  }
4718
4723
  if (Text) {
4719
- return React6.createElement(Text, null, formattedRelativeTime);
4724
+ return React7.createElement(Text, null, formattedRelativeTime);
4720
4725
  }
4721
- return React6.createElement(React6.Fragment, null, formattedRelativeTime);
4726
+ return React7.createElement(React7.Fragment, null, formattedRelativeTime);
4722
4727
  };
4723
4728
  var FormattedRelativeTime = function(_a2) {
4724
- var value = _a2.value, unit = _a2.unit, updateIntervalInSeconds = _a2.updateIntervalInSeconds, otherProps = __rest(_a2, ["value", "unit", "updateIntervalInSeconds"]);
4729
+ var _b = _a2.value, value = _b === void 0 ? 0 : _b, _c = _a2.unit, unit = _c === void 0 ? "second" : _c, updateIntervalInSeconds = _a2.updateIntervalInSeconds, otherProps = __rest(_a2, ["value", "unit", "updateIntervalInSeconds"]);
4725
4730
  invariant(!updateIntervalInSeconds || !!(updateIntervalInSeconds && canIncrement(unit)), "Cannot schedule update with unit longer than hour");
4726
- var _b = React6.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
4727
- var _c = React6.useState(0), prevValue = _c[0], setPrevValue = _c[1];
4728
- var _d = React6.useState(0), currentValueInSeconds = _d[0], setCurrentValueInSeconds = _d[1];
4731
+ var _d = React7.useState(), prevUnit = _d[0], setPrevUnit = _d[1];
4732
+ var _e = React7.useState(0), prevValue = _e[0], setPrevValue = _e[1];
4733
+ var _f = React7.useState(0), currentValueInSeconds = _f[0], setCurrentValueInSeconds = _f[1];
4729
4734
  var updateTimer;
4730
4735
  if (unit !== prevUnit || value !== prevValue) {
4731
4736
  setPrevValue(value || 0);
4732
4737
  setPrevUnit(unit);
4733
4738
  setCurrentValueInSeconds(canIncrement(unit) ? valueToSeconds(value, unit) : 0);
4734
4739
  }
4735
- React6.useEffect(function() {
4740
+ React7.useEffect(function() {
4736
4741
  function clearUpdateTimer() {
4737
4742
  clearTimeout(updateTimer);
4738
4743
  }
@@ -4764,17 +4769,13 @@ var ReactIntl = (() => {
4764
4769
  var unitDuration = getDurationInSeconds(currentUnit);
4765
4770
  currentValue = Math.round(currentValueInSeconds / unitDuration);
4766
4771
  }
4767
- return React6.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps));
4772
+ return React7.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps));
4768
4773
  };
4769
4774
  FormattedRelativeTime.displayName = "FormattedRelativeTime";
4770
- FormattedRelativeTime.defaultProps = {
4771
- value: 0,
4772
- unit: "second"
4773
- };
4774
4775
  var relative_default = FormattedRelativeTime;
4775
4776
 
4776
4777
  // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/plural.js
4777
- var React7 = __toESM(window.React);
4778
+ var React8 = __toESM(window.React);
4778
4779
  var FormattedPlural = function(props) {
4779
4780
  var _a2 = useIntl(), formatPlural2 = _a2.formatPlural, Text = _a2.textComponent;
4780
4781
  var value = props.value, other = props.other, children = props.children;
@@ -4784,18 +4785,15 @@ var ReactIntl = (() => {
4784
4785
  return children(formattedPlural);
4785
4786
  }
4786
4787
  if (Text) {
4787
- return React7.createElement(Text, null, formattedPlural);
4788
+ return React8.createElement(Text, null, formattedPlural);
4788
4789
  }
4789
4790
  return formattedPlural;
4790
4791
  };
4791
- FormattedPlural.defaultProps = {
4792
- type: "cardinal"
4793
- };
4794
4792
  FormattedPlural.displayName = "FormattedPlural";
4795
4793
  var plural_default = FormattedPlural;
4796
4794
 
4797
4795
  // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/message.js
4798
- var React8 = __toESM(window.React);
4796
+ var React9 = __toESM(window.React);
4799
4797
  function areEqual(prevProps, nextProps) {
4800
4798
  var values = prevProps.values, otherProps = __rest(prevProps, ["values"]);
4801
4799
  var nextValues = nextProps.values, nextOtherProps = __rest(nextProps, ["values"]);
@@ -4803,7 +4801,7 @@ var ReactIntl = (() => {
4803
4801
  }
4804
4802
  function FormattedMessage(props) {
4805
4803
  var intl = useIntl();
4806
- var formatMessage3 = intl.formatMessage, _a2 = intl.textComponent, Text = _a2 === void 0 ? React8.Fragment : _a2;
4804
+ var formatMessage3 = intl.formatMessage, _a2 = intl.textComponent, Text = _a2 === void 0 ? React9.Fragment : _a2;
4807
4805
  var id = props.id, description = props.description, defaultMessage = props.defaultMessage, values = props.values, children = props.children, _b = props.tagName, Component = _b === void 0 ? Text : _b, ignoreTag = props.ignoreTag;
4808
4806
  var descriptor = { id, description, defaultMessage };
4809
4807
  var nodes = formatMessage3(descriptor, values, {
@@ -4813,17 +4811,17 @@ var ReactIntl = (() => {
4813
4811
  return children(Array.isArray(nodes) ? nodes : [nodes]);
4814
4812
  }
4815
4813
  if (Component) {
4816
- return React8.createElement(Component, null, React8.Children.toArray(nodes));
4814
+ return React9.createElement(Component, null, React9.Children.toArray(nodes));
4817
4815
  }
4818
- return React8.createElement(React8.Fragment, null, nodes);
4816
+ return React9.createElement(React9.Fragment, null, nodes);
4819
4817
  }
4820
4818
  FormattedMessage.displayName = "FormattedMessage";
4821
- var MemoizedFormattedMessage = React8.memo(FormattedMessage, areEqual);
4819
+ var MemoizedFormattedMessage = React9.memo(FormattedMessage, areEqual);
4822
4820
  MemoizedFormattedMessage.displayName = "MemoizedFormattedMessage";
4823
4821
  var message_default = MemoizedFormattedMessage;
4824
4822
 
4825
4823
  // ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/packages/react-intl/lib/src/components/dateTimeRange.js
4826
- var React9 = __toESM(window.React);
4824
+ var React10 = __toESM(window.React);
4827
4825
  var FormattedDateTimeRange = function(props) {
4828
4826
  var intl = useIntl();
4829
4827
  var from = props.from, to = props.to, children = props.children, formatProps = __rest(props, ["from", "to", "children"]);
@@ -4831,8 +4829,8 @@ var ReactIntl = (() => {
4831
4829
  if (typeof children === "function") {
4832
4830
  return children(formattedValue);
4833
4831
  }
4834
- var Text = intl.textComponent || React9.Fragment;
4835
- return React9.createElement(Text, null, formattedValue);
4832
+ var Text = intl.textComponent || React10.Fragment;
4833
+ return React10.createElement(Text, null, formattedValue);
4836
4834
  };
4837
4835
  FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
4838
4836
  var dateTimeRange_default = FormattedDateTimeRange;
@@ -0,0 +1,9 @@
1
+ import { CreateIntlFn } from '@formatjs/intl';
2
+ import * as React from 'react';
3
+ import type { IntlConfig, IntlShape } from '../types';
4
+ /**
5
+ * Create intl object
6
+ * @param config intl config
7
+ * @param cache cache for formatter instances to prevent memory leak
8
+ */
9
+ export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2015, Yahoo Inc.
4
+ * Copyrights licensed under the New BSD License.
5
+ * See the accompanying LICENSE file for terms.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.createIntl = void 0;
9
+ var tslib_1 = require("tslib");
10
+ var intl_1 = require("@formatjs/intl");
11
+ var React = tslib_1.__importStar(require("react"));
12
+ var utils_1 = require("../utils");
13
+ var intl_messageformat_1 = require("intl-messageformat");
14
+ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
15
+ if (!values) {
16
+ return values;
17
+ }
18
+ return Object.keys(values).reduce(function (acc, k) {
19
+ var v = values[k];
20
+ acc[k] = (0, intl_messageformat_1.isFormatXMLElementFn)(v)
21
+ ? (0, utils_1.assignUniqueKeysToParts)(v)
22
+ : v;
23
+ return acc;
24
+ }, {});
25
+ }
26
+ var formatMessage = function (config, formatters, descriptor, rawValues) {
27
+ var rest = [];
28
+ for (var _i = 4; _i < arguments.length; _i++) {
29
+ rest[_i - 4] = arguments[_i];
30
+ }
31
+ var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
32
+ var chunks = intl_1.formatMessage.apply(void 0, tslib_1.__spreadArray([config,
33
+ formatters,
34
+ descriptor,
35
+ values], rest, false));
36
+ if (Array.isArray(chunks)) {
37
+ return React.Children.toArray(chunks);
38
+ }
39
+ return chunks;
40
+ };
41
+ /**
42
+ * Create intl object
43
+ * @param config intl config
44
+ * @param cache cache for formatter instances to prevent memory leak
45
+ */
46
+ var createIntl = function (_a, cache) {
47
+ var rawDefaultRichTextElements = _a.defaultRichTextElements, config = tslib_1.__rest(_a, ["defaultRichTextElements"]);
48
+ var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
49
+ var coreIntl = (0, intl_1.createIntl)(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
50
+ var resolvedConfig = {
51
+ locale: coreIntl.locale,
52
+ timeZone: coreIntl.timeZone,
53
+ fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
54
+ formats: coreIntl.formats,
55
+ defaultLocale: coreIntl.defaultLocale,
56
+ defaultFormats: coreIntl.defaultFormats,
57
+ messages: coreIntl.messages,
58
+ onError: coreIntl.onError,
59
+ defaultRichTextElements: defaultRichTextElements,
60
+ };
61
+ return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
62
+ // @ts-expect-error fix this
63
+ coreIntl.formatters),
64
+ // @ts-expect-error fix this
65
+ $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
66
+ };
67
+ exports.createIntl = createIntl;
@@ -22,8 +22,5 @@ var FormattedPlural = function (props) {
22
22
  // Work around @types/react where React.FC cannot return string
23
23
  return formattedPlural;
24
24
  };
25
- FormattedPlural.defaultProps = {
26
- type: 'cardinal',
27
- };
28
25
  FormattedPlural.displayName = 'FormattedPlural';
29
26
  exports.default = FormattedPlural;
@@ -1,6 +1,6 @@
1
- import { CreateIntlFn, IntlCache } from '@formatjs/intl';
1
+ import { IntlCache } from '@formatjs/intl';
2
2
  import * as React from 'react';
3
- import type { IntlConfig, IntlShape, ResolvedIntlConfig } from '../types';
3
+ import type { IntlConfig, IntlShape } from '../types';
4
4
  interface State {
5
5
  /**
6
6
  * Explicit intl cache to prevent memory leaks
@@ -17,15 +17,9 @@ interface State {
17
17
  */
18
18
  prevConfig: IntlConfig;
19
19
  }
20
- /**
21
- * Create intl object
22
- * @param config intl config
23
- * @param cache cache for formatter instances to prevent memory leak
24
- */
25
- export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
26
20
  export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
27
21
  static displayName: string;
28
- static defaultProps: Pick<ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
22
+ static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
29
23
  private cache;
30
24
  state: State;
31
25
  static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
@@ -5,13 +5,12 @@
5
5
  * See the accompanying LICENSE file for terms.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.createIntl = void 0;
9
8
  var tslib_1 = require("tslib");
10
9
  var intl_1 = require("@formatjs/intl");
11
10
  var React = tslib_1.__importStar(require("react"));
12
11
  var utils_1 = require("../utils");
13
12
  var injectIntl_1 = require("./injectIntl");
14
- var intl_messageformat_1 = require("intl-messageformat");
13
+ var createIntl_1 = require("./createIntl");
15
14
  function processIntlConfig(config) {
16
15
  return {
17
16
  locale: config.locale,
@@ -28,60 +27,6 @@ function processIntlConfig(config) {
28
27
  defaultRichTextElements: config.defaultRichTextElements,
29
28
  };
30
29
  }
31
- function assignUniqueKeysToFormatXMLElementFnArgument(values) {
32
- if (!values) {
33
- return values;
34
- }
35
- return Object.keys(values).reduce(function (acc, k) {
36
- var v = values[k];
37
- acc[k] = (0, intl_messageformat_1.isFormatXMLElementFn)(v)
38
- ? (0, utils_1.assignUniqueKeysToParts)(v)
39
- : v;
40
- return acc;
41
- }, {});
42
- }
43
- var formatMessage = function (config, formatters, descriptor, rawValues) {
44
- var rest = [];
45
- for (var _i = 4; _i < arguments.length; _i++) {
46
- rest[_i - 4] = arguments[_i];
47
- }
48
- var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
49
- var chunks = intl_1.formatMessage.apply(void 0, tslib_1.__spreadArray([config,
50
- formatters,
51
- descriptor,
52
- values], rest, false));
53
- if (Array.isArray(chunks)) {
54
- return React.Children.toArray(chunks);
55
- }
56
- return chunks;
57
- };
58
- /**
59
- * Create intl object
60
- * @param config intl config
61
- * @param cache cache for formatter instances to prevent memory leak
62
- */
63
- var createIntl = function (_a, cache) {
64
- var rawDefaultRichTextElements = _a.defaultRichTextElements, config = tslib_1.__rest(_a, ["defaultRichTextElements"]);
65
- var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
66
- var coreIntl = (0, intl_1.createIntl)(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
67
- var resolvedConfig = {
68
- locale: coreIntl.locale,
69
- timeZone: coreIntl.timeZone,
70
- fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
71
- formats: coreIntl.formats,
72
- defaultLocale: coreIntl.defaultLocale,
73
- defaultFormats: coreIntl.defaultFormats,
74
- messages: coreIntl.messages,
75
- onError: coreIntl.onError,
76
- defaultRichTextElements: defaultRichTextElements,
77
- };
78
- return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
79
- // @ts-expect-error fix this
80
- coreIntl.formatters),
81
- // @ts-expect-error fix this
82
- $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
83
- };
84
- exports.createIntl = createIntl;
85
30
  var IntlProvider = /** @class */ (function (_super) {
86
31
  tslib_1.__extends(IntlProvider, _super);
87
32
  function IntlProvider() {
@@ -89,7 +34,7 @@ var IntlProvider = /** @class */ (function (_super) {
89
34
  _this.cache = (0, intl_1.createIntlCache)();
90
35
  _this.state = {
91
36
  cache: _this.cache,
92
- intl: (0, exports.createIntl)(processIntlConfig(_this.props), _this.cache),
37
+ intl: (0, createIntl_1.createIntl)(processIntlConfig(_this.props), _this.cache),
93
38
  prevConfig: processIntlConfig(_this.props),
94
39
  };
95
40
  return _this;
@@ -99,7 +44,7 @@ var IntlProvider = /** @class */ (function (_super) {
99
44
  var config = processIntlConfig(props);
100
45
  if (!(0, utils_1.shallowEqual)(prevConfig, config)) {
101
46
  return {
102
- intl: (0, exports.createIntl)(config, cache),
47
+ intl: (0, createIntl_1.createIntl)(config, cache),
103
48
  prevConfig: config,
104
49
  };
105
50
  }
@@ -72,12 +72,12 @@ var SimpleFormattedRelativeTime = function (props) {
72
72
  return React.createElement(React.Fragment, null, formattedRelativeTime);
73
73
  };
74
74
  var FormattedRelativeTime = function (_a) {
75
- var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = tslib_1.__rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
75
+ var _b = _a.value, value = _b === void 0 ? 0 : _b, _c = _a.unit, unit = _c === void 0 ? 'second' : _c, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = tslib_1.__rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
76
76
  (0, ecma402_abstract_1.invariant)(!updateIntervalInSeconds ||
77
77
  !!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
78
- var _b = React.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
79
- var _c = React.useState(0), prevValue = _c[0], setPrevValue = _c[1];
80
- var _d = React.useState(0), currentValueInSeconds = _d[0], setCurrentValueInSeconds = _d[1];
78
+ var _d = React.useState(), prevUnit = _d[0], setPrevUnit = _d[1];
79
+ var _e = React.useState(0), prevValue = _e[0], setPrevValue = _e[1];
80
+ var _f = React.useState(0), currentValueInSeconds = _f[0], setCurrentValueInSeconds = _f[1];
81
81
  var updateTimer;
82
82
  if (unit !== prevUnit || value !== prevValue) {
83
83
  setPrevValue(value || 0);
@@ -124,8 +124,4 @@ var FormattedRelativeTime = function (_a) {
124
124
  return (React.createElement(SimpleFormattedRelativeTime, tslib_1.__assign({ value: currentValue, unit: currentUnit }, otherProps)));
125
125
  };
126
126
  FormattedRelativeTime.displayName = 'FormattedRelativeTime';
127
- FormattedRelativeTime.defaultProps = {
128
- value: 0,
129
- unit: 'second',
130
- };
131
127
  exports.default = FormattedRelativeTime;