react-intl 7.1.13 → 8.0.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 +15 -15
- package/index.js +21 -46
- package/package.json +23 -21
- package/react-intl.iife.js +113 -111
- package/src/components/createFormattedComponent.d.ts +1 -1
- package/src/components/createFormattedComponent.js +17 -24
- package/src/components/createIntl.d.ts +1 -1
- package/src/components/createIntl.js +12 -16
- package/src/components/dateTimeRange.js +6 -8
- package/src/components/injectIntl.d.ts +1 -1
- package/src/components/injectIntl.js +14 -16
- package/src/components/message.js +10 -12
- package/src/components/plural.js +4 -7
- package/src/components/provider.d.ts +2 -2
- package/src/components/provider.js +15 -17
- package/src/components/relative.js +10 -12
- package/src/components/useIntl.d.ts +1 -1
- package/src/components/useIntl.js +6 -10
- package/src/types.d.ts +1 -1
- package/src/types.js +1 -2
- package/src/utils.d.ts +2 -1
- package/src/utils.js +21 -29
- package/lib/index.d.ts +0 -46
- package/lib/index.js +0 -26
- package/lib/src/components/createFormattedComponent.d.ts +0 -27
- package/lib/src/components/createFormattedComponent.js +0 -62
- package/lib/src/components/createIntl.d.ts +0 -9
- package/lib/src/components/createIntl.js +0 -58
- package/lib/src/components/dateTimeRange.d.ts +0 -9
- package/lib/src/components/dateTimeRange.js +0 -15
- package/lib/src/components/injectIntl.d.ts +0 -39
- package/lib/src/components/injectIntl.js +0 -35
- package/lib/src/components/message.d.ts +0 -11
- package/lib/src/components/message.js +0 -35
- package/lib/src/components/plural.d.ts +0 -14
- package/lib/src/components/plural.js +0 -23
- package/lib/src/components/provider.d.ts +0 -29
- package/lib/src/components/provider.js +0 -59
- package/lib/src/components/relative.d.ts +0 -10
- package/lib/src/components/relative.js +0 -125
- package/lib/src/components/useIntl.d.ts +0 -2
- package/lib/src/components/useIntl.js +0 -8
- package/lib/src/types.d.ts +0 -14
- package/lib/src/types.js +0 -1
- package/lib/src/utils.d.ts +0 -25
- package/lib/src/utils.js +0 -69
package/lib/src/utils.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FormatXMLElementFn } from 'intl-messageformat';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ResolvedIntlConfig } from './types';
|
|
4
|
-
export declare function invariant(condition: boolean, message: string, Err?: any): asserts condition;
|
|
5
|
-
export declare function invariantIntlContext(intl?: any): asserts intl;
|
|
6
|
-
export type DefaultIntlConfig = Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
|
|
7
|
-
export declare const DEFAULT_INTL_CONFIG: DefaultIntlConfig;
|
|
8
|
-
/**
|
|
9
|
-
* Builds an array of {@link React.ReactNode}s with index-based keys, similar to
|
|
10
|
-
* {@link React.Children.toArray}. However, this function tells React that it
|
|
11
|
-
* was intentional, so they won't produce a bunch of warnings about it.
|
|
12
|
-
*
|
|
13
|
-
* React doesn't recommend doing this because it makes reordering inefficient,
|
|
14
|
-
* but we mostly need this for message chunks, which don't tend to reorder to
|
|
15
|
-
* begin with.
|
|
16
|
-
*/
|
|
17
|
-
export declare const toKeyedReactNodeArray: typeof React.Children.toArray;
|
|
18
|
-
/**
|
|
19
|
-
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
20
|
-
* argument `parts` through, assigning unique key to each part, to prevent
|
|
21
|
-
* "Each child in a list should have a unique "key"" React error.
|
|
22
|
-
* @param formatXMLElementFn
|
|
23
|
-
*/
|
|
24
|
-
export declare function assignUniqueKeysToParts(formatXMLElementFn: FormatXMLElementFn<React.ReactNode>): FormatXMLElementFn<React.ReactNode>;
|
|
25
|
-
export declare function shallowEqual<T extends Record<string, unknown> = Record<string, unknown>>(objA?: T, objB?: T): boolean;
|
package/lib/src/utils.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG } from '@formatjs/intl';
|
|
4
|
-
export function invariant(condition, message, Err) {
|
|
5
|
-
if (Err === void 0) { Err = Error; }
|
|
6
|
-
if (!condition) {
|
|
7
|
-
throw new Err(message);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function invariantIntlContext(intl) {
|
|
11
|
-
invariant(intl, '[React Intl] Could not find required `intl` object. ' +
|
|
12
|
-
'<IntlProvider> needs to exist in the component ancestry.');
|
|
13
|
-
}
|
|
14
|
-
export var DEFAULT_INTL_CONFIG = __assign(__assign({}, CORE_DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|
|
15
|
-
var toKeyedReactNode = function (reactNode, key) {
|
|
16
|
-
return React.isValidElement(reactNode)
|
|
17
|
-
? React.cloneElement(reactNode, { key: key })
|
|
18
|
-
: reactNode;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Builds an array of {@link React.ReactNode}s with index-based keys, similar to
|
|
22
|
-
* {@link React.Children.toArray}. However, this function tells React that it
|
|
23
|
-
* was intentional, so they won't produce a bunch of warnings about it.
|
|
24
|
-
*
|
|
25
|
-
* React doesn't recommend doing this because it makes reordering inefficient,
|
|
26
|
-
* but we mostly need this for message chunks, which don't tend to reorder to
|
|
27
|
-
* begin with.
|
|
28
|
-
*/
|
|
29
|
-
export var toKeyedReactNodeArray = function (children) { var _a;
|
|
30
|
-
/**
|
|
31
|
-
* Note: {@link React.Children.map} will add its own index-based prefix to
|
|
32
|
-
* every key anyway, so the auto-injected one doesn't even have to be unique.
|
|
33
|
-
* This basically just tells React that it's explicit/intentional.
|
|
34
|
-
*/
|
|
35
|
-
return (_a = React.Children.map(children, toKeyedReactNode)) !== null && _a !== void 0 ? _a : []; };
|
|
36
|
-
/**
|
|
37
|
-
* Takes a `formatXMLElementFn`, and composes it in function, which passes
|
|
38
|
-
* argument `parts` through, assigning unique key to each part, to prevent
|
|
39
|
-
* "Each child in a list should have a unique "key"" React error.
|
|
40
|
-
* @param formatXMLElementFn
|
|
41
|
-
*/
|
|
42
|
-
export function assignUniqueKeysToParts(formatXMLElementFn) {
|
|
43
|
-
return function (parts) {
|
|
44
|
-
// eslint-disable-next-line prefer-rest-params
|
|
45
|
-
return formatXMLElementFn(toKeyedReactNodeArray(parts));
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function shallowEqual(objA, objB) {
|
|
49
|
-
if (objA === objB) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
if (!objA || !objB) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
var aKeys = Object.keys(objA);
|
|
56
|
-
var bKeys = Object.keys(objB);
|
|
57
|
-
var len = aKeys.length;
|
|
58
|
-
if (bKeys.length !== len) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
for (var i = 0; i < len; i++) {
|
|
62
|
-
var key = aKeys[i];
|
|
63
|
-
if (objA[key] !== objB[key] ||
|
|
64
|
-
!Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
}
|