react-intlayer 4.1.11 → 5.0.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 (205) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/{getEnumeration.cjs → IntlayerNode.cjs} +14 -13
  3. package/dist/cjs/IntlayerNode.cjs.map +1 -0
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  6. package/dist/cjs/client/index.cjs +2 -5
  7. package/dist/cjs/client/index.cjs.map +1 -1
  8. package/dist/cjs/client/t.cjs +2 -2
  9. package/dist/cjs/client/t.cjs.map +1 -1
  10. package/dist/cjs/client/useContent.cjs +2 -2
  11. package/dist/cjs/client/useContent.cjs.map +1 -1
  12. package/dist/cjs/client/useDictionary.cjs +3 -3
  13. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  14. package/dist/cjs/client/useIntlayer.cjs +7 -4
  15. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  16. package/dist/cjs/client/useIntlayerAsync.cjs +3 -4
  17. package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -1
  18. package/dist/cjs/client/useLocale.cjs +1 -1
  19. package/dist/cjs/client/useLocale.cjs.map +1 -1
  20. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
  21. package/dist/cjs/client/useTraduction.cjs +5 -5
  22. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  23. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -3
  24. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  25. package/dist/cjs/editor/IntlayerEditorProvider.cjs +3 -1
  26. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  27. package/dist/cjs/editor/renderContentEditor.cjs +5 -4
  28. package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
  29. package/dist/cjs/getDictionary.cjs +13 -13
  30. package/dist/cjs/getDictionary.cjs.map +1 -1
  31. package/dist/cjs/getIntlayer.cjs +10 -29
  32. package/dist/cjs/getIntlayer.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +5 -13
  34. package/dist/cjs/index.cjs.map +1 -1
  35. package/dist/cjs/{getIntlayerAsync.cjs → markdown/MarkdownProvider.cjs} +18 -19
  36. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -0
  37. package/dist/cjs/{server/useTraduction.cjs → markdown/MarkdownRenderer.cjs} +17 -12
  38. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -0
  39. package/dist/cjs/markdown/index.cjs +27 -0
  40. package/dist/cjs/markdown/index.cjs.map +1 -0
  41. package/dist/cjs/{getTranslation.cjs → markdown/renderMarkdown.cjs} +13 -16
  42. package/dist/cjs/markdown/renderMarkdown.cjs.map +1 -0
  43. package/dist/cjs/plugins.cjs +85 -0
  44. package/dist/cjs/plugins.cjs.map +1 -0
  45. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  46. package/dist/cjs/server/index.cjs +2 -8
  47. package/dist/cjs/server/index.cjs.map +1 -1
  48. package/dist/cjs/server/t.cjs +5 -3
  49. package/dist/cjs/server/t.cjs.map +1 -1
  50. package/dist/cjs/server/useDictionary.cjs +2 -2
  51. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  52. package/dist/cjs/server/useIntlayer.cjs +2 -2
  53. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  54. package/dist/esm/IntlayerNode.mjs +16 -0
  55. package/dist/esm/IntlayerNode.mjs.map +1 -0
  56. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  57. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  58. package/dist/esm/client/index.mjs +1 -3
  59. package/dist/esm/client/index.mjs.map +1 -1
  60. package/dist/esm/client/t.mjs +1 -1
  61. package/dist/esm/client/t.mjs.map +1 -1
  62. package/dist/esm/client/useContent.mjs +3 -3
  63. package/dist/esm/client/useContent.mjs.map +1 -1
  64. package/dist/esm/client/useDictionary.mjs +3 -3
  65. package/dist/esm/client/useDictionary.mjs.map +1 -1
  66. package/dist/esm/client/useIntlayer.mjs +8 -7
  67. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  68. package/dist/esm/client/useIntlayerAsync.mjs +5 -5
  69. package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
  70. package/dist/esm/client/useLocale.mjs +1 -1
  71. package/dist/esm/client/useLocale.mjs.map +1 -1
  72. package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
  73. package/dist/esm/client/useTraduction.mjs +3 -3
  74. package/dist/esm/client/useTraduction.mjs.map +1 -1
  75. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -3
  76. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  77. package/dist/esm/editor/IntlayerEditorProvider.mjs +3 -1
  78. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  79. package/dist/esm/editor/renderContentEditor.mjs +5 -4
  80. package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
  81. package/dist/esm/getDictionary.mjs +18 -14
  82. package/dist/esm/getDictionary.mjs.map +1 -1
  83. package/dist/esm/getIntlayer.mjs +15 -20
  84. package/dist/esm/getIntlayer.mjs.map +1 -1
  85. package/dist/esm/index.mjs +3 -9
  86. package/dist/esm/index.mjs.map +1 -1
  87. package/dist/esm/markdown/MarkdownProvider.mjs +19 -0
  88. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -0
  89. package/dist/esm/markdown/MarkdownRenderer.mjs +16 -0
  90. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -0
  91. package/dist/esm/markdown/index.mjs +4 -0
  92. package/dist/esm/markdown/index.mjs.map +1 -0
  93. package/dist/esm/markdown/renderMarkdown.mjs +11 -0
  94. package/dist/esm/markdown/renderMarkdown.mjs.map +1 -0
  95. package/dist/esm/plugins.mjs +61 -0
  96. package/dist/esm/plugins.mjs.map +1 -0
  97. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  98. package/dist/esm/server/index.mjs +1 -5
  99. package/dist/esm/server/index.mjs.map +1 -1
  100. package/dist/esm/server/t.mjs +4 -2
  101. package/dist/esm/server/t.mjs.map +1 -1
  102. package/dist/esm/server/useDictionary.mjs +2 -2
  103. package/dist/esm/server/useDictionary.mjs.map +1 -1
  104. package/dist/esm/server/useIntlayer.mjs +2 -4
  105. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  106. package/dist/types/IntlayerNode.d.ts +9 -0
  107. package/dist/types/IntlayerNode.d.ts.map +1 -0
  108. package/dist/types/UI/ContentSelector.d.ts +1 -1
  109. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  110. package/dist/types/client/IntlayerProvider.d.ts +4 -4
  111. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  112. package/dist/types/client/index.d.ts +0 -1
  113. package/dist/types/client/index.d.ts.map +1 -1
  114. package/dist/types/client/t.d.ts +1 -1
  115. package/dist/types/client/t.d.ts.map +1 -1
  116. package/dist/types/client/useContent.d.ts +1 -1
  117. package/dist/types/client/useDictionary.d.ts +3 -2
  118. package/dist/types/client/useDictionary.d.ts.map +1 -1
  119. package/dist/types/client/useIntlayer.d.ts +4 -2
  120. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  121. package/dist/types/client/useIntlayerAsync.d.ts +4 -5
  122. package/dist/types/client/useIntlayerAsync.d.ts.map +1 -1
  123. package/dist/types/client/useLocale.d.ts +3 -3
  124. package/dist/types/client/useLocale.d.ts.map +1 -1
  125. package/dist/types/client/useLocaleBase.d.ts +2 -2
  126. package/dist/types/client/useLocaleCookie.d.ts +4 -4
  127. package/dist/types/client/useLocaleCookie.d.ts.map +1 -1
  128. package/dist/types/client/useTraduction.d.ts +3 -3
  129. package/dist/types/client/useTraduction.d.ts.map +1 -1
  130. package/dist/types/editor/ContentSelectorWrapper.d.ts +2 -8
  131. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  132. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  133. package/dist/types/editor/renderContentEditor.d.ts +3 -7
  134. package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
  135. package/dist/types/getDictionary.d.ts +4 -12
  136. package/dist/types/getDictionary.d.ts.map +1 -1
  137. package/dist/types/getIntlayer.d.ts +4 -34
  138. package/dist/types/getIntlayer.d.ts.map +1 -1
  139. package/dist/types/index.d.ts +8 -5
  140. package/dist/types/index.d.ts.map +1 -1
  141. package/dist/types/markdown/MarkdownProvider.d.ts +9 -0
  142. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -0
  143. package/dist/types/markdown/MarkdownRenderer.d.ts +5 -0
  144. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -0
  145. package/dist/types/markdown/index.d.ts +4 -0
  146. package/dist/types/markdown/index.d.ts.map +1 -0
  147. package/dist/types/markdown/renderMarkdown.d.ts +3 -0
  148. package/dist/types/markdown/renderMarkdown.d.ts.map +1 -0
  149. package/dist/types/plugins.d.ts +48 -0
  150. package/dist/types/plugins.d.ts.map +1 -0
  151. package/dist/types/server/IntlayerServerProvider.d.ts +7 -7
  152. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
  153. package/dist/types/server/index.d.ts +0 -2
  154. package/dist/types/server/index.d.ts.map +1 -1
  155. package/dist/types/server/t.d.ts +20 -4
  156. package/dist/types/server/t.d.ts.map +1 -1
  157. package/dist/types/server/useDictionary.d.ts +3 -2
  158. package/dist/types/server/useDictionary.d.ts.map +1 -1
  159. package/dist/types/server/useIntlayer.d.ts +3 -2
  160. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  161. package/package.json +15 -15
  162. package/dist/cjs/getEnumeration.cjs.map +0 -1
  163. package/dist/cjs/getIntlayerAsync.cjs.map +0 -1
  164. package/dist/cjs/getTranslation.cjs.map +0 -1
  165. package/dist/cjs/processDictionary/contentDictionary.cjs +0 -17
  166. package/dist/cjs/processDictionary/contentDictionary.cjs.map +0 -1
  167. package/dist/cjs/processDictionary/index.cjs +0 -201
  168. package/dist/cjs/processDictionary/index.cjs.map +0 -1
  169. package/dist/cjs/recursiveTransformContent.cjs +0 -54
  170. package/dist/cjs/recursiveTransformContent.cjs.map +0 -1
  171. package/dist/cjs/server/getLocaleTranslation.cjs +0 -43
  172. package/dist/cjs/server/getLocaleTranslation.cjs.map +0 -1
  173. package/dist/cjs/server/useTraduction.cjs.map +0 -1
  174. package/dist/esm/getEnumeration.mjs +0 -12
  175. package/dist/esm/getEnumeration.mjs.map +0 -1
  176. package/dist/esm/getIntlayerAsync.mjs +0 -18
  177. package/dist/esm/getIntlayerAsync.mjs.map +0 -1
  178. package/dist/esm/getTranslation.mjs +0 -14
  179. package/dist/esm/getTranslation.mjs.map +0 -1
  180. package/dist/esm/processDictionary/contentDictionary.mjs +0 -1
  181. package/dist/esm/processDictionary/contentDictionary.mjs.map +0 -1
  182. package/dist/esm/processDictionary/index.mjs +0 -179
  183. package/dist/esm/processDictionary/index.mjs.map +0 -1
  184. package/dist/esm/recursiveTransformContent.mjs +0 -32
  185. package/dist/esm/recursiveTransformContent.mjs.map +0 -1
  186. package/dist/esm/server/getLocaleTranslation.mjs +0 -19
  187. package/dist/esm/server/getLocaleTranslation.mjs.map +0 -1
  188. package/dist/esm/server/useTraduction.mjs +0 -11
  189. package/dist/esm/server/useTraduction.mjs.map +0 -1
  190. package/dist/types/getEnumeration.d.ts +0 -31
  191. package/dist/types/getEnumeration.d.ts.map +0 -1
  192. package/dist/types/getIntlayerAsync.d.ts +0 -13
  193. package/dist/types/getIntlayerAsync.d.ts.map +0 -1
  194. package/dist/types/getTranslation.d.ts +0 -25
  195. package/dist/types/getTranslation.d.ts.map +0 -1
  196. package/dist/types/processDictionary/contentDictionary.d.ts +0 -14
  197. package/dist/types/processDictionary/contentDictionary.d.ts.map +0 -1
  198. package/dist/types/processDictionary/index.d.ts +0 -9
  199. package/dist/types/processDictionary/index.d.ts.map +0 -1
  200. package/dist/types/recursiveTransformContent.d.ts +0 -27
  201. package/dist/types/recursiveTransformContent.d.ts.map +0 -1
  202. package/dist/types/server/getLocaleTranslation.d.ts +0 -9
  203. package/dist/types/server/getLocaleTranslation.d.ts.map +0 -1
  204. package/dist/types/server/useTraduction.d.ts +0 -24
  205. package/dist/types/server/useTraduction.d.ts.map +0 -1
@@ -1,12 +1,12 @@
1
1
  import { useLocaleBase } from "./useLocaleBase.mjs";
2
- import { useTraduction } from "./useTraduction.mjs";
2
+ import { useTranslation } from "./useTraduction.mjs";
3
3
  const useContent = (languageContent) => {
4
4
  const { locale } = useLocaleBase();
5
- const content = useTraduction(languageContent);
5
+ const content = useTranslation(languageContent);
6
6
  return {
7
7
  locale,
8
8
  content,
9
- t: useTraduction
9
+ t: useTranslation
10
10
  };
11
11
  };
12
12
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocaleBase } from './useLocaleBase';\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 } = useLocaleBase();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,cAAc;AAEjC,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 { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } 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 } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":"AACA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAKxB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,cAAc;AAEjC,QAAM,UAAU,eAAe,eAAe;AAE9C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { useContext } from "react";
3
- import { getDictionary } from "../getDictionary.mjs";
4
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
- const useDictionary = (dictionary, locale, isRenderEditor = false) => {
4
+ import { getDictionary } from "../getDictionary.mjs";
5
+ const useDictionary = (dictionary, locale) => {
6
6
  const { locale: currentLocale } = useContext(IntlayerClientContext);
7
7
  const localeTarget = locale ?? currentLocale;
8
- return getDictionary(dictionary, localeTarget, isRenderEditor);
8
+ return getDictionary(dictionary, localeTarget);
9
9
  };
10
10
  export {
11
11
  useDictionary
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { DeclarationContent } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary, type UseDictionary } 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: UseDictionary = <T extends DeclarationContent>(\n dictionary: T,\n locale?: Locales,\n isRenderEditor = false\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary(dictionary, localeTarget, isRenderEditor);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAyC;AAClD,SAAS,6BAA6B;AAO/B,MAAM,gBAA+B,CAC1C,YACA,QACA,iBAAiB,UACd;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,cAAc,YAAY,cAAc,cAAc;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { getDictionary } from '../getDictionary';\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?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAOvB,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,cAAc,YAAY,YAAY;AAC/C;","names":[]}
@@ -1,19 +1,20 @@
1
1
  "use client";
2
2
  import { useChangedContent } from "@intlayer/editor-react";
3
3
  import { useContext } from "react";
4
- import { getDictionary } from "../getDictionary.mjs";
5
- import {
6
- getIntlayer
7
- } from "../getIntlayer.mjs";
8
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
9
- const useIntlayer = (key, locale, isRenderEditor = true) => {
5
+ import { getDictionary } from "../getDictionary.mjs";
6
+ import { getIntlayer } from "../getIntlayer.mjs";
7
+ const useIntlayer = (key, locale) => {
10
8
  const { locale: currentLocale } = useContext(IntlayerClientContext);
11
9
  const { changedContent } = useChangedContent();
12
10
  const localeTarget = locale ?? currentLocale;
13
11
  if (changedContent?.[key]) {
14
- return getDictionary(key, localeTarget, isRenderEditor);
12
+ return getDictionary(
13
+ changedContent?.[key],
14
+ localeTarget
15
+ );
15
16
  }
16
- return getIntlayer(key, localeTarget, isRenderEditor);
17
+ return getIntlayer(key, localeTarget);
17
18
  };
18
19
  export {
19
20
  useIntlayer
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport {\n type DictionaryKeys,\n getIntlayer,\n type UseIntlayerEditable,\n} from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key 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: UseIntlayerEditable = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales,\n isRenderEditor = true\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n return getDictionary(key, localeTarget, isRenderEditor);\n }\n\n return getIntlayer(key, localeTarget, isRenderEditor);\n};\n"],"mappings":";AAGA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AAO/B,MAAM,cAAmC,CAC9C,KACA,QACA,iBAAiB,SACd;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AACzB,WAAO,cAAc,KAAK,cAAc,cAAc;AAAA,EACxD;AAEA,SAAO,YAAY,KAAK,cAAc,cAAc;AACtD;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { type DictionaryKeys } from '@intlayer/core';\nimport { getDictionary } from '../getDictionary';\nimport { getIntlayer } from '../getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\n/**\n * On the client side, Hook that picking one dictionary by its key 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 = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n return getDictionary(\n changedContent?.[key] as IntlayerDictionaryTypesConnector[T],\n localeTarget\n );\n }\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AASrB,MAAM,cAAc,CACzB,KACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AACzB,WAAO;AAAA,MACL,iBAAiB,GAAG;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import { useContext, useEffect, useMemo, useState } from "react";
3
- import {
4
- getIntlayer
5
- } from "../getIntlayer.mjs";
6
- import { getIntlayerAsync } from "../getIntlayerAsync.mjs";
7
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
+ import {
5
+ getIntlayer,
6
+ getIntlayerAsync
7
+ } from "@intlayer/core";
8
8
  const useIntlayerAsync = (key, locale, isRenderEditor = true) => {
9
9
  const { locale: currentLocale } = useContext(IntlayerClientContext);
10
10
  const localeTarget = locale ?? currentLocale;
11
- const localeDictionary = getIntlayer(key, localeTarget, isRenderEditor);
11
+ const localeDictionary = getIntlayer(key, localeTarget);
12
12
  const [distantDictionary, setDistantDictionary] = useState(void 0);
13
13
  const [isLoading, setIsLoading] = useState(false);
14
14
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport {\n DataFromDictionaryKey,\n type DictionaryKeys,\n getIntlayer,\n} from '../getIntlayer';\nimport { getIntlayerAsync } from '../getIntlayerAsync';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nexport type UseIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R> & { isLoading: boolean };\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayerAsync: UseIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales,\n isRenderEditor = true\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const localeDictionary = getIntlayer(key, localeTarget, isRenderEditor);\n const [distantDictionary, setDistantDictionary] = useState<\n typeof localeDictionary | null | undefined\n >(undefined);\n const [isLoading, setIsLoading] = useState(false);\n\n useEffect(() => {\n setIsLoading(true);\n\n getIntlayerAsync(key)\n .then((distantDictionary) => {\n if (distantDictionary) {\n setDistantDictionary(distantDictionary);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const dictionary = useMemo(\n () => distantDictionary ?? localeDictionary,\n [distantDictionary, localeDictionary]\n );\n\n return { ...dictionary, isLoading };\n};\n"],"mappings":";AAGA,SAAS,YAAY,WAAW,SAAS,gBAAgB;AACzD;AAAA,EAGE;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AAoB/B,MAAM,mBAAqC,CAChD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,mBAAmB,YAAY,KAAK,cAAc,cAAc;AACtE,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAEhD,MAAS;AACX,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAEjB,qBAAiB,GAAG,EACjB,KAAK,CAACA,uBAAsB;AAC3B,UAAIA,oBAAmB;AACrB,6BAAqBA,kBAAiB;AAAA,MACxC;AAAA,IACF,CAAC,EACA,QAAQ,MAAM;AACb,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa;AAAA,IACjB,MAAM,qBAAqB;AAAA,IAC3B,CAAC,mBAAmB,gBAAgB;AAAA,EACtC;AAEA,SAAO,EAAE,GAAG,YAAY,UAAU;AACpC;","names":["distantDictionary"]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport {\n type Dictionary,\n type DictionaryKeys,\n getIntlayer,\n getIntlayerAsync,\n} from '@intlayer/core';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales | `${Locales}`,\n isRenderEditor = true\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const localeDictionary = getIntlayer(key, localeTarget);\n const [distantDictionary, setDistantDictionary] = useState<\n typeof localeDictionary | null | undefined\n >(undefined);\n const [isLoading, setIsLoading] = useState(false);\n\n useEffect(() => {\n setIsLoading(true);\n\n getIntlayerAsync(key)\n .then((distantDictionary) => {\n if (distantDictionary) {\n setDistantDictionary(distantDictionary);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const dictionary = useMemo(\n () => distantDictionary ?? localeDictionary,\n [distantDictionary, localeDictionary]\n );\n\n return { ...(dictionary as object), isLoading } as typeof localeDictionary & {\n isLoading: boolean;\n };\n};\n"],"mappings":";AAGA,SAAS,YAAY,WAAW,SAAS,gBAAgB;AACzD,SAAS,6BAA6B;AACtC;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAUA,MAAM,mBAAmB,CAC9B,KACA,QACA,iBAAiB,SACd;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,mBAAmB,YAAY,KAAK,YAAY;AACtD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAEhD,MAAS;AACX,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAEjB,qBAAiB,GAAG,EACjB,KAAK,CAACA,uBAAsB;AAC3B,UAAIA,oBAAmB;AACrB,6BAAqBA,kBAAiB;AAAA,MACxC;AAAA,IACF,CAAC,EACA,QAAQ,MAAM;AACb,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa;AAAA,IACjB,MAAM,qBAAqB;AAAA,IAC3B,CAAC,mBAAmB,gBAAgB;AAAA,EACtC;AAEA,SAAO,EAAE,GAAI,YAAuB,UAAU;AAGhD;","names":["distantDictionary"]}
@@ -25,7 +25,7 @@ const useLocale = ({ onLocaleChange } = {}) => {
25
25
  const { setLocaleCookie } = useLocaleCookie();
26
26
  const setLocale = useCallback(
27
27
  (locale2) => {
28
- if (!availableLocales.includes(locale2)) {
28
+ if (!availableLocales.map(String).includes(locale2)) {
29
29
  console.error(`Locale ${locale2} is not available`);
30
30
  return;
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: Locales) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale: setLocaleState } = useContext(\n IntlayerClientContext\n );\n const { setLocaleCookie } = useLocaleCookie();\n\n const setLocale = useCallback(\n (locale: Locales) => {\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleCookie(locale);\n onLocaleChange?.(locale);\n },\n [\n onLocaleChange,\n availableLocales,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n ]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";AAGA,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ;AAAA,EACF,IAAI,iBAAiB,EAAE;AACvB,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,WAAW,eAAe,IAAI;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAE5C,QAAM,YAAY;AAAA,IAChB,CAACA,YAAoB;AACnB,UAAI,CAAC,iBAAiB,SAASA,OAAM,GAAG;AACtC,gBAAQ,MAAM,UAAUA,OAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,qBAAeA,OAAM;AACrB,sBAAgBA,OAAM;AACtB,uBAAiBA,OAAM;AAAA,IACzB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["locale"]}
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: Locales | `${Locales}`) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale: setLocaleState } = useContext(\n IntlayerClientContext\n );\n const { setLocaleCookie } = useLocaleCookie();\n\n const setLocale = useCallback(\n (locale: Locales | `${Locales}`) => {\n if (!availableLocales.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleCookie(locale);\n onLocaleChange?.(locale);\n },\n [\n onLocaleChange,\n availableLocales,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n ]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";AAGA,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ;AAAA,EACF,IAAI,iBAAiB,EAAE;AACvB,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,WAAW,eAAe,IAAI;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAE5C,QAAM,YAAY;AAAA,IAChB,CAACA,YAAmC;AAClC,UAAI,CAAC,iBAAiB,IAAI,MAAM,EAAE,SAASA,OAAM,GAAG;AAClD,gBAAQ,MAAM,UAAUA,OAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,qBAAeA,OAAM;AACrB,sBAAgBA,OAAM;AACtB,uBAAiBA,OAAM;AAAA,IACzB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["locale"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = getConfiguration().middleware;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as unknown as\n | Locales\n | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: Locales) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AAAA,SAAuB,wBAAwB;AAC/C,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI,iBAAiB,EAAE;AAE1C,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAO3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = getConfiguration().middleware;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as unknown as\n | Locales\n | `${Locales}`\n | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: Locales | `${Locales}`) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AAAA,SAAuB,wBAAwB;AAC/C,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI,iBAAiB,EAAE;AAE1C,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAQ3C,MAAM,kBAAkB,CAAC,WAAmC;AACjE,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
@@ -1,11 +1,11 @@
1
+ import { getTranslation } from "@intlayer/core";
1
2
  import { useContext } from "react";
2
- import { getTranslation } from "../getTranslation.mjs";
3
3
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
- const useTraduction = (languageContent) => {
4
+ const useTranslation = (languageContent) => {
5
5
  const { locale } = useContext(IntlayerClientContext);
6
6
  return getTranslation(languageContent, locale);
7
7
  };
8
8
  export {
9
- useTraduction
9
+ useTranslation
10
10
  };
11
11
  //# sourceMappingURL=useTraduction.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\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 * ```tsx\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\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): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAuB/B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation, type LanguageContent } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\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 * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\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 useTranslation = <Content = string>(\n languageContent: LanguageContent<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":"AAAA,SAAS,sBAA4C;AACrD,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAuB/B,MAAM,iBAAiB,CAC5B,oBACY;AACZ,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -16,7 +16,6 @@ import { ContentSelector } from "../UI/ContentSelector.mjs";
16
16
  const ContentSelectorWrapperContent = ({
17
17
  children,
18
18
  dictionaryKey,
19
- dictionaryPath,
20
19
  keyPath,
21
20
  ...props
22
21
  }) => {
@@ -30,10 +29,9 @@ const ContentSelectorWrapperContent = ({
30
29
  const handleSelect = useCallback(
31
30
  () => setFocusedContent({
32
31
  dictionaryKey,
33
- dictionaryPath,
34
32
  keyPath
35
33
  }),
36
- [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]
34
+ [dictionaryKey, keyPath, setFocusedContent]
37
35
  );
38
36
  const isSelected = useMemo(
39
37
  () => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n\n if (enabled) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AA2EI,SAoBK,UApBL;AAzEJ,SAAS,qBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAWhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,MAAI,SAAS;AACX,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n\n if (enabled) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AAmEI,SAoBK,UApBL;AAjEJ,SAAyB,qBAAqB;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,SAAS,iBAAiB;AAAA,EAC5C;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,MAAI,SAAS;AACX,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
@@ -19,7 +19,9 @@ const IntlayerEditorHooksEnabled = () => {
19
19
  });
20
20
  const { setLocaleDictionaries } = useDictionariesRecordActions();
21
21
  useEffect(() => {
22
- setLocaleDictionaries(dictionaries);
22
+ setLocaleDictionaries(
23
+ dictionaries
24
+ );
23
25
  }, [setLocaleDictionaries]);
24
26
  useIframeClickInterceptor();
25
27
  const { setChangedContent } = useChangedContentActions();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport { getConfiguration } 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 {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useIframeClickInterceptor,\n useEditorEnabled,\n useChangedContentActions,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n const { editor } = getConfiguration();\n const eventSource = new IntlayerEventListener();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n eventSource.initialize();\n\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n\n return () => eventSource.cleanup();\n }, []);\n\n return <></>;\n};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n const configuration = getConfiguration();\n\n const { editor } = configuration;\n\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[editor.editorURL, editor.cmsURL, editor.applicationURL]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAiES,wBAeL,YAfK;AA7DT,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAMjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd,0BAAsB,YAAY;AAAA,EACpC,GAAG,CAAC,qBAAqB,CAAC;AAK1B,4BAA0B;AAK1B,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AACvD,QAAM,EAAE,OAAO,IAAI,iBAAiB;AACpC,QAAM,cAAc,IAAI,sBAAsB;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,gBAAY,WAAW;AAEvB,gBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAEtD,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,gCAAE;AACX;AAEA,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,EAAE,OAAO,IAAI;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AACA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,OAAO,WAAW,OAAO,QAAQ,OAAO,cAAc;AAAA,MACvE,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { Dictionary } from '@intlayer/core';\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 {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useIframeClickInterceptor,\n useEditorEnabled,\n useChangedContentActions,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(\n dictionaries as unknown as Record<string, Dictionary>\n );\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n const { editor } = getConfiguration();\n const eventSource = new IntlayerEventListener();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n eventSource.initialize();\n\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n\n return () => eventSource.cleanup();\n }, []);\n\n return <></>;\n};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n const configuration = getConfiguration();\n\n const { editor } = configuration;\n\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[editor.editorURL, editor.cmsURL, editor.applicationURL]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAoES,wBAeL,YAfK;AAhET,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAOjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd;AAAA,MACE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,qBAAqB,CAAC;AAK1B,4BAA0B;AAK1B,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AACvD,QAAM,EAAE,OAAO,IAAI,iBAAiB;AACpC,QAAM,cAAc,IAAI,sBAAsB;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,gBAAY,WAAW;AAEvB,gBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAEtD,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,gCAAE;AACX;AAEA,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,EAAE,OAAO,IAAI;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AACA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,OAAO,WAAW,OAAO,QAAQ,OAAO,cAAc;AAAA,MACvE,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -2,10 +2,11 @@ import { jsx } from "react/jsx-runtime";
2
2
  import {
3
3
  ContentSelectorWrapper
4
4
  } from "./ContentSelectorWrapper.mjs";
5
- const renderIntlayerEditor = (props) => {
6
- const Result = /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content });
7
- return { ...Result, value: props.content };
8
- };
5
+ import { rendererIntlayerNode } from "../IntlayerNode.mjs";
6
+ const renderIntlayerEditor = (props) => rendererIntlayerNode({
7
+ value: props.content,
8
+ children: /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content })
9
+ });
9
10
  export {
10
11
  renderIntlayerEditor
11
12
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children'\n> & {\n content: string;\n};\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode => {\n const Result = (\n <ContentSelectorWrapper {...props}>{props.content}</ContentSelectorWrapper>\n );\n\n return { ...Result, value: props.content };\n};\n"],"mappings":"AAqBI;AApBJ;AAAA,EACE;AAAA,OAEK;AAaA,MAAM,uBAAuB,CAClC,UACiB;AACjB,QAAM,SACJ,oBAAC,0BAAwB,GAAG,OAAQ,gBAAM,SAAQ;AAGpD,SAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAC3C;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\nimport { type NodeProps } from '@intlayer/core';\nimport { IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children' | 'content'\n> &\n NodeProps;\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode =>\n rendererIntlayerNode({\n value: props.content,\n children: (\n <ContentSelectorWrapper {...props}>\n {props.content}\n </ContentSelectorWrapper>\n ),\n });\n"],"mappings":"AAmBM;AAnBN;AAAA,EACE;AAAA,OAEK;AAEP,SAAuB,4BAA4B;AAQ5C,MAAM,uBAAuB,CAClC,UAEA,qBAAqB;AAAA,EACnB,OAAO,MAAM;AAAA,EACb,UACE,oBAAC,0BAAwB,GAAG,OACzB,gBAAM,SACT;AAEJ,CAAC;","names":[]}
@@ -1,18 +1,22 @@
1
- import { processDictionary } from "./processDictionary/index.mjs";
2
1
  import {
3
- recursiveTransformContent
4
- } from "./recursiveTransformContent.mjs";
5
- const getDictionary = (dictionary, locale, isRenderEditor = false) => {
6
- const result = processDictionary(
7
- dictionary.content,
8
- dictionary.key,
9
- dictionary.filePath,
10
- [],
11
- locale
12
- );
13
- return recursiveTransformContent(
14
- result,
15
- isRenderEditor
2
+ getDictionary as getDictionaryCore
3
+ } from "@intlayer/core";
4
+ import {
5
+ intlayerNodePlugins,
6
+ markdownPlugin,
7
+ reactNodePlugins
8
+ } from "./plugins.mjs";
9
+ const getDictionary = (dictionary, locale, additionalPlugins) => {
10
+ const plugins = [
11
+ intlayerNodePlugins,
12
+ reactNodePlugins,
13
+ markdownPlugin,
14
+ ...additionalPlugins ?? []
15
+ ];
16
+ return getDictionaryCore(
17
+ dictionary,
18
+ locale,
19
+ plugins
16
20
  );
17
21
  };
18
22
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { DeclarationContent, DictionaryValue } from '@intlayer/core';\nimport { processDictionary } from './processDictionary/index';\nimport {\n DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<T['content'], K, R>;\n\nexport type UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionary<T, L, R>;\n\n/**\n * Hook that picks 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 getDictionary: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionary<T, L, R>;\n};\n"],"mappings":"AAEA,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AAwBA,MAAM,gBAA+B,CAK1C,YACA,QACA,iBAAoB,UACjB;AACH,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Dictionary,\n type Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\nimport type { Locales } from '@intlayer/config/client';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends Locales | `${Locales}` = Locales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AACA;AAAA,EAGE,iBAAiB;AAAA,OACZ;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,24 +1,19 @@
1
- import dictionaries from "@intlayer/dictionaries-entry";
2
- import { processDictionary } from "./processDictionary/index.mjs";
3
1
  import {
4
- recursiveTransformContent
5
- } from "./recursiveTransformContent.mjs";
6
- const getIntlayer = (key, locale, isRenderEditor = false) => {
7
- const dictionary = dictionaries[key];
8
- if (!dictionary) {
9
- throw new Error(`Dictionary ${key} not found`, dictionaries);
10
- }
11
- const result = processDictionary(
12
- dictionary.content,
13
- dictionary.key,
14
- dictionary.filePath,
15
- [],
16
- locale
17
- );
18
- return recursiveTransformContent(
19
- result,
20
- isRenderEditor
21
- );
2
+ getIntlayer as getIntlayerCore
3
+ } from "@intlayer/core";
4
+ import {
5
+ intlayerNodePlugins,
6
+ markdownPlugin,
7
+ reactNodePlugins
8
+ } from "./plugins.mjs";
9
+ const getIntlayer = (key, locale, additionalPlugins) => {
10
+ const plugins = [
11
+ intlayerNodePlugins,
12
+ reactNodePlugins,
13
+ markdownPlugin,
14
+ ...additionalPlugins ?? []
15
+ ];
16
+ return getIntlayerCore(key, locale, plugins);
22
17
  };
23
18
  export {
24
19
  getIntlayer
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\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 { processDictionary } from './processDictionary/index';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\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\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\nexport type DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport type UseIntlayerEditable = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport const getIntlayer: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key} not found`, dictionaries);\n }\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n};\n"],"mappings":"AAOA,OAAO,kBAAkB;AAEzB,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AA6DA,MAAM,cAA2B,CAKtC,KACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAG,cAAc,YAAY;AAAA,EAC7D;AAEA,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\nimport type { IntlayerDictionaryTypesConnector, Locales } from 'intlayer';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends Locales | `${Locales}`,\n>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getIntlayerCore(key, locale, plugins) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAEA;AAAA,EAGE,eAAe;AAAA,OACV;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,cAAc,CAIzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
@@ -1,4 +1,3 @@
1
- import { getTranslation } from "./getTranslation.mjs";
2
1
  import {
3
2
  IntlayerProvider,
4
3
  IntlayerClientContext,
@@ -6,7 +5,6 @@ import {
6
5
  useIntlayerAsync,
7
6
  useDictionary,
8
7
  useLocale,
9
- useTraduction,
10
8
  useLocaleCookie,
11
9
  useIntlayerContext,
12
10
  localeCookie,
@@ -15,15 +13,12 @@ import {
15
13
  useLocaleBase,
16
14
  t
17
15
  } from "./client/index.mjs";
18
- import { getDictionary } from "./getDictionary.mjs";
19
- import { getIntlayer } from "./getIntlayer.mjs";
16
+ import { MarkdownProvider } from "./markdown/index.mjs";
20
17
  export {
21
18
  IntlayerClientContext,
22
19
  IntlayerProvider,
20
+ MarkdownProvider,
23
21
  getBrowserLocale,
24
- getDictionary,
25
- getIntlayer,
26
- getTranslation,
27
22
  localeCookie,
28
23
  setLocaleCookie,
29
24
  t,
@@ -33,7 +28,6 @@ export {
33
28
  useIntlayerContext,
34
29
  useLocale,
35
30
  useLocaleBase,
36
- useLocaleCookie,
37
- useTraduction
31
+ useLocaleCookie
38
32
  };
39
33
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport { type IntlayerNode } from './editor/renderContentEditor';\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T, S> {}\n}\n\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;","names":[]}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import {
4
+ createContext,
5
+ useContext
6
+ } from "react";
7
+ const MarkdownContext = createContext({
8
+ renderMarkdown: (markdown) => markdown
9
+ });
10
+ const useMarkdownContext = () => useContext(MarkdownContext);
11
+ const MarkdownProvider = ({
12
+ children,
13
+ renderMarkdown
14
+ }) => /* @__PURE__ */ jsx(MarkdownContext.Provider, { value: { renderMarkdown }, children });
15
+ export {
16
+ MarkdownProvider,
17
+ useMarkdownContext
18
+ };
19
+ //# sourceMappingURL=MarkdownProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) => (\n <MarkdownContext.Provider value={{ renderMarkdown }}>\n {children}\n </MarkdownContext.Provider>\n);\n"],"mappings":";AA0BE;AAxBF;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAQP,MAAM,kBAAkB,cAAoC;AAAA,EAC1D,gBAAgB,CAAC,aAAqB;AACxC,CAAC;AAEM,MAAM,qBAAqB,MAAM,WAAW,eAAe;AAE3D,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AACF,MACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,eAAe,GAC/C,UACH;","names":[]}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { useMarkdownContext } from "./MarkdownProvider.mjs";
3
+ import { rendererIntlayerNode } from "../IntlayerNode.mjs";
4
+ const MarkdownRenderer = ({
5
+ markdown
6
+ }) => {
7
+ const { renderMarkdown } = useMarkdownContext();
8
+ return rendererIntlayerNode({
9
+ value: markdown,
10
+ children: renderMarkdown(markdown)
11
+ });
12
+ };
13
+ export {
14
+ MarkdownRenderer
15
+ };
16
+ //# sourceMappingURL=MarkdownRenderer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { FC } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\n\nexport const MarkdownRenderer: FC<{ markdown: string }> = ({\n markdown,\n}): IntlayerNode => {\n const { renderMarkdown } = useMarkdownContext();\n\n return rendererIntlayerNode({\n value: markdown,\n children: renderMarkdown(markdown),\n });\n};\n"],"mappings":";AAGA,SAAS,0BAA0B;AACnC,SAAuB,4BAA4B;AAE5C,MAAM,mBAA6C,CAAC;AAAA,EACzD;AACF,MAAoB;AAClB,QAAM,EAAE,eAAe,IAAI,mBAAmB;AAE9C,SAAO,qBAAqB;AAAA,IAC1B,OAAO;AAAA,IACP,UAAU,eAAe,QAAQ;AAAA,EACnC,CAAC;AACH;","names":[]}
@@ -0,0 +1,4 @@
1
+ export * from "./MarkdownProvider.mjs";
2
+ export * from "./MarkdownRenderer.mjs";
3
+ export * from "./renderMarkdown.mjs";
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\nexport * from './renderMarkdown';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { rendererIntlayerNode } from "../IntlayerNode.mjs";
3
+ import { MarkdownRenderer } from "./MarkdownRenderer.mjs";
4
+ const renderMarkdown = (markdown) => rendererIntlayerNode({
5
+ value: markdown,
6
+ children: /* @__PURE__ */ jsx(MarkdownRenderer, { markdown })
7
+ });
8
+ export {
9
+ renderMarkdown
10
+ };
11
+ //# sourceMappingURL=renderMarkdown.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/renderMarkdown.tsx"],"sourcesContent":["import { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport { MarkdownRenderer } from './MarkdownRenderer';\n\nexport const renderMarkdown = (markdown: string): IntlayerNode =>\n rendererIntlayerNode({\n value: markdown,\n children: <MarkdownRenderer markdown={markdown} />,\n });\n"],"mappings":"AAMc;AANd,SAA4B,4BAA4B;AACxD,SAAS,wBAAwB;AAE1B,MAAM,iBAAiB,CAAC,aAC7B,qBAAqB;AAAA,EACnB,OAAO;AAAA,EACP,UAAU,oBAAC,oBAAiB,UAAoB;AAClD,CAAC;","names":[]}
@@ -0,0 +1,61 @@
1
+ import {
2
+ NodeType
3
+ } from "@intlayer/core";
4
+ import { createElement } from "react";
5
+ import { renderIntlayerEditor } from "./editor/index.mjs";
6
+ import { renderMarkdown } from "./markdown/renderMarkdown.mjs";
7
+ const intlayerNodePlugins = {
8
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
9
+ transform: (_node, {
10
+ plugins,
11
+ // Removed to avoid next error - Functions cannot be passed directly to Client Components
12
+ ...rest
13
+ }) => renderIntlayerEditor(rest)
14
+ };
15
+ const createReactElement = (element) => {
16
+ if (typeof element === "string") {
17
+ return element;
18
+ }
19
+ const convertChildrenAsArray = (element2) => {
20
+ if (element2?.props && typeof element2.props.children === "object") {
21
+ const childrenResult = [];
22
+ const { children } = element2.props;
23
+ Object.keys(children ?? {}).forEach((key) => {
24
+ childrenResult.push(
25
+ createReactElement((children ?? {})[key])
26
+ );
27
+ });
28
+ return {
29
+ ...element2,
30
+ props: { ...element2.props, children: childrenResult }
31
+ };
32
+ }
33
+ return {
34
+ ...element2,
35
+ props: { ...element2.props, children: element2.props.children }
36
+ };
37
+ };
38
+ const fixedElement = convertChildrenAsArray(
39
+ element
40
+ );
41
+ const { type, props } = fixedElement;
42
+ return createElement(
43
+ type ?? "div",
44
+ props,
45
+ ...props.children
46
+ );
47
+ };
48
+ const reactNodePlugins = {
49
+ canHandle: (node) => typeof node === "object" && typeof node.ref !== "undefined" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
50
+ transform: createReactElement
51
+ };
52
+ const markdownPlugin = {
53
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
54
+ transform: (node) => renderMarkdown(node[NodeType.Markdown])
55
+ };
56
+ export {
57
+ intlayerNodePlugins,
58
+ markdownPlugin,
59
+ reactNodePlugins
60
+ };
61
+ //# sourceMappingURL=plugins.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n} from '@intlayer/core';\nimport { type ReactElement, type ReactNode, createElement } from 'react';\nimport { renderIntlayerEditor } from './editor';\nimport type { IntlayerNode } from './IntlayerNode';\nimport { renderMarkdown } from './markdown/renderMarkdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T, _S> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) => renderIntlayerEditor(rest),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T, _S> = T extends {\n ref: any;\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n// This function recursively creates React elements from a given JSON-like structure\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n createReactElement((children ?? {})[key as keyof typeof children])\n );\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'div',\n props,\n ...(props.children as ReactNode[])\n );\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.ref !== 'undefined' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: createReactElement,\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T, _S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: string;\n}\n ? IntlayerNode<string>\n : never;\n\n/** Markdown plugin. Replaces node with a function that takes quantity => string. */\nexport const markdownPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent) => renderMarkdown(node[NodeType.Markdown]),\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T, _S> {\n reactNode: ReactNodeCond<T, _S>;\n intlayerNode: IntlayerNodeCond<T, _S>;\n markdown: MarkdownCond<T, _S>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AACA;AAAA,EAKE;AAAA,OACK;AACP,SAA4C,qBAAqB;AACjE,SAAS,4BAA4B;AAErC,SAAS,sBAAsB;AAWxB,MAAM,sBAA+B;AAAA,EAC1C,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MACG,qBAAqB,IAAI;AAChC;AAeA,MAAM,qBAAqB,CAAC,YAA0B;AACpD,MAAI,OAAO,YAAY,UAAU;AAE/B,WAAO;AAAA,EACT;AAEA,QAAM,yBAAyB,CAC7BA,aAC2C;AAC3C,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAC;AACrC,YAAM,EAAE,SAAS,IAAIA,SAAQ;AAG7B,aAAO,KAAK,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC3C,uBAAe;AAAA,UACb,oBAAoB,YAAY,CAAC,GAAG,GAA4B,CAAC;AAAA,QACnE;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL,GAAGA;AAAA,QACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAU,eAAe;AAAA,MACtD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAGA;AAAA,MACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAUA,SAAQ,MAAM,SAAS;AAAA,IAC9D;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,MAAM,IAAI;AAGxB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,GAAI,MAAM;AAAA,EACZ;AACF;AAGO,MAAM,mBAA4B;AAAA,EACvC,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,QAAQ,eACpB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW;AACb;AAcO,MAAM,iBAA0B;AAAA,EACrC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,SAA0B,eAAe,KAAK,SAAS,QAAQ,CAAC;AAC9E;","names":["element"]}