react-intl 6.5.1 → 6.5.2

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/lib/index.js CHANGED
@@ -1,25 +1,50 @@
1
- import { createFormattedComponent, createFormattedDateTimePartsComponent, } from './src/components/createFormattedComponent';
2
- import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, } from './src/components/injectIntl';
3
- import useIntl from './src/components/useIntl';
4
- import IntlProvider, { createIntl } from './src/components/provider';
5
- import FormattedRelativeTime from './src/components/relative';
6
- import FormattedPlural from './src/components/plural';
7
- import FormattedMessage from './src/components/message';
8
- import FormattedDateTimeRange from './src/components/dateTimeRange';
9
- export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, createIntl, injectIntl, useIntl, };
10
- export { createIntlCache, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
11
- export function defineMessages(msgs) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormattedListParts = exports.FormattedNumberParts = exports.FormattedTimeParts = exports.FormattedDateParts = exports.FormattedDisplayName = exports.FormattedList = exports.FormattedNumber = exports.FormattedTime = exports.FormattedDate = exports.defineMessage = exports.defineMessages = exports.ReactIntlError = exports.ReactIntlErrorCode = exports.MissingTranslationError = exports.MessageFormatError = exports.MissingDataError = exports.InvalidConfigError = exports.UnsupportedFormatterError = exports.createIntlCache = exports.useIntl = exports.injectIntl = exports.createIntl = exports.RawIntlProvider = exports.IntlProvider = exports.IntlContext = exports.FormattedRelativeTime = exports.FormattedPlural = exports.FormattedMessage = exports.FormattedDateTimeRange = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var createFormattedComponent_1 = require("./src/components/createFormattedComponent");
6
+ var injectIntl_1 = tslib_1.__importStar(require("./src/components/injectIntl"));
7
+ exports.injectIntl = injectIntl_1.default;
8
+ Object.defineProperty(exports, "RawIntlProvider", { enumerable: true, get: function () { return injectIntl_1.Provider; } });
9
+ Object.defineProperty(exports, "IntlContext", { enumerable: true, get: function () { return injectIntl_1.Context; } });
10
+ var useIntl_1 = tslib_1.__importDefault(require("./src/components/useIntl"));
11
+ exports.useIntl = useIntl_1.default;
12
+ var provider_1 = tslib_1.__importStar(require("./src/components/provider"));
13
+ exports.IntlProvider = provider_1.default;
14
+ Object.defineProperty(exports, "createIntl", { enumerable: true, get: function () { return provider_1.createIntl; } });
15
+ var relative_1 = tslib_1.__importDefault(require("./src/components/relative"));
16
+ exports.FormattedRelativeTime = relative_1.default;
17
+ var plural_1 = tslib_1.__importDefault(require("./src/components/plural"));
18
+ exports.FormattedPlural = plural_1.default;
19
+ var message_1 = tslib_1.__importDefault(require("./src/components/message"));
20
+ exports.FormattedMessage = message_1.default;
21
+ var dateTimeRange_1 = tslib_1.__importDefault(require("./src/components/dateTimeRange"));
22
+ exports.FormattedDateTimeRange = dateTimeRange_1.default;
23
+ var intl_1 = require("@formatjs/intl");
24
+ Object.defineProperty(exports, "createIntlCache", { enumerable: true, get: function () { return intl_1.createIntlCache; } });
25
+ Object.defineProperty(exports, "UnsupportedFormatterError", { enumerable: true, get: function () { return intl_1.UnsupportedFormatterError; } });
26
+ Object.defineProperty(exports, "InvalidConfigError", { enumerable: true, get: function () { return intl_1.InvalidConfigError; } });
27
+ Object.defineProperty(exports, "MissingDataError", { enumerable: true, get: function () { return intl_1.MissingDataError; } });
28
+ Object.defineProperty(exports, "MessageFormatError", { enumerable: true, get: function () { return intl_1.MessageFormatError; } });
29
+ Object.defineProperty(exports, "MissingTranslationError", { enumerable: true, get: function () { return intl_1.MissingTranslationError; } });
30
+ Object.defineProperty(exports, "ReactIntlErrorCode", { enumerable: true, get: function () { return intl_1.IntlErrorCode; } });
31
+ Object.defineProperty(exports, "ReactIntlError", { enumerable: true, get: function () { return intl_1.IntlError; } });
32
+ function defineMessages(msgs) {
12
33
  return msgs;
13
34
  }
14
- export function defineMessage(msg) {
35
+ exports.defineMessages = defineMessages;
36
+ function defineMessage(msg) {
15
37
  return msg;
16
38
  }
39
+ exports.defineMessage = defineMessage;
17
40
  // IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./src/types').CustomFormatConfig`
18
- export var FormattedDate = createFormattedComponent('formatDate');
19
- export var FormattedTime = createFormattedComponent('formatTime');
20
- export var FormattedNumber = createFormattedComponent('formatNumber');
21
- export var FormattedList = createFormattedComponent('formatList');
22
- export var FormattedDisplayName = createFormattedComponent('formatDisplayName');
23
- export var FormattedDateParts = createFormattedDateTimePartsComponent('formatDate');
24
- export var FormattedTimeParts = createFormattedDateTimePartsComponent('formatTime');
25
- export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
41
+ exports.FormattedDate = (0, createFormattedComponent_1.createFormattedComponent)('formatDate');
42
+ exports.FormattedTime = (0, createFormattedComponent_1.createFormattedComponent)('formatTime');
43
+ exports.FormattedNumber = (0, createFormattedComponent_1.createFormattedComponent)('formatNumber');
44
+ exports.FormattedList = (0, createFormattedComponent_1.createFormattedComponent)('formatList');
45
+ exports.FormattedDisplayName = (0, createFormattedComponent_1.createFormattedComponent)('formatDisplayName');
46
+ exports.FormattedDateParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatDate');
47
+ exports.FormattedTimeParts = (0, createFormattedComponent_1.createFormattedDateTimePartsComponent)('formatTime');
48
+ var createFormattedComponent_2 = require("./src/components/createFormattedComponent");
49
+ Object.defineProperty(exports, "FormattedNumberParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedNumberParts; } });
50
+ Object.defineProperty(exports, "FormattedListParts", { enumerable: true, get: function () { return createFormattedComponent_2.FormattedListParts; } });
@@ -1,6 +1,9 @@
1
- import { __rest } from "tslib";
2
- import * as React from 'react';
3
- import useIntl from './useIntl';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFormattedComponent = exports.createFormattedDateTimePartsComponent = exports.FormattedListParts = exports.FormattedNumberParts = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var React = tslib_1.__importStar(require("react"));
6
+ var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
4
7
  var DisplayName;
5
8
  (function (DisplayName) {
6
9
  DisplayName["formatDate"] = "FormattedDate";
@@ -18,22 +21,24 @@ var DisplayNameParts;
18
21
  DisplayNameParts["formatNumber"] = "FormattedNumberParts";
19
22
  DisplayNameParts["formatList"] = "FormattedListParts";
20
23
  })(DisplayNameParts || (DisplayNameParts = {}));
21
- export var FormattedNumberParts = function (props) {
22
- var intl = useIntl();
23
- var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
24
+ var FormattedNumberParts = function (props) {
25
+ var intl = (0, useIntl_1.default)();
26
+ var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
24
27
  return children(intl.formatNumberToParts(value, formatProps));
25
28
  };
26
- FormattedNumberParts.displayName = 'FormattedNumberParts';
27
- export var FormattedListParts = function (props) {
28
- var intl = useIntl();
29
- var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
29
+ exports.FormattedNumberParts = FormattedNumberParts;
30
+ exports.FormattedNumberParts.displayName = 'FormattedNumberParts';
31
+ var FormattedListParts = function (props) {
32
+ var intl = (0, useIntl_1.default)();
33
+ var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
30
34
  return children(intl.formatListToParts(value, formatProps));
31
35
  };
32
- FormattedNumberParts.displayName = 'FormattedNumberParts';
33
- export function createFormattedDateTimePartsComponent(name) {
36
+ exports.FormattedListParts = FormattedListParts;
37
+ exports.FormattedNumberParts.displayName = 'FormattedNumberParts';
38
+ function createFormattedDateTimePartsComponent(name) {
34
39
  var ComponentParts = function (props) {
35
- var intl = useIntl();
36
- var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
40
+ var intl = (0, useIntl_1.default)();
41
+ var value = props.value, children = props.children, formatProps = tslib_1.__rest(props, ["value", "children"]);
37
42
  var date = typeof value === 'string' ? new Date(value || 0) : value;
38
43
  var formattedParts = name === 'formatDate'
39
44
  ? intl.formatDateToParts(date, formatProps)
@@ -43,10 +48,11 @@ export function createFormattedDateTimePartsComponent(name) {
43
48
  ComponentParts.displayName = DisplayNameParts[name];
44
49
  return ComponentParts;
45
50
  }
46
- export function createFormattedComponent(name) {
51
+ exports.createFormattedDateTimePartsComponent = createFormattedDateTimePartsComponent;
52
+ function createFormattedComponent(name) {
47
53
  var Component = function (props) {
48
- var intl = useIntl();
49
- var value = props.value, children = props.children, formatProps = __rest(props
54
+ var intl = (0, useIntl_1.default)();
55
+ var value = props.value, children = props.children, formatProps = tslib_1.__rest(props
50
56
  // TODO: fix TS type definition for localeMatcher upstream
51
57
  , ["value", "children"]);
52
58
  // TODO: fix TS type definition for localeMatcher upstream
@@ -60,3 +66,4 @@ export function createFormattedComponent(name) {
60
66
  Component.displayName = DisplayName[name];
61
67
  return Component;
62
68
  }
69
+ exports.createFormattedComponent = createFormattedComponent;
@@ -1,9 +1,11 @@
1
- import { __rest } from "tslib";
2
- import * as React from 'react';
3
- import useIntl from './useIntl';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var React = tslib_1.__importStar(require("react"));
5
+ var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
4
6
  var FormattedDateTimeRange = function (props) {
5
- var intl = useIntl();
6
- var from = props.from, to = props.to, children = props.children, formatProps = __rest(props, ["from", "to", "children"]);
7
+ var intl = (0, useIntl_1.default)();
8
+ var from = props.from, to = props.to, children = props.children, formatProps = tslib_1.__rest(props, ["from", "to", "children"]);
7
9
  var formattedValue = intl.formatDateTimeRange(from, to, formatProps);
8
10
  if (typeof children === 'function') {
9
11
  return children(formattedValue);
@@ -12,4 +14,4 @@ var FormattedDateTimeRange = function (props) {
12
14
  return React.createElement(Text, null, formattedValue);
13
15
  };
14
16
  FormattedDateTimeRange.displayName = 'FormattedDateTimeRange';
15
- export default FormattedDateTimeRange;
17
+ exports.default = FormattedDateTimeRange;
@@ -1,7 +1,10 @@
1
- import { __assign } from "tslib";
2
- import * as React from 'react';
3
- import hoistNonReactStatics from 'hoist-non-react-statics';
4
- import { invariantIntlContext } from '../utils';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Context = exports.Provider = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var React = tslib_1.__importStar(require("react"));
6
+ var hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
7
+ var utils_1 = require("../utils");
5
8
  function getDisplayName(Component) {
6
9
  return Component.displayName || Component.name || 'Component';
7
10
  }
@@ -12,22 +15,23 @@ var IntlContext = typeof window !== 'undefined' && !window.__REACT_INTL_BYPASS_G
12
15
  (window.__REACT_INTL_CONTEXT__ = React.createContext(null))
13
16
  : React.createContext(null);
14
17
  var IntlConsumer = IntlContext.Consumer, IntlProvider = IntlContext.Provider;
15
- export var Provider = IntlProvider;
16
- export var Context = IntlContext;
17
- export default function injectIntl(WrappedComponent, options) {
18
+ exports.Provider = IntlProvider;
19
+ exports.Context = IntlContext;
20
+ function injectIntl(WrappedComponent, options) {
18
21
  var _a = options || {}, _b = _a.intlPropName, intlPropName = _b === void 0 ? 'intl' : _b, _c = _a.forwardRef, forwardRef = _c === void 0 ? false : _c, _d = _a.enforceContext, enforceContext = _d === void 0 ? true : _d;
19
22
  var WithIntl = function (props) { return (React.createElement(IntlConsumer, null, function (intl) {
20
23
  var _a;
21
24
  if (enforceContext) {
22
- invariantIntlContext(intl);
25
+ (0, utils_1.invariantIntlContext)(intl);
23
26
  }
24
27
  var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
25
- return (React.createElement(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
28
+ return (React.createElement(WrappedComponent, tslib_1.__assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
26
29
  })); };
27
30
  WithIntl.displayName = "injectIntl(".concat(getDisplayName(WrappedComponent), ")");
28
31
  WithIntl.WrappedComponent = WrappedComponent;
29
32
  if (forwardRef) {
30
- return hoistNonReactStatics(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
33
+ return (0, hoist_non_react_statics_1.default)(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, tslib_1.__assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
31
34
  }
32
- return hoistNonReactStatics(WithIntl, WrappedComponent);
35
+ return (0, hoist_non_react_statics_1.default)(WithIntl, WrappedComponent);
33
36
  }
37
+ exports.default = injectIntl;
@@ -1,20 +1,22 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright 2015, Yahoo Inc.
3
4
  * Copyrights licensed under the New BSD License.
4
5
  * See the accompanying LICENSE file for terms.
5
6
  */
6
- import { __rest } from "tslib";
7
- import * as React from 'react';
8
- import useIntl from './useIntl';
9
- import { shallowEqual } from '../utils';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ var tslib_1 = require("tslib");
9
+ var React = tslib_1.__importStar(require("react"));
10
+ var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
11
+ var utils_1 = require("../utils");
10
12
  function areEqual(prevProps, nextProps) {
11
- var values = prevProps.values, otherProps = __rest(prevProps, ["values"]);
12
- var nextValues = nextProps.values, nextOtherProps = __rest(nextProps, ["values"]);
13
- return (shallowEqual(nextValues, values) &&
14
- shallowEqual(otherProps, nextOtherProps));
13
+ var values = prevProps.values, otherProps = tslib_1.__rest(prevProps, ["values"]);
14
+ var nextValues = nextProps.values, nextOtherProps = tslib_1.__rest(nextProps, ["values"]);
15
+ return ((0, utils_1.shallowEqual)(nextValues, values) &&
16
+ (0, utils_1.shallowEqual)(otherProps, nextOtherProps));
15
17
  }
16
18
  function FormattedMessage(props) {
17
- var intl = useIntl();
19
+ var intl = (0, useIntl_1.default)();
18
20
  var formatMessage = intl.formatMessage, _a = intl.textComponent, Text = _a === void 0 ? React.Fragment : _a;
19
21
  var id = props.id, description = props.description, defaultMessage = props.defaultMessage, values = props.values, children = props.children, _b = props.tagName, Component = _b === void 0 ? Text : _b, ignoreTag = props.ignoreTag;
20
22
  var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
@@ -32,4 +34,4 @@ function FormattedMessage(props) {
32
34
  FormattedMessage.displayName = 'FormattedMessage';
33
35
  var MemoizedFormattedMessage = React.memo(FormattedMessage, areEqual);
34
36
  MemoizedFormattedMessage.displayName = 'MemoizedFormattedMessage';
35
- export default MemoizedFormattedMessage;
37
+ exports.default = MemoizedFormattedMessage;
@@ -1,12 +1,15 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright 2015, Yahoo Inc.
3
4
  * Copyrights licensed under the New BSD License.
4
5
  * See the accompanying LICENSE file for terms.
5
6
  */
6
- import * as React from 'react';
7
- import useIntl from './useIntl';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ var tslib_1 = require("tslib");
9
+ var React = tslib_1.__importStar(require("react"));
10
+ var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
8
11
  var FormattedPlural = function (props) {
9
- var _a = useIntl(), formatPlural = _a.formatPlural, Text = _a.textComponent;
12
+ var _a = (0, useIntl_1.default)(), formatPlural = _a.formatPlural, Text = _a.textComponent;
10
13
  var value = props.value, other = props.other, children = props.children;
11
14
  var pluralCategory = formatPlural(value, props);
12
15
  var formattedPlural = props[pluralCategory] || other;
@@ -23,4 +26,4 @@ FormattedPlural.defaultProps = {
23
26
  type: 'cardinal',
24
27
  };
25
28
  FormattedPlural.displayName = 'FormattedPlural';
26
- export default FormattedPlural;
29
+ exports.default = FormattedPlural;
@@ -1,6 +1,6 @@
1
+ import { CreateIntlFn, IntlCache } from '@formatjs/intl';
1
2
  import * as React from 'react';
2
3
  import type { IntlConfig, IntlShape, ResolvedIntlConfig } from '../types';
3
- import { IntlCache, CreateIntlFn } from '@formatjs/intl';
4
4
  interface State {
5
5
  /**
6
6
  * Explicit intl cache to prevent memory leaks
@@ -25,7 +25,7 @@ interface State {
25
25
  export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
26
26
  export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
27
27
  static displayName: string;
28
- static defaultProps: Pick<ResolvedIntlConfig, "onError" | "timeZone" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
28
+ static defaultProps: Pick<ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
29
29
  private cache;
30
30
  state: State;
31
31
  static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
@@ -1,14 +1,17 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright 2015, Yahoo Inc.
3
4
  * Copyrights licensed under the New BSD License.
4
5
  * See the accompanying LICENSE file for terms.
5
6
  */
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';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.createIntl = void 0;
9
+ var tslib_1 = require("tslib");
10
+ var intl_1 = require("@formatjs/intl");
11
+ var React = tslib_1.__importStar(require("react"));
12
+ var utils_1 = require("../utils");
13
+ var injectIntl_1 = require("./injectIntl");
14
+ var intl_messageformat_1 = require("intl-messageformat");
12
15
  function processIntlConfig(config) {
13
16
  return {
14
17
  locale: config.locale,
@@ -31,8 +34,8 @@ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
31
34
  }
32
35
  return Object.keys(values).reduce(function (acc, k) {
33
36
  var v = values[k];
34
- acc[k] = isFormatXMLElementFn(v)
35
- ? assignUniqueKeysToParts(v)
37
+ acc[k] = (0, intl_messageformat_1.isFormatXMLElementFn)(v)
38
+ ? (0, utils_1.assignUniqueKeysToParts)(v)
36
39
  : v;
37
40
  return acc;
38
41
  }, {});
@@ -43,7 +46,7 @@ var formatMessage = function (config, formatters, descriptor, rawValues) {
43
46
  rest[_i - 4] = arguments[_i];
44
47
  }
45
48
  var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
46
- var chunks = coreFormatMessage.apply(void 0, __spreadArray([config,
49
+ var chunks = intl_1.formatMessage.apply(void 0, tslib_1.__spreadArray([config,
47
50
  formatters,
48
51
  descriptor,
49
52
  values], rest, false));
@@ -57,10 +60,10 @@ var formatMessage = function (config, formatters, descriptor, rawValues) {
57
60
  * @param config intl config
58
61
  * @param cache cache for formatter instances to prevent memory leak
59
62
  */
60
- export var createIntl = function (_a, cache) {
61
- var rawDefaultRichTextElements = _a.defaultRichTextElements, config = __rest(_a, ["defaultRichTextElements"]);
63
+ var createIntl = function (_a, cache) {
64
+ var rawDefaultRichTextElements = _a.defaultRichTextElements, config = tslib_1.__rest(_a, ["defaultRichTextElements"]);
62
65
  var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
63
- var coreIntl = coreCreateIntl(__assign(__assign(__assign({}, DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
66
+ var coreIntl = (0, intl_1.createIntl)(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
64
67
  var resolvedConfig = {
65
68
  locale: coreIntl.locale,
66
69
  timeZone: coreIntl.timeZone,
@@ -72,20 +75,21 @@ export var createIntl = function (_a, cache) {
72
75
  onError: coreIntl.onError,
73
76
  defaultRichTextElements: defaultRichTextElements,
74
77
  };
75
- return __assign(__assign({}, coreIntl), {
78
+ return tslib_1.__assign(tslib_1.__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
76
79
  // @ts-expect-error fix this
77
- formatMessage: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),
80
+ coreIntl.formatters),
78
81
  // @ts-expect-error fix this
79
82
  $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
80
83
  };
84
+ exports.createIntl = createIntl;
81
85
  var IntlProvider = /** @class */ (function (_super) {
82
- __extends(IntlProvider, _super);
86
+ tslib_1.__extends(IntlProvider, _super);
83
87
  function IntlProvider() {
84
88
  var _this = _super !== null && _super.apply(this, arguments) || this;
85
- _this.cache = createIntlCache();
89
+ _this.cache = (0, intl_1.createIntlCache)();
86
90
  _this.state = {
87
91
  cache: _this.cache,
88
- intl: createIntl(processIntlConfig(_this.props), _this.cache),
92
+ intl: (0, exports.createIntl)(processIntlConfig(_this.props), _this.cache),
89
93
  prevConfig: processIntlConfig(_this.props),
90
94
  };
91
95
  return _this;
@@ -93,20 +97,20 @@ var IntlProvider = /** @class */ (function (_super) {
93
97
  IntlProvider.getDerivedStateFromProps = function (props, _a) {
94
98
  var prevConfig = _a.prevConfig, cache = _a.cache;
95
99
  var config = processIntlConfig(props);
96
- if (!shallowEqual(prevConfig, config)) {
100
+ if (!(0, utils_1.shallowEqual)(prevConfig, config)) {
97
101
  return {
98
- intl: createIntl(config, cache),
102
+ intl: (0, exports.createIntl)(config, cache),
99
103
  prevConfig: config,
100
104
  };
101
105
  }
102
106
  return null;
103
107
  };
104
108
  IntlProvider.prototype.render = function () {
105
- invariantIntlContext(this.state.intl);
106
- return React.createElement(Provider, { value: this.state.intl }, this.props.children);
109
+ (0, utils_1.invariantIntlContext)(this.state.intl);
110
+ return React.createElement(injectIntl_1.Provider, { value: this.state.intl }, this.props.children);
107
111
  };
108
112
  IntlProvider.displayName = 'IntlProvider';
109
- IntlProvider.defaultProps = DEFAULT_INTL_CONFIG;
113
+ IntlProvider.defaultProps = utils_1.DEFAULT_INTL_CONFIG;
110
114
  return IntlProvider;
111
115
  }(React.PureComponent));
112
- export default IntlProvider;
116
+ exports.default = IntlProvider;
@@ -1,12 +1,14 @@
1
- import { __assign, __rest } from "tslib";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
2
4
  /*
3
5
  * Copyright 2015, Yahoo Inc.
4
6
  * Copyrights licensed under the New BSD License.
5
7
  * See the accompanying LICENSE file for terms.
6
8
  */
7
- import * as React from 'react';
8
- import { invariant, } from '@formatjs/ecma402-abstract';
9
- import useIntl from './useIntl';
9
+ var React = tslib_1.__importStar(require("react"));
10
+ var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
11
+ var useIntl_1 = tslib_1.__importDefault(require("./useIntl"));
10
12
  var MINUTE = 60;
11
13
  var HOUR = 60 * 60;
12
14
  var DAY = 60 * 60 * 24;
@@ -58,8 +60,8 @@ function canIncrement(unit) {
58
60
  return INCREMENTABLE_UNITS.indexOf(unit) > -1;
59
61
  }
60
62
  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 _a = (0, useIntl_1.default)(), formatRelativeTime = _a.formatRelativeTime, Text = _a.textComponent;
64
+ var children = props.children, value = props.value, unit = props.unit, otherProps = tslib_1.__rest(props, ["children", "value", "unit"]);
63
65
  var formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps);
64
66
  if (typeof children === 'function') {
65
67
  return children(formattedRelativeTime);
@@ -70,8 +72,8 @@ var SimpleFormattedRelativeTime = function (props) {
70
72
  return React.createElement(React.Fragment, null, formattedRelativeTime);
71
73
  };
72
74
  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
+ var value = _a.value, unit = _a.unit, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = tslib_1.__rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
76
+ (0, ecma402_abstract_1.invariant)(!updateIntervalInSeconds ||
75
77
  !!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
76
78
  var _b = React.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
77
79
  var _c = React.useState(0), prevValue = _c[0], setPrevValue = _c[1];
@@ -119,11 +121,11 @@ var FormattedRelativeTime = function (_a) {
119
121
  var unitDuration = getDurationInSeconds(currentUnit);
120
122
  currentValue = Math.round(currentValueInSeconds / unitDuration);
121
123
  }
122
- return (React.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
124
+ return (React.createElement(SimpleFormattedRelativeTime, tslib_1.__assign({ value: currentValue, unit: currentUnit }, otherProps)));
123
125
  };
124
126
  FormattedRelativeTime.displayName = 'FormattedRelativeTime';
125
127
  FormattedRelativeTime.defaultProps = {
126
128
  value: 0,
127
129
  unit: 'second',
128
130
  };
129
- export default FormattedRelativeTime;
131
+ exports.default = FormattedRelativeTime;
@@ -1,8 +1,12 @@
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);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var React = tslib_1.__importStar(require("react"));
5
+ var injectIntl_1 = require("./injectIntl");
6
+ var utils_1 = require("../utils");
7
+ function useIntl() {
8
+ var intl = React.useContext(injectIntl_1.Context);
9
+ (0, utils_1.invariantIntlContext)(intl);
7
10
  return intl;
8
11
  }
12
+ exports.default = useIntl;
package/lib/src/types.js CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/src/utils.js CHANGED
@@ -1,25 +1,30 @@
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. ' +
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. ' +
7
10
  '<IntlProvider> needs to exist in the component ancestry.');
8
11
  }
9
- export var DEFAULT_INTL_CONFIG = __assign(__assign({}, CORE_DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
12
+ exports.invariantIntlContext = invariantIntlContext;
13
+ exports.DEFAULT_INTL_CONFIG = tslib_1.__assign(tslib_1.__assign({}, intl_1.DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
10
14
  /**
11
15
  * Takes a `formatXMLElementFn`, and composes it in function, which passes
12
16
  * argument `parts` through, assigning unique key to each part, to prevent
13
17
  * "Each child in a list should have a unique "key"" React error.
14
18
  * @param formatXMLElementFn
15
19
  */
16
- export function assignUniqueKeysToParts(formatXMLElementFn) {
20
+ function assignUniqueKeysToParts(formatXMLElementFn) {
17
21
  return function (parts) {
18
22
  // eslint-disable-next-line prefer-rest-params
19
23
  return formatXMLElementFn(React.Children.toArray(parts));
20
24
  };
21
25
  }
22
- export function shallowEqual(objA, objB) {
26
+ exports.assignUniqueKeysToParts = assignUniqueKeysToParts;
27
+ function shallowEqual(objA, objB) {
23
28
  if (objA === objB) {
24
29
  return true;
25
30
  }
@@ -41,3 +46,4 @@ export function shallowEqual(objA, objB) {
41
46
  }
42
47
  return true;
43
48
  }
49
+ exports.shallowEqual = shallowEqual;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intl",
3
- "version": "6.5.1",
3
+ "version": "6.5.2",
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",
@@ -132,16 +132,16 @@
132
132
  "@types/react": "16 || 17 || 18",
133
133
  "hoist-non-react-statics": "^3.3.2",
134
134
  "tslib": "^2.4.0",
135
- "@formatjs/intl-displaynames": "6.6.1",
136
- "@formatjs/intl": "2.9.5",
137
- "@formatjs/ecma402-abstract": "1.17.2",
138
- "@formatjs/icu-messageformat-parser": "2.7.0",
139
- "@formatjs/intl-listformat": "7.5.0",
140
- "intl-messageformat": "10.5.4"
135
+ "@formatjs/ecma402-abstract": "1.17.3",
136
+ "@formatjs/icu-messageformat-parser": "2.7.1",
137
+ "@formatjs/intl": "2.9.6",
138
+ "@formatjs/intl-displaynames": "6.6.2",
139
+ "@formatjs/intl-listformat": "7.5.1",
140
+ "intl-messageformat": "10.5.5"
141
141
  },
142
142
  "devDependencies": {
143
- "@formatjs/intl-numberformat": "8.8.0",
144
- "@formatjs/intl-relativetimeformat": "11.2.7"
143
+ "@formatjs/intl-numberformat": "8.8.1",
144
+ "@formatjs/intl-relativetimeformat": "11.2.8"
145
145
  },
146
146
  "peerDependencies": {
147
147
  "react": "^16.6.0 || 17 || 18",