react-intlayer 5.5.1 → 5.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/dist/cjs/client/useDictionary.cjs +5 -0
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +5 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/types/client/useDictionary.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -22,12 +22,17 @@ __export(useDictionary_exports, {
|
|
|
22
22
|
useDictionary: () => useDictionary
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useDictionary_exports);
|
|
25
|
+
var import_editor_react = require("@intlayer/editor-react");
|
|
25
26
|
var import_react = require("react");
|
|
26
27
|
var import_getDictionary = require('../getDictionary.cjs');
|
|
27
28
|
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
28
29
|
const useDictionary = (dictionary, locale) => {
|
|
29
30
|
const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
31
|
const localeTarget = locale ?? currentLocale;
|
|
32
|
+
const { changedContent } = (0, import_editor_react.useChangedContent)();
|
|
33
|
+
if (changedContent?.[dictionary.key]) {
|
|
34
|
+
return (0, import_getDictionary.getDictionary)(changedContent?.[dictionary.key], localeTarget);
|
|
35
|
+
}
|
|
31
36
|
return (0, import_getDictionary.getDictionary)(dictionary, localeTarget);
|
|
32
37
|
};
|
|
33
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkC;AAClC,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,QAAI,uCAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,eAAO,oCAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,aAAO,oCAAgC,YAAY,YAAY;AACjE;","names":[]}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useChangedContent } from "@intlayer/editor-react";
|
|
2
3
|
import { useContext } from "react";
|
|
3
4
|
import { getDictionary } from "../getDictionary.mjs";
|
|
4
5
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
5
6
|
const useDictionary = (dictionary, locale) => {
|
|
6
7
|
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
7
8
|
const localeTarget = locale ?? currentLocale;
|
|
9
|
+
const { changedContent } = useChangedContent();
|
|
10
|
+
if (changedContent?.[dictionary.key]) {
|
|
11
|
+
return getDictionary(changedContent?.[dictionary.key], localeTarget);
|
|
12
|
+
}
|
|
8
13
|
return getDictionary(dictionary, localeTarget);
|
|
9
14
|
};
|
|
10
15
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,WAAO,cAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
|
|
@@ -5,5 +5,5 @@ import type { Dictionary } from '@intlayer/core';
|
|
|
5
5
|
*
|
|
6
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
7
7
|
*/
|
|
8
|
-
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) =>
|
|
8
|
+
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => any;
|
|
9
9
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,QAYvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"js-cookie": "^3.0.5",
|
|
72
|
-
"@intlayer/config": "5.5.
|
|
73
|
-
"@intlayer/core": "5.5.
|
|
74
|
-
"@intlayer/
|
|
75
|
-
"@intlayer/
|
|
76
|
-
"@intlayer/
|
|
72
|
+
"@intlayer/config": "5.5.2",
|
|
73
|
+
"@intlayer/core": "5.5.2",
|
|
74
|
+
"@intlayer/dictionaries-entry": "5.5.2",
|
|
75
|
+
"@intlayer/editor-react": "5.5.2",
|
|
76
|
+
"@intlayer/api": "5.5.2"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@craco/types": "^7.1.0",
|
|
@@ -89,21 +89,21 @@
|
|
|
89
89
|
"tsc-alias": "^1.8.11",
|
|
90
90
|
"tsup": "^8.4.0",
|
|
91
91
|
"typescript": "^5.8.2",
|
|
92
|
-
"@intlayer/backend": "5.5.1",
|
|
93
92
|
"@utils/eslint-config": "1.0.4",
|
|
94
93
|
"@utils/ts-config": "1.0.4",
|
|
95
94
|
"@utils/ts-config-types": "1.0.4",
|
|
96
|
-
"@utils/tsup-config": "1.0.4"
|
|
95
|
+
"@utils/tsup-config": "1.0.4",
|
|
96
|
+
"@intlayer/backend": "5.5.2"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"react": ">=16.0.0",
|
|
100
100
|
"react-dom": ">=16.0.0",
|
|
101
|
-
"@intlayer/api": "5.5.
|
|
102
|
-
"@intlayer/config": "5.5.
|
|
103
|
-
"@intlayer/
|
|
104
|
-
"@intlayer/
|
|
105
|
-
"
|
|
106
|
-
"intlayer": "5.5.
|
|
101
|
+
"@intlayer/api": "5.5.2",
|
|
102
|
+
"@intlayer/config": "5.5.2",
|
|
103
|
+
"@intlayer/core": "5.5.2",
|
|
104
|
+
"@intlayer/editor-react": "5.5.2",
|
|
105
|
+
"intlayer": "5.5.2",
|
|
106
|
+
"@intlayer/dictionaries-entry": "5.5.2"
|
|
107
107
|
},
|
|
108
108
|
"engines": {
|
|
109
109
|
"node": ">=14.18"
|