react-intl 6.0.6 → 6.0.8
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 +43 -0
- package/index.d.ts.map +1 -0
- package/index.js +51 -0
- package/lib/index.d.ts +43 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/src/components/createFormattedComponent.d.ts +29 -0
- package/lib/src/components/createFormattedComponent.d.ts.map +1 -0
- package/lib/src/components/createFormattedComponent.js +62 -0
- package/lib/src/components/dateTimeRange.d.ts +11 -0
- package/lib/src/components/dateTimeRange.d.ts.map +1 -0
- package/lib/src/components/dateTimeRange.js +15 -0
- package/lib/src/components/injectIntl.d.ts +22 -0
- package/lib/src/components/injectIntl.d.ts.map +1 -0
- package/lib/src/components/injectIntl.js +29 -0
- package/lib/src/components/message.d.ts +12 -0
- package/lib/src/components/message.d.ts.map +1 -0
- package/lib/src/components/message.js +35 -0
- package/lib/src/components/plural.d.ts +15 -0
- package/lib/src/components/plural.d.ts.map +1 -0
- package/lib/src/components/plural.js +26 -0
- package/lib/src/components/provider.d.ts +35 -0
- package/lib/src/components/provider.d.ts.map +1 -0
- package/lib/src/components/provider.js +112 -0
- package/lib/src/components/relative.d.ts +12 -0
- package/lib/src/components/relative.d.ts.map +1 -0
- package/lib/src/components/relative.js +129 -0
- package/lib/src/components/useIntl.d.ts +3 -0
- package/lib/src/components/useIntl.d.ts.map +1 -0
- package/lib/src/components/useIntl.js +8 -0
- package/lib/src/types.d.ts +12 -0
- package/lib/src/types.d.ts.map +1 -0
- package/lib/src/types.js +1 -0
- package/lib/src/utils.d.ts +14 -0
- package/lib/src/utils.d.ts.map +1 -0
- package/lib/src/utils.js +43 -0
- package/package.json +9 -9
- package/react-intl.iife.js +4688 -0
- package/src/components/createFormattedComponent.d.ts +29 -0
- package/src/components/createFormattedComponent.d.ts.map +1 -0
- package/src/components/createFormattedComponent.js +69 -0
- package/src/components/dateTimeRange.d.ts +11 -0
- package/src/components/dateTimeRange.d.ts.map +1 -0
- package/src/components/dateTimeRange.js +17 -0
- package/src/components/injectIntl.d.ts +22 -0
- package/src/components/injectIntl.d.ts.map +1 -0
- package/src/components/injectIntl.js +33 -0
- package/src/components/message.d.ts +12 -0
- package/src/components/message.d.ts.map +1 -0
- package/src/components/message.js +37 -0
- package/src/components/plural.d.ts +15 -0
- package/src/components/plural.d.ts.map +1 -0
- package/src/components/plural.js +29 -0
- package/src/components/provider.d.ts +35 -0
- package/src/components/provider.d.ts.map +1 -0
- package/src/components/provider.js +116 -0
- package/src/components/relative.d.ts +12 -0
- package/src/components/relative.d.ts.map +1 -0
- package/src/components/relative.js +131 -0
- package/src/components/useIntl.d.ts +3 -0
- package/src/components/useIntl.d.ts.map +1 -0
- package/src/components/useIntl.js +12 -0
- package/src/types.d.ts +12 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +2 -0
- package/src/utils.d.ts +14 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +49 -0
- package/BUILD +0 -130
- package/CHANGELOG.md +0 -1384
- package/example-sandboxes/rescripts/.rescriptsrc.js +0 -28
- package/example-sandboxes/rescripts/package-lock.json +0 -18035
- package/example-sandboxes/rescripts/package.json +0 -35
- package/example-sandboxes/rescripts/public/index.html +0 -42
- package/example-sandboxes/rescripts/src/App.tsx +0 -16
- package/example-sandboxes/rescripts/src/index.tsx +0 -5
- package/example-sandboxes/rescripts/src/react-app-env.d.ts +0 -1
- package/example-sandboxes/rescripts/src/styles.css +0 -4
- package/example-sandboxes/rescripts/tsconfig.json +0 -20
- package/example-sandboxes/strict-locale-type/.env +0 -1
- package/example-sandboxes/strict-locale-type/package-lock.json +0 -14595
- package/example-sandboxes/strict-locale-type/package.json +0 -35
- package/example-sandboxes/strict-locale-type/src/App.tsx +0 -48
- package/example-sandboxes/strict-locale-type/src/index.html +0 -28
- package/example-sandboxes/strict-locale-type/src/index.tsx +0 -7
- package/example-sandboxes/strict-locale-type/src/styles.css +0 -4
- package/example-sandboxes/strict-locale-type/tsconfig.json +0 -7
- package/example-sandboxes/strict-message-types/.env +0 -1
- package/example-sandboxes/strict-message-types/package-lock.json +0 -14596
- package/example-sandboxes/strict-message-types/package.json +0 -35
- package/example-sandboxes/strict-message-types/src/App.tsx +0 -31
- package/example-sandboxes/strict-message-types/src/index.html +0 -28
- package/example-sandboxes/strict-message-types/src/index.tsx +0 -7
- package/example-sandboxes/strict-message-types/src/styles.css +0 -4
- package/example-sandboxes/strict-message-types/tsconfig.json +0 -7
- package/examples/BUILD +0 -70
- package/examples/Bug2727.tsx +0 -37
- package/examples/HandleChange.tsx +0 -48
- package/examples/Hooks.tsx +0 -126
- package/examples/Injected.tsx +0 -41
- package/examples/Messages.tsx +0 -82
- package/examples/StaticTypeSafetyAndCodeSplitting/StaticTypeSafetyAndCodeSplitting.tsx +0 -44
- package/examples/StaticTypeSafetyAndCodeSplitting/en.json +0 -3
- package/examples/StaticTypeSafetyAndCodeSplitting/intlHelpers.tsx +0 -39
- package/examples/StaticTypeSafetyAndCodeSplitting/it.json +0 -3
- package/examples/TimeZone.tsx +0 -44
- package/examples/advanced/Advanced.tsx +0 -68
- package/examples/advanced/compiled-lang/en.json +0 -77
- package/examples/advanced/compiled-lang/fr.json +0 -77
- package/examples/index.html +0 -20
- package/examples/index.tsx +0 -44
- package/examples/package.json +0 -20
- package/index.ts +0 -127
- package/jest.config.js +0 -27
- package/src/components/createFormattedComponent.tsx +0 -123
- package/src/components/dateTimeRange.tsx +0 -26
- package/src/components/injectIntl.tsx +0 -111
- package/src/components/message.tsx +0 -73
- package/src/components/plural.tsx +0 -45
- package/src/components/provider.tsx +0 -196
- package/src/components/relative.tsx +0 -192
- package/src/components/useIntl.ts +0 -10
- package/src/types.ts +0 -29
- package/src/utils.ts +0 -77
- package/tests/functional/index.ts +0 -18
- package/tests/functional/support/build.ts +0 -16
- package/tests/functional/support/format.tsx +0 -112
- package/tests/perf/index.tsx +0 -196
- package/tests/setup.js +0 -10
- package/tests/unit/components/__snapshots__/displayName.tsx.snap +0 -19
- package/tests/unit/components/__snapshots__/message.tsx.snap +0 -41
- package/tests/unit/components/__snapshots__/relative.tsx.snap +0 -11
- package/tests/unit/components/__snapshots__/useIntl.tsx.snap +0 -25
- package/tests/unit/components/date.tsx +0 -233
- package/tests/unit/components/dateTimeRange.tsx +0 -103
- package/tests/unit/components/displayName.tsx +0 -57
- package/tests/unit/components/message.tsx +0 -509
- package/tests/unit/components/number.tsx +0 -198
- package/tests/unit/components/plural.tsx +0 -116
- package/tests/unit/components/provider.tsx +0 -215
- package/tests/unit/components/relative.tsx +0 -263
- package/tests/unit/components/time.tsx +0 -242
- package/tests/unit/components/useIntl.tsx +0 -64
- package/tests/unit/components/withIntl.tsx +0 -66
- package/tests/unit/react-intl.ts +0 -88
- package/tests/unit/testUtils.tsx +0 -42
- package/tsconfig.json +0 -5
package/src/types.d.ts
ADDED
|
@@ -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":["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/src/types.js
ADDED
package/src/utils.d.ts
ADDED
|
@@ -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":["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/src/utils.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shallowEqual = exports.assignUniqueKeysToParts = exports.DEFAULT_INTL_CONFIG = exports.invariantIntlContext = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var React = tslib_1.__importStar(require("react"));
|
|
6
|
+
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
7
|
+
var intl_1 = require("@formatjs/intl");
|
|
8
|
+
function invariantIntlContext(intl) {
|
|
9
|
+
(0, ecma402_abstract_1.invariant)(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
10
|
+
'<IntlProvider> needs to exist in the component ancestry.');
|
|
11
|
+
}
|
|
12
|
+
exports.invariantIntlContext = invariantIntlContext;
|
|
13
|
+
exports.DEFAULT_INTL_CONFIG = tslib_1.__assign(tslib_1.__assign({}, intl_1.DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|
|
14
|
+
/**
|
|
15
|
+
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
16
|
+
* argument `parts` through, assigning unique key to each part, to prevent
|
|
17
|
+
* "Each child in a list should have a unique "key"" React error.
|
|
18
|
+
* @param formatXMLElementFn
|
|
19
|
+
*/
|
|
20
|
+
function assignUniqueKeysToParts(formatXMLElementFn) {
|
|
21
|
+
return function (parts) {
|
|
22
|
+
// eslint-disable-next-line prefer-rest-params
|
|
23
|
+
return formatXMLElementFn(React.Children.toArray(parts));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.assignUniqueKeysToParts = assignUniqueKeysToParts;
|
|
27
|
+
function shallowEqual(objA, objB) {
|
|
28
|
+
if (objA === objB) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (!objA || !objB) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
var aKeys = Object.keys(objA);
|
|
35
|
+
var bKeys = Object.keys(objB);
|
|
36
|
+
var len = aKeys.length;
|
|
37
|
+
if (bKeys.length !== len) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
for (var i = 0; i < len; i++) {
|
|
41
|
+
var key = aKeys[i];
|
|
42
|
+
if (objA[key] !== objB[key] ||
|
|
43
|
+
!Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
exports.shallowEqual = shallowEqual;
|
package/BUILD
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
|
|
2
|
-
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
|
|
3
|
-
load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
|
|
4
|
-
load("@npm//:defs.bzl", "npm_link_all_packages")
|
|
5
|
-
load("//tools:index.bzl", "check_format", "package_json_test", "ts_compile")
|
|
6
|
-
load("//tools:jest.bzl", "jest_test")
|
|
7
|
-
|
|
8
|
-
npm_link_all_packages(name = "node_modules")
|
|
9
|
-
|
|
10
|
-
PACKAGE_NAME = "react-intl"
|
|
11
|
-
|
|
12
|
-
npm_package(
|
|
13
|
-
name = PACKAGE_NAME,
|
|
14
|
-
srcs = [
|
|
15
|
-
"LICENSE.md",
|
|
16
|
-
"README.md",
|
|
17
|
-
"package.json",
|
|
18
|
-
"%s.iife.js" % PACKAGE_NAME,
|
|
19
|
-
":dist",
|
|
20
|
-
":dist-esm",
|
|
21
|
-
],
|
|
22
|
-
package = PACKAGE_NAME,
|
|
23
|
-
visibility = ["//visibility:public"],
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
SRCS = glob(["src/**/*.ts*"]) + ["index.ts"]
|
|
27
|
-
|
|
28
|
-
SRC_DEPS = [
|
|
29
|
-
":node_modules/@formatjs/ecma402-abstract",
|
|
30
|
-
":node_modules/@formatjs/icu-messageformat-parser",
|
|
31
|
-
":node_modules/@formatjs/intl-displaynames",
|
|
32
|
-
":node_modules/@formatjs/intl-listformat",
|
|
33
|
-
":node_modules/@formatjs/intl",
|
|
34
|
-
":node_modules/intl-messageformat",
|
|
35
|
-
"//:node_modules/@types/hoist-non-react-statics",
|
|
36
|
-
"//:node_modules/@types/react",
|
|
37
|
-
"//:node_modules/hoist-non-react-statics",
|
|
38
|
-
"//:node_modules/react",
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
TESTS = glob([
|
|
42
|
-
"tests/unit/**/*.ts*",
|
|
43
|
-
"tests/unit/**/*.snap",
|
|
44
|
-
])
|
|
45
|
-
|
|
46
|
-
TEST_DEPS = SRC_DEPS + [
|
|
47
|
-
"//:node_modules/@testing-library/jest-dom",
|
|
48
|
-
"//:node_modules/@testing-library/react",
|
|
49
|
-
"//:node_modules/cjs-module-lexer",
|
|
50
|
-
"//:node_modules/react-dom",
|
|
51
|
-
"//:node_modules/typescript",
|
|
52
|
-
":node_modules/@formatjs/intl-numberformat",
|
|
53
|
-
":node_modules/@formatjs/intl-relativetimeformat",
|
|
54
|
-
"//:node_modules/@types/node",
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
ts_compile(
|
|
58
|
-
name = "dist",
|
|
59
|
-
srcs = SRCS,
|
|
60
|
-
package = PACKAGE_NAME,
|
|
61
|
-
skip_esm = False,
|
|
62
|
-
deps = SRC_DEPS,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
esbuild(
|
|
66
|
-
name = "%s.esbuild.iife" % PACKAGE_NAME,
|
|
67
|
-
config = {
|
|
68
|
-
"globalName": "ReactIntl",
|
|
69
|
-
},
|
|
70
|
-
entry_point = "lib/index.js",
|
|
71
|
-
external = ["react"],
|
|
72
|
-
target = "es6",
|
|
73
|
-
# TODO: fix this and set it back to es5
|
|
74
|
-
deps = [
|
|
75
|
-
":dist-esm",
|
|
76
|
-
] + SRC_DEPS,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
genrule(
|
|
80
|
-
name = "external-rename",
|
|
81
|
-
srcs = [":%s.esbuild.iife.js" % PACKAGE_NAME],
|
|
82
|
-
outs = ["%s.iife.js" % PACKAGE_NAME],
|
|
83
|
-
cmd = "cat $< | sed -E 's/__require\\(\"react\"\\)/window.React/g' > $@",
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
jest_test(
|
|
87
|
-
name = "unit",
|
|
88
|
-
srcs = SRCS + TESTS + [
|
|
89
|
-
"tests/setup.js",
|
|
90
|
-
],
|
|
91
|
-
jest_config = "jest.config.js",
|
|
92
|
-
# TODO: fix
|
|
93
|
-
tags = ["manual"],
|
|
94
|
-
deps = TEST_DEPS,
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
jest_test(
|
|
98
|
-
name = "functional",
|
|
99
|
-
srcs = glob(["tests/functional/**/*.ts*"]) + [
|
|
100
|
-
"tests/setup.js",
|
|
101
|
-
"package.json",
|
|
102
|
-
],
|
|
103
|
-
jest_config = "jest.config.js",
|
|
104
|
-
deps = TEST_DEPS + [":dist"],
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
write_source_files(
|
|
108
|
-
name = "tsconfig_json",
|
|
109
|
-
files = {"tsconfig.json": "//tools:tsconfig.golden.json"},
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
check_format(
|
|
113
|
-
name = "prettier",
|
|
114
|
-
srcs = glob(
|
|
115
|
-
[
|
|
116
|
-
"**/*",
|
|
117
|
-
],
|
|
118
|
-
exclude = [
|
|
119
|
-
"CHANGELOG.md",
|
|
120
|
-
"tests/unit/components/__snapshots__/*",
|
|
121
|
-
"**/.env",
|
|
122
|
-
"**/.gitignore",
|
|
123
|
-
],
|
|
124
|
-
),
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
package_json_test(
|
|
128
|
-
name = "package_json_test",
|
|
129
|
-
deps = SRC_DEPS,
|
|
130
|
-
)
|