@ttoss/react-i18n 1.19.2 → 1.19.4

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/dist/esm/index.js CHANGED
@@ -8,7 +8,7 @@ import * as React from "react";
8
8
  import { IntlProvider } from "react-intl";
9
9
  import { Fragment, jsx } from "react/jsx-runtime";
10
10
  var DEFAULT_LOCALE = "en";
11
- var I18nConfigContext = React.createContext({
11
+ var I18nConfigContext = /*#__PURE__*/React.createContext({
12
12
  defaultLocale: DEFAULT_LOCALE,
13
13
  setLocale: () => {
14
14
  return null;
@@ -24,32 +24,28 @@ var I18nProvider = ({
24
24
  const [messages, setMessages] = React.useState();
25
25
  React.useEffect(() => {
26
26
  if (loadLocaleData) {
27
- loadLocaleData(locale).then((message) => {
27
+ loadLocaleData(locale).then(message => {
28
28
  return setMessages(message);
29
29
  });
30
30
  }
31
31
  }, [loadLocaleData, locale]);
32
- return /* @__PURE__ */ jsx(
33
- I18nConfigContext.Provider,
34
- {
35
- value: {
36
- defaultLocale: DEFAULT_LOCALE,
37
- locale,
38
- setLocale,
39
- ...intlConfig
40
- },
41
- children: /* @__PURE__ */ jsx(
42
- IntlProvider,
43
- {
44
- defaultLocale: DEFAULT_LOCALE,
45
- locale,
46
- messages,
47
- ...intlConfig,
48
- children: /* @__PURE__ */ jsx(Fragment, { children })
49
- }
50
- )
51
- }
52
- );
32
+ return /* @__PURE__ */jsx(I18nConfigContext.Provider, {
33
+ value: {
34
+ defaultLocale: DEFAULT_LOCALE,
35
+ locale,
36
+ setLocale,
37
+ ...intlConfig
38
+ },
39
+ children: /* @__PURE__ */jsx(IntlProvider, {
40
+ defaultLocale: DEFAULT_LOCALE,
41
+ locale,
42
+ messages,
43
+ ...intlConfig,
44
+ children: /* @__PURE__ */jsx(Fragment, {
45
+ children
46
+ })
47
+ })
48
+ });
53
49
  };
54
50
 
55
51
  // src/useI18n.ts
@@ -58,13 +54,9 @@ import { useIntl } from "react-intl";
58
54
  var useI18n = () => {
59
55
  const intl = useIntl();
60
56
  const config = React2.useContext(I18nConfigContext);
61
- return { ...config, intl };
62
- };
63
- export {
64
- DEFAULT_LOCALE,
65
- FormattedMessage,
66
- I18nProvider,
67
- defineMessage,
68
- defineMessages,
69
- useI18n
57
+ return {
58
+ ...config,
59
+ intl
60
+ };
70
61
  };
62
+ export { DEFAULT_LOCALE, FormattedMessage, I18nProvider, defineMessage, defineMessages, useI18n };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  "use strict";
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
12
15
  };
13
16
  var __copyProps = (to, from, except, desc) => {
14
17
  if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
18
22
  }
19
23
  return to;
20
24
  };
21
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
35
+ value: true
36
+ }), mod);
30
37
 
31
38
  // src/index.ts
32
39
  var src_exports = {};
@@ -62,32 +69,28 @@ var I18nProvider = ({
62
69
  const [messages, setMessages] = React.useState();
63
70
  React.useEffect(() => {
64
71
  if (loadLocaleData) {
65
- loadLocaleData(locale).then((message) => {
72
+ loadLocaleData(locale).then(message => {
66
73
  return setMessages(message);
67
74
  });
68
75
  }
69
76
  }, [loadLocaleData, locale]);
70
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
- I18nConfigContext.Provider,
72
- {
73
- value: {
74
- defaultLocale: DEFAULT_LOCALE,
75
- locale,
76
- setLocale,
77
- ...intlConfig
78
- },
79
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
- import_react_intl.IntlProvider,
81
- {
82
- defaultLocale: DEFAULT_LOCALE,
83
- locale,
84
- messages,
85
- ...intlConfig,
86
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children })
87
- }
88
- )
89
- }
90
- );
77
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(I18nConfigContext.Provider, {
78
+ value: {
79
+ defaultLocale: DEFAULT_LOCALE,
80
+ locale,
81
+ setLocale,
82
+ ...intlConfig
83
+ },
84
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_intl.IntlProvider, {
85
+ defaultLocale: DEFAULT_LOCALE,
86
+ locale,
87
+ messages,
88
+ ...intlConfig,
89
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
90
+ children
91
+ })
92
+ })
93
+ });
91
94
  };
92
95
 
93
96
  // src/useI18n.ts
@@ -96,7 +99,10 @@ var import_react_intl2 = require("react-intl");
96
99
  var useI18n = () => {
97
100
  const intl = (0, import_react_intl2.useIntl)();
98
101
  const config = React2.useContext(I18nConfigContext);
99
- return { ...config, intl };
102
+ return {
103
+ ...config,
104
+ intl
105
+ };
100
106
  };
101
107
  // Annotate the CommonJS export names for ESM import in node:
102
108
  0 && (module.exports = {
@@ -106,4 +112,4 @@ var useI18n = () => {
106
112
  defineMessage,
107
113
  defineMessages,
108
114
  useI18n
109
- });
115
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-i18n",
3
- "version": "1.19.2",
3
+ "version": "1.19.4",
4
4
  "license": "UNLICENSED",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -17,8 +17,8 @@
17
17
  "build": "tsup",
18
18
  "dev": "yarn workspace @ttoss/storybook run dev",
19
19
  "pretest:compile": "yarn run pretest:compile:en && yarn run pretest:compile:ptBR",
20
- "pretest:compile:en": "formatjs compile i18n/lang/en.json --ast --out-file i18n/compiled-lang/en.json",
21
- "pretest:compile:ptBR": "formatjs compile i18n/lang/pt-BR.json --ast --out-file i18n/compiled-lang/pt-BR.json",
20
+ "pretest:compile:en": "formatjs compile i18n/lang/en.json --ast --out-file i18n/compiled/en.json",
21
+ "pretest:compile:ptBR": "formatjs compile i18n/lang/pt-BR.json --ast --out-file i18n/compiled/pt-BR.json",
22
22
  "pretest:extract": "formatjs extract 'tests/**/*.ts*' --out-file i18n/lang/en.json",
23
23
  "pretest": "yarn run pretest:extract && yarn run pretest:compile",
24
24
  "test": "jest"
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@formatjs/cli": "^6.0.4",
36
- "@ttoss/config": "^1.29.1",
37
- "@ttoss/i18n-cli": "^0.4.2",
38
- "@ttoss/test-utils": "^1.20.8"
36
+ "@ttoss/config": "^1.29.2",
37
+ "@ttoss/i18n-cli": "^0.4.3",
38
+ "@ttoss/test-utils": "^1.21.0"
39
39
  },
40
40
  "keywords": [
41
41
  "React",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "ee0c2e51d38f37f997c020d4303cf90be720ecb0"
48
+ "gitHead": "01701f2c03d9872297d85af0a33d1ca4c2a6eb6b"
49
49
  }