react-intl 6.0.3 → 6.0.6

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 (149) hide show
  1. package/BUILD +130 -0
  2. package/CHANGELOG.md +1384 -0
  3. package/LICENSE.md +0 -0
  4. package/README.md +0 -0
  5. package/example-sandboxes/rescripts/.rescriptsrc.js +28 -0
  6. package/example-sandboxes/rescripts/package-lock.json +18035 -0
  7. package/example-sandboxes/rescripts/package.json +35 -0
  8. package/example-sandboxes/rescripts/public/index.html +42 -0
  9. package/example-sandboxes/rescripts/src/App.tsx +16 -0
  10. package/example-sandboxes/rescripts/src/index.tsx +5 -0
  11. package/example-sandboxes/rescripts/src/react-app-env.d.ts +1 -0
  12. package/example-sandboxes/rescripts/src/styles.css +4 -0
  13. package/example-sandboxes/rescripts/tsconfig.json +20 -0
  14. package/example-sandboxes/strict-locale-type/.env +1 -0
  15. package/example-sandboxes/strict-locale-type/package-lock.json +14595 -0
  16. package/example-sandboxes/strict-locale-type/package.json +35 -0
  17. package/example-sandboxes/strict-locale-type/src/App.tsx +48 -0
  18. package/example-sandboxes/strict-locale-type/src/index.html +28 -0
  19. package/example-sandboxes/strict-locale-type/src/index.tsx +7 -0
  20. package/example-sandboxes/strict-locale-type/src/styles.css +4 -0
  21. package/example-sandboxes/strict-locale-type/tsconfig.json +7 -0
  22. package/example-sandboxes/strict-message-types/.env +1 -0
  23. package/example-sandboxes/strict-message-types/package-lock.json +14596 -0
  24. package/example-sandboxes/strict-message-types/package.json +35 -0
  25. package/example-sandboxes/strict-message-types/src/App.tsx +31 -0
  26. package/example-sandboxes/strict-message-types/src/index.html +28 -0
  27. package/example-sandboxes/strict-message-types/src/index.tsx +7 -0
  28. package/example-sandboxes/strict-message-types/src/styles.css +4 -0
  29. package/example-sandboxes/strict-message-types/tsconfig.json +7 -0
  30. package/examples/BUILD +70 -0
  31. package/examples/Bug2727.tsx +37 -0
  32. package/examples/HandleChange.tsx +48 -0
  33. package/examples/Hooks.tsx +126 -0
  34. package/examples/Injected.tsx +41 -0
  35. package/examples/Messages.tsx +82 -0
  36. package/examples/StaticTypeSafetyAndCodeSplitting/StaticTypeSafetyAndCodeSplitting.tsx +44 -0
  37. package/examples/StaticTypeSafetyAndCodeSplitting/en.json +3 -0
  38. package/examples/StaticTypeSafetyAndCodeSplitting/intlHelpers.tsx +39 -0
  39. package/examples/StaticTypeSafetyAndCodeSplitting/it.json +3 -0
  40. package/examples/TimeZone.tsx +44 -0
  41. package/examples/advanced/Advanced.tsx +68 -0
  42. package/examples/advanced/compiled-lang/en.json +77 -0
  43. package/examples/advanced/compiled-lang/fr.json +77 -0
  44. package/examples/index.html +20 -0
  45. package/examples/index.tsx +44 -0
  46. package/examples/package.json +20 -0
  47. package/index.ts +127 -0
  48. package/jest.config.js +27 -0
  49. package/package.json +12 -8
  50. package/src/components/createFormattedComponent.tsx +123 -0
  51. package/src/components/dateTimeRange.tsx +26 -0
  52. package/src/components/injectIntl.tsx +111 -0
  53. package/src/components/message.tsx +73 -0
  54. package/src/components/plural.tsx +45 -0
  55. package/src/components/provider.tsx +196 -0
  56. package/src/components/relative.tsx +192 -0
  57. package/src/components/useIntl.ts +10 -0
  58. package/src/types.ts +29 -0
  59. package/src/utils.ts +77 -0
  60. package/tests/functional/index.ts +18 -0
  61. package/tests/functional/support/build.ts +16 -0
  62. package/tests/functional/support/format.tsx +112 -0
  63. package/tests/perf/index.tsx +196 -0
  64. package/tests/setup.js +10 -0
  65. package/tests/unit/components/__snapshots__/displayName.tsx.snap +19 -0
  66. package/tests/unit/components/__snapshots__/message.tsx.snap +41 -0
  67. package/tests/unit/components/__snapshots__/relative.tsx.snap +11 -0
  68. package/tests/unit/components/__snapshots__/useIntl.tsx.snap +25 -0
  69. package/tests/unit/components/date.tsx +233 -0
  70. package/tests/unit/components/dateTimeRange.tsx +103 -0
  71. package/tests/unit/components/displayName.tsx +57 -0
  72. package/tests/unit/components/message.tsx +509 -0
  73. package/tests/unit/components/number.tsx +198 -0
  74. package/tests/unit/components/plural.tsx +116 -0
  75. package/tests/unit/components/provider.tsx +215 -0
  76. package/tests/unit/components/relative.tsx +263 -0
  77. package/tests/unit/components/time.tsx +242 -0
  78. package/tests/unit/components/useIntl.tsx +64 -0
  79. package/tests/unit/components/withIntl.tsx +66 -0
  80. package/tests/unit/react-intl.ts +88 -0
  81. package/tests/unit/testUtils.tsx +42 -0
  82. package/tsconfig.json +5 -0
  83. package/index.d.ts +0 -43
  84. package/index.d.ts.map +0 -1
  85. package/index.js +0 -51
  86. package/lib/index.d.ts +0 -43
  87. package/lib/index.d.ts.map +0 -1
  88. package/lib/index.js +0 -26
  89. package/lib/src/components/createFormattedComponent.d.ts +0 -29
  90. package/lib/src/components/createFormattedComponent.d.ts.map +0 -1
  91. package/lib/src/components/createFormattedComponent.js +0 -62
  92. package/lib/src/components/dateTimeRange.d.ts +0 -11
  93. package/lib/src/components/dateTimeRange.d.ts.map +0 -1
  94. package/lib/src/components/dateTimeRange.js +0 -15
  95. package/lib/src/components/injectIntl.d.ts +0 -22
  96. package/lib/src/components/injectIntl.d.ts.map +0 -1
  97. package/lib/src/components/injectIntl.js +0 -29
  98. package/lib/src/components/message.d.ts +0 -12
  99. package/lib/src/components/message.d.ts.map +0 -1
  100. package/lib/src/components/message.js +0 -35
  101. package/lib/src/components/plural.d.ts +0 -15
  102. package/lib/src/components/plural.d.ts.map +0 -1
  103. package/lib/src/components/plural.js +0 -26
  104. package/lib/src/components/provider.d.ts +0 -35
  105. package/lib/src/components/provider.d.ts.map +0 -1
  106. package/lib/src/components/provider.js +0 -108
  107. package/lib/src/components/relative.d.ts +0 -12
  108. package/lib/src/components/relative.d.ts.map +0 -1
  109. package/lib/src/components/relative.js +0 -129
  110. package/lib/src/components/useIntl.d.ts +0 -3
  111. package/lib/src/components/useIntl.d.ts.map +0 -1
  112. package/lib/src/components/useIntl.js +0 -8
  113. package/lib/src/types.d.ts +0 -12
  114. package/lib/src/types.d.ts.map +0 -1
  115. package/lib/src/types.js +0 -1
  116. package/lib/src/utils.d.ts +0 -14
  117. package/lib/src/utils.d.ts.map +0 -1
  118. package/lib/src/utils.js +0 -43
  119. package/react-intl.iife.js +0 -7485
  120. package/src/components/createFormattedComponent.d.ts +0 -29
  121. package/src/components/createFormattedComponent.d.ts.map +0 -1
  122. package/src/components/createFormattedComponent.js +0 -69
  123. package/src/components/dateTimeRange.d.ts +0 -11
  124. package/src/components/dateTimeRange.d.ts.map +0 -1
  125. package/src/components/dateTimeRange.js +0 -17
  126. package/src/components/injectIntl.d.ts +0 -22
  127. package/src/components/injectIntl.d.ts.map +0 -1
  128. package/src/components/injectIntl.js +0 -33
  129. package/src/components/message.d.ts +0 -12
  130. package/src/components/message.d.ts.map +0 -1
  131. package/src/components/message.js +0 -37
  132. package/src/components/plural.d.ts +0 -15
  133. package/src/components/plural.d.ts.map +0 -1
  134. package/src/components/plural.js +0 -29
  135. package/src/components/provider.d.ts +0 -35
  136. package/src/components/provider.d.ts.map +0 -1
  137. package/src/components/provider.js +0 -112
  138. package/src/components/relative.d.ts +0 -12
  139. package/src/components/relative.d.ts.map +0 -1
  140. package/src/components/relative.js +0 -131
  141. package/src/components/useIntl.d.ts +0 -3
  142. package/src/components/useIntl.d.ts.map +0 -1
  143. package/src/components/useIntl.js +0 -12
  144. package/src/types.d.ts +0 -12
  145. package/src/types.d.ts.map +0 -1
  146. package/src/types.js +0 -2
  147. package/src/utils.d.ts +0 -14
  148. package/src/utils.d.ts.map +0 -1
  149. package/src/utils.js +0 -49
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/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"}
package/lib/src/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/react-intl/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"}
package/lib/src/utils.js DELETED
@@ -1,43 +0,0 @@
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
- }