react-intlayer 1.0.0 → 1.2.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.
Files changed (169) hide show
  1. package/dist/cjs/ContentEditor/ContentEditor.cjs +36 -39
  2. package/dist/cjs/ContentEditor/ContentEditor.d.ts +2 -2
  3. package/dist/cjs/ContentEditor/contentRender.cjs +10 -18
  4. package/dist/cjs/ContentEditor/index.cjs +11 -27
  5. package/dist/cjs/ContentEditor/index.d.ts +3 -3
  6. package/dist/cjs/IntlayerProvider.cjs +37 -0
  7. package/dist/cjs/IntlayerProvider.cjs.map +1 -0
  8. package/dist/cjs/IntlayerProvider.d.ts +9 -0
  9. package/dist/cjs/client/IntlayerClientProvider.cjs +45 -0
  10. package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -0
  11. package/dist/cjs/client/IntlayerClientProvider.d.ts +24 -0
  12. package/dist/cjs/client/index.cjs +24 -31
  13. package/dist/cjs/client/index.cjs.map +1 -1
  14. package/dist/cjs/client/index.d.ts +10 -19
  15. package/dist/cjs/client/useContent.cjs +11 -16
  16. package/dist/cjs/client/useContent.cjs.map +1 -1
  17. package/dist/cjs/client/useContent.d.ts +10 -8
  18. package/dist/cjs/client/useIntlayer.cjs +11 -18
  19. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  20. package/dist/cjs/client/useIntlayer.d.ts +8 -3
  21. package/dist/cjs/client/useLocale.cjs +12 -20
  22. package/dist/cjs/client/useLocale.cjs.map +1 -1
  23. package/dist/cjs/client/useLocale.d.ts +8 -5
  24. package/dist/cjs/client/useLocaleCookie.cjs +20 -30
  25. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
  26. package/dist/cjs/client/useLocaleCookie.d.ts +12 -3
  27. package/dist/cjs/client/useTraduction.cjs +11 -18
  28. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  29. package/dist/cjs/client/useTraduction.d.ts +22 -4
  30. package/dist/cjs/getEnumeration.cjs +9 -14
  31. package/dist/cjs/getEnumeration.cjs.map +1 -1
  32. package/dist/cjs/getEnumeration.d.ts +27 -5
  33. package/dist/cjs/getTranslation.cjs +9 -14
  34. package/dist/cjs/getTranslation.cjs.map +1 -1
  35. package/dist/cjs/getTranslation.d.ts +23 -6
  36. package/dist/cjs/index.cjs +20 -27
  37. package/dist/cjs/index.cjs.map +1 -1
  38. package/dist/cjs/index.d.ts +11 -20
  39. package/dist/cjs/processDictionary/contentDictionary.d.cjs +4 -8
  40. package/dist/cjs/processDictionary/contentDictionary.d.d.ts +6 -9
  41. package/dist/cjs/processDictionary/index.cjs +15 -17
  42. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  43. package/dist/cjs/processDictionary/index.d.ts +6 -17
  44. package/dist/cjs/server/IntlayerServerProvider.cjs +46 -0
  45. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -0
  46. package/dist/cjs/server/IntlayerServerProvider.d.ts +37 -0
  47. package/dist/cjs/server/getLocaleTranslation.cjs +12 -19
  48. package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
  49. package/dist/cjs/server/getLocaleTranslation.d.ts +8 -7
  50. package/dist/cjs/server/index.cjs +20 -27
  51. package/dist/cjs/server/index.cjs.map +1 -1
  52. package/dist/cjs/server/index.d.ts +9 -13
  53. package/dist/cjs/server/serverContext.cjs +25 -31
  54. package/dist/cjs/server/serverContext.cjs.map +1 -1
  55. package/dist/cjs/server/serverContext.d.ts +16 -24
  56. package/dist/cjs/server/useIntlayer.cjs +12 -21
  57. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  58. package/dist/cjs/server/useIntlayer.d.ts +8 -3
  59. package/dist/cjs/server/useTraduction.cjs +12 -19
  60. package/dist/cjs/server/useTraduction.cjs.map +1 -1
  61. package/dist/cjs/server/useTraduction.d.ts +22 -4
  62. package/dist/cjs/useIntlayerBase.cjs +22 -31
  63. package/dist/cjs/useIntlayerBase.cjs.map +1 -1
  64. package/dist/cjs/useIntlayerBase.d.ts +7 -18
  65. package/dist/esm/ContentEditor/ContentEditor.d.mts +2 -2
  66. package/dist/esm/ContentEditor/ContentEditor.mjs +38 -29
  67. package/dist/esm/ContentEditor/contentRender.mjs +5 -3
  68. package/dist/esm/ContentEditor/index.d.mts +3 -3
  69. package/dist/esm/ContentEditor/index.mjs +3 -3
  70. package/dist/esm/IntlayerProvider.d.mts +9 -0
  71. package/dist/esm/IntlayerProvider.mjs +17 -0
  72. package/dist/esm/IntlayerProvider.mjs.map +1 -0
  73. package/dist/esm/client/IntlayerClientProvider.d.mts +24 -0
  74. package/dist/esm/client/IntlayerClientProvider.mjs +24 -0
  75. package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -0
  76. package/dist/esm/client/index.d.mts +10 -19
  77. package/dist/esm/client/index.mjs +14 -14
  78. package/dist/esm/client/index.mjs.map +1 -1
  79. package/dist/esm/client/useContent.d.mts +10 -8
  80. package/dist/esm/client/useContent.mjs +7 -5
  81. package/dist/esm/client/useContent.mjs.map +1 -1
  82. package/dist/esm/client/useIntlayer.d.mts +8 -3
  83. package/dist/esm/client/useIntlayer.mjs +9 -5
  84. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  85. package/dist/esm/client/useLocale.d.mts +8 -5
  86. package/dist/esm/client/useLocale.mjs +7 -5
  87. package/dist/esm/client/useLocale.mjs.map +1 -1
  88. package/dist/esm/client/useLocaleCookie.d.mts +12 -3
  89. package/dist/esm/client/useLocaleCookie.mjs +11 -5
  90. package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
  91. package/dist/esm/client/useTraduction.d.mts +22 -4
  92. package/dist/esm/client/useTraduction.mjs +7 -5
  93. package/dist/esm/client/useTraduction.mjs.map +1 -1
  94. package/dist/esm/getEnumeration.d.mts +27 -5
  95. package/dist/esm/getEnumeration.mjs +9 -4
  96. package/dist/esm/getEnumeration.mjs.map +1 -1
  97. package/dist/esm/getTranslation.d.mts +23 -6
  98. package/dist/esm/getTranslation.mjs +8 -4
  99. package/dist/esm/getTranslation.mjs.map +1 -1
  100. package/dist/esm/index.d.mts +11 -20
  101. package/dist/esm/index.mjs +9 -11
  102. package/dist/esm/index.mjs.map +1 -1
  103. package/dist/esm/processDictionary/contentDictionary.d.d.mts +6 -9
  104. package/dist/esm/processDictionary/contentDictionary.d.mjs +1 -1
  105. package/dist/esm/processDictionary/index.d.mts +6 -17
  106. package/dist/esm/processDictionary/index.mjs +25 -9
  107. package/dist/esm/processDictionary/index.mjs.map +1 -1
  108. package/dist/esm/server/IntlayerServerProvider.d.mts +37 -0
  109. package/dist/esm/server/IntlayerServerProvider.mjs +21 -0
  110. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -0
  111. package/dist/esm/server/getLocaleTranslation.d.mts +8 -7
  112. package/dist/esm/server/getLocaleTranslation.mjs +8 -6
  113. package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
  114. package/dist/esm/server/index.d.mts +9 -13
  115. package/dist/esm/server/index.mjs +10 -10
  116. package/dist/esm/server/index.mjs.map +1 -1
  117. package/dist/esm/server/serverContext.d.mts +16 -24
  118. package/dist/esm/server/serverContext.mjs +13 -6
  119. package/dist/esm/server/serverContext.mjs.map +1 -1
  120. package/dist/esm/server/useIntlayer.d.mts +8 -3
  121. package/dist/esm/server/useIntlayer.mjs +10 -6
  122. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  123. package/dist/esm/server/useTraduction.d.mts +22 -4
  124. package/dist/esm/server/useTraduction.mjs +8 -6
  125. package/dist/esm/server/useTraduction.mjs.map +1 -1
  126. package/dist/esm/useIntlayerBase.d.mts +7 -18
  127. package/dist/esm/useIntlayerBase.mjs +9 -4
  128. package/dist/esm/useIntlayerBase.mjs.map +1 -1
  129. package/package.json +10 -10
  130. package/src/IntlayerProvider.tsx +24 -0
  131. package/src/client/IntlayerClientProvider.tsx +45 -0
  132. package/src/client/index.ts +5 -5
  133. package/src/client/useContent.ts +3 -0
  134. package/src/client/useIntlayer.ts +7 -2
  135. package/src/client/useLocale.ts +5 -2
  136. package/src/client/useLocaleCookie.ts +9 -1
  137. package/src/client/useTraduction.ts +23 -3
  138. package/src/getEnumeration.ts +25 -0
  139. package/src/getTranslation.ts +21 -1
  140. package/src/index.ts +3 -4
  141. package/src/processDictionary/index.ts +1 -1
  142. package/src/server/IntlayerServerProvider.tsx +39 -0
  143. package/src/server/getLocaleTranslation.ts +5 -2
  144. package/src/server/index.ts +3 -3
  145. package/src/server/serverContext.ts +4 -4
  146. package/src/server/useIntlayer.ts +8 -2
  147. package/src/server/useTraduction.ts +23 -3
  148. package/src/useIntlayerBase.ts +4 -1
  149. package/dist/cjs/LocaleContextProvider.cjs +0 -49
  150. package/dist/cjs/LocaleContextProvider.cjs.map +0 -1
  151. package/dist/cjs/LocaleContextProvider.d.ts +0 -10
  152. package/dist/cjs/client/LocaleClientContextProvider.cjs +0 -54
  153. package/dist/cjs/client/LocaleClientContextProvider.cjs.map +0 -1
  154. package/dist/cjs/client/LocaleClientContextProvider.d.ts +0 -20
  155. package/dist/cjs/server/LocaleServerContextProvider.cjs +0 -49
  156. package/dist/cjs/server/LocaleServerContextProvider.cjs.map +0 -1
  157. package/dist/cjs/server/LocaleServerContextProvider.d.ts +0 -34
  158. package/dist/esm/LocaleContextProvider.d.mts +0 -10
  159. package/dist/esm/LocaleContextProvider.mjs +0 -15
  160. package/dist/esm/LocaleContextProvider.mjs.map +0 -1
  161. package/dist/esm/client/LocaleClientContextProvider.d.mts +0 -20
  162. package/dist/esm/client/LocaleClientContextProvider.mjs +0 -16
  163. package/dist/esm/client/LocaleClientContextProvider.mjs.map +0 -1
  164. package/dist/esm/server/LocaleServerContextProvider.d.mts +0 -34
  165. package/dist/esm/server/LocaleServerContextProvider.mjs +0 -14
  166. package/dist/esm/server/LocaleServerContextProvider.mjs.map +0 -1
  167. package/src/LocaleContextProvider.tsx +0 -26
  168. package/src/client/LocaleClientContextProvider.tsx +0 -35
  169. package/src/server/LocaleServerContextProvider.tsx +0 -24
@@ -8,35 +8,28 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var useTraduction_exports = {};
24
20
  __export(useTraduction_exports, {
25
- useTraduction: () => useTraduction,
21
+ useTraduction: () => useTraduction
26
22
  });
27
23
  module.exports = __toCommonJS(useTraduction_exports);
28
- var import_getTranslation = require("../getTranslation.cjs");
29
- var import_LocaleServerContextProvider = require("./LocaleServerContextProvider.cjs");
30
- var import_serverContext = require("./serverContext.cjs");
24
+ var import_getTranslation = require('../getTranslation.cjs');
25
+ var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
26
+ var import_serverContext = require('./serverContext.cjs');
31
27
  const useTraduction = (languageContent) => {
32
- const locale = (0, import_serverContext.getServerContext)(
33
- import_LocaleServerContextProvider.LocaleServerContext
34
- );
28
+ const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
35
29
  return (0, import_getTranslation.getTranslation)(languageContent, locale);
36
30
  };
37
31
  // Annotate the CommonJS export names for ESM import in node:
38
- 0 &&
39
- (module.exports = {
40
- useTraduction,
41
- });
42
- //# sourceMappingURL=useTraduction.cjs.map
32
+ 0 && (module.exports = {
33
+ useTraduction
34
+ });
35
+ //# sourceMappingURL=useTraduction.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { LocaleServerContext } from './LocaleServerContextProvider';\nimport { getServerContext } from './serverContext';\n\nexport const useTraduction = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(LocaleServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAA+B;AAC/B,yCAAoC;AACpC,2BAAiC;AAE1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,sDAAmB;AAE5D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * },\n * 'fr');\n * // 'Bonjour'\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAA+B;AAC/B,oCAAsC;AACtC,2BAAiC;AAsB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,mDAAqB;AAE9D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -1,7 +1,25 @@
1
- import { LanguageContent } from "@intlayer/core";
1
+ import { LanguageContent } from '@intlayer/core';
2
2
 
3
- declare const useTraduction: <Content>(
4
- languageContent: LanguageContent<Content>
5
- ) => Content;
3
+ /**
4
+ * On the server side, hook to get the translation content based on the locale
5
+ *
6
+ * If not locale found, it will return the content related to the default locale.
7
+ *
8
+ * Return either the content editor, or the content itself depending on the configuration.
9
+ *
10
+ * Usage:
11
+ *
12
+ * const content = getTranslation<string>({
13
+ * en: 'Hello',
14
+ * fr: 'Bonjour',
15
+ * },
16
+ * 'fr');
17
+ * // 'Bonjour'
18
+ *
19
+ * Using TypeScript:
20
+ * - this function will require each locale to be defined if defined in the project configuration.
21
+ * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
22
+ */
23
+ declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
6
24
 
7
25
  export { useTraduction };
@@ -10,47 +10,38 @@ var __export = (target, all) => {
10
10
  __defProp(target, name, { get: all[name], enumerable: true });
11
11
  };
12
12
  var __copyProps = (to, from, except, desc) => {
13
- if ((from && typeof from === "object") || typeof from === "function") {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
14
  for (let key of __getOwnPropNames(from))
15
15
  if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, {
17
- get: () => from[key],
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
19
- });
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
17
  }
21
18
  return to;
22
19
  };
23
- var __toESM = (mod, isNodeMode, target) => (
24
- (target = mod != null ? __create(__getProtoOf(mod)) : {}),
25
- __copyProps(
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
31
- ? __defProp(target, "default", { value: mod, enumerable: true })
32
- : target,
33
- mod
34
- )
35
- );
36
- var __toCommonJS = (mod) =>
37
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
29
  var useIntlayerBase_exports = {};
39
30
  __export(useIntlayerBase_exports, {
40
- useIntlayerBase: () => useIntlayerBase,
31
+ useIntlayerBase: () => useIntlayerBase
41
32
  });
42
33
  module.exports = __toCommonJS(useIntlayerBase_exports);
43
- var import_dictionaries_entry = __toESM(
44
- require("@intlayer/dictionaries-entry")
45
- );
46
- var import_processDictionary = require("./processDictionary/index.cjs");
34
+ var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
35
+ var import_processDictionary = require('./processDictionary/index.cjs');
47
36
  const useIntlayerBase = (id, locale) => {
48
37
  const dictionary = import_dictionaries_entry.default[id];
49
- return (0, import_processDictionary.processDictionary)(dictionary, locale);
38
+ return (0, import_processDictionary.processDictionary)(
39
+ dictionary,
40
+ locale
41
+ );
50
42
  };
51
43
  // Annotate the CommonJS export names for ESM import in node:
52
- 0 &&
53
- (module.exports = {
54
- useIntlayerBase,
55
- });
56
- //# sourceMappingURL=useIntlayerBase.cjs.map
44
+ 0 && (module.exports = {
45
+ useIntlayerBase
46
+ });
47
+ //# sourceMappingURL=useIntlayerBase.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Locales } from '@intlayer/config/client';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAY3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
1
+ {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\n/**\n * Hook that picking one dictionary by its id and return the content.\n */\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAe3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
@@ -1,23 +1,12 @@
1
- import { Locales } from "@intlayer/config/client";
2
- import { IntlayerDictionaryTypesConnector } from "intlayer";
3
-
4
- /**
5
- * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.
6
- * Using an external package allow to alias it in the bundle configuration (such as webpack).
7
- * The alias allow hot reload the app (such as nextjs) on any dictionary change.
8
- */
1
+ import { Locales } from '@intlayer/config/client';
2
+ import { IntlayerDictionaryTypesConnector } from 'intlayer';
9
3
 
10
4
  type StringFallback<T> = T extends never ? string : T;
11
5
  type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
12
- type UseIntlayer = <T extends DictionaryKeys>(
13
- id: T,
14
- locale?: Locales
15
- ) => IntlayerDictionaryTypesConnector[T];
6
+ type UseIntlayer = <T extends DictionaryKeys>(id: T, locale?: Locales) => IntlayerDictionaryTypesConnector[T];
7
+ /**
8
+ * Hook that picking one dictionary by its id and return the content.
9
+ */
16
10
  declare const useIntlayerBase: UseIntlayer;
17
11
 
18
- export {
19
- type DictionaryKeys,
20
- type StringFallback,
21
- type UseIntlayer,
22
- useIntlayerBase,
23
- };
12
+ export { type DictionaryKeys, type StringFallback, type UseIntlayer, useIntlayerBase };
@@ -1,7 +1,7 @@
1
- import { FC } from "react";
1
+ import { FC } from 'react';
2
2
 
3
3
  type ContentEditorProps = {
4
- children?: string;
4
+ children?: string;
5
5
  };
6
6
  declare const ContentEditor: FC<ContentEditorProps>;
7
7
 
@@ -1,6 +1,11 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useEffect, useState, useRef, useCallback } from "react";
3
+ import {
4
+ useEffect,
5
+ useState,
6
+ useRef,
7
+ useCallback
8
+ } from "react";
4
9
  const PRESS_DETECT_DURATION = 500;
5
10
  const ContentEditor = ({ children }) => {
6
11
  const divRef = useRef(null);
@@ -51,32 +56,36 @@ const ContentEditor = ({ children }) => {
51
56
  const handleOnBlur = () => {
52
57
  setIsEditing(false);
53
58
  };
54
- const onContentChange = (_e) => {};
55
- return /* @__PURE__ */ jsx("div", {
56
- role: "textbox",
57
- tabIndex: 0,
58
- onKeyUp: () => null,
59
- contentEditable: isEditing,
60
- onInput: onContentChange,
61
- onClick: handleOnClick,
62
- onMouseDown: handleMouseDown,
63
- onMouseUp: handleMouseUp,
64
- onMouseLeave: handleMouseUp,
65
- onTouchStart: handleMouseDown,
66
- onTouchEnd: handleMouseUp,
67
- onTouchCancel: handleMouseUp,
68
- onBlur: handleOnBlur,
69
- suppressContentEditableWarning: true,
70
- style: isEditing
71
- ? {
72
- backgroundColor: "transparent",
73
- cursor: "text",
74
- display: "inline",
75
- }
76
- : { cursor: "pointer", display: "inline" },
77
- ref: divRef,
78
- children,
79
- });
59
+ const onContentChange = (_e) => {
60
+ };
61
+ return /* @__PURE__ */ jsx(
62
+ "div",
63
+ {
64
+ role: "textbox",
65
+ tabIndex: 0,
66
+ onKeyUp: () => null,
67
+ contentEditable: isEditing,
68
+ onInput: onContentChange,
69
+ onClick: handleOnClick,
70
+ onMouseDown: handleMouseDown,
71
+ onMouseUp: handleMouseUp,
72
+ onMouseLeave: handleMouseUp,
73
+ onTouchStart: handleMouseDown,
74
+ onTouchEnd: handleMouseUp,
75
+ onTouchCancel: handleMouseUp,
76
+ onBlur: handleOnBlur,
77
+ suppressContentEditableWarning: true,
78
+ style: isEditing ? {
79
+ backgroundColor: "transparent",
80
+ cursor: "text",
81
+ display: "inline"
82
+ } : { cursor: "pointer", display: "inline" },
83
+ ref: divRef,
84
+ children
85
+ }
86
+ );
87
+ };
88
+ export {
89
+ ContentEditor
80
90
  };
81
- export { ContentEditor };
82
- //# sourceMappingURL=ContentEditor.mjs.map
91
+ //# sourceMappingURL=ContentEditor.mjs.map
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { ContentEditor } from "./ContentEditor.mjs";
2
+ import { ContentEditor } from './ContentEditor.mjs';
3
3
  const contentRender = (content) => {
4
4
  const isEditable = process.env.NODE_ENV === "development";
5
5
  if (isEditable && ContentEditor) {
@@ -7,5 +7,7 @@ const contentRender = (content) => {
7
7
  }
8
8
  return content;
9
9
  };
10
- export { contentRender };
11
- //# sourceMappingURL=contentRender.mjs.map
10
+ export {
11
+ contentRender
12
+ };
13
+ //# sourceMappingURL=contentRender.mjs.map
@@ -1,3 +1,3 @@
1
- export { ContentEditor } from "./ContentEditor.mjs";
2
- export { contentRender } from "./contentRender.mjs";
3
- import "react";
1
+ export { ContentEditor } from './ContentEditor.mjs';
2
+ export { contentRender } from './contentRender.mjs';
3
+ import 'react';
@@ -1,3 +1,3 @@
1
- export * from "./ContentEditor.mjs";
2
- export * from "./contentRender.mjs";
3
- //# sourceMappingURL=index.mjs.map
1
+ export * from './ContentEditor.mjs';
2
+ export * from './contentRender.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { IntlayerClientProviderProps } from './client/IntlayerClientProvider.mjs';
3
+ import { IntlayerServerProviderProps } from './server/IntlayerServerProvider.mjs';
4
+ import '@intlayer/config/client';
5
+
6
+ type IntlayerProviderProps = IntlayerClientProviderProps & IntlayerServerProviderProps;
7
+ declare const IntlayerProvider: FC<IntlayerProviderProps>;
8
+
9
+ export { IntlayerProvider };
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
3
+ import {
4
+ IntlayerClientProvider
5
+ } from './client/IntlayerClientProvider.mjs';
6
+ import {
7
+ IntlayerServerProvider
8
+ } from './server/IntlayerServerProvider.mjs';
9
+ const defaultLocale = intlayerIntlConfiguration.defaultLocale;
10
+ const IntlayerProvider = ({
11
+ children,
12
+ locale = defaultLocale
13
+ }) => /* @__PURE__ */ jsx(IntlayerServerProvider, { locale, children: /* @__PURE__ */ jsx(IntlayerClientProvider, { locale, children }) });
14
+ export {
15
+ IntlayerProvider
16
+ };
17
+ //# sourceMappingURL=IntlayerProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport type { FC } from 'react';\nimport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/IntlayerClientProvider';\nimport {\n IntlayerServerProvider,\n type IntlayerServerProviderProps,\n} from './server/IntlayerServerProvider';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\ntype IntlayerProviderProps = IntlayerClientProviderProps &\n IntlayerServerProviderProps;\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerProvider locale={locale}>\n <IntlayerClientProvider locale={locale}>{children}</IntlayerClientProvider>\n </IntlayerServerProvider>\n);\n"],"mappings":"AAqBI;AArBJ,SAAS,iCAAiC;AAE1C;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,gBAAgB,0BAA0B;AAKzC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,oBAAC,0BAAuB,QACtB,8BAAC,0BAAuB,QAAiB,UAAS,GACpD;","names":[]}
@@ -0,0 +1,24 @@
1
+ import * as react from 'react';
2
+ import { PropsWithChildren, FC } from 'react';
3
+ import { Locales } from '@intlayer/config/client';
4
+
5
+ type IntlayerValue = {
6
+ locale: Locales;
7
+ };
8
+ /**
9
+ * Context that store the current locale on the client side
10
+ */
11
+ declare const IntlayerClientContext: react.Context<IntlayerValue>;
12
+ /**
13
+ * Hook that provides the current locale
14
+ */
15
+ declare const useIntlayerContext: () => IntlayerValue;
16
+ type IntlayerClientProviderProps = PropsWithChildren & {
17
+ locale: Locales;
18
+ };
19
+ /**
20
+ * Provider that store the current locale on the client side
21
+ */
22
+ declare const IntlayerClientProvider: FC<IntlayerClientProviderProps>;
23
+
24
+ export { IntlayerClientContext, IntlayerClientProvider, type IntlayerClientProviderProps, useIntlayerContext };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import {
4
+ intlayerIntlConfiguration
5
+ } from "@intlayer/config/client";
6
+ import {
7
+ createContext,
8
+ useContext
9
+ } from "react";
10
+ import { localeCookie } from './useLocaleCookie.mjs';
11
+ const IntlayerClientContext = createContext({
12
+ locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale
13
+ });
14
+ const useIntlayerContext = () => useContext(IntlayerClientContext);
15
+ const IntlayerClientProvider = ({
16
+ locale,
17
+ children
18
+ }) => /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value: { locale }, children });
19
+ export {
20
+ IntlayerClientContext,
21
+ IntlayerClientProvider,
22
+ useIntlayerContext
23
+ };
24
+ //# sourceMappingURL=IntlayerClientProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n intlayerIntlConfiguration,\n type Locales,\n} from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n type FC,\n} from 'react';\nimport { localeCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => (\n <IntlayerClientContext.Provider value={{ locale }}>\n {children}\n </IntlayerClientContext.Provider>\n);\n"],"mappings":";AAyCE;AAvCF;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAStB,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,0BAA0B;AACpD,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,OAAO,GAC7C,UACH;","names":[]}
@@ -1,19 +1,10 @@
1
- export {
2
- LocaleClientContext,
3
- LocaleClientContextProvider,
4
- LocaleClientContextProviderProps,
5
- useLocaleContext,
6
- } from "./LocaleClientContextProvider.mjs";
7
- export { useIntlayer } from "./useIntlayer.mjs";
8
- export { useLocale } from "./useLocale.mjs";
9
- export { useTraduction } from "./useTraduction.mjs";
10
- export {
11
- localeCookie,
12
- setLocaleCookie,
13
- useLocaleCookie,
14
- } from "./useLocaleCookie.mjs";
15
- import "react";
16
- import "@intlayer/config/client";
17
- import "../useIntlayerBase.mjs";
18
- import "intlayer";
19
- import "@intlayer/core";
1
+ export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.mjs';
2
+ export { useIntlayer } from './useIntlayer.mjs';
3
+ export { useLocale } from './useLocale.mjs';
4
+ export { useTraduction } from './useTraduction.mjs';
5
+ export { localeCookie, setLocaleCookie, useLocaleCookie } from './useLocaleCookie.mjs';
6
+ import 'react';
7
+ import '@intlayer/config/client';
8
+ import '../useIntlayerBase.mjs';
9
+ import 'intlayer';
10
+ import '@intlayer/core';
@@ -1,25 +1,25 @@
1
1
  import {
2
- LocaleClientContext,
3
- useLocaleContext,
4
- LocaleClientContextProvider,
5
- } from "./LocaleClientContextProvider.mjs";
6
- import { useIntlayer } from "./useIntlayer.mjs";
7
- import { useLocale } from "./useLocale.mjs";
8
- import { useTraduction } from "./useTraduction.mjs";
2
+ IntlayerClientContext,
3
+ useIntlayerContext,
4
+ IntlayerClientProvider
5
+ } from './IntlayerClientProvider.mjs';
6
+ import { useIntlayer } from './useIntlayer.mjs';
7
+ import { useLocale } from './useLocale.mjs';
8
+ import { useTraduction } from './useTraduction.mjs';
9
9
  import {
10
10
  useLocaleCookie,
11
11
  localeCookie,
12
- setLocaleCookie,
13
- } from "./useLocaleCookie.mjs";
12
+ setLocaleCookie
13
+ } from './useLocaleCookie.mjs';
14
14
  export {
15
- LocaleClientContext,
16
- LocaleClientContextProvider,
15
+ IntlayerClientContext as IntlayerClient,
16
+ IntlayerClientProvider,
17
17
  localeCookie,
18
18
  setLocaleCookie,
19
19
  useIntlayer,
20
+ useIntlayerContext,
20
21
  useLocale,
21
- useLocaleContext,
22
22
  useLocaleCookie,
23
- useTraduction,
23
+ useTraduction
24
24
  };
25
- //# sourceMappingURL=index.mjs.map
25
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { LocaleClientContextProviderProps } from './LocaleClientContextProvider';\nexport {\n LocaleClientContext,\n useLocaleContext,\n LocaleClientContextProvider,\n} from './LocaleClientContextProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { IntlayerClientProviderProps } from './IntlayerClientProvider';\nexport {\n IntlayerClientContext as IntlayerClient,\n useIntlayerContext,\n IntlayerClientProvider,\n} from './IntlayerClientProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AACA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -1,12 +1,14 @@
1
- import * as intlayer from "intlayer";
2
- import { LanguageContent } from "@intlayer/core";
1
+ import * as _intlayer_config_client from '@intlayer/config/client';
2
+ import * as intlayer from 'intlayer';
3
+ import { LanguageContent } from '@intlayer/core';
3
4
 
4
- declare const useContent: <Content>(
5
- languageContent: LanguageContent<Content>
6
- ) => {
7
- locale: intlayer.Locales;
8
- content: Content;
9
- t: <Content_1>(languageContent: LanguageContent<Content_1>) => Content_1;
5
+ /**
6
+ * On the client side, hook to get the translation content based on the locale
7
+ */
8
+ declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
9
+ locale: intlayer.Locales;
10
+ content: Content;
11
+ t: <Content_1 = string>(languageContent: Partial<Record<_intlayer_config_client.LocalesValues, Content_1>>) => Content_1;
10
12
  };
11
13
 
12
14
  export { useContent };
@@ -1,13 +1,15 @@
1
- import { useLocale } from "./useLocale.mjs";
2
- import { useTraduction } from "./useTraduction.mjs";
1
+ import { useLocale } from './useLocale.mjs';
2
+ import { useTraduction } from './useTraduction.mjs';
3
3
  const useContent = (languageContent) => {
4
4
  const { locale } = useLocale();
5
5
  const content = useTraduction(languageContent);
6
6
  return {
7
7
  locale,
8
8
  content,
9
- t: useTraduction,
9
+ t: useTraduction
10
10
  };
11
11
  };
12
- export { useContent };
13
- //# sourceMappingURL=useContent.mjs.map
12
+ export {
13
+ useContent
14
+ };
15
+ //# sourceMappingURL=useContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocale } from './useLocale';\nimport { useTraduction } from './useTraduction';\n\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocale();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAEvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocale } from './useLocale';\nimport { useTraduction } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocale();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -1,7 +1,12 @@
1
- import { UseIntlayer } from "../useIntlayerBase.mjs";
2
- import "@intlayer/config/client";
3
- import "intlayer";
1
+ import { UseIntlayer } from '../useIntlayerBase.mjs';
2
+ import '@intlayer/config/client';
3
+ import 'intlayer';
4
4
 
5
+ /**
6
+ * On the client side, Hook that picking one dictionary by its id and return the content
7
+ *
8
+ * If the locale is not provided, it will use the locale from the client context
9
+ */
5
10
  declare const useIntlayer: UseIntlayer;
6
11
 
7
12
  export { useIntlayer };
@@ -1,11 +1,15 @@
1
1
  "use client";
2
2
  import { useContext } from "react";
3
- import { useIntlayerBase } from "../useIntlayerBase.mjs";
4
- import { LocaleClientContext } from "./LocaleClientContextProvider.mjs";
3
+ import {
4
+ useIntlayerBase
5
+ } from '../useIntlayerBase.mjs';
6
+ import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
5
7
  const useIntlayer = (id, locale) => {
6
- const { locale: currentLocale } = useContext(LocaleClientContext);
8
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
7
9
  const localeTarget = locale ?? currentLocale;
8
10
  return useIntlayerBase(id, localeTarget);
9
11
  };
10
- export { useIntlayer };
11
- //# sourceMappingURL=useIntlayer.mjs.map
12
+ export {
13
+ useIntlayer
14
+ };
15
+ //# sourceMappingURL=useIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext } from 'react';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { LocaleClientContext } from './LocaleClientContextProvider';\n\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(LocaleClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,2BAA2B;AAE7B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,mBAAmB;AAChE,QAAM,eAAe,UAAU;AAE/B,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext } from 'react';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AAO/B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
@@ -1,10 +1,13 @@
1
- import * as _intlayer_config_client from "@intlayer/config/client";
1
+ import * as _intlayer_config_client from '@intlayer/config/client';
2
2
 
3
+ /**
4
+ * On the client side, hook to get the current locale and all related fields
5
+ */
3
6
  declare const useLocale: () => {
4
- locale: _intlayer_config_client.Locales;
5
- defaultLocale: _intlayer_config_client.Locales;
6
- availableLocales: _intlayer_config_client.Locales[];
7
- localeList: _intlayer_config_client.Locales[];
7
+ locale: _intlayer_config_client.Locales;
8
+ defaultLocale: _intlayer_config_client.Locales;
9
+ availableLocales: _intlayer_config_client.Locales[];
10
+ localeList: _intlayer_config_client.Locales[];
8
11
  };
9
12
 
10
13
  export { useLocale };