react-intlayer 3.0.3 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +5 -14
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/craco/intlayerCracoPlugin.cjs +1 -2
  4. package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -1
  5. package/dist/cjs/editor/ContentSelectorConnector.cjs +57 -0
  6. package/dist/cjs/editor/ContentSelectorConnector.cjs.map +1 -0
  7. package/dist/cjs/editor/ContentSelectorWrapper.cjs +33 -0
  8. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -0
  9. package/dist/cjs/editor/IntlayerEditorProvider.cjs +31 -0
  10. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -0
  11. package/dist/cjs/editor/index.cjs +27 -0
  12. package/dist/cjs/editor/index.cjs.map +1 -0
  13. package/dist/cjs/editor/renderContentEditor.cjs +54 -0
  14. package/dist/cjs/editor/renderContentEditor.cjs.map +1 -0
  15. package/dist/cjs/index.cjs +2 -0
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/useDictionaryBase.cjs +2 -2
  18. package/dist/cjs/useDictionaryBase.cjs.map +1 -1
  19. package/dist/cjs/{craco → utils}/removeUndefinedValueObject.cjs.map +1 -1
  20. package/dist/esm/client/IntlayerProvider.mjs +5 -14
  21. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  22. package/dist/esm/craco/intlayerCracoPlugin.mjs +1 -2
  23. package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -1
  24. package/dist/esm/editor/ContentSelectorConnector.mjs +37 -0
  25. package/dist/esm/editor/ContentSelectorConnector.mjs.map +1 -0
  26. package/dist/esm/editor/ContentSelectorWrapper.mjs +10 -0
  27. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -0
  28. package/dist/esm/editor/IntlayerEditorProvider.mjs +8 -0
  29. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -0
  30. package/dist/esm/editor/index.mjs +4 -0
  31. package/dist/esm/editor/index.mjs.map +1 -0
  32. package/dist/esm/editor/renderContentEditor.mjs +31 -0
  33. package/dist/esm/editor/renderContentEditor.mjs.map +1 -0
  34. package/dist/esm/index.mjs +2 -0
  35. package/dist/esm/index.mjs.map +1 -1
  36. package/dist/esm/useDictionaryBase.mjs +1 -1
  37. package/dist/esm/useDictionaryBase.mjs.map +1 -1
  38. package/dist/esm/{craco → utils}/removeUndefinedValueObject.mjs.map +1 -1
  39. package/dist/types/client/IntlayerProvider.d.ts +0 -1
  40. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  41. package/dist/types/craco/intlayerCracoPlugin.d.ts.map +1 -1
  42. package/dist/types/editor/ContentSelectorConnector.d.ts +14 -0
  43. package/dist/types/editor/ContentSelectorConnector.d.ts.map +1 -0
  44. package/dist/types/editor/ContentSelectorWrapper.d.ts +10 -0
  45. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -0
  46. package/dist/types/editor/IntlayerEditorProvider.d.ts +3 -0
  47. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -0
  48. package/dist/types/editor/index.d.ts +4 -0
  49. package/dist/types/editor/index.d.ts.map +1 -0
  50. package/dist/types/editor/renderContentEditor.d.ts +14 -0
  51. package/dist/types/editor/renderContentEditor.d.ts.map +1 -0
  52. package/dist/types/index.d.ts +1 -1
  53. package/dist/types/index.d.ts.map +1 -1
  54. package/dist/types/useDictionaryBase.d.ts.map +1 -1
  55. package/dist/types/{craco → utils}/removeUndefinedValueObject.d.ts.map +1 -1
  56. package/package.json +30 -22
  57. /package/dist/cjs/{craco → utils}/removeUndefinedValueObject.cjs +0 -0
  58. /package/dist/esm/{craco → utils}/removeUndefinedValueObject.mjs +0 -0
  59. /package/dist/types/{craco → utils}/removeUndefinedValueObject.d.ts +0 -0
@@ -26,9 +26,9 @@ __export(IntlayerProvider_exports, {
26
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
- var import_intlayer_editor = require("intlayer-editor");
30
29
  var import_react = require("react");
31
30
  var import_useLocaleCookie = require('./useLocaleCookie.cjs');
31
+ var import_IntlayerEditorProvider = require('../editor/IntlayerEditorProvider.cjs');
32
32
  const IntlayerClientContext = (0, import_react.createContext)({
33
33
  locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
34
34
  setLocale: () => null
@@ -37,10 +37,10 @@ const useIntlayerContext = () => (0, import_react.useContext)(IntlayerClientCont
37
37
  const IntlayerProvider = ({
38
38
  locale,
39
39
  children,
40
- setLocale: setLocaleProp,
41
- editorEnabled
40
+ setLocale: setLocaleProp
42
41
  }) => {
43
- const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
42
+ const { internationalization } = (0, import_client.getConfiguration)();
43
+ const { defaultLocale, locales: availableLocales } = internationalization;
44
44
  const [currentLocale, setCurrentLocale] = (0, import_react.useState)(
45
45
  locale ?? import_useLocaleCookie.localeCookie ?? defaultLocale
46
46
  );
@@ -61,16 +61,7 @@ const IntlayerProvider = ({
61
61
  () => ({ locale: currentLocale, setLocale }),
62
62
  [currentLocale, setLocale]
63
63
  );
64
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
- import_intlayer_editor.ContentEditionLayout,
66
- {
67
- locale: currentLocale,
68
- setLocale,
69
- localeList: availableLocales,
70
- editorEnabled,
71
- children
72
- }
73
- ) });
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_IntlayerEditorProvider.IntlayerEditorProvider, { children }) });
74
65
  };
75
66
  // Annotate the CommonJS export names for ESM import in node:
76
67
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\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 editorEnabled?: boolean;\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 editorEnabled,\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 editorEnabled={editorEnabled}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+EM;AA7EN,oBAA+C;AAC/C,6BAAqC;AACrC,mBAQO;AACP,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AAWjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,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,EAAG;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,MACZ;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
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 { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\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 { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = 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 <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EM;AA3EN,oBAA+C;AAC/C,mBAQO;AACP,6BAA8C;AAC9C,oCAAuC;AAUhC,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,qBAAqB,QAAI,gCAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,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,EAAG;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,sDAAC,wDAAwB,UAAS,GACpC;AAEJ;","names":[]}
@@ -37,7 +37,7 @@ var import_path = require("path");
37
37
  var import_config = require("@intlayer/config");
38
38
  var import_webpack = require("@intlayer/webpack");
39
39
  var import_webpack2 = __toESM(require("webpack"));
40
- var import_removeUndefinedValueObject = require('./removeUndefinedValueObject.cjs');
40
+ var import_removeUndefinedValueObject = require('../utils/removeUndefinedValueObject.cjs');
41
41
  const intlayerConfig = (0, import_config.getConfiguration)();
42
42
  const env = (0, import_config.formatEnvVariable)("react_app");
43
43
  const overrideWebpackConfig = ({
@@ -62,7 +62,6 @@ const overrideCracoConfig = ({
62
62
  const { mainDir, baseDir } = intlayerConfig.content;
63
63
  const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
64
64
  const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
65
- console.log("env", (0, import_removeUndefinedValueObject.removeUndefinedValueObject)(env));
66
65
  return {
67
66
  ...cracoConfig,
68
67
  webpack: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n console.log('env', removeUndefinedValueObject(env));\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAOxC,oBAAoD;AACpD,qBAAwD;AACxD,IAAAA,kBAA6D;AAC7D,wCAA2C;AAG3C,MAAM,qBAAiB,gCAAiB;AAGxC,MAAM,UAA8B,iCAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,UAAQ,IAAI,WAAO,8DAA2B,GAAG,CAAC;AAElD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,gBAAAC,QAAQ,sBAAkB,8DAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,eAAAC,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":["import_webpack","webpack","IntLayerWebpackPlugin"]}
1
+ {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAOxC,oBAAoD;AACpD,qBAAwD;AACxD,IAAAA,kBAA6D;AAC7D,wCAA2C;AAG3C,MAAM,qBAAiB,gCAAiB;AAGxC,MAAM,UAA8B,iCAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,gBAAAC,QAAQ,sBAAkB,8DAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,eAAAC,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":["import_webpack","webpack","IntLayerWebpackPlugin"]}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var ContentSelectorConnector_exports = {};
21
+ __export(ContentSelectorConnector_exports, {
22
+ ContentSelectorConnector: () => ContentSelectorConnector,
23
+ ContentSelectorContext: () => ContentSelectorContext,
24
+ ContentSelectorProvider: () => ContentSelectorProvider,
25
+ useContentSelectorContext: () => useContentSelectorContext
26
+ });
27
+ module.exports = __toCommonJS(ContentSelectorConnector_exports);
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ var import_react = require("react");
30
+ var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
31
+ const ContentSelectorContext = (0, import_react.createContext)({
32
+ state: { ContentSelectorWrapper: import_ContentSelectorWrapper.ContentSelectorWrapper },
33
+ setState: () => {
34
+ }
35
+ });
36
+ const useContentSelectorContext = () => (0, import_react.useContext)(ContentSelectorContext);
37
+ const ContentSelectorProvider = ({
38
+ children
39
+ }) => {
40
+ const [state, setState] = (0, import_react.useState)({
41
+ // Add your default state here
42
+ ContentSelectorWrapper: import_ContentSelectorWrapper.ContentSelectorWrapper
43
+ });
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorContext.Provider, { value: { state, setState }, children });
45
+ };
46
+ const ContentSelectorConnector = (props) => {
47
+ const { ContentSelectorWrapper: ContentSelectorWrapper2 } = useContentSelectorContext().state;
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorWrapper2, { ...props });
49
+ };
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ ContentSelectorConnector,
53
+ ContentSelectorContext,
54
+ ContentSelectorProvider,
55
+ useContentSelectorContext
56
+ });
57
+ //# sourceMappingURL=ContentSelectorConnector.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorConnector.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useState,\n} from 'react';\nimport {\n ContentSelectorWrapper,\n ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\ntype ContentSelectorContextValue = {\n state: {\n ContentSelectorWrapper: typeof ContentSelectorWrapper;\n };\n setState: (value: ContentSelectorContextValue['state']) => void;\n};\n\nexport const ContentSelectorContext =\n createContext<ContentSelectorContextValue>({\n state: { ContentSelectorWrapper },\n setState: () => {},\n });\n\nexport const useContentSelectorContext = () =>\n useContext(ContentSelectorContext);\n\nexport const ContentSelectorProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const [state, setState] = useState({\n // Add your default state here\n ContentSelectorWrapper,\n });\n\n return (\n <ContentSelectorContext.Provider value={{ state, setState }}>\n {children}\n </ContentSelectorContext.Provider>\n );\n};\n\nexport const ContentSelectorConnector: FC<ContentSelectorWrapperProps> = (\n props\n) => {\n const { ContentSelectorWrapper } = useContentSelectorContext().state;\n\n return <ContentSelectorWrapper {...props} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCI;AArCJ,mBAMO;AACP,oCAGO;AASA,MAAM,6BACX,4BAA2C;AAAA,EACzC,OAAO,EAAE,6EAAuB;AAAA,EAChC,UAAU,MAAM;AAAA,EAAC;AACnB,CAAC;AAEI,MAAM,4BAA4B,UACvC,yBAAW,sBAAsB;AAE5B,MAAM,0BAAiD,CAAC;AAAA,EAC7D;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS;AAAA;AAAA,IAEjC;AAAA,EACF,CAAC;AAED,SACE,4CAAC,uBAAuB,UAAvB,EAAgC,OAAO,EAAE,OAAO,SAAS,GACvD,UACH;AAEJ;AAEO,MAAM,2BAA4D,CACvE,UACG;AACH,QAAM,EAAE,wBAAAA,wBAAuB,IAAI,0BAA0B,EAAE;AAE/D,SAAO,4CAACA,yBAAA,EAAwB,GAAG,OAAO;AAC5C;","names":["ContentSelectorWrapper"]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var ContentSelectorWrapper_exports = {};
21
+ __export(ContentSelectorWrapper_exports, {
22
+ ContentSelectorWrapper: () => ContentSelectorWrapper
23
+ });
24
+ module.exports = __toCommonJS(ContentSelectorWrapper_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ const ContentSelectorWrapper = ({
27
+ children
28
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ ContentSelectorWrapper
32
+ });
33
+ //# sourceMappingURL=ContentSelectorWrapper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyPath } from '@intlayer/core';\nimport { type FC, type ReactNode } from 'react';\n\nexport type ContentSelectorWrapperProps = {\n children: ReactNode;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n}) => <>{children}</>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcM;AAFC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AACF,MAAM,2EAAG,UAAS;","names":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var IntlayerEditorProvider_exports = {};
20
+ __export(IntlayerEditorProvider_exports, {
21
+ IntlayerEditorProvider: () => IntlayerEditorProvider
22
+ });
23
+ module.exports = __toCommonJS(IntlayerEditorProvider_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_ContentSelectorConnector = require('./ContentSelectorConnector.cjs');
26
+ const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelectorConnector.ContentSelectorProvider, { children });
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ IntlayerEditorProvider
30
+ });
31
+ //# sourceMappingURL=IntlayerEditorProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\nimport { ContentSelectorProvider } from './ContentSelectorConnector';\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <ContentSelectorProvider>{children}</ContentSelectorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIE;AAHF,sCAAwC;AAEjC,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE,4CAAC,2DAAyB,UAAS;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var editor_exports = {};
17
+ module.exports = __toCommonJS(editor_exports);
18
+ __reExport(editor_exports, require('./ContentSelectorWrapper.cjs'), module.exports);
19
+ __reExport(editor_exports, require('./ContentSelectorConnector.cjs'), module.exports);
20
+ __reExport(editor_exports, require('./renderContentEditor.cjs'), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require('./ContentSelectorWrapper.cjs'),
24
+ ...require('./ContentSelectorConnector.cjs'),
25
+ ...require('./renderContentEditor.cjs')
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\nexport * from './ContentSelectorConnector';\nexport * from './renderContentEditor';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,qCAAd;AACA,2BAAc,uCADd;AAEA,2BAAc,kCAFd;","names":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var renderContentEditor_exports = {};
20
+ __export(renderContentEditor_exports, {
21
+ renderIntlayerEditor: () => renderIntlayerEditor
22
+ });
23
+ module.exports = __toCommonJS(renderContentEditor_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_ContentSelectorConnector = require('./ContentSelectorConnector.cjs');
27
+ const {
28
+ editor: { enabled }
29
+ } = (0, import_client.getConfiguration)();
30
+ const IntlayerEditorElement = ({
31
+ content,
32
+ isContentSelectable,
33
+ ...props
34
+ }) => {
35
+ if (enabled && isContentSelectable) {
36
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelectorConnector.ContentSelectorConnector, { ...props, children: content });
37
+ }
38
+ return content;
39
+ };
40
+ const renderIntlayerEditor = (data, isContentSelectable) => {
41
+ const Result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
+ IntlayerEditorElement,
43
+ {
44
+ ...data,
45
+ isContentSelectable
46
+ }
47
+ );
48
+ return { ...Result, value: data.content };
49
+ };
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ renderIntlayerEditor
53
+ });
54
+ //# sourceMappingURL=renderContentEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorConnector } from './ContentSelectorConnector';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n isContentSelectable: boolean;\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n isContentSelectable,\n ...props\n}) => {\n if (enabled && isContentSelectable) {\n return (\n <ContentSelectorConnector {...props}>{content}</ContentSelectorConnector>\n );\n }\n return content;\n};\n\nexport type RenderIntlayerEditorResult = ReactNode & { value: string };\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable: boolean\n): RenderIntlayerEditorResult => {\n const Result = (\n <IntlayerEditorElement\n {...data}\n isContentSelectable={isContentSelectable}\n />\n );\n\n return { ...Result, value: data.content };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBM;AAxBN,oBAAiC;AAGjC,sCAAyC;AAEzC,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAUrB,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAW,qBAAqB;AAClC,WACE,4CAAC,4DAA0B,GAAG,OAAQ,mBAAQ;AAAA,EAElD;AACA,SAAO;AACT;AAIO,MAAM,uBAAuB,CAClC,MACA,wBAC+B;AAC/B,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
@@ -27,6 +27,7 @@ __export(src_exports, {
27
27
  t: () => import_client.t,
28
28
  useDictionary: () => import_client.useDictionary,
29
29
  useIntlayer: () => import_client.useIntlayer,
30
+ useIntlayerContext: () => import_client.useIntlayerContext,
30
31
  useLocale: () => import_client.useLocale,
31
32
  useLocaleBase: () => import_client.useLocaleBase,
32
33
  useLocaleCookie: () => import_client.useLocaleCookie,
@@ -46,6 +47,7 @@ var import_client = require('./client/index.cjs');
46
47
  t,
47
48
  useDictionary,
48
49
  useIntlayer,
50
+ useIntlayerContext,
49
51
  useLocale,
50
52
  useLocaleBase,
51
53
  useLocaleCookie,
@@ -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 useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './useDictionaryBase';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAcO;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\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 { type IntlayerNode } from './useDictionaryBase';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAeO;","names":[]}
@@ -22,15 +22,15 @@ __export(useDictionaryBase_exports, {
22
22
  useDictionaryBase: () => useDictionaryBase
23
23
  });
24
24
  module.exports = __toCommonJS(useDictionaryBase_exports);
25
- var import_intlayer_editor = require("intlayer-editor");
26
25
  var import_react = require("react");
27
26
  var import_processDictionary = require('./processDictionary/index.cjs');
27
+ var import_renderContentEditor = require('./editor/renderContentEditor.cjs');
28
28
  const recursiveTransformContent = (value, isContentSelectable = false) => {
29
29
  if (typeof value === "function") {
30
30
  return (props) => recursiveTransformContent(value(props), isContentSelectable);
31
31
  } else if (typeof value === "object") {
32
32
  if (typeof value.dictionaryId !== "undefined") {
33
- return (0, import_intlayer_editor.renderIntlayerEditor)(value, isContentSelectable);
33
+ return (0, import_renderContentEditor.renderIntlayerEditor)(value, isContentSelectable);
34
34
  } else if (Array.isArray(value)) {
35
35
  return value.map(
36
36
  (el) => recursiveTransformContent(el, isContentSelectable)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useDictionaryBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { renderIntlayerEditor } from 'intlayer-editor';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\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 useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\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 isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,6BAAqC;AACrC,mBAA+C;AAC/C,+BAAkC;AAqC3B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,iBAAO,6CAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,eAAW,6BAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;AACH,QAAM,aAAS;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":["value"]}
1
+ {"version":3,"sources":["../../src/useDictionaryBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\nimport { renderIntlayerEditor } from './editor/renderContentEditor';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\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 useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\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 isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,mBAA+C;AAC/C,+BAAkC;AAClC,iCAAqC;AAqC9B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,iBAAO,iDAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,eAAW,6BAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;AACH,QAAM,aAAS;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":["value"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/craco/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
@@ -2,7 +2,6 @@
2
2
  import "../chunk-ZD7AOCMD.mjs";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { getConfiguration } from "@intlayer/config/client";
5
- import { ContentEditionLayout } from "intlayer-editor";
6
5
  import {
7
6
  createContext,
8
7
  useContext,
@@ -11,6 +10,7 @@ import {
11
10
  useCallback
12
11
  } from "react";
13
12
  import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
13
+ import { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider.mjs';
14
14
  const IntlayerClientContext = createContext({
15
15
  locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
16
16
  setLocale: () => null
@@ -19,10 +19,10 @@ const useIntlayerContext = () => useContext(IntlayerClientContext);
19
19
  const IntlayerProvider = ({
20
20
  locale,
21
21
  children,
22
- setLocale: setLocaleProp,
23
- editorEnabled
22
+ setLocale: setLocaleProp
24
23
  }) => {
25
- const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
24
+ const { internationalization } = getConfiguration();
25
+ const { defaultLocale, locales: availableLocales } = internationalization;
26
26
  const [currentLocale, setCurrentLocale] = useState(
27
27
  locale ?? localeCookie ?? defaultLocale
28
28
  );
@@ -43,16 +43,7 @@ const IntlayerProvider = ({
43
43
  () => ({ locale: currentLocale, setLocale }),
44
44
  [currentLocale, setLocale]
45
45
  );
46
- return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ jsx(
47
- ContentEditionLayout,
48
- {
49
- locale: currentLocale,
50
- setLocale,
51
- localeList: availableLocales,
52
- editorEnabled,
53
- children
54
- }
55
- ) });
46
+ return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ jsx(IntlayerEditorProvider, { children }) });
56
47
  };
57
48
  export {
58
49
  IntlayerClientContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\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 editorEnabled?: boolean;\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 editorEnabled,\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 editorEnabled={editorEnabled}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;AA+EM;AA7EN,SAAS,wBAAsC;AAC/C,SAAS,4BAA4B;AACrC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAWjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
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 { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\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 { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = 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 <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;AA6EM;AA3EN,SAAS,wBAAsC;AAC/C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,uBAAuB;AAC9C,SAAS,8BAA8B;AAUhC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAUjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC9B,8BAAC,0BAAwB,UAAS,GACpC;AAEJ;","names":[]}
@@ -3,7 +3,7 @@ import { resolve, relative, join } from "path";
3
3
  import { getConfiguration, formatEnvVariable } from "@intlayer/config";
4
4
  import { IntLayerPlugin as IntLayerWebpackPlugin } from "@intlayer/webpack";
5
5
  import webpack from "webpack";
6
- import { removeUndefinedValueObject } from './removeUndefinedValueObject.mjs';
6
+ import { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject.mjs';
7
7
  const intlayerConfig = getConfiguration();
8
8
  const env = formatEnvVariable("react_app");
9
9
  const overrideWebpackConfig = ({
@@ -28,7 +28,6 @@ const overrideCracoConfig = ({
28
28
  const { mainDir, baseDir } = intlayerConfig.content;
29
29
  const dictionariesPath = join(mainDir, "dictionaries.mjs");
30
30
  const relativeDictionariesPath = relative(baseDir, dictionariesPath);
31
- console.log("env", removeUndefinedValueObject(env));
32
31
  return {
33
32
  ...cracoConfig,
34
33
  webpack: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n console.log('env', removeUndefinedValueObject(env));\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAGA,SAAS,SAAS,UAAU,YAAY;AAOxC,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,kBAAkB,6BAA6B;AACxD,OAAO,aAAsD;AAC7D,SAAS,kCAAkC;AAG3C,MAAM,iBAAiB,iBAAiB;AAGxC,MAAM,MAA8B,kBAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,UAAQ,IAAI,OAAO,2BAA2B,GAAG,CAAC;AAElD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,QAAQ,kBAAkB,2BAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,sBAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAGA,SAAS,SAAS,UAAU,YAAY;AAOxC,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,kBAAkB,6BAA6B;AACxD,OAAO,aAAsD;AAC7D,SAAS,kCAAkC;AAG3C,MAAM,iBAAiB,iBAAiB;AAGxC,MAAM,MAA8B,kBAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,QAAQ,kBAAkB,2BAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,sBAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import "../chunk-ZD7AOCMD.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import {
5
+ createContext,
6
+ useContext,
7
+ useState
8
+ } from "react";
9
+ import {
10
+ ContentSelectorWrapper
11
+ } from './ContentSelectorWrapper.mjs';
12
+ const ContentSelectorContext = createContext({
13
+ state: { ContentSelectorWrapper },
14
+ setState: () => {
15
+ }
16
+ });
17
+ const useContentSelectorContext = () => useContext(ContentSelectorContext);
18
+ const ContentSelectorProvider = ({
19
+ children
20
+ }) => {
21
+ const [state, setState] = useState({
22
+ // Add your default state here
23
+ ContentSelectorWrapper
24
+ });
25
+ return /* @__PURE__ */ jsx(ContentSelectorContext.Provider, { value: { state, setState }, children });
26
+ };
27
+ const ContentSelectorConnector = (props) => {
28
+ const { ContentSelectorWrapper: ContentSelectorWrapper2 } = useContentSelectorContext().state;
29
+ return /* @__PURE__ */ jsx(ContentSelectorWrapper2, { ...props });
30
+ };
31
+ export {
32
+ ContentSelectorConnector,
33
+ ContentSelectorContext,
34
+ ContentSelectorProvider,
35
+ useContentSelectorContext
36
+ };
37
+ //# sourceMappingURL=ContentSelectorConnector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorConnector.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useState,\n} from 'react';\nimport {\n ContentSelectorWrapper,\n ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\ntype ContentSelectorContextValue = {\n state: {\n ContentSelectorWrapper: typeof ContentSelectorWrapper;\n };\n setState: (value: ContentSelectorContextValue['state']) => void;\n};\n\nexport const ContentSelectorContext =\n createContext<ContentSelectorContextValue>({\n state: { ContentSelectorWrapper },\n setState: () => {},\n });\n\nexport const useContentSelectorContext = () =>\n useContext(ContentSelectorContext);\n\nexport const ContentSelectorProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const [state, setState] = useState({\n // Add your default state here\n ContentSelectorWrapper,\n });\n\n return (\n <ContentSelectorContext.Provider value={{ state, setState }}>\n {children}\n </ContentSelectorContext.Provider>\n );\n};\n\nexport const ContentSelectorConnector: FC<ContentSelectorWrapperProps> = (\n props\n) => {\n const { ContentSelectorWrapper } = useContentSelectorContext().state;\n\n return <ContentSelectorWrapper {...props} />;\n};\n"],"mappings":";;AAuCI;AArCJ;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AASA,MAAM,yBACX,cAA2C;AAAA,EACzC,OAAO,EAAE,uBAAuB;AAAA,EAChC,UAAU,MAAM;AAAA,EAAC;AACnB,CAAC;AAEI,MAAM,4BAA4B,MACvC,WAAW,sBAAsB;AAE5B,MAAM,0BAAiD,CAAC;AAAA,EAC7D;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS;AAAA;AAAA,IAEjC;AAAA,EACF,CAAC;AAED,SACE,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,EAAE,OAAO,SAAS,GACvD,UACH;AAEJ;AAEO,MAAM,2BAA4D,CACvE,UACG;AACH,QAAM,EAAE,wBAAAA,wBAAuB,IAAI,0BAA0B,EAAE;AAE/D,SAAO,oBAACA,yBAAA,EAAwB,GAAG,OAAO;AAC5C;","names":["ContentSelectorWrapper"]}
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import "../chunk-ZD7AOCMD.mjs";
3
+ import { Fragment, jsx } from "react/jsx-runtime";
4
+ const ContentSelectorWrapper = ({
5
+ children
6
+ }) => /* @__PURE__ */ jsx(Fragment, { children });
7
+ export {
8
+ ContentSelectorWrapper
9
+ };
10
+ //# sourceMappingURL=ContentSelectorWrapper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyPath } from '@intlayer/core';\nimport { type FC, type ReactNode } from 'react';\n\nexport type ContentSelectorWrapperProps = {\n children: ReactNode;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n}) => <>{children}</>;\n"],"mappings":";;AAcM;AAFC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AACF,MAAM,gCAAG,UAAS;","names":[]}
@@ -0,0 +1,8 @@
1
+ import "../chunk-ZD7AOCMD.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { ContentSelectorProvider } from './ContentSelectorConnector.mjs';
4
+ const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ jsx(ContentSelectorProvider, { children });
5
+ export {
6
+ IntlayerEditorProvider
7
+ };
8
+ //# sourceMappingURL=IntlayerEditorProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\nimport { ContentSelectorProvider } from './ContentSelectorConnector';\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <ContentSelectorProvider>{children}</ContentSelectorProvider>\n);\n"],"mappings":";AAIE;AAHF,SAAS,+BAA+B;AAEjC,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE,oBAAC,2BAAyB,UAAS;","names":[]}
@@ -0,0 +1,4 @@
1
+ export * from './ContentSelectorWrapper.mjs';
2
+ export * from './ContentSelectorConnector.mjs';
3
+ export * from './renderContentEditor.mjs';
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\nexport * from './ContentSelectorConnector';\nexport * from './renderContentEditor';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,31 @@
1
+ import "../chunk-ZD7AOCMD.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { getConfiguration } from "@intlayer/config/client";
4
+ import { ContentSelectorConnector } from './ContentSelectorConnector.mjs';
5
+ const {
6
+ editor: { enabled }
7
+ } = getConfiguration();
8
+ const IntlayerEditorElement = ({
9
+ content,
10
+ isContentSelectable,
11
+ ...props
12
+ }) => {
13
+ if (enabled && isContentSelectable) {
14
+ return /* @__PURE__ */ jsx(ContentSelectorConnector, { ...props, children: content });
15
+ }
16
+ return content;
17
+ };
18
+ const renderIntlayerEditor = (data, isContentSelectable) => {
19
+ const Result = /* @__PURE__ */ jsx(
20
+ IntlayerEditorElement,
21
+ {
22
+ ...data,
23
+ isContentSelectable
24
+ }
25
+ );
26
+ return { ...Result, value: data.content };
27
+ };
28
+ export {
29
+ renderIntlayerEditor
30
+ };
31
+ //# sourceMappingURL=renderContentEditor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorConnector } from './ContentSelectorConnector';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryId: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n isContentSelectable: boolean;\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n isContentSelectable,\n ...props\n}) => {\n if (enabled && isContentSelectable) {\n return (\n <ContentSelectorConnector {...props}>{content}</ContentSelectorConnector>\n );\n }\n return content;\n};\n\nexport type RenderIntlayerEditorResult = ReactNode & { value: string };\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable: boolean\n): RenderIntlayerEditorResult => {\n const Result = (\n <IntlayerEditorElement\n {...data}\n isContentSelectable={isContentSelectable}\n />\n );\n\n return { ...Result, value: data.content };\n};\n"],"mappings":";AAwBM;AAxBN,SAAS,wBAAwB;AAGjC,SAAS,gCAAgC;AAEzC,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,IAAI,iBAAiB;AAUrB,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAW,qBAAqB;AAClC,WACE,oBAAC,4BAA0B,GAAG,OAAQ,mBAAQ;AAAA,EAElD;AACA,SAAO;AACT;AAIO,MAAM,uBAAuB,CAClC,MACA,wBAC+B;AAC/B,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
@@ -8,6 +8,7 @@ import {
8
8
  useLocale,
9
9
  useTraduction,
10
10
  useLocaleCookie,
11
+ useIntlayerContext,
11
12
  localeCookie,
12
13
  setLocaleCookie,
13
14
  getBrowserLocale,
@@ -24,6 +25,7 @@ export {
24
25
  t,
25
26
  useDictionary,
26
27
  useIntlayer,
28
+ useIntlayerContext,
27
29
  useLocale,
28
30
  useLocaleBase,
29
31
  useLocaleCookie,
@@ -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 useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './useDictionaryBase';\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,OACK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\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 { type IntlayerNode } from './useDictionaryBase';\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,OACK;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import "./chunk-ZD7AOCMD.mjs";
2
- import { renderIntlayerEditor } from "intlayer-editor";
3
2
  import { isValidElement } from "react";
4
3
  import { processDictionary } from './processDictionary/index.mjs';
4
+ import { renderIntlayerEditor } from './editor/renderContentEditor.mjs';
5
5
  const recursiveTransformContent = (value, isContentSelectable = false) => {
6
6
  if (typeof value === "function") {
7
7
  return (props) => recursiveTransformContent(value(props), isContentSelectable);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useDictionaryBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { renderIntlayerEditor } from 'intlayer-editor';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\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 useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\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 isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";AAOA,SAAS,4BAA4B;AACrC,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AAqC3B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,aAAO,qBAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,WAAW,eAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;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":["value"]}
1
+ {"version":3,"sources":["../../src/useDictionaryBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\nimport { renderIntlayerEditor } from './editor/renderContentEditor';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\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 useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\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 isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";AAOA,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AAqC9B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,aAAO,qBAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,WAAW,eAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;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":["value"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/craco/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
@@ -15,7 +15,6 @@ export declare const useIntlayerContext: () => IntlayerValue;
15
15
  export type IntlayerProviderProps = PropsWithChildren & {
16
16
  locale?: Locales;
17
17
  setLocale?: (locale: Locales) => void;
18
- editorEnabled?: boolean;
19
18
  };
20
19
  /**
21
20
  * Provider that store the current locale on the client side
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA+CtD,CAAC"}
1
+ {"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAIf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAuCtD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAUvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAyBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
1
+ {"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAUvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAuBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { ContentSelectorWrapper, ContentSelectorWrapperProps } from './ContentSelectorWrapper';
3
+ type ContentSelectorContextValue = {
4
+ state: {
5
+ ContentSelectorWrapper: typeof ContentSelectorWrapper;
6
+ };
7
+ setState: (value: ContentSelectorContextValue['state']) => void;
8
+ };
9
+ export declare const ContentSelectorContext: import("react").Context<ContentSelectorContextValue>;
10
+ export declare const useContentSelectorContext: () => ContentSelectorContextValue;
11
+ export declare const ContentSelectorProvider: FC<PropsWithChildren>;
12
+ export declare const ContentSelectorConnector: FC<ContentSelectorWrapperProps>;
13
+ export {};
14
+ //# sourceMappingURL=ContentSelectorConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelectorConnector.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorConnector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,EAAE,EACF,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC,KAAK,2BAA2B,GAAG;IACjC,KAAK,EAAE;QACL,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;KACvD,CAAC;IACF,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACjE,CAAC;AAEF,eAAO,MAAM,sBAAsB,sDAI/B,CAAC;AAEL,eAAO,MAAM,yBAAyB,mCACF,CAAC;AAErC,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,iBAAiB,CAazD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,2BAA2B,CAMpE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type KeyPath } from '@intlayer/core';
2
+ import { type FC, type ReactNode } from 'react';
3
+ export type ContentSelectorWrapperProps = {
4
+ children: ReactNode;
5
+ dictionaryId: string;
6
+ dictionaryPath: string;
7
+ keyPath: KeyPath[];
8
+ };
9
+ export declare const ContentSelectorWrapper: FC<ContentSelectorWrapperProps>;
10
+ //# sourceMappingURL=ContentSelectorWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAE9C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export declare const IntlayerEditorProvider: FC<PropsWithChildren>;
3
+ //# sourceMappingURL=IntlayerEditorProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG9C,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAExD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './ContentSelectorWrapper';
2
+ export * from './ContentSelectorConnector';
3
+ export * from './renderContentEditor';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { KeyPath } from '@intlayer/core';
2
+ import type { ReactNode } from 'react';
3
+ export type IntlayerEditorElementProps = {
4
+ content: string;
5
+ dictionaryId: string;
6
+ dictionaryPath: string;
7
+ keyPath: KeyPath[];
8
+ isContentSelectable: boolean;
9
+ };
10
+ export type RenderIntlayerEditorResult = ReactNode & {
11
+ value: string;
12
+ };
13
+ export declare const renderIntlayerEditor: (data: IntlayerEditorElementProps, isContentSelectable: boolean) => RenderIntlayerEditorResult;
14
+ //# sourceMappingURL=renderContentEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAM,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,oBAAoB,SACzB,0BAA0B,uBACX,OAAO,KAC3B,0BASF,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export { getTranslation } from './getTranslation';
2
- export { IntlayerProvider, type IntlayerProviderProps, IntlayerClientContext, useIntlayer, useDictionary, useLocale, useTraduction, useLocaleCookie, localeCookie, setLocaleCookie, getBrowserLocale, useLocaleBase, t, } from './client/index';
2
+ export { IntlayerProvider, type IntlayerProviderProps, IntlayerClientContext, useIntlayer, useDictionary, useLocale, useTraduction, useLocaleCookie, useIntlayerContext, localeCookie, setLocaleCookie, getBrowserLocale, useLocaleBase, t, } from './client/index';
3
3
  export { type IntlayerNode } from './useDictionaryBase';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryBase.d.ts","sourceRoot":"","sources":["../../src/useDictionaryBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EACV,kBAAkB,EAElB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS;IACvD,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE,CAAC;CACtC,GACG,CAAC,QAAQ,EAAE,MAAM,KAAK,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAC3E,CAAC,SAAS;IACN,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAChC,GACD,CAAC,SAAS,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GACrC,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GACnD,KAAK,GACP,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,MAAM,GACrE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAC5B,CAAC,SAAS;IACN,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B,GACD,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,CAAC,SAAS;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GACvD,SAAS,GACT;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAC9C,GACP,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,YAAY,CAAC,CAAC,CAAC,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,oCAET,MAyBF,CAAC;AAEF,KAAK,kBAAkB,CACrB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,IACf,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,SAAS,kBAAkB,EAAE,CAAC,SAAS,OAAO,EAC1E,UAAU,EAAE,CAAC,EACb,MAAM,CAAC,EAAE,CAAC,KACP,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAG9B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAoB/B,CAAC"}
1
+ {"version":3,"file":"useDictionaryBase.d.ts","sourceRoot":"","sources":["../../src/useDictionaryBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EACV,kBAAkB,EAElB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS;IACvD,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE,CAAC;CACtC,GACG,CAAC,QAAQ,EAAE,MAAM,KAAK,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAC3E,CAAC,SAAS;IACN,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAChC,GACD,CAAC,SAAS,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GACrC,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GACnD,KAAK,GACP,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,MAAM,GACrE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAC5B,CAAC,SAAS;IACN,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B,GACD,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,CAAC,SAAS;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GACvD,SAAS,GACT;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAC9C,GACP,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,YAAY,CAAC,CAAC,CAAC,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,oCAET,MAyBF,CAAC;AAEF,KAAK,kBAAkB,CACrB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,IACf,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,SAAS,kBAAkB,EAAE,CAAC,SAAS,OAAO,EAC1E,UAAU,EAAE,CAAC,EACb,MAAM,CAAC,EAAE,CAAC,KACP,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAG9B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAoB/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../../src/craco/removeUndefinedValueObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACrE,CAAC,KACL,CAYF,CAAC"}
1
+ {"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../../src/utils/removeUndefinedValueObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACrE,CAAC,KACL,CAYF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "3.0.3",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "description": "Internationalization layer for React applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
6
6
  "keywords": [
@@ -60,6 +60,11 @@
60
60
  "require": "./dist/cjs/vite/intlayerPlugin.cjs",
61
61
  "import": "./dist/esm/vite/intlayerPlugin.mjs"
62
62
  },
63
+ "./editor": {
64
+ "types": "./dist/types/editor/index.d.ts",
65
+ "require": "./dist/cjs/editor/index.cjs",
66
+ "import": "./dist/esm/editor/index.mjs"
67
+ },
63
68
  "./package.json": "./package.json"
64
69
  },
65
70
  "main": "dist/cjs/index.cjs",
@@ -81,42 +86,45 @@
81
86
  ],
82
87
  "dependencies": {
83
88
  "@craco/craco": "^7.1.0",
84
- "cross-spawn": "^7.0.3",
89
+ "cross-spawn": "^7.0.5",
85
90
  "js-cookie": "^3.0.5",
86
- "react-cookie": "^7.1.4",
87
- "vite": "^5.4.8",
88
- "webpack": "^5.92.1",
89
- "@intlayer/chokidar": "^3.0.3",
90
- "@intlayer/config": "^3.0.3",
91
- "@intlayer/webpack": "^3.0.3",
92
- "@intlayer/core": "^3.0.3",
93
- "intlayer": "^3.0.3",
94
- "intlayer-editor": "^3.0.3"
91
+ "react-cookie": "^7.2.2",
92
+ "vite": "^5.4.11",
93
+ "webpack": "^5.96.1",
94
+ "@intlayer/chokidar": "^3.2.0",
95
+ "@intlayer/core": "^3.2.0",
96
+ "@intlayer/webpack": "^3.2.0",
97
+ "@intlayer/config": "^3.2.0"
95
98
  },
96
99
  "devDependencies": {
97
100
  "@craco/types": "^7.1.0",
98
101
  "@types/cross-spawn": "^6.0.6",
99
102
  "@types/js-cookie": "^3.0.6",
100
- "@types/node": "^20.14.9",
101
- "@types/react": "^18.3.3",
102
- "concurrently": "^8.2.2",
103
- "eslint": "^9.11.1",
104
- "prettier": "3.3.3",
103
+ "@types/node": "^22.9.0",
104
+ "@types/react": "^18.3.12",
105
+ "concurrently": "^9.1.0",
106
+ "eslint": "^9.14.0",
107
+ "prettier": "^3.3.3",
105
108
  "react": "^18.3.1",
106
109
  "react-dom": "^18.3.1",
107
- "rimraf": "5.0.5",
110
+ "rimraf": "^6.0.1",
108
111
  "tsc-alias": "^1.8.10",
109
- "tsup": "^8.3.0",
110
- "typescript": "^5.5.2",
112
+ "tsup": "^8.3.5",
113
+ "typescript": "^5.6.3",
111
114
  "@utils/eslint-config": "^1.0.4",
112
115
  "@utils/ts-config-types": "^1.0.4",
113
116
  "@utils/tsup-config": "^1.0.4",
114
117
  "@utils/ts-config": "^1.0.4"
115
118
  },
116
119
  "peerDependencies": {
117
- "react": "^18.2.0",
118
- "react-dom": "^18.2.0",
119
- "@intlayer/dictionaries-entry": "^3.0.3"
120
+ "react": ">=16.0.0 <19.0.0",
121
+ "react-dom": ">=16.0.0 <19.0.0",
122
+ "@intlayer/chokidar": "^3.2.0",
123
+ "@intlayer/config": "^3.2.0",
124
+ "@intlayer/core": "^3.2.0",
125
+ "@intlayer/webpack": "^3.2.0",
126
+ "@intlayer/dictionaries-entry": "^3.2.0",
127
+ "intlayer": "^3.2.0"
120
128
  },
121
129
  "engines": {
122
130
  "node": ">=14.18"