react-intl 6.0.6 → 6.1.1

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.
Files changed (147) hide show
  1. package/index.d.ts +43 -0
  2. package/index.d.ts.map +1 -0
  3. package/index.js +51 -0
  4. package/lib/index.d.ts +43 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +26 -0
  7. package/lib/src/components/createFormattedComponent.d.ts +29 -0
  8. package/lib/src/components/createFormattedComponent.d.ts.map +1 -0
  9. package/lib/src/components/createFormattedComponent.js +62 -0
  10. package/lib/src/components/dateTimeRange.d.ts +11 -0
  11. package/lib/src/components/dateTimeRange.d.ts.map +1 -0
  12. package/lib/src/components/dateTimeRange.js +15 -0
  13. package/lib/src/components/injectIntl.d.ts +22 -0
  14. package/lib/src/components/injectIntl.d.ts.map +1 -0
  15. package/lib/src/components/injectIntl.js +29 -0
  16. package/lib/src/components/message.d.ts +12 -0
  17. package/lib/src/components/message.d.ts.map +1 -0
  18. package/lib/src/components/message.js +35 -0
  19. package/lib/src/components/plural.d.ts +15 -0
  20. package/lib/src/components/plural.d.ts.map +1 -0
  21. package/lib/src/components/plural.js +26 -0
  22. package/lib/src/components/provider.d.ts +35 -0
  23. package/lib/src/components/provider.d.ts.map +1 -0
  24. package/lib/src/components/provider.js +112 -0
  25. package/lib/src/components/relative.d.ts +12 -0
  26. package/lib/src/components/relative.d.ts.map +1 -0
  27. package/lib/src/components/relative.js +129 -0
  28. package/lib/src/components/useIntl.d.ts +3 -0
  29. package/lib/src/components/useIntl.d.ts.map +1 -0
  30. package/lib/src/components/useIntl.js +8 -0
  31. package/lib/src/types.d.ts +12 -0
  32. package/lib/src/types.d.ts.map +1 -0
  33. package/lib/src/types.js +1 -0
  34. package/lib/src/utils.d.ts +14 -0
  35. package/lib/src/utils.d.ts.map +1 -0
  36. package/lib/src/utils.js +43 -0
  37. package/package.json +10 -10
  38. package/react-intl.iife.js +4688 -0
  39. package/src/components/createFormattedComponent.d.ts +29 -0
  40. package/src/components/createFormattedComponent.d.ts.map +1 -0
  41. package/src/components/createFormattedComponent.js +69 -0
  42. package/src/components/dateTimeRange.d.ts +11 -0
  43. package/src/components/dateTimeRange.d.ts.map +1 -0
  44. package/src/components/dateTimeRange.js +17 -0
  45. package/src/components/injectIntl.d.ts +22 -0
  46. package/src/components/injectIntl.d.ts.map +1 -0
  47. package/src/components/injectIntl.js +33 -0
  48. package/src/components/message.d.ts +12 -0
  49. package/src/components/message.d.ts.map +1 -0
  50. package/src/components/message.js +37 -0
  51. package/src/components/plural.d.ts +15 -0
  52. package/src/components/plural.d.ts.map +1 -0
  53. package/src/components/plural.js +29 -0
  54. package/src/components/provider.d.ts +35 -0
  55. package/src/components/provider.d.ts.map +1 -0
  56. package/src/components/provider.js +116 -0
  57. package/src/components/relative.d.ts +12 -0
  58. package/src/components/relative.d.ts.map +1 -0
  59. package/src/components/relative.js +131 -0
  60. package/src/components/useIntl.d.ts +3 -0
  61. package/src/components/useIntl.d.ts.map +1 -0
  62. package/src/components/useIntl.js +12 -0
  63. package/src/types.d.ts +12 -0
  64. package/src/types.d.ts.map +1 -0
  65. package/src/types.js +2 -0
  66. package/src/utils.d.ts +14 -0
  67. package/src/utils.d.ts.map +1 -0
  68. package/src/utils.js +49 -0
  69. package/BUILD +0 -130
  70. package/CHANGELOG.md +0 -1384
  71. package/example-sandboxes/rescripts/.rescriptsrc.js +0 -28
  72. package/example-sandboxes/rescripts/package-lock.json +0 -18035
  73. package/example-sandboxes/rescripts/package.json +0 -35
  74. package/example-sandboxes/rescripts/public/index.html +0 -42
  75. package/example-sandboxes/rescripts/src/App.tsx +0 -16
  76. package/example-sandboxes/rescripts/src/index.tsx +0 -5
  77. package/example-sandboxes/rescripts/src/react-app-env.d.ts +0 -1
  78. package/example-sandboxes/rescripts/src/styles.css +0 -4
  79. package/example-sandboxes/rescripts/tsconfig.json +0 -20
  80. package/example-sandboxes/strict-locale-type/.env +0 -1
  81. package/example-sandboxes/strict-locale-type/package-lock.json +0 -14595
  82. package/example-sandboxes/strict-locale-type/package.json +0 -35
  83. package/example-sandboxes/strict-locale-type/src/App.tsx +0 -48
  84. package/example-sandboxes/strict-locale-type/src/index.html +0 -28
  85. package/example-sandboxes/strict-locale-type/src/index.tsx +0 -7
  86. package/example-sandboxes/strict-locale-type/src/styles.css +0 -4
  87. package/example-sandboxes/strict-locale-type/tsconfig.json +0 -7
  88. package/example-sandboxes/strict-message-types/.env +0 -1
  89. package/example-sandboxes/strict-message-types/package-lock.json +0 -14596
  90. package/example-sandboxes/strict-message-types/package.json +0 -35
  91. package/example-sandboxes/strict-message-types/src/App.tsx +0 -31
  92. package/example-sandboxes/strict-message-types/src/index.html +0 -28
  93. package/example-sandboxes/strict-message-types/src/index.tsx +0 -7
  94. package/example-sandboxes/strict-message-types/src/styles.css +0 -4
  95. package/example-sandboxes/strict-message-types/tsconfig.json +0 -7
  96. package/examples/BUILD +0 -70
  97. package/examples/Bug2727.tsx +0 -37
  98. package/examples/HandleChange.tsx +0 -48
  99. package/examples/Hooks.tsx +0 -126
  100. package/examples/Injected.tsx +0 -41
  101. package/examples/Messages.tsx +0 -82
  102. package/examples/StaticTypeSafetyAndCodeSplitting/StaticTypeSafetyAndCodeSplitting.tsx +0 -44
  103. package/examples/StaticTypeSafetyAndCodeSplitting/en.json +0 -3
  104. package/examples/StaticTypeSafetyAndCodeSplitting/intlHelpers.tsx +0 -39
  105. package/examples/StaticTypeSafetyAndCodeSplitting/it.json +0 -3
  106. package/examples/TimeZone.tsx +0 -44
  107. package/examples/advanced/Advanced.tsx +0 -68
  108. package/examples/advanced/compiled-lang/en.json +0 -77
  109. package/examples/advanced/compiled-lang/fr.json +0 -77
  110. package/examples/index.html +0 -20
  111. package/examples/index.tsx +0 -44
  112. package/examples/package.json +0 -20
  113. package/index.ts +0 -127
  114. package/jest.config.js +0 -27
  115. package/src/components/createFormattedComponent.tsx +0 -123
  116. package/src/components/dateTimeRange.tsx +0 -26
  117. package/src/components/injectIntl.tsx +0 -111
  118. package/src/components/message.tsx +0 -73
  119. package/src/components/plural.tsx +0 -45
  120. package/src/components/provider.tsx +0 -196
  121. package/src/components/relative.tsx +0 -192
  122. package/src/components/useIntl.ts +0 -10
  123. package/src/types.ts +0 -29
  124. package/src/utils.ts +0 -77
  125. package/tests/functional/index.ts +0 -18
  126. package/tests/functional/support/build.ts +0 -16
  127. package/tests/functional/support/format.tsx +0 -112
  128. package/tests/perf/index.tsx +0 -196
  129. package/tests/setup.js +0 -10
  130. package/tests/unit/components/__snapshots__/displayName.tsx.snap +0 -19
  131. package/tests/unit/components/__snapshots__/message.tsx.snap +0 -41
  132. package/tests/unit/components/__snapshots__/relative.tsx.snap +0 -11
  133. package/tests/unit/components/__snapshots__/useIntl.tsx.snap +0 -25
  134. package/tests/unit/components/date.tsx +0 -233
  135. package/tests/unit/components/dateTimeRange.tsx +0 -103
  136. package/tests/unit/components/displayName.tsx +0 -57
  137. package/tests/unit/components/message.tsx +0 -509
  138. package/tests/unit/components/number.tsx +0 -198
  139. package/tests/unit/components/plural.tsx +0 -116
  140. package/tests/unit/components/provider.tsx +0 -215
  141. package/tests/unit/components/relative.tsx +0 -263
  142. package/tests/unit/components/time.tsx +0 -242
  143. package/tests/unit/components/useIntl.tsx +0 -64
  144. package/tests/unit/components/withIntl.tsx +0 -66
  145. package/tests/unit/react-intl.ts +0 -88
  146. package/tests/unit/testUtils.tsx +0 -42
  147. package/tsconfig.json +0 -5
@@ -0,0 +1,112 @@
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, __extends, __rest, __spreadArray } from "tslib";
7
+ import * as React from 'react';
8
+ import { Provider } from './injectIntl';
9
+ import { DEFAULT_INTL_CONFIG, invariantIntlContext, assignUniqueKeysToParts, shallowEqual, } from '../utils';
10
+ import { formatMessage as coreFormatMessage, createIntl as coreCreateIntl, createIntlCache, } from '@formatjs/intl';
11
+ import { isFormatXMLElementFn, } from 'intl-messageformat';
12
+ function processIntlConfig(config) {
13
+ return {
14
+ locale: config.locale,
15
+ timeZone: config.timeZone,
16
+ fallbackOnEmptyString: config.fallbackOnEmptyString,
17
+ formats: config.formats,
18
+ textComponent: config.textComponent,
19
+ messages: config.messages,
20
+ defaultLocale: config.defaultLocale,
21
+ defaultFormats: config.defaultFormats,
22
+ onError: config.onError,
23
+ onWarn: config.onWarn,
24
+ wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
25
+ defaultRichTextElements: config.defaultRichTextElements,
26
+ };
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), {
76
+ // @ts-expect-error fix this
77
+ formatMessage: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),
78
+ // @ts-expect-error fix this
79
+ $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
80
+ };
81
+ var IntlProvider = /** @class */ (function (_super) {
82
+ __extends(IntlProvider, _super);
83
+ function IntlProvider() {
84
+ var _this = _super !== null && _super.apply(this, arguments) || this;
85
+ _this.cache = createIntlCache();
86
+ _this.state = {
87
+ cache: _this.cache,
88
+ intl: createIntl(processIntlConfig(_this.props), _this.cache),
89
+ prevConfig: processIntlConfig(_this.props),
90
+ };
91
+ return _this;
92
+ }
93
+ IntlProvider.getDerivedStateFromProps = function (props, _a) {
94
+ var prevConfig = _a.prevConfig, cache = _a.cache;
95
+ var config = processIntlConfig(props);
96
+ if (!shallowEqual(prevConfig, config)) {
97
+ return {
98
+ intl: createIntl(config, cache),
99
+ prevConfig: config,
100
+ };
101
+ }
102
+ return null;
103
+ };
104
+ IntlProvider.prototype.render = function () {
105
+ invariantIntlContext(this.state.intl);
106
+ return React.createElement(Provider, { value: this.state.intl }, this.props.children);
107
+ };
108
+ IntlProvider.displayName = 'IntlProvider';
109
+ IntlProvider.defaultProps = DEFAULT_INTL_CONFIG;
110
+ return IntlProvider;
111
+ }(React.PureComponent));
112
+ export default IntlProvider;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { RelativeTimeFormatSingularUnit } from '@formatjs/ecma402-abstract';
3
+ import { FormatRelativeTimeOptions } from '@formatjs/intl';
4
+ export interface Props extends FormatRelativeTimeOptions {
5
+ value?: number;
6
+ unit?: RelativeTimeFormatSingularUnit;
7
+ updateIntervalInSeconds?: number;
8
+ children?(value: string): React.ReactElement | null;
9
+ }
10
+ declare const FormattedRelativeTime: React.FC<Props>;
11
+ export default FormattedRelativeTime;
12
+ //# sourceMappingURL=relative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../../src/components/relative.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAEL,8BAA8B,EAC/B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAC,yBAAyB,EAAC,MAAM,gBAAgB,CAAA;AAuDxD,MAAM,WAAW,KAAM,SAAQ,yBAAyB;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,8BAA8B,CAAA;IACrC,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACpD;AA8BD,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmF1C,CAAA;AAQD,eAAe,qBAAqB,CAAA"}
@@ -0,0 +1,129 @@
1
+ import { __assign, __rest } from "tslib";
2
+ /*
3
+ * Copyright 2015, Yahoo Inc.
4
+ * Copyrights licensed under the New BSD License.
5
+ * See the accompanying LICENSE file for terms.
6
+ */
7
+ import * as React from 'react';
8
+ import { invariant, } from '@formatjs/ecma402-abstract';
9
+ import useIntl from './useIntl';
10
+ var MINUTE = 60;
11
+ var HOUR = 60 * 60;
12
+ var DAY = 60 * 60 * 24;
13
+ function selectUnit(seconds) {
14
+ var absValue = Math.abs(seconds);
15
+ if (absValue < MINUTE) {
16
+ return 'second';
17
+ }
18
+ if (absValue < HOUR) {
19
+ return 'minute';
20
+ }
21
+ if (absValue < DAY) {
22
+ return 'hour';
23
+ }
24
+ return 'day';
25
+ }
26
+ function getDurationInSeconds(unit) {
27
+ switch (unit) {
28
+ case 'second':
29
+ return 1;
30
+ case 'minute':
31
+ return MINUTE;
32
+ case 'hour':
33
+ return HOUR;
34
+ default:
35
+ return DAY;
36
+ }
37
+ }
38
+ function valueToSeconds(value, unit) {
39
+ if (!value) {
40
+ return 0;
41
+ }
42
+ switch (unit) {
43
+ case 'second':
44
+ return value;
45
+ case 'minute':
46
+ return value * MINUTE;
47
+ default:
48
+ return value * HOUR;
49
+ }
50
+ }
51
+ var INCREMENTABLE_UNITS = [
52
+ 'second',
53
+ 'minute',
54
+ 'hour',
55
+ ];
56
+ function canIncrement(unit) {
57
+ if (unit === void 0) { unit = 'second'; }
58
+ return INCREMENTABLE_UNITS.indexOf(unit) > -1;
59
+ }
60
+ var SimpleFormattedRelativeTime = function (props) {
61
+ var _a = useIntl(), formatRelativeTime = _a.formatRelativeTime, Text = _a.textComponent;
62
+ var children = props.children, value = props.value, unit = props.unit, otherProps = __rest(props, ["children", "value", "unit"]);
63
+ var formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps);
64
+ if (typeof children === 'function') {
65
+ return children(formattedRelativeTime);
66
+ }
67
+ if (Text) {
68
+ return React.createElement(Text, null, formattedRelativeTime);
69
+ }
70
+ return React.createElement(React.Fragment, null, formattedRelativeTime);
71
+ };
72
+ var FormattedRelativeTime = function (_a) {
73
+ var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = __rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
74
+ invariant(!updateIntervalInSeconds ||
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];
79
+ var updateTimer;
80
+ if (unit !== prevUnit || value !== prevValue) {
81
+ setPrevValue(value || 0);
82
+ setPrevUnit(unit);
83
+ setCurrentValueInSeconds(canIncrement(unit) ? valueToSeconds(value, unit) : 0);
84
+ }
85
+ React.useEffect(function () {
86
+ function clearUpdateTimer() {
87
+ clearTimeout(updateTimer);
88
+ }
89
+ clearUpdateTimer();
90
+ // If there's no interval and we cannot increment this unit, do nothing
91
+ if (!updateIntervalInSeconds || !canIncrement(unit)) {
92
+ return clearUpdateTimer;
93
+ }
94
+ // Figure out the next interesting time
95
+ var nextValueInSeconds = currentValueInSeconds - updateIntervalInSeconds;
96
+ var nextUnit = selectUnit(nextValueInSeconds);
97
+ // We've reached the max auto incrementable unit, don't schedule another update
98
+ if (nextUnit === 'day') {
99
+ return clearUpdateTimer;
100
+ }
101
+ var unitDuration = getDurationInSeconds(nextUnit);
102
+ var remainder = nextValueInSeconds % unitDuration;
103
+ var prevInterestingValueInSeconds = nextValueInSeconds - remainder;
104
+ var nextInterestingValueInSeconds = prevInterestingValueInSeconds >= currentValueInSeconds
105
+ ? prevInterestingValueInSeconds - unitDuration
106
+ : prevInterestingValueInSeconds;
107
+ var delayInSeconds = Math.abs(nextInterestingValueInSeconds - currentValueInSeconds);
108
+ if (currentValueInSeconds !== nextInterestingValueInSeconds) {
109
+ updateTimer = setTimeout(function () { return setCurrentValueInSeconds(nextInterestingValueInSeconds); }, delayInSeconds * 1e3);
110
+ }
111
+ return clearUpdateTimer;
112
+ }, [currentValueInSeconds, updateIntervalInSeconds, unit]);
113
+ var currentValue = value || 0;
114
+ var currentUnit = unit;
115
+ if (canIncrement(unit) &&
116
+ typeof currentValueInSeconds === 'number' &&
117
+ updateIntervalInSeconds) {
118
+ currentUnit = selectUnit(currentValueInSeconds);
119
+ var unitDuration = getDurationInSeconds(currentUnit);
120
+ currentValue = Math.round(currentValueInSeconds / unitDuration);
121
+ }
122
+ return (React.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
123
+ };
124
+ FormattedRelativeTime.displayName = 'FormattedRelativeTime';
125
+ FormattedRelativeTime.defaultProps = {
126
+ value: 0,
127
+ unit: 'second',
128
+ };
129
+ export default FormattedRelativeTime;
@@ -0,0 +1,3 @@
1
+ import { IntlShape } from '../types';
2
+ export default function useIntl(): IntlShape;
3
+ //# sourceMappingURL=useIntl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntl.d.ts","sourceRoot":"","sources":["../../../src/components/useIntl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,MAAM,CAAC,OAAO,UAAU,OAAO,IAAI,SAAS,CAI3C"}
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { Context } from './injectIntl';
3
+ import { invariantIntlContext } from '../utils';
4
+ export default function useIntl() {
5
+ var intl = React.useContext(Context);
6
+ invariantIntlContext(intl);
7
+ return intl;
8
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { ResolvedIntlConfig as CoreResolvedIntlConfig, IntlFormatters, Formatters } from '@formatjs/intl';
3
+ import { DEFAULT_INTL_CONFIG } from './utils';
4
+ export declare type IntlConfig = Omit<ResolvedIntlConfig, keyof typeof DEFAULT_INTL_CONFIG> & Partial<typeof DEFAULT_INTL_CONFIG>;
5
+ export interface ResolvedIntlConfig extends CoreResolvedIntlConfig<React.ReactNode> {
6
+ textComponent?: React.ComponentType | keyof React.ReactHTML;
7
+ wrapRichTextChunksInFragment?: boolean;
8
+ }
9
+ export interface IntlShape extends ResolvedIntlConfig, IntlFormatters<React.ReactNode> {
10
+ formatters: Formatters;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,cAAc,EACd,UAAU,EACX,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,mBAAmB,EAAC,MAAM,SAAS,CAAA;AAC3C,oBAAY,UAAU,GAAG,IAAI,CAC3B,kBAAkB,EAClB,MAAM,OAAO,mBAAmB,CACjC,GACC,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAErC,MAAM,WAAW,kBACf,SAAQ,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC;IAC/C,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,KAAK,CAAC,SAAS,CAAA;IAC3D,4BAA4B,CAAC,EAAE,OAAO,CAAA;CACvC;AAED,MAAM,WAAW,SACf,SAAQ,kBAAkB,EACxB,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC;IACjC,UAAU,EAAE,UAAU,CAAA;CACvB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { ResolvedIntlConfig } from './types';
2
+ import * as React from 'react';
3
+ import { FormatXMLElementFn } from 'intl-messageformat';
4
+ export declare function invariantIntlContext(intl?: any): asserts intl;
5
+ export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
6
+ /**
7
+ * Takes a `formatXMLElementFn`, and composes it in function, which passes
8
+ * argument `parts` through, assigning unique key to each part, to prevent
9
+ * "Each child in a list should have a unique "key"" React error.
10
+ * @param formatXMLElementFn
11
+ */
12
+ export declare function assignUniqueKeysToParts(formatXMLElementFn: FormatXMLElementFn<React.ReactNode>): FormatXMLElementFn<React.ReactNode>;
13
+ export declare function shallowEqual<T extends Record<string, unknown> = Record<string, unknown>>(objA?: T, objB?: T): boolean;
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AAKrD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAM7D;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CACpC,kBAAkB,EAChB,uBAAuB,GACvB,SAAS,GACT,UAAU,GACV,UAAU,GACV,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,SAAS,CAIZ,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,GACtD,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAKrC;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,WA6BnB"}
@@ -0,0 +1,43 @@
1
+ import { __assign } from "tslib";
2
+ import * as React from 'react';
3
+ import { invariant } from '@formatjs/ecma402-abstract';
4
+ import { DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG } from '@formatjs/intl';
5
+ export function invariantIntlContext(intl) {
6
+ invariant(intl, '[React Intl] Could not find required `intl` object. ' +
7
+ '<IntlProvider> needs to exist in the component ancestry.');
8
+ }
9
+ export var DEFAULT_INTL_CONFIG = __assign(__assign({}, CORE_DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
10
+ /**
11
+ * Takes a `formatXMLElementFn`, and composes it in function, which passes
12
+ * argument `parts` through, assigning unique key to each part, to prevent
13
+ * "Each child in a list should have a unique "key"" React error.
14
+ * @param formatXMLElementFn
15
+ */
16
+ export function assignUniqueKeysToParts(formatXMLElementFn) {
17
+ return function (parts) {
18
+ // eslint-disable-next-line prefer-rest-params
19
+ return formatXMLElementFn(React.Children.toArray(parts));
20
+ };
21
+ }
22
+ export function shallowEqual(objA, objB) {
23
+ if (objA === objB) {
24
+ return true;
25
+ }
26
+ if (!objA || !objB) {
27
+ return false;
28
+ }
29
+ var aKeys = Object.keys(objA);
30
+ var bKeys = Object.keys(objB);
31
+ var len = aKeys.length;
32
+ if (bKeys.length !== len) {
33
+ return false;
34
+ }
35
+ for (var i = 0; i < len; i++) {
36
+ var key = aKeys[i];
37
+ if (objA[key] !== objB[key] ||
38
+ !Object.prototype.hasOwnProperty.call(objB, key)) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intl",
3
- "version": "6.0.6",
3
+ "version": "6.1.1",
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",
@@ -128,24 +128,24 @@
128
128
  "types": "index.d.ts",
129
129
  "sideEffects": false,
130
130
  "dependencies": {
131
- "@formatjs/ecma402-abstract": "1.11.9",
132
- "@formatjs/icu-messageformat-parser": "2.1.5",
133
- "@formatjs/intl": "2.3.2",
134
- "@formatjs/intl-displaynames": "6.1.0",
135
- "@formatjs/intl-listformat": "7.1.0",
131
+ "@formatjs/ecma402-abstract": "1.12.0",
132
+ "@formatjs/icu-messageformat-parser": "2.1.7",
133
+ "@formatjs/intl": "2.4.1",
134
+ "@formatjs/intl-displaynames": "6.1.3",
135
+ "@formatjs/intl-listformat": "7.1.2",
136
136
  "@types/hoist-non-react-statics": "^3.3.1",
137
137
  "@types/react": "16 || 17 || 18",
138
138
  "hoist-non-react-statics": "^3.3.2",
139
- "intl-messageformat": "10.1.2",
139
+ "intl-messageformat": "10.1.4",
140
140
  "tslib": "2.4.0"
141
141
  },
142
142
  "devDependencies": {
143
- "@formatjs/intl-numberformat": "8.1.0",
144
- "@formatjs/intl-relativetimeformat": "11.1.0"
143
+ "@formatjs/intl-numberformat": "8.1.3",
144
+ "@formatjs/intl-relativetimeformat": "11.1.3"
145
145
  },
146
146
  "peerDependencies": {
147
147
  "react": "^16.6.0 || 17 || 18",
148
- "typescript": "^4.5"
148
+ "typescript": "^4.7"
149
149
  },
150
150
  "peerDependenciesMeta": {
151
151
  "typescript": {