react-intl 3.12.0 → 3.12.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.12.1](https://github.com/formatjs/react-intl/compare/v3.12.0...v3.12.1) (2020-03-04)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * clarify err messages ([b207d80](https://github.com/formatjs/react-intl/commit/b207d805a9e5609983ac1b2ca8f9708030e12337))
11
+ * inline defineMessages macro, fix [#1592](https://github.com/formatjs/react-intl/issues/1592) ([5ae8349](https://github.com/formatjs/react-intl/commit/5ae8349dc2ee08b54a54a2a521b8a9c052960d04))
12
+
5
13
  ## [3.12.0](https://github.com/formatjs/react-intl/compare/v3.11.0...v3.12.0) (2020-02-04)
6
14
 
7
15
 
@@ -11,7 +11,7 @@ interface Props extends FormatPluralOptions {
11
11
  many?: React.ReactNode;
12
12
  children?(value: React.ReactNode): React.ReactElement | null;
13
13
  }
14
- declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "format" | "localeMatcher" | "type" | "value"> & {
14
+ declare const _default: React.ForwardRefExoticComponent<Pick<Props, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
15
15
  forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
16
16
  } & React.RefAttributes<any>> & {
17
17
  WrappedComponent: React.ComponentType<Props>;
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
32
  var React = require("react");
33
33
  var injectIntl_1 = require("./injectIntl");
34
34
  var utils_1 = require("../utils");
35
- var intl_locales_supported_1 = require("intl-locales-supported");
36
35
  var number_1 = require("../formatters/number");
37
36
  var relativeTime_1 = require("../formatters/relativeTime");
38
37
  var dateTime_1 = require("../formatters/dateTime");
@@ -62,12 +61,10 @@ function processIntlConfig(config) {
62
61
  function createIntl(config, cache) {
63
62
  var formatters = utils_1.createFormatters(cache);
64
63
  var resolvedConfig = __assign(__assign({}, utils_1.DEFAULT_INTL_CONFIG), config);
65
- if (!resolvedConfig.locale ||
66
- !intl_locales_supported_1.default(resolvedConfig.locale)) {
67
- var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
68
- if (typeof onError === 'function') {
69
- onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\". " +
70
- ("Using default locale: \"" + defaultLocale + "\" as fallback.")));
64
+ var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
65
+ if (!locale) {
66
+ if (onError) {
67
+ onError(utils_1.createError("\"locale\" was not configured, using \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/API.md#intlshape for more details"));
71
68
  }
72
69
  // Since there's no registered locale data for `locale`, this will
73
70
  // fallback to the `defaultLocale` to make sure things can render.
@@ -76,6 +73,13 @@ function createIntl(config, cache) {
76
73
  // each <FormattedMessage> contains a `defaultMessage` prop.
77
74
  resolvedConfig.locale = resolvedConfig.defaultLocale || 'en';
78
75
  }
76
+ else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
77
+ onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\" in Intl.NumberFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md#runtime-requirements for more details"));
78
+ }
79
+ else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length &&
80
+ onError) {
81
+ onError(utils_1.createError("Missing locale data for locale: \"" + locale + "\" in Intl.DateTimeFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://github.com/formatjs/react-intl/blob/master/docs/Getting-Started.md#runtime-requirements for more details"));
82
+ }
79
83
  return __assign(__assign({}, resolvedConfig), { formatters: formatters, formatNumber: number_1.formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: number_1.formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: relativeTime_1.formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: dateTime_1.formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: dateTime_1.formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: dateTime_1.formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: dateTime_1.formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: plural_1.formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: message_1.formatMessage.bind(null, resolvedConfig, formatters), formatHTMLMessage: message_1.formatHTMLMessage.bind(null, resolvedConfig, formatters), formatList: list_1.formatList.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: displayName_1.formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
80
84
  }
81
85
  exports.createIntl = createIntl;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  export * from './types';
3
- export { defineMessages } from '@formatjs/macro';
3
+ export declare function defineMessages<T, U extends Record<string, T>>(msgs: U): U;
4
4
  import { CustomFormatConfig } from './types';
5
5
  import { UnifiedNumberFormatOptions } from '@formatjs/intl-unified-numberformat';
6
6
  import { IntlListFormatOptions } from '@formatjs/intl-listformat';
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var macro_1 = require("@formatjs/macro");
4
- exports.defineMessages = macro_1.defineMessages;
3
+ function defineMessages(msgs) {
4
+ return msgs;
5
+ }
6
+ exports.defineMessages = defineMessages;
5
7
  var createFormattedComponent_1 = require("./components/createFormattedComponent");
6
8
  var injectIntl_1 = require("./components/injectIntl");
7
9
  exports.injectIntl = injectIntl_1.default;
@@ -127,7 +127,7 @@ export const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
127
127
  // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
128
128
  //
129
129
  // @public (undocumented)
130
- export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "format" | "localeMatcher" | "type" | "value"> & {
130
+ export const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
131
131
  forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
132
132
  } & React.RefAttributes<any>> & {
133
133
  WrappedComponent: React.ComponentType<Props_2>;
@@ -126,7 +126,7 @@ export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] &
126
126
  children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
127
127
  }>;
128
128
 
129
- export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "format" | "localeMatcher" | "type" | "value"> & {
129
+ export declare const FormattedPlural: React.ForwardRefExoticComponent<Pick<Props_2, "children" | "other" | "zero" | "one" | "two" | "few" | "many" | "localeMatcher" | "format" | "type" | "value"> & {
130
130
  forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
131
131
  } & React.RefAttributes<any>> & {
132
132
  WrappedComponent: React.ComponentType<Props_2>;
@@ -718,17 +718,33 @@ declare enum TYPE {
718
718
  }
719
719
 
720
720
  declare type UnifiedNumberFormatOptions = Intl.NumberFormatOptions & NumberFormatDigitOptions & {
721
- localeMatcher?: 'lookup' | 'best fit';
722
- style?: 'decimal' | 'percent' | 'currency' | 'unit';
723
- compactDisplay?: 'short' | 'long';
724
- currencyDisplay?: 'symbol' | 'code' | 'name' | 'narrowSymbol';
725
- currencySign?: 'standard' | 'accounting';
726
- notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
727
- signDisplay?: 'auto' | 'always' | 'never' | 'exceptZero';
721
+ localeMatcher?: UnifiedNumberFormatOptionsLocaleMatcher;
722
+ style?: UnifiedNumberFormatOptionsStyle;
723
+ compactDisplay?: UnifiedNumberFormatOptionsCompactDisplay;
724
+ currencyDisplay?: UnifiedNumberFormatOptionsCurrencyDisplay;
725
+ currencySign?: UnifiedNumberFormatOptionsCurrencySign;
726
+ notation?: UnifiedNumberFormatOptionsNotation;
727
+ signDisplay?: UnifiedNumberFormatOptionsSignDisplay;
728
728
  unit?: Unit_2;
729
- unitDisplay?: 'long' | 'short' | 'narrow';
729
+ unitDisplay?: UnifiedNumberFormatOptionsUnitDisplay;
730
730
  };
731
731
 
732
+ declare type UnifiedNumberFormatOptionsCompactDisplay = 'short' | 'long';
733
+
734
+ declare type UnifiedNumberFormatOptionsCurrencyDisplay = 'symbol' | 'code' | 'name' | 'narrowSymbol';
735
+
736
+ declare type UnifiedNumberFormatOptionsCurrencySign = 'standard' | 'accounting';
737
+
738
+ declare type UnifiedNumberFormatOptionsLocaleMatcher = 'lookup' | 'best fit';
739
+
740
+ declare type UnifiedNumberFormatOptionsNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
741
+
742
+ declare type UnifiedNumberFormatOptionsSignDisplay = 'auto' | 'always' | 'never' | 'exceptZero';
743
+
744
+ declare type UnifiedNumberFormatOptionsStyle = 'decimal' | 'percent' | 'currency' | 'unit';
745
+
746
+ declare type UnifiedNumberFormatOptionsUnitDisplay = 'long' | 'short' | 'narrow';
747
+
732
748
  declare type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
733
749
 
734
750
  declare type Unit_2 = 'degree' | 'acre' | 'hectare' | 'percent' | 'bit' | 'byte' | 'gigabit' | 'gigabyte' | 'kilobit' | 'kilobyte' | 'megabit' | 'megabyte' | 'petabyte' | 'terabit' | 'terabyte' | 'day' | 'hour' | 'millisecond' | 'minute' | 'month' | 'second' | 'week' | 'year' | 'centimeter' | 'foot' | 'inch' | 'kilometer' | 'meter' | 'mile-scandinavian' | 'mile' | 'millimeter' | 'yard' | 'gram' | 'kilogram' | 'ounce' | 'pound' | 'stone' | 'celsius' | 'fahrenheit' | 'fluid-ounce' | 'gallon' | 'liter' | 'milliliter';