react-intl 8.1.4 → 8.2.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 +2 -2
- package/index.js +3 -2
- package/package.json +7 -9
- package/react-intl.iife.js +47 -358
- package/server.d.ts +10 -0
- package/server.js +10 -0
- package/src/components/context.d.ts +5 -0
- package/src/components/context.js +5 -0
- package/src/components/provider.d.ts +3 -27
- package/src/components/provider.js +27 -24
- package/src/components/useIntl.js +1 -1
- package/src/components/injectIntl.d.ts +0 -50
- package/src/components/injectIntl.js +0 -42
package/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { type NumberFormatOptions } from "@formatjs/ecma402-abstract";
|
|
|
2
2
|
import { type CustomFormatConfig, type FormatDateOptions, type FormatTimeOptions, type MessageDescriptor } from "@formatjs/intl";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { createIntl } from "./src/components/createIntl.js";
|
|
5
|
+
import { Context as IntlContext, Provider as RawIntlProvider } from "./src/components/context.js";
|
|
5
6
|
import FormattedDateTimeRange from "./src/components/dateTimeRange.js";
|
|
6
|
-
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider, type WithIntlProps, type WrappedComponentProps } from "./src/components/injectIntl.js";
|
|
7
7
|
import FormattedMessage from "./src/components/message.js";
|
|
8
8
|
import FormattedPlural from "./src/components/plural.js";
|
|
9
9
|
import IntlProvider from "./src/components/provider.js";
|
|
@@ -12,7 +12,7 @@ import useIntl from "./src/components/useIntl.js";
|
|
|
12
12
|
import { type IntlShape } from "./src/types.js";
|
|
13
13
|
export { createIntlCache, type CustomFormatConfig, type CustomFormats, type FormatDateOptions, type FormatDisplayNameOptions, type FormatListOptions, type FormatNumberOptions, type FormatPluralOptions, type FormatRelativeTimeOptions, type Formatters, type IntlCache, type IntlFormatters, InvalidConfigError, type MessageDescriptor, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError } from "@formatjs/intl";
|
|
14
14
|
export { type IntlConfig, type IntlShape, type ResolvedIntlConfig } from "./src/types.js";
|
|
15
|
-
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime,
|
|
15
|
+
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, useIntl };
|
|
16
16
|
export declare function defineMessages<
|
|
17
17
|
K extends keyof any,
|
|
18
18
|
T = MessageDescriptor,
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright 2015, Yahoo Inc.
|
|
3
4
|
* Copyrights licensed under the New BSD License.
|
|
@@ -8,8 +9,8 @@ import "@formatjs/intl";
|
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { createFormattedComponent, createFormattedDateTimePartsComponent } from "./src/components/createFormattedComponent.js";
|
|
10
11
|
import { createIntl } from "./src/components/createIntl.js";
|
|
12
|
+
import { Context as IntlContext, Provider as RawIntlProvider } from "./src/components/context.js";
|
|
11
13
|
import FormattedDateTimeRange from "./src/components/dateTimeRange.js";
|
|
12
|
-
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider } from "./src/components/injectIntl.js";
|
|
13
14
|
import FormattedMessage from "./src/components/message.js";
|
|
14
15
|
import FormattedPlural from "./src/components/plural.js";
|
|
15
16
|
import IntlProvider from "./src/components/provider.js";
|
|
@@ -17,7 +18,7 @@ import FormattedRelativeTime from "./src/components/relative.js";
|
|
|
17
18
|
import useIntl from "./src/components/useIntl.js";
|
|
18
19
|
import "./src/types.js";
|
|
19
20
|
export { createIntlCache, InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError } from "@formatjs/intl";
|
|
20
|
-
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime,
|
|
21
|
+
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, useIntl };
|
|
21
22
|
export function defineMessages(msgs) {
|
|
22
23
|
return msgs;
|
|
23
24
|
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intl",
|
|
3
3
|
"description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.2.0",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "Eric Ferraiuolo <edf@ericf.me>",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"types": "index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
|
-
".": "./index.js"
|
|
11
|
+
".": "./index.js",
|
|
12
|
+
"./server": "./server.js"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"@formatjs/intl": "4.1.2",
|
|
19
|
-
"@formatjs/icu-messageformat-parser": "3.5.1",
|
|
20
|
-
"intl-messageformat": "11.1.2"
|
|
15
|
+
"@formatjs/ecma402-abstract": "3.1.2",
|
|
16
|
+
"@formatjs/intl": "4.1.3",
|
|
17
|
+
"@formatjs/icu-messageformat-parser": "3.5.2",
|
|
18
|
+
"intl-messageformat": "11.1.3"
|
|
21
19
|
},
|
|
22
20
|
"peerDependencies": {
|
|
23
21
|
"@types/react": "19",
|
package/react-intl.iife.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
var ReactIntl = (() => {
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -41,9 +42,6 @@ var ReactIntl = (() => {
|
|
|
41
42
|
}
|
|
42
43
|
return target;
|
|
43
44
|
};
|
|
44
|
-
var __commonJS = (cb, mod2) => function __require2() {
|
|
45
|
-
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
46
|
-
};
|
|
47
45
|
var __export = (target, all) => {
|
|
48
46
|
for (var name in all)
|
|
49
47
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -70,261 +68,6 @@ var ReactIntl = (() => {
|
|
|
70
68
|
return value;
|
|
71
69
|
};
|
|
72
70
|
|
|
73
|
-
// node_modules/.aspect_rules_js/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js
|
|
74
|
-
var require_react_is_development = __commonJS({
|
|
75
|
-
"node_modules/.aspect_rules_js/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js"(exports) {
|
|
76
|
-
"use strict";
|
|
77
|
-
if (true) {
|
|
78
|
-
(function() {
|
|
79
|
-
"use strict";
|
|
80
|
-
var hasSymbol = typeof Symbol === "function" && Symbol.for;
|
|
81
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
|
|
82
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
|
|
83
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
|
|
84
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
|
|
85
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
|
|
86
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
|
|
87
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
|
|
88
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
|
|
89
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
|
|
90
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
|
|
91
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
|
|
92
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
|
|
93
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
|
|
94
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
|
|
95
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
|
|
96
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
|
|
97
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
|
|
98
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
|
|
99
|
-
function isValidElementType(type) {
|
|
100
|
-
return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
101
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
102
|
-
}
|
|
103
|
-
function typeOf(object) {
|
|
104
|
-
if (typeof object === "object" && object !== null) {
|
|
105
|
-
var $$typeof = object.$$typeof;
|
|
106
|
-
switch ($$typeof) {
|
|
107
|
-
case REACT_ELEMENT_TYPE:
|
|
108
|
-
var type = object.type;
|
|
109
|
-
switch (type) {
|
|
110
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
111
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
112
|
-
case REACT_FRAGMENT_TYPE:
|
|
113
|
-
case REACT_PROFILER_TYPE:
|
|
114
|
-
case REACT_STRICT_MODE_TYPE:
|
|
115
|
-
case REACT_SUSPENSE_TYPE:
|
|
116
|
-
return type;
|
|
117
|
-
default:
|
|
118
|
-
var $$typeofType = type && type.$$typeof;
|
|
119
|
-
switch ($$typeofType) {
|
|
120
|
-
case REACT_CONTEXT_TYPE:
|
|
121
|
-
case REACT_FORWARD_REF_TYPE:
|
|
122
|
-
case REACT_LAZY_TYPE:
|
|
123
|
-
case REACT_MEMO_TYPE:
|
|
124
|
-
case REACT_PROVIDER_TYPE:
|
|
125
|
-
return $$typeofType;
|
|
126
|
-
default:
|
|
127
|
-
return $$typeof;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
case REACT_PORTAL_TYPE:
|
|
131
|
-
return $$typeof;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return void 0;
|
|
135
|
-
}
|
|
136
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
137
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
138
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
139
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
140
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
141
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
142
|
-
var Fragment6 = REACT_FRAGMENT_TYPE;
|
|
143
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
144
|
-
var Memo = REACT_MEMO_TYPE;
|
|
145
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
146
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
147
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
148
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
149
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
|
150
|
-
function isAsyncMode(object) {
|
|
151
|
-
{
|
|
152
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
153
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
|
154
|
-
console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
158
|
-
}
|
|
159
|
-
function isConcurrentMode(object) {
|
|
160
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
161
|
-
}
|
|
162
|
-
function isContextConsumer(object) {
|
|
163
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
164
|
-
}
|
|
165
|
-
function isContextProvider(object) {
|
|
166
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
167
|
-
}
|
|
168
|
-
function isElement(object) {
|
|
169
|
-
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
170
|
-
}
|
|
171
|
-
function isForwardRef(object) {
|
|
172
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
173
|
-
}
|
|
174
|
-
function isFragment(object) {
|
|
175
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
176
|
-
}
|
|
177
|
-
function isLazy(object) {
|
|
178
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
179
|
-
}
|
|
180
|
-
function isMemo(object) {
|
|
181
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
182
|
-
}
|
|
183
|
-
function isPortal(object) {
|
|
184
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
185
|
-
}
|
|
186
|
-
function isProfiler(object) {
|
|
187
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
188
|
-
}
|
|
189
|
-
function isStrictMode(object) {
|
|
190
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
191
|
-
}
|
|
192
|
-
function isSuspense(object) {
|
|
193
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
194
|
-
}
|
|
195
|
-
exports.AsyncMode = AsyncMode;
|
|
196
|
-
exports.ConcurrentMode = ConcurrentMode;
|
|
197
|
-
exports.ContextConsumer = ContextConsumer;
|
|
198
|
-
exports.ContextProvider = ContextProvider;
|
|
199
|
-
exports.Element = Element;
|
|
200
|
-
exports.ForwardRef = ForwardRef;
|
|
201
|
-
exports.Fragment = Fragment6;
|
|
202
|
-
exports.Lazy = Lazy;
|
|
203
|
-
exports.Memo = Memo;
|
|
204
|
-
exports.Portal = Portal;
|
|
205
|
-
exports.Profiler = Profiler;
|
|
206
|
-
exports.StrictMode = StrictMode;
|
|
207
|
-
exports.Suspense = Suspense;
|
|
208
|
-
exports.isAsyncMode = isAsyncMode;
|
|
209
|
-
exports.isConcurrentMode = isConcurrentMode;
|
|
210
|
-
exports.isContextConsumer = isContextConsumer;
|
|
211
|
-
exports.isContextProvider = isContextProvider;
|
|
212
|
-
exports.isElement = isElement;
|
|
213
|
-
exports.isForwardRef = isForwardRef;
|
|
214
|
-
exports.isFragment = isFragment;
|
|
215
|
-
exports.isLazy = isLazy;
|
|
216
|
-
exports.isMemo = isMemo;
|
|
217
|
-
exports.isPortal = isPortal;
|
|
218
|
-
exports.isProfiler = isProfiler;
|
|
219
|
-
exports.isStrictMode = isStrictMode;
|
|
220
|
-
exports.isSuspense = isSuspense;
|
|
221
|
-
exports.isValidElementType = isValidElementType;
|
|
222
|
-
exports.typeOf = typeOf;
|
|
223
|
-
})();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// node_modules/.aspect_rules_js/react-is@16.13.1/node_modules/react-is/index.js
|
|
229
|
-
var require_react_is = __commonJS({
|
|
230
|
-
"node_modules/.aspect_rules_js/react-is@16.13.1/node_modules/react-is/index.js"(exports, module) {
|
|
231
|
-
"use strict";
|
|
232
|
-
if (false) {
|
|
233
|
-
module.exports = null;
|
|
234
|
-
} else {
|
|
235
|
-
module.exports = require_react_is_development();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// node_modules/.aspect_rules_js/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js
|
|
241
|
-
var require_hoist_non_react_statics_cjs = __commonJS({
|
|
242
|
-
"node_modules/.aspect_rules_js/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"(exports, module) {
|
|
243
|
-
"use strict";
|
|
244
|
-
var reactIs = require_react_is();
|
|
245
|
-
var REACT_STATICS = {
|
|
246
|
-
childContextTypes: true,
|
|
247
|
-
contextType: true,
|
|
248
|
-
contextTypes: true,
|
|
249
|
-
defaultProps: true,
|
|
250
|
-
displayName: true,
|
|
251
|
-
getDefaultProps: true,
|
|
252
|
-
getDerivedStateFromError: true,
|
|
253
|
-
getDerivedStateFromProps: true,
|
|
254
|
-
mixins: true,
|
|
255
|
-
propTypes: true,
|
|
256
|
-
type: true
|
|
257
|
-
};
|
|
258
|
-
var KNOWN_STATICS = {
|
|
259
|
-
name: true,
|
|
260
|
-
length: true,
|
|
261
|
-
prototype: true,
|
|
262
|
-
caller: true,
|
|
263
|
-
callee: true,
|
|
264
|
-
arguments: true,
|
|
265
|
-
arity: true
|
|
266
|
-
};
|
|
267
|
-
var FORWARD_REF_STATICS = {
|
|
268
|
-
"$$typeof": true,
|
|
269
|
-
render: true,
|
|
270
|
-
defaultProps: true,
|
|
271
|
-
displayName: true,
|
|
272
|
-
propTypes: true
|
|
273
|
-
};
|
|
274
|
-
var MEMO_STATICS = {
|
|
275
|
-
"$$typeof": true,
|
|
276
|
-
compare: true,
|
|
277
|
-
defaultProps: true,
|
|
278
|
-
displayName: true,
|
|
279
|
-
propTypes: true,
|
|
280
|
-
type: true
|
|
281
|
-
};
|
|
282
|
-
var TYPE_STATICS = {};
|
|
283
|
-
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
|
284
|
-
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
|
285
|
-
function getStatics(component) {
|
|
286
|
-
if (reactIs.isMemo(component)) {
|
|
287
|
-
return MEMO_STATICS;
|
|
288
|
-
}
|
|
289
|
-
return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
|
|
290
|
-
}
|
|
291
|
-
var defineProperty2 = Object.defineProperty;
|
|
292
|
-
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
293
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
294
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
295
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
|
296
|
-
var objectPrototype = Object.prototype;
|
|
297
|
-
function hoistNonReactStatics2(targetComponent, sourceComponent, blacklist) {
|
|
298
|
-
if (typeof sourceComponent !== "string") {
|
|
299
|
-
if (objectPrototype) {
|
|
300
|
-
var inheritedComponent = getPrototypeOf(sourceComponent);
|
|
301
|
-
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
302
|
-
hoistNonReactStatics2(targetComponent, inheritedComponent, blacklist);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
var keys = getOwnPropertyNames(sourceComponent);
|
|
306
|
-
if (getOwnPropertySymbols) {
|
|
307
|
-
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
308
|
-
}
|
|
309
|
-
var targetStatics = getStatics(targetComponent);
|
|
310
|
-
var sourceStatics = getStatics(sourceComponent);
|
|
311
|
-
for (var i = 0; i < keys.length; ++i) {
|
|
312
|
-
var key = keys[i];
|
|
313
|
-
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
314
|
-
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
315
|
-
try {
|
|
316
|
-
defineProperty2(targetComponent, key, descriptor);
|
|
317
|
-
} catch (e) {
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return targetComponent;
|
|
323
|
-
}
|
|
324
|
-
module.exports = hoistNonReactStatics2;
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
|
|
328
71
|
// packages/react-intl/index.ts
|
|
329
72
|
var react_intl_exports = {};
|
|
330
73
|
__export(react_intl_exports, {
|
|
@@ -341,8 +84,8 @@ var ReactIntl = (() => {
|
|
|
341
84
|
FormattedRelativeTime: () => relative_default,
|
|
342
85
|
FormattedTime: () => FormattedTime,
|
|
343
86
|
FormattedTimeParts: () => FormattedTimeParts,
|
|
344
|
-
IntlContext: () =>
|
|
345
|
-
IntlProvider: () =>
|
|
87
|
+
IntlContext: () => IntlContext,
|
|
88
|
+
IntlProvider: () => provider_default,
|
|
346
89
|
InvalidConfigError: () => InvalidConfigError,
|
|
347
90
|
MessageFormatError: () => MessageFormatError,
|
|
348
91
|
MissingDataError: () => MissingDataError,
|
|
@@ -355,7 +98,6 @@ var ReactIntl = (() => {
|
|
|
355
98
|
createIntlCache: () => createIntlCache,
|
|
356
99
|
defineMessage: () => defineMessage,
|
|
357
100
|
defineMessages: () => defineMessages,
|
|
358
|
-
injectIntl: () => injectIntl,
|
|
359
101
|
useIntl: () => useIntl
|
|
360
102
|
});
|
|
361
103
|
|
|
@@ -2103,10 +1845,10 @@ var ReactIntl = (() => {
|
|
|
2103
1845
|
};
|
|
2104
1846
|
var IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
|
|
2105
1847
|
function matchIdentifierAtIndex(s, index) {
|
|
2106
|
-
var
|
|
1848
|
+
var _a;
|
|
2107
1849
|
IDENTIFIER_PREFIX_RE.lastIndex = index;
|
|
2108
1850
|
const match = IDENTIFIER_PREFIX_RE.exec(s);
|
|
2109
|
-
return (
|
|
1851
|
+
return (_a = match[1]) != null ? _a : "";
|
|
2110
1852
|
}
|
|
2111
1853
|
var Parser = class {
|
|
2112
1854
|
constructor(message, options = {}) {
|
|
@@ -2414,7 +2156,7 @@ var ReactIntl = (() => {
|
|
|
2414
2156
|
};
|
|
2415
2157
|
}
|
|
2416
2158
|
parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
|
2417
|
-
var
|
|
2159
|
+
var _a;
|
|
2418
2160
|
let typeStartPosition = this.clonePosition();
|
|
2419
2161
|
let argType = this.parseIdentifierIfPossible().value;
|
|
2420
2162
|
let typeEndPosition = this.clonePosition();
|
|
@@ -2495,7 +2237,7 @@ var ReactIntl = (() => {
|
|
|
2495
2237
|
type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
|
|
2496
2238
|
value,
|
|
2497
2239
|
location,
|
|
2498
|
-
style: (
|
|
2240
|
+
style: (_a = styleAndLocation == null ? void 0 : styleAndLocation.style) != null ? _a : null
|
|
2499
2241
|
},
|
|
2500
2242
|
err: null
|
|
2501
2243
|
};
|
|
@@ -8608,9 +8350,9 @@ var ReactIntl = (() => {
|
|
|
8608
8350
|
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
|
|
8609
8351
|
var PROCESSED_DATA;
|
|
8610
8352
|
function processData() {
|
|
8611
|
-
var
|
|
8353
|
+
var _a, _b;
|
|
8612
8354
|
if (!PROCESSED_DATA) {
|
|
8613
|
-
const paradigmLocales = (_b = (
|
|
8355
|
+
const paradigmLocales = (_b = (_a = data.supplemental.languageMatching["written-new"][0]) == null ? void 0 : _a.paradigmLocales) == null ? void 0 : _b._locales.split(" ");
|
|
8614
8356
|
const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
|
|
8615
8357
|
const data2 = data.supplemental.languageMatching["written-new"].slice(5);
|
|
8616
8358
|
const matches = data2.map((d) => {
|
|
@@ -9001,8 +8743,8 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
|
9001
8743
|
});
|
|
9002
8744
|
__publicField(this, "formatToParts", (values) => formatToParts2(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message));
|
|
9003
8745
|
__publicField(this, "resolvedOptions", () => {
|
|
9004
|
-
var
|
|
9005
|
-
return { locale: ((
|
|
8746
|
+
var _a;
|
|
8747
|
+
return { locale: ((_a = this.resolvedLocale) == null ? void 0 : _a.toString()) || Intl.NumberFormat.supportedLocalesOf(this.locales)[0] };
|
|
9006
8748
|
});
|
|
9007
8749
|
__publicField(this, "getAst", () => this.ast);
|
|
9008
8750
|
this.locales = locales;
|
|
@@ -9166,8 +8908,8 @@ Description: ${descriptor == null ? void 0 : descriptor.description}
|
|
|
9166
8908
|
var MissingTranslationError = class extends IntlError {
|
|
9167
8909
|
constructor(descriptor, locale) {
|
|
9168
8910
|
super(IntlErrorCode.MISSING_TRANSLATION, `Missing message: "${descriptor.id}" for locale "${locale}", using ${descriptor.defaultMessage ? `default message (${typeof descriptor.defaultMessage === "string" ? descriptor.defaultMessage : descriptor.defaultMessage.map((e) => {
|
|
9169
|
-
var
|
|
9170
|
-
return (
|
|
8911
|
+
var _a;
|
|
8912
|
+
return (_a = e.value) != null ? _a : JSON.stringify(e);
|
|
9171
8913
|
}).join()})` : "id"} as fallback.`);
|
|
9172
8914
|
__publicField(this, "descriptor");
|
|
9173
8915
|
this.descriptor = descriptor;
|
|
@@ -9710,53 +9452,16 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9710
9452
|
return true;
|
|
9711
9453
|
}
|
|
9712
9454
|
|
|
9713
|
-
// packages/react-intl/src/components/
|
|
9714
|
-
var hoistNonReactStaticsNs = __toESM(require_hoist_non_react_statics_cjs());
|
|
9455
|
+
// packages/react-intl/src/components/context.ts
|
|
9715
9456
|
var React2 = __toESM(window.React);
|
|
9716
|
-
var
|
|
9717
|
-
var hoistNonReactStatics = (_a = hoistNonReactStaticsNs.default) != null ? _a : hoistNonReactStaticsNs;
|
|
9718
|
-
function getDisplayName(Component) {
|
|
9719
|
-
return Component.displayName || Component.name || "Component";
|
|
9720
|
-
}
|
|
9721
|
-
var IntlContext = typeof window !== "undefined" && !window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__ ? window.__REACT_INTL_CONTEXT__ || (window.__REACT_INTL_CONTEXT__ = React2.createContext(
|
|
9457
|
+
var IntlContext = React2.createContext(
|
|
9722
9458
|
null
|
|
9723
|
-
)
|
|
9724
|
-
var
|
|
9725
|
-
var Provider = IntlProvider;
|
|
9726
|
-
var Context = IntlContext;
|
|
9727
|
-
function injectIntl(WrappedComponent, options) {
|
|
9728
|
-
const {
|
|
9729
|
-
intlPropName = "intl",
|
|
9730
|
-
forwardRef: forwardRef2 = false,
|
|
9731
|
-
enforceContext = true
|
|
9732
|
-
} = options || {};
|
|
9733
|
-
const WithIntl = (props) => React2.createElement(IntlConsumer, null, (intl) => {
|
|
9734
|
-
if (enforceContext) {
|
|
9735
|
-
invariantIntlContext(intl);
|
|
9736
|
-
}
|
|
9737
|
-
const intlProp = { [intlPropName]: intl };
|
|
9738
|
-
return React2.createElement(
|
|
9739
|
-
WrappedComponent,
|
|
9740
|
-
__spreadProps(__spreadValues(__spreadValues({}, props), intlProp), {
|
|
9741
|
-
ref: forwardRef2 ? props.forwardedRef : null
|
|
9742
|
-
})
|
|
9743
|
-
);
|
|
9744
|
-
});
|
|
9745
|
-
WithIntl.displayName = `injectIntl(${getDisplayName(WrappedComponent)})`;
|
|
9746
|
-
WithIntl.WrappedComponent = WrappedComponent;
|
|
9747
|
-
if (forwardRef2) {
|
|
9748
|
-
return hoistNonReactStatics(
|
|
9749
|
-
// @ts-expect-error
|
|
9750
|
-
React2.forwardRef((props, ref) => React2.createElement(WithIntl, __spreadProps(__spreadValues({}, props), { forwardedRef: ref }))),
|
|
9751
|
-
WrappedComponent
|
|
9752
|
-
);
|
|
9753
|
-
}
|
|
9754
|
-
return hoistNonReactStatics(WithIntl, WrappedComponent);
|
|
9755
|
-
}
|
|
9459
|
+
);
|
|
9460
|
+
var Provider = IntlContext.Provider;
|
|
9756
9461
|
|
|
9757
9462
|
// packages/react-intl/src/components/useIntl.ts
|
|
9758
9463
|
function useIntl() {
|
|
9759
|
-
const intl = React3.useContext(
|
|
9464
|
+
const intl = React3.useContext(IntlContext);
|
|
9760
9465
|
invariantIntlContext(intl);
|
|
9761
9466
|
return intl;
|
|
9762
9467
|
}
|
|
@@ -9779,20 +9484,20 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9779
9484
|
})(DisplayNameParts || {});
|
|
9780
9485
|
var FormattedNumberParts = (props) => {
|
|
9781
9486
|
const intl = useIntl();
|
|
9782
|
-
const
|
|
9487
|
+
const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
|
|
9783
9488
|
return children(intl.formatNumberToParts(value, formatProps));
|
|
9784
9489
|
};
|
|
9785
9490
|
FormattedNumberParts.displayName = "FormattedNumberParts";
|
|
9786
9491
|
var FormattedListParts = (props) => {
|
|
9787
9492
|
const intl = useIntl();
|
|
9788
|
-
const
|
|
9493
|
+
const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
|
|
9789
9494
|
return children(intl.formatListToParts(value, formatProps));
|
|
9790
9495
|
};
|
|
9791
9496
|
FormattedNumberParts.displayName = "FormattedNumberParts";
|
|
9792
9497
|
function createFormattedDateTimePartsComponent(name) {
|
|
9793
9498
|
const ComponentParts = (props) => {
|
|
9794
9499
|
const intl = useIntl();
|
|
9795
|
-
const
|
|
9500
|
+
const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
|
|
9796
9501
|
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
9797
9502
|
const formattedParts = name === "formatDate" ? intl.formatDateToParts(date, formatProps) : intl.formatTimeToParts(date, formatProps);
|
|
9798
9503
|
return children(formattedParts);
|
|
@@ -9803,7 +9508,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9803
9508
|
function createFormattedComponent(name) {
|
|
9804
9509
|
const Component = (props) => {
|
|
9805
9510
|
const intl = useIntl();
|
|
9806
|
-
const
|
|
9511
|
+
const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
|
|
9807
9512
|
const formattedValue = intl[name](value, formatProps);
|
|
9808
9513
|
if (typeof children === "function") {
|
|
9809
9514
|
return children(formattedValue);
|
|
@@ -9840,8 +9545,8 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9840
9545
|
}
|
|
9841
9546
|
return chunks;
|
|
9842
9547
|
};
|
|
9843
|
-
var createIntl2 = (
|
|
9844
|
-
var _b =
|
|
9548
|
+
var createIntl2 = (_a, cache) => {
|
|
9549
|
+
var _b = _a, { defaultRichTextElements: rawDefaultRichTextElements } = _b, config2 = __objRest(_b, ["defaultRichTextElements"]);
|
|
9845
9550
|
const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(
|
|
9846
9551
|
rawDefaultRichTextElements
|
|
9847
9552
|
);
|
|
@@ -9876,7 +9581,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9876
9581
|
var React5 = __toESM(window.React);
|
|
9877
9582
|
var FormattedDateTimeRange = (props) => {
|
|
9878
9583
|
const intl = useIntl();
|
|
9879
|
-
const
|
|
9584
|
+
const _a = props, { from, to, children } = _a, formatProps = __objRest(_a, ["from", "to", "children"]);
|
|
9880
9585
|
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
9881
9586
|
if (typeof children === "function") {
|
|
9882
9587
|
return children(formattedValue);
|
|
@@ -9890,7 +9595,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9890
9595
|
// packages/react-intl/src/components/message.tsx
|
|
9891
9596
|
var React6 = __toESM(window.React);
|
|
9892
9597
|
function areEqual(prevProps, nextProps) {
|
|
9893
|
-
const
|
|
9598
|
+
const _a = prevProps, { values } = _a, otherProps = __objRest(_a, ["values"]);
|
|
9894
9599
|
const _b = nextProps, { values: nextValues } = _b, nextOtherProps = __objRest(_b, ["values"]);
|
|
9895
9600
|
return shallowEqual(nextValues, values) && shallowEqual(otherProps, nextOtherProps);
|
|
9896
9601
|
}
|
|
@@ -9962,33 +9667,27 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
9962
9667
|
defaultRichTextElements: config2.defaultRichTextElements
|
|
9963
9668
|
};
|
|
9964
9669
|
}
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
});
|
|
9974
|
-
}
|
|
9975
|
-
static getDerivedStateFromProps(props, { prevConfig, cache }) {
|
|
9976
|
-
const config2 = processIntlConfig(props);
|
|
9977
|
-
if (!shallowEqual(prevConfig, config2)) {
|
|
9978
|
-
return {
|
|
9979
|
-
intl: createIntl2(config2, cache),
|
|
9980
|
-
prevConfig: config2
|
|
9981
|
-
};
|
|
9670
|
+
function IntlProviderImpl(props) {
|
|
9671
|
+
const cacheRef = React8.useRef(createIntlCache());
|
|
9672
|
+
const prevConfigRef = React8.useRef(void 0);
|
|
9673
|
+
const intlRef = React8.useRef(void 0);
|
|
9674
|
+
const filteredProps = {};
|
|
9675
|
+
for (const key in props) {
|
|
9676
|
+
if (props[key] !== void 0) {
|
|
9677
|
+
filteredProps[key] = props[key];
|
|
9982
9678
|
}
|
|
9983
|
-
return null;
|
|
9984
9679
|
}
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9680
|
+
const config2 = processIntlConfig(__spreadValues(__spreadValues({}, DEFAULT_INTL_CONFIG2), filteredProps));
|
|
9681
|
+
if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config2)) {
|
|
9682
|
+
prevConfigRef.current = config2;
|
|
9683
|
+
intlRef.current = createIntl2(config2, cacheRef.current);
|
|
9988
9684
|
}
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9685
|
+
invariantIntlContext(intlRef.current);
|
|
9686
|
+
return React8.createElement(Provider, { value: intlRef.current }, props.children);
|
|
9687
|
+
}
|
|
9688
|
+
IntlProviderImpl.displayName = "IntlProvider";
|
|
9689
|
+
var IntlProvider = IntlProviderImpl;
|
|
9690
|
+
var provider_default = IntlProvider;
|
|
9992
9691
|
|
|
9993
9692
|
// packages/react-intl/src/components/relative.tsx
|
|
9994
9693
|
var React9 = __toESM(window.React);
|
|
@@ -10043,7 +9742,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
10043
9742
|
}
|
|
10044
9743
|
var SimpleFormattedRelativeTime = (props) => {
|
|
10045
9744
|
const { formatRelativeTime: formatRelativeTime2, textComponent: Text } = useIntl();
|
|
10046
|
-
const
|
|
9745
|
+
const _a = props, { children, value, unit } = _a, otherProps = __objRest(_a, ["children", "value", "unit"]);
|
|
10047
9746
|
const formattedRelativeTime = formatRelativeTime2(value || 0, unit, otherProps);
|
|
10048
9747
|
if (typeof children === "function") {
|
|
10049
9748
|
return children(formattedRelativeTime);
|
|
@@ -10053,8 +9752,8 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
10053
9752
|
}
|
|
10054
9753
|
return React9.createElement(React9.Fragment, null, formattedRelativeTime);
|
|
10055
9754
|
};
|
|
10056
|
-
var FormattedRelativeTime = (
|
|
10057
|
-
var _b =
|
|
9755
|
+
var FormattedRelativeTime = (_a) => {
|
|
9756
|
+
var _b = _a, {
|
|
10058
9757
|
value = 0,
|
|
10059
9758
|
unit = "second",
|
|
10060
9759
|
updateIntervalInSeconds
|
|
@@ -10142,16 +9841,6 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
|
|
|
10142
9841
|
})();
|
|
10143
9842
|
/*! Bundled license information:
|
|
10144
9843
|
|
|
10145
|
-
react-is/cjs/react-is.development.js:
|
|
10146
|
-
(** @license React v16.13.1
|
|
10147
|
-
* react-is.development.js
|
|
10148
|
-
*
|
|
10149
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
10150
|
-
*
|
|
10151
|
-
* This source code is licensed under the MIT license found in the
|
|
10152
|
-
* LICENSE file in the root directory of this source tree.
|
|
10153
|
-
*)
|
|
10154
|
-
|
|
10155
9844
|
decimal.js/decimal.mjs:
|
|
10156
9845
|
(*!
|
|
10157
9846
|
* decimal.js v10.6.0
|
package/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MessageDescriptor } from "@formatjs/intl";
|
|
2
|
+
export { createIntlCache, type IntlCache, type MessageDescriptor } from "@formatjs/intl";
|
|
3
|
+
export { createIntl } from "./src/components/createIntl.js";
|
|
4
|
+
export type { IntlConfig, IntlShape, ResolvedIntlConfig } from "./src/types.js";
|
|
5
|
+
export declare function defineMessages<
|
|
6
|
+
K extends keyof any,
|
|
7
|
+
T = MessageDescriptor,
|
|
8
|
+
U extends Record<K, T> = Record<K, T>
|
|
9
|
+
>(msgs: U): U;
|
|
10
|
+
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
|
package/server.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "@formatjs/intl";
|
|
2
|
+
export { createIntlCache } from "@formatjs/intl";
|
|
3
|
+
export { createIntl } from "./src/components/createIntl.js";
|
|
4
|
+
// Identity functions — duplicated here to avoid importing from "use client" index
|
|
5
|
+
export function defineMessages(msgs) {
|
|
6
|
+
return msgs;
|
|
7
|
+
}
|
|
8
|
+
export function defineMessage(msg) {
|
|
9
|
+
return msg;
|
|
10
|
+
}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import { type IntlCache } from "@formatjs/intl";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
import type { IntlConfig
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Explicit intl cache to prevent memory leaks
|
|
8
|
-
*/
|
|
9
|
-
cache: IntlCache;
|
|
10
|
-
/**
|
|
11
|
-
* Intl object we created
|
|
12
|
-
*/
|
|
13
|
-
intl?: IntlShape;
|
|
14
|
-
/**
|
|
15
|
-
* list of memoized config we care about.
|
|
16
|
-
* This is important since creating intl is
|
|
17
|
-
* very expensive
|
|
18
|
-
*/
|
|
19
|
-
prevConfig: IntlConfig;
|
|
20
|
-
}
|
|
21
|
-
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
|
|
22
|
-
static displayName: string;
|
|
23
|
-
static defaultProps: DefaultIntlConfig;
|
|
24
|
-
private cache;
|
|
25
|
-
state: State;
|
|
26
|
-
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
|
|
27
|
-
render(): React.JSX.Element;
|
|
28
|
-
}
|
|
2
|
+
import type { IntlConfig } from "../types.js";
|
|
3
|
+
declare const IntlProvider: React.FC<React.PropsWithChildren<IntlConfig>>;
|
|
4
|
+
export default IntlProvider;
|
|
@@ -7,7 +7,7 @@ import { createIntlCache } from "@formatjs/intl";
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { DEFAULT_INTL_CONFIG, invariantIntlContext, shallowEqual } from "../utils.js";
|
|
9
9
|
import { createIntl } from "./createIntl.js";
|
|
10
|
-
import { Provider } from "./
|
|
10
|
+
import { Provider } from "./context.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function processIntlConfig(config) {
|
|
13
13
|
return {
|
|
@@ -25,30 +25,33 @@ function processIntlConfig(config) {
|
|
|
25
25
|
defaultRichTextElements: config.defaultRichTextElements
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!shallowEqual(prevConfig, config)) {
|
|
40
|
-
return {
|
|
41
|
-
intl: createIntl(config, cache),
|
|
42
|
-
prevConfig: config
|
|
43
|
-
};
|
|
28
|
+
function IntlProviderImpl(props) {
|
|
29
|
+
const cacheRef = React.useRef(createIntlCache());
|
|
30
|
+
const prevConfigRef = React.useRef(undefined);
|
|
31
|
+
const intlRef = React.useRef(undefined);
|
|
32
|
+
// Filter out undefined values from props so they don't override defaults.
|
|
33
|
+
// React's defaultProps treated `prop={undefined}` as "not provided"; we
|
|
34
|
+
// replicate that behaviour here after converting to a function component.
|
|
35
|
+
const filteredProps = {};
|
|
36
|
+
for (const key in props) {
|
|
37
|
+
if (props[key] !== undefined) {
|
|
38
|
+
filteredProps[key] = props[key];
|
|
44
39
|
}
|
|
45
|
-
return null;
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const config = processIntlConfig({
|
|
42
|
+
...DEFAULT_INTL_CONFIG,
|
|
43
|
+
...filteredProps
|
|
44
|
+
});
|
|
45
|
+
if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config)) {
|
|
46
|
+
prevConfigRef.current = config;
|
|
47
|
+
intlRef.current = createIntl(config, cacheRef.current);
|
|
53
48
|
}
|
|
49
|
+
invariantIntlContext(intlRef.current);
|
|
50
|
+
return /* @__PURE__ */ _jsx(Provider, {
|
|
51
|
+
value: intlRef.current,
|
|
52
|
+
children: props.children
|
|
53
|
+
});
|
|
54
54
|
}
|
|
55
|
+
IntlProviderImpl.displayName = "IntlProvider";
|
|
56
|
+
const IntlProvider = IntlProviderImpl;
|
|
57
|
+
export default IntlProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import "../types.js";
|
|
3
3
|
import { invariantIntlContext } from "../utils.js";
|
|
4
|
-
import { Context } from "./
|
|
4
|
+
import { Context } from "./context.js";
|
|
5
5
|
export default function useIntl() {
|
|
6
6
|
const intl = React.useContext(Context);
|
|
7
7
|
invariantIntlContext(intl);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type IntlShape } from "../types.js";
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
/**
|
|
6
|
-
* Set this to `true` prior to mounting to bypass using a globally-exposed context.
|
|
7
|
-
*/
|
|
8
|
-
__REACT_INTL_BYPASS_GLOBAL_CONTEXT__: boolean | undefined;
|
|
9
|
-
__REACT_INTL_CONTEXT__: React.Context<IntlShape> | undefined;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare const Provider: React.Provider<IntlShape>;
|
|
13
|
-
export declare const Context: React.Context<IntlShape>;
|
|
14
|
-
export interface Opts<
|
|
15
|
-
IntlPropName extends string = "intl",
|
|
16
|
-
ForwardRef extends boolean = false
|
|
17
|
-
> {
|
|
18
|
-
intlPropName?: IntlPropName;
|
|
19
|
-
forwardRef?: ForwardRef;
|
|
20
|
-
enforceContext?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export type WrappedComponentProps<IntlPropName extends string = "intl"> = { [k in IntlPropName] : IntlShape };
|
|
23
|
-
/**
|
|
24
|
-
* Utility type to help deal with the fact that `Omit` doesn't play well with unions:
|
|
25
|
-
* - https://github.com/microsoft/TypeScript/issues/31501
|
|
26
|
-
* - https://github.com/microsoft/TypeScript/issues/28339
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* DistributedOmit<X | Y, K> --> Omit<X, K> | Omit<Y, K>
|
|
30
|
-
*/
|
|
31
|
-
export type DistributedOmit<
|
|
32
|
-
T,
|
|
33
|
-
K extends PropertyKey
|
|
34
|
-
> = T extends unknown ? Omit<T, K> : never;
|
|
35
|
-
export type WithIntlProps<P> = DistributedOmit<P, keyof WrappedComponentProps> & {
|
|
36
|
-
forwardedRef?: React.Ref<any>;
|
|
37
|
-
};
|
|
38
|
-
export default function injectIntl<
|
|
39
|
-
IntlPropName extends string = "intl",
|
|
40
|
-
P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>
|
|
41
|
-
>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, false>): React.FC<WithIntlProps<P>> & {
|
|
42
|
-
WrappedComponent: React.ComponentType<P>;
|
|
43
|
-
};
|
|
44
|
-
export default function injectIntl<
|
|
45
|
-
IntlPropName extends string = "intl",
|
|
46
|
-
P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>,
|
|
47
|
-
T extends React.ComponentType<P> = any
|
|
48
|
-
>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, true>): React.ForwardRefExoticComponent<React.PropsWithoutRef<WithIntlProps<React.PropsWithChildren<P>>> & React.RefAttributes<T>> & {
|
|
49
|
-
WrappedComponent: React.ComponentType<P>;
|
|
50
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as hoistNonReactStaticsNs from "hoist-non-react-statics";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import "../types.js";
|
|
4
|
-
import { invariantIntlContext } from "../utils.js";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const hoistNonReactStatics = hoistNonReactStaticsNs.default ?? hoistNonReactStaticsNs;
|
|
7
|
-
function getDisplayName(Component) {
|
|
8
|
-
return Component.displayName || Component.name || "Component";
|
|
9
|
-
}
|
|
10
|
-
// This is primarily dealing with packaging systems where multiple copies of react-intl
|
|
11
|
-
// might exist
|
|
12
|
-
const IntlContext = typeof window !== "undefined" && !window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__ ? window.__REACT_INTL_CONTEXT__ || (window.__REACT_INTL_CONTEXT__ = React.createContext(null)) : React.createContext(null);
|
|
13
|
-
const { Consumer: IntlConsumer, Provider: IntlProvider } = IntlContext;
|
|
14
|
-
export const Provider = IntlProvider;
|
|
15
|
-
export const Context = IntlContext;
|
|
16
|
-
export default function injectIntl(WrappedComponent, options) {
|
|
17
|
-
const { intlPropName = "intl", forwardRef = false, enforceContext = true } = options || {};
|
|
18
|
-
const WithIntl = (props) => /* @__PURE__ */ _jsx(IntlConsumer, { children: (intl) => {
|
|
19
|
-
if (enforceContext) {
|
|
20
|
-
invariantIntlContext(intl);
|
|
21
|
-
}
|
|
22
|
-
const intlProp = { [intlPropName]: intl };
|
|
23
|
-
return /* @__PURE__ */ _jsx(WrappedComponent, {
|
|
24
|
-
...props,
|
|
25
|
-
...intlProp,
|
|
26
|
-
ref: forwardRef ? props.forwardedRef : null
|
|
27
|
-
});
|
|
28
|
-
} });
|
|
29
|
-
WithIntl.displayName = `injectIntl(${getDisplayName(WrappedComponent)})`;
|
|
30
|
-
WithIntl.WrappedComponent = WrappedComponent;
|
|
31
|
-
if (forwardRef) {
|
|
32
|
-
return hoistNonReactStatics(
|
|
33
|
-
// @ts-expect-error
|
|
34
|
-
React.forwardRef((props, ref) => /* @__PURE__ */ _jsx(WithIntl, {
|
|
35
|
-
...props,
|
|
36
|
-
forwardedRef: ref
|
|
37
|
-
})),
|
|
38
|
-
WrappedComponent
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return hoistNonReactStatics(WithIntl, WrappedComponent);
|
|
42
|
-
}
|