react-intlayer 1.2.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/cjs/{ContentEditor/contentRender.cjs → client/ContentEditionLayout.cjs} +13 -14
  2. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -0
  3. package/dist/cjs/client/ContentEditionLayout.d.ts +6 -0
  4. package/dist/cjs/client/{IntlayerClientProvider.cjs → IntlayerProvider.cjs} +21 -10
  5. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -0
  6. package/dist/{esm/client/IntlayerClientProvider.d.mts → cjs/client/IntlayerProvider.d.ts} +4 -3
  7. package/dist/cjs/client/index.cjs +6 -6
  8. package/dist/cjs/client/index.cjs.map +1 -1
  9. package/dist/cjs/client/index.d.ts +2 -1
  10. package/dist/cjs/client/useContent.d.ts +1 -2
  11. package/dist/cjs/client/useIntlayer.cjs +2 -2
  12. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  13. package/dist/cjs/client/useIntlayer.d.ts +2 -1
  14. package/dist/cjs/client/useLocale.cjs +2 -2
  15. package/dist/cjs/client/useLocale.cjs.map +1 -1
  16. package/dist/cjs/client/useLocaleBase.cjs +2 -2
  17. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  18. package/dist/cjs/client/useTraduction.cjs +2 -2
  19. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  20. package/dist/cjs/getEnumeration.cjs +0 -4
  21. package/dist/cjs/getEnumeration.cjs.map +1 -1
  22. package/dist/cjs/getTranslation.cjs +0 -4
  23. package/dist/cjs/getTranslation.cjs.map +1 -1
  24. package/dist/cjs/index.cjs +7 -4
  25. package/dist/cjs/index.cjs.map +1 -1
  26. package/dist/cjs/index.d.ts +3 -2
  27. package/dist/cjs/processDictionary/{contentDictionary.d.cjs → contentDictionary.cjs} +3 -3
  28. package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -0
  29. package/dist/cjs/processDictionary/contentDictionary.d.ts +16 -0
  30. package/dist/cjs/processDictionary/index.cjs +114 -33
  31. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  32. package/dist/cjs/processDictionary/index.d.ts +5 -4
  33. package/dist/cjs/server/IntlayerServerProvider.cjs +3 -4
  34. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  35. package/dist/cjs/server/IntlayerServerProvider.d.ts +1 -1
  36. package/dist/cjs/server/index.d.ts +1 -0
  37. package/dist/cjs/server/useIntlayer.d.ts +2 -1
  38. package/dist/cjs/useIntlayerBase.cjs +48 -1
  39. package/dist/cjs/useIntlayerBase.cjs.map +1 -1
  40. package/dist/cjs/useIntlayerBase.d.ts +51 -4
  41. package/dist/cjs/vite/intlayerPlugin.cjs +1 -1
  42. package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -1
  43. package/dist/esm/client/ContentEditionLayout.d.mts +6 -0
  44. package/dist/esm/client/ContentEditionLayout.mjs +15 -0
  45. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -0
  46. package/dist/{cjs/client/IntlayerClientProvider.d.ts → esm/client/IntlayerProvider.d.mts} +4 -3
  47. package/dist/esm/client/{IntlayerClientProvider.mjs → IntlayerProvider.mjs} +17 -6
  48. package/dist/esm/client/IntlayerProvider.mjs.map +1 -0
  49. package/dist/esm/client/index.d.mts +2 -1
  50. package/dist/esm/client/index.mjs +4 -4
  51. package/dist/esm/client/index.mjs.map +1 -1
  52. package/dist/esm/client/useContent.d.mts +1 -2
  53. package/dist/esm/client/useIntlayer.d.mts +2 -1
  54. package/dist/esm/client/useIntlayer.mjs +1 -1
  55. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  56. package/dist/esm/client/useLocale.mjs +1 -1
  57. package/dist/esm/client/useLocale.mjs.map +1 -1
  58. package/dist/esm/client/useLocaleBase.mjs +1 -1
  59. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  60. package/dist/esm/client/useTraduction.mjs +1 -1
  61. package/dist/esm/client/useTraduction.mjs.map +1 -1
  62. package/dist/esm/getEnumeration.mjs +0 -4
  63. package/dist/esm/getEnumeration.mjs.map +1 -1
  64. package/dist/esm/getTranslation.mjs +0 -4
  65. package/dist/esm/getTranslation.mjs.map +1 -1
  66. package/dist/esm/index.d.mts +3 -2
  67. package/dist/esm/index.mjs +6 -4
  68. package/dist/esm/index.mjs.map +1 -1
  69. package/dist/esm/processDictionary/contentDictionary.d.mts +16 -0
  70. package/dist/esm/processDictionary/contentDictionary.mjs +1 -0
  71. package/dist/esm/processDictionary/index.d.mts +5 -4
  72. package/dist/esm/processDictionary/index.mjs +116 -34
  73. package/dist/esm/processDictionary/index.mjs.map +1 -1
  74. package/dist/esm/server/IntlayerServerProvider.d.mts +1 -1
  75. package/dist/esm/server/IntlayerServerProvider.mjs +3 -4
  76. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  77. package/dist/esm/server/index.d.mts +1 -0
  78. package/dist/esm/server/useIntlayer.d.mts +2 -1
  79. package/dist/esm/useIntlayerBase.d.mts +51 -4
  80. package/dist/esm/useIntlayerBase.mjs +46 -1
  81. package/dist/esm/useIntlayerBase.mjs.map +1 -1
  82. package/dist/esm/vite/intlayerPlugin.mjs +1 -1
  83. package/dist/esm/vite/intlayerPlugin.mjs.map +1 -1
  84. package/package.json +14 -9
  85. package/src/index.ts +4 -3
  86. package/dist/cjs/ContentEditor/ContentEditor.cjs +0 -110
  87. package/dist/cjs/ContentEditor/ContentEditor.cjs.map +0 -1
  88. package/dist/cjs/ContentEditor/ContentEditor.d.ts +0 -8
  89. package/dist/cjs/ContentEditor/contentRender.cjs.map +0 -1
  90. package/dist/cjs/ContentEditor/contentRender.d.ts +0 -3
  91. package/dist/cjs/ContentEditor/index.cjs +0 -25
  92. package/dist/cjs/ContentEditor/index.cjs.map +0 -1
  93. package/dist/cjs/ContentEditor/index.d.ts +0 -3
  94. package/dist/cjs/IntlayerProvider.cjs +0 -37
  95. package/dist/cjs/IntlayerProvider.cjs.map +0 -1
  96. package/dist/cjs/IntlayerProvider.d.ts +0 -9
  97. package/dist/cjs/client/IntlayerClientProvider.cjs.map +0 -1
  98. package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +0 -1
  99. package/dist/cjs/processDictionary/contentDictionary.d.d.ts +0 -29
  100. package/dist/esm/ContentEditor/ContentEditor.d.mts +0 -8
  101. package/dist/esm/ContentEditor/ContentEditor.mjs +0 -92
  102. package/dist/esm/ContentEditor/ContentEditor.mjs.map +0 -1
  103. package/dist/esm/ContentEditor/contentRender.d.mts +0 -3
  104. package/dist/esm/ContentEditor/contentRender.mjs +0 -14
  105. package/dist/esm/ContentEditor/contentRender.mjs.map +0 -1
  106. package/dist/esm/ContentEditor/index.d.mts +0 -3
  107. package/dist/esm/ContentEditor/index.mjs +0 -3
  108. package/dist/esm/ContentEditor/index.mjs.map +0 -1
  109. package/dist/esm/IntlayerProvider.d.mts +0 -9
  110. package/dist/esm/IntlayerProvider.mjs +0 -18
  111. package/dist/esm/IntlayerProvider.mjs.map +0 -1
  112. package/dist/esm/client/IntlayerClientProvider.mjs.map +0 -1
  113. package/dist/esm/processDictionary/contentDictionary.d.d.mts +0 -29
  114. package/dist/esm/processDictionary/contentDictionary.d.mjs +0 -1
  115. package/src/ContentEditor/ContentEditor.tsx +0 -116
  116. package/src/ContentEditor/contentRender.tsx +0 -11
  117. package/src/ContentEditor/index.tsx +0 -2
  118. package/src/IntlayerProvider.tsx +0 -24
  119. package/src/cli/react-intlayer.ts +0 -60
  120. package/src/client/IntlayerClientProvider.tsx +0 -76
  121. package/src/client/getBrowserLocale.tsx +0 -192
  122. package/src/client/index.ts +0 -16
  123. package/src/client/useContent.ts +0 -20
  124. package/src/client/useIntlayer.ts +0 -25
  125. package/src/client/useLocale.ts +0 -23
  126. package/src/client/useLocaleBase.ts +0 -24
  127. package/src/client/useLocaleCookie.ts +0 -32
  128. package/src/client/useTraduction.ts +0 -33
  129. package/src/craco/craco.config.ts +0 -11
  130. package/src/craco/intlayerCracoPlugin.ts +0 -89
  131. package/src/getEnumeration.ts +0 -46
  132. package/src/getTranslation.ts +0 -42
  133. package/src/processDictionary/contentDictionary.d.ts +0 -27
  134. package/src/processDictionary/index.ts +0 -144
  135. package/src/server/IntlayerServerProvider.tsx +0 -36
  136. package/src/server/getLocaleTranslation.ts +0 -22
  137. package/src/server/index.ts +0 -8
  138. package/src/server/serverContext.ts +0 -85
  139. package/src/server/useIntlayer.ts +0 -23
  140. package/src/server/useTraduction.ts +0 -34
  141. package/src/useIntlayerBase.ts +0 -35
  142. package/src/vite/intlayerPlugin.ts +0 -59
  143. /package/dist/esm/processDictionary/{contentDictionary.d.mjs.map → contentDictionary.mjs.map} +0 -0
@@ -16,22 +16,21 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var contentRender_exports = {};
20
- __export(contentRender_exports, {
21
- contentRender: () => contentRender
19
+ var ContentEditionLayout_exports = {};
20
+ __export(ContentEditionLayout_exports, {
21
+ ContentEditionLayout: () => ContentEditionLayout
22
22
  });
23
- module.exports = __toCommonJS(contentRender_exports);
23
+ module.exports = __toCommonJS(ContentEditionLayout_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_ContentEditor = require('./ContentEditor.cjs');
26
- const contentRender = (content) => {
27
- const isEditable = process.env.NODE_ENV === "development";
28
- if (isEditable && import_ContentEditor.ContentEditor) {
29
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentEditor.ContentEditor, { children: content });
30
- }
31
- return content;
32
- };
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_client2 = require("intlayer-editor/client");
27
+ const {
28
+ editor: { enabled }
29
+ } = (0, import_client.getConfiguration)();
30
+ const BlankLayout = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
31
+ const ContentEditionLayout = typeof import_client2.ContentEditionLayout === "undefined" || !enabled ? BlankLayout : import_client2.ContentEditionLayout;
33
32
  // Annotate the CommonJS export names for ESM import in node:
34
33
  0 && (module.exports = {
35
- contentRender
34
+ ContentEditionLayout
36
35
  });
37
- //# sourceMappingURL=contentRender.cjs.map
36
+ //# sourceMappingURL=ContentEditionLayout.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n ContentEditionLayout as ContentEditionLayoutBase,\n type ContentEditionLayoutProps,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof ContentEditionLayoutBase === 'undefined' || !enabled\n ? BlankLayout\n : ContentEditionLayoutBase;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYE;AAZF,oBAAiC;AACjC,IAAAA,iBAGO;AAGP,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAErB,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,2EAAG,UAAS;AAIP,MAAM,uBACX,OAAO,eAAAC,yBAA6B,eAAe,CAAC,UAChD,cACA,eAAAA;","names":["import_client","ContentEditionLayoutBase"]}
@@ -0,0 +1,6 @@
1
+ import { ContentEditionLayoutProps } from 'intlayer-editor/client';
2
+ import { FC } from 'react';
3
+
4
+ declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
5
+
6
+ export { ContentEditionLayout };
@@ -17,31 +17,33 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var IntlayerClientProvider_exports = {};
21
- __export(IntlayerClientProvider_exports, {
20
+ var IntlayerProvider_exports = {};
21
+ __export(IntlayerProvider_exports, {
22
22
  IntlayerClientContext: () => IntlayerClientContext,
23
- IntlayerClientProvider: () => IntlayerClientProvider,
23
+ IntlayerProvider: () => IntlayerProvider,
24
24
  useIntlayerContext: () => useIntlayerContext
25
25
  });
26
- module.exports = __toCommonJS(IntlayerClientProvider_exports);
26
+ module.exports = __toCommonJS(IntlayerProvider_exports);
27
27
  var import_jsx_runtime = require("react/jsx-runtime");
28
28
  var import_client = require("@intlayer/config/client");
29
29
  var import_react = require("react");
30
+ var import_ContentEditionLayout = require('./ContentEditionLayout.cjs');
30
31
  var import_useLocaleCookie = require('./useLocaleCookie.cjs');
31
32
  const IntlayerClientContext = (0, import_react.createContext)({
32
33
  locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
33
34
  setLocale: () => null
34
35
  });
35
36
  const useIntlayerContext = () => (0, import_react.useContext)(IntlayerClientContext);
36
- const IntlayerClientProvider = ({
37
+ const IntlayerProvider = ({
37
38
  locale,
38
- children
39
+ children,
40
+ setLocale: setLocaleProp
39
41
  }) => {
40
42
  const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
41
43
  const [currentLocale, setCurrentLocale] = (0, import_react.useState)(
42
44
  locale ?? import_useLocaleCookie.localeCookie ?? defaultLocale
43
45
  );
44
- const setLocale = (0, import_react.useCallback)(
46
+ const setLocaleBase = (0, import_react.useCallback)(
45
47
  (newLocale) => {
46
48
  if (currentLocale.toString() === newLocale.toString())
47
49
  return;
@@ -54,16 +56,25 @@ const IntlayerClientProvider = ({
54
56
  },
55
57
  [availableLocales, currentLocale, locale]
56
58
  );
59
+ const setLocale = setLocaleProp ?? setLocaleBase;
57
60
  const value = (0, import_react.useMemo)(
58
61
  () => ({ locale: currentLocale, setLocale }),
59
62
  [currentLocale, setLocale]
60
63
  );
61
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children });
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_ContentEditionLayout.ContentEditionLayout,
66
+ {
67
+ locale: currentLocale,
68
+ setLocale,
69
+ localeList: availableLocales,
70
+ children
71
+ }
72
+ ) });
62
73
  };
63
74
  // Annotate the CommonJS export names for ESM import in node:
64
75
  0 && (module.exports = {
65
76
  IntlayerClientContext,
66
- IntlayerClientProvider,
77
+ IntlayerProvider,
67
78
  useIntlayerContext
68
79
  });
69
- //# sourceMappingURL=IntlayerClientProvider.cjs.map
80
+ //# sourceMappingURL=IntlayerProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EM;AA3EN,oBAA+C;AAC/C,mBAQO;AACP,kCAAqC;AACrC,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AAUjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,oBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS;AAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MAEX;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
@@ -14,12 +14,13 @@ declare const IntlayerClientContext: react.Context<IntlayerValue>;
14
14
  * Hook that provides the current locale
15
15
  */
16
16
  declare const useIntlayerContext: () => IntlayerValue;
17
- type IntlayerClientProviderProps = PropsWithChildren & {
17
+ type IntlayerProviderProps = PropsWithChildren & {
18
18
  locale?: Locales;
19
+ setLocale?: (locale: Locales) => void;
19
20
  };
20
21
  /**
21
22
  * Provider that store the current locale on the client side
22
23
  */
23
- declare const IntlayerClientProvider: FC<IntlayerClientProviderProps>;
24
+ declare const IntlayerProvider: FC<IntlayerProviderProps>;
24
25
 
25
- export { IntlayerClientContext, IntlayerClientProvider, type IntlayerClientProviderProps, useIntlayerContext };
26
+ export { IntlayerClientContext, IntlayerProvider, type IntlayerProviderProps, useIntlayerContext };
@@ -18,20 +18,20 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var client_exports = {};
20
20
  __export(client_exports, {
21
- IntlayerClient: () => import_IntlayerClientProvider.IntlayerClientContext,
22
- IntlayerClientProvider: () => import_IntlayerClientProvider.IntlayerClientProvider,
21
+ IntlayerClientContext: () => import_IntlayerProvider.IntlayerClientContext,
22
+ IntlayerProvider: () => import_IntlayerProvider.IntlayerProvider,
23
23
  getBrowserLocale: () => import_getBrowserLocale.getBrowserLocale,
24
24
  localeCookie: () => import_useLocaleCookie.localeCookie,
25
25
  setLocaleCookie: () => import_useLocaleCookie.setLocaleCookie,
26
26
  useIntlayer: () => import_useIntlayer.useIntlayer,
27
- useIntlayerContext: () => import_IntlayerClientProvider.useIntlayerContext,
27
+ useIntlayerContext: () => import_IntlayerProvider.useIntlayerContext,
28
28
  useLocale: () => import_useLocale.useLocale,
29
29
  useLocaleBase: () => import_useLocaleBase.useLocaleBase,
30
30
  useLocaleCookie: () => import_useLocaleCookie.useLocaleCookie,
31
31
  useTraduction: () => import_useTraduction.useTraduction
32
32
  });
33
33
  module.exports = __toCommonJS(client_exports);
34
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
34
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
35
35
  var import_useIntlayer = require('./useIntlayer.cjs');
36
36
  var import_useLocaleBase = require('./useLocaleBase.cjs');
37
37
  var import_useLocale = require('./useLocale.cjs');
@@ -40,8 +40,8 @@ var import_useLocaleCookie = require('./useLocaleCookie.cjs');
40
40
  var import_getBrowserLocale = require('./getBrowserLocale.cjs');
41
41
  // Annotate the CommonJS export names for ESM import in node:
42
42
  0 && (module.exports = {
43
- IntlayerClient,
44
- IntlayerClientProvider,
43
+ IntlayerClientContext,
44
+ IntlayerProvider,
45
45
  getBrowserLocale,
46
46
  localeCookie,
47
47
  setLocaleCookie,
@@ -1 +1 @@
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 { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAIO;AACP,yBAA4B;AAC5B,2BAA8B;AAC9B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;AACP,8BAAiC;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAKO;AACP,yBAA4B;AAC5B,2BAA8B;AAC9B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;AACP,8BAAiC;","names":[]}
@@ -1,4 +1,4 @@
1
- export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.js';
1
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderProps, useIntlayerContext } from './IntlayerProvider.js';
2
2
  export { useIntlayer } from './useIntlayer.js';
3
3
  export { useLocaleBase } from './useLocaleBase.js';
4
4
  export { useLocale } from './useLocale.js';
@@ -8,5 +8,6 @@ export { getBrowserLocale } from './getBrowserLocale.js';
8
8
  import 'react';
9
9
  import '@intlayer/config/client';
10
10
  import '../useIntlayerBase.js';
11
+ import '@intlayer/config';
11
12
  import 'intlayer';
12
13
  import '@intlayer/core';
@@ -1,4 +1,3 @@
1
- import * as _intlayer_config_client from '@intlayer/config/client';
2
1
  import * as intlayer from 'intlayer';
3
2
  import { LanguageContent } from '@intlayer/core';
4
3
 
@@ -8,7 +7,7 @@ import { LanguageContent } from '@intlayer/core';
8
7
  declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
9
8
  locale: intlayer.Locales;
10
9
  content: Content;
11
- t: <Content_1 = string>(languageContent: Partial<Record<_intlayer_config_client.LocalesValues, Content_1>>) => Content_1;
10
+ t: <Content_1 = string>(languageContent: Partial<Record<intlayer.LocalesValues, Content_1>>) => Content_1;
12
11
  };
13
12
 
14
13
  export { useContent };
@@ -24,9 +24,9 @@ __export(useIntlayer_exports, {
24
24
  module.exports = __toCommonJS(useIntlayer_exports);
25
25
  var import_react = require("react");
26
26
  var import_useIntlayerBase = require('../useIntlayerBase.cjs');
27
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
27
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
28
28
  const useIntlayer = (id, locale) => {
29
- const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
29
+ const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
30
  const localeTarget = locale ?? currentLocale;
31
31
  return (0, import_useIntlayerBase.useIntlayerBase)(id, localeTarget);
32
32
  };
@@ -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 { 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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,6BAIO;AACP,oCAAsC;AAO/B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,mDAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,wCAAgB,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 './IntlayerProvider';\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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,6BAIO;AACP,8BAAsC;AAO/B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,wCAAgB,IAAI,YAAY;AACzC;","names":[]}
@@ -1,6 +1,7 @@
1
1
  import { UseIntlayer } from '../useIntlayerBase.js';
2
- import '@intlayer/config/client';
2
+ import '@intlayer/config';
3
3
  import 'intlayer';
4
+ import 'react';
4
5
 
5
6
  /**
6
7
  * On the client side, Hook that picking one dictionary by its id and return the content
@@ -25,10 +25,10 @@ module.exports = __toCommonJS(useLocale_exports);
25
25
  var import_client = require("@intlayer/config/client");
26
26
  var import_core = require("@intlayer/core");
27
27
  var import_react = require("react");
28
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
28
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
29
29
  const useLocale = () => {
30
30
  const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
31
- const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
31
+ const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
32
32
  return {
33
33
  locale,
34
34
  // Current locale
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = () => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale } = useContext(IntlayerClientContext);\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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AACjC,kBAA2B;AAC3B,mBAA2B;AAC3B,oCAAsC;AAK/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,mDAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = () => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale } = useContext(IntlayerClientContext);\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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AACjC,kBAA2B;AAC3B,mBAA2B;AAC3B,8BAAsC;AAK/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,6CAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -25,10 +25,10 @@ module.exports = __toCommonJS(useLocaleBase_exports);
25
25
  var import_client = require("@intlayer/config/client");
26
26
  var import_core = require("@intlayer/core");
27
27
  var import_react = require("react");
28
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
28
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
29
29
  const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
30
30
  const useLocaleBase = () => {
31
- const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
31
+ const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
32
32
  return {
33
33
  locale,
34
34
  // Current locale
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AACjC,kBAA2B;AAC3B,mBAA2B;AAC3B,oCAAsC;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AAKd,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,mDAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AACjC,kBAA2B;AAC3B,mBAA2B;AAC3B,8BAAsC;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AAKd,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,6CAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -23,9 +23,9 @@ __export(useTraduction_exports, {
23
23
  module.exports = __toCommonJS(useTraduction_exports);
24
24
  var import_react = require("react");
25
25
  var import_getTranslation = require('../getTranslation.cjs');
26
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
26
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
27
27
  const useTraduction = (languageContent) => {
28
- const { locale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
28
+ const { locale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
29
29
  return (0, import_getTranslation.getTranslation)(languageContent, locale);
30
30
  };
31
31
  // Annotate the CommonJS export names for ESM import in node:
@@ -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 './IntlayerClientProvider';\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2B;AAC3B,4BAA+B;AAC/B,oCAAsC;AAuB/B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,QAAI,yBAAW,mDAAqB;AAEnD,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2B;AAC3B,4BAA+B;AAC/B,8BAAsC;AAuB/B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -22,15 +22,11 @@ __export(getEnumeration_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(getEnumeration_exports);
24
24
  var import_core = require("@intlayer/core");
25
- var import_contentRender = require('./ContentEditor/contentRender.cjs');
26
25
  const getEnumeration = (enumerationContent, quantity) => {
27
26
  const result = (0, import_core.getEnumerationContent)(
28
27
  enumerationContent,
29
28
  quantity
30
29
  );
31
- if (typeof result === "string") {
32
- return (0, import_contentRender.contentRender)(result);
33
- }
34
30
  return result;
35
31
  };
36
32
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AAC5D,2BAA8B;AA8BvB,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AA8BrD,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -23,16 +23,12 @@ __export(getTranslation_exports, {
23
23
  module.exports = __toCommonJS(getTranslation_exports);
24
24
  var import_client = require("@intlayer/config/client");
25
25
  var import_core = require("@intlayer/core");
26
- var import_contentRender = require('./ContentEditor/contentRender.cjs');
27
26
  const getTranslation = (languageContent, locale) => {
28
27
  const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
29
28
  const result = (0, import_core.getTranslationContent)(
30
29
  languageContent,
31
30
  locale ?? defaultLocale
32
31
  );
33
- if (typeof result === "string") {
34
- return (0, import_contentRender.contentRender)(result);
35
- }
36
32
  return result;
37
33
  };
38
34
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n *\n * Allow to pick a content based on a locale.\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 * ```ts\n * const content = getTranslation<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 getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAA4D;AAC5D,2BAA8B;AAuBvB,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAE7C,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\n\n/**\n *\n * Allow to pick a content based on a locale.\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 * ```ts\n * const content = getTranslation<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 getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAA4D;AAuBrD,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAE7C,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
@@ -18,11 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var src_exports = {};
20
20
  __export(src_exports, {
21
- IntlayerClient: () => import_client.IntlayerClient,
22
- IntlayerClientProvider: () => import_client.IntlayerClientProvider,
21
+ IntlayerClientContext: () => import_client.IntlayerClientContext,
22
+ IntlayerProvider: () => import_client.IntlayerProvider,
23
23
  getBrowserLocale: () => import_client.getBrowserLocale,
24
24
  getTranslation: () => import_getTranslation.getTranslation,
25
25
  localeCookie: () => import_client.localeCookie,
26
+ recursiveStringifyContent: () => import_useIntlayerBase.recursiveStringifyContent,
26
27
  setLocaleCookie: () => import_client.setLocaleCookie,
27
28
  useIntlayer: () => import_client.useIntlayer,
28
29
  useLocale: () => import_client.useLocale,
@@ -33,13 +34,15 @@ __export(src_exports, {
33
34
  module.exports = __toCommonJS(src_exports);
34
35
  var import_getTranslation = require('./getTranslation.cjs');
35
36
  var import_client = require('./client/index.cjs');
37
+ var import_useIntlayerBase = require('./useIntlayerBase.cjs');
36
38
  // Annotate the CommonJS export names for ESM import in node:
37
39
  0 && (module.exports = {
38
- IntlayerClient,
39
- IntlayerClientProvider,
40
+ IntlayerClientContext,
41
+ IntlayerProvider,
40
42
  getBrowserLocale,
41
43
  getTranslation,
42
44
  localeCookie,
45
+ recursiveStringifyContent,
43
46
  setLocaleCookie,
44
47
  useIntlayer,
45
48
  useLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n IntlayerClient,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n} from './client/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAYO;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n} from './client/index';\nexport { recursiveStringifyContent } from './useIntlayerBase';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAYO;AACP,6BAA0C;","names":[]}
@@ -1,13 +1,14 @@
1
1
  export { getTranslation } from './getTranslation.js';
2
- export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps } from './client/IntlayerClientProvider.js';
2
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderProps } from './client/IntlayerProvider.js';
3
3
  export { useIntlayer } from './client/useIntlayer.js';
4
4
  export { useLocaleBase } from './client/useLocaleBase.js';
5
5
  export { useLocale } from './client/useLocale.js';
6
6
  export { useTraduction } from './client/useTraduction.js';
7
7
  export { localeCookie, setLocaleCookie, useLocaleCookie } from './client/useLocaleCookie.js';
8
8
  export { getBrowserLocale } from './client/getBrowserLocale.js';
9
+ export { recursiveStringifyContent } from './useIntlayerBase.js';
9
10
  import '@intlayer/config/client';
10
11
  import '@intlayer/core';
11
12
  import 'react';
12
- import './useIntlayerBase.js';
13
+ import '@intlayer/config';
13
14
  import 'intlayer';
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
12
12
  return to;
13
13
  };
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var contentDictionary_d_exports = {};
16
- module.exports = __toCommonJS(contentDictionary_d_exports);
17
- //# sourceMappingURL=contentDictionary.d.cjs.map
15
+ var contentDictionary_exports = {};
16
+ module.exports = __toCommonJS(contentDictionary_exports);
17
+ //# sourceMappingURL=contentDictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/processDictionary/contentDictionary.ts"],"sourcesContent":["import type { KeyPath, Locales } from '@intlayer/core';\nimport type { ReactNode } from 'react';\n\nexport type TransformedContentValue =\n | string\n | ReactNode\n | {\n [key: string]: TransformedContentValue;\n }\n | undefined\n | ((quantity: number) => TransformedContentValue);\n\nexport type TransformedContentObject = {\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n locale: Locales;\n content: TransformedContentValue | TransformedContentValue[] | undefined;\n};\n\nexport type TransformedContent =\n | Record<\n string,\n | TransformedContentValue\n | TransformedContentValue[]\n | TransformedContentObject\n | undefined\n >\n | ReactNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { KeyPath, Locales } from '@intlayer/core';
2
+ import { ReactNode } from 'react';
3
+
4
+ type TransformedContentValue = string | ReactNode | {
5
+ [key: string]: TransformedContentValue;
6
+ } | undefined | ((quantity: number) => TransformedContentValue);
7
+ type TransformedContentObject = {
8
+ dictionaryId: string;
9
+ dictionaryPath: string;
10
+ keyPath: KeyPath[];
11
+ locale: Locales;
12
+ content: TransformedContentValue | TransformedContentValue[] | undefined;
13
+ };
14
+ type TransformedContent = Record<string, TransformedContentValue | TransformedContentValue[] | TransformedContentObject | undefined> | ReactNode;
15
+
16
+ export type { TransformedContent, TransformedContentObject, TransformedContentValue };